| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- // pages/login/login.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- openid:'',
- username:'',
- password:'',
- userInfo: {},
- // hasUserInfo: false,
- // canIUse: wx.canIUse('button.open-type.getUserInfo'),
- // canIUseGetUserProfile: false,
- // canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
- },
- onClickIcon(){
- },
- async handleLogin () {
- let app = getApp();
- let openid = app.globalData.openID;
- await wx.p.request({
- url: `${app.globalData.url}wx/wxLogin`,
- method:'POST',
- data:{account: this.data.username,
- password:this.data.password,
- openid
- }
- }).then(res=>{
- if(res.data.code==200){
- wx.showToast({
- title:res.data.msg ,
- })
- wx.redirectTo({
- url: '../zero/zero',
- })
- }else{
- wx.showModal({
- content: res.data.msg,
- showCancel:false,
- confirmText:'返回'
- })
- }
-
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- let app = getApp();
- this.setData({
- username:app.globalData.phoneNumber
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- // getUserProfile(e) {
- // // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
- // wx.getUserProfile({
- // desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- // success: (res) => {
- // console.log(res)
- // this.setData({
- // userInfo: res.userInfo,
- // hasUserInfo: true
- // })
- // }
- // })
- // },
- // getUserInfo(e) {
- // // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
- // console.log(e)
- // this.setData({
- // userInfo: e.detail.userInfo,
- // hasUserInfo: true
- // })
- // }
- })
|