reply.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="container">
  3. <view class="reply_btn flex_item">
  4. <view class="btn" v-for="(item, index) in navList" :key="index" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">
  5. {{ item.text }}({{ item.number }})
  6. </view>
  7. </view>
  8. <swiper :current="tabCurrentIndex" class="swiper-box" :style="{ height: maxheight + 'px' }" duration="300" @change="changeTab">
  9. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  10. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadDate">
  11. <!-- 评论列表 -->
  12. <view v-for="(item, index) in tabItem.orderList" :key="index" class="eva-box">
  13. <view class="row-1 flex1">
  14. <image class="portrait" :src="item.avatar" mode="aspectFill"></image>
  15. <view class="right flex1">
  16. <view>
  17. <view class="name flex1">
  18. <view>{{ item.nickname }}</view>
  19. <!-- <image src="../../static/label/vip.png"></image> -->
  20. </view>
  21. <uniRate class="rate" disabled size="10" margin="1" :value="item.product_score" ></uniRate>
  22. </view>
  23. <view class="bot">
  24. <text class="attr"></text>
  25. <text class="time">{{ item.add_time }}</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="con">{{ item.comment }}</view>
  30. <view class="con_box">
  31. <view class="con_image" v-for="ls in item.pics"><image :src="ls"></image></view>
  32. </view>
  33. </view>
  34. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  35. </scroll-view>
  36. </swiper-item>
  37. </swiper>
  38. </view>
  39. </template>
  40. <script>
  41. import { reply_config, reply_list } from '@/api/product.js';
  42. import uniRate from '@/components/uni-rate/uni-rate.vue';
  43. export default {
  44. components: {
  45. uniRate
  46. },
  47. watch: {},
  48. data() {
  49. return {
  50. maxheight: '',
  51. id: '', //商品id
  52. list: '', //评论列表
  53. reply: '', //评论配置
  54. tabCurrentIndex: 0,
  55. navList: [
  56. {
  57. state: 0,
  58. text: '全部',
  59. loadingType: 'more',
  60. number: '',
  61. orderList: [],
  62. page: 1, //当前页数
  63. limit: 5 //每次信息条数
  64. },
  65. {
  66. state: 1,
  67. text: '好评',
  68. loadingType: 'more',
  69. number: '',
  70. orderList: [],
  71. page: 1, //当前页数
  72. limit: 5 //每次信息条数
  73. },
  74. {
  75. state: 3,
  76. text: '差评',
  77. loadingType: 'more',
  78. number: '',
  79. orderList: [],
  80. page: 1, //当前页数
  81. limit:5 //每次信息条数
  82. },
  83. {
  84. state: 2,
  85. text: '中评',
  86. loadingType: 'more',
  87. number: '',
  88. orderList: [],
  89. page: 1, //当前页数
  90. limit: 5 //每次信息条数
  91. }
  92. ]
  93. };
  94. },
  95. computed: {},
  96. onReady() {
  97. // 初始化获取页面宽度
  98. uni.createSelectorQuery()
  99. .select('.container')
  100. .fields(
  101. {
  102. size: true
  103. },
  104. data => {
  105. // 保存头部高度
  106. this.maxheight = data.height - Math.floor((data.width / 750) * 145);
  107. }
  108. )
  109. .exec();
  110. },
  111. onLoad(option) {
  112. this.id = option.id;
  113. },
  114. onShow() {
  115. let obj = this;
  116. reply_config({}, this.id).then(function({ data }) {
  117. obj.reply = data;
  118. obj.navList[0].number = obj.reply.sum_count;
  119. obj.navList[1].number = obj.reply.good_count;
  120. obj.navList[2].number = obj.reply.poor_count;
  121. obj.navList[3].number = obj.reply.in_count;
  122. });
  123. this.loadDate();
  124. },
  125. methods: {
  126. async loadDate(source) {
  127. //这里是将订单挂载到tab列表下
  128. let index = this.tabCurrentIndex;
  129. let navItem = this.navList[index];
  130. let state = navItem.state;
  131. if (source === 'tabChange' && navItem.loaded === true) {
  132. //tab切换只有第一次需要加载数据
  133. return;
  134. }
  135. if (navItem.loadingType === 'loading') {
  136. //防止重复加载
  137. return;
  138. }
  139. if (navItem.loadingType === 'noMore') {
  140. //防止重复加载
  141. return;
  142. }
  143. // 修改当前对象状态为加载中
  144. navItem.loadingType = 'loading';
  145. reply_list(
  146. {
  147. type: state,
  148. page: navItem.page,
  149. limit: navItem.limit
  150. },
  151. this.id
  152. )
  153. .then(({ data }) => {
  154. let arr = data;
  155. navItem.orderList = navItem.orderList.concat(arr);
  156. console.log(navItem.orderList,111)
  157. navItem.page++;
  158. if (navItem.limit == data.length) {
  159. //判断是否还有数据, 有改为 more, 没有改为noMore
  160. navItem.loadingType = 'more';
  161. return;
  162. } else {
  163. //判断是否还有数据, 有改为 more, 没有改为noMore
  164. navItem.loadingType = 'noMore';
  165. }
  166. this.$set(navItem, 'loaded', true);
  167. })
  168. .catch(e => {
  169. console.log(e);
  170. });
  171. },
  172. // async GetList(){
  173. // let obj = this;
  174. // reply_list({}, obj.id).then(function({ data }) {
  175. // // console.log(data)
  176. // obj.list = data;
  177. // });
  178. // },
  179. //跳转接口
  180. navTo(url) {
  181. uni.navigateTo({
  182. url
  183. });
  184. },
  185. //swiper 切换
  186. changeTab(e) {
  187. this.tabCurrentIndex = e.target.current;
  188. this.loadDate('tabChange');
  189. },
  190. //顶部tab点击
  191. tabClick(index) {
  192. this.tabCurrentIndex = index;
  193. }
  194. }
  195. };
  196. </script>
  197. <style lang="scss">
  198. page {
  199. background: #ffffff;
  200. height: 100%;
  201. .container {
  202. height: 100%;
  203. padding: 25rpx 25rpx;
  204. padding-top: 120rpx;
  205. .swiper-box {
  206. // height: 100%;
  207. .list-scroll-content {
  208. height: 100%;
  209. }
  210. }
  211. }
  212. }
  213. .reply_btn {
  214. padding: 15rpx 0rpx;
  215. .btn {
  216. padding: 10rpx 25rpx;
  217. font-size: 24rpx;
  218. background: #f4f4f4;
  219. margin-right: 25rpx;
  220. }
  221. .current {
  222. background-color: #e93323 !important;
  223. color: #ffffff !important;
  224. }
  225. }
  226. .eva-box {
  227. padding: 20rpx 0;
  228. // height: 100%;
  229. .row-1{
  230. .portrait {
  231. flex-shrink: 0;
  232. width: 80rpx;
  233. height: 80rpx;
  234. border-radius: 100px;
  235. }
  236. .right {
  237. flex: 1;
  238. font-size: $font-base;
  239. color: $font-color-base;
  240. padding-left: 26rpx;
  241. .name{
  242. margin-bottom: 20rpx;
  243. image{
  244. width: 35rpx;
  245. height: 25rpx;
  246. }
  247. }
  248. .bot {
  249. display: flex;
  250. justify-content: space-between;
  251. font-size: $font-sm;
  252. color: $font-color-light;
  253. }
  254. }
  255. }
  256. .con {
  257. font-size:24rpx;
  258. font-weight:500;
  259. color:rgba(84,84,86,1);
  260. padding: 20rpx 0 35rpx 0;
  261. letter-spacing: 3rpx;
  262. }
  263. .con_image {
  264. width: 150rpx;
  265. height: 150rpx;
  266. display: inline-block;
  267. margin-right: 20rpx;
  268. image {
  269. width: 100%;
  270. height: 100%;
  271. }
  272. }
  273. }
  274. </style>