withdraw.vue 12 KB

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