withdraw.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <s-layout title="申请提现" class="withdraw-wrap" navbar="inner">
  3. <!-- <view class="page-bg"></view> -->
  4. <!-- <view class="wallet-num-box ss-flex ss-col-center ss-row-between" :style="[
  5. {
  6. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  7. paddingTop: Number(statusBarHeight + 108) + 'rpx',
  8. },
  9. ]">
  10. <view class="">
  11. <view class="num-title">可提现金额(元)</view>
  12. <view class="wallet-num">{{ userInfo.commission }}</view>
  13. </view>
  14. <button class="ss-reset-button log-btn" @tap="sheep.$router.go('/pages/pay/withdraw-log')">提现记录</button>
  15. </view> -->
  16. <!-- 提现输入卡片-->
  17. <view class="draw-card">
  18. <view class="card-title">提现金额</view>
  19. <view class="input-box ss-flex ss-col-center border-bottom">
  20. <view class="unit">¥</view>
  21. <uni-easyinput :inputBorder="false" class="ss-flex-1 ss-p-l-10" v-model="state.amount" type="number"
  22. placeholder="请输入提现金额" />
  23. </view>
  24. <view class="card-title">持卡人</view>
  25. <view class="input-box ss-flex ss-col-center border-bottom">
  26. <view class="unit"></view>
  27. <uni-easyinput :inputBorder="false" class="ss-flex-1 ss-p-l-10" v-model="state.name"
  28. placeholder="请输入持卡人姓名" />
  29. </view>
  30. <view class="card-title">卡号</view>
  31. <view class="input-box ss-flex ss-col-center border-bottom">
  32. <view class="unit"></view>
  33. <uni-easyinput :inputBorder="false" class="ss-flex-1 ss-p-l-10" v-model="state.accountNo"
  34. placeholder="请输卡号" />
  35. </view>
  36. <view class="bank-box ss-flex ss-col-center ss-row-between ss-m-b-30">
  37. <view class="name">选择银行</view>
  38. <view class="bank-list ss-flex ss-col-center" @tap="onAccountSelect(true)">
  39. <view v-if="!state.accountInfo.type" class="empty-text">请选择提现方式</view>
  40. <view v-if="state.accountInfo.type === '0'" class="empty-text">工商银行</view>
  41. <view v-if="state.accountInfo.type === '1'" class="empty-text">建设银行</view>
  42. <view v-if="state.accountInfo.type === '2'" class="empty-text">农业银行</view>
  43. <!-- <view v-if="!state.accountInfo.type" class="empty-text">请选择提现方式</view>
  44. <view v-if="state.accountInfo.type === 'wechat'" class="empty-text">微信零钱</view>
  45. <view v-if="state.accountInfo.type === 'alipay'" class="empty-text">支付宝账户</view>
  46. <view v-if="state.accountInfo.type === 'bank'" class="empty-text">银行卡转账</view> -->
  47. <text class="cicon-forward"></text>
  48. </view>
  49. </view>
  50. <view class="bind-box ss-flex ss-col-center ss-row-between" v-if="state.accountInfo.type">
  51. <view class="placeholder-text" v-if="state.accountInfo.account_name">
  52. {{ state.accountInfo.account_header }}|{{ state.accountInfo.account_name }}
  53. </view>
  54. <!-- <view class="placeholder-text" v-else>暂无提现账户</view>
  55. <button class="add-btn ss-reset-button" @tap="onAccountEdit(true)">
  56. {{ state.accountInfo.account_name ? '修改' : '添加' }}
  57. </button> -->
  58. </view>
  59. <button class="ss-reset-button save-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onConfirm">
  60. 确认提现
  61. </button>
  62. </view>
  63. <!-- 提现说明 -->
  64. <view class="draw-notice">
  65. <view class="title ss-m-b-30">提现说明</view>
  66. <!-- <view class="draw-list" v-for="(rule, index) in state.rulesList" :key="index">
  67. {{ index + 1 }}.{{ rule }}
  68. </view>-->
  69. <view class="draw-list">
  70. 当前可提现金额:<text>¥{{state.userGet.brokeragePrice}}</text>
  71. </view>
  72. <view class="draw-list">
  73. 冻结佣金:<text>¥{{state.userGet.frozenPrice}}</text>
  74. </view>
  75. <view class="draw-list">
  76. 说明:每笔佣金冻结期为0天,到期后可提现
  77. </view>
  78. </view>
  79. <!-- 选择提现账户 -->
  80. <account-type-select :show="state.accountSelect" @close="onAccountSelect(false)" round="10"
  81. v-model="state.accountInfo" :methods="state.rules.methods" />
  82. <!-- 编辑账户信息 -->
  83. <account-info-modal v-if="state.accountInfo.type" v-model="state.accountInfo" :show="state.accountEdit"
  84. @close="onAccountEdit(false)" round="10" />
  85. </s-layout>
  86. </template>
  87. <script setup>
  88. import {
  89. computed,
  90. reactive,
  91. onBeforeMount
  92. } from 'vue';
  93. import sheep from '@/sheep';
  94. import accountTypeSelect from './components/account-type-select.vue';
  95. import accountInfoModal from './components/account-info-modal.vue';
  96. import {
  97. onPageScroll
  98. } from '@dcloudio/uni-app';
  99. const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
  100. onPageScroll(() => {});
  101. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  102. function filterRules(rules) {
  103. let list = [];
  104. let str1 = '';
  105. if (rules.min_amount > 0) {
  106. str1 += `最少 ${rules.min_amount}元; `;
  107. }
  108. if (rules.max_amount > 0) {
  109. str1 += `最多 ${rules.max_amount}元;`;
  110. }
  111. if (str1 !== '') {
  112. list.push('单次提现金额 ' + str1);
  113. }
  114. if (rules.max_num > 0) {
  115. list.push(`每${rules.num_unit === 'day' ? '天' : '月'}最多可提现 ${rules.max_num} 次;`);
  116. }
  117. if (rules.charge_rate_format > 0) {
  118. list.push(`每次收取提现手续费 ${rules.charge_rate_format}%;`);
  119. }
  120. list.push(
  121. `提现申请后将${rules.auto_arrival ? '自动' : '审核后'}到账, 到账结果请查收对应渠道服务通知;`,
  122. );
  123. list.push('如有疑问请及时联系客服.');
  124. return list;
  125. }
  126. const userStore = sheep.$store('user');
  127. const userInfo = computed(() => userStore.userInfo);
  128. const state = reactive({
  129. userGet: {},
  130. accountNo: '',
  131. name: '',
  132. amount: '',
  133. type: '',
  134. accountInfo: {},
  135. accountSelect: false,
  136. accountEdit: false,
  137. rules: {
  138. min_amount: 0,
  139. max_amount: 0,
  140. max_num: 0,
  141. num_unit: 0,
  142. charge_rate_format: 0,
  143. charge_rate: 0,
  144. methods: [],
  145. },
  146. rulesList: [],
  147. });
  148. const onAccountEdit = (e) => {
  149. state.accountEdit = e;
  150. };
  151. const onAccountSelect = (e) => {
  152. state.accountSelect = e;
  153. };
  154. const onConfirm = async () => {
  155. let payload = {
  156. accountNo: state.accountNo,
  157. name: state.name,
  158. bankName: state.accountInfo.type,
  159. type: '2',
  160. price: state.amount * 100
  161. };
  162. console.log(payload);
  163. // return;
  164. // if (payload.money > userInfo.commission || payload.money <= 0) {
  165. // sheep.$helper.toast('请输入正确的提现金额');
  166. // return;
  167. // }
  168. // if (!payload.type) {
  169. // sheep.$helper.toast('请选择提现方式');
  170. // return;
  171. // }
  172. // if (!payload.account_name || !payload.account_header || !payload.account_no) {
  173. // sheep.$helper.toast('请完善您的账户信息');
  174. // return;
  175. // }
  176. // if (sheep.$platform.name === 'H5' && payload.type === 'wechat') {
  177. // sheep.$helper.toast('请使用微信浏览器操作');
  178. // return;
  179. // }
  180. let {
  181. code,
  182. msg,
  183. data
  184. } = await sheep.$api.pay.withdraw.apply(payload);
  185. if (code === -1) {
  186. sheep.$platform.useProvider('wechat').bind();
  187. }
  188. if (code === 0) {
  189. userStore.getInfo();
  190. uni.showModal({
  191. title: '操作成功',
  192. content: '您的提现申请已成功提交',
  193. cancelText: '继续提现',
  194. confirmText: '查看记录',
  195. success: function(res) {
  196. res.confirm && sheep.$router.go('/pages/pay/withdraw-log');
  197. },
  198. });
  199. }
  200. };
  201. async function getWithdrawRules() {
  202. let {
  203. error,
  204. data
  205. } = await sheep.$api.pay.withdraw.rules();
  206. if (error === 0) {
  207. state.rules = data;
  208. state.rulesList = filterRules(state.rules);
  209. }
  210. }
  211. onBeforeMount(async () => {
  212. getWithdrawRules();
  213. let res = await sheep.$api.pay.withdraw.userGet();
  214. state.userGet = res.data
  215. });
  216. </script>
  217. <style lang="scss" scoped>
  218. :deep() {
  219. .uni-input-input {
  220. font-family: OPPOSANS !important;
  221. }
  222. }
  223. .wallet-num-box {
  224. padding: 0 40rpx 80rpx;
  225. background: var(--ui-BG-Main) v-bind(headerBg) center/750rpx 100% no-repeat;
  226. border-radius: 0 0 5% 5%;
  227. .num-title {
  228. font-size: 26rpx;
  229. font-weight: 500;
  230. color: $white;
  231. margin-bottom: 20rpx;
  232. }
  233. .wallet-num {
  234. font-size: 60rpx;
  235. font-weight: 500;
  236. color: $white;
  237. font-family: OPPOSANS;
  238. }
  239. .log-btn {
  240. width: 170rpx;
  241. height: 60rpx;
  242. line-height: 60rpx;
  243. border: 1rpx solid $white;
  244. border-radius: 30rpx;
  245. padding: 0;
  246. font-size: 26rpx;
  247. font-weight: 500;
  248. color: $white;
  249. }
  250. }
  251. // 提现输入卡片
  252. .draw-card {
  253. background-color: $white;
  254. border-radius: 20rpx;
  255. width: 690rpx;
  256. min-height: 560rpx;
  257. margin: -60rpx 30rpx 30rpx 30rpx;
  258. padding: 30rpx;
  259. position: relative;
  260. z-index: 3;
  261. box-sizing: border-box;
  262. .card-title {
  263. font-size: 30rpx;
  264. font-weight: 500;
  265. margin-bottom: 30rpx;
  266. }
  267. .bank-box {
  268. .name {
  269. font-size: 28rpx;
  270. font-weight: 500;
  271. }
  272. .bank-list {
  273. .empty-text {
  274. font-size: 28rpx;
  275. font-weight: 400;
  276. color: $dark-9;
  277. }
  278. .cicon-forward {
  279. color: $dark-9;
  280. }
  281. }
  282. .input-box {
  283. width: 624rpx;
  284. height: 100rpx;
  285. margin-bottom: 40rpx;
  286. .unit {
  287. font-size: 48rpx;
  288. color: #333;
  289. font-weight: 500;
  290. }
  291. .uni-easyinput__placeholder-class {
  292. font-size: 30rpx;
  293. height: 36rpx;
  294. }
  295. :deep(.uni-easyinput__content-input) {
  296. font-size: 48rpx;
  297. }
  298. }
  299. .save-btn {
  300. width: 616rpx;
  301. height: 86rpx;
  302. line-height: 86rpx;
  303. border-radius: 40rpx;
  304. margin-top: 80rpx;
  305. }
  306. }
  307. .bind-box {
  308. .placeholder-text {
  309. font-size: 26rpx;
  310. color: $dark-9;
  311. }
  312. .add-btn {
  313. width: 100rpx;
  314. height: 50rpx;
  315. border-radius: 25rpx;
  316. line-height: 50rpx;
  317. font-size: 22rpx;
  318. color: var(--ui-BG-Main);
  319. background-color: var(--ui-BG-Main-light);
  320. }
  321. }
  322. .input-box {
  323. width: 624rpx;
  324. height: 100rpx;
  325. margin-bottom: 40rpx;
  326. .unit {
  327. font-size: 48rpx;
  328. color: #333;
  329. font-weight: 500;
  330. }
  331. .uni-easyinput__placeholder-class {
  332. font-size: 30rpx;
  333. }
  334. :deep(.uni-easyinput__content-input) {
  335. font-size: 48rpx;
  336. }
  337. }
  338. .save-btn {
  339. width: 616rpx;
  340. height: 86rpx;
  341. line-height: 86rpx;
  342. border-radius: 40rpx;
  343. margin-top: 80rpx;
  344. }
  345. }
  346. // 提现说明
  347. .draw-notice {
  348. width: 684rpx;
  349. background: #ffffff;
  350. border: 2rpx solid #fffaee;
  351. border-radius: 20rpx;
  352. margin: 20rpx 32rpx 0 32rpx;
  353. padding: 30rpx;
  354. box-sizing: border-box;
  355. .title {
  356. font-weight: 500;
  357. color: #333333;
  358. font-size: 30rpx;
  359. }
  360. .draw-list {
  361. font-size: 24rpx;
  362. color: #999999;
  363. line-height: 46rpx;
  364. }
  365. }
  366. </style>