Просмотр исходного кода

【前端模版】更新移动端源码

吴昊天 3 лет назад
Родитель
Сommit
b961d9bc87

+ 411 - 404
template/uni-app/App.vue

@@ -1,405 +1,412 @@
-<script>
-	import {
-		checkLogin
-	} from './libs/login';
-	import {
-		HTTP_REQUEST_URL
-	} from './config/app';
-	import {
-		getShopConfig,
-		silenceAuth
-	} from '@/api/public';
-	import Auth from '@/libs/wechat.js';
-	import Routine from './libs/routine.js';
-	import {
-		silenceBindingSpread
-	} from "@/utils";
-	import {
-		getCartCounts,
-	} from '@/api/order.js';
-	import {
-		colorChange,
-		getCrmebCopyRight
-	} from '@/api/api.js';
-	import {
-		mapGetters
-	} from "vuex"
-	import colors from '@/mixins/color.js';
-	let green =
-		'--view-theme: rgba(66,202,77,1);--view-theme-16: #42CA4D;--view-priceColor:#FF7600;--view-minorColor:rgba(108, 198, 94, 0.5);--view-minorColorT:rgba(66, 202, 77, 0.1);--view-bntColor:#FE960F;--view-op-ten: rgba(66,202,77, 0.1);--view-main-start:#70E038; --view-main-over:#42CA4D;--view-op-point-four: rgba(66,202,77, 0.04);'
-	let red =
-		'--view-theme: rgba(233,51,35,1);--view-theme-16: #e93323;--view-priceColor:#e93323;--view-minorColor:rgba(233, 51, 35, 0.5);--view-minorColorT:rgba(233, 51, 35, 0.1);--view-bntColor:#FE960F;--view-op-ten: rgba(233,51,35, 0.1);--view-main-start:#FF6151; --view-main-over:#e93323;--view-op-point-four: rgba(233,51,35, 0.04);'
-	let blue =
-		'--view-theme: rgba(29,176,252,1);--view-theme-16:#1db0fc;--view-priceColor:#FD502F;--view-minorColor:rgba(58, 139, 236, 0.5);--view-minorColorT:rgba(9, 139, 243, 0.1);--view-bntColor:#22CAFD;--view-op-ten: rgba(29,176,252, 0.1);--view-main-start:#40D1F4; --view-main-over:#1DB0FC;--view-op-point-four: rgba(29,176,252, 0.04);'
-	let pink =
-		'--view-theme: rgba(255,68,143,1);--view-theme-16:#ff448f;--view-priceColor:#FF448F;--view-minorColor:rgba(255, 68, 143, 0.5);--view-minorColorT:rgba(255, 68, 143, 0.1);--view-bntColor:#282828;--view-op-ten: rgba(255,68,143, 0.1);--view-main-start:#FF67AD; --view-main-over:#FF448F;--view-op-point-four: rgba(255,68,143, 0.04);'
-	let orange =
-		'--view-theme: rgba(254,92,45,1); --view-theme-16:#FE5C2D;--view-priceColor:#FE5C2D;--view-minorColor:rgba(254, 92, 45, 0.5);--view-minorColorT:rgba(254, 92, 45, 0.1);--view-bntColor:#FDB000;--view-op-ten: rgba(254,92,45, 0.1);--view-main-start:#FF9445; --view-main-over:#FE5C2D;--view-op-point-four: rgba(254,92,45, 0.04);'
-
-	export default {
-		globalData: {
-			spid: 0,
-			code: 0,
-			isLogin: false,
-			userInfo: {},
-			MyMenus: [],
-			globalData: false,
-			isIframe: false,
-			tabbarShow: true,
-			windowHeight: 0,
-			locale: ''
-		},
-		mixins: [colors],
-		computed: mapGetters(['isLogin', 'cartNum']),
-		watch: {
-			isLogin: {
-				deep: true, //深度监听设置为 true
-				handler: function(newV, oldV) {
-					if (newV) {
-						// this.getCartNum()
-					} else {
-						this.$store.commit('indexData/setCartNum', '')
-					}
-				}
-			},
-			cartNum(newCart, b) {
-				this.$store.commit('indexData/setCartNum', newCart + '')
-				if (newCart > 0) {
-					uni.setTabBarBadge({
-						index: Number(uni.getStorageSync('FOOTER_ADDCART')) || 2,
-						text: newCart + ''
-					})
-				} else {
-					uni.hideTabBarRedDot({
-						index: Number(uni.getStorageSync('FOOTER_ADDCART')) || 2
-					})
-				}
-			}
-		},
-		async onLaunch(option) {
-			let that = this;
-			colorChange('color_change').then(res => {
-				uni.setStorageSync('is_diy', res.data.is_diy)
-				uni.$emit('is_diy', res.data.is_diy)
-				switch (res.data.status) {
-					case 1:
-						uni.setStorageSync('viewColor', blue)
-						uni.$emit('ok', blue, res.data.status)
-						break;
-					case 2:
-						uni.setStorageSync('viewColor', green)
-						uni.$emit('ok', green, res.data.status)
-						break;
-					case 3:
-						uni.setStorageSync('viewColor', red)
-						uni.$emit('ok', red, res.data.status)
-						break;
-					case 4:
-						uni.setStorageSync('viewColor', pink)
-						uni.$emit('ok', pink, res.data.status)
-						break;
-					case 5:
-						uni.setStorageSync('viewColor', orange)
-						uni.$emit('ok', orange, res.data.status)
-						break;
-					default:
-						uni.setStorageSync('viewColor', red)
-						uni.$emit('ok', red, res.data.status)
-						break
-				}
-			});
-			if (option.query.spread) {
-				that.$Cache.set('spread', option.query.spread);
-				that.globalData.spid = option.query.spread;
-				that.globalData.pid = option.query.spread;
-				silenceBindingSpread()
-			}
-			if (option.query.spid) {
-				that.$Cache.set('spread', option.query.spid);
-				that.globalData.spid = option.query.spid;
-				that.globalData.pid = option.query.spid;
-				// silenceBindingSpread()
-			}
-			// #ifdef APP-PLUS || H5
-			uni.getSystemInfo({
-				success: function(res) {
-					// 首页没有title获取的整个页面的高度,里面的页面有原生标题要减掉就是视口的高度
-					// 状态栏是动态的可以拿到 标题栏是固定写死的是44px
-					let height = res.windowHeight - res.statusBarHeight - 44
-					// #ifdef H5 || APP-PLUS
-					that.globalData.windowHeight = res.windowHeight + 'px'
-					// #endif
-					// // #ifdef APP-PLUS
-					// that.globalData.windowHeight = height + 'px'
-					// // #endif
-
-				}
-			});
-			// #endif	
-			// #ifdef MP
-			if (HTTP_REQUEST_URL == '') {
-				console.error(
-					"请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
-				);
-				return false;
-			}
-			if (option.query.hasOwnProperty('scene')) {
-
-				switch (option.scene) {
-					//扫描小程序码
-					case 1047:
-						let val = that.$util.getUrlParams(decodeURIComponent(option.query.scene));
-						that.globalData.code = val.pid === undefined ? val : val.pid;
-						break;
-						//长按图片识别小程序码
-					case 1048:
-						that.globalData.code = option.query.scene;
-						break;
-						//手机相册选取小程序码
-					case 1049:
-						that.globalData.code = option.query.scene;
-						break;
-						//直接进入小程序
-					case 1001:
-						that.globalData.spid = option.query.scene;
-						break;
-				}
-			}
-			const updateManager = wx.getUpdateManager();
-
-			updateManager.onCheckForUpdate(function(res) {
-				// 请求完新版本信息的回调
-			});
-
-			updateManager.onUpdateReady(function() {
-				wx.showModal({
-					title: '更新提示',
-					content: '新版本已经准备好,是否重启应用?',
-					success: function(res) {
-						if (res.confirm) {
-							// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-							updateManager.applyUpdate();
-						}
-					}
-				});
-			});
-
-			updateManager.onUpdateFailed(function() {
-				return that.Tips({
-					title: '新版本下载失败'
-				});
-			});
-			// #endif
-			// getShopConfig().then(res => {
-			// 	this.$store.commit('SETPHONESTATUS', res.data.status);
-			// });
-			// 获取导航高度;
-			uni.getSystemInfo({
-				success: function(res) {
-					that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
-				}
-			});
-			// #ifdef MP
-			let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
-			that.globalData.navH = menuButtonInfo.top * 2 + menuButtonInfo.height / 2;
-			// #endif
-
-			// #ifdef H5
-			uni.getSystemInfo({
-				success(e) {
-					/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
-					if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
-						window.location.pathname = '/static/html/pc.html';
-					}
-				}
-			});
-			if (option.query.hasOwnProperty('type') && option.query.type == "iframeWindow") {
-				this.globalData.isIframe = true;
-			} else {
-				this.globalData.isIframe = false;
-			}
-
-			//公众号静默授权
-			// if (window.location.pathname !== '/' && option.query.scope === 'snsapi_base') {
-			// 	let snsapiBase = 'snsapi_base';
-			// 	let urlData = location.pathname + location.search;
-			// 	// if (!that.$store.getters.isLogin && uni.getStorageSync('authIng')) {
-			// 	// 	uni.setStorageSync('authIng', false)
-			// 	// }
-			// 	if (!that.$store.getters.isLogin && Auth.isWeixin()) {
-			// 		let code,
-			// 			state,
-			// 			scope = ''
-
-			// 		if (option.query.code instanceof Array) {
-			// 			code = option.query.code[option.query.code.length - 1]
-			// 		} else {
-			// 			code = option.query.code
-			// 		}
-
-
-			// 		if (code && code != uni.getStorageSync('snsapiCode') && location.pathname.indexOf(
-			// 				'/pages/users/wechat_login/index') === -1) {
-			// 			// 存储静默授权code
-			// 			uni.setStorageSync('snsapiCode', code);
-			// 			let spread = that.globalData.spid ? that.globalData.spid : '';
-			// 			uni.setStorageSync('authIng', true)
-			// 			silenceAuth({
-			// 					code: code,
-			// 					spread: that.$Cache.get('spread'),
-			// 					spid: that.globalData.code
-			// 				})
-			// 				.then(res => {
-			// 					uni.setStorageSync('authIng', false)
-			// 					uni.setStorageSync('snRouter', decodeURIComponent(decodeURIComponent(option.query
-			// 						.back_url)));
-			// 					if (res.data.key !== undefined && res.data.key) {
-			// 						this.$Cache.set('snsapiKey', res.data.key);
-			// 					} else {
-
-			// 						let time = res.data.expires_time - this.$Cache.time();
-			// 						this.$store.commit('LOGIN', {
-			// 							token: res.data.token,
-			// 							time: time
-			// 						});
-			// 						this.$Cache.set('WX_AUTH', code);
-			// 						this.$store.commit('SETUID', res.data.userInfo.uid);
-			// 						this.$store.commit('UPDATE_USERINFO', res.data.userInfo);
-
-			// 						if (option.query.back_url) {
-			// 							location.replace(decodeURIComponent(decodeURIComponent(option.query
-			// 								.back_url)));
-			// 						}
-			// 					}
-			// 				})
-			// 				.catch(error => {
-			// 					uni.setStorageSync('authIng', false)
-			// 					let url = ''
-			// 					if (option.query.back_url instanceof Array) {
-			// 						url = option.query.back_url[option.query.back_url.length - 1]
-			// 					} else {
-			// 						url = option.query.back_url
-			// 					}
-			// 					if (!that.$Cache.has('snsapiKey')) {
-			// 						if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
-			// 							Auth.oAuth(snsapiBase, url);
-			// 						}
-			// 					}
-			// 				});
-			// 		} else {
-			// 			if (!this.$Cache.has('snsapiKey')) {
-			// 				if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
-			// 					Auth.oAuth(snsapiBase, urlData);
-			// 				}
-			// 			}
-			// 		}
-			// 	} else {
-			// 		if (option.query.back_url) {
-			// 			location.replace(uni.getStorageSync('snRouter'));
-			// 		}
-			// 	}
-			// }
-			// #endif
-			// #ifdef MP
-			// 小程序静默授权
-			// if (!this.$store.getters.isLogin) {
-			// 	Routine.getCode()
-			// 		.then(code => {
-			// 			this.silenceAuth(code);
-			// 		})
-			// 		.catch(res => {
-			// 			uni.hideLoading();
-			// 		});
-			// }
-			// #endif
-			// #ifdef H5
-			// 添加crmeb chat 统计
-			var __s = document.createElement('script');
-			__s.src = `${HTTP_REQUEST_URL}/api/get_script`;
-			document.head.appendChild(__s);
-			// #endif
-			getCrmebCopyRight().then(res => {
-				uni.setStorageSync('copyRight', res.data)
-			})
-		},
-		methods: {
-			// 小程序静默授权
-			// silenceAuth(code) {
-			// 	let that = this;
-			// 	let spread = that.globalData.spid ? that.globalData.spid : '';
-			// 	silenceAuth({
-			// 			code: code,
-			// 			spread_spid: spread,
-			// 			spread_code: that.globalData.code
-			// 		})
-			// 		.then(res => {
-			// 			if (res.data.token !== undefined && res.data.token) {
-			// 				uni.hideLoading();
-			// 				let time = res.data.expires_time - this.$Cache.time();
-			// 				that.$store.commit('LOGIN', {
-			// 					token: res.data.token,
-			// 					time: time
-			// 				});
-			// 				that.$store.commit('SETUID', res.data.userInfo.uid);
-			// 				that.$store.commit('UPDATE_USERINFO', res.data.userInfo);
-			// 			}
-			// 		})
-			// 		.catch(res => {});
-			// },
-		},
-		onHide: function() {
-
-		}
-	};
-</script>
-
-<style>
-	@import url('@/plugin/emoji-awesome/css/tuoluojiang.css');
-	@import url('@/plugin/animate/animate.min.css');
-	@import 'static/css/base.css';
-	@import 'static/iconfont/iconfont.css';
-	@import 'static/css/guildford.css';
-	@import 'static/css/style.scss';
-
-	view {
-		box-sizing: border-box;
-	}
-
-	page {
-		font-family: PingFang SC;
-	}
-
-	.bg-color-red {
-		background-color: var(--view-theme) !important;
-	}
-
-	.syspadding {
-		padding-top: var(--status-bar-height);
-	}
-
-	.flex {
-		display: flex;
-	}
-
-	.uni-scroll-view::-webkit-scrollbar {
-		/* 隐藏滚动条,但依旧具备可以滚动的功能 */
-		display: none;
-	}
-
-	::-webkit-scrollbar {
-		width: 0;
-		height: 0;
-		color: transparent;
-	}
-
-	.uni-system-open-location .map-content.fix-position {
-		height: 100vh;
-		top: 0;
-		bottom: 0;
-	}
-
-	.open-location {
-		width: 100%;
-		height: 100vh;
-	}
+<script>
+	import {
+		checkLogin
+	} from './libs/login';
+	import {
+		HTTP_REQUEST_URL
+	} from './config/app';
+	import {
+		getShopConfig,
+		silenceAuth
+	} from '@/api/public';
+	import Auth from '@/libs/wechat.js';
+	import Routine from './libs/routine.js';
+	import {
+		silenceBindingSpread
+	} from "@/utils";
+	import {
+		getCartCounts,
+	} from '@/api/order.js';
+	import {
+		colorChange,
+		getCrmebCopyRight,
+
+	} from '@/api/api.js';
+	import {
+		getLangJson
+	} from '@/api/user.js'
+	import {
+		mapGetters
+	} from "vuex"
+	import colors from '@/mixins/color.js';
+	let green =
+		'--view-theme: rgba(66,202,77,1);--view-theme-16: #42CA4D;--view-priceColor:#FF7600;--view-minorColor:rgba(108, 198, 94, 0.5);--view-minorColorT:rgba(66, 202, 77, 0.1);--view-bntColor:#FE960F;--view-op-ten: rgba(66,202,77, 0.1);--view-main-start:#70E038; --view-main-over:#42CA4D;--view-op-point-four: rgba(66,202,77, 0.04);'
+	let red =
+		'--view-theme: rgba(233,51,35,1);--view-theme-16: #e93323;--view-priceColor:#e93323;--view-minorColor:rgba(233, 51, 35, 0.5);--view-minorColorT:rgba(233, 51, 35, 0.1);--view-bntColor:#FE960F;--view-op-ten: rgba(233,51,35, 0.1);--view-main-start:#FF6151; --view-main-over:#e93323;--view-op-point-four: rgba(233,51,35, 0.04);'
+	let blue =
+		'--view-theme: rgba(29,176,252,1);--view-theme-16:#1db0fc;--view-priceColor:#FD502F;--view-minorColor:rgba(58, 139, 236, 0.5);--view-minorColorT:rgba(9, 139, 243, 0.1);--view-bntColor:#22CAFD;--view-op-ten: rgba(29,176,252, 0.1);--view-main-start:#40D1F4; --view-main-over:#1DB0FC;--view-op-point-four: rgba(29,176,252, 0.04);'
+	let pink =
+		'--view-theme: rgba(255,68,143,1);--view-theme-16:#ff448f;--view-priceColor:#FF448F;--view-minorColor:rgba(255, 68, 143, 0.5);--view-minorColorT:rgba(255, 68, 143, 0.1);--view-bntColor:#282828;--view-op-ten: rgba(255,68,143, 0.1);--view-main-start:#FF67AD; --view-main-over:#FF448F;--view-op-point-four: rgba(255,68,143, 0.04);'
+	let orange =
+		'--view-theme: rgba(254,92,45,1); --view-theme-16:#FE5C2D;--view-priceColor:#FE5C2D;--view-minorColor:rgba(254, 92, 45, 0.5);--view-minorColorT:rgba(254, 92, 45, 0.1);--view-bntColor:#FDB000;--view-op-ten: rgba(254,92,45, 0.1);--view-main-start:#FF9445; --view-main-over:#FE5C2D;--view-op-point-four: rgba(254,92,45, 0.04);'
+
+	export default {
+		globalData: {
+			spid: 0,
+			code: 0,
+			isLogin: false,
+			userInfo: {},
+			MyMenus: [],
+			globalData: false,
+			isIframe: false,
+			tabbarShow: true,
+			windowHeight: 0,
+			locale: ''
+		},
+		mixins: [colors],
+		computed: mapGetters(['isLogin', 'cartNum']),
+		watch: {
+			isLogin: {
+				deep: true, //深度监听设置为 true
+				handler: function(newV, oldV) {
+					if (newV) {
+						// this.getCartNum()
+					} else {
+						this.$store.commit('indexData/setCartNum', '')
+					}
+				}
+			},
+			cartNum(newCart, b) {
+				this.$store.commit('indexData/setCartNum', newCart + '')
+				if (newCart > 0) {
+					uni.setTabBarBadge({
+						index: Number(uni.getStorageSync('FOOTER_ADDCART')) || 2,
+						text: newCart + ''
+					})
+				} else {
+					uni.hideTabBarRedDot({
+						index: Number(uni.getStorageSync('FOOTER_ADDCART')) || 2
+					})
+				}
+			}
+		},
+		async onLaunch(option) {
+			let that = this;
+			colorChange('color_change').then(res => {
+				uni.setStorageSync('is_diy', res.data.is_diy)
+				uni.$emit('is_diy', res.data.is_diy)
+				switch (res.data.status) {
+					case 1:
+						uni.setStorageSync('viewColor', blue)
+						uni.$emit('ok', blue, res.data.status)
+						break;
+					case 2:
+						uni.setStorageSync('viewColor', green)
+						uni.$emit('ok', green, res.data.status)
+						break;
+					case 3:
+						uni.setStorageSync('viewColor', red)
+						uni.$emit('ok', red, res.data.status)
+						break;
+					case 4:
+						uni.setStorageSync('viewColor', pink)
+						uni.$emit('ok', pink, res.data.status)
+						break;
+					case 5:
+						uni.setStorageSync('viewColor', orange)
+						uni.$emit('ok', orange, res.data.status)
+						break;
+					default:
+						uni.setStorageSync('viewColor', red)
+						uni.$emit('ok', red, res.data.status)
+						break
+				}
+			});
+			getLangJson().then(res => {
+				uni.setStorageSync('localeJson', res.data)
+			})
+			if (option.query.spread) {
+				that.$Cache.set('spread', option.query.spread);
+				that.globalData.spid = option.query.spread;
+				that.globalData.pid = option.query.spread;
+				silenceBindingSpread()
+			}
+			if (option.query.spid) {
+				that.$Cache.set('spread', option.query.spid);
+				that.globalData.spid = option.query.spid;
+				that.globalData.pid = option.query.spid;
+				// silenceBindingSpread()
+			}
+			// #ifdef APP-PLUS || H5
+			uni.getSystemInfo({
+				success: function(res) {
+					// 首页没有title获取的整个页面的高度,里面的页面有原生标题要减掉就是视口的高度
+					// 状态栏是动态的可以拿到 标题栏是固定写死的是44px
+					let height = res.windowHeight - res.statusBarHeight - 44
+					// #ifdef H5 || APP-PLUS
+					that.globalData.windowHeight = res.windowHeight + 'px'
+					// #endif
+					// // #ifdef APP-PLUS
+					// that.globalData.windowHeight = height + 'px'
+					// // #endif
+
+				}
+			});
+			// #endif	
+			// #ifdef MP
+			if (HTTP_REQUEST_URL == '') {
+				console.error(
+					"请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
+				);
+				return false;
+			}
+			if (option.query.hasOwnProperty('scene')) {
+
+				switch (option.scene) {
+					//扫描小程序码
+					case 1047:
+						let val = that.$util.getUrlParams(decodeURIComponent(option.query.scene));
+						that.globalData.code = val.pid === undefined ? val : val.pid;
+						break;
+						//长按图片识别小程序码
+					case 1048:
+						that.globalData.code = option.query.scene;
+						break;
+						//手机相册选取小程序码
+					case 1049:
+						that.globalData.code = option.query.scene;
+						break;
+						//直接进入小程序
+					case 1001:
+						that.globalData.spid = option.query.scene;
+						break;
+				}
+			}
+			const updateManager = wx.getUpdateManager();
+
+			updateManager.onCheckForUpdate(function(res) {
+				// 请求完新版本信息的回调
+			});
+
+			updateManager.onUpdateReady(function() {
+				wx.showModal({
+					title: '更新提示',
+					content: '新版本已经准备好,是否重启应用?',
+					success: function(res) {
+						if (res.confirm) {
+							// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+							updateManager.applyUpdate();
+						}
+					}
+				});
+			});
+
+			updateManager.onUpdateFailed(function() {
+				return that.Tips({
+					title: '新版本下载失败'
+				});
+			});
+			// #endif
+			// getShopConfig().then(res => {
+			// 	this.$store.commit('SETPHONESTATUS', res.data.status);
+			// });
+			// 获取导航高度;
+			uni.getSystemInfo({
+				success: function(res) {
+					that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
+				}
+			});
+			// #ifdef MP
+			let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
+			that.globalData.navH = menuButtonInfo.top * 2 + menuButtonInfo.height / 2;
+			// #endif
+
+			// #ifdef H5
+			uni.getSystemInfo({
+				success(e) {
+					/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
+					if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
+						window.location.pathname = '/static/html/pc.html';
+					}
+				}
+			});
+			if (option.query.hasOwnProperty('type') && option.query.type == "iframeWindow") {
+				this.globalData.isIframe = true;
+			} else {
+				this.globalData.isIframe = false;
+			}
+
+			//公众号静默授权
+			// if (window.location.pathname !== '/' && option.query.scope === 'snsapi_base') {
+			// 	let snsapiBase = 'snsapi_base';
+			// 	let urlData = location.pathname + location.search;
+			// 	// if (!that.$store.getters.isLogin && uni.getStorageSync('authIng')) {
+			// 	// 	uni.setStorageSync('authIng', false)
+			// 	// }
+			// 	if (!that.$store.getters.isLogin && Auth.isWeixin()) {
+			// 		let code,
+			// 			state,
+			// 			scope = ''
+
+			// 		if (option.query.code instanceof Array) {
+			// 			code = option.query.code[option.query.code.length - 1]
+			// 		} else {
+			// 			code = option.query.code
+			// 		}
+
+
+			// 		if (code && code != uni.getStorageSync('snsapiCode') && location.pathname.indexOf(
+			// 				'/pages/users/wechat_login/index') === -1) {
+			// 			// 存储静默授权code
+			// 			uni.setStorageSync('snsapiCode', code);
+			// 			let spread = that.globalData.spid ? that.globalData.spid : '';
+			// 			uni.setStorageSync('authIng', true)
+			// 			silenceAuth({
+			// 					code: code,
+			// 					spread: that.$Cache.get('spread'),
+			// 					spid: that.globalData.code
+			// 				})
+			// 				.then(res => {
+			// 					uni.setStorageSync('authIng', false)
+			// 					uni.setStorageSync('snRouter', decodeURIComponent(decodeURIComponent(option.query
+			// 						.back_url)));
+			// 					if (res.data.key !== undefined && res.data.key) {
+			// 						this.$Cache.set('snsapiKey', res.data.key);
+			// 					} else {
+
+			// 						let time = res.data.expires_time - this.$Cache.time();
+			// 						this.$store.commit('LOGIN', {
+			// 							token: res.data.token,
+			// 							time: time
+			// 						});
+			// 						this.$Cache.set('WX_AUTH', code);
+			// 						this.$store.commit('SETUID', res.data.userInfo.uid);
+			// 						this.$store.commit('UPDATE_USERINFO', res.data.userInfo);
+
+			// 						if (option.query.back_url) {
+			// 							location.replace(decodeURIComponent(decodeURIComponent(option.query
+			// 								.back_url)));
+			// 						}
+			// 					}
+			// 				})
+			// 				.catch(error => {
+			// 					uni.setStorageSync('authIng', false)
+			// 					let url = ''
+			// 					if (option.query.back_url instanceof Array) {
+			// 						url = option.query.back_url[option.query.back_url.length - 1]
+			// 					} else {
+			// 						url = option.query.back_url
+			// 					}
+			// 					if (!that.$Cache.has('snsapiKey')) {
+			// 						if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
+			// 							Auth.oAuth(snsapiBase, url);
+			// 						}
+			// 					}
+			// 				});
+			// 		} else {
+			// 			if (!this.$Cache.has('snsapiKey')) {
+			// 				if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
+			// 					Auth.oAuth(snsapiBase, urlData);
+			// 				}
+			// 			}
+			// 		}
+			// 	} else {
+			// 		if (option.query.back_url) {
+			// 			location.replace(uni.getStorageSync('snRouter'));
+			// 		}
+			// 	}
+			// }
+			// #endif
+			// #ifdef MP
+			// 小程序静默授权
+			// if (!this.$store.getters.isLogin) {
+			// 	Routine.getCode()
+			// 		.then(code => {
+			// 			this.silenceAuth(code);
+			// 		})
+			// 		.catch(res => {
+			// 			uni.hideLoading();
+			// 		});
+			// }
+			// #endif
+			// #ifdef H5
+			// 添加crmeb chat 统计
+			var __s = document.createElement('script');
+			__s.src = `${HTTP_REQUEST_URL}/api/get_script`;
+			document.head.appendChild(__s);
+			// #endif
+			getCrmebCopyRight().then(res => {
+				uni.setStorageSync('copyRight', res.data)
+			})
+		},
+		methods: {
+			// 小程序静默授权
+			// silenceAuth(code) {
+			// 	let that = this;
+			// 	let spread = that.globalData.spid ? that.globalData.spid : '';
+			// 	silenceAuth({
+			// 			code: code,
+			// 			spread_spid: spread,
+			// 			spread_code: that.globalData.code
+			// 		})
+			// 		.then(res => {
+			// 			if (res.data.token !== undefined && res.data.token) {
+			// 				uni.hideLoading();
+			// 				let time = res.data.expires_time - this.$Cache.time();
+			// 				that.$store.commit('LOGIN', {
+			// 					token: res.data.token,
+			// 					time: time
+			// 				});
+			// 				that.$store.commit('SETUID', res.data.userInfo.uid);
+			// 				that.$store.commit('UPDATE_USERINFO', res.data.userInfo);
+			// 			}
+			// 		})
+			// 		.catch(res => {});
+			// },
+		},
+		onHide: function() {
+
+		}
+	};
+</script>
+
+<style>
+	@import url('@/plugin/emoji-awesome/css/tuoluojiang.css');
+	@import url('@/plugin/animate/animate.min.css');
+	@import 'static/css/base.css';
+	@import 'static/iconfont/iconfont.css';
+	@import 'static/css/guildford.css';
+	@import 'static/css/style.scss';
+
+	view {
+		box-sizing: border-box;
+	}
+
+	page {
+		font-family: PingFang SC;
+	}
+
+	.bg-color-red {
+		background-color: var(--view-theme) !important;
+	}
+
+	.syspadding {
+		padding-top: var(--status-bar-height);
+	}
+
+	.flex {
+		display: flex;
+	}
+
+	.uni-scroll-view::-webkit-scrollbar {
+		/* 隐藏滚动条,但依旧具备可以滚动的功能 */
+		display: none;
+	}
+
+	::-webkit-scrollbar {
+		width: 0;
+		height: 0;
+		color: transparent;
+	}
+
+	.uni-system-open-location .map-content.fix-position {
+		height: 100vh;
+		top: 0;
+		bottom: 0;
+	}
+
+	.open-location {
+		width: 100%;
+		height: 100vh;
+	}
 </style>

