Commit ce9392ed8b7395e08c34b942a56832f7795509e3

Authored by yvan.ni
1 parent 1ccad8ec

判断图片组合要不要显示的优化

components/diy_picMax/diy_picMax.js
  1 +var ut = require("../../utils/util.js");
1 Component({ 2 Component({
2 properties: { 3 properties: {
3 object: { 4 object: {
@@ -10,7 +11,8 @@ Component({ @@ -10,7 +11,8 @@ Component({
10 // 这里是一些组件内部数据 11 // 这里是一些组件内部数据
11 someData: {}, 12 someData: {},
12 pic_height: 0,//图片组合的高度 13 pic_height: 0,//图片组合的高度
13 - is_yspan: 0, //是否要严格按照比例来实现 14 + is_yspan: 0, //是否要严格按照比例来实现
  15 + is_time_show:0
14 }, 16 },
15 ready: function () { 17 ready: function () {
16 //-- console.log(this.data.object.data) -- 18 //-- console.log(this.data.object.data) --
@@ -25,6 +27,26 @@ Component({ @@ -25,6 +27,26 @@ Component({
25 27
26 }) 28 })
27 this.setData({ pic_height: height, is_yspan: is_yspan }) 29 this.setData({ pic_height: height, is_yspan: is_yspan })
  30 +
  31 +
  32 + var start_time=this.properties.object.start_time;
  33 + var end_time=this.properties.object.end_time;
  34 +
  35 + if(start_time && end_time) {
  36 +
  37 + var start_time = Date.parse(new Date(start_time.replace(/-/g, '/'))) / 1000;
  38 + var end_time = Date.parse(new Date(end_time.replace(/-/g, '/'))) / 1000;
  39 + var now = ut.gettimestamp();
  40 +
  41 +
  42 + if (start_time < now && end_time > now) {
  43 + this.setData({is_time_show: 1});
  44 + }
  45 + }else{
  46 + this.setData({is_time_show: 1});
  47 + }
  48 +
  49 +
28 }, 50 },
29 methods: { 51 methods: {
30 //-- 智能跳转到页面 -- 52 //-- 智能跳转到页面 --
components/diy_picMax/diy_picMax.wxml
1 <!-- 图片组合 --> 1 <!-- 图片组合 -->
  2 +<block wx:if="{{is_time_show}}">
2 <wxs module="g_filter" src="../diy_notice/g_filter.wxs"></wxs> 3 <wxs module="g_filter" src="../diy_notice/g_filter.wxs"></wxs>
3 <!-- 如果有纵向合并的时候,要求要按照绝对布局来实现 --> 4 <!-- 如果有纵向合并的时候,要求要按照绝对布局来实现 -->
4 <block wx:if="{{is_yspan}}"> 5 <block wx:if="{{is_yspan}}">
@@ -49,4 +50,5 @@ @@ -49,4 +50,5 @@
49 </view> 50 </view>
50 <view class="picMax-clear"></view> 51 <view class="picMax-clear"></view>
51 </view> 52 </view>
  53 +</block>
52 </block> 54 </block>
53 \ No newline at end of file 55 \ No newline at end of file