收藏
回答

iphone 11 真机无法调试 ios 15.4.1

框架类型 问题类型 操作系统 操作系统版本 手机型号 微信版本
小程序 Bug iOS 15.4.1 iPhone 11 8.0.20

import WxValidate from '../../utils/WxValidate'; const md5 = require("../../utils/md5.js"); // 获取应用实例 const app = getApp(); Page({ /** * 页面的初始数据 */ data: { bgImg: "/images/backgroundPic.png", tzlLogo: "/images/tzl_logo.png", openid: '' }, onLoad: function (options) { let bgImgBase64 = wx.getFileSystemManager().readFileSync(this.data.bgImg, 'base64'); let tzlLogoBase64 = wx.getFileSystemManager().readFileSync(this.data.tzlLogo, 'base64'); this.setData({ bgImg: 'data:image/png;base64,' + bgImgBase64, tzlLogo: 'data:image/png;base64,' + tzlLogoBase64 }) this.initValidate(); // 表单验证 this.getUserInfo(); }, getUserInfo: function (e) { let that = this; wx.login({ success: res => { if (res.code) { console.log('获取用户登录凭证 code:' + res.code); wx.request({ url: app.globalData.conf.baseRequestUrl + 'wechat/getUserInfor', method: "GET", data: { code: res.code }, success: function (result) { let data = result.data; if (data) { let openid = data.openid; that.setData({ openid: openid }) that.passwordFreeLogin(); } } }) } else { console.log('获取用户登录态失败:' + res.errMsg); } } }) }, passwordFreeLogin: function () { console.log("passwordFreeLogin---------------openid: " + this.data.openid); wx.request({ url: app.globalData.conf.baseRequestUrl + 'user2/passwordFreeLogin', data: { openid: this.data.openid }, method: "POST", dataType: "JSON", header: { 'content-type': 'application/x-www-form-urlencoded' // 默认值 }, success: (res) => { let data = res.data; console.log("passwordFreeLogin---------------" + JSON.stringify(data)); if (data) { let cookies = res.cookies[0].split(";"); let shiro_session = cookies[0]; app.globalData.conf.token = shiro_session; data = JSON.parse(data); if (data.ret) { wx.redirectTo({ url: '../index/index', }) } } } }); }, submitForm: function (e) { const params = e.detail.value; if (!this.WxValidate.checkForm(params)) { const error = this.WxValidate.errorList[0]; wx.showModal({ content: error.msg, showCancel: false, }) return false; } console.log('将要提交的表单信息:', params); wx.request({ url: app.globalData.conf.baseRequestUrl + 'user2/login', data: { loginName: params.loginName, password: md5.hexMD5(params.password), openid : this.data.openid }, method: "POST", dataType: "JSON", header: { 'content-type': 'application/x-www-form-urlencoded' // 默认值 }, success: (res) => { let data = res.data; if (data) { let cookies = res.cookies[0].split(";"); let shiro_session = cookies[0]; app.globalData.conf.token = shiro_session; wx.setStorage({ key: "token", data: shiro_session }) data = JSON.parse(data); if (data.ret) { wx.redirectTo({ url: '../index/index', }) } else { wx.showModal({ content: data.msg, showCancel: false, }) } } } }); }, initValidate: function () { const rules = { loginName: { required: true }, password: { required: true } } const message = { loginName: { required: '请输入登录账号' }, password: { required: '请输入登录密码' } } // 创建实例 this.WxValidate = new WxValidate(rules, message); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, })
回答关注问题邀请回答
收藏

1 个回答

  • Demons
    Demons
    2022-04-14

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2022-04-14
    有用
    回复
登录 后发表内容