chain.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <u-popup v-model="show" mode="bottom" closeable border-radius="14" safe-area-inset-bottom :duration="100">
  3. <view class="content-wrapper">
  4. <!-- 头部 -->
  5. <u-sticky>
  6. <view class="sticky">
  7. <view class="sticky-title xl normal bold">产业链</view>
  8. </view>
  9. </u-sticky>
  10. <!-- 内容 -->
  11. <view class="cate-two flex col-top" style="height: 100%;">
  12. <!-- 左侧 -->
  13. <view class="aside bg-white">
  14. <scroll-view style="height: 100%" scroll-y="true" scroll-with-animation="true">
  15. <block v-for="(item, index) in cateList" :key="index">
  16. <view class="first-cate"></view>
  17. <view :class="'one-item xs ' + (index == selectIndex ? 'active' : 'muted')"
  18. @click="changeActive(index)">
  19. <view v-if="index == selectIndex" class="active-line bg-primary "></view>
  20. <text class="name xs flex-1">{{ item.title }}</text>
  21. <u-icon :name="(index == selectIndex ? 'arrow-down' : 'arrow-right')"
  22. size="28"></u-icon>
  23. </view>
  24. <!-- 二级分类 -->
  25. <view class="muted xs" v-for="(twoItem, twoIndex) in cateTwoList" :key="twoIndex"
  26. v-if="index == selectIndex">
  27. <view :class="'one-item xs ' + (twoIndex == selectTowIndex ? 'active' : '')"
  28. @click.stop="changeTwoActive(twoIndex)">
  29. <text class="name xs flex-1">{{ twoItem.title }}</text>
  30. </view>
  31. </view>
  32. </block>
  33. </scroll-view>
  34. </view>
  35. <!-- 右侧 -->
  36. <view class="main">
  37. <view class="main-wrap">
  38. <view class="cate-two">
  39. <view class="two-item bg-white m-b-20">
  40. <view class="three-list flex flex-wrap" style="padding: 20rpx;">
  41. <view class="text-center w-full p-6" v-for="(sitem, sindex) in cateThreeList"
  42. :key="sindex" v-if="sitem.type == 1" @tap="changeThreeActive(sitem)">
  43. <view class="three-item flex row-between"
  44. :class="{ 'three-active': cateThreeId == sitem.id }">
  45. <view></view>
  46. <view class="flex-1 xs">{{ sitem.title }}</view>
  47. <view>
  48. <u-icon name="checkmark" size="28" color="#F37171" v-if="cateThreeId == sitem.id"></u-icon>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </u-popup>
  60. </template>
  61. <script>
  62. import {
  63. getCategoryTree
  64. } from '@/api/app';
  65. export default {
  66. name: "chain",
  67. props: {
  68. value: {
  69. type: Boolean
  70. },
  71. },
  72. data() {
  73. return {
  74. keyword: '',
  75. hideRight: true,
  76. menuCurrentIndex: 0,
  77. topicData: [],
  78. cateList: [],
  79. selectIndex: 0, //一级分类索引
  80. selectTowIndex: 0, //二级分类索引
  81. selectThreeIndex: null, //二级分类索引
  82. cateTwoList: [], //二级分类列表
  83. cateThreeList: [], //三级分类列表
  84. cateThreeId: 0,
  85. }
  86. },
  87. created() {
  88. this.getListFun()
  89. },
  90. computed: {
  91. // 弹窗Popup显示状态
  92. show: {
  93. get: function() {
  94. return this.value
  95. },
  96. set: function(value) {
  97. this.$emit('input', value)
  98. }
  99. }
  100. },
  101. methods: {
  102. // 获取
  103. async getListFun() {
  104. const {
  105. code,
  106. data
  107. } = await getCategoryTree({})
  108. if (code == 1) {
  109. this.cateList = data
  110. this.cateTwoList = data[this.selectIndex].children
  111. this.cateThreeSet()
  112. }
  113. },
  114. changeActive(index) {
  115. this.selectIndex = index
  116. this.selectTowIndex = 0 //二级分类索引重置0
  117. this.cateTwoList = this.cateList[this.selectIndex].children
  118. this.cateThreeSet()
  119. },
  120. changeTwoActive(index) {
  121. this.selectTowIndex = index
  122. this.cateThreeSet()
  123. },
  124. changeThreeActive(item) {
  125. this.cateThreeId = item.id
  126. this.$emit('change', item)
  127. this.$emit('input', false)
  128. },
  129. cateThreeSet() {
  130. let children = this.cateTwoList[this.selectTowIndex].children
  131. this.cateThreeList = children.filter((item, index) => item.type == 1)
  132. },
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .bb {
  138. border-bottom: 1px solid $-color-body;
  139. }
  140. .content-wrapper {
  141. height: 900rpx;
  142. .sticky {
  143. width: 100vw;
  144. }
  145. .sticky-title {
  146. padding: 24rpx 0;
  147. text-align: center;
  148. }
  149. .container {
  150. height: 712rpx;
  151. display: flex;
  152. // 左侧菜单
  153. .left-menu {
  154. width: 250rpx;
  155. .submenu {
  156. height: 90rpx;
  157. line-height: 90rpx;
  158. text-align: center;
  159. font-size: 26rpx;
  160. }
  161. // 菜单选中
  162. .active {
  163. font-weight: 500;
  164. color: $-color-primary;
  165. position: relative;
  166. background-color: rgba($-color-primary, 0.1);
  167. }
  168. .active::before {
  169. content: '';
  170. width: 6rpx;
  171. height: 30rpx;
  172. position: absolute;
  173. left: 10rpx;
  174. top: 50%;
  175. transform: translateY(-50%);
  176. background-color: $-color-primary;
  177. }
  178. }
  179. // 右侧内容
  180. .right-content {
  181. width: 100%;
  182. .tags {
  183. padding: 20rpx;
  184. .tags-item {
  185. margin-bottom: 30rpx;
  186. }
  187. image {
  188. width: 120rpx;
  189. height: 120rpx;
  190. border-radius: 50%;
  191. position: relative;
  192. }
  193. image::after {
  194. content: '';
  195. color: #FFFFFF;
  196. font-size: 50rpx;
  197. font-weight: 500;
  198. text-align: center;
  199. line-height: 120rpx;
  200. width: 120rpx;
  201. height: 120rpx;
  202. position: absolute;
  203. border-radius: 50%;
  204. left: 0;
  205. top: 0;
  206. background: rgba(0, 0, 0, 0.1) url('/bundle_b/static/icon_tags.png') no-repeat center center;
  207. background-size: 40rpx;
  208. }
  209. }
  210. }
  211. }
  212. }
  213. .cate-two {
  214. .aside {
  215. width: 250rpx;
  216. flex: none;
  217. height: 100%;
  218. .first-cate {
  219. margin: 0 20rpx 0rpx 40rpx;
  220. border-top: $-solid-border;
  221. }
  222. .first-cate:first-child {
  223. border: none;
  224. }
  225. .one-item {
  226. position: relative;
  227. text-align: center;
  228. padding: 26rpx 10rpx;
  229. display: flex;
  230. align-items: center;
  231. justify-content: space-between;
  232. &.active {
  233. color: $-color-primary;
  234. font-size: 26rpx;
  235. font-weight: bold;
  236. }
  237. .active-line {
  238. position: absolute;
  239. width: 6rpx;
  240. height: 30rpx;
  241. left: 4rpx;
  242. top: 50%;
  243. transform: translateY(-50%);
  244. }
  245. }
  246. }
  247. .main {
  248. height: 100%;
  249. flex: 1;
  250. width: 500rpx;
  251. padding-left: 16rpx;
  252. /deep/ .u-tabs {
  253. border-radius: 0 0 12rpx 12rpx;
  254. box-shadow: 0px 4px 8px 1px rgba(0, 0, 0, 0.03)
  255. }
  256. .main-wrap {
  257. position: relative;
  258. .two-item {
  259. border-radius: 10rpx;
  260. .title {
  261. height: 90rpx;
  262. padding: 0 20rpx;
  263. .line {
  264. width: 40rpx;
  265. height: 1px;
  266. background-color: #BBBBBB;
  267. }
  268. }
  269. }
  270. .three-list {
  271. align-items: flex-start;
  272. padding: 0 10rpx;
  273. .three-item {
  274. background: #F7F8FA;
  275. padding: 16rpx 50rpx;
  276. text-align: center;
  277. border-radius: 12rpx;
  278. }
  279. .three-item.three-active {
  280. border: 2rpx solid #F37171;
  281. font-weight: bold;
  282. color: #F37171;
  283. }
  284. }
  285. }
  286. .goods .item {
  287. border-radius: 14rpx;
  288. }
  289. }
  290. }
  291. </style>