mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
微信登录版
This commit is contained in:
22
wechat_v2/utils/login.js
Normal file
22
wechat_v2/utils/login.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const api = require("../API/request")
|
||||
const appLogin =(options)=>{
|
||||
console.log("登录")
|
||||
wx.login({
|
||||
success:(res)=>{
|
||||
console.log("登录",res)
|
||||
if(res.errMsg == "login:ok"){
|
||||
api.userLogin({
|
||||
code : res.code,
|
||||
options:options
|
||||
}).then(res=>{
|
||||
wx.setStorageSync('token', res.token)
|
||||
// wx.setStorageSync('userType', res.data.userType)
|
||||
// wx.setStorageSync('userInfo', res.data.userInfo)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
module.exports={
|
||||
appLogin
|
||||
}
|
||||
19
wechat_v2/utils/util.js
Normal file
19
wechat_v2/utils/util.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const formatTime = date => {
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
const second = date.getSeconds()
|
||||
|
||||
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
|
||||
}
|
||||
|
||||
const formatNumber = n => {
|
||||
n = n.toString()
|
||||
return n[1] ? n : `0${n}`
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime
|
||||
}
|
||||
Reference in New Issue
Block a user