index.vue 7.8 KB

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