accountRecord.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="account-record">
  3. <view class="fix">
  4. <view class="top"></view>
  5. <view class="head">
  6. <span class="cuIcon-back" @click="back"></span>
  7. <view class="case"> {{ navTitle }} </view>
  8. </view>
  9. <!-- 当type为all或settlement时展示Tab -->
  10. <view v-if="showTab" class="tab-container">
  11. <view
  12. class="tab-item"
  13. v-for="(tab, index) in settlementTabs"
  14. :key="index"
  15. :class="{ active: currentTab === index }"
  16. @click="switchTab(index)"
  17. >
  18. {{ tab }}
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 列表区域 -->
  23. <mescroll-uni
  24. class="list-box"
  25. ref="mescrollRef"
  26. :fixed="false"
  27. @up="getList"
  28. @down="downCallback"
  29. @init="mescrollInit"
  30. :use="false"
  31. >
  32. <AccountList :list="accountData"></AccountList>
  33. </mescroll-uni>
  34. </view>
  35. </template>
  36. <script>
  37. import api from '@/api/account';
  38. import AccountList from './components/account-list.vue';
  39. export default {
  40. name: 'AccountRecord',
  41. components: {
  42. AccountList,
  43. },
  44. computed: {
  45. navTitle() {
  46. switch (this.type) {
  47. case 'all':
  48. return '账户明细';
  49. case 'pending':
  50. return '待结算明细';
  51. case 'auditing':
  52. return '提现审核中';
  53. case 'completed':
  54. return '已提现明细';
  55. default:
  56. return '账户明细';
  57. }
  58. },
  59. },
  60. data() {
  61. return {
  62. settlementTabs: ['全部', '结算', '提现'],
  63. params: {},
  64. currentTab: 0,
  65. type: '',
  66. showTab: false,
  67. accountData: [],
  68. };
  69. },
  70. onLoad(options) {
  71. if (options.type) {
  72. this.type = options.type;
  73. if (this.type === 'all' || this.type === 'settlement') {
  74. this.showTab = true;
  75. this.currentTab = this.type === 'all' ? 0 : 1;
  76. } else {
  77. this.showTab = false;
  78. }
  79. }
  80. this.mescroll && this.mescroll.triggerUpScroll();
  81. },
  82. onShow() {
  83. if (this.accountData.length === 0) {
  84. this.mescroll && this.mescroll.triggerUpScroll();
  85. }
  86. },
  87. methods: {
  88. mescrollInit(mescroll) {
  89. this.mescroll = mescroll;
  90. },
  91. // 下拉刷新
  92. downCallback() {
  93. this.mescroll.resetUpScroll();
  94. this.accountData = [];
  95. },
  96. // 切换Tab
  97. switchTab(index) {
  98. this.currentTab = index;
  99. this.params.mainType = index === 0 ? '' : index === 1 ? 'SETTLE' : 'WITHDRAW';
  100. this.getList({ num: 1, size: 10, ...this.params });
  101. },
  102. // 获取列表数据
  103. getList(page) {
  104. let params = this.buildParams(page);
  105. api
  106. .getAccountList(params)
  107. .then((res) => {
  108. if (res.data.code === 200) {
  109. const records = res.data.result.records;
  110. const total = res.data.result.total;
  111. if (page.num === 1) {
  112. this.accountData = records;
  113. } else {
  114. this.accountData = this.accountData.concat(records);
  115. }
  116. this.mescroll.endSuccess(records.length, total);
  117. if (this.accountData.length < 5) {
  118. this.$refs.mescrollRef.upLoadType = 'NO_DATA';
  119. }
  120. } else {
  121. this.accountData = [];
  122. this.mescroll.endErr();
  123. }
  124. })
  125. .catch(() => {
  126. this.mescroll.endErr();
  127. });
  128. },
  129. // 请求参数
  130. buildParams(page) {
  131. let params = {
  132. pageSize: page.size,
  133. pageNo: page.num,
  134. };
  135. if (this.type === 'all' || this.type === 'settlement') {
  136. switch (this.currentTab) {
  137. case 0: // 全部
  138. params.mainType = '';
  139. break;
  140. case 1: // 结算
  141. params.mainType = 'SETTLE';
  142. break;
  143. case 2: // 提现
  144. params.mainType = 'WITHDRAW';
  145. break;
  146. }
  147. } else if (this.type === 'pending') {
  148. params.mainType = 'SETTLE';
  149. params.subType = 'PENDING';
  150. } else if (this.type === 'auditing') {
  151. params.mainType = 'WITHDRAW';
  152. params.subType = 'PENDING';
  153. } else if (this.type === 'completed') {
  154. params.mainType = 'WITHDRAW';
  155. params.subType = 'DONE';
  156. }
  157. return params;
  158. },
  159. resetList() {
  160. // 重置页码
  161. if (this.mescroll) {
  162. this.mescroll.resetUpScroll();
  163. }
  164. this.accountData = [];
  165. },
  166. back() {
  167. uni.navigateBack({
  168. delta: 1,
  169. });
  170. },
  171. },
  172. };
  173. </script>
  174. <style lang="scss" scoped>
  175. .account-record {
  176. width: 100vw;
  177. height: 100vh;
  178. position: fixed;
  179. background: #f7f8fc;
  180. .fix {
  181. width: 100%;
  182. height: auto;
  183. background: #ffffff;
  184. position: sticky;
  185. top: 0px;
  186. /*#ifdef APP-PLUS*/
  187. .top {
  188. width: 100%;
  189. height: var(--status-bar-height);
  190. background: #fff;
  191. }
  192. /*#endif*/
  193. .head {
  194. width: 100%;
  195. height: 112rpx;
  196. padding: 20rpx;
  197. display: flex;
  198. align-items: center;
  199. background: #fff;
  200. position: relative;
  201. border-bottom: 1rpx solid #eeeeee;
  202. .cuIcon-back {
  203. font-size: 40rpx;
  204. margin-right: 40rpx;
  205. }
  206. .case {
  207. position: absolute;
  208. left: 50%;
  209. transform: translateX(-50%);
  210. font-weight: 500;
  211. font-size: 38rpx;
  212. color: #333333;
  213. }
  214. }
  215. }
  216. .tab-container {
  217. display: flex;
  218. width: 100%;
  219. height: 80rpx;
  220. line-height: 80rpx;
  221. background: #fff;
  222. .tab-item {
  223. flex: 1;
  224. text-align: center;
  225. font-weight: 400;
  226. font-size: 29rpx;
  227. color: #333333;
  228. position: relative;
  229. &.active {
  230. font-weight: 500;
  231. font-size: 31rpx;
  232. color: #449aff;
  233. &::after {
  234. content: '';
  235. position: absolute;
  236. bottom: 5rpx;
  237. left: 50%;
  238. transform: translateX(-50%);
  239. width: 50rpx;
  240. height: 6rpx;
  241. background: #449aff;
  242. border-radius: 7rpx;
  243. }
  244. }
  245. }
  246. }
  247. .list-box {
  248. height: 80vh;
  249. flex: 1;
  250. overflow-y: auto;
  251. padding: 10rpx 31rpx;
  252. font-size: 28rpx;
  253. color: #333;
  254. margin: 17rpx 31rpx;
  255. background: #fff;
  256. border-radius: 10rpx;
  257. }
  258. }
  259. </style>