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.

177 lines
3.8 KiB

4 years ago
  1. <template>
  2. <view class="app">
  3. <view class="wrap">
  4. <view class="list" v-for="(item, index) in list" :key="index">
  5. <product-list :list="item.products"></product-list>
  6. <view class="star-wrap row">
  7. <view class="column fill">
  8. <text class="tit fill">您对宝贝还满意吗</text>
  9. <text class="title clamp">{{ item.title }}</text>
  10. </view>
  11. <text
  12. v-for="(sItem, sIndex) in 5"
  13. :key="sIndex"
  14. class="mix-icon icon-iconfontxingxing"
  15. :class="{active: item.rating > sIndex}"
  16. @click="checkStar(sIndex, item)"
  17. ></text>
  18. </view>
  19. <view class="textarea-wrap">
  20. <textarea maxlength="100" v-model="item.content" placeholder="分享一下使用心得,让大家了解一下吧 .." placeholder-style="color:#999" />
  21. </view>
  22. <view class="upload-wrap">
  23. <mix-upload-image :length="4" :index="index" @onChange="onImageChange"></mix-upload-image>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="btn-wrap">
  28. <mix-button ref="confirmBtn" text="提交" @onConfirm="confirm"></mix-button>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import productList from '@/pages/order/components/product-list.vue'
  34. export default {
  35. components: {
  36. productList
  37. },
  38. data() {
  39. return {
  40. data: {},
  41. list: []
  42. }
  43. },
  44. onLoad(options) {
  45. const data = JSON.parse(options.data);
  46. this.list = data.products.map(item=> {
  47. item.rating = 5;
  48. item.content = '';
  49. item.images = [];
  50. return item;
  51. });
  52. this.data = data;
  53. },
  54. methods: {
  55. async confirm(){
  56. const data = {
  57. order_id: this.data.id,
  58. list: this.list.map(item=> {
  59. return {
  60. product_id: item.sku.product_id,
  61. sku: item.sku.name || '',
  62. content: item.content || '买家未填写评价内容',
  63. rating: item.rating,
  64. images: item.images
  65. }
  66. })
  67. }
  68. const res = await this.$request('order', 'addRating', data);
  69. this.$util.msg(res.msg);
  70. if(res.status === 1){
  71. const prePage = this.$util.prePage();
  72. if(prePage.refreshList){
  73. prePage.refreshList()
  74. }else{
  75. prePage.loadData && prePage.loadData();
  76. }
  77. setTimeout(()=>{
  78. uni.navigateBack();
  79. }, 1000)
  80. }
  81. this.$refs.confirmBtn.stop();
  82. },
  83. checkStar(current, item){
  84. item.rating = current + 1;
  85. },
  86. onImageChange(e){
  87. console.log(e.list.map(item=> item));
  88. this.list[e.index].images = e.list.map(item=> item.url)
  89. }
  90. }
  91. }
  92. </script>
  93. <style>
  94. page{
  95. background-color: #f7f7f7;
  96. }
  97. </style>
  98. <style scoped lang="scss">
  99. .app{
  100. padding: 20rpx;
  101. }
  102. .list{
  103. margin-bottom: 20rpx;
  104. background-color: #fff;
  105. border-radius: 12rpx;
  106. overflow: hidden;
  107. &:last-child{
  108. margin-bottom: 0;
  109. border-radius: 12rpx 12rpx 0 0;
  110. }
  111. }
  112. .star-wrap{
  113. padding: 30rpx 24rpx 10rpx;
  114. .tit{
  115. font-size: 30rpx;
  116. color: #333;
  117. font-weight: 700;
  118. }
  119. .title{
  120. width: 400rpx;
  121. margin-top: 16rpx;
  122. font-size: 24rpx;
  123. color: #666;
  124. }
  125. .icon-iconfontxingxing{
  126. margin-right: 6rpx;
  127. font-size: 36rpx;
  128. color: #ccc;
  129. &.active{
  130. color: #f0a80e;
  131. }
  132. }
  133. }
  134. .textarea-wrap{
  135. padding: 20rpx;
  136. background-color: #fff;
  137. border-radius: 12rpx;
  138. textarea{
  139. width: 100%;
  140. height: 200rpx;
  141. padding: 20rpx;
  142. font-size: 28rpx;
  143. color: #333;
  144. line-height: 1.4;
  145. background-color: #f7f7f7;
  146. border-radius: 12rpx;
  147. }
  148. }
  149. .upload-wrap{
  150. padding: 10rpx 0 10rpx 20rpx;
  151. /deep/ {
  152. .upload-content{
  153. background-color: #fff;
  154. }
  155. .upload-item{
  156. width: 144rpx;
  157. height: 144rpx;
  158. }
  159. .upload-add-btn{
  160. width: 144rpx;
  161. height: 144rpx;
  162. }
  163. }
  164. }
  165. .btn-wrap{
  166. padding: 60rpx 0;
  167. background-color: #fff;
  168. border-radius: 0 0 12rpx 12rpx;
  169. }
  170. </style>