You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
2.9 KiB
119 lines
2.9 KiB
<template> |
|
<!--pages/user/profession/index.wxml--> |
|
<view> |
|
<uni-collapse> |
|
<uni-collapse-item :title="item.industryname" v-for="(item, index) in professionList" :key="index"> |
|
<view v-for="(sonItem, sonItemIndex) in item.sunList" :key="sonItemIndex" class="sonItem" @tap="sonItemClick" :data-id="sonItem.industrycode" :data-name="sonItem.industryname">{{sonItem.industryname}}</view> |
|
</uni-collapse-item> |
|
</uni-collapse> |
|
<!-- <van-collapse :value="activeName" @change="onChange" accordion> |
|
<van-collapse-item v-for="(item, index) in professionList" :key="index" :title="item.industryname" :name="item.id" vx:for-index="itemIndex"> |
|
<view v-for="(sonItem, sonItemIndex) in item.sunList" :key="sonItemIndex" class="sonItem" @tap="sonItemClick" :data-id="sonItem.industrycode" :data-name="sonItem.industryname">{{sonItem.industryname}}</view> |
|
</van-collapse-item> |
|
</van-collapse> --> |
|
</view> |
|
</template> |
|
|
|
<script> |
|
const app = getApp(); |
|
export default { |
|
data() { |
|
return { |
|
activeName: '1', |
|
professionList: [] |
|
}; |
|
}, |
|
|
|
components: { |
|
}, |
|
props: {}, |
|
|
|
/** |
|
* 生命周期函数--监听页面加载 |
|
*/ |
|
onLoad: function (options) { |
|
this.getProfessionList(); |
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面初次渲染完成 |
|
*/ |
|
onReady: function () {}, |
|
|
|
/** |
|
* 生命周期函数--监听页面显示 |
|
*/ |
|
onShow: function () {}, |
|
|
|
/** |
|
* 生命周期函数--监听页面隐藏 |
|
*/ |
|
onHide: function () {}, |
|
|
|
/** |
|
* 生命周期函数--监听页面卸载 |
|
*/ |
|
onUnload: function () {}, |
|
|
|
/** |
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
*/ |
|
onPullDownRefresh: function () {}, |
|
|
|
/** |
|
* 页面上拉触底事件的处理函数 |
|
*/ |
|
onReachBottom: function () {} |
|
/** |
|
* 用户点击右上角分享 |
|
*/ |
|
// onShareAppMessage: function () { |
|
// } |
|
, |
|
methods: { |
|
onChange(event) { |
|
this.setData({ |
|
activeName: event.detail |
|
}); |
|
}, |
|
|
|
getProfessionList() { |
|
app.http('post', 'api/industry/listIndustry').then(res => { |
|
console.log(res); |
|
|
|
if (res.data.success) { |
|
this.setData({ |
|
professionList: res.data.data |
|
}); |
|
} |
|
}); |
|
}, |
|
|
|
sonItemClick(e) { |
|
console.log(e); |
|
let name = e.currentTarget.dataset.name; |
|
let id = e.currentTarget.dataset.id; |
|
let pages = getCurrentPages(); //获取当前页面js里面的pages里的所有信息。 |
|
|
|
let prevPage = pages[pages.length - 2]; //prevPage 是获取上一个页面的js里面的pages的所有信息。 -2 是上一个页面,-3是上上个页面以此类推。 |
|
//也可以直接给页面上的参数赋值 |
|
//try fix |
|
prevPage.$vm.form.industryId = id; |
|
//try fix |
|
prevPage.$vm.form.profession = name; |
|
uni.navigateBack({ |
|
delta: 1 |
|
}); |
|
} |
|
|
|
} |
|
}; |
|
</script> |
|
<style> |
|
/* pages/user/profession/index.wxss */ |
|
.sonItem{ |
|
font-size: 28rpx; |
|
line-height: 40rpx; |
|
padding: 20rpx; |
|
} |
|
</style> |