41 lines
722 B
JavaScript
41 lines
722 B
JavaScript
|
||||
|
|
import { wechatLogin } from "@/api/auth.js";
|
|||
|
|
// 服务端接口 - 获取手机号
|
|||
|
|
function getPhoneNumberFn(code,phoneCode ) {
|
|||
|
|
return new Promise(resolve => {
|
|||
|
|
wechatLogin({
|
|||
|
|
mobile:'',
|
|||
|
|
smscode:'',
|
|||
|
|
phoneCode:phoneCode,
|
|||
|
|
token:code,
|
|||
|
|
type:1,
|
|||
|
|
isValid: true,
|
|||
|
|
}).then(res => {
|
|||
|
|
resolve(res)
|
|||
|
|
})
|
|||
|
|
.catch(err => {
|
|||
|
|
console.log('获取手机号失败2:', err);
|
|||
|
|
})
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 微信api : 微信登录
|
|||
|
|
function loginFn() {
|
|||
|
|
return new Promise((resolve, reject) => {
|
|||
|
|
uni.login({
|
|||
|
|
success: async (res) => {
|
|||
|
|
// 第一遍code
|
|||
|
|
resolve(res)
|
|||
|
|
},
|
|||
|
|
fail: (err) => {
|
|||
|
|
console.log('login fail:', err);
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export {
|
|||
|
|
loginFn,
|
|||
|
|
getPhoneNumberFn
|
|||
|
|
}
|