小程序值左側(cè)滑動點擊對應(yīng)渲染右邊滑動

1 這是wxml

<view class='bg_nav'> <view > <label class="bg_title">滿減</label> <label>滿80減90</label> </view></view><!--內(nèi)容滑塊區(qū) --><view class='borer_top dis-flex flex-justify mg_top20'> <scroll-view scroll-y class='w_173' style='height:{{windowHeight}}px'> <view wx:for="{{productData}}" data-id="{{item.classify_id}}" data-index="{{index}}" class='{{index==indexs?"scroll_atc2":"scroll_atc1"}} ' bindtap='tap_product'> {{item.classify_name}} </view> <!-- <view class='scroll_atc2'>家用電器</view> <view class='scroll_atc1'>家用電器</view> --> </scroll-view> <scroll-view class='w_557' scroll-y style="height:{{windowHeight}}px"> <view wx:for="{{proBlcokData}}" wx:for-item="index_one"> <view class='f_24 pd_50bt30'>{{index_one.classify_name}}</view> <view class='flex-wrapr borer_bottom'> <view class='center pd_bt20' wx:for="{{index_one.category3}}" wx:for-item="index_two" data-categoryId="{{index_two.classify_id}}" data-prid="{{index_two.parent_id}}" data-name="{{index_two.classify_name}}" bindtap='navTo_name'> <image class='wh_100' src='{{index_two.img}}'></image> <view class='f_24'>{{index_two.classify_name}}</view> </view> </view> </view> </scroll-view></view>

1 這是wxss

.bg_nav{background: rgba(255, 215, 0, 0.1);margin:20rpx 15rpx;padding:15rpx 40rpx;}.bg_title{background: #E52E31;padding:10rpx 30rpx;margin-right:20rpx;border-radius:6rpx;color:#fff}.bg_title{font-size:30rpx;}.dis-flex{ display: flex; display: -webkit-flex;}.flex-justify{ justify-content:space-between; -webkit-justify-content:space-between;} page{ background: #fff; overflow: hidden;} .center{text-align:center;width:175rpx;} .pd_50bt30{padding-top:50rpx;padding-bottom:30rpx;padding-left:26rpx;} .pd_bt20{padding-bottom:20rpx;} .top-region{ padding:0 30rpx; padding-top: 20rpx; z-index: 99; opacity: .8; -webkit-transition: .4s; -moz-transition: .4s; transition: .4s;}.search{ position: relative; border-radius: 100rpx; padding-right: 28rpx;}.search .search-input{ width: 560rpx; height: 58rpx; line-height: 58rpx; border-radius: 100rpx; background: #F2F2F2; font-size: 22rpx; color: #ddd; padding-left: 56rpx;}.search .search-icon{ position: absolute; top: 50%; left: 26rpx; margin-top: -14rpx; width: 28rpx; height: 28rpx; z-index: 10;}.menu{ margin-top: 14rpx;}.icon-menu{ width: 36rpx; height: 36rpx;} .f_24{font-size:24rpx}.f_22{font-size:22rpx} .w_173{width:173rpx;}.w_557{width:557rpx;}.w_185{width:185rpx;} .wh_100{width:100rpx;height:100rpx;} .borer_top{border-top:1px solid #F2F2F2;}.borer_bottom{border-bottom:1px solid #F2F2F2;} .mg_top20{margin-top:20rpx;} .scroll_atc1{ color:#333333; background:#F2F2F2; padding:30rpx; font-size:26rpx;} .scroll_atc2{ background:#fff; padding:30rpx 30rpx; font-size:26rpx; border-left:6rpx solid goldenrod }

3這是js

Page({ /** * 頁面的初始數(shù)據(jù) */ data: { productData: [{ classify_name: 'vr世界' },{ classify_name: 'vr世界2' }], oneId: '', windowHeight: '', indexs: 0, typeId: 1, proBlcokData: [{ classify_name:'1'}] }, /** * 生命周期函數(shù)--監(jiān)聽頁面加載 */ onLoad: function (options) { const that = this; const token = wx.getStorageSync('token'); that.setData({ token: token }) //獲取 手機高度初始化 that.getSystemInfo(); }, //獲取手機設(shè)備信息 getSystemInfo: function () { const that = this; wx.getSystemInfo({ success: function (res) { const wh = res.windowHeight - 52; that.setData({ windowHeight: wh }) } }) }, // 點擊標題 tap_product: function (e) { const that = this; that.setData({ indexs: e.currentTarget.dataset.index, oneId: e.currentTarget.dataset.id, }) //點擊執(zhí)行 對應(yīng)產(chǎn)品內(nèi)容 that.ProductBlock(); }, //點擊產(chǎn)品 到搜索界面 navTo_name: function (e) { const that = this; wx.navigateTo({ url: `/pages/ShopSearch/ShopSearch?words=${e.currentTarget.dataset.name}&categoryId=${e.currentTarget.dataset.categoryid}`, }) }, // 點擊進入購物車 go_gwc: function () { wx.navigateTo({ url: '/pages/Cart/Cart' }) },})

復(fù)制上面代碼就可以得到該效果

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 小程序 通訊錄效果圖 三個主要部分 : 1)右側(cè)定位導(dǎo)航 2)左側(cè)內(nèi)容部分 3)頂部固定導(dǎo)航 wxml 部分 <v...
    pengkiw閱讀 8,417評論 1 9
  • 好久沒有更新了,今天更新點東西。 大多數(shù)的商城類小程序都有這個功能,點擊“全部訂單”,“待付款”,“待發(fā)貨”,“待...
    _vb閱讀 1,114評論 0 2
  • // pages/logs/travel.js JS部分trag_daystr為數(shù)據(jù) 可根據(jù)自己需求改變 var ...
    悟空_大師兄_閱讀 1,245評論 0 0
  • 每天的學習記錄,可能有的地方寫的不對,因為剛學,以后發(fā)現(xiàn)錯的話會回來改掉整體流程 https://develope...
    有點健忘閱讀 5,053評論 0 7
  • 有些東西,你需要自己去爭取。加油(^ω^)寶寶
    寶_閱讀 151評論 0 0

友情鏈接更多精彩內(nèi)容