index.vue 8.0 KB

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