index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="container">
  3. <JHeader title="评价" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  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="common.seamingImgUrl(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. <tui-rate :current="commentStar" :size="20" normal="#b2b2b2" active="#C5AA7B" @change="onCommentStarChange"></tui-rate>
  19. <label v-if="commentStar < 2" style="width: 80upx;">差</label>
  20. <label v-else-if="commentStar < 4" style="width: 80upx;">好</label>
  21. <label v-else style="width: 80upx;">非常好</label>
  22. </view>
  23. <view class="textarea-box mar-top-40 mar-left-20">
  24. <textarea
  25. v-model="commentText" class="textarea-text" maxlength="200" placeholder-style="color:#BBBBBB"
  26. placeholder="感谢您对宝贝的看法"
  27. />
  28. </view>
  29. <view class="mar-left-10 evaluateImg">
  30. <ATFMoreUpload
  31. :imgs="fileList"
  32. @upload="handleSaveImg" @delete="handleDeleteImg"
  33. ></ATFMoreUpload>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="storeEvaluate-box">
  38. <view class="storeEvaluate flex-start flex-column">
  39. <view class="fs26 mar-top-30 flex-display flex-sp-around">
  40. <label>描述相符</label>
  41. <tui-rate :current="descStar" :size="20" normal="#b2b2b2" active="#C5AA7B" @change="ondescStarChange"></tui-rate>
  42. <label v-if="descStar < 2" style="width: 80upx;">差</label>
  43. <label v-else-if="descStar < 4" style="width: 80upx;">好</label>
  44. <label v-else style="width: 80upx;">非常好</label>
  45. </view>
  46. <view class="fs26 mar-top-50 flex-display flex-sp-around">
  47. <label>物流服务</label>
  48. <tui-rate :current="logisticsStar" :size="20" normal="#b2b2b2" active="#C5AA7B" @change="onlogisticsStarChange"></tui-rate>
  49. <label v-if="logisticsStar < 2" style="width: 80upx;">差</label>
  50. <label v-else-if="logisticsStar < 4" style="width: 80upx;">好</label>
  51. <label v-else style="width: 80upx;">非常好</label>
  52. </view>
  53. <view class="fs26 mar-top-50 flex-display flex-sp-around">
  54. <label>服务态度</label>
  55. <tui-rate :current="serviceStar" :size="20" normal="#b2b2b2" active="#C5AA7B" @change="onserviceStarChange"></tui-rate>
  56. <label v-if="serviceStar < 2" style="width: 80upx;">差</label>
  57. <label v-else-if="serviceStar < 4" style="width: 80upx;">好</label>
  58. <label v-else style="width: 80upx;">非常好</label>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="butBox flex-items-plus">
  63. <view class="submitbut" @click="submitTap">发表评论</view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import { addCommentOrderApi, getOrderDetailApi } from '../../../api/anotherTFInterface'
  69. export default {
  70. name: 'Evaluate',
  71. data() {
  72. return {
  73. commentData: {},
  74. orderId: 0,
  75. skuId: 0,
  76. commentStar: 5,
  77. descStar: 5,
  78. logisticsStar: 5,
  79. serviceStar: 5,
  80. fileList: [],
  81. commentText: '',
  82. commentImgsFlag: false,
  83. commentImgs: ''
  84. }
  85. },
  86. onLoad(options) {
  87. this.orderId = Number(options.orderId)
  88. this.skuId = Number(options.skuId)
  89. getOrderDetailApi({
  90. orderId: this.orderId,
  91. noticeId: 0
  92. }).then((res) => {
  93. this.commentData = res.data.skus.find((item) => item.skuId === this.skuId) || {}
  94. })
  95. },
  96. methods: {
  97. handleSaveImg(imgUrl) {
  98. this.fileList.push(imgUrl)
  99. this.$forceUpdate()
  100. },
  101. handleDeleteImg(imgUrl) {
  102. this.fileList.splice(this.fileList.findIndex((item) => item === imgUrl), 1)
  103. this.$forceUpdate()
  104. },
  105. onCommentStarChange(e) {
  106. this.commentStar = e.index
  107. },
  108. ondescStarChange(e) {
  109. this.descStar = e.index
  110. },
  111. onlogisticsStarChange(e) {
  112. this.logisticsStar = e.index
  113. },
  114. onserviceStarChange(e) {
  115. this.serviceStar = e.index
  116. },
  117. submitTap() {
  118. if (!this.commentText) {
  119. uni.showToast({
  120. title: '请先说点什么吧',
  121. icon: 'none'
  122. })
  123. return
  124. }
  125. uni.showLoading({
  126. mask: true,
  127. title: '提交中...'
  128. })
  129. if (this.fileList.length > 0) {
  130. this.commentImgsFlag = true
  131. for (let i = 0; i < this.fileList.length; i++) {
  132. this.commentImgs += this.fileList[i].response.data.url + ','
  133. }
  134. }
  135. const data = [ {
  136. orderId: this.orderId,
  137. skuId: this.commentData.skuId,
  138. productId: this.commentData.productId,
  139. image: this.commentImgs,
  140. comment: this.commentText,
  141. star: this.commentStar,
  142. des: this.descStar,
  143. delivery: this.logisticsStar,
  144. attitude: this.serviceStar
  145. } ]
  146. addCommentOrderApi({
  147. params: data
  148. }).then((res) => {
  149. uni.hideLoading()
  150. uni.showToast({
  151. title: '评价成功'
  152. })
  153. setTimeout(() => {
  154. uni.redirectTo({
  155. url: '/another-tf/another-serve/evaSuccessful/index'
  156. })
  157. }, 1500)
  158. })
  159. .catch((e) => {
  160. uni.hideLoading()
  161. uni.showToast({
  162. title: e.message
  163. })
  164. })
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="less" scoped>
  170. .container {
  171. min-height: 100vh;
  172. background-color: #F7F7F7;
  173. box-sizing: border-box;
  174. .addEvaluate-box {
  175. margin-top: 20upx;
  176. .addEvaluate {
  177. width: 690upx;
  178. height: auto;
  179. background-color: #FFFFFF;
  180. border-radius: 10upx;
  181. padding-bottom: 30upx;
  182. .addEvaluateTitle-box {
  183. .title-img {
  184. width: 90upx;
  185. height: 90upx;
  186. border-radius: 4upx;
  187. }
  188. .title-textbox {
  189. width: 530upx;
  190. margin-left: 20upx;
  191. }
  192. }
  193. }
  194. .textarea-box {
  195. .textarea-text {
  196. width: 610upx;
  197. height: 200upx;
  198. font-size: 26upx;
  199. padding: 20upx 20upx;
  200. border: 2rpx solid #E4E5E6;
  201. }
  202. }
  203. }
  204. .storeEvaluate-box {
  205. margin-top: 20upx;
  206. margin-left: 30upx;
  207. height: 440upx;
  208. .storeEvaluate {
  209. background-color: #FFFFFF;
  210. width: 690upx;
  211. height: 270upx;
  212. border-radius: 10upx;
  213. }
  214. }
  215. .butBox {
  216. position: fixed;
  217. bottom: 20upx;
  218. width: 100%;
  219. .submitbut {
  220. height: 100upx;
  221. width: 690upx;
  222. background: #333333;
  223. color: #FFEBC4;
  224. font-size: 28upx;
  225. text-align: center;
  226. line-height: 100upx;
  227. margin: 0 auto;
  228. }
  229. }
  230. }
  231. </style>