wallet.vue 13 KB

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