建材商城系统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.

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