token已存入Storage, 认证厂家详情接口初步完成
This commit is contained in:
@@ -75,14 +75,48 @@
|
||||
this.getCategories()
|
||||
this.getBanner()
|
||||
this.getImgUrl()
|
||||
this.getToken()
|
||||
this.imgUrl = uni.getStorageSync('img_url')
|
||||
},
|
||||
|
||||
methods: {
|
||||
getToken() {
|
||||
var that = this
|
||||
uni.login({
|
||||
"provider": "weixin",
|
||||
"onlyAuthorize": true, // 微信登录仅请求授权认证
|
||||
success: function(event) {
|
||||
const {
|
||||
code
|
||||
} = event
|
||||
console.log("登录code", code);
|
||||
let fromData = {
|
||||
code: code
|
||||
}
|
||||
that.$apiServe.login({
|
||||
code: code
|
||||
}).then(res => {
|
||||
console.log('登录code换取的用户', res.data.data);
|
||||
uni.setStorageSync('token', res.data.data.token);
|
||||
})
|
||||
},
|
||||
fail: function(err) {
|
||||
// 登录授权失败
|
||||
// err.code是错误码
|
||||
}
|
||||
})
|
||||
},
|
||||
//获取手机code
|
||||
getphonenumber(e) {
|
||||
let that = this
|
||||
// const {
|
||||
// code
|
||||
// } = e.detail;
|
||||
// console.log("手机code : ", code);
|
||||
},
|
||||
//获取子组件的getProducts方法返回数据的length,用于当length为0时取消发送请求
|
||||
getChild(e) {
|
||||
this.reachBottomLength = e
|
||||
|
||||
},
|
||||
//获取一级分类
|
||||
getCategories() {
|
||||
@@ -106,43 +140,6 @@
|
||||
url: '../../packageSearch/search/search'
|
||||
})
|
||||
},
|
||||
getphonenumber(e) {
|
||||
let that = this
|
||||
console.log(e);
|
||||
//必须要公司注册,且微信认证过的小程序,才能获取到手机号的接口权限
|
||||
if (e.detail.errMsg == "getPhoneNumber:fail ") {
|
||||
console.log('用户拒绝提供手机号');
|
||||
} else {
|
||||
console.log('用户同意提供手机号');
|
||||
}
|
||||
const {
|
||||
phoneCode
|
||||
} = e.detail;
|
||||
console.log("手机code : ", phoneCode);
|
||||
uni.login({
|
||||
"provider": "weixin",
|
||||
"onlyAuthorize": true, // 微信登录仅请求授权认证
|
||||
success: function(event) {
|
||||
const {
|
||||
code
|
||||
} = event
|
||||
|
||||
console.log("登录code", code);
|
||||
//客户端成功获取授权临时票据(code),向业务服务器发起登录请求。
|
||||
// 调用登录接口 拿到token 传手机code,更新手机号码
|
||||
let fromData = {
|
||||
code: code
|
||||
}
|
||||
that.$apiServe.login(fromData).then(res => {
|
||||
console.log(res);
|
||||
})
|
||||
},
|
||||
fail: function(err) {
|
||||
// 登录授权失败
|
||||
// err.code是错误码
|
||||
}
|
||||
})
|
||||
},
|
||||
//点击一级分类跳转到分类页
|
||||
toClassify() {
|
||||
uni.navigateTo({
|
||||
|
||||
Reference in New Issue
Block a user