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. getLogList();
  211. }
  212. function appendTimeHMS(arr) {
  213. return [arr[0] + ' 00:00:00', arr[1] + ' 23:59:59'];
  214. }
  215. // 确认操作
  216. async function onConfirm() {
  217. if (state.amount <= 0) {
  218. sheep.$helper.toast('请输入正确的金额');
  219. return;
  220. }
  221. uni.showModal({
  222. title: '提示',
  223. content: '确认把您的佣金转入到余额钱包中?',
  224. success: async function (res) {
  225. if (res.confirm) {
  226. const { error } = await sheep.$api.commission.transfer({
  227. amount: state.amount,
  228. });
  229. if (error === 0) {
  230. state.showModal = false;
  231. sheep.$store('user').getInfo();
  232. onChangeTab({ index: 0 });
  233. }
  234. }
  235. },
  236. });
  237. }
  238. onLoad(async (options) => {
  239. const today = dayjs().format('YYYY-MM-DD');
  240. state.date = [today, today];
  241. getLogList();
  242. });
  243. onReachBottom(() => {
  244. if (state.loadStatus !== 'noMore') {
  245. getLogList(state.pagination.current_page + 1);
  246. }
  247. });
  248. </script>
  249. <style lang="scss" scoped>
  250. // 钱包
  251. .header-box {
  252. background-color: $white;
  253. padding: 30rpx;
  254. .card-box {
  255. width: 100%;
  256. min-height: 300rpx;
  257. padding: 40rpx;
  258. background-size: 100% 100%;
  259. border-radius: 30rpx;
  260. overflow: hidden;
  261. position: relative;
  262. z-index: 1;
  263. box-sizing: border-box;
  264. &::after {
  265. content: '';
  266. display: block;
  267. width: 100%;
  268. height: 100%;
  269. z-index: 2;
  270. position: absolute;
  271. top: 0;
  272. left: 0;
  273. background: v-bind("sheep.$url.css('/static/img/shop/user/wallet_card_bg.png')") no-repeat;
  274. pointer-events: none;
  275. }
  276. .card-head {
  277. color: $white;
  278. font-size: 24rpx;
  279. }
  280. .ss-eye-icon {
  281. font-size: 40rpx;
  282. color: $white;
  283. }
  284. .money-num {
  285. font-size: 40rpx;
  286. line-height: normal;
  287. font-weight: 500;
  288. color: $white;
  289. font-family: OPPOSANS;
  290. }
  291. .reduce-num {
  292. font-size: 26rpx;
  293. font-weight: 400;
  294. color: $white;
  295. }
  296. .withdraw-btn {
  297. width: 120rpx;
  298. height: 60rpx;
  299. line-height: 60rpx;
  300. border-radius: 30px;
  301. font-size: 24rpx;
  302. font-weight: 500;
  303. background-color: $white;
  304. color: var(--ui-BG-Main);
  305. }
  306. .balance-btn {
  307. width: 120rpx;
  308. height: 60rpx;
  309. line-height: 60rpx;
  310. border-radius: 30px;
  311. font-size: 24rpx;
  312. font-weight: 500;
  313. color: $white;
  314. border: 1px solid $white;
  315. }
  316. }
  317. }
  318. .loading-money {
  319. margin-top: 56rpx;
  320. .loading-money-title {
  321. font-size: 24rpx;
  322. font-weight: 400;
  323. color: #ffffff;
  324. line-height: normal;
  325. margin-bottom: 30rpx;
  326. }
  327. .loading-money-num {
  328. font-size: 30rpx;
  329. font-family: OPPOSANS;
  330. font-weight: 500;
  331. color: #fefefe;
  332. }
  333. }
  334. // 筛选
  335. .filter-box {
  336. height: 120rpx;
  337. padding: 0 30rpx;
  338. background-color: $bg-page;
  339. .total-box {
  340. font-size: 24rpx;
  341. font-weight: 500;
  342. color: $dark-9;
  343. }
  344. .date-btn {
  345. background-color: $white;
  346. line-height: 54rpx;
  347. border-radius: 27rpx;
  348. padding: 0 20rpx;
  349. font-size: 24rpx;
  350. font-weight: 500;
  351. color: $dark-6;
  352. .ss-seldate-icon {
  353. font-size: 50rpx;
  354. color: $dark-9;
  355. }
  356. }
  357. }
  358. // tab
  359. .wallet-tab-card {
  360. .tab-item {
  361. height: 80rpx;
  362. position: relative;
  363. .tab-title {
  364. font-size: 30rpx;
  365. }
  366. .cur-tab-title {
  367. font-weight: $font-weight-bold;
  368. }
  369. .tab-line {
  370. width: 60rpx;
  371. height: 6rpx;
  372. border-radius: 6rpx;
  373. position: absolute;
  374. left: 50%;
  375. transform: translateX(-50%);
  376. bottom: 2rpx;
  377. background-color: var(--ui-BG-Main);
  378. }
  379. }
  380. }
  381. // 钱包记录
  382. .wallet-list {
  383. padding: 30rpx;
  384. background-color: #ffff;
  385. .head-img {
  386. width: 70rpx;
  387. height: 70rpx;
  388. border-radius: 50%;
  389. background: $gray-c;
  390. }
  391. .list-content {
  392. justify-content: space-between;
  393. align-items: flex-start;
  394. flex: 1;
  395. .title {
  396. font-size: 28rpx;
  397. color: $dark-3;
  398. width: 400rpx;
  399. }
  400. .time {
  401. color: $gray-c;
  402. font-size: 22rpx;
  403. }
  404. }
  405. .money {
  406. font-size: 28rpx;
  407. font-weight: bold;
  408. font-family: OPPOSANS;
  409. .add {
  410. color: var(--ui-BG-Main);
  411. }
  412. .minus {
  413. color: $dark-3;
  414. }
  415. }
  416. }
  417. .model-title {
  418. font-size: 36rpx;
  419. font-weight: bold;
  420. color: #333333;
  421. }
  422. .model-subtitle {
  423. font-size: 26rpx;
  424. color: #c2c7cf;
  425. }
  426. .model-btn {
  427. width: 100%;
  428. height: 80rpx;
  429. border-radius: 40rpx;
  430. font-size: 28rpx;
  431. font-weight: 500;
  432. color: #ffffff;
  433. line-height: normal;
  434. }
  435. .input-box {
  436. height: 100rpx;
  437. .unit {
  438. font-size: 48rpx;
  439. color: #333;
  440. font-weight: 500;
  441. line-height: normal;
  442. }
  443. .uni-easyinput__placeholder-class {
  444. font-size: 30rpx;
  445. height: 40rpx;
  446. line-height: normal;
  447. }
  448. }
  449. </style>