Разница между файлами не показана из-за своего большого размера
+ 690 - 671
template/uni-app/api/user.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/en_us.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/fr_fr.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/it_it.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/ja_jp.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/ko_kr.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/mn_mn.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/th_th.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/vi_vn.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/zh_cn.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 1181
template/uni-app/lang/zh_ft.json


+ 1 - 1
template/uni-app/manifest.json

@@ -167,7 +167,7 @@
     "quickapp" : {},
     /* 小程序特有相关 */
     "mp-weixin" : {
-        "appid" : "wx1234567890",
+        "appid" : "wx3b82801238ca1b57",
         "setting" : {
             "urlCheck" : false,
             "minified" : true,

+ 6 - 5
template/uni-app/pages/goods/lottery/grids/record.vue

@@ -86,16 +86,17 @@
 		},
 		filters: {
 			typeName(type) {
+				console.log(type)
 				if (type == 2) {
-					return this.$t(`积分`)
+					return '积分'
 				} else if (type == 3) {
-					return this.$t(`余额`)
+					return '余额'
 				} else if (type == 4) {
-					return this.$t(`红包`)
+					return '红包'
 				} else if (type == 5) {
-					return this.$t(`优惠券`)
+					return '优惠券'
 				} else if (type == 6) {
-					return this.$t(`商品`)
+					return '商品'
 				}
 			}
 		},

+ 19 - 46
template/uni-app/pages/users/user_info/index.vue

@@ -103,7 +103,7 @@
 						</view>
 					</view>
 					<!-- #endif -->
-					<view class="item acea-row row-between-wrapper">
+					<view class="item acea-row row-between-wrapper" v-if="array.length">
 						<view>{{$t(`语言切换`)}}</view>
 						<view class="uni-list-cell-db">
 							<picker @change="bindPickerChange" range-key="name" :value="setIndex" :range="array">
@@ -155,10 +155,12 @@
 	import {
 		getUserInfo,
 		userEdit,
-		getLogout
+		getLogout,
+		getLangList,
+		getLangJson
 	} from '@/api/user.js';
 	import {
-		switchH5Login
+		switchH5Login,
 	} from '@/api/api.js';
 	import {
 		toLogin
@@ -195,47 +197,7 @@
 				canvasStatus: false,
 				fileSizeString: '',
 				version: '',
-				array: [{
-						name: '中文',
-						value: 'zh_cn'
-					},
-					{
-						name: 'English',
-						value: 'en_us'
-					},
-					{
-						name: '日本語',
-						value: 'ja_jp'
-					},
-					{
-						name: 'Français',
-						value: 'fr_fr'
-					},
-					{
-						name: 'ไทย',
-						value: 'th_th'
-					},
-					{
-						name: 'Italiano',
-						value: 'it_it'
-					},
-					{
-						name: 'Монгол',
-						value: 'mn_mn'
-					},
-					{
-						name: '한국인',
-						value: 'ko_kr'
-					},
-					{
-						name: 'Tiếng Việt',
-						value: 'vi_vn'
-					},
-					{
-						name: '中文(繁体)',
-						value: 'zh_ft'
-					},
-				],
+				array: [],
 				setIndex: 0,
 			};
 		},
