You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

312 lines
7.5 KiB

3 months ago
  1. <template>
  2. <view :data-theme="theme">
  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 font_sm' 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. </view>
  46. </template>
  47. <script>
  48. import {
  49. orderProduct,
  50. orderComment
  51. } from '@/api/order.js';
  52. import {toLogin} from '@/libs/login.js';
  53. import {mapGetters} from "vuex";
  54. let app = getApp();
  55. export default {
  56. data() {
  57. return {
  58. pics: [],
  59. picsPath: [],
  60. scoreList: [{
  61. name: "商品质量",
  62. stars: ["", "", "", "", ""],
  63. index: -1
  64. },
  65. {
  66. name: "服务态度",
  67. stars: ["", "", "", "", ""],
  68. index: -1
  69. }
  70. ],
  71. orderId: '',
  72. productId: 0, //产品id
  73. evaluateId: 0, //评价id
  74. unique: '',
  75. productInfo: {storeName:'',sku:'',truePrice:'',cartNum:'',image:''},
  76. cart_num: 0,
  77. id: 0 ,//订单id
  78. theme:app.globalData.theme,
  79. };
  80. },
  81. computed: mapGetters(['isLogin']),
  82. watch: {
  83. isLogin: {
  84. handler: function(newV, oldV) {
  85. if (newV) {
  86. this.getOrderProduct();
  87. }
  88. },
  89. deep: true
  90. }
  91. },
  92. onLoad(options) {
  93. if (!options.unique || !options.orderId ) return this.$util.Tips({
  94. title: '缺少参数'
  95. }, {
  96. tab: 3,
  97. url: 1
  98. });
  99. this.unique = Number(options.unique) || 0;
  100. this.orderId = options.orderId || 0;
  101. this.evaluateId = Number(options.id) || 0;
  102. if (this.isLogin) {
  103. this.getOrderProduct();
  104. } else {
  105. toLogin();
  106. }
  107. },
  108. methods: {
  109. /**
  110. * 获取某个产品详情
  111. *
  112. */
  113. getOrderProduct: function() {
  114. let that = this;
  115. orderProduct({
  116. orderId: that.evaluateId,
  117. uni: that.unique
  118. }).then(res => {
  119. that.$set(that, 'productInfo', res.data);
  120. // that.$set(that, 'cart_num', res.data.cartNum);
  121. // that.$set(that, 'productId', res.data.productId);
  122. });
  123. },
  124. stars: function(indexn, indexw) {
  125. this.scoreList[indexw].index = indexn;
  126. },
  127. /**
  128. * 删除图片
  129. *
  130. */
  131. DelPic: function(index) {
  132. let that = this,
  133. pic = this.picsPath[index];
  134. that.picsPath.splice(index, 1);
  135. that.pics.splice(index, 1);
  136. },
  137. /**
  138. * 上传文件
  139. *
  140. */
  141. uploadpic: function() {
  142. let that = this;
  143. that.$util.uploadImageOne({
  144. url: 'upload/image',
  145. name: 'multipart',
  146. model: "product",
  147. pid: 1
  148. }, function(res) {
  149. that.pics.push(res.data.url);
  150. that.picsPath.push(res.data.localPath);
  151. that.$set(that, 'pics', that.pics);
  152. that.$set(that, 'picsPath', that.picsPath);
  153. });
  154. },
  155. /**
  156. * 立即评价
  157. */
  158. formSubmit: function(e) {
  159. let formId = e.detail.formId,
  160. value = e.detail.value,
  161. that = this,
  162. product_score = that.scoreList[0].index + 1 === 0 ? "" : that.scoreList[0].index + 1,
  163. service_score = that.scoreList[1].index + 1 === 0 ? "" : that.scoreList[1].index + 1;
  164. if (!value.comment) return that.$util.Tips({
  165. title: '请填写你对宝贝的心得!'
  166. });
  167. value.productScore = product_score;
  168. value.serviceScore = service_score;
  169. value.pics = that.pics.length>0?JSON.stringify(that.pics):'';
  170. value.productId = that.productInfo.productId;
  171. value.orderNo = that.orderId;
  172. value.unique = that.unique;
  173. value.sku = that.productInfo.sku;
  174. uni.showLoading({
  175. title: "正在发布评论……"
  176. });
  177. orderComment(value).then(res => {
  178. uni.hideLoading();
  179. return that.$util.Tips({
  180. title: '感谢您的评价!',
  181. icon: 'success'
  182. }, '/pages/order/order_details/index?order_id=' + that.orderId);
  183. }).catch(err => {
  184. uni.hideLoading();
  185. return that.$util.Tips({
  186. title: err
  187. });
  188. });
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. .goodsStyle .text .name, .attr{
  195. //width: 496rpx;
  196. }
  197. .font_sm{
  198. width: 360rpx;
  199. font-size: 24rpx;
  200. color: #999;
  201. padding-top: 10rpx;
  202. }
  203. .icon-shitixing{
  204. color: #FFBB00 !important;
  205. }
  206. .evaluate-con .score {
  207. background-color: #fff;
  208. // border-top: 1rpx solid #f5f5f5;
  209. margin-top: 20rpx;
  210. font-size: 28rpx;
  211. color: #282828;
  212. padding: 46rpx 24rpx;
  213. }
  214. .evaluate-con .score .item~.item {
  215. margin-top: 36rpx;
  216. }
  217. .evaluate-con .score .item .starsList {
  218. padding: 0 35rpx 0 40rpx;
  219. }
  220. .evaluate-con .score .item .starsList .iconfont {
  221. font-size: 40rpx;
  222. color: #aaa;
  223. }
  224. .evaluate-con .score .item .starsList .iconfont~.iconfont {
  225. margin-left: 20rpx;
  226. }
  227. .evaluate-con .score .item .evaluate {
  228. color: #aaa;
  229. font-size: 24rpx;
  230. }
  231. .evaluate-con .score .textarea {
  232. width: 100%;
  233. background-color: #F5F5F5;
  234. border-radius: 14rpx;
  235. margin-top: 55rpx;
  236. }
  237. .evaluate-con .score .textarea textarea {
  238. font-size: 28rpx;
  239. padding: 38rpx 30rpx 0 30rpx;
  240. width: 100%;
  241. box-sizing: border-box;
  242. height: 160rpx;
  243. width: auto !important;
  244. }
  245. .evaluate-con .score .textarea .placeholder {
  246. color: #bbb;
  247. }
  248. .evaluate-con .score .textarea .list {
  249. margin-top: 25rpx;
  250. padding-left: 5rpx;
  251. }
  252. .evaluate-con .score .textarea .list .pictrue {
  253. width: 140rpx;
  254. height: 140rpx;
  255. margin: 0 0 35rpx 25rpx;
  256. position: relative;
  257. font-size: 22rpx;
  258. color: #bbb;
  259. border-radius: 14rpx;
  260. }
  261. .evaluate-con .score .textarea .list .pictrue:nth-last-child(1) {
  262. border: 1rpx solid #ddd;
  263. box-sizing: border-box;
  264. }
  265. .evaluate-con .score .textarea .list .pictrue image {
  266. width: 100%;
  267. height: 100%;
  268. border-radius: 14rpx;
  269. }
  270. .evaluate-con .score .textarea .list .pictrue .icon-guanbi1 {
  271. font-size: 45rpx;
  272. position: absolute;
  273. top: -20rpx;
  274. right: -20rpx;
  275. }
  276. .evaluate-con .score .textarea .list .pictrue .icon-icon25201 {
  277. color: #bfbfbf;
  278. font-size: 50rpx;
  279. }
  280. .evaluate-con .score .evaluateBnt {
  281. font-size: 30rpx;
  282. color: #fff;
  283. width: 100%;
  284. height: 86rpx;
  285. border-radius: 43rpx;
  286. text-align: center;
  287. line-height: 86rpx;
  288. margin-top: 45rpx;
  289. }
  290. .bg_color{
  291. @include main_bg_color(theme);
  292. }
  293. </style>