加入验证码功能

This commit is contained in:
wuxw 2020-02-11 00:04:33 +08:00
parent 83003c4324
commit 70393faeb6
5 changed files with 185 additions and 68 deletions

View File

@ -13,6 +13,7 @@ class MappingConstant{
static CURRENT_COMMUNITY_INFO = "currentCommunityInfo"; // 小区信息
static OWNER_INFO = "ownerInfo"; // 当前业主信息
static CURRENT_COMMUNITY_INFO = "currentCommunityInfo"; //业主当前小区信息
static HC_ENV = "_HC_ENV"
}

View File

@ -11,6 +11,8 @@ const baseUrl = 'https://app.demo.winqi.cn/';
//const baseUrl = 'http://hc.demo.winqi.cn:8012/';
const hcBaseUrl = 'https://hc.demo.winqi.cn';
//获取环境
const getEnv = baseUrl + 'app/env/getEnv';
// 登录接口
const loginUrl = baseUrl + 'app/loginWx';
const areaUrl = baseUrl + "app/area.listAreas";
@ -100,8 +102,12 @@ const queryConfigFee = baseUrl + "/app/fee.queryFeeConfig";
//缴费历史查询
const queryFeeDetail = baseUrl +"/app/fee.queryFeeDetail";
//发送验证码
const userSendSms = baseUrl +"/app/user.userSendSms";
module.exports = {
getEnv:getEnv,
baseUrl: baseUrl,
hcBaseUrl: hcBaseUrl,
loginUrl: loginUrl,
@ -137,5 +143,6 @@ module.exports = {
queryConfigFee: queryConfigFee,
queryFeeByCarInout: queryFeeByCarInout,
preOrderTempCarInout: preOrderTempCarInout,
queryFeeDetail: queryFeeDetail
queryFeeDetail: queryFeeDetail,
userSendSms: userSendSms
};

View File

@ -9,23 +9,25 @@ Page({
* 页面的初始数据
*/
data: {
areaCode:'',
areaName:'',
communityName:'',
appUserName:'',
idCard:'',
link:'',
msgCode:'',
areaShow:false,
areaList:{
areaCode: '',
areaName: '',
communityName: '',
appUserName: '',
idCard: '',
link: '',
second: 60,
msgCode: '',
areaShow: false,
btnValue: '获取验证码',
areaList: {
province_list: {
},
city_list: {
},
county_list: {
}
}
},
@ -33,14 +35,14 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
let _that = this;
let _location = context.getLocation();
let _currentLocation = context.getCurrentLocation();
let _areaName = _currentLocation.city + _currentLocation.district;
let _areaCode = _currentLocation.adcode;
//加载省份
context._loadArea('','',function(_areaList){
context._loadArea('', '', function(_areaList) {
_that.setData({
areaList: _areaList,
communityName: _location,
@ -54,15 +56,15 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
if(this.data.areaCode == ''|| this.data.areaCode == undefined){
onShow: function() {
if (this.data.areaCode == '' || this.data.areaCode == undefined) {
let _currentLocation = context.getCurrentLocation();
let _areaName = _currentLocation.city + _currentLocation.district;
let _areaCode = _currentLocation.adcode;
@ -71,60 +73,106 @@ Page({
areaName: _areaName
});
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
},
bindInput:function(e){
console.log('数据监听',e);
let _that = this;
let dataset = e.currentTarget.dataset;
let value = e.detail;
let name = dataset.name;
_that.data[name] = value;
bindInput: function(e) {
console.log('数据监听', e);
let _that = this;
let dataset = e.currentTarget.dataset;
let value = e.detail;
let name = dataset.name;
_that.data[name] = value;
// _that.setData({
// name: value
// });
console.log(this.data);
console.log(this.data);
},
sendMsgCode:function(){
sendMsgCode: function() {
console.log('获取验证码');
var _that = this;
let obj = {
tel: this.data.link
};
if (obj.tel == '') {
wx.showToast({
title: '请输入手机号',
icon: 'none',
duration: 2000
});
return;
}
context.request({
url: constant.url.userSendSms,
header: context.getHeaders(),
method: "POST",
data: obj, //动态数据
success: function(res) {
console.log(res);
//成功情况下跳转
if (res.statusCode == 200) {
wx.hideLoading();
_that.timer();
return;
}
wx.hideLoading();
wx.showToast({
title: res.data,
icon: 'none',
duration: 2000
});
},
fail: function(e) {
wx.hideLoading();
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
}
});
},
bindOwner: function (e) {
bindOwner: function(e) {
let obj = {
"areaCode": this.data.areaCode,
@ -141,9 +189,9 @@ Page({
msg = "请填写小区名称";
} else if (obj.appUserName == "") {
msg = "请填写业主名称";
} else if (obj.idCard == "") {
msg = "请填写身份证";
} else if (obj.link == ""){
// } else if (obj.idCard == "") {
// msg = "请填写身份证";
} else if (obj.link == "") {
msg = "请填写手机号";
} else if (obj.msgCode == "") {
msg = "请填写验证码";
@ -163,16 +211,16 @@ Page({
url: constant.url.appUserBindingOwner,
header: context.getHeaders(),
method: "POST",
data:obj, //动态数据
success: function (res) {
data: obj, //动态数据
success: function(res) {
console.log(res);
//成功情况下跳转
if (res.statusCode == 200) {
wx.hideLoading();
wx.redirectTo({
url: "/pages/viewBindOwner/viewBindOwner"
});
return;
wx.hideLoading();
wx.redirectTo({
url: "/pages/viewBindOwner/viewBindOwner"
});
return;
}
wx.hideLoading();
wx.showToast({
@ -181,7 +229,7 @@ Page({
duration: 2000
});
},
fail:function(e){
fail: function(e) {
wx.hideLoading();
wx.showToast({
title: "服务器异常了",
@ -193,8 +241,8 @@ Page({
}
},
onConfirm:function(e){
console.log("onConfirm",e);
onConfirm: function(e) {
console.log("onConfirm", e);
let _areaCode = e.detail.values[2].code;
let _areaName = e.detail.values[1].name + e.detail.values[2].name;
this.setData({
@ -203,37 +251,58 @@ Page({
areaShow: false
});
},
onChange:function(e){
console.log(e);
onChange: function(e) {
console.log(e);
},
chooseArea:function(e){
chooseArea: function(e) {
this.setData({
areaShow:true
areaShow: true
});
},
onCancel:function(e){
onCancel: function(e) {
this.setData({
areaShow: false
});
},
/**
* 选择小区
*/
chooseCommunity:function(e){
if (this.data.areaCode == '' || this.data.areaCode == undefined){
/**
* 选择小区
*/
chooseCommunity: function(e) {
if (this.data.areaCode == '' || this.data.areaCode == undefined) {
wx.showToast({
title: '请先选择地区',
icon:'none'
icon: 'none'
});
return;
}
wx.navigateTo({
url: '/pages/viewCommunitys/viewCommunitys?areaCode='+this.data.areaCode,
})
wx.navigateTo({
url: '/pages/viewCommunitys/viewCommunitys?areaCode=' + this.data.areaCode,
})
},
timer: function() {
let promise = new Promise((resolve, reject) => {
let setTimer = setInterval(
() => {
var second = this.data.second - 1;
this.setData({
second: second,
btnValue: second + '秒',
btnDisabled: true
})
if (this.data.second <= 0) {
this.setData({
second: 60,
btnValue: '获取验证码',
btnDisabled: false
})
resolve(setTimer)
}
}, 1000)
})
promise.then((setTimer) => {
clearInterval(setTimer)
})
}
})

View File

@ -12,7 +12,7 @@
<van-field value="{{ idCard }}" bindinput="bindInput" data-name="idCard" type="idcard" label="身份证" placeholder="请输入身份证" required />
<van-field value="{{ link }}" bindinput="bindInput" data-name="link" type="number" label="手机号" placeholder="请输入手机号" required />
<van-field value="{{ msgCode }}" bindinput="bindInput" data-name="msgCode" center clearable label="验证码" placeholder="请输入短信验证码" required use-button-slot>
<van-button slot="button" type="number" size="small" type="primary" catchtap="sendMsgCode">发送验证码</van-button>
<van-button slot="button" type="number" size="small" type="primary" catchtap="sendMsgCode" disabled='{{btnDisabled}}'>{{btnValue}}</van-button>
</van-field>
</van-cell-group>

View File

@ -129,6 +129,7 @@ Page({
onLoad: function(options) {
let _that = this;
console.log(context);
this._loadHCEnv();
context.getOwner(function (_owner) {
let _communityId = '';
if (_owner == null) {
@ -169,11 +170,16 @@ Page({
},
_judgeBindOwner:function(){
let env = wx.getStorageSync(constant.mapping.HC_ENV);
let _msg = '您还没有绑定业主,请先绑定业主';
if (env == 'DEV' || env == 'TEST'){
_msg = '您还没有绑定业主,请先绑定业主或取消查看演示环境';
}
context.getOwner(function(_owner){
if(_owner == null){
Dialog.confirm({
title: '温馨提示',
message: '您还没有绑定业主,请先绑定业主或取消查看演示环境'
message: _msg
}).then(() => {
// on confirm
wx.navigateTo({
@ -181,6 +187,9 @@ Page({
})
}).catch(() => {
// on cancel
if (env != 'DEV' && env != 'TEST'){ //生产环境 不做处理
return ;
}
//这里写死 演示数据
let _ownerInfo = { "appUserId": "982020011296320035", "appUserName": "吴学文", "communityId": "7020181217000001", "communityName": "万博家博园(城西区)", "idCard": "632126199109162011", "link": "18999999999", "memberId": "772019092507000013", "state": "12000", "stateName": "审核成功" };
@ -324,6 +333,37 @@ Page({
}
});
},
_loadHCEnv: function () {
let _that = this;
let _objData = {
};
context.request({
url: constant.url.getEnv,
header: context.getHeaders(),
method: "GET",
data: _objData, //动态数据
success: function (res) {
console.log("请求返回信息:", res);
if (res.statusCode == 200) {
wx.setStorageSync(constant.mapping.HC_ENV, res.data);
return;
}
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
},
fail: function (e) {
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
}
});
},
_moreActivities:function(){
wx.navigateTo({
url: '/pages/activites/activites',