ktianc 7fbdcb3b0f 版本升级
1. 新增:微信小程序端新增微信手机号登录功能(必须为企业认证小程序)
2. 新增:加入动态更新常见问题
3. 新增:新增小程序分享功能
4. 新增:小程序新增第一次登录需要修改密码
5. 新增:新增接口权限控制
6. 新增:用户新增is_staff用来判断是否为工作人员
7. 新增:软删除新增is_delete字段来判断,delete_datetime当前主要来记录时间
8. 更新:部分接口删除功能已更新,需要试用软删除的才会试用软删除
9. 更新:更新系统配置缓存功能
10. 更新:接口认证依赖项更新
11. 更新:获取系统基础配置信息与用户协议与隐私协议更新
12. 优化:优化接口与数据库操作
2023-02-27 17:28:27 +08:00

65 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 微信存储https://developers.weixin.qq.com/miniprogram/dev/framework/ability/storage.html
// 微信登录
// 微信小程序登录流程https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html
// 登录失败的原因可能是因为没将后台IP添加到白名单
import { mapGetters } from 'vuex'
import { setUserOpenid } from '@/common/request/api/login.js'
import { toast } from '@/common/utils/common'
export const wxLoginMixins = {
computed: {
...mapGetters([
'isUserOpenid',
])
},
data () {
return {
}
},
methods: {
onGetPhoneNumber(e) {
return new Promise((resolve, reject) => {
// 获取手机号官方文档https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html
if (e.detail.errMsg === "getPhoneNumber:fail user deny") {
// 用户拒绝授权
toast("已取消授权")
reject("已取消授权")
} else if (e.detail.errMsg === "getPhoneNumber:fail no permission") {
// 微信公众平台未认证或未使用企业认证
toast("微信公众平台未认证或未使用企业认证")
reject("微信公众平台未认证或未使用企业认证")
} else if (e.detail.errMsg === "getPhoneNumber:ok") {
// code换取用户手机号 每个code只能使用一次code的有效期为5min
this.$store.dispatch('auth/wxLogin', e.detail.code).then(res => {
this.setOpenid();
this.$store.dispatch('auth/GetInfo').then(result => {
resolve(result)
})
})
} else {
toast("授权失败")
reject("授权失败")
}
})
},
setOpenid() {
let self = this;
// uniapp 官方文档https://uniapp.dcloud.io/api/plugins/login.html#login
if (self.isUserOpenid) { return; };
uni.login({
provider: 'weixin',
success: function (loginRes) {
if (loginRes.code) {
setUserOpenid(loginRes.code).then(res => {
// console.log("更新openid成功", res)
self.$store.commit("auth/SET_IS_USER_OPENID", true);
})
} else {
console.log('登录失败获取code失败' + res.errMsg)
}
}
});
}
}
}