platform.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="select_popup_container platform">
  3. <!-- 头部内容 -->
  4. <view class="popup_title">
  5. <view class="popup_title_msn">请选择平台分类</view>
  6. <view class="close" @click="close"><text class="iconfont">&#xe761;</text></view>
  7. </view>
  8. <!-- 头部内容结束 -->
  9. <view class="tap_list">
  10. <view class="tap_list_item" v-for="(item, index) in tapList" :key="index" @click="selectTap(item, index)" :class="{ 'border': selectIndex == index }">
  11. {{item.label}}
  12. </view>
  13. <view class="tap_list_item" :class="{ 'border': selectIndex == -1 }" @click="pleaseSelect">请选择</view>
  14. </view>
  15. <view class="content_list">
  16. <scroll-view scroll-y="true" class="popup_sroll">
  17. <view class="content_list_item" @click="selectItem(item, index)" v-for="(item, index) in selectClassifiedData" :key="index">{{ item.label }}</view>
  18. </scroll-view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. // +----------------------------------------------------------------------
  24. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  25. // +----------------------------------------------------------------------
  26. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  27. // +----------------------------------------------------------------------
  28. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  29. // +----------------------------------------------------------------------
  30. // | Author: CRMEB Team <admin@crmeb.com>
  31. // +----------------------------------------------------------------------
  32. import { navigateTo, serialize, setStorage } from '../../../libs/uniApi.js';
  33. export default {
  34. props: {
  35. // 从外部传入的分类数据(平台分类)
  36. classifiedData: {
  37. type: Array,
  38. default: () => {
  39. return [];
  40. }
  41. }
  42. },
  43. data() {
  44. return {
  45. selectIndex: -1,
  46. tapList: [],
  47. selectClassifiedData: []
  48. };
  49. },
  50. watch: {
  51. classifiedData: {
  52. handler(val) {
  53. this.selectClassifiedData = this.classifiedData
  54. },
  55. deep: true
  56. }
  57. },
  58. created() {
  59. this.selectClassifiedData = serialize(this.classifiedData);
  60. },
  61. methods: {
  62. selectItem(item, index) {
  63. if(!(item.children && item.children.length)) {
  64. this.$emit('getPlatData', item, this.tapList);
  65. return;
  66. }
  67. if(this.selectIndex > -1) {
  68. this.tapList.splice(this.selectIndex + 1, 999);
  69. this.tapList.push(item);
  70. this.selectIndex = -1;
  71. this.selectClassifiedData = serialize(item.children);
  72. return;
  73. }
  74. if(item.children && item.children.length) {
  75. this.tapList.push(item);
  76. this.selectClassifiedData = serialize(item.children);
  77. return;
  78. }
  79. },
  80. // 选择标签
  81. selectTap(item, index) {
  82. this.selectIndex = index;
  83. this.selectClassifiedData = serialize(item.children);
  84. },
  85. // 点击请选择
  86. pleaseSelect() {
  87. this.selectIndex = -1;
  88. this.selectClassifiedData = this.tapList[this.tapList.length - 1].children;
  89. },
  90. // 点击关闭按钮
  91. close() {
  92. this.$emit('close');
  93. }
  94. }
  95. };
  96. </script>
  97. <style lang="scss" scoped>
  98. .select_popup_container {
  99. background: #fff;
  100. border-radius: 16rpx 16rpx 0 0;
  101. }
  102. .popup_title {
  103. display: flex;
  104. justify-content: flex-end;
  105. padding: 36rpx 30rpx;
  106. position: relative;
  107. &_msn {
  108. position: absolute;
  109. top: 50%;
  110. left: 50%;
  111. transform: translate(-50%, -50%);
  112. color: #282828;
  113. font-size: 32rpx;
  114. font-weight: bold;
  115. }
  116. .close {
  117. position: relative;
  118. z-index: 10;
  119. font-size: 28rpx;
  120. color: #8a8a8a;
  121. }
  122. }
  123. .tap_list {
  124. margin-top: 35rpx;
  125. border-bottom: 1px solid #EEEEEE;
  126. width: 710rpx;
  127. margin: auto;
  128. margin-bottom: 40rpx;
  129. display: flex;
  130. .border {
  131. border-bottom: 2px solid #E93323 !important;
  132. color: #E93323 !important;
  133. }
  134. &_item {
  135. padding-bottom: 18rpx;
  136. margin-right: 30rpx;
  137. }
  138. }
  139. .content_list {
  140. .popup_sroll {
  141. height: 742rpx;
  142. }
  143. .content_list_item {
  144. color: #333333;
  145. margin-bottom: 50rpx;
  146. margin-left: 30rpx;
  147. margin-right: 30rpx;
  148. display: flex;
  149. align-items: center;
  150. justify-content: space-between;
  151. > view {
  152. flex: 0.6;
  153. }
  154. > view:nth-child(2) {
  155. flex: 0.4;
  156. display: flex;
  157. justify-content: flex-end;
  158. }
  159. .iconfont {
  160. color: #e93323;
  161. font-size: 36rpx !important;
  162. }
  163. }
  164. }
  165. </style>