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)
    })
  • 相关阅读:
    nginx 配置详解
    ngnix 负载均衡
    nginx 安装搭建与配置介绍
    11.15java实习生面试总结
    笔试题:编写一个用户注册接口
    java第一次笔试+面试总结
    《啊哈算法》读后总结(下)
    java常见排序算法
    Tomcat安装及配置教程
    算法题:购买n个苹果,苹果6个一袋或者8个一袋,若想袋数最少,如何购买?
  • 原文地址:https://www.cnblogs.com/wukongz/p/13566442.html
Copyright © 2011-2022 走看看