chain.vue 8.0 KB

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