index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <template>
  2. <view class="sidebar-wrap">
  3. <up-popup
  4. mode="left"
  5. :show="show"
  6. :safeAreaInsetTop="false"
  7. :safeAreaInsetBottom="false"
  8. @close="close"
  9. @open="open"
  10. zIndex="99999"
  11. :customStyle="{ backgroundColor: '#fafafa' }"
  12. >
  13. <view class="list-wrap">
  14. <up-list height="100%">
  15. <up-list-item
  16. height="50"
  17. v-for="(item, index) in indexList"
  18. :key="index"
  19. >
  20. <view :class="['navigator-box', item.open ? 'open' : '']">
  21. <!-- 跳转链接行 -->
  22. <navigator
  23. v-if="item.type === 'navigator'"
  24. :render-link="false"
  25. class="navigator-link"
  26. hover-class="none"
  27. :url="item.url"
  28. >
  29. <view class="title">
  30. <uni-icons
  31. customPrefix="iconfont"
  32. :class="[item.icon, 'item-icon']"
  33. size="20"
  34. color="#f8c007"
  35. ></uni-icons>
  36. <text class="item-text">{{ item.name }}</text>
  37. </view>
  38. <view v-if="item.type === 'collapse'" class="arrow-icon">
  39. <uni-icons type="down" size="20"></uni-icons>
  40. </view>
  41. </navigator>
  42. <!-- 折叠行 -->
  43. <view
  44. v-else
  45. class="navigator-link collapse-row"
  46. @click="handleCollapse(item)"
  47. >
  48. <view class="title">
  49. <uni-icons
  50. customPrefix="iconfont"
  51. :class="[item.icon, 'item-icon']"
  52. size="20"
  53. color="#f8c007"
  54. ></uni-icons>
  55. <text class="item-text">{{ item.name }}</text>
  56. </view>
  57. <view v-if="item.type === 'collapse'" class="arrow-icon">
  58. <uni-icons type="down" size="20"></uni-icons>
  59. </view>
  60. </view>
  61. <!-- 折叠内容 -->
  62. <view class="collapse-content" v-if="item.type === 'collapse'">
  63. <navigator
  64. v-for="subItem in item.child"
  65. :render-link="false"
  66. class="navigator-link sub-link"
  67. hover-class="none"
  68. :url="subItem.url"
  69. :key="subItem.url"
  70. >
  71. <view class="title">
  72. <text class="item-text subItem-text">{{
  73. subItem.name
  74. }}</text>
  75. </view>
  76. </navigator>
  77. </view>
  78. </view>
  79. </up-list-item>
  80. <view class="white-box"></view>
  81. </up-list>
  82. </view>
  83. <view class="footer-box">
  84. <navigator
  85. :url="item.url"
  86. class="item-box"
  87. v-for="item in footerList"
  88. :key="item.url"
  89. >
  90. <view class="icon-box">
  91. <uni-icons
  92. :size="item.size"
  93. color="#ffffff"
  94. customPrefix="iconfont"
  95. :type="item.icon"
  96. ></uni-icons>
  97. </view>
  98. <view class="name">{{ item.label }}</view>
  99. </navigator>
  100. </view>
  101. </up-popup>
  102. </view>
  103. </template>
  104. <script setup>
  105. import { ref, nextTick, computed, watchEffect, onMounted, watch } from "vue";
  106. // import { onHide } from "@dcloudio/uni-app";
  107. import { useAppStore } from "@/stores/app";
  108. import { useSliderStore } from "@/stores/slider";
  109. const appStore = useAppStore();
  110. // 获取slider 的状态
  111. const sliderStore = useSliderStore();
  112. const indexList = ref([]);
  113. const isSvip = computed(() => {
  114. return appStore.isLogin && appStore?.$userInfo?.svip;
  115. });
  116. watchEffect(() => {
  117. getIndexList();
  118. });
  119. let timer = null;
  120. // slider显示逻辑
  121. const show = ref(sliderStore.sidebarShow);
  122. onMounted(() => {
  123. show.value = sliderStore.sidebarShow;
  124. });
  125. watch(
  126. show,
  127. (newVal) => {
  128. sliderStore.updateSidebarShow(newVal);
  129. },
  130. { immediate: true }
  131. );
  132. watch(
  133. () => sliderStore.sidebarShow,
  134. (newVal) => {
  135. show.value = newVal;
  136. }
  137. );
  138. const emit = defineEmits(["open", "close"]);
  139. const footerList = [
  140. {
  141. url: "/pages/users/customer_service_message/index",
  142. icon: "icon-kefu2",
  143. label: "客服",
  144. size: 30,
  145. },
  146. {
  147. url: "/pages/users/setting/index",
  148. icon: "icon-shezhi",
  149. label: "设置",
  150. size: 24,
  151. },
  152. ];
  153. function getIndexList() {
  154. indexList.value = [
  155. // {
  156. // name: "设置主题色",
  157. // icon: "icon-wodedingdan",
  158. // type: "navigator",
  159. // url: "/pages/user/themeDebug",
  160. // },
  161. // {
  162. // name: "新商城",
  163. // icon: "icon-gouwuche",
  164. // type: "navigator",
  165. // url: "/pages/mall/index",
  166. // },
  167. {
  168. name: "我的订单",
  169. type: "collapse",
  170. icon: "icon-changyonggongneng",
  171. open: false,
  172. child: [
  173. {
  174. name: "商城订单",
  175. icon: "",
  176. type: "navigator",
  177. url: "/pages/order_list/index",
  178. },
  179. {
  180. name: "邮寄存金",
  181. icon: "",
  182. type: "navigator",
  183. url: "/pages/users/vault/storeMetal/order",
  184. },
  185. {
  186. name: "约价回收",
  187. icon: "",
  188. type: "navigator",
  189. url: "/pages/users/vault/recycle/recyle_order",
  190. },
  191. {
  192. name: "秒杀订单",
  193. icon: "",
  194. type: "navigator",
  195. url: "/pages/users/utils/flashSale/order",
  196. },
  197. {
  198. name: "定制订单",
  199. icon: "",
  200. type: "navigator",
  201. url: "/pages/users/utils/factory/orderList",
  202. },
  203. // {
  204. // name: "换款订单",
  205. // icon: "",
  206. // type: "navigator",
  207. // url: "/pages/users/new_live_exchange/tradeOrderFormOrder",
  208. // },
  209. // {
  210. // name: "团购订单",
  211. // icon: "",
  212. // type: "navigator",
  213. // url: "/pages/group_buying/order",
  214. // },
  215. ],
  216. },
  217. {
  218. name: "购物车",
  219. icon: "icon-gouwuche1",
  220. type: "navigator",
  221. url: "/pages/order_addcart/order_addcart",
  222. },
  223. {
  224. name: "买卖料",
  225. icon: "icon-jinku",
  226. type: "collapse",
  227. open: false,
  228. child: [
  229. {
  230. name: "充值",
  231. icon: "",
  232. type: "navigator",
  233. url: "/pages/users/vault/recharge",
  234. },
  235. {
  236. name: "提现",
  237. icon: "",
  238. type: "navigator",
  239. url: "/pages/users/vault/withdraw",
  240. },
  241. {
  242. name: "买料",
  243. icon: "",
  244. type: "navigator",
  245. url: "/pages/users/vault/buy",
  246. },
  247. {
  248. name: "卖料",
  249. icon: "",
  250. type: "navigator",
  251. url: "/pages/users/vault/storeMetal/index",
  252. },
  253. {
  254. name: "存料",
  255. icon: "",
  256. type: "navigator",
  257. url: "/pages/users/vault/storeMetal/goldBullionStock",
  258. },
  259. {
  260. name: "提料",
  261. icon: "",
  262. type: "navigator",
  263. url: "/pages/users/vault/storeMetal/metalExchange",
  264. },
  265. ],
  266. },
  267. {
  268. name: "钱包",
  269. icon: "icon-licai",
  270. type: "navigator",
  271. url: "/pages/users/vault/index",
  272. },
  273. // {
  274. // name: "钱包",
  275. // icon: "icon-licai",
  276. // type: "navigator",
  277. // url: "/pages/users/vault/newIndex",
  278. // },
  279. // {
  280. // name: "金价预警",
  281. // icon: "icon-yujing",
  282. // type: "navigator",
  283. // url: "/pages/users/gold_price_warning/index",
  284. // },
  285. {
  286. name: "常用功能",
  287. type: "collapse",
  288. icon: "icon-changyonggongneng",
  289. open: false,
  290. child: [
  291. // {
  292. // name: "每日一攒",
  293. // icon: "",
  294. // type: "navigator",
  295. // url: "/pages/users/accumulate_gold/index",
  296. // },
  297. // {
  298. // name: "直播换款",
  299. // icon: "",
  300. // type: "navigator",
  301. // url: "/pages/users/new_live_exchange/index",
  302. // },
  303. {
  304. name: "每日一攒",
  305. icon: "",
  306. type: "navigator",
  307. url: "/pages/users/accumulate_gold/newIndex",
  308. },
  309. // {
  310. // name: "福利秒杀",
  311. // icon: "",
  312. // type: "navigator",
  313. // url: "/pages/users/utils/flashSale/newIndex",
  314. // },
  315. ],
  316. },
  317. {
  318. name: "超级工具",
  319. type: "collapse",
  320. icon: "icon-chaojigongju",
  321. open: false,
  322. child: [
  323. {
  324. name: "金价预警",
  325. icon: "",
  326. type: "navigator",
  327. url: "/pages/users/gold_price_warning/index",
  328. },
  329. {
  330. name: "黄金算盘",
  331. icon: "",
  332. type: "navigator",
  333. url: "/pages/users/record_note/index",
  334. },
  335. {
  336. name: "自动买卖",
  337. icon: "",
  338. type: "navigator",
  339. url: "/pages/users/auto_buy/index",
  340. },
  341. ],
  342. },
  343. // {
  344. // name: "排行榜",
  345. // icon: "icon-a-ziyuan87",
  346. // type: "navigator",
  347. // url: "/pages/users/ranking_list/index",
  348. // },
  349. // {
  350. // name: "每日一攒",
  351. // icon: "icon-jicunjinxianxing",
  352. // type: "navigator",
  353. // url: "/pages/users/accumulate_gold/index",
  354. // },
  355. // {
  356. // name: "VIP会员",
  357. // icon: "icon-viphuiyuan1",
  358. // type: "navigator",
  359. // url: "/pages/VIP/VIP",
  360. // },
  361. // {
  362. // name: "SVIP会员",
  363. // icon: "icon-viphuiyuan1",
  364. // type: "navigator",
  365. // url: "/pages/SVIP/SVIP",
  366. // },
  367. // {
  368. // name: "贝币商城",
  369. // icon: "icon-beibishangcheng",
  370. // type: "navigator",
  371. // url: "/pages/bb_mall/index",
  372. // },
  373. // {
  374. // name: "客服消息",
  375. // icon: "icon-kefu2",
  376. // type: "navigator",
  377. // url: "/pages/message_create/message_create",
  378. // },
  379. // {
  380. // name: "加盟我们",
  381. // icon: "icon-jiamengwomen",
  382. // type: "navigator",
  383. // url: "/pages/join_us/index",
  384. // },
  385. // {
  386. // name: "找款订单",
  387. // icon: "icon-zhaokuan",
  388. // type: "navigator",
  389. // url: "/pages/find_funds/fundsOrder",
  390. // },
  391. ];
  392. }
  393. function open() {
  394. show.value = true;
  395. uni.hideTabBar();
  396. emit("open");
  397. }
  398. // onHide(() => {
  399. // show.value = false;
  400. // hideTabBar();
  401. // });
  402. defineExpose({
  403. open,
  404. close,
  405. show,
  406. });
  407. function close() {
  408. show.value = false;
  409. // hideTabBar();
  410. emit("close");
  411. }
  412. function hideTabBar() {
  413. // uni.showTabBar({
  414. // async complete() {
  415. // await nextTick()
  416. // fixTabBarGap()
  417. // }
  418. // });
  419. // timer && clearTimeout(timer)
  420. // timer = setTimeout(() => {
  421. // uni.showTabBar();
  422. // }, 250)
  423. }
  424. function fixTabBarGap() {
  425. const info = uni.getSystemInfoSync();
  426. // 页面真实高度 = windowHeight + tabBar 高度
  427. const page = uni.createSelectorQuery().select(".page-container");
  428. page
  429. .boundingClientRect((rect) => {
  430. const gap = info.screenHeight - rect.height;
  431. if (gap > 0) {
  432. // 用 CSS 动态修正底部多余空白
  433. document.body.style.height = `${info.windowHeight}px`;
  434. }
  435. })
  436. .exec();
  437. }
  438. function handleCollapse(item) {
  439. item.open = !item.open;
  440. }
  441. </script>
  442. <style lang="scss" scoped>
  443. .sidebar-wrap {
  444. position: relative;
  445. }
  446. ::v-deep .u-popup__content {
  447. display: flex;
  448. flex-direction: column;
  449. justify-content: space-between;
  450. align-items: space-between;
  451. height: 100vh;
  452. }
  453. .navigator-box {
  454. overflow: hidden;
  455. &.open {
  456. .arrow-icon {
  457. transform: rotate(-180deg);
  458. }
  459. .collapse-content {
  460. max-height: 500px !important;
  461. }
  462. }
  463. .collapse-row {
  464. &:active {
  465. background-color: #f8f8f8;
  466. }
  467. }
  468. }
  469. .list-wrap {
  470. width: 70vw;
  471. height: 88%;
  472. background-color: #fafafa;
  473. padding: 30rpx 20rpx 0;
  474. overflow: auto;
  475. margin: var(--status-bar-height) 0 0;
  476. // ::v-deep .u-list-item {
  477. // height: 95rpx;
  478. // }
  479. .navigator-link {
  480. padding: 0 20rpx 0 25rpx;
  481. width: 100%;
  482. display: flex;
  483. justify-content: space-between;
  484. line-height: 100rpx;
  485. &.sub-link {
  486. line-height: 70rpx;
  487. .title {
  488. padding-left: 54rpx;
  489. }
  490. }
  491. }
  492. .arrow-icon {
  493. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  494. }
  495. .collapse-content {
  496. // background-color: #FAFAFA;
  497. transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  498. max-height: 0;
  499. }
  500. .u-list-item {
  501. background-color: #fff;
  502. margin-bottom: 15rpx;
  503. border-radius: 15rpx;
  504. overflow: hidden;
  505. .item-icon {
  506. vertical-align: middle;
  507. margin-right: 20rpx;
  508. }
  509. .item-text {
  510. font-size: 32rpx;
  511. vertical-align: middle;
  512. }
  513. }
  514. .white-box {
  515. min-height: 30rpx;
  516. background-color: #fafafa;
  517. }
  518. }
  519. .footer-box {
  520. position: absolute;
  521. bottom: 0;
  522. left: 0;
  523. z-index: 1000;
  524. width: 100%;
  525. display: flex;
  526. align-items: center;
  527. justify-content: center;
  528. padding: 0 0.9375rem;
  529. gap: 1.25rem;
  530. margin-bottom: 0.9375rem;
  531. .item-box {
  532. display: flex;
  533. flex-direction: column;
  534. align-items: center;
  535. justify-content: center;
  536. .icon-box {
  537. width: 80rpx;
  538. height: 80rpx;
  539. border-radius: 100rpx;
  540. background-color: $header-color;
  541. display: flex;
  542. justify-content: center;
  543. align-items: center;
  544. }
  545. .name {
  546. margin: 10rpx 0 0;
  547. font-size: 28rpx;
  548. text-align: center;
  549. }
  550. }
  551. }
  552. .uni-cover-view {
  553. width: 100vw;
  554. height: 100vh;
  555. background-color: #000;
  556. }
  557. </style>