index.vue 7.7 KB

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