<template> <view class="page"> <!-- 用户首页显示 --> <view class="useryonghu"> <u-navbar :is-back="false" title="首页" :border-bottom="false" :background="bgc" title-color='#fff' title-size='44' height='58'></u-navbar> <view class="ditu"> <view class="dtxs"> <map class='map' :latitude="latitude" :longitude="longitude" @markertap="handleMarkerClick" @scale="onMapScaleChange" :show-location="true" :markers="covers" :scale="mapScale" /> </view> <view class="fujin"> <image src="https://api.ccttiot.com/smartmeter/img/static/u7HPhEwbIJqbLRpImBON" mode="" @click="btnindex(5)"></image> <image src="https://api.ccttiot.com/smartmeter/img/static/uGVN2tOaCq2hiWKy1cYl" mode="" @click="btnindex(6)" v-if="isMch"></image> <image src="https://api.ccttiot.com/smartmeter/img/static/uzSmYNgLYJRMEmo4TWyA" mode="" @click="btnindex(7)" style="width: 58rpx;height: 58rpx;position: fixed;top: 940rpx;right: 60rpx;"></image> </view> <view class="tubiao"> <view class="gr" @click="btnindex(1)"> <image src="https://api.ccttiot.com/smartmeter/img/static/uJBKoGWpRH2lM1NpQU0I" mode="" style="width: 96rpx;height:98rpx;"></image> <!-- 个人中心 --> </view> <view class="gr" @click="btnindex(2)"> <image src="https://api.ccttiot.com/smartmeter/img/static/u8rWtdPtHabALkII23Zr" mode="" style="width: 96rpx;height:102rpx;"></image> <!-- 我的订单 --> </view> <view class="gr" @click="btnindex(3)"> <image src="https://api.ccttiot.com/smartmeter/img/static/uphoDfOVnT6VEyj6glfF" mode="" style="width: 96rpx;height:98rpx;"></image> <!-- 附近门店 --> </view> <view class="gr" @click="btnindex(4)"> <image src="https://api.ccttiot.com/smartmeter/img/static/uBN46m7mPVlbbPth80FC" mode="" style="width: 96rpx;height:94rpx;"></image> <!-- 联系客服 --> </view> </view> <view class="guangg"> <image :src="imgad" mode=""></image> </view> <view class="saoma" @click="scanQRCode"> <view> <image src="https://api.ccttiot.com/smartmeter/img/static/uBh15vzRx6gV0wRQj7gi" mode=""></image> 扫一扫 </view> </view> </view> <view class="tip_box" v-if="czflag"> <view class="top"> <view class="txt"> 系统检测到您的设备未联网或者为蓝牙版本,金额充值失败,请靠近设备进行蓝牙充值 </view> </view> <view class="bot"> <view class="bot_left" @click="czflag = false"> 取消 </view> <view class="bot_right" @click="tocz()"> 蓝牙充值 </view> </view> </view> </view> </view> </template> <script> export default { data() { return { params: { year: true, month: true, day: true, hour: false, minute: false, second: false }, dateindex: 1, latitude: '', // 初始纬度 longitude: '', // 初始经度 covers: [], // 覆盖物数组 jinweidu: '', userType: '', isMch: false, imgad: '', mapScale: 15, czflag:false, datetime:0, dingobj:'' }; }, onLoad() { // this.initOtherCovers(); // 初始化其他覆盖物 }, onShow() { this.logins(); this.getad() this.gethuidaio() }, methods: { onMapScaleChange(e) { // console.log(this.covers,'eeeeeeeee'); this.mapScale = e.detail.scale; // 更新当前缩放级别 this.getMyLocation() // this.covers.forEach(marker => { // marker.label.content = this.mapScale > 13 ? marker.label.content : ''; // }); }, scanQRCode() { uni.scanCode({ onlyFromCamera: true, scanType: ['qrCode'], success: res => { function getQueryParam(url, paramName) { let regex = new RegExp(`[?&]${paramName}=([^&]*)`); let results = regex.exec(url); return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null; } let sceneValue = res.result let decodedValue = decodeURIComponent(sceneValue); let id = getQueryParam(decodedValue, 'deviceNo') this.$u.get(`/app/device/${id}/withSuitList`).then((res) => { if (res.code == 200) { uni.navigateTo({ url: '/page_components/fuwu/index?id=' + id }) } }) }, fail: err => { console.error('扫描失败:', err); uni.showToast({ title: '扫描失败', icon: 'none' }); } }); }, getad() { this.$u.get("/app/ad").then((res) => { if (res.code == 200) { this.imgad = res.data.picture } }) }, btnindex(num) { if (num == 2) { uni.navigateTo({ url: '/page_fenbao/statulist/question/index' }) } else if (num == 3) { uni.navigateTo({ url: '/page_fenbao/statulist/about/index' }) } else if (num == 1) { uni.navigateTo({ url: '/page_fenbao/statulist/myorder/index' }) } else if (num == 4) { uni.navigateTo({ url: '/page_fenbao/statulist/merchant/index' }) } else if (num == 5) { uni.navigateTo({ url: '/page_fenbao/statulist/nearby/index' }) } else if (num == 6) { uni.switchTab({ url: '/pages/index/index' }) } else if (num == 7) { uni.navigateTo({ url: '/page_fenbao/statulist/fault/yichang/index' }) } }, getMyLocation() { uni.getLocation({ type: 'wgs84', success: (res) => { // console.log('我的位置:', res); this.latitude = res.latitude; this.longitude = res.longitude; this.jinweidu = this.longitude + ',' + this.latitude; // 请求附近的店铺 this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 1000).then( res => { if (res.code == 200) { // console.log(res); // 假设返回的店铺数据在res.rows中,并且每个店铺有latitude和longitude字段 res.data.forEach(item => { const shopCover = { id: parseFloat(item.storeId), latitude: item.lat, longitude: item.lng, width: 25, height: 30, iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', // 你可以为每个店铺指定不同的图标 label: { content: item.name, // anchorX:-20, textAlign: 'center' } }; this.covers.push(shopCover); // 将店铺覆盖物添加到数组中 }); } }); }, fail: (err) => { console.error('获取位置失败:', err); } }); }, handleMarkerClick(event) { // console.log(event); const markerId = event.markerId; uni.navigateTo({ url: '/page_user/mapditu/index?markerId=' + markerId }) }, logins() { if (uni.getStorageSync('userType')) { this.userType = uni.getStorageSync('userType') this.userType = '01' if (this.userType == '01') { this.getDeviceList() } else if (this.userType == '00') { this.getdevice() } } else { } this.getuserinfo() }, getuserinfo() { this.$u.get("/app/user/userInfo").then((res) => { if (res.code == 200) { this.isMch = res.data.isMch uni.setStorageSync('userType', res.data.userType) this.userType = res.data.userType if (this.userType == '01') { this.getDeviceList() } else if (this.userType == '00') { this.getdevice() } } else { this.jmlogin() } }); }, jmlogin() { let taht = this wx.login({ success(res) { if (res.code) { let data = { loginCode: res.code, }; taht.$u.post('/app/auth/wxLogin', data).then(res => { if (res.code == 10003) { // uni.navigateTo({ // url: '/pages/login/login' // }) } else if (res.code == 200) { uni.setStorageSync('token', res.token); taht.logins() } }); } }, }); }, gethuidaio(){ this.$u.get('/app/bill/recharge/device/fail/list').then(res => { if(res.code == 200){ if(res.data.length > 0){ this.czflag = true this.dingobj = res.data }else{ uni.removeStorageSync('time') } } }) }, tocz(){ this.czflag = false uni.navigateTo({ url:'/page_fenbao/chongzhi?dingobj=' + JSON.stringify(this.dingobj) }) }, }, mounted() { this.getMyLocation(); // 获取并设置自身位置的覆盖物 } }; </script> <style lang="scss"> /deep/ .u-title{ padding-bottom: 41rpx; } /deep/ .u-icon__icon{ padding-bottom: 41rpx; } /deep/ .map { width: 100%; height: 100%; } .dateactive { background: #E1F3ED; } page { // background-color: ; background: linear-gradient(180deg, #8883F0 0%, rgba(255, 255, 255, 0) 100%); border-radius: 0rpx 0rpx 0rpx 0rpx; } .page { width: 750rpx; padding-left: 34rpx; padding-right: 34rpx; box-sizing: border-box; height: 100%; // 代理样式 .tip_box{ position: fixed; left: 72rpx; top: 700rpx; width: 610rpx; background: #F7FAFE; border-radius: 30rpx 30rpx 30rpx 30rpx; z-index: 10000000; .top{ padding: 52rpx 38rpx 42rpx 36rpx; .txt{ width: 100%; text-align: center; font-weight: 500; font-size: 32rpx; color: #3D3D3D; } } .bot{ border-top: 2rpx solid #D8D8D8 ; display: flex; flex-wrap: nowrap; height: 100%; .bot_left{ width: 50%; height: 98rpx; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 36rpx; color: #3D3D3D; } .bot_right{ width: 50%; height: 98rpx; display: flex; align-items: center; justify-content: center; border-left: 2rpx solid #D8D8D8 ; font-weight: 500; font-size: 36rpx; color: #8883F0; } } } .userdaili { .gongneng { width: 680rpx; height: 304rpx; background: #FFFFFF; border-radius: 24rpx 24rpx 24rpx 24rpx; padding: 0 50rpx; box-sizing: border-box; .icons { display: inline-block; width: 145rpx; text-align: center; image { margin-top: 34rpx; width: 50px; height: 50px; } } } .ordertongji { width: 680rpx; height: 342rpx; background: #FFFFFF; border-radius: 24rpx 24rpx 24rpx 24rpx; .shuju { display: flex; justify-content: space-between; padding: 0 40rpx; box-sizing: border-box; margin-top: 24rpx; .ddje { text-align: center; .shu { font-weight: 500; font-size: 40rpx; color: #3D3D3D; } .sb { margin-top: 20rpx; font-weight: 500; font-size: 20rpx; color: #3D3D3D; } } } .date { padding-left: 80rpx; padding-right: 80rpx; box-sizing: border-box; display: flex; justify-content: space-between; margin-top: 26rpx; text { padding: 6rpx 18rpx; box-sizing: border-box; background: #eee; border-radius: 10rpx 10rpx 10rpx 10rpx; font-size: 24rpx; color: #808080; } } .orderday { display: flex; justify-content: space-between; width: 100%; padding: 10rpx 12rpx; box-sizing: border-box; text { margin-right: 10rpx; border-radius: 20rpx; text-align: center; display: inline-block; width: 148rpx; height: 84rpx; text-align: center; line-height: 84rpx; } } } .dttitle { margin: 36rpx 0; font-weight: 500; font-size: 36rpx; color: #3D3D3D; } .zhanghu { margin-top: 32rpx; width: 680rpx; height: 264rpx; background: #FFFFFF; border-radius: 24rpx 24rpx 24rpx 24rpx; padding: 36rpx 38rpx; box-sizing: border-box; .zhtitle { display: flex; justify-content: space-between; .sj { display: flex; justify-content: space-between; text { font-size: 24rpx; color: #3D3D3D; } } .tx { font-size: 24rpx; color: #27D089; } } .zhje { margin-top: 20rpx; display: flex; justify-content: space-between; border-bottom: 1px solid #ccc; padding-bottom: 20rpx; text { font-weight: 500; font-size: 48rpx; color: #3D3D3D; } .btntx { width: 156rpx; height: 42rpx; background: linear-gradient(270deg, #54DAA1 0%, #19CD82 100%); border-radius: 40rpx 40rpx 40rpx 40rpx; font-size: 24rpx; color: #FFFFFF; text-align: center; line-height: 42rpx; margin-top: 10rpx; } } .buc { margin-top: 20rpx; font-size: 24rpx; color: #979797; } } } //样式结束 .title { font-weight: 500; font-size: 36rpx; color: #3D3D3D; line-height: 50rpx; text-align: left; font-style: normal; text-transform: none; } .guangg { image { border-radius: 30rpx; width: 680rpx; height: 238rpx; } } .saoma { width: 750rpx; height: 186rpx; background: #FFFFFF; position: fixed; bottom: 0; left: 0; padding-top: 38rpx; border-radius: 54rpx 54rpx 0 0; view { text-align: center; width: 676rpx; height: 102rpx; background: linear-gradient(270deg, #8883F0 0%, #8883F0 100%); border-radius: 54rpx 54rpx 54rpx 54rpx; font-weight: 500; font-size: 40rpx; color: #FFFFFF; margin: auto; line-height: 102rpx; } image { width: 56rpx; height: 56rpx; vertical-align: middle; margin-right: 10rpx; margin-bottom: 10rpx; } } .ditu { width: 100%; height: 980rpx; background: #FFFFFF; border-radius: 38rpx 38rpx 38rpx 38rpx; // margin-top: 34rpx; padding-top: 16rpx; .fujin { position: fixed; top: 940rpx; padding-left: 30rpx; image { width: 210rpx; height: 62rpx; } } .dtxs { width: 642rpx; height: 812rpx; margin: auto; } .tubiao { display: flex; justify-content: space-between; padding: 0 50rpx; box-sizing: border-box; padding-top: 20rpx; padding-bottom: 24rpx; .gr { text-align: center; width: 100%; font-weight: 400; font-size: 24rpx; color: #3D3D3D; image { display: block; margin: auto; margin-bottom: 14rpx; } } } } } </style>