bonus-Certificate-app/pages/mine/feedback/index.vue

304 lines
7.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template><page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
<Navbar2 title="问题反馈"/>
<view class="rating-page">
<view class="border-box">
<view style="font-size: 32rpx;margin-bottom: 10px;color: #64686E;font-size: 14px;">在系统使用中是否遇到以下问题<span style="color: red;">*</span></view>
<view class="tag-box">
<view class="tag-view" @click="type=1" :class="type==1?'active tag-view':'tag-view'">后台问题</view>
<view class="tag-view" @click="type=2" :class="type==2?'active tag-view':'tag-view'">APP问题</view>
</view>
</view>
<view style="margin-bottom: 10px;color: #64686E;font-size: 14px;">问题/建议描述<span style="color: red;">*</span></view>
<!-- 评价输入 -->
<view class="comment-box">
<view>
<u--textarea
v-model="detail" maxlength="100"
placeholder="请详细描述在系统使用中遇到的问题或改进建议"
height="120" style="font-size: 24rpx;background: transparent;"
></u--textarea>
</view>
<view style="font-size: 14px;margin-bottom: 10px;margin-top: 20rpx;color: #64686E;">上传照片最多5张</view>
<!-- 图片上传 -->
<view class="upload-box">
<u-upload
:fileList="fileList"
@afterRead="afterRead"
@delete="deletePic"
:maxCount="5"
multiple
>
<view class="upload-btn">
<u-icon name="camera" size="44" color="#666666"></u-icon>
<text class="upload-text">添加图片</text>
</view>
</u-upload>
</view>
<view style="color: #E60044;margin: 10px auto;font-size: 12px;">上传问题截图,出力时效会更快</view>
</view>
<view class="contact-box">
<text class="contact-title">是否每次出现同样问题<span style="color: red;">*</span></text>
<view class="tag-box">
<view class="tag-view" @click="rate=1" :class="rate==1?'active tag-view':'tag-view'">每次必出现</view>
<view class="tag-view" @click="rate=2" :class="rate==2?'active tag-view':'tag-view'">偶尔一次</view>
<view class="tag-view" @click="rate=3" :class="rate==3?'active tag-view':'tag-view'">只有一次</view>
</view>
</view>
<view class="contact-box">
<text class="contact-title">联系方式<span style="color: red;">*</span></text>
<u--input
v-model="contactInfo"
placeholder="填写联系方式"
border="bottom" maxlength="30"
></u--input>
</view>
<view style="color: #64686E;margin: 10px auto;font-size: 12px;">我们会更快的联系您解决问题</view>
<!-- 提交按钮 -->
<view class="submit-btn">
<u-button
shape="squrd"
@click="submitFeedback"
style="margin-bottom: 10px;font-size: 28rpx;"
:customStyle="{
width: '100%',
height: '80rpx',
background: '#1F72EA',
color: '#ffffff',
border: 'none'
}"
>提交</u-button>
</view>
</view>
</template>
<script>
import { postFeedBackApi } from "@/api/mine/index.js"
import { pathToBase64, base64ToPath } from 'image-tools';
import { uploadBase64 } from "@/api/upload"
export default {
data() {
return {
fontValue:uni.getStorageSync('fontSize') || 8,
type:1,
rate:1,
detail: '',
fileList: [],
contactInfo: '',
}
},
onLoad() {
},
methods: {
//提交按钮
async submitFeedback() {
console.log(this.fileList)
if(this.detail==""){
uni.$u.toast('请认真填写建议')
return
}
if(this.contactInfo==""){
uni.$u.toast('请填写联系方式')
return
}
let arr = []
this.fileList.forEach(item=>{
arr.push(item.url)
})
let param = {
"fileUrls": arr,
"type": this.type,
"rate": this.rate,
"detail": this.detail,
"contacts": this.contactInfo,
}
console.log(param)
const res = await postFeedBackApi(param)
if(res.code==200){
uni.showToast({
title: '提交成功',
icon: 'none'
});
setTimeout(()=>{
uni.navigateBack()
},800)
}
},
// 新增图片
async afterRead(event) {
// console.log(event)
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file);
let fileListLen = this[`fileList${event.name}`].length;
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: "uploading",
message: "上传中",
});
});
console.log(lists)
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url);
console.log(result)
let item = this[`fileList${event.name}`][fileListLen];
this[`fileList${event.name}`].splice(
fileListLen,
1,
Object.assign(item, {
status: "success",
message: "",
url: result.url,
})
);
fileListLen++;
}
},
//上传接口
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
this.imgToBase64(url).then(base64 => {
let param = {
"base64File":base64
}
uploadBase64(param).then(res => {
if(res.code==200){
resolve(res.data)
}
})
})
});
},
imgToBase64(data) {
return new Promise((resolve, reject) => {
pathToBase64(data).then(base64 => {
resolve(base64)
}).catch(error => {
console.error(error)
reject(error)
})
})
},
deletePic(event) {
this.fileList.splice(event.index, 1);
},
}
}
</script>
<style lang="scss" scoped>
/deep/.u-action-sheet__item-wrap {
overflow: auto;
max-height: 50vh;
}
.rating-page {
height: 94vh;
overflow-y: auto;
background-color: #ffffff;
padding: 40rpx;
padding-bottom: 100rpx;
.border-box{
background-color: #ffffff;
// padding: 16rpx;
border-radius: 8px;
margin-bottom: 20rpx;
}
.contact-box {
margin-top: 40rpx;
background-color: #ffffff;
padding: 20rpx 0rpx;
border-radius: 8px;
.contact-title {
font-size: 28rpx;
color: #64686E;
margin-bottom: 20rpx;
}
}
.detail-rating {
margin-top: 40rpx;
.rating-item {
display: flex;
align-items: center;
margin-bottom: 30rpx;
.item-label {
width: 200rpx;
font-size: 28rpx;
color: #333333;
}
.hearts-row {
display: flex;
gap: 0rpx;
}
}
}
.comment-box {
margin-top: 20rpx;
height: auto;
background: #fff;
padding-bottom: 10px;
}
.submit-btn {
padding: 20rpx 30rpx;
margin-top: 20px;
}
}
.upload-box {
margin-top: 30rpx;
margin-left: 10px;
display: flex;
.upload-btn {
width: 160rpx;
height: 160rpx;
// background-color: #f7f8fa;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 1px dashed #000;
border-radius: 8rpx;
.upload-text {
font-size: 24rpx;
color: #666666;
margin-top: 10rpx;
}
}
}
::v-deep .u-textarea {
background-color: #f7f8fa;
border-radius: 8rpx;
padding: 20rpx;
}
.tag-box{
width: 100%;
height: 3vh;
margin: 20rpx auto;
display: flex;
align-items: self-end;
background: #FFF;
}
.tag-view{
width: auto;
height: auto;
color: #2A2B2F;
background: #FFF;
font-size: 24rpx;
margin-right: 40rpx;
padding: 10rpx 20rpx;
border-radius: 2px 2px 2px 2px;
border: 1px solid #D1D3D7;
}
.active{
color: #FFF;
background: #1F72EA;
}
</style>