evaluate.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. import { J_STORAGE_KEY } from '../../config/constant'
  89. const NET = require('../../utils/request')
  90. const API = require('../../config/api')
  91. export default {
  92. data() {
  93. return {
  94. commentData: {},
  95. orderId: 0,
  96. commentStar: 5,
  97. descStar: 5,
  98. logisticsStar: 5,
  99. serviceStar: 5,
  100. fileList: [],
  101. action: API.UploadUrl,
  102. formData: { 'folderId': -1 },
  103. commentText: '',
  104. commentImgsFlag: false,
  105. commentImgs: '',
  106. headerToken: { Authorization: '' }
  107. }
  108. },
  109. onLoad(options) {
  110. if (options.detail) {
  111. const params = this.$getJumpParam(options)
  112. this.commentData = params.commentData
  113. this.orderId = params.orderId
  114. } else {
  115. this.commentData = uni.getStorageSync('evaluateItem')
  116. this.orderId = uni.getStorageSync('orderId')
  117. uni.removeStorageSync('evaluateItem')
  118. uni.removeStorageSync('orderId')
  119. }
  120. const res = uni.getStorageSync(J_STORAGE_KEY)
  121. this.headerToken.Authorization = res.token
  122. },
  123. onReady() {
  124. this.fileList = this.$refs.uUpload.lists
  125. },
  126. methods: {
  127. onCommentStarChange(e) {
  128. this.commentStar = e
  129. },
  130. ondescStarChange(e) {
  131. this.descStar = e
  132. },
  133. onlogisticsStarChange(e) {
  134. this.logisticsStar = e
  135. },
  136. onserviceStarChange(e) {
  137. this.serviceStar = e
  138. },
  139. submitTap() {
  140. if (!this.commentText) {
  141. uni.showToast({
  142. title: '请先说点什么吧',
  143. icon: 'none'
  144. })
  145. return
  146. }
  147. // uni.showLoading({
  148. // mask: true,
  149. // title: '提交中...',
  150. // })
  151. if (this.fileList.length > 0) {
  152. this.commentImgsFlag = true
  153. for (let i = 0; i < this.fileList.length; i++) {
  154. this.commentImgs += this.fileList[i].response.data.url + ','
  155. }
  156. }
  157. const data = [ {
  158. orderId: this.orderId,
  159. skuId: this.commentData.skuId,
  160. productId: this.commentData.productId,
  161. image: this.commentImgs,
  162. comment: this.commentText,
  163. star: this.commentStar,
  164. des: this.descStar,
  165. delivery: this.logisticsStar,
  166. attitude: this.serviceStar
  167. } ]
  168. NET.request(API.Comment, {
  169. params: data
  170. }, 'POST').then((res) => {
  171. uni.hideLoading()
  172. uni.showToast({
  173. title: '评价成功'
  174. })
  175. setTimeout(() => {
  176. uni.redirectTo({
  177. url: '../goodsModule/evaSuccessful'
  178. })
  179. }, 1500)
  180. })
  181. .catch((res) => {
  182. uni.hideLoading()
  183. uni.showToast({
  184. title: res.message
  185. })
  186. })
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss">
  192. page {
  193. background-color: #F7F7F7;
  194. }
  195. .container {
  196. .addEvaluate-box {
  197. margin-top: 20upx;
  198. .addEvaluate {
  199. width: 690upx;
  200. height: auto;
  201. background-color: #FFFFFF;
  202. border-radius: 10upx;
  203. padding-bottom: 30upx;
  204. .addEvaluateTitle-box {
  205. .title-img {
  206. width: 90upx;
  207. height: 90upx;
  208. border-radius: 4upx;
  209. }
  210. .title-textbox {
  211. width: 530upx;
  212. margin-left: 20upx;
  213. }
  214. }
  215. }
  216. .textarea-box {
  217. .textarea-text {
  218. width: 610upx;
  219. height: 200upx;
  220. font-size: 26upx;
  221. padding: 20upx 20upx;
  222. border: 2rpx solid #E4E5E6;
  223. }
  224. }
  225. .addPicture-box {
  226. background-color: #F5F5F5;
  227. width: 150upx;
  228. height: 150upx;
  229. margin-top: 40upx;
  230. margin-left: 20upx;
  231. border-radius: 10upx;
  232. display: flex;
  233. justify-content: center;
  234. align-items: center;
  235. color: #BBBBBB;
  236. .addPicture-icon {
  237. font-size: 100upx;
  238. font-weight: 300;
  239. margin-top: -30upx;
  240. }
  241. .addPicture {
  242. margin-top: -20upx;
  243. }
  244. }
  245. }
  246. .storeEvaluate-box {
  247. margin-top: 20upx;
  248. margin-left: 30upx;
  249. height: 440upx;
  250. .storeEvaluate {
  251. background-color: #FFFFFF;
  252. width: 690upx;
  253. height: 270upx;
  254. border-radius: 10upx;
  255. }
  256. }
  257. .butBox {
  258. position: fixed;
  259. bottom: 20upx;
  260. width: 100%;
  261. .submitbut {
  262. height: 100upx;
  263. width: 690upx;
  264. background: #333333;
  265. color: #FFEBC4;
  266. font-size: 28upx;
  267. text-align: center;
  268. line-height: 100upx;
  269. margin: 0 auto;
  270. }
  271. }
  272. }
  273. </style>
  274. <style scoped>.evaluateImg /deep/ .u-upload .u-list-item {
  275. background: none;
  276. border: 2rpx solid #E4E5E6;
  277. border-radius: 0;
  278. }
  279. .evaluateImg /deep/ .u-upload .u-list-item .uicon-plus:before {
  280. content: '';
  281. height: 71rpx;
  282. width: 71rpx;
  283. background: url("../../static/images/origin/addImg.png") no-repeat center center;
  284. display: block;
  285. background-size: contain;
  286. }</style>