money.vue 8.3 KB

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