论坛风格切换切换到宽版
  • 34阅读
  • 9回复

小程序 [复制链接]

上一主题 下一主题
离线北斗星
 

只看楼主 倒序阅读 使用道具 楼主   发表于: 2021-12-30
  1. <view class="container">
  2.   <view class="userinfo">
  3.     <button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
  4.     <block wx:else>
  5.       <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
  6.       <text class="userinfo-nickname">{{userInfo.nickName}}</text>
  7.     </block>
  8.   </view>
  9.   <view class="userinfo">
  10.     <button wx:if="{{canIUse}}" bindtap='getLogin'> 登陆 </button>
  11.     
  12.   </view>
  13.   <view class="usermotto">
  14.     <text class="user-motto">{{motto}}</text>
  15.     <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"></button>
  16.   </view>
  17. </view>

离线北斗星

只看该作者 沙发   发表于: 2021-12-30
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5.   data: {
  6.     motto: 'Hello World',
  7.     userInfo: {},
  8.     hasUserInfo: false,
  9.     canIUseGetUserProfile: false,
  10.     //canIUse: wx.canIUse('button.open-type.getUserInfo')
  11.   },
  12.   //事件处理函数
  13.   bindViewTap: function () {
  14.     wx.navigateTo({
  15.       url: '../logs/logs'
  16.     })
  17.   },
  18.   onLoad: function () {
  19.     if (app.globalData.userInfo) {
  20.       this.setData({
  21.         userInfo: app.globalData.userInfo,
  22.         hasUserInfo: true
  23.       })
  24.     } else if (this.data.canIUse) {
  25.       // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  26.       // 所以此处加入 callback 以防止这种情况
  27.       app.userInfoReadyCallback = res => {
  28.         this.setData({
  29.           userInfo: res.userInfo,
  30.           hasUserInfo: true
  31.         })
  32.       }
  33.     } else {
  34.       // 在没有 open-type=getUserInfo 版本的兼容处理
  35.       wx.getUserInfo({
  36.         success: res => {
  37.           app.globalData.userInfo = res.userInfo
  38.           this.setData({
  39.             userInfo: res.userInfo,
  40.             hasUserInfo: true
  41.           })
  42.         }
  43.       })
  44.     }
  45.   },
  46.   getUserProfile(e) {
  47.     // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
  48.     // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  49.     wx.getUserProfile({
  50.       desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  51.       success: (res) => {
  52.         this.setData({
  53.           userInfo: res.userInfo,
  54.           hasUserInfo: true
  55.         })
  56.       }
  57.     })
  58.   },
  59.   getUserInfo: function (e) {
  60.     console.log(e)
  61.     app.globalData.userInfo = e.detail.userInfo
  62.     this.setData({
  63.       userInfo: e.detail.userInfo,
  64.       hasUserInfo: true
  65.     })
  66.   },
  67.   getLogin: function (e) {
  68.     wx.login({
  69.       success(res) {
  70.         if (res.code) {
  71.           console.log(res.code);
  72.           // 发起网络请求
  73.           wx.request({
  74.             url: 'https://gj.cnyou.com/api/onlogin',
  75.             method: 'post',
  76.             data: {
  77.               code: res.code
  78.             },
  79.             header: {
  80.               'content-type': 'application/json' // 默认值
  81.             },
  82.             success(res) {
  83.               console.log(res.data);
  84.             }
  85.           })
  86.         } else {
  87.           console.log('登录失败!' + res.errMsg)
  88.         }
  89.       }
  90.     })
  91.   },
  92.   getPhoneNumber(e) {
  93.     console.log(e.detail.errMsg)
  94.     console.log(e.detail.iv)
  95.     console.log(e.detail.encryptedData)
  96.   }
  97. })

离线北斗星

