1 changed files with 46 additions and 0 deletions
@ -0,0 +1,46 @@ |
|||||
|
import { HTTP, Method } from '../utils/http.js' |
||||
|
|
||||
|
const token_url = 'oas-admin/screen/user/ageAndSex' |
||||
|
|
||||
|
class AuthModel extends HTTP { |
||||
|
constructor() { |
||||
|
super() |
||||
|
} |
||||
|
// 获取 Token
|
||||
|
fetchAuthToken(success) { |
||||
|
// 获取token
|
||||
|
this._fetchWXCode().then(res => { |
||||
|
if (!res) return |
||||
|
let params = { |
||||
|
url: token_url, |
||||
|
method: Method.GET, |
||||
|
data: { |
||||
|
code: res |
||||
|
}, |
||||
|
success: success, |
||||
|
} |
||||
|
this.request(params) |
||||
|
}) |
||||
|
} |
||||
|
// 获取微信code
|
||||
|
_fetchWXCode() { |
||||
|
return new Promise(resolve => { |
||||
|
wx.login({ |
||||
|
success(res) { |
||||
|
console.log('获取Code成功 ' + res.code) |
||||
|
if (res.code) { |
||||
|
resolve(res.code) |
||||
|
} else { |
||||
|
wx.showToast({ |
||||
|
icon: "none", |
||||
|
title: '登录失败', |
||||
|
}) |
||||
|
console.log('登录失败!' + res.errMsg) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export { AuthModel } |
Loading…
Reference in new issue