addEvaluate.vue 5.5 KB

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