withdraw.vue 11 KB

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