|
|
@@ -140,7 +140,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
Promise.all([
|
|
|
- this.$http.get('/sysConfig/get/gas_fee').then(res => {
|
|
|
+ this.$http.get('/sysConfig/get/gift_gas_fee').then(res => {
|
|
|
this.gas = res.value;
|
|
|
return Promise.resolve();
|
|
|
}),
|
|
|
@@ -219,94 +219,115 @@ export default {
|
|
|
tradeCode: this.password
|
|
|
})
|
|
|
.then(() => {
|
|
|
- this.$http
|
|
|
- .post('/asset/gift', {
|
|
|
- assetId: this.$route.query.id,
|
|
|
- toUserId: this.$route.query.toUserId
|
|
|
- })
|
|
|
- .then(res => {
|
|
|
- this.orderId = res.id;
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.payType === 'ALIPAY') {
|
|
|
- // document.location.replace(
|
|
|
- // resolveUrl(this.$baseUrl, 'payOrder/gift/alipay?id=' + res.id)
|
|
|
- // );
|
|
|
- if (this.inWeixin) {
|
|
|
- document.location.replace(
|
|
|
- resolveUrl(this.$baseUrl, '/payOrder/gift/alipay_wx?id=' + res.id)
|
|
|
- );
|
|
|
- } else {
|
|
|
- this.$http
|
|
|
- .get(
|
|
|
- `/payOrder/gift/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${res.id}`
|
|
|
- )
|
|
|
- .then(res => {
|
|
|
- this.hrefUrl =
|
|
|
- 'alipays://platformapi/startapp?saId=10000007&qrcode=' + res;
|
|
|
- // window.open(
|
|
|
- // 'alipays://platformapi/startapp?saId=10000007&qrcode=' + res,
|
|
|
- // '_blank'
|
|
|
- // );
|
|
|
- this.$nextTick(() => {
|
|
|
- document.getElementById('pay').click();
|
|
|
- });
|
|
|
+ if (Number(this.gas)) {
|
|
|
+ this.$http
|
|
|
+ .post('/asset/gift', {
|
|
|
+ assetId: this.$route.query.id,
|
|
|
+ toUserId: this.$route.query.toUserId
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.orderId = res.id;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.payType === 'ALIPAY') {
|
|
|
+ // document.location.replace(
|
|
|
+ // resolveUrl(this.$baseUrl, 'payOrder/gift/alipay?id=' + res.id)
|
|
|
+ // );
|
|
|
+ if (this.inWeixin) {
|
|
|
+ document.location.replace(
|
|
|
+ resolveUrl(this.$baseUrl, '/payOrder/gift/alipay_wx?id=' + res.id)
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.$http
|
|
|
+ .get(
|
|
|
+ `/payOrder/gift/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${
|
|
|
+ res.id
|
|
|
+ }`
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ this.hrefUrl =
|
|
|
+ 'alipays://platformapi/startapp?saId=10000007&qrcode=' + res;
|
|
|
+ // window.open(
|
|
|
+ // 'alipays://platformapi/startapp?saId=10000007&qrcode=' + res,
|
|
|
+ // '_blank'
|
|
|
+ // );
|
|
|
+ this.$nextTick(() => {
|
|
|
+ document.getElementById('pay').click();
|
|
|
+ });
|
|
|
|
|
|
- this.$toast.loading({
|
|
|
- message: '加载中...',
|
|
|
- forbidClick: true
|
|
|
- });
|
|
|
- this.getOrder(true);
|
|
|
- })
|
|
|
- .catch(e => {
|
|
|
- if (e.error) {
|
|
|
- this.$toast(e.error);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- } else if (this.payType === 'WEIXIN') {
|
|
|
- if (this.inWeixin) {
|
|
|
- this.$toast.loading('加载中');
|
|
|
- this.$http
|
|
|
- .post('/payOrder/gift/weixin', {
|
|
|
- id: res.id,
|
|
|
- openId: localStorage.getItem('openId')
|
|
|
- })
|
|
|
- .then(res => {
|
|
|
- console.log({
|
|
|
- ...res,
|
|
|
- package: res.package || res.packageValue,
|
|
|
- timestamp: res.timestamp || res.timeStamp
|
|
|
- });
|
|
|
- let _this = this;
|
|
|
- wx.chooseWXPay({
|
|
|
- ...res,
|
|
|
- package: res.package || res.packageValue,
|
|
|
- timestamp: res.timeStamp,
|
|
|
- success(res) {
|
|
|
- _this.$toast.success('支付成功');
|
|
|
- setTimeout(() => {
|
|
|
- _this.$router.replace('/orders');
|
|
|
- }, 1000);
|
|
|
- },
|
|
|
- fail(e) {
|
|
|
- console.log(e);
|
|
|
- _this.$toast('支付失败,请稍后再试');
|
|
|
+ this.$toast.loading({
|
|
|
+ message: '加载中...',
|
|
|
+ forbidClick: true
|
|
|
+ });
|
|
|
+ this.getOrder(true);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e.error) {
|
|
|
+ this.$toast(e.error);
|
|
|
}
|
|
|
});
|
|
|
- });
|
|
|
- } else {
|
|
|
- document.location.replace(
|
|
|
- resolveUrl(this.$baseUrl, 'payOrder/gift/weixin_h5?id=' + res.id)
|
|
|
- );
|
|
|
+ }
|
|
|
+ } else if (this.payType === 'WEIXIN') {
|
|
|
+ if (this.inWeixin) {
|
|
|
+ this.$toast.loading('加载中');
|
|
|
+ this.$http
|
|
|
+ .post('/payOrder/gift/weixin', {
|
|
|
+ id: res.id,
|
|
|
+ openId: localStorage.getItem('openId')
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ console.log({
|
|
|
+ ...res,
|
|
|
+ package: res.package || res.packageValue,
|
|
|
+ timestamp: res.timestamp || res.timeStamp
|
|
|
+ });
|
|
|
+ let _this = this;
|
|
|
+ wx.chooseWXPay({
|
|
|
+ ...res,
|
|
|
+ package: res.package || res.packageValue,
|
|
|
+ timestamp: res.timeStamp,
|
|
|
+ success(res) {
|
|
|
+ _this.$toast.success('支付成功');
|
|
|
+ setTimeout(() => {
|
|
|
+ _this.$router.replace('/orders');
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ fail(e) {
|
|
|
+ console.log(e);
|
|
|
+ _this.$toast('支付失败,请稍后再试');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ document.location.replace(
|
|
|
+ resolveUrl(this.$baseUrl, 'payOrder/gift/weixin_h5?id=' + res.id)
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e) {
|
|
|
+ this.$toast(e.error);
|
|
|
}
|
|
|
});
|
|
|
- })
|
|
|
- .catch(e => {
|
|
|
- if (e) {
|
|
|
- this.$toast(e.error);
|
|
|
- }
|
|
|
- });
|
|
|
+ } else {
|
|
|
+ this.$http
|
|
|
+ .post('/asset/giftWithoutGasFee', {
|
|
|
+ assetId: this.$route.query.id,
|
|
|
+ toUserId: this.$route.query.toUserId
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.$toast.success('转赠成功');
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$router.go(-2);
|
|
|
+ }, 1500);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e) {
|
|
|
+ this.$toast(e.error);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
})
|
|
|
.catch(e => {
|
|
|
if (e) {
|