customerList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="content">
  3. <view class="filter-box">
  4. <u-search placeholder="请输入关键字" v-model="filterText" @search="setFilterText" @custom="setFilterText"></u-search>
  5. </view>
  6. <u-tabs-swiper ref="uTabs" :active-color="mainColor" :list="tabList" :current="current" @change="tabsChange"
  7. :is-scroll="false"></u-tabs-swiper>
  8. <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" class="swiper-box">
  9. <swiper-item class="swiper-item" v-for="(item, index1) in tabList" :key="index1">
  10. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  11. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  12. @refresherrestore="onRestore">
  13. <u-card :show-head="false" :show-foot="false" margin="10px 15px" borderRadius="40" v-for="(site, index2) in item.tableList"
  14. :key="index2" class="card-box">
  15. <view slot="body" class="card-content">
  16. <view class="student-info">
  17. <view class="info-name">{{site.studentName}}</view>
  18. <view class="info-type" :class="site.status == 1 ? 'info-type-active' : ''">{{site.status == 0 ? '未报名' : '已报名'}}</view>
  19. <view class="info-name" style="clear: left;">{{site.parentName}}</view>
  20. <view class="info-phone">{{site.parentPhone}}</view>
  21. </view>
  22. <u-image width="28px" height="28px" :src="site.type == 1 ? iconPath1 : iconPath2"></u-image>
  23. </view>
  24. </u-card>
  25. <u-divider v-if="item.isOver" bg-color="transparent" :style="{paddingTop : item.tableList.length == 0 ? '10px' : ''}">没有更多了</u-divider>
  26. </scroll-view>
  27. </swiper-item>
  28. </swiper>
  29. <u-top-tips ref="uTips"></u-top-tips>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. mapGetters
  35. } from 'vuex'
  36. const NET = require('@/utils/request')
  37. const API = require('@/config/api')
  38. export default {
  39. computed: {
  40. ...mapGetters([
  41. 'mainColor',
  42. 'handleCustomStyle',
  43. 'handleDefaultCustomStyle',
  44. ])
  45. },
  46. data() {
  47. return {
  48. filterText: '',
  49. triggered: false,
  50. tabList: [{
  51. name: '全部',
  52. isOver: false,
  53. pageIndex: 1,
  54. filterText: '',
  55. type: 2,
  56. tableList: [],
  57. }, {
  58. name: '已报名',
  59. isOver: false,
  60. pageIndex: 1,
  61. filterText: '',
  62. type: 1,
  63. tableList: [],
  64. }, {
  65. name: '意向客户',
  66. isOver: false,
  67. pageIndex: 1,
  68. filterText: '',
  69. type: 0,
  70. tableList: [],
  71. }],
  72. current: 0,
  73. swiperCurrent: 0,
  74. iconPath1: API.getServerImg + 'weibaoming.png',
  75. iconPath2: API.getServerImg + 'xianshangkehu.png',
  76. }
  77. },
  78. onLoad() {
  79. this.getTableList(0)
  80. this.getTableList(1)
  81. this.getTableList(2)
  82. },
  83. onReady() {},
  84. methods: {
  85. // 设置过滤字段
  86. setFilterText(value) {
  87. this.tabList[this.current].filterText = value
  88. this.onRefresh()
  89. },
  90. // tab页面切换
  91. tabsChange(index) {
  92. this.swiperCurrent = index;
  93. },
  94. // swiper-item左右移动,通知tabs的滑块跟随移动
  95. transition(e) {
  96. let dx = e.detail.dx;
  97. this.$refs.uTabs.setDx(dx);
  98. },
  99. // swiper滑动结束,分别设置tabs和swiper的状态
  100. animationfinish(e) {
  101. let current = e.detail.current;
  102. this.$refs.uTabs.setFinishCurrent(current);
  103. this.swiperCurrent = current;
  104. this.current = current;
  105. },
  106. // 下拉刷新
  107. onRefresh() {
  108. this.triggered = true
  109. this.tabList[this.current].isOver = false
  110. this.tabList[this.current].pageIndex = 1
  111. this.tabList[this.current].tableList = []
  112. this.getTableList(this.current, 'refresh')
  113. },
  114. // 重置下拉刷新状态
  115. onRestore() {
  116. this.triggered = 'restore'
  117. this.triggered = false
  118. },
  119. // 懒加载
  120. handleLoadMore() {
  121. if (!this.tabList[this.current].isOver) {
  122. this.tabList[this.current].pageIndex++
  123. this.getTableList(this.current)
  124. }
  125. },
  126. // 获取列表数据
  127. getTableList(index) {
  128. NET.request(API.getCustomerList, {
  129. name: this.tabList[index].filterText,
  130. type: this.tabList[index].type,
  131. page: this.tabList[index].pageIndex,
  132. size: 10,
  133. }, 'POST').then(res => {
  134. this.triggered = false
  135. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  136. this.tabList[index].isOver = res.data.row.length != 10
  137. }).catch(error => {
  138. this.triggered = false
  139. this.$refs.uTips.show({
  140. title: error.msg,
  141. type: 'warning',
  142. })
  143. })
  144. }
  145. },
  146. }
  147. </script>
  148. <style>
  149. page {
  150. width: 100%;
  151. height: 100%;
  152. background-color: #f7f7f7;
  153. }
  154. </style>
  155. <style lang="scss" scoped>
  156. @import "@/static/css/themes.scss";
  157. .content {
  158. width: 100%;
  159. float: left;
  160. .filter-box {
  161. height: 48px;
  162. padding: 10px 15px;
  163. background-color: #FFFFFF;
  164. }
  165. .swiper-box {
  166. height: calc(100vh - 82px);
  167. .swiper-item {
  168. height: calc(100vh - 82px);
  169. .scroll-box {
  170. width: 100%;
  171. height: calc(100vh - 82px);
  172. .card-box {
  173. .card-content {
  174. display: flex;
  175. align-items: center;
  176. .student-info {
  177. flex: 1;
  178. .info-name {
  179. width: 64px;
  180. float: left;
  181. line-height: 28px;
  182. font-size: 14px;
  183. font-weight: bold;
  184. }
  185. .info-type {
  186. padding: 0 10px;
  187. margin-top: 3px;
  188. border-radius: 20px;
  189. float: left;
  190. line-height: 20px;
  191. font-size: 10px;
  192. color: #FFFFFF;
  193. background-color: #999999;
  194. }
  195. .info-type-active {
  196. background-color: $mainColor;
  197. }
  198. .info-phone {
  199. width: calc(100% - 64px);
  200. float: left;
  201. line-height: 28px;
  202. font-size: 12px;
  203. color: #999999;
  204. }
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. </style>