commission.vue 12 KB

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