withdraw.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <!-- 分佣提现 -->
  2. <template>
  3. <s-layout title="申请提现" class="withdraw-wrap" navbar="inner">
  4. <view class="page-bg"></view>
  5. <view
  6. class="wallet-num-box ss-flex ss-col-center ss-row-between"
  7. :style="[
  8. {
  9. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  10. paddingTop: Number(statusBarHeight + 108) + 'rpx',
  11. },
  12. ]"
  13. >
  14. <view class="">
  15. <view class="num-title">可提现金额(元)</view>
  16. <view class="wallet-num">{{ fen2yuan(state.brokerageInfo.brokeragePrice) }}</view>
  17. </view>
  18. <button
  19. class="ss-reset-button log-btn"
  20. @tap="sheep.$router.go('/pages/commission/wallet', { type: 2 })"
  21. >
  22. 提现记录
  23. </button>
  24. </view>
  25. <!-- 提现输入卡片-->
  26. <view class="draw-card">
  27. <view class="bank-box ss-flex ss-col-center ss-row-between ss-m-b-30">
  28. <view class="name">提现至</view>
  29. <view class="bank-list ss-flex ss-col-center" @tap="onAccountSelect(true)">
  30. <view v-if="!state.accountInfo.type" class="empty-text">请选择提现方式</view>
  31. <view v-if="state.accountInfo.type === '1'" class="empty-text">钱包余额</view>
  32. <view v-if="state.accountInfo.type === '2'" class="empty-text">银行卡转账</view>
  33. <view v-if="state.accountInfo.type === '3'" class="empty-text">微信零钱</view>
  34. <view v-if="state.accountInfo.type === '4'" class="empty-text">支付宝账户</view>
  35. <text class="cicon-forward" />
  36. </view>
  37. </view>
  38. <!-- 提现金额 -->
  39. <view class="card-title">提现金额</view>
  40. <view class="input-box ss-flex ss-col-center border-bottom">
  41. <view class="unit">¥</view>
  42. <uni-easyinput
  43. :inputBorder="false"
  44. class="ss-flex-1 ss-p-l-10"
  45. v-model="state.accountInfo.price"
  46. type="number"
  47. placeholder="请输入提现金额"
  48. />
  49. </view>
  50. <!-- 提现账号 -->
  51. <view class="card-title" v-show="['2', '3', '4'].includes(state.accountInfo.type)">
  52. 提现账号
  53. </view>
  54. <view
  55. class="input-box ss-flex ss-col-center border-bottom"
  56. v-show="['2', '3', '4'].includes(state.accountInfo.type)"
  57. >
  58. <view class="unit" />
  59. <uni-easyinput
  60. :inputBorder="false"
  61. class="ss-flex-1 ss-p-l-10"
  62. v-model="state.accountInfo.accountNo"
  63. placeholder="请输入提现账号"
  64. />
  65. </view>
  66. <!-- 收款码 -->
  67. <view class="card-title" v-show="['3', '4'].includes(state.accountInfo.type)">收款码</view>
  68. <view
  69. class="input-box ss-flex ss-col-center"
  70. v-show="['3', '4'].includes(state.accountInfo.type)"
  71. >
  72. <view class="unit" />
  73. <view class="upload-img">
  74. <s-uploader
  75. v-model:url="state.accountInfo.accountQrCodeUrl"
  76. fileMediatype="image"
  77. limit="1"
  78. mode="grid"
  79. :imageStyles="{ width: '168rpx', height: '168rpx' }"
  80. />
  81. </view>
  82. </view>
  83. <!-- 持卡人姓名 -->
  84. <view class="card-title" v-show="state.accountInfo.type === '2'">持卡人</view>
  85. <view
  86. class="input-box ss-flex ss-col-center border-bottom"
  87. v-show="state.accountInfo.type === '2'"
  88. >
  89. <view class="unit" />
  90. <uni-easyinput
  91. :inputBorder="false"
  92. class="ss-flex-1 ss-p-l-10"
  93. v-model="state.accountInfo.name"
  94. placeholder="请输入持卡人姓名"
  95. />
  96. </view>
  97. <!-- 提现银行 -->
  98. <view class="card-title" v-show="state.accountInfo.type === '2'">提现银行</view>
  99. <view
  100. class="input-box ss-flex ss-col-center border-bottom"
  101. v-show="state.accountInfo.type === '2'"
  102. >
  103. <view class="unit" />
  104. <!--银入输入改为下拉-->
  105. <!--银行改为下拉选择-->
  106. <picker
  107. @change="bankChange"
  108. :value="state.bankListSelectedIndex"
  109. :range="state.bankList"
  110. range-key="label"
  111. style="width: 100%"
  112. >
  113. <uni-easyinput
  114. :inputBorder="false"
  115. :value="state.accountInfo.bankName"
  116. placeholder="请选择银行"
  117. suffixIcon="right"
  118. disabled
  119. :styles="{ disableColor: '#fff', borderColor: '#fff', color: '#333!important' }"
  120. />
  121. </picker>
  122. </view>
  123. <!-- 开户地址 -->
  124. <view class="card-title" v-show="state.accountInfo.type === '2'">开户地址</view>
  125. <view
  126. class="input-box ss-flex ss-col-center border-bottom"
  127. v-show="state.accountInfo.type === '2'"
  128. >
  129. <view class="unit" />
  130. <uni-easyinput
  131. :inputBorder="false"
  132. class="ss-flex-1 ss-p-l-10"
  133. v-model="state.accountInfo.bankAddress"
  134. placeholder="请输入开户地址"
  135. />
  136. </view>
  137. <button class="ss-reset-button save-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onConfirm">
  138. 确认提现
  139. </button>
  140. </view>
  141. <!-- 提现说明 -->
  142. <view class="draw-notice">
  143. <view class="title ss-m-b-30">提现说明</view>
  144. <view class="draw-list"> 最低提现金额 {{ fen2yuan(state.minPrice) }} 元 </view>
  145. <view class="draw-list">
  146. 冻结佣金:<text>¥{{ fen2yuan(state.brokerageInfo.frozenPrice) }}</text>
  147. (每笔佣金的冻结期为 {{ state.frozenDays }} 天,到期后可提现)
  148. </view>
  149. </view>
  150. <!-- 选择提现账户 -->
  151. <account-type-select
  152. :show="state.accountSelect"
  153. @close="onAccountSelect(false)"
  154. round="10"
  155. v-model="state.accountInfo"
  156. :methods="state.withdrawTypes"
  157. />
  158. </s-layout>
  159. </template>
  160. <script setup>
  161. import { computed, reactive, onBeforeMount } from 'vue';
  162. import sheep from '@/sheep';
  163. import accountTypeSelect from './components/account-type-select.vue';
  164. import { fen2yuan } from '@/sheep/hooks/useGoods';
  165. import TradeConfigApi from '@/sheep/api/trade/config';
  166. import BrokerageApi from '@/sheep/api/trade/brokerage';
  167. import DictApi from '@/sheep/api/system/dict';
  168. const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
  169. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  170. const userStore = sheep.$store('user');
  171. const userInfo = computed(() => userStore.userInfo);
  172. const state = reactive({
  173. accountInfo: {
  174. // 提现表单
  175. type: undefined,
  176. accountNo: undefined,
  177. accountQrCodeUrl: undefined,
  178. name: undefined,
  179. bankName: undefined,
  180. bankAddress: undefined,
  181. },
  182. accountSelect: false,
  183. brokerageInfo: {}, // 分销信息
  184. frozenDays: 0, // 冻结天数
  185. minPrice: 0, // 最低提现金额
  186. withdrawTypes: [], // 提现方式
  187. bankList: [], // 银行字典数据
  188. bankListSelectedIndex: '', // 选中银行 bankList 的 index
  189. });
  190. // 打开提现方式的弹窗
  191. const onAccountSelect = (e) => {
  192. state.accountSelect = e;
  193. };
  194. // 获取提现银行配置字典
  195. async function getDictDataListByType() {
  196. let { code, data } = await DictApi.getDictDataListByType('brokerage_bank_name');
  197. if (code !== 0) {
  198. return;
  199. }
  200. if (data && data.length > 0) {
  201. state.bankList = data;
  202. }
  203. }
  204. //银行下拉选择
  205. // 银行选择
  206. function bankChange(e) {
  207. const value = e.detail.value;
  208. state.bankListSelectedIndex = value;
  209. state.accountInfo.bankName = state.bankList[value].label;
  210. }
  211. // 提交提现
  212. const onConfirm = async () => {
  213. // 参数校验
  214. debugger;
  215. if (
  216. !state.accountInfo.price ||
  217. state.accountInfo.price > state.brokerageInfo.price ||
  218. state.accountInfo.price <= 0
  219. ) {
  220. sheep.$helper.toast('请输入正确的提现金额');
  221. return;
  222. }
  223. if (!state.accountInfo.type) {
  224. sheep.$helper.toast('请选择提现方式');
  225. return;
  226. }
  227. // 提交请求
  228. let { code } = await BrokerageApi.createBrokerageWithdraw({
  229. ...state.accountInfo,
  230. price: state.accountInfo.price * 100,
  231. });
  232. if (code !== 0) {
  233. return;
  234. }
  235. // 提示
  236. uni.showModal({
  237. title: '操作成功',
  238. content: '您的提现申请已成功提交',
  239. cancelText: '继续提现',
  240. confirmText: '查看记录',
  241. success: (res) => {
  242. if (res.confirm) {
  243. sheep.$router.go('/pages/commission/wallet', { type: 2 })
  244. return;
  245. }
  246. getBrokerageUser();
  247. state.accountInfo = {};
  248. }
  249. });
  250. };
  251. // 获得分销配置
  252. async function getWithdrawRules() {
  253. let { code, data } = await TradeConfigApi.getTradeConfig();
  254. if (code !== 0) {
  255. return;
  256. }
  257. if (data) {
  258. state.minPrice = data.brokerageWithdrawMinPrice || 0;
  259. state.frozenDays = data.brokerageFrozenDays || 0;
  260. state.withdrawTypes = data.brokerageWithdrawTypes;
  261. }
  262. }
  263. // 获得分销信息
  264. async function getBrokerageUser() {
  265. const { data, code } = await BrokerageApi.getBrokerageUser();
  266. if (code === 0) {
  267. state.brokerageInfo = data;
  268. }
  269. }
  270. onBeforeMount(() => {
  271. getWithdrawRules();
  272. getBrokerageUser();
  273. getDictDataListByType();//获取银行配置字典
  274. })
  275. </script>
  276. <style lang="scss" scoped>
  277. :deep() {
  278. .uni-input-input {
  279. font-family: OPPOSANS !important;
  280. }
  281. }
  282. .wallet-num-box {
  283. padding: 0 40rpx 80rpx;
  284. background: var(--ui-BG-Main) v-bind(headerBg) center/750rpx 100% no-repeat;
  285. border-radius: 0 0 5% 5%;
  286. .num-title {
  287. font-size: 26rpx;
  288. font-weight: 500;
  289. color: $white;
  290. margin-bottom: 20rpx;
  291. }
  292. .wallet-num {
  293. font-size: 60rpx;
  294. font-weight: 500;
  295. color: $white;
  296. font-family: OPPOSANS;
  297. }
  298. .log-btn {
  299. width: 170rpx;
  300. height: 60rpx;
  301. line-height: 60rpx;
  302. border: 1rpx solid $white;
  303. border-radius: 30rpx;
  304. padding: 0;
  305. font-size: 26rpx;
  306. font-weight: 500;
  307. color: $white;
  308. }
  309. }
  310. // 提现输入卡片
  311. .draw-card {
  312. background-color: $white;
  313. border-radius: 20rpx;
  314. width: 690rpx;
  315. min-height: 560rpx;
  316. margin: -60rpx 30rpx 30rpx 30rpx;
  317. padding: 30rpx;
  318. position: relative;
  319. z-index: 3;
  320. box-sizing: border-box;
  321. .card-title {
  322. font-size: 30rpx;
  323. font-weight: 500;
  324. margin-bottom: 30rpx;
  325. }
  326. .bank-box {
  327. .name {
  328. font-size: 28rpx;
  329. font-weight: 500;
  330. }
  331. .bank-list {
  332. .empty-text {
  333. font-size: 28rpx;
  334. font-weight: 400;
  335. color: $dark-9;
  336. }
  337. .cicon-forward {
  338. color: $dark-9;
  339. }
  340. }
  341. .input-box {
  342. width: 624rpx;
  343. height: 100rpx;
  344. margin-bottom: 40rpx;
  345. .unit {
  346. font-size: 48rpx;
  347. color: #333;
  348. font-weight: 500;
  349. }
  350. .uni-easyinput__placeholder-class {
  351. font-size: 30rpx;
  352. height: 36rpx;
  353. }
  354. :deep(.uni-easyinput__content-input) {
  355. font-size: 48rpx;
  356. }
  357. }
  358. .save-btn {
  359. width: 616rpx;
  360. height: 86rpx;
  361. line-height: 86rpx;
  362. border-radius: 40rpx;
  363. margin-top: 80rpx;
  364. }
  365. }
  366. .bind-box {
  367. .placeholder-text {
  368. font-size: 26rpx;
  369. color: $dark-9;
  370. }
  371. .add-btn {
  372. width: 100rpx;
  373. height: 50rpx;
  374. border-radius: 25rpx;
  375. line-height: 50rpx;
  376. font-size: 22rpx;
  377. color: var(--ui-BG-Main);
  378. background-color: var(--ui-BG-Main-light);
  379. }
  380. }
  381. .input-box {
  382. width: 624rpx;
  383. height: 100rpx;
  384. margin-bottom: 40rpx;
  385. .unit {
  386. font-size: 48rpx;
  387. color: #333;
  388. font-weight: 500;
  389. }
  390. .uni-easyinput__placeholder-class {
  391. font-size: 30rpx;
  392. }
  393. :deep(.uni-easyinput__content-input) {
  394. font-size: 48rpx;
  395. }
  396. }
  397. .save-btn {
  398. width: 616rpx;
  399. height: 86rpx;
  400. line-height: 86rpx;
  401. border-radius: 40rpx;
  402. margin-top: 80rpx;
  403. }
  404. }
  405. // 提现说明
  406. .draw-notice {
  407. width: 684rpx;
  408. background: #ffffff;
  409. border: 2rpx solid #fffaee;
  410. border-radius: 20rpx;
  411. margin: 20rpx 32rpx 0 32rpx;
  412. padding: 30rpx;
  413. box-sizing: border-box;
  414. .title {
  415. font-weight: 500;
  416. color: #333333;
  417. font-size: 30rpx;
  418. }
  419. .draw-list {
  420. font-size: 24rpx;
  421. color: #999999;
  422. line-height: 46rpx;
  423. }
  424. }
  425. </style>