微信小程序左上角返回按钮触发事件
  • 首页
  • 写文档
  • 主页
  • 登录/注册

从A页面跳转到B页面,再从B页面通过左上角返回按钮,返回到A页面

A页面:
在这里插入图片描述
B页面:
在这里插入图片描述
从B页面返回到A页面时,触发事件请求接口:
在这里插入图片描述代码如下:
B页面js代码

  onShow: function () {
    wx.setStorageSync('aShow', true)
  },

A页面js代码

onShow: function () {
    var page = this;
    let aShow = '';
    //获取存储信息
    wx.getStorage({
      key: 'aShow',
      success: function (res) {
        // success
        aShow = res.data;
        if (aShow) {
          //  学习进度
          app.sendRequest({
            url: api.course.study_plan,
            data: {
              curriculum_id: page.data.curriculum_id
            },
            success(plan_res) {
              if (JSON.stringify(plan_res.data) != "{}") {

                // 设置数据  
                page.setData({
                  joined: 1,
                  standard_id: plan_res.data.standard_id,
                  standard_name: plan_res.data.standard_name,
                  text: '继续学习'
                });

              } else {
                page.setData({
                  standard_id: ''
                });
              }

            }
          });
        }
      }
    })


  },
    • 阅读量
    • 发布日期(默)
    • 排序:

    • 文档
    • 粉丝
    • 评论
    • 点赞
    • 访客
    个人分类
    评论区 写评论
    ↑ 收起 ↑ 提 交