top.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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. success: function(res) {
  151. console.log('条码类型:' + res.scanType);
  152. console.log('条码内容:' + res.result);
  153. },
  154. fail(fail){
  155. console.log(fail)
  156. // if ([0, 11, 12].includes(fail.code)) return;
  157. // permision.showManualAuth('android.permission.CAMERA');
  158. }
  159. });
  160. },
  161. onSearch() {
  162. openSearch()
  163. },
  164. openCustomerCenter() {
  165. uni.navigateTo({
  166. url: '/pages/government/customer-center'
  167. });
  168. },
  169. toQY() {
  170. // this.$yghttp.get('/yima/request/appUser/enterprise').then(res=>{
  171. // if(res.data.has){
  172. this.$openPage(this.toQyKongLimList[0])
  173. // }else{
  174. // this.$openPage({thirdApplicationId:res.data.thirdApplicationId,name:''})
  175. // // uni.navigateTo({
  176. // // url:"/pages/web-view/Apps?path="+res.data.url
  177. // // })
  178. // }
  179. // })
  180. }
  181. },
  182. watch: {
  183. scrollTop: {
  184. handler: function(newNum, oldNum) {
  185. const scrollNum = Number(newNum) || 0
  186. // this.scrollStyle = scrollNum > 140 ? true : false;
  187. const num = uni.upx2px(40)
  188. // if (scrollNum > num) {
  189. // this.showNavBg = true
  190. // } else {
  191. // this.showNavBg = false
  192. // }
  193. // if (scrollNum >= 15 && scrollNum < 70) {
  194. // const op = scrollNum / 70;
  195. // this.navScrollStyle = {
  196. // opacity: 1 - op,
  197. // }
  198. // }
  199. // if (scrollNum >= 70 && scrollNum < 140) {
  200. // const op = (scrollNum - 70) / 70;
  201. // this.navScrollStyle = {
  202. // backgroundColor: `rgba(255, 255, 255, ${op})`,
  203. // opacity: op,
  204. // }
  205. // }
  206. // if (scrollNum >= 140) {
  207. // this.navScrollStyle = {
  208. // backgroundColor: `rgba(255, 255, 255 ,1)`,
  209. // }
  210. // }
  211. },
  212. immediate: true
  213. },
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .top-box {
  219. width: 100%;
  220. overflow: hidden;
  221. position: relative;
  222. .swiper-content {
  223. position: absolute;
  224. left: 0;
  225. top: 0;
  226. right: 0;
  227. }
  228. .swiper-boxs {
  229. overflow: hidden;
  230. width: 200%;
  231. position: absolute;
  232. left: -50%;
  233. /* (width - 100%)/ 2 */
  234. top: 0;
  235. border-radius: 0 0 50% 50%;
  236. .swiper-box {
  237. margin: 0 auto;
  238. width: 750rpx;
  239. height: 100%;
  240. overflow: hidden;
  241. }
  242. }
  243. // .zw-show-bg {
  244. // background: url("@/static/home_bar_01.png") no-repeat center center;
  245. // }
  246. // .sh-show-bg {
  247. // // background: url("@/static/home_bar_02.png") no-repeat center center;
  248. // background-image: url("http://sly2020.oss-cn-beijing.aliyuncs.com/2024/01/25/b737a2ca9cd1492abc290e2081cb3739.png");
  249. // }
  250. .hide-nav-bg {
  251. background: none !important;
  252. }
  253. .nav-top {
  254. position: fixed;
  255. z-index: 2;
  256. left: 0;
  257. top: 0;
  258. right: 0;
  259. padding: 0 $zw-padding;
  260. background-size: 100% 100%;
  261. .status-title {
  262. width: 100%;
  263. height: 113rpx;
  264. padding-top: 27rpx;
  265. display: flex;
  266. justify-content: space-between;
  267. align-items: stretch;
  268. .title-identity-box,
  269. .title-btn {
  270. width: 200rpx;
  271. display: flex;
  272. align-items: center;
  273. }
  274. // 86rpx
  275. .title-identity-box {
  276. .title-identity {
  277. width: 141rpx;
  278. height: 57rpx;
  279. display: flex;
  280. justify-content: center;
  281. align-items: center;
  282. border-radius: 30rpx;
  283. .identity-icon {
  284. font-size: 34rpx;
  285. }
  286. .identity-icon {
  287. width: 37.47rpx;
  288. height: 29.64rpx;
  289. }
  290. text+text {
  291. font-size: 26rpx;
  292. font-weight: 400;
  293. padding-left: 14rpx;
  294. }
  295. }
  296. }
  297. .title-btn {
  298. display: flex;
  299. justify-content: flex-end;
  300. align-items: center;
  301. .title-btn-item {
  302. width: 55rpx;
  303. height: 45rpx;
  304. }
  305. .title-btn-item {
  306. font-size: 40rpx;
  307. &:first-child {
  308. margin-right: 20rpx;
  309. }
  310. }
  311. }
  312. .title-name {
  313. flex: 1;
  314. display: flex;
  315. align-items: stretch;
  316. justify-content: center;
  317. text {
  318. display: flex;
  319. align-items: center;
  320. &+text {
  321. margin-left: 60rpx;
  322. }
  323. font-size: 36rpx;
  324. font-family: PingFang SC,
  325. PingFang SC-Medium;
  326. font-weight: 500;
  327. }
  328. .active-title-name {
  329. font-family: PingFang SC, PingFang SC-Bold;
  330. font-weight: 700;
  331. position: relative;
  332. &::before {
  333. content: '';
  334. position: absolute;
  335. left: 0;
  336. bottom: 0;
  337. width: 100%;
  338. height: 8rpx;
  339. border-radius: 4rpx;
  340. }
  341. }
  342. }
  343. }
  344. .status-search {
  345. width: 100%;
  346. height: 110rpx;
  347. padding: 20rpx 0;
  348. display: flex;
  349. justify-content: space-between;
  350. align-items: stretch;
  351. .weather-box {
  352. width: 70rpx;
  353. height: 100%;
  354. display: flex;
  355. flex-direction: column;
  356. justify-content: center;
  357. align-items: center;
  358. .weather-img {
  359. width: 70rpx;
  360. height: 70rpx;
  361. }
  362. .weather-icon {}
  363. .weather-num {
  364. // padding-top: 5rpx;
  365. font-size: 22rpx;
  366. line-height: 1;
  367. font-family: PingFang SC, PingFang SC-Bold;
  368. font-weight: 700;
  369. // text-align: left;
  370. text {
  371. font-weight: 400;
  372. transform: scale(0.8);
  373. }
  374. }
  375. }
  376. .search-box {
  377. flex: 1;
  378. height: 100%;
  379. border-radius: 35rpx;
  380. overflow: hidden;
  381. padding: 0 20rpx;
  382. display: flex;
  383. align-items: center;
  384. .search-icon {
  385. font-size: 30rpx;
  386. }
  387. .search-text {
  388. font-size: 27rpx;
  389. padding-left: 3px;
  390. }
  391. }
  392. }
  393. }
  394. .zw-nav-top,
  395. .sh-nav-top {
  396. .title-identity-box,
  397. .title-btn,
  398. .weather-icon,
  399. .weather-num {
  400. color: #fff;
  401. }
  402. .title-identity {
  403. background-color: rgba(255, 255, 255, 0.3);
  404. // box-shadow: 0px 4px 6px 0px rgba(3, 148, 180, 0.30);
  405. }
  406. .title-name {
  407. .active-title-name {
  408. color: #fff;
  409. &::before {
  410. background-color: #fff;
  411. }
  412. }
  413. }
  414. .search-box {
  415. background: rgba(255, 255, 255, 0.30);
  416. border: 1rpx solid rgba(255, 255, 255, 0.36);
  417. color: #fff;
  418. .search-text {
  419. color: rgba(255, 255, 255, 0.50);
  420. }
  421. }
  422. }
  423. .zw-nav-top {
  424. .title-name {
  425. text {
  426. color: #D5F1F6;
  427. }
  428. }
  429. }
  430. .sh-nav-top {
  431. .title-name {
  432. text {
  433. color: #FFE6D6;
  434. }
  435. }
  436. }
  437. .scroll-style {
  438. .weather-icon {
  439. color: #FABB00;
  440. }
  441. .title-identity-box,
  442. .title-btn,
  443. .weather-num,
  444. .title-name>text {
  445. color: #000 !important;
  446. }
  447. .active-title-name::before {
  448. background-color: #000 !important;
  449. }
  450. .title-identity {
  451. // background-color: rgba(255, 255, 255, 0.3);
  452. border: 1rpx solid #ccc;
  453. // box-shadow: 0px 4px 6px 0px rgba(3, 148, 180, 0.30);
  454. }
  455. .search-box {
  456. border: 1rpx solid #ccc;
  457. color: #c1c1c1;
  458. .search-text {
  459. color: #c1c1c1;
  460. }
  461. }
  462. }
  463. .status-placeholder {
  464. width: 100%;
  465. // height: calc(113rpx + 110rpx);
  466. height: 223rpx;
  467. // height: 120px;
  468. }
  469. .shortcut-box {
  470. position: relative;
  471. left: 0;
  472. right: 0;
  473. top: 0;
  474. z-index: 1;
  475. .shortcut-content {
  476. width: 100%;
  477. padding: 35rpx $zw-padding 0;
  478. .shortcut-item {
  479. display: flex;
  480. flex-direction: column;
  481. justify-content: center;
  482. align-items: center;
  483. .iconfont-icon {
  484. font-size: 50rpx;
  485. font-weight: bold;
  486. color: #fff;
  487. }
  488. .icon_img {
  489. width: 50rpx;
  490. height: 50rpx;
  491. vertical-align: middle;
  492. }
  493. .iconfont-name {
  494. width: 100%;
  495. padding-top: 15rpx;
  496. font-size: 28rpx;
  497. font-weight: 400;
  498. text-align: center;
  499. color: #fafafa;
  500. }
  501. }
  502. }
  503. }
  504. }
  505. </style>