只看该作者 板凳   发表于: 2021-12-31
  1. // pages/user/user.js
  2. const app = getApp()
  3. Page({
  4.   /**
  5.    * 页面的初始数据
  6.    */
  7.   data: {
  8.     userInfo: {},
  9.     hasUserInfo: false,
  10.     canIUseGetUserProfile: false,
  11.     //canIUse: wx.canIUse('button.open-type.getUserInfo'),
  12.     skey: null
  13.   },
  14.   /**
  15.    * 生命周期函数--监听页面加载
  16.    */
  17.   onLoad: function (options) {
  18.     
  19.       //获取缓存中skey的值
  20.       try {
  21.         var skey = wx.getStorageSync('skey')
  22.         var hasKey = false
  23.         if (skey) {
  24.           hasKey = true
  25.         } else {
  26.           hasKey = false
  27.         }
  28.         //console.log(skey)
  29.         if (skey) {
  30.           this.setData({
  31.             skey: skey
  32.           })
  33.         }
  34.         
  35.       } catch (e) {
  36.       }
  37.       if (app.globalData.userInfo) {
  38.         //console.log(hasKey);
  39.         this.setData({
  40.           userInfo: app.globalData.userInfo,
  41.           hasUserInfo: true,
  42.           hasKey: hasKey
  43.         })
  44.       } else if (this.data.canIUseGetUserProfile) {
  45.         // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  46.         // 所以此处加入 callback 以防止这种情况
  47.         app.userInfoReadyCallback = res => {
  48.           this.setData({
  49.             userInfo: res.userInfo,
  50.             hasUserInfo: true,
  51.             hasKey: hasKey
  52.           })
  53.         }
  54.       } else {
  55.         // 在没有 open-type=getUserInfo 版本的兼容处理
  56.         wx.getUserProfile({
  57.           desc: '用于完善会员资料',
  58.           success: res => {
  59.             app.globalData.userInfo = res.userInfo
  60.             this.setData({
  61.               userInfo: res.userInfo,
  62.               hasUserInfo: true,
  63.               hasKey: hasKey
  64.             })
  65.           }
  66.         })
  67.       }
  68.       
  69.   },
  70.   isLogin() {
  71.     app.isLogin();
  72.   },
  73.   goto:function(e){
  74.     var url = e.currentTarget.dataset.url;
  75.     if (wx.getStorageSync("skey")) {
  76.       wx.reLaunch({
  77.         url: "../" + url + "/" + url,
  78.       });
  79.     } else {
  80.       app.issLogin(url);
  81.     }
  82.     //
  83.   },
  84.   suggest: function (e) {
  85.     var url = e.currentTarget.dataset.url;
  86.     wx.navigateTo({
  87.       url: "../" + url + "/" + url,
  88.     });
  89.   },
  90.   read: function (e) {
  91.     var id = e.currentTarget.dataset.id;
  92.     wx.navigateTo({
  93.       url: "../read/read?id=" + id ,
  94.     });
  95.   },
  96.   readweb: function (e) {
  97.     var id = e.currentTarget.dataset.id;
  98.     wx.navigateTo({
  99.       url: "../user/xie1?id=" + id ,
  100.     });
  101.   },
  102.   bindViewTap1: function() {
  103.     wx.redirectTo({
  104.         url: "../scanble/scanble"
  105.     });
  106.   },
  107.   getUserProfile(e) {
  108.     // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
  109.     // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  110.     wx.getUserProfile({
  111.       desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  112.       success: (res) => {
  113.         this.setData({
  114.           userInfo: res.userInfo,
  115.           hasUserInfo: true
  116.         })
  117.       }
  118.     })
  119.   },
  120.   getUserInfo: function (e) {
  121.     var that = this
  122.     wx.showModal({
  123.       title: '隐私提示',
  124.       content: '首次授权用户请阅读血压云隐私协议。是否授权血压云获取您微信的昵称信息?',
  125.       cancelText:'阅读协议',
  126.       confirmText:'同意授权',
  127.       success (res) {
  128.         if (res.confirm) {
  129.           //console.log(e)
  130.           //console.log(e.detail.errMsg)
  131.           //console.log(e.detail.iv)
  132.           //console.log(e.detail.encryptedData)
  133.           app.globalData.userInfo = e.detail.userInfo
  134.           app.getLogin(e.detail);
  135.           //console.log('用户点击确定1')
  136.           that.setData({
  137.             userInfo: e.detail.userInfo,
  138.             hasUserInfo: true,
  139.             hasKey: true
  140.           })
  141.           //console.log('用户点击确定2')
  142.         } else if (res.cancel) {
  143.           wx.navigateTo({
  144.             url: '../user/xie1',
  145.           })
  146.           //console.log('用户点击取消')
  147.         }
  148.       }
  149.     })
  150.     
  151.   },
  152.   outLogin() {
  153.     this.setData({
  154.       hasUserInfo: false,
  155.       hasKey:false
  156.     })
  157.     wx.removeStorage({
  158.       key: "userInfo"
  159.     }),
  160.       app.globalData.userInfo = null,
  161.       wx.removeStorage({ key: 'skey' })
  162.   },
  163.   delLogin() {
  164.     var that = this
  165.     wx.showModal({
  166.       title: '帐号注销',
  167.       content: '此功能将清除您在血压云所有的血压记录数据及注册信息,请谨慎使用。',
  168.       cancelText:'取消',
  169.       confirmText:'注销帐号',
  170.       success (res) {
  171.         if (res.confirm) {
  172.           that.setData({
  173.             hasUserInfo: false,
  174.             hasKey:false
  175.           })
  176.           wx.removeStorage({
  177.             key: "userInfo"
  178.           }),
  179.             app.globalData.userInfo = null,
  180.             wx.removeStorage({ key: 'skey' })
  181.           //console.log('用户确认注销帐号')
  182.         } else if (res.cancel) {
  183.           //console.log('用户点击取消')
  184.         }
  185.       }
  186.     })
  187.     
  188.   },
  189.   openSetting() { wx.openSetting() },
  190.   bindGetUserInfo(e) {
  191.     console.log(e.detail.userInfo)
  192.   },
  193.   onGotUserInfo(e) {
  194.     console.log(e.detail.errMsg)
  195.     console.log(e.detail.userInfo)
  196.     console.log(e.detail.rawData)
  197.   },
  198.   getPhoneNumber(e){
  199.     wx.showToast({
  200.       title: "登陆成功"
  201.     })
  202.     console.log(e.detail.userInfo)
  203.     // 查看是否授权
  204.     wx.getSetting({
  205.       success(res) {
  206.         if (res.authSetting['scope.userInfo']) {
  207.           // 已经授权,可以直接调用 getUserInfo 获取头像昵称
  208.           wx.getUserInfo({
  209.             success: function (res) {
  210.               console.log(res.userInfo)
  211.               //this.login(res);
  212.             }
  213.           })
  214.         }
  215.       }
  216.     })
  217.     
  218.   },
  219.   
  220.   /**
  221.    * 生命周期函数--监听页面初次渲染完成
  222.    */
  223.   onReady: function () {
  224.   
  225.   },
  226.   /**
  227.    * 生命周期函数--监听页面显示
  228.    */
  229.   onShow: function () {
  230.   
  231.   },
  232.   /**
  233.    * 生命周期函数--监听页面隐藏
  234.    */
  235.   onHide: function () {
  236.   
  237.   },
  238.   /**
  239.    * 生命周期函数--监听页面卸载
  240.    */
  241.   onUnload: function () {
  242.   
  243.   },
  244.   /**
  245.    * 页面相关事件处理函数--监听用户下拉动作
  246.    */
  247.   onPullDownRefresh: function () {
  248.     var that = this;
  249.       that.onload
  250.   },
  251.   /**
  252.    * 页面上拉触底事件的处理函数
  253.    */
  254.   onReachBottom: function () {
  255.   
  256.   },
  257.   /**
  258.    * 用户点击右上角分享
  259.    */
  260.   onShareAppMessage: function () {
  261.   
  262.   },
  263.   getLogin() {
  264.     app.getLogin();
  265.   },
  266. })

