cate-two.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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.cateTwoList = data[this.selectIndex].children
  138. this.cateThreeSet()
  139. }
  140. },
  141. changeActive(index) {
  142. this.selectIndex = index
  143. this.selectTowIndex = 0 //二级分类索引重置0
  144. this.cateTwoList = this.cateList[this.selectIndex].children
  145. this.cateThreeSet()
  146. },
  147. changeTwoActive(index) {
  148. this.selectTowIndex = index
  149. this.cateThreeSet()
  150. },
  151. onRefresh() {
  152. this.status = loadingType.LOADING
  153. this.page = 1
  154. },
  155. //产业链
  156. cateThreeSet() {
  157. this.cateTwoId = this.cateTwoList[this.selectTowIndex].id
  158. let children = this.cateTwoList[this.selectTowIndex].children
  159. console.log(children)
  160. if (children[0].title != '全部') {
  161. children.unshift({
  162. type: 1,
  163. title: '全部'
  164. })
  165. }
  166. this.currentTab = 0;
  167. this.cateThreeList = children.filter((item, index) => item.type == 1)
  168. if (this.cateThreeList.length > 0) {
  169. this.refreshTalents();
  170. } else {
  171. // this.cateTwoId = 0;
  172. }
  173. },
  174. childrenCate(cate) {
  175. if (cate.children) {
  176. this.cateThreeList = cate.children
  177. } else {
  178. //没有子分类,跳转人才列表页面
  179. console.log(cate)
  180. uni.navigateTo({
  181. url: '/pages/talents/talents?cate_id=' + cate.id
  182. })
  183. }
  184. },
  185. // 改变当前的Tabs位置
  186. changeTab(index) {
  187. this.currentTab = index;
  188. this.refreshTalents()
  189. },
  190. refreshTalents() {
  191. // this.cateTwoId = this.cateThreeList[this.currentTab].id
  192. this.chain = this.cateThreeList[this.currentTab].title
  193. //通风报信
  194. uni.$emit("refreshTalentsList", {
  195. cid: this.cateTwoId,
  196. chain: this.chain,
  197. top: this.top
  198. })
  199. },
  200. },
  201. watch: {
  202. 'sortConfig.saleSort'() {
  203. this.onRefresh()
  204. },
  205. 'sortConfig.priceSort'() {
  206. this.onRefresh()
  207. }
  208. },
  209. computed: {
  210. ...mapGetters(['appConfig', 'sysInfo']),
  211. }
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. .cate-two {
  216. .aside {
  217. width: 250rpx;
  218. flex: none;
  219. height: 100%;
  220. .first-cate {
  221. margin: 0 20rpx 0rpx 40rpx;
  222. border-top: $-solid-border;
  223. }
  224. .first-cate:first-child {
  225. border: none;
  226. }
  227. .one-item {
  228. position: relative;
  229. text-align: center;
  230. padding: 26rpx 10rpx;
  231. display: flex;
  232. align-items: center;
  233. justify-content: space-between;
  234. &.active {
  235. color: $-color-primary;
  236. font-size: 26rpx;
  237. font-weight: bold;
  238. }
  239. .active-line {
  240. position: absolute;
  241. width: 6rpx;
  242. height: 30rpx;
  243. left: 4rpx;
  244. top: 50%;
  245. transform: translateY(-50%);
  246. }
  247. }
  248. }
  249. .main {
  250. height: 100%;
  251. flex: 1;
  252. width: 500rpx;
  253. padding-left: 16rpx;
  254. /deep/ .u-tabs {
  255. border-radius: 0 0 12rpx 12rpx;
  256. box-shadow: 0px 4px 8px 1px rgba(0, 0, 0, 0.03)
  257. }
  258. .main-wrap {
  259. position: relative;
  260. .two-item {
  261. border-radius: 10rpx;
  262. .title {
  263. height: 90rpx;
  264. padding: 0 20rpx;
  265. .line {
  266. width: 40rpx;
  267. height: 1px;
  268. background-color: #BBBBBB;
  269. }
  270. }
  271. }
  272. .three-list {
  273. align-items: flex-start;
  274. padding: 0 10rpx;
  275. .three-item {
  276. width: 33%;
  277. .text {
  278. text-align: center;
  279. }
  280. }
  281. }
  282. }
  283. .goods .item {
  284. border-radius: 14rpx;
  285. }
  286. }
  287. }
  288. </style>