Browse Source

优化代码,添加分享

liguorui 6 years ago
parent
commit
c16c623925

+ 8 - 11
app.js

@@ -34,16 +34,13 @@ App({
     //   }
     // })
     wx.getSystemInfo({
-      success:function(res) {        
-        _self.globalData.pxscale = res.pixelRatio;
-        _self.globalData.scale = 750/res.windowWidth;
-        _self.globalData.windowHeight = res.windowHeight;
-        _self.globalData.windowh = res.windowHeight*_self.globalData.scale;
-        _self.globalData.Authorization = false;
-      }
-    });
-    wx.getSystemInfo({
-        success: function(res) {
+        success:function(res) {        
+            // _self.globalData.pxscale = res.pixelRatio;
+            // _self.globalData.scale = 750/res.windowWidth;
+            // _self.globalData.windowHeight = res.windowHeight;
+            // _self.globalData.windowh = res.windowHeight*_self.globalData.scale;
+            // _self.globalData.Authorization = false;
+
             var model = res.model
             if (model.search('iPhone X') != -1){
                 _self.globalData.isIpx = true;
@@ -51,7 +48,7 @@ App({
                 _self.globalData.isIpx = false;
             }
         }
-    })
+    });
   },
   globalData: {
     //serverpath:"https://api.jasonre.cn"

+ 2 - 1
app.wxss

@@ -1,6 +1,7 @@
 /**app.wxss**/
 page{
   font-family: PingFangSC-Regular,NotoSansHans-Regular;
+  height: 100%;
 }
 .navigator-hover{
   background-color: transparent;
@@ -62,7 +63,7 @@ page{
 .page_footer{
   height: 98rpx;
   z-index:100;
-  position: fixed;
+  position: absolute;
   bottom: 0rpx;
   width: 100%;
   display: flex;

+ 19 - 0
common/share.js

@@ -0,0 +1,19 @@
+export default {
+  onShareAppMessage: function(){
+    return {
+      title: '第一好车,物美价廉淘辆车',
+      //imageUrl: "",
+      success: (res) => {
+        wx.showToast({
+          title:"转发成功!"
+        })
+      },
+      fail: (res) => {
+        wx.showToast({
+          title:"转发失败!",
+          icon:"none"
+        })
+      }
+    }
+  }
+}

+ 30 - 2
common/stylemap.js

@@ -1,8 +1,36 @@
 var app = getApp();
-var headerheight = 170
+var windowstyle = {
+
+}
+wx.getSystemInfo({
+    success:function(res) {   
+
+        // _self.globalData.pxscale = res.pixelRatio;
+        // _self.globalData.scale = 750/res.windowWidth;
+        // _self.globalData.windowHeight = res.windowHeight;
+        // _self.globalData.windowh = res.windowHeight*_self.globalData.scale;
+        // _self.globalData.Authorization = false;
+
+		windowstyle.pxscale = res.pixelRatio;
+        windowstyle.scale = 750/res.windowWidth;
+        windowstyle.windowHeight = res.windowHeight;
+        windowstyle.windowh = res.windowHeight*windowstyle.scale;
+        windowstyle.Authorization = false;
+        // var model = res.model
+        // if (model.search('iPhone X') != -1){
+        //     _self.globalData.isIpx = true;
+        // }else{
+        //     _self.globalData.isIpx = false;
+        // }
+    }
+});
+var headerheight = 170;
 export default {
+	"windowh": windowstyle.windowh,
+	"windowHeight": windowstyle.windowHeight,
+	"pxscale":windowstyle.pxscale,
 	"headerheight":headerheight,
 	"topsearchheight":78,
 	"footerheight":app.globalData.isIpx?140:98,
-	"contentheight":app.globalData.windowHeight-headerheight/app.globalData.scale
+	"contentheight":windowstyle.windowHeight-headerheight/windowstyle.scale
 }

+ 4 - 4
components/brandlist/brandlist.wxml

@@ -27,7 +27,7 @@
   <scroll-view
     bindscroll="brandScroll"
     scroll-y=true
-    style="height: {{windowh-headerheight}}rpx"
+    style="height: {{contentheight}}px"
     scroll-into-view ="{{scrolltoinit}}"
   >
     <view class="brandw_list">
@@ -75,7 +75,7 @@
 <scroll-view
   class="brand_serieslist"
   scroll-y=true
-  style="height: {{windowh-headerheight}}rpx; {{show&&serieslist?'left:0rpx;':''}}"
+  style="height: {{contentheight}}px; {{show&&serieslist?'left:0rpx;':''}}"
 >
   <view class="series_lelong">
       <view
@@ -150,9 +150,9 @@
     <view class="brandw_title_w">车型</view>
   </view>
   <page-scroll 
-    styleSheet="height:{{windowh-headerheight}}rpx;"
+    styleSheet="height:{{contentheight}}px;"
     scroll-y=true
-    style="height: {{windowh-headerheight}}rpx;"
+    style="height: {{contentheight}}px;"
   >
     <view wx:if="{{modellist.length>0}}" class="brandw_list">
       <block wx:for="{{modellist}}" wx:key="car_model_id">

+ 0 - 4
module/footer.wxml

@@ -1,9 +1,5 @@
 <template name="footer">
   <view 
-    class="page_footer_place"
-    style="height:{{footerheight}}rpx;"
-    ></view>
-  <view 
     class="page_footer"
     style="height:{{footerheight}}rpx;"
     >

+ 1 - 1
module/logs/logs.wxml

@@ -1,6 +1,6 @@
 <view 
 	class="logs_content"
-	style="left:{{openlog?'0rpx':'100%'}};"
+	style="left:{{openlog?'0rpx':'100%'}}; height:{{windowHeight}}px"
 >
 	<image 
 		class="logs_back"

+ 1 - 1
pages/buy/brandlist.wxml

@@ -60,7 +60,7 @@
     <scroll-view
       class="brand_serieslist"
       scroll-y=true
-      style="height: {{windowh-headerheight}}rpx; {{serieslist?'right:0rpx;':''}}"
+      style="height: {{contentheight}}px; {{serieslist?'right:0rpx;':''}}"
     >
       <view class="series_lelong">
           <view

+ 1 - 1
pages/buy/buy.js

@@ -12,7 +12,7 @@ Page({
    * 页面的初始数据
    */
   data: {
-    windowh: app.globalData.windowh,
+    
     list:false,
     limit:10,
     pageindex:0,

+ 8 - 4
pages/buy/buy.wxml

@@ -68,11 +68,15 @@
       </block>
     </view>
   </view>
-  <template 
-    is="footer"
-    data="{{local:1,footerheight:footerheight}}"
-  />
+  <view 
+    class="page_footer_place"
+    style="height:{{footerheight}}rpx;"
+    ></view>
 </page-scroll>
+<template 
+  is="footer"
+  data="{{local:1,footerheight:footerheight}}"
+/>
 <!--筛选品牌模块-->
 <brandlist
   brandrecommend = "{{brandrecommend}}"

+ 1 - 1
pages/buy/more.wxml

@@ -19,7 +19,7 @@
     <view class="brandw_title_w">更多筛选</view>
   </view>
   <page-scroll 
-    styleSheet="height:{{windowh-headerheight}}rpx;"
+    styleSheet="height:{{contentheight}}px;"
     scroll-y=true
   >
     <view class="wheres_more_i">

+ 18 - 1
pages/cardetail/cardetail.js

@@ -15,7 +15,7 @@ Page(Object.assign({
    * 页面的初始数据
    */
   data: {
-    windowh: app.globalData.windowh,
+    
     collocatetype:[{
       label:"基本参数",
       name:"jiben"
@@ -346,5 +346,22 @@ Page(Object.assign({
     item.opensub = !item.opensub;
     check_info[obj.index]._child[obj.indext] = item;
     this.setData({detail:Object.assign({},this.data.detail,{check_info:check_info})});
+  },
+  onShareAppMessage: function(){
+    return {
+      title: this.data.name,
+      imageUrl: this.data.detail.imgs[0],
+      success: (res) => {
+        wx.showToast({
+          title:"转发成功!"
+        })
+      },
+      fail: (res) => {
+        wx.showToast({
+          title:"转发失败!",
+          icon:"none"
+        })
+      }
+    }
   }
 },logs))

+ 2 - 2
pages/cardetail/cardetail.wxml

@@ -11,7 +11,7 @@
 />
 <swc-scroll 
   className="content"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   scroll-y="{{openlog?'false':'true'}}"
   scrollitem="{{scrollitem}}"
   bind:swc="swcItem"
@@ -363,7 +363,7 @@
 		<view class="check_title_w">检测报告</view>
 	</view>
 	<page-scroll 
-		styleSheet="height:{{windowh-headerheight}}rpx;"
+		styleSheet="height:{{contentheight}}px;"
   		scroll-y=true
 		class="cardetail_check_report">
 		<view class="checkw_result">{{detail.check_result}}

+ 1 - 1
pages/collect/collect.js

@@ -10,7 +10,7 @@ Page({
    * 页面的初始数据
    */
   data: { 
-    windowh: app.globalData.windowh, 
+     
     limit:10,
     pageindex:0,
     lock:false,

+ 1 - 1
pages/collect/collect.wxml

@@ -15,7 +15,7 @@
 > -->
 <page-scroll 
   className="conent"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   scroll-y="{{openlog?'false':'true'}}"
   bind:scrolltolower="{{hasloadall?'':'getCollect'}}"
 >

+ 1 - 1
pages/evaluate/evaluate.js

@@ -13,7 +13,7 @@ Page({
     
     getbrand:pathmap.getbrands,
     getseries:pathmap.carseries,
-    windowh: app.globalData.windowh,
+    
     area:{},
     areaselect:{},
     series:{},

+ 1 - 1
pages/evaluate/evaluate.wxml

@@ -5,7 +5,7 @@
 	/>
 <page-scroll 
 	className="content"
-	styleSheet="height:{{windowh-headerheight}}rpx;"
+	styleSheet="height:{{contentheight}}px;"
 	scroll-y="{{selectbar==''?'true':'false'}}"
 	bind:scrolltolower="{{hasloadall?'':'getMyBuy'}}"
 >

+ 1 - 1
pages/hot/hot.js

@@ -10,7 +10,7 @@ Page({
    * 页面的初始数据
    */
   data: { 
-    windowh: app.globalData.windowh, 
+     
     limit:10,
     lock:false,
     list:[],

+ 1 - 1
pages/hot/hot.wxml

@@ -7,7 +7,7 @@
 />
 <page-scroll 
   className="content"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   scroll-y="{{selectbar==''?'true':'false'}}"
   bindscrolltolower="{{hasloadall?'':'getHots'}}"
 >

+ 1 - 1
pages/hotdt/hotdt.wxml

@@ -5,7 +5,7 @@
 	/>
 <page-scroll 
   className="conent"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   scroll-y="true"
 >	
 	<view class="hotdt_c">

+ 4 - 4
pages/index/index.js

@@ -2,15 +2,15 @@
 //获取应用实例
 import {get,post} from "../../common/request.js"
 import stylemap from "../../common/stylemap"
+import share from "../../common/share"
 import pathmap from "../../common/pathmap"
 import bindTopSource from "../../common/topsource"
 import { retCartData} from "../../data/car"
 import bindSearch from "../../module/search/search.js"
 const app = getApp();
 
-Page({
-  data: {
-    windowh: app.globalData.windowh,
+Page(Object.assign({
+  data: {    
     banner:[],
     goodcars:[],
     recommended:[],
@@ -181,4 +181,4 @@ Page({
   // checkshowoutend:function(e){
 
   // }
-})
+},share))

+ 9 - 5
pages/index/index.wxml

@@ -143,9 +143,13 @@
       url="../buy/buy"
       class="show_more">加载更多 <image src="../../img/right.png"/></navigator>
     <image class="bottom_banner" src="../../img/banner.png"></image>
-    <template 
-      is="footer" 
-      data="{{local:0,footerheight:footerheight}}"
-    />  
-  </view>                                     
+  </view>   
+  <view 
+    class="page_footer_place"
+    style="height:{{footerheight}}rpx;"
+    ></view>                                  
 </page-scroll>
+<template 
+  is="footer" 
+  data="{{local:0,footerheight:footerheight}}"
+/>  

+ 1 - 1
pages/loans/loans.wxml

@@ -6,7 +6,7 @@
 />
 <page-scroll 
  className="content"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   scroll-y="{{selectbar==''?'true':'false'}}"
 >
 	<view>

+ 1 - 1
pages/mybuy/mybuy.js

@@ -11,7 +11,7 @@ Page({
    * 页面的初始数据
    */
   data: { 
-    windowh: app.globalData.windowh, 
+     
     limit:10,
     pageindex:0,
     lock:false,

+ 1 - 1
pages/mybuy/mybuy.wxml

@@ -6,7 +6,7 @@
 />
 <page-scroll 
   className="conent"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   bind:scrolltolower="{{hasloadall?'':'getMyBuy'}}"
 >
 

+ 1 - 1
pages/myloan/myloan.js

@@ -10,7 +10,7 @@ Page({
    * 页面的初始数据
    */
   data: {
-    windowh: app.globalData.windowh,
+    
     timetorate:{
       "12":"rates_a",
       "24":"rates_b",

+ 1 - 1
pages/myloan/myloan.wxml

@@ -6,7 +6,7 @@
 />
 <page-scroll 
   className="content"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   scroll-y="{{selectbar==''?'true':'false'}}"
 >
 	<view class="myloan_con_c">

+ 1 - 1
pages/mysuggest/mysuggest.js

@@ -9,7 +9,7 @@ Page({
    * 页面的初始数据
    */
   data: {
-    windowh: app.globalData.windowh, 
+     
     value:""
   },
 

+ 1 - 1
pages/mysuggest/mysuggest.wxml

@@ -6,7 +6,7 @@
 	/>
 <page-scroll 
   className="content"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   scroll-y="{{selectbar==''?'true':'false'}}"
 >
 	<view class="mysuggest_c">

+ 1 - 1
pages/orderdetail/orderdetail.js

@@ -11,7 +11,7 @@ Page({
    * 页面的初始数据
    */
   data: {
-    windowh: app.globalData.windowh, 
+     
   
   },
 

+ 1 - 1
pages/orderdetail/orderdetail.wxml

@@ -6,7 +6,7 @@
 />
 <page-scroll 
   className="conent"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
 >
 	<view class="order_info">
 		<view class="order_info_t">

+ 1 - 1
pages/sell/sell.js

@@ -13,7 +13,7 @@ Page({
   data: {  
     getbrand:pathmap.getbrands,
     getseries:pathmap.carseries,
-    windowh: app.globalData.windowh,
+    
     area:{},
     areaselect:{},
     series:{},

+ 10 - 6
pages/sell/sell.wxml

@@ -6,7 +6,7 @@
 	/>
 <page-scroll 
   className="conent"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   scroll-y="{{selectbar==''?'true':'false'}}"
   bindscrolltolower="{{hasloadall?'':'getMyBuy'}}"
 >
@@ -204,12 +204,16 @@
   		class="sub_sell"
   		bindtap="subSell"
   		>提交预约</view>
-  	<image class="sell_bottom_banner" src="../../img/sell.png"/>
-  	<template 
-      is="footer" 
-      data="{{local:2,footerheight:footerheight}}"
-    />  
+  	<image class="sell_bottom_banner" src="../../img/sell.png"/> 
+  <view 
+    class="page_footer_place"
+    style="height:{{footerheight}}rpx;"
+    ></view>
 </page-scroll>
+<template 
+  is="footer" 
+  data="{{local:2,footerheight:footerheight}}"
+/> 
 <brandlist
   getbrand="{{getbrand}}"
   getseries="{{getseries}}"

+ 1 - 1
pages/shop/shop.js

@@ -11,7 +11,7 @@ Page({
    * 页面的初始数据
    */
   data: {
-    windowh: app.globalData.windowh,
+    
     offset:0,
     limit:10,
     lock:false,

+ 1 - 1
pages/shop/shop.wxml

@@ -7,7 +7,7 @@
 />
 <page-scroll 
   className="content"
-  styleSheet="height:{{windowh-headerheight}}rpx;"
+  styleSheet="height:{{contentheight}}px;"
   scroll-y
   bind:scrolltolower="{{hasloadall?'':'loadCars'}}"
 >

+ 1 - 1
pages/test/test.js

@@ -10,7 +10,7 @@ Page({
    * 页面的初始数据
    */
   data: { 
-    windowh: app.globalData.windowh, 
+     
     limit:10,
     lock:false,
     list:[],

+ 8 - 4
pages/usercenter/usercenter.wxml

@@ -44,9 +44,13 @@
 		bindtap="logOut"
 		class="usercenter_logout"
 	>退出登录</view>
-	<template 
-      is="footer" 
-      data="{{local:3,footerheight:footerheight}}"
-    /> 
+  <view 
+    class="page_footer_place"
+    style="height:{{footerheight}}rpx;"
+    ></view>
 </page-scroll>
+<template 
+  is="footer" 
+  data="{{local:3,footerheight:footerheight}}"
+/> 
 <include src="../../module/logs/logs.wxml"/>