commission.vue 12 KB

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