数据库中的carpool_tppe:"我要找车",是发布信息界面选择的发布信息类型,想以这个类型对数据进行分类,显示在导航栏对应的数据中,console.log()打印出来的结果是0,没有获取到数据,如图:
wxml代码:
<segment items="{{items}}" defaultIndex="0"
binditemchanged="onSegmentItemChanged" >
<view slot="0" class="segment-page people">
<view class="quanbu-group">
<view class="shu-group">|</view>
<text>全部信息(共有500条信息)</text>
<view class="paixu-group">按出发时间排序</view>
</view>
<view class="people-group" wx:for="{{carpoolings}}" wx:key="key" wx:for-item="carpooling">
<view class="people-left">
<view class="people-title">
<view class="people-top">
<text>顶</text>
</view>
<view class="departure-time">出发:</view>
<view class="people-start">{{carpooling.date}}</view>
</view>
<view class="people-route">
<text class="people-content">{{carpooling.departure_address}}</text>
<text class="people-arrow">→ </text>
<text class="purpose-content">{{carpooling.end}}</text>
<text>(</text>
<text class="channel-centent">{{carpooling.channel}}</text>
<text>)</text>
</view>
<view class="people-seat-list">
<view class="people-model-title">车型:</view>
<view class="people-model">{{carpooling.vehicle_type}}</view>
<view class="people-seat">{{carpooling.people}}空位</view>
</view>
<view class="people-details">
<view class="people-remarks">备注:</view>
<text>{{carpooling.content}}</text>
</view>
<view class="release-list">
<view class="release">发布:</view>
<view class="detail-time">2022/9/2 8:35:36</view>
</view>
</view>
<view class="people-right">
<button class="people-contact">
<image src="/images/telephone.png"></image>
</button>
</view>
</view>
</view>
<view slot="1" class="segment-page car"></view>
</segment>
js代码:
onLoad: function (options) {
},
loadcarpoolings:function(){
const that=this;
db.collection("carpooling").where({
carpool_type:"我要找车"
}).limit(10).get().then(res=>{
console.log(res);
const carpoolings = res.data
that.setData({
"carpoolings":carpoolings
})
})
},
onSegmentItemChanged:function(event){
// console.log(event);
const active = event.detail.index;
this.setData({
active:active
})
console.log(event.detail.index);
db.collection("carpooling").where({
carpool_type:event.detail.index.toString()
})
.get({
success:function(res){
console.log(res);
that.setData({
"carpooling":res.data
})
}
})
},
看下network里这个请求有返回参数没