publishEvaluation.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <!-- 发表评价 -->
  2. <template>
  3. <view class="container">
  4. <view class="gap"></view>
  5. <view class="content" v-for="(item,index) in detailList" :key="index">
  6. <view class="goods_detail_wrap">
  7. <view class="goods_img_wrap">
  8. <image :src="item.productImage" mode="" class="goods_img"></image>
  9. </view>
  10. <view class="goods_detail_right">
  11. <view class="goods_name">{{item.goodsName}}</view>
  12. <view class="goods_spec" v-if="item.specValues">{{item.specValues}}</view>
  13. </view>
  14. </view>
  15. <view class="goods_rate">
  16. <view class="goods_rate_text">{{$L('整体评分')}}</view>
  17. <uni-rate v-model="item.score" :size="16" active-color="#FC1C1C" :evaItem='item' :margin="5"
  18. @change="onChange" />
  19. <view class="rate_text">{{item.rate_text}}</view>
  20. </view>
  21. <view class="remark_con">
  22. <image class="evalute_icon" v-if="!item.content" :src="imgUrl+'store/evalute-icon.png'" mode=""></image>
  23. <textarea v-model="item.content" :class="{input_state:item.content}" auto-height maxlength="200"
  24. :placeholder="$L('宝贝满足你的条件吗?请说说使用心得吧')" />
  25. </view>
  26. <view class="remark_wrap">
  27. <view class="upload_img_wrap">
  28. <view class="evaluate_img" v-for="(imgItem,index2) in item.goodsList" :key="index2">
  29. <image :src="imgItem" mode="aspectFit" class="upload_img"></image>
  30. <image :src="closeImg" mode="" class="close_img" @click="delUploadImg(index2,item)"></image>
  31. </view>
  32. <view class="upload_img_box" @click="uploadImg(item)" v-if="item.goodsList.length < 5">
  33. <view class="upload_image">
  34. <image :src="cameraImg" mode=""></image>
  35. <view class="upload_text">
  36. {{item.goodsList.length == 0? $L("添加图片"):item.goodsList.length+'/5'}}</view>
  37. <view class="upload_img_text">{{$L('最多可上传5张')}}</view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="empty-20">
  43. </view>
  44. </view>
  45. <view class="store_evaluate">
  46. <view class="store_evaluate_logo_name">
  47. <image class="store_logo" :src="imgUrl+'goods_detail/store_logo.png'"></image>
  48. <text>{{store_info.storeName}}</text>
  49. </view>
  50. <view class="store_evaluate_list">
  51. <view class="store_evaluate_list_item">
  52. <view class="goods_rate_text">{{$L('描述相符')}}</view>
  53. <uni-rate class="uni_rate" v-model="store_info.description" :size="16" active-color="#FC1C1C"
  54. text='description' :margin="5" @change="onChangeStore" />
  55. <view class="rate_text">{{store_eva_text.description}}</view>
  56. </view>
  57. <view class="store_evaluate_list_item">
  58. <view class="goods_rate_text">{{$L('物流服务')}}</view>
  59. <uni-rate class="uni_rate" v-model="store_info.expressSpeed" :size="16" active-color="#FC1C1C"
  60. text='expressSpeed' :margin="5" @change="onChangeStore" />
  61. <view class="rate_text">{{store_eva_text.expressSpeed}}</view>
  62. </view>
  63. <view class="store_evaluate_list_item">
  64. <view class="goods_rate_text">{{$L('服务态度')}}</view>
  65. <uni-rate class="uni_rate" v-model="store_info.serviceAttitude" :size="16" active-color="#FC1C1C"
  66. text='serviceAttitude' :margin="5" @change="onChangeStore" />
  67. <view class="rate_text">{{store_eva_text.serviceAttitude}}</view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="submit_btn_wrap">
  72. <view class="submit_btn" @click="publishEvaluation()">{{$L('发布')}}</view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. import {
  78. uniRate
  79. } from '../../components/uni-rate/uni-rate.vue'
  80. import {
  81. mapState
  82. } from 'vuex';
  83. export default {
  84. data() {
  85. return {
  86. cameraImg: getApp().globalData.imgUrl + 'order/camera.png',
  87. closeImg: getApp().globalData.imgUrl + 'order-detail/guanbi.png',
  88. orderSn: '', // 商品订单号
  89. detailList: [], //数据列表
  90. goodsList: [], //上传图片绝对路径
  91. imgList: [], //上传图片相对路径
  92. content: '', //评价内容
  93. value: 5, //星星评分1-5
  94. rate_text: '非常好', //评分文字说明
  95. sourceType: '', //页面来源 如果是从交易成功页面进入 则返回交易成功的上一页(订单详情 orderDetail,订单列表orderList),否则返回上一页
  96. windowHeight: '', //窗口高度
  97. imgUrl: getApp().globalData.imgUrl,
  98. store_info: {},
  99. store_eva_text: {
  100. serviceAttitude: '好评',
  101. description: '好评',
  102. expressSpeed: '好评'
  103. }
  104. }
  105. },
  106. components: {
  107. // uniRate
  108. },
  109. computed: {
  110. ...mapState(['userInfo'])
  111. },
  112. onLoad(option) {
  113. this.orderSn = option.orderSn;
  114. this.sourceType = option.sourceType;
  115. this.loadData();
  116. uni.getSystemInfo({
  117. success: (res) => {
  118. this.windowHeight = res.windowHeight;
  119. }
  120. });
  121. },
  122. // 页面周期与 onLoad 同级
  123. onBackPress(e) {
  124. if (e.from == 'backbutton') {
  125. uni.showModal({
  126. title: this.$L('确定要退出评价?'),
  127. content: this.$L('退出后编辑过的内容将不保存'),
  128. confirmText: this.$L('是'),
  129. cancelText: this.$L('否'),
  130. success: function(res) {
  131. if (res.confirm) {
  132. uni.navigateBack({
  133. delta: 1
  134. });
  135. }
  136. }
  137. });
  138. return true; //阻止默认返回行为
  139. }
  140. },
  141. methods: {
  142. // 售后详情
  143. loadData() {
  144. let param = {}
  145. param.url = 'v3/business/front/orderInfo/detail'
  146. param.method = 'POST'
  147. param.data = {
  148. orderSn: this.orderSn,
  149. }
  150. this.$request(param).then(res => {
  151. if (res.state == 200) {
  152. this.store_info = res.data.childOrdersVOS[0]
  153. this.detailList = res.data.childOrdersVOS[0].orderProductListVOList
  154. this.detailList.map(item => {
  155. this.$set(item, 'content', '')
  156. this.$set(item, 'score', 5)
  157. this.$set(item, 'rate_text', '非常好')
  158. this.$set(item, 'goodsList', [])
  159. this.$set(item, 'imgList', [])
  160. })
  161. this.$set(this.store_info, 'serviceAttitude', 5)
  162. this.$set(this.store_info, 'description', 5)
  163. this.$set(this.store_info, 'expressSpeed', 5)
  164. } else {
  165. this.$api.msg(res.msg);
  166. }
  167. }).catch((e) => {
  168. //异常处理
  169. })
  170. },
  171. // 商品价格格式化
  172. bigPrice(val) {
  173. return val.toFixed(2).toString().split('.')[0]
  174. },
  175. smallPrice(val) {
  176. return val.toFixed(2).toString().split('.')[1]
  177. },
  178. // 店铺评价时间
  179. onChangeStore(e) {
  180. if (e.value >= 4) {
  181. this.store_eva_text[e.text] = '好评'
  182. } else if (e.value > 1 && e.value < 4) {
  183. this.store_eva_text[e.text] = '中评'
  184. } else {
  185. this.store_eva_text[e.text] = '差评'
  186. }
  187. },
  188. onChange(e) {
  189. this.value = e.value
  190. if (this.value == 5) {
  191. e.item.rate_text = '非常好'
  192. } else if (this.value == 4) {
  193. e.item.rate_text = '好'
  194. } else if (this.value == 3) {
  195. e.item.rate_text = '一般'
  196. } else if (this.value == 2) {
  197. e.item.rate_text = '差'
  198. } else {
  199. e.item.rate_text = '非常差'
  200. }
  201. },
  202. // 上传评价图片
  203. uploadImg(product) {
  204. let _this = this;
  205. if (product.goodsList.length == 5) {
  206. uni.showToast({
  207. title: '最多上传5张图片!',
  208. icon: 'none',
  209. })
  210. return
  211. }
  212. uni.chooseImage({
  213. count: 5,
  214. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  215. success: function(res) {
  216. setTimeout(() => {
  217. uni.showLoading({
  218. title: '上传中',
  219. mask: true
  220. })
  221. })
  222. res.tempFilePaths.forEach(item => {
  223. uni.uploadFile({
  224. url: getApp().globalData.apiUrl + 'v3/oss/common/upload',
  225. filePath: item,
  226. name: 'file',
  227. formData: {
  228. 'source': 'evaluate',
  229. 'file': item
  230. },
  231. success: (uploadFileRes) => {
  232. let result = JSON.parse(uploadFileRes.data);
  233. if (result.state == 200) {
  234. product.goodsList.push(result.data.url)
  235. product.imgList.push(result.data.path)
  236. }
  237. },
  238. complete: () => {
  239. uni.hideLoading()
  240. }
  241. });
  242. })
  243. }
  244. });
  245. },
  246. // 删除评价图片
  247. delUploadImg(index, product) {
  248. product.goodsList.splice(index, 1)
  249. product.imgList.splice(index, 1)
  250. },
  251. // 提交评价
  252. publishEvaluation() {
  253. let param = {}
  254. let goodsCommentInfoList = []
  255. this.detailList.map(item => {
  256. let product = {}
  257. product.content = item.content
  258. product.goodsId = item.goodsId
  259. product.image = item.imgList.join(',')
  260. product.orderProductId = item.orderProductId
  261. product.productId = item.productId
  262. product.score = item.score
  263. goodsCommentInfoList.push(product)
  264. })
  265. param.url = 'v3/business/front/orderComment/addOrderComment'
  266. param.method = 'POST'
  267. param.header = {
  268. "Content-Type": "application/json"
  269. }
  270. param.data = {
  271. description: this.store_info.description,
  272. deliverSpeed: this.store_info.expressSpeed,
  273. serviceAttitude: this.store_info.serviceAttitude,
  274. orderSn: this.orderSn,
  275. goodsCommentInfoList: goodsCommentInfoList
  276. }
  277. this.$request(param).then(res => {
  278. if (res.state == 200) {
  279. uni.showToast({
  280. title: '评价成功!',
  281. icon: 'none',
  282. duration: 700
  283. })
  284. if (this.sourceType == 'orderDetail') {
  285. setTimeout(() => {
  286. uni.navigateTo({
  287. url: '/pages/order/detail?orderSn=' + this.orderSn
  288. })
  289. }, 1000)
  290. } else if (this.sourceType == 'orderList') {
  291. setTimeout(() => {
  292. uni.navigateTo({
  293. url: '/pages/order/list?state=0'
  294. })
  295. }, 1000)
  296. } else {
  297. setTimeout(() => {
  298. uni.navigateBack({
  299. delta: 1
  300. })
  301. }, 1000)
  302. }
  303. } else {
  304. this.$api.msg(res.msg);
  305. }
  306. }).catch((e) => {
  307. //异常处理
  308. })
  309. }
  310. }
  311. }
  312. </script>
  313. <style lang="scss">
  314. page {
  315. width: 750rpx;
  316. margin: 0 auto;
  317. }
  318. page,
  319. .container {
  320. // background: $bg-color-split;
  321. height: 100%;
  322. position: relative;
  323. overflow: scroll;
  324. }
  325. page {
  326. background-color: white;
  327. }
  328. .gap {
  329. width: 100%;
  330. height: 20rpx;
  331. background-color: #f8f8f8;
  332. }
  333. .content {
  334. background-color: #fff;
  335. .goods_detail_wrap {
  336. padding: 20rpx;
  337. width: 100%;
  338. display: flex;
  339. .goods_img_wrap {
  340. width: 140rpx;
  341. height: 140rpx;
  342. border-radius: 14rpx;
  343. margin-right: 20rpx;
  344. .goods_img {
  345. width: 140rpx;
  346. height: 140rpx;
  347. border-radius: 14rpx;
  348. }
  349. }
  350. .goods_detail_right {
  351. width: 100%;
  352. display: flex;
  353. flex-direction: column;
  354. .goods_name {
  355. margin-top: 20rpx;
  356. font-size: 28rpx;
  357. font-weight: 600;
  358. color: #343434;
  359. width: 540rpx;
  360. white-space: nowrap;
  361. overflow: hidden;
  362. text-overflow: ellipsis;
  363. }
  364. .goods_spec {
  365. font-size: 26rpx;
  366. color: #949494;
  367. margin-top: 16rpx;
  368. }
  369. }
  370. }
  371. .goods_rate {
  372. display: flex;
  373. align-items: center;
  374. padding: 0 20rpx 20rpx 20rpx;
  375. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  376. .goods_rate_text {
  377. font-size: 30rpx;
  378. color: #343434;
  379. font-weight: 600;
  380. margin-right: 38rpx;
  381. }
  382. .rate_text {
  383. font-size: 28rpx;
  384. color: #949494;
  385. margin-left: 10rpx;
  386. }
  387. }
  388. .remark_wrap {
  389. padding-bottom: 20rpx;
  390. box-sizing: border-box;
  391. width: 710rpx;
  392. margin: 0 auto;
  393. }
  394. .remark_con {
  395. display: flex;
  396. align-items: center;
  397. margin: 40rpx 0;
  398. image {
  399. width: 28rpx;
  400. height: 27rpx;
  401. margin-left: 23rpx;
  402. }
  403. textarea {
  404. width: 100%;
  405. font-size: 28rpx;
  406. line-height: 28rpx;
  407. color: #949494;
  408. // box-sizing: border-box;
  409. padding-left: 14rpx;
  410. line-height: 36rpx;
  411. // word-wrap : break-word;
  412. }
  413. }
  414. .upload_img_wrap {
  415. display: flex;
  416. flex-wrap: nowrap;
  417. overflow-x: auto;
  418. white-space: nowrap;
  419. /* 解决ios手机页面滑动卡顿问题 */
  420. -webkit-overflow-scrolling: touch;
  421. .evaluate_img {
  422. position: relative;
  423. width: 210rpx;
  424. height: 220rpx;
  425. padding-top: 10rpx;
  426. margin-right: 10rpx;
  427. .upload_img {
  428. width: 210rpx;
  429. height: 210rpx;
  430. }
  431. .close_img {
  432. width: 30rpx;
  433. height: 30rpx;
  434. position: absolute;
  435. right: -10rpx;
  436. top: 0rpx;
  437. z-index: 999;
  438. }
  439. }
  440. .upload_img_box {
  441. padding-top: 10rpx;
  442. .upload_image {
  443. width: 210rpx;
  444. height: 210rpx;
  445. display: flex;
  446. flex-direction: column;
  447. justify-content: center;
  448. align-items: center;
  449. border: 2rpx dashed #DEDEDE;
  450. image {
  451. width: 50rpx;
  452. height: 40rpx;
  453. }
  454. .upload_text {
  455. font-size: 26rpx;
  456. color: #949494;
  457. margin-top: 15rpx;
  458. }
  459. .upload_img_text {
  460. font-size: 20rpx;
  461. color: #949494;
  462. }
  463. }
  464. }
  465. }
  466. // }
  467. }
  468. .input_state {
  469. padding: 0 24rpx !important;
  470. color: #333333 !important;
  471. line-height: 20rpx;
  472. }
  473. .store_evaluate {
  474. width: 750rpx;
  475. margin-bottom: 180rpx;
  476. .store_evaluate_logo_name {
  477. padding: 32rpx 0;
  478. .store_logo {
  479. width: 34rpx;
  480. height: 32rpx;
  481. margin-left: 30rpx;
  482. }
  483. text {
  484. font-size: 32rpx;
  485. color: #2d2d2d;
  486. margin-left: 10rpx;
  487. }
  488. }
  489. .store_evaluate_list {
  490. border-top: 1rpx solid #f2f2f2;
  491. padding: 0 32rpx;
  492. font-size: 28rpx;
  493. .store_evaluate_list_item {
  494. display: flex;
  495. align-items: center;
  496. margin-top: 44rpx;
  497. .rate_text {
  498. margin-left: 48rpx;
  499. }
  500. .goods_rate_text {
  501. margin-right: 50rpx;
  502. }
  503. }
  504. }
  505. }
  506. .empty-20 {
  507. width: 750rpx;
  508. height: 20rpx;
  509. background: #F5F5F5;
  510. }
  511. .submit_btn_wrap {
  512. width: 750rpx;
  513. display: flex;
  514. justify-content: center;
  515. position: fixed;
  516. bottom: 0;
  517. right: auto;
  518. left: auto;
  519. background-color: white;
  520. .submit_btn {
  521. width: 668rpx;
  522. height: 88rpx;
  523. font-size: 36rpx;
  524. color: #FEFEFE;
  525. display: flex;
  526. justify-content: center;
  527. align-items: center;
  528. background: #F30300;
  529. // box-shadow: 1rpx 3rpx 15rpx 0rpx rgba(252, 30, 28, 0.26);
  530. border-radius: 44rpx;
  531. margin-bottom: 20rpx;
  532. }
  533. }
  534. </style>