huanggang hace 7 años
padre
commit
d39b305c1e

+ 1 - 1
app.json

@@ -13,7 +13,7 @@
   ],
   "window": {
     "backgroundTextStyle": "dark",
-    "navigationBarBackgroundColor": "#FF6760",
+    "navigationBarBackgroundColor": "#eb4e4f",
     "navigationBarTitleText": "熊猫美妆",
     "navigationBarTextStyle": "white"
   },

+ 86 - 0
jsUrlHelper.js

@@ -0,0 +1,86 @@
+let jsUrlHelper = {
+  getUrlParam: function (url, ref) {
+    var str = "";
+
+    // 如果不包括此参数
+    if (url.indexOf(ref) == -1)
+      return "";
+
+    str = url.substr(url.indexOf('?') + 1);
+
+    arr = str.split('&');
+    for (i in arr) {
+      var paired = arr[i].split('=');
+
+      if (paired[0] == ref) {
+        return paired[1];
+      }
+    }
+
+    return "";
+  },
+  putUrlParam: function (url, ref, value) {
+
+    // 如果没有参数
+    if (url.indexOf('?') == -1)
+      return url + "?" + ref + "=" + value;
+
+    // 如果不包括此参数
+    if (url.indexOf(ref) == -1)
+      return url + "&" + ref + "=" + value;
+
+    var arr_url = url.split('?');
+
+    var base = arr_url[0];
+
+    var arr_param = arr_url[1].split('&');
+
+    for (i = 0; i < arr_param.length; i++) {
+
+      var paired = arr_param[i].split('=');
+
+      if (paired[0] == ref) {
+        paired[1] = value;
+        arr_param[i] = paired.join('=');
+        break;
+      }
+    }
+
+    return base + "?" + arr_param.join('&');
+  },
+  delUrlParam: function (url, ref) {
+    console.log(url);
+    // 如果不包括此参数
+    if (url.indexOf(ref) == -1)
+      return url;
+
+    var arr_url = url.split('?');
+
+    var base = arr_url[0];
+
+    var arr_param = arr_url[1].split('&');
+
+    var index = -1;
+
+    for (let i = 0; i < arr_param.length; i++) {
+
+      var paired = arr_param[i].split('=');
+
+      if (paired[0] == ref) {
+
+        index = i;
+        break;
+      }
+    }
+
+    if (index == -1) {
+      return url;
+    } else {
+      arr_param.splice(index, 1);
+      return base + "?" + arr_param.join('&');
+    }
+  }
+};
+
+
+module.exports = jsUrlHelper; 

+ 8 - 3
pages/components/blockItem/blockItem.js

