wallet.vue 11 KB

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