index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view>
  3. <form @submit="formSubmit" report-submit='true'>
  4. <view class='evaluate-con pad30'>
  5. <view class='goodsStyle acea-row row-between borRadius14'>
  6. <view class='pictrue'>
  7. <image :src='orderItem.picUrl'></image>
  8. </view>
  9. <view class='text acea-row row-between'>
  10. <view>
  11. <view class='name line2'>{{ orderItem.spuName }}</view>
  12. <view class='attr line1'>
  13. <text v-for="(property, propertyIndex) in orderItem.properties" :key="propertyIndex" style="padding-right: 10rpx;">
  14. {{ property.valueName }} 
  15. </text>
  16. </view>
  17. </view>
  18. <view class='money'>
  19. <view>¥{{ fen2yuan(orderItem.price) }}</view>
  20. <view class='num'>x{{ orderItem.count }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class='score borRadius14'>
  25. <view class='item acea-row row-middle' v-for="(item,indexw) in scoreList" :key="indexw">
  26. <view>{{item.name}}</view>
  27. <view class='starsList'>
  28. <text @click="stars(indexn, indexw)" v-for="(itemn, indexn) in item.stars" :key="indexn"
  29. class='iconfont' :class="item.index >= indexn? 'icon-shitixing':'icon-kongxinxing'" />
  30. </view>
  31. <text class='evaluate'>{{item.index === -1 ? "" : item.index + 1 + "分"}}</text>
  32. </view>
  33. <view class='textarea'>
  34. <textarea placeholder='商品满足你的期待么?说说你的想法,分享给想买的他们吧~' name="comment" placeholder-class='placeholder'></textarea>
  35. <view class='list acea-row row-middle'>
  36. <view class='pictrue' v-for="(item,index) in pics" :key="index">
  37. <image :src='item' />
  38. <text class='iconfont icon-guanbi1' @click='DelPic(index)' />
  39. </view>
  40. <view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic' v-if="pics.length < 9">
  41. <text class='iconfont icon-icon25201'></text>
  42. <view>上传图片</view>
  43. </view>
  44. </view>
  45. </view>
  46. <button class='evaluateBnt bg-color' formType="submit">立即评价</button>
  47. </view>
  48. </view>
  49. </form>
  50. </view>
  51. </template>
  52. <script>
  53. import * as OrderApi from '@/api/trade/order.js';
  54. import { toLogin } from '@/libs/login.js';
  55. import { mapGetters } from "vuex";
  56. import * as Util from '@/utils/util.js';
  57. export default {
  58. data() {
  59. return {
  60. pics: [],
  61. scoreList: [{
  62. name: "商品质量",
  63. stars: ["", "", "", "", ""],
  64. index: -1
  65. }, {
  66. name: "服务态度",
  67. stars: ["", "", "", "", ""],
  68. index: -1
  69. }],
  70. orderItemId: 0, // 订单项编号
  71. orderItem: {},
  72. };
  73. },
  74. computed: mapGetters(['isLogin']),
  75. watch: {
  76. isLogin: {
  77. handler: function(newV, oldV) {
  78. if (newV) {
  79. this.getOrderItem();
  80. }
  81. },
  82. deep: true
  83. }
  84. },
  85. onLoad(options) {
  86. if (!this.isLogin) {
  87. toLogin();
  88. return
  89. }
  90. // 解析参数
  91. if (!options.orderItemId) {
  92. return this.$util.Tips({
  93. title: '缺少参数'
  94. }, {
  95. tab: 3,
  96. url: 1
  97. });
  98. }
  99. this.orderItemId = Number(options.orderItemId || 0);
  100. this.getOrderItem()
  101. },
  102. methods: {
  103. /**
  104. * 获得订单项
  105. */
  106. getOrderItem: function() {
  107. OrderApi.getOrderItem(this.orderItemId).then(res => {
  108. this.orderItem = res.data;
  109. })
  110. },
  111. stars: function(indexn, indexw) {
  112. this.scoreList[indexw].index = indexn;
  113. },
  114. /**
  115. * 删除图片
  116. */
  117. DelPic: function(index) {
  118. this.pics.splice(index, 1);
  119. },
  120. /**
  121. * 上传文件
  122. */
  123. uploadpic: function() {
  124. this.$util.uploadImageOne({}, res => {
  125. this.pics.push(res.data);
  126. this.$set(this, 'pics', this.pics);
  127. });
  128. },
  129. /**
  130. * 立即评价
  131. */
  132. formSubmit: function(e) {
  133. const value = e.detail.value;
  134. const descriptionScores = this.scoreList[0].index + 1 === 0 ? "" : this.scoreList[0].index + 1;
  135. const benefitScores = this.scoreList[1].index + 1 === 0 ? "" : this.scoreList[1].index + 1;
  136. if (!value.comment) {
  137. return this.$util.Tips({
  138. title: '请填写你对宝贝的心得!'
  139. });
  140. }
  141. // 提交请求
  142. uni.showLoading({
  143. title: "正在发布评论……"
  144. });
  145. OrderApi.createOrderItemComment({
  146. anonymous: false, // TODO 芋艿:后面加个匿名框框
  147. orderItemId: this.orderItemId,
  148. descriptionScores: descriptionScores,
  149. benefitScores: benefitScores,
  150. content: value.comment,
  151. picUrls: this.pics
  152. }).then(res => {
  153. uni.hideLoading();
  154. return this.$util.Tips({
  155. title: '感谢您的评价!',
  156. icon: 'success'
  157. }, '/pages/order_details/index?order_id=' + this.orderItem.orderId);
  158. }).catch(err => {
  159. uni.hideLoading();
  160. return this.$util.Tips({
  161. title: err
  162. });
  163. });
  164. },
  165. fen2yuan(price) {
  166. return Util.fen2yuan(price)
  167. },
  168. }
  169. }
  170. </script>
  171. <style lang="scss" scoped>
  172. .goodsStyle .text .name, .attr{
  173. //width: 496rpx;
  174. }
  175. .icon-shitixing{
  176. color: #FFBB00 !important;
  177. }
  178. .evaluate-con .score {
  179. background-color: #fff;
  180. // border-top: 1rpx solid #f5f5f5;
  181. margin-top: 20rpx;
  182. font-size: 28rpx;
  183. color: #282828;
  184. padding: 46rpx 24rpx;
  185. }
  186. .evaluate-con .score .item~.item {
  187. margin-top: 36rpx;
  188. }
  189. .evaluate-con .score .item .starsList {
  190. padding: 0 35rpx 0 40rpx;
  191. }
  192. .evaluate-con .score .item .starsList .iconfont {
  193. font-size: 40rpx;
  194. color: #aaa;
  195. }
  196. .evaluate-con .score .item .starsList .iconfont~.iconfont {
  197. margin-left: 20rpx;
  198. }
  199. .evaluate-con .score .item .evaluate {
  200. color: #aaa;
  201. font-size: 24rpx;
  202. }
  203. .evaluate-con .score .textarea {
  204. width: 100%;
  205. background-color: #F5F5F5;
  206. border-radius: 14rpx;
  207. margin-top: 55rpx;
  208. }
  209. .evaluate-con .score .textarea textarea {
  210. font-size: 28rpx;
  211. padding: 38rpx 30rpx 0 30rpx;
  212. width: 100%;
  213. box-sizing: border-box;
  214. height: 160rpx;
  215. width: auto !important;
  216. }
  217. .evaluate-con .score .textarea .placeholder {
  218. color: #bbb;
  219. }
  220. .evaluate-con .score .textarea .list {
  221. margin-top: 25rpx;
  222. padding-left: 5rpx;
  223. }
  224. .evaluate-con .score .textarea .list .pictrue {
  225. width: 140rpx;
  226. height: 140rpx;
  227. margin: 0 0 35rpx 25rpx;
  228. position: relative;
  229. font-size: 22rpx;
  230. color: #bbb;
  231. border-radius: 14rpx;
  232. }
  233. .evaluate-con .score .textarea .list .pictrue:nth-last-child(1) {
  234. border: 1rpx solid #ddd;
  235. box-sizing: border-box;
  236. }
  237. .evaluate-con .score .textarea .list .pictrue image {
  238. width: 100%;
  239. height: 100%;
  240. border-radius: 14rpx;
  241. }
  242. .evaluate-con .score .textarea .list .pictrue .icon-guanbi1 {
  243. font-size: 45rpx;
  244. position: absolute;
  245. top: -20rpx;
  246. right: -20rpx;
  247. }
  248. .evaluate-con .score .textarea .list .pictrue .icon-icon25201 {
  249. color: #bfbfbf;
  250. font-size: 50rpx;
  251. }
  252. .evaluate-con .score .evaluateBnt {
  253. font-size: 30rpx;
  254. color: #fff;
  255. width: 100%;
  256. height: 86rpx;
  257. border-radius: 43rpx;
  258. text-align: center;
  259. line-height: 86rpx;
  260. margin-top: 45rpx;
  261. }
  262. </style>