首页完善

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

View File

@ -34,9 +34,9 @@
clearable
/>
</up-form-item> -->
<up-form-item label="意见" prop="options" required>
<up-form-item label="意见" prop="userOpinion" required>
<up-textarea
v-model="opinionModel.options"
v-model="opinionModel.userOpinion"
placeholder="请输入内容"
class="input-content"
:maxlength="500"
@ -53,7 +53,6 @@
name="1"
multiple
:maxCount="5"
accept="image"
@delete="deletePic"
:fileList="fileList"
@afterRead="afterRead"
@ -84,13 +83,6 @@
@tap="onContinueFill"
style="width: 95%; margin: 30rpx auto"
/>
<!-- <up-button
text="退出"
:plain="true"
type="primary"
@tap="onExit"
style="width: 95%; margin: 0 auto"
/> -->
</view>
</template>
@ -106,6 +98,7 @@
<script setup>
import { submitOptionsApi } from '@/services/options.js'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
//
@ -113,7 +106,13 @@ const opinionModel = ref({
userName: '',
userPhone: '',
unit: '',
options: '',
userOpinion: '',
})
onLoad((option) => {
if (option.taskId) {
opinionModel.value.taskId = option.taskId
}
})
const fileList = ref([])
@ -152,7 +151,7 @@ const opinionRules = ref({
// message: '',
// },
// ],
options: [
userOpinion: [
{
type: 'string',
required: true,
@ -181,19 +180,35 @@ const onSubmitOptions = () => {
.validate()
.then(async (valid) => {
if (valid) {
console.log('opinionModel.value', opinionModel.value)
const res = await submitOptionsApi(opinionModel.value)
let files = []
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) {
uni.$u.toast('提交成功')
isSuccess.value = true
opinionModel.value.options = ''
opinionModel.value.userPhone = ''
opinionModel.value.userName = ''
opinionModel.value.unit = ''
} else {
uni.$u.toast(res.msg + '提交失败')
}
res = JSON.parse(res.data)
if (res.data === '添加成功') {
uni.$u.toast('添加成功')
isSuccess.value = true
} else {
uni.$u.toast('添加失败' + res.data)
}
},
fail: (err) => {},
})
}
})
.catch(() => {
@ -224,41 +239,9 @@ const deletePic = (event) => {
const afterRead = async (event) => {
console.log('event', event)
let lists = [].concat(event.file)
let fileListLen = fileList.value.length
lists.map((item) => {
fileList.value.push({
...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;
}
}
.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>

View File

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