Commit a0fd8492948062ea95e83f4977efbf36f68789ff
1 parent
f3f09f94
商品分组、服务卡项分组自定义模版分类标题置顶
Showing
7 changed files
with
38 additions
and
20 deletions
components/diy_goodsGroup/diy_goodsGroup.js
| @@ -14,7 +14,14 @@ Component({ | @@ -14,7 +14,14 @@ Component({ | ||
| 14 | type: Object, | 14 | type: Object, |
| 15 | value: null, | 15 | value: null, |
| 16 | }, | 16 | }, |
| 17 | - | 17 | + sticky: { |
| 18 | + type: Number, | ||
| 19 | + value: 0, | ||
| 20 | + }, | ||
| 21 | + container: { | ||
| 22 | + type: Function, | ||
| 23 | + value: null, | ||
| 24 | + }, | ||
| 18 | }, | 25 | }, |
| 19 | data: { | 26 | data: { |
| 20 | // 这里是一些组件内部数据 | 27 | // 这里是一些组件内部数据 |
| @@ -47,14 +54,17 @@ Component({ | @@ -47,14 +54,17 @@ Component({ | ||
| 47 | swiper_hei: 0, | 54 | swiper_hei: 0, |
| 48 | title_class: "", | 55 | title_class: "", |
| 49 | is_no_plus: 1, | 56 | is_no_plus: 1, |
| 57 | + container: null, | ||
| 50 | }, | 58 | }, |
| 51 | 59 | ||
| 52 | - ready: function () { }, | ||
| 53 | - | ||
| 54 | lifetimes: { | 60 | lifetimes: { |
| 61 | + ready: function () { | ||
| 62 | + this.setData({ | ||
| 63 | + container: () => wx.createSelectorQuery().select('#container') | ||
| 64 | + }) | ||
| 65 | + }, | ||
| 66 | + | ||
| 55 | attached: function () { | 67 | attached: function () { |
| 56 | - | ||
| 57 | - | ||
| 58 | //要兼容性的写法,因为有些商家都还未更新商品分组的最新的效果~~3.0公众号的html页面所以不用兼容写法 | 68 | //要兼容性的写法,因为有些商家都还未更新商品分组的最新的效果~~3.0公众号的html页面所以不用兼容写法 |
| 59 | var nav_item = this.data.object; | 69 | var nav_item = this.data.object; |
| 60 | var nav_list = this.data.object.nav_list; | 70 | var nav_list = this.data.object.nav_list; |
components/diy_goodsGroup/diy_goodsGroup.json
| 1 | { | 1 | { |
| 2 | "component": true, | 2 | "component": true, |
| 3 | "usingComponents": { | 3 | "usingComponents": { |
| 4 | - "mp-loading": "weui-miniprogram/loading/loading" | 4 | + "mp-loading": "weui-miniprogram/loading/loading", |
| 5 | + "mp-sticky": "../mp-sticky/mp-sticky" | ||
| 5 | } | 6 | } |
| 6 | } | 7 | } |
| 7 | \ No newline at end of file | 8 | \ No newline at end of file |
components/diy_goodsGroup/diy_goodsGroup.wxml
| @@ -4,13 +4,27 @@ | @@ -4,13 +4,27 @@ | ||
| 4 | 4 | ||
| 5 | <!-- 要不要顶部标题 --> | 5 | <!-- 要不要顶部标题 --> |
| 6 | <mp-loading show ="{{goods_array.length== 0}}" type="circle"></mp-loading> | 6 | <mp-loading show ="{{goods_array.length== 0}}" type="circle"></mp-loading> |
| 7 | + | ||
| 8 | +<view id="container"> | ||
| 9 | + | ||
| 10 | + | ||
| 7 | <block wx:if="{{is_nav}}"> | 11 | <block wx:if="{{is_nav}}"> |
| 12 | + <mp-sticky wx:if="{{sticky == 1}}" container="{{container}}"> | ||
| 8 | <view class="flex gr_title_list" style="overflow-x: auto;"> | 13 | <view class="flex gr_title_list" style="overflow-x: auto;"> |
| 9 | <view class="gr_title_item" wx:for="{{nav_list}}" data-index="{{index}}" bindtap="gr_set_nav" data-idlist="{{item.idlist}}" data-wgroup="{{item.wgroup}}" data-classstyle="{{item.classstyle}}"> | 14 | <view class="gr_title_item" wx:for="{{nav_list}}" data-index="{{index}}" bindtap="gr_set_nav" data-idlist="{{item.idlist}}" data-wgroup="{{item.wgroup}}" data-classstyle="{{item.classstyle}}"> |
| 10 | <text class="{{index==title_index?'t_red':''}}" style="{{title_class}}">{{item.title}}</text> | 15 | <text class="{{index==title_index?'t_red':''}}" style="{{title_class}}">{{item.title}}</text> |
| 11 | </view> | 16 | </view> |
| 12 | </view> | 17 | </view> |
| 18 | + </mp-sticky> | ||
| 19 | + | ||
| 20 | + <view class="flex gr_title_list" style="overflow-x: auto;" wx:else> | ||
| 21 | + <view class="gr_title_item" wx:for="{{nav_list}}" data-index="{{index}}" bindtap="gr_set_nav" data-idlist="{{item.idlist}}" data-wgroup="{{item.wgroup}}" data-classstyle="{{item.classstyle}}"> | ||
| 22 | + <text class="{{index==title_index?'t_red':''}}" style="{{title_class}}">{{item.title}}</text> | ||
| 23 | + </view> | ||
| 24 | + </view> | ||
| 13 | </block> | 25 | </block> |
| 26 | + | ||
| 27 | + | ||
| 14 | <view style="background-color: {{bg_color}};"> | 28 | <view style="background-color: {{bg_color}};"> |
| 15 | <!--1个列表的时候--> | 29 | <!--1个列表的时候--> |
| 16 | <view class="zs_goods_wai" wx:if='{{object.column==1}}'> | 30 | <view class="zs_goods_wai" wx:if='{{object.column==1}}'> |
| @@ -885,4 +899,6 @@ | @@ -885,4 +899,6 @@ | ||
| 885 | </view> | 899 | </view> |
| 886 | </swiper> | 900 | </swiper> |
| 887 | 901 | ||
| 902 | +</view> | ||
| 903 | + | ||
| 888 | </view> | 904 | </view> |
| 889 | \ No newline at end of file | 905 | \ No newline at end of file |
components/diy_serviceCard/diy_serviceCard.js
| @@ -19,9 +19,10 @@ Component({ | @@ -19,9 +19,10 @@ Component({ | ||
| 19 | }, | 19 | }, |
| 20 | sticky: { | 20 | sticky: { |
| 21 | type: Number, | 21 | type: Number, |
| 22 | + value: 0, | ||
| 22 | }, | 23 | }, |
| 23 | container: { | 24 | container: { |
| 24 | - type: Object, | 25 | + type: Function, |
| 25 | value: null, | 26 | value: null, |
| 26 | }, | 27 | }, |
| 27 | }, | 28 | }, |
| @@ -185,10 +186,6 @@ Component({ | @@ -185,10 +186,6 @@ Component({ | ||
| 185 | show: function() { | 186 | show: function() { |
| 186 | //--初始化卡类-- | 187 | //--初始化卡类-- |
| 187 | // this.card_init(); | 188 | // this.card_init(); |
| 188 | - // this.setData({ | ||
| 189 | - // container: () => wx.createSelectorQuery().select('#container') | ||
| 190 | - // }); | ||
| 191 | - console.log('onshow'); | ||
| 192 | }, | 189 | }, |
| 193 | }, | 190 | }, |
| 194 | 191 |
components/diy_serviceCard/diy_serviceCard.wxml
| @@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
| 12 | </block> --> | 12 | </block> --> |
| 13 | <view id="container"> | 13 | <view id="container"> |
| 14 | 14 | ||
| 15 | - <mp-sticky wx:if="{{sticky == 1}}"> | 15 | + <mp-sticky wx:if="{{sticky == 1}}" container="{{container}}"> |
| 16 | <scroll-view scroll-x="true" enhanced="true" fast-deceleration="true" show-scrollbar="false" wx:if="{{is_nav}}"> | 16 | <scroll-view scroll-x="true" enhanced="true" fast-deceleration="true" show-scrollbar="false" wx:if="{{is_nav}}"> |
| 17 | <view class="flex" style="{{myStyle}};"> | 17 | <view class="flex" style="{{myStyle}};"> |
| 18 | <view | 18 | <view |
pages/index/index/index.js
| @@ -88,12 +88,6 @@ Page({ | @@ -88,12 +88,6 @@ Page({ | ||
| 88 | container: null, | 88 | container: null, |
| 89 | }, | 89 | }, |
| 90 | 90 | ||
| 91 | - onReady() { | ||
| 92 | - this.setData({ | ||
| 93 | - container: () => wx.createSelectorQuery().select('#container') | ||
| 94 | - }) | ||
| 95 | - console.log('container', this.data.container); | ||
| 96 | - }, | ||
| 97 | 91 | ||
| 98 | onLoad: async function (tt) { | 92 | onLoad: async function (tt) { |
| 99 | wx.showShareMenu({ | 93 | wx.showShareMenu({ |
pages/index/index/index.wxml
| @@ -469,7 +469,7 @@ | @@ -469,7 +469,7 @@ | ||
| 469 | </block> | 469 | </block> |
| 470 | <!--商品分组--> | 470 | <!--商品分组--> |
| 471 | <block wx:if="{{item.ename=='goodsGroup'}}"> | 471 | <block wx:if="{{item.ename=='goodsGroup'}}"> |
| 472 | - <goodsGroup object="{{item.content}}"></goodsGroup> | 472 | + <goodsGroup object="{{item.content}}" sticky="{{template_arr[0].content.is_top}}"></goodsGroup> |
| 473 | 473 | ||
| 474 | </block> | 474 | </block> |
| 475 | <!--通知--> | 475 | <!--通知--> |
| @@ -536,7 +536,7 @@ | @@ -536,7 +536,7 @@ | ||
| 536 | 536 | ||
| 537 | <!-- 服务卡项 --> | 537 | <!-- 服务卡项 --> |
| 538 | <block wx:if="{{item.ename=='servicecategory'}}"> | 538 | <block wx:if="{{item.ename=='servicecategory'}}"> |
| 539 | - <serviceCard object="{{item.content}}" sticky="{{template_arr[0].content.is_top}}" id="container"></serviceCard> | 539 | + <serviceCard object="{{item.content}}" sticky="{{template_arr[0].content.is_top}}"></serviceCard> |
| 540 | </block> | 540 | </block> |
| 541 | 541 | ||
| 542 | 542 |