首页完善
This commit is contained in:
parent
70a75f36c2
commit
f5504e6cd7
|
|
@ -1,8 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="content">
|
<view class="content" v-if="!isError">
|
||||||
<text class="text-box">
|
<text class="text-box">   {{ taskDescribe }} </text>
|
||||||
  我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约我用十年青春,赴你最后之约
|
|
||||||
</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>
|
||||||
|
|
|
||||||
|
|
@ -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 = {
|
||||||
if (res.code === 0) {
|
file: f.url,
|
||||||
uni.$u.toast('提交成功')
|
name: 'file',
|
||||||
isSuccess.value = true
|
uri: f.url,
|
||||||
opinionModel.value.options = ''
|
|
||||||
opinionModel.value.userPhone = ''
|
|
||||||
opinionModel.value.userName = ''
|
|
||||||
opinionModel.value.unit = ''
|
|
||||||
} else {
|
|
||||||
uni.$u.toast(res.msg + '提交失败')
|
|
||||||
}
|
}
|
||||||
|
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')
|
||||||
|
|
||||||
|
res = JSON.parse(res.data)
|
||||||
|
if (res.data === '添加成功') {
|
||||||
|
uni.$u.toast('添加成功')
|
||||||
|
isSuccess.value = true
|
||||||
|
} else {
|
||||||
|
uni.$u.toast('添加失败' + res.data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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>
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue