aqyj/pages/bind/binduser.js

230 lines
5.0 KiB
JavaScript

// pages/bind/binduser.js
Page({
/**
* 页面的初始数据
*/
data: {
username:'',
password:'',
mpopenid:'',
isExists:false,
msg:''
},
usernameChange: function (e) {
this.data.username = e.detail.value
},
passwordChange: function (e) {
this.data.password = e.detail.value
},
denglu: function(){
var that=this
console.log(that.data)
wx.request({
url: getApp().globalData.serverUrl + 'bindmp',
header: {
'content-type': 'application/json', //
},
method: 'POST',
data:that.data,
success: res => {
if (res.statusCode === 200) {
if (res.data.code == 1) {
wx.showToast({})
getApp().globalData.userInfo = {
userid: 0,
username: '',
name: '',
isaqy: 0,
mpopenid: '',
companyid: '',
perms: [],
openid:null
} //重置globaldata和session
getApp().mplogin()
wx.switchTab({
url: '/pages/main/main',
})
}else{
wx.showModal({
content: '账户或密码不正确!',
showCancel: false,
confirmText: "确定"
})
}
}
}
});
},
denglu2: function(){
var data = this.data
data.username = 'test4'
data.password = 'q4'
wx.request({
url: getApp().globalData.serverUrl + 'bindmp',
header: {
'content-type': 'application/json', //
},
method: 'POST',
data:data,
success: res => {
if (res.statusCode === 200) {
if (res.data.code == 1) {
wx.showToast({})
getApp().globalData.userInfo = {
userid: 0,
username: '',
name: '',
isaqy: 0,
mpopenid: '',
companyid: '',
perms: [],
openid:null
} //重置globaldata和session
getApp().mplogin()
wx.switchTab({
url: '/pages/main/main',
})
}else{
wx.showModal({
content: '账户或密码不正确!',
showCancel: false,
confirmText: "确定"
})
}
}
}
});
},
getUserbasic:function(){
var that = this
wx.request({
url: getApp().globalData.serverUrl + 'api/user?a=get_user_from_username&username='+that.data.username,
header: {
'content-type': 'application/json', //
},
method: 'GET',
success: res => {
if (res.data.code == 1) {
that.setData({
isExists:true
})
that.setData(res.data.data)
} else {
that.setData({
isExists: false,
msg:'未查到该账户信息,是否账户有误'
})
}
}
});
},
onGetInfo:function(e){
this.setData({
userInfo:e.detail.userInfo
})
this.denglu()
},
onGetInfo2:function(e){
this.setData({
userInfo:e.detail.userInfo
})
this.denglu2()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
mpopenid:getApp().globalData.userInfo.mpopenid
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
wx.hideHomeButton()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
showPw(){
wx.showModal({
title: '',
content: '默认密码是0000,如果您修改过或者账号错误,请联系贵公司管理员(一般是安全管理部门),请及时登陆pc端修改密码!',
showCancel:false,
confirmText:'知道了',
success (res) {
}
})
},
intro:function(){
let fileurl = getApp().globalData.serverUrl + 'media/安全生产管理系统-国检集团.docx'
wx.showLoading({
title: '下载中...',
})
console.log(fileurl)
wx.downloadFile({
url: fileurl,
success(res) {
const filePath = res.tempFilePath
console.log(filePath)
var filetype
if (fileurl.indexOf(".docx") != -1) {
filetype = 'docx'
}
wx.openDocument({
filePath,
fileType: filetype,
success(res) {
wx.hideLoading()
console.log('打开文档成功')
}, fail: function (e) {
console.log(e)
}
})
}
})
}
})