commission.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <s-layout class="wallet-wrap" :title="$t('user.wallet.commission.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.commission.my')}}</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-30">
  15. <view class="money-num">{{ state.showMoney ? userInfo.commission : '*****' }}</view>
  16. <view class="ss-flex">
  17. <view class="ss-m-r-20">
  18. <button
  19. class="ss-reset-button withdraw-btn"
  20. @tap="sheep.$router.go('/pages/pay/withdraw')"
  21. >
  22. {{$t('user.wallet.commission.withdraw')}}
  23. </button>
  24. </view>
  25. <button class="ss-reset-button balance-btn ss-m-l-20" @tap="state.showModal = true">
  26. {{$t('user.wallet.commission.tobalance')}}
  27. </button>
  28. </view>
  29. </view>
  30. <view class="ss-flex">
  31. <view class="loading-money">
  32. <view class="loading-money-title">{{$t('user.wallet.commission.unget')}}</view>
  33. <view class="loading-money-num">{{
  34. state.showMoney ? agentInfo.pending_reward || '0.00' : '*****'
  35. }}</view>
  36. </view>
  37. <view class="loading-money ss-m-l-100">
  38. <view class="loading-money-title">{{$t('user.wallet.commission.withdrawAvailable')}}</view>
  39. <view class="loading-money-num">{{
  40. state.showMoney ? userInfo.commission || '0.00' : '*****'
  41. }}</view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <su-sticky>
  47. <!-- 统计 -->
  48. <view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between">
  49. <uni-datetime-picker v-model="state.data" type="daterange" @change="onChangeTime" :end="state.today">
  50. <button class="ss-reset-button date-btn">
  51. <text>{{ dateFilterText }}</text>
  52. <text class="cicon-drop-down ss-seldate-icon"></text>
  53. </button>
  54. </uni-datetime-picker>
  55. <view class="total-box">
  56. <view class="ss-m-b-10">{{$t('user.wallet.commission.income')}}¥{{ state.pagination.income.toFixed(2) }}</view>
  57. <view>{{$t('user.wallet.commission.payout')}}¥{{ (-state.pagination.expense).toFixed(2) }}</view>
  58. </view>
  59. </view>
  60. <su-tabs
  61. :list="tabMaps"
  62. @change="onChangeTab"
  63. :scrollable="false"
  64. :current="state.currentTab"
  65. ></su-tabs>
  66. </su-sticky>
  67. <s-empty
  68. v-if="state.pagination.total === 0"
  69. icon="/static/data-empty.png"
  70. :text="$t('user.wallet.commission.noData')"
  71. ></s-empty>
  72. <!-- 转余额弹框 -->
  73. <su-popup
  74. :show="state.showModal"
  75. type="bottom"
  76. round="20"
  77. @close="state.showModal = false"
  78. showClose
  79. >
  80. <view class="ss-p-x-20 ss-p-y-30">
  81. <view class="model-title ss-m-b-30 ss-m-l-20">{{$t('user.wallet.commission.tobalance')}}</view>
  82. <view class="model-subtitle ss-m-b-100 ss-m-l-20">{{$t('user.wallet.commission.msg1')}}</view>
  83. <view class="input-box ss-flex ss-col-center border-bottom ss-m-b-70 ss-m-x-20">
  84. <view class="unit">¥</view>
  85. <uni-easyinput
  86. :inputBorder="false"
  87. class="ss-flex-1 ss-p-l-10"
  88. v-model="state.amount"
  89. type="number"
  90. :placeholder="$t('user.wallet.commission.enterAmount')"
  91. />
  92. </view>
  93. <button
  94. class="ss-reset-button model-btn ui-BG-Main-Gradient ui-Shadow-Main"
  95. @tap="onConfirm"
  96. >
  97. {{$t('user.wallet.commission.confirm')}}
  98. </button>
  99. </view>
  100. </su-popup>
  101. <!-- 钱包记录 -->
  102. <view v-if="state.pagination.total > 0">
  103. <view
  104. class="wallet-list ss-flex border-bottom"
  105. v-for="item in state.pagination.data"
  106. :key="item.id"
  107. >
  108. <view class="list-content">
  109. <view class="title-box ss-flex ss-row-between ss-m-b-20">
  110. <text class="title ss-line-1"
  111. >{{ item.event_text }}{{ item.memo ? '-' + item.memo : '' }}</text
  112. >
  113. <view class="money">
  114. <text v-if="item.amount >= 0" class="add">+{{ item.amount }}</text>
  115. <text v-else class="minus">{{ item.amount }}</text>
  116. </view>
  117. </view>
  118. <text class="time">{{ item.createtime }}</text>
  119. </view>
  120. </view>
  121. </view>
  122. <!-- <u-gap></u-gap> -->
  123. <uni-load-more
  124. v-if="state.pagination.total > 0"
  125. :status="state.loadStatus"
  126. :content-text="{
  127. contentdown: $t('activity.index.uploadMore'),
  128. }"
  129. />
  130. </s-layout>
  131. </template>
  132. <script setup>
  133. import { computed, reactive } from 'vue';
  134. import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  135. import sheep from '@/sheep';
  136. import dayjs from 'dayjs';
  137. import _ from 'lodash';
  138. const headerBg = sheep.$url.css('/assets/addons/shopro/uniapp/user/wallet_card_bg.png');
  139. // 数据
  140. const pagination = {
  141. data: [],
  142. current_page: 1,
  143. total: 1,
  144. last_page: 1,
  145. expense: 0,
  146. income: 0,
  147. };
  148. const state = reactive({
  149. showMoney: false,
  150. date: [],
  151. currentTab: 0,
  152. pagination,
  153. loadStatus: '',
  154. showModal: false,
  155. today:'',
  156. });
  157. const tabMaps = [
  158. {
  159. name: uni.getLocale() == 'en' ? 'all' : '全部',
  160. value: 'all',
  161. },
  162. {
  163. name: uni.getLocale() == 'en' ? 'income' : '收入',
  164. value: 'income',
  165. },
  166. {
  167. name: uni.getLocale() == 'en' ? 'expenses' : '支出',
  168. value: 'expense',
  169. },
  170. ];
  171. const userInfo = computed(() => sheep.$store('user').userInfo);
  172. const agentInfo = computed(() => sheep.$store('user').agentInfo);
  173. const dateFilterText = computed(() => {
  174. if (state.date[0] === state.date[1]) {
  175. return state.date[0];
  176. } else {
  177. return state.date.join('~');
  178. }
  179. });
  180. async function getLogList(page = 1, list_rows = 8) {
  181. state.loadStatus = 'loading';
  182. let res = await sheep.$api.user.wallet.log({
  183. type: 'commission',
  184. tab: tabMaps[state.currentTab].value,
  185. list_rows,
  186. page,
  187. date: appendTimeHMS(state.date),
  188. });
  189. if (res.code === 1) {
  190. let list = _.concat(state.pagination.data, res.data.list.data);
  191. state.pagination = {
  192. ...res.data.list,
  193. data: list,
  194. income: res.data.income,
  195. expense: res.data.expense,
  196. };
  197. if (state.pagination.current_page < state.pagination.last_page) {
  198. state.loadStatus = 'more';
  199. } else {
  200. state.loadStatus = 'noMore';
  201. }
  202. }
  203. }
  204. function onChangeTab(e) {
  205. state.pagination = pagination;
  206. state.currentTab = e.index;
  207. getLogList();
  208. }
  209. function onChangeTime(e) {
  210. state.date[0] = e[0];
  211. state.date[1] = e[e.length - 1];
  212. state.pagination = pagination;
  213. getLogList();
  214. }
  215. function appendTimeHMS(arr) {
  216. return [arr[0] + ' 00:00:00', arr[1] + ' 23:59:59'];
  217. }
  218. // 确认操作
  219. async function onConfirm() {
  220. if (state.amount <= 0) {
  221. sheep.$helper.toast($t('user.wallet.commission.enterAmount'));
  222. return;
  223. }
  224. uni.showModal({
  225. title: $t('user.wallet.commission.tips'),
  226. content: $t('user.wallet.commission.tipsToBalance'),
  227. success: async function (res) {
  228. if (res.confirm) {
  229. const { code } = await sheep.$api.commission.transfer({
  230. amount: state.amount,
  231. });
  232. if (code === 1) {
  233. state.showModal = false;
  234. sheep.$store('user').getInfo();
  235. onChangeTab({ index: 0 });
  236. }
  237. }
  238. },
  239. });
  240. }
  241. async function getAgentInfo() {
  242. const { code, data } = await sheep.$store('user').getAgentInfo();
  243. }
  244. onLoad(async (options) => {
  245. state.today = dayjs().format('YYYY-MM-DD');
  246. state.date = [state.today, state.today];
  247. getLogList();
  248. getAgentInfo();
  249. });
  250. onReachBottom(() => {
  251. if (state.loadStatus !== 'noMore') {
  252. getLogList(state.pagination.current_page + 1);
  253. }
  254. });
  255. </script>
  256. <style lang="scss" scoped>
  257. // 钱包
  258. .header-box {
  259. background-color: $white;
  260. padding: 30rpx;
  261. .card-box {
  262. width: 100%;
  263. min-height: 300rpx;
  264. padding: 40rpx;
  265. background-size: 100% 100%;
  266. border-radius: 30rpx;
  267. overflow: hidden;
  268. position: relative;
  269. z-index: 1;
  270. box-sizing: border-box;
  271. &::after {
  272. content: '';
  273. display: block;
  274. width: 100%;
  275. height: 100%;
  276. z-index: 2;
  277. position: absolute;
  278. top: 0;
  279. left: 0;
  280. background: v-bind(headerBg) no-repeat;
  281. pointer-events: none;
  282. }
  283. .card-head {
  284. color: $white;
  285. font-size: 24rpx;
  286. }
  287. .ss-eye-icon {
  288. font-size: 40rpx;
  289. color: $white;
  290. }
  291. .money-num {
  292. font-size: 40rpx;
  293. line-height: normal;
  294. font-weight: 500;
  295. color: $white;
  296. font-family: OPPOSANS;
  297. }
  298. .reduce-num {
  299. font-size: 26rpx;
  300. font-weight: 400;
  301. color: $white;
  302. }
  303. .withdraw-btn {
  304. width: 120rpx;
  305. height: 60rpx;
  306. line-height: 60rpx;
  307. border-radius: 30px;
  308. font-size: 24rpx;
  309. font-weight: 500;
  310. background-color: $white;
  311. color: var(--ui-BG-Main);
  312. }
  313. .balance-btn {
  314. width: 120rpx;
  315. height: 60rpx;
  316. line-height: 60rpx;
  317. border-radius: 30px;
  318. font-size: 24rpx;
  319. font-weight: 500;
  320. color: $white;
  321. border: 1px solid $white;
  322. }
  323. }
  324. }
  325. .loading-money {
  326. margin-top: 56rpx;
  327. .loading-money-title {
  328. font-size: 24rpx;
  329. font-weight: 400;
  330. color: #ffffff;
  331. line-height: normal;
  332. margin-bottom: 30rpx;
  333. }
  334. .loading-money-num {
  335. font-size: 30rpx;
  336. font-family: OPPOSANS;
  337. font-weight: 500;
  338. color: #fefefe;
  339. }
  340. }
  341. // 筛选
  342. .filter-box {
  343. height: 120rpx;
  344. padding: 0 30rpx;
  345. background-color: $bg-page;
  346. .total-box {
  347. font-size: 24rpx;
  348. font-weight: 500;
  349. color: $dark-9;
  350. }
  351. .date-btn {
  352. background-color: $white;
  353. line-height: 54rpx;
  354. border-radius: 27rpx;
  355. padding: 0 20rpx;
  356. font-size: 24rpx;
  357. font-weight: 500;
  358. color: $dark-6;
  359. .ss-seldate-icon {
  360. font-size: 50rpx;
  361. color: $dark-9;
  362. }
  363. }
  364. }
  365. // tab
  366. .wallet-tab-card {
  367. .tab-item {
  368. height: 80rpx;
  369. position: relative;
  370. .tab-title {
  371. font-size: 30rpx;
  372. }
  373. .cur-tab-title {
  374. font-weight: $font-weight-bold;
  375. }
  376. .tab-line {
  377. width: 60rpx;
  378. height: 6rpx;
  379. border-radius: 6rpx;
  380. position: absolute;
  381. left: 50%;
  382. transform: translateX(-50%);
  383. bottom: 2rpx;
  384. background-color: var(--ui-BG-Main);
  385. }
  386. }
  387. }
  388. // 钱包记录
  389. .wallet-list {
  390. padding: 30rpx;
  391. background-color: #ffff;
  392. .head-img {
  393. width: 70rpx;
  394. height: 70rpx;
  395. border-radius: 50%;
  396. background: $gray-c;
  397. }
  398. .list-content {
  399. justify-content: space-between;
  400. align-items: flex-start;
  401. flex: 1;
  402. .title {
  403. font-size: 28rpx;
  404. color: $dark-3;
  405. width: 400rpx;
  406. }
  407. .time {
  408. color: $gray-c;
  409. font-size: 22rpx;
  410. }
  411. }
  412. .money {
  413. font-size: 28rpx;
  414. font-weight: bold;
  415. font-family: OPPOSANS;
  416. .add {
  417. color: var(--ui-BG-Main);
  418. }
  419. .minus {
  420. color: $dark-3;
  421. }
  422. }
  423. }
  424. .model-title {
  425. font-size: 36rpx;
  426. font-weight: bold;
  427. color: #333333;
  428. }
  429. .model-subtitle {
  430. font-size: 26rpx;
  431. color: #c2c7cf;
  432. }
  433. .model-btn {
  434. width: 100%;
  435. height: 80rpx;
  436. border-radius: 40rpx;
  437. font-size: 28rpx;
  438. font-weight: 500;
  439. color: #ffffff;
  440. line-height: normal;
  441. }
  442. .input-box {
  443. height: 100rpx;
  444. .unit {
  445. font-size: 48rpx;
  446. color: #333;
  447. font-weight: 500;
  448. line-height: normal;
  449. }
  450. .uni-easyinput__placeholder-class {
  451. font-size: 30rpx;
  452. height: 40rpx;
  453. line-height: normal;
  454. }
  455. }
  456. </style>