@@ -253,6 +215,7 @@
 		onLoad() {
 			if (this.isLogin) {
 				this.getUserInfo();
+				this.getLangList()
 				// #ifdef APP-PLUS
 				this.formatSize()
 				// 获取版本号
@@ -261,12 +224,17 @@
 					this.version = inf.version;
 				});
 				// #endif 
-				this.setLang();
 			} else {
 				toLogin();
 			}
 		},
 		methods: {
+			getLangList() {
+				getLangList().then(res => {
+					this.array = res.data
+					this.setLang();
+				})
+			},
 			isNew() {
 				this.$util.Tips({
 					title: this.$t(`当前为最新版本`)
@@ -281,8 +249,13 @@
 			},
 			bindPickerChange(e, item) {
 				this.setIndex = e.detail.value
-				this.$i18n.locale = this.array[this.setIndex].value;
 				uni.setStorageSync('locale', this.array[this.setIndex].value);
+				getLangJson().then(res => {
+					uni.setStorageSync('localeJson', res.data)
+					this.$i18n.locale = this.array[this.setIndex].value;
+					this.$i18n.setLocaleMessage(this.array[this.setIndex].value, res.data[this
+						.array[this.setIndex].value]);
+				})
 			},
 
 			updateApp() {

+ 18 - 39
template/uni-app/utils/lang.js

@@ -1,39 +1,18 @@
-import en_us from '../lang/en_us.json'
-import zh_cn from '../lang/zh_cn.json'
-import fr_fr from '../lang/fr_fr.json'
-import th_th from '../lang/th_th.json'
-import ja_jp from '../lang/ja_jp.json'
-import it_it from '../lang/it_it.json'
-import ko_kr from '../lang/ko_kr.json'
-import mn_mn from '../lang/mn_mn.json'
-import vi_vn from '../lang/vi_vn.json'
-import zh_ft from '../lang/zh_ft.json'
-import Vue from 'vue'; 
-import VueI18n from 'vue-i18n'
-
-
-Vue.use(VueI18n)
-let langJson = {
-		'en_us': en_us,
-		'zh_cn': zh_cn,
-		'fr_fr': fr_fr,
-		'th_th': th_th,
-		'ja_jp': ja_jp,
-		'it_it': it_it,
-		'ko_kr': ko_kr,
-		'mn_mn': mn_mn,
-		'vi_vn': vi_vn,
-		'zh_ft': zh_ft,
-	}
-let lang = '';
-// #ifdef MP || APP-PLUS
-lang = uni.getStorageSync('locale') != '' ? uni.getStorageSync('locale') : 'zh_cn';
-// #endif
-// #ifdef H5
-lang = uni.getStorageSync('locale') != '' ? uni.getStorageSync('locale') : navigator.language.toLowerCase().replace('-','_');
-// #endif
-const i18n = new VueI18n({
-	locale: lang in langJson ? lang :'en_us',
-	messages: langJson
-})
-export default i18n 
+import Vue from 'vue';
+import VueI18n from 'vue-i18n'
+
+
+Vue.use(VueI18n)
+
+let lang = '';
+// #ifdef MP || APP-PLUS
+lang = uni.getStorageSync('locale') != '' ? uni.getStorageSync('locale') : 'zh-CN';
+// #endif
+// #ifdef H5
+lang = uni.getStorageSync('locale') != '' ? uni.getStorageSync('locale') : navigator.language;
+// #endif
+const i18n = new VueI18n({
+	locale: lang ? lang : 'zh-CN',
+	messages: uni.getStorageSync('localeJson')
+})
+export default i18n

+ 94 - 92
template/uni-app/utils/request.js

@@ -1,93 +1,95 @@
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-
-import {
-	HTTP_REQUEST_URL,
-	HEADER,
-	TOKENNAME
-} from '@/config/app';
-import {
-	toLogin,
-	checkLogin
-} from '../libs/login';
-import store from '../store';
-import i18n from './lang.js';
-
-/**
- * 发送请求
- */
-function baseRequest(url, method, data, {
-	noAuth = false,
-	noVerify = false
-}) {
-	let Url = HTTP_REQUEST_URL,
-		header = HEADER;
-
-	if (!noAuth) {
-		//登录过期自动登录
-		if (!store.state.app.token && !checkLogin()) {
-			toLogin();
-			return Promise.reject({
-				msg: i18n.t(`未登录`)
-			});
-		}
-	}
-	if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token;
-
-	return new Promise((reslove, reject) => {
-		header['Cb-lang'] = uni.getStorageSync('locale') ? uni.getStorageSync('locale') :'zh_cn'
-		uni.request({
-			url: Url + '/api/' + url,
-			method: method || 'GET',
-			header: header,
-			data: data || {},
-			success: (res) => {
-				if (noVerify)
-					reslove(res.data, res);
-				else if (res.data.status == 200)
-					reslove(res.data, res);
-				else if ([110002, 110003, 110004].indexOf(res.data.status) !== -1) {
-					toLogin();
-					reject(res.data);
-				} else if (res.data.status == 100103) {
-					uni.showModal({
-						title: i18n.t(`提示`),
-						content: res.data.msg,
-						showCancel: false,
-						confirmText: i18n.t(`我知道了`)
-					});
-				} else
-					reject(res.data.msg || i18n.t(`系统错误`));
-			},
-			fail: (msg) => {
-				let data = {
-					mag: i18n.t(`请求失败`),
-					status: 1 //1没网
-				}
-				// #ifdef APP-PLUS
-				reject(data);
-				// #endif
-				// #ifndef APP-PLUS
-				reject(i18n.t(`请求失败`));
-				// #endif
-			}
-		})
-	});
-}
-
-const request = {};
-
-['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => {
-	request[method] = (api, data, opt) => baseRequest(api, method, data, opt || {})
-});
-
-
-
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+
+import {
+	HTTP_REQUEST_URL,
+	HEADER,
+	TOKENNAME
+} from '@/config/app';
+import {
+	toLogin,
+	checkLogin
+} from '../libs/login';
+import store from '../store';
+import i18n from './lang.js';
+
+/**
+ * 发送请求
+ */
+function baseRequest(url, method, data, {
+	noAuth = false,
+	noVerify = false
+}) {
+	let Url = HTTP_REQUEST_URL,
+		header = HEADER;
+
+	if (!noAuth) {
+		//登录过期自动登录
+		if (!store.state.app.token && !checkLogin()) {
+			toLogin();
+			return Promise.reject({
+				msg: i18n.t(`未登录`)
+			});
+		}
+	}
+	if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token;
+
+	return new Promise((reslove, reject) => {
+		if (uni.getStorageSync('locale')) {
+			header['Cb-lang'] = uni.getStorageSync('locale')
+		}
+		uni.request({
+			url: Url + '/api/' + url,
+			method: method || 'GET',
+			header: header,
+			data: data || {},
+			success: (res) => {
+				if (noVerify)
+					reslove(res.data, res);
+				else if (res.data.status == 200)
+					reslove(res.data, res);
+				else if ([110002, 110003, 110004].indexOf(res.data.status) !== -1) {
+					toLogin();
+					reject(res.data);
+				} else if (res.data.status == 100103) {
+					uni.showModal({
+						title: i18n.t(`提示`),
+						content: res.data.msg,
+						showCancel: false,
+						confirmText: i18n.t(`我知道了`)
+					});
+				} else
+					reject(res.data.msg || i18n.t(`系统错误`));
+			},
+			fail: (msg) => {
+				let data = {
+					mag: i18n.t(`请求失败`),
+					status: 1 //1没网
+				}
+				// #ifdef APP-PLUS
+				reject(data);
+				// #endif
+				// #ifndef APP-PLUS
+				reject(i18n.t(`请求失败`));
+				// #endif
+			}
+		})
+	});
+}
+
+const request = {};
+
+['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => {
+	request[method] = (api, data, opt) => baseRequest(api, method, data, opt || {})
+});
+
+
+
 export default request;