reply.vue 6.9 KB

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