123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- const webSocket = require('./utils/websocket.js');
- App({
-
- globalData: {
- url: 'http://yhbdemo.niufangw.com/v1/'
- },
- judge_Land() {
- try {
- const value = wx.getStorageSync('wx_id')
- if (value) {
-
- }
- } catch (e) {
-
- }
- try {
- const value = wx.getStorageSync('access_token')
- if (value) {
-
- console.log(value);
-
- }else{
- wx.reLaunch({
- url: '/pages/Landpage/Land/Land'
- })
- }
- } catch (e) {
-
- }
-
-
- if (wx.getStorageSync('access_token')) {
-
- wx.reLaunch({
- url: '/pages/index/index'
- })
- } else if (wx.getStorageSync('wx_id')) {
-
- wx.reLaunch({
- url: '/pages/Landpage/Land/Land'
- })
- }else {
- wx.reLaunch({
- url: '/pages/Jurisdiction/click_Jurisdiction/click_Jurisdiction'
- })
- }
-
- },
- onLoad: function (options) {
- webSocket.connectSocket();
-
- },
- onLaunch: function (options) {
- wx.showShareMenu();
- var _this = this;
-
-
- },
-
- Tips(text) {
- wx.showToast({
- title: text,
- icon: 'none',
- duration: 2500
- })
- },
-
- showLoading: function () {
- wx.showToast({
- title: '加载中',
- icon: 'loading'
- });
- },
-
- cancelLoading: function () {
- wx.hideToast();
- },
-
- postRequest(p_url, p_data, callback, errFun) {
- p_data.key = wx.getStorageSync('access_key');
- p_data.token = wx.getStorageSync('access_token');
- wx.request({
- url: this.globalData.url + p_url,
- method: 'POST',
- data: p_data,
- header: { 'Content-Type': 'application/x-www-form-urlencoded' },
- dataType: 'json',
- success: function (res) {
- if(res.data.code == "401"){
- wx.clearStorageSync();
- wx.navigateTo({
- url: '/pages/Landpage/Land/Land'
- });
- }
- return typeof callback == "function" && callback(res.data)
- },
- fail: function (err) {
- return typeof errFun == "function" && errFun(err.data)
- }
- })
- },
- getRequest(g_url, g_data, callback, errFun) {
- g_data.key = wx.getStorageSync('access_key');
- g_data.token = wx.getStorageSync('access_token');
- wx.request({
- url: this.globalData.url + g_url,
- method: 'GET',
- data: g_data,
- header: { 'Content-Type': 'application/x-www-form-urlencoded' },
- dataType: 'json',
- success: function (res) {
- return typeof callback == "function" && callback(res.data)
- },
- fail: function (err) {
- return typeof errFun == "function" && errFun(err.data)
- }
- })
- },
-
- Multigraph(dt_url, dt_filePath, callback) {
- wx.uploadFile({
- url: this.globalData.url + dt_url,
- filePath: dt_filePath,
- name: 'img',
- formData: {
- key: wx.getStorageSync('access_key'),
- token: wx.getStorageSync('access_token'),
- },
- success: function (res) {
- var data = JSON.parse(res.data);
- return typeof callback == "function" && callback(data)
- wx.showModal({
- title: '提示',
- content: '上传失败,请从新上传',
- showCancel: false,
- })
- }, fail: function (d) {
- wx.showModal({
- title: '提示',
- content: '上传失败',
- showCancel: false,
- })
- }
- })
- },
- getDistrict(latitude, longitude) {
- let _page = this;
- let keys = '3VTBZ-JEH6Q-M7D5I-GNPVS-3QWBH-QUFY3';
- wx.request({
- url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${keys}`,
- header: {
- 'Content-Type': 'application/json'
- },
- success: function (res) {
- console.log(res);
- if (res.data.status == 0) {
- console.log(res.data.result.address_component);
- _page.postRequest('trajectory/location/position', res.data.result.address_component)
-
-
-
-
-
-
-
- }
- }
- })
- },
- Imsocket: function () {
- return webSocket;
- },
- UserId: function () {
- return wx.getStorageSync('access_token');
- },
- UserToken: function () {
- return wx.getStorageSync('access_user');
- }
- })
- getApp().judge_Land();
|