From e48615ec0a07b304b0287271f7f3833f8587b376 Mon Sep 17 00:00:00 2001
From: jt <jt@activesoft.com.cn>
Date: 星期一, 21 八月 2023 16:52:33 +0800
Subject: [PATCH] 5600码盘页面功能新增

---
 pages/login/index.vue |  411 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 327 insertions(+), 84 deletions(-)

diff --git a/pages/login/index.vue b/pages/login/index.vue
index dea3ef1..3a1f07c 100644
--- a/pages/login/index.vue
+++ b/pages/login/index.vue
@@ -1,8 +1,8 @@
-
 <style>
 	input::-webkit-input-placeholder {
 		font-size: 12rpx;
 	}
+
 	#headr {
 		background: #434343;
 		/* width: 375px; */
@@ -13,71 +13,84 @@
 		background-size: cover !important; 
 		background-repeat: no-repeat !important; */
 	}
-	.SetServer{    
+
+	.SetServer {
 		float: left;
 		margin-left: 20rpx;
 	}
-	.check_rememberPwd{
+
+	.check_rememberPwd {
 		margin-top: 20rpx;
 		margin-left: 20rpx;
 	}
+
 	.logo {
 		height: 180rpx;
-		width: 180rpx; 
+		width: 180rpx;
 		margin-top: 170rpx;
 	}
+
 	.logo_input {
 		height: 40rpx;
 		width: 40rpx;
 		margin-left: 40rpx;
 	}
+
 	.logo_icon {
 		height: 50rpx;
 		width: 50rpx;
 		margin-left: 15rpx;
 		margin-top: 20rpx;
 	}
-	.mui-content{
+
+	.mui-content {
 		height: 100%;
 		padding-top: 140rpx;
 		background: #FFFFFF;
 		z-index: 1;
 	}
+
 	.mui-input-group .la_icon {
-	    width: 100rpx;
-	    text-align: center;
-	    font-family: 'Helvetica Neue',Helvetica,sans-serif;
-	    line-height: 1.5;
-	    float: left;
-	    padding: 7px 13px;
+		width: 100rpx;
+		text-align: center;
+		font-family: 'Helvetica Neue', Helvetica, sans-serif;
+		line-height: 1.5;
+		float: left;
+		padding: 7px 13px;
 	}
+
 	.mui-input-group .mui-input-row {
-	    height: 85rpx;
+		height: 85rpx;
 		position: relative;
 		clear: left;
 		overflow: hidden;
 	}
+
 	.mui-input-row:first-child {
 		border-top: 1px solid #c8c7cc;
 	}
+
 	.mui-input-row:last-child {
 		border-bottom: 1px solid #c8c7cc;
 	}
+
 	.mui-input-group .mui-input-row:last-child:after {
-		background-color:#fff;
+		background-color: #fff;
 	}
+
 	.mui-input-group .mui-input-row:after {
-	    position: absolute;
-	    right: 0;
-	    bottom: 0;
-	    left: 15px;
-	    height: 1px;
-	    content: '';
-	    transform: scaleY(.5);
-	    background-color: #c8c7cc;
+		position: absolute;
+		right: 0;
+		bottom: 0;
+		left: 15px;
+		height: 1px;
+		content: '';
+		transform: scaleY(.5);
+		background-color: #c8c7cc;
 	}
+
 	.mui-input-row input {
-		font-family: 'Helvetica Neue',Helvetica,sans-serif;
+		font-family: 'Helvetica Neue', Helvetica, sans-serif;
 		font-size: 15px;
 		width: 480rpx;
 		/* float: right; */
@@ -95,7 +108,7 @@
 		background: 0 0;
 		-webkit-appearance: none;
 	}
-	
+
 	.mui-input-group label.mui-navigate-right {
 		font-size: 25px;
 		float: right;
@@ -105,7 +118,7 @@
 		margin-top: -88rpx;
 		display: inline-block;
 	}
-	
+
 	button.btn_login {
 		margin-top: 50rpx;
 		padding: 20rpx;
@@ -115,7 +128,7 @@
 		color: #fff;
 	}
 </style>
- 
+
 
 <template>
 	<view class="" style="width: 100vw;height: 64vh;">
@@ -131,17 +144,21 @@
 					<label class="mui-navigate-right" id="sersel"><image class="logo_icon" src="../../images/login/sel_left.png" ></image></label>
 				</div> -->
 				<div class="mui-input-row">
-					<label class="la_icon" ><image class="logo_input" src="../../images/login/person_30.png"></image></label>
+					<label class="la_icon">
+						<image class="logo_input" src="../../images/login/person_30.png"></image>
+					</label>
 					<input type="text" class="mui-input" v-model="userName" placeholder="璇疯緭鍏ヨ处鍙�>
 					<!-- <label class="mui-navigate-right" id="namsel"><image class="logo_icon" src="../../images/login/user-photo.png</image></label> -->
 				</div>
 				<div class="mui-input-row">
-					<label class="la_icon" ><image class="logo_input" src="../../images/login/lock_30.png"></image></label>
+					<label class="la_icon">
+						<image class="logo_input" src="../../images/login/lock_30.png"></image>
+					</label>
 					<input type="password" class="mui-input" v-model="userPwd" placeholder="璇疯緭鍏ュ瘑鐮�>
 				</div>
 				<checkbox-group class="check_rememberPwd" @change="rememberPwd">
 					<label>
-						<checkbox value="1" :checked="ischecked"/>
+						<checkbox value="1" :checked="ischecked" />
 						<text>璁颁綇瀵嗙爜</text>
 					</label>
 				</checkbox-group>
@@ -151,28 +168,53 @@
 				<span>鐗堟湰鍙凤細</span>
 				<span>{{version}}</span>
 			</p>
-			<div class="" style="text-align: center;background: white;border-top: 0px solid #C0C0C0;color: #7cd0f8;position: absolute;bottom: 0;width: 100%;height: 24px;padding-top:3px;font-size: 11px;">
+			<div class=""
+				style="text-align: center;background: white;border-top: 0px solid #C0C0C0;color: #7cd0f8;position: absolute;bottom: 0;width: 100%;height: 24px;padding-top:3px;font-size: 11px;">
 			</div>
 		</div>
 		<view>
 			<!-- 杈撳叆妗嗙ず渚�-->
 			<uni-popup ref="inputDialog" type="dialog">
-				<uni-popup-dialog ref="inputClose"  mode="input" title="璁剧疆" :value="userServer"
-					placeholder="璇疯緭鍏ュ唴瀹� @confirm="dialogInputConfirm"></uni-popup-dialog>
+				<uni-popup-dialog ref="inputClose" mode="input" title="璁剧疆" :value="userServer" placeholder="璇疯緭鍏ュ唴瀹�
+					@confirm="dialogInputConfirm"></uni-popup-dialog>
 			</uni-popup>
+			<!-- 鐗堟湰鍗囩骇寮圭獥寮� -->
+			<uni-popup ref="promotion" type="center">
+				<view class="promotion" style="width: 700rpx;padding:20rpx 40rpx; background: white;font-size: 36rpx;">
+					<view class="operates" v-if="showBtns==true">
+						<view style="text-align: center;padding-top:20rpx;padding-bottom: 40rpx;">
+							绯荤粺鏈夋柊鐗堟湰锛屾槸鍚﹂渶瑕佹洿鏂�+						</view>
+						<text @click="cancel"
+							style="display: inline-block;color: #7cd0f8;width: 50%; text-align: center;">鍙栨秷</text>
+						<text @click="sure"
+							style="display: inline-block;color: #7cd0f8;width: 50%; text-align: center;">纭</text>
+					</view>
+					<view class="operates" v-else>
+						<cmd-progress :percent="percentage" stroke-color="linear-gradient(to right, #ef32d9, #89fffd)">
+						</cmd-progress>
+					</view>
+				</view>
+			</uni-popup>
+			<!-- 鐗堟湰鍗囩骇寮圭獥缁撴潫 -->
 		</view>
+
 	</view>
-	 
+
 </template>
 
-<script> 
+<script>
+	import cmdProgress from "@/components/cmd-progress/cmd-progress.vue"
 	// import {
 	// 	mapState,
 	// 	mapMutations,
 	// 	mapActions ,
 	// } from 'vuex'
 	export default {
-		data(){
+		components: {
+			cmdProgress
+		},
+		data() {
 			//鑾峰彇鍏ㄥ眬鍙傛暟锛歶rl-鏈嶅姟鍣ㄥ湴鍧� 			var server = uni.getStorageSync('server');
 			var account = uni.getStorageSync('account');
@@ -180,21 +222,36 @@
 			var url = this.$store.state.url;
 			var username = this.$store.state.username;
 			var userpwd = this.$store.state.userpwd;
-			var ischecked=false;
-			if(!server)
+			var ischecked = false;
+			if (!server)
 				server = url;
-			if(!account)
+			if (!account)
 				account = username;
-			if(account && password)
-				ischecked=true;
+			if (account && password)
+				ischecked = true;
 			// console.log(url);
 			return {
-				login:"寮�鐧诲綍",
-				userServer:server,
-				userName:account,
-				userPwd:password,
-				ischecked:ischecked,
-				version:"1.0.0",
+				login: "寮�鐧诲綍",
+				userServer: server,
+				userName: account,
+				userPwd: password,
+				ischecked: ischecked,
+				version: "1.0.0",
+				downloadUrl: "", //瀹夊崜app涓嬭浇閾炬帴
+				percentage: 0, //涓嬭浇杩涘害
+				showBtns: true,
+			}
+		},
+		onShow() {
+			this.query(); //鐗堟湰鍗囩骇
+		},
+		watch: {
+			//鐩戝惉杩涘害鏉�+			percentage(e) {
+				// console.log(e);
+				if (e >= 100) {
+					this.$refs.promotion.close();
+				}
 			}
 		},
 		// computed: mapState({
@@ -203,7 +260,157 @@
 		// 	loginprovider: state => state.loginProvider,
 		// 	appinfo:state=>state.appInfo
 		// }),
-		methods:{
+		methods: {
+			//鏌ヨ褰撳墠鐗堟湰鍙�+			query() {
+				// #ifdef APP-PLUS
+				plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
+					console.log(wgtinfo);
+					var version = wgtinfo.version; //瀹㈡埛绔増鏈彿
+					// var versionCode = parseInt(wgtinfo.versionCode); //瀹㈡埛绔増鏈彿缂栫爜
+					this.check(version) //妫�祴鏄惁闇�鏇存柊
+				})
+				//#endif
+			},
+			//妫�祴鏄惁闇�鏇存柊
+			async check(version) {
+				if (!this.userServer) {
+					uni.showModal({
+						title: "鎻愮ず",
+						content: "鏈緭鍏ョ綉绔欏湴鍧�紝璇烽噸鏂伴厤缃緭鍏ワ紒",
+						showCancel: false,
+						confirmText: "鍙栨秷"
+					});
+					return;
+				}
+				var dataInfo = {
+					server: this.userServer
+				};
+				this.$store.dispatch('GetApkVersionInfo', dataInfo).then(success => {
+					console.log(success);
+					if (success.code == '00000') {
+						let resp = success.data;
+						if (resp) {
+							// const obj = resp.data.filter(item => {
+							// 	return item.groupName == 'version'
+							// })
+							//鑾峰彇褰撳墠鐗堟湰鍙�+							const VersionName = resp.VersionName; //鏇存柊鍖呭悕绉�+							const VersionCode = resp.VersionCode; //鐗堟湰缂栫爜
+							const versionNum = resp.Version; //鏈嶅姟绔増鏈彿
+							// this.downloadUrl = resp.PdaUrl+"/"+VersionName; //app涓嬭浇閾炬帴
+							this.downloadUrl = "http://" + this.userServer + "/Program/" + VersionName; //app涓嬭浇閾炬帴this.
+							var isver = this.compare(versionNum,version);
+							if (isver) {
+								this.$refs.promotion.open();
+							} else {
+								console.log('褰撳墠宸叉槸鏈�柊鐗堟湰')
+							}
+						}
+					} else {
+						uni.showModal({
+							title: "閿欒",
+							content: success.msg,
+							showCancel: false,
+							confirmText: "鍙栨秷"
+						});
+					}
+				}).catch(ex => {
+					console.log(ex);
+					uni.showModal({
+						title: "閿欒",
+						content: ex.errMsg ? ex.errMsg : ex.message,
+						showCancel: false,
+						confirmText: "鍙栨秷"
+					});
+				});
+			},
+			compare(curV, reqV) {
+				var arr1 = curV.toString().split('.');
+			    var arr2 = reqV.toString().split('.');
+			    //灏嗕袱涓増鏈彿鎷嗘垚鏁板瓧
+			    var minL = Math.min(arr1.length, arr2.length);
+			    var pos = 0; //褰撳墠姣旇緝浣�+			    var diff = 0; //褰撳墠涓轰綅姣旇緝鏄惁鐩哥瓑
+			    var flag = false;
+			    //閫愪釜姣旇緝濡傛灉褰撳墠浣嶇浉绛夊垯缁х画姣旇緝涓嬩竴浣�+			    while (pos < minL) {
+			        diff = parseInt(arr1[pos]) - parseInt(arr2[pos]);
+			        if (diff == 0) {
+			            pos++;
+			            continue;
+			        } else if (diff > 0) {
+			            flag = true;
+			            break;
+			        } else {
+			            flag = false;
+			            break;
+			        }
+			    }
+			    return flag;
+			},
+			//纭鏇存柊
+			sure() {
+				//鍏抽棴鎸夐挳
+				this.showBtns = false;
+				let sys = uni.getSystemInfoSync().platform //妫�煡绯荤粺
+				if (sys == "ios") {
+					// this.getIosInfo()
+				} else if (sys == "android") {
+					this.updateAPP() // 璋冪敤涓嬭浇鏂规硶app鍐呬笅杞�+				}
+			},
+			//鍙栨秷鏇存柊
+			cancel() {
+				this.$refs.promotion.close();
+			},
+			//閾炬帴鑻规灉鍟嗗簵涓嬭浇
+			// getIosInfo() {
+			// 	let appleId = "浣犵殑appid"
+			// 	plus.runtime.launchApplication({
+			// 		action: "itms-apps://itunes.apple.com/cn/app/id" + appleId + "?mt=8"
+			// 	}, function(e) {
+			// 		console.log('Open system default browser failed: ' + e.message);
+			// 	});
+			// },
+			//瀹夊崜鏇存柊
+			updateAPP() {
+				let _this = this;
+				let url = this.downloadUrl;
+				// 瀹樻柟API
+				var dtask = plus.downloader.createDownload(url, {}, function(d, status) {
+					//d涓轰笅杞界殑鏂囦欢瀵硅薄
+					if (status == 200) {
+						//涓嬭浇鎴愬姛,d.filename鏄枃浠跺湪淇濆瓨鍦ㄦ湰鍦扮殑鐩稿璺緞锛屼娇鐢ㄤ笅闈㈢殑API鍙浆涓哄钩鍙扮粷瀵硅矾寰�+						var fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
+						plus.runtime.openFile(d.filename); //閫夋嫨杞欢鎵撳紑鏂囦欢
+						uni.showToast({
+							icon: 'none',
+							title: '鏇存柊鎴愬姛'
+						});
+						_this.$refs.promotion.close();
+					} else {
+						//涓嬭浇澶辫触
+						plus.downloader.clear(); //娓呴櫎涓嬭浇浠诲姟
+						uni.showToast({
+							icon: 'none',
+							title: '鏇存柊澶辫触'
+						});
+						_this.showBtns = false;
+					}
+				})
+				//寮�涓嬭浇
+				dtask.start();
+				//鐩戝惉涓嬭浇杩涘害
+				dtask.addEventListener('statechanged', function(task) {
+					_this.percentage = parseInt(
+						(parseFloat(task.downloadedSize) / parseFloat(task.totalSize)) * 100);
+					if (_this.percentage == 100) {
+						_this.$refs.promotion.close();
+					}
+					console.log('涓嬭浇杩涘害锛� + _this.percentage);
+				});
+			},
 			// ...mapMutations({
 			// 	mutatLogin:'login'
 			// }),
@@ -221,19 +428,22 @@
 				// setTimeout(() => {
 				// uni.hideLoading();
 				this.userServer = val;
-				uni.setStorageSync('server',val);
+				uni.setStorageSync('server', val);
 				// this.value = val
 				// 鍏抽棴绐楀彛鍚庯紝鎭㈠榛樿鍐呭
-				this.$refs.inputDialog.close()
+				this.$refs.inputDialog.close();
+
+				this.query(); //鐗堟湰鍗囩骇
+				// }, 3000)
 				// }, 3000)
 			},
-			rememberPwd(e){  //璁颁綇瀵嗙爜
+			rememberPwd(e) { //璁颁綇瀵嗙爜
 				console.log(e.target);
-				uni.setStorageSync('account','');
-				uni.setStorageSync('password','');
-				if(e.target.value[0]=='1'){
-					uni.setStorageSync('account',this.userName);
-					uni.setStorageSync('password',this.userPwd);
+				uni.setStorageSync('account', '');
+				uni.setStorageSync('password', '');
+				if (e.target.value[0] == '1') {
+					uni.setStorageSync('account', this.userName);
+					uni.setStorageSync('password', this.userPwd);
 				}
 			},
 			// getCookie(key){
@@ -253,19 +463,34 @@
 			// 	exdate.setDate(exdate.getDate(),expiredays)
 			// 	document.cookie = cName+'='+ documentURLComponent(value)+
 			// 	((expiredays==null)?'':';expires='+exdate.toGMTString());
-				
+
 			// },
-			logind(){
-				if(!this.userServer){
-					uni.showModal({title:"鎻愮ず",content:"鏈緭鍏ョ綉绔欏湴鍧�紝璇烽噸鏂伴厤缃緭鍏ワ紒",showCancel:false,confirmText:"鍙栨秷"});
+			logind() {
+				if (!this.userServer) {
+					uni.showModal({
+						title: "鎻愮ず",
+						content: "鏈緭鍏ョ綉绔欏湴鍧�紝璇烽噸鏂伴厤缃緭鍏ワ紒",
+						showCancel: false,
+						confirmText: "鍙栨秷"
+					});
 					return;
 				}
-				if(!this.userName){
-					uni.showModal({title:"鎻愮ず",content:"鏈緭鍏ョ敤鎴峰悕锛岃閲嶆柊杈撳叆锛�,showCancel:false,confirmText:"鍙栨秷"});
+				if (!this.userName) {
+					uni.showModal({
+						title: "鎻愮ず",
+						content: "鏈緭鍏ョ敤鎴峰悕锛岃閲嶆柊杈撳叆锛�,
+						showCancel: false,
+						confirmText: "鍙栨秷"
+					});
 					return;
 				}
-				if(!this.userPwd){
-					uni.showModal({title:"鎻愮ず",content:"鏈緭鍏ュ瘑鐮侊紝璇烽噸鏂拌緭鍏ワ紒",showCancel:false,confirmText:"鍙栨秷"});
+				if (!this.userPwd) {
+					uni.showModal({
+						title: "鎻愮ず",
+						content: "鏈緭鍏ュ瘑鐮侊紝璇烽噸鏂拌緭鍏ワ紒",
+						showCancel: false,
+						confirmText: "鍙栨秷"
+					});
 					return;
 				}
 				//妫�煡 "鐧诲綍鐘舵�/閿佸睆鐘舵�" 缁撴潫
@@ -274,45 +499,63 @@
 					uname: this.userName,
 					pwd: this.userPwd,
 					cname: plus.device.model,
-					type:"0"
+					type: "0"
 				};
 				console.log(loginInfo);
-				
-				this.$data.login="loading......";
+
+				this.$data.login = "loading......";
 				//鐧诲綍
-				this.$store.dispatch('login',loginInfo).then(success=>{
-					// console.log(success);
-					if (success.code == '00000') {
+				this.$store.dispatch('login', loginInfo).then(success => {
+					console.log(success);
+					if (success.code == '00000' || success.err_code==0) {
+						//鐧诲綍鎴愬姛鍚庢竻绌虹紦瀛樻暟鎹�+						this.$store.commit("areaFunc", null);
+						this.$store.commit("classAttrList", null);
+						this.$store.commit("classGridStyleInfo", null);
+						this.$store.commit("dicValueInfo", null);
+						this.$store.commit("subClassAttrList", null);
+						this.$store.commit("subClassGridStyleInfo", null);
 						//璁剧疆鍏ㄥ眬鍙傛暟锛歶ser-鐢ㄦ埛淇℃伅
-						uni.setStorageSync('server',loginInfo.server);
-						// uni.setStorageSync('account',loginInfo.uname);
-						// uni.setStorageSync('password',loginInfo.pwd);
+						uni.setStorageSync('server', loginInfo.server);
+						uni.setStorageSync('account', loginInfo.uname);
+						uni.setStorageSync('password', loginInfo.pwd);
 						// this.mutatLogin({loginid:success});
-						this.$store.commit('login',{
-							loginid:success 
+						this.$store.commit('login', {
+							loginid: success
 						});
 						uni.navigateTo({
-							url:'../index/index?args=9999999999'
+							url: '../index/index?args=9999999999'
 						})
 						// uni.redirectTo({
 						// 	url:'../index/index?args=9999999999'
 						// });
-						this.login="寮�鐧诲綍";
-					}else{
-						uni.showModal({title:"閿欒",content:success.msg,showCancel:false,confirmText:"鍙栨秷"});
-						this.login="寮�鐧诲綍";
+						this.login = "寮�鐧诲綍";
+
+					} else {
+						uni.showModal({
+							title: "閿欒",
+							content: success.msg,
+							showCancel: false,
+							confirmText: "鍙栨秷"
+						});
+						this.login = "寮�鐧诲綍";
 					}
-				}).catch(ex=>{
-					// console.log(ex);
-					uni.showModal({title:"閿欒",content:ex.errMsg,showCancel:false,confirmText:"鍙栨秷"});
-					this.login="寮�鐧诲綍";
+				}).catch(ex => {
+					console.log(ex);
+					uni.showModal({
+						title: "閿欒",
+						content: ex.errMsg,
+						showCancel: false,
+						confirmText: "鍙栨秷"
+					});
+					this.login = "寮�鐧诲綍";
 				});
 			}
 		},
 		onLoad() {
-			plus.runtime.getProperty(plus.runtime.appid,(info)=>{
+			plus.runtime.getProperty(plus.runtime.appid, (info) => {
 				// console.log(info);
-				this.$data.version=info.version;
+				this.$data.version = info.version;
 			});
 		}
 	}

--
Gitblit v1.9.1