top.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <view class="top-box" :style="{ 'height': swiperHeight + 'rpx'}">
  3. <view :style="{backgroundSize:'100% '+swiperHeight+'rpx',backgroundImage: 'url('+bannerList[0].image+')'}"
  4. :class="['nav-top', pattern === 1 ? 'zw-nav-top zw-show-bg' : 'sh-nav-top sh-show-bg' , showNavBg ? '' : 'hide-nav-bg']">
  5. <view class="status-bar" :style="{'height': statusBarHeight + 'px'}" />
  6. <view class="status-title">
  7. <view class="title-identity-box">
  8. <view class="title-identity" @click.stop="toQY()">
  9. <!-- <text class="iconfont_yige identity-icon">&#xe610;</text> -->
  10. <image class="identity-icon" src="@/static/ZW/icon.png" mode="aspectFit"></image>
  11. <text>企业</text>
  12. </view>
  13. </view>
  14. <view class="title-name">
  15. <text :class="{'active-title-name':pattern === 1}" @click.stop="home.init(1)">政务</text>
  16. <text :class="{'active-title-name':pattern === 2}" @click.stop="home.init(2)">生活</text>
  17. </view>
  18. <view class="title-btn">
  19. <image class="title-btn-item" src="@/static/ZW/service.png" mode="aspectFit"
  20. @click.stop="openCustomerCenter()"></image>
  21. <!-- <text class="iconfont_yige title-btn-item" @click.stop="openCustomerCenter()">&#xe60e;</text> -->
  22. <text class="iconfont_yige title-btn-item" style="font-size: 48rpx;"
  23. @click.stop="home.init(3)">&#xe6bd;</text>
  24. </view>
  25. </view>
  26. <view class="status-search">
  27. <view class="weather-box" @click.stop="openWeather()">
  28. <template v-if="weatherInfo">
  29. <image class="weather-img iconfont_yige" :src="weatherInfo.icon" mode="aspectFit"></image>
  30. <!-- <text class="weather-icon iconfont_yige">&#xe62a;</text> -->
  31. <text class="weather-num" v-if="weatherInfo.temperature">{{weatherInfo.temperature}}
  32. <text>°C</text> </text>
  33. </template>
  34. </view>
  35. <view class="search-box" @click.stop="onSearch()">
  36. <text class="search-icon iconfont_yige">&#xe653;</text>
  37. <text class="search-text iconfont_yige">请输入检索关键字</text>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- <view :style=" {'width':'100%','height': statusBarHeight + 'px' }"></view> -->
  42. <view class="shortcut-box" :style="{ 'paddingTop': statusBarHeight + 'px'}">
  43. <view class="status-placeholder"></view>
  44. <view class="shortcut-content">
  45. <u-row gutter="20">
  46. <u-col span="3">
  47. <view class="shortcut-item" @click.stop="openScanCode()">
  48. <image class="icon_img" src="@/static/ZW/scanQR.png" mode="aspectFit"></image>
  49. <!-- <text class="iconfont_yige iconfont-icon">&#xe8b5;</text> -->
  50. <text class="zw-one-row iconfont-name">扫一扫</text>
  51. </view>
  52. </u-col>
  53. <block v-if="topKongLimList.length > 0">
  54. <u-col span="3" v-for="item in topKongLimList" :key="item.id">
  55. <view class="shortcut-item" @click.stop="$openPage(item)">
  56. <!-- <text class="iconfont_yige iconfont-icon">&#xf71e;</text> -->
  57. <image class="icon_img" :src="$getImgPath(item.icon)" mode="aspectFit"></image>
  58. <text class="zw-one-row iconfont-name">{{item.name}}</text>
  59. </view>
  60. </u-col>
  61. </block>
  62. </u-row>
  63. </view>
  64. </view>
  65. <!-- <view class="swiper-boxs" :style="{ 'height': swiperHeight + 'rpx'}">
  66. <view class="swiper-box">
  67. <zw-swiper :height="swiperHeight" :keyword=" pattern === 1 ? $keys.ZW_BANNER : $keys.SH_BANNER" />
  68. </view>
  69. </view> -->
  70. <view class="swiper-content" :style="{ 'height': swiperHeight + 'rpx'}">
  71. <zw-swiper ref="swiperRef" :height="swiperHeight"
  72. :keyword="pattern === 1 ? $keys.ZW_BANNER : $keys.SH_BANNER"
  73. :StorageKey="pattern === 1 ? $keys.sy_zw_BANNER : $keys.sy_sh_BANNER" @getBanner="getBannerList" />
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import Mixin from "./Mixin.js";
  79. import {
  80. openSearch
  81. } from "../../government/conmon.js"
  82. import {
  83. getPhotograph
  84. } from "@/utils/tool.js"
  85. import permision from "@/utils/permission.js"
  86. export default {
  87. props: {
  88. pattern: {
  89. type: Number,
  90. default: 1
  91. },
  92. swiperHeight: {
  93. type: Number,
  94. default: 720
  95. },
  96. scrollTop: {
  97. type: Number,
  98. default: 0
  99. },
  100. topKongLimList: {
  101. type: Array,
  102. default: () => []
  103. },
  104. toQyKongLimList: {
  105. type: Array,
  106. default: () => []
  107. },
  108. // 天气
  109. weatherInfo: {
  110. type: Object,
  111. default: null
  112. },
  113. },
  114. mixins: [Mixin],
  115. inject: ["home"],
  116. data() {
  117. return {
  118. showNavBg: true,
  119. scrollStyle: false,
  120. navScrollStyle: {
  121. // 'background-image': url("@/static/home_bar_01.png")
  122. },
  123. keyword: '',
  124. bannerList: [{}]
  125. }
  126. },
  127. methods: {
  128. openWeather() {
  129. this.$skipWeb('https://html5.moji.com/tpd/days40_web/index.html#/home?cityid=584', '宜昌天气')
  130. // this.$skipWeb('https://m.weather.com.cn/mweather/101200901.shtml', '宜昌天气')
  131. },
  132. getBannerList(e) {
  133. if (e && e.length > 0) {
  134. this.bannerList = e
  135. } else {
  136. this.bannerList = [{}]
  137. }
  138. },
  139. init() {
  140. this.$refs.swiperRef.init()
  141. },
  142. async openScanCode() {
  143. // #ifdef APP-PLUS
  144. let flag = await permision.showAuthTipModal("android.permission.CAMERA")
  145. if (!flag) return
  146. // #endif
  147. // getPhotograph();
  148. // 允许从相机和相册扫码
  149. uni.scanCode({
  150. scanType: ['qrCode'],
  151. success: function(res) {
  152. switch (res.scanType) {
  153. case 'QR_CODE':
  154. // 二维码
  155. const result = res.result
  156. const val = result.split("?")[1]
  157. const v = val.split("&")
  158. const obj = {};
  159. v.forEach(el => {
  160. const _v = el.split("=");
  161. obj[_v[0]] = _v[1]
  162. });
  163. if (obj.URLType === 'BigTurnplate') {
  164. uni.navigateTo({
  165. url: `/pages/game/Lottery?activityId=${obj.activityId}`
  166. })
  167. }
  168. if (obj.URLType === 'Task') {
  169. uni.navigateTo({
  170. url: `/pages/task/task-details?taskId=${obj.taskId}`
  171. })
  172. }
  173. break;
  174. }
  175. console.log('条码类型:' + res.scanType);
  176. console.log('条码内容:' + res.result);
  177. },
  178. fail(fail) {
  179. console.log(fail)
  180. // if ([0, 11, 12].includes(fail.code)) return;
  181. // permision.showManualAuth('android.permission.CAMERA');
  182. }
  183. });
  184. },
  185. onSearch() {
  186. openSearch()
  187. },
  188. openCustomerCenter() {
  189. uni.navigateTo({
  190. url: '/pages/government/customer-center'
  191. });
  192. },
  193. toQY() {
  194. // this.$yghttp.get('/yima/request/appUser/enterprise').then(res=>{
  195. // if(res.data.has){
  196. this.$openPage(this.toQyKongLimList[0])
  197. // }else{
  198. // this.$openPage({thirdApplicationId:res.data.thirdApplicationId,name:''})
  199. // // uni.navigateTo({
  200. // // url:"/pages/web-view/Apps?path="+res.data.url
  201. // // })
  202. // }
  203. // })
  204. }
  205. },
  206. watch: {
  207. scrollTop: {
  208. handler: function(newNum, oldNum) {
  209. const scrollNum = Number(newNum) || 0
  210. // this.scrollStyle = scrollNum > 140 ? true : false;
  211. const num = uni.upx2px(40)
  212. // if (scrollNum > num) {
  213. // this.showNavBg = true
  214. // } else {
  215. // this.showNavBg = false
  216. // }
  217. // if (scrollNum >= 15 && scrollNum < 70) {
  218. // const op = scrollNum / 70;
  219. // this.navScrollStyle = {
  220. // opacity: 1 - op,
  221. // }
  222. // }
  223. // if (scrollNum >= 70 && scrollNum < 140) {
  224. // const op = (scrollNum - 70) / 70;
  225. // this.navScrollStyle = {
  226. // backgroundColor: `rgba(255, 255, 255, ${op})`,
  227. // opacity: op,
  228. // }
  229. // }
  230. // if (scrollNum >= 140) {
  231. // this.navScrollStyle = {
  232. // backgroundColor: `rgba(255, 255, 255 ,1)`,
  233. // }
  234. // }
  235. },
  236. immediate: true
  237. },
  238. }
  239. }
  240. </script>
  241. <style lang="scss" scoped>
  242. .top-box {
  243. width: 100%;
  244. overflow: hidden;
  245. position: relative;
  246. .swiper-content {
  247. position: absolute;
  248. left: 0;
  249. top: 0;
  250. right: 0;
  251. }
  252. .swiper-boxs {
  253. overflow: hidden;
  254. width: 200%;
  255. position: absolute;
  256. left: -50%;
  257. /* (width - 100%)/ 2 */
  258. top: 0;
  259. border-radius: 0 0 50% 50%;
  260. .swiper-box {
  261. margin: 0 auto;
  262. width: 750rpx;
  263. height: 100%;
  264. overflow: hidden;
  265. }
  266. }
  267. // .zw-show-bg {
  268. // background: url("@/static/home_bar_01.png") no-repeat center center;
  269. // }
  270. // .sh-show-bg {
  271. // // background: url("@/static/home_bar_02.png") no-repeat center center;
  272. // background-image: url("http://sly2020.oss-cn-beijing.aliyuncs.com/2024/01/25/b737a2ca9cd1492abc290e2081cb3739.png");
  273. // }
  274. .hide-nav-bg {
  275. background: none !important;
  276. }
  277. .nav-top {
  278. position: fixed;
  279. z-index: 2;
  280. left: 0;
  281. top: 0;
  282. right: 0;
  283. padding: 0 $zw-padding;
  284. background-size: 100% 100%;
  285. .status-title {
  286. width: 100%;
  287. height: 113rpx;
  288. padding-top: 27rpx;
  289. display: flex;
  290. justify-content: space-between;
  291. align-items: stretch;
  292. .title-identity-box,
  293. .title-btn {
  294. width: 200rpx;
  295. display: flex;
  296. align-items: center;
  297. }
  298. // 86rpx
  299. .title-identity-box {
  300. .title-identity {
  301. width: 141rpx;
  302. height: 57rpx;
  303. display: flex;
  304. justify-content: center;
  305. align-items: center;
  306. border-radius: 30rpx;
  307. .identity-icon {
  308. font-size: 34rpx;
  309. }
  310. .identity-icon {
  311. width: 37.47rpx;
  312. height: 29.64rpx;
  313. }
  314. text+text {
  315. font-size: 26rpx;
  316. font-weight: 400;
  317. padding-left: 14rpx;
  318. }
  319. }
  320. }
  321. .title-btn {
  322. display: flex;
  323. justify-content: flex-end;
  324. align-items: center;
  325. .title-btn-item {
  326. width: 55rpx;
  327. height: 45rpx;
  328. }
  329. .title-btn-item {
  330. font-size: 40rpx;
  331. &:first-child {
  332. margin-right: 20rpx;
  333. }
  334. }
  335. }
  336. .title-name {
  337. flex: 1;
  338. display: flex;
  339. align-items: stretch;
  340. justify-content: center;
  341. text {
  342. display: flex;
  343. align-items: center;
  344. &+text {
  345. margin-left: 60rpx;
  346. }
  347. font-size: 36rpx;
  348. font-family: PingFang SC,
  349. PingFang SC-Medium;
  350. font-weight: 500;
  351. }
  352. .active-title-name {
  353. font-family: PingFang SC, PingFang SC-Bold;
  354. font-weight: 700;
  355. position: relative;
  356. &::before {
  357. content: '';
  358. position: absolute;
  359. left: 0;
  360. bottom: 0;
  361. width: 100%;
  362. height: 8rpx;
  363. border-radius: 4rpx;
  364. }
  365. }
  366. }
  367. }
  368. .status-search {
  369. width: 100%;
  370. height: 110rpx;
  371. padding: 20rpx 0;
  372. display: flex;
  373. justify-content: space-between;
  374. align-items: stretch;
  375. .weather-box {
  376. width: 70rpx;
  377. height: 100%;
  378. display: flex;
  379. flex-direction: column;
  380. justify-content: center;
  381. align-items: center;
  382. .weather-img {
  383. width: 70rpx;
  384. height: 70rpx;
  385. }
  386. .weather-icon {}
  387. .weather-num {
  388. // padding-top: 5rpx;
  389. font-size: 22rpx;
  390. line-height: 1;
  391. font-family: PingFang SC, PingFang SC-Bold;
  392. font-weight: 700;
  393. // text-align: left;
  394. text {
  395. font-weight: 400;
  396. transform: scale(0.8);
  397. }
  398. }
  399. }
  400. .search-box {
  401. flex: 1;
  402. height: 100%;
  403. border-radius: 35rpx;
  404. overflow: hidden;
  405. padding: 0 20rpx;
  406. display: flex;
  407. align-items: center;
  408. .search-icon {
  409. font-size: 30rpx;
  410. }
  411. .search-text {
  412. font-size: 27rpx;
  413. padding-left: 3px;
  414. }
  415. }
  416. }
  417. }
  418. .zw-nav-top,
  419. .sh-nav-top {
  420. .title-identity-box,
  421. .title-btn,
  422. .weather-icon,
  423. .weather-num {
  424. color: #fff;
  425. }
  426. .title-identity {
  427. background-color: rgba(255, 255, 255, 0.3);
  428. // box-shadow: 0px 4px 6px 0px rgba(3, 148, 180, 0.30);
  429. }
  430. .title-name {
  431. .active-title-name {
  432. color: #fff;
  433. &::before {
  434. background-color: #fff;
  435. }
  436. }
  437. }
  438. .search-box {
  439. background: rgba(255, 255, 255, 0.30);
  440. border: 1rpx solid rgba(255, 255, 255, 0.36);
  441. color: #fff;
  442. .search-text {
  443. color: rgba(255, 255, 255, 0.50);
  444. }
  445. }
  446. }
  447. .zw-nav-top {
  448. .title-name {
  449. text {
  450. color: #D5F1F6;
  451. }
  452. }
  453. }
  454. .sh-nav-top {
  455. .title-name {
  456. text {
  457. color: #FFE6D6;
  458. }
  459. }
  460. }
  461. .scroll-style {
  462. .weather-icon {
  463. color: #FABB00;
  464. }
  465. .title-identity-box,
  466. .title-btn,
  467. .weather-num,
  468. .title-name>text {
  469. color: #000 !important;
  470. }
  471. .active-title-name::before {
  472. background-color: #000 !important;
  473. }
  474. .title-identity {
  475. // background-color: rgba(255, 255, 255, 0.3);
  476. border: 1rpx solid #ccc;
  477. // box-shadow: 0px 4px 6px 0px rgba(3, 148, 180, 0.30);
  478. }
  479. .search-box {
  480. border: 1rpx solid #ccc;
  481. color: #c1c1c1;
  482. .search-text {
  483. color: #c1c1c1;
  484. }
  485. }
  486. }
  487. .status-placeholder {
  488. width: 100%;
  489. // height: calc(113rpx + 110rpx);
  490. height: 223rpx;
  491. // height: 120px;
  492. }
  493. .shortcut-box {
  494. position: relative;
  495. left: 0;
  496. right: 0;
  497. top: 0;
  498. z-index: 1;
  499. .shortcut-content {
  500. width: 100%;
  501. padding: 35rpx $zw-padding 0;
  502. .shortcut-item {
  503. display: flex;
  504. flex-direction: column;
  505. justify-content: center;
  506. align-items: center;
  507. .iconfont-icon {
  508. font-size: 50rpx;
  509. font-weight: bold;
  510. color: #fff;
  511. }
  512. .icon_img {
  513. width: 50rpx;
  514. height: 50rpx;
  515. vertical-align: middle;
  516. }
  517. .iconfont-name {
  518. width: 100%;
  519. padding-top: 15rpx;
  520. font-size: 28rpx;
  521. font-weight: 400;
  522. text-align: center;
  523. color: #fafafa;
  524. }
  525. }
  526. }
  527. }
  528. }
  529. </style>