微信登录版

This commit is contained in:
qianlile
2021-08-28 11:30:34 +08:00
parent 7af68fee6b
commit 33aecb6bda
432 changed files with 13362 additions and 0 deletions

22
wechat_v2/utils/login.js Normal file
View 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
View 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
}