ios系统下预览跟体验版不加载js中的方法,安卓一切正常
发布于 6 年前 作者 xgu 5831 次浏览 来自 问答

正常效果应该是这样的:(而且开发者工具和安卓都正常)

但是用苹果手机打开是这样的,初始值加载不到,所有页面绑定的方法点击也无效

到底是什么原因啊…要自闭了

2 回复

提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

iphone7系统版本12.1.3、微信版本7.0.2,

正常效果应该是:未填写手机号点击 ‘发送验证码’ 或 ‘下一步’ 都有错误提示,但预览时在该手机上点击事件都没有反应,sendCode初始化的值也取不到,用别的ios系统的手机出现一样的情况,而且是每个页面绑定的点击事件都不生效。

这种情况在安卓系统不会,并且使用真机调试时,ios的手机也使用正常。

js代码:

Page({
  data: {
    sendCode: '获取验证码',
    isSend: false,
  },
 
  //获取输入的手机号
  getPhone(e) {
    this.setData({
      phone: e.detail.value
    })
  },
  //获取输入的验证码
  getVerificationCode(e) {
    this.setData({
      code: e.detail.value
    })
  },
 
  getCode: function () {
    let that = this;
    if (that.isEmpty(that.data.phone)) {
      wx.showToast({
        title: '手机号不能为空',
        icon: 'none',
        duration: 2000
      })
      return false;
    }
    that.updateTime(60);
  },
 
  updateTime: function (restTime) {
    var that = this;
    if (restTime == 0) {
      that.setData({
        isSend: false,
        sendCode: '获取验证码'
      })
      restTime = 60;
    } else {
      that.setData({
        isSend: true,
        sendCode: restTime + '秒后重新发送'
      })
      restTime--;
      setTimeout(function () {
        that.updateTime(restTime);
      }, 1000);
    }
  },
 
  next: function () {
    let that = this;
    if (that.isEmpty(that.data.phone) && that.isEmpty(that.data.code)) {
      wx.showToast({
        title: '请输入手机号和验证码',
        icon: 'none',
        duration: 2000
      })
      return false;
    } else if (that.isEmpty(that.data.code)) {
      wx.showToast({
        title: '验证码不能为空',
        icon: 'none',
        duration: 2000
      })
      return false;
    } else {
      wx.showToast({
        title: '成功',
        icon: 'none',
        duration: 3000,
      })
    }
  },
 
  isEmpty: function(data) {
    if(typeof (data) == 'undefinde' || typeof (data) == 'null') {
      return true;
    } else if (typeof (data) == 'array') {
      return data.length < 1;
    } else if (data == null || data == "null") {
      return true;
    } else {
      return data.toString().length < 1;
    }
  }
})
回到顶部