Helius
2022-05-27 4351e71d782741143a98f86f6648acd16689165f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//app.js
var util = require('utils/util.js')
var api = require('utils/service-api.js');
App({
 
      baseUrl: "https://filehive2.jyymatrix.cc/xcxapi",
  //  baseUrl : "http://localhost:8080",
 
  //登录后获得的token
  loginToken: "",
  //判断用户是否登录
  isLogin: false,
  //最近门店
  shopInfo: {},
  //所有门店
  shopList: [],
 
 
  onLaunch: function(options) {
 
    this.getShop();
    if (options.scene == 1044) {
      wx.getShareInfo({
        shareTickets: options.shareTickets,
        success: function(res) {
          console.log("onLaunchoptions转发成功")
          console.log(res)
          var encryptedData = res.encryptedData;
          var iv = res.iv
        }
      })
    }
 
 
  },
 
  /**
   * 获取门店
   */
  getShop: function() {
    const app = this;
    wx.getLocation({
      type: 'wgs84',
      success(res) {
        const latitude = res.latitude;
        const longitude = res.longitude;
        app.doGgetShopList(longitude, latitude);
      },
      fail(res) {
        console.log("用户拒绝授权");
        app.doGgetShopList(0, 0);
      }
    })
  },
  doGgetShopList: function(longitude, latitude) {
    util.request({
      api: api.yuyue.getShopList + "/" + longitude + "/" + latitude,
      callback: function(data) {
       
        let shopInfo = data.mapInfo.shopInfo;
        if (getApp().shopInfo.id == null) {
          getApp().shopInfo = shopInfo;
          wx.setNavigationBarTitle({
            title: shopInfo.shopShortName
          });
        }
        getApp().shopList = data.rows;
 
      },
 
    });
  },
 
 
  checkAuthorize(scope) {
    wx.getSetting({
      success: (res) => {
        console.log(res.authSetting[scope])
        if (!res.authSetting[scope]) {
          wx.showModal({
            title: '用户未授权',
            content: '拒绝授权将不能体验小程序完整功能,点击确定开启授权',
            success: (res) => {
              console.log(res)
              if (res.confirm) {
                wx.openSetting({})
              }
            }
          })
        }
      }
    })
  }
 
})