add.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <!-- 评价 -->
  2. <template>
  3. <s-layout title="评价">
  4. <view>
  5. <view v-for="(item, index) in state.orderInfo.items" :key="item.id">
  6. <view v-if="item.btns.includes('comment')">
  7. <view class="commont-from-wrap">
  8. <!-- 评价商品 -->
  9. <s-goods-item :img="item.goods_image" :title="item.goods_title" :skuText="item.goods_sku_text"
  10. :price="item.goods_price" :num="item.goods_num"></s-goods-item>
  11. </view>
  12. <view class="form-item">
  13. <!-- 评分 -->
  14. <view class="star-box ss-flex ss-col-center">
  15. <view class="star-title ss-m-r-40">
  16. <!-- {{ rateMap[state.commentList[index].level] }} -->
  17. 商品质量
  18. </view>
  19. <uni-rate v-model="state.commentList[index].level" />
  20. </view>
  21. <view class="star-box ss-flex ss-col-center">
  22. <view class="star-title ss-m-r-40">
  23. <!-- {{ rateMap[state.commentList[index].level] }} -->
  24. 服务态度
  25. </view>
  26. <uni-rate v-model="state.commentList[index].level2" />
  27. </view>
  28. <!-- 评价 -->
  29. <view class="area-box">
  30. <uni-easyinput :inputBorder="false" type="textarea" maxlength="120" autoHeight
  31. v-model="state.commentList[index].content"
  32. placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~"></uni-easyinput>
  33. <view class="img-box">
  34. <s-uploader v-model:url="state.commentList[index].images" fileMediatype="image"
  35. limit="9" mode="grid" :imageStyles="{ width: '168rpx', height: '168rpx' }" />
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <su-fixed bottom placeholder>
  43. <view class="foot_box ss-flex ss-row-center ss-col-center">
  44. <button class="ss-reset-button post-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onSubmit">
  45. 发布
  46. </button>
  47. </view>
  48. </su-fixed>
  49. </s-layout>
  50. </template>
  51. <script setup>
  52. import sheep from '@/sheep';
  53. import {
  54. onLoad
  55. } from '@dcloudio/uni-app';
  56. import {
  57. computed,
  58. reactive
  59. } from 'vue';
  60. const state = reactive({
  61. orderInfo: {},
  62. commentList: [],
  63. orderId: null
  64. });
  65. const rateMap = {
  66. 1: '糟糕',
  67. 2: '差评',
  68. 3: '一般',
  69. 4: '良好',
  70. 5: '好评',
  71. };
  72. async function onSubmit() {
  73. // 对接商品评价
  74. // console.log(state.orderInfo);
  75. // return;
  76. let obj = {
  77. anonymous: false,
  78. benefitScores: state.commentList[0].level2,
  79. content: state.commentList[0].content,
  80. descriptionScores: state.commentList[0].level,
  81. orderItemId: state.commentList[0].item_id,
  82. picUrls: 'https://t7.baidu.com/it/u=2531125946,3055766435&fm=193&f=GIF'
  83. }
  84. const {
  85. code
  86. } = await sheep.$api.order.comment(obj);
  87. if (code === 0) {
  88. sheep.$router.back();
  89. }
  90. }
  91. onLoad(async (options) => {
  92. let id = '';
  93. if (options.orderSN) {
  94. id = options.orderSN;
  95. }
  96. if (options.id) {
  97. id = options.id;
  98. }
  99. if (options.orderId) {
  100. state.orderId = options.orderId
  101. }
  102. const res = await sheep.$api.order.detail(id);
  103. if (res.code === 0) {
  104. let obj = {
  105. 10: ['待发货', '等待买家付款', ["apply_refund"]],
  106. 30: ['待评价', '等待买家评价', ["express", "comment"]]
  107. }
  108. res.data.status_text = obj[res.data.status][0];
  109. res.data.status_desc = obj[res.data.status][1];
  110. res.data.btns = obj[res.data.status][2];
  111. res.data.address = {
  112. province_name: res.data.receiverAreaName.split(' ')[0],
  113. district_name: res.data.receiverAreaName.split(' ')[2],
  114. city_name: res.data.receiverAreaName.split(' ')[1],
  115. address: res.data.receiverDetailAddress,
  116. consignee: res.data.receiverName,
  117. mobile: res.data.receiverMobile,
  118. }
  119. res.data.pay_fee = res.data.payPrice / 100
  120. res.data.create_time = sheep.$helper.timeFormat(res.data.createTime, 'yyyy-mm-dd hh:MM:ss')
  121. res.data.order_sn = res.data.no
  122. res.data.id = res.data.id
  123. res.data.goods_amount = res.data.totalPrice / 100
  124. res.data.dispatch_amount = res.data.deliveryPrice / 100
  125. res.data.pay_types_text = res.data.payChannelName.split(',')
  126. res.data.items = res.data.items.map(ite => {
  127. return {
  128. ...ite,
  129. btns: obj[res.data.status][2],
  130. goods_title: ite.spuName,
  131. goods_num: ite.count,
  132. goods_price: ite.price / 100,
  133. goods_image: ite.picUrl,
  134. goods_sku_text: ite.properties.reduce((it0, it1) => it0 + it1.valueName + ' ', '')
  135. }
  136. })
  137. if (res.data.btns.includes('comment')) {
  138. state.orderInfo = res.data;
  139. state.orderInfo.items.forEach((item) => {
  140. if (item.btns.includes('comment')) {
  141. state.commentList.push({
  142. item_id: item.id,
  143. level: 5,
  144. content: '',
  145. images: [],
  146. });
  147. }
  148. });
  149. console.log(state.orderInfo.items, '循环')
  150. return;
  151. }
  152. }
  153. sheep.$helper.toast('无待评价订单');
  154. });
  155. </script>
  156. <style lang="scss" scoped>
  157. // 评价商品
  158. .goods-card {
  159. margin: 10rpx 0;
  160. padding: 20rpx;
  161. background: #fff;
  162. }
  163. // 评论,选择图片
  164. .form-item {
  165. background: #fff;
  166. .star-box {
  167. height: 100rpx;
  168. padding: 0 25rpx;
  169. }
  170. .star-title {
  171. font-weight: 600;
  172. }
  173. }
  174. .area-box {
  175. width: 690rpx;
  176. min-height: 306rpx;
  177. background: rgba(249, 250, 251, 1);
  178. border-radius: 20rpx;
  179. padding: 28rpx;
  180. margin: auto;
  181. .img-box {
  182. margin-top: 20rpx;
  183. }
  184. }
  185. .post-btn {
  186. width: 690rpx;
  187. line-height: 80rpx;
  188. border-radius: 40rpx;
  189. color: rgba(#fff, 0.9);
  190. margin-bottom: 20rpx;
  191. }
  192. </style>