- 筛选弹窗组件封装
- 筛选弹窗内部交互实现
- 通过子父通信,将筛选条件传递给Job.vue组件
在Job.vue组件中,携带新的筛选条件到api/job.js中去加载新的数据
LeanCloud的比较查询
curl -X GET \
-H "X-LC-Id: 自己的id" \
-H "X-LC-Key: 自己的key" \
-H "Content-Type: application/json" \
-G \
--data-urlencode 'where={"district":{"$in":['渝中区','渝北区']}}' \
https://API_BASE_URL/1.1/classes/Job
逻辑代码
import Vue from 'vue'
let $u = Vue.prototype.$u
export const getJobList=(condition,p)=>{
// 处理前的条件对象
// {
// gender:'1',
// cfytype:'2',
// district:['渝中区','渝北区'],
// payment:['1','2']
// }
// 处理后的条件对象
// {
// gender:'1',
// cfytype:'2',
// district:{"$in":['渝中区','渝北区']},
// payment:{"$in":['1','2']}
// }
for(let attr in condition){
if(attr=='district'||attr=='payment'){
condition[attr] = {"$in":condition[attr]}
}
}
let wh = JSON.stringify(condition) //整合查询条件
let url = `/1.1/classes/Job?where=${wh}&limit=10&skip=${p*10}`
return $u.get(url)
}