wallet.vue 11 KB

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