123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- <template>
- <view :class="[index==0?'flex flex-column vh100 w100':'']">
- <view :class="[tabList.length>1?'u-flex-2':'u-flex-2','bg-white w100']" :style="'padding-top:'+height+'px;'">
- <view class="plr-36 flex">
-
- <view class="img-pic" @click="toMy">
- <image :src="token?'../../static/home-online.png':'../../static/home-offline.png'" mode=""></image>
- </view>
-
- <view class="img-logo">
- <image src="../../static/logo-title.png" mode=""></image>
- </view>
- <view class="" style="width: 76rpx;"></view>
- </view>
- <u-tabs :list="tabList" font-size="32" bg-color="#fff" height="90" active-color="#00C28E"
- inactive-color="#777" :is-scroll="false" :current="index" @change="change">
- </u-tabs>
- </view>
- <view class="u-flex-7 w100" v-show="current==0" style="height:10%">
- <map id="map" style="width: 100%; height: 100%;position: relative;" :latitude="latitude0"
- :longitude="longitude0" :markers="covers" :polyline="polyline" @regionchange="getCenterMap">
- <cover-image @click="toDetail" v-if="list.length>0&&list[0].status==0" class=""
- style="width: 100%;height: 80rpx;position: absolute;bottom: 20rpx;left: 0rpx;"
- src="../../static/home-1.png"></cover-image>
- <cover-image @click="toDetail" v-if="list.length>0&&(list[0].status==1||list[0].status==5)" class=""
- style="width: 100%;height: 80rpx;position: absolute;bottom: 20rpx;left: 0rpx;"
- src="../../static/home-2.png"></cover-image>
- <cover-image @click="toDetail" v-if="list.length>0&&list[0].status==4" class=""
- style="width: 100%;height: 80rpx;position: absolute;bottom: 20rpx;left: 0rpx;"
- src="../../static/home-3.png"></cover-image>
- <cover-image @click="toDetail" v-if="list.length>0&&list[0].status==2" class=""
- style="width: 100%;height: 80rpx;position: absolute;bottom: 20rpx;left: 0rpx;"
- src="../../static/home-4.png"></cover-image>
- <cover-image @click="toDetail" v-if="list.length>0&&list[0].status==3" class=""
- style="width: 100%;height: 80rpx;position: absolute;bottom: 20rpx;left: 0rpx;"
- src="../../static/home-5.png"></cover-image>
- <cover-view v-if="showTime" @click="showTime=false"
- style="width: 100%;height: 100%;background-color: rgba(0,0,0,.7);"></cover-view>
- <cover-image @click="goCenter" class=""
- style="width:100rpx;height: 100rpx;position: absolute;bottom: 120rpx;right: 10rpx;"
- src="../../static/now1.png"></cover-image>
- </map>
- </view>
- <view class="u-flex-7 w100" v-show="current==0">
- <indexAddress :location="longitude+','+latitude" @close="showTime=false" @showTime="showTime=true"
- :other="other" :showTime="showTime" :city="city"></indexAddress>
- </view>
- <sfindex v-show="current==1" class="w100"></sfindex>
- <hyindex v-show="current==2" :hylist="hylist" class="w100"></hyindex>
- </view>
- </template>
- <script>
- import amapFile from '../../libs/amap-wx.js'
- import Voice from '@/components/baidu.js';
- import {
- mapState
- } from 'vuex'
- export default {
- data() {
- return {
- index: 0,
- current: '',
- timer3: null,
- other: {},
- list: [],
- hylist: [],
- timer: null,
- showTime: false,
- amapPlugin: null,
- key: 'bb6f4ed802756f963b37c184ce4e9766',
- latitude: '',
- longitude: '',
- latitude1: '', //打开地图时的中心点
- longitude1: '', //打开地图时的中心点
- latitude0: "",
- longitude0: "",
- polyline: [],
- mapContext: null,
- appMap: null,
- scale: "16",
- driverCovers: {}
- }
- },
- computed: {
- ...mapState(["city","height","start","tabList","token"]),
- covers() {
- return [{
- id: 0,
- latitude: this.latitude,
- longitude: this.longitude,
- // #ifdef MP-WEIXIN
- iconPath: '../../static/now.png',
- // #endif
- // #ifndef MP-WEIXIN
- iconPath: '../../static/now2.png',
- // #endif
- title: '当前位置',
- width: 30,
- height: 45
- }]
- }
- },
- //分享
- onShareAppMessage(res) {
- if (res.from === 'button') { // 来自页面内分享按钮
- console.log(res.target)
- }
- return {
- }
- },
- onShareTimeline(res) {
- console.log(111111111);
- return {}
- },
- onReady() {
- this.mapContext = uni.createMapContext('map')
- },
- onLoad(option) {
- this.getpush()
- this.timer3 = setInterval(() => {
- if (this.tabList && this.tabList[0]) {
- this.current = this.tabList[0].id
- clearInterval(this.timer3)
- this.timer3 = null
- }
- }, 200)
- // 定位
- this.amapPlugin = new amapFile.AMapWX({
- key: this.key
- });
- uni.$on('other', (data) => {
- this.other = data
- })
- },
- onHide() {
- clearInterval(this.timer)
- this.timer = null
- },
- onUnload() {
- uni.$off('other')
- clearInterval(this.timer)
- this.timer = null
- },
- onShow() {
- this.getRegeo()
- this.timer = setInterval(() => {
- this.getList()
- }, 3000)
- },
- methods: {
- getpush: function() {
-
- },
- getCenterMap() {
- let _this = this
- // #ifdef MP-WEIXIN
- this.mapContext.getCenterLocation({
- success: (res) => {
- console.log(res);
- if (res.longitude != 0) {
- _this.longitude = res.longitude
- _this.latitude = res.latitude
- _this.mapContext.translateMarker({
- markerId: 0,
- destination: {
- longitude: res.longitude,
- latitude: res.latitude
- },
- duration: 1000,
- animationEnd() {
- //console.log(111111);
- }
- })
- _this.amapPlugin.getRegeo({
- location: res.longitude + ',' + res.latitude,
- success(data) {
- //console.log(data);
- let city;
- if (!_this.city) {
- if (typeof data[0].regeocodeData.addressComponent.city ==
- 'object') {
- city = data[0].regeocodeData.addressComponent.province
- } else {
- city = data[0].regeocodeData.addressComponent.city
- }
- }
- let start = {
- city: city,
- latitude: data[0].latitude,
- longitude: data[0].longitude,
- address: data[0].name,
- name: data[0].desc,
- flag: true
- }
- _this.$store.commit('getStart', start)
- }
- })
- }
- }
- })
- // #endif
- },
- goCenter() {
- this.mapContext.moveToLocation({
- longitude: this.longitude1,
- latitude: this.latitude1,
- longitude0: this.longitude1,
- latitude0: this.latitude1,
- success() {
- //console.log(11111111);
- }
- })
- },
- getList() {
- this.$http('/addons/ddrive/order/order_taking', {}, "POST").then(data => {
- this.list = data.data
- this.hylist = data.hy
- })
- },
- toDetail() {
- if (this.list.length == 1) {
- uni.navigateTo({
- url: '/pages/home/detail?id=' + this.list[0].id
- })
- } else {
- uni.navigateTo({
- url: '/pages/my/order/dj-order'
- })
- }
- },
- toAnquan() {
- uni.navigateTo({
- url: '/pages/home/security'
- })
- },
- change(index) {
- this.index = index;
- this.current = this.tabList[index].id;
- if (this.current == 2) {
- uni.$emit('price')
- }
- },
- toMy() {
- if (this.token) {
- uni.navigateTo({
- url: '/pages/my/index'
- })
- } else {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }
- },
- // 获取定位
- getRegeo() {
- let _this = this
- uni.showLoading({
- title: '获取定位信息中'
- });
- this.amapPlugin.getRegeo({
- success: (data) => {
- let city;
- if (!_this.city) {
- if (typeof data[0].regeocodeData.addressComponent.city == 'object') {
- city = data[0].regeocodeData.addressComponent.province
- } else {
- city = data[0].regeocodeData.addressComponent.city
- }
- _this.$store.commit('getCity', city)
- }
- _this.latitude = data[0].latitude
- _this.longitude = data[0].longitude
- _this.latitude1 = data[0].latitude
- _this.longitude1 = data[0].longitude
- _this.latitude0 = data[0].latitude
- _this.longitude0 = data[0].longitude
- if (!_this.start.name) {
- let start = {
- city: city,
- latitude: data[0].latitude,
- longitude: data[0].longitude,
- address: data[0].name,
- name: data[0].desc,
- flag: true
- }
- _this.$store.commit('getStart', start)
- }
- uni.hideLoading();
- },
- fail: (msg) => {
- uni.showToast({
- title: '没有开启位置权限',
- icon: 'none'
- })
- }
- });
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .img-pic {
- image {
- width: 76rpx;
- height: 76rpx;
- }
- }
- .img-logo {
- image {
- width: 168rpx;
- height: 42rpx;
- }
- }
- </style>
|