xiaohaizhao 4 days ago
parent
commit
6208bc50c1
7 changed files with 66 additions and 37 deletions
  1. 16 2
      app.js
  2. 8 13
      pages/login/phone.js
  3. 1 1
      project.private.config.json
  4. 20 21
      utils/language.js
  5. 12 0
      utils/work/apps.js
  6. 9 0
      utils/work/work-icon.wxss
  7. 0 0
      utils/work/work.wxss

+ 16 - 2
app.js

@@ -53,8 +53,22 @@ App({
                 })
             });
         }
-        if (!wx.getStorageSync('languagecode')) wx.setStorageSync('languagecode', 'ZH');
-        this.globalData.Language.getLanguages(wx.getStorageSync('languagecode'));
+        if (wx.getStorageSync('languagecode')) {
+            setTimeout(() => {
+                this.globalData.Language.getLanguages(wx.getStorageSync('languagecode'))
+            }, 500)
+        } else {
+            wx.getSystemInfoAsync({
+                success: res => {
+                    let languagecode = 'ZH';
+                    try {
+                        languagecode = res.language.split("_")[0].toUpperCase()
+                    } catch (error) {}
+                    wx.setStorageSync('languagecode', languagecode);
+                    this.globalData.Language.getLanguages(languagecode);
+                }
+            })
+        }
     },
     initSocket() {
         let that = this;

+ 8 - 13
pages/login/phone.js

@@ -42,19 +42,14 @@ Page({
 	changeLanguages(e) {
 		let item = this.data.languages[e.detail.value];
 		getApp().globalData.Language.getLanguages(item.languagecode).then(res => {
-			try {
-				this.setData({
-					language: res,
-					languagename: item.languagename || '简体中文',
-					rowIndex: item.rowindex - 1
-				})
-			} catch (error) {
-				this.setData({
-					language: res,
-					languagename: '简体中文',
-					rowIndex: item.rowindex - 1
-				})
-			}
+			this.setData({
+				language: res,
+				languagename: item.languagename || '简体中文',
+				rowIndex: item.rowindex - 1
+			})
+			this.selectComponent('#login').setData({
+				language: res,
+			});
 			this.changeTitle();
 		})
 	},

+ 1 - 1
project.private.config.json

@@ -20,6 +20,6 @@
     "bigPackageSizeSupport": false,
     "useIsolateContext": true
   },
-  "libVersion": "3.8.2",
+  "libVersion": "3.10.0",
   "condition": {}
 }

+ 20 - 21
utils/language.js

@@ -1,6 +1,8 @@
 class Language {
 	constructor() {
+		this.languagecode = null;
 		this.languagePackage = null;
+		this.getLanguages = this.getLanguages.bind(this);
 	}
 
 	getLanguages(languagecode) {
@@ -9,28 +11,33 @@ class Language {
 				let res = {
 					data: {}
 				}
-				if (languagecode != 'ZH' || this.languagePackage == null) res = await getApp().globalData.http.base({
+				if (languagecode != 'ZH') res = await getApp().globalData.http.base({
 					id: 2024062809072801,
 					content: {
 						date: Date.now()
 					}
 				})
-				console.log("获取语言包", res.data)
 				this.languagePackage = res.data[languagecode] || {};
-				resolve(this.languagePackage)
 				this.languagecode = languagecode;
+				resolve(this.languagePackage)
 				wx.removeStorageSync('languagecode');
 				wx.setStorageSync('languagecode', languagecode)
 			})
 		})
 	}
 
-	async getLanguagePackage(that, setNavBarTitle) {
-		that.setData({
-			language: this.languagePackage || await this.getLanguages(wx.getStorageSync('languagecode')),
-			sColors: getApp().globalData.sColors
-		})
-		if (setNavBarTitle) this.setNavBarTitle(setNavBarTitle)
+	getLanguagePackage(that, setNavBarTitle) {
+		if (this.languagecode == null) {
+			setTimeout(() => {
+				this.getLanguagePackage(that, setNavBarTitle)
+			}, 100)
+		} else {
+			that.setData({
+				language: this.languagePackage,
+				sColors: getApp().globalData.sColors
+			})
+			if (setNavBarTitle) this.setNavBarTitle(setNavBarTitle)
+		}
 	}
 
 	getMapText(text, f = '', r = '') {
@@ -38,7 +45,7 @@ class Language {
 		try {
 			v = this.languagePackage[text] || text
 		} catch (error) {
-			console.log('getMapText:未获取到', text)
+			if (wx.getStorageSync('languagecode') != 'ZH') console.log('getMapText:未获取到', text)
 			v = text
 		}
 		return f + v + r
@@ -48,19 +55,11 @@ class Language {
 			title: this.getMapText(title)
 		})
 	}
-
-	modeBoxPrompts(list, title = '提示', confirmText = '确定') {
-		wx.showModal({
-			title: this.getMapText(title),
-			content: this.joint(list),
-			showCancel: false,
-			confirmText: this.getMapText(confirmText),
-		})
-	}
-	showToast(list) {
+	showToast(list, mask = false) {
 		if (list.length) wx.showToast({
 			title: this.joint(list),
-			icon: "none"
+			icon: "none",
+			mask: mask
 		})
 	}
 	modeBoxPrompts(list = [], title = '提示', confirmText = '确定') {

+ 12 - 0
utils/work/apps.js

@@ -29,6 +29,18 @@ function getapps() {
 		name: "销售漏斗",
 		path: "/packageA/salesHourglass/index",
 		icon: "work-xiaoshouloudou"
+	}, {
+		name: "360°画像",
+		path: "/portrayal/index/index",
+		icon: "work-kehuhuaxiang"
+	}, {
+		name: "销售数据",
+		path: "/salesPanel/index/index",
+		icon: "work-xiaoshoushuju"
+	}, {
+		name: "数据总览",
+		path: "/salesPanel/dataOverview/index",
+		icon: "work-shujutongji"
 	}];
 	let app = [...getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['通用']), ...getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['数据统计'], ['数据分析'])],
 		list = [];

+ 9 - 0
utils/work/work-icon.wxss

@@ -8,6 +8,15 @@
     -moz-osx-font-smoothing: grayscale;
 }
 
+
+.work-xiaoshoushuju:before {
+    content: "\e625";
+}
+
+.work-shujutongji:before {
+    content: "\e626";
+}
+
 .work-qiandao:before {
     content: "\e615";
 }

File diff suppressed because it is too large
+ 0 - 0
utils/work/work.wxss


Some files were not shown because too many files changed in this diff