Skip to content

Commit

Permalink
适配IphoneX底部安全区域,解决按钮被遮挡问题;Tabbar中购物车Icon添加数量显示Badge。Fit in the safe a…
Browse files Browse the repository at this point in the history
…rea at the bottom of IphoneX to solve the problem of blocking the button; Add the number of shopping cart Icon in Tabbar to display Badge.
  • Loading branch information
hulucode committed Nov 15, 2019
1 parent 508865d commit 59957c3
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 11 deletions.
13 changes: 13 additions & 0 deletions app.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,17 @@
.space {
height:20rpx;
background-color: #F2f2f2;
}
.safeAreaOldPaddingBttom {
padding-bottom: env(safe-area-inset-bottom);
}
.safeAreaNewPaddingBttom{
padding-bottom: constant(safe-area-inset-bottom);
}

.safeAreaOldMarginBttom {
margin-bottom: env(safe-area-inset-bottom);
}
.safeAreaNewMarginBttom{
margin-bottom: constant(safe-area-inset-bottom);
}
11 changes: 6 additions & 5 deletions pages/goods-details/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
<view class='kjBuyButton' wx:if="{{curGoodsKanjia}}">
<button class="weui-btn" type="warn" bindtap="tobuy">用当前价购买</button>
</view>
<view wx:if="{{!curGoodsKanjia}}" class="footer-box">
<view wx:if="{{!curGoodsKanjia}}" class="footer-box safeAreaOldPaddingBttom safeAreaNewPaddingBttom">
<view class="contact">
<contact-button style="opacity:0;position:absolute;" type="default-dark" session-from="weapp" size="27"></contact-button>
<view style='position:absolute;bottom:10rpx;'> 客服 </view>
Expand Down Expand Up @@ -231,14 +231,15 @@
<view class="num-jia {{buyNumber== buyNumMax ? 'hui': ''}}" bindtap="numJiaTap">+</view>
</view>
</view>
<view class="popup-join-btn" wx:if="{{shopType =='addShopCar'}}" bindtap="addShopCar">
加入购物车
<view class="safeAreaOldPaddingBttom safeAreaNewPaddingBttom" wx:if="{{shopType =='addShopCar'}}" bindtap="addShopCar">
<view class="popup-join-btn">加入购物车</view>
</view>
<view class="popup-join-btn" data-shopType="{{shopType}}" wx:if="{{shopType =='tobuy' || shopType =='toPingtuan'}}" bindtap="buyNow">
立即购买
<view class="safeAreaOldPaddingBttom safeAreaNewPaddingBttom" data-shopType="{{shopType}}" wx:if="{{shopType =='tobuy' || shopType =='toPingtuan'}}" bindtap="buyNow">
<view class="popup-join-btn">立即购买</view>
</view>
</view>
</view>
<view class="safeAreaOldMarginBttom safeAreaNewMarginBttom"></view>
</view>

<block wx:if="{{posterShow}}">
Expand Down
6 changes: 6 additions & 0 deletions pages/index/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const WXAPI = require('apifm-wxapi')
const CONFIG = require('../../config.js')
const TOOLS = require('../../utils/tools.js')

//获取应用实例
var app = getApp()
Page({
Expand Down Expand Up @@ -134,6 +136,10 @@ Page({
that.kanjiaGoods()
that.pingtuanGoods()
},
onShow: function(e){
// 获取购物车数据,显示TabBarBadge
TOOLS.showTabBarBadge();
},
onPageScroll(e) {
let scrollTop = this.data.scrollTop
this.setData({
Expand Down
3 changes: 3 additions & 0 deletions pages/my/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const app = getApp()
const CONFIG = require('../../config.js')
const WXAPI = require('apifm-wxapi')
const AUTH = require('../../utils/auth')
const TOOLS = require('../../utils/tools.js')

Page({
data: {
Expand Down Expand Up @@ -37,6 +38,8 @@ Page({
_this.getUserAmount();
}
})
// 获取购物车数据,显示TabBarBadge
TOOLS.showTabBarBadge();
},
onGotUserInfo(e){
if (!e.detail.userInfo) {
Expand Down
2 changes: 1 addition & 1 deletion pages/order-list/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
<view class="btn active" hidden="{{(item.status==0 || item.status==-1) ? true : false}}" bindtap="refundApply" data-id="{{item.id}}" data-amount='{{item.amountReal}}'>退换货</view>
</view>
</view>

</view>
<view class="safeAreaOldMarginBttom safeAreaNewMarginBttom"></view>
</view>
7 changes: 4 additions & 3 deletions pages/select-address/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
<view class="right-edit" bindtap="editAddess" data-id="{{item.id}}"></view>
</view>
</view>
<view class="bottom-box">
<view class="add-btn" bindtap="addAddess">新增收货地址</view>
<view class="bottom-box-container safeAreaOldPaddingBttom safeAreaNewPaddingBttom">
<view class="bottom-box">
<view class="add-btn" bindtap="addAddess">新增收货地址</view>
</view>
</view>

</view>
9 changes: 8 additions & 1 deletion pages/shop-cart/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const WXAPI = require('apifm-wxapi')
const TOOLS = require('../../utils/tools.js')

const app = getApp()

Page({
data: {
goodsList: {
Expand Down Expand Up @@ -178,7 +181,11 @@ Page({
shopCarInfo.shopNum = tempNumber;
wx.setStorage({
key: "shopCarInfo",
data: shopCarInfo
data: shopCarInfo,
success: function (res) {
// 获取购物车数据,显示TabBarBadge
TOOLS.showTabBarBadge();
}
})
},
bindAllSelect: function() {
Expand Down
2 changes: 1 addition & 1 deletion pages/to-pay-order/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</view>
</view>

<view class="jiesuan-box">
<view class="jiesuan-box safeAreaOldPaddingBttom safeAreaNewPaddingBttom">
<view class="left-price">
<view class="total">合计:¥ {{allGoodsAndYunPrice - youhuijine}} + {{totalScoreToPay}} 积分</view>
</view>
Expand Down
22 changes: 22 additions & 0 deletions utils/tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 显示购物车tabBar的Badge
function showTabBarBadge(){
wx.getStorage({
key: 'shopCarInfo',
success: function (res) {
if (res.data.shopNum > 0) {
wx.setTabBarBadge({
index: 1,
text: `${res.data.shopNum}`
});
} else {
wx.removeTabBarBadge({
index: 1
});
}
}
});
}

module.exports = {
showTabBarBadge: showTabBarBadge
}

0 comments on commit 59957c3

Please sign in to comment.