evaluate.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="container">
  3. <u-navbar title="评价" leftIconColor="#ffffff" titleStyle="color:#fff" :autoBack="true" placeholder></u-navbar>
  4. <view class="box flex-center">
  5. <image :src="details.productCover" class="img" mode="" />
  6. <view class="box_text">{{details.productTitle}}</view>
  7. </view>
  8. <view class="box">
  9. <view class="item">
  10. <view class="item_t">
  11. <view class="item_t_lab">评分</view>
  12. <view>
  13. <star :value="details.commentScore" @change="starChange" />
  14. </view>
  15. </view>
  16. <view class="item_b">
  17. <u-textarea v-model="details.comment" placeholder="说点什么吧..." placeholderStyle="color:#cccccc;font-size:28rpx" maxlength="500" count="500"></u-textarea>
  18. </view>
  19. </view>
  20. <view class="item">
  21. <view class="item_t">
  22. <view class="item_t_lab">产品图片 {{details.commentImagesCopy.length}}<text>/3</text> </view>
  23. </view>
  24. <view class="item_b" style="padding-left:0;">
  25. <u-upload :fileList="details.commentImagesCopy" file="image" :multiple="false" :maxCount="3" @afterRead="afterRead" @delete="deletePic" name="upload1" width="75" height="75">
  26. <view class="upload">
  27. <image src="https://guess-shop.oss-cn-beijing.aliyuncs.com/static/online/img45.png" mode="" />
  28. </view>
  29. </u-upload>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="btnBox">
  34. <view class="red" @click="submit()">发布</view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { shoporderComment } from "@/api/giftPackageCenter"
  40. import { storage } from "@/utils/tools.js"
  41. import star from "@/components/star/index.vue"
  42. export default {
  43. components: {
  44. star
  45. },
  46. data () {
  47. return {
  48. value: "",
  49. fileList: [],
  50. details: {
  51. orderId: undefined,
  52. productTitle: undefined,
  53. productCover: undefined,
  54. productId: undefined,
  55. comment: '',
  56. commentScore: 0,
  57. commentImagesCopy: []
  58. }
  59. }
  60. },
  61. onLoad (options) {
  62. if (options.orderId && options.productTitle && options.productCover && options.productId) {
  63. console.log(options)
  64. this.details.orderId = options.orderId;
  65. this.details.productTitle = options.productTitle;
  66. this.details.productCover = options.productCover;
  67. this.details.productId = options.productId;
  68. }
  69. },
  70. methods: {
  71. afterRead (e) {
  72. console.log(e)
  73. uni.showLoading({
  74. title: '上传中',
  75. });
  76. uni.uploadFile({
  77. url: uni.$u.http.config.baseURL + '/common/upload',
  78. filePath: e.file.url,
  79. name: 'file',
  80. header: {
  81. apiToken: storage.get('apiToken')
  82. },
  83. success: (res) => {
  84. uni.hideLoading();
  85. let data = JSON.parse(res.data);
  86. if (data.code != 200) return
  87. this.details.commentImagesCopy.push(data.data)
  88. uni.showToast({
  89. title: '上传成功',
  90. icon: 'success',
  91. duration: 1000
  92. })
  93. },
  94. fail: (err) => {
  95. console.log(err);
  96. uni.hideLoading();
  97. uni.showModal({
  98. content: err.errMsg,
  99. showCancel: false
  100. });
  101. }
  102. });
  103. },
  104. deletePic (e) {
  105. this.details.commentImagesCopy.splice(e.index, 1);
  106. },
  107. starChange (e) {
  108. this.details.commentScore = e;
  109. },
  110. submit () {
  111. if (!this.details.commentScore) {
  112. uni.$u.toast('请选择评分');
  113. return
  114. } else if (!this.details.comment) {
  115. uni.$u.toast('请输入评分内容');
  116. return
  117. }
  118. this.details.commentImages = this.details.commentImagesCopy.map((v) => {
  119. return v.url;
  120. });
  121. console.log(this.details)
  122. shoporderComment(this.details).then(res => {
  123. uni.showToast({
  124. title: '评价成功!',
  125. duration: 2000
  126. });
  127. setTimeout(() => {
  128. uni.navigateBack()
  129. }, 1500)
  130. })
  131. }
  132. },
  133. }
  134. </script>
  135. <style lang='scss' scoped>
  136. ::v-deep .u-navbar__content,
  137. ::v-deep .u-status-bar {
  138. background-color: #c90700 !important;
  139. }
  140. .container {
  141. background: #f8f8f8;
  142. min-height: 100vh;
  143. padding: 30rpx;
  144. padding-bottom: 150rpx;
  145. .box {
  146. background: #ffffff;
  147. border-radius: 30rpx;
  148. padding: 37rpx 20rpx;
  149. margin-bottom: 30rpx;
  150. > image {
  151. width: 144rpx;
  152. height: 144rpx;
  153. border-radius: 12rpx;
  154. margin-right: 24rpx;
  155. flex-shrink: 0;
  156. }
  157. > .box_text {
  158. font-size: 28rpx;
  159. color: #1a1a1a;
  160. line-height: 42rpx;
  161. overflow: hidden;
  162. text-overflow: ellipsis;
  163. display: -webkit-box;
  164. -webkit-line-clamp: 2;
  165. -webkit-box-orient: vertical;
  166. }
  167. .item {
  168. width: 100%;
  169. margin-bottom: 40rpx;
  170. .item_t {
  171. display: flex;
  172. .item_t_lab {
  173. font-size: 28rpx;
  174. color: #1a1a1a;
  175. font-family: FZCuYuan-M03;
  176. margin-right: 25rpx;
  177. text {
  178. font-size: 22rpx;
  179. color: #808080;
  180. }
  181. }
  182. }
  183. .item_b {
  184. padding-left: 75rpx;
  185. margin-top: 15rpx;
  186. ::v-deep .u-textarea {
  187. background: #f7f7f7;
  188. margin-top: 10rpx;
  189. }
  190. ::v-deep .u-textarea__count {
  191. background: #f7f7f7 !important;
  192. }
  193. .upload {
  194. width: 146rpx;
  195. height: 146rpx;
  196. border-radius: 14rpx;
  197. text-align: center;
  198. line-height: 155rpx;
  199. border: 1rpx dashed #cbcbcb;
  200. background: #fcfcfc;
  201. text {
  202. color: #cbcbcb;
  203. }
  204. image {
  205. width: 51rpx;
  206. height: 36rpx;
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. .btnBox {
  214. width: 100%;
  215. background: #ffffff;
  216. padding: 45rpx 50rpx 33rpx;
  217. box-sizing: border-box;
  218. border-top: 1rpx solid #e7e7e7;
  219. position: fixed;
  220. left: 0;
  221. bottom: 0;
  222. > view {
  223. height: 80rpx;
  224. background: #fb0b03;
  225. border-radius: 40rpx;
  226. text-align: center;
  227. line-height: 80rpx;
  228. font-size: 32rpx;
  229. color: #ffffff;
  230. }
  231. }
  232. .flex-center {
  233. display: flex;
  234. align-items: center;
  235. }
  236. ::v-deep .placeholderClass {
  237. font-family: FZZhunYuan-M02S;
  238. font-size: 28rpx;
  239. color: #cccccc;
  240. }
  241. </style>