commission.vue 12 KB

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