离线北斗星

只看该作者 地板   发表于: 2021-12-31
<!-- {{!hasKey}}  {{!hasUserInfo && canIUse}}-->
<view class="user_bg">
        <view class="top">
            <view class="top_left" wx:if="{{!hasKey}}">
                <image src="../../images/u.png" style="border-radius:50px;"></image>
                <button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile" class="bt_idnex"> 点此授权登陆1 </button>
                <button wx:else open-type="getUserInfo" bindgetuserinfo="getUserInfo" class="bt_idnex"> 点此授权登陆2 </button>
            </view>
            <view class="top_left" wx:else>
                <block>
                  <image src="{{userInfo.avatarUrl}}" style="border-radius:50px;"></image>
                </block>
                <view>{{userInfo.nickName}}</view>
                <button bindtap="outLogin" >退出 </button>
            </view>
        </view>
</view>

<view>

<view class='itemclass' bindtap="goto" data-url="mylist"><view>我的血压列表</view><view>></view>  </view>

<view class='itemclass' bindtap="bindViewTap1"><view>蓝牙测量(支持西恩、斐讯蓝牙血压计)</view><view>></view></view>
<view class='itemclass' bindtap="read" data-id="2"><view>API接口合作</view><view>></view></view>

<view class='itemclass' bindtap="suggest" data-url="suggest"><view>建议与反馈</view><view>></view></view>

<view class='itemclass' bindtap="read" data-id="1"><view>关于我们</view><view>></view></view>
<!--<view class='itemclass' bindtap="read" data-id="3"><view>使用帮助</view><view>></view></view>-->
<view class='itemclass' bindtap="readweb" data-id="2"><view>使用帮助</view><view>></view></view>
<view class='itemclass' bindtap="openSetting"><view >权限设置</view><view>></view></view>
<view class='itemclass' bindtap="delLogin" wx:if="{{hasKey}}"><view>帐号注销</view><view>></view></view>
<view class='itemclass' bindtap="readweb" data-id="1"><view>血压云隐私协议</view><view>></view></view>
<!--<view class='itemclass' bindtap="auth"><view>登陆</view><view>></view></view>-->
</view>


<!-- 需要使用 button 来授权登录 -->
<!--<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">授权登录</button>
<view wx:else>请升级微信版本</view>
<view wx:if="{{skey === null}}">
<button bindgetphonenumber="getPhoneNumber" openType="getPhoneNumber"> 请登陆/注册</button>
</view>
<view wx:else>
  <open-data type="userAvatarUrl"></open-data>
  <open-data type="userNickName"></open-data>
</view>
<button open-type="openSetting">权限设置</button>
<button open-type="getUserInfo" lang="zh_CN" bindgetuserinfo="onGotUserInfo"
  >获取用户信息</button>-->
离线北斗星

只看该作者 4楼  发表于: 2021-12-31
<!--index.wxml {{!hasUserInfo && canIUse && !hasKey}} -->
<view class="container">

  <view class="userinfo">
  <view class="text_index">开心生活每一天</view>
    <view wx:if="{{!hasKey}}">
          <button open-type="getUserInfo" bindgetuserinfo="getUserInfo" class="bt_idnex"> 开始使用 </button>
    </view>
    <view class="name_index" wx:else>
        <block>
          <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
          <view class="userinfo-nickname">{{userInfo.nickName}}</view>
        </block>
    </view>
  </view>
  <!--<view class="userinfo">
  {{hasUserInfo}} {{canIUse}} {{hasKey}}
    <button bindtap="getLogin" >登陆 </button>
    <button bindtap="isLogin" >验证登陆 </button>
     <button bindtap="outLogin" >退出 </button>
  </view>-->
  <view class="add">
    
     <view><image src="../../images/add.png" class="addbp" bindtap='bindAddTap' mode="cover"></image>
      <image src="../../images/lanya.png" class="addbp" bindtap='bindAddLanYaTap' mode="cover"></image></view>
     <text class="addname">{{motto}}。支持西恩、斐讯蓝牙血压计</text>
    
  </view>
</view>

离线北斗星

只看该作者 5楼  发表于: 2021-12-31
//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    motto: '添加血压',
    userInfo: {},
    hasUserInfo: false,
    hasKey:false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  //事件处理函数
  bindViewTap: function() {
    //wx.navigateTo({
    //  url: '../logs/logs'
    //})
    wx.navigateTo({
      url: '../user/user'
    })
  },
  bindAddTap: function () {
    wx.switchTab({
      url: '../add/add'  
    })
  },
  bindAddLanYaTap: function () {
    wx.redirectTo({
      url: '../scanble/scanble'  
    })
  },
  onLoad: function () {
    var skey = wx.getStorageSync('skey')
    var hasKey = false
    if (skey){
        hasKey = true
    }else{
        hasKey = false
    }
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true,
        hasKey:hasKey
      })
    } else if (this.data.canIUse){
      // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true,
          hasKey: hasKey
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true,
            hasKey: hasKey
          })
        }
      })
    }
  },
  getUserInfo: function(e) {
    console.log(e)
    console.log(e.detail.errMsg)
    console.log(e.detail.iv)
    console.log(e.detail.encryptedData)
    app.globalData.userInfo = e.detail.userInfo
    app.getLogin(e.detail);
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true,
      hasKey: true
    })
  },
  
  getPhoneNumber(e) {
    console.log(e.detail.errMsg)
    console.log(e.detail.iv)
    console.log(e.detail.encryptedData)
  },
  getLogin(){
    app.getLogin();
  },
  isLogin(){
    app.isLogin();
  },
  outLogin(){
    this.setData({
      hasUserInfo: false
    })
    wx.removeStorage({
      key: "userInfo"
    }),
    app.globalData.userInfo=null,
      wx.removeStorage({key: 'skey'})
    
  }
  
})
离线北斗星

只看该作者 6楼  发表于: 2021-12-31
<!--index.wxml {{!hasUserInfo && canIUse && !hasKey}} -->
<view class="container">

  <view class="userinfo">
  <view class="text_index">开心生活每一天</view>
    <view wx:if="{{!hasKey}}">
          <button open-type="getUserInfo" bindgetuserinfo="getUserInfo" class="bt_idnex"> 开始使用 </button>
    </view>
    <view class="name_index" wx:else>
        <block>
          <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
          <view class="userinfo-nickname">{{userInfo.nickName}}</view>
        </block>
    </view>
  </view>
  <!--<view class="userinfo">
  {{hasUserInfo}} {{canIUse}} {{hasKey}}
    <button bindtap="getLogin" >登陆 </button>
    <button bindtap="isLogin" >验证登陆 </button>
     <button bindtap="outLogin" >退出 </button>
  </view>-->
  <view class="add">
    
     <view><image src="../../images/add.png" class="addbp" bindtap='bindAddTap' mode="cover"></image>
      <image src="../../images/lanya.png" class="addbp" bindtap='bindAddLanYaTap' mode="cover"></image></view>
     <text class="addname">{{motto}}。支持西恩、斐讯蓝牙血压计</text>
    
  </view>
</view>

离线北斗星

只看该作者 7楼  发表于: 2021-12-31
//app.js

const updateManager = wx.getUpdateManager()

updateManager.onCheckForUpdate(function (res) {
  // 请求完新版本信息的回调
  console.log(res.hasUpdate)
})

updateManager.onUpdateReady(function () {
  wx.showModal({
    title: '更新提示',
    content: '新版本已经准备好,是否重启应用?',
    success: function (res) {
      if (res.confirm) {
        // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
        updateManager.applyUpdate()
      }
    }
  })
})

updateManager.onUpdateFailed(function () {
  // 新版本下载失败
})


App({
  data: {
    domain: "https://gjapi.xueyayun.cn/",
    //domain: "https://ludehealth.com:8082/lude",
    encryptedData: null,
    iv: null,
    frends: wx.getStorageSync("frends"),
    soundSwitch: !0
},
globalData: {
  userInfo: null,
  url:'https://gjapi.xueyayun.cn/'
},
isIphoneX: function() {
  return wx.getSystemInfoSync().model.indexOf("iPhone X") >= 0;
},
  onLaunch: function () {
    // 展示本地存储能力
    //var logs = wx.getStorageSync('logs') || []
   // logs.unshift(Date.now())
   // wx.setStorageSync('logs', logs)

    // 登录
    /*wx.login({
      success: res => {
        console.log('已登陆')
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })*/
    // 获取用户信息
    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          
          // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
          wx.getUserInfo({
            success: res => {
              // 可以将 res 发送给后台解码出 unionId
              this.globalData.userInfo = res.userInfo

              // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
              // 所以此处加入 callback 以防止这种情况
              if (this.userInfoReadyCallback) {
                this.userInfoReadyCallback(res)
              }
            }
          })
        }
      }
    })
  },
  getLogin:function(e){
    var that = this
    wx.login({
      success(res) {
        if (res.code) {
          console.log(res.code);
          // 发起网络请求
          wx.request({
            url: that.globalData.url + 'api/onlogin',
            method: 'post',
            data: {
              code: res.code,
              userInfo: e.userInfo
            },
            header: {
              'content-type': 'application/json' // 默认值
            },
            success(res) {
              console.log(res.data);
              if (res.data.result == 1) {
                try {
                  wx.setStorage({
                    key: "skey", //res.data.uid
                    data: res.data.skey
                  })
                } catch (e) {

                }
              } else {
                console.log(res.data.msg);
              }

            }
          })
        } else {
          console.log('登录失败!' + res.errMsg)
        }
      }
    })
  },
  isLogin() {   //是否登陆
    var that = this;
    var skey = wx.getStorageSync('skey')
    console.log(skey)
    if (skey) {
      //that.doLogin();
      // 检查 session_key 是否过期
      //wx.checkSession({
        // session_key 有效(未过期)
       // success: function () {
          // 业务逻辑处理
      //  },

        // session_key 过期
      //  fail: function () {
     //     console.log('失败登陆');
          // session_key过期,重新登录
      //    that.doLogin();
      //  }
     // });
    } else {
      console.log('未登陆');
      //需要登陆
      that.doLogin();
    }
  },
  issLogin(url) {   //是否登陆
    var that = this;
    var skey = wx.getStorageSync('skey')
    console.log(skey)
    if (skey) {
      wx.switchTab({
        url: "../" + url + "/" + url,
      });
      // 检查 session_key 是否过期
      /*wx.checkSession({
        // session_key 有效(未过期)
        success: function () {
          // 业务逻辑处理
          console.log(url);
          wx.switchTab({
            url: "../" + url + "/" + url,
          });

        },

        // session_key 过期
        fail: function () {
          // session_key过期,重新登录
          that.doLogin();
        }
      });*/
    } else {
      console.log('未登陆');
      //需要登陆
      wx.showModal({
        title: "温馨提示",
        content: "未登陆,请先点击授权登陆",
        showCancel: false,
        success: function (t) {
          
        }
      });
    }
  },
  doLogin(){
    wx.showModal({
      title: "温馨提示",
      content: "您尚未登陆,请先前往个人中心登陆",
      showCancel: false,
      success: function (t) {
        t.confirm && wx.switchTab({
          url: "../user/user"
        });
      }
    });
  }
})
离线北斗星

只看该作者 8楼  发表于: 2022-01-04
public function get(string $openid, string $lang = 'zh_CN')
    {
        $params = [
            'openid' => $openid,
            'lang' => $lang,
        ];

        return $this->httpGet('cgi-bin/user/info', $params);
    }
离线北斗星

只看该作者 9楼  发表于: 2022-01-04
public function get(string $openid, string $lang = 'zh_CN')
    {
        $params = [
            'openid' => $openid,
            'lang' => $lang,
        ];

        return $this->httpGet('cgi-bin/user/info', $params);
    }

    /**
     * Batch get users.
     *
     * @param array  $openids
     * @param string $lang
     *
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
     *
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function select(array $openids, string $lang = 'zh_CN')
    {
        return $this->httpPostJson('cgi-bin/user/info/batchget', [
            'user_list' => array_map(function ($openid) use ($lang) {
                return [
                    'openid' => $openid,
                    'lang' => $lang,
                ];
            }, $openids),
        ]);
    }
快速回复
限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
上一个 下一个