首页 > 其他分享 >getOpenId

getOpenId

时间:2024-01-22 23:55:21浏览次数:34  
标签:openId getOpenId envId resp setData wx

 

Page({

  /**
   * 页面的初始数据
   */
  data: {
    showUploadTip: false,
    haveGetOpenId: false,
    envId: '',
    openId: ''
  },

  onl oad(options) {
    this.setData({
      envId: options.envId
    });
  },

  getOpenId() {
    wx.showLoading({
      title: '',
    });
   wx.cloud.callFunction({
      name: 'quickstartFunctions',
      config: {
        env: this.data.envId
      },
      data: {
        type: 'getOpenId'
      }
    }).then((resp) => {
      console.log(resp);
      this.setData({
        haveGetOpenId: true,
        //openId: resp.result.openid
        openId:resp.result.userInfo.openId
      });
     wx.hideLoading();
   }).catch((e) => {
      this.setData({
        showUploadTip: true
      });
     wx.hideLoading();
    });
  },

  clearOpenId() {
    this.setData({
      haveGetOpenId: false,
      openId: ''
    });
  }

});

 

 

 

 

#################

标签:openId,getOpenId,envId,resp,setData,wx
From: https://www.cnblogs.com/herd/p/17976206

相关文章