index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view :style="viewColor">
  3. <form @submit="formSubmit" report-submit='true'>
  4. <view class='evaluate-con' v-if="productInfo.product">
  5. <view class='goodsStyle acea-row row-between'>
  6. <view class='pictrue'>
  7. <image :src='productInfo.productAttr.image' v-if="productInfo.productAttr.image"></image>
  8. <image :src='productInfo.product.image' v-else></image>
  9. </view>
  10. <view class='text acea-row row-between'>
  11. <view class='name line2'>{{productInfo.product.store_name}}</view>
  12. <view class='money'>
  13. <view>¥{{productInfo.productAttr.price}}</view>
  14. <view class='num'>x{{cart_num}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class='score'>
  19. <view class='item acea-row row-middle' v-for="(item,indexw) in scoreList" :key="indexw">
  20. <view>{{item.name}}</view>
  21. <view class='starsList'>
  22. <text @click="stars(indexn, indexw)" v-for="(itemn, indexn) in item.stars" :key="indexn" class='iconfont' :class="item.index >= indexn? 'icon-shitixing font-color':'icon-kongxinxing'"></text>
  23. </view>
  24. <text class='evaluate'>{{item.index === -1 ? "" : item.index + 1 + "分"}}</text>
  25. </view>
  26. <view class='textarea'>
  27. <textarea placeholder='商品满足你的期待么?说说你的想法,分享给想买的他们吧~' name="comment" placeholder-class='placeholder'></textarea>
  28. <view class='list acea-row row-middle'>
  29. <view class='pictrue' v-for="(item,index) in pics" :key="index">
  30. <image :src='item'></image>
  31. <text class='iconfont icon-guanbi1 font-color' @click='DelPic(index)'></text>
  32. </view>
  33. <view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic' v-if="pics.length < 6">
  34. <text class='iconfont icon-icon25201'></text>
  35. <view>上传图片</view>
  36. </view>
  37. </view>
  38. </view>
  39. <button class='evaluateBnt' formType="submit">立即评价</button>
  40. </view>
  41. </view>
  42. </form>
  43. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  44. </view>
  45. </template>
  46. <script>
  47. // +----------------------------------------------------------------------
  48. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  49. // +----------------------------------------------------------------------
  50. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  51. // +----------------------------------------------------------------------
  52. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  53. // +----------------------------------------------------------------------
  54. // | Author: CRMEB Team <admin@crmeb.com>
  55. // +----------------------------------------------------------------------
  56. import {
  57. orderProduct,
  58. orderComment
  59. } from '@/api/order.js';
  60. import {
  61. mapGetters
  62. } from "vuex";
  63. import authorize from '@/components/Authorize';
  64. export default {
  65. components: {
  66. authorize,
  67. },
  68. data() {
  69. return {
  70. pics: [],
  71. scoreList: [{
  72. name: "商品质量",
  73. stars: ["", "", "", "", ""],
  74. index: -1
  75. },
  76. {
  77. name: "服务态度",
  78. stars: ["", "", "", "", ""],
  79. index: -1
  80. },
  81. {
  82. name: "物流服务",
  83. stars: ["", "", "", "", ""],
  84. index: -1
  85. }
  86. ],
  87. orderId: '',
  88. unique: '',
  89. productInfo: {},
  90. cart_num: 0,
  91. isAuto: false, //没有授权的不会自动授权
  92. isShowAuth: false //是否隐藏授权
  93. };
  94. },
  95. computed: mapGetters(['isLogin','viewColor']),
  96. onLoad(options) {
  97. if (!options.uni && options.order_id) return this.$util.Tips({
  98. title: '缺少参数'
  99. }, {
  100. tab: 3,
  101. url: 1
  102. });
  103. this.unique = options.uni;
  104. this.orderId = options.order_id;
  105. if (this.isLogin) {
  106. this.getOrderProduct();
  107. } else {
  108. this.isAuto = true;
  109. this.isShowAuth = true
  110. }
  111. },
  112. methods: {
  113. onLoadFun() {
  114. this.isShowAuth = false;
  115. this.getOrderProduct();
  116. },
  117. // 授权关闭
  118. authColse: function(e) {
  119. this.isShowAuth = e
  120. },
  121. /**
  122. * 获取某个产品详情
  123. *
  124. */
  125. getOrderProduct: function() {
  126. let that = this;
  127. orderProduct(that.unique).then(res => {
  128. that.$set(that, 'productInfo', res.data.cart_info);
  129. that.cart_num = res.data.product_num;
  130. }).catch(error=>{
  131. this.$util.Tips({
  132. title:error
  133. },{
  134. tab: 3,
  135. url: 1
  136. })
  137. })
  138. },
  139. stars: function(indexn, indexw) {
  140. this.scoreList[indexw].index = indexn;
  141. },
  142. /**
  143. * 删除图片
  144. *
  145. */
  146. DelPic: function(index) {
  147. let that = this,
  148. pic = this.pics[index];
  149. that.pics.splice(index, 1);
  150. that.$set(that, 'pics', that.pics);
  151. },
  152. /**
  153. * 上传文件
  154. *
  155. */
  156. uploadpic: function() {
  157. let that = this;
  158. console.log('地方');
  159. that.$util.uploadImageOne('upload/image', function(res) {
  160. console.log(res);
  161. that.pics.push(res.data.path);
  162. that.$set(that, 'pics', that.pics);
  163. });
  164. },
  165. /**
  166. * 立即评价
  167. */
  168. formSubmit: function(e) {
  169. let formId = e.detail.formId,
  170. value = e.detail.value,
  171. that = this,
  172. product_score = that.scoreList[0].index + 1 === 0 ? "" : that.scoreList[0].index + 1,
  173. service_score = that.scoreList[1].index + 1 === 0 ? "" : that.scoreList[1].index + 1,
  174. logistics_score = that.scoreList[2].index + 1 === 0 ? "" : that.scoreList[2].index + 1;
  175. if (!value.comment) return that.$util.Tips({
  176. title: '请填写你对宝贝的心得!'
  177. });
  178. value.product_score = product_score;
  179. value.service_score = service_score;
  180. value.postage_score = logistics_score;
  181. value.pics = that.pics;
  182. uni.showLoading({
  183. title: "正在发布评论……"
  184. });
  185. orderComment(this.unique,value).then(res => {
  186. uni.hideLoading();
  187. that.$util.Tips({
  188. title: '感谢您的评价!',
  189. icon: 'success'
  190. });
  191. setTimeout(()=>{
  192. uni.redirectTo({url:'/pages/order_details/index?order_id=' + that.orderId})
  193. },500)
  194. }).catch(err => {
  195. uni.hideLoading();
  196. return that.$util.Tips({
  197. title: err
  198. });
  199. });
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="scss" scoped>
  205. .evaluate-con .score {
  206. background-color: #fff;
  207. border-top: 1rpx solid #f5f5f5;
  208. font-size: 28rpx;
  209. color: #282828;
  210. padding: 48rpx 30rpx 65rpx 30rpx;
  211. }
  212. .evaluate-con .score .item~.item {
  213. margin-top: 30rpx;
  214. }
  215. .evaluate-con .score .item .starsList {
  216. padding: 0 35rpx 0 40rpx;
  217. }
  218. .evaluate-con .score .item .starsList .iconfont {
  219. font-size: 40rpx;
  220. color: #aaa;
  221. }
  222. .evaluate-con .score .item .starsList .iconfont~.iconfont {
  223. margin-left: 20rpx;
  224. }
  225. .evaluate-con .score .item .evaluate {
  226. color: #aaa;
  227. font-size: 24rpx;
  228. }
  229. .evaluate-con .score .textarea {
  230. width: 690rpx;
  231. background-color: #fafafa;
  232. border-radius: 10rpx;
  233. margin-top: 48rpx;
  234. }
  235. .evaluate-con .score .textarea textarea {
  236. font-size: 28rpx;
  237. padding: 38rpx 30rpx 0 30rpx;
  238. width: 100%;
  239. box-sizing: border-box;
  240. height: 160rpx;
  241. }
  242. .evaluate-con .score .textarea .placeholder {
  243. color: #bbb;
  244. }
  245. .evaluate-con .score .textarea .list {
  246. margin-top: 25rpx;
  247. padding-left: 5rpx;
  248. }
  249. .evaluate-con .score .textarea .list .pictrue {
  250. width: 140rpx;
  251. height: 140rpx;
  252. margin: 0 0 35rpx 25rpx;
  253. position: relative;
  254. font-size: 22rpx;
  255. color: #bbb;
  256. }
  257. .evaluate-con .score .textarea .list .pictrue:nth-last-child(1) {
  258. border: 1rpx solid #ddd;
  259. box-sizing: border-box;
  260. }
  261. .evaluate-con .score .textarea .list .pictrue image {
  262. width: 100%;
  263. height: 100%;
  264. border-radius: 3rpx;
  265. }
  266. .evaluate-con .score .textarea .list .pictrue .icon-guanbi1 {
  267. font-size: 45rpx;
  268. position: absolute;
  269. top: -20rpx;
  270. right: -20rpx;
  271. }
  272. .evaluate-con .score .textarea .list .pictrue .icon-icon25201 {
  273. color: #bfbfbf;
  274. font-size: 50rpx;
  275. }
  276. .evaluate-con .score .evaluateBnt {
  277. font-size: 30rpx;
  278. color: #fff;
  279. width: 690rpx;
  280. height: 86rpx;
  281. border-radius: 43rpx;
  282. text-align: center;
  283. line-height: 86rpx;
  284. margin-top: 45rpx;
  285. background-color: var(--view-theme);
  286. }
  287. </style>