123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- // pages/blueDemos/blueDemos.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- },
- onLoad(options) {
- console.log("gadsfadfqwerqr====00==");
- wx.getSetting({
- success(res) {
- console.log("gadsfadfqwerqr====00==" + JSON.stringify(res));
- if (res.authSetting['scope.userInfo']) {
- // 已经授权,可以直接调用 getUserInfo 获取头像昵称
- wx.getUserInfo({
- success: function (res) {
- console.log("获取用户信息成功", res.userInfo)
- }
- })
- } else {
- // 否则,先通过 wx.createUserInfoButton 接口发起授权
- let button = wx.createUserInfoButton({
- type: 'text',
- text: '获取用户信息',
- style: {
- left: 10,
- top: 160,
- width: 200,
- height: 40,
- lineHeight: 40,
- backgroundColor: '#ff0000',
- color: '#ffffff',
- textAlign: 'center',
- fontSize: 16,
- borderRadius: 4
- }
- })
- button.onTap((res) => {
- console.log(res)
- })
- }
- },
- fail(err) {
- console.log("gadsfadfqwerqr====11==" + JSON.stringify(err));
- console.log("获取用户信息失败", err)
- }
- });
- ///获取定位权限
- wx.authorize({
- scope: 'scope.userFuzzyLocation',
- success(res) {
- console.log("gadsfadfqwerqr====22==" + JSON.stringify(res));
- },
- fail(err) {
- console.log("gadsfadfqwerqr====333==" + JSON.stringify(err));
- }
- });
- ///获取蓝牙权限
- wx.authorize({
- scope: 'scope.bluetooth',
- success(res) {
- console.log("gadsfadfqwerqr====444==" + JSON.stringify(res));
- },
- fail(err) {
- console.log("gadsfadfqwerqr====555==" + JSON.stringify(err));
- }
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|