withdraw.vue 11 KB

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