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