Files
Wx_BLWConfigTools_V01_Prod/pages/login/login.js
2025-12-11 09:50:45 +08:00

116 lines
2.6 KiB
JavaScript

// pages/login.js
// app.js
const app = getApp()
import {
settoken,
Login
} from '../../lib/RequestingCenter.js'
Page({
/**
* 页面的初始数据
*/
data: {
login:false,
islong:false,
Uid:null,
Pwd:null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
getwxlogin:function(){
app.toast(2,"暂未开放!");
},
//验证
submitForm(e) {
let that = this;
let type = e.currentTarget.dataset['type']
if(type=="1"){
that.setData({
islong:true
})
}
if(this.data.Uid == null || this.data.Uid=="" || this.data.Pwd == ""|| this.data.Pwd == null){
app.toast(2,"数据不完整")
}else {
Login({Pwd:that.data.Pwd,islong:that.data.islong,Uid:that.data.Uid}).then(res=>{
if(res.Status==200){
settoken(res.Data.token)
console.log("------------------------------------------")
// console.log(res)
if(that.data.islong){
wx.setStorageSync('xiaoxi_token', res.Data.token)
}
res.Data.userinfo.HeadImg = app.globalData.ImgUrl.replace("ImgUrl",res.Data.userinfo.HeadImg)
app.globalData.userinfo = res.Data.userinfo,
// console.log(res.Data.userinfo)
app.globalData.autho = res.Data.autho
// console.log(res.Data.autho)
// console.log("------------------------------------------")
app.toast(1,"登录成功",wx.reLaunch({
url: "/pages/index/index",
}))
}else{
app.toast(2,res.Message||"网络繁忙")
}
},err=>{
app.toast(2,"网络繁忙")
}
).catch(
err => {
console.log(err)
app.toast("异常",'error')
}
);
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
//登录
getlogin:function(){
this.setData({
login:true
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})