cate-two.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="cate-two flex col-top" style="height: 100%;">
  3. <!-- 左侧 -->
  4. <view class="aside bg-white">
  5. <scroll-view style="height: 100%" scroll-y="true" scroll-with-animation="true">
  6. <block v-for="(item, index) in cateList" :key="index">
  7. <view class="first-cate"></view>
  8. <view :class="'one-item xs ' + (index == selectIndex ? 'active' : 'muted')"
  9. @click="changeActive(index)">
  10. <view v-if="index == selectIndex" class="active-line bg-primary "></view>
  11. <text class="name xs flex-1">{{ item.title }}</text>
  12. <u-icon :name="(index == selectIndex ? 'arrow-down' : 'arrow-right')" size="28"></u-icon>
  13. </view>
  14. <!-- 二级分类 -->
  15. <view class="muted xs" v-for="(twoItem, twoIndex) in cateTwoList" :key="twoIndex"
  16. v-if="index == selectIndex">
  17. <view :class="'one-item xs ' + (twoIndex == selectTowIndex ? 'active' : '')"
  18. @click.stop="changeTwoActive(twoIndex)">
  19. <text class="name xs flex-1">{{ twoItem.title }}</text>
  20. <!-- <view v-if="twoIndex == selectTowIndex" class="active-line bg-primary"></view> -->
  21. </view>
  22. </view>
  23. </block>
  24. </scroll-view>
  25. </view>
  26. <!-- 右侧 -->
  27. <view class="main" id="main">
  28. <!-- 产业链 -->
  29. <u-tabs :list="cateThreeList" name="title" :is-scroll="true" :current="currentTab" :bold="false"
  30. active-color="#DD4250" height="80" font-size="24" @change="changeTab" />
  31. <!-- 列表 -->
  32. <talents-list :cid="cateTwoId" :chain="chain" :top="top"></talents-list>
  33. <!-- 过时的 -->
  34. <view class="main-wrap" v-if="false">
  35. <view class="cate-two">
  36. <view class="p-t-20">
  37. <!-- <view class="bg-white" v-for="(item, index) in list" :key="index">
  38. <record-cell :remark="item.source_type" :date="item.create_time_format"
  39. :money="item.change_amount_format" :type="item.change_type" />
  40. </view> -->
  41. </view>
  42. <view class="two-item bg-white m-b-20" v-if="false">
  43. <!-- 产业链 -->
  44. <view class="title flex col-center row-between">
  45. <text
  46. style="width: 12rpx;height: 12rpx;background: #DD4250;border-radius: 50%; margin-right: 20rpx;"></text>
  47. <text class="name bold sm flex-1">产业链</text>
  48. </view>
  49. <view class="three-list flex flex-wrap" style="padding: 20rpx;">
  50. <view class="three-item" style="padding: 6rpx;width: 50%;"
  51. v-for="(sitem, sindex) in cateThreeList" :key="sindex" v-if="sitem.type == 1"
  52. @tap="childrenCate(sitem)">
  53. <view class=" flex-col col-center" style="background: #F7F8FA; padding: 16rpx 50rpx;">
  54. <view class="text xs">{{ sitem.title }}</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. getCategoryTree
  67. } from '@/api/app';
  68. import {
  69. mapGetters,
  70. mapActions
  71. } from 'vuex'
  72. import {
  73. loadingType,
  74. } from '@/utils/type.js'
  75. import {
  76. pxToRpx
  77. } from '@/utils/tools'
  78. export default {
  79. name: "cate-two",
  80. props: {
  81. // top: {
  82. // type: Number
  83. // },
  84. },
  85. data() {
  86. return {
  87. cateList: [],
  88. selectIndex: 0, //一级分类索引
  89. selectTowIndex: 0, //二级分类索引
  90. cateTwoList: [], //二级分类列表
  91. cateThreeList: [], //三级分类列表
  92. cateTwoId: 0,
  93. sortConfig: {
  94. goodsType: 'double',
  95. priceSort: '',
  96. saleSort: '',
  97. },
  98. status: loadingType.LOADING,
  99. hasData: true,
  100. chain: '', //todo 搜索关键词
  101. //产业链配置
  102. currentTab: 0,
  103. upOption: {
  104. empty: {
  105. icon: '/static/images/order_null.png',
  106. tip: '暂无数据', // 提示
  107. }
  108. },
  109. top: 0
  110. };
  111. },
  112. created() {
  113. this.getListFun()
  114. },
  115. mounted() {
  116. },
  117. updated: function() {
  118. this.$nextTick(() => {
  119. // 仅在整个视图都被重新渲染之后才会运行的代码
  120. setTimeout(() => {
  121. uni.createSelectorQuery().in(this).select('#main')
  122. .boundingClientRect(data => {
  123. console.log("得到布局位置信息" + JSON.stringify(data));
  124. this.top = pxToRpx(data.top) + 80
  125. }).exec();
  126. }, 30)
  127. });
  128. },
  129. methods: {
  130. async getListFun() {
  131. const {
  132. code,
  133. data
  134. } = await getCategoryTree({})
  135. if (code == 1) {
  136. this.cateList = data
  137. this.cateList.forEach((item, index) => {
  138. if (item.id == this.userInfo.chain.pid) {
  139. this.selectIndex = index;
  140. }
  141. });
  142. this.cateTwoList = data[this.selectIndex].children
  143. this.cateTwoList.forEach((item, index) => {
  144. if (item.id == this.userInfo.chain.id) {
  145. this.selectTowIndex = index;
  146. }
  147. });
  148. this.cateThreeSet()
  149. }
  150. },
  151. changeActive(index) {
  152. this.$toast({
  153. title: '您无法查看企业所属产业分类之外的图谱信息',
  154. duration: 3000
  155. })
  156. return false;
  157. this.selectIndex = index
  158. this.selectTowIndex = 0 //二级分类索引重置0
  159. this.cateTwoList = this.cateList[this.selectIndex].children
  160. this.cateThreeSet()
  161. },
  162. changeTwoActive(index) {
  163. this.$toast({
  164. title: '您无法查看企业所属产业分类之外的图谱信息',
  165. duration: 3000
  166. })
  167. return false;
  168. this.selectTowIndex = index
  169. this.cateThreeSet()
  170. },
  171. onRefresh() {
  172. this.status = loadingType.LOADING
  173. this.page = 1
  174. },
  175. //产业链
  176. cateThreeSet() {
  177. this.cateTwoId = this.cateTwoList[this.selectTowIndex].id
  178. let children = this.cateTwoList[this.selectTowIndex].children
  179. console.log(children)
  180. if (children[0].title != '全部') {
  181. children.unshift({
  182. type: 1,
  183. title: '全部'
  184. })
  185. }
  186. this.currentTab = 0;
  187. this.cateThreeList = children.filter((item, index) => item.type == 1)
  188. if (this.cateThreeList.length > 0) {
  189. this.refreshTalents();
  190. } else {
  191. // this.cateTwoId = 0;
  192. }
  193. },
  194. childrenCate(cate) {
  195. if (cate.children) {
  196. this.cateThreeList = cate.children
  197. } else {
  198. //没有子分类,跳转人才列表页面
  199. console.log(cate)
  200. uni.navigateTo({
  201. url: '/pages/talents/talents?cate_id=' + cate.id
  202. })
  203. }
  204. },
  205. // 改变当前的Tabs位置
  206. changeTab(index) {
  207. this.currentTab = index;
  208. this.refreshTalents()
  209. },
  210. refreshTalents() {
  211. // this.cateTwoId = this.cateThreeList[this.currentTab].id
  212. this.chain = this.cateThreeList[this.currentTab].title
  213. //通风报信
  214. uni.$emit("refreshTalentsList", {
  215. cid: this.cateTwoId,
  216. chain: this.chain,
  217. top: this.top
  218. })
  219. },
  220. },
  221. watch: {
  222. 'sortConfig.saleSort'() {
  223. this.onRefresh()
  224. },
  225. 'sortConfig.priceSort'() {
  226. this.onRefresh()
  227. }
  228. },
  229. computed: {
  230. ...mapGetters(['appConfig', 'sysInfo', 'userInfo']),
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .cate-two {
  236. .aside {
  237. width: 250rpx;
  238. flex: none;
  239. height: 100%;
  240. .first-cate {
  241. margin: 0 20rpx 0rpx 40rpx;
  242. border-top: $-solid-border;
  243. }
  244. .first-cate:first-child {
  245. border: none;
  246. }
  247. .one-item {
  248. position: relative;
  249. text-align: center;
  250. padding: 26rpx 10rpx;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. &.active {
  255. color: $-color-primary;
  256. font-size: 26rpx;
  257. font-weight: bold;
  258. }
  259. .active-line {
  260. position: absolute;
  261. width: 6rpx;
  262. height: 30rpx;
  263. left: 4rpx;
  264. top: 50%;
  265. transform: translateY(-50%);
  266. }
  267. }
  268. }
  269. .main {
  270. height: 100%;
  271. flex: 1;
  272. width: 500rpx;
  273. padding-left: 16rpx;
  274. /deep/ .u-tabs {
  275. border-radius: 0 0 12rpx 12rpx;
  276. box-shadow: 0px 4px 8px 1px rgba(0, 0, 0, 0.03)
  277. }
  278. .main-wrap {
  279. position: relative;
  280. .two-item {
  281. border-radius: 10rpx;
  282. .title {
  283. height: 90rpx;
  284. padding: 0 20rpx;
  285. .line {
  286. width: 40rpx;
  287. height: 1px;
  288. background-color: #BBBBBB;
  289. }
  290. }
  291. }
  292. .three-list {
  293. align-items: flex-start;
  294. padding: 0 10rpx;
  295. .three-item {
  296. width: 33%;
  297. .text {
  298. text-align: center;
  299. }
  300. }
  301. }
  302. }
  303. .goods .item {
  304. border-radius: 14rpx;
  305. }
  306. }
  307. }
  308. </style>