|
@@ -9,14 +9,16 @@
|
|
|
|
|
|
<view class="login-contont">
|
|
<view class="login-contont">
|
|
<view class="uInput">
|
|
<view class="uInput">
|
|
- <u-input placeholder="请输入金额" border="bottom" type="number" v-model="price" :customStyle="inpustyle">
|
|
|
|
|
|
+
|
|
|
|
+ <u-input placeholder="请输入金额" border="bottom" :fontSize="40" type="digit"
|
|
|
|
+ @change="validateInput($event,1)" v-model="price" :customStyle="inpustyle">
|
|
<span slot="prefix" style="font-size: 30px">¥</span>
|
|
<span slot="prefix" style="font-size: 30px">¥</span>
|
|
</u-input>
|
|
</u-input>
|
|
</view>
|
|
</view>
|
|
<view class="login-contont-button">
|
|
<view class="login-contont-button">
|
|
<button class="btn" @click="Pay">立即支付</button>
|
|
<button class="btn" @click="Pay">立即支付</button>
|
|
<view style="margin-top: 20rpx; font-size: 26rpx">
|
|
<view style="margin-top: 20rpx; font-size: 26rpx">
|
|
- 支付成功后,次日有奖励红包,农商网小程序领取
|
|
|
|
|
|
+ 支付成功后,次日有奖励红包,农商直采小程序领取
|
|
<!-- 支付成功立返
|
|
<!-- 支付成功立返
|
|
<span
|
|
<span
|
|
style="color: red">
|
|
style="color: red">
|
|
@@ -88,8 +90,21 @@
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
this.shopId = options.shopId
|
|
this.shopId = options.shopId
|
|
this.getInfo();
|
|
this.getInfo();
|
|
|
|
+ this.getShopInfo();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ validateInput(e, num) {
|
|
|
|
+ const inputTypeNum = /[^\d]/g //数字
|
|
|
|
+ switch (num) {
|
|
|
|
+ case 1:
|
|
|
|
+ //要写nextTick 不然无效
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.listData.integral = e.replace(inputTypeNum, '');
|
|
|
|
+ })
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
async getShopInfo() {
|
|
async getShopInfo() {
|
|
let res = await axios.get(
|
|
let res = await axios.get(
|
|
`${requestConfig.BaseUrl}user/app/v1/store/getStoreInfoByScan?shopId=${this.shopId}`, {
|
|
`${requestConfig.BaseUrl}user/app/v1/store/getStoreInfoByScan?shopId=${this.shopId}`, {
|
|
@@ -99,7 +114,8 @@
|
|
});
|
|
});
|
|
if (res.data.code == 200) {
|
|
if (res.data.code == 200) {
|
|
this.shopInfo = res.data.data
|
|
this.shopInfo = res.data.data
|
|
-
|
|
|
|
|
|
+ } else {
|
|
|
|
+ uni.$u.toast(res.data.msg);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -114,7 +130,10 @@
|
|
);
|
|
);
|
|
if (res.data.code == 200) {
|
|
if (res.data.code == 200) {
|
|
uni.$u.toast('绑定手机号成功');
|
|
uni.$u.toast('绑定手机号成功');
|
|
|
|
+ this.userInfo = res.data.data
|
|
this.showPhone = false
|
|
this.showPhone = false
|
|
|
|
+ this.getShopInfo()
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
},
|
|
},
|
|
@@ -139,44 +158,71 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async Pay() {
|
|
async Pay() {
|
|
|
|
+ uni.showLoading({
|
|
|
|
+ title: '支付中'
|
|
|
|
+ });
|
|
|
|
+ // uni.hideLoading();
|
|
|
|
+ // window.open(`${requestConfig.redirectOpen}pages/index/paySuccess`)
|
|
|
|
+
|
|
|
|
+ if (!this.price) {
|
|
|
|
+ uni.$u.toast('请输入支付金额!');
|
|
|
|
+ }
|
|
let res = await axios.get(`${requestConfig.BaseUrl}order/app/v1/buyer/order/createOfflineOrder
|
|
let res = await axios.get(`${requestConfig.BaseUrl}order/app/v1/buyer/order/createOfflineOrder
|
|
- ?shopId=110351${this.shopId}&price=${this.price}`, {
|
|
|
|
|
|
+ ?shopId=${this.shopId}&price=${this.price}`, {
|
|
headers: {
|
|
headers: {
|
|
'token': `${this.userInfo.token}`
|
|
'token': `${this.userInfo.token}`
|
|
}
|
|
}
|
|
});
|
|
});
|
|
if (res.data.code == 200) {
|
|
if (res.data.code == 200) {
|
|
- uni.$u.toast('线下订单创建成功!订单id=', res.data.data);
|
|
|
|
|
|
+ //post请求
|
|
|
|
+ let data = {
|
|
|
|
+ "orderId": res.data.data, //订单id
|
|
|
|
+ "orderType": 11, //订单类型 -1--其他 2-司机保证金 3-商品交易 4-线下交易
|
|
|
|
+ "payKinds": 0, //支付类型 0-微信 1-支付宝
|
|
|
|
+ "payMeth": 6 //5-微信小程序支付 6-微信H5支付 7-支付宝app支付
|
|
|
|
+ }
|
|
|
|
+ const pay = await axios.post(`${requestConfig.BaseUrl}order/app/v1/buyer/order/offlineOrderPay
|
|
|
|
+ `, data, {
|
|
|
|
+ headers: {
|
|
|
|
+ 'Token': `${this.userInfo.token}`
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (pay.data.code == 200) {
|
|
|
|
+ let res = JSON.parse(pay.data.data.result)
|
|
|
|
+ console.log(res);
|
|
|
|
+ WeixinJSBridge.invoke(
|
|
|
|
+ "getBrandWCPayRequest", {
|
|
|
|
+ // 公众号名称,由商户传入
|
|
|
|
+ appId: res.appId,
|
|
|
|
+ // 时间戳,自1970年以来的秒数
|
|
|
|
+ timeStamp: res.timeStamp,
|
|
|
|
+ // 随机串
|
|
|
|
+ nonceStr: res.nonceStr,
|
|
|
|
+ package: res.package,
|
|
|
|
+ // 微信签名方式:
|
|
|
|
+ signType: res.signType,
|
|
|
|
+ // 微信签名
|
|
|
|
+ paySign: res.paySign,
|
|
|
|
+ },
|
|
|
|
+ function(res) {
|
|
|
|
+ if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
|
|
+ // 使用以上方式判断前端返回,
|
|
|
|
+ // 微信团队郑重提示:
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ window.location.href = requestConfig.redirectOpen
|
|
|
|
+ // res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
|
+ } else {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ uni.$u.toast('支付失败!');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
|
|
|
|
+ } else {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ uni.$u.toast('支付失败!');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- //post请求
|
|
|
|
- // const res = await axios.get(`${requestConfig.BaseUrl}order/app/v1/buyer/order/createOfflineOrder
|
|
|
|
- // ?shopId=110330&price=${this.price}`, {}, {
|
|
|
|
- // headers: {
|
|
|
|
- // 'Token': `${this.userInfo.token}`
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
- // WeixinJSBridge.invoke(
|
|
|
|
- // "getBrandWCPayRequest", {
|
|
|
|
- // // 公众号名称,由商户传入
|
|
|
|
- // appId: requestConfig.appID,
|
|
|
|
- // // 时间戳,自1970年以来的秒数
|
|
|
|
- // timeStamp: '',
|
|
|
|
- // // 随机串
|
|
|
|
- // nonceStr: '',
|
|
|
|
- // package: "",
|
|
|
|
- // // 微信签名方式:
|
|
|
|
- // signType: "MD5",
|
|
|
|
- // // 微信签名
|
|
|
|
- // paySign: '',
|
|
|
|
- // },
|
|
|
|
- // function(res) {
|
|
|
|
- // if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
|
|
- // // 使用以上方式判断前端返回,微信团队郑重提示:
|
|
|
|
- // // res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // );
|
|
|
|
},
|
|
},
|
|
async getInfo() {
|
|
async getInfo() {
|
|
let code = this.GetQueryString("code");
|
|
let code = this.GetQueryString("code");
|
|
@@ -189,8 +235,9 @@
|
|
this.showPhone = true
|
|
this.showPhone = true
|
|
} else {
|
|
} else {
|
|
this.showPhone = false
|
|
this.showPhone = false
|
|
|
|
+ this.getShopInfo()
|
|
}
|
|
}
|
|
- this.getShopInfo()
|
|
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
uni.$u.toast('获取微信登录信息失败!');
|
|
uni.$u.toast('获取微信登录信息失败!');
|
|
}
|
|
}
|