money.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <s-layout class="wallet-wrap" title="钱包">
  3. <!-- 钱包卡片 -->
  4. <view class="header-box ss-flex ss-row-center ss-col-center">
  5. <view class="card-box ui-BG-Main ui-Shadow-Main">
  6. <view class="card-head ss-flex ss-col-center">
  7. <view class="card-title ss-m-r-10">钱包余额(元)</view>
  8. <view @tap="state.showMoney = !state.showMoney" class="ss-eye-icon"
  9. :class="state.showMoney ? 'cicon-eye' : 'cicon-eye-off'"></view>
  10. </view>
  11. <view class="ss-flex ss-row-between ss-col-center ss-m-t-64">
  12. <view class="money-num">{{ state.showMoney ? userInfo.money : '*****' }}</view>
  13. <button class="ss-reset-button topup-btn" @tap="sheep.$router.go('/pages/pay/recharge')">
  14. 充值
  15. </button>
  16. </view>
  17. </view>
  18. </view>
  19. <su-sticky>
  20. <!-- 统计 -->
  21. <view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between">
  22. <!-- <uni-datetime-picker v-model="state.data" type="daterange" @change="onChangeTime" :end="state.today">
  23. <button class="ss-reset-button date-btn">
  24. <text>{{ dateFilterText }}</text>
  25. <text class="cicon-drop-down ss-seldate-icon"></text>
  26. </button>
  27. </uni-datetime-picker> -->
  28. <view class="total-box">
  29. <!-- state.pagination.income.toFixed(2) -->
  30. <view class="ss-m-b-10">总收入¥{{ }}</view>
  31. <view>总支出¥{{ }}</view>
  32. <!-- (-state.pagination.expense).toFixed(2) -->
  33. </view>
  34. </view>
  35. <su-tabs :list="tabMaps" @change="onChange" :scrollable="false" :current="state.currentTab"></su-tabs>
  36. </su-sticky>
  37. <s-empty v-if="state.pagination.total === 0" text="暂无数据" icon="/static/data-empty.png" />
  38. <!-- 钱包记录 -->
  39. <view v-if="state.pagination.total > 0">
  40. <view class="wallet-list ss-flex border-bottom" v-for="item in state.pagination.data" :key="item.id">
  41. <view class="list-content">
  42. <view class="title-box ss-flex ss-row-between ss-m-b-20">
  43. <!-- <text class="title ss-line-1">{{ item.event_text }}{{ item.memo ? '-' + item.memo : '' }}</text> -->
  44. <text class="title ss-line-1">{{ item.title }}</text>
  45. <view class="money">
  46. <text v-if="(item.amount >= 0||item.price>=0)" class="add">+{{ item.amount||item.price }}</text>
  47. <text v-else class="minus">{{ item.price }}</text>
  48. </view>
  49. </view>
  50. <text class="time">{{ item.createTime }}</text>
  51. </view>
  52. </view>
  53. </view>
  54. <uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
  55. contentdown: '上拉加载更多',
  56. }" />
  57. </s-layout>
  58. </template>
  59. <script setup>
  60. import {
  61. computed,
  62. watch,
  63. reactive
  64. } from 'vue';
  65. import {
  66. onLoad,
  67. onReachBottom
  68. } from '@dcloudio/uni-app';
  69. import sheep from '@/sheep';
  70. import dayjs from 'dayjs';
  71. import _ from 'lodash';
  72. const headerBg = sheep.$url.css('/static/img/shop/user/wallet_card_bg.png');
  73. const pagination = {
  74. data: [],
  75. current_page: 1,
  76. total: 1,
  77. last_page: 1,
  78. expense: 0,
  79. income: 0,
  80. };
  81. // 数据
  82. const state = reactive({
  83. showMoney: false,
  84. date: [],
  85. currentTab: 0,
  86. pagination,
  87. loadStatus: '',
  88. today: '',
  89. });
  90. const tabMaps = [{
  91. name: '全部',
  92. // value: 'all',
  93. },
  94. {
  95. name: '收入',
  96. value: '1',
  97. },
  98. {
  99. name: '支出',
  100. value: '2',
  101. },
  102. ];
  103. const userInfo = computed(() => sheep.$store('user').userInfo);
  104. console.log(userInfo)
  105. const dateFilterText = computed(() => {
  106. if (state.date[0] === state.date[1]) {
  107. return state.date[0];
  108. } else {
  109. return state.date.join('~');
  110. }
  111. });
  112. async function getLogList(page = 1, list_rows = 8) {
  113. // state.loadStatus = 'loading';
  114. let res = await sheep.$api.user.wallet.log({
  115. // type: 'money',
  116. type: tabMaps[state.currentTab].value,
  117. pageSize: list_rows,
  118. pageNo: page,
  119. // date: appendTimeHMS(state.date),
  120. });
  121. if (res.code === 0) {
  122. let list = _.concat(state.pagination.data, res.data.list);
  123. state.pagination = {
  124. ...res.data,
  125. data: list,
  126. income: res.data.income,
  127. expense: res.data.expense,
  128. };
  129. console.log('交易数据',state.pagination)
  130. if (state.pagination.current_page < state.pagination.last_page) {
  131. state.loadStatus = 'more';
  132. } else {
  133. state.loadStatus = 'noMore';
  134. }
  135. }
  136. }
  137. onLoad(async (options) => {
  138. state.today = dayjs().format('YYYY-MM-DD');
  139. state.date = [state.today, state.today];
  140. getLogList();
  141. });
  142. function onChange(e) {
  143. state.pagination = pagination;
  144. state.currentTab = e.index;
  145. getLogList();
  146. }
  147. function onChangeTime(e) {
  148. state.date[0] = e[0];
  149. state.date[1] = e[e.length - 1];
  150. state.pagination = pagination;
  151. getLogList();
  152. }
  153. function appendTimeHMS(arr) {
  154. return [arr[0] + ' 00:00:00', arr[1] + ' 23:59:59'];
  155. }
  156. onReachBottom(() => {
  157. if (state.loadStatus !== 'noMore') {
  158. getLogList(state.pagination.current_page + 1);
  159. }
  160. });
  161. </script>
  162. <style lang="scss" scoped>
  163. // 钱包
  164. .header-box {
  165. background-color: $white;
  166. padding: 30rpx;
  167. .card-box {
  168. width: 100%;
  169. min-height: 300rpx;
  170. padding: 40rpx;
  171. background-size: 100% 100%;
  172. border-radius: 30rpx;
  173. overflow: hidden;
  174. position: relative;
  175. z-index: 1;
  176. box-sizing: border-box;
  177. &::after {
  178. content: '';
  179. display: block;
  180. width: 100%;
  181. height: 100%;
  182. z-index: 2;
  183. position: absolute;
  184. top: 0;
  185. left: 0;
  186. background: v-bind(headerBg) no-repeat;
  187. pointer-events: none;
  188. }
  189. .card-head {
  190. color: $white;
  191. font-size: 30rpx;
  192. }
  193. .ss-eye-icon {
  194. font-size: 40rpx;
  195. color: $white;
  196. }
  197. .money-num {
  198. font-size: 70rpx;
  199. line-height: 70rpx;
  200. font-weight: 500;
  201. color: $white;
  202. font-family: OPPOSANS;
  203. }
  204. .reduce-num {
  205. font-size: 26rpx;
  206. font-weight: 400;
  207. color: $white;
  208. }
  209. .topup-btn {
  210. width: 120rpx;
  211. height: 60rpx;
  212. line-height: 60rpx;
  213. border-radius: 30px;
  214. font-size: 26rpx;
  215. font-weight: 500;
  216. background-color: $white;
  217. color: var(--ui-BG-Main);
  218. }
  219. }
  220. }
  221. // 筛选
  222. .filter-box {
  223. height: 114rpx;
  224. background-color: $bg-page;
  225. .total-box {
  226. font-size: 24rpx;
  227. font-weight: 500;
  228. color: $dark-9;
  229. }
  230. .date-btn {
  231. background-color: $white;
  232. line-height: 54rpx;
  233. border-radius: 27rpx;
  234. padding: 0 20rpx;
  235. font-size: 24rpx;
  236. font-weight: 500;
  237. color: $dark-6;
  238. .ss-seldate-icon {
  239. font-size: 50rpx;
  240. color: $dark-9;
  241. }
  242. }
  243. }
  244. .tabs-box {
  245. background: $white;
  246. border-bottom: 2rpx solid #eeeeee;
  247. }
  248. // tab
  249. .wallet-tab-card {
  250. .tab-item {
  251. height: 80rpx;
  252. position: relative;
  253. .tab-title {
  254. font-size: 30rpx;
  255. }
  256. .cur-tab-title {
  257. font-weight: $font-weight-bold;
  258. }
  259. .tab-line {
  260. width: 60rpx;
  261. height: 6rpx;
  262. border-radius: 6rpx;
  263. position: absolute;
  264. left: 50%;
  265. transform: translateX(-50%);
  266. bottom: 2rpx;
  267. background-color: var(--ui-BG-Main);
  268. }
  269. }
  270. }
  271. // 钱包记录
  272. .wallet-list {
  273. padding: 30rpx;
  274. background-color: #ffff;
  275. .head-img {
  276. width: 70rpx;
  277. height: 70rpx;
  278. border-radius: 50%;
  279. background: $gray-c;
  280. }
  281. .list-content {
  282. justify-content: space-between;
  283. align-items: flex-start;
  284. flex: 1;
  285. .title {
  286. font-size: 28rpx;
  287. color: $dark-3;
  288. width: 400rpx;
  289. }
  290. .time {
  291. color: $gray-c;
  292. font-size: 22rpx;
  293. }
  294. }
  295. .money {
  296. font-size: 28rpx;
  297. font-weight: bold;
  298. font-family: OPPOSANS;
  299. .add {
  300. color: var(--ui-BG-Main);
  301. }
  302. .minus {
  303. color: $dark-3;
  304. }
  305. }
  306. }
  307. </style>