|
@@ -11,28 +11,22 @@
|
|
|
<text class="tit">微信支付</text>
|
|
<text class="tit">微信支付</text>
|
|
|
<text>推荐使用微信支付</text>
|
|
<text>推荐使用微信支付</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <label class="radio">
|
|
|
|
|
- <radio value="" color="#921a23" :checked="payType == 1"></radio>
|
|
|
|
|
- </label>
|
|
|
|
|
|
|
+ <label class="radio"><radio value="" color="#ee2f72" :checked="payType == 1"></radio></label>
|
|
|
</view>
|
|
</view>
|
|
|
<!-- #ifdef APP-PLUS -->
|
|
<!-- #ifdef APP-PLUS -->
|
|
|
<view class="type-item b-b" @click="changePayType(2)">
|
|
<view class="type-item b-b" @click="changePayType(2)">
|
|
|
<text class="icon iconfont iconzhifubao"></text>
|
|
<text class="icon iconfont iconzhifubao"></text>
|
|
|
<view class="con"><text class="tit">支付宝支付</text></view>
|
|
<view class="con"><text class="tit">支付宝支付</text></view>
|
|
|
- <label class="radio">
|
|
|
|
|
- <radio value="" color="#921a23" :checked="payType == 2"></radio>
|
|
|
|
|
- </label>
|
|
|
|
|
|
|
+ <label class="radio"><radio value="" color="#ee2f72" :checked="payType == 2"></radio></label>
|
|
|
</view>
|
|
</view>
|
|
|
<!-- #endif -->
|
|
<!-- #endif -->
|
|
|
- <view class="type-item" @click="changePayType(3)">
|
|
|
|
|
|
|
+ <view class="type-item" @click="changePayType(3)" v-if="yue">
|
|
|
<text class="icon iconfont iconyue"></text>
|
|
<text class="icon iconfont iconyue"></text>
|
|
|
<view class="con">
|
|
<view class="con">
|
|
|
<text class="tit">余额支付</text>
|
|
<text class="tit">余额支付</text>
|
|
|
<text>可用余额 ¥{{ now_money }}</text>
|
|
<text>可用余额 ¥{{ now_money }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <label class="radio">
|
|
|
|
|
- <radio value="" color="#921a23" :checked="payType == 3"></radio>
|
|
|
|
|
- </label>
|
|
|
|
|
|
|
+ <label class="radio"><radio value="" color="#ee2f72" :checked="payType == 3"></radio></label>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<text class="mix-btn" :class="{ clickbg: payLoding }" @click="!payLoding ? confirm() : ''">确认支付</text>
|
|
<text class="mix-btn" :class="{ clickbg: payLoding }" @click="!payLoding ? confirm() : ''">确认支付</text>
|
|
@@ -40,464 +34,445 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
- import {
|
|
|
|
|
- balance
|
|
|
|
|
- } from '@/api/wallet.js';
|
|
|
|
|
- import {
|
|
|
|
|
- createOrderkey,
|
|
|
|
|
- computedOrderkey,
|
|
|
|
|
- orderPay
|
|
|
|
|
- } from '@/api/order.js';
|
|
|
|
|
- import {
|
|
|
|
|
- mapState
|
|
|
|
|
- } from 'vuex';
|
|
|
|
|
- export default {
|
|
|
|
|
- data() {
|
|
|
|
|
- return {
|
|
|
|
|
- payType: 1, //支付类型
|
|
|
|
|
- // #ifdef H5
|
|
|
|
|
- payName: 'weixin',
|
|
|
|
|
- // #endif
|
|
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
|
|
- payName: 'weixin',
|
|
|
|
|
- // #endif
|
|
|
|
|
- orderInfo: {},
|
|
|
|
|
- money: 0.0, //订单金额
|
|
|
|
|
- now_money: 0.0, //余额
|
|
|
|
|
- orderKey: '',
|
|
|
|
|
- orderId: '', //保存订单id
|
|
|
|
|
- payLoding: false, //判断是否支付中
|
|
|
|
|
- type: '', //判断是否从订单中进入
|
|
|
|
|
- // #ifdef H5
|
|
|
|
|
- froms: '', //保存h5中数据来源对象
|
|
|
|
|
- // #endif
|
|
|
|
|
- pinkid: '', //保存拼团商品id
|
|
|
|
|
- store_id: 0,
|
|
|
|
|
- point_id: 0,
|
|
|
|
|
- shipping_type: 1,
|
|
|
|
|
- goodsType: 0,
|
|
|
|
|
- };
|
|
|
|
|
- },
|
|
|
|
|
- computed: {
|
|
|
|
|
|
|
+import { balance } from '@/api/wallet.js';
|
|
|
|
|
+import { createOrderkey, computedOrderkey, orderPay } from '@/api/order.js';
|
|
|
|
|
+import { mapState } from 'vuex';
|
|
|
|
|
+export default {
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ payType: 1, //支付类型
|
|
|
// #ifdef H5
|
|
// #ifdef H5
|
|
|
- ...mapState(['weichatObj'])
|
|
|
|
|
|
|
+ payName: 'weixin',
|
|
|
// #endif
|
|
// #endif
|
|
|
- },
|
|
|
|
|
- onLoad(options) {
|
|
|
|
|
- if (options.store_id) {
|
|
|
|
|
- this.store_id = options.store_id
|
|
|
|
|
- }
|
|
|
|
|
- if (options.goodstype) {
|
|
|
|
|
- this.goodsType = options.goodstype
|
|
|
|
|
- console.log(this.goodsType, 'this.goodsTypethis.goodsTypethis.goodsType')
|
|
|
|
|
- }
|
|
|
|
|
- if (options.type == 1) {
|
|
|
|
|
- console.log(options.ordid,options.money,'------------------------')
|
|
|
|
|
- this.type = 1;
|
|
|
|
|
- this.orderId = options.ordid;
|
|
|
|
|
- this.money = options.money*1;
|
|
|
|
|
- } else {
|
|
|
|
|
- this.orderKey = options.key;
|
|
|
|
|
- let prepage = this.$api.prePage();
|
|
|
|
|
- computedOrderkey({
|
|
|
|
|
- orderkey: this.orderKey,
|
|
|
|
|
- couponId: prepage.couponChecked ? prepage.couponChecked.id : '', //优惠券编号
|
|
|
|
|
- addressId: prepage.addressData.id, //地址编号
|
|
|
|
|
- useIntegral: prepage.checkedPoints ? 1 : 0,
|
|
|
|
|
- shipping_type: prepage.shipping_type
|
|
|
|
|
- }).then(({
|
|
|
|
|
- data
|
|
|
|
|
- }) => {
|
|
|
|
|
- // 获取支付金额
|
|
|
|
|
- console.log(data)
|
|
|
|
|
- if (this.shipping_type == 1) { //快递
|
|
|
|
|
- this.money = +data.result.pay_price + +data.result.deposit;
|
|
|
|
|
- }
|
|
|
|
|
- if (this.shipping_type == 2) { //自提
|
|
|
|
|
- this.money = +data.result.pay_price + +data.result.deposit - +data.result.pay_postage;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- // 保存pinkid
|
|
|
|
|
- if (options.pinkid) {
|
|
|
|
|
- this.pinkid = options.pinkid;
|
|
|
|
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
|
|
+ payName: 'weixin',
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ orderInfo: {},
|
|
|
|
|
+ money: 0.0, //订单金额
|
|
|
|
|
+ now_money: 0.0, //余额
|
|
|
|
|
+ orderKey: '',
|
|
|
|
|
+ orderId: '', //保存订单id
|
|
|
|
|
+ payLoding: false, //判断是否支付中
|
|
|
|
|
+ type: '', //判断是否从订单中进入
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
|
+ froms: '', //保存h5中数据来源对象
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ pinkid: '', //保存拼团商品id
|
|
|
|
|
+ store_id: 0,
|
|
|
|
|
+ point_id: 0,
|
|
|
|
|
+ shipping_type: 1,
|
|
|
|
|
+ goodsType: 0,
|
|
|
|
|
+ yue: false //是否开启余额抵扣
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
|
+ ...mapState(['weichatObj'])
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ },
|
|
|
|
|
+ onLoad(options) {
|
|
|
|
|
+ this.yue = options.isyue;
|
|
|
|
|
+ if (options.store_id) {
|
|
|
|
|
+ this.store_id = options.store_id;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (options.goodstype) {
|
|
|
|
|
+ this.goodsType = options.goodstype;
|
|
|
|
|
+ console.log(this.goodsType, 'this.goodsTypethis.goodsTypethis.goodsType');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (options.type == 1) {
|
|
|
|
|
+ console.log(options.ordid, options.money, '------------------------');
|
|
|
|
|
+ this.type = 1;
|
|
|
|
|
+ this.orderId = options.ordid;
|
|
|
|
|
+ this.money = options.money * 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.orderKey = options.key;
|
|
|
|
|
+ let prepage = this.$api.prePage();
|
|
|
|
|
+ computedOrderkey({
|
|
|
|
|
+ orderkey: this.orderKey,
|
|
|
|
|
+ couponId: prepage.couponChecked ? prepage.couponChecked.id : '', //优惠券编号
|
|
|
|
|
+ addressId: prepage.addressData.id, //地址编号
|
|
|
|
|
+ useIntegral: prepage.checkedPoints ? 1 : 0,
|
|
|
|
|
+ useIntegral: prepage.checkedYue ? 1 : 0,
|
|
|
|
|
+ shipping_type: prepage.shipping_type
|
|
|
|
|
+ }).then(({ data }) => {
|
|
|
|
|
+ // 获取支付金额
|
|
|
|
|
+ console.log(data, '123456');
|
|
|
|
|
+ this.money = +data.result.pay_price;
|
|
|
|
|
+ //快递
|
|
|
|
|
+ // if (this.shipping_type == 1) {
|
|
|
|
|
+ // this.money = +data.result.pay_price + +data.result.deposit;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //自提
|
|
|
|
|
+ // if (this.shipping_type == 2) {
|
|
|
|
|
+ // this.money = +data.result.pay_price + +data.result.deposit - +data.result.pay_postage;
|
|
|
|
|
+ // }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // 保存pinkid
|
|
|
|
|
+ if (options.pinkid) {
|
|
|
|
|
+ this.pinkid = options.pinkid;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (options.point_id) {
|
|
|
|
|
+ this.point_id = options.point_id;
|
|
|
|
|
+ console.log(this.point_id, 'this.point_id+++++++++++++');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (options.shipping_type) {
|
|
|
|
|
+ this.shipping_type = options.shipping_type;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 载入余额
|
|
|
|
|
+ balance({}).then(({ data }) => {
|
|
|
|
|
+ // 获取余额
|
|
|
|
|
+ this.now_money = data.now_money;
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ //选择支付方式
|
|
|
|
|
+ changePayType(type) {
|
|
|
|
|
+ this.payType = type;
|
|
|
|
|
+ if (this.payType == 1) {
|
|
|
|
|
+ this.payName = 'weixin';
|
|
|
}
|
|
}
|
|
|
- if (options.point_id) {
|
|
|
|
|
- this.point_id = options.point_id
|
|
|
|
|
- console.log(this.point_id, 'this.point_id+++++++++++++')
|
|
|
|
|
|
|
+ if (this.payType == 2) {
|
|
|
|
|
+ this.payName = 'ali';
|
|
|
}
|
|
}
|
|
|
- if (options.shipping_type) {
|
|
|
|
|
- this.shipping_type = options.shipping_type
|
|
|
|
|
|
|
+ if (this.payType == 3) {
|
|
|
|
|
+ this.payName = 'yue';
|
|
|
}
|
|
}
|
|
|
- // 载入余额
|
|
|
|
|
- balance({}).then(({
|
|
|
|
|
- data
|
|
|
|
|
- }) => {
|
|
|
|
|
- // 获取余额
|
|
|
|
|
- this.now_money = data.now_money;
|
|
|
|
|
- });
|
|
|
|
|
},
|
|
},
|
|
|
- methods: {
|
|
|
|
|
- //选择支付方式
|
|
|
|
|
- changePayType(type) {
|
|
|
|
|
- this.payType = type;
|
|
|
|
|
- if (this.payType == 1) {
|
|
|
|
|
- this.payName = 'weixin';
|
|
|
|
|
- }
|
|
|
|
|
- if (this.payType == 2) {
|
|
|
|
|
- this.payName = 'ali';
|
|
|
|
|
- }
|
|
|
|
|
- if (this.payType == 3) {
|
|
|
|
|
- this.payName = 'yue';
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- // 支付金额
|
|
|
|
|
- orderMoneyPay() {
|
|
|
|
|
- let obj = this;
|
|
|
|
|
- orderPay({
|
|
|
|
|
- uni: obj.orderId,
|
|
|
|
|
- // #ifdef H5
|
|
|
|
|
- from: obj.froms ? 'weixin' : 'H5', //来源
|
|
|
|
|
- // #endif
|
|
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
|
|
- from: 'routine', //来源
|
|
|
|
|
- // #endif
|
|
|
|
|
- // #ifdef APP-PLUS
|
|
|
|
|
- from: 'app', //来源
|
|
|
|
|
- // #endif
|
|
|
|
|
- paytype: obj.payName //支付类型 weixin-微信 yue-余额
|
|
|
|
|
- })
|
|
|
|
|
- .then(e => {
|
|
|
|
|
- // 判断是否为余额支付
|
|
|
|
|
- if (obj.payName == 'yue' && e.data.status == 'SUCCESS') {
|
|
|
|
|
- if (e.status == 200) {
|
|
|
|
|
- obj.paySuccessTo();
|
|
|
|
|
- } else {
|
|
|
|
|
- obj.$api.msg(msg);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 支付金额
|
|
|
|
|
+ orderMoneyPay() {
|
|
|
|
|
+ let obj = this;
|
|
|
|
|
+ orderPay({
|
|
|
|
|
+ uni: obj.orderId,
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
|
+ from: obj.froms ? 'weixin' : 'H5', //来源
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
|
|
+ from: 'routine', //来源
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ // #ifdef APP-PLUS
|
|
|
|
|
+ from: 'app', //来源
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ paytype: obj.payName //支付类型 weixin-微信 yue-余额
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(e => {
|
|
|
|
|
+ // 判断是否为余额支付
|
|
|
|
|
+ if (obj.payName == 'yue' && e.data.status == 'SUCCESS') {
|
|
|
|
|
+ if (e.status == 200) {
|
|
|
|
|
+ obj.paySuccessTo();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ obj.$api.msg(msg);
|
|
|
}
|
|
}
|
|
|
- if (obj.payName == 'weixin' || obj.payName == 'routine') {
|
|
|
|
|
- let da = e.data.result.jsConfig;
|
|
|
|
|
- let data = {
|
|
|
|
|
- // #ifdef H5
|
|
|
|
|
- timestamp: da.timestamp,
|
|
|
|
|
- // #endif
|
|
|
|
|
- // #ifdef MP
|
|
|
|
|
- timeStamp: da.timestamp,
|
|
|
|
|
- // #endif
|
|
|
|
|
- nonceStr: da.nonceStr,
|
|
|
|
|
- package: da.package,
|
|
|
|
|
- signType: da.signType,
|
|
|
|
|
- paySign: da.paySign,
|
|
|
|
|
- success: function(res) {
|
|
|
|
|
- obj.paySuccessTo();
|
|
|
|
|
- },
|
|
|
|
|
- fail: () => {
|
|
|
|
|
- uni.switchTab({
|
|
|
|
|
- url: '/pages/cart/cart?state=0'
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (obj.payName == 'weixin' || obj.payName == 'routine') {
|
|
|
|
|
+ let da = e.data.result.jsConfig;
|
|
|
|
|
+ let data = {
|
|
|
// #ifdef H5
|
|
// #ifdef H5
|
|
|
- if (obj.payName == 'weixin') {
|
|
|
|
|
- obj.weichatObj.chooseWXPay(data);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ timestamp: da.timestamp,
|
|
|
// #endif
|
|
// #endif
|
|
|
- console.log('开始支付')
|
|
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
|
|
- console.log('MP-WEIXIN++++++++++')
|
|
|
|
|
- console.log(obj.payName)
|
|
|
|
|
- if (obj.payName == 'weixin') {
|
|
|
|
|
- console.log('开始支付')
|
|
|
|
|
- wx.requestPayment(data);
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // #ifdef MP
|
|
|
|
|
+ timeStamp: da.timestamp,
|
|
|
// #endif
|
|
// #endif
|
|
|
|
|
+ nonceStr: da.nonceStr,
|
|
|
|
|
+ package: da.package,
|
|
|
|
|
+ signType: da.signType,
|
|
|
|
|
+ paySign: da.paySign,
|
|
|
|
|
+ success: function(res) {
|
|
|
|
|
+ obj.paySuccessTo();
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: () => {
|
|
|
|
|
+ uni.switchTab({
|
|
|
|
|
+ url: '/pages/cart/cart?state=0'
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
|
+ if (obj.payName == 'weixin') {
|
|
|
|
|
+ obj.weichatObj.chooseWXPay(data);
|
|
|
}
|
|
}
|
|
|
- uni.hideLoading();
|
|
|
|
|
- obj.payLoding = false;
|
|
|
|
|
- })
|
|
|
|
|
- .catch(e => {
|
|
|
|
|
- // 支付完成
|
|
|
|
|
- obj.payLoding = false;
|
|
|
|
|
- console.log(e);
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- // 支付成功跳转
|
|
|
|
|
- paySuccessTo() {
|
|
|
|
|
- uni.hideLoading();
|
|
|
|
|
- uni.redirectTo({
|
|
|
|
|
- url: '/pages/money/paySuccess?orderid=' + this.orderId + "&mun=" + this.money
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- //确认支付
|
|
|
|
|
- confirm: async function() {
|
|
|
|
|
- let obj = this;
|
|
|
|
|
- wx.getSetting({
|
|
|
|
|
- withSubscriptions: true,
|
|
|
|
|
- success(res) {
|
|
|
|
|
- if (res["utyQMQe5vfiJt1CA3-Q3JnGd2_dQ3mdyY0K44Gpaut4"] == "accept") {
|
|
|
|
|
- console.log('订阅成功')
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ console.log('开始支付');
|
|
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
|
|
+ console.log('MP-WEIXIN++++++++++');
|
|
|
|
|
+ console.log(obj.payName);
|
|
|
|
|
+ if (obj.payName == 'weixin') {
|
|
|
|
|
+ console.log('开始支付');
|
|
|
|
|
+ wx.requestPayment(data);
|
|
|
}
|
|
}
|
|
|
|
|
+ // #endif
|
|
|
}
|
|
}
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ obj.payLoding = false;
|
|
|
})
|
|
})
|
|
|
- if (wx.requestSubscribeMessage) {
|
|
|
|
|
- wx.requestSubscribeMessage({
|
|
|
|
|
- tmplIds: ['utyQMQe5vfiJt1CA3-Q3JnGd2_dQ3mdyY0K44Gpaut4'],
|
|
|
|
|
- success(res) {
|
|
|
|
|
- console.log(res,'订阅消息')
|
|
|
|
|
- },
|
|
|
|
|
- fail(err) {
|
|
|
|
|
- console.log(err)
|
|
|
|
|
- },
|
|
|
|
|
- complete() {
|
|
|
|
|
-
|
|
|
|
|
- // 判断是否余额不足
|
|
|
|
|
- if (obj.payName == 'yue' && +obj.now_money < obj.money) {
|
|
|
|
|
- uni.showModal({
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- content: '账户余额不足!',
|
|
|
|
|
- showCancel: false,
|
|
|
|
|
- success: res => {},
|
|
|
|
|
- fail: () => {},
|
|
|
|
|
- complete: () => {}
|
|
|
|
|
- });
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- uni.showLoading({
|
|
|
|
|
- title: '支付中',
|
|
|
|
|
- mask: true
|
|
|
|
|
- })
|
|
|
|
|
- // 支付中
|
|
|
|
|
- obj.payLoding = true;
|
|
|
|
|
- // #ifdef H5
|
|
|
|
|
- // 获取当前是否为微信浏览器
|
|
|
|
|
- obj.froms = uni.getStorageSync('weichatBrowser') || '';
|
|
|
|
|
- // #endif
|
|
|
|
|
- // 判断是否为未支付订单中跳转进入
|
|
|
|
|
- if (obj.type != 1) {
|
|
|
|
|
- // 初次生成订单
|
|
|
|
|
- console.log('初次生成订单')
|
|
|
|
|
- obj.firstCreateOrder();
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- // 已经生成订单未支付
|
|
|
|
|
- console.log('已经生成订单未支付')
|
|
|
|
|
- obj.orderMoneyPay();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
-
|
|
|
|
|
- // 判断是否余额不足
|
|
|
|
|
- if (obj.payName == 'yue' && +obj.now_money < obj.money) {
|
|
|
|
|
- uni.showModal({
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- content: '账户余额不足!',
|
|
|
|
|
- showCancel: false,
|
|
|
|
|
- success: res => {},
|
|
|
|
|
- fail: () => {},
|
|
|
|
|
- complete: () => {}
|
|
|
|
|
- });
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- uni.showLoading({
|
|
|
|
|
- title: '支付中',
|
|
|
|
|
- mask: true
|
|
|
|
|
- })
|
|
|
|
|
- // 支付中
|
|
|
|
|
- obj.payLoding = true;
|
|
|
|
|
- // #ifdef H5
|
|
|
|
|
- // 获取当前是否为微信浏览器
|
|
|
|
|
- obj.froms = uni.getStorageSync('weichatBrowser') || '';
|
|
|
|
|
- // #endif
|
|
|
|
|
- // 判断是否为未支付订单中跳转进入
|
|
|
|
|
- if (obj.type != 1) {
|
|
|
|
|
- // 初次生成订单
|
|
|
|
|
- console.log('初次生成订单')
|
|
|
|
|
- obj.firstCreateOrder();
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- // 已经生成订单未支付
|
|
|
|
|
- console.log('已经生成订单未支付')
|
|
|
|
|
- obj.orderMoneyPay();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- },
|
|
|
|
|
- // 初次订单创建
|
|
|
|
|
- firstCreateOrder() {
|
|
|
|
|
- let obj = this;
|
|
|
|
|
- // 获取下单页面数据
|
|
|
|
|
- let prepage = obj.$api.prePage();
|
|
|
|
|
- console.log(obj.goodsType, 'obj.goodsType+++++++++++++++++++')
|
|
|
|
|
- let data = {
|
|
|
|
|
- free_check: obj.goodsType == '3' ? '1' : '0',
|
|
|
|
|
- real_name: prepage.addressData.real_name, //联系人名称
|
|
|
|
|
- phone: prepage.addressData.phone, //联系人号码
|
|
|
|
|
- couponId: prepage.couponChecked.id, //优惠券编号
|
|
|
|
|
- addressId: prepage.addressData.id, //支付地址id
|
|
|
|
|
- useIntegral: prepage.checkedPoints ? 1 : 0, //是否积分抵扣1为是0为否
|
|
|
|
|
- payType: obj.payName, //支付类型 weixin-微信 yue-余额
|
|
|
|
|
- mark: prepage.desc, //备注
|
|
|
|
|
- time_area: prepage.time_area,//配送时间
|
|
|
|
|
- // #ifdef H5
|
|
|
|
|
- from: obj.froms ? 'weixin' : 'H5', //来源
|
|
|
|
|
- // #endif
|
|
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
|
|
- from: 'routine', //来源
|
|
|
|
|
- // #endif
|
|
|
|
|
- // #ifdef APP-PLUS
|
|
|
|
|
- from: 'app', //来源
|
|
|
|
|
- // #endif
|
|
|
|
|
- shipping_type: this.shipping_type //提货方式 1 快递 2自提
|
|
|
|
|
- };
|
|
|
|
|
- if (obj.goodsType == '3') {
|
|
|
|
|
- data.free_check = '1'
|
|
|
|
|
- data.shipping_type = '2'
|
|
|
|
|
- } else {
|
|
|
|
|
- data.store_id = obj.store_id
|
|
|
|
|
- data.point_id = obj.point_id
|
|
|
|
|
- }
|
|
|
|
|
- console.log(data, '888888888887777777777777')
|
|
|
|
|
- // 判断是否拼团商品
|
|
|
|
|
- if (obj.pinkid) {
|
|
|
|
|
- data.pinkId = obj.pinkid;
|
|
|
|
|
|
|
+ .catch(e => {
|
|
|
|
|
+ // 支付完成
|
|
|
|
|
+ obj.payLoding = false;
|
|
|
|
|
+ console.log(e);
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ // 支付成功跳转
|
|
|
|
|
+ paySuccessTo() {
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ uni.redirectTo({
|
|
|
|
|
+ url: '/pages/money/paySuccess?orderid=' + this.orderId + '&mun=' + this.money
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ //确认支付
|
|
|
|
|
+ confirm: async function() {
|
|
|
|
|
+ let obj = this;
|
|
|
|
|
+ wx.getSetting({
|
|
|
|
|
+ withSubscriptions: true,
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ if (res['utyQMQe5vfiJt1CA3-Q3JnGd2_dQ3mdyY0K44Gpaut4'] == 'accept') {
|
|
|
|
|
+ console.log('订阅成功');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- // 生成订单
|
|
|
|
|
- createOrderkey(data, obj.orderKey)
|
|
|
|
|
- .then(({
|
|
|
|
|
- data,
|
|
|
|
|
- status,
|
|
|
|
|
- msg
|
|
|
|
|
- }) => {
|
|
|
|
|
- // 判断是否支付失败
|
|
|
|
|
- if (data.status == 'ORDER_EXIST') {
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ if (wx.requestSubscribeMessage) {
|
|
|
|
|
+ wx.requestSubscribeMessage({
|
|
|
|
|
+ tmplIds: ['utyQMQe5vfiJt1CA3-Q3JnGd2_dQ3mdyY0K44Gpaut4'],
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ console.log(res, '订阅消息');
|
|
|
|
|
+ },
|
|
|
|
|
+ fail(err) {
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ },
|
|
|
|
|
+ complete() {
|
|
|
|
|
+ // 判断是否余额不足
|
|
|
|
|
+ if (obj.payName == 'yue' && +obj.now_money < obj.money) {
|
|
|
uni.showModal({
|
|
uni.showModal({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
- content: msg,
|
|
|
|
|
- showCancel: false
|
|
|
|
|
|
|
+ content: '账户余额不足!',
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ success: res => {},
|
|
|
|
|
+ fail: () => {},
|
|
|
|
|
+ complete: () => {}
|
|
|
});
|
|
});
|
|
|
- uni.hideLoading();
|
|
|
|
|
- obj.payLoding = false;
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- // 保存订单号
|
|
|
|
|
- obj.orderId = data.result.orderId;
|
|
|
|
|
- // 判断是否为余额支付
|
|
|
|
|
- if (obj.payName == 'yue') {
|
|
|
|
|
- if (status == 200 && data.status == 'SUCCESS') {
|
|
|
|
|
- obj.paySuccessTo();
|
|
|
|
|
- } else {
|
|
|
|
|
- obj.$api.msg(msg);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '支付中',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ });
|
|
|
|
|
+ // 支付中
|
|
|
|
|
+ obj.payLoding = true;
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
|
+ // 获取当前是否为微信浏览器
|
|
|
|
|
+ obj.froms = uni.getStorageSync('weichatBrowser') || '';
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ // 判断是否为未支付订单中跳转进入
|
|
|
|
|
+ if (obj.type != 1) {
|
|
|
|
|
+ // 初次生成订单
|
|
|
|
|
+ console.log('初次生成订单');
|
|
|
|
|
+ obj.firstCreateOrder();
|
|
|
} else {
|
|
} else {
|
|
|
- // 立即支付
|
|
|
|
|
|
|
+ // 已经生成订单未支付
|
|
|
|
|
+ console.log('已经生成订单未支付');
|
|
|
obj.orderMoneyPay();
|
|
obj.orderMoneyPay();
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
- .catch(e => {
|
|
|
|
|
- obj.payLoding = false;
|
|
|
|
|
- console.log(e);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 判断是否余额不足
|
|
|
|
|
+ if (obj.payName == 'yue' && +obj.now_money < obj.money) {
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ content: '账户余额不足!',
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ success: res => {},
|
|
|
|
|
+ fail: () => {},
|
|
|
|
|
+ complete: () => {}
|
|
|
});
|
|
});
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '支付中',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ });
|
|
|
|
|
+ // 支付中
|
|
|
|
|
+ obj.payLoding = true;
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
|
+ // 获取当前是否为微信浏览器
|
|
|
|
|
+ obj.froms = uni.getStorageSync('weichatBrowser') || '';
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ // 判断是否为未支付订单中跳转进入
|
|
|
|
|
+ if (obj.type != 1) {
|
|
|
|
|
+ // 初次生成订单
|
|
|
|
|
+ console.log('初次生成订单');
|
|
|
|
|
+ obj.firstCreateOrder();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 已经生成订单未支付
|
|
|
|
|
+ console.log('已经生成订单未支付');
|
|
|
|
|
+ obj.orderMoneyPay();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 初次订单创建
|
|
|
|
|
+ firstCreateOrder() {
|
|
|
|
|
+ let obj = this;
|
|
|
|
|
+ // 获取下单页面数据
|
|
|
|
|
+ let prepage = obj.$api.prePage();
|
|
|
|
|
+ console.log(obj.goodsType, 'obj.goodsType+++++++++++++++++++');
|
|
|
|
|
+ let data = {
|
|
|
|
|
+ free_check: obj.goodsType == '3' ? '1' : '0',
|
|
|
|
|
+ real_name: prepage.addressData.real_name, //联系人名称
|
|
|
|
|
+ phone: prepage.addressData.phone, //联系人号码
|
|
|
|
|
+ couponId: prepage.couponChecked.id, //优惠券编号
|
|
|
|
|
+ addressId: prepage.addressData.id, //支付地址id
|
|
|
|
|
+ useIntegral: prepage.checkedPoints ? 1 : 0, //是否积分抵扣1为是0为否
|
|
|
|
|
+ payType: obj.payName, //支付类型 weixin-微信 yue-余额
|
|
|
|
|
+ mark: prepage.desc, //备注
|
|
|
|
|
+ time_area: prepage.time_area, //配送时间
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
|
+ from: obj.froms ? 'weixin' : 'H5', //来源
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
|
|
+ from: 'routine', //来源
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ // #ifdef APP-PLUS
|
|
|
|
|
+ from: 'app', //来源
|
|
|
|
|
+ // #endif
|
|
|
|
|
+ shipping_type: this.shipping_type //提货方式 1 快递 2自提
|
|
|
|
|
+ };
|
|
|
|
|
+ if (obj.goodsType == '3') {
|
|
|
|
|
+ data.free_check = '1';
|
|
|
|
|
+ data.shipping_type = '2';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ data.store_id = obj.store_id;
|
|
|
|
|
+ data.point_id = obj.point_id;
|
|
|
}
|
|
}
|
|
|
|
|
+ console.log(data, '888888888887777777777777');
|
|
|
|
|
+ // 判断是否拼团商品
|
|
|
|
|
+ if (obj.pinkid) {
|
|
|
|
|
+ data.pinkId = obj.pinkid;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 生成订单
|
|
|
|
|
+ createOrderkey(data, obj.orderKey)
|
|
|
|
|
+ .then(({ data, status, msg }) => {
|
|
|
|
|
+ // 判断是否支付失败
|
|
|
|
|
+ if (data.status == 'ORDER_EXIST') {
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ content: msg,
|
|
|
|
|
+ showCancel: false
|
|
|
|
|
+ });
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ obj.payLoding = false;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 保存订单号
|
|
|
|
|
+ obj.orderId = data.result.orderId;
|
|
|
|
|
+ // 判断是否为余额支付
|
|
|
|
|
+ if (obj.payName == 'yue') {
|
|
|
|
|
+ if (status == 200 && data.status == 'SUCCESS') {
|
|
|
|
|
+ obj.paySuccessTo();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ obj.$api.msg(msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 立即支付
|
|
|
|
|
+ obj.orderMoneyPay();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(e => {
|
|
|
|
|
+ obj.payLoding = false;
|
|
|
|
|
+ console.log(e);
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
<style lang="scss">
|
|
|
- .app {
|
|
|
|
|
- width: 100%;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+.app {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- .price-box {
|
|
|
|
|
- background-color: #fff;
|
|
|
|
|
- height: 265upx;
|
|
|
|
|
- display: flex;
|
|
|
|
|
- flex-direction: column;
|
|
|
|
|
- justify-content: center;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- font-size: 28upx;
|
|
|
|
|
- color: #909399;
|
|
|
|
|
|
|
+.price-box {
|
|
|
|
|
+ background-color: #fff;
|
|
|
|
|
+ height: 265upx;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ font-size: 28upx;
|
|
|
|
|
+ color: #909399;
|
|
|
|
|
|
|
|
- .price {
|
|
|
|
|
- font-size: 50upx;
|
|
|
|
|
- color: #303133;
|
|
|
|
|
- margin-top: 12upx;
|
|
|
|
|
|
|
+ .price {
|
|
|
|
|
+ font-size: 50upx;
|
|
|
|
|
+ color: #303133;
|
|
|
|
|
+ margin-top: 12upx;
|
|
|
|
|
|
|
|
- &:before {
|
|
|
|
|
- content: '¥';
|
|
|
|
|
- font-size: 40upx;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ &:before {
|
|
|
|
|
+ content: '¥';
|
|
|
|
|
+ font-size: 40upx;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- .pay-type-list {
|
|
|
|
|
- margin-top: 20upx;
|
|
|
|
|
- background-color: #fff;
|
|
|
|
|
- padding-left: 60upx;
|
|
|
|
|
-
|
|
|
|
|
- .type-item {
|
|
|
|
|
- height: 120upx;
|
|
|
|
|
- padding: 20upx 0;
|
|
|
|
|
- display: flex;
|
|
|
|
|
- justify-content: space-between;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- padding-right: 60upx;
|
|
|
|
|
- font-size: 30upx;
|
|
|
|
|
- position: relative;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .icon {
|
|
|
|
|
- width: 100upx;
|
|
|
|
|
- font-size: 52upx;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+.pay-type-list {
|
|
|
|
|
+ margin-top: 20upx;
|
|
|
|
|
+ background-color: #fff;
|
|
|
|
|
+ padding-left: 60upx;
|
|
|
|
|
|
|
|
- .iconyue {
|
|
|
|
|
- color: #fe8e2e;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ .type-item {
|
|
|
|
|
+ height: 120upx;
|
|
|
|
|
+ padding: 20upx 0;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ padding-right: 60upx;
|
|
|
|
|
+ font-size: 30upx;
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- .iconweixin {
|
|
|
|
|
- color: #36cb59;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ .icon {
|
|
|
|
|
+ width: 100upx;
|
|
|
|
|
+ font-size: 52upx;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- .iconzhifubao {
|
|
|
|
|
- color: #01aaef;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ .iconyue {
|
|
|
|
|
+ color: #fe8e2e;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- .tit {
|
|
|
|
|
- font-size: $font-lg;
|
|
|
|
|
- color: $font-color-dark;
|
|
|
|
|
- margin-bottom: 4upx;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ .iconweixin {
|
|
|
|
|
+ color: #36cb59;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- .con {
|
|
|
|
|
- flex: 1;
|
|
|
|
|
- display: flex;
|
|
|
|
|
- flex-direction: column;
|
|
|
|
|
- font-size: $font-sm;
|
|
|
|
|
- color: $font-color-light;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ .iconzhifubao {
|
|
|
|
|
+ color: #01aaef;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- .mix-btn {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- justify-content: center;
|
|
|
|
|
- width: 630upx;
|
|
|
|
|
- height: 80upx;
|
|
|
|
|
- margin: 80upx auto 30upx;
|
|
|
|
|
|
|
+ .tit {
|
|
|
font-size: $font-lg;
|
|
font-size: $font-lg;
|
|
|
- color: #fff;
|
|
|
|
|
- background-color: $base-color;
|
|
|
|
|
- border-radius: 10upx;
|
|
|
|
|
- /* box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4); */
|
|
|
|
|
|
|
+ color: $font-color-dark;
|
|
|
|
|
+ margin-bottom: 4upx;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- .clickbg {
|
|
|
|
|
- background-color: $color-gray !important;
|
|
|
|
|
|
|
+ .con {
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ font-size: $font-sm;
|
|
|
|
|
+ color: $font-color-light;
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.mix-btn {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ width: 630upx;
|
|
|
|
|
+ height: 80upx;
|
|
|
|
|
+ margin: 80upx auto 30upx;
|
|
|
|
|
+ font-size: $font-lg;
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ background-color: $base-color;
|
|
|
|
|
+ border-radius: 10upx;
|
|
|
|
|
+ /* box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4); */
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.clickbg {
|
|
|
|
|
+ background-color: $color-gray !important;
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|