2018-09-11 13:06:48 +08:00

410 lines
13 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// welcome/signin/signin.js
import { DBPost } from '../../db/DBpost.js';
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
multiArray: [['1705', '其他学院暂缓开通'], ['112', '113', '114', '115', '116', '117', '121', '122', '211', '212', '213', '221', '222'], ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38']],
multiIndex: [0, 0, 0],
newnicheng: '',
newmima: '',
disabled: true,
disabled1: true, //是否可用
opacity: 0.4, //不透明度
yanzhengjishu:0,//验证计数
newxuehao:0, //验证学号
changdu:false,//密码长度
xueyuan:0, //1705
banji:0, //213
geren:0, //28
openid:0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
bindMultiPickerChange: function (e) {
this.setData({
disabled1:false
})
console.log('picker发送选择改变携带值为', e.detail.value)
this.setData({
multiIndex: e.detail.value
})
this.setData({
xueyuan: this.data.multiArray[0][this.data.multiIndex[0]] //学院号!!!!!
})
this.setData({
banji: this.data.multiArray[1][this.data.multiIndex[1]]
})
this.setData({
geren: this.data.multiArray[2][this.data.multiIndex[2]]
})
console.log('学院号', this.data.xueyuan);
console.log('班级号', this.data.banji);
console.log('学号', this.data.geren);
},
bindMultiPickerColumnChange: function (e) {
console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
var data = {
multiArray: this.data.multiArray,
multiIndex: this.data.multiIndex
};
data.multiIndex[e.detail.column] = e.detail.value;
switch (e.detail.column) {
case 0:
switch (data.multiIndex[0]) {
case 0:
data.multiArray[1] = ['112', '113', '114', '115', '116', '117', '121', '122', '211', '212', '213', '221', '222'];//1.2
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38'];//1.2.1
break;
case 1:
data.multiArray[1] = ['暂缓开通'];//2.2
data.multiArray[2] = ['暂缓开通'];//2.2.1
break;
}
data.multiIndex[1] = 0;
data.multiIndex[2] = 0;
break;
case 1:
switch (data.multiIndex[0]) {
case 0:
switch (data.multiIndex[1]) {
case 0:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38'];
break;
case 1:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37'];
break;
case 2:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37'];
break;
case 3:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37'];
break;
case 4:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37'];
break;
case 5:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38'];
break;
case 6:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39'];
break;
case 7:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39'];
break;
case 8:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36'];
break;
case 9:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36'];
break;
case 10:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37'];
break;
case 11:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37'];
break;
case 12:
data.multiArray[2] = ['01', '02', '03', '04', '05', '06', '07', '08', '09','10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37'];
break;
}
break;
case 1:
switch (data.multiIndex[1]) {
case 0:
data.multiArray[2] = [' '];
break;
case 1:
data.multiArray[2] = [' '];
break;
case 2:
data.multiArray[2] = [' '];
break;
}
break;
}
data.multiIndex[2] = 0;
console.log(data.multiIndex);
break;
}
this.setData(data);
},
//判断长度
IsTel: function (s) {
if (s != null) {
var length = s.length;
if (length == 6) {
return true;
} else {
return false;
}
}
},
//密码的输入框
mima: function (e) {
var that = this
console.log('输入值为',e.detail.value)
var isTel = that.IsTel(e.detail.value)
that.setData({
changdu:isTel
})
console.log('点击态判断',that.data.changdu)
if (isTel&&that.data.yanzhengjishu!=0) {
that.setData({
disabled: false,
opacity: 1
})
} else {
that.setData({
disabled: true,
opacity: 0.4
})
}
var dbPost = new DBPost();
that.setData({
newmima: e.detail.value
})
dbPost.newmima(that.data.newmima);
},
//提交按钮确认
sumit: function () {
var that=this;
var dbPost = new DBPost();
wx.showModal({
title: '确认',
content: '如果您绑定了他人的学号,将给您造成很大的麻烦',
confirmText: '继续绑定',
cancelText: '重新选择',
confirmColor: '#10aeff',
success: function (res) {
if (res.confirm) {
wx.login({
success: function (res) {
if (res.code) {
wx.request({
url: 'http://maoye.club/yingbo/rcs/API/bangding.php',
data: {
code: res.code,
xuehao:that.data.newxuehao
},
success: function (result) {
console.log(result);
dbPost.newxuehao(result.data.xueHao);
dbPost.newxingming(result.data.xingMing);
dbPost.newzhuanye(result.data.zhuanYe);
dbPost.newxueyuan(result.data.xueYuan);
dbPost.newadmin(result.data.admin);
that.data.xuehao = result.data.xueHao;
console.log(that.data.xuehao);
wx.switchTab({ url: '../../pages/post/post' })
wx.showToast({
title: '注册成功',
icon: 'success',
duration: 2000
})
}
})
} else {
console.log('获取失败' + res.errMsg)
}
}
});
console.log('用户点击继续绑定')
} else if (res.cancel) {
console.log('用户点击重新选择')
}
}
})
},
yanzheng:function () { //验证
var a = this.data.xueyuan
var b = this.data.banji
var c = this.data.geren
this.setData({
newxuehao:(a+b+c)
})
var that=this;
wx.request({
url: 'http://maoye.club/yingbo/rcs/API/yanzheng.php', //仅为示例,并非真实的接口地址
data: {
code:that.data.newxuehao
},
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
console.log(res.data);
if(res.data==null){
that.data.openid=1;
}else{
that.data.openid = res.data.openid;
}
console.log(that.data.openid)
if(!that.data.openid){
wx.showToast({
title: '验证成功',
icon: 'success',
duration: 2000
})
if (that.data.yanzhengjishu != 0) { //判断是否可以点击完成注册
that.setData({
disabled: false,
opacity: 1
})
} else {
that.setData({
disabled: true,
opacity: 0.4
})
}
}else{
that.setData({
disabled: true,
opacity: 0.4
})
wx.showModal({
title: '警告',
content: '此学号已经被其他人绑定',
confirmText: '重新选择',
cancelText: '联系客服',
confirmColor: '#10aeff',
success: function (res) {
if (res.confirm) {
console.log('用户点击重新选择')
} else if (res.cancel) {
wx.showModal({
title: '联系客服',
content: 'QQ1144131090',
confirmColor: '#10aeff',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
console.log('用户点击联系客服')
}
}
})
}
}
})
this.setData({
yanzhengjishu:this.data.yanzhengjishu+1 //验证计数
})
console.log('验证计数',this.data.yanzhengjishu)
console.log('上传学号为',this.data.newxuehao)
console.log(this.data.openid)
}
})