123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- // pages/login/index.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- nvabarData: {
- showCapsule: 0, //是否显示左上角图标,消息中心 1表示显示 0表示不显示
- showBack: 1, //返回
- title: '登录', //导航栏 中间的标题
- // 此页面 页面内容距最顶部的距离
- height: app.globalData.height * 2 + 20,
- },
- user: {},
- password:'',
- phone:'',
- },
- formSubmit: function (e) {
- console.log('form发生了submit事件,携带数据为:', e.detail.value)
- let phone = e.detail.value.phone
- let passwd = e.detail.value.password
- if (phone) {
- if (passwd) {
- let pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])');
- if (passwd.length <8||passwd.length >20||!pwdRegex.test(passwd) ) {
- wx.showModal({
- title: '提示',
- content: '密码格式错误',
- confirmText: '确定',
- success(res) {
- if (res.confirm) {
- // console.log('用户点击取消')
- } else if (res.cancel) {
- // console.log('用户点击取消')
- }
- }
- })
- } else {
- wx.request({
- method: "get",
- url: app.globalData.publicUrl + 'api/financial/companyuser',
- data: {
- phone: e.detail.value.phone
- },
- success: (e) => {
- if (e.data.errcode == 0) {
- console.log("login==================>"+e.data.data[0])
- // console.log("==================>"+delete e.data.data[0].IDcard)
- // if (e.data.data[0].IDcard) {
- // delete e.data.data[0].IDcard;
- // }
- if (e.data.data[0]!=undefined){
- delete e.data.data[0].IDcard;
- }
- if (e.data.data.length>0){
- delete e.data.data[0].IDcard;
- }
-
- this.setData({
- user: e.data.data[0]
- })
- // console.log('find---user',this.data.user);
- wx.request({
- method: "POST",
- url: app.globalData.publicUrl + 'api/financial/companyuser/login',
- data: {
- phone: phone,
- passwd: passwd
- },
- success: (e) => {
- console.log('success', e);
- if (e.data.errcode == 0) {
- wx.setStorage({
- key: 'user',
- data: this.data.user,
- })
- wx.redirectTo({
- url: '/pages/home/index'
- })
- } else {
- wx.showToast({
- title: e.data.errmsg,
- icon: 'none',
- duration: 1500
- })
- }
- }
- })
- }
- }
- })
- // wx.showToast({
- // title: '密码格式不正确,请重新输入',
- // icon: 'none',
- // duration: 1500
- // })
- }
- } else {
- wx.showToast({
- title: '密码为空,请重新输入',
- icon: 'none',
- duration: 1500
- })
- }
- } else {
- wx.showToast({
- title: '手机号为空,请输入手机号',
- icon: 'none',
- duration: 1500
- })
- }
- },
- // 忘记密码
- unBtnPass: function () {
- wx.navigateTo({
- url: '/pages/unpassword/index'
- })
- },
- // 注冊跳转
- registerBtn: function () {
- wx.navigateTo({
- url: '/pages/register/index'
- })
- },
- // 返回
- fanhui() {
- wx.redirectTo({
- url: '/pages/home/index',
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this;
- wx.getStorage({
- key: 'phone',
- success (res) {
- console.log(res.data)
- that.setData({
- phone:res.data
- })
- }
- })
- wx.getStorage({
- key: 'password',
- success (res) {
- console.log(res.data)
- that.setData({
- password:res.data
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|