commission.vue 11 KB

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