Explorar o código

tabbar逻辑调整

xiaohaizhao %!s(int64=2) %!d(string=hai) anos
pai
achega
8dbbf391d1

+ 2 - 6
pages/index/collect/index.js

@@ -23,6 +23,7 @@ Component({
 		init() {
 			this.getList()
 			this.selectComponent("#ListBox").setHeight(".head", this);
+			return true;
 		},
 		/* 获取列表 */
 		getList() {
@@ -232,12 +233,7 @@ Component({
 					title: res.msg,
 					icon: "none"
 				});
-				this.setData({
-					list: this.data.list.filter(v => v.sa_shoppingcartid != item.sa_shoppingcartid)
-				})
-				if (this.data.results.some(v => v == item.sa_shoppingcartid)) this.changeResults({
-					item
-				}, true);
+				this.getList(true)
 				getApp().globalData.getCollectCount()
 			})
 		},

+ 16 - 11
pages/index/index.js

@@ -1,4 +1,4 @@
-const pageInit = {},
+let pageInit = null,
 	_Http = getApp().globalData.http;
 
 
@@ -9,20 +9,27 @@ Page({
 		msgList: []
 	},
 	onLoad(options) {
+		pageInit = {
+			Home: false,
+			Message: false,
+			Market: false,
+			Collect: false,
+			UserCenter: false,
+		};
 		if (options.PageCur) this.setData({
 			PageCur: options.PageCur
 		})
 		this.refreshData();
 		this.getCollectCount();
 		this.updateMsgCount();
-		getApp().globalData.getCollectCount = this.getCollectCount.bind(this);
-		getApp().globalData.socketCallback = this.updateMsgCount.bind(this);
 	},
 	/**
 	 * 更新站点信息
 	 * 主要用来渲染首页的banner和宫格
 	 */
 	refreshData() {
+		getApp().globalData.getCollectCount = this.getCollectCount.bind(this);
+		getApp().globalData.socketCallback = this.updateMsgCount.bind(this);
 		let page = this.selectComponent("#Home");
 		if (page && wx.getStorageSync('userauth').length != 0) {
 			let authList = {},
@@ -148,7 +155,7 @@ Page({
 				bannerList: banner ? banner.ads : []
 			});
 			pageInit.Home = true;
-      page.selectComponent("#ListBox").setHeight(".head", page);
+			page.selectComponent("#ListBox").setHeight(".head", page);
 
 		} else {
 			setTimeout(this.refreshData, 10);
@@ -174,6 +181,7 @@ Page({
 	},
 	/* 更新消息数量 */
 	updateMsgCount() {
+		console.log("调用")
 		pageInit.Message = false;
 		_Http.basic({
 			"classname": "system.message.Message",
@@ -197,8 +205,7 @@ Page({
 			content: {
 				nocache: true,
 				pageNumber: 1,
-				pageSize: 3,
-				pageTotal: 1,
+				pageSize: 1,
 				type: "",
 				where: {}
 			},
@@ -224,11 +231,9 @@ Page({
 	cutBar({
 		detail
 	}) {
-		if (!pageInit[detail]) {
-			let page = this.selectComponent("#" + detail);
-			page && page.init();
-			pageInit[detail] = true;
-		}
+		let page = this.selectComponent("#" + detail);
+		if (!page) return;
+		if (!pageInit[detail] && page.init()) pageInit[detail] = true;
 		this.setData({
 			PageCur: detail
 		})

+ 7 - 15
pages/index/index.wxml

@@ -1,21 +1,13 @@
 <cu-custom isBack="{{false}}">
 	<view slot="content">E-订单</view>
 </cu-custom>
-<view hidden="{{PageCur!='Home'}}">
-	<Home id='Home' bind:cutBar="cutBar" />
-</view>
-<view hidden="{{PageCur!='Message'}}">
-	<Message id='Message' />
-</view>
-<view hidden="{{PageCur!='Market'}}">
-	<Market id='Market' />
-</view>
-<view hidden="{{PageCur!='Collect'}}">
-	<Collect id='Collect' />
-</view>
-<view hidden="{{PageCur!='UserCenter'}}">
-	<UserCenter id='UserCenter' />
-</view>
+
+<view hidden="{{PageCur!='Home'}}"><Home id='Home' bind:cutBar="cutBar" /></view>
+<view hidden="{{PageCur!='Message'}}"><Message id='Message' /></view>
+<view hidden="{{PageCur!='Market'}}"><Market id='Market' /></view>
+<view hidden="{{PageCur!='Collect'}}"><Collect id='Collect' /></view>
+<view hidden="{{PageCur!='UserCenter'}}"><UserCenter id='UserCenter' /></view>
+
 <view class="cu-bar tabbar bg-white foot">
 	<view class="action {{PageCur=='Home'?'text-blue':'text-gray'}}" bindtap="NavChange" data-cur="Home">
 		<view class="cuIcon-homefill"></view>

+ 2 - 1
pages/index/market/index.js

@@ -45,7 +45,7 @@ Component({
     init() {
       this.getBrand();
       this.getTradefie();
-      getApp().globalData.setTemporaryId = this.handleFiltrate.bind(this)
+			return true;
     },
     showModal(e) {
       this.setData({
@@ -59,6 +59,7 @@ Component({
     },
     /* 获取品牌 */
     getBrand() {
+      getApp().globalData.setTemporaryId = this.handleFiltrate.bind(this);
       _Http.basic({
         "id": 20220924163702,
         content: {

+ 2 - 1
pages/index/message/index.js

@@ -25,7 +25,8 @@ Component({
       this.setData({
         tabshow: true
       })
-      this.getlist(true)
+      this.getlist(true);
+			return true;
     },
     getlist(init = false) {
       if (init.detail != undefined) init = init.detail;

+ 5 - 6
pages/index/userCenter/index.js

@@ -11,17 +11,15 @@ Component({
 	data: {},
 	methods: {
 		init() {
-			console.log("打开个人应用")
 			this.queryUserMsg();
-
-			let authlist = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心']);
+			// let authlist = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心']);
 			let pathList = [{
 				name: "修改登录密码",
 				icon: "icon-a-wodeguanyuyingyong",
 				color: "var(--warning)",
 				path: `/pages/tabbar/mine/changePassword/index`
 			}]
-			if (authlist.length != 0) authlist[0].apps.forEach(v => {
+		/* 	if (authlist.length != 0) authlist[0].apps.forEach(v => {
 				switch (v.name) {
 					case "teamManagement":
 						console.log(v)
@@ -36,10 +34,11 @@ Component({
 						})
 						break;
 				}
-			});
+			}); */
 			this.setData({
 				pathList
-			})
+			});
+			return true;
 		},
 		/* 查询用户信息 */
 		queryUserMsg() {