platform.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. import { navigateTo, serialize, setStorage } from '../../../libs/uniApi.js';
  24. export default {
  25. props: {
  26. // 从外部传入的分类数据(平台分类)
  27. classifiedData: {
  28. type: Array,
  29. default: () => {
  30. return [];
  31. }
  32. }
  33. },
  34. data() {
  35. return {
  36. selectIndex: -1,
  37. tapList: [],
  38. selectClassifiedData: []
  39. };
  40. },
  41. watch: {
  42. classifiedData: {
  43. handler(val) {
  44. this.selectClassifiedData = this.classifiedData
  45. },
  46. deep: true
  47. }
  48. },
  49. created() {
  50. this.selectClassifiedData = serialize(this.classifiedData);
  51. },
  52. methods: {
  53. selectItem(item, index) {
  54. if(!(item.children && item.children.length)) {
  55. this.$emit('getPlatData', item, this.tapList);
  56. return;
  57. }
  58. if(this.selectIndex > -1) {
  59. this.tapList.splice(this.selectIndex + 1, 999);
  60. this.tapList.push(item);
  61. this.selectIndex = -1;
  62. this.selectClassifiedData = serialize(item.children);
  63. return;
  64. }
  65. if(item.children && item.children.length) {
  66. this.tapList.push(item);
  67. this.selectClassifiedData = serialize(item.children);
  68. return;
  69. }
  70. },
  71. // 选择标签
  72. selectTap(item, index) {
  73. this.selectIndex = index;
  74. this.selectClassifiedData = serialize(item.children);
  75. },
  76. // 点击请选择
  77. pleaseSelect() {
  78. this.selectIndex = -1;
  79. this.selectClassifiedData = this.tapList[this.tapList.length - 1].children;
  80. },
  81. // 点击关闭按钮
  82. close() {
  83. this.$emit('close');
  84. }
  85. }
  86. };
  87. </script>
  88. <style lang="scss" scoped>
  89. .select_popup_container {
  90. background: #fff;
  91. border-radius: 16rpx 16rpx 0 0;
  92. }
  93. .popup_title {
  94. display: flex;
  95. justify-content: flex-end;
  96. padding: 36rpx 30rpx;
  97. position: relative;
  98. &_msn {
  99. position: absolute;
  100. top: 50%;
  101. left: 50%;
  102. transform: translate(-50%, -50%);
  103. color: #282828;
  104. font-size: 32rpx;
  105. font-weight: bold;
  106. }
  107. .close {
  108. position: relative;
  109. z-index: 10;
  110. font-size: 28rpx;
  111. color: #8a8a8a;
  112. }
  113. }
  114. .tap_list {
  115. margin-top: 35rpx;
  116. border-bottom: 1px solid #EEEEEE;
  117. width: 710rpx;
  118. margin: auto;
  119. margin-bottom: 40rpx;
  120. display: flex;
  121. .border {
  122. border-bottom: 2px solid #E93323 !important;
  123. color: #E93323 !important;
  124. }
  125. &_item {
  126. padding-bottom: 18rpx;
  127. margin-right: 30rpx;
  128. }
  129. }
  130. .content_list {
  131. .popup_sroll {
  132. height: 742rpx;
  133. }
  134. .content_list_item {
  135. color: #333333;
  136. margin-bottom: 50rpx;
  137. margin-left: 30rpx;
  138. margin-right: 30rpx;
  139. display: flex;
  140. align-items: center;
  141. justify-content: space-between;
  142. > view {
  143. flex: 0.6;
  144. }
  145. > view:nth-child(2) {
  146. flex: 0.4;
  147. display: flex;
  148. justify-content: flex-end;
  149. }
  150. .iconfont {
  151. color: #e93323;
  152. font-size: 36rpx !important;
  153. }
  154. }
  155. }
  156. </style>