index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <div class="plan-page">
  3. <div class="plan-title">
  4. <!-- <el-tabs v-model="activeName" class="demo-tabs">
  5. <el-tab-pane label="专家处方" name="1"></el-tab-pane>
  6. <el-tab-pane label="我的处方" name="2"></el-tab-pane>
  7. </el-tabs> -->
  8. <div class="tabs">
  9. <div class="tab" :class="{ active: activeTab === 'left' }" @click="setActiveTab('left')">专家处方</div>
  10. <div class="tab" :class="{ active: activeTab === 'right' }" @click="setActiveTab('right')">
  11. 我的处方
  12. <span class="badge-dot">2</span>
  13. </div>
  14. <div class="slider" :style="sliderStyle"></div>
  15. </div>
  16. </div>
  17. <div class="plan-content">
  18. <div class="filter-wrap">
  19. <div class="filter-item type-cascader">
  20. <el-cascader v-model="typeVal" :options="typeOptions"></el-cascader>
  21. </div>
  22. <div class="filter-item">
  23. <el-select v-model="proviceVal" style="width: 76px">
  24. <el-option
  25. v-for="item in proviceOptions"
  26. :key="item.value"
  27. :label="item.label"
  28. :value="item.value"
  29. />
  30. </el-select>
  31. </div>
  32. <div class="filter-item">
  33. <el-select v-model="expertVal" placeholder="推荐专家" style="width: 86px">
  34. <el-option
  35. v-for="item in expertOptions"
  36. :key="item.value"
  37. :label="item.label"
  38. :value="item.value"
  39. />
  40. </el-select>
  41. </div>
  42. <div class="filter-item">
  43. <el-select v-model="filterVal" placeholder="筛选" style="width: 68px">
  44. <el-option
  45. v-for="item in filterOptions"
  46. :key="item.value"
  47. :label="item.label"
  48. :value="item.value"
  49. />
  50. </el-select>
  51. </div>
  52. </div>
  53. <div v-if="activeName === '1'" class="expert-prescription">
  54. <div class="plan-menu">
  55. <el-anchor :container="containerRef" direction="vertical" type="default" @click="handleClick">
  56. <el-menu default-active="1" class="el-menu-vertical-demo">
  57. <el-sub-menu index="1">
  58. <template #title>
  59. <img class="menu-icon" src="@/assets/img/gallery/icon-0.png" alt="">
  60. <span class="menu-text">秋梢期</span>
  61. </template>
  62. <el-menu-item index="1-1"><el-anchor-link href="#part1" title="巡园农事" /></el-menu-item>
  63. <el-menu-item index="1-2">
  64. <el-anchor-link href="#part2" title="梢期防虫" />
  65. </el-menu-item>
  66. <el-menu-item index="1-3">
  67. <el-anchor-link href="#part3" title="梢期营养" />
  68. </el-menu-item>
  69. </el-sub-menu>
  70. <el-sub-menu index="2">
  71. <template #title>
  72. <img class="menu-icon" src="@/assets/img/gallery/icon-1.png" alt="">
  73. <span class="menu-text">开花期</span>
  74. </template>
  75. <el-menu-item index="2-1">
  76. <el-anchor-link href="#part2-1" title="巡园农事" />
  77. </el-menu-item>
  78. <el-menu-item index="2-2">
  79. <el-anchor-link href="#part2-2" title="摇花吹花" />
  80. </el-menu-item>
  81. <el-menu-item index="2-3">
  82. <el-anchor-link href="#part2-3" title="花期防治" />
  83. </el-menu-item>
  84. </el-sub-menu>
  85. </el-menu>
  86. </el-anchor>
  87. </div>
  88. <div class="expert-content" ref="containerRef">
  89. <div id="part1" style="height: 300px; background: rgba(255, 0, 0, 0.02)">part1</div>
  90. <div id="part2" style="height: 300px; background: rgba(0, 255, 0, 0.02); margin-top: 30px">
  91. part2
  92. </div>
  93. <div id="part3" style="height: 300px; background: rgba(0, 0, 255, 0.02); margin-top: 30px">
  94. part3
  95. </div>
  96. <div id="part4" style="height: 300px; background: rgba(0, 0, 255, 0.02); margin-top: 30px">
  97. part4
  98. </div>
  99. </div>
  100. </div>
  101. <div v-if="activeName === '2'" class="my-prescription">我的</div>
  102. </div>
  103. </div>
  104. </template>
  105. <script setup>
  106. import { computed, ref } from "vue";
  107. const activeName = ref("1");
  108. const containerRef = ref(null);
  109. const handleClick = (e) => {
  110. e.preventDefault();
  111. };
  112. const activeTab = ref("left");
  113. // const tabBarHeight = computed(() => store.state.home.tabBarHeight);
  114. const sliderStyle = computed(() => {
  115. // 根据当前激活的选项卡计算滑动条位置
  116. const position = activeTab.value === "left" ? "25%" : "75%";
  117. return {
  118. left: `calc(${position} - 12px)`, // 减去滑动条宽度的一半以实现居中
  119. };
  120. });
  121. function setActiveTab(tab) {
  122. activeTab.value = tab;
  123. }
  124. const typeVal = ref([1, 3]);
  125. const typeOptions = ref([
  126. {
  127. value: 1,
  128. label: "荔枝",
  129. children: [
  130. {
  131. value: 2,
  132. label: "井岗红糯",
  133. },
  134. {
  135. value: 3,
  136. label: "桂味",
  137. },
  138. {
  139. value: 4,
  140. label: "妃子笑",
  141. },
  142. {
  143. value: 5,
  144. label: "黑叶",
  145. },
  146. ],
  147. },
  148. {
  149. value: 6,
  150. label: "龙眼",
  151. children: [
  152. {
  153. value: 7,
  154. label: "龙眼1",
  155. },
  156. {
  157. value: 8,
  158. label: "龙眼2",
  159. },
  160. {
  161. value: 9,
  162. label: "龙眼3",
  163. },
  164. {
  165. value: 10,
  166. label: "龙眼4",
  167. },
  168. ],
  169. },
  170. {
  171. value: 11,
  172. label: "琵琶",
  173. children: [
  174. {
  175. value: 12,
  176. label: "琵琶1",
  177. },
  178. {
  179. value: 13,
  180. label: "琵琶2",
  181. },
  182. {
  183. value: 14,
  184. label: "琵琶3",
  185. },
  186. {
  187. value: 15,
  188. label: "琵琶4",
  189. },
  190. ],
  191. },
  192. ]);
  193. const proviceVal = ref("广东");
  194. const proviceOptions = ref([
  195. {
  196. value: "广东",
  197. label: "广东省",
  198. },
  199. {
  200. value: "广西",
  201. label: "广西省",
  202. },
  203. {
  204. value: "福建",
  205. label: "福建省",
  206. },
  207. {
  208. value: "海南",
  209. label: "海南省",
  210. },
  211. ]);
  212. const expertVal = ref("");
  213. const expertOptions = ref([
  214. {
  215. value: "1",
  216. label: "韦帮稳",
  217. },
  218. {
  219. value: "2",
  220. label: "冼继东",
  221. },
  222. {
  223. value: "3",
  224. label: "专家3",
  225. },
  226. {
  227. value: "4",
  228. label: "专家4",
  229. },
  230. ]);
  231. const filterVal = ref("");
  232. const filterOptions = ref([
  233. {
  234. value: "1",
  235. label: "最新",
  236. },
  237. {
  238. value: "3",
  239. label: "好评",
  240. },
  241. ]);
  242. </script>
  243. <style lang="scss" scoped>
  244. .plan-page {
  245. .plan-title {
  246. width: 158px;
  247. margin: 0 auto;
  248. padding: 6px 0;
  249. .tabs {
  250. display: flex;
  251. position: relative;
  252. height: 36px;
  253. line-height: 36px;
  254. .tab {
  255. flex: 1;
  256. text-align: center;
  257. cursor: pointer;
  258. color: rgba(0, 0, 0, 0.5);
  259. z-index: 2;
  260. transition: color 0.3s ease;
  261. position: relative;
  262. &.active {
  263. color: #000000;
  264. font-weight: bold;
  265. }
  266. .badge-dot {
  267. position: absolute;
  268. top: 0;
  269. right: -6px;
  270. width: 16px;
  271. height: 16px;
  272. background-color: #ff0000;
  273. border-radius: 50%;
  274. font-size: 12px;
  275. line-height: 16px;
  276. color: #fff;
  277. }
  278. }
  279. .slider {
  280. position: absolute;
  281. height: 4px;
  282. width: 24px;
  283. background: #2199f8;
  284. border-radius: 16px;
  285. bottom: 0;
  286. left: calc(25% - 12px); /* 初始位置在第一个选项卡中间 */
  287. transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  288. }
  289. }
  290. .content {
  291. padding: 20px;
  292. background: #f8f9fa;
  293. border-radius: 8px;
  294. min-height: 200px;
  295. }
  296. .content-section {
  297. display: none;
  298. animation: fadeIn 0.5s ease;
  299. }
  300. .content-section.active {
  301. display: block;
  302. }
  303. @keyframes fadeIn {
  304. from {
  305. opacity: 0;
  306. transform: translateY(10px);
  307. }
  308. to {
  309. opacity: 1;
  310. transform: translateY(0);
  311. }
  312. }
  313. .code-example {
  314. margin-top: 30px;
  315. background: #2d3748;
  316. color: #e2e8f0;
  317. padding: 20px;
  318. border-radius: 8px;
  319. font-family: "Fira Code", monospace;
  320. overflow-x: auto;
  321. }
  322. .code-example h3 {
  323. color: #81e6d9;
  324. margin-bottom: 15px;
  325. }
  326. .explanation {
  327. margin-top: 25px;
  328. padding: 15px;
  329. background: #f1f8ff;
  330. border-left: 4px solid #4361ee;
  331. border-radius: 4px;
  332. }
  333. }
  334. .plan-content {
  335. background: #f5f7fb;
  336. .filter-wrap {
  337. padding: 10px 0;
  338. width: 100%;
  339. display: flex;
  340. align-items: center;
  341. justify-content: space-between;
  342. .type-cascader {
  343. flex: 1;
  344. text-align: center;
  345. ::v-deep {
  346. .el-input__inner {
  347. width: 80px;
  348. }
  349. }
  350. }
  351. .filter-item {
  352. width: fit-content;
  353. ::v-deep {
  354. .el-input__wrapper {
  355. background: none;
  356. box-shadow: none;
  357. }
  358. .el-input__inner {
  359. font-size: 14px;
  360. color: rgba(0, 0, 0, 0.5);
  361. }
  362. .el-select__wrapper {
  363. background: none;
  364. box-shadow: none;
  365. gap: 2px;
  366. padding: 4px 2px;
  367. justify-content: center;
  368. }
  369. .el-select__selection {
  370. flex: none;
  371. width: fit-content;
  372. }
  373. .el-select__placeholder {
  374. color: rgba(0, 0, 0, 0.5);
  375. position: static;
  376. transform: none;
  377. width: fit-content;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. .expert-prescription {
  384. display: flex;
  385. width: 100%;
  386. height: calc(100vh - 52px - 48px - 50px);
  387. .plan-menu {
  388. width: 100px;
  389. height: 100%;
  390. padding: 10px 0;
  391. box-sizing: border-box;
  392. background: #fff;
  393. border-radius: 0 10px 10px 0;
  394. .menu-icon {
  395. width: 13px;
  396. }
  397. .menu-text {
  398. padding: 0 4px;
  399. }
  400. ::v-deep {
  401. .el-anchor {
  402. height: 100%;
  403. background: none;
  404. }
  405. .el-anchor__marker {
  406. display: none;
  407. }
  408. .el-menu {
  409. background: none;
  410. border: none;
  411. .el-sub-menu__title {
  412. background: none;
  413. padding: 0 2px;
  414. justify-content: center;
  415. }
  416. .el-sub-menu__title {
  417. height: 32px;
  418. }
  419. .el-sub-menu .el-sub-menu__icon-arrow {
  420. position: static;
  421. padding-top: 6px;
  422. }
  423. .el-sub-menu {
  424. margin-bottom: 16px;
  425. &.is-opened {
  426. .el-sub-menu__icon-arrow {
  427. padding-bottom: 6px;
  428. padding-top: 0;
  429. }
  430. }
  431. .el-menu-item {
  432. height: 32px;
  433. line-height: 32px;
  434. margin: 4px 8px;
  435. padding: 0 2px;
  436. justify-content: center;
  437. background: none;
  438. }
  439. .el-menu-item.is-active {
  440. background: none;
  441. color: #fff;
  442. }
  443. .el-anchor__item {
  444. width: 100%;
  445. text-align: center;
  446. }
  447. .el-anchor__link {
  448. color: #666666;
  449. }
  450. .el-anchor__link.is-active {
  451. background: linear-gradient(180deg, #70BFFE, #2199F8);
  452. border-radius: 20px;
  453. color: #fff;
  454. }
  455. }
  456. }
  457. .el-anchor__list {
  458. padding-left: 0;
  459. }
  460. }
  461. }
  462. .expert-content {
  463. width: calc(100% - 100px);
  464. height: calc(100vh - 100px);
  465. overflow: auto;
  466. }
  467. }
  468. }
  469. </style>