@@ -18,7 +18,7 @@ Component({
    * 组件的初始数据
    */
   data: {
-
+    imgShow:false
   },
 
   /**
@@ -32,8 +32,7 @@ Component({
       if(!type)return;
       switch(type){
         case "url":{
-          let attr = encodeURIComponent(`${target_data}&title=${title}`);
-          console.log(attr);
+          let attr = encodeURIComponent(`${target_data}`);
           wx.navigateTo({
             url: '/pages/webView/webView?url='+attr
           })
@@ -61,6 +60,12 @@ Component({
           console.log(type+'类型找不到');
         }
       }
+    },
+    load(e){
+    
+      this.setData({
+        imgShow:true
+      });
     }
   }
 })

+ 10 - 3
pages/components/blockItem/blockItem.wxml

@@ -1,7 +1,14 @@
 <block wx:if="{{item_data.show_type == 'image' || item_data.type == 'image'}}">
-  <image bindtap="navigator" data-title="{{item_data.title}}" data-target="{{item_data.data}}" data-type="{{item_data.type}}" mode="scaleToFill" src="{{item_data.image}}" style="width:{{(item_data.width/1080*750)+'rpx'}}; height:{{(item_data.height/1080*750)+'rpx'}}"></image>
+  <image bindtap="navigator" data-title="{{item_data.title}}" data-target="{{item_data.data}}" data-type="{{item_data.type}}" mode="scaleToFill" src="{{item_data.image}}" style="width:{{(item_data.width/1080*750)+'rpx'}}; height:{{(item_data.height/1080*750)+'rpx'}}" lazy-load="true" class='{{imgShow? "show" : "hide"}}' bindload='load'></image>
 </block>
 
 <block wx:elif="{{item_data.show_type == 'brand'|| item_data.type == 'brand'}}">
-    <image src="{{item_data.image}}" mode='widthFix' style='min-height:250rpx;' data-title="{{item_data.title}}"></image>
-</block>
+    <image src="{{item_data.image}}" bindload='load' class='{{imgShow? "show" : "hide"}}' lazy-load="true" mode='widthFix' style='min-height:250rpx;' data-title="{{item_data.title}}"></image>
+</block>
+
+<block wx:elif="{{item_data.show_type == 'ugc'|| item_data.type == 'ugc'}}">
+    <view>
+        <text class='ugc_title'>{{item_data.title}}</text>
+    </view>
+    <image src="{{item_data.image}}" bindload='load' class='{{imgShow? "show" : "hide"}}' data-type="{{item_data.type}}" bindtap="navigator" data-target="{{item_data.data}}" mode='widthFix' lazy-load="true" data-title="{{item_data.title}}"></image>
+</block> 

+ 17 - 0
pages/components/blockItem/blockItem.wxss

@@ -0,0 +1,17 @@
+.ugc_title {
+    padding-left: 30rpx;
+    font-size: 32rpx;
+    height: 84rpx;
+    line-height: 84rpx;
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}
+.show {
+  opacity: 1;
+  transition: opacity .3s linear;
+  -webkit-transition: opacity .3s linear;
+}
+.hide {
+  opacity: 0;
+}

+ 2 - 1
pages/components/blockList/blockList.json

@@ -8,6 +8,7 @@
     "horizon":"../blocks/horizon/horizon",
     "home_goods": "../blocks/home_goods/home_goods",
     "homeGrid": "../blocks/homeGrid/homeGrid",
-    "homeWords":"../blocks/home_words/homeWords"
+    "homeWords":"../blocks/home_words/homeWords",
+    "homeTwo":"../blocks/home2/homeTwo"
   }
 }

+ 2 - 0
pages/components/blockList/blockList.wxml

@@ -3,6 +3,8 @@
     <divider wx:if="{{item.item_type == 'divider'}}" items="{{item}}"></divider> 
     <homeThree wx:if="{{item.item_type == 'home3'}}" items="{{item.items}}"></homeThree> 
     <homeOne wx:if="{{item.item_type == 'home1'}}" items="{{item.items}}" ></homeOne>
+    <homeOne wx:if="{{item.item_type == 'home5'}}" items="{{item.items}}"></homeOne>
+    <homeTwo wx:if="{{item.item_type == 'home2'}}" items="{{item.items}}"></homeTwo>
     <horizon wx:if="{{item.item_type == 'horizon' || item.item_type == 'horizon_goods'}}" items="{{item.items}}"></horizon>
     <home_goods wx:if="{{item.item_type == 'home_goods'}}" summery="{{summery}}" goods_items="{{item.items}}"></home_goods>
     <homeGrid wx:if="{{item.item_type == 'home_grid'}}" items="{{item.items}}"></homeGrid>

+ 1 - 0
pages/components/blocks/carousel/carousel.wxss

@@ -2,4 +2,5 @@
 image {
   width: 100%;
   height: 100%;
+  vertical-align: middle;
 }

+ 25 - 0
pages/components/blocks/home2/homeTwo.js

@@ -0,0 +1,25 @@
+// pages/components/blocks/home2/homeTwo.js
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    items: {
+      type: Array
+    }
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+
+  }
+})

+ 6 - 0
pages/components/blocks/home2/homeTwo.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "blockItem": "../../blockItem/blockItem"
+  }
+}

+ 14 - 0
pages/components/blocks/home2/homeTwo.wxml

@@ -0,0 +1,14 @@
+<!--pages/components/blocks/home2/homeTwo.wxml-->
+<view style='display:flex;'>
+    <view style='flex:1;' class='flex-1px-r'>
+        <blockItem item_data="{{items[0]}}"></blockItem>
+    </view>
+    <view style='display:flex;flex:1;flex-direction:column;'>
+      <view style='flex:1;' class='flex-1px-b'>
+        <blockItem item_data="{{items[1]}}"></blockItem>
+      </view>
+      <view style='flex:1;'>
+        <blockItem item_data="{{items[2]}}"></blockItem>
+      </view>
+    </view>
+</view>

+ 27 - 0
pages/components/blocks/home2/homeTwo.wxss

@@ -0,0 +1,27 @@
+.flex-1px-r,.flex-1px-b {
+  position: relative;
+}
+.flex-1px-r::after {
+  content: "";
+  position: absolute;
+  right: 0;
+  top: 0;
+  bottom: 0;
+  width: 2rpx;
+  background: #c7c7c7;
+  z-index: 5;
+  transform: scaleX(0.5);
+  -webkit-transform: scaleX(0.5);
+}
+.flex-1px-b::after{
+  content: "";
+  position: absolute;
+  right: 0;
+  left: 0;
+  bottom: 10rpx;
+  height: 2rpx;
+  background: #c7c7c7;
+  z-index: 5;
+  transform: scaleY(0.5);
+  -webkit-transform: scaleY(0.5);
+}

+ 23 - 0
pages/components/blocks/search/search.js

@@ -0,0 +1,23 @@
+// pages/components/blocks/search/search.js
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+
+  }
+})

+ 4 - 0
pages/components/blocks/search/search.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 3 - 0
pages/components/blocks/search/search.wxml

@@ -0,0 +1,3 @@
+<view class='search_box'>
+  <text>搜索商品 品牌 功效 规格</text>
+</view>

+ 16 - 0
pages/components/blocks/search/search.wxss

@@ -0,0 +1,16 @@
+.search_box {
+  font-size: 24rpx;
+}
+.search_box text {
+  width:720rpx;
+height:70rpx;
+line-height:70rpx;
+background:#f7f7f7;
+display:inline-block;
+border-radius:5rpx;
+color:#999999;
+padding-left:36rpx;
+box-sizing:border-box;
+margin-left:15rpx;
+
+}

+ 3 - 1
pages/components/blocks/tabs/tabs.json

@@ -1,4 +1,6 @@
 {
   "component": true,
-  "usingComponents": {}
+  "usingComponents": {
+    "searchBox": "..//search/search"
+  }
 }

+ 3 - 2
pages/components/blocks/tabs/tabs.wxml

@@ -1,6 +1,7 @@
 
-<view>
-  <scroll-view class="scroll-view_H" scroll-x="true" style="width: 100%">
+<view class="scroll-view_H">
+  <searchBox></searchBox>
+  <scroll-view scroll-x="true" style="width: 100%">
     <view 
       wx:for="{{tabs}}" 
       wx:key="tabsIndex" 

+ 1 - 1
pages/index/index.wxss

@@ -20,5 +20,5 @@
   margin-top: 200px;
 }
 .clear_fixed {
-  height: 64rpx;
+  height: 142rpx;
 }

+ 1 - 5
pages/shopCart/shopCart.js

@@ -6,10 +6,6 @@ Page({
     logs: []
   },
   onLoad: function () {
-    this.setData({
-      logs: (wx.getStorageSync('logs') || []).map(log => {
-        return util.formatTime(new Date(log))
-      })
-    })
+    
   }
 })

+ 1 - 2
pages/shopCart/shopCart.wxml

@@ -1,2 +1 @@
-<!--logs.wxml-->
-<web-view src="https://passport.lrlz.com/mobile/index.php?act=bonusex&op=open&client_type=wap&type_sn=28971520821035338917&title=%E6%AF%8F%E5%A4%A9%E5%8D%81%E7%82%B9%20%E8%AF%95%E8%AF%95%E6%89%8B%E6%B0%94"></web-view>
+

+ 0 - 8
pages/shopCart/shopCart.wxss

@@ -1,8 +0,0 @@
-.log-list {
-  display: flex;
-  flex-direction: column;
-  padding: 40rpx;
-}
-.log-item {
-  margin: 10rpx;
-}

+ 3 - 4
pages/webView/webView.js

@@ -1,4 +1,4 @@
-// pages/web-view/webView.js
+let jsUrlHelper = require('../../jsUrlHelper.js');
 Page({
 
   /**
@@ -13,10 +13,9 @@ Page({
    */
   onLoad: function (options) {
     let url = decodeURIComponent(options.url);
-    var reg = /[\u4E00-\u9FA5]/g;
-    var result = url.replace(reg, '');
+    let targetUrl = jsUrlHelper.delUrlParam(url,'title');
     this.setData({
-      webViewUrl: result
+      webViewUrl: targetUrl
     })
   },