index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <template>
  2. <view class="box">
  3. <!-- 绑定按钮 -->
  4. <view class="bindBtn" @click="bindBtn"></view>
  5. <!-- tab切换 -->
  6. <view class="tabBox" v-if="isBind">
  7. <view class="tabItem" :class="{'activeTab' : activeTab == 0}" @click="tabClick('0')" style="margin-right: 20px;" tabindex="0">
  8. {{ fyname }}
  9. </view>
  10. <view class="tabItem" :class="{'activeTab' : activeTab == 1}" @click="tabClick('1')" tabindex="0">
  11. 闽南文化
  12. </view>
  13. </view>
  14. <view class="" style="height: 100%; position: relative">
  15. <!-- 具体非遗项目 -->
  16. <u-swiper @change="change" radius="0" :circular="true" :list="swiperList" showTitle keyName="image" interval="5000" height="100%" v-show="activeTab == 0"></u-swiper>
  17. <!-- 闽南文化 -->
  18. <u-swiper @change="change" radius="0" :circular="true" :list="swiperList1" keyName="image" interval="5000" height="100%" v-show="activeTab == 1"></u-swiper>
  19. </view>
  20. <!-- <view class="tilte img_logo"> -->
  21. <image
  22. src="../../static/img/web_title.png"
  23. mode="aspectFit"
  24. class="img_logo"
  25. />
  26. <!-- </view> -->
  27. <!-- 菜单 -->
  28. <!-- 具体非遗项目菜单 -->
  29. <view class="fy_box_menu" v-if="activeTab == 0">
  30. <!-- @click="bgBtn" -->
  31. <!-- <view class="menu_poimg">
  32. <image class="img" src="https://huli-app.wenlvti.net/app_static/minnanhun/image/img_@2x.png"></image>
  33. </view> -->
  34. <view @click="fyMenuBtn(item.page)" class="menu_item" v-for="(item, index) in list" :key="item.name" :style="{'backgroundImage':`url(${item.logo})`}" tabindex="0">
  35. <!-- <view class="menu_img">
  36. <image class="img" :src="item.img"></image>
  37. </view> -->
  38. <view class="menu_tit">
  39. {{ item.title }}
  40. </view>
  41. <!-- <view class="" style="color: #de807b; font-size: 10px; position: absolute; top: 58%; left: 5%">
  42. {{ item.name }}
  43. </view> -->
  44. </view>
  45. </view>
  46. <!-- 闽南文化菜单 -->
  47. <view class="box_menu" v-if="activeTab == 1">
  48. <!-- @click="bgBtn" -->
  49. <!-- <view class="menu_poimg">
  50. <image class="img" src="https://huli-app.wenlvti.net/app_static/minnanhun/image/img_@2x.png"></image>
  51. </view> -->
  52. <view @click="menuBtn(index)" class="menu_item" v-for="(item, index) in list1" :key="item.name" :style="{'backgroundImage':`url(${item.logo})`}" tabindex="0">
  53. <!-- <view class="menu_img">
  54. <image class="img" :src="item.img"></image>
  55. </view> -->
  56. <view class="menu_tit">
  57. {{ item.title }}
  58. </view>
  59. <!-- <view class="" style="color: #de807b; font-size: 10px; position: absolute; top: 58%; left: 5%">
  60. {{ item.name }}
  61. </view> -->
  62. </view>
  63. </view>
  64. <!-- 弹出输入框,有用户名和机器码两个输入框 -->
  65. <uni-popup ref="inputPopup" type="dialog">
  66. <view class="popup-content">
  67. <view class="popup-container">
  68. <view class="popup-title">绑定机器码</view>
  69. <input class="popup-input" v-model="username" placeholder="请输入用户名" />
  70. <input class="popup-input" v-model="device_code" placeholder="请输入机器码" />
  71. <view class="popup-actions">
  72. <view class="action-btn cancel" @click="closePopup" tabindex="0">取消</view>
  73. <view class="action-btn confirm" @click="confirmInput" tabindex="0">确定</view>
  74. </view>
  75. </view>
  76. </view>
  77. </uni-popup>
  78. <view class="logout" @click="logout"></view>
  79. </view>
  80. </template>
  81. <script>
  82. let that;
  83. export default {
  84. data() {
  85. return {
  86. isBind: false, // 是否绑定
  87. fyname:'非遗项目',
  88. username:'',
  89. device_code:'',
  90. swiperId: 0,
  91. music: true,
  92. // 创建音频上下文
  93. scrollHeight: '',
  94. innerAudioContext: uni.createInnerAudioContext(),
  95. cityList: [],
  96. // 非遗项目轮播图
  97. swiperList: [
  98. {
  99. image: '/static/img/swiper1.jpg',
  100. title: ''
  101. },
  102. ],
  103. // 闽南文化轮播图
  104. swiperList1: [
  105. {
  106. image: '/static/img/swiper1.jpg',
  107. title: ''
  108. },
  109. {
  110. image: '/static/img/swiper2.jpg',
  111. title: ''
  112. },
  113. ],
  114. // swiperList:[
  115. // {
  116. // image: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/tv44.jpg',
  117. // title: '陈元光(657—711年),字廷炬,号龙湖。唐朝光州固始县人(今河南省固始县人)。漳州首任刺史。他是闽台地区重要的民间信仰之一,被奉为开漳圣王。号称“蛮荒”之地的闽南,经济文化得到了迅速发展。 陈元光成为促进中原文化与闽越文化融合的奠基者。'
  118. // },
  119. // ],
  120. list: [
  121. ],
  122. // #ifdef H5
  123. list1:[
  124. {
  125. title: '保护概况',
  126. logo: 'static/img/index/1.png',
  127. },
  128. {
  129. title: '闽南精神',
  130. logo: 'static/img/index/2.png',
  131. },
  132. {
  133. title: '古早话仙',
  134. logo: 'static/img/index/3.png',
  135. },
  136. {
  137. title: '民俗风情',
  138. logo: 'static/img/index/4.png',
  139. },
  140. {
  141. title: '保护传承',
  142. logo: 'static/img/index/5.png',
  143. },
  144. {
  145. title: '闽南时尚',
  146. logo: 'static/img/index/6.png',
  147. },
  148. {
  149. title: '文化之旅',
  150. logo: 'static/img/index/7.png',
  151. },
  152. {
  153. title: '厝边记忆',
  154. logo: 'static/img/index/8.png',
  155. }
  156. ],
  157. // #endif
  158. // #ifdef APP
  159. list1:[
  160. {
  161. title: '保护概况',
  162. logo: '/static/img/index/1.png',
  163. },
  164. {
  165. title: '闽南精神',
  166. logo: '/static/img/index/2.png',
  167. },
  168. {
  169. title: '古早话仙',
  170. logo: '/static/img/index/3.png',
  171. },
  172. {
  173. title: '民俗风情',
  174. logo: '/static/img/index/4.png',
  175. },
  176. {
  177. title: '保护传承',
  178. logo: '/static/img/index/5.png',
  179. },
  180. {
  181. title: '闽南时尚',
  182. logo: '/static/img/index/6.png',
  183. },
  184. {
  185. title: '文化之旅',
  186. logo: '/static/img/index/7.png',
  187. },
  188. {
  189. title: '厝边记忆',
  190. logo: '/static/img/index/8.png',
  191. }
  192. ],
  193. // #endif
  194. activeTab: 1
  195. };
  196. },
  197. onLoad(o) {
  198. // this.music = o.music;
  199. that = this;
  200. this.playMusic();
  201. if(uni.getStorageSync('device_code')){
  202. this.isBind = true;
  203. this.device_code = uni.getStorageSync('device_code')
  204. this.getTerminalConfig()
  205. }else{
  206. this.isBind = false;
  207. }
  208. },
  209. methods: {
  210. bindBtn() {
  211. console.log('触发点击');
  212. // 弹出绑定框
  213. this.$refs.inputPopup.open()
  214. },
  215. // 确认机器码
  216. confirmInput(){
  217. this.$api.bindMachineCode({
  218. username:this.username,
  219. device_code:this.device_code
  220. },
  221. function(res){
  222. console.log(res);
  223. that.$u.toast(res.msg)
  224. setTimeout(()=>{
  225. if(res.code === 0){
  226. that.isBind = false;
  227. }else{
  228. that.isBind = true;
  229. uni.setStorageSync('device_code',that.device_code)
  230. that.getTerminalConfig()
  231. }
  232. that.closePopup()
  233. },1000)
  234. })
  235. },
  236. closePopup() {
  237. this.$refs.inputPopup.close();
  238. this.username = ''
  239. this.device_code = ''
  240. },
  241. // 获取终端按钮配置
  242. getTerminalConfig() {
  243. this.$api.getTerminalConfig({
  244. device_code: this.device_code
  245. }, function(res) {
  246. console.log(res);
  247. that.fyname = res.data.name || '非遗项目';
  248. that.swiperList = res.data.images;
  249. that.list = res.data.page_json
  250. });
  251. },
  252. tabClick(index) {
  253. this.activeTab = index;
  254. this.swiperId = 0
  255. // this.$refs.mySwiper.scrollTo(0, 0, 0);
  256. },
  257. menuBtn(i) {
  258. uni.redirectTo({
  259. url: '/pages/index2/index2?id=' + i
  260. });
  261. this.innerAudioContext.pause();
  262. },
  263. fyMenuBtn(page){
  264. uni.navigateTo({
  265. url: page
  266. })
  267. },
  268. change(i) {
  269. this.swiperId = i.current;
  270. },
  271. // 了解详情
  272. lianjieBtn() {
  273. uni.redirectTo({
  274. url: '/pages/index/index_xq?id=' + this.swiperId
  275. });
  276. this.innerAudioContext.pause();
  277. },
  278. // 退出
  279. logout(){
  280. uni.removeStorageSync('device_code')
  281. // 刷新页面
  282. this.isBind = false
  283. this.activeTab = 1
  284. // window.location.reload();
  285. },
  286. // myBtn() {
  287. // uni.redirectTo({
  288. // url: '/pages/index/guanYu'
  289. // });
  290. // this.innerAudioContext.pause();
  291. // },
  292. playMusic() {
  293. if (this.music) {
  294. // 设置音频源
  295. this.innerAudioContext.src = 'https://huli-app.wenlvti.net/app_static/minnanhun/image/audio2.mp3';
  296. // 设置为自动播放
  297. this.innerAudioContext.autoplay = true;
  298. // 其他属性设置(可选)
  299. this.innerAudioContext.loop = true; // 是否循环播放,默认为false
  300. } else {
  301. // this.innerAudioContext.pause();
  302. }
  303. }
  304. }
  305. };
  306. </script>
  307. <style>
  308. /* @keyframes switch-bg {
  309. 30% {
  310. background-image: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/bg1.jpg');
  311. }
  312. 70% {
  313. background-image: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/bg3.jpg');
  314. }
  315. 90% {
  316. background-image: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/bg4.jpg');
  317. }
  318. 100% {
  319. background-image: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/ind.png');
  320. }
  321. } */
  322. .box {
  323. width: 100%;
  324. height: 100vh;
  325. /* animation-name: switch-bg;
  326. animation-duration: 20s;
  327. animation-iteration-count: infinite;
  328. animation-timing-function: linear;
  329. animation-delay: 5s; */
  330. /* background-image: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/ind.png'); */
  331. box-sizing: border-box;
  332. /* background-size: 100% 100%; */
  333. /* background-attachment: fixed; */
  334. margin: 0;
  335. }
  336. :deep(.u-swiper__wrapper__item__wrapper__title) {
  337. width: 30% !important;
  338. height: 20% !important;
  339. position: absolute;
  340. bottom: 42% !important;
  341. left: 0 !important;
  342. font-size: 10px !important;
  343. font-family: MiSans, MiSans;
  344. color: #dcd9d7;
  345. letter-spacing: 0.1em;
  346. background-color: transparent !important;
  347. }
  348. .animate-box {
  349. width: 100%;
  350. height: 65%;
  351. overflow: hidden;
  352. }
  353. .jieshao {
  354. animation: 40s wordsLoop linear infinite normal;
  355. }
  356. @keyframes wordsLoop {
  357. 0% {
  358. transform: translateY(0);
  359. -webkit-transform: translateY(0);
  360. }
  361. 100% {
  362. transform: translateY(-100%);
  363. -webkit-transform: translateY(-100%);
  364. }
  365. }
  366. @-webkit-keyframes wordsLoop {
  367. 0% {
  368. transform: translateY(0);
  369. -webkit-transform: translateY(0);
  370. }
  371. 100% {
  372. transform: translateY(-100%);
  373. -webkit-transform: translateY(-100%);
  374. }
  375. }
  376. .img {
  377. width: 100%;
  378. height: 100%;
  379. }
  380. .img_logo {
  381. /* display: flex; */
  382. /* background: url('/static/img/img_logo.png') no-repeat; */
  383. /* background-size: 100% 100%; */
  384. position: relative;
  385. z-index: 999;
  386. text-shadow: 1px 1px 2px black;
  387. width: 35%;
  388. aspect-ratio: 14/5;
  389. position: absolute;
  390. top: 0;
  391. left: 5%;
  392. /* left: 90%; */
  393. }
  394. .mn_tit {
  395. width: 80%;
  396. height: 10%;
  397. font-size: 14px;
  398. }
  399. .boc_tit {
  400. position: relative;
  401. z-index: 999;
  402. width: 25%;
  403. height: 8%;
  404. margin: -46% 0 0 3%;
  405. }
  406. .boc_tit1 {
  407. position: absolute;
  408. left: -11%;
  409. width: 80%;
  410. height: 100%;
  411. }
  412. .boc_tit2 {
  413. font-size: 12px;
  414. font-family: MiSans, MiSans;
  415. color: #dcd9d7;
  416. margin-top: 3%;
  417. letter-spacing: 0.1em;
  418. }
  419. .box_menu {
  420. position: absolute;
  421. z-index: 999;
  422. display: flex;
  423. flex-wrap: wrap;
  424. width: 90%;
  425. height: 34%;
  426. bottom: 10%;
  427. left: 9%;
  428. }
  429. .fy_box_menu{
  430. position: absolute;
  431. z-index: 999;
  432. display: flex;
  433. flex-wrap: wrap;
  434. width: 90%;
  435. height: 34%;
  436. bottom: 0%;
  437. left: 9%;
  438. }
  439. .menu_item {
  440. position: relative;
  441. width: 22%;
  442. height: 45%;
  443. margin: 0 0 0 1%;
  444. cursor: pointer;
  445. border-radius: 10rpx;
  446. display: flex;
  447. align-items: center;
  448. justify-content: flex-start;
  449. background-size: contain;
  450. background-position: center;
  451. background-repeat: no-repeat;
  452. }
  453. .menu_img {
  454. width: 100%;
  455. height: 100%;
  456. }
  457. .menu_tit {
  458. /* font-size: 88rpx; */
  459. font-family: nzgrRuyinZouZhangKai, nzgrRuyinZouZhangKai;
  460. font-weight: 500;
  461. font-size: clamp(8px, 1.6vw, 50px);
  462. line-height: 76px;
  463. background: linear-gradient(180deg, #d1392d 0%, rgba(209, 57, 45, 0.89) 100%);
  464. -webkit-background-clip: text;
  465. -webkit-text-fill-color: transparent;
  466. margin-left: 14%;
  467. }
  468. /* .menu_poimg {
  469. position: absolute;
  470. top: -8%;
  471. left: 8%;
  472. width: 13%;
  473. height: 53%;
  474. z-index: 1;
  475. } */
  476. .liaoJie {
  477. position: absolute;
  478. bottom: -245%;
  479. left: 1%;
  480. width: 25%;
  481. height: 45%;
  482. border-radius: 40rpx;
  483. text-align: center;
  484. line-height: 20px;
  485. color: #ffffff;
  486. background: rgba(255, 255, 255, 0.2);
  487. font-size: 12px;
  488. }
  489. .mn_js {
  490. width: 25%;
  491. height: 44%;
  492. border-radius: 2%;
  493. font-size: 10px;
  494. line-height: 18px;
  495. border: 1px #ffffff solid;
  496. color: #dcd9d7;
  497. position: absolute;
  498. top: 15%;
  499. left: 67%;
  500. padding: 1%;
  501. background-color: rgba(0, 0, 0, 0.2);
  502. box-sizing: border-box;
  503. overflow: hidden;
  504. }
  505. .guanyu {
  506. width: 80%;
  507. height: 10%;
  508. position: absolute;
  509. top: 75%;
  510. left: 10%;
  511. line-height: 16px;
  512. padding-top: 1%;
  513. box-sizing: border-box;
  514. text-align: center;
  515. letter-spacing: 0.2em;
  516. border-radius: 15px;
  517. background-color: rgba(0, 0, 0, 0.5);
  518. }
  519. .tabBox {
  520. display: flex;
  521. justify-content: space-around;
  522. align-items: center;
  523. position: absolute;
  524. top: 10%;
  525. z-index: 99999;
  526. color: #aa734d;
  527. left: 50%;
  528. transform: translateX(-50%);
  529. }
  530. .tabItem {
  531. text-align: center;
  532. padding: 10px 20px;
  533. background-color: #cdc0b6;
  534. border-radius: 25px;
  535. /* 阴影立体 */
  536. box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  537. }
  538. .activeTab {
  539. color: #fff;
  540. background-color: #aa734d;
  541. }
  542. .bindBtn{
  543. top: 0;
  544. right: 0;
  545. position: absolute;
  546. z-index: 99999;
  547. width: 5%;
  548. height: 5%;
  549. }
  550. /* 弹窗 */
  551. /* 打开按钮 */
  552. .open-btn {
  553. padding: 10px 16px;
  554. background-color: #007aff;
  555. color: white;
  556. text-align: center;
  557. border-radius: 10px;
  558. width: 120px;
  559. margin: 20px auto;
  560. }
  561. /* 弹窗容器 */
  562. .popup-container {
  563. width: 280px;
  564. padding: 20px 18px;
  565. background-color: #ffffff;
  566. border-radius: 14px;
  567. box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  568. display: flex;
  569. flex-direction: column;
  570. align-items: center;
  571. justify-content: center;
  572. }
  573. /* 标题 */
  574. .popup-title {
  575. font-size: 17px;
  576. font-weight: 600;
  577. color: #333;
  578. margin-bottom: 16px;
  579. text-align: center;
  580. }
  581. /* 输入框 */
  582. .popup-input {
  583. width: 80%;
  584. margin-bottom: 12px;
  585. padding: 10px 20px;
  586. font-size: 14px;
  587. border: 1px solid #ddd;
  588. border-radius: 8px;
  589. outline: none;
  590. transition: border-color 0.3s;
  591. }
  592. .popup-input:focus {
  593. border-color: #007aff;
  594. }
  595. /* 自定义按钮容器 */
  596. .popup-actions {
  597. display: flex;
  598. justify-content: space-around;
  599. margin-top: 16px;
  600. width: 90%;
  601. }
  602. /* 自定义按钮样式 */
  603. .action-btn {
  604. flex: 1;
  605. text-align: center;
  606. padding: 10px 0;
  607. border-radius: 8px;
  608. font-size: 14px;
  609. font-weight: 500;
  610. transition: background-color 0.3s;
  611. user-select: none;
  612. }
  613. /* 取消按钮 */
  614. .action-btn.cancel {
  615. background-color: #f1f1f1;
  616. color: #555;
  617. margin-right: 10px;
  618. }
  619. .action-btn.cancel:active {
  620. background-color: #e2e2e2;
  621. }
  622. /* 确定按钮 */
  623. .action-btn.confirm {
  624. background-color: #007aff;
  625. color: white;
  626. }
  627. .action-btn.confirm:active {
  628. background-color: #005ec6;
  629. }
  630. /* 退出按钮 */
  631. .logout{
  632. width: 5%;
  633. height: 10%;
  634. position: absolute;
  635. bottom: 0;
  636. right: 0;
  637. }
  638. </style>