Commit 49d9c61b by 李嘉林

底部导航展示购物车数量

parent b7d442ce
......@@ -69,7 +69,8 @@ Component({
show: true,
mmm: false,
mainColor: "",
showFlag: "up"
showFlag: "up",
cartNum: 0
},
ready() {
if (app.themeColor["--main-color"] != "#ffffff") {
......@@ -92,35 +93,49 @@ Component({
}
this.setData({
mmm: Math.ceil(app.globalData.footerVal.componentData.list.length / 2 - 1)
})
console.log(Math.ceil(app.globalData.footerVal.componentData.list.length / 2 - 1), this.data.selected)
console.log(this.data.mmm,'ready')
});
console.log(
Math.ceil(app.globalData.footerVal.componentData.list.length / 2 - 1),
this.data.selected
);
console.log(this.data.mmm, "ready");
},
attached() {
let that = this;
if (app.globalData.footerVal) {
let mm=(Math.ceil(app.globalData.footerVal.componentData.list.length/2-1)==that.data.selected&&app.globalData.footerVal.componentData['styleSelectionNum']==1)
let mm =
Math.ceil(app.globalData.footerVal.componentData.list.length / 2 - 1) ==
that.data.selected &&
app.globalData.footerVal.componentData["styleSelectionNum"] == 1;
console.log(733333,mm)
console.log(733333, mm);
that.setData({
componentData: app.globalData.footerVal.componentData,
list: app.globalData.footerVal.componentData.list,
mm:mm
mm: mm
});
console.log('777777',Math.ceil(this.data.list.length/2-1),this.data.selected,this.data.componentData['styleSelectionNum'])
console.log(
"777777",
Math.ceil(this.data.list.length / 2 - 1),
this.data.selected,
this.data.componentData["styleSelectionNum"]
);
} else {
console.log(73333381)
console.log(73333381);
app.footerCallBack = function(params) {
console.log('back')
console.log("back");
that.setData({
componentData: params.componentData,
list: params.componentData.list,
list: params.componentData.list
// mm:(Math.ceil(params.componentData.list.length/2-1)==that.data.selected&&params.componentData['styleSelectionNum']==1)
});
let mm=(Math.ceil(params.componentData.list.length/2-1)==that.data.selected&&params.componentData['styleSelectionNum']==1)
console.log('87777777',mm)
let mm =
Math.ceil(params.componentData.list.length / 2 - 1) ==
that.data.selected &&
params.componentData["styleSelectionNum"] == 1;
console.log("87777777", mm);
};
}
......@@ -133,9 +148,10 @@ Component({
//
this.setData({
mm:(Math.ceil(this.data.list.length/2-1)==this.data.selected&&this.data.componentData['styleSelectionNum']==1)
})
mm:
Math.ceil(this.data.list.length / 2 - 1) == this.data.selected &&
this.data.componentData["styleSelectionNum"] == 1
});
},
methods: {
init() {},
......
......@@ -31,6 +31,10 @@
<!-- 名称 -->
<view class="text" style="color: {{selected === index ? componentData.selectTextColor : componentData.defaultTextColor}};font-size:{{selected === index ? componentData.selectionTextNum*2 : componentData.defaultTextNum*2}}rpx">
{{item.title}}</view>
<!-- 购物车商品数量 -->
<view class="isCart" wx:if="{{item.link&&item.link.link&&item.link.link=='/shopCart/shoppingCart'&&cartNum>0}}">
{{cartNum}}
</view>
</view>
</view>
</view>
......
......@@ -1492,3 +1492,17 @@
-ms-transform: translateY(0);
-o-transform: translateY(0);
}
.isCart{
width: 36rpx;
height: 36rpx;
background: var(--main-color);
position: absolute;
right: -8rpx;
top: 0;
color: #fff;
border-radius: 50%;
font-size: 24rpx;
text-align: center;
line-height: 36rpx;
z-index: 999;
}
\ No newline at end of file
......@@ -4,4 +4,7 @@ export default {
addCart(data) {
return requestPOST(`${process.env.OLSHOP_URL}/cart/add_item`, data);
},
}
\ No newline at end of file
my_cart_count() {
return requestPOST(`${process.env.OLSHOP_URL}/cart/my_cart_count`);
}
};
\ No newline at end of file
......@@ -6,6 +6,7 @@ import goodsApi from "./api/goods"
import orderApi from "./api/order"
import promoteApi from "./api/promote";
import indexApi from './api/index'
import cartApi from './api/cart'
import { DFSImg } from "@/utils/index";
import { $themeToLink, $themeAddToCard } from "@/utils/mayi";
import shop from "./api/shop";
......@@ -58,6 +59,7 @@ mpApp.goodsApi = goodsApi;
mpApp.orderApi = orderApi;
mpApp.promoteApi = promoteApi;
mpApp.indexApi = indexApi;
mpApp.cartApi = cartApi;
mpApp.DFSImg = DFSImg;
mpApp.getThemePage = getThemePage
......
......@@ -242,12 +242,8 @@ export default {
// wx.removeStorageSync('changeAdr')
// }
// 获取购物车数量
this.getCartNum();
},
methods: {
init(pageList) {
......@@ -284,6 +280,13 @@ export default {
},
scrolltolower(){
console.log("scrolltolower")
},
getCartNum() {
app.cartApi.my_cart_count().then(res => {
if (res.data.code == 200) {
this.$mp.page.getTabBar().setData({"cartNum": Number(res.data.data)});
}
});
}
},
onPullDownRefresh(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment