balance.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view class="container">
  3. <view class="top"></view>
  4. <view class="head">
  5. <span class="cuIcon-back" @click="back"></span>
  6. <view class="case"> 账户余额 </view>
  7. </view>
  8. <view class="main-box">
  9. <view class="one-box">
  10. <view>
  11. <view class="title">账户余额(元)</view>
  12. <view class="money">{{ formatAmount(balance) }}</view>
  13. </view>
  14. <view v-if="1">
  15. <view class="btn-cash" @click="toPage('withdrawal')">
  16. <image src="/static/finance/account/cash.png" mode="aspectFit" class="btn-img"></image>
  17. <view>提现</view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="two-box">
  22. <u-grid :col="4" :border="false">
  23. <u-grid-item
  24. v-for="(item, k) in accountMenus"
  25. :key="k"
  26. :customStyle="{
  27. paddingTop: '21rpx',
  28. paddingBottom: '21rpx',
  29. }"
  30. style="background: 'none'"
  31. @click="toPage(item.type)"
  32. >
  33. <image class="icon" :src="item.icon" mode="aspectFit"></image>
  34. <text class="desc">{{ item.title }}</text>
  35. </u-grid-item>
  36. </u-grid>
  37. </view>
  38. <view class="thr-box">
  39. <u-sticky :offset-top="20" :customNavHeight="54">
  40. <view class="section-title">
  41. <view>
  42. <text>账户明细</text>
  43. </view>
  44. <view class="action" @click="toPage('all')">
  45. <text>全部</text>
  46. <u-icon name="arrow-right" color="#999" size="26" top="1"></u-icon>
  47. </view>
  48. </view>
  49. </u-sticky>
  50. <!-- 账户列表 -->
  51. <mescroll-uni
  52. class="list-box"
  53. ref="mescrollRef"
  54. :fixed="false"
  55. @up="getList"
  56. @down="downCallback"
  57. @init="mescrollInit"
  58. :use="{ up: true, down: true }"
  59. >
  60. <AccountList :list="accountData"></AccountList>
  61. </mescroll-uni>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import api from '@/api/account';
  68. import { formatAmount } from '@/common/util/util';
  69. import { accountMenus } from './dictionary';
  70. import AccountList from './components/account-list.vue';
  71. export default {
  72. name: 'Finance',
  73. components: {
  74. AccountList,
  75. },
  76. data() {
  77. return {
  78. accountMenus,
  79. formatAmount,
  80. accountData: [],
  81. mescroll: null,
  82. balance: 0,
  83. };
  84. },
  85. onShow() {
  86. if (!this.balance) {
  87. this.getFinanceInfo();
  88. }
  89. },
  90. onLoad(options) {
  91. this.balance = options.balance;
  92. },
  93. methods: {
  94. getFinanceInfo() {
  95. api.getAccountInfo().then((res) => {
  96. if (res.data.code === 200 && res.data.result) {
  97. this.balance = res.data.result.availableAmount;
  98. }
  99. });
  100. },
  101. // 账户列表
  102. getList(page) {
  103. let params = {
  104. pageNo: page.num,
  105. pageSize: page.size,
  106. };
  107. api
  108. .getAccountList(params)
  109. .then((res) => {
  110. if (res.data.code === 200) {
  111. const records = res.data.result.records;
  112. const total = res.data.result.total;
  113. if (records == null && page.num === 1) {
  114. this.accountData = [];
  115. } else {
  116. this.accountData = records ? this.accountData.concat(records) : this.accountData;
  117. }
  118. this.mescroll.endSuccess(records.length, total);
  119. if (this.accountData.length < 5) {
  120. this.$refs.mescrollRef.upLoadType = 'NO_DATA';
  121. }
  122. } else {
  123. this.accountData = [];
  124. this.mescroll.endErr();
  125. }
  126. })
  127. .catch(() => {
  128. this.mescroll.endErr();
  129. });
  130. },
  131. // 跳转账户明细
  132. toPage(type) {
  133. let path = type === 'withdrawal' ? type : `accountRecord?type=${type}`;
  134. uni.navigateTo({
  135. url: `/pages/finance/${path}`,
  136. });
  137. },
  138. mescrollInit(mescroll) {
  139. this.mescroll = mescroll;
  140. },
  141. // 下拉刷新
  142. downCallback() {
  143. this.mescroll.resetUpScroll();
  144. this.accountData = [];
  145. },
  146. back() {
  147. uni.switchTab({
  148. url: '/pages/finance/index',
  149. });
  150. },
  151. },
  152. };
  153. </script>
  154. <style lang="scss" scoped>
  155. .container {
  156. width: 100%;
  157. height: 100vh;
  158. background: #f7f8fc;
  159. font-family: Source Han Sans SC;
  160. position: fixed;
  161. overflow: hidden;
  162. /*#ifdef APP-PLUS*/
  163. .top {
  164. width: 100%;
  165. height: var(--status-bar-height);
  166. background: #fff;
  167. }
  168. /*#endif*/
  169. .head {
  170. width: 100%;
  171. height: 112rpx;
  172. padding: 20rpx;
  173. display: flex;
  174. align-items: center;
  175. background: #fff;
  176. position: fixed;
  177. z-index: 999;
  178. border-bottom: 1rpx solid #eeeeee;
  179. .cuIcon-back {
  180. font-size: 40rpx;
  181. margin-right: 40rpx;
  182. }
  183. .case {
  184. position: absolute;
  185. left: 50%;
  186. transform: translateX(-50%);
  187. font-weight: 500;
  188. font-size: 38rpx;
  189. color: #333333;
  190. }
  191. }
  192. .main-box {
  193. border-top: 1rpx solid #eeeeee;
  194. padding-top: 112rpx;
  195. .one-box {
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: center;
  199. margin: 22rpx 31rpx 0;
  200. padding: 21rpx 19rpx 19rpx 31rpx;
  201. background: linear-gradient(286deg, #34bbff 0%, #4496fb 100%);
  202. box-shadow: 0rpx 4rpx 10rpx 0rpx #dae3f4;
  203. border-radius: 21rpx 21rpx 0rpx 0rpx;
  204. .title {
  205. font-family: Source Han Sans CN;
  206. font-weight: 400;
  207. font-size: 25rpx;
  208. color: #ffffff;
  209. }
  210. .money {
  211. font-family: DIN Alternate;
  212. font-weight: bold;
  213. font-size: 63rpx;
  214. color: #ffffff;
  215. }
  216. .item {
  217. font-weight: 400;
  218. font-size: 26rpx;
  219. color: #666666;
  220. }
  221. .btn-cash {
  222. display: flex;
  223. justify-content: center;
  224. align-items: center;
  225. width: 144rpx;
  226. height: 63rpx;
  227. background: #ffffff;
  228. border-radius: 8rpx 8rpx 8rpx 8rpx;
  229. font-family: Source Han Sans SC;
  230. font-weight: 500;
  231. font-size: 29rpx;
  232. color: #38b2fe;
  233. .btn-img {
  234. width: 33rpx;
  235. height: 33rpx;
  236. margin-right: 10rpx;
  237. }
  238. }
  239. }
  240. .two-box {
  241. height: 151rpx;
  242. background: linear-gradient(180deg, #c3ebff 0%, #f7f8fc 100%);
  243. box-shadow: inset 0rpx 2rpx 0rpx 0rpx rgba(255, 255, 255, 0.4);
  244. border-radius: 21rpx 21rpx 0rpx 0rpx;
  245. .icon {
  246. width: 62rpx;
  247. height: 62rpx;
  248. }
  249. .desc {
  250. font-weight: 400;
  251. font-size: 25rpx;
  252. color: #7a7f89;
  253. margin-top: 10rpx;
  254. }
  255. }
  256. .thr-box {
  257. margin: 10rpx 31rpx 40rpx;
  258. padding: 0 31rpx 31rpx;
  259. background: #ffffff;
  260. border-radius: 10rpx 10rpx 10rpx 10rpx;
  261. max-height: 65vh;
  262. overflow-y: auto;
  263. display: flex;
  264. flex-direction: column;
  265. .section-title {
  266. width: 100%;
  267. height: 80rpx;
  268. font-weight: 500;
  269. font-size: 31rpx;
  270. color: #333333;
  271. display: flex;
  272. align-items: center;
  273. justify-content: space-between;
  274. background: #fff;
  275. border-bottom: 1rpx solid #eeeeee;
  276. }
  277. .list-box {
  278. flex: 1;
  279. overflow-y: auto;
  280. }
  281. .action {
  282. font-weight: 400;
  283. font-size: 27rpx;
  284. color: #666666;
  285. display: flex;
  286. align-items: center;
  287. }
  288. }
  289. }
  290. }
  291. ::v-deep {
  292. .u-grid-item {
  293. background: none;
  294. }
  295. }
  296. </style>