customerList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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" @click="goToOrderList(site)">
  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. if (!this.triggered) {
  109. this.triggered = true
  110. this.tabList[this.current].isOver = false
  111. this.tabList[this.current].pageIndex = 1
  112. this.tabList[this.current].tableList = []
  113. this.getTableList(this.current, 'refresh')
  114. }
  115. },
  116. // 重置下拉刷新状态
  117. onRestore() {
  118. this.triggered = 'restore'
  119. this.triggered = false
  120. },
  121. // 懒加载
  122. handleLoadMore() {
  123. if (!this.tabList[this.current].isOver) {
  124. this.tabList[this.current].pageIndex++
  125. this.getTableList(this.current)
  126. }
  127. },
  128. // 获取列表数据
  129. getTableList(index) {
  130. NET.request(API.getCustomerList, {
  131. name: this.tabList[index].filterText,
  132. type: this.tabList[index].type,
  133. page: this.tabList[index].pageIndex,
  134. size: 10,
  135. }, 'POST').then(res => {
  136. this.triggered = false
  137. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  138. this.tabList[index].isOver = res.data.row.length != 10
  139. }).catch(error => {
  140. this.triggered = false
  141. this.$refs.uTips.show({
  142. title: error.msg,
  143. type: 'warning',
  144. })
  145. })
  146. },
  147. // 跳转订单列表
  148. goToOrderList(item) {
  149. if (item.status == 1) {
  150. uni.navigateTo({
  151. url: '/pagesMain/orderList?id=' + item.id
  152. });
  153. }
  154. }
  155. },
  156. }
  157. </script>
  158. <style>
  159. page {
  160. width: 100%;
  161. height: 100%;
  162. background-color: #f7f7f7;
  163. }
  164. </style>
  165. <style lang="scss" scoped>
  166. @import "@/static/css/themes.scss";
  167. .content {
  168. width: 100%;
  169. float: left;
  170. .filter-box {
  171. height: 48px;
  172. padding: 10px 15px;
  173. background-color: #FFFFFF;
  174. }
  175. .swiper-box {
  176. height: calc(100vh - 82px);
  177. .swiper-item {
  178. height: calc(100vh - 82px);
  179. .scroll-box {
  180. width: 100%;
  181. height: calc(100vh - 82px);
  182. .card-box {
  183. .card-content {
  184. display: flex;
  185. align-items: center;
  186. .student-info {
  187. flex: 1;
  188. .info-name {
  189. width: 64px;
  190. float: left;
  191. line-height: 28px;
  192. font-size: 14px;
  193. font-weight: bold;
  194. }
  195. .info-type {
  196. padding: 0 10px;
  197. margin-top: 3px;
  198. border-radius: 20px;
  199. float: left;
  200. line-height: 20px;
  201. font-size: 10px;
  202. color: #FFFFFF;
  203. background-color: #999999;
  204. }
  205. .info-type-active {
  206. background-color: $mainColor;
  207. }
  208. .info-phone {
  209. width: calc(100% - 64px);
  210. float: left;
  211. line-height: 28px;
  212. font-size: 12px;
  213. color: #999999;
  214. }
  215. }
  216. }
  217. }
  218. }
  219. }
  220. }
  221. }
  222. </style>