withdraw.vue 9.5 KB

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