| @@ -43,13 +43,10 @@ App({ | |||
| .then(res => { | |||
| if (res.data.subMalls) { | |||
| let list = JSON.parse(res.data.subMalls) | |||
| console.log(list, 888) | |||
| wx.setStorageSync('tenantData', JSON.stringify(list)) | |||
| wx.setStorageSync('groupIf', true) | |||
| wx.setStorageSync('tenantId', JSON.parse(res.data.subMalls)[0].parentTenantId) | |||
| wx.setStorageSync('tenantId', list.filter(e => e.tenantId == res.data.selectedMall)[0].tenantId) | |||
| } else { | |||
| wx.setStorageSync('tenantData', "[]") | |||
| wx.setStorageSync('groupIf', false) | |||
| wx.setStorageSync('tenantId', '') | |||
| } | |||
| wx.setStorageSync('openId',res.data.openId) | |||
| @@ -31,8 +31,8 @@ Component({ | |||
| }, | |||
| data: { | |||
| showGroupIf: JSON.parse(wx.getStorageSync('tenantData')).length>0?true:false, | |||
| tenantData: JSON.parse(wx.getStorageSync('tenantData')), | |||
| groupIf: wx.getStorageSync('groupIf'), | |||
| tenantId: wx.getStorageSync('tenantId'), | |||
| array: [], | |||
| index: 1, | |||
| @@ -51,12 +51,8 @@ Component({ | |||
| this.setData({ | |||
| index: e.detail.value | |||
| }) | |||
| let groupIf = false; | |||
| let selectIndex = 0; | |||
| this.data.tenantData.map((item, index) => { | |||
| if (e.detail.value == item.parentTenantId) { | |||
| groupIf = true; | |||
| } | |||
| if (e.detail.value == item.tenantId) { | |||
| selectIndex = index; | |||
| wx.setStorageSync('tenantId', item.tenantId) | |||
| @@ -66,19 +62,23 @@ Component({ | |||
| tenantId: this.data.tenantData[selectIndex].parentTenantId, | |||
| subTenantId: this.data.tenantData[e.detail.value].tenantId | |||
| } | |||
| if (groupIf) { | |||
| wx.setStorageSync('groupIf', true) | |||
| } else { | |||
| wx.setStorageSync('groupIf', false) | |||
| } | |||
| this.checkAble = true; | |||
| Http.post({ | |||
| url: config.api.selectMall, | |||
| data: param | |||
| }).then(res => { | |||
| wx.showModal({ | |||
| title: '提示', | |||
| content: '切换成功!', | |||
| wx.setStorageSync('tenantId', this.data.tenantData[e.detail.value].tenantId) | |||
| // wx.showModal({ | |||
| // title: '提示', | |||
| // content: '切换成功!', | |||
| // }) | |||
| wx.showToast({ | |||
| title: '切换成功!', | |||
| icon: 'success', | |||
| duration: 2000 | |||
| }) | |||
| wx.reLaunch({ | |||
| url: '/index/index', | |||
| }) | |||
| }) | |||
| .catch(err => { | |||
| @@ -87,11 +87,11 @@ Component({ | |||
| content: err.message, | |||
| showCancel: false, | |||
| success: function (res) { | |||
| // 如果游戏下架或者找不到,重启首页 | |||
| // 重启首页 | |||
| if (res.confirm) { | |||
| // wx.reLaunch({ | |||
| // url: '/pages/index/index', | |||
| // }) | |||
| wx.reLaunch({ | |||
| url: '/pages/index/index', | |||
| }) | |||
| } | |||
| } | |||
| }) | |||
| @@ -105,16 +105,16 @@ Component({ | |||
| } | |||
| }, | |||
| attached: function(){ | |||
| console.log(JSON.parse(wx.getStorageSync('tenantData')),11111) | |||
| console.log(JSON.parse(wx.getStorageSync('tenantData')), wx.getStorageSync('tenantId'),11111) | |||
| let list = []; | |||
| let tindex = 0; | |||
| this.data.tenantData.map((item,index)=>{ | |||
| list.push(item.name) | |||
| if(item.tenantId == this.data.tenantId){ | |||
| if (item.tenantId == wx.getStorageSync('tenantId')){ | |||
| tindex = index | |||
| } | |||
| }) | |||
| console.log(list,9999) | |||
| console.log(list,tindex,9999) | |||
| this.setData({ | |||
| array:list, | |||
| index: tindex | |||
| @@ -10,7 +10,7 @@ | |||
| </view> | |||
| </view> | |||
| <view class='title' style="color:{{color}}!important">{{text}}</view> | |||
| <picker bindchange="bindPickerChange" wx:if="{{showLocationIf}}" class="pick-box" value="{{index}}" range="{{array}}"> | |||
| <picker bindchange="bindPickerChange" wx:if="{{showLocationIf&&showGroupIf}}" class="pick-box" value="{{index}}" range="{{array}}"> | |||
| <icon class='iconfont icon-daohangdizhiweizhi'></icon> | |||
| <view class="picker locations"> | |||
| {{array[index]}} | |||
| @@ -228,6 +228,59 @@ Page({ | |||
| //获取条形码 | |||
| // util.barcode("barcode", optionss.quancode, 510, 100); | |||
| }, | |||
| //获取距离 | |||
| GetDistance(lat1, lng1, lat2, lng2) { | |||
| var radLat1 = lat1 * Math.PI / 180.0; | |||
| var radLat2 = lat2 * Math.PI / 180.0; | |||
| var a = radLat1 - radLat2; | |||
| var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0; | |||
| var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + | |||
| Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); | |||
| s = s * 6378.137;// EARTH_RADIUS; | |||
| s = Math.round(s * 10000) / 10000; | |||
| return s; | |||
| }, | |||
| //切换商场 | |||
| checkoutGroup(tenantId, parentTenantId){ | |||
| let param = { | |||
| tenantId: parentTenantId, | |||
| subTenantId: tenantId | |||
| } | |||
| Http.post({ | |||
| url: config.api.selectMall, | |||
| data: param | |||
| }).then(res => { | |||
| wx.setStorageSync('tenantId', tenantId) | |||
| // wx.showModal({ | |||
| // title: '提示', | |||
| // content: '切换成功!', | |||
| // }) | |||
| wx.showToast({ | |||
| title: '切换成功!', | |||
| icon: 'success', | |||
| duration: 2000 | |||
| }) | |||
| wx.reLaunch({ | |||
| url: '/index/index', | |||
| }) | |||
| }) | |||
| .catch(err => { | |||
| wx.showModal({ | |||
| title: '提示', | |||
| content: err.message, | |||
| showCancel: false, | |||
| success: function (res) { | |||
| // 重启首页 | |||
| if (res.confirm) { | |||
| wx.reLaunch({ | |||
| url: '/pages/index/index', | |||
| }) | |||
| } | |||
| } | |||
| }) | |||
| this.alphaClick(); | |||
| }) | |||
| }, | |||
| /** | |||
| * 获得经纬度 | |||
| */ | |||
| @@ -237,6 +290,29 @@ Page({ | |||
| type: "wgs84", | |||
| success: function (res) { | |||
| console.log(res, 9999) | |||
| // let minNum = 0; | |||
| // let minIndex = 0; | |||
| // JSON.parse(wx.getStorageSync('tenantData')).map((item, index) => { | |||
| // let lang = that.GetDistance(res.latitude,item.latitude,res.longitude,item.longitude) | |||
| // minIndex = (index == 0 || lang < minNum) ? index : minIndex; | |||
| // minNum = (index == 0 || lang < minNum) ? lang : minNum; | |||
| // }) | |||
| // if (JSON.parse(wx.getStorageSync('tenantData'))[minIndex].tenantId != wx.getStorageSync('tenantId')){ | |||
| // wx.showModal({ | |||
| // title: '提示', | |||
| // content: '系统检测到您离' + JSON.parse(wx.getStorageSync('tenantData'))[minIndex].name + '较近,要切换至' + JSON.parse(wx.getStorageSync('tenantData'))[minIndex].name+'吗?', | |||
| // success: function (res) { | |||
| // // 重启首页 | |||
| // if (res.confirm) { | |||
| // console.log(6789) | |||
| // that.checkoutGroup(JSON.parse(wx.getStorageSync('tenantData'))[minIndex].tenantId, JSON.parse(wx.getStorageSync('tenantData'))[minIndex].parentTenantId) | |||
| // // wx.reLaunch({ | |||
| // // url: '/pages/index/index', | |||
| // // }) | |||
| // } | |||
| // } | |||
| // }) | |||
| // } | |||
| if (res && res.longitude && res.latitude) { | |||
| Http.post({ | |||
| url: config.api.updateLBS, | |||