Showing
11 changed files
with
152 additions
and
53 deletions
config/amap-wx.js
0 → 100644
| 1 | +function AMapWX(a){this.key=a.key,this.requestConfig={key:a.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"}}AMapWX.prototype.getWxLocation=function(a,b){wx.getLocation({type:"gcj02",success:function(a){var c=a.longitude+","+a.latitude;wx.setStorage({key:"userLocation",data:c}),b(c)},fail:function(c){wx.getStorage({key:"userLocation",success:function(a){a.data&&b(a.data)}}),a.fail({errCode:"0",errMsg:c.errMsg||""})}})},AMapWX.prototype.getRegeo=function(a){function c(c){var d=b.requestConfig;wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:b.key,location:c,extensions:"all",s:d.s,platform:d.platform,appname:b.key,sdkversion:d.sdkversion,logversion:d.logversion},method:"GET",header:{"content-type":"application/json"},success:function(b){var d,e,f,g,h,i,j,k,l;b.data.status&&"1"==b.data.status?(d=b.data.regeocode,e=d.addressComponent,f=[],g="",d&&d.roads[0]&&d.roads[0].name&&(g=d.roads[0].name+"附近"),h=c.split(",")[0],i=c.split(",")[1],d.pois&&d.pois[0]&&(g=d.pois[0].name+"附近",j=d.pois[0].location,j&&(h=parseFloat(j.split(",")[0]),i=parseFloat(j.split(",")[1]))),e.provice&&f.push(e.provice),e.city&&f.push(e.city),e.district&&f.push(e.district),e.streetNumber&&e.streetNumber.street&&e.streetNumber.number?(f.push(e.streetNumber.street),f.push(e.streetNumber.number)):(k="",d&&d.roads[0]&&d.roads[0].name&&(k=d.roads[0].name),f.push(k)),f=f.join(""),l=[{iconPath:a.iconPath,width:a.iconWidth,height:a.iconHeight,name:f,desc:g,longitude:h,latitude:i,id:0,regeocodeData:d}],a.success(l)):a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}var b=this;a.location?c(a.location):b.getWxLocation(a,function(a){c(a)})},AMapWX.prototype.getWeather=function(a){function d(d){var e="base";a.type&&"forecast"==a.type&&(e="all"),wx.request({url:"https://restapi.amap.com/v3/weather/weatherInfo",data:{key:b.key,city:d,extensions:e,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion},method:"GET",header:{"content-type":"application/json"},success:function(b){function c(a){var b={city:{text:"城市",data:a.city},weather:{text:"天气",data:a.weather},temperature:{text:"温度",data:a.temperature},winddirection:{text:"风向",data:a.winddirection+"风"},windpower:{text:"风力",data:a.windpower+"级"},humidity:{text:"湿度",data:a.humidity+"%"}};return b}var d,e;b.data.status&&"1"==b.data.status?b.data.lives?(d=b.data.lives,d&&d.length>0&&(d=d[0],e=c(d),e["liveData"]=d,a.success(e))):b.data.forecasts&&b.data.forecasts[0]&&a.success({forecast:b.data.forecasts[0]}):a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}function e(e){wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:b.key,location:e,extensions:"all",s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion},method:"GET",header:{"content-type":"application/json"},success:function(b){var c,e;b.data.status&&"1"==b.data.status?(e=b.data.regeocode,e.addressComponent?c=e.addressComponent.adcode:e.aois&&e.aois.length>0&&(c=e.aois[0].adcode),d(c)):a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}var b=this,c=b.requestConfig;a.city?d(a.city):b.getWxLocation(a,function(a){e(a)})},AMapWX.prototype.getPoiAround=function(a){function d(d){var e={key:b.key,location:d,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.querytypes&&(e["types"]=a.querytypes),a.querykeywords&&(e["keywords"]=a.querykeywords),wx.request({url:"https://restapi.amap.com/v3/place/around",data:e,method:"GET",header:{"content-type":"application/json"},success:function(b){var c,d,e,f;if(b.data.status&&"1"==b.data.status){if(b=b.data,b&&b.pois){for(c=[],d=0;d<b.pois.length;d++)e=0==d?a.iconPathSelected:a.iconPath,c.push({latitude:parseFloat(b.pois[d].location.split(",")[1]),longitude:parseFloat(b.pois[d].location.split(",")[0]),iconPath:e,width:22,height:32,id:d,name:b.pois[d].name,address:b.pois[d].address});f={markers:c,poisData:b.pois},a.success(f)}}else a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}var b=this,c=b.requestConfig;a.location?d(a.location):b.getWxLocation(a,function(a){d(a)})},AMapWX.prototype.getStaticmap=function(a){function f(b){c.push("location="+b),a.zoom&&c.push("zoom="+a.zoom),a.size&&c.push("size="+a.size),a.scale&&c.push("scale="+a.scale),a.markers&&c.push("markers="+a.markers),a.labels&&c.push("labels="+a.labels),a.paths&&c.push("paths="+a.paths),a.traffic&&c.push("traffic="+a.traffic);var e=d+c.join("&");a.success({url:e})}var e,b=this,c=[],d="https://restapi.amap.com/v3/staticmap?";c.push("key="+b.key),e=b.requestConfig,c.push("s="+e.s),c.push("platform="+e.platform),c.push("appname="+e.appname),c.push("sdkversion="+e.sdkversion),c.push("logversion="+e.logversion),a.location?f(a.location):b.getWxLocation(a,function(a){f(a)})},AMapWX.prototype.getInputtips=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.location&&(d["location"]=a.location),a.keywords&&(d["keywords"]=a.keywords),a.type&&(d["type"]=a.type),a.city&&(d["city"]=a.city),a.citylimit&&(d["citylimit"]=a.citylimit),wx.request({url:"https://restapi.amap.com/v3/assistant/inputtips",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){b&&b.data&&b.data.tips&&a.success({tips:b.data.tips})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},AMapWX.prototype.getDrivingRoute=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.origin&&(d["origin"]=a.origin),a.destination&&(d["destination"]=a.destination),a.strategy&&(d["strategy"]=a.strategy),a.waypoints&&(d["waypoints"]=a.waypoints),a.avoidpolygons&&(d["avoidpolygons"]=a.avoidpolygons),a.avoidroad&&(d["avoidroad"]=a.avoidroad),wx.request({url:"https://restapi.amap.com/v3/direction/driving",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){b&&b.data&&b.data.route&&a.success({paths:b.data.route.paths,taxi_cost:b.data.route.taxi_cost||""})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},AMapWX.prototype.getWalkingRoute=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.origin&&(d["origin"]=a.origin),a.destination&&(d["destination"]=a.destination),wx.request({url:"https://restapi.amap.com/v3/direction/walking",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){b&&b.data&&b.data.route&&a.success({paths:b.data.route.paths})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},AMapWX.prototype.getTransitRoute=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.origin&&(d["origin"]=a.origin),a.destination&&(d["destination"]=a.destination),a.strategy&&(d["strategy"]=a.strategy),a.city&&(d["city"]=a.city),a.cityd&&(d["cityd"]=a.cityd),wx.request({url:"https://restapi.amap.com/v3/direction/transit/integrated",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){if(b&&b.data&&b.data.route){var c=b.data.route;a.success({distance:c.distance||"",taxi_cost:c.taxi_cost||"",transits:c.transits})}},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},AMapWX.prototype.getRidingRoute=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.origin&&(d["origin"]=a.origin),a.destination&&(d["destination"]=a.destination),wx.request({url:"https://restapi.amap.com/v4/direction/bicycling",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){b&&b.data&&b.data.data&&a.success({paths:b.data.data.paths})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},module.exports.AMapWX=AMapWX; | 
config/gdMapConfig.js
0 → 100644
config/tcMapConfig.js
deleted
100644 → 0
| 1 | <template> | 1 | <template> | 
| 2 | - <view> | ||
| 3 | - <!-- 公共组件-每个页面必须引入 --> | ||
| 4 | - <public-module></public-module> | ||
| 5 | - <map style="width: 100%; min-height: 100vh;" :markers="markers" :scale="scale" :latitude="getPos.latitude" :longitude="getPos.longitude"></map> | 2 | + <view class="map"> | 
| 3 | + <map | ||
| 4 | + id="my-map" | ||
| 5 | + ref="my-map" | ||
| 6 | + class="my-map" | ||
| 7 | + :style="{ height: allScreen - 44 + 'px' }" | ||
| 8 | + :latitude="myLatitude" | ||
| 9 | + :longitude="myLongitude" | ||
| 10 | + :markers="makers" | ||
| 11 | + enable-3D="true" | ||
| 12 | + show-compass="true" | ||
| 13 | + show-location="true" | ||
| 14 | + ></map> | ||
| 6 | </view> | 15 | </view> | 
| 7 | </template> | 16 | </template> | 
| 8 | 17 | ||
| 9 | <script> | 18 | <script> | 
| 10 | -import { mapUrl, mapKay } from '@/config/tcMapConfig.js'; | 19 | +const amapFile = require('@/config/amap-wx.js'); | 
| 20 | +import { gdMapRequiredKey } from '@/config/gdMapConfig.js'; | ||
| 11 | 21 | ||
| 12 | export default { | 22 | export default { | 
| 13 | - components: {}, | ||
| 14 | data() { | 23 | data() { | 
| 15 | return { | 24 | return { | 
| 16 | - getPos: { | ||
| 17 | - longitude: 0, | ||
| 18 | - latitude: 0 | ||
| 19 | - }, | ||
| 20 | - scale: 15, | ||
| 21 | - markers: [ | 25 | + mapContext: null, | 
| 26 | + allScreen: '', | ||
| 27 | + myLatitude: 0, //纬度 | ||
| 28 | + myLongitude: 0, //经度 | ||
| 29 | + makers: [ | ||
| 22 | { | 30 | { | 
| 31 | + id: 1, | ||
| 23 | latitude: 0, | 32 | latitude: 0, | 
| 24 | - longitude: 0 | 33 | + longitude: 0, | 
| 34 | + iconPath: '../../static/location.png', | ||
| 35 | + width: '50px', | ||
| 36 | + height: '50px' | ||
| 25 | } | 37 | } | 
| 26 | ] | 38 | ] | 
| 27 | }; | 39 | }; | 
| 28 | }, | 40 | }, | 
| 29 | onLoad(e) { | 41 | onLoad(e) { | 
| 30 | - if (e.data != null) { | ||
| 31 | - const params = JSON.parse(e.data); | ||
| 32 | - if (params) this.getPos.longitude = params.longitude; | ||
| 33 | - this.getPos.latitude = params.latitude; | ||
| 34 | - this.markers[0].longitude = params.longitude; | ||
| 35 | - this.markers[0].latitude = params.latitude; | 42 | + let params = null; | 
| 43 | + if (e.data !== null) { | ||
| 44 | + params = JSON.parse(e.data); | ||
| 36 | } | 45 | } | 
| 46 | + let that = this; | ||
| 47 | + var myAmapFun = new amapFile.AMapWX({ key: gdMapRequiredKey }); | ||
| 48 | + that.getMyLocation(params.longitude, params.latitude); | ||
| 49 | + uni.getSystemInfo({ | ||
| 50 | + success: function(e) { | ||
| 51 | + that.allScreen = e.screenHeight; | ||
| 52 | + } | ||
| 53 | + }); | ||
| 37 | }, | 54 | }, | 
| 38 | - methods: {} | 55 | + onReady: function(res) { | 
| 56 | + this.mapContext = uni.createMapContext('my-map', this); | ||
| 57 | + }, | ||
| 58 | + methods: { | ||
| 59 | + getMyLocation(eLong, eLat) { | ||
| 60 | + let that = this; | ||
| 61 | + const newPos = this.bd_decrypt(eLong, eLat); | ||
| 62 | + that.myLatitude = newPos.lat; | ||
| 63 | + that.myLongitude = newPos.lng; | ||
| 64 | + that.makers[0].longitude = newPos.lng; | ||
| 65 | + that.makers[0].latitude = newPos.lat; | ||
| 66 | + if (newPos.lng == undefined || newPos.lat == undefined) { | ||
| 67 | + //如果没有位置信息则使用当前定位 | ||
| 68 | + getLocationFunc(); | ||
| 69 | + } | ||
| 70 | + const getLocationFunc = () => | ||
| 71 | + uni.getLocation({ | ||
| 72 | + type: 'gcj02', | ||
| 73 | + success: function(res) { | ||
| 74 | + that.myLatitude = res.latitude; | ||
| 75 | + that.myLongitude = res.longitude; | ||
| 76 | + } | ||
| 77 | + }); | ||
| 78 | + }, | ||
| 79 | + //服务端返回的是百度地图坐标系,百度地图坐标系转换为高德地图坐标系(重要,不然会造成位置误差) | ||
| 80 | + bd_decrypt(bd_lng, bd_lat) { | ||
| 81 | + var X_PI = (Math.PI * 3000.0) / 180.0; | ||
| 82 | + var x = bd_lng - 0.0065; | ||
| 83 | + var y = bd_lat - 0.006; | ||
| 84 | + var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * X_PI); | ||
| 85 | + var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * X_PI); | ||
| 86 | + var gg_lng = z * Math.cos(theta); | ||
| 87 | + var gg_lat = z * Math.sin(theta); | ||
| 88 | + return { lng: gg_lng, lat: gg_lat }; | ||
| 89 | + } | ||
| 90 | + } | ||
| 39 | }; | 91 | }; | 
| 40 | </script> | 92 | </script> | 
| 41 | 93 | ||
| 42 | -<style lang="scss" scoped></style> | 94 | +<style scoped> | 
| 95 | +.my-map { | ||
| 96 | + width: 750rpx; | ||
| 97 | +} | ||
| 98 | +</style> | 
| @@ -88,9 +88,12 @@ | @@ -88,9 +88,12 @@ | ||
| 88 | "usingComponents": true, | 88 | "usingComponents": true, | 
| 89 | "permission": { | 89 | "permission": { | 
| 90 | "scope.userLocation": { | 90 | "scope.userLocation": { | 
| 91 | - "desc": "你的位置信息将用于小程序位置接口的效果展示" | 91 | + "desc": "如果没有位置信息则使用当前定位" | 
| 92 | } | 92 | } | 
| 93 | }, | 93 | }, | 
| 94 | + "requiredPrivateInfos": [ | ||
| 95 | + "getLocation" | ||
| 96 | + ], | ||
| 94 | "lazyCodeLoading": "requiredComponents", | 97 | "lazyCodeLoading": "requiredComponents", | 
| 95 | //开启分包优化 | 98 | //开启分包优化 | 
| 96 | "optimization": { | 99 | "optimization": { | 
| @@ -92,7 +92,15 @@ | @@ -92,7 +92,15 @@ | ||
| 92 | "path": "deviceDetailPage/devicePosition", | 92 | "path": "deviceDetailPage/devicePosition", | 
| 93 | "style": { | 93 | "style": { | 
| 94 | "navigationBarTitleText": "设备地理位置" | 94 | "navigationBarTitleText": "设备地理位置" | 
| 95 | - } | 95 | + }, | 
| 96 | + "permission": { | ||
| 97 | + "scope.userLocation": { | ||
| 98 | + "desc": "如果没有位置信息则使用当前定位" | ||
| 99 | + } | ||
| 100 | + }, | ||
| 101 | + "requiredPrivateInfos": [ | ||
| 102 | + "getLocation" | ||
| 103 | + ] | ||
| 96 | } | 104 | } | 
| 97 | ] | 105 | ] | 
| 98 | }, | 106 | }, | 
| @@ -131,14 +131,14 @@ export default { | @@ -131,14 +131,14 @@ export default { | ||
| 131 | getDeviceTotalData() { | 131 | getDeviceTotalData() { | 
| 132 | uni.$u.http.get('/yt/homepage/app').then(res => { | 132 | uni.$u.http.get('/yt/homepage/app').then(res => { | 
| 133 | if (res) { | 133 | if (res) { | 
| 134 | - this.deviceData.onLine = res.totalDevice.onLine; | ||
| 135 | - this.deviceData.unLine = res.totalDevice.offLine; | ||
| 136 | - this.deviceData.noActive = res.totalDevice.inActive; | ||
| 137 | - this.alertData.noHandle = res.totalAlarm.activedAlarm; | ||
| 138 | - this.alertData.doneHandle = res.totalAlarm.clearedAck; | ||
| 139 | - this.alertData.errorReport = res.totalAlarm.clearedUnack; | 134 | + this.deviceData.onLine = res.totalDevice?.onLine; | 
| 135 | + this.deviceData.unLine = res.totalDevice?.offLine; | ||
| 136 | + this.deviceData.noActive = res.totalDevice?.inActive; | ||
| 137 | + this.alertData.noHandle = res.totalAlarm?.activedAlarm; | ||
| 138 | + this.alertData.doneHandle = res.totalAlarm?.clearedAck; | ||
| 139 | + this.alertData.errorReport = res.totalAlarm?.clearedUnack; | ||
| 140 | //异步实时更新告警徽标数 | 140 | //异步实时更新告警徽标数 | 
| 141 | - this.updateBadgeTotal(res.totalAlarm.activedAlarm); | 141 | + this.updateBadgeTotal(res.totalAlarm?.activedAlarm); | 
| 142 | } | 142 | } | 
| 143 | }); | 143 | }); | 
| 144 | }, | 144 | }, | 
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30"> | 8 | <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30"> | 
| 9 | <block v-if="userInfo.isToken || userInfo.isThirdLogin"> | 9 | <block v-if="userInfo.isToken || userInfo.isThirdLogin"> | 
| 10 | <view @click.top="openPersonalInfo" class="u-m-r-20"> | 10 | <view @click.top="openPersonalInfo" class="u-m-r-20"> | 
| 11 | - <image class="avatar" mode="aspectFill" :src="!userInfo.avatar ? '../../static/logo.png' : userInfo.avatar || thirdObj.avatarUrl"></image> | 11 | + <image class="avatar" mode="aspectFill" :src="plateInfo.logo || userInfo.avatar || thirdObj.avatarUrl||'../../static/logo.png'"></image> | 
| 12 | </view> | 12 | </view> | 
| 13 | <view class="u-flex-1" @click.top="openPersonalInfo"> | 13 | <view class="u-flex-1" @click.top="openPersonalInfo"> | 
| 14 | <view class="nickName u-flex"> | 14 | <view class="nickName u-flex"> | 
| @@ -17,14 +17,14 @@ | @@ -17,14 +17,14 @@ | ||
| 17 | </view> | 17 | </view> | 
| 18 | <view v-if="userInfo.isThirdLogin" @click.stop="clickAccountFunc" class="detail"><text class="text">绑定账号</text></view> | 18 | <view v-if="userInfo.isThirdLogin" @click.stop="clickAccountFunc" class="detail"><text class="text">绑定账号</text></view> | 
| 19 | </view> | 19 | </view> | 
| 20 | - <view style="color:#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">{{ handlePhoneFunc(userInfo.phoneNumber || '') }}</view> | 20 | + <view style="color: #ffffff; font-size: 14px" v-if="userInfo.phoneNumber">{{ handlePhoneFunc(userInfo.phoneNumber || '') }}</view> | 
| 21 | </view> | 21 | </view> | 
| 22 | </block> | 22 | </block> | 
| 23 | <block v-else> | 23 | <block v-else> | 
| 24 | <view class="u-m-r-20" @click="openLoginFunc"> | 24 | <view class="u-m-r-20" @click="openLoginFunc"> | 
| 25 | <view class="avatar u-flex"><image class="avatar" mode="aspectFill" src="../../static/logo.png"></image></view> | 25 | <view class="avatar u-flex"><image class="avatar" mode="aspectFill" src="../../static/logo.png"></image></view> | 
| 26 | </view> | 26 | </view> | 
| 27 | - <view class="u-flex-1"><view @click="openLoginFunc" class="u-font-lg click-login login-btn ">请点击登录</view></view> | 27 | + <view class="u-flex-1"><view @click="openLoginFunc" class="u-font-lg click-login login-btn">请点击登录</view></view> | 
| 28 | </block> | 28 | </block> | 
| 29 | <view v-if="userInfo.isToken" @click="openPersonalInfo"><u-icon name="arrow-right" color="white" size="13"></u-icon></view> | 29 | <view v-if="userInfo.isToken" @click="openPersonalInfo"><u-icon name="arrow-right" color="white" size="13"></u-icon></view> | 
| 30 | </view> | 30 | </view> | 
| @@ -168,7 +168,7 @@ export default { | @@ -168,7 +168,7 @@ export default { | ||
| 168 | this.getOpenId = getApp().globalData.openId; | 168 | this.getOpenId = getApp().globalData.openId; | 
| 169 | }, | 169 | }, | 
| 170 | computed: { | 170 | computed: { | 
| 171 | - ...mapState(['userInfo']) | 171 | + ...mapState(['userInfo', 'plateInfo']) | 
| 172 | }, | 172 | }, | 
| 173 | methods: { | 173 | methods: { | 
| 174 | handlePhoneFunc(e) { | 174 | handlePhoneFunc(e) { | 
| @@ -177,7 +177,7 @@ export default { | @@ -177,7 +177,7 @@ export default { | ||
| 177 | const y = e.toString().replace(result, '$1****$2'); | 177 | const y = e.toString().replace(result, '$1****$2'); | 
| 178 | return y; | 178 | return y; | 
| 179 | }, | 179 | }, | 
| 180 | - ...mapMutations(['emptyUserInfo', 'setUserInfo']), | 180 | + ...mapMutations(['emptyUserInfo', 'setUserInfo', 'setPlateInfo']), | 
| 181 | // 跳转前判断登录 | 181 | // 跳转前判断登录 | 
| 182 | onTokenJump(url) { | 182 | onTokenJump(url) { | 
| 183 | this.judgeLogin(() => { | 183 | this.judgeLogin(() => { | 
| @@ -342,6 +342,12 @@ export default { | @@ -342,6 +342,12 @@ export default { | ||
| 342 | this.setUserInfo(res); | 342 | this.setUserInfo(res); | 
| 343 | } | 343 | } | 
| 344 | }); | 344 | }); | 
| 345 | + //储存平台信息 | ||
| 346 | + uni.$u.http.get('/yt/platform/get').then(res => { | ||
| 347 | + if (res) { | ||
| 348 | + this.setPlateInfo(res); | ||
| 349 | + } | ||
| 350 | + }); | ||
| 345 | }, | 351 | }, | 
| 346 | bindPhoneFunc() { | 352 | bindPhoneFunc() { | 
| 347 | this.bindPhone = true; | 353 | this.bindPhone = true; | 
| @@ -428,4 +434,4 @@ export default { | @@ -428,4 +434,4 @@ export default { | ||
| 428 | 434 | ||
| 429 | <style lang="scss" scoped> | 435 | <style lang="scss" scoped> | 
| 430 | @import './static/personal.scss'; | 436 | @import './static/personal.scss'; | 
| 431 | -</style> | 437 | +</style> | 
| @@ -5,8 +5,8 @@ | @@ -5,8 +5,8 @@ | ||
| 5 | <view class="u-flex login-main"> | 5 | <view class="u-flex login-main"> | 
| 6 | <view class="content"> | 6 | <view class="content"> | 
| 7 | <view class="hello login-text-muted">您好,</view> | 7 | <view class="hello login-text-muted">您好,</view> | 
| 8 | - | ||
| 9 | - <view class="hello-welcome login-text-muted">欢迎来到ThingsKit!</view> | 8 | + <!-- <view class="hello-welcome login-text-muted">欢迎来到ThingsKit!</view> --> | 
| 9 | + <view style="width:587rpx" class="text-clip hello-welcome login-text-muted">欢迎来到{{ plateInfo.name !== undefined ? plateInfo.name : 'ThingsKit' }}!</view> | ||
| 10 | </view> | 10 | </view> | 
| 11 | </view> | 11 | </view> | 
| 12 | 12 | ||
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | <view class="form-row u-flex"> | 17 | <view class="form-row u-flex"> | 
| 18 | <u-input v-model="loginForm.password" :password="showPassword" placeholder="请输入登录密码" border="bottom"> | 18 | <u-input v-model="loginForm.password" :password="showPassword" placeholder="请输入登录密码" border="bottom"> | 
| 19 | <template slot="suffix"> | 19 | <template slot="suffix"> | 
| 20 | - <view @click="showPasswordMode" style="padding:10rpx"> | 20 | + <view @click="showPasswordMode" style="padding: 10rpx"> | 
| 21 | <u-icon width="18" height="14" :name="showPassword ? '/static/eye-hide.png' : '/static/eye.png'"></u-icon> | 21 | <u-icon width="18" height="14" :name="showPassword ? '/static/eye-hide.png' : '/static/eye.png'"></u-icon> | 
| 22 | </view> | 22 | </view> | 
| 23 | </template> | 23 | </template> | 
| @@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
| 45 | </template> | 45 | </template> | 
| 46 | 46 | ||
| 47 | <script> | 47 | <script> | 
| 48 | -import { mapMutations, mapActions } from 'vuex'; | 48 | +import { mapMutations, mapActions, mapState } from 'vuex'; | 
| 49 | import { loginApp } from '@/config/login'; | 49 | import { loginApp } from '@/config/login'; | 
| 50 | import baseUrl from '@/config/baseUrl.js'; | 50 | import baseUrl from '@/config/baseUrl.js'; | 
| 51 | import WXBizDataCrypt from '@/config/WXBizDataCrypt.js'; | 51 | import WXBizDataCrypt from '@/config/WXBizDataCrypt.js'; | 
| @@ -75,9 +75,11 @@ export default { | @@ -75,9 +75,11 @@ export default { | ||
| 75 | } | 75 | } | 
| 76 | }); | 76 | }); | 
| 77 | }, | 77 | }, | 
| 78 | - | 78 | + computed: { | 
| 79 | + ...mapState(['plateInfo']) | ||
| 80 | + }, | ||
| 79 | methods: { | 81 | methods: { | 
| 80 | - ...mapMutations(['setUserInfo']), | 82 | + ...mapMutations(['setUserInfo', 'setPlateInfo']), | 
| 81 | ...mapActions(['updateBadgeTotal']), | 83 | ...mapActions(['updateBadgeTotal']), | 
| 82 | //微信授权登录 | 84 | //微信授权登录 | 
| 83 | //#ifdef MP-WEIXIN | 85 | //#ifdef MP-WEIXIN | 
| @@ -157,18 +159,23 @@ export default { | @@ -157,18 +159,23 @@ export default { | ||
| 157 | 159 | ||
| 158 | saveUserInfo() { | 160 | saveUserInfo() { | 
| 159 | //储存个人信息 | 161 | //储存个人信息 | 
| 160 | - | ||
| 161 | uni.$u.http.get('/yt/user/me/info').then(res => { | 162 | uni.$u.http.get('/yt/user/me/info').then(res => { | 
| 162 | if (res) { | 163 | if (res) { | 
| 163 | this.setUserInfo(res); | 164 | this.setUserInfo(res); | 
| 164 | } | 165 | } | 
| 165 | }); | 166 | }); | 
| 167 | + //储存平台信息 | ||
| 168 | + uni.$u.http.get('/yt/platform/get').then(res => { | ||
| 169 | + if (res) { | ||
| 170 | + this.setPlateInfo(res); | ||
| 171 | + } | ||
| 172 | + }); | ||
| 166 | }, | 173 | }, | 
| 167 | async getAlarmTotalData() { | 174 | async getAlarmTotalData() { | 
| 168 | const res = await uni.$u.http.get('/yt/homepage/app'); | 175 | const res = await uni.$u.http.get('/yt/homepage/app'); | 
| 169 | if (res) { | 176 | if (res) { | 
| 170 | //异步实时更新告警徽标数 | 177 | //异步实时更新告警徽标数 | 
| 171 | - this.updateBadgeTotal(res.totalAlarm.activedAlarm); | 178 | + this.updateBadgeTotal(res.totalAlarm?.activedAlarm); | 
| 172 | } | 179 | } | 
| 173 | }, | 180 | }, | 
| 174 | onSubmitFunc() { | 181 | onSubmitFunc() { | 
static/location.png
0 → 100644
4.86 KB
| @@ -2,7 +2,9 @@ export const state = { | @@ -2,7 +2,9 @@ export const state = { | ||
| 2 | //用户数据 | 2 | //用户数据 | 
| 3 | userInfo: {}, | 3 | userInfo: {}, | 
| 4 | //存储告警徽标数据 | 4 | //存储告警徽标数据 | 
| 5 | - badgeInfo: 0 | 5 | + badgeInfo: 0, | 
| 6 | + //平台信息 | ||
| 7 | + plateInfo:{} | ||
| 6 | }; | 8 | }; | 
| 7 | export const mutations = { | 9 | export const mutations = { | 
| 8 | //储存用户信息 | 10 | //储存用户信息 | 
| @@ -18,16 +20,32 @@ export const mutations = { | @@ -18,16 +20,32 @@ export const mutations = { | ||
| 18 | // #endif | 20 | // #endif | 
| 19 | } | 21 | } | 
| 20 | }, | 22 | }, | 
| 23 | + //储存平台信息 | ||
| 24 | + setPlateInfo(state, data) { | ||
| 25 | + if (data) { | ||
| 26 | + state.plateInfo = Object.assign({}, state.plateInfo, data); | ||
| 27 | + // #ifdef H5 | ||
| 28 | + window.sessionStorage.setItem('plateInfo', JSON.stringify(state.plateInfo)); | ||
| 29 | + // #endif | ||
| 30 | + // #ifndef H5 | ||
| 31 | + uni.setStorageSync('plateInfo', state.plateInfo); | ||
| 32 | + wx.setStorageSync('plateInfo', state.plateInfo); | ||
| 33 | + // #endif | ||
| 34 | + } | ||
| 35 | + }, | ||
| 21 | // 退出APP | 36 | // 退出APP | 
| 22 | emptyUserInfo(state) { | 37 | emptyUserInfo(state) { | 
| 23 | state.userInfo = {}; | 38 | state.userInfo = {}; | 
| 39 | + state.plateInfo = {}; | ||
| 24 | state.badgeInfo = 0; | 40 | state.badgeInfo = 0; | 
| 25 | // #ifdef H5 | 41 | // #ifdef H5 | 
| 26 | window.sessionStorage.removeItem("userInfo"); | 42 | window.sessionStorage.removeItem("userInfo"); | 
| 43 | + window.sessionStorage.removeItem("plateInfo"); | ||
| 27 | // #endif | 44 | // #endif | 
| 28 | // #ifndef H5 | 45 | // #ifndef H5 | 
| 29 | uni.removeStorageSync("userInfo"); | 46 | uni.removeStorageSync("userInfo"); | 
| 30 | uni.removeStorageSync('storagePre'); | 47 | uni.removeStorageSync('storagePre'); | 
| 48 | + uni.removeStorageSync('plateInfo'); | ||
| 31 | // #endif | 49 | // #endif | 
| 32 | }, | 50 | }, | 
| 33 | setBadgeInfo(state, payload) { | 51 | setBadgeInfo(state, payload) { |