order-evaluate.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="">
  3. <!-- 商品区 -->
  4. <view class="padding margin-lr margin-tb-sm bg-main border-radius">
  5. <view class="goods-area" v-for="(item, index) in order_detail" :key="index">
  6. <view class="dflex">
  7. <view class="img">
  8. <image :src="item.goodsMasterImg"></image>
  9. </view>
  10. <view class="margin-left-sm">
  11. <text class="clamp-2">{{ item.goodsName }}</text>
  12. <view class="ft-dark fs-xs padding-top-xs">
  13. <text class="margin-right">× {{ item.goodsCount }}</text>
  14. {{ item.goodsAttr || '&nbsp;&nbsp;' }}
  15. </view>
  16. <view class="margin-top-sm">
  17. <text class="price">{{ order_data.orderActualPrice }}</text>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <!-- 评分 -->
  24. <view class="evaluate-kps">
  25. <view class="padding margin-lr margin-tb-sm bg-main border-radius dflex-b">
  26. <view>
  27. <text>总体评分</text>
  28. <text class="margin-left ft-base fs-xs">
  29. {{postData.review_type}}
  30. </text>
  31. </view>
  32. <use-rate @change="rateChange" value="5"></use-rate>
  33. </view>
  34. </view>
  35. <!-- 评价区 -->
  36. <view class="evaluate-area">
  37. <view class="padding margin-lr margin-tb-sm bg-main border-radius">
  38. <!-- 评价内容 -->
  39. <textarea class="ft-black w-full fs-sm" v-model="postData.review_content"
  40. placeholder="请输入评价内容"></textarea>
  41. <!-- 上传图片 -->
  42. <use-upload class="pos-r" @upload="uploadImgs"></use-upload>
  43. </view>
  44. </view>
  45. <!-- 是否匿名评价 -->
  46. <view>
  47. <view class="padding margin-lr margin-tb-sm bg-main border-radius dflex-b">
  48. <text>提交评价的图片{{ anonymity ? '不可见' : '可见' }}</text>
  49. <view>
  50. <!-- <text class="ft-dark">匿名</text> -->
  51. <switch color="#FF6A6C" @change="switchChange" />
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 提交操作 -->
  56. <view class="padding w-full margin-top">
  57. <view class="dflex-b border-radius-big">
  58. <view class="tac padding-tb-sm flex1 bg-base-ping" @click="submit">提交评价</view>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import {
  65. orderinfo,
  66. comment,
  67. } from '../../../utils/api_order.js'
  68. import useUpload from '../../../components/use-upload/use-upload.vue'
  69. import useRate from '../../../components/use-rate/use-rate.vue'
  70. export default {
  71. components:{
  72. useUpload,
  73. useRate
  74. },
  75. data() {
  76. return {
  77. // 商品数据
  78. order_detail: [],
  79. // 订单数据
  80. order_data: {},
  81. // 订单ID
  82. order_id: '',
  83. postData: {
  84. orderId: '',
  85. review_cnt: 5,
  86. review_type: '好评',
  87. review_content: '',
  88. review_imgs: '',
  89. review_anonymity: '0',
  90. },
  91. now_date:'',//当前时间
  92. };
  93. },
  94. onLoad(options) {
  95. this.order_id = options.id;
  96. if (!this.order_id) {
  97. this.$api.msg('订单编号不存在');
  98. }
  99. this.loadData();
  100. },
  101. methods: {
  102. loadData() {
  103. let _this = this;
  104. // 订单详情
  105. var data=_this.order_id
  106. orderinfo(data).then((res) => {
  107. if(res.success){
  108. _this.order_data = res.data;
  109. _this.order_detail = res.data.orderDetails;
  110. return
  111. }
  112. _this.$api.msg(res.msg);
  113. })
  114. },
  115. uploadImgs(options) {
  116. let imgs = [];
  117. options.forEach((_) => {
  118. imgs.push(_);
  119. });
  120. if (imgs.length > 0) this.postData.review_imgs = imgs;
  121. },
  122. submit() {
  123. this.getNowDate()
  124. let _this = this;
  125. if (!_this.postData.review_content) {
  126. _this.$api.msg('请填写评价内容');
  127. return;
  128. }
  129. if (_this.issubmit) return;
  130. if(_this.postData.review_type=='差评'){
  131. var type=1
  132. }else if(_this.postData.review_type=='中评'){
  133. var type=2
  134. }else if(_this.postData.review_type=='好评'){
  135. var type=3
  136. }
  137. _this.issubmit = true;
  138. _this.postData.orderId = _this.order_id;
  139. var imgshu=this.postData.review_imgs.toString()
  140. uni.showModal({
  141. title: '提示',
  142. content: '提交评价',
  143. success: function(res) {
  144. if (res.confirm) {
  145. var data={
  146. "orderId": _this.postData.orderId,
  147. "goodsId": _this.order_detail[0].goodsId,
  148. "skuId":_this.order_detail[0].skuId,
  149. "reviewContent": _this.postData.review_content,
  150. "reviewType": type,//1差评 2中评 3好评
  151. "reviewCnt": _this.postData.review_cnt,//1-5
  152. "reviewImgs": imgshu,
  153. "state": _this.postData.review_anonymity,//0隐藏 1显示
  154. "createTime": _this.now_date,
  155. "skuId": _this.order_detail[0].skuId,
  156. }
  157. comment(data).then((res) => {
  158. if(res.success){
  159. _this.$api.msg('提交成功');
  160. _this.issubmit = false;
  161. uni.navigateBack({});
  162. return
  163. }
  164. _this.$api.msg(res.msg);
  165. _this.issubmit = false;
  166. })
  167. } else if (res.cancel) {
  168. console.log('用户点击取消');
  169. }
  170. }
  171. });
  172. },
  173. //获取当前时间
  174. getNowDate() {
  175. var _this = this;
  176. // this.timer = setInterval(function() {
  177. var aData = new Date();
  178. var month = aData.getMonth() < 9 ? "0" + (aData.getMonth() + 1) : aData.getMonth() + 1;
  179. var date = aData.getDate() <= 9 ? "0" + aData.getDate() : aData.getDate();
  180. var date2 = aData.getDate() <= 9 ? "0" + (aData.getDate()-1) : (aData.getDate()-1);
  181. var Hour = aData.getHours() <= 9 ? "0" + (aData.getHours()) : aData.getHours();
  182. var Miunte = aData.getMinutes() <= 9 ? "0" + (aData.getMinutes()) : aData.getMinutes();
  183. var Seconds = aData.getSeconds() <= 9 ? "0" + (aData.getSeconds()) : aData.getSeconds();
  184. // console.log(aData.getTime())
  185. _this.now_date = aData.getFullYear() + "-" + month + "-" + date + ' '+ Hour +":"+ Miunte +":"+ Seconds;
  186. // console.log(aData.getFullYear() + "-" + month + "-" + date2)昨天
  187. // }, 86400000);
  188. },
  189. switchChange(options) {
  190. this.postData.review_anonymity = options.detail.value ? '1' : '0';
  191. },
  192. rateChange(options) {
  193. switch (options.value) {
  194. case 1:
  195. this.postData.review_type = '差评';
  196. break;
  197. case 2:
  198. case 3:
  199. this.postData.review_type = '中评';
  200. break;
  201. case 4:
  202. case 5:
  203. this.postData.review_type = '好评';
  204. break;
  205. }
  206. this.postData.review_cnt = options.value;
  207. }
  208. }
  209. };
  210. </script>
  211. <style lang="scss">
  212. page {
  213. background: $page-color-base;
  214. }
  215. @import url('/packageShang/components/iconfont/iconfont.css');
  216. @import url('/packageShang/common/common.scss');
  217. /* 商品区 */
  218. .goods-area {
  219. &:last-child {
  220. margin-bottom: 0;
  221. }
  222. image {
  223. width: 180rpx;
  224. height: 180rpx;
  225. }
  226. }
  227. </style>