quanwei
2 days ago 04102f7237efefa744090ed7c25f7b5d0807b679
mobile/pages/diy-page/diy-page.vue
@@ -4,7 +4,7 @@
      <view class="tc d-b-c  header"
         :style="topBarHeight() == 0 ? '': 'height:'+topBarHeight()+'px;padding-top:'+(topBarTop() + 5)+'px'">
         <view class="reg180" :style="topBarHeight() == 0 ? '': 'height:'+topBarHeight()+'px;'">
            <text   v-if="hasPage()" @click="goback"  class="icon iconfont icon-jiantou"></text>
            <text v-if="hasPage()" @click="goback" class="icon iconfont icon-jiantou"></text>
         </view>
         <view class="gray3 f28">{{page_info.params.name}}</view>
         <view class="gray3 m20" @click="showShare()"><text class="icon iconfont icon-share1"></text></view>
@@ -12,7 +12,7 @@
      <view :style="topBarHeight() == 0 ? '': 'height:'+topBarHeight()+'px;padding-top:'+(topBarTop() + 5)+'px'"
         class="ww100"></view>
      <!-- #endif -->
      <diy :diyItems="items"></diy>
      <diy :diyItems="items" :index_open_city="index_open_city"></diy>
      <!--底部弹窗-->
      <share :isMpShare="isMpShare" @close="closeBottmpanel"></share>
      <!--app分享-->
@@ -33,44 +33,66 @@
      data() {
         return {
            /*页面ID*/
            page_id:null,
            page_id: null,
            /*diy类别*/
            items:{},
            items: {},
            /*页面信息*/
            page_info:{},
            page_info: {},
            /*分享*/
            isMpShare: false,
            /*app分享*/
            isAppShare: false,
            index_open_city: 0,
            appParams: {
               title: '',
               summary: '',
               path: ''
            },
            url: '',
            longitude: 0,
            latitude: 0,
         }
      },
      onLoad(e) {
         this.page_id=e.page_id;
         this.getData();
         this.page_id = e.page_id;
         this.getAdds();
         //#ifdef H5
         this.url = window.location.href;
         //#endif
      },
      methods: {
         hasPage(){
         hasPage() {
            var pages = getCurrentPages();
            return pages.length > 1;
         },
         goback() {
            uni.navigateBack();
         },
         getAdds() {
            let self = this;
            uni.getLocation({
               type: 'wgs84',
               success: function(res) {
                  console.log('当前位置的经度:' + res.longitude);
                  console.log('当前位置的纬度:' + res.latitude);
                  uni.setStorageSync('longitude',res.longitude)
                  uni.setStorageSync('latitude',res.latitude)
                  self.longitude = res.longitude;
                  self.latitude = res.latitude;
                  self.getData();
               },fetch() {
                  self.getData();
               }
            })
         },
         /*获取数据*/
         getData(page_id) {
            let self = this;
            self._get('index/diy', {
               page_id: self.page_id,
               url: self.url
               url: self.url,
               longitude: self.longitude,
               latitude: self.latitude
            }, function(res) {
               self.page_info = res.data.page;
               self.items = res.data.items;
@@ -86,24 +108,24 @@
               //#endif
            });
         },
         /*设置页面*/
         setPage(page){
         setPage(page) {
            uni.setNavigationBarTitle({
                title: page.params.name
               title: page.params.name
            });
            let colors='#000000';
            if(page.style.titleTextColor=='white'){
            let colors = '#000000';
            if (page.style.titleTextColor == 'white') {
               //字母要小写
               colors='#ffffff'
               colors = '#ffffff'
            }
            uni.setNavigationBarColor({
                frontColor: colors,
                backgroundColor: page.style.titleBackgroundColor
               frontColor: colors,
               backgroundColor: page.style.titleBackgroundColor
            })
         },
         /*分享当前页面*/
         onShareAppMessage() {
@@ -120,7 +142,7 @@
         showShare() {
            let self = this;
            //#ifdef MP-WEIXIN
               return;
            return;
            //#endif
            //#ifndef APP-PLUS
            self.isMpShare = true;
@@ -151,4 +173,4 @@
<style>
</style>
</style>