修改登录接口,修改页面

This commit is contained in:
liuwu 2023-09-06 16:30:45 +08:00
parent 6485e88aeb
commit 04a24a8a3c
4 changed files with 102 additions and 21 deletions

View File

@ -8,7 +8,8 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
username:'',
password:''
}, },
/** /**
@ -41,25 +42,76 @@ Page({
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady() { onReady() {
//登录 var username = wx.getStorageSync('loginName')
var password = wx.getStorageSync('password')
console.log(username)
console.log(password)
if (username && password){
this.autoLogin(username,password)
}
},
autoLogin(username,password){
this.setData({
username:username,
password:password
})
const _this = this; const _this = this;
wx.login({ $api.getUserInfo({
success: res => { "loginName": _this.data.username,
$api.getUserInfo({ "password": _this.data.password,
"loginName": "erds", }).then(obj => {
"password": "123456", if (obj.code === 0){
}).then(obj => { wx.reLaunch({
if (obj.code === 0){ url: '/pages/evaluation/evaluation'
wx.reLaunch({ });
url: '/pages/evaluation/evaluation' wx.setStorageSync("loginName", _this.data.username);
}); wx.setStorageSync("password", _this.data.password);
} }else {
}).catch(err => { Dialog.alert({
Dialog.alert({ message:'用户名或密码错误'
message:'服务器错误404请联系管理员'
})
}) })
}, }
}).catch(err => {
Dialog.alert({
message:'服务器错误404请联系管理员'
})
})
},
login(){
const _this = this;
if (!_this.data.username){
Dialog.alert({
message:'请输入用户名'
})
return false
}
if (!_this.data.password){
Dialog.alert({
message:'请输入密码'
})
return false
}
$api.getUserInfo({
"loginName": _this.data.username,
"password": _this.data.password,
}).then(obj => {
if (obj.code === 0){
wx.reLaunch({
url: '/pages/evaluation/evaluation'
});
wx.setStorageSync("loginName", _this.data.username);
wx.setStorageSync("password", _this.data.password);
}else {
Dialog.alert({
message:'用户名或密码错误'
})
}
}).catch(err => {
Dialog.alert({
message:'服务器错误404请联系管理员'
})
}) })
}, },
/** /**

View File

@ -1,5 +1,33 @@
<!--pages/loading/loading.wxml--> <!--pages/loading/loading.wxml-->
<view class="container"> <view class="container">
<van-loading type="spinner" /> <!-- <van-loading type="spinner" />-->
<view style="width:100%">
<van-cell-group>
<van-field
model:value="{{ username }}"
required
size="large"
clearable
label="用户名"
placeholder="请输入用户名"
input-align="right"
/>
<van-field
model:value="{{ password }}"
type="password"
size="large"
label="密码"
clearable
placeholder="请输入密码"
input-align="right"
required
/>
</van-cell-group>
<view style="margin-top:20px;">
<van-button type="primary" block round bind:tap="login">登录</van-button>
</view>
</view>
</view> </view>
<van-dialog id="van-dialog" /> <van-dialog id="van-dialog" />

View File

@ -27,7 +27,7 @@
<view class="list_row" data-cattleNum="{{item.name}}" wx:for="{{list}}" wx:key="id" wx:for-item="item"> <view class="list_row" data-cattleNum="{{item.name}}" wx:for="{{list}}" wx:key="id" wx:for-item="item">
<view class="list_row_right"> <view class="list_row_right">
<view>部门:{{item.deptName?item.deptName:'暂无'}}</view> <view>部门:{{item.deptName?item.deptName:'暂无'}}</view>
<view>考核类型:{{item.type?item.type:'暂无'}}</view> <view style="color:green">考核类型:{{item.type?item.type:'暂无'}}</view>
<view>考核指标:{{item.target?item.target:'暂无'}}</view> <view>考核指标:{{item.target?item.target:'暂无'}}</view>
<view>指标明细:{{item.detailed?item.detailed:'暂无'}}</view> <view>指标明细:{{item.detailed?item.detailed:'暂无'}}</view>
<view>标准分:{{item.score?item.score:'暂无'}}</view> <view>标准分:{{item.score?item.score:'暂无'}}</view>

View File

@ -1,5 +1,6 @@
// const base_url = "https://breed.nxcyx.com/wx/"; //配置的域名 // const base_url = "https://breed.nxcyx.com/wx/"; //配置的域名
const base_url = "http://192.168.0.107:8088"; //配置的域名 // const base_url = "http://192.168.0.107:8088"; //配置的域名
const base_url = "http://39.106.198.243:8088"; //配置的域名
// const base_url = "http://q43k76.natappfree.cc/wx/" // const base_url = "http://q43k76.natappfree.cc/wx/"
/** /**