多租户商城-商户小程序端
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.

269 lines
7.5 KiB

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