index.vue 7.3 KB

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