zoukankan      html  css  js  c++  java
  • 微信小程序 获取手机号 获取基础信息 自定义分享 获取dom节点

    微信小程序 获取手机号 

    // 授权手机号 需要button标签 注意:open-type 的值 必须是getPhoneNumber
    <button open-type="getPhoneNumber" bindgetphonenumber="getuserinfo">授权登录</button>
    getuserinfo (e) {
        let that = this
        if (e.detail.errMsg.indexOf("getPhoneNumber:ok") > -1) {
          // 授权成功 通过login 获取code 提交服务端 进行解密 解密的参数为 data
          wx.login({
            success: res => {
              if (res.code) {
                let data = {
                  encryptedData: e.detail.encryptedData,
                  iv: e.detail.iv,
                  code: res.code
                }
            }) 
        } else {
          wx.showToast({
            title: '授权失败,请重新授权!',
            icon: 'none',
            duration: 2000
          })
        }
    }

     微信小程序 获取基础信息

    // 获取基础信息 需要button标签 设置 open-type 为 getUserInfo
    <button open-type="getUserInfo" bindgetuserinfo="getuserinfo">授权基础信息</button>
      getuserinfo(res) {
        var self = this
        if (res.detail.errMsg.indexOf("getUserInfo:ok") > -1) {
          console.log(res.detail.userInfo)
        } else {
          wx.showToast({
            title: '授权失败,请重新授权!',
            icon: 'none',
            duration: 2000
          })
        }
      }

    微信小程序 自定义分享

      onShareAppMessage (res) {
        console.log(res)
        return {
          title: title,
          imageUrl: imageUrl,
          path: '/pages/hotinfo/hotinfo?articleCode=' + articleCode,
          success: function(res) {
             // 无法监听到返回函数
          }
        }
      },
    })

    微信小程序 获取dom节点

    const query = wx.createSelectorQuery()
    query.select('#the-id').boundingClientRect()
    query.selectViewport().scrollOffset()
    query.exec(function(res){
      consoel.log(res)
    })
  • 相关阅读:
    C语言的AES加密
    curl指定域名的IP
    gdb调试知识
    C++获取寄存器eip的值
    C++嵌入lua
    [置顶] python字典和nametuple互相转换例子
    【python】redis基本命令和基本用法详解
    xshell登录到CentOS7上时出现“The remote SSH server rejected X11 forwarding request.
    selinue引起的ssh连接错误
    SCP和SFTP相同点和区别
  • 原文地址:https://www.cnblogs.com/wukongz/p/13566442.html
Copyright © 2011-2022 走看看