首页完善

This commit is contained in:
BianLzhaoMin 2025-03-31 19:00:13 +08:00
parent 70a75f36c2
commit f5504e6cd7
3 changed files with 98 additions and 76 deletions

View File

@ -1,8 +1,6 @@
<template> <template>
<view class="content"> <view class="content" v-if="!isError">
<text class="text-box"> <text class="text-box"> &emsp;&emsp;{{ taskDescribe }} </text>
&emsp;&emsp;我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约
</text>
<view> <view>
<up-button <up-button
@ -17,32 +15,39 @@
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
import { getTaskDetailsApi } from '@/services/options'
const isError = ref(false) const isError = ref(false)
const taskDescribe = ref('')
const pageHeight = ref(0) const origin = window.location.href
const calcPageHeight = () => { const taskId = ref('')
const systemInfo = uni.getSystemInfoSync()
console.log('systemInfo', systemInfo) if (origin.indexOf('=') > -1) {
const windowHeight = systemInfo.windowHeight // taskId.value = origin.split('=')[1]
const statusBarHeight = systemInfo.statusBarHeight || 0
const navBarHeight = 44 //
const totalNavHeight = statusBarHeight + navBarHeight
pageHeight.value = windowHeight - totalNavHeight
} }
// calcPageHeight() //
const getTaskDetailsData = async () => {
const { data: res } = await getTaskDetailsApi({
id: taskId.value,
})
console.log('res', res, res.code)
if (res.code == 200) {
isError.value = false
taskDescribe.value = res.data.taskDescribe
} else {
isError.value = true
uni.redirectTo({ url: `/pages/error/index?taskId=${taskId.value}` })
}
}
getTaskDetailsData()
// //
const onSubmitOptions = () => { const onSubmitOptions = () => {
uni.navigateTo({ url: '/pages/opinion/index' }) uni.navigateTo({ url: '/pages/opinion/index' })
} }
if (isError.value) {
uni.redirectTo({ url: '/pages/error/index' })
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -34,9 +34,9 @@
clearable clearable
/> />
</up-form-item> --> </up-form-item> -->
<up-form-item label="意见" prop="options" required> <up-form-item label="意见" prop="userOpinion" required>
<up-textarea <up-textarea
v-model="opinionModel.options" v-model="opinionModel.userOpinion"
placeholder="请输入内容" placeholder="请输入内容"
class="input-content" class="input-content"
:maxlength="500" :maxlength="500"
@ -53,7 +53,6 @@
name="1" name="1"
multiple multiple
:maxCount="5" :maxCount="5"
accept="image"
@delete="deletePic" @delete="deletePic"
:fileList="fileList" :fileList="fileList"
@afterRead="afterRead" @afterRead="afterRead"
@ -84,13 +83,6 @@
@tap="onContinueFill" @tap="onContinueFill"
style="width: 95%; margin: 30rpx auto" style="width: 95%; margin: 30rpx auto"
/> />
<!-- <up-button
text="退出"
:plain="true"
type="primary"
@tap="onExit"
style="width: 95%; margin: 0 auto"
/> -->
</view> </view>
</template> </template>
@ -106,6 +98,7 @@
<script setup> <script setup>
import { submitOptionsApi } from '@/services/options.js' import { submitOptionsApi } from '@/services/options.js'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue' import { ref } from 'vue'
// //
@ -113,7 +106,13 @@ const opinionModel = ref({
userName: '', userName: '',
userPhone: '', userPhone: '',
unit: '', unit: '',
options: '', userOpinion: '',
})
onLoad((option) => {
if (option.taskId) {
opinionModel.value.taskId = option.taskId
}
}) })
const fileList = ref([]) const fileList = ref([])
@ -152,7 +151,7 @@ const opinionRules = ref({
// message: '', // message: '',
// }, // },
// ], // ],
options: [ userOpinion: [
{ {
type: 'string', type: 'string',
required: true, required: true,
@ -181,19 +180,35 @@ const onSubmitOptions = () => {
.validate() .validate()
.then(async (valid) => { .then(async (valid) => {
if (valid) { if (valid) {
console.log('opinionModel.value', opinionModel.value) let files = []
const res = await submitOptionsApi(opinionModel.value) fileList.value.forEach((f) => {
let d = {
file: f.url,
name: 'file',
uri: f.url,
}
files.push(d)
})
uni.uploadFile({
url: '/manager/option/appUploadFile',
files: files,
name: 'file',
formData: {
param: JSON.stringify(opinionModel.value),
},
success: (res) => {
console.log(res, 'res')
if (res.code === 0) { res = JSON.parse(res.data)
uni.$u.toast('提交成功') if (res.data === '添加成功') {
isSuccess.value = true uni.$u.toast('添加成功')
opinionModel.value.options = '' isSuccess.value = true
opinionModel.value.userPhone = '' } else {
opinionModel.value.userName = '' uni.$u.toast('添加失败' + res.data)
opinionModel.value.unit = '' }
} else { },
uni.$u.toast(res.msg + '提交失败') fail: (err) => {},
} })
} }
}) })
.catch(() => { .catch(() => {
@ -224,41 +239,9 @@ const deletePic = (event) => {
const afterRead = async (event) => { const afterRead = async (event) => {
console.log('event', event) console.log('event', event)
let lists = [].concat(event.file) let lists = [].concat(event.file)
let fileListLen = fileList.value.length
lists.map((item) => { lists.map((item) => {
fileList.value.push({ fileList.value.push({
...item, ...item,
status: 'uploading',
message: '上传中',
})
})
for (let i = 0; i < lists.length; i++) {
const result = await uploadFilePromise(lists[i].url)
let item = fileList.value[fileListLen]
fileList.value.splice(fileListLen, 1, {
...item,
status: 'success',
message: '',
url: result,
})
fileListLen++
}
}
const uploadFilePromise = (url) => {
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: 'http://192.168.2.21:7001/upload',
filePath: url,
name: 'file',
formData: {
user: 'test',
},
success: (res) => {
setTimeout(() => {
resolve(res.data.data)
}, 1000)
},
}) })
}) })
} }
@ -303,4 +286,23 @@ const uploadFilePromise = (url) => {
color: #848181; color: #848181;
} }
} }
.upload-container {
display: flex;
align-items: center;
background-color: #fff;
width: 100%;
padding: 10rpx;
view {
margin-right: 8rpx;
width: 160rpx;
height: 160rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: #f4f5f7;
border-radius: 2rpx;
}
}
</style> </style>

View File

@ -1,10 +1,25 @@
import { http } from '@/utils/http' import { http } from '@/utils/http'
// 通过id获取是否过期以及公告
export const getTaskDetailsApi = (data) => {
return http({
method: 'POST',
url: '/manager/option/getTaskDetails',
data,
})
}
// 提交意见接口 // 提交意见接口
export const submitOptionsApi = (data) => { export const submitOptionsApi = (data) => {
return http({ return http({
method: 'POST', method: 'POST',
url: '/manager/option/addOption', url: '/manager/option/appUploadFile',
data, data,
}) })
} }
// export const submitOptionsApi = (data) => {
// return http({
// method: 'POST',
// url: '/manager/option/addOption',
// data,
// })
// }