// pages/register/register.js
Page({
/**
* 页面的初始数据
*/
data: {
Adress_State:true,
Register_State:true, // 是否使能签到按钮
number:'',
name:'',
password:'',
repassword:'',
loginSmb:'', // 接收返回数据
adress:''
},
Checkbox:function (params) {
this.setData({
Adress_State:!this.data.Adress_State
})
},
// click_but: function (params) {
// console.log("s")
// wx.chooseLocation({
// success: (res) => {
// console.log(res)
// this.setData({
// adress:res.address
// })
// console.log(this.data.adress)
// }
// })
// },
// 获取地址
get_adress: function (params) {
// var self = this
var that = this
// 获取当前的经纬度坐标
wx.getLocation({
success(res) {
// 纬度
const latitude = res.latitude
// 经度
const longitude = res.longitude
// 请求腾讯地图逆地址解析接口
wx.request({
// url: `https://www.liuserver.top/ws/geocoder/v1/?location=${latitude},${longitude}&key=UIKBZ-JDLO4-QC3UJ-DHLDY-IZLM5-MTFLY`,
url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=Y2FBZ-DISOK-BPHJG-AFPO7-W2T66-35F5Y&get_poi=1`,
success(res) {
console.log(res)
console.log(res.data.result.address)
that.setData({
adress:res.data.result.address
})
console.log(that.data.adress)
}
})
}
})
},
rgnb_input: function (e) {
var value = e.detail.value;
console.log(value)
if(value != ''){
this.setData({
number:value
})
}
if(this.data.name != '' && this.data.password != '' && this.data.repassword != ''){
this.setData({
Register_State: false
})
}
},
rgname_input: function (e){
var value = e.detail.value;
console.log(value)
if(value != ''){
this.setData({
name:value
})
}
if(this.data.number != '' && this.data.password != '' && this.data.repassword != ''){
this.setData({
Register_State: false
})
}
},
rgpwd_input: function (e){
var value = e.detail.value;
console.log(value)
if(value != ''){
this.setData({
password:value
})
}
if(this.data.name != '' && this.data.number != '' && this.data.repassword != ''){
this.setData({
Register_State: false
})
}
},
repwd_input: function (e){
var value = e.detail.value;
console.log(value)
if(value != ''){
this.setData({
repassword:value
})
}
if(this.data.name != '' && this.data.number != '' && this.data.password != ''){
this.setData({
Register_State: false
})
}
},
Register: function(){
wx.request({
// url: 'http://222.178.203.72:19005/whst/63/_016z.z.z0//api/register',
url: 'http://222.178.203.72:19005/whst/63/_vvvzkhtrdqudqzsno98888//api/register',
// url: 'http://222.178.203.72:19005/whst/63/_khtrdqudqzsno98..1//api/login',
method: 'POST',
data: {
number: this.data.number,
name: this.data.name,
password: this.data.password,
repassword:this.data.repassword,
location:this.data.adress
// username: "ls",
// password: "123456"
},
header: {
'content-type': 'application/json' // 默认值
},
success: (result) => {
console.log(result)
console.log(result.data)
this.setData({
loginSmb:result.data.message
})
console.log(this.data.loginSmb)
// wx.navigateTo({ // 跳转到不是tabbar的页面
// // url: 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds///download/register/register',
// url: 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds///download/index/index',
// })
// 如果返回true,那么登录成功跳转页面,否则清楚密码、和用户名
// if(false){
// console.log("shiyan")
// }
if(this.data.loginSmb == "注册成功"){
wx.showToast({
title: '注册成功',
icon: 'success',
duration: 2000
})
this.setData({
Inputvalue_pwd: '', // 对应于清空输入框内的内容
Inputvalue_nb:'',
Inputvalue_name:'',
Inputvalue_repwd:"",
number:"",
name:'',
password:"",
repassword:"",
Register_State:true
})
wx.navigateTo({ // 跳转到不是tabbar的页面
url: 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds///download/home/home',
})
}
else if(this.data.loginSmb == "学号或密码不合法"){
console.log("学号或密码不合法!")
this.setData({
Inputvalue_nb: '', // 对应于清空输入框内的内容
// loginBtnState:true,
number:"",
password:"",
Inputvalue_pwd:"",
Register_State:true
})
wx.showToast({
title: '不合法!',
icon: 'fail',
duration: 2000
})
}
else if(this.data.loginSmb == "两次密码不一致"){
console.log("两次密码不一致!")
this.setData({
Inputvalue_pwd: '', // 对应于清空输入框内的内容
Inputvalue_repwd:"",
password:"",
repassword:"",
Register_State:true
})
wx.showToast({
title: '密码不一致',
icon: 'fail',
duration: 2000
})
}
else{
console.log("都不正确!")
this.setData({
Inputvalue_pwd: '', // 对应于清空输入框内的内容
Inputvalue_nb:'',
Inputvalue_name:'',
Inputvalue_repwd:"",
number:"",
name:'',
password:"",
repassword:"",
Register_State:true
})
wx.showToast({
title: '都不正确!',
icon: 'fail',
duration: 2000
})
}
},
fail: (res) => {
console.log(res)
},
})
console.log("Register")
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})