Skip to content

Commit

Permalink
实现横幅对横竖屏的适应
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbeamman7 committed Jun 22, 2022
1 parent fddb7d6 commit 1df768e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ unpackage/release/*
.DS_Store
*/.DS_Store
config.js
.idea
.idea
.hbuilderx
8 changes: 8 additions & 0 deletions components/scrollBook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,13 @@
.ellipsis-2row{
line-height: 200%;
}
.hor navigator {
width: 170px;
margin: 3px 15px;
}
.hor navigator image {
width: 170px;
height: 223.4px;
}
}
</style>
7 changes: 7 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
"autoclose" : true,
"delay" : 0
},
// 屏幕方向
"screenOrientation": [
"portrait-primary",
"landscape-primary",
"portrait-secondary",
"landscape-secondary"
],
/* 模块配置 */
"modules" : {},
/* 应用发布信息 */
Expand Down
35 changes: 24 additions & 11 deletions pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
</view>

<view v-if="banners.length>0" class="base-padding base-margin-bottom">
<swiper :style="'height:'+bannerHeight" :autoplay="autoplay" :indicator-dots="indicatorDots" :interval="interval"
:duration="duration">
<swiper :style="'height:'+bannerHeight" :autoplay="autoplay" :indicator-dots="indicatorDots"
:interval="interval" :duration="duration">
<swiper-item v-for="banner in banners" :key="banner.id" class="radius-basic">
<image @click="bannerClick" :data-url="banner.link" :src="banner.image" :style="'height:'+bannerHeight+';width:'+bannerWidth"></image>
<image @click="bannerClick" :data-url="banner.link" :src="banner.image"
:style="'height:'+bannerHeight+';width:'+bannerWidth"></image>
</swiper-item>
</swiper>
</view>
Expand Down Expand Up @@ -40,7 +41,8 @@
<view v-if="category.books" class='panel base-padding base-margin-bottom'>
<view class='panel-heading'>
<view class='panel-title font-lv1 strong'>{{category.title}}
<navigator :url="'/pages/list/list?tab=new&cid='+category.id" class='pull-right color-link font-lv3'>更多</navigator>
<navigator :url="'/pages/list/list?tab=new&cid='+category.id"
class='pull-right color-link font-lv3'>更多</navigator>
</view>
</view>
<view class='panel-body'>
Expand Down Expand Up @@ -112,13 +114,23 @@
if (this.showHeaderSearch == true) this.showHeaderSearch = false
}
},
onResize(e) {
let that = this
let info = uni.getSystemInfoSync()
let oriInfo = util.getSysInfo()
let newInfo = {...oriInfo, ...info}
util.setSysInfo(newInfo)
// 重新计算横幅的宽高
that.bannerWidth = parseFloat(that.bannerWidth.split("px")[0])*((e.size.windowWidth -60 )/ e.size.windowHeight) + 'px'
that.bannerHeight = parseFloat(that.bannerHeight.split("px")[0])*((e.size.windowWidth -60 ) / e.size.windowHeight) + 'px'
},
methods: {
adLoad() {
this.adLoaded = true
},
adClose() {
this.adClosed = true
},
adLoad() {
this.adLoaded = true
},
adClose() {
this.adClosed = true
},
loadData() {
let that = this
let cids = []
Expand Down Expand Up @@ -163,7 +175,8 @@
that.bannerWidth = width / info.pixelRatio + "px"
that.bannerHeight = height / info.pixelRatio + "px"
}
if (resRecommendBooks.data && resRecommendBooks.data.books) recommendBooks = resRecommendBooks.data.books
if (resRecommendBooks.data && resRecommendBooks.data.books) recommendBooks =
resRecommendBooks.data.books
if (resBookLists.data && resBookLists.data.books) {
bookLists = resBookLists.data.books
categories = categories.map(function(category) {
Expand Down

0 comments on commit 1df768e

Please sign in to comment.