首页完善
This commit is contained in:
parent
70a75f36c2
commit
f5504e6cd7
|
|
@ -1,8 +1,6 @@
|
|||
<template>
|
||||
<view class="content">
|
||||
<text class="text-box">
|
||||
  我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约
|
||||
</text>
|
||||
<view class="content" v-if="!isError">
|
||||
<text class="text-box">   {{ 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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
// })
|
||||
// }
|
||||
|
|
|
|||
Loading…
Reference in New Issue