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 | 14 | type: Object, |
| 15 | 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 | 26 | data: { |
| 20 | 27 | // 这里是一些组件内部数据 |
| ... | ... | @@ -47,14 +54,17 @@ Component({ |
| 47 | 54 | swiper_hei: 0, |
| 48 | 55 | title_class: "", |
| 49 | 56 | is_no_plus: 1, |
| 57 | + container: null, | |
| 50 | 58 | }, |
| 51 | 59 | |
| 52 | - ready: function () { }, | |
| 53 | - | |
| 54 | 60 | lifetimes: { |
| 61 | + ready: function () { | |
| 62 | + this.setData({ | |
| 63 | + container: () => wx.createSelectorQuery().select('#container') | |
| 64 | + }) | |
| 65 | + }, | |
| 66 | + | |
| 55 | 67 | attached: function () { |
| 56 | - | |
| 57 | - | |
| 58 | 68 | //要兼容性的写法,因为有些商家都还未更新商品分组的最新的效果~~3.0公众号的html页面所以不用兼容写法 |
| 59 | 69 | var nav_item = this.data.object; |
| 60 | 70 | var nav_list = this.data.object.nav_list; | ... | ... |
components/diy_goodsGroup/diy_goodsGroup.json
components/diy_goodsGroup/diy_goodsGroup.wxml
| ... | ... | @@ -4,13 +4,27 @@ |
| 4 | 4 | |
| 5 | 5 | <!-- 要不要顶部标题 --> |
| 6 | 6 | <mp-loading show ="{{goods_array.length== 0}}" type="circle"></mp-loading> |
| 7 | + | |
| 8 | +<view id="container"> | |
| 9 | + | |
| 10 | + | |
| 7 | 11 | <block wx:if="{{is_nav}}"> |
| 12 | + <mp-sticky wx:if="{{sticky == 1}}" container="{{container}}"> | |
| 8 | 13 | <view class="flex gr_title_list" style="overflow-x: auto;"> |
| 9 | 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 | 15 | <text class="{{index==title_index?'t_red':''}}" style="{{title_class}}">{{item.title}}</text> |
| 11 | 16 | </view> |
| 12 | 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 | 25 | </block> |
| 26 | + | |
| 27 | + | |
| 14 | 28 | <view style="background-color: {{bg_color}};"> |
| 15 | 29 | <!--1个列表的时候--> |
| 16 | 30 | <view class="zs_goods_wai" wx:if='{{object.column==1}}'> |
| ... | ... | @@ -885,4 +899,6 @@ |
| 885 | 899 | </view> |
| 886 | 900 | </swiper> |
| 887 | 901 | |
| 902 | +</view> | |
| 903 | + | |
| 888 | 904 | </view> |
| 889 | 905 | \ No newline at end of file | ... | ... |
components/diy_serviceCard/diy_serviceCard.js
| ... | ... | @@ -19,9 +19,10 @@ Component({ |
| 19 | 19 | }, |
| 20 | 20 | sticky: { |
| 21 | 21 | type: Number, |
| 22 | + value: 0, | |
| 22 | 23 | }, |
| 23 | 24 | container: { |
| 24 | - type: Object, | |
| 25 | + type: Function, | |
| 25 | 26 | value: null, |
| 26 | 27 | }, |
| 27 | 28 | }, |
| ... | ... | @@ -185,10 +186,6 @@ Component({ |
| 185 | 186 | show: function() { |
| 186 | 187 | //--初始化卡类-- |
| 187 | 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 | 12 | </block> --> |
| 13 | 13 | <view id="container"> |
| 14 | 14 | |
| 15 | - <mp-sticky wx:if="{{sticky == 1}}"> | |
| 15 | + <mp-sticky wx:if="{{sticky == 1}}" container="{{container}}"> | |
| 16 | 16 | <scroll-view scroll-x="true" enhanced="true" fast-deceleration="true" show-scrollbar="false" wx:if="{{is_nav}}"> |
| 17 | 17 | <view class="flex" style="{{myStyle}};"> |
| 18 | 18 | <view | ... | ... |
pages/index/index/index.js
| ... | ... | @@ -88,12 +88,6 @@ Page({ |
| 88 | 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 | 92 | onLoad: async function (tt) { |
| 99 | 93 | wx.showShareMenu({ | ... | ... |
pages/index/index/index.wxml
| ... | ... | @@ -469,7 +469,7 @@ |
| 469 | 469 | </block> |
| 470 | 470 | <!--商品分组--> |
| 471 | 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 | 474 | </block> |
| 475 | 475 | <!--通知--> |
| ... | ... | @@ -536,7 +536,7 @@ |
| 536 | 536 | |
| 537 | 537 | <!-- 服务卡项 --> |
| 538 | 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 | 540 | </block> |
| 541 | 541 | |
| 542 | 542 | ... | ... |