@ctsy/wechat
TypeScript icon, indicating that this package has built-in type declarations

1.0.26 • Public • Published

castle-wechat 使用说明

注意事项

  1. 该组件需要配合服务端使用,服务程序暂不开源,如需合作请联系18990191742

使用方式

  1. 安装
yarn add -D @ctsy/wechat
// npm i -D @ctsy/wechat
// cdn 引入:https://npm.taobao.org/@ctsy/wechat/dist/main.min.js
  1. 导入
import Wechat,{
  IsWechatBrower,
  user,
  config,
  jsConfig,
  location
} from "@ctsy/wechat";
  1. 在App.vue中的created中完成配置,或在main.ts中
if (IsWechatBrower) {
    await config({
      WechatID: "gh_339982221ea7",
      UUID: '',//来自本地缓存的用户的UUID信息
      BaiduMapAK:'',//百度Map的AK
    });
    let UserInfo = await user();
    //获得用户信息后请保存到Vuex中或其它地方
    jsConfig();
} else {
}
  1. 结合vue-router拦截器使用
router.beforeEach(async (to, from, next) => {
  //可以在此处提示正在请求认证
  if (IsWechatBrower && !window.Store.state.User.Wechat.openid) {
    let { d } = await user()
    window.Store.commit('M_USER_WECHAT', d)
  }
}
  1. 使用其它需要的接口

Readme

Keywords

none

Package Sidebar

Install

npm i @ctsy/wechat

Weekly Downloads

1

Version

1.0.26

License

ISC

Unpacked Size

12.7 kB

Total Files

7

Last publish

Collaborators

  • ida_xyt
  • yanpengquan