- 如何把一个数据库集合的内容,分类展示在页面中?
在一个数据库集合中,我需要把所有数据分类展示在页面中,比如:我想把一个数据库中的集合分别显示在,我要找车,我要找人,我找货车,我要找货,等四个类目中,发布信息界面,也是按,我要找车,我要找人,我找货车,我要找货,来区分发布信息的,该如何去写代码?效果如图: [图片][图片] 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="carpooling" 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> </segment> js代码: data: { items:['我要找车','我要找人','我找货车','我要找货'], }, loadcarpoolings:function(){ const that=this; db.collection("carpooling").limit(10).get().then(res=>{ console.log(res); const carpoolings = res.data that.setData({ carpoolings:carpoolings }) }) },
2022-09-04 - picker组件,当选择第一个或者没有选择时,如何默认内容显示?
picker组件,当我选择了第一个,或者没有进行选择,显示内容,当选择第二个内容时,第一个隐藏显示第二个内容,我现在需要的是,当打开页面时,就默认显示第一张图的内容,或者选择了第一个选项显示,这个默认显示该怎么实现,如图: [图片][图片] wxml代码: <view class="carpooling-group"> <view class="carpooling-list"> <view class="carpooling-title">拼车类型</view> <picker class="carpooling-option" name="education" range='{{title}}' value="{{title[choice]}}" bindchange="onEducationEvent"> <view class='ms-text'>{{title[choice]?title[choice]:'请选择拼车类型'}}</view> </picker> </view> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:for="{{cars}}" wx:key="car"> <view data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> <!-- 我要找车 --> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:if="{{choice==0}}" wx:for="{{vehicle}}" wx:key="vehicle"> <view data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> <!-- 我要找人 --> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:if="{{choice==1}}" wx:for="{{carpooling}}" wx:key="carpooling"> <view catchtap="OnDatailsEvent" data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> <!-- 我找货车 --> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:if="{{choice==2}}" wx:for="{{truck}}" wx:key="truck"> <view catchtap="OnDatailsEvent" data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> <!-- 我要找货 --> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:if="{{choice==3}}" wx:for="{{goods}}" wx:key="goods"> <view catchtap="OnDatailsEvent" data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> <view class="introduce-group"> <view class="introduce">备注</view> <textarea class="introduce-centent"></textarea> </view> <button>提交</button> </view> js代码: data: { cars:[ {'id':'出发时间','name':'','value':'出发时间'}, {'id':'时间补充','name':'','value':'时间补充'}, {'id':'始发地','name':'','value':'始发地'}, {'id':'终点','name':'','value':'终点'}, ], vehicle:[ {'id':'车型','name':'','value':'车型'}, {'id':'人数','name':'','value':'人数'}, {'id':'联系电话','name':'','value':'手机号码'}, ], carpooling:[ {'id':'途径','name':'','value':'途径'}, {'id':'车型','name':'','value':'车型'}, {'id':'空位','name':'','value':'空位'}, {'id':'联系电话','name':'','value':'手机号码'}, ], truck:[ {'id':'车型','name':'','value':'车型'}, {'id':'货物重量','name':'','value':'吨'}, {'id':'货物尺寸','name':'','value':'例:3米x2米x1米'}, {'id':'联系电话','name':'','value':'手机号码'}, ], goods:[ {'id':'途径','name':'','value':'途径'}, {'id':'车型','name':'','value':'车型'}, {'id':'载重','name':'','value':'吨'}, {'id':'货箱尺寸','name':'','value':'例:3米x2米x1米'}, {'id':'联系电话','name':'','value':'手机号码'}, ], title:["我要找车","我要找人","我找货车","我要找货",] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { const type=options.type; this.setData({ type:type }) }, onEducationEvent:function(event){ // console.log(event); const choice = event.detail.value; this.setData({ choice:choice, }) },
2022-09-03 - 在一个页面使用了3个textarea,要插入到数据库中,只成功插人了最后一个?
在个页面使用了3个textarea,在插入到数据库中,只显示最后一个,后来就把3个name的名字改成3个不一样的名字,同样也只是显示一条数据。这个要怎么解决?如图: [图片] wxml代码: <view class="resume-group"> <form bindsubmit="onSubmitEvent"> <view class="resume-top"> <view class="input"> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:for="{{ress}}" wx:key="res"> <view data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> </view> </view> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:for="{{sumes}}" wx:key="sume"> <view data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> <view class="introduce-group"> <view class="introduce">自我介绍</view> <textarea class="introduce-centent" name="content" placeholder="请输入您的自我介绍"></textarea> </view> <view class="experience-group"> <text class="item">工作经历</text> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:for="{{expers}}" wx:key="exper"> <view data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> <view class="position-group"> <text>起始时间</text> <view class="section"> <picker name="starttime" mode="date" value="{{date}}" fields="month" start="1985-09" bindchange="bindDateChange"> <view class="picker"> {{date}} <view class="icon"></view> </view> </picker> </view> <view>-</view> <view class="section"> <picker name="endtime" mode="date" value="{{date}}" fields="month" end="2021-12" bindchange="bindDateChangEvent"> <view class="picker"> {{Data}} <view class="icon"></view> </view> </picker> </view> </view> <view class="introduce-group"> <textarea class="introduce-centent" name="contentone" placeholder="请输入您的工作内容"></textarea> </view> </view> <view class="experience-group"> <text class="item">教育经历</text> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:for="{{ences}}" wx:key="key"> <view data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> <view class="position-group"> <text>起始时间</text> <view class="section"> <picker name="starttime" mode="date" value="{{date}}" fields="month" start="1985-09" bindchange="bindChange"> <view class="picker"> {{datae}} <view class="icon"></view> </view> </picker> </view> <view>-</view> <view class="section"> <picker name="endtime" mode="date" value="{{date}}" fields="month" end="2021-12" bindchange="bindChangEvent"> <view class="picker"> {{Datae}} <view class="icon"></view> </view> </picker> </view> </view> <view class="introduce-group"> <textarea class="introduce-centent" name="contenttwo" placeholder="请输入您的学习内容"></textarea> </view> </view> <button formType="submit">提交</button> </form> </view> js代码 onSubmitEvent:function(event){ console.log(event); const content = event.detail.value.content; const author=app.globalData.userInfo; wx.showLoading({ title:"正在发表中..." }) // // 特3456书yuuo莞6543李zxcz蒜7782法fgnv级 wx.cloud.callFunction({ name:"resume", data:{ content:content, author:author, // contentone:event.detail.value.contentone, // contenttwo:event.detail.value.contenttwo, full_Name:event.detail.value.full_Name, Gender:event.detail.value.Gender, Age:event.detail.value.Age, native_place:event.detail.value.native_place, working_years:event.detail.value.working_years, education:event.detail.value.education, intention:event.detail.value.intention, Company_name:event.detail.value.Company_name, position:event.detail.value.position, school:event.detail.value.school, specialty:event.detail.value.specialty, starttime:event.detail.value.starttime, endtime:event.detail.value.endtime }, success:res => { console.log(res); const _id = res.result._id; if(_id){ wx.hideLoading(); wx.showToast({ title:"恭喜!发送成功!" }); // setTimeout(function(){ // wx.navigateBack({}) // },800) }else{ wx.showToast({ title:res.result.errMsg, }) } } }) },
2022-09-02 - 如何在一个云函数中执行多个数据库集合操作?
如图,我有多个发布信息页面,每个发布页面信息配置一个数据库,但是所有发布信息都需要执行内容检测,所有我的想法是把这些数据库集合放到一个带有内容检测的这个云函数中,求指教 [图片] 我尝试了用if判断去实现,不知道这个if中的值该怎么传,我写了一段代码,会报错,第一个发布页面有报警,如图 [图片][图片] 代码如下: 云函数代码: if(errcode == 0){ if(collection==recruit){ return await db.collection("recruit").add({ data:{ content:content, author:author, location:location, varchar:varchar, firstName:firstName, position:position, work:work, education:education, create_time:db.serverDate(), } }) }else if(collection==release-resume){ return await db.collection("release-resume").add({ data:{ content:content, author:author, education:education, full_Name:full_Name, Gender:Gender, Age:Age } }) } }else{ return await {"errcode":1,"errmsg":"您的内容有风险,请修改再发布!"} }; 页面JS代码: /** * 发布事件 */ onSubmitEvent:function(event){ console.log(event); const content = event.detail.value.content; const author=app.globalData.userInfo; wx.showLoading({ title:"正在发表中..." }) // 特3456书yuuo莞6543李zxcz蒜7782法fgnv级 wx.cloud.callFunction({ name:"recruit", data:{ content:content, author:author, full_Name:event.detail.value.full_Name, Gender:event.detail.value.Gender, Age:event.detail.value.Age }, success:res => { console.log(res); const _id = res.result._id; if(_id){ wx.hideLoading(); wx.showToast({ title:"恭喜!发送成功!" }); // setTimeout(function(){ // wx.navigateBack({}) // },800) }else{ wx.showToast({ title:res.result.errMsg, }) } } }) },
2022-08-31 - 代码没有做任何修改,之前好好的,怎么就突然不行了呢?
今天在做第二个发布页面时,想把两个数据库集合放在一个云函数中实现,没有成功,尝试一下第一个发布页面,没有反应,我就删除了一些刚写的代码,还是不行,一直到我把所有新写的代码都删除了,还原了之前的代码,居然还是没有反应,和之前一模一样的代码,怎么就不行了呢? /** * 发布事件 */ onSubmitEvent:function(event){ console.log(event); const content = event.detail.value.content; const location=this.data.location; const author=app.globalData.userInfo; wx.showLoading({ title:"正在发表中..." }) // 特3456书yuuo莞6543李zxcz蒜7782法fgnv级 wx.cloud.callFunction({ name:"recruit", data:{ content:content, author:author, location:location, varchar:event.detail.value.varchar, firstName:event.detail.value.firstName, work:event.detail.value.work, education:event.detail.value.education, position:"" }, success:res => { console.log(res); const _id = res.result._id; if(_id){ wx.hideLoading(); wx.showToast({ title:"恭喜!发送成功!" }); setTimeout(function(){ wx.navigateBack({}) },800) }else{ wx.showToast({ title:res.result.errMsg, }) } } }) }, 云函数代码: if(errcode == 0){ return await db.collection("recruit").add({ data:{ content:content, author:author, location:location, varchar:varchar, firstName:firstName, position:position, work:work, education:education, create_time:db.serverDate(), } }) }else{ return await {"errcode":1,"errmsg":"您的内容有风险,请修改再发布!"} };
2022-08-30 - 在一个云函数中写了两个数据库集合,当提交信息时报错?
创建两个发布页面,在写第二个发布页面时,再建了一个数据集合,因为都需要进行文字检测,我把插入数据库两个集合都写在一个云函数中,就提示报错如图:,再在第一个发布页面发布信息时,点击提交就没有反应 [图片] 云函数代码: if(errcode == 0){ if(collection==recruit){ return await db.collection("recruit").add({ data:{ content:content, author:author, location:location, varchar:varchar, firstName:firstName, position:position, work:work, education:education, create_time:db.serverDate(), } }) }else if(collection==release-resume){ return await db.collection("release-resume").add({ data:{ content:content, author:author, education:education, full_Name:full_Name, Gender:Gender, Age:Age } }) } }else{ return await {"errcode":1,"errmsg":"您的内容有风险,请修改再发布!"} }; 页面JS代码: /** * 发布事件 */ onSubmitEvent:function(event){ console.log(event); const content = event.detail.value.content; const author=app.globalData.userInfo; wx.showLoading({ title:"正在发表中..." }) // 特3456书yuuo莞6543李zxcz蒜7782法fgnv级 wx.cloud.callFunction({ name:"recruit", data:{ content:content, author:author, full_Name:event.detail.value.full_Name, Gender:event.detail.value.Gender, Age:event.detail.value.Age }, success:res => { console.log(res); const _id = res.result._id; if(_id){ wx.hideLoading(); wx.showToast({ title:"恭喜!发送成功!" }); // setTimeout(function(){ // wx.navigateBack({}) // },800) }else{ wx.showToast({ title:res.result.errMsg, }) } } }) },
2022-08-30 - 想实现导航栏上滑到顶部时固定,下滑复位的动作,不起作用,求助?
[图片] 代码: wxml: <view class="segment-group"> <scroll-view enable-flex class="segment-header {{scrollTop > 200?'scrollTop':''}}"> <block wx:for="{{items}}" wx:key="item"> <view class="segment-item active" wx:if="{{currentIndex === index}}" bindtap="onItemTapEvent" data-index="{{index}}">{{item}}</view> <view class="segment-item" wx:else bindtap="onItemTapEvent" data-index="{{index}}">{{item}}</view> </block> </scroll-view> <block wx:for="{{items}}" wx:key="item"> <slot name="{{index}}" wx:if="{{currentIndex === index}}"></slot> </block> </view> wxss: .scrollTop{ position:fixed; display:flex; justify-content:space-evenly; top:0; left:0; right:0; border-radius:none; } js: onPageScroll:function(event){ console.log(event); var scrollTop=event.scrollTop; this.setData({ scrollTop:scrollTop, }) },
2022-08-28 - 上拉加载更多触底时报错?
下拉加载触底时,调试器显示已经加载,页面没有加载出数据,并且报错,报错如图: [图片] 之前的10条信息调试器上没有显示时间,加载的信息有时间显示,如图: [图片][图片] 代码如下: //下拉刷新上啦加载 loadrecruits:function(start=0){ const that=this; let promise = db.collection("recruit"); if(start > 0){ promise = promise.skip(start); } promise.limit(10).orderBy("create_time","desc").get().then(res => { console.log(res); const recruits = res.data; let hasmore = true; if(recruits.length == 0){ hasmore = false; } let newRecruits = []; if(start > 0){ newRecruits = that.data.recruits.concat(recruits); }else{ newRecruits = recruits; } newRecruits.forEach((recruit,index) => { recruit.create_time = recruit.create_time.getTime(); }) that.setData({ recruits:newRecruits, hasmore:hasmore }); }) }, onPullDownRefresh: function (event) { this.loadrecruits(0); }, onReachBottom: function (event) { this.loadrecruits(this.data.recruits.length); }, 我不知道下拉加载这个组件在wxml中位置是不是对的 wxml代码如下: <wxs src="../../utils/util.wxs" module="util"/> <searchbar isnavigator="{{true}}"></searchbar> <import src="menu/menu.wxml" /> <view class="menu"> <block wx:for="{{menus}}" wx:key="menu"> <view catchtap="toHotPush" data-index="{{index}}"> <template is="menu" data="{{...item}}"></template> </view> </block> </view> <view> <view class="ad-group"> <image src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/yingshiji.png"></image> </view> </view> <segment items="{{items}}" defaultIndex="0" bind:itemchanged="onSegmentItemChanged"> <view slot="0" class="segment-page work-page"> <view class="list-group" wx:for="{{recruits}}" wx:key="recruit" wx:for-item="recruit"> <view class="list-title">自动化装配钳工</view> <view class="content">{{recruit.content}}</view> <view class="nickName"> <image class="nickName-avatar" src="{{recruit.author.avatarUrl}}"> </image> <view class="nickName-company"> <view class="company">深圳市赢世纪科技有限公司</view> <view class="nickName-firstName"> <view class="firstName">{{recruit.firstName}}</view> <!-- <view class="spot">·</view> <view class="position">人事经理</view> --> </view> </view> <button class="varchar"> <image src="/images/telephone.png"></image> <text>电话</text> </button> </view> <view class="list-detail"> <view class="detail-location"> <image class="location" src="../../images/location.png"/> <text class="location-text">{{recruit.location.address}}</text> </view> <view class="detail-time">{{util.timeFormat(recruit.create_time)}}</view> </view> </view> </view> <view slot="1" class="segment-page worker-page"> <view class="worker-group"> <view class="worker-top"> <text>顶</text> </view> <view class="worker"> <view class="worker-left"> <image src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/pinche.jpg"></image> </view> <view class="worker-middle"> <view class="top-list"> <text class="name">张三</text> <text class="gender">男</text> <text class="real-name">实名认证</text> </view> <view class="bottom-list"> <text class="age">30岁</text> <text class="age-years">15年</text> <text class="education">中专</text> </view> <view class="worker-skill"> <text class="skill">CAD</text> <text class="skill">SolidWorks</text> </view> </view> <view class="worker-right"> <text class="topping">我要置顶</text> <text class="xz">个人</text> </view> </view> <view class="worker-introduce"> <text>本人从事自动化设备10余年,熟练使用CAD,SW软件,对机械原理比较了解</text> </view> <viwe class="worker-expect"> <text class="expect">期望</text> <view class="quyu">深圳</view> <view class="line">|</view> <view class="position">钳工</view> <view class="line">|</view> <view class="wages">5000-8000</view> </viwe> </view> </view> <view slot="2" class="segment-page carpooling-page"> <view class="people-group"> <view class="people-left"> <view class="people-title"> <view class="people-top"> <text>顶</text> </view> <view class="people-start">2021-11-25 09:36出发</view> </view> <view class="people-seat-list"> <view class="people-model-title">车型:</view> <view class="people-model">七座商务车</view> <view class="people-seat">3空位</view> </view> <view class="people-route"> <text class="people-rise">深圳石岩</text> <text class="people-arrow">→ </text> <text class="people-end">湖南省邵阳市洞口县</text> <text class="people-channel">(经东莞,广州,惠州,东莞长安 )</text> </view> <view class="people-details"> <view class="people-remarks">备注:</view> <text>诚信拼车,行李少优先</text> </view> </view> <view class="people-right"> <button class="people-contact"> <image src="/images/telephone.png"></image> </button> </view> </view> </view> <view slot="3" class="segment-page secondhand-page">二手交易的页面</view> <loadingmore hasmore="{{hasmore}}"></loadingmore>//下拉刷新上拉加载导入的组件 </segment>
2022-08-27 - components中自定义了一个二级下拉菜单,在插入数据库中时,这个值要如何获取?
picker的界面不够直观,就自定义了一个二级下拉菜单组件,那么现在问题是,我要怎样获取到这个值,并插入到数据库中?效果如图: [图片] 下面代码是插入到数据库中的其他字段。position二级菜单要插入的字段,那么这个值要怎么获取并插入到数据库中? onSubmitEvent:function(event){ console.log(event); const content = event.detail.value.content; const location=this.data.location; const author=app.globalData.userInfo; wx.showLoading({ title:"正在发表中..." }) // 特3456书yuuo莞6543李zxcz蒜7782法fgnv级 wx.cloud.callFunction({ name:"recruit", data:{ content:content, author:author, location:location, varchar:event.detail.value.varchar, firstName:event.detail.value.firstName, work:event.detail.value.work, education:event.detail.value.education, position:event.currentTarget.dataset.index; }, success:res => { console.log(res); const _id = res.result._id; if(_id){ wx.hideLoading(); wx.showToast({ title:"恭喜!发送成功!" }); }else{ wx.showToast({ title:res.result.errMsg, }) } } }) }, 代码片段 https://developers.weixin.qq.com/s/a0FU9NmV7wBR
2022-08-26 - 自定义的component下拉菜单组件如何插入到数据库中?
如图下拉菜单,因数据太多,不想用微信开发中的多列选择器区完成这个功能,不够直观,所以想用自定义的组件,该如何插入到数据库中,求大师帮助。 [图片] component中wxlm代码: <!--下拉选框--> <view class="list-select"> <view class="position">招聘职位</view> <view class="select-box"> <view class="select {{shownavindex == 1? 'active' : ''}}" bindtap="list" data-nav="1"> <view class="content" >{{quanbu_name}}</view> </view> </view> <view class="icon-group"> <view class="select {{shownavindex == 1? 'active' : ''}}" bindtap="list" data-nav="1"> <icon class="icon"></icon> </view> </view> </view> <!--选择工种标签--> <view class="gongzhong {{gzopen ? 'slidown' : 'slidup'}} {{gzshow ? 'disappear':''}}"> <view class="gz gz-left"> <view class="view {{select1 == index ? 'current1' : ''}}" wx:for="{{gz}}" wx:key="key" bindtap="gzselectLeft" data-index='{{index}}'> {{index}} </view> </view> <view class="gz gz-right"> <view class="view {{select2 == item?'current2':''}}" wx:for="{{gzright}}" wx:key="key" wx:if="{{gzright}}" bindtap='gzselectRight' data-index="{{item}}"> <text>{{item}}</text> </view> </view> <view class='form-btn'> <button class='btn-reset' bindtap='gzEmpty'>重置</button> <button class='btn-submit' bindtap='gzFilter'>确定</button> </view> <view class="fullbg {{isfull ?'fullopacity':''}}" bindtap="hidebg"></view> </view> js代码: Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { quanbu_name:"请选择您的招聘职位", gz:{ "计算机/互联网/通信/电子":["技术工程师","机械设计","PLC编程", "车工","焊工","铣工","磨床","","车工",], "后端开发":["Java开发工程师","PHP开发工程师","C/C++开发工程师", "Python开发工程师","NET开发工程师","C#开发工程师","Ruby开发工程师","Go开发工程师","大数据开发工程师","Hadoop工程师","爬虫开发工程师","脚本开发工程师","多媒体开发工程师","GIS开发工程师","全栈开发工程师","ERP开发工程师","区块链开发","高级软件工程师","软件工程师","系统架构设计师","系统分析员","技术文员/助理","技术文档工程师","其他",], "自动化技术":["钳工","焊工","电工","调试",], }, gzopen: false, //选择工种筛选弹窗 gzshow: true, isfull: false, select1: '', //选中后的第二个子菜单,默认显示工种下的子菜单 select2: '', //选择部分的中间 shownavindex: '', gzIndex: 0, }, onLoad: function (options) { this.setData({ select:!this.data.select }) }, /** * 组件的方法列表 */ methods: { // 列表下拉框是否隐藏 list: function(e) { if (this.data.gzopen) { this.setData({ content: this.data.nv, gzopen: false, gzshow: false, isfull: false, shownavindex: 0 }) } else { this.setData({ gzopen: true, gzshow: false, isfull: true, shownavindex: e.currentTarget.dataset.nav }) } }, // 点击灰色背景隐藏所有的筛选内容 hidebg: function(e) { this.setData({ gzopen: false, gzshow: true, isfull: false, shownavindex: 0, }) }, // 选择工种第一栏选择内容 gzselectLeft: function(e) { // console.log(e); var name=e.currentTarget.dataset.index; // console.log('用户选中左边菜单栏的索引值是:'+e.target.dataset.index); this.setData({ quanbu_name:name, gzright:this.data. gz[e.currentTarget.dataset.index], select1: e.target.dataset.index, }); }, // 选择工种右边栏选择的内容 gzselectRight: function(e) { // console.log(e); var name=e.currentTarget.dataset.index; // console.log(''+e.currentTarget.dataset.index); this.setData({ quanbu_name:name, select2: e.currentTarget.dataset.index }); }, // 选择工种清空筛选项 gzEmpty: function() { this.setData({ select1: '', select2: '-1' }) }, // 选择工种筛选项后,点击提交 gzFilter: function() { // console.log('选择的一级选项是:' + this.data.select1); // console.log('选择的二级选项是:' + this.data.select2); // 隐藏选择工种下拉框 this.setData({ gzopen: false, gzshow: false, isfull: false, shownavindex: 0 }) }, } }) ppage中wxlm代码: <selecttwo wx:for-item="{{selecttwo}}" ></selecttwo>
2022-08-24