cash.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <view>
  3. <uni-nav-bar :fixed="true" shadow left-icon="left" title="余额明细" :statusBar="true" @clickLeft="handleToBack" />
  4. <view class="content">
  5. <view class="content_background" style="padding: 49upx 0">
  6. <view class="card">
  7. <view class="uni-form" style="padding: 34upx 0">
  8. <view
  9. style="
  10. font-size: 32upx;
  11. font-weight: bold;
  12. color: #000000;
  13. margin: 0px 32upx 18upx;
  14. "
  15. >提现账户</view
  16. >
  17. <view class="uni-form-item" style="border-bottom: 0">
  18. <view class="title">
  19. <image
  20. src="/static/common/alipay.png"
  21. mode="aspectFill"
  22. class="form_item_icon"
  23. />
  24. 支付宝支付
  25. </view>
  26. <view @tap="handleSelectPayType" data-type="alipay">
  27. <image
  28. src="/static/common/radio_selected.png"
  29. mode="aspectFill"
  30. class="form_item_btn_icon"
  31. v-if="payType == 'alipay'"
  32. />
  33. <image
  34. src="/static/common/radio_unselect.png"
  35. mode="aspectFill"
  36. class="form_item_btn_icon"
  37. v-else
  38. />
  39. </view>
  40. </view>
  41. <view
  42. class="uni-column"
  43. style="padding: 10upx 80upx 30upx"
  44. v-if="payType == 'alipay'"
  45. >
  46. <input
  47. class="uni-input"
  48. placeholder="支付宝账号"
  49. style="
  50. height: 50upx;
  51. font-size: 28upx;
  52. font-weight: 400;
  53. color: #999999;
  54. margin: 0 0 20upx;
  55. border-bottom: 1px solid #eee;
  56. "
  57. v-model="alipayParams.account"
  58. />
  59. <input
  60. class="uni-input"
  61. placeholder="支付宝认证实名(真实姓名)"
  62. style="
  63. height: 50upx;
  64. font-size: 28upx;
  65. font-weight: 400;
  66. color: #999999;
  67. border-bottom: 1px solid #eee;
  68. "
  69. v-model="alipayParams.name"
  70. />
  71. </view>
  72. <view class="uni-form-item uni-column" v-if="false">
  73. <view class="title">
  74. <image
  75. src="/static/common/wechat.png"
  76. mode="aspectFill"
  77. class="form_item_icon"
  78. />
  79. 微信支付
  80. </view>
  81. <view @tap="handleSelectPayType" data-type="wxpay">
  82. <image
  83. src="/static/common/radio_selected.png"
  84. mode="aspectFill"
  85. class="form_item_btn_icon"
  86. v-if="payType == 'wxpay'"
  87. />
  88. <image
  89. src="/static/common/radio_unselect.png"
  90. mode="aspectFill"
  91. class="form_item_btn_icon"
  92. v-else
  93. />
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. <view class="card" style="margin-top: 20upx">
  99. <view class="uni-form" style="padding: 34upx 0">
  100. <view
  101. style="
  102. font-size: 32upx;
  103. font-weight: bold;
  104. color: #000000;
  105. margin: 0px 32upx 18upx;
  106. "
  107. >提现金额</view
  108. >
  109. <view
  110. class="uni-column"
  111. style="padding: 10upx 80upx 30upx"
  112. v-if="payType == 'alipay'"
  113. >
  114. <view
  115. class="flex align-center"
  116. style="
  117. border-bottom: 1px solid #eee;
  118. margin: 0 0 20upx;
  119. color: #ff490e;
  120. "
  121. >
  122. <text style="margin-right: 5upx">¥</text>
  123. <input
  124. class="uni-input"
  125. type="number"
  126. style="
  127. height: 50upx;
  128. font-size: 28upx;
  129. font-weight: 400;
  130. color: #999999;
  131. "
  132. placeholder="请填写提现金额"
  133. v-model="alipayParams.money"
  134. />
  135. </view>
  136. <view
  137. class="flex"
  138. style="font-size: 24upx; font-weight: 400; color: #999999"
  139. >
  140. <view>当前余额 {{ maxMoney }}</view>
  141. <view
  142. style="color: #07d69e; margin-left: 20upx"
  143. @tap.stop="handleAllCash"
  144. >全部提现</view
  145. >
  146. </view>
  147. </view>
  148. <view class="uni-form-item uni-column" v-if="false">
  149. <view class="title">
  150. <image
  151. src="/static/common/wechat.png"
  152. mode="aspectFill"
  153. class="form_item_icon"
  154. />
  155. 微信支付
  156. </view>
  157. <view @tap="handleSelectPayType" data-type="wxpay">
  158. <image
  159. src="/static/common/radio_selected.png"
  160. mode="aspectFill"
  161. class="form_item_btn_icon"
  162. v-if="payType == 'wxpay'"
  163. />
  164. <image
  165. src="/static/common/radio_unselect.png"
  166. mode="aspectFill"
  167. class="form_item_btn_icon"
  168. v-else
  169. />
  170. </view>
  171. </view>
  172. </view>
  173. </view>
  174. <view class="footer">
  175. <image mode="widthFix" src="/static/common/footer.png" />
  176. </view>
  177. </view>
  178. <view class="footer_btn_wrap" style="position: fixed" @tap="handleToCash">
  179. <view
  180. class="footer_btn"
  181. :class="{
  182. footer_btn_disabled: alipayParams?.money <= 0 || maxMoney <= 0,
  183. }"
  184. >
  185. 确认提现
  186. </view>
  187. </view>
  188. </view>
  189. </view>
  190. </template>
  191. <script setup>
  192. import { ref, reactive } from "vue";
  193. import { onLoad, onShow } from "@dcloudio/uni-app";
  194. import request from "/common/request.js";
  195. import auth from "/common/auth.js";
  196. const statusBarHeight = ref();
  197. const payType = ref("alipay");
  198. const maxMoney = ref(0);
  199. const alipayParams = reactive({
  200. account: "",
  201. name: "",
  202. money: "",
  203. });
  204. onLoad((option) => {
  205. statusBarHeight.value = uni.getSystemInfoSync().statusBarHeight;
  206. });
  207. onShow(() => {
  208. renderData();
  209. uni.$emit('fastOrderNum', false);
  210. uni.$emit('receiveOrdernum', false);
  211. });
  212. async function renderData() {
  213. if (auth()) {
  214. getUserInfo();
  215. uni.pageScrollTo({ scrollTop: 0, duration: 0 });
  216. }
  217. }
  218. const handleToBack = () => {
  219. const canNavBack = getCurrentPages();
  220. if (canNavBack && canNavBack.length > 1) uni.navigateBack();
  221. else history.back();
  222. };
  223. const handleSelectPayType = (e) => {
  224. payType.value = e?.currentTarget?.dataset?.type;
  225. };
  226. function getUserInfo() {
  227. request({
  228. url: "/api/user/getInfo",
  229. method: "GET",
  230. success: (res) => {
  231. console.log("用户信息", res);
  232. if (res.data?.code == 1) {
  233. maxMoney.value = res.data?.data?.balance;
  234. // alipayParams.money = res.data?.data?.balance;
  235. }
  236. },
  237. fail: () => {},
  238. complete: () => {
  239. uni.hideLoading();
  240. },
  241. });
  242. }
  243. function handleAllCash() {
  244. alipayParams.money = maxMoney.value;
  245. }
  246. function handleToCash() {
  247. if (maxMoney.value <= 0) return;
  248. if (payType.value == "alipay") {
  249. if (!alipayParams.account) {
  250. uni.showToast({
  251. title: "请输入支付宝账号",
  252. duration: 2000,
  253. icon: "none",
  254. });
  255. return;
  256. } else {
  257. // const reg =
  258. // /^(1[3456789]\d{9})|([a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+)$/;
  259. // if (!reg.test(alipayParams.account)) {
  260. // uni.showToast({
  261. // title: "支付宝账号为手机或邮箱",
  262. // duration: 3000,
  263. // icon: "none",
  264. // });
  265. // return;
  266. // }
  267. }
  268. if (!alipayParams.name) {
  269. uni.showToast({
  270. title: "请输入支付宝认证实名",
  271. duration: 2000,
  272. icon: "none",
  273. });
  274. return;
  275. } else {
  276. const reg = /^[\u4e00-\u9fa5]+$/;
  277. if (!reg.test(alipayParams.name)) {
  278. uni.showToast({
  279. title: "支付宝认证实名需为中文",
  280. duration: 3000,
  281. icon: "none",
  282. });
  283. return;
  284. }
  285. }
  286. }
  287. if (!alipayParams.money) {
  288. uni.showToast({
  289. title: "请填写提现金额",
  290. duration: 2000,
  291. icon: "none",
  292. });
  293. return;
  294. }
  295. if (alipayParams.money > maxMoney) {
  296. uni.showToast({
  297. title: "提现余额不足",
  298. duration: 2000,
  299. icon: "none",
  300. });
  301. return;
  302. }
  303. uni.showLoading();
  304. request({
  305. url: "/api/user/addTx",
  306. method: "POST",
  307. data: {
  308. money: alipayParams.money,
  309. tx_type: 2,
  310. zfb_name: alipayParams.name,
  311. zfb_action: alipayParams.account,
  312. },
  313. success: (res) => {
  314. console.log("提现res", res);
  315. if (res.data?.code == 1) {
  316. uni.showToast({
  317. title: "提现申请已提交",
  318. duration: 2000,
  319. icon: "none",
  320. });
  321. setTimeout(function () {
  322. const canNavBack = getCurrentPages();
  323. if (canNavBack && canNavBack.length > 1) {
  324. uni.navigateBack();
  325. } else {
  326. history.back();
  327. }
  328. }, 2000);
  329. } else {
  330. uni.showToast({
  331. title: res.data.msg,
  332. duration: 2000,
  333. icon: "none",
  334. });
  335. }
  336. },
  337. fail: () => {},
  338. complete: () => {
  339. uni.hideLoading();
  340. },
  341. });
  342. }
  343. </script>
  344. <style lang="scss" scoped>
  345. uni-page-body,
  346. .content {
  347. // min-height: calc(100vh);
  348. }
  349. .content {
  350. background: linear-gradient(90deg, #37ecba 0%, #72afd3 100%);
  351. .uni-form {
  352. .uni-form-item {
  353. margin: 0 20upx 0 32upx;
  354. .title {
  355. font-size: 30upx !important;
  356. .form_item_icon {
  357. width: 52upx;
  358. height: 52upx;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. </style>