小程序
小游戏
企业微信
微信支付
扫描小程序码分享
设置验证时,就报错(不是很懂这是什么原因)
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
提供下 这个页面JS的所有代码
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
// 判断全国号段
const regNumber = mobile => {
var move = /^((134)|(135)|(136)|(137)|(138)|(139)|(147)|(150)|(151)|(152)|(157)|(158)|(159)|(178)|(182)|(183)|(184)|(187)|(188)|(198))\d{8}$/g; //移动
var link = /^((130)|(131)|(132)|(155)|(156)|(145)|(185)|(186)|(176)|(175)|(170)|(171)|(166))\d{8}$/g; //联通
var telecom = /^((133)|(153)|(173)|(177)|(180)|(181)|(189)|(199))\d{8}$/g; //电信
if (move.test(mobile)) {
return true;
} else if (link.test(mobile)) {
} else if (telecom.test(mobile)) {
} else {
return false;
}
},
regNumber(mobile) {
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
提供下 这个页面JS的所有代码
Page({
/**
* 页面的初始数据
*/
data: {
login_VerifyCode: '获取验证码',
telNumber: '', // 用户手机号
phone_code: '', // 手机验证码
error_tip: false, // 获取手机号、验证码的错误提示
error_tip_txt: '', // 错误信息提示内容
code_show: false, // 重复点击 获取验证码
regNumber:''
},
// 获取手机验证码
getPhoneCode: function() {
if (this.data.login_VerifyCode == '获取验证码' || this.data.login_VerifyCode == '重新发送'){
let telNumber = this.data.telNumber;
console.log('获取验证码', telNumber.length);
console.log(util.regNumber(telNumber));
if (telNumber == '') {
this.setData({
error_tip: true,
error_tip_txt: '请输入手机号码'
})
} else if (telNumber.length != 11) {
this.setData({
error_tip: true,
error_tip_txt: '请输入正确的手机号码'
})
} else {
//验证是否是北京移动的手机号码
var url = '/v1/broadband/isBJMobiel.do';
var params = {
session: wx.getStorageSync('session'),
phone: telNumber
}
httpUtil.postData(url, params, '', (res) => {
console.log('判断手机号码的', res);
if (res.module == "N") {
this.setData({
error_tip: true,
error_tip_txt: '此手机号非北京移动用户',
code_show: true
})
} else {
var url = '/v1/bdbrokerRenewal/authSendMsg.do';
var params = {
session: wx.getStorageSync('session'),
phone: telNumber
};
httpUtil.postData(url, params, '', (res) => {
console.log(res);
if (res.success) {
wx.showToast({
title: '短信验证码发送成功,请注意查收',
icon: 'success',
duration: 2000
})
var total_micro_second = 60;
// 验证码倒计时
this.count_down(total_micro_second);
} else {
that.setData({
login_tip: "验证码发送失败,请稍候重试"
});
}
});
}
});
}
}
},
// 倒计时 验证码
count_down: function(total_micro_second) { //发送验证码按钮
var that = this;
if (total_micro_second <= 0) {
that.setData({
login_VerifyCode: "重新发送"
});
// timeout则跳出递归
return false;
} else {
// 渲染倒计时时钟
that.setData({
login_VerifyCode: total_micro_second + "s"
});
total_micro_second--;
if (that.data.login_timer == true) {
setTimeout(function() {
that.count_down(total_micro_second);
}, 1000)
} else {
that.setData({
login_VerifyCode: "获取验证码"
});
}
}
},
// 输入框失去焦点 手机号
input_phone: function(e) {
console.log('手机号码', e);
this.setData({
telNumber: e.detail.value,
error_tip_txt: ''
})
this.color_finish();
},
// 输入框输入 验证码
input_code: function(e) {
console.log('验证码值', e);
this.setData({
phone_code: e.detail.value
})
this.color_finish();
},
// 完成 提交按钮颜色变化
color_finish: function() {
if (telNumber_status(this.data.telNumber) && code_status(this.data.phone_code)) {
this.setData({
finish_show: false
})
} else {
this.setData({
finish_show: true
})
}
},
// 判断全国号段
const regNumber = mobile => {
var move = /^((134)|(135)|(136)|(137)|(138)|(139)|(147)|(150)|(151)|(152)|(157)|(158)|(159)|(178)|(182)|(183)|(184)|(187)|(188)|(198))\d{8}$/g; //移动
var link = /^((130)|(131)|(132)|(155)|(156)|(145)|(185)|(186)|(176)|(175)|(170)|(171)|(166))\d{8}$/g; //联通
var telecom = /^((133)|(153)|(173)|(177)|(180)|(181)|(189)|(199))\d{8}$/g; //电信
if (move.test(mobile)) {
return true;
} else if (link.test(mobile)) {
return true;
} else if (telecom.test(mobile)) {
return true;
} else {
return false;
}
},
}
// 判断全国号段
const regNumber = mobile => {
var move = /^((134)|(135)|(136)|(137)|(138)|(139)|(147)|(150)|(151)|(152)|(157)|(158)|(159)|(178)|(182)|(183)|(184)|(187)|(188)|(198))\d{8}$/g; //移动
var link = /^((130)|(131)|(132)|(155)|(156)|(145)|(185)|(186)|(176)|(175)|(170)|(171)|(166))\d{8}$/g; //联通
var telecom = /^((133)|(153)|(173)|(177)|(180)|(181)|(189)|(199))\d{8}$/g; //电信
if (move.test(mobile)) {
return true;
} else if (link.test(mobile)) {
return true;
} else if (telecom.test(mobile)) {
return true;
} else {
return false;
}
},
}
regNumber(mobile) {
var move = /^((134)|(135)|(136)|(137)|(138)|(139)|(147)|(150)|(151)|(152)|(157)|(158)|(159)|(178)|(182)|(183)|(184)|(187)|(188)|(198))\d{8}$/g; //移动
var link = /^((130)|(131)|(132)|(155)|(156)|(145)|(185)|(186)|(176)|(175)|(170)|(171)|(166))\d{8}$/g; //联通
var telecom = /^((133)|(153)|(173)|(177)|(180)|(181)|(189)|(199))\d{8}$/g; //电信
if (move.test(mobile)) {
return true;
} else if (link.test(mobile)) {
return true;
} else if (telecom.test(mobile)) {
return true;
} else {
return false;
}
}
}