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)
    })
  • 相关阅读:
    解决淘淘第三天无法显示图片
    包名与工程名
    明明有这个类却提示出错
    出错,网页显示不出内容
    配置域名
    本地jar包添加到maven仓库
    POJ1704 Georgia and Bob 博弈论 尼姆博弈 阶梯博弈
    POJ 2960 S-Nim 博弈论 sg函数
    sg函数总结
    POJ 2425 A Chess Game 博弈论 sg函数
  • 原文地址:https://www.cnblogs.com/wukongz/p/13566442.html
Copyright © 2011-2022 走看看