mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-04 22:59:49 +08:00
完成充值功能整体开发。
This commit is contained in:
@@ -409,6 +409,12 @@ const install = (Vue, vm) => {
|
||||
let getLiveInfo = (params, config = {}) => http.post('/Api/LiveBroadCast/GetLiveInfo', params, { custom: { methodName: 'liveBroadCast.getLiveInfo', needToken: false } });
|
||||
|
||||
|
||||
//充值规则列表
|
||||
let getTopUpTypeList = (params, config = {}) => http.post('/Api/TopUp/TypeList', params, { custom: { methodName: 'topUp.typeList', needToken: false } });
|
||||
//获取单个充值规则
|
||||
let getTypeDetail = (params, config = {}) => http.post('/Api/TopUp/getTypeDetail', params, { custom: { methodName: 'topUp.getTypeDetail', needToken: false } });
|
||||
|
||||
|
||||
// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
|
||||
vm.$u.api = {
|
||||
shopConfigV2,
|
||||
@@ -602,7 +608,10 @@ const install = (Vue, vm) => {
|
||||
getSolitairePageList,
|
||||
getSolitaireDetail,
|
||||
|
||||
getLiveInfo
|
||||
getLiveInfo,
|
||||
|
||||
getTopUpTypeList,
|
||||
getTypeDetail
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,10 +15,40 @@
|
||||
<u-form-item label="当前金额" borderBottom>
|
||||
<view class="coreshop-text-red coreshop-text-price coreshop-font-17">{{ user.balance || '0'}}</view>
|
||||
</u-form-item>
|
||||
<u-form-item label="储值金额" prop="money">
|
||||
<u--input type="number" v-model="form.money" placeholder='请输入要储值的金额' />
|
||||
<u-form-item label="储值金额" prop="form.money">
|
||||
<u--input type="number" v-model="form.money" disabled="true" placeholder='请输入要储值的金额' border="bottom" clearable />
|
||||
</u-form-item>
|
||||
</u--form>
|
||||
|
||||
<view class="coreshop-flex coreshop-align-center coreshop-justify-center coreshop-padding-10">
|
||||
请选择您的充值方案
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<u-grid :border="false" col="2">
|
||||
<u-grid-item v-for="(item, key) in typeList" :key="key">
|
||||
<view class="coreshop-padding-10 coreshop-percent-100">
|
||||
<u-button type="error" :plain="item.plain" :text="item.title" @click="changeMoney(key)"></u-button>
|
||||
</view>
|
||||
</u-grid-item>
|
||||
</u-grid>
|
||||
</view>
|
||||
|
||||
<view class="coreshop-font-13 coreshop-line-height-22 coreshop-margin-top-40">
|
||||
<p>
|
||||
充值须知:
|
||||
</p>
|
||||
<p>
|
||||
1、充值金额永不过期;
|
||||
</p>
|
||||
<p>
|
||||
2、充值一经办理,概不退款;
|
||||
</p>
|
||||
<p>
|
||||
3、充值金额将无法用于提现;
|
||||
</p>
|
||||
</view>
|
||||
|
||||
<!--按钮-->
|
||||
<view class="coreshop-bg-white coreshop-footer-fixed coreshop-foot-padding-bottom">
|
||||
<u-button type="error" size="normal" @click="navigateToHandle">去支付</u-button>
|
||||
@@ -32,8 +62,10 @@
|
||||
data() {
|
||||
return {
|
||||
user: {}, // 用户信息
|
||||
typeList: [],
|
||||
topUpTypeId: 0,
|
||||
form: {
|
||||
money: ''// 储值的金额
|
||||
money: 0// 储值的金额
|
||||
},
|
||||
rules: {
|
||||
money: [
|
||||
@@ -56,6 +88,7 @@
|
||||
},
|
||||
onLoad() {
|
||||
this.userInfo()
|
||||
this.getTopUpTypeList();
|
||||
},
|
||||
methods: {
|
||||
// 获取用户信息
|
||||
@@ -66,14 +99,47 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取用户信息
|
||||
getTopUpTypeList() {
|
||||
this.$u.api.getTopUpTypeList().then(res => {
|
||||
if (res.status) {
|
||||
for (var i = 0; i < res.data.length; i++) {
|
||||
res.data[i].plain = i != 0;
|
||||
if (i == 0) {
|
||||
this.form.money = res.data[0].defaultMoney;
|
||||
this.topUpTypeId = res.data[0].id;
|
||||
}
|
||||
}
|
||||
this.typeList = res.data;
|
||||
}
|
||||
})
|
||||
},
|
||||
changeMoney(key) {
|
||||
for (var i = 0; i < this.typeList.length; i++) {
|
||||
if (key == i) {
|
||||
this.typeList[i].plain = false;
|
||||
this.form.money = this.typeList[i].defaultMoney;
|
||||
this.topUpTypeId = this.typeList[i].id;
|
||||
} else {
|
||||
this.typeList[i].plain = true;
|
||||
}
|
||||
}
|
||||
this.$refs.uForm.validateField('form.money')
|
||||
console.log(key);
|
||||
console.log(this.topUpTypeId);
|
||||
},
|
||||
// 去储值
|
||||
navigateToHandle() {
|
||||
this.$refs.uForm.validate().then(res => {
|
||||
console.log('验证通过');
|
||||
if (this.topUpTypeId <= 0) {
|
||||
this.$u.toast('请选择您要储值的方案。')
|
||||
return false;
|
||||
}
|
||||
if (!Number(this.form.money)) {
|
||||
this.$u.toast('请输入要储值的金额')
|
||||
this.$u.toast('请选择您要储值的方案。')
|
||||
} else {
|
||||
this.$u.route('/pages/payment/pay/pay?recharge=' + Number(this.form.money) + '&type=' + this.orderType)
|
||||
this.$u.route('/pages/payment/pay/pay?recharge=' + Number(this.topUpTypeId) + '&type=' + this.orderType)
|
||||
}
|
||||
}).catch(errors => {
|
||||
uni.$u.toast('提交的数据校验失败,请输入合法信息!')
|
||||
|
||||
@@ -127,10 +127,11 @@
|
||||
trade_type: 'APP',
|
||||
}
|
||||
}
|
||||
data['ids'] = (this.type == this.$globalConstVars.paymentType.common || this.type == this.$globalConstVars.paymentType.pinTuan || this.type == this.$globalConstVars.paymentType.group || this.type == this.$globalConstVars.paymentType.seckill || this.type == this.$globalConstVars.paymentType.bargain || this.type == this.$globalConstVars.paymentType.giveaway || this.type == this.$globalConstVars.paymentType.solitaire || this.type == this.$globalConstVars.paymentType.transactionComponent || this.type == this.$globalConstVars.paymentType.serviceOrder) ? this.orderId : this.uid
|
||||
data.ids = (this.type == this.$globalConstVars.paymentType.common || this.type == this.$globalConstVars.paymentType.pinTuan || this.type == this.$globalConstVars.paymentType.group || this.type == this.$globalConstVars.paymentType.seckill || this.type == this.$globalConstVars.paymentType.bargain || this.type == this.$globalConstVars.paymentType.giveaway || this.type == this.$globalConstVars.paymentType.solitaire || this.type == this.$globalConstVars.paymentType.transactionComponent || this.type == this.$globalConstVars.paymentType.serviceOrder) ? this.orderId : this.uid
|
||||
|
||||
// 判断订单支付类型
|
||||
if (this.type == this.$globalConstVars.paymentType.recharge && this.recharge) {
|
||||
data.ids = this.recharge;
|
||||
data.params.money = this.recharge;
|
||||
} else if ((this.type == this.$globalConstVars.paymentType.formPay || this.type == this.$globalConstVars.paymentType.formOrder) && this.recharge) {
|
||||
data.ids = this.orderId;
|
||||
|
||||
@@ -137,17 +137,14 @@
|
||||
//trade_type: 'NATIVE',
|
||||
}
|
||||
}
|
||||
data['ids'] = (this.type == this.$globalConstVars.paymentType.common || this.type == this.$globalConstVars.paymentType.pinTuan || this.type == this.$globalConstVars.paymentType.group || this.type == this.$globalConstVars.paymentType.seckill || this.type == this.$globalConstVars.paymentType.bargain || this.type == this.$globalConstVars.paymentType.giveaway || this.type == this.$globalConstVars.paymentType.solitaire || this.type == this.$globalConstVars.paymentType.transactionComponent || this.type == this.$globalConstVars.paymentType.serviceOrder) ? this.orderId : this.uid
|
||||
data.ids = (this.type == this.$globalConstVars.paymentType.common || this.type == this.$globalConstVars.paymentType.pinTuan || this.type == this.$globalConstVars.paymentType.group || this.type == this.$globalConstVars.paymentType.seckill || this.type == this.$globalConstVars.paymentType.bargain || this.type == this.$globalConstVars.paymentType.giveaway || this.type == this.$globalConstVars.paymentType.solitaire || this.type == this.$globalConstVars.paymentType.transactionComponent || this.type == this.$globalConstVars.paymentType.serviceOrder) ? this.orderId : this.uid
|
||||
|
||||
// 判断订单支付类型
|
||||
if (this.type == this.$globalConstVars.paymentType.recharge && this.recharge) {
|
||||
data['params'] = {
|
||||
money: this.recharge
|
||||
}
|
||||
data.ids = this.recharge;
|
||||
data.params.money = this.recharge;
|
||||
} else if ((this.type == this.$globalConstVars.paymentType.formPay || this.type == this.$globalConstVars.paymentType.formOrder) && this.recharge) {
|
||||
data['ids'] = this.orderId;
|
||||
data['params'] = {
|
||||
}
|
||||
data.ids = this.orderId;
|
||||
}
|
||||
let _this = this
|
||||
switch (code) {
|
||||
@@ -164,7 +161,7 @@
|
||||
signType: res.data.paymentParameters.signType,
|
||||
paySign: res.data.paymentParameters.paySign,
|
||||
success: function (e) {
|
||||
uni.hideLoading();
|
||||
uni.hideLoading();
|
||||
if (e.errMsg === 'requestOrderPayment:ok') {
|
||||
_this.$u.route({ type: 'redirectTo', url: '/pages/payment/result/result?id=' + res.data.paymentId });
|
||||
}
|
||||
|
||||
@@ -48,10 +48,34 @@
|
||||
<template v-else-if="type == $globalConstVars.paymentType.recharge">
|
||||
<view class="coreshop-list-item">
|
||||
<view class="content">
|
||||
<text class="coreshop-text-grey">充值金额</text>
|
||||
<text class="coreshop-text-grey">充值规则</text>
|
||||
</view>
|
||||
<view class="action">
|
||||
<text class="coreshop-text-price coreshop-text-red coreshop-font-lg">{{ recharge || '' }}</text>
|
||||
<text class="coreshop-font-sm coreshop-text-gray">{{ topUpType.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="coreshop-list-item">
|
||||
<view class="content">
|
||||
<text class="coreshop-text-grey">支付金额</text>
|
||||
</view>
|
||||
<view class="action">
|
||||
<text class="coreshop-text-price coreshop-text-red coreshop-font-lg">{{ topUpType.defaultMoney }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="coreshop-list-item" v-if="topUpType.giftMoney>0">
|
||||
<view class="content">
|
||||
<text class="coreshop-text-grey">赠送金额</text>
|
||||
</view>
|
||||
<view class="action">
|
||||
<text class="coreshop-text-price coreshop-text-gray coreshop-font-lg">{{ topUpType.giftMoney }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="coreshop-list-item" v-if="topUpType.giftPoint>0">
|
||||
<view class="content">
|
||||
<text class="coreshop-font-sm coreshop-text-gray">赠送积分</text>
|
||||
</view>
|
||||
<view class="action">
|
||||
<text class="coreshop-font-sm coreshop-text-gray">{{ topUpType.giftPoint }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -137,6 +161,7 @@
|
||||
orderInfo: {}, // 订单详情
|
||||
userInfo: {}, // 用户信息
|
||||
serviceInfo: {}, // 服务信息
|
||||
topUpType: {}, // 充值类型信息
|
||||
formId: 0,
|
||||
};
|
||||
},
|
||||
@@ -161,11 +186,14 @@
|
||||
this.type = Number(options.type);
|
||||
this.formId = Number(options.formId);
|
||||
|
||||
console.log(this.recharge);
|
||||
|
||||
if (this.orderId && (this.type == this.$globalConstVars.paymentType.common || this.type == this.$globalConstVars.paymentType.pinTuan || this.type == this.$globalConstVars.paymentType.group || this.type == this.$globalConstVars.paymentType.seckill || this.type == this.$globalConstVars.paymentType.bargain || this.type == this.$globalConstVars.paymentType.giveaway || this.type == this.$globalConstVars.paymentType.solitaire || this.type == this.$globalConstVars.paymentType.transactionComponent)) {
|
||||
// 商品订单
|
||||
this.getOrderInfo();
|
||||
} else if (this.recharge && this.type == this.$globalConstVars.paymentType.recharge) {
|
||||
} else if (this.recharge > 0 && this.type == this.$globalConstVars.paymentType.recharge) {
|
||||
// 充值订单 获取用户id
|
||||
this.getTypeDetail();
|
||||
this.getUserInfo();
|
||||
} else if (this.formId && (this.type == this.$globalConstVars.paymentType.formPay || this.type == this.$globalConstVars.paymentType.formOrder)) {
|
||||
// 表单订单 id传到订单上
|
||||
@@ -209,6 +237,19 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
//获取单个充值规则
|
||||
getTypeDetail() {
|
||||
let data = {
|
||||
id: this.recharge
|
||||
};
|
||||
this.$u.api.getTypeDetail(data).then(res => {
|
||||
if (res.status) {
|
||||
this.topUpType = res.data;
|
||||
} else {
|
||||
this.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
// 获取用户信息
|
||||
getUserInfo() {
|
||||
this.$u.api.userInfo().then(res => {
|
||||
|
||||
Reference in New Issue
Block a user