money.vue 7.3 KB

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