179 lines
4.2 KiB
JavaScript
179 lines
4.2 KiB
JavaScript
// welcome/login/login.js
|
||
import {
|
||
DBPost
|
||
} from '../../db/DBpost.js';
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
xuehao: 0,
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
onLoad: function(options) {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady: function() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow: function() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide: function() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload: function() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh: function() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom: function() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage: function() {
|
||
|
||
},
|
||
zhuce: function() {
|
||
wx.navigateTo({
|
||
url: '../signin/signin'
|
||
})
|
||
},
|
||
denglu: function() {
|
||
wx.showLoading({
|
||
title: '登录中',
|
||
})
|
||
var that = this;
|
||
var dbPost = new DBPost();
|
||
wx.login({
|
||
success: function(res) {
|
||
if (res.code) {
|
||
wx.request({
|
||
url: 'https://powerrain.cn/rcs/API/login.php',
|
||
data: {
|
||
code: res.code
|
||
},
|
||
success: function(result) {
|
||
console.log(result);
|
||
if (result.data != null) {
|
||
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);
|
||
var timestamp = +new Date();
|
||
timestamp = timestamp / 1000;
|
||
timestamp = parseInt(timestamp);
|
||
dbPost.newloginTime(timestamp);
|
||
}
|
||
if (!that.data.xuehao) {
|
||
wx.hideLoading()
|
||
wx.vibrateShort()
|
||
wx.showModal({
|
||
title: '警告',
|
||
content: '您还未曾注册过~',
|
||
confirmText: '注册账号',
|
||
cancelText: '联系客服',
|
||
confirmColor: '#10aeff',
|
||
success: function(res) {
|
||
if (res.confirm) {
|
||
wx.navigateTo({
|
||
url: '../signin/signin'
|
||
})
|
||
console.log('用户点击注册')
|
||
} else if (res.cancel) {
|
||
wx.showModal({
|
||
title: '联系客服',
|
||
content: 'QQ:1144131090',
|
||
confirmText: '复制',
|
||
confirmColor: '#10aeff',
|
||
success: function(res) {
|
||
if (res.confirm) {
|
||
wx.setClipboardData({
|
||
data: '1144131090',
|
||
success: function(res) {
|
||
wx.showToast({
|
||
title: '复制成功',
|
||
icon: 'success'
|
||
})
|
||
}
|
||
})
|
||
console.log('用户点击确定')
|
||
} else if (res.cancel) {
|
||
console.log('用户点击取消')
|
||
}
|
||
}
|
||
})
|
||
console.log('用户点击联系客服')
|
||
}
|
||
}
|
||
})
|
||
|
||
} else {
|
||
wx.hideLoading()
|
||
wx.switchTab({
|
||
url: '../../pages/post/post'
|
||
})
|
||
}
|
||
},
|
||
fail: function() {
|
||
wx.hideLoading();
|
||
wx.showToast({
|
||
title: "登录失败",
|
||
icon: "none"
|
||
})
|
||
}
|
||
})
|
||
} else {
|
||
console.log('获取失败' + res.errMsg)
|
||
}
|
||
}
|
||
});
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
}
|
||
}) |