111
This commit is contained in:
37
scoring/utils/wxutils.js
Normal file
37
scoring/utils/wxutils.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { GET, GET_TOKEN } from '@/utils/request.js'
|
||||
import { loginSystem } from '@/api/login'
|
||||
export function getOpenId() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
var token = await loginSystem();
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
//发起网络请求
|
||||
GET_TOKEN(`/wx/openid/${res.code}`, null, token)
|
||||
.then(response => {
|
||||
response.data.openid
|
||||
resolve({
|
||||
status: 200,
|
||||
openid: response.data.openid,
|
||||
message: '获取openid成功'
|
||||
})
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error)
|
||||
reject({
|
||||
status: 400,
|
||||
openid: null,
|
||||
message: '获取openid失败'
|
||||
})
|
||||
})
|
||||
} else {
|
||||
reject({
|
||||
status: 400,
|
||||
openid: null,
|
||||
message: '获取微信信息失败'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user