withdraw.vue 12 KB

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