complaint.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <view class="complaint-page">
  3. <template v-if="showComplaintList">
  4. <!-- 处理状态展示 -->
  5. <view class="status-block"
  6. v-if="complaintInfo.disposeLogList && complaintInfo.disposeLogList.length > 0 && complaintInfo.disposeLogList[0].userType == 1">
  7. <view class="status-title">书嗨处理</view>
  8. <view class="time">--</view>
  9. <view class="status-info">
  10. <view class="info-row">
  11. <text class="label">处理状态:</text>
  12. <text class="value status-text">{{ complaintStatusText }}</text>
  13. </view>
  14. <view class="info-row">
  15. <text class="label">平台回复:</text>
  16. <text class="value">{{ complaintInfo.description || "暂无" }}</text>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- 处理记录时间轴 -->
  21. <view class="complaint-records">
  22. <!-- 我的投诉 -->
  23. <view class="complaint-item" v-for="(item, index) in complaintInfo.disposeLogList" :key="index">
  24. <view class="complaint-header">
  25. <view class="header-main">
  26. <text class="title">{{ item.userType == 1 ? "我的投诉" : "客服回复" }}</text>
  27. <text class="time">{{ item.createTime }}</text>
  28. </view>
  29. </view>
  30. <view class="complaint-content">
  31. <view class="info-row" v-if="item.reason">
  32. <text class="label">投诉原因:</text>
  33. <text class="value">{{ item.reason }}</text>
  34. </view>
  35. <view class="info-row" v-if="item.contactNumber">
  36. <text class="label">联系方式:</text>
  37. <text class="value">{{ item.contactNumber }}</text>
  38. </view>
  39. <view class="info-row">
  40. <text class="label">投诉说明:</text>
  41. <text class="value">{{ item.description }}</text>
  42. </view>
  43. <view class="info-row image-list" v-if="item.imgList && item.imgList.length">
  44. <text class="label">上传凭证:</text>
  45. <view class="images">
  46. <image v-for="(img, imgIndex) in item.imgList" :key="imgIndex" :src="img"
  47. mode="aspectFill" @click="previewImage(item.imgList, imgIndex)">
  48. </image>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="bottom-fixed-con"
  55. v-if="complaintInfo.complaintsStatus == 2 && complaintInfo.disposeLogList && complaintInfo.disposeLogList.length > 0 && complaintInfo.disposeLogList[0].userType == 2">
  56. <u-button type="primary" @click="continueComplaint">继续投诉</u-button>
  57. </view>
  58. </template>
  59. <!-- 新投诉表单,仅在status为1时显示 -->
  60. <template v-else>
  61. <!-- 表单区域 -->
  62. <view class="form-block">
  63. <!-- 投诉原因 -->
  64. <view class="form-item flex-a">
  65. <view class="common-text-2 required">投诉原因</view>
  66. <view class="input-wrapper flex-1" @click="showReasonPicker">
  67. <text class="placeholder" v-if="!complaintReason">请选择投诉原因</text>
  68. <text v-else>{{ complaintReason }}</text>
  69. <u-icon name="arrow-right" color="#333" size="32" top="3rpx"></u-icon>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 相关订单 -->
  74. <view class="form-block order-block"
  75. v-if="complaintInfo.orderDetailList && complaintInfo.orderDetailList.length > 0">
  76. <view class="common-text-2 mb-20">相关订单</view>
  77. <view class="flex mb-30" v-for="(item, index) in complaintInfo.orderDetailList"
  78. :key="item.detailOrderId">
  79. <image :src="item.cover" mode="aspectFill"
  80. style="width: 120rpx; height: 120rpx; border-radius: 8rpx; flex-shrink: 0;"></image>
  81. <view class="flex-1 ml-20"
  82. style="display: flex; flex-direction: column; justify-content: space-between; min-height: 120rpx;">
  83. <view style="display: flex; justify-content: space-between;">
  84. <view class="u-line-2"
  85. style="font-size: 28rpx; color: #333; line-height: 40rpx; flex: 1; margin-right: 20rpx;">
  86. {{ item.bookName }}
  87. </view>
  88. <view style="font-size: 28rpx; color: #333;">¥{{ item.price }}</view>
  89. </view>
  90. <view style="font-size: 24rpx; color: #999; margin-top: 8rpx;" v-if="item.conditionType">
  91. 品相:{{ item.conditionType | conditionText }}
  92. </view>
  93. <view style="display: flex; justify-content: flex-end; margin-top: 10rpx;">
  94. <u-number-box v-model="item.num" disabled :input-width="60"
  95. :input-height="50"></u-number-box>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <!-- 上传凭证 -->
  101. <view class="common-text-2 required mb-20 mt-20">上传凭证(最多3张)</view>
  102. <view class="form-block" style="padding: 20rpx">
  103. <common-image-upload v-model="uploadSuccessList" :maxCount="3" :uploadUrl="uploadUrl"
  104. tip="上传“有效截图”可以让问题优先被发现哦!"></common-image-upload>
  105. </view>
  106. <!-- 投诉说明 -->
  107. <view class="common-text-2 required mb-20 mt-20">投诉说明</view>
  108. <view class="form-block" style="padding: 20rpx">
  109. <u-input v-model="description" type="textarea" placeholder="描述具体情况,有助于客服更快处理" :height="200"
  110. :border="false" maxlength="300"></u-input>
  111. </view>
  112. <view class="form-block mt-20">
  113. <!-- 联系方式 -->
  114. <view class="form-item flex-a" style="padding: 14rpx 0">
  115. <view class="common-text-2 required">联系电话</view>
  116. <u-input class="flex-1" input-align="right" placeholder-style="color:#999;font-size:28rpx;"
  117. v-model="phone" placeholder="请输入联系方式" :border="false" type="number" maxlength="11"></u-input>
  118. </view>
  119. </view>
  120. <!-- 底部按钮 -->
  121. <view class="bottom-fixed-con">
  122. <u-button type="primary" :custom-style="submitBtnStyle" @click="submitComplaint">提交</u-button>
  123. </view>
  124. <!-- 投诉原因选择器 -->
  125. <u-picker v-model="showPicker" mode="selector" :range="reasonList" @confirm="confirmReason"
  126. @cancel="showPicker = false"></u-picker>
  127. </template>
  128. </view>
  129. </template>
  130. <script>
  131. import CommonImageUpload from "@/components/image-upload.vue";
  132. // api前缀
  133. export default {
  134. components: {
  135. CommonImageUpload
  136. },
  137. data() {
  138. return {
  139. showComplaintList: false,
  140. complaintReason: "",
  141. phone: "",
  142. description: "",
  143. showPicker: false,
  144. reasonList: [],
  145. orderId: "",
  146. complaintInfo: {
  147. status: 1,
  148. platformReply: "",
  149. orderDetailList: [],
  150. disposeLogList: [],
  151. },
  152. uploadSuccessList: [],
  153. submitBtnStyle: {
  154. backgroundColor: '#38C148',
  155. color: '#fff',
  156. height: '88rpx',
  157. fontSize: '32rpx',
  158. borderRadius: '44rpx'
  159. }
  160. };
  161. },
  162. computed: {
  163. complaintStatusText() {
  164. const status = this.complaintInfo.complaintsStatus;
  165. const statusMap = {
  166. 0: "未投诉过",
  167. 1: "待处理",
  168. 2: "处理中",
  169. 3: "已完结",
  170. };
  171. return statusMap[status] || "未知状态";
  172. },
  173. uploadUrl() {
  174. return `/api/token/shop/order/complaintUpload/${this.orderId}`;
  175. },
  176. },
  177. onLoad(ops) {
  178. if (ops.orderId) {
  179. this.orderId = ops.orderId;
  180. this.getComplaintInfo();
  181. }
  182. this.getComplaintsOptions();
  183. },
  184. methods: {
  185. continueComplaint() {
  186. this.showComplaintList = false;
  187. },
  188. // 获取投诉信息
  189. getComplaintInfo() {
  190. // 修改为 shop/order 接口
  191. uni.$u.http.get(`/token/shop/order/getComplaintsInfo?orderId=${this.orderId}&type=1`).then((res) => {
  192. if (res.code === 200) {
  193. this.complaintInfo = res.data;
  194. this.showComplaintList = res.data.complaintsStatus != 0;
  195. }
  196. });
  197. },
  198. //根据code获取字典 /token/common/getDictOptions
  199. getDict(code) {
  200. return uni.$u.http.get("/token/common/getDictOptions?type=" + code);
  201. },
  202. //获取投诉选项 complaints_options
  203. getComplaintsOptions() {
  204. this.getDict("shop_order_complaints_options").then((res) => {
  205. if (res.code === 200) {
  206. this.reasonList = res.data.map((item) => item.dictLabel);
  207. }
  208. });
  209. },
  210. showReasonPicker() {
  211. this.showPicker = true;
  212. },
  213. confirmReason(e) {
  214. this.complaintReason = this.reasonList[e[0]];
  215. this.showPicker = false;
  216. },
  217. submitComplaint() {
  218. if (!this.complaintReason) {
  219. return uni.$u.toast("请选择投诉原因");
  220. }
  221. if (!this.description) {
  222. return uni.$u.toast("请输入投诉说明");
  223. }
  224. if (!this.phone) {
  225. return uni.$u.toast("请输入联系方式");
  226. }
  227. // 准备投诉数据
  228. const complaintData = {
  229. orderId: this.orderId,
  230. reason: this.complaintReason,
  231. description: this.description,
  232. contactNumber: this.phone,
  233. fileUrls: this.uploadSuccessList || [],
  234. };
  235. // 提交投诉 - 修改为 shop/order 接口
  236. uni.$u.http.post("/token/shop/order/addComplaints", complaintData).then((res) => {
  237. if (res.code === 200) {
  238. uni.$u.toast("投诉上报已上报给管理员");
  239. // 返回订单页
  240. setTimeout(() => {
  241. uni.navigateBack({
  242. delta: 1,
  243. });
  244. }, 1500);
  245. } else {
  246. uni.$u.toast(res.msg || "提交失败");
  247. }
  248. });
  249. },
  250. // 图片预览
  251. previewImage(urls, current) {
  252. uni.previewImage({
  253. urls: urls,
  254. current: current,
  255. });
  256. },
  257. },
  258. };
  259. </script>
  260. <style lang="scss" scoped>
  261. .complaint-page {
  262. min-height: 100vh;
  263. background: #f8f8f8;
  264. padding: 20rpx;
  265. padding-bottom: 120rpx;
  266. .status-block {
  267. background: #ffffff;
  268. border-radius: 12rpx;
  269. padding: 30rpx;
  270. margin-bottom: 20rpx;
  271. .status-title {
  272. font-size: 32rpx;
  273. font-weight: 600;
  274. color: #222;
  275. }
  276. .status-info {
  277. .info-row {
  278. display: flex;
  279. font-size: 28rpx;
  280. line-height: 48rpx;
  281. .label {
  282. color: #333;
  283. min-width: 140rpx;
  284. }
  285. .value {
  286. color: #333;
  287. flex: 1;
  288. }
  289. .status-text {
  290. color: #ff5b5b;
  291. }
  292. }
  293. }
  294. }
  295. .complaint-records {
  296. .complaint-item {
  297. background: #ffffff;
  298. border-radius: 12rpx;
  299. padding: 30rpx;
  300. margin-bottom: 20rpx;
  301. .complaint-header {
  302. margin-bottom: 24rpx;
  303. .header-main {
  304. display: flex;
  305. flex-direction: column;
  306. gap: 8rpx;
  307. .title {
  308. font-size: 32rpx;
  309. font-weight: 600;
  310. color: #222222;
  311. }
  312. .time {
  313. font-size: 26rpx;
  314. color: #999;
  315. }
  316. }
  317. }
  318. .complaint-content {
  319. .info-row {
  320. display: flex;
  321. margin-bottom: 16rpx;
  322. font-size: 28rpx;
  323. line-height: 1.5;
  324. .label {
  325. color: #333;
  326. white-space: nowrap;
  327. }
  328. .value {
  329. color: #333;
  330. flex: 1;
  331. }
  332. }
  333. .image-list {
  334. .label {
  335. display: block;
  336. font-size: 28rpx;
  337. color: #333;
  338. margin-bottom: 16rpx;
  339. }
  340. .images {
  341. display: flex;
  342. flex-wrap: wrap;
  343. gap: 20rpx;
  344. image {
  345. width: 140rpx;
  346. height: 140rpx;
  347. border-radius: 8rpx;
  348. }
  349. }
  350. }
  351. }
  352. }
  353. }
  354. .form-block {
  355. background: #ffffff;
  356. border-radius: 12rpx;
  357. padding: 0 30rpx;
  358. margin-bottom: 20rpx;
  359. }
  360. .order-block {
  361. padding: 30rpx;
  362. .order-item {
  363. margin-top: 20rpx;
  364. .goods-img {
  365. width: 120rpx;
  366. height: 120rpx;
  367. border-radius: 8rpx;
  368. margin-right: 20rpx;
  369. background-color: #f5f5f5;
  370. }
  371. .goods-info {
  372. display: flex;
  373. flex-direction: column;
  374. justify-content: space-between;
  375. .goods-name {
  376. font-size: 28rpx;
  377. color: #333;
  378. }
  379. .goods-price {
  380. font-size: 28rpx;
  381. color: #333;
  382. font-weight: bold;
  383. }
  384. }
  385. .goods-num {
  386. font-size: 26rpx;
  387. color: #999;
  388. align-self: flex-end;
  389. }
  390. }
  391. }
  392. .required::before {
  393. content: "*";
  394. color: #ff5b5b;
  395. margin-right: 4rpx;
  396. }
  397. .form-item {
  398. padding: 30rpx 0;
  399. .input-wrapper {
  400. display: flex;
  401. justify-content: flex-end;
  402. align-items: center;
  403. font-size: 28rpx;
  404. color: #333;
  405. .placeholder {
  406. color: #999;
  407. }
  408. }
  409. }
  410. .common-text-2 {
  411. font-size: 28rpx;
  412. color: #333;
  413. font-weight: bold;
  414. }
  415. .mb-20 {
  416. margin-bottom: 20rpx;
  417. }
  418. .mt-20 {
  419. margin-top: 20rpx;
  420. }
  421. .text-right {
  422. text-align: right;
  423. }
  424. .bottom-fixed-con {
  425. position: fixed;
  426. bottom: 0;
  427. left: 0;
  428. width: 100%;
  429. background: #fff;
  430. padding: 20rpx 30rpx;
  431. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  432. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  433. z-index: 100;
  434. }
  435. }
  436. .upload-image {
  437. ::v-deep .u-list-item {
  438. background: #ffffff !important;
  439. border: 2rpx dashed #ddd;
  440. }
  441. }
  442. </style>