小趴菜
小趴菜
  • 发布:2023-04-28 22:49
  • 更新:2023-04-28 22:49
  • 阅读:317

小程序中使用unicloud-db联表查询,动态切换tab,赋值where查询无效

分类:uniCloud

小程序中使用unicloud-db联表查询,动态切换tab,赋值where查询无效,参考这个不起作用 https://ask.dcloud.net.cn/question/148249?notification_id-1107178rf-falseitem_id-204316__answer_id-204316__single-TRUE#!answer_204316

<view class="container">  
        <view class="header">  
            <uni-segmented-control :current="current" :values="navigate" @clickItem="onClickItem" styleType="button"  
                activeColor="#FF7A14"></uni-segmented-control>  
        </view>  
        <view class="list">  
            <unicloud-db ref="order" page-data="add" :page-size="10" :getcount="true" v-slot:default="{data, loading, hasMore, error}" :collection="collectionList"  
                :orderby="orderby">  
                    <view class="">  
                        <block v-for="(item,index) in data" :key="index">  
                            <orderItem :deleteIcon="true" :item="item" @on-delete="onDelete"></orderItem>  
                        </block>  
                    </view>  
                    <uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>  
            </unicloud-db>  
        </view>  
    </view>  
<script>  
const db = uniCloud.database();  
    export default {  
        data() {  
            return {  
                navigate: ['全部', '类型1', '类型2'],  
                current: 0,  
                orderby: "create_date desc",  
                collectionList: [  
                    db.collection('carpool-order').where(`user_id==$cloudEnv_uid`).getTemp(),  
                    db.collection('uni-id-users').field("_id, nickname, avatar_file.url as image").getTemp()  
                ]  
            };  
        },  
        methods: {  
            onClickItem(e) {  
                console.log(e);  
                switch (e.currentIndex){  
                    case 0:  
                        this.$set(this.collectionList, 0, db.collection('carpool-order').where(`user_id==$cloudEnv_uid`).getTemp())  
                        break;  
                    case 1:  
                        this.collectionList[0] = db.collection('carpool-order').where(`user_id==$cloudEnv_uid&&order_type==1`).getTemp()  
                        break;  
                    default:  
                        this.collectionList[0] = db.collection('carpool-order').where(`user_id==$cloudEnv_uid&&order_type==2`).getTemp()  
                        break;  
                }  
            },  
            onDelete(id) {  
                this.$refs.order.remove(id)  
            }  
        },  
    }  
</script>
2023-04-28 22:49 负责人:DCloud_uni-ad_HDX 分享
已邀请:

要回复问题请先登录注册