|
@@ -9,11 +9,12 @@ const timestamp = +moment.utc();
|
|
|
|
|
|
// 带Origin后缀的通过getter获取
|
|
|
export const state = () => ({
|
|
|
- openIdOrigin: "oJR5R6gWNpGre5hfPXkFvcdBhIrE",
|
|
|
+ openIdOrigin: "",
|
|
|
accessTokenOrigin: "",
|
|
|
unionIdOrigin: "",
|
|
|
userInfo: {},
|
|
|
- stationId: settings.stationId,
|
|
|
+ stationIdOrigin: "",
|
|
|
+ appIdOrigin: "",
|
|
|
noncestr,
|
|
|
timestamp,
|
|
|
signature:"",
|
|
@@ -32,6 +33,18 @@ export const getters = {
|
|
|
}
|
|
|
return state.accessToken
|
|
|
},
|
|
|
+ stationId: (state) => {
|
|
|
+ if (!state.stationIdOrigin) {
|
|
|
+ getAuthen()
|
|
|
+ }
|
|
|
+ return state.stationIdOrigin
|
|
|
+ },
|
|
|
+ appId: (state) => {
|
|
|
+ if (!state.appIdOrigin) {
|
|
|
+ getAuthen()
|
|
|
+ }
|
|
|
+ return state.appIdOrigin
|
|
|
+ },
|
|
|
unionId: (state) => {
|
|
|
if (!state.unionIdOrigin) {
|
|
|
getAuthen()
|
|
@@ -39,8 +52,6 @@ export const getters = {
|
|
|
return state.unionIdOrigin
|
|
|
},
|
|
|
userInfo: (state) => state.userInfo,
|
|
|
- stationId: (state) => state.stationId,
|
|
|
-
|
|
|
}
|
|
|
|
|
|
export const mutations = {
|
|
@@ -57,7 +68,13 @@ export const mutations = {
|
|
|
state.userInfo = userInfo
|
|
|
},
|
|
|
setSignature(state, signature) {
|
|
|
- state.state = signature
|
|
|
+ state.signature = signature
|
|
|
+ },
|
|
|
+ setStationId(state,stationId){
|
|
|
+ state.stationIdOrigin = stationId
|
|
|
+ },
|
|
|
+ setAppId(state, appId) {
|
|
|
+ state.appIdOrigin = appId
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -102,7 +119,7 @@ export const actions = {
|
|
|
noncestr:state.noncestr,
|
|
|
timestamp:state.timestamp,
|
|
|
url:window.location.href.replace(/#(\w|\W){0,}/g, ''),
|
|
|
- stationId:state.stationId
|
|
|
+ stationId:getters.stationId
|
|
|
}
|
|
|
})
|
|
|
if(sdkSignRes.retCode !== 0){Promise.reject("获取Sdk签名错误")}
|
|
@@ -111,11 +128,25 @@ export const actions = {
|
|
|
|
|
|
return Promise.resolve({
|
|
|
debug: settings.debug, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
|
- appId: settings.appId, // 必填,公众号的唯一标识
|
|
|
+ appId: getters.appId, // 必填,公众号的唯一标识
|
|
|
timestamp: state.timestamp, // 必填,生成签名的时间戳
|
|
|
nonceStr: state.noncestr, // 必填,生成签名的随机串
|
|
|
signature:sdkSignRes.data,
|
|
|
jsApiList // 必填,需要使用的JS接口列表
|
|
|
})
|
|
|
+ },
|
|
|
+ async getAppId({commit,state, getters},stationId){
|
|
|
+ const appIdRes = await this.$axios.$get("/getStationGzhAppId",{
|
|
|
+ params:{
|
|
|
+ stationId:stationId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if(appIdRes.retCode !== 0){return Promise.reject("获取appid失败")}
|
|
|
+ commit("setStationId",stationId)
|
|
|
+ commit("setAppId", appIdRes.data.appId)
|
|
|
+ return Promise.resolve({
|
|
|
+ stationId,
|
|
|
+ appId:appIdRes.data.appId
|
|
|
+ })
|
|
|
}
|
|
|
}
|