evaluate.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view class="container">
  3. <global-loading />
  4. <!-- 评论商品 -->
  5. <view class="addEvaluate-box flex-items-plus flex-column-plus">
  6. <view class="addEvaluate flex-column-plus">
  7. <view class="addEvaluateTitle-box flex-row-plus mar-top-20 mar-left-20">
  8. <image class="title-img" :src="commentData.image"></image>
  9. <view class="title-textbox overflow">
  10. <label class="fs24 title-text">{{ commentData.productName }}</label>
  11. <view class="font-color-999 fs22 mar-top-10">
  12. {{ commentData.value }}
  13. </view>
  14. </view>
  15. </view>
  16. <view class="fs26 mar-top-50 flex-display flex-sp-around">
  17. <label>宝贝描述</label>
  18. <u-rate
  19. v-model="commentStar" size="40" active-color="#C5AA7B" inactive-color="#b2b2b2"
  20. gutter="32"
  21. @change="onCommentStarChange"
  22. ></u-rate>
  23. <label v-if="commentStar < 2" style="width: 80upx;">差</label>
  24. <label v-else-if="commentStar < 4" style="width: 80upx;">好</label>
  25. <label v-else style="width: 80upx;">非常好</label>
  26. </view>
  27. <view class="textarea-box mar-top-40 mar-left-20">
  28. <textarea
  29. v-model="commentText" class="textarea-text" maxlength="200" placeholder-style="color:#BBBBBB"
  30. placeholder="感谢您对宝贝的看法"
  31. />
  32. </view>
  33. <view class="mar-left-10 evaluateImg">
  34. <u-upload
  35. ref="uUpload" :action="action" :limit-type="['png', 'jpg', 'jpeg', 'webp', 'gif', 'image']"
  36. :header="headerToken" :form-data="formData"
  37. ></u-upload>
  38. </view>
  39. <!-- <view class="addPicture-box flex-column-plus">
  40. <label class="addPicture-icon">+</label>
  41. <label class="fs24 addPicture">图片</label>
  42. </view> -->
  43. </view>
  44. </view>
  45. <view class="storeEvaluate-box">
  46. <view class="storeEvaluate flex-start flex-column">
  47. <view class="fs26 mar-top-30 flex-display flex-sp-around">
  48. <label>描述相符</label>
  49. <u-rate
  50. v-model="descStar" size="40" active-color="#C5AA7B" inactive-color="#b2b2b2"
  51. gutter="32"
  52. @change="ondescStarChange"
  53. ></u-rate>
  54. <label v-if="descStar < 2" style="width: 80upx;">差</label>
  55. <label v-else-if="descStar < 4" style="width: 80upx;">好</label>
  56. <label v-else style="width: 80upx;">非常好</label>
  57. </view>
  58. <view class="fs26 mar-top-50 flex-display flex-sp-around">
  59. <label>物流服务</label>
  60. <u-rate
  61. v-model="logisticsStar" size="40" active-color="#C5AA7B" inactive-color="#b2b2b2"
  62. gutter="32"
  63. @click="onlogisticsStarChange"
  64. ></u-rate>
  65. <label v-if="logisticsStar < 2" style="width: 80upx;">差</label>
  66. <label v-else-if="logisticsStar < 4" style="width: 80upx;">好</label>
  67. <label v-else style="width: 80upx;">非常好</label>
  68. </view>
  69. <view class="fs26 mar-top-50 flex-display flex-sp-around">
  70. <label>服务态度</label>
  71. <u-rate
  72. v-model="serviceStar" size="40" active-color="#C5AA7B" inactive-color="#b2b2b2"
  73. gutter="32"
  74. @click="onserviceStarChange"
  75. ></u-rate>
  76. <label v-if="serviceStar < 2" style="width: 80upx;">差</label>
  77. <label v-else-if="serviceStar < 4" style="width: 80upx;">好</label>
  78. <label v-else style="width: 80upx;">非常好</label>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="butBox flex-items-plus">
  83. <view class="submitbut" @click="submitTap">发表评论</view>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. const NET = require('../../utils/request')
  89. const API = require('../../config/api')
  90. export default {
  91. data() {
  92. return {
  93. commentData: {},
  94. orderId: 0,
  95. commentStar: 5,
  96. descStar: 5,
  97. logisticsStar: 5,
  98. serviceStar: 5,
  99. fileList: [],
  100. action: API.UploadUrl,
  101. formData: { 'folderId': -1 },
  102. commentText: '',
  103. commentImgsFlag: false,
  104. commentImgs: '',
  105. headerToken: { Authorization: '' }
  106. }
  107. },
  108. onLoad(options) {
  109. if (options.detail) {
  110. const params = this.$getJumpParam(options)
  111. this.commentData = params.commentData
  112. this.orderId = params.orderId
  113. } else {
  114. this.commentData = uni.getStorageSync('evaluateItem')
  115. this.orderId = uni.getStorageSync('orderId')
  116. uni.removeStorageSync('evaluateItem')
  117. uni.removeStorageSync('orderId')
  118. }
  119. const res = uni.getStorageSync('storage_key')
  120. this.headerToken.Authorization = res.token
  121. },
  122. onReady() {
  123. this.fileList = this.$refs.uUpload.lists
  124. },
  125. methods: {
  126. onCommentStarChange(e) {
  127. this.commentStar = e
  128. },
  129. ondescStarChange(e) {
  130. this.descStar = e
  131. },
  132. onlogisticsStarChange(e) {
  133. this.logisticsStar = e
  134. },
  135. onserviceStarChange(e) {
  136. this.serviceStar = e
  137. },
  138. submitTap() {
  139. if (!this.commentText) {
  140. uni.showToast({
  141. title: '请先说点什么吧',
  142. icon: 'none'
  143. })
  144. return
  145. }
  146. // uni.showLoading({
  147. // mask: true,
  148. // title: '提交中...',
  149. // })
  150. if (this.fileList.length > 0) {
  151. this.commentImgsFlag = true
  152. for (let i = 0; i < this.fileList.length; i++) {
  153. this.commentImgs += this.fileList[i].response.data.url + ','
  154. }
  155. }
  156. const data = [ {
  157. orderId: this.orderId,
  158. skuId: this.commentData.skuId,
  159. productId: this.commentData.productId,
  160. image: this.commentImgs,
  161. comment: this.commentText,
  162. star: this.commentStar,
  163. des: this.descStar,
  164. delivery: this.logisticsStar,
  165. attitude: this.serviceStar
  166. } ]
  167. NET.request(API.Comment, {
  168. params: data
  169. }, 'POST').then((res) => {
  170. uni.hideLoading()
  171. uni.showToast({
  172. title: '评价成功'
  173. })
  174. setTimeout(() => {
  175. uni.redirectTo({
  176. url: '../goodsModule/evaSuccessful'
  177. })
  178. }, 1500)
  179. })
  180. .catch((res) => {
  181. uni.hideLoading()
  182. uni.showToast({
  183. title: res.message
  184. })
  185. })
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss">
  191. page {
  192. background-color: #F7F7F7;
  193. }
  194. .container {
  195. .addEvaluate-box {
  196. margin-top: 20upx;
  197. .addEvaluate {
  198. width: 690upx;
  199. height: auto;
  200. background-color: #FFFFFF;
  201. border-radius: 10upx;
  202. padding-bottom: 30upx;
  203. .addEvaluateTitle-box {
  204. .title-img {
  205. width: 90upx;
  206. height: 90upx;
  207. border-radius: 4upx;
  208. }
  209. .title-textbox {
  210. width: 530upx;
  211. margin-left: 20upx;
  212. }
  213. }
  214. }
  215. .textarea-box {
  216. .textarea-text {
  217. width: 610upx;
  218. height: 200upx;
  219. font-size: 26upx;
  220. padding: 20upx 20upx;
  221. border: 2rpx solid #E4E5E6;
  222. }
  223. }
  224. .addPicture-box {
  225. background-color: #F5F5F5;
  226. width: 150upx;
  227. height: 150upx;
  228. margin-top: 40upx;
  229. margin-left: 20upx;
  230. border-radius: 10upx;
  231. display: flex;
  232. justify-content: center;
  233. align-items: center;
  234. color: #BBBBBB;
  235. .addPicture-icon {
  236. font-size: 100upx;
  237. font-weight: 300;
  238. margin-top: -30upx;
  239. }
  240. .addPicture {
  241. margin-top: -20upx;
  242. }
  243. }
  244. }
  245. .storeEvaluate-box {
  246. margin-top: 20upx;
  247. margin-left: 30upx;
  248. height: 440upx;
  249. .storeEvaluate {
  250. background-color: #FFFFFF;
  251. width: 690upx;
  252. height: 270upx;
  253. border-radius: 10upx;
  254. }
  255. }
  256. .butBox {
  257. position: fixed;
  258. bottom: 20upx;
  259. width: 100%;
  260. .submitbut {
  261. height: 100upx;
  262. width: 690upx;
  263. background: #333333;
  264. color: #FFEBC4;
  265. font-size: 28upx;
  266. text-align: center;
  267. line-height: 100upx;
  268. margin: 0 auto;
  269. }
  270. }
  271. }
  272. </style>
  273. <style scoped>.evaluateImg /deep/ .u-upload .u-list-item {
  274. background: none;
  275. border: 2rpx solid #E4E5E6;
  276. border-radius: 0;
  277. }
  278. .evaluateImg /deep/ .u-upload .u-list-item .uicon-plus:before {
  279. content: '';
  280. height: 71rpx;
  281. width: 71rpx;
  282. background: url("../../static/images/origin/addImg.png") no-repeat center center;
  283. display: block;
  284. background-size: contain;
  285. }</style>