123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- // pages/deviceConnect0/deviceConnect0.ts
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- scopeBluetooth: false,
- userFuzzyLocation: true,
- nvabarData: {
- showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
- title: '连接配网', //导航栏 中间的标题
- callback() {
- wx.navigateBack({
- delta: 1,
- })
- }
- },
- isNotruter: false
- },
- onShow() {
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- wx.offAppShow(this.getSetting);
- wx.onAppShow(this.getSetting);
- this.getSetting();
- if (options.isLognlink) {
- this.setData({
- isNotruter: true,
- nvabarData: {
- showCapsule: 1,
- title: '连接配网',
- callback: () => {
- wx.redirectTo({
- url: '/pages/index/index'
- });
- }
- },
- })
- }
- },
- getBluetoothStatusCallck(v) {
- this.setData({
- scopeBluetooth: v
- })
- },
- getSetting() {
- const _this = this;
- wx.getSetting({
- success(res) {
- if (res.authSetting["scope.userFuzzyLocation"]) {
- // 成功
- app.getBluetoothStatus();
- _this.setData({
- userFuzzyLocation: true,
- });
- } else if (res.authSetting["scope.userFuzzyLocation"] === undefined) {
- wx.authorize({
- scope: "scope.userFuzzyLocation",
- success() {
- _this.getSetting();
- }
- });
- } else {
- _this.setData({
- userFuzzyLocation: false,
- });
- wx.showModal({
- title: '请打开系统位置获取',
- success(res) {
- if (res.confirm) {
- console.log('用户点击确定')
- wx.openSetting({
- complete() {
- // _this.getSetting();
- }
- })
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- })
- }
- }
- })
- },
- next() {
- const _this = this;
- wx.openBluetoothAdapter({
- success(res) {
- if (_this.data.scopeBluetooth && _this.data.userFuzzyLocation) {
- wx.navigateTo({
- url: './../deviceConnect1/deviceConnect1',
- });
- }
- },
- fail(res) {
- if (res.errCode === 10001) {
- wx.showToast({
- title: '蓝牙未打开',
- icon: "none",
- duration: 2000
- })
- }
- }
- });
- },
- setBluetooth() {
- wx.openSetting({
- complete() {
- // app.getBluetoothStatus();
- }
- })
- },
- setUserFuzzyLocation() {
- const _this = this;
- wx.openSetting({
- complete() {
- // _this.getSetting();
- }
- })
- },
- notRoter() {
- getCurrentPages()[0].onLoad();
- wx.redirectTo({
- url: '/pages/index/index'
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- wx.offAppShow(this.getSetting);
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|