@@ -1,7 +1,7 @@ | |||||
<!-- | <!-- | ||||
* @Date: 2022-08-17 16:19:13 | * @Date: 2022-08-17 16:19:13 | ||||
* @LastEditors: JinxChen | * @LastEditors: JinxChen | ||||
* @LastEditTime: 2023-04-06 14:23:25 | |||||
* @LastEditTime: 2023-04-08 15:03:04 | |||||
* @FilePath: \TelpoH5FrontendWeb\README.md | * @FilePath: \TelpoH5FrontendWeb\README.md | ||||
* @description: 项目说明 | * @description: 项目说明 | ||||
--> | --> | ||||
@@ -341,3 +341,16 @@ update | |||||
- 注释 获取微信jssdk接口 | - 注释 获取微信jssdk接口 | ||||
- packageHome | - packageHome | ||||
- 修改 appId获取的方式,本地配置文件固定配置,不再从url路由获取 | - 修改 appId获取的方式,本地配置文件固定配置,不再从url路由获取 | ||||
## v1.0.40 | |||||
`2023.4.8` | |||||
update | |||||
- packageList | |||||
- 增加 微信授权code调用方式,在缓存的基础上在路由增加一个code | |||||
- packageHome | |||||
- 增加 微信授权code调用方式,缓存没有则从路由获取 | |||||
- appId | |||||
- 修改 测试环境appId |
@@ -1,7 +1,7 @@ | |||||
<!-- | <!-- | ||||
* @Date: 2022-01-19 10:08:26 | * @Date: 2022-01-19 10:08:26 | ||||
* @LastEditors: JinxChen | * @LastEditors: JinxChen | ||||
* @LastEditTime: 2023-04-06 10:30:46 | |||||
* @LastEditTime: 2023-04-08 16:46:23 | |||||
* @FilePath: \TelpoH5FrontendWeb\src\App.vue | * @FilePath: \TelpoH5FrontendWeb\src\App.vue | ||||
* @description: | * @description: | ||||
--> | --> | ||||
@@ -37,7 +37,7 @@ export default { | |||||
}); | }); | ||||
}, | }, | ||||
debug() { | debug() { | ||||
if (process.env.NODE_ENV !== 'production') { | |||||
if (process.env.NODE_ENV !== 'development') { | |||||
const script = document.createElement('script'); | const script = document.createElement('script'); | ||||
script.src = "//cdn.jsdelivr.net/npm/eruda"; | script.src = "//cdn.jsdelivr.net/npm/eruda"; | ||||
document.body.appendChild(script); | document.body.appendChild(script); | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* @Date: 2022-03-19 19:57:20 | * @Date: 2022-03-19 19:57:20 | ||||
* @LastEditors: JinxChen | * @LastEditors: JinxChen | ||||
* @LastEditTime: 2023-04-06 09:17:15 | |||||
* @LastEditTime: 2023-04-08 16:46:06 | |||||
* @FilePath: \TelpoH5FrontendWeb\src\config\appId.js | * @FilePath: \TelpoH5FrontendWeb\src\config\appId.js | ||||
* @description: | * @description: | ||||
*/ | */ | ||||
@@ -9,5 +9,5 @@ const AppId = process.env.NODE_ENV === 'production' ? | |||||
'wxd78b83bdb0b4df55' : | 'wxd78b83bdb0b4df55' : | ||||
process.env.VUE_APP_BASE_API.indexOf('ai.ssjlai.com') > -1 ? | process.env.VUE_APP_BASE_API.indexOf('ai.ssjlai.com') > -1 ? | ||||
'wxd78b83bdb0b4df55': | 'wxd78b83bdb0b4df55': | ||||
/* 'wx785c95a3e7f46f72' */'wxd78b83bdb0b4df55'; //wx5e26f0813859e5f6 2022.10.12 更改测试公众号 | |||||
'wx5e26f0813859e5f6'/* 'wxd78b83bdb0b4df55' */; //wx5e26f0813859e5f6 2022.10.12 更改测试公众号 | |||||
export default AppId; | export default AppId; |
@@ -1,11 +1,11 @@ | |||||
/* | /* | ||||
* @Date: 2021-11-20 10:26:39 | * @Date: 2021-11-20 10:26:39 | ||||
* @LastEditors: JinxChen | * @LastEditors: JinxChen | ||||
* @LastEditTime: 2023-04-06 09:13:27 | |||||
* @LastEditTime: 2023-04-08 14:56:13 | |||||
* @FilePath: \TelpoH5FrontendWeb\src\config\models.js | * @FilePath: \TelpoH5FrontendWeb\src\config\models.js | ||||
* @description: | * @description: | ||||
*/ | */ | ||||
export const VERSION_MODEL = '1.0.39F'; //版本号 | |||||
export const VERSION_MODEL = '1.0.40F'; //版本号 | |||||
export const IMAGE_URL = { | export const IMAGE_URL = { | ||||
production: 'http://zfb.ssjlai.com/web/', | production: 'http://zfb.ssjlai.com/web/', | ||||
test: 'http://zfb.ssjlai.com/web/', | test: 'http://zfb.ssjlai.com/web/', | ||||
@@ -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-06 10:11:00 | |||||
* @LastEditTime: 2023-04-08 16:35:10 | |||||
* @FilePath: \TelpoH5FrontendWeb\src\views\package-home\index.vue | * @FilePath: \TelpoH5FrontendWeb\src\views\package-home\index.vue | ||||
* @description: | * @description: | ||||
--> | --> | ||||
@@ -63,9 +63,8 @@ export default { | |||||
) { | ) { | ||||
let timeStamp = new Date().getTime(); | let timeStamp = new Date().getTime(); | ||||
let code = url.split("&")[0]; | let code = url.split("&")[0]; | ||||
console.log("code", code); | |||||
if (isNotNull(code)) { | if (isNotNull(code)) { | ||||
this.$store.commit("wxAuthCode", code); | |||||
/* this.getOpenId(); */ | |||||
this.getWxCode(); | this.getWxCode(); | ||||
} | } | ||||
} else { | } else { | ||||
@@ -96,8 +95,8 @@ export default { | |||||
}) | }) | ||||
}, | }, | ||||
// 根据code获取openId | // 根据code获取openId | ||||
getOpenId() { | |||||
let code = this.$store.getters.wxAuthCode; | |||||
getOpenId(code) { | |||||
//let code = this.$store.getters.wxAuthCode; | |||||
APIPay.getOpenId(code).then(res => { | APIPay.getOpenId(code).then(res => { | ||||
let data= res.data; | let data= res.data; | ||||
if(data.code === 20000) { | if(data.code === 20000) { | ||||
@@ -120,7 +119,7 @@ export default { | |||||
} | } | ||||
}) | }) | ||||
} else { | } else { | ||||
let redUrl = encodeURIComponent(`${commonUrl}/h5-frontendweb/#/${params.routerName}?imei=${params.imei}&appId=${AppId}&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; | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
<!-- | <!-- | ||||
* @Date: 2022-03-29 16:57:58 | * @Date: 2022-03-29 16:57:58 | ||||
* @LastEditors: JinxChen | * @LastEditors: JinxChen | ||||
* @LastEditTime: 2023-04-06 14:21:05 | |||||
* @LastEditTime: 2023-04-08 14:57:19 | |||||
* @FilePath: \TelpoH5FrontendWeb\src\views\package-list\index.vue | * @FilePath: \TelpoH5FrontendWeb\src\views\package-list\index.vue | ||||
* @description: TODO 小台风充值h5 | * @description: TODO 小台风充值h5 | ||||
--> | --> | ||||
@@ -107,6 +107,7 @@ import { APIPay } from "@/api/pay"; | |||||
import APICore from "@/api/core"; | import APICore from "@/api/core"; | ||||
let wx = require("weixin-js-sdk"); // TODO 再封装,可拦截错误提示等操作 | let wx = require("weixin-js-sdk"); // TODO 再封装,可拦截错误提示等操作 | ||||
import { isNotNull } from "@/utils/index"; | import { isNotNull } from "@/utils/index"; | ||||
import { VERSION_MODEL } from '@/config/models'; | |||||
export default { | export default { | ||||
name: "packageList", | name: "packageList", | ||||
data() { | data() { | ||||
@@ -139,30 +140,28 @@ export default { | |||||
payProductId: null, //套餐id | payProductId: null, //套餐id | ||||
packageIssue: null, //套餐分期 | packageIssue: null, //套餐分期 | ||||
payType: '1', //支付方式 1 微信, 2 支付宝,支付宝又分为花呗和全额支付,全额支付分期数传0 或者1 ,花呗则传 3 6 12 | payType: '1', //支付方式 1 微信, 2 支付宝,支付宝又分为花呗和全额支付,全额支付分期数传0 或者1 ,花呗则传 3 6 12 | ||||
openId: '' | |||||
}; | }; | ||||
}, | }, | ||||
created() { | created() { | ||||
this.getAuth(); | this.getAuth(); | ||||
this.getParams(); | this.getParams(); | ||||
this.getCode(); | |||||
//this.getWxAutograph(); | //this.getWxAutograph(); | ||||
// 套餐列表 | // 套餐列表 | ||||
this.getDevicePayPackage(); | this.getDevicePayPackage(); | ||||
console.log("当前版本", VERSION_MODEL); | |||||
}, | }, | ||||
methods: { | methods: { | ||||
// 根据code获取openId | // 根据code获取openId | ||||
getOpenId() { | |||||
let code = this.$store.getters.wxAuthCode; | |||||
let openId = this.$store.getters.openId; | |||||
if(isNotNull(openId)) { | |||||
console.log("已经存在openId"); | |||||
} else { | |||||
APIPay.getOpenId(code).then(res => { | |||||
let data= res.data; | |||||
if(data.code === 20000) { | |||||
this.$store.commit("openId", data.data.openId); | |||||
} | |||||
}) | |||||
} | |||||
getOpenId(code) { | |||||
APIPay.getOpenId(code).then(res => { | |||||
let data= res.data; | |||||
if(data.code === 20000) { | |||||
this.openId = data.data.openId; | |||||
this.$store.commit("openId", data.data.openId); | |||||
} | |||||
}) | |||||
}, | }, | ||||
// 获取b端接口的token | // 获取b端接口的token | ||||
getAuth() { | getAuth() { | ||||
@@ -171,19 +170,21 @@ export default { | |||||
this.$store.commit("gatewayToken", res.data.data); | this.$store.commit("gatewayToken", res.data.data); | ||||
}); | }); | ||||
}, | }, | ||||
getCode() { | |||||
let url = window.location.href.split("?code=")[1]; | |||||
console.log("url", url); | |||||
if (isNotNull(url) ||window.location.href.indexOf("code") > -1) { | |||||
let code = url.split("&")[0]; | |||||
if (isNotNull(code)) { | |||||
this.getOpenId(code); | |||||
} | |||||
} | |||||
}, | |||||
// 获取url传过来的参数 | // 获取url传过来的参数 | ||||
getParams() { | getParams() { | ||||
let params = this.$route.query; | let params = this.$route.query; | ||||
console.log("params", params); | |||||
if (params) { | if (params) { | ||||
let url = window.location.href.split("?code=")[1]; | |||||
if ( isNotNull(url) || window.location.href.indexOf("code") > -1) { | |||||
let timeStamp = new Date().getTime(); | |||||
let code = url.split("&")[0]; | |||||
if (isNotNull(code)) { | |||||
this.$store.commit("wxAuthCode", `${code}`); | |||||
this.getOpenId(); | |||||
} | |||||
} | |||||
this.params = {...params}; | this.params = {...params}; | ||||
} | } | ||||
}, | }, | ||||
@@ -295,7 +296,7 @@ export default { | |||||
this.aliPay(data); | this.aliPay(data); | ||||
} else { | } else { | ||||
// 微信 | // 微信 | ||||
let openId = this.$store.getters.openId; | |||||
let openId = this.openId; | |||||
this.payProductId = payTypeToPackAgeId.filter(item => { | this.payProductId = payTypeToPackAgeId.filter(item => { | ||||
return item.payType === '1' || item.payType === 1 | return item.payType === '1' || item.payType === 1 | ||||
})[0].productId; | })[0].productId; | ||||
@@ -319,7 +320,7 @@ export default { | |||||
console.log("微信支付", data); | console.log("微信支付", data); | ||||
let orderData = data; | let orderData = data; | ||||
let reqBody = { | let reqBody = { | ||||
openId: this.$store.getters.openId, //openId | |||||
openId: this.openId, //openId | |||||
imei: this.params.imei, //imei | imei: this.params.imei, //imei | ||||
iccid: this.params.iccid, | iccid: this.params.iccid, | ||||
productId: this.payProductId, //套餐id | productId: this.payProductId, //套餐id | ||||
@@ -472,7 +473,7 @@ export default { | |||||
}); | }); | ||||
let orderData = data; | let orderData = data; | ||||
let reqBody = { | let reqBody = { | ||||
openId: this.$store.getters.openId, //openId | |||||
openId: this.openId, //openId | |||||
imei: this.params.imei, //imei | imei: this.params.imei, //imei | ||||
iccid: this.params.iccid, | iccid: this.params.iccid, | ||||
productId: this.payProductId, //套餐id | productId: this.payProductId, //套餐id | ||||