【微信H5开发】the permission value is offline verifying

一、配置了完整的config后为什么还是显示the permission value is offline verifying呢,安卓没问题而iphone手机会出现问题?

iphone手机获取路径是你进入该网站第一个页面开始算(包括刷新页面)
所以,我们需要对url进行缓存处理,而安卓不用

在这里插入图片描述

二、处理问题(Vue)

①准备
/* utils/index.js */
// 判断ios
export function isIOS() {
  return navigator.userAgent.indexOf('iPhone') > -1
}
// 获取缓存的url
export function getIOSFirstUrl() {
  return store.getters.iOSFirstUrl
}
// 设置缓存的url
export function setIOSFirstUrl(url) {
  store.dispatch('setIOSFirstUrl', url)
}
/* store/modules/app.js */
// 在store做缓存
const state = {
  iOSFirstUrl: null,
}
const mutations = {
  SET_IOS_FIRST_URL(state, url) {
    state.iOSFirstUrl = url
  }
}
const actions = {
  setIOSFirstUrl({ commit }, url) {
    commit('SET_IOS_FIRST_URL', url)
  }
}
export default {
  state,
  mutations,
  actions
}

②实际使用
/* src\router\index.js */
// ...router自带的东西
const { wx } = window
router.afterEach(async (to, from) => {
  console.log('router afterEach', { from, to })
  const url = isIOS() ? getIOSFirstUrl() : window.location.href
  // 调用API获取的config
  getJssdkConfig({
    url
  }).then(wxConfig => {
    wx.config(wxConfig)
    wx.ready(() => {
    	wx.updateTimelineShareData(/*对应配置*/)
    	wx.updateTimelineShareData(/*对应配置*/)
    })
  })
})
router.beforeEach(async (to, from, next) => {
	// ... 业务逻辑
	// 没有就设置到缓存
	if (!getIOSFirstUrl()) {
	  setIOSFirstUrl(window.location.href.split('#')[0])
	}
	// ... 业务逻辑
})
// ...router自带的东西
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值