117 lines
2.9 KiB
JavaScript
117 lines
2.9 KiB
JavaScript
//index.js
|
|
//获取应用实例
|
|
const app = getApp()
|
|
var utils = require('../../utils/util.js')
|
|
Page({
|
|
data: {
|
|
motto: '欢迎登陆',
|
|
userInfo: {},
|
|
hasUserInfo: false,
|
|
canIUse: wx.canIUse('button.open-type.getUserInfo'),
|
|
wd:"",
|
|
jd:"",
|
|
buttonClicked:false
|
|
|
|
},
|
|
onReady: function () {
|
|
var that = this
|
|
wx.getLocation({
|
|
type: 'wgs84',
|
|
success: function (res) {
|
|
console.log(res)
|
|
var latitude = res.latitude
|
|
var longitude = res.longitude
|
|
that.setData({
|
|
wd: latitude,
|
|
jd: longitude
|
|
})
|
|
}
|
|
})
|
|
},
|
|
formSubmit: function (e) {//定义函数名称
|
|
console.log(e)
|
|
var that = this;
|
|
var name = e.detail.value.username;
|
|
var pwd = e.detail.value.password;
|
|
var dataList = {};
|
|
if (name == "") {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '请输入用户名!',
|
|
success: function (res) {
|
|
|
|
}
|
|
})
|
|
} else {
|
|
if (pwd == "") {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '请输入密码!',
|
|
success: function (res) {
|
|
|
|
}
|
|
})
|
|
} else {
|
|
that.setData({
|
|
buttonClicked: true
|
|
})
|
|
setTimeout(function () {
|
|
that.setData({
|
|
buttonClicked: false
|
|
})
|
|
},5000)
|
|
var dataList = { "name": name, "pwd": pwd, "x": that.data.wd, "y": that.data.jd, "appName": "appName" };
|
|
dataList = JSON.stringify(dataList);
|
|
console.log(dataList)
|
|
wx.request({
|
|
url: 'https://oa.dcqcdc.com/dccdc/wxapp/login',//请求地址
|
|
//url: 'https://oa.dcqcdc.com/InfectionWX/GetAllHangIntheAirQuestion'
|
|
data: {
|
|
username: name,
|
|
pwd: pwd,
|
|
x: that.data.wd,
|
|
y: that.data.jd,
|
|
appName: "appName"
|
|
},
|
|
header: {//请求头
|
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
},
|
|
|
|
method: "POST",//get为默认方法/POST
|
|
success: function (res) {
|
|
console.log(res.data)
|
|
if (res.data.State == 1){
|
|
wx.navigateTo({
|
|
url: '../inquiry/inquiry?name=' + name,
|
|
success: function (res) {
|
|
|
|
},
|
|
fail: function (res) {
|
|
|
|
},
|
|
complete: function (res) {
|
|
|
|
},
|
|
})
|
|
}else{
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '用户名密码错误!',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
console.log('用户点击确定')
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
},
|
|
fail: function (err) { console.log(err) },//请求失败
|
|
complete: function () { }//请求完成后执行的函数
|
|
})
|
|
}
|
|
}
|
|
|
|
}
|
|
})
|