reviews.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view>
  3. <!--标题栏-->
  4. <bar-title bgColor='bg-white' title="商品评价">
  5. <block slot="content">商品评价</block>
  6. <block slot="right">
  7. </block>
  8. </bar-title>
  9. <view class="bg-white padding-sm zaiui-goods-info-view margin-bottom" v-if="info.id">
  10. <view class="cu-avatar lg" :style="[{backgroundImage:'url('+ info.pic[0] +')'}]"/>
  11. <view class="goods-info-view">
  12. <view class="text-cut text-black text-lg">{{info.name}}</view>
  13. <!-- <view class="text-cut text-gray">{{info.sku_name}}</view> -->
  14. </view>
  15. </view>
  16. <!--评论-->
  17. <view class="margin-top bg-white zaiui-comment-view-box" v-if="total">
  18. <view class="zaiui-border-view"/>
  19. <block v-for="(item, index) in reviewList">
  20. <view class="zaiui-view-box" :key="item.id">
  21. <view class="flex flex-wrap text-sm">
  22. <view class="basis-1">
  23. <view class="cu-avatar sm round" :style="`background-image:url(${item.user.avatar || '/static/images/avatar/1.jpg'})`"/>
  24. </view>
  25. <view class="basis-9 text-sm">
  26. <view>{{item.user.name}}</view>
  27. <view class="margin-top-xs">{{item.content}}</view>
  28. <view class="text-gray margin-top-sm">{{item.cdate_str}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="zaiui-border-view" v-if="index != 1"/>
  33. </block>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import barTitle from '@/components/zaiui-common/basics/bar-title';
  39. import _goods_data from '@/static/zaiui/data/goods.js'; //虚拟数据
  40. import _tool from '@/static/zaiui/util/tools.js'; //工具函数
  41. export default {
  42. components: {
  43. barTitle,
  44. },
  45. data() {
  46. return {
  47. bannerCur: 0, bannerList: [], bottomModal: false, modalTitle: '', modalType: 'promotion', selectType: '',
  48. goodsId: '',
  49. info: {},
  50. reviewList: [],
  51. total: 0,
  52. num: 10,
  53. pg: 1,
  54. hasNext: true
  55. }
  56. },
  57. onLoad(options) {
  58. this.goodsId = options.id;
  59. this.loadInfo()
  60. this.loadReviewList()
  61. },
  62. onReady() {
  63. _tool.setBarColor(true);
  64. uni.pageScrollTo({
  65. scrollTop: 0,
  66. duration: 0
  67. });
  68. },
  69. computed: {
  70. },
  71. methods: {
  72. loadInfo() {
  73. this.req({
  74. url: '?l=resource.view',
  75. data: {type: 3, type_id: this.goodsId},
  76. success: res => {
  77. if(res.data.status == 1) {
  78. this.info = res.data.data.info;
  79. }else {
  80. uni.showToast({
  81. icon: 'error',
  82. title: res.data.msg
  83. })
  84. }
  85. }
  86. })
  87. },
  88. loadReviewList() {
  89. this.reqByuser({
  90. url: '?l=resource.getReviewList',
  91. data: {
  92. type: 3,
  93. type_id: this.goodsId,
  94. num: this.num,
  95. pg: this.pg
  96. },
  97. success: res => {
  98. if(res.data.status == 1) {
  99. this.total = res.data.data.total;
  100. this.reviewList = this.pg == 1 ? res.data.data.list : this.reviewList.concat(res.data.data.list)
  101. this.hasNext = res.data.page.status
  102. }else {
  103. uni.showToast({
  104. icon: 'error',
  105. title: res.data.msg
  106. })
  107. }
  108. }
  109. })
  110. },
  111. },
  112. onReachBottom() {
  113. if(this.hasNext) {
  114. this.pg++;
  115. this.loadReviewList()
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. /* #ifdef APP-PLUS */
  122. @import "../../static/colorui/main.css";
  123. @import "../../static/colorui/icon.css";
  124. @import "../../static/zaiui/style/app.scss";
  125. /* #endif */
  126. @import "../../static/zaiui/style/goods.scss";
  127. </style>
  128. <style scoped lang="scss">
  129. .zaiui-goods-info-view {
  130. position: relative;
  131. .cu-avatar {
  132. position: absolute;
  133. }
  134. .goods-info-view {
  135. position: relative;
  136. padding-left: 112.72upx;
  137. height: 94.54upx;
  138. line-height: 1.7;
  139. }
  140. }
  141. </style>