|
|
@@ -113,6 +113,8 @@
|
|
|
>
|
|
|
</u-modal>
|
|
|
|
|
|
+ <webAuthAlert ref="webAuthAlert" @confirm="webAuthConfirm"></webAuthAlert>
|
|
|
+
|
|
|
<login ref="login" @signIn="signIn" @phoneSuccess="phoneSuccess"></login>
|
|
|
<toast ref="toast"></toast>
|
|
|
<home-btn></home-btn>
|
|
|
@@ -122,9 +124,11 @@
|
|
|
|
|
|
<script>
|
|
|
import exchangeSuccess from "@/components/alert/exchangeSuccess.vue"
|
|
|
+ import webAuthAlert from "@/components/alert/webAuthAlert.vue"
|
|
|
export default {
|
|
|
components: {
|
|
|
- exchangeSuccess
|
|
|
+ exchangeSuccess,
|
|
|
+ webAuthAlert
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -165,7 +169,6 @@
|
|
|
confirmStyle: {
|
|
|
color: 'white',
|
|
|
},
|
|
|
- interval: '',
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
@@ -179,9 +182,6 @@
|
|
|
this.confirmStyle.color = this.vuex_theme.bgColor;
|
|
|
},
|
|
|
onShow() {
|
|
|
- if(this.vuex_goodsInterval){
|
|
|
- this.queryOrder();
|
|
|
- }
|
|
|
uni.$on('ADDRESS',(res)=>{
|
|
|
this.address=res
|
|
|
})
|
|
|
@@ -274,13 +274,47 @@
|
|
|
* 确认兑换
|
|
|
*/
|
|
|
async confirm() {
|
|
|
+ // #ifdef H5
|
|
|
+ if(this.$isEmpty(this.vuex_gzh_userOpenid)){
|
|
|
+ let code = this.$util.getUrlParam("code");
|
|
|
+ if(this.$isEmpty(code)){
|
|
|
+ this.$refs.webAuthAlert.show = true;
|
|
|
+ }else{
|
|
|
+ this.getWxUserInfo(code)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.exchangeGoods();
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
+
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ this.exchangeGoods();
|
|
|
+ // this.$refs.toast.warn('小程序暂未开放现金兑换,请前往H5兑换')
|
|
|
+ // #endif
|
|
|
+ },
|
|
|
+ //获取微信网页授权用户信息
|
|
|
+ async getWxUserInfo(code) {
|
|
|
+ let params = {
|
|
|
+ code: code
|
|
|
+ }
|
|
|
+ let res = await this.$api.wxApp.getH5WxUserInfo(params)
|
|
|
+ if (res.data.success) {
|
|
|
+ this.$u.vuex('vuex_gzh_userOpenid', res.data.data.openid);
|
|
|
+ this.exchangeGoods();
|
|
|
+ } else {
|
|
|
+ this.$refs.toast.error(res.data.msg)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //商品兑换
|
|
|
+ async exchangeGoods() {
|
|
|
let params = {
|
|
|
type: this.exchangeType,
|
|
|
phone: this.vuex_phone,
|
|
|
goodsId: this.id,
|
|
|
addressId: this.address.id,
|
|
|
num: this.exChangeData.num,
|
|
|
- activeId: this.vuex_active_setting.defaultActiveId
|
|
|
+ activeId: this.vuex_active_setting.defaultActiveId,
|
|
|
+ openId: this.vuex_gzh_userOpenid
|
|
|
}
|
|
|
if(this.exchangeType === 2){params.point = this.exChangeData.point;}
|
|
|
this.$api.pointgoods.exchange(params).then(res=>{
|
|
|
@@ -294,16 +328,26 @@
|
|
|
this.$refs.exchangeSuccess.showSuccess(this.detail.imgUrl)
|
|
|
}else{
|
|
|
//混合兑换,用户选择纯积分兑换
|
|
|
- if(!this.$isNotEmpty(res.data.data.qrCodeUrl)){
|
|
|
+ if(!this.$isNotEmpty(res.data.data)){
|
|
|
this.$refs.exchangeSuccess.showSuccess(this.detail.imgUrl)
|
|
|
return;
|
|
|
}
|
|
|
- // uni.navigateTo({
|
|
|
- // url: `/pages/webview/payOrder?url=${res.data.data.qrCodeUrl}&orderId=${res.data.data.id}`
|
|
|
- // })
|
|
|
- this.$u.vuex('vuex_goodsOrder', res.data.data.id);
|
|
|
- this.$u.vuex('vuex_goodsInterval', true);
|
|
|
- window.location.href = res.data.data.qrCodeUrl
|
|
|
+
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ this.$refs.toast.warn('小程序暂未开放现金兑换,请前往H5兑换')
|
|
|
+ // #endif
|
|
|
+
|
|
|
+ // #ifdef H5
|
|
|
+ console.log("支付订单",res.data.data)
|
|
|
+ this.$shareConfig.H5Pay(res.data.data).then((res) => {
|
|
|
+ console.log("商品兑换页面res", res)
|
|
|
+ this.$refs.exchangeSuccess.showSuccess(this.detail.imgUrl)
|
|
|
+ },(err) => {
|
|
|
+ console.log("商品兑换页面err", err)
|
|
|
+ this.$refs.toast.error(err.errMsg)
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -311,36 +355,9 @@
|
|
|
console.log(error);
|
|
|
})
|
|
|
},
|
|
|
- //查询订单状态
|
|
|
- queryOrder(){
|
|
|
- let params = {
|
|
|
- id: this.vuex_goodsOrder
|
|
|
- }
|
|
|
- this.interval = setInterval(async() => {
|
|
|
- let res = await this.$api.order.orderDetail(params)
|
|
|
- if(res.data.success && res.data.data.payStatus === '付款成功'){
|
|
|
- this.$refs.exchangeSuccess.showSuccess(this.detail.imgUrl);
|
|
|
- this.$u.vuex('vuex_goodsInterval', false);
|
|
|
- this.$u.vuex('vuex_goodsOrder', 0);
|
|
|
- clearInterval(this.interval)
|
|
|
- }
|
|
|
- }, 1500)
|
|
|
- this.countDown(); //30秒拿不到支付回调抛出异常处理
|
|
|
- },
|
|
|
- countDown(){
|
|
|
- let seconds = 30;
|
|
|
- let timer = setInterval(() => {
|
|
|
- seconds--
|
|
|
- if (seconds == 0) {
|
|
|
- if(this.vuex_goodsInterval){
|
|
|
- this.$refs.toast.error('订单回调异常');
|
|
|
- this.$u.vuex('vuex_goodsInterval', false);
|
|
|
- this.$u.vuex('vuex_goodsOrder', 0);
|
|
|
- clearInterval(this.interval) //清除支付回调接口轮询
|
|
|
- }
|
|
|
- clearInterval(timer)
|
|
|
- }
|
|
|
- }, 1000)
|
|
|
+ //网页授权
|
|
|
+ webAuthConfirm(){
|
|
|
+ this.$webAuth.getUserOpenid();
|
|
|
},
|
|
|
cancel(){
|
|
|
this.exchangeShow = false;
|