complaint.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <view class="complaint-page">
  3. <template v-if="complaintInfo.complaintsStatus == 1">
  4. <!-- 处理状态展示 -->
  5. <view class="status-block" v-if="complaintInfo.disposeLogList && complaintInfo.disposeLogList.length">
  6. <view class="status-title">书嗨处理</view>
  7. <view class="time">--</view>
  8. <view class="status-info">
  9. <view class="info-row">
  10. <text class="label">处理状态:</text>
  11. <text class="value status-text">{{ complaintStatusText }}</text>
  12. </view>
  13. <view class="info-row">
  14. <text class="label">平台回复:</text>
  15. <text class="value">{{ complaintInfo.description || '暂无' }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 处理记录时间轴 -->
  20. <view class="complaint-records">
  21. <!-- 我的投诉 -->
  22. <view class="complaint-item" v-for="(item, index) in complaintInfo.disposeLogList" :key="index">
  23. <view class="complaint-header">
  24. <view class="header-main">
  25. <text class="title">{{ item.userType == 1 ? '我的投诉' : '客服回复' }}</text>
  26. <text class="time">{{ item.createTime }}</text>
  27. </view>
  28. </view>
  29. <view class="complaint-content">
  30. <view class="info-row" v-if="item.reason">
  31. <text class="label">投诉原因:</text>
  32. <text class="value">{{ item.reason }}</text>
  33. </view>
  34. <view class="info-row" v-if="item.contactNumber">
  35. <text class="label">联系方式:</text>
  36. <text class="value">{{ item.contactNumber }}</text>
  37. </view>
  38. <view class="info-row">
  39. <text class="label">投诉说明:</text>
  40. <text class="value">{{ item.description }}</text>
  41. </view>
  42. <view class="info-row image-list" v-if="item.imgList && item.imgList.length">
  43. <text class="label">上传凭证:</text>
  44. <view class="images">
  45. <image v-for="(img, imgIndex) in item.imgList" :key="imgIndex" :src="img"
  46. mode="aspectFill" @click="previewImage(item.imgList, imgIndex)">
  47. </image>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <!-- 新投诉表单,仅在status为1时显示 -->
  55. <template v-else>
  56. <!-- 表单区域 -->
  57. <view class="form-block">
  58. <!-- 投诉原因 -->
  59. <view class="form-item flex-a">
  60. <view class="common-text-2 required">投诉原因</view>
  61. <view class="input-wrapper flex-1" @click="showReasonPicker">
  62. <text class="placeholder" v-if="!complaintReason">请选择投诉原因</text>
  63. <text v-else>{{ complaintReason }}</text>
  64. <u-icon name="arrow-right" color="#333" size="32" top="3rpx"></u-icon>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="form-block">
  69. <!-- 联系方式 -->
  70. <view class="form-item flex-a" style="padding:14rpx 0">
  71. <view class="common-text-2 required">联系方式</view>
  72. <u-input class="flex-1" input-align="right" placeholder-style="color:#999;font-size:28rpx;"
  73. v-model="phone" placeholder="请输入联系方式" :border="false" type="number" maxlength="11"></u-input>
  74. </view>
  75. </view>
  76. <view class="common-text-2 required mb-20">投诉说明</view>
  77. <view class="form-block" style="padding: 20rpx;">
  78. <!-- 投诉说明 -->
  79. <u-input v-model="description" type="textarea" placeholder="请描述投诉情况,有助于客服更快处理" :height="200"
  80. :border="false"></u-input>
  81. </view>
  82. <!-- 图片上传 -->
  83. <view class="common-text-2 required mb-20">上传凭证(最多3张)</view>
  84. <u-upload class="upload-image" :fileList="fileList" @on-choose-complete="afterRead" @delete="deletePic"
  85. :maxCount="3" :auto-upload="false" :previewFullImage="true" uploadText="点击上传"
  86. @on-uploaded="onUploaded"></u-upload>
  87. <!-- 底部按钮 -->
  88. <view class="bottom-fixed-con">
  89. <u-button type="primary" @click="submitComplaint">提交</u-button>
  90. </view>
  91. <!-- 投诉原因选择器 -->
  92. <u-picker v-model="showPicker" mode="selector" :range="reasonList" @confirm="confirmReason"
  93. @cancel="showPicker = false"></u-picker>
  94. </template>
  95. </view>
  96. </template>
  97. <script>
  98. import ENV_CONFIG from '@/.env.js'
  99. // api前缀
  100. const env = ENV_CONFIG[process.env.ENV_TYPE || 'dev'];
  101. export default {
  102. data() {
  103. return {
  104. complaintReason: '',
  105. phone: '',
  106. description: '',
  107. fileList: [],
  108. showPicker: false,
  109. reasonList: [],
  110. orderId: '',
  111. complaintInfo: {
  112. status: 1,
  113. platformReply: '',
  114. disposeLogList: []
  115. }
  116. }
  117. },
  118. computed: {
  119. complaintStatusText() {
  120. const status = this.complaintInfo.complaintsStatus;
  121. const statusMap = {
  122. "0": '未投诉过',
  123. "1": '待处理',
  124. "2": '处理中',
  125. "3": '已完结'
  126. };
  127. return statusMap[status] || '未知状态';
  128. }
  129. },
  130. onLoad(ops) {
  131. if (ops.orderId) {
  132. this.orderId = ops.orderId
  133. this.getComplaintInfo()
  134. }
  135. this.getComplaintsOptions()
  136. },
  137. methods: {
  138. // 获取投诉信息
  139. getComplaintInfo() {
  140. uni.$u.http.get(`/token/order/getComplaintsInfo?orderId=${this.orderId}&type=1`)
  141. .then(res => {
  142. if (res.code === 200) {
  143. this.complaintInfo = res.data
  144. }
  145. })
  146. },
  147. //根据code获取字典 /token/common/getDictOptions
  148. getDict(code) {
  149. return uni.$u.http.get('/token/common/getDictOptions?type=' + code)
  150. },
  151. //获取投诉选项 complaints_options
  152. getComplaintsOptions() {
  153. this.getDict('complaints_options').then(res => {
  154. if (res.code === 200) {
  155. this.reasonList = res.data.map(item => item.dictLabel)
  156. }
  157. })
  158. },
  159. showReasonPicker() {
  160. this.showPicker = true
  161. },
  162. confirmReason(e) {
  163. this.complaintReason = this.reasonList[e[0]]
  164. this.showPicker = false
  165. },
  166. onUploaded(lists, name) {
  167. console.log(lists, name, 'xx111x')
  168. },
  169. afterRead(lists) {
  170. // 先检查token是否存在
  171. const token = uni.getStorageSync('token');
  172. const uploadTasks = lists.map(item => {
  173. return new Promise((resolve, reject) => {
  174. console.log(item, env.apiUrl + `/api/token/order/complaintUpload/${this.orderId}`, 'xx111x')
  175. uni.uploadFile({
  176. url: env.apiUrl + `/api/token/order/complaintUpload/${this.orderId}`,
  177. filePath: item.url,
  178. name: 'file',
  179. header: {
  180. Authorization: 'Bearer ' + token
  181. },
  182. success: (res) => {
  183. const result = JSON.parse(res.data);
  184. if (result.code === 200 && result.data) {
  185. resolve(result.data);
  186. } else {
  187. uni.$u.toast(result.msg || '上传失败');
  188. reject(new Error(result.msg || '上传失败'));
  189. }
  190. },
  191. fail: (err) => {
  192. uni.$u.toast('上传失败');
  193. reject(err);
  194. }
  195. });
  196. });
  197. });
  198. Promise.all(uploadTasks).then(results => {
  199. this.uploadSuccessList = results.flat();
  200. this.fileList = lists;
  201. console.log(this.fileList, 'xx111x', results)
  202. }).catch(err => {
  203. console.error('Upload failed:', err);
  204. });
  205. },
  206. deletePic(event) {
  207. this.fileList.splice(event.index, 1)
  208. },
  209. submitComplaint() {
  210. if (!this.complaintReason) {
  211. return uni.$u.toast('请选择投诉原因')
  212. }
  213. if (!this.phone) {
  214. return uni.$u.toast('请输入联系方式')
  215. }
  216. if (!this.description) {
  217. return uni.$u.toast('请输入投诉说明')
  218. }
  219. // 准备投诉数据
  220. const complaintData = {
  221. orderId: this.orderId,
  222. reason: this.complaintReason,
  223. description: this.description,
  224. contactNumber: this.phone,
  225. fileUrls: this.uploadSuccessList
  226. }
  227. // 提交投诉
  228. uni.$u.http.post('/token/order/addComplaints', complaintData)
  229. .then(res => {
  230. if (res.code === 200) {
  231. uni.$u.toast('投诉上报已上报给管理员')
  232. // 返回订单页
  233. setTimeout(() => {
  234. uni.navigateBack({
  235. delta: 1
  236. })
  237. }, 1500)
  238. } else {
  239. uni.$u.toast(res.msg || '提交失败')
  240. }
  241. })
  242. },
  243. // 图片预览
  244. previewImage(urls, current) {
  245. uni.previewImage({
  246. urls: urls,
  247. current: current
  248. });
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss">
  254. .complaint-page {
  255. min-height: 100vh;
  256. background: #F8F8F8;
  257. padding: 20rpx;
  258. padding-bottom: 120rpx;
  259. .status-block {
  260. background: #FFFFFF;
  261. border-radius: 12rpx;
  262. padding: 30rpx;
  263. margin-bottom: 20rpx;
  264. .status-title {
  265. font-size: 32rpx;
  266. font-weight: 600;
  267. color: #222;
  268. }
  269. .divider {
  270. height: 2rpx;
  271. background: #EEEEEE;
  272. margin: 20rpx 0;
  273. }
  274. .status-info {
  275. .info-row {
  276. display: flex;
  277. font-size: 28rpx;
  278. line-height: 48rpx;
  279. .label {
  280. color: #333;
  281. min-width: 140rpx;
  282. }
  283. .value {
  284. color: #333;
  285. flex: 1;
  286. }
  287. .status-text {
  288. color: #FF5B5B;
  289. }
  290. }
  291. }
  292. }
  293. .complaint-records {
  294. .complaint-item {
  295. background: #FFFFFF;
  296. border-radius: 12rpx;
  297. padding: 30rpx;
  298. margin-bottom: 20rpx;
  299. .complaint-header {
  300. margin-bottom: 24rpx;
  301. .header-main {
  302. display: flex;
  303. flex-direction: column;
  304. gap: 8rpx;
  305. .title {
  306. font-size: 32rpx;
  307. font-weight: 600;
  308. color: #222222;
  309. }
  310. .time {
  311. font-size: 26rpx;
  312. color: #999;
  313. }
  314. }
  315. }
  316. .complaint-content {
  317. .info-row {
  318. display: flex;
  319. margin-bottom: 16rpx;
  320. font-size: 28rpx;
  321. line-height: 1.5;
  322. .label {
  323. color: #333;
  324. white-space: nowrap;
  325. }
  326. .value {
  327. color: #333;
  328. flex: 1;
  329. }
  330. }
  331. .image-list {
  332. .label {
  333. display: block;
  334. font-size: 28rpx;
  335. color: #333;
  336. margin-bottom: 16rpx;
  337. }
  338. .images {
  339. display: flex;
  340. flex-wrap: wrap;
  341. gap: 20rpx;
  342. image {
  343. width: 140rpx;
  344. height: 140rpx;
  345. border-radius: 8rpx;
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. .form-block {
  353. background: #FFFFFF;
  354. border-radius: 12rpx;
  355. padding: 0 30rpx;
  356. margin-bottom: 20rpx;
  357. }
  358. .required::before {
  359. content: '*';
  360. color: #FF5B5B;
  361. margin-right: 4rpx;
  362. }
  363. .form-item {
  364. padding: 30rpx 0;
  365. .input-wrapper {
  366. display: flex;
  367. justify-content: flex-end;
  368. align-items: center;
  369. font-size: 28rpx;
  370. color: #333;
  371. .placeholder {
  372. color: #999;
  373. }
  374. }
  375. }
  376. }
  377. .upload-image {
  378. .u-list-item {
  379. background: #ffffff !important;
  380. }
  381. }
  382. </style>