addEvaluate.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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="productImage"></image>
  9. <view class="title-textbox overflow">
  10. <label class="fs28 title-text">{{ orderProductVO.productName }}</label>
  11. <view v-if="orderProductVO.value" class="fs24 mar-top-10 sukValue">
  12. {{ orderProductVO.value }}
  13. </view>
  14. <view v-else class="font-color-999 fs24 mar-top-10">
  15. 默认规格
  16. </view>
  17. </view>
  18. </view>
  19. <view class="fs26 mar-top-40 mar-left-20 addEvaluateText">追加评价</view>
  20. <view class="textarea-box mar-top-20 mar-left-20">
  21. <textarea
  22. v-model="commentText" class="textarea-text" maxlength="200" placeholder-style="color:#BBBBBB"
  23. placeholder="亲,有什么需要追加的吗"
  24. />
  25. </view>
  26. <view class="mar-left-10 mar-top-10 evaluateImg">
  27. <u-upload
  28. ref="uUpload" :action="action" :limit-type="['png', 'jpg', 'jpeg', 'webp', 'gif', 'image']"
  29. :header="headerToken" :form-data="formData"
  30. ></u-upload>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="butBox flex-items-plus mar-left-30">
  35. <view class="submitbut" @click="submitTap">追加评论</view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import { J_STORAGE_KEY } from '../../config/constant'
  41. const NET = require('../../utils/request')
  42. const API = require('../../config/api')
  43. export default {
  44. data() {
  45. return {
  46. addCommentVOList: {},
  47. orderProductVO: {},
  48. commentText: '',
  49. fileList: [],
  50. commentImgsFlag: false,
  51. commentImgs: '',
  52. action: API.UploadUrl,
  53. formData: { 'folderId': -1 },
  54. headerToken: { Authorization: '' },
  55. productImage: '',
  56. type: 0
  57. }
  58. },
  59. onLoad(options) {
  60. this.type = options.type
  61. if (options.detail) {
  62. const params = this.$getJumpParam(options)
  63. this.addCommentVOList = params.addCommentVOList
  64. this.orderProductVO = params.type === 1 ? this.addCommentVOList.skus[0] : this.addCommentVOList
  65. this.productImage = this.orderProductVO.image
  66. } else {
  67. if (options.type == 1) {
  68. this.addCommentVOList = uni.getStorageSync('addCommentVOList')
  69. this.orderProductVO = this.addCommentVOList.skus[0]
  70. this.productImage = this.orderProductVO.image
  71. } else {
  72. this.addCommentVOList = uni.getStorageSync('addCommentVOList')
  73. this.orderProductVO = this.addCommentVOList
  74. this.productImage = this.orderProductVO.productImage
  75. }
  76. uni.removeStorageSync('addCommentVOList')
  77. }
  78. if (options.commentId) {
  79. this.commentId = options.commentId
  80. }
  81. const res = uni.getStorageSync(J_STORAGE_KEY)
  82. this.headerToken.Authorization = res.token
  83. },
  84. onReady() {
  85. this.fileList = this.$refs.uUpload.lists
  86. },
  87. methods: {
  88. submitTap() {
  89. if (!this.commentText) {
  90. uni.showToast({
  91. title: '请先说点什么吧',
  92. icon: 'none'
  93. })
  94. return
  95. }
  96. // uni.showLoading({
  97. // title: '提交中...',
  98. // })
  99. if (this.fileList.length > 0) {
  100. this.commentImgsFlag = true
  101. for (let i = 0; i < this.fileList.length; i++) {
  102. this.commentImgs += this.fileList[i].response.data.url + ','
  103. }
  104. }
  105. let data = []
  106. if (this.type == 1) {
  107. data = [ {
  108. commentId: this.commentId,
  109. image: this.commentImgs,
  110. comment: this.commentText
  111. } ]
  112. } else if (this.type == 2) {
  113. data = [ {
  114. commentId: this.addCommentVOList.commentId,
  115. image: this.commentImgs,
  116. comment: this.commentText
  117. } ]
  118. }
  119. NET.request(API.AdditionalComment, { params: data }, 'POST').then((res) => {
  120. uni.hideLoading()
  121. uni.showToast({
  122. title: '追评成功'
  123. })
  124. setTimeout(() => {
  125. uni.redirectTo({
  126. url: 'userEvaluate'
  127. })
  128. }, 1500)
  129. })
  130. .catch((res) => {
  131. uni.hideLoading()
  132. uni.showToast({
  133. title: res.message
  134. })
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss">
  141. page {
  142. background-color: #F7F7F7;
  143. }
  144. .container {
  145. .addEvaluate-box {
  146. margin-top: 20upx;
  147. .addEvaluate {
  148. width: 690upx;
  149. background-color: #FFFFFF;
  150. border-radius: 10upx;
  151. padding-bottom: 30upx;
  152. .addEvaluateText {
  153. font-weight: bold;
  154. }
  155. .addEvaluateTitle-box {
  156. .title-img {
  157. width: 90upx;
  158. height: 90upx;
  159. border-radius: 4upx;
  160. }
  161. .title-textbox {
  162. width: 530upx;
  163. margin-left: 20upx;
  164. font-weight: bold;
  165. .sukValue {
  166. color: #CCCCCC;
  167. font-weight: 400;
  168. }
  169. }
  170. }
  171. }
  172. .textarea-box {
  173. .textarea-text {
  174. width: 610upx;
  175. height: 200upx;
  176. background-color: #FFFFFF;
  177. font-size: 26upx;
  178. padding: 20upx 20upx;
  179. border: 2rpx solid #E4E5E6;
  180. }
  181. }
  182. .addPicture-box {
  183. background-color: #F5F5F5;
  184. width: 40upx;
  185. height: 40upx;
  186. margin-top: 100upx;
  187. margin-left: 100upx;
  188. border-radius: 10upx;
  189. display: flex;
  190. justify-content: center;
  191. align-items: center;
  192. color: #BBBBBB;
  193. }
  194. }
  195. .butBox {
  196. position: absolute;
  197. bottom: 40upx;
  198. .submitbut {
  199. height: 100upx;
  200. width: 690upx;
  201. background: #333333;
  202. color: #FFEBC4;
  203. font-size: 28upx;
  204. text-align: center;
  205. line-height: 100upx;
  206. }
  207. }
  208. }
  209. </style>
  210. <style scoped>
  211. .evaluateImg /deep/ .u-upload .u-list-item {
  212. background: none;
  213. border: 2rpx solid #E4E5E6;
  214. border-radius: 0;
  215. }
  216. .evaluateImg /deep/ .u-upload .u-list-item .uicon-plus:before {
  217. content: '';
  218. height: 71rpx;
  219. width: 71rpx;
  220. background: url("../../static/images/origin/addImg.png") no-repeat center center;
  221. display: block;
  222. background-size: contain;
  223. }
  224. </style>