index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="pagesCons">
  3. <view class="utabs">
  4. <u-tabs-swiper ref="uTabs" :list="tabList" name="dispName" :current="current" bar-width="150" active-color="#58c4c4" @change="tabsChange" :is-scroll="false"
  5. swiperWidth="750"></u-tabs-swiper>
  6. </view>
  7. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  8. <swiper-item class="swiper-item" v-for="(tabs, index) in tabList" :key="index">
  9. <scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
  10. <view
  11. class="check-order-list"
  12. v-if="index==current"
  13. v-for="(item,sindex) in 35"
  14. :key="item.id+'-'+sindex"
  15. >
  16. <view v-if="current==0" class="flex align_center justify_between">
  17. <view class="l_box">钜惠礼(首单满2000元减300)</view>
  18. <view class="r_box">剩余1次</view>
  19. </view>
  20. <view v-if="current==1">
  21. <view class="l_box">钜惠礼(首单满2000元减300)</view>
  22. <view class="flex align_center justify_between" style="padding-top: 0.2em;">
  23. <view class="r_box">剩余1次</view>
  24. <view class="r_box">2022-15-25</view>
  25. </view>
  26. </view>
  27. </view>
  28. <view style="padding: 20upx;">
  29. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  30. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  31. </view>
  32. </scroll-view>
  33. </swiper-item>
  34. </swiper>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. components: {
  40. },
  41. data() {
  42. return {
  43. status: 'loadmore',
  44. noDataText: '暂无数据',
  45. tabList: [
  46. {
  47. dispName: '品项明细',
  48. typeId: 1,
  49. queryLabel: 'WAIT_REFORM' // tab参数
  50. },
  51. {
  52. dispName: '使用记录',
  53. typeId: 2,
  54. queryLabel: 'FINISH_REFORM' // tab参数
  55. }
  56. ],
  57. current: 0,
  58. swiperCurrent: 0,
  59. pageNo: 1,
  60. pageSize: 6,
  61. list: [],
  62. total: 0,
  63. action:'swiperChange', // 操作类型,上划分页,或左右滑动
  64. statusList: [], // 问题状态数据字典
  65. sourceTypeList: [] // 问题来源数据字典
  66. }
  67. },
  68. onLoad() {
  69. // 监听整改完成后刷新事件
  70. uni.$on('refreshBL',this.getRow)
  71. this.statusList = this.$store.state.vuex_backLogStatusList
  72. this.sourceTypeList = this.$store.state.vuex_backLogSourceTypeList
  73. this.getRow(1)
  74. },
  75. onUnload() {
  76. uni.$off('refreshBL',this.getRow)
  77. },
  78. methods:{
  79. getsourceType(value) {
  80. let type = this.sourceTypeList.find(a=>a.code==value)
  81. return type ? type.dispName : '--'
  82. },
  83. getstatus(value) {
  84. let status = this.statusList.find(a=>a.code==value)
  85. return status ? status.dispName : '--'
  86. },
  87. // tabs通知swiper切换
  88. tabsChange(index) {
  89. this.swiperCurrent = index;
  90. },
  91. swiperChange(event){
  92. this.action = 'swiperChange'
  93. this.status = 'loading'
  94. },
  95. // swiper-item左右移动,通知tabs的滑块跟随移动
  96. transition(e) {
  97. let dx = e.detail.dx;
  98. this.$refs.uTabs.setDx(dx);
  99. },
  100. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  101. // swiper滑动结束,分别设置tabs和swiper的状态
  102. animationfinish(e) {
  103. let current = e.detail.current;
  104. let isCurtab = this.current == current
  105. if(this.status!="nomore"){
  106. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab;
  107. if(loadData){
  108. this.$refs.uTabs.setFinishCurrent(current);
  109. this.swiperCurrent = current;
  110. this.current = current;
  111. this.resetPage();
  112. }
  113. }
  114. },
  115. // scroll-view到底部加载更多
  116. onreachBottom() {
  117. this.action = 'onreachBottom'
  118. if(this.list.length < this.total){
  119. this.resetPage()
  120. }else{
  121. this.status = "nomore"
  122. }
  123. },
  124. // 查询列表
  125. getRow (pageNo) {
  126. if (pageNo) {
  127. this.pageNo = pageNo
  128. }
  129. let params = {
  130. pageNo: this.pageNo,
  131. pageSize: this.pageSize,
  132. reformState: this.tabList[this.current].queryLabel, // tab分类
  133. }
  134. this.status = "loading"
  135. getBackLogList(params).then(res => {
  136. console.log(params,res.data.list,'+++++++++++')
  137. if (res.status == 200) {
  138. if(this.pageNo>1){
  139. this.list = this.list.concat(res.data.list || [])
  140. }else{
  141. this.list = res.data.list || []
  142. }
  143. this.total = res.data.count || 0
  144. } else {
  145. this.list = []
  146. this.total = 0
  147. this.noDataText = res.message
  148. }
  149. this.status = "loadmore"
  150. })
  151. },
  152. resetPage(){
  153. this.status = 'loading';
  154. // 上划分页
  155. if(this.action == 'onreachBottom'){
  156. this.pageNo += 1
  157. this.getRow()
  158. }
  159. // 左右切换tab
  160. if(this.action == 'swiperChange'){
  161. this.list = [];
  162. this.getRow(1);
  163. }
  164. },
  165. }
  166. }
  167. </script>
  168. <style lang="scss">
  169. page {
  170. height: 100%;
  171. }
  172. .pagesCons{
  173. height: 100%;
  174. display: flex;
  175. flex-direction: column;
  176. .text-right {
  177. text-align: right;
  178. }
  179. .utabs{
  180. border-bottom: 1px solid #eee;
  181. }
  182. .check-list{
  183. flex: 1;
  184. .swiper-item{
  185. width: 100%;
  186. height: 100%;
  187. overflow: hidden;
  188. .scroll-view {
  189. width: 100%;
  190. height: 100%;
  191. overflow: auto;
  192. }
  193. }
  194. }
  195. // 列表样式
  196. .check-order-list{
  197. background: #ffffff;
  198. border-bottom: 1px solid #eee;
  199. padding: 1em;
  200. &:active{
  201. background: #f8f8f8;
  202. }
  203. .l_box{
  204. font-size: 1em;
  205. flex-grow: 1;
  206. }
  207. .r_box{
  208. color: #999;
  209. > view{
  210. padding: 0 0.1em;
  211. }
  212. }
  213. }
  214. }
  215. </style>