index.vue 7.6 KB

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