blob: 261e0a15be298cce2e5c657a8b959eadb81247cc [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view class="leaveMsg">
3 <view class="leaveMsg-con">
4 <u-input v-model="title" placeholder="请填写留言标题(14字符之内)" maxlength="14" />
5 <u-input v-model="value" type="textarea" :border="false" height="300" :auto-height="true" placeholder="请填写您的留言内容(140字符之内)"
6 maxlength="140" />
7 <u-upload :action="action" ref="uUpload" :max-size="2 * 1024 * 1024" max-count="4" @on-change="get" @on-remove="remove"
8 :header="header"></u-upload>
9 </view>
10 <u-button @click="submit" :custom-style="leaveMsgnBtn">提交留言</u-button>
11 </view>
12</template>
13
14<script>
guangchao.xu1bc4ccc2021-01-19 17:09:26 +080015 const app = getApp()
guangchao.xu070005a2020-12-07 09:56:40 +080016 export default {
17 data() {
18 return {
19 title: "",
20 value: "",
21 action: "",
22 header: {
23 Authorization: ""
24 },
25 leaveMsgnBtn: {
26 backgroundColor: ' #2FA8E1',
27 padding: '50rpx 0',
28 color: '#FFFFFF',
29 width: ' 600rpx',
30 fontSize: '30rpx',
31 border: '1px solid #2FA8E1',
32 marginTop: '50rpx'
33 },
34 list: []
35 }
36 },
37 methods: {
38 get(res, index, lists) {
39 let that = this
40 let obj = {
41 minpicid: JSON.parse(res.data).minpicid,
42 picid: JSON.parse(res.data).picid
43 }
44 that.list.push(obj)
45 },
46 submit() {
47 let that = this
48 let {
49 title,
50 value,
51 list
52 } = that
53 if (title == "") {
54 uni.showToast({
55 icon: "none",
56 title: "请填写留言标题",
57 duration: 1500
58 })
59 return false
60 }
61 if (value == "") {
62 uni.showToast({
63 icon: "none",
64 title: "请填写留言内容",
65 duration: 1500
66 })
67 return false
68 }
guangchao.xu1bc4ccc2021-01-19 17:09:26 +080069 let version = app.globalData.version
guangchao.xu070005a2020-12-07 09:56:40 +080070 let params = {
guangchao.xu1bc4ccc2021-01-19 17:09:26 +080071 title,
guangchao.xu070005a2020-12-07 09:56:40 +080072 content: value,
guangchao.xu1bc4ccc2021-01-19 17:09:26 +080073 pictures: list,
74 version
guangchao.xu070005a2020-12-07 09:56:40 +080075 }
76 that.$u.post("/v1/feedback/release", params).then(res => {
77 uni.showToast({
78 title: "留言成功,我们将尽快给您回复",
guangchao.xu1bc4ccc2021-01-19 17:09:26 +080079 icon: "none",
80 duration: 1500,
guangchao.xu070005a2020-12-07 09:56:40 +080081 complete: (res) => {
82 setTimeout(() => {
83 uni.navigateBack({
guangchao.xu1bc4ccc2021-01-19 17:09:26 +080084 delta: 1
guangchao.xu070005a2020-12-07 09:56:40 +080085 })
86 }, 1500)
87 }
88 })
89 })
90 },
91 remove(index, lists) {
92 let that = this
93 that.list.splice(index, 1)
94 }
95 },
96 onLoad() {
97 let that = this
98 let token = uni.getStorageSync("token")
99 that.action = that.$u.http.config.baseUrl + "/v1/uploadpic"
100 that.header.Authorization = "Bearer " + token
101 }
102 }
103</script>
104
105<style lang="scss" scoped>
106 .leaveMsg {
107 width: 100vw;
108 height: 100vh;
109 background-color: #FFFFFF;
110
111 &-btn {
112 background-color: #2FA8E1;
113 font-family: "PingFang-SC-Medium";
114 color: #FFFFFF;
115 border-radius: 50rpx;
116 padding: 20rpx 30rpx;
117 font-size: 30rpx;
118 }
119
120 &-con {
121 padding: 10rpx 30rpx;
122 }
123 }
124</style>