list.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <!-- 余额明细页面 -->
  2. <template>
  3. <view class="content">
  4. <view class="navbar">
  5. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{current: tabCurrentIndex === index}"
  6. @click="tabClick(index)">
  7. {{item.text}}
  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="loadData">
  13. <view v-if="tabItem.loadingState != 'first_loading'&&tabItem.rechargeList.length == 0" class="empty_part flex_column_start_center">
  14. <image :src="imgUrl+'empty_goods.png'" />
  15. <text>{{$L('还没有数据哦')}}~</text>
  16. </view>
  17. <!-- 余额列表 -->
  18. <template v-if="tabItem.rechargeList.length > 0">
  19. <view v-for="(item,index) in tabItem.rechargeList" :key="index" class="log-item flex_row_between_center b_b"
  20. @click="viewDetail(item.rechargeId)">
  21. <view class="left flex_column_start_start">
  22. <text class="type">{{item.payStateValue}}</text>
  23. <text class="time">{{item.createTime}}</text>
  24. </view>
  25. <view class="right flex_row_end_center">
  26. <text :class="{amount:true,add:item.type==2,flag:true}">+</text>
  27. <text :class="{amount:true,add:item.type==2}">{{item.payAmount}}</text>
  28. <text class="iconfont iconziyuan11"></text>
  29. </view>
  30. </view>
  31. </template>
  32. <loadingState v-if="tabItem.loadingState == 'first_loading'||tabItem.rechargeList.length > 0" :state='tabItem.loadingState' />
  33. </scroll-view>
  34. </swiper-item>
  35. </swiper>
  36. </view>
  37. </template>
  38. <script>
  39. import loadingState from "@/components/loading-state.vue";
  40. import {
  41. mapState
  42. } from 'vuex';
  43. export default {
  44. components: {
  45. loadingState
  46. },
  47. data() {
  48. return {
  49. imgUrl: getApp().globalData.imgUrl,
  50. tabCurrentIndex: 0,
  51. navList: [{
  52. state: 0,
  53. text: this.$L('全部'),
  54. loadingState: 'first_loading',
  55. rechargeList: [],
  56. current: 1, //分页
  57. },
  58. {
  59. state: 1,
  60. text: '充值成功',
  61. loadingState: 'first_loading',
  62. rechargeList: [],
  63. current: 1, //分页
  64. },
  65. {
  66. state: 2,
  67. text: '待充值',
  68. loadingState: 'first_loading',
  69. rechargeList: [],
  70. current: 1, //分页
  71. },
  72. ],
  73. stopPullDownRefresh: false, //是否下拉刷新中
  74. };
  75. },
  76. onLoad(options) {
  77. /**
  78. * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
  79. * 替换onLoad下代码即可
  80. */
  81. // #ifndef MP
  82. this.loadData()
  83. // #endif
  84. // #ifdef MP
  85. this.loadData()
  86. // #endif
  87. },
  88. computed: {
  89. ...mapState(['userInfo'])
  90. },
  91. //下拉刷新
  92. onPullDownRefresh() {
  93. let index = this.tabCurrentIndex;
  94. let navItem = this.navList[index];
  95. navItem.loadingState = 'first_loading';
  96. navItem.rechargeList = [];
  97. navItem.current = 1;
  98. this.stopPullDownRefresh = true; //下拉刷新状态
  99. this.loadData();
  100. },
  101. methods: {
  102. //获取订单列表
  103. loadData(source) {
  104. //将订单挂载到tab列表下,起到缓存的效果,避免多次请求
  105. let index = this.tabCurrentIndex;
  106. let navItem = this.navList.filter(item => item.state == index)[0];
  107. let state = navItem.state;
  108. if (source === 'tabChange' && navItem.loadingState !== 'first_loading') {
  109. //tab切换只有第一次需要加载数据
  110. return;
  111. }
  112. if (navItem.loadingState === 'loading') {
  113. //防止重复加载
  114. return;
  115. }
  116. if (navItem.loadingState == 'no_more_data') {
  117. //已经没有数据,无需再请求
  118. return;
  119. }
  120. let param = {};
  121. param.url = 'v3/member/front/balanceRecharge/list';
  122. param.data = {};
  123. param.data.pageSize = 10;
  124. param.data.current = navItem.current;
  125. navItem.loadingState = navItem.loadingState == 'first_loading' ? navItem.loadingState : 'loading';
  126. if (navItem.state == 1) {
  127. param.data.payState = 2;
  128. } else if (navItem.state == 2) {
  129. param.data.payState = 1;
  130. }
  131. this.$request(param).then(res => {
  132. if (res.state == 200) {
  133. navItem.rechargeList = navItem.rechargeList.concat(res.data.list);
  134. let hasMore = this.$checkPaginationHasMore(res.data.pagination); //是否还有数据
  135. if (hasMore) {
  136. navItem.current++;
  137. navItem.loadingState = 'allow_loading_more';
  138. } else {
  139. navItem.loadingState = 'no_more_data';
  140. }
  141. } else {
  142. this.$api.msg(res.msg);
  143. }
  144. if (this.stopPullDownRefresh) {
  145. this.stopPullDownRefresh = false;
  146. uni.stopPullDownRefresh();
  147. }
  148. }).catch((e) => {
  149. //异常处理
  150. })
  151. },
  152. //swiper 切换
  153. changeTab(e) {
  154. this.tabCurrentIndex = e.target.current;
  155. this.loadData('tabChange');
  156. },
  157. //顶部tab点击
  158. tabClick(index) {
  159. this.tabCurrentIndex = index;
  160. },
  161. //马上去逛逛事件
  162. goGoodsList() {
  163. uni.navigateTo({
  164. url: `/pages/product/list`
  165. })
  166. },
  167. //查看详情
  168. viewDetail(id) {
  169. uni.navigateTo({
  170. url: `/pages/recharge/detail?rechargeId=${id}`,
  171. })
  172. },
  173. },
  174. }
  175. </script>
  176. <style lang="scss">
  177. page,
  178. .content {
  179. background: $bg-color-split;
  180. height: 100%;
  181. width: 750rpx;
  182. margin: 0 auto;
  183. }
  184. .swiper-box {
  185. height: calc(100% - 40px);
  186. }
  187. .list-scroll-content {
  188. height: 100%;
  189. }
  190. .navbar {
  191. display: flex;
  192. height: 80rpx;
  193. padding: 0 5px;
  194. background: #fff;
  195. position: relative;
  196. z-index: 10;
  197. .nav-item {
  198. flex: 1;
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. height: 100%;
  203. font-size: 28rpx;
  204. color: $main-font-color;
  205. position: relative;
  206. &.current {
  207. color: $main-color;
  208. font-size: 32rpx;
  209. &:after {
  210. content: '';
  211. position: absolute;
  212. left: 50%;
  213. bottom: 0;
  214. transform: translateX(-50%);
  215. width: 35rpx;
  216. height: 8rpx;
  217. background-color: $main-color;
  218. border-radius: 4rpx;
  219. }
  220. }
  221. }
  222. }
  223. .uni-swiper-item {
  224. height: auto;
  225. }
  226. .log-item {
  227. padding: 30rpx;
  228. background: #fff;
  229. position: relative;
  230. &:first-child {
  231. margin-top: 20rpx;
  232. }
  233. &.b_b:after {
  234. left: 30rpx;
  235. right: 30rpx;
  236. }
  237. .left {
  238. margin-right: 40rpx;
  239. .type {
  240. color: $main-font-color;
  241. font-size: 30rpx;
  242. font-weight: bold;
  243. }
  244. .desc {
  245. color: $main-second-color;
  246. font-size: 26rpx;
  247. margin: 10rpx 0;
  248. }
  249. .time {
  250. color: $main-third-color;
  251. font-size: 22rpx;
  252. margin-top: 10rpx;
  253. }
  254. }
  255. .right {
  256. .amount {
  257. color: #949494;
  258. font-size: 32rpx;
  259. &.add {
  260. color: $main-color;
  261. }
  262. &.flag {
  263. margin-top: -7rpx;
  264. margin-right: 2rpx;
  265. }
  266. }
  267. .iconfont {
  268. color: #949494;
  269. font-size: 20rpx;
  270. margin-left: 19rpx;
  271. }
  272. }
  273. }
  274. .empty_part {
  275. margin-top: 108rpx;
  276. image {
  277. width: 210rpx;
  278. height: 210rpx;
  279. }
  280. text {
  281. color: $main-third-color;
  282. font-size: 26rpx;
  283. margin-top: 57rpx;
  284. }
  285. button {
  286. width: 245rpx;
  287. height: 66rpx;
  288. background: rgba(252, 28, 28, .05);
  289. border-radius: 33rpx;
  290. color: $main-color;
  291. font-size: 30rpx;
  292. font-weight: bold;
  293. margin-top: 29rpx;
  294. }
  295. uni-button:after {
  296. border-radius: 200rpx;
  297. border-color: #fff;
  298. }
  299. }
  300. </style>