complaintListDetail.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="mainbox">
  3. <view class="imgs">
  4. <image v-for="(img,i) in images" :key="i" :src="img" mode="aspectFill" @click="previewImage(i,images)"></image>
  5. </view>
  6. <viwe class="con">
  7. <view class="title">{{info.title}}</view>
  8. <view>{{info.content}}</view>
  9. <view style="margin-top: 24rpx;color:#999999">时间:{{info.createTime || '--'}}</view>
  10. </viwe>
  11. <viwe class="con">
  12. <view class="msg">
  13. <view v-for="(msg,i) in msgList" :key="i" style="margin-bottom: 24rpx;">
  14. <view class="lable">{{msg.sendType ==2?'商家回复:':msg.sendType ==3?'平台回复:':msg.sendType ==1?'我:':''}}</view>
  15. <view class="imgs" v-if="msg.images">
  16. <image v-for="(img,i) in msg.images.split(',')" :key="i" :src="img" mode="aspectFill" @click="previewImage(i,msg.images.split(','))"></image>
  17. </view>
  18. <view class="val">{{msg.content||''}}</view>
  19. <view class="val x-f" style="margin-top: 10rpx;font-size: 28rpx;color:#999999;">
  20. <text style="margin-right: 16rpx;">{{msg.createTime || '--'}}</text>
  21. <u-icon name="chat" color="#999" size="48rpx" v-if="msg.sendType ==2||msg.sendType ==3" @click="open"></u-icon>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- <view class="mymsg">
  26. <view class="val">问题问题问题问题问题问题问题问题问题问题</view>
  27. <view class="val x-f" style="margin-top: 10rpx;font-size: 28rpx;color:#999999;"><text style="margin-right: 16rpx;">2022-12-22 12:33</text></view>
  28. </view> -->
  29. </viwe>
  30. <u-popup :show="show" :closeable="true" @close="close">
  31. <view class="replybox">
  32. <view class="replybox-title">回复:</view>
  33. <view class="form-item">
  34. <u-upload v-if="fileList1.length>0" :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" width="60" height="60":maxCount="4"></u-upload>
  35. <u--textarea v-model="content" placeholder="输入回复内容" border="none" count
  36. maxlength='300'></u--textarea>
  37. </view>
  38. <view class="replybox-footer x-bc">
  39. <view class="uploadbox" :style="{visibility: fileList1.length>0 ? 'hidden':'visible'}">
  40. <u-upload :disabled="fileList1.length>0" :fileList="fileList1" uploadIcon="photo" uploadIconColor="#666" @afterRead="afterRead" @delete="deletePic" name="1" width="24" height="24":maxCount="4"></u-upload>
  41. </view>
  42. <view class="send" @click="send">发送</view>
  43. </view>
  44. </view>
  45. </u-popup>
  46. </view>
  47. </template>
  48. <script>
  49. import {storeComplaintDetail,storeComplaintMsg,storeComplaintMsgAdd} from "@/api/user.js"
  50. export default {
  51. data() {
  52. return {
  53. id:'',
  54. images:[],
  55. info: {},
  56. msgList: [],
  57. fileList1: [],
  58. show: false,
  59. content:'',
  60. replyImages: ""
  61. }
  62. },
  63. onLoad(option) {
  64. this.id = option.id
  65. this.getDetail()
  66. this.getMsg()
  67. },
  68. methods: {
  69. open() {
  70. this.content = ''
  71. this.fileList1 = []
  72. this.replyImages = ''
  73. this.show = true
  74. },
  75. close() {
  76. this.show = false
  77. },
  78. previewImage(index,images) {
  79. uni.previewImage({
  80. current: index,
  81. urls: images
  82. });
  83. },
  84. getDetail() {
  85. storeComplaintDetail(this.id).then(res=>{
  86. if(res.code == 200) {
  87. this.info = res.data || {}
  88. this.images = res.data&&res.data.images.split(',')
  89. } else {
  90. uni.showToast({
  91. title:res.msg,
  92. icon: "none"
  93. })
  94. }
  95. })
  96. },
  97. getMsg() {
  98. storeComplaintMsg({
  99. complaintId: this.id,
  100. pageNum: 1,
  101. pageSize: 100,
  102. }).then(res=>{
  103. if(res.code == 200) {
  104. this.msgList = res.rows
  105. } else {
  106. uni.showToast({
  107. title:res.msg,
  108. icon: "none"
  109. })
  110. }
  111. })
  112. },
  113. send() {
  114. if (this.fileList1.length > 0) {
  115. this.replyImages = this.fileList1.map(item=>item.url).join(',')
  116. }
  117. if(!this.content) {
  118. uni.showToast({
  119. title: '请输入回复内容',
  120. icon: "none"
  121. })
  122. return
  123. }
  124. const param = {
  125. complaintId: this.id,
  126. sendType: 1,
  127. content: this.content,
  128. images: this.replyImages
  129. }
  130. storeComplaintMsgAdd(param).then(res=>{
  131. if(res.code == 200) {
  132. this.getMsg()
  133. this.show = false
  134. } else {
  135. uni.showToast({
  136. title: res.msg,
  137. icon: "none"
  138. })
  139. }
  140. })
  141. },
  142. deletePic(event) {
  143. this[`fileList${event.name}`].splice(event.index, 1)
  144. },
  145. async afterRead(event) {
  146. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  147. let lists = [].concat(event.file)
  148. let fileListLen = this[`fileList${event.name}`].length
  149. lists.map((item) => {
  150. this[`fileList${event.name}`].push({
  151. ...item,
  152. status: 'uploading',
  153. message: '上传中'
  154. })
  155. })
  156. for (let i = 0; i < lists.length; i++) {
  157. const result = await this.uploadFilePromise(lists[i].url)
  158. let item = this[`fileList${event.name}`][fileListLen]
  159. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  160. status: 'success',
  161. message: '',
  162. url: result
  163. }))
  164. fileListLen++
  165. }
  166. },
  167. uploadFilePromise(url) {
  168. return new Promise((resolve, reject) => {
  169. let a = uni.uploadFile({
  170. url: uni.getStorageSync('requestPath') + '/app/common/uploadOSS',
  171. filePath: url,
  172. name: 'file',
  173. formData: {
  174. user: 'test'
  175. },
  176. success: (res) => {
  177. setTimeout(() => {
  178. console.log(JSON.parse(res.data).url)
  179. resolve(JSON.parse(res.data).url)
  180. }, 1000)
  181. }
  182. });
  183. })
  184. },
  185. }
  186. }
  187. </script>
  188. <style scoped lang="scss">
  189. .lable {
  190. margin-bottom: 16rpx;
  191. }
  192. .send{
  193. flex-shrink: 0;
  194. padding: 10rpx 24rpx;
  195. font-size: 28rpx;
  196. border-radius: 28rpx 28rpx 28rpx 28rpx;
  197. border: 2rpx solid #FF5C03;
  198. font-weight: 500;
  199. font-size: 24rpx;
  200. color: #FF5C03;
  201. }
  202. .replybox {
  203. padding: 0 24rpx 24rpx 24rpx;
  204. &-title {
  205. padding: 24rpx 0;
  206. }
  207. .form-item {
  208. background-color: #fff;
  209. border: 1rpx solid #ddd;
  210. border-radius: 10rpx;
  211. padding: 16rpx;
  212. }
  213. &-footer {
  214. margin-top: 24rpx;
  215. }
  216. .uploadbox {
  217. position: relative;
  218. }
  219. }
  220. .msg{
  221. margin-bottom: 20rpx;
  222. background-color: #f5f5f5;
  223. padding: 16rpx;
  224. border-radius: 16rpx 16rpx 16rpx 16rpx;
  225. }
  226. .val {
  227. color:#222;
  228. word-break: break-all;
  229. }
  230. .mainbox {
  231. padding: 24rpx;
  232. .imgs {
  233. display: flex;
  234. flex-wrap: wrap;
  235. image {
  236. height: 150rpx;
  237. width: 150rpx;
  238. margin: 0 20rpx 20rpx 0;
  239. }
  240. }
  241. .con{
  242. display: block;
  243. background: #FFFFFF;
  244. border-radius: 16rpx 16rpx 16rpx 16rpx;
  245. padding: 24rpx;
  246. overflow: hidden;
  247. font-size: 28rpx;
  248. margin-bottom: 24rpx;
  249. color: #666666;
  250. .title {
  251. font-size: 30rpx;
  252. font-weight: 500;
  253. color: #333;
  254. }
  255. }
  256. }
  257. </style>