|
@@ -1,11 +1,19 @@
|
|
|
-const pageInit = {};
|
|
|
+const pageInit = {},
|
|
|
+ _Http = getApp().globalData.http;
|
|
|
+
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
PageCur: 'Home',
|
|
|
+ collectCount: "", //购物车商品数量
|
|
|
},
|
|
|
- onLoad() {
|
|
|
+ onLoad(options) {
|
|
|
+ if (options.PageCur) this.setData({
|
|
|
+ PageCur: options.PageCur
|
|
|
+ })
|
|
|
this.refreshData();
|
|
|
+ this.getCollectCount();
|
|
|
+ getApp().globalData.getCollectCount = this.getCollectCount.bind(this);
|
|
|
},
|
|
|
/**
|
|
|
* 更新站点信息
|
|
@@ -25,7 +33,7 @@ Page({
|
|
|
function getedd() {
|
|
|
let paths = [{
|
|
|
name: "商城",
|
|
|
- path: "/packageA/market/index",
|
|
|
+ PageCur: "Market",
|
|
|
icon: "work-shangcheng"
|
|
|
}, {
|
|
|
name: "销售订单",
|
|
@@ -41,7 +49,7 @@ Page({
|
|
|
icon: "work-cuxiaohuodong"
|
|
|
}, {
|
|
|
name: "购物车",
|
|
|
- path: "/packageA/shopping/index",
|
|
|
+ PageCur: "Collect",
|
|
|
icon: "work-gouwuche"
|
|
|
}, {
|
|
|
name: "打款凭证",
|
|
@@ -142,18 +150,44 @@ Page({
|
|
|
return;
|
|
|
}
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 更新购物车数量
|
|
|
+ */
|
|
|
+ getCollectCount() {
|
|
|
+ return _Http.basic({
|
|
|
+ "id": 20220927093202,
|
|
|
+ "content": {}
|
|
|
+ }).then(res => {
|
|
|
+ console.log("购物车数量", res)
|
|
|
+ getApp().globalData.collectCount = res.data.num;
|
|
|
+ pageInit.Collect = false;
|
|
|
+ this.setData({
|
|
|
+ collectCount: res.data.num
|
|
|
+ })
|
|
|
+ return res.data.num;
|
|
|
+ });
|
|
|
+ },
|
|
|
/**
|
|
|
* 切换页面
|
|
|
*/
|
|
|
NavChange(e) {
|
|
|
- let PageCur = e.currentTarget.dataset.cur;
|
|
|
- if (!pageInit[PageCur]) {
|
|
|
- let page = this.selectComponent("#" + PageCur);
|
|
|
+ this.cutBar({
|
|
|
+ detail: e.currentTarget.dataset.cur
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 切换bar
|
|
|
+ */
|
|
|
+ cutBar({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ if (!pageInit[detail]) {
|
|
|
+ let page = this.selectComponent("#" + detail);
|
|
|
page && page.init();
|
|
|
- pageInit[PageCur] = true;
|
|
|
+ pageInit[detail] = true;
|
|
|
}
|
|
|
this.setData({
|
|
|
- PageCur
|
|
|
+ PageCur: detail
|
|
|
})
|
|
|
- },
|
|
|
+ }
|
|
|
})
|