|
|
@@ -4,30 +4,32 @@
|
|
|
<view class="title pt-30 pb-30">充值金额</view>
|
|
|
<view class="flex-wrap">
|
|
|
<view
|
|
|
- :class="[
|
|
|
+ :class="[
|
|
|
'option',
|
|
|
'flex-center',
|
|
|
`option-${index === payOption && !payValue ? 'active' : ''}`,
|
|
|
]"
|
|
|
- v-for="(item, index) in payOptions"
|
|
|
- :key="index"
|
|
|
- @click="changeOption(index)"
|
|
|
+ v-for="(item, index) in payOptions"
|
|
|
+ :key="index"
|
|
|
+ @click="changeOption(index)"
|
|
|
>
|
|
|
<view
|
|
|
- class="tag fs-24 color-fff fw-500"
|
|
|
- v-if="payOptionsDiscount[index]"
|
|
|
- >{{ payOptionsDiscount[index] }}</view
|
|
|
+ class="tag fs-24 color-fff fw-500"
|
|
|
+ v-if="payOptionsDiscount[index]"
|
|
|
+ >{{ payOptionsDiscount[index] }}
|
|
|
+ </view
|
|
|
>
|
|
|
{{ item }}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view v-if="payOptionsDiscountDay[payOption]" class="flex-align-center">
|
|
|
<view class="fs-30 color-666"
|
|
|
- >折扣优惠有效期{{ payOptionsDiscountDay[payOption] }}天</view
|
|
|
+ >折扣优惠有效期{{ payOptionsDiscountDay[payOption] }}天
|
|
|
+ </view
|
|
|
>
|
|
|
<view
|
|
|
- class="ml-12 color-primary fs-30"
|
|
|
- @click="to(`/pages-common/activity/activity?id=${activityId}`)"
|
|
|
+ class="ml-12 color-primary fs-30"
|
|
|
+ @click="to(`/pages-common/activity/activity?id=${activityId}`)"
|
|
|
>
|
|
|
<text>详细规则</text>
|
|
|
<text class="fs-24 ml-6">>></text>
|
|
|
@@ -35,28 +37,31 @@
|
|
|
</view>
|
|
|
<view class="title pt-60 pb-30">自定义金额</view>
|
|
|
<style-input
|
|
|
- :value="payValue > 0 ? payValue : ''"
|
|
|
- title="金额"
|
|
|
- type="digit"
|
|
|
- @input="input"
|
|
|
+ :value="payValue > 0 ? payValue : ''"
|
|
|
+ title="金额"
|
|
|
+ type="digit"
|
|
|
+ @input="input"
|
|
|
/>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<style-bottom-view>
|
|
|
<view class="pl-60 pr-60 pb-20">
|
|
|
- <style-button size="small" type="primary" @click="confirm"
|
|
|
- >充值</style-button
|
|
|
+ <style-button size="small" type="primary" @click="debounceConfirm"
|
|
|
+ >充值
|
|
|
+ </style-button
|
|
|
>
|
|
|
</view>
|
|
|
</style-bottom-view>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref } from "vue";
|
|
|
-import { fetchProfile, insertMoney } from "../../api/user";
|
|
|
-import { onLoad } from "@dcloudio/uni-app";
|
|
|
-import { to, back } from "@/utils/navigate";
|
|
|
+import {ref} from "vue";
|
|
|
+import {fetchProfile, insertMoney} from "../../api/user";
|
|
|
+import {onLoad} from "@dcloudio/uni-app";
|
|
|
+import {back, to} from "@/utils/navigate";
|
|
|
+import {debounce} from "@/utils/util";
|
|
|
+
|
|
|
const balance = ref(0);
|
|
|
const payOption = ref(3);
|
|
|
const payOptions = ref([30, 50, 100, 200, 500, 1000]);
|
|
|
@@ -72,6 +77,11 @@ const changeOption = (index: number) => {
|
|
|
payValue.value = 0;
|
|
|
payOption.value = index;
|
|
|
};
|
|
|
+
|
|
|
+const debounceConfirm = debounce(()=>{
|
|
|
+ confirm();
|
|
|
+},500)
|
|
|
+
|
|
|
const confirm = () => {
|
|
|
if (payValue.value && !/^[0-9]*(\.\d{1,2})?$/.test(`${payValue.value}`)) {
|
|
|
uni.showModal({
|
|
|
@@ -83,8 +93,8 @@ const confirm = () => {
|
|
|
return;
|
|
|
}
|
|
|
const params = payValue.value
|
|
|
- ? Number(payValue.value)
|
|
|
- : payOptions.value[payOption.value];
|
|
|
+ ? Number(payValue.value)
|
|
|
+ : payOptions.value[payOption.value];
|
|
|
if (params > 10000 || params <= 0) {
|
|
|
uni.showModal({
|
|
|
title: "温馨提示",
|
|
|
@@ -98,41 +108,48 @@ const confirm = () => {
|
|
|
title: "加载中",
|
|
|
});
|
|
|
insertMoney(params)
|
|
|
- .then(() => {
|
|
|
- return fetchProfile();
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- payValue.value = 0;
|
|
|
- balance.value = res.balance;
|
|
|
- uni.hideLoading();
|
|
|
- uni.showToast({
|
|
|
- title: "已支付",
|
|
|
- icon: "success",
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- if (needBack.value) {
|
|
|
- back();
|
|
|
- } else {
|
|
|
- to("/pages-user/wallet/wallet");
|
|
|
+ .then(() => {
|
|
|
+ return fetchProfile();
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ payValue.value = 0;
|
|
|
+ balance.value = res.balance;
|
|
|
+ uni.hideLoading();
|
|
|
+ uni.showToast({
|
|
|
+ title: "已支付",
|
|
|
+ icon: "success",
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ if (needBack.value) {
|
|
|
+ back();
|
|
|
+ } else {
|
|
|
+ to("/pages-user/wallet/wallet");
|
|
|
+ }
|
|
|
+ }, 2000);
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ if (/cancel/.test(err.errMsg)) {
|
|
|
+ return;
|
|
|
}
|
|
|
- }, 2000);
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- if (/cancel/.test(err.errMsg)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- uni.showModal({
|
|
|
- content: `${err.errMsg},请重试`,
|
|
|
+ uni.showModal({
|
|
|
+ content: `${err.errMsg},请重试`,
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
};
|
|
|
+
|
|
|
+
|
|
|
onLoad((options: any) => {
|
|
|
+ console.log(options)
|
|
|
if (options.value) {
|
|
|
payOption.value = payOptions.value.findIndex(
|
|
|
- (item) => item === Number((Number(options.value) / 100).toFixed(2))
|
|
|
+ (item) => item === Number((Number(options.value) / 100).toFixed(2))
|
|
|
);
|
|
|
needBack.value = !!options.back;
|
|
|
}
|
|
|
+
|
|
|
+ if(options.discount){
|
|
|
+ payValue.value = Number((Number(options.discount) / 100).toFixed(2));
|
|
|
+ }
|
|
|
fetchProfile().then((res) => {
|
|
|
// console.log(res);
|
|
|
balance.value = res.balance;
|
|
|
@@ -143,7 +160,7 @@ onLoad((options: any) => {
|
|
|
if (fi >= 0) {
|
|
|
payOptionsDiscount.value[fi] = item.rightsDesc;
|
|
|
payOptionsDiscountDay.value[fi] =
|
|
|
- item.validity > 0 ? item.validity : 1;
|
|
|
+ item.validity > 0 ? item.validity : 1;
|
|
|
}
|
|
|
});
|
|
|
activityId.value = res.activityList[0].id;
|
|
|
@@ -172,9 +189,11 @@ onLoad((options: any) => {
|
|
|
color: #000;
|
|
|
font-weight: 500;
|
|
|
overflow: hidden;
|
|
|
+
|
|
|
&:nth-child(3n + 1) {
|
|
|
margin-left: 0;
|
|
|
}
|
|
|
+
|
|
|
.tag {
|
|
|
position: absolute;
|
|
|
top: 0px;
|
|
|
@@ -186,6 +205,7 @@ onLoad((options: any) => {
|
|
|
white-space: nowrap;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
.option-active {
|
|
|
background-color: var(--color-primary);
|
|
|
color: #fff;
|