21 changed files with 701 additions and 116 deletions
@ -0,0 +1,84 @@ |
|||
Page({ |
|||
data: { |
|||
list:[], |
|||
children:[] |
|||
}, |
|||
toggleExpand(e) { |
|||
const id = e.currentTarget.dataset.id; |
|||
const canGo = e.currentTarget.dataset.have; |
|||
// const list = this.data.list.map(item => {
|
|||
// if (item.id === id) {
|
|||
// return { ...item, haveChildren: !item.haveChildren };
|
|||
// } else {
|
|||
// return { ...item, haveChildren: false };
|
|||
// }
|
|||
// });
|
|||
// this.setData({ list });
|
|||
if(!canGo){ |
|||
wx.navigateTo({ |
|||
url: '/pages/newdetail/newdetail?name='+id // 支持参数传递
|
|||
// url: '/pages/detail/detail?name='+id // 支持参数传递
|
|||
}) |
|||
} |
|||
}, |
|||
// 在生命周期函数中加载数据
|
|||
onLoad(options) { |
|||
let that = this; |
|||
const s = options.name; |
|||
const eventChannel = this.getOpenerEventChannel(); //取到事件对象
|
|||
wx.setNavigationBarTitle({ title: s }); |
|||
eventChannel.on("getCartDatalist",data=>{//发布事件
|
|||
that.setData({ |
|||
|
|||
list:data, |
|||
children: data.children //cartDataList为此页的数据模型
|
|||
// this.setData({list:childIndex.children});
|
|||
}); |
|||
console.log(that.data.cartDataList,"我被传过来了"); |
|||
}); |
|||
console.log(eventChannel); |
|||
}, |
|||
refresh: function(e) { |
|||
|
|||
wx.navigateTo({ |
|||
url: '/pages/detail/detail?id=1&name=example' |
|||
}); |
|||
}, |
|||
// 点击事件处理函数
|
|||
handleItemClick: function (e) { |
|||
// const index = e.currentTarget.dataset.index; // 主列表索引
|
|||
// const subIndex = e.currentTarget.dataset.subIndex; // 子列表索引
|
|||
// const subItem = this.data.list[index].sublist[subIndex];
|
|||
// wx.showToast({ title: `点击了 ${subItem.name}`, icon: 'none' });
|
|||
const childIndex = e.currentTarget.dataset.childIndex; |
|||
// const {parentIndex, childIndex} = e.currentTarget.dataset
|
|||
// const childData = this.data.list[parentIndex].children[childIndex]
|
|||
// const childId = e.currentTarget.dataset.child;
|
|||
|
|||
console.log(childIndex); |
|||
if(childIndex.haveChildren){ |
|||
wx.navigateTo({ |
|||
|
|||
url: '/pages/elselist/elselist', // 支持参数传递
|
|||
// url: '/pages/detail/detail?name='+childIndex.id // 支持参数传递
|
|||
success (res) { |
|||
// 通过eventChannel向被打开页面传送数据
|
|||
res.eventChannel.emit('getCartDatalist', childIndex) //触发事件
|
|||
} |
|||
}) |
|||
}else{ |
|||
console.log(childIndex.id); |
|||
wx.navigateTo({ |
|||
|
|||
url: '/pages/newdetail/newdetail?name='+childIndex.id // 支持参数传递
|
|||
// url: '/pages/detail/detail?name='+childIndex.id // 支持参数传递
|
|||
}) |
|||
} |
|||
wx.showToast({ |
|||
title: `点击了子项 ${childIndex.id}`, |
|||
icon: 'none' |
|||
}); |
|||
}, |
|||
|
|||
|
|||
}) |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"usingComponents": { |
|||
|
|||
}, |
|||
"navigationBarTitleText": "OBD分类" |
|||
} |
@ -0,0 +1,29 @@ |
|||
<scroll-view scroll-y style="height: 100vh;"> |
|||
<view |
|||
wx:for="{{children}}" |
|||
wx:key="id" |
|||
class="list-item" |
|||
data-index="{{index}}" |
|||
bindtap="toggleExpand" |
|||
data-id="{{item.id}}" |
|||
data-have="{{item.haveChildren}}" |
|||
> |
|||
<!-- style="background-color: {{item.haveChildren ? 'lightblue' : 'white'}}" --> |
|||
<!-- {{item.haveChildren ? '▼' : '▶'}} --> |
|||
{{item.name}} |
|||
<view wx:if="{{item.haveChildren}}" class="sublist" > |
|||
<view |
|||
wx:for="{{item.children}}" |
|||
wx:for-item="child" |
|||
wx:key="id" |
|||
catchtap="handleItemClick" |
|||
class="sublist-item" |
|||
data-parent-index="{{index}}" |
|||
data-child-index="{{child}}" |
|||
|
|||
> |
|||
{{child.name}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</scroll-view> |
@ -0,0 +1,12 @@ |
|||
.list-item { |
|||
padding: 10px; |
|||
border-bottom: 1px solid #ccc; |
|||
} |
|||
|
|||
.sublist { |
|||
margin-left: 20px; |
|||
} |
|||
|
|||
.sublist-item { |
|||
padding: 5px; |
|||
} |
@ -1,9 +1,26 @@ |
|||
<view class="container1"> |
|||
<text class="text-item" bindtap="handleTextTap" data-id="{{videoUrl}}" data-name="{{videoUrl}}" wx:key="id"> |
|||
演示视频 |
|||
</text> |
|||
<view class="container-view" > |
|||
<text class="text-item" bindtap="handleTextTap" data-id="{{videoUrl}}" data-name="{{videoUrl}}" wx:key="id">演示视频</text> |
|||
<!-- <view class="divider"></view> |
|||
<text class="text-item" bindtap="sendBlueOrder" data-key="{{commandMap[0].value}}" data-name="{{commandMap[0].value}}" wx:key="id">增加钥匙/{{commandMap[0].value}}</text> --> |
|||
<view class="divider"></view> |
|||
<text class="text-item" bindtap="sendBlueOrder" data-key="{{commandMap[0].value}}" data-name="{{commandMap[0].value}}" wx:key="id">增加钥匙/{{commandMap[0].value}}</text> |
|||
<view class="divider"></view> |
|||
<text class="text-item" bindtap="service" data-id="{{support}}" data-url="{{support}}" wx:key="id">联系客服:{{support}}</text> |
|||
<view class="list"> |
|||
<view |
|||
wx:for="{{commandMap}}" |
|||
wx:key="id" |
|||
class="list-item" |
|||
bindtap="handleItemClick" |
|||
data-id="{{item.value}}" |
|||
> |
|||
<text class="text-item">{{item.key}}</text> |
|||
|
|||
</view> |
|||
</view> |
|||
<text class="text-item" bindtap="service" data-id="{{support}}" data-url="{{support}}" wx:key="id">联系客服:</text> |
|||
<!-- <view> |
|||
<image class="qrcode" show-menu-by-longpress="1" src="https://mp-356f0dff-3257-4311-9774-dd14ef66bbf8.cdn.bspapp.com/imageUrl/name_card.jpg" mode="widthFix"></image> |
|||
</view> --> |
|||
|
|||
<view style="width: 100%; justify-content: center;" class="view_class"> |
|||
<image src="/utils/image/qrpic.png" show-menu-by-longpress="true" class="qr"></image> |
|||
</view> |
|||
</view> |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 560 KiB |
After Width: | Height: | Size: 288 KiB |
Loading…
Reference in new issue