reflect.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <view class="reflect-container">
  3. <uv-navbar title="提现" placeholder autoBack bgColor="#f7f7f7"></uv-navbar>
  4. <view class="reflect-top">
  5. <view class="reflect-top-container">
  6. <view class="reflect-top-title">可提现金额</view>
  7. <view class="reflect-top-amount">
  8. <text class="reflect-top-amount-text">¥</text>
  9. <text class="reflect-top-amount-num">{{ info.ableAmount || 0 }}</text>
  10. </view>
  11. <view class="reflect-top-withdrawing"
  12. >提现中金额:¥{{ info.processingAmount || 0 }}</view
  13. >
  14. <view class="reflect-top-btn" @click.stop="handleWithdraw">
  15. <view class="iconfont">&#xe632;</view>
  16. <text>提现明细</text>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="main-container">
  21. <view class="main-container-title">请输入提现金额</view>
  22. <view class="main-container-input">
  23. <text class="main-container-input-text">¥</text>
  24. <input
  25. v-model="formData.amount"
  26. class="reflect-input"
  27. placeholder="请输入提现金额"
  28. type="digit"
  29. @blur="handleBlur"
  30. />
  31. </view>
  32. <view class="main-container-prompt">单笔提现上限200,可多笔提现。</view>
  33. <view class="list u-flex-center-sb">
  34. <view class="label">到账方式</view>
  35. <view class="value u-flex-center">
  36. <text class="value-text">支付宝</text>
  37. <uv-icon name="arrow-right" color="#808080" size="30rpx"></uv-icon>
  38. </view>
  39. </view>
  40. <view class="list u-flex-center-sb">
  41. <view class="label">到账支付宝号</view>
  42. <view class="value">
  43. <input
  44. v-model="formData.accountInfo"
  45. class="reflect-input"
  46. placeholder="请输入支付宝号"
  47. placeholder-style="color: #808080;"
  48. />
  49. </view>
  50. </view>
  51. </view>
  52. <view class="reflect-btn">
  53. <button class="u-btn-two" @click.stop="withdrawBtn">确认提现</button>
  54. </view>
  55. <!-- 输入支付密码 -->
  56. <uv-popup
  57. ref="popupRef"
  58. mode="bottom"
  59. round="40rpx"
  60. closeable
  61. @change="handleClose"
  62. >
  63. <view class="popup-container" :style="{ paddingBottom: keyboardHeight ? keyboardHeight + 'px' : '36rpx'}">
  64. <view class="popup-container-top">
  65. <view class="popup-container-title">输入支付密码</view>
  66. <view class="popup-container-amount">
  67. <text class="popup-container-amount-text">¥</text>
  68. <text class="popup-container-amount-num">{{
  69. formData.amount || 0
  70. }}</text>
  71. </view>
  72. <view class="popup-container-prompt">提现金额</view>
  73. </view>
  74. <view class="popup-container-list">
  75. <view class="popup-list-item">
  76. <text class="popup-list-item-lable">手续费:</text>
  77. <text class="popup-list-item-value">¥{{ formData.fee || 0 }}</text>
  78. </view>
  79. <view class="popup-list-item u-mb20">
  80. <text class="popup-list-item-lable">费率:</text>
  81. <text class="popup-list-item-value"
  82. >{{ formData.withdrawRatio || 0 }}%</text
  83. >
  84. </view>
  85. <view>
  86. <uv-code-input
  87. v-if="formData.fee != null"
  88. v-model="formData.payPassword"
  89. size="82rpx"
  90. space="25rpx"
  91. dot
  92. :focus="formData.focusShow ? true : false"
  93. @finish="handleFinish"
  94. :adjustPosition="false"
  95. ></uv-code-input>
  96. </view>
  97. <view class="popup-container-btn u-flex-center-sb">
  98. <view class="confirm" @click="withdrawConfirm">确认提现</view>
  99. <view class="cancel" @click="withdrawCancel">取消</view>
  100. </view>
  101. </view>
  102. </view>
  103. </uv-popup>
  104. </view>
  105. </template>
  106. <script setup>
  107. import { ref, nextTick } from "vue";
  108. import {
  109. onLoad,
  110. onReachBottom,
  111. onPullDownRefresh,
  112. onShow,
  113. } from "@dcloudio/uni-app";
  114. import {
  115. withdrawalAmount_Api,
  116. addWithdrawal_Api,
  117. withdrawalFee_Api,
  118. isSetPayPassword_Api,
  119. } from "@/api/userInfo.js";
  120. import {
  121. agentWithdrawalAmount_Api,
  122. agentAddWithdrawal_Api,
  123. agentWithdrawalFee_Api,
  124. } from "@/api/agencyCenter.js";
  125. const popupRef = ref(null);
  126. const info = ref({});
  127. const formData = ref({});
  128. const pageType = ref("1");
  129. const isSetPayPassword = ref(null);
  130. // 跳转提现明细
  131. const handleWithdraw = () => {
  132. uni.navigateTo({
  133. url: "/pages/user/wallet/reflectList?pageType=" + pageType.value,
  134. });
  135. };
  136. // 输入框失焦处理数据
  137. const handleBlur = () => {
  138. if (formData.value.amount) {
  139. formData.value.amount = (formData.value.amount * 1).toFixed(2);
  140. }
  141. };
  142. // 提现按钮
  143. const withdrawBtn = () => {
  144. // console.log("提现", formData.value);
  145. if (!formData.value.amount) {
  146. uni.showToast({
  147. title: "请输入提现金额",
  148. icon: "none",
  149. });
  150. return;
  151. }
  152. if (formData.value.amount * 1 > 200) {
  153. uni.showToast({
  154. title: "提现金额不能大于200",
  155. icon: "none",
  156. });
  157. return;
  158. }
  159. if (formData.value.amount * 1 > info.value.ableAmount * 1) {
  160. uni.showToast({
  161. title: "提现金额不能大于可提现金额",
  162. icon: "none",
  163. });
  164. return;
  165. }
  166. if (!formData.value.accountInfo) {
  167. uni.showToast({
  168. title: "请输入支付宝号",
  169. icon: "none",
  170. });
  171. return;
  172. }
  173. if (!isSetPayPassword.value) {
  174. uni.$uv.toast("请先设置支付密码");
  175. setTimeout(() => {
  176. uni.navigateTo({
  177. url: "/pages/set/payPassword",
  178. });
  179. }, 500);
  180. return;
  181. }
  182. let url = pageType.value == "1" ? withdrawalFee_Api : agentWithdrawalFee_Api;
  183. url({ amount: formData.value.amount })
  184. .then((res) => {
  185. // console.log("提现手续费", res);
  186. if (res.code == 200 && res.data) {
  187. formData.value.fee = res.data.fee || 0;
  188. formData.value.withdrawRatio = res.data.withdrawRatio || 0;
  189. popupRef.value.open();
  190. setTimeout(() => {
  191. formData.value.focusShow = true;
  192. uni.onKeyboardHeightChange(listener);
  193. }, 500);
  194. }
  195. })
  196. .catch((err) => {
  197. console.log(err);
  198. });
  199. };
  200. const keyboardHeight = ref(0);
  201. const listener = (res) => {
  202. // console.log(res.height);
  203. keyboardHeight.value = res.height || 0;
  204. };
  205. // 关闭弹窗处理数据
  206. const handleClose = (e) => {
  207. if (!e.show) {
  208. // console.log("关闭");
  209. formData.value.fee = undefined;
  210. formData.value.withdrawRatio = undefined;
  211. formData.value.payPassword = undefined;
  212. uni.offKeyboardHeightChange(listener); // 需传入与监听时同一个的函数对象
  213. }
  214. };
  215. // 输入完成处理数据
  216. const handleFinish = () => {
  217. // console.log("输入完成");
  218. try {
  219. uni.hideKeyboard();
  220. } catch (error) {}
  221. formData.value.focusShow = false;
  222. withdrawConfirm();
  223. };
  224. // 确认提现
  225. const withdrawConfirm = () => {
  226. if (!formData.value.payPassword) {
  227. uni.showToast({
  228. title: "请输入支付密码",
  229. icon: "none",
  230. });
  231. return;
  232. }
  233. let form = {
  234. amount: formData.value.amount,
  235. accountInfo: formData.value.accountInfo,
  236. fee: formData.value.fee,
  237. payPassword: formData.value.payPassword,
  238. withdrawalMethod: "1", // 提现方式 1:支付宝 2:微信
  239. };
  240. // console.log("确认提现", form);
  241. uni.showLoading({
  242. title: "加载中...",
  243. mask: true,
  244. });
  245. let url = pageType.value == "1" ? addWithdrawal_Api : agentAddWithdrawal_Api;
  246. url(form)
  247. .then((res) => {
  248. // console.log("确认提现", res);
  249. uni.hideLoading();
  250. if (res.code == 200) {
  251. uni.showToast({
  252. title: "提交成功",
  253. icon: "success",
  254. });
  255. popupRef.value.close();
  256. formData.value = {};
  257. setTimeout(() => {
  258. getInfo();
  259. }, 500);
  260. }
  261. })
  262. .catch((err) => {
  263. // uni.hideLoading();
  264. console.log(err);
  265. });
  266. };
  267. // 取消提现
  268. const withdrawCancel = () => {
  269. popupRef.value.close();
  270. formData.value = {};
  271. };
  272. const getInfo = () => {
  273. uni.showLoading({
  274. title: "加载中...",
  275. });
  276. let url =
  277. pageType.value == "1" ? withdrawalAmount_Api : agentWithdrawalAmount_Api;
  278. url()
  279. .then((res) => {
  280. uni.hideLoading();
  281. if (res.code == 200) {
  282. info.value = res.data;
  283. }
  284. })
  285. .catch((err) => {
  286. uni.hideLoading();
  287. console.log(err);
  288. });
  289. };
  290. onLoad((options) => {
  291. console.log("onLoad", options);
  292. if (options.pageType) {
  293. console.log("pageType", options.pageType);
  294. pageType.value = options.pageType;
  295. }
  296. getInfo();
  297. });
  298. onShow(() => {
  299. if (!isSetPayPassword.value) {
  300. try {
  301. isSetPayPassword_Api().then((res) => {
  302. // console.log(res);
  303. if (res && res.code == 200 && res.data) {
  304. isSetPayPassword.value = res.data ? true : false;
  305. }
  306. });
  307. } catch (error) {}
  308. }
  309. });
  310. </script>
  311. <style lang="scss" scoped>
  312. .reflect-container {
  313. .reflect-top {
  314. background-color: #f7f7f7;
  315. padding: 24rpx 30rpx 44rpx 30rpx;
  316. box-sizing: border-box;
  317. // min-height: 400rpx;
  318. .reflect-top-container {
  319. // min-height: 445rpx;
  320. width: 100%;
  321. // https://shop.xiaocaituan.com/image/personalCenter/wallet/icon_bg1.png
  322. background: url("https://shop.xiaocaituan.com/image/personalCenter/wallet/icon_bg1.png");
  323. background-repeat: no-repeat;
  324. background-size: 100% 100%;
  325. text-align: center;
  326. padding: 36rpx 0 44rpx 0;
  327. color: #ffffff;
  328. box-sizing: border-box;
  329. .reflect-top-title {
  330. margin-bottom: 17rpx;
  331. font-size: 28rpx;
  332. font-weight: 700;
  333. color: #ffffff;
  334. }
  335. .reflect-top-amount {
  336. margin-bottom: 14rpx;
  337. .reflect-top-amount-text {
  338. font-size: 36rpx;
  339. }
  340. .reflect-top-amount-num {
  341. font-size: 66rpx;
  342. font-weight: normal;
  343. }
  344. }
  345. .reflect-top-withdrawing {
  346. margin-bottom: 28rpx;
  347. font-size: 28rpx;
  348. font-weight: 400;
  349. color: #fceae8;
  350. }
  351. .reflect-top-btn {
  352. width: 280rpx;
  353. height: 70rpx;
  354. border: 1rpx solid #ffffff;
  355. border-radius: 36rpx;
  356. display: flex;
  357. align-items: center;
  358. justify-content: center;
  359. margin: auto;
  360. .iconfont {
  361. margin-right: 10rpx;
  362. }
  363. }
  364. }
  365. }
  366. .main-container {
  367. padding: 40rpx 54rpx;
  368. box-sizing: border-box;
  369. margin-top: -40rpx;
  370. background: #ffffff;
  371. border-radius: 40rpx 40rpx 0px 0px;
  372. .main-container-title {
  373. font-size: 32rpx;
  374. font-weight: 700;
  375. color: #333333;
  376. }
  377. .main-container-prompt {
  378. font-size: 28rpx;
  379. font-weight: 400;
  380. color: #ff0000;
  381. margin-top: 10rpx;
  382. }
  383. .main-container-input {
  384. padding: 20rpx 0;
  385. display: flex;
  386. align-items: center;
  387. border-bottom: 1rpx solid #d9d9d9;
  388. .main-container-input-text {
  389. font-size: 60rpx;
  390. font-weight: 700;
  391. color: #eb5153;
  392. margin-right: 5rpx;
  393. }
  394. .reflect-input {
  395. // color: #cccccc;
  396. font-size: 28rpx;
  397. flex: 1;
  398. }
  399. }
  400. .list {
  401. padding-top: 30rpx;
  402. .label {
  403. flex-shrink: 0;
  404. margin-right: 10rpx;
  405. font-size: 28rpx;
  406. font-weight: 400;
  407. color: #1a1a1a;
  408. }
  409. .value {
  410. font-size: 28rpx;
  411. .value-text {
  412. color: #1a1a1a;
  413. }
  414. .value-prompt {
  415. color: #808080;
  416. }
  417. .reflect-input {
  418. text-align: right;
  419. flex: 1;
  420. }
  421. }
  422. }
  423. }
  424. .reflect-btn {
  425. padding: 40rpx 54rpx;
  426. box-sizing: border-box;
  427. .u-btn-two {
  428. height: 90rpx;
  429. line-height: 90rpx;
  430. }
  431. }
  432. }
  433. .popup-container {
  434. padding: 0 0 36rpx 0;
  435. .popup-container-top {
  436. text-align: center;
  437. background: #f8f8f8;
  438. padding-bottom: 43rpx;
  439. padding-top: 36rpx;
  440. .popup-container-title {
  441. font-size: 32rpx;
  442. font-weight: 700;
  443. color: #1a1a1a;
  444. margin-bottom: 46rpx;
  445. }
  446. .popup-container-amount {
  447. .popup-container-amount-text {
  448. font-size: 30rpx;
  449. font-weight: normal;
  450. color: #eb5153;
  451. }
  452. .popup-container-amount-num {
  453. font-size: 60rpx;
  454. font-weight: normal;
  455. color: #eb5153;
  456. }
  457. }
  458. .popup-container-prompt {
  459. font-size: 28rpx;
  460. font-weight: 400;
  461. color: #1a1a1a;
  462. }
  463. }
  464. .popup-container-list {
  465. padding: 30rpx 54rpx;
  466. box-sizing: border-box;
  467. position: relative;
  468. .popup-list-item {
  469. padding-bottom: 20rpx;
  470. font-size: 28rpx;
  471. .popup-list-item-value {
  472. color: #808080;
  473. }
  474. }
  475. }
  476. .popup-container-btn {
  477. margin: 70rpx 0 0 0;
  478. .confirm,
  479. .cancel {
  480. width: 310rpx;
  481. height: 76rpx;
  482. border-radius: 38rpx;
  483. box-sizing: border-box;
  484. text-align: center;
  485. line-height: 76rpx;
  486. font-weight: 700;
  487. font-size: 28rpx;
  488. }
  489. .confirm {
  490. background: #eb5153;
  491. color: #ffffff;
  492. }
  493. .cancel {
  494. background: #ffffff;
  495. border: 1rpx solid #cccccc;
  496. color: #808080;
  497. }
  498. }
  499. }
  500. </style>