evaluate.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="page-wrap">
  3. <u-navbar
  4. title="发表评价"
  5. :autoBack="true"
  6. :safeAreaInsetTop="true"
  7. >
  8. </u-navbar>
  9. <view class="product u-flex" v-for="(item,index) in orderDetails.detailList" :key="item.id">
  10. <u--image :showLoading="true" :src="item.mainImg" width="180rpx" height="180rpx"></u--image>
  11. <view class="text">
  12. <view class="up">
  13. <view class="name ellipsis-2">{{item.goodsName}}</view>
  14. <view class="info">
  15. {{item.specification}}
  16. {{item.unit}}
  17. </view>
  18. </view>
  19. <!-- <view class="down u-flex u-row-between">
  20. <view class="left">
  21. <text class="price">¥ <text class="price-num">{{item.price}}</text></text>
  22. </view>
  23. </view> -->
  24. </view>
  25. </view>
  26. <view class="rate-wrap u-flex">
  27. <text class="rate-title">商品评价</text>
  28. <u-rate count="5" v-model="params.rate" active-color="#FFBE00" size="20"></u-rate>
  29. <text class="rate-text">{{params.rate|rateText}}</text>
  30. </view>
  31. <u--textarea v-model="params.content" height="200rpx" maxlength="200" placeholder="如实描述商品和使用感受,更受欢迎" ></u--textarea>
  32. <view class="upload-wrap">
  33. <u-upload
  34. width="140rpx"
  35. height="140rpx"
  36. :fileList="fileList"
  37. @afterRead="afterRead"
  38. @delete="deletePic"
  39. :previewImage="true"
  40. multiple
  41. name="name"
  42. :maxCount="9"
  43. ></u-upload>
  44. </view>
  45. <view class="full-btn" @click="submit">提交评价</view>
  46. </view>
  47. </template>
  48. <script>
  49. import {uploadImg} from '../utils/uploadImg.js'
  50. export default {
  51. data() {
  52. return {
  53. id:'',
  54. params:{
  55. rate:3,
  56. content:'',
  57. imgs:[]
  58. },
  59. fileList:[],
  60. orderDetails:{},
  61. staticUrl:this.$commonConfig.staticUrl,
  62. }
  63. },
  64. onShow() {
  65. },
  66. onLoad(page) {
  67. console.log('page',page);
  68. this.id = page.id;
  69. this.getOrderDetails(this.id)
  70. },
  71. methods: {
  72. getOrderDetails(id){
  73. this.$u.api.orderDetails({id:id}).then(res=>{
  74. this.orderDetails = res.data
  75. console.log('orderDetails',JSON.parse(JSON.stringify(res.data)));
  76. }).catch(err=>{
  77. console.log('getOrderDetails',err);
  78. })
  79. },
  80. // 新增图片
  81. async afterRead(event){
  82. //使用这个封装
  83. const result = await uploadImg(event,this.fileList)
  84. // let parseResult = JSON.parse(result.data).data;
  85. let item = this.fileList[result.fileListLen]
  86. this.fileList.splice(result.fileListLen, 1, Object.assign(item, {
  87. status: 'success',
  88. message: '成功',
  89. url: JSON.parse(result.data).data
  90. }));
  91. },
  92. // 删除图片
  93. deletePic(event) {
  94. this.fileList.splice(event.index, 1)
  95. },
  96. submit(){
  97. this.params.imgs = this.fileList.map(item =>{
  98. if(item.message=='成功'){
  99. return item.url.url
  100. }
  101. })
  102. console.log('params',this.params);
  103. }
  104. }
  105. }
  106. </script>
  107. <style>
  108. page{
  109. background-color: #F5F5F5;
  110. }
  111. </style>
  112. <style lang="scss" scoped>
  113. .product{
  114. background-color: #fff;
  115. margin-bottom: 0;
  116. }
  117. .rate-wrap{
  118. background-color: #fff;
  119. margin-bottom: 20rpx;
  120. padding: 20rpx;
  121. .rate-title{
  122. font-size: 30rpx;
  123. color: #333;
  124. font-weight: 600;
  125. margin-right: 20rpx;
  126. }
  127. .rate-text{
  128. font-size: 26rpx;
  129. margin-left: 20rpx;
  130. color: #ccc;
  131. }
  132. }
  133. .upload-wrap{
  134. margin-top: 40rpx;
  135. padding: 20rpx;
  136. background-color: #fff;
  137. }
  138. </style>