|
|
@@ -58,7 +58,6 @@
|
|
|
|
|
|
<script>
|
|
|
const path = require('path');
|
|
|
-import { add } from 'mathjs';
|
|
|
import product from '../mixins/product';
|
|
|
import { mapState } from 'vuex';
|
|
|
let inWeixin = /micromessenger/i.test(navigator.userAgent);
|
|
|
@@ -97,10 +96,10 @@ export default {
|
|
|
money() {
|
|
|
let money = 0;
|
|
|
if (this.info.price && !this.couponInfo) {
|
|
|
- money = add(this.info.price, money);
|
|
|
+ money = this.accAdd(this.info.price, money);
|
|
|
}
|
|
|
if (this.gas && (!this.couponInfo || this.couponInfo.needGas)) {
|
|
|
- money = add(money, this.gas);
|
|
|
+ money = this.accAdd(money, this.gas);
|
|
|
}
|
|
|
|
|
|
return money;
|
|
|
@@ -169,46 +168,56 @@ export default {
|
|
|
this.$http
|
|
|
.post(url)
|
|
|
.then(res => {
|
|
|
- this.$toast.clear();
|
|
|
- this.orderId = res.id;
|
|
|
- this.$router.replace('/submit?orderId=' + res.id);
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.payType === 'ALIPAY') {
|
|
|
- document.location.replace(path.resolve(this.$baseUrl, 'payOrder/alipay?id=' + res.id));
|
|
|
- } else if (this.payType === 'WEIXIN') {
|
|
|
- if (this.inWeixin) {
|
|
|
- this.$toast.loading('加载中');
|
|
|
- this.$http
|
|
|
- .post('/payOrder/weixin', { id: res.id, openId: localStorage.getItem('openId') })
|
|
|
- .then(res => {
|
|
|
- console.log({
|
|
|
- ...res,
|
|
|
- package: res.package || res.packageValue
|
|
|
- });
|
|
|
- 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('支付失败,请稍后再试');
|
|
|
- }
|
|
|
+ if (this.money) {
|
|
|
+ this.$toast.clear();
|
|
|
+ this.orderId = res.id;
|
|
|
+ this.$router.replace('/submit?orderId=' + res.id);
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.payType === 'ALIPAY') {
|
|
|
+ document.location.replace(path.resolve(this.$baseUrl, 'payOrder/alipay?id=' + res.id));
|
|
|
+ } else if (this.payType === 'WEIXIN') {
|
|
|
+ if (this.inWeixin) {
|
|
|
+ this.$toast.loading('加载中');
|
|
|
+ this.$http
|
|
|
+ .post('/payOrder/weixin', {
|
|
|
+ id: res.id,
|
|
|
+ openId: localStorage.getItem('openId')
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ console.log({
|
|
|
+ ...res,
|
|
|
+ package: res.package || res.packageValue
|
|
|
+ });
|
|
|
+ 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(
|
|
|
- path.resolve(this.$baseUrl, 'payOrder/weixin_h5?id=' + res.id)
|
|
|
- );
|
|
|
+ } else {
|
|
|
+ document.location.replace(
|
|
|
+ path.resolve(this.$baseUrl, 'payOrder/weixin_h5?id=' + res.id)
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$toast.success('支付成功');
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$router.replace('/orderDetail?id=' + res.id);
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
})
|
|
|
.catch(e => {
|
|
|
if (e) {
|