平台兼容性

Vue2 Vue3
×
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
× × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × × × × × × ×

mpvue-process

登录验证
1. mpvue页面登录判断

配置apiBaseUrl,登录页,需要登录才能查看的页面:
config = {
  baseUrl: 'https://www.xxxxxxx.com/',
  loginPage: '/pages/login/main',
  pageAuth: [
    '/pages/xxxx/main',
    '/pages/yyyy/main'
  ]
}
在main.js中添加
import MpvueProcess from 'mpvue-process'
Vue.use(MpvueProcess, config)
2. 使用
页面级登录判断:
this.navigateTo()替换mpvue.navigateTo()方法,如果页面需要登录则会先跳转到登录页

按钮级登录判断:
if(!this.isAuthed){
    没登录情况
} else{
    登录请求
}

3.登录后保存token
this.setStore('token',xxxxxx)
请求封装
需要转loading的
const res = await this.request('api1', 'GET', {}, true)
不需要转loading的
const res = await this.request('api2', 'GET', {})
this.request('api3', 'GET', {}).then(resp=>{console.log(resp)})
自定义header
const res = await this.request('api2', 'GET', {}, false, headers)
本请求会自动封装如下header
{'Content-Type': 'application/json', 'Authorization': 'Token ' + getStore('token')}
缓存
this.setStore('key',value,1*24*60*60) // 缓存一天,默认2天
this.getStore('key')

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问