complaint.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <view class="container">
  3. <view class="form-item top_item" @click="navTo">
  4. <text>我的咨询投诉</text>
  5. <u-icon name="arrow-right" color="#333" size="20"></u-icon>
  6. </view>
  7. <u-form labelPosition="top" labelWidth='0' :model="formdata" :rules="rules" ref="uForm" errorType="toast">
  8. <u-form-item label=" " prop="complaintType">
  9. <view class="form-item">
  10. <view class="form-item-title">投诉方式</view>
  11. <view class="tagbox">
  12. <view :class="formdata.complaintType == 1?'tagitem active':'tagitem'"
  13. @click="formdata.complaintType = 1">咨询</view>
  14. <view :class="formdata.complaintType == 2?'tagitem active':'tagitem'"
  15. @click="formdata.complaintType = 2">投诉/举报</view>
  16. </view>
  17. </view>
  18. </u-form-item>
  19. <u-form-item label=" " prop="type">
  20. <view class="form-item">
  21. <view class="form-item-title">投诉类型</view>
  22. <view class="tagbox">
  23. <view :class="formdata.type == 1?'tagitem active':'tagitem'" @click="formdata.type = 1">店铺
  24. </view>
  25. <view :class="formdata.type == 2?'tagitem active':'tagitem'" @click="formdata.type = 2">商品
  26. </view>
  27. <view :class="formdata.type == 0?'tagitem active':'tagitem'" @click="formdata.type = 0">其他
  28. </view>
  29. </view>
  30. </view>
  31. </u-form-item>
  32. <u-form-item label=" " prop="title" v-if="formdata.type == 1">
  33. <view class="form-item">
  34. <view class="form-item-title">选择店铺</view>
  35. <view class="storename" @click="openStore">{{storeId? storeName : "选择店铺"}}</view>
  36. </view>
  37. </u-form-item>
  38. <u-form-item label=" " prop="title">
  39. <view class="form-item">
  40. <view class="form-item-title">标题</view>
  41. <u--input v-model="formdata.title" placeholder="请输入标题" maxlength='100'></u--input>
  42. </view>
  43. </u-form-item>
  44. <u-form-item label=" " prop="content">
  45. <view class="form-item">
  46. <view class="form-item-title">内容</view>
  47. <u--textarea v-model="formdata.content" placeholder="请详细描述您遇到的问题,我们会认真处理您的问题" count
  48. maxlength='200'></u--textarea>
  49. </view>
  50. </u-form-item>
  51. <u-form-item label=" " prop="images">
  52. <view class="form-item">
  53. <view class="form-item-title">上传凭证</view>
  54. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1"
  55. :maxCount="4"></u-upload>
  56. </view>
  57. </u-form-item>
  58. </u-form>
  59. <view class="btn-box">
  60. <view class="sub-btn" @click="submit()">提交</view>
  61. </view>
  62. <u-popup :show="show" :closeable="true" @close="close">
  63. <view class="storePop">
  64. <view class="storePop-title">选择店铺</view>
  65. <scroll-view class="scroll-list" scroll-y="true" @scrolltolower="lower" >
  66. <view class="storebox" v-for="(item,index) in storeList" :key="index">
  67. <image class="logo" :src="item.store.logoUrl" mode="aspectFill"></image>
  68. <view class="storebox-r">
  69. <view class="x-bc" style="flex: 1;min-height: 104rpx;">
  70. <view class="storename ellipsis">{{item.store.storeName || ''}}</view>
  71. <view class="storebox-btn" @click="handleClick(item)">选择</u-icon></view>
  72. </view>
  73. </view>
  74. </view>
  75. </scroll-view>
  76. </view>
  77. </u-popup>
  78. </view>
  79. </template>
  80. <script>
  81. import {recommendList} from "@/api/index.js"
  82. import {storeComplaint} from "@/api/user.js"
  83. export default {
  84. data() {
  85. return {
  86. show: false,
  87. total: 0,
  88. pageNum: 1,
  89. storeId: '',
  90. storeName: "",
  91. isLastPage: false,
  92. storeList: [],
  93. fileList1: [],
  94. formdata: {
  95. title: '',
  96. type: 0, //0默认1店铺2商品
  97. content: '',
  98. images: '',
  99. complaintType: '',
  100. },
  101. rules: {
  102. complaintType: [{
  103. required: true,
  104. message: '请选择投诉方式'
  105. }],
  106. title: [{
  107. required: true,
  108. message: '请输入标题'
  109. }],
  110. content: [{
  111. required: true,
  112. message: '请输入内容'
  113. }],
  114. images: [{
  115. required: true,
  116. message: '请上传凭证'
  117. }]
  118. }
  119. }
  120. },
  121. methods: {
  122. openStore() {
  123. this.storeId = ''
  124. this.storeName = ''
  125. this.show = true
  126. this.pageNum = 1
  127. this.getList()
  128. },
  129. close() {
  130. this.show = false
  131. },
  132. lower(event) {
  133. if(this.total>this.storeList.length){
  134. this.pageNum++;
  135. this.getList();
  136. }
  137. },
  138. handleClick(item) {
  139. this.storeId = item.store.storeId
  140. this.storeName = item.store.storeName
  141. this.show = false
  142. },
  143. getList(){
  144. if(this.isLastPage){
  145. return;
  146. }
  147. const param = {
  148. pageNum: this.pageNum,
  149. pageSize: 10
  150. };
  151. recommendList(param).then(res => {
  152. if(res.code==200){
  153. //设置列表数据
  154. if (this.pageNum == 1) {
  155. this.storeList = res.rows;
  156. } else {
  157. this.storeList = this.storeList.concat(res.rows);
  158. }
  159. this.total=res.total
  160. this.isLastPage=this.storeList.length>=res.total
  161. }else{
  162. uni.showToast({
  163. icon:'none',
  164. title: "请求失败",
  165. });
  166. }
  167. });
  168. },
  169. navTo() {
  170. this.$isLogin().then(
  171. res => {
  172. if (res) {
  173. uni.navigateTo({
  174. url: '/pages_user/complaintList'
  175. })
  176. } else {
  177. uni.navigateTo({
  178. url: '/pages/auth/login'
  179. })
  180. }
  181. }
  182. );
  183. },
  184. submit() {
  185. if (this.fileList1.length > 0) {
  186. this.formdata.images = this.fileList1.map(item=>item.url).join(',')
  187. }
  188. if(this.formdata.type == 1&&!this.storeId) {
  189. uni.showToast({
  190. title: '请选择店铺',
  191. icon: 'none'
  192. })
  193. return
  194. }
  195. this.$refs.uForm.validate().then(res => {
  196. if (res) {
  197. this.$isLogin().then(res => {
  198. if (res) {
  199. if(this.formdata.type == 1) {
  200. this.formdata = {
  201. ...this.formdata,
  202. storeId: this.storeId
  203. }
  204. }
  205. storeComplaint(this.formdata).then(res => {
  206. if (res.code == 200) {
  207. uni.showModal({
  208. title: '',
  209. content: '我们已收到您的反馈,谢谢',
  210. showCancel: false,
  211. success: function(res) {
  212. if (res.confirm) {
  213. uni.navigateBack()
  214. } else if (res.cancel) {
  215. uni.navigateBack()
  216. }
  217. }
  218. });
  219. } else {
  220. uni.showToast({
  221. title: res.msg,
  222. icon: 'none'
  223. })
  224. }
  225. })
  226. } else {
  227. uni.navigateTo({
  228. url: '/pages/auth/login'
  229. })
  230. }
  231. });
  232. }
  233. })
  234. },
  235. deletePic(event) {
  236. this[`fileList${event.name}`].splice(event.index, 1)
  237. },
  238. async afterRead(event) {
  239. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  240. let lists = [].concat(event.file)
  241. let fileListLen = this[`fileList${event.name}`].length
  242. lists.map((item) => {
  243. this[`fileList${event.name}`].push({
  244. ...item,
  245. status: 'uploading',
  246. message: '上传中'
  247. })
  248. })
  249. for (let i = 0; i < lists.length; i++) {
  250. const result = await this.uploadFilePromise(lists[i].url)
  251. let item = this[`fileList${event.name}`][fileListLen]
  252. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  253. status: 'success',
  254. message: '',
  255. url: result
  256. }))
  257. fileListLen++
  258. }
  259. },
  260. uploadFilePromise(url) {
  261. return new Promise((resolve, reject) => {
  262. let a = uni.uploadFile({
  263. url: uni.getStorageSync('requestPath') + '/app/common/uploadOSS',
  264. filePath: url,
  265. name: 'file',
  266. formData: {
  267. user: 'test'
  268. },
  269. success: (res) => {
  270. setTimeout(() => {
  271. console.log(JSON.parse(res.data).url)
  272. resolve(JSON.parse(res.data).url)
  273. }, 1000)
  274. }
  275. });
  276. })
  277. },
  278. }
  279. }
  280. </script>
  281. <style scoped lang="scss">
  282. .container {
  283. padding: 24rpx;
  284. }
  285. .scroll-list {
  286. height: 60vh;
  287. padding: 24rpx;
  288. box-sizing: border-box;
  289. }
  290. ::v-deep .u-form-item__body {
  291. padding: 0 !important;
  292. }
  293. .storePop{
  294. background-color: #f5f5f5;
  295. &-title {
  296. padding: 24rpx;
  297. text-align: center;
  298. border-bottom: 1rpx solid #eee;
  299. background-color: #fff;
  300. }
  301. .storebox {
  302. background-color: #fff;
  303. padding: 20rpx;
  304. font-family: PingFang SC;
  305. color: #333333;
  306. border-radius: 16rpx 16rpx 16rpx 16rpx;
  307. overflow: hidden;
  308. display: flex;
  309. align-items: flex-start;
  310. margin-bottom: 24rpx;
  311. .logo {
  312. flex-shrink: 0;
  313. width: 104rpx;
  314. height: 104rpx;
  315. background: #fff;
  316. border-radius: 16rpx 16rpx 16rpx 16rpx;
  317. border: 1rpx solid #eee;
  318. margin-right: 16rpx;
  319. box-sizing: border-box;
  320. }
  321. .storename {
  322. font-weight: 500;
  323. font-size: 32rpx;
  324. }
  325. .storedesc {
  326. margin-top: 12rpx;
  327. font-weight: 400;
  328. font-size: 22rpx;
  329. }
  330. .storebox-r {
  331. flex: 1;
  332. overflow: hidden;
  333. }
  334. .storebox-btn {
  335. flex-shrink: 0;
  336. padding: 10rpx 24rpx;
  337. font-size: 28rpx;
  338. border-radius: 28rpx 28rpx 28rpx 28rpx;
  339. border: 2rpx solid #FF5C03;
  340. font-weight: 500;
  341. font-size: 24rpx;
  342. color: #FF5C03;
  343. }
  344. }
  345. }
  346. .btn-box {
  347. width: 100%;
  348. height: 120upx;
  349. padding: 0 30upx;
  350. display: flex;
  351. align-items: center;
  352. justify-content: center;
  353. .sub-btn {
  354. width: 100%;
  355. height: 88upx;
  356. line-height: 88upx;
  357. text-align: center;
  358. font-size: 30upx;
  359. font-family: PingFang SC;
  360. font-weight: bold;
  361. color: #FFFFFF;
  362. background: #2583EB;
  363. border-radius: 44upx;
  364. }
  365. }
  366. .tagbox {
  367. display: flex;
  368. align-items: center;
  369. flex-wrap: wrap;
  370. .tagitem {
  371. min-width: 100rpx;
  372. box-sizing: border-box;
  373. font-family: PingFang SC, PingFang SC;
  374. font-weight: 400;
  375. font-size: 30rpx;
  376. padding: 8rpx 12rpx;
  377. background: #FFF;
  378. border: 1rpx solid #2583EB;
  379. color: #2583EB;
  380. border-radius: 4rpx 4rpx 4rpx 4rpx;
  381. margin-right: 24rpx;
  382. text-align: center;
  383. }
  384. .active {
  385. color: #FFFFFF;
  386. border: 1rpx solid #2583EB;
  387. background: #2583EB;
  388. }
  389. }
  390. .form-item {
  391. background-color: #fff;
  392. border-radius: 16rpx;
  393. padding: 0 24rpx 24rpx 24rpx;
  394. margin-bottom: 16rpx;
  395. &-title {
  396. font-family: PingFang SC, PingFang SC;
  397. font-weight: 600;
  398. font-size: 32rpx;
  399. color: #222222;
  400. padding: 24rpx 0;
  401. }
  402. }
  403. .top_item {
  404. font-family: PingFang SC, PingFang SC;
  405. font-weight: 400;
  406. font-size: 30rpx;
  407. color: #222222;
  408. display: flex;
  409. align-items: center;
  410. justify-content: space-between;
  411. padding: 24rpx !important;
  412. }
  413. </style>