index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="px-20">
  4. <view class="h-120 bg--w111-fff rd-24rpx mt-24 pl-24 flex-y-center">
  5. <text class="fs-28 fw-500 mr-32">商品评价</text>
  6. <view class="flex-y-center">
  7. <view class="flex-y-center nav-item" v-for="(item, index) in replyNav" :key="index"
  8. @tap="replyNavChange(item.value)">
  9. <image :src=" reply_score == item.value ? item.activePic : item.pic" class="w-44 h-44"></image>
  10. <text class="fs-32 pl-14"
  11. :class="reply_score == item.value ? 'font-num' : 'text--w111-999'">{{item.title}}</text>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="bg--w111-fff rd-24rpx mt-20 pt-32 pr-24 pb-32 pl-24">
  16. <view class="flex-y-center pb-40 bb-e">
  17. <image :src="productInfo.attrInfo ? productInfo.attrInfo.image : productInfo.image" class="w-88 h-88 rd-16rpx"></image>
  18. <view class="pl-20 flex-1">
  19. <view class="fs-28 lh-40rpx line1 w-538">{{productInfo.store_name}}</view>
  20. <view class="fs-32 SemiBold mt-12">¥{{productInfo.attrInfo?productInfo.attrInfo.price:productInfo.price}}</view>
  21. </view>
  22. </view>
  23. <view class="pt-40">
  24. <textarea placeholder='商品满足你的期待么?说说你的想法,分享给想买的他们吧~(最多输入100个字)' v-model="comment" name="comment" placeholder-class='placeholder' maxlength='100' class="fs-26 lh-40rpx"></textarea>
  25. <view class="grid-column-4 grid-gap-24rpx">
  26. <view class="relative h-148" v-for="(item,index) in pics" :key="index">
  27. <image :src="item" mode="aspectFill" class="w-148 h-148 rd-16rpx"></image>
  28. <view class="abs-rt w-32 h-32 del-pic flex-center fs-24" @click="DelPic(index)">
  29. <text class="iconfont icon-ic_close fs-24 text--w111-fff"></text>
  30. </view>
  31. </view>
  32. <view class="h-148 flex-col flex-center upload bg--w111-f5f5f5 rd-16rpx"
  33. @click='uploadpic' v-if="pics.length < 8">
  34. <image class="w-48 h-48" src="../static/ic_camera.png"></image>
  35. <text class="fs-24 lh-34rpx pt-8">上传图片</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="bg--w111-fff rd-24rpx mt-20 pt-32 pr-24 pb-32 pl-24">
  41. <view class="flex-y-center">
  42. <text class="fs-28 fw-500">商品质量</text>
  43. <view class="ml-40 flex">
  44. <text class="star iconfont text--w111-999"
  45. :class="item <= product_score ? 'icon-ic_star1 font-num' : 'icon-ic_star'"
  46. v-for="(item, index) in starArr" :key="index" @click="stars(0,item)"></text>
  47. </view>
  48. </view>
  49. <view class="flex-y-center mt-40">
  50. <text class="fs-28 fw-500">服务态度</text>
  51. <view class="ml-40 flex">
  52. <text class="star iconfont text--w111-999"
  53. :class="item <= service_score ? 'icon-ic_star1 font-num' : 'icon-ic_star'"
  54. v-for="(item, index) in starArr" :key="index" @click="stars(1,item)"></text>
  55. </view>
  56. </view>
  57. <!-- delivery_score -->
  58. <view class="flex-y-center mt-40">
  59. <text class="fs-28 fw-500">物流服务</text>
  60. <view class="ml-40 flex">
  61. <text class="star iconfont text--w111-999"
  62. :class="item <= delivery_score ? 'icon-ic_star1 font-num' : 'icon-ic_star'"
  63. v-for="(item, index) in starArr" :key="index" @click="stars(2,item)"></text>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="h-120"></view>
  69. <view class='fixed-lb w-full bg--w111-fff pb-safe'>
  70. <view class="mx-20 h-120 flex-center">
  71. <view class="w-full h-80 rd-40rpx flex-center text--w111-fff fs-28 bg-color"
  72. :class="isSelectStar ? '' : 'opacity-05'"
  73. @tap="formSubmit">提交</view>
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import {orderProduct,orderComment} from '@/api/order.js';
  80. import {toLogin} from '@/libs/login.js';
  81. import {mapGetters} from "vuex";
  82. import colors from "@/mixins/color";
  83. import { HTTP_REQUEST_URL } from '@/config/app';
  84. export default {
  85. components: {},
  86. mixins: [colors],
  87. data() {
  88. return {
  89. imgHost: HTTP_REQUEST_URL,
  90. pics: [],
  91. replyNav:[
  92. {
  93. title:'好评',
  94. pic: HTTP_REQUEST_URL + '/statics/images/product/product_reply_icon1_0.png',
  95. activePic:HTTP_REQUEST_URL + '/statics/images/product/product_reply_icon1.png',
  96. value:3,
  97. },
  98. {
  99. title:'中评',
  100. pic: HTTP_REQUEST_URL + '/statics/images/product/product_reply_icon2_0.png',
  101. activePic: HTTP_REQUEST_URL + '/statics/images/product/product_reply_icon2.png',
  102. value:2,
  103. },
  104. {
  105. title:'差评',
  106. pic: HTTP_REQUEST_URL + '/statics/images/product/product_reply_icon3_0.png',
  107. activePic: HTTP_REQUEST_URL + '/statics/images/product/product_reply_icon3.png',
  108. value:1,
  109. }
  110. ],
  111. orderId: '',
  112. unique: '',
  113. productInfo: {},
  114. cart_num: 0,
  115. isAuto: false, //没有授权的不会自动授权
  116. isShowAuth: false, //是否隐藏授权
  117. canvasWidth: "",
  118. canvasHeight: "",
  119. canvasStatus: false,
  120. product_score:-1,
  121. service_score:-1,
  122. delivery_score: -1,
  123. reply_score:3,
  124. comment:"",
  125. starArr:[1,2,3,4,5]
  126. };
  127. },
  128. watch: {
  129. isLogin: {
  130. handler: function(newV, oldV) {
  131. if (newV) {
  132. // #ifndef MP
  133. this.getOrderProduct();
  134. // #endif
  135. }
  136. },
  137. deep: true
  138. }
  139. },
  140. computed:{
  141. ...mapGetters(['isLogin']),
  142. isSelectStar(){
  143. if(this.product_score >= 0 && this.service_score >= 0 && this.delivery_score >= 0 && this.comment ){
  144. return true
  145. }
  146. }
  147. },
  148. onLoad(options) {
  149. if (!options.unique || !options.uni) return this.$util.Tips({
  150. title: '缺少参数'
  151. }, {
  152. tab: 3,
  153. url: 1
  154. });
  155. this.unique = options.unique;
  156. this.orderId = options.uni;
  157. if (this.isLogin) {
  158. this.getOrderProduct();
  159. }
  160. },
  161. onShow() {
  162. uni.removeStorageSync('form_type_cart');
  163. },
  164. methods: {
  165. /**
  166. * 获取某个产品详情
  167. *
  168. */
  169. getOrderProduct: function() {
  170. let that = this;
  171. orderProduct(that.unique).then(res => {
  172. that.$set(that, 'productInfo', res.data.productInfo);
  173. that.cart_num = res.data.cart_num;
  174. });
  175. },
  176. stars: function(type, star) {
  177. if(type == 0){
  178. this.product_score = star;
  179. }else if(type == 1){
  180. this.service_score = star;
  181. }else {
  182. this.delivery_score = star;
  183. }
  184. },
  185. replyNavChange(value){
  186. this.reply_score = value;
  187. },
  188. /**
  189. * 删除图片
  190. *
  191. */
  192. DelPic: function(index) {
  193. let that = this,
  194. pic = this.pics[index];
  195. that.pics.splice(index, 1);
  196. that.$set(that, 'pics', that.pics);
  197. },
  198. /**
  199. * 上传文件
  200. *
  201. */
  202. uploadpic: function() {
  203. let that = this;
  204. this.canvasStatus = true
  205. that.$util.uploadImageChange({count:8,url:'upload/image'}, function(res) {
  206. that.pics.push(res.data.url);
  207. }, (res) => {
  208. this.canvasStatus = false
  209. }, (res) => {
  210. this.canvasWidth = res.w
  211. this.canvasHeight = res.h
  212. });
  213. },
  214. /**
  215. * 立即评价
  216. */
  217. formSubmit: function() {
  218. let that = this;
  219. if (!this.comment) return that.$util.Tips({
  220. title: '请填写你对宝贝的心得!'
  221. });
  222. if(!this.isSelectStar) return that.$util.Tips({
  223. title: '请完成打分!'
  224. });
  225. let data = {
  226. reply_score: this.reply_score,
  227. product_score: this.product_score,
  228. service_score: this.service_score,
  229. delivery_score: this.delivery_score,
  230. pics: this.pics,
  231. unique: this.unique,
  232. comment: this.comment
  233. };
  234. uni.showLoading({
  235. title: "正在发布评论……"
  236. });
  237. orderComment(data).then(res => {
  238. uni.hideLoading();
  239. let jumpPath = res.data.to_lottery ?
  240. '/pages/goods/goods_comment_con/lottery_comment?type=4&order_id=' + that
  241. .orderId : '/pages/goods/order_details/index?order_id=' + that.orderId
  242. let obj = {
  243. tab: 3,
  244. url: 1
  245. };
  246. let pages = getCurrentPages();
  247. if (pages[pages.length - 3]) {
  248. if (pages[pages.length - 3].route == 'pages/goods/order_pay_status/index') {
  249. obj.tab = 5;
  250. obj.url = '/pages/goods/order_list/index';
  251. }
  252. }
  253. if (res.data.to_lottery) {
  254. obj.tab = 5;
  255. obj.url = '/pages/goods/goods_comment_con/lottery_comment?type=4&order_id=' + that.orderId
  256. }
  257. that.$util.Tips({
  258. title: '感谢您的评价!',
  259. icon: 'success'
  260. }, obj);
  261. }).catch(err => {
  262. uni.hideLoading();
  263. return that.$util.Tips({
  264. title: err
  265. });
  266. });
  267. }
  268. }
  269. }
  270. </script>
  271. <style lang="scss" scoped>
  272. .SemiBold {
  273. font-family: SemiBold;
  274. }
  275. .good-pic{
  276. width: 54rpx;
  277. height: 59rpx;
  278. }
  279. .nav-item ~ .nav-item{
  280. margin-left: 38rpx;
  281. }
  282. .bb-e{
  283. border-bottom: 1px solid #eee;
  284. }
  285. .placeholder{
  286. color: #ccc;
  287. font-size: 26rpx;
  288. line-height: 40rpx;
  289. }
  290. .upload{
  291. border: 1px dashed #ccc;
  292. }
  293. .del-pic{
  294. background-color: #999;
  295. border-radius: 0 16rpx 0 16rpx;
  296. }
  297. .star ~ .star{
  298. margin-left: 24rpx;
  299. }
  300. .bg-hui{
  301. background-color: #ccc;
  302. }
  303. </style>