建材商城系统20241014
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

387 lines
8.4 KiB

8 months ago
8 months ago
1 week ago
8 months ago
1 week ago
1 week ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
1 week ago
8 months ago
1 week ago
8 months ago
1 week ago
1 week ago
1 week ago
8 months ago
8 months ago
8 months ago
  1. <template>
  2. <view class="purse">
  3. <navbar title="立即提现" leftClick @leftClick="$utils.navigateBack"
  4. bgColor="#DC2828"
  5. color="#fff"
  6. />
  7. <!-- 水洗店 -->
  8. <view class="userShop">
  9. <userShopCommission purse />
  10. </view>
  11. <view class="from-body">
  12. <view>我要提现</view>
  13. <view class="from-line">
  14. <input
  15. placeholder="请输入提现积分"
  16. v-model="withdrawAmount"
  17. type="digit"
  18. />
  19. </view>
  20. <view class="from-line">
  21. <input
  22. placeholder="请输入姓名"
  23. v-model="form.name"
  24. type="digit"
  25. />
  26. </view>
  27. <view class="from-line">
  28. <input
  29. placeholder="请输入开户行"
  30. v-model="form.openingBank"
  31. type="digit"
  32. />
  33. </view>
  34. <view class="from-line">
  35. <input
  36. placeholder="请输入银行卡号"
  37. v-model="form.cardNumber"
  38. type="digit"
  39. />
  40. </view>
  41. <view class="tips" v-if="userInfo.money">
  42. 可提现¥{{userInfo.money}}
  43. </view>
  44. <!-- 快捷积分选择 -->
  45. <!-- <view class="quick-amounts" v-if="userInfo.money && parseFloat(userInfo.money) > 0">
  46. <view class="quick-label">快捷选择</view>
  47. <view class="amount-buttons">
  48. <view
  49. class="amount-btn"
  50. v-for="amount in quickAmounts"
  51. :key="amount"
  52. :class="{'disabled': amount > parseFloat(userInfo.money)}"
  53. @click="selectQuickAmount(amount)"
  54. >
  55. ¥{{amount}}
  56. </view>
  57. <view
  58. class="amount-btn all"
  59. @click="selectAllAmount"
  60. >
  61. 全部
  62. </view>
  63. </view>
  64. </view> -->
  65. <!-- <view class="from-line">
  66. <input placeholder="请输入姓名" />
  67. </view>
  68. <view class="from-line">
  69. <input placeholder="请输入开户行" />
  70. </view>
  71. <view class="from-line">
  72. <input placeholder="请输入银行卡卡号" />
  73. </view> -->
  74. <view class="mt56">提现说明</view>
  75. <view style="color: #777;font-size: 26rpx;">
  76. <uv-parse :content="configList.withdrawal_instructions"></uv-parse>
  77. </view>
  78. <!-- <p>1本次提现必须通过银行卡提现暂不支持其他途径</p>
  79. <p>2如若遇到24小时提现未到账请联系客服</p> -->
  80. </view>
  81. <view class="b-fiexd">
  82. <view
  83. class="button-submit"
  84. :class="{'disabled': isSubmitting || !withdrawAmount}"
  85. @click="submitWithdraw"
  86. >
  87. {{isSubmitting ? '提交中...' : '提交'}}
  88. </view>
  89. </view>
  90. <!-- <quick-order-entry
  91. ref="quickOrderEntry"
  92. /> -->
  93. </view>
  94. </template>
  95. <script>
  96. import userShopCommission from '@/components/userShop/userShopCommission.vue'
  97. export default {
  98. components: {
  99. userShopCommission,
  100. },
  101. data() {
  102. return {
  103. notice: '',
  104. withdrawAmount: '', // 提现积分
  105. isSubmitting: false, // 是否正在提交
  106. quickAmounts: [10, 50, 100, 200, 500], // 快捷积分选项
  107. form : {},
  108. }
  109. },
  110. computed: {
  111. userInfo() {
  112. return this.$store.state.userInfo || {};
  113. }
  114. },
  115. onLoad() {
  116. this.$store.commit('getUserInfo');
  117. let form = uni.getStorageSync('purse_form')
  118. if(form){
  119. this.form = form
  120. }
  121. },
  122. methods: {
  123. // 选择快捷积分
  124. selectQuickAmount(amount) {
  125. if (amount > parseFloat(this.userInfo.money)) return;
  126. this.withdrawAmount = amount.toString();
  127. },
  128. // 选择全部积分
  129. selectAllAmount() {
  130. if (this.userInfo.money) {
  131. this.withdrawAmount = parseFloat(this.userInfo.money).toString();
  132. }
  133. },
  134. // 积分输入处理
  135. onAmountInput(e) {
  136. let value = e.detail.value;
  137. // 只允许输入数字和小数点
  138. value = value.replace(/[^\d.]/g, '');
  139. // 只允许一个小数点
  140. const pointIndex = value.indexOf('.');
  141. if (pointIndex !== -1) {
  142. value = value.substring(0, pointIndex + 1) + value.substring(pointIndex + 1).replace(/\./g, '');
  143. }
  144. // 最多保留2位小数
  145. if (pointIndex !== -1 && value.length > pointIndex + 3) {
  146. value = value.substring(0, pointIndex + 3);
  147. }
  148. this.withdrawAmount = value;
  149. },
  150. // 验证提现积分
  151. validateAmount() {
  152. if (!this.withdrawAmount) {
  153. uni.showToast({
  154. title: '请输入提现积分',
  155. icon: 'none'
  156. });
  157. return false;
  158. }
  159. if(this.$utils.verificationAll(this.form, {
  160. name : '请输入姓名',//
  161. openingBank : '请输入开户行',//
  162. cardNumber : '请输入银行卡号',//
  163. })){
  164. return
  165. }
  166. const amount = parseFloat(this.withdrawAmount);
  167. if (isNaN(amount) || amount <= 0) {
  168. uni.showToast({
  169. title: '请输入正确的提现积分',
  170. icon: 'none'
  171. });
  172. return false;
  173. }
  174. // 检查提现积分是否超过可用余额
  175. if (this.userInfo.money && amount > parseFloat(this.userInfo.money)) {
  176. uni.showToast({
  177. title: '提现积分不能超过可用余额',
  178. icon: 'none'
  179. });
  180. return false;
  181. }
  182. // 检查最小提现积分(假设最小提现1元)
  183. if (amount < 1) {
  184. uni.showToast({
  185. title: '最小提现积分为1元',
  186. icon: 'none'
  187. });
  188. return false;
  189. }
  190. return true;
  191. },
  192. // 提交提现申请
  193. submitWithdraw() {
  194. if (this.isSubmitting) return;
  195. // 验证提现积分
  196. if (!this.validateAmount()) return;
  197. uni.setStorageSync('purse_form', this.form)
  198. // 确认提现
  199. uni.showModal({
  200. title: '确认提现',
  201. content: `确定要提现 ¥${this.withdrawAmount} 元吗?`,
  202. success: (res) => {
  203. if (res.confirm) {
  204. this.doWithdraw();
  205. }
  206. }
  207. });
  208. },
  209. // 执行提现操作
  210. doWithdraw() {
  211. this.isSubmitting = true;
  212. const params = {
  213. money: parseFloat(this.withdrawAmount),
  214. ...this.form,
  215. };
  216. this.$api('openMoney', params, res => {
  217. this.isSubmitting = false;
  218. if (res.code === 200) {
  219. uni.showToast({
  220. title: '提现申请提交成功',
  221. icon: 'success',
  222. duration: 2000,
  223. success: () => {
  224. // 清空输入框
  225. this.withdrawAmount = '';
  226. // 刷新用户信息
  227. this.$store.commit('getUserInfo');
  228. // 延迟返回上一页或跳转到提现记录页面
  229. setTimeout(() => {
  230. uni.navigateBack();
  231. }, 2000);
  232. }
  233. });
  234. } else {
  235. uni.showModal({
  236. title: '提现失败',
  237. content: res.message || '提现申请提交失败,请重试',
  238. showCancel: false
  239. });
  240. }
  241. }, err => {
  242. this.isSubmitting = false;
  243. console.error('提现请求失败', err);
  244. uni.showModal({
  245. title: '网络错误',
  246. content: '网络连接失败,请检查网络后重试',
  247. showCancel: false
  248. });
  249. });
  250. }
  251. }
  252. }
  253. </script>
  254. <style scoped lang="scss">
  255. .purse{
  256. min-height: 100vh;
  257. background-color: #ffffff;
  258. .from-body {
  259. padding: 40rpx 20rpx;
  260. font-size: 28rpx;
  261. font-family: PingFang SC, PingFang SC-Bold;
  262. font-weight: 700;
  263. text-align: left;
  264. color: #333333;
  265. line-height: 40px;
  266. padding-bottom: 160rpx;
  267. .from-line {
  268. margin-top: 40rpx;
  269. }
  270. input {
  271. width: 612rpx;
  272. height: 90rpx;
  273. line-height: 90rpx;
  274. background: #F5F5F5;
  275. border-radius: 46rpx;
  276. padding: 0 50rpx;
  277. font-size: 28rpx;
  278. font-family: PingFang SC, PingFang SC-Regular;
  279. font-weight: 400;
  280. text-align: left;
  281. color: #333;
  282. }
  283. .tips {
  284. margin-top: 20rpx;
  285. font-size: 24rpx;
  286. color: #999;
  287. font-weight: 400;
  288. }
  289. .quick-amounts {
  290. margin-top: 30rpx;
  291. .quick-label {
  292. font-size: 26rpx;
  293. color: #666;
  294. margin-bottom: 20rpx;
  295. font-weight: 400;
  296. }
  297. .amount-buttons {
  298. display: flex;
  299. flex-wrap: wrap;
  300. gap: 20rpx;
  301. .amount-btn {
  302. padding: 16rpx 32rpx;
  303. background: #f5f5f5;
  304. border-radius: 30rpx;
  305. font-size: 26rpx;
  306. color: #333;
  307. text-align: center;
  308. border: 1rpx solid transparent;
  309. transition: all 0.3s;
  310. &:active {
  311. transform: scale(0.95);
  312. }
  313. &.disabled {
  314. opacity: 0.5;
  315. color: #999;
  316. }
  317. &.all {
  318. background: $uni-color;
  319. color: #fff;
  320. }
  321. }
  322. }
  323. }
  324. }
  325. .button-submit {
  326. width: 596rpx;
  327. height: 90rpx;
  328. line-height: 90rpx;
  329. background: $uni-color;
  330. border-radius: 46rpx;
  331. margin: 20rpx auto;
  332. font-size: 28rpx;
  333. font-family: PingFang SC, PingFang SC-Regular;
  334. font-weight: 400;
  335. text-align: center;
  336. color: #ffffff;
  337. transition: opacity 0.3s;
  338. &.disabled {
  339. opacity: 0.6;
  340. background: #ccc;
  341. }
  342. }
  343. }
  344. </style>