You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

403 lines
10 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <div class="productContent">
  3. <div class="selectBox" @click="handelMenu" :class="{ 'active': isOpen }">
  4. <span class="placeholder" :style="{ color: selectedItem ? '#333' : '#A8ABB2' }">
  5. {{ selectedItem || placeholder }}
  6. </span>
  7. <span class="arrow">
  8. <el-icon>
  9. <ArrowDown />
  10. </el-icon>
  11. </span>
  12. </div>
  13. <div class="menu" v-show="isOpen">
  14. <div class="coinselect" @click="coinhandelMenu" :class="{ 'active': coinisOpen }">
  15. <div class="cointxt">
  16. 金币产品
  17. </div>
  18. <span class="coin-arrow">
  19. <el-icon>
  20. <ArrowDown />
  21. </el-icon>
  22. </span>
  23. </div>
  24. <div class="coinoption" v-show="coinisOpen">
  25. <el-radio v-model="selectedValue" label="金币充值" size="large" />
  26. </div>
  27. <div class="product">
  28. <div class="coinselect" @click="producthandelMenu" :class="{ 'active': productisOpen }">
  29. <div class="cointxt">
  30. 软件产品
  31. </div>
  32. <span class="coin-arrow">
  33. <el-icon>
  34. <ArrowDown />
  35. </el-icon>
  36. </span>
  37. </div>
  38. <div class="productOption" v-show="productisOpen">
  39. <hr class="line">
  40. <div class="checktxt">软件</div>
  41. <div class="marketprodut">
  42. <div class="fistlevel" v-for="(menu, index) in menuData" :key="menu.name" @click="clickmenu(index)"
  43. :class="{ 'selected': menu.options.includes(selectedValue) }">
  44. <div class="label">
  45. {{ menu.name }}
  46. <el-icon :class="{ 'rotate': activeIndex === index }">
  47. <ArrowDown />
  48. </el-icon>
  49. </div>
  50. <div v-show="activeIndex == index" class="selectoption" @click.stop>
  51. <el-radio-group v-model="selectedValue">
  52. <div class="option" v-for="product in menu.options" :key="product">
  53. <el-radio :label="product">
  54. {{ product }}
  55. </el-radio>
  56. </div>
  57. </el-radio-group>
  58. </div>
  59. </div>
  60. </div>
  61. <hr class="line">
  62. <div class="ai">
  63. <div class="checktxt">AI机构探测神器</div>
  64. <hr class="line">
  65. <el-radio-group v-model="selectedValue">
  66. <el-radio v-for="ai in AIProduct" :key="ai" :label="ai" :value="ai">
  67. {{ ai }}
  68. </el-radio>
  69. </el-radio-group>
  70. </div>
  71. <div class="ai">
  72. <div class="checktxt">超级机构探测神器</div>
  73. <hr class="line">
  74. <el-radio-group v-model="selectedValue">
  75. <el-radio v-for="ai in superProduct" :key="ai" :label="ai" :value="ai">
  76. {{ ai }}
  77. </el-radio>
  78. </el-radio-group>
  79. </div>
  80. <div class="ai">
  81. <div class="checktxt">其他</div>
  82. <hr class="line">
  83. <el-radio-group v-model="selectedValue">
  84. <el-radio v-for="ai in InfoFee" :key="ai" :label="ai" :value="ai">
  85. {{ ai }}
  86. </el-radio>
  87. </el-radio-group>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </template>
  94. <script setup>
  95. import { ref, watch, onMounted, computed, onUnmounted, nextTick } from 'vue';
  96. import { ArrowDown } from '@element-plus/icons-vue';
  97. const searchData = ref('')
  98. const isOpen = ref(false)
  99. const coinisOpen = ref(false)
  100. const productisOpen = ref(false)
  101. const selectedItem = ref('')
  102. const dropdownRef = ref(null)
  103. const placeholder = ref('请选择产品')
  104. const handelMenu = () => {
  105. isOpen.value = !isOpen.value
  106. ifselectAndOpen()
  107. }
  108. const coinhandelMenu = () => {
  109. coinisOpen.value = !coinisOpen.value
  110. }
  111. const producthandelMenu = () => {
  112. productisOpen.value = !productisOpen.value
  113. }
  114. // 接收父组件通过 v-model 传入的值
  115. const props = defineProps({
  116. modelValue: {
  117. type: String,
  118. default: ''
  119. }
  120. })
  121. const emit = defineEmits(['update:modelValue'])
  122. const selectedValue = ref('')
  123. watch(selectedValue, (newVal) => {
  124. emit('update:modelValue', newVal ? newVal : '');
  125. selectedItem.value = newVal || '';
  126. });
  127. const AIProduct = ['AI机构追踪', 'AI机构出击 ', 'AI机构资金', 'AI机活跃度']
  128. const superProduct = ['超级机构透视', '超级机构伏击 ', '超级机构猎杀', '超级机构脉搏', '超级机构罗盘']
  129. const InfoFee = ['静态信息费', '博股会员']
  130. const menuData = [
  131. {
  132. name: '美股',
  133. options: ['美服软件', '美服金卡', '美服套餐']
  134. },
  135. {
  136. name: '新加坡股',
  137. options: ['新加坡软件', '新加坡服务']
  138. },
  139. {
  140. name: '韩股',
  141. options: ['韩服工具', '韩服会员']
  142. },
  143. {
  144. name: '港股',
  145. options: ['韩服工具', '韩服会员']
  146. }
  147. ];
  148. //全局事件实现点击外部关闭选项
  149. const closeSoftwareSubmenu = () => {
  150. activeIndex.value = -1; // 将展开的二级菜单索引重置为 -1,实现关闭
  151. };
  152. const closeWholeDropdown = () => {
  153. isOpen.value = false; // 关闭整个弹窗
  154. // 可选:同时关闭弹窗内的子面板(如金币产品、软件产品展开面板)
  155. coinisOpen.value = false;
  156. productisOpen.value = false;
  157. closeSoftwareSubmenu(); // 同时关闭软件二级选项框
  158. };
  159. const handleGlobalClick = (e) => {
  160. // --- 原有:处理软件二级选项框外部关闭逻辑 ---
  161. if (productisOpen.value) {
  162. const submenuContainers = document.querySelectorAll('.selectoption');
  163. const firstLevelContainers = document.querySelectorAll('.fistlevel');
  164. let isClickInsideSubmenu = false;
  165. let isClickInsideFirstLevel = false;
  166. submenuContainers.forEach(container => container.contains(e.target) && (isClickInsideSubmenu = true));
  167. firstLevelContainers.forEach(container => container.contains(e.target) && (isClickInsideFirstLevel = true));
  168. if (!isClickInsideSubmenu && !isClickInsideFirstLevel) {
  169. closeSoftwareSubmenu();
  170. }
  171. }
  172. // --- 新增:处理整个弹窗外部关闭逻辑 ---
  173. if (isOpen.value) { // 仅当弹窗处于打开状态时判断
  174. // 获取整个下拉弹窗的 DOM 容器
  175. const dropdownContainer = document.querySelector('.menu');
  176. // 获取弹窗触发按钮(类名 .selectBox),点击按钮需正常切换弹窗,不触发关闭
  177. const triggerButton = document.querySelector('.selectBox');
  178. // 点击位置不在弹窗内,且不在触发按钮内 → 关闭整个弹窗
  179. if (!dropdownContainer?.contains(e.target) && !triggerButton?.contains(e.target)) {
  180. closeWholeDropdown();
  181. }
  182. }
  183. };
  184. const ifselectAndOpen = async () => {
  185. await nextTick();
  186. if (selectedValue.value == '金币充值') {
  187. coinisOpen.value = true
  188. } else if (selectedValue.value) {
  189. productisOpen.value = true
  190. } else {
  191. //不做处理
  192. }
  193. }
  194. //软件相关
  195. const activeIndex = ref(-1)
  196. const clickmenu = (index) => {
  197. activeIndex.value = activeIndex.value === index ? -1 : index;
  198. }
  199. onMounted(async () => {
  200. selectedValue.value = props.modelValue;
  201. selectedItem.value = selectedValue.value || '';
  202. document.addEventListener('click', handleGlobalClick); // 绑定全局事件
  203. });
  204. onUnmounted(() => {
  205. document.removeEventListener('click', handleGlobalClick); // 解绑全局事件
  206. });
  207. </script>
  208. <style scoped lang="scss">
  209. .productContent {
  210. position: relative;
  211. width: 450px;
  212. font-family: 'Arial', sans-serif;
  213. }
  214. .selectBox {
  215. border: 1px solid #e5e7eb;
  216. padding: 4px 12px;
  217. height: 23px;
  218. cursor: pointer;
  219. display: flex;
  220. justify-content: space-between;
  221. align-items: center;
  222. background-color: #fff;
  223. border-radius: 6px;
  224. transition: all 0.3s ease;
  225. .placeholder {
  226. flex: 1;
  227. font-size: 14px;
  228. line-height: 18px;
  229. color: #A8ABB2;
  230. }
  231. }
  232. .arrow {
  233. margin-left: 8px;
  234. color: #999;
  235. transition: transform 0.3s ease;
  236. }
  237. .selectBox.active .arrow {
  238. transform: rotate(180deg);
  239. }
  240. .menu {
  241. position: absolute;
  242. top: 100%;
  243. left: 0;
  244. width: 160%;
  245. max-height: 600px;
  246. min-height: 200px;
  247. display: flex;
  248. padding: 10px;
  249. flex-direction: column;
  250. align-items: flex-start;
  251. gap: 10px;
  252. flex-shrink: 0;
  253. border-radius: 8px;
  254. background: #E4F0FC;
  255. box-shadow: 0 0 4px 0 #00000040;
  256. z-index: 100;
  257. .coinselect {
  258. width: 100px;
  259. height: 20px;
  260. border: 1px solid #175BE5;
  261. padding: 5px 0 5px 12px;
  262. display: flex;
  263. border-radius: 5px;
  264. .cointxt {
  265. width: 70px;
  266. height: 100%;
  267. display: flex;
  268. justify-content: center;
  269. align-items: center;
  270. color: #175be5;
  271. text-align: center;
  272. font-family: "PingFang SC";
  273. font-size: 14px;
  274. font-style: normal;
  275. font-weight: 700;
  276. line-height: 20px;
  277. }
  278. }
  279. .coin-arrow {
  280. flex: 1;
  281. display: flex;
  282. justify-content: center;
  283. align-items: center;
  284. color: #175BE5;
  285. }
  286. .coinselect.active .coin-arrow {
  287. transform: rotate(-90deg);
  288. }
  289. .product {
  290. width: 100%;
  291. .line {
  292. display: flex;
  293. height: 1px;
  294. padding: 0 16px;
  295. align-items: flex-start;
  296. align-content: flex-start;
  297. gap: 8px 60px;
  298. flex-shrink: 0;
  299. align-self: stretch;
  300. flex-wrap: wrap;
  301. border-top: 1px solid #7E91FF;
  302. }
  303. .checktxt {
  304. color: #5870ff;
  305. font-family: "PingFang SC";
  306. font-size: 13px;
  307. font-style: normal;
  308. font-weight: 700;
  309. line-height: 22px;
  310. margin: 10px 20px;
  311. }
  312. .productOption {
  313. width: 100%;
  314. .ai {
  315. width: 100%;
  316. }
  317. .marketprodut {
  318. width: 100%;
  319. display: flex;
  320. flex-wrap: wrap;
  321. gap: 10px;
  322. .fistlevel {
  323. position: relative;
  324. width: 130px;
  325. .label .el-icon {
  326. margin-left: 5px;
  327. transition: transform 0.3s ease;
  328. }
  329. .label .rotate {
  330. transform: rotate(-90deg); // 箭头旋转效果
  331. }
  332. .label {
  333. margin-left: 10px;
  334. }
  335. .selectoption {
  336. width: 100px;
  337. background-color: #fff;
  338. padding: 5px 20px;
  339. position: absolute;
  340. left: 60px;
  341. top: 0;
  342. z-index: 999;
  343. border: 1px solid #175BE5;
  344. border-radius: 6px;
  345. :deep(.el-checkbox__label) {
  346. color: #333333;
  347. font-family: "PingFang SC";
  348. font-size: 13px;
  349. font-style: normal;
  350. font-weight: 400;
  351. line-height: 22px;
  352. }
  353. }
  354. }
  355. .fistlevel.selected .label {
  356. color: #175BE5;
  357. }
  358. }
  359. }
  360. }
  361. }
  362. </style>