|
@@ -1,7 +1,7 @@ |
|
|
<!-- |
|
|
<!-- |
|
|
* @Date: 2023-02-24 14:18:25 |
|
|
* @Date: 2023-02-24 14:18:25 |
|
|
* @LastEditors: JinxChen |
|
|
* @LastEditors: JinxChen |
|
|
* @LastEditTime: 2023-04-17 16:34:52 |
|
|
|
|
|
|
|
|
* @LastEditTime: 2023-09-20 14:20:27 |
|
|
* @FilePath: \TelpoH5FrontendWeb\src\views\package-home\index.vue |
|
|
* @FilePath: \TelpoH5FrontendWeb\src\views\package-home\index.vue |
|
|
* @description: |
|
|
* @description: |
|
|
--> |
|
|
--> |
|
@@ -23,22 +23,53 @@ export default { |
|
|
return { |
|
|
return { |
|
|
params: {}, //获取路由的参数 |
|
|
params: {}, //获取路由的参数 |
|
|
isRecharge: null, //是否已经支付 |
|
|
isRecharge: null, //是否已经支付 |
|
|
|
|
|
isHasBasePackage: null, //是否存在基础套餐 |
|
|
|
|
|
whiteTitleList: ['小台风', '零川'], //白名单物联网卡列表 |
|
|
|
|
|
currentIotTitle: '', //当前设备所属物联网名字 |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
/* this.getToken(); */ |
|
|
|
|
|
this.getAuth(); |
|
|
this.getAuth(); |
|
|
|
|
|
}, |
|
|
|
|
|
mounted() { |
|
|
this.getParams(); |
|
|
this.getParams(); |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
// 2023.09.20 修改需求 进入首页同时查套餐和充值状态 |
|
|
|
|
|
// 1.无基础套餐卡不是零川或者小台风,跳转错误页面 |
|
|
|
|
|
// 2.无基础套餐卡但是零川或者小台风,跳转话费查询页面 |
|
|
|
|
|
// 3.如果有基础套餐并且已充值,跳转费查询页面 |
|
|
|
|
|
// 4.如果有基础套餐但未充值,跳转套餐充值页面 |
|
|
|
|
|
getDevicePayPackage() { |
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
APICore.devicePayPackage(this.params.imei) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
let data = res.data; |
|
|
|
|
|
if (data.code === 106 || data.code === 104) { |
|
|
|
|
|
this.getAuth(); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
this.getDevicePayPackage(); |
|
|
|
|
|
}, 1500); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 筛选是否存在基础套餐, producModelId = 1 是基础套餐, 2 是加油包 |
|
|
|
|
|
const isHasBasePackage = data.data.packagesList.some(res => { |
|
|
|
|
|
return res.producModelId === 1; |
|
|
|
|
|
}); |
|
|
|
|
|
resolve(isHasBasePackage); |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(e => { |
|
|
|
|
|
reject(false); |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
checkImei() { |
|
|
checkImei() { |
|
|
let reqBody = { |
|
|
let reqBody = { |
|
|
imei: this.params.imei, |
|
|
imei: this.params.imei, |
|
|
iccid: this.params.iccid || '' |
|
|
iccid: this.params.iccid || '' |
|
|
}; |
|
|
}; |
|
|
APIWx.CheckImei(reqBody).then(res =>{ |
|
|
APIWx.CheckImei(reqBody).then(res =>{ |
|
|
console.log("res", res.data.isRecharge); |
|
|
|
|
|
this.isRecharge = res.data.isRecharge; |
|
|
this.isRecharge = res.data.isRecharge; |
|
|
|
|
|
this.currentIotTitle = res.data.title; |
|
|
this.getWxCode(); |
|
|
this.getWxCode(); |
|
|
}).catch(e => { |
|
|
}).catch(e => { |
|
|
console.log("e", e.message); |
|
|
console.log("e", e.message); |
|
@@ -107,16 +138,39 @@ export default { |
|
|
getWxCode() { |
|
|
getWxCode() { |
|
|
let params = this.params; |
|
|
let params = this.params; |
|
|
let commonUrl = process.env.VUE_APP_BASE_API; |
|
|
let commonUrl = process.env.VUE_APP_BASE_API; |
|
|
// todo 暂时去掉 |
|
|
|
|
|
if(this.isRecharge) { |
|
|
|
|
|
// 如果是已经支付,但未激活,跳转激活界面 |
|
|
|
|
|
/* this.$router.replace({ |
|
|
|
|
|
name: 'cardActive', |
|
|
|
|
|
query: { |
|
|
|
|
|
imei: params.imei, |
|
|
|
|
|
iccid: params.iccid |
|
|
|
|
|
} |
|
|
|
|
|
}) */ |
|
|
|
|
|
|
|
|
let isWhiteTitle = this.whiteTitleList.includes(this.currentIotTitle) > 0; |
|
|
|
|
|
let cardInfoBaseUrl = encodeURIComponent(`${commonUrl}/h5-frontendweb/#/cardInfo?imei=${params.imei}&iccid=${params.iccid}`); |
|
|
|
|
|
let toupBaseUrl = encodeURIComponent(`${commonUrl}/h5-frontendweb/#/${params.routerName}?imei=${params.imei}&iccid=${params.iccid}`); |
|
|
|
|
|
if(this.isHasBasePackage) { |
|
|
|
|
|
// 有套餐 |
|
|
|
|
|
if(this.isRecharge) { |
|
|
|
|
|
// 已支付,跳转话费查询页面 |
|
|
|
|
|
console.log("有套餐跳转话费查询页面"); |
|
|
|
|
|
let wxRedUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${AppId}&redirect_uri=${cardInfoBaseUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`; |
|
|
|
|
|
window.location.href = wxRedUrl; |
|
|
|
|
|
} else if (!this.isRecharge) { |
|
|
|
|
|
// 未支付, 跳转套餐充值页面 |
|
|
|
|
|
console.log("跳转套餐充值页面"); |
|
|
|
|
|
let wxRedUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${AppId}&redirect_uri=${toupBaseUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`; |
|
|
|
|
|
window.location.href = wxRedUrl; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 无套餐 |
|
|
|
|
|
if(isWhiteTitle) { |
|
|
|
|
|
// 是零川或者小台风,跳转话费查询页面 |
|
|
|
|
|
let wxRedUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${AppId}&redirect_uri=${cardInfoBaseUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`; |
|
|
|
|
|
window.location.href = wxRedUrl; |
|
|
|
|
|
console.log("无套餐跳转话费查询页面"); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 跳转错误页面; |
|
|
|
|
|
this.$router.replace({ |
|
|
|
|
|
name: 'iotcardError' |
|
|
|
|
|
}) |
|
|
|
|
|
console.log("跳转错误页面"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 2023.09.20 废弃 |
|
|
|
|
|
/* if(this.isRecharge) { |
|
|
let redUrl = encodeURIComponent(`${commonUrl}/h5-frontendweb/#/cardInfo?imei=${params.imei}&iccid=${params.iccid}`); |
|
|
let redUrl = encodeURIComponent(`${commonUrl}/h5-frontendweb/#/cardInfo?imei=${params.imei}&iccid=${params.iccid}`); |
|
|
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${AppId}&redirect_uri=${redUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`; |
|
|
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${AppId}&redirect_uri=${redUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`; |
|
|
window.location.href = url; |
|
|
window.location.href = url; |
|
@@ -124,23 +178,22 @@ export default { |
|
|
let redUrl = encodeURIComponent(`${commonUrl}/h5-frontendweb/#/${params.routerName}?imei=${params.imei}&iccid=${params.iccid}`); |
|
|
let redUrl = encodeURIComponent(`${commonUrl}/h5-frontendweb/#/${params.routerName}?imei=${params.imei}&iccid=${params.iccid}`); |
|
|
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${AppId}&redirect_uri=${redUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`; |
|
|
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${AppId}&redirect_uri=${redUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`; |
|
|
window.location.href = url; |
|
|
window.location.href = url; |
|
|
} |
|
|
|
|
|
|
|
|
} */ |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
// 获取url传过来的参数 |
|
|
// 获取url传过来的参数 |
|
|
getParams() { |
|
|
|
|
|
|
|
|
async getParams() { |
|
|
let params = this.$route.query; |
|
|
let params = this.$route.query; |
|
|
if (params) { |
|
|
if (params) { |
|
|
console.log("params", params); |
|
|
|
|
|
this.params = {...params}; |
|
|
this.params = {...params}; |
|
|
this.$store.commit("appId", AppId); |
|
|
this.$store.commit("appId", AppId); |
|
|
if(params.reqUrl) { |
|
|
if(params.reqUrl) { |
|
|
const reqUrl = encodeURI(params.reqUrl); |
|
|
const reqUrl = encodeURI(params.reqUrl); |
|
|
window.location.href = reqUrl; |
|
|
window.location.href = reqUrl; |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
this.isHasBasePackage = await this.getDevicePayPackage(); |
|
|
this.checkImei(); |
|
|
this.checkImei(); |
|
|
} |
|
|
} |
|
|
console.log("this.params", this.params); |
|
|
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|