App({ /** * 当小程序初始化完成时,会触发 onLaunch(全局只触发一次) */ onLaunch: function () { // wx.checkSession({ // success: function () { // console.debug("already login"); // try { // var userToken = wx.getStorageSync('user_token'); // if (userToken == null || userToken == undefined || userToken == "") { // wx.removeStorageSync("user_token"); // wx.removeStorageSync("openid"); // that.login(); // } // } catch (e) { // console.log(e); // } // }, // fail: function () { // console.log("go login"); // wx.removeStorageSync("user_token"); // wx.removeStorageSync("openid"); // that.login(); // } // }) }, // login: function () { // var that = this; // wx.login({ // success: function (res) { // console.debug("wx.login" + res); // if (res.code) { // // that.loginToTaishan(res.code); // } else { // console.log('登录失败!' + res.errMsg) // } // }, // fail: function (res) { // console.log('fail' + res.errMsg) // } // }) // }, /** * 登录泰山系统 * @param {*} code */ // loginToTaishan: function (code) { // wx.request({ // url: this.globalData.cloudBase + "/Wx/Login/code=" + code, // method: 'GET', // header: { // "Content-Type": "json" // }, // success: function (res) { // console.debug("login " + res.data); // if (res.data.code === "0") { // try { // wx.setStorageSync('openid', res.data.openid); // if (res.data.reg === "1") { // wx.setStorageSync('headIcon', res.data.headIcon); // wx.setStorageSync('nick', res.data.nick); // wx.setStorageSync('user_token', res.data.userToken); // } else { // console.log("user check fail "); // } // } catch (e) { // console.log(e); // } // } else { // console.log("login to taishan fail " + res); // } // }, // fail: function (res) { // console.log("fail" + res); // } // }) // }, globalData: { defaultCity: '', defaultCounty: '', weatherData: '', g_isPlayingMusic: false, g_currentMusicPostId: null, //doubanBase: "https://api.douban.com", heWeatherBase: "https://free-api.heweather.com", //juhetoutiaoBase: "https://v.juhe.cn/toutiao/index", cloudBase: "https://wx.dahengsi.com", tencentMapKey: "4HYBZ-EB23D-SLC42-HQ5R3-LP3LQ-OZFU5", heWeatherKey: "4a817b4338e04cc59bdb92da7771411e", //juhetoutiaoKey: "a9f703a0200d68926f707f3f13629078", marketIndex: 0, imageBase: "https://wx.dahengsi.com", bluetoothErrCode: { ok: 0, //已连接 alreadyConnect: -1, //未初始化蓝牙适配器 notInit: 10000, //当前蓝牙适配器不可用 notAvailable: 10001, //没有找到指定设备 noDevice: 10002, //连接失败 connectionFail: 10003, //没有找到指定服务 noService: 10004, //没有找到指定特征 noCharacteristic: 10005, //当前连接已断开 noConnection: 10006, //当前特征不支持此操作 propertyNotSupport: 10007, //其余所有系统上报的异常 systemErro: 10008, //Android 系统特有,系统版本低于 4.3 不支持 BLE systemNotSupport: 10009, //连接超时 operateTimeOut: 10012, //连接 deviceId 为空或者是格式不正确 invalidData: 10013 } } })