lilei vor 3 Jahren
Ursprung
Commit
fe61cb6257
13 geänderte Dateien mit 437 neuen und 312 gelöschten Zeilen
  1. 8 0
      api/data.js
  2. 0 43
      api/login.js
  3. 13 12
      api/user.js
  4. 65 69
      libs/tools.js
  5. 1 1
      pages.json
  6. 54 37
      pages/login/login.scss
  7. 204 0
      pages/login/login.vue
  8. 0 144
      pages/login/pwLogin.vue
  9. 1 2
      pages/userCenter/index.vue
  10. 0 0
      static/default/logo.png
  11. BIN
      static/filter.png
  12. BIN
      static/ledou.png
  13. 91 4
      store/index.js

+ 8 - 0
api/data.js

@@ -5,4 +5,12 @@ export const getLookUpDatas = (params) => {
     url: `lookup/findByLookup/${params.type}`,
     method: 'get'
   })
+}
+// 查询最新版本信息
+export const getSysVersion = (params) => {
+  return axios.request({
+    url: `zycar-mgr/sysVersion/getLatest`,
+    method: 'post',
+	data: {applyCode:'zyit',versionType: params.versionType}
+  }, true)
 }

+ 0 - 43
api/login.js

@@ -1,43 +0,0 @@
-import axios from '@/libs/axios.js';
-
-export const login = params => {
-  return axios.request({
-    url: `login`,
-    method: 'post',
-	data: params
-  },true)
-};
-export const logout = params => {
-  return axios.request({
-    url: `logout`,
-    data: params,
-    method: 'get'
-  })
-};
-
-// 验证是否登录过
-export const checkLogin = () => {
-  let token = getApp().globalData.token
-  if (token&&token!='') {
-    return axios.request({
-      url: `checkToken`,
-      method: 'get'
-    })
-  } else {
-    return new Promise(resolve => {
-      resolve({
-        status: '9001',
-        message: '系统未登录'
-      });
-    });
-  }
-};
-
-// 获取登录用户信息
-export const getUserInfo = params => {
-  return axios.request({
-    url: `customer/getDetail`,
-    data: params,
-    method: 'get'
-  })
-};

+ 13 - 12
api/user.js

@@ -3,13 +3,21 @@ import axios from '@/libs/axios.js'
 //  axios.request()  第二个参数若为true则表示不传token
 
 // 登录
-export const login = (params) => {
+export const login = params => {
   return axios.request({
-    url: 'login',
+    url: `login`,
+    method: 'post',
+	data: params
+  },true)
+};
+// 退出
+export const logout = params => {
+  return axios.request({
+    url: `logout`,
     data: params,
-    method: 'post'
-  }, true)
-}
+    method: 'get'
+  })
+};
 //  校验手机号是否注册
 export const validateUser = params => {
   return axios.request({
@@ -48,13 +56,6 @@ export const getStore = (token) => {
     method: 'get'
   })
 }
-// 登出
-export const logout = () => {
-  return axios.request({
-    url: 'logout',
-    method: 'get'
-  })
-}
 // 修改密码
 export const changePwd = params => {
   return axios.request({

+ 65 - 69
libs/tools.js

@@ -1,17 +1,5 @@
-let carmera = uni.requireNativePlugin('uniplugin_camerascan')
+let carmera = uni.requireNativePlugin('ziteng-maskcamera')
 let cameraModule = uni.requireNativePlugin("SMUniPlugin-CameraModule")
-
-export function objToUrl(obj) {
-  let uri = '';
-  let keys = Object.keys(obj);
-  keys.forEach(item => {
-    uri += '&' + item + '=' + obj[item];
-  });
-
-  uri = uri.substr(1);
-
-  return uri;
-}
 // 节流函数
 export function throttle(fn, gaptime) {
 	if (gaptime == null || gaptime == undefined) {
@@ -58,21 +46,25 @@ export const imgToBase64 = function (path,callback){
 export const openCamera = function (type,callback){
 	let carNumberOptions = {
 		 widthRatio: 0.8,
-		 heightRatio: 0.3,
+		 heightRatio: 0.2,
 		 showText: '请将车牌号码对准框中'
 	}
 	let carVinNumberOptions = {
-		 widthRatio: 1,
-		 heightRatio: 0.15,
+		 widthRatio: 0.9,
+		 heightRatio: 0.1,
 		 showText: '请将车辆VIN码对准框中'
 	}
 	let option = (type == 'searchCar'  || type == 'carNumber') ? carNumberOptions : carVinNumberOptions
 	// 竖屏 false,横屏 true
-	let isLandscape = (type == 'searchCar'  || type == 'carNumber') ? false : true
+	let isLandscape = false
 	//安卓摄像头
 	if(uni.getSystemInfoSync().platform === 'android'){
+		option.isLandscape = isLandscape
 		carmera.show(option,function(result){
-			callback(result)
+			console.log(result)
+			if(result.msg != 'backCancel'){
+				callback(result.data)
+			}
 		})
 	}
 	// ios 摄像头
@@ -88,7 +80,7 @@ export const openCamera = function (type,callback){
 			y = (screenHeight - h)/2
 		}else{
 			// 竖屏
-			w = screenWidth*option.widthRatio*0.9
+			w = screenWidth*option.widthRatio
 			h = screenHeight*option.heightRatio
 			x = (screenWidth - w)/2
 			y = (screenHeight - h)/2 - 50
@@ -101,7 +93,7 @@ export const openCamera = function (type,callback){
 		  'isLandscape': isLandscape
 		 },
 		 (result) => {
-			  callback({path:'file://'+result})
+			  callback('file://'+result)
 		 })
 	}
 }
@@ -234,13 +226,16 @@ export const  setStorageForAppVersion = function(currTimeStamp){
  * @param {Object} server_version 服务器最新 应用版本号
  * @param {Object} curr_version 当前应用版本号
  * isQzgx 是否强制更新
- * market 打开应用市场
+ * callback 登录
  */
-export const checkVersionToLoadUpdate = function(newVersion,type,market){
-	console.log(newVersion)
-	const curVer = getApp().globalData.version
-	const server_version = newVersion.version
-	const curr_version = curVer.versionCode
+export const checkVersionToLoadUpdate = function(newVersion,type,callback){
+	if(newVersion.version == '2001'||newVersion.version == '2002'){
+		newVersion.version = 201
+	}
+	const curVer = getApp().globalData.version  // 当前版本信息
+	console.log(newVersion,curVer,callback)
+	const curr_version = curVer.version.replace(/\./g,'')
+	const server_version = newVersion.version // 最新版本信息
 	const isQzgx = newVersion.forceUpgrade != 1
 	let isWifi = plus.networkinfo.getCurrentType()!=3 ? '有新的版本发布,检测到您目前非Wifi连接,' : '有新的版本发布,'
 	let msg = isWifi + (!isQzgx ? '请立即更新?' : '是否立即更新版本?')
@@ -274,57 +269,35 @@ export const checkVersionToLoadUpdate = function(newVersion,type,market){
 	// 打开ios 应用市场
 	let openIosAppSotre = function(downloadUrl){
 		//在App Store Connect中的App Store下的app信息,可找到appleId
-		// let appleId= 111111111
 		plus.runtime.launchApplication({
-			// action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
 			action: downloadUrl
 		}, function(e) {
 			console.log('Open system default browser failed: ' + e.message);
 		})
 	}
-	// 打开应用市场
-	// const marketOpen = function(){
-	// 	market.open({
-	// 		ios:'',
-	// 		android:'com.zyucgj.car'
-	// 	});
-	// }
+	console.log(server_version,curr_version)
 	if(Number(server_version) > Number(curr_version)){
-		// #ifndef APP-PLUS
-			uni.showModal({
-				title: msg,
-				content: '更新内容:'+newVersion.upgradeContent,
-				showCancel: isQzgx,
-				confirmText:'立即更新',
-				cancelText:'稍后进行',
-				success: function (res) {
-					if (res.confirm) {
-						if(curVer.platform == 'android'){
-							//设置 最新版本apk的下载链接
-							downloadApp(newVersion.attachment);
-						}else{
-							openIosAppSotre(newVersion.downloadUrl)
-						}
-						// marketOpen()
-					} else if (res.cancel) {
-						console.log('稍后更新');
-					}
-				}
-			});
-		// #endif
-		// #ifdef APP-PLUS
-			plus.nativeUI.confirm('更新内容:'+newVersion.upgradeContent, function(e){
-				if(e.index == 0){  //  确认
+		uni.showModal({
+			title: msg,
+			content: '更新内容:'+newVersion.upgradeContent,
+			showCancel: isQzgx,
+			confirmText:'立即更新',
+			cancelText:'稍后进行',
+			success: function (res) {
+				if (res.confirm) {
 					if(curVer.platform == 'android'){
-						//设置最新版本apk的下载链接
+						//设置 最新版本apk的下载链接
 						downloadApp(newVersion.attachment);
 					}else{
 						openIosAppSotre(newVersion.downloadUrl)
 					}
-					// marketOpen()
+				} else if (res.cancel) {
+					console.log('稍后更新');
+					callback()
 				}
-			},{"title":msg,"buttons": !isQzgx ? ["立即更新"] : ["立即更新","稍后进行"]})
-		// #endif
+			}
+		});
+		uni.hideLoading();
 	}else{
 		if(type){
 			uni.showToast({
@@ -332,6 +305,8 @@ export const checkVersionToLoadUpdate = function(newVersion,type,market){
 				title: '已是最新版本',
 				duration: 1500  
 			}); 
+		}else{
+			callback()
 		}
 	}
 }
@@ -376,9 +351,30 @@ export const numberToFixed = function (val, num, max) {
   else if (num == 5)_value = _value.replace(/^(\-)*(\d+)\.(\d\d\d\d\d).*$/, '$1$2.$3')
   else if (num == 0)_value = _value.indexOf('.') >= 0 ? _value.split('.')[0] : _value
   else _value = _value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3')
-  return _value > maxNums ? maxNums : _value
+  // console.log(_value,maxNums,Number(_value)>Number(maxNums),'_value')
+  return Number(_value)>Number(maxNums) ? maxNums : _value
 }
-
-
-
-  
+// 保存图片到阿里云
+export const saveImgToAliOss = function(src,callback){
+	console.log(src,getApp().globalData.baseUrl,'getApp().globalData.baseUrl')
+	const authorization = getApp().globalData.token
+	uni.uploadFile({
+		url: getApp().globalData.baseUrl + 'upload/', //自行修改各自的对应的接口 
+		filePath: src,
+		name: 'file',
+		header: {'X-AUTH-TOKEN':authorization},
+		success: (uploadFileRes) => {
+			if (uploadFileRes) {
+				let res = JSON.parse(uploadFileRes.data);
+				callback(res)
+			}
+			uni.showToast({
+				icon: 'none',
+				title: uploadFileRes ? '保存图片成功' : '保存图片失败'
+			})
+		},
+		fail:(error) => {
+			console.log(error)
+		}
+	});
+}

+ 1 - 1
pages.json

@@ -4,7 +4,7 @@
 	},
 	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
 		{
-			"path": "pages/login/pwLogin",
+			"path": "pages/login/login",
 			"style": {
 				"navigationBarTitleText": ""
 			}

+ 54 - 37
pages/login/login.scss

@@ -1,67 +1,78 @@
-.pw-login-wrap, .forget-wrap, .apply-wrap{
+.login-wrap, .forget-wrap, .apply-wrap{
 	background-color: #FFFFFF;
 	width: 100%;
 	height: 100vh;
 	box-sizing: border-box;
-	position: relative;
-	.logo{
+	display: flex;
+	flex-direction: column;
+	align-items: center;
+	.login-head{
+		padding: 10upx 0;
+		text-align: center;
+		color: #999999;
+	}
+	.login-body{
+		flex-grow: 1;
+		width: 85%;
 		display: flex;
+		flex-direction: column;
+		align-items: center;
 		justify-content: center;
-		padding-top: 20vh;
-		padding-bottom: 100upx;
+	}
+	.logo{
+		display: block;
+		margin-bottom: 50upx;
+		width: 160upx;
+		height: 48upx;
+	}
+	.login-title{
+		font-size: 40upx;
+		margin: 50upx 0;
 	}
 	.login-form{
 		display: block;
-		width: 80%;
 		margin: 0 auto;
+		width: 100%;
+		.mt20{
+			margin-top: 30upx;
+		}
 		.form-item{
-			margin-bottom: 20upx;
 			position: relative;
 			display: flex;
 			align-items: center;
-			border: 1upx solid #dcdee2;
-			border-radius: 80upx;
+			border-bottom: 1upx solid #EEEEEE;
 			.require-tip{
 				position: absolute;
-				left: 0;
+				left: -26upx;
 				top: 26upx;
 				color: red;
 			}
-			.item-inp{
-				flex-grow: 1;
-			}
 			.item-inp, .item-picker{
-				font-size: 30upx;
-				padding: 14upx 20upx;
+				font-size: 32upx;
+				padding: 20upx 0;
 			}
 			.getcode-btn{
-				position: absolute;
-				right: 0upx;
-				top: 0;
-				font-size: 24upx;
-				background: #999;
-				color: #FFFFFF;
-				border: 0;
-				border-top-left-radius: 0;
-				border-bottom-left-radius: 0;
-				line-height: 3;
-				z-index: 10;
+				font-size: 28upx;
+				color: #0485F6;
+				margin: 0;
+				padding: 0;
 			}
 		}
 		.flex-box{
 			display: flex;
 			justify-content: space-between;
 			font-size: 26upx;
+			align-items: center;
 		}
 		.form-btn-con{
-			margin-top: 60upx;
+			margin-top: 100upx;
 			.form-btn{
 				font-size: 32upx;
 				display: block;
-				line-height: 75upx;
+				line-height: 84upx;
 				margin: 0 auto;
-				background-color: #07c160;
 				color: #fff;
+				border-radius: 100upx;
 			}
 			uni-button.form-btn:after{
 				border: none;
@@ -69,19 +80,25 @@
 			.apply-btn{
 				display: block;
 				text-align: center;
-				margin-top: 50upx;
+				margin-top: 30upx;
+				border: 1upx solid #BBBBBB;
+				padding: 24upx 0;
+				border-radius: 100upx;
 			}
 		}
+		.forget-pass{
+			color: #606266;
+		}
 	}
-	.ysxy{
-		font-size: 24upx;
-		text-align: center;
+	
+	.authUserYs{
 		width: 100%;
-		position: absolute;
-		bottom: 160upx;
-		left: 0;
+		padding: 60upx;
+		font-size: 26upx;
+		display: flex;
+		align-items: center;
 		text{
-			color: #00aaff;
+			color: #0485F6;
 		}
 	}
 }

+ 204 - 0
pages/login/login.vue

@@ -0,0 +1,204 @@
+<template>
+	<view class="login-wrap">
+		<view class="login-head">
+			<view v-if="showEnvTips">{{ envTips }}</view>
+		</view>
+		<view class="login-body">
+			<image :src="`../../static/${theme}/logo.png`" class="logo"></image>
+			<form class="login-form" @submit="AndroidCheckUpdate">
+				<view class="form-item">
+					<u-input v-model="form.username" :custom-style="{fontSize:'34upx'}" height="110" type="number" clearable maxlength="11" placeholder="请输入手机号/用户名" />
+				</view>
+				<view class="form-item">
+					<u-input v-model="form.password" :custom-style="{fontSize:'34upx'}" height="110" type="password" :password-icon="true" maxlength="12" placeholder="请输入密码"/>
+				</view>
+				<view class="flex-box mt20">
+					<view class="remember-pass">
+						<checkbox-group @change="rememberChange">
+							<label>
+								<u-checkbox v-model="isRemember" label-size="13px" shape="circle">记住密码</u-checkbox>
+							</label>
+						</checkbox-group>
+					</view>
+					<view class="forget-pass" @click="forgetPass">忘记密码</view>
+				</view>
+				<view class="form-btn-con">
+					<button class="form-btn" :disabled="isDisabled" :style="{'background':isDisabled?'#e5e5e5':$config('buttonColors')}" form-type="submit">登录</button>
+					<text class="apply-btn" @click="applyTrial">没有账号?马上申请试用</text>
+				</view>
+			</form>
+		</view>
+		
+		<view class="authUserYs">
+			<u-checkbox-group width="45rpx" @change="authuserChange">
+				<u-checkbox v-model="isAuthuserYs" :label-disabled="false" shape="circle">
+				</u-checkbox>
+			</u-checkbox-group>
+			<view>登录代表同意</view>
+			<view @click="toYsPage">
+				<text>用户协议</text>及<text>隐私保护政策</text>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+import { checkVersionToLoadUpdate, setStorageForAppVersion,clzConfirm } from '@/libs/tools'
+import { isvalidPhone } from '@/libs/validate.js';
+import { login } from '@/api/user.js';
+import { getSysVersion } from '@/api/data.js'
+export default {
+	data() {
+		return {
+			form: {
+				username: this.$store.state.vuex_user.account,
+				password: this.$store.state.vuex_user.password
+			},
+			isRemember: true, //  是否记住密码
+			isAuthuserYs: false, // 是否同意隐私政策
+			envTips: '',
+			showEnvTips: false,
+			theme: ''
+		};
+	},
+	computed: {
+		isDisabled() {
+			return this.form.username == '' || this.form.password == ''
+		}
+	},
+	onShow() {
+		this.isRemember = this.$store.state.vuex_isRemember;
+		this.envTips = getApp().globalData.envTips;
+		this.showEnvTips = process.env.NODE_ENV == 'development';
+		this.theme = getApp().globalData.theme;
+		
+		//#ifdef APP-PLUS
+		  this.isAuthuserYs = plus.runtime.isAgreePrivacy()
+		  uni.getSystemInfo({
+			  success:(res) => {
+				  console.log(res)
+				  // 获取最新版本信息
+				  plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{
+					wgtinfo.platform = res.platform
+				  	getApp().globalData.version = wgtinfo
+				  })
+			  }  
+		  })
+		//#endif
+	},
+	methods: {
+		// 版本更新
+		AndroidCheckUpdate(){
+			let _this = this
+			let version = getApp().globalData.version
+			uni.showLoading({
+				title: '正在登录...'
+			});
+			getSysVersion({versionType:version.platform=='android'?'ANDROID':'IOS'}).then(ret => {
+				if(ret.status == 200){
+					this.$store.state.vuex_versionInfo = ret.data
+					checkVersionToLoadUpdate(ret.data,0,_this.formSubmit);
+				}
+			})
+		},
+		// 过滤权限code
+		fiterAuthCode(data) {
+			data.permCodes = data.permCodes.filter(item => item.indexOf('_mobile') > 0);
+			return data;
+		},
+		//  表单提交
+		formSubmit() {
+			const _this = this;
+			//  表单校验
+			if (_this.form.username == '') {
+				uni.showToast({ icon: 'none', title: '请输入用户名' });
+				return;
+			}
+			if (!isvalidPhone(_this.form.username)) {
+				uni.showToast({ icon: 'none', title: '请输入正确的手机号码' });
+				return;
+			}
+			if (_this.form.password == '') {
+				uni.showToast({ icon: 'none', title: '请输入密码' });
+				return;
+			}
+			if (_this.form.password.length < 6 || _this.form.password.length > 12) {
+				uni.showToast({ icon: 'none', title: '请输入6-12位密码' });
+				return;
+			}
+			if (!_this.isAuthuserYs) {
+				uni.showToast({ icon: 'none', title: '请同意并阅读用户隐私政策' });
+				return;
+			}
+			
+			//  登录
+			login(_this.form).then(ret => {
+				uni.hideLoading();
+				let res = ret.data ? ret.data : ret;
+				if (res.status == 200) {
+					_this.$u.vuex('vuex_token', 'Bearer ' + res.access_token);
+					_this.$u.vuex('vuex_userData', _this.fiterAuthCode(res.auth_user));
+					getApp().globalData.token = 'Bearer ' + res.access_token;
+					//登录成功将用户名密码存储到用户本地
+					if (_this.isRemember) {
+						//用户勾选“记住密码”
+						_this.$u.vuex('vuex_user.account', _this.form.username);
+						_this.$u.vuex('vuex_user.password', _this.form.password);
+					} else {
+						//用户没有勾选“记住密码”
+						_this.$u.vuex('vuex_user.account', '');
+						_this.$u.vuex('vuex_user.password', '');
+						_this.form.username = '';
+						_this.form.password = '';
+					}
+					uni.setStorageSync('loginTimeOut', 'NO');
+					_this.toMain();
+				} else {
+					uni.showToast({ icon: 'none', title: res.message });
+				}
+			});
+		},
+		toMain() {
+			// 跳转到首页
+			uni.redirectTo({
+				url: '/pages/index'
+			});
+		},
+		//  申请试用
+		applyTrial() {
+			uni.navigateTo({
+				url: '/pages/login/apply-trial'
+			});
+		},
+		//  忘记密码
+		forgetPass() {
+			uni.navigateTo({
+				url: '/pages/login/forget-pass?username=' + this.form.username
+			});
+		},
+		//  判断是否记住密码
+		rememberChange(e) {
+			this.isRemember = e.detail.value.length > 0;
+		},
+		// 隐私
+		authuserChange(e) {
+			this.$u.vuex('vuex_isUsrAuthYs', this.isAuthuserYs);
+			//#ifdef APP-PLUS
+			if(!this.isAuthuserYs){
+				plus.runtime.disagreePrivacy()
+			}else{
+				plus.runtime.agreePrivacy()
+			}
+			//#endif
+		},
+		toYsPage() {
+			uni.navigateTo({
+				url: '/pages/login/userAuthYs'
+			});
+		}
+	}
+};
+</script>
+<style scoped lang="scss">
+@import './login.scss';
+</style>

+ 0 - 144
pages/login/pwLogin.vue

@@ -1,144 +0,0 @@
-<template>
-	<view class="pw-login-wrap">
-		<!-- <view v-if="!buildType" style="text-align: center;color: #999999;padding-top: 40px;">{{ envTips }}</view> -->
-		<view class="logo">
-			<u-image src="/static/logo.png" width="160" height="48" ></u-image>
-		</view>
-		<form class="login-form" @submit="formSubmit">
-			<view class="form-item">
-				<input v-model="form.loginName" class="item-inp" name="loginName" type="text" maxlength="30" placeholder="请输入用户名" />
-			</view>
-			<view class="form-item">
-				<input v-model="form.password" class="item-inp" name="password" password type="text" maxlength="12" placeholder="请输入密码" />
-			</view>
-			<view class="flex-box" style="margin-top: 60upx;">
-				<view class="remember-pass">
-					<u-checkbox v-model="isRemember" value="true" :size="30" :label-size="26" :active-color="$config('primaryColor')" class="login-form-checkbox" @change="rememberChange">记住密码</u-checkbox>
-				</view>
-			</view>
-			<view class="form-btn-con">
-				<button class="form-btn" :style="{background:$config('primaryColor'),borderRadius:'100px'}" form-type="submit">登录</button>
-			</view>
-		</form>
-		<view class="ysxy" @click="toYs">登录即代表同意<text>隐私政策</text>和<text>服务条款</text></view>
-	</view>
-</template>
-
-<script>
-import market from "@/js_sdk/dc-market/market.js"
-import { checkVersionToLoadUpdate, setStorageForAppVersion,clzConfirm } from '@/libs/tools'
-import { isvalidPhone } from '@/libs/validate.js';
-import { login } from '@/api/user.js';
-import { getSysVersion } from '@/api/data.js'
-export default {
-	data() {
-		return {
-			form: {
-				loginName: this.$store.state.vuex_user.account,
-				password: this.$store.state.vuex_user.password
-			},
-			isRemember: true, //  是否记住密码
-			envTips: '',
-			buildType: '',
-		};
-	},
-	mounted() {
-		this.isRemember = this.$store.state.vuex_isRemember || true;
-		this.envTips = getApp().globalData.envTips;
-		this.buildType = getApp().globalData.buildType;
-	},
-	onShow() {
-	},
-	methods: {
-		//  获取微信login  code
-		getWechatCode(){
-			const _this = this
-			wx.login({
-			  success (res) {
-			    if (res.code) {
-					//发起网络请求
-					let formData = JSON.parse(JSON.stringify(_this.form))
-					formData.code = res.code
-					_this.submitForm(formData)
-			    } else {
-					console.log('登录失败,点击“登录”重试!' + res.errMsg)
-			    }
-			  }
-			})
-		},
-		//  表单提交
-		formSubmit() {
-			const _this = this;
-			//  表单校验
-			if (_this.form.loginName == '') {
-				uni.showToast({ icon: 'none', title: '请输入用户名' });
-				return;
-			}
-			if (_this.form.password == '') {
-				uni.showToast({ icon: 'none', title: '请输入密码' });
-				return;
-			}
-			if (_this.form.password.length < 6 || _this.form.password.length > 12) {
-				uni.showToast({ icon: 'none', title: '请输入6-12位密码' });
-				return;
-			}
-			uni.showLoading({
-				title: '正在登录...'
-			});
-		 
-			this.submitForm(_this.form)
-		},
-		submitForm(formData){
-			const _this = this
-			//  登录
-			// login(formData).then(res => {
-			// 	uni.hideLoading()
-			// 	if (res.status == 200) {
-			// 		_this.$u.vuex('vuex_token', res.data)
-			// 		getApp().globalData.token = res.data
-			// 		//登录成功将用户名密码存储到用户本地
-			// 		if (_this.isRemember) {
-			// 			//用户勾选“记住密码”
-			// 			_this.$u.vuex('vuex_user.account', _this.form.loginName)
-			// 			_this.$u.vuex('vuex_user.password', _this.form.password)
-			// 		} else {
-			// 			//用户没有勾选“记住密码”
-			// 			_this.$u.vuex('vuex_user.account', '')
-			// 			_this.$u.vuex('vuex_user.password', '')
-			// 			_this.form.loginName = ''
-			// 			_this.form.password = ''
-			// 		}
-			// 		uni.setStorageSync('loginTimeOut', 'NO')
-					// _this.toMain()
-			// 	} else {
-			// 		uni.showToast({ icon: 'none', title: res.message })
-			// 	}
-			// })
-		},
-		toMain() {
-			// 跳转到首页
-			uni.switchTab({
-				url: '/pages/index/index'
-			});
-		},
-		//  忘记密码
-		forgetPass() {
-			uni.navigateTo({
-				url: '/pages/login/forget-pass?username=' + this.form.loginName
-			});
-		},
-		//  判断是否记住密码
-		rememberChange(e) {
-			this.isRemember = e.value;
-		},
-		toYs(){
-			uni.navigateTo({
-				url: '/pages/login/userAuthYs'
-			})
-		}
-	}
-};
-</script>
-<style scoped lang="scss">
-@import './login.scss';
-</style>

+ 1 - 2
pages/userCenter/index.vue

@@ -26,8 +26,7 @@
 </template>
 
 <script>
-	import {logout} from '@/api/login.js'
-	import { getUserInfo } from '@/api/user.js'
+	import { getUserInfo, logout } from '@/api/user.js'
 	export default {
 		data() {
 			return {

+ 0 - 0
static/logo.png → static/default/logo.png


BIN
static/filter.png


BIN
static/ledou.png


+ 91 - 4
store/index.js

@@ -16,6 +16,9 @@ let saveStateKeys = [
 	'vuex_user',
 	'vuex_token',
 	'vuex_userData',
+	'vuex_isRemember',
+	'vuex_isUsrAuthYs',
+	'vuex_versionInfo',
 ];
 
 // 保存变量到本地存储中
@@ -32,18 +35,72 @@ const saveLifeData = function(key, value) {
 	}
 }
 
+// websocket 连接
+const SocketInit = function($store,state,wsUrl){
+	// 开始连接
+	state.vuex_socket = uni.connectSocket({
+	    url: wsUrl, // ws 请求地址
+	    complete: ()=> {
+			console.log('连接complete回调!')
+		}
+	});
+	// 打开连接
+	state.vuex_socket.onOpen(function(e){
+		console.log('连接成功!')
+	})
+	// 连接关闭
+	state.vuex_socket.onClose(function(e){
+		console.log('ws关闭!')
+	})
+	// 连接错误
+	state.vuex_socket.onError(function(e){
+		console.log('ws错误!', JSON.stringify(e))
+	})
+	// 接受消息
+	state.vuex_socket.onMessage(function(e){
+		if (e.data != 'pong'){
+		  let ret = JSON.parse(e.data)
+		  console.log('ws接收!', ret)
+		  state.vuex_wsMessageData = ret
+		  // 入厂车辆拍照识别
+		  if (ret.type == 'enter_store_vehicle'){}
+		  // 新未读消息
+		  if (ret.type == 'no_read_count'){
+			state.vuex_messagUnReadCount = ret.data.no_read_count
+		  }
+		}
+	})
+	// 发送心跳包
+	state.vuex_heartInterId = setInterval(function() {
+		if (state.vuex_socket.readyState != 1) {
+			 // 停止心跳
+			 clearInterval(state.vuex_heartInterId)
+			 SocketInit($store,state,wsUrl)
+			 uni.$emit('wsMessage','reconnect')
+		} else {
+			$store.commit("$sendWebsocket", "ping")
+		}
+	}, 20000)
+}
+
 // store 对象
 const store = new Vuex.Store({
 	// 下面这些值仅为示例,使用过程中请删除
 	state: {
 		// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
 		// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
-		vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {
-			account: '',
-			password: ''
-		},
 		vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
 		vuex_userData: lifeData.vuex_userData ? lifeData.vuex_userData : '',
+		vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {account:'',password:''},
+		vuex_isRemember: lifeData.vuex_isRemember ? lifeData.vuex_isRemember : true,
+		vuex_isUsrAuthYs: lifeData.vuex_isUsrAuthYs ? lifeData.vuex_isUsrAuthYs : false,
+		vuex_versionInfo: lifeData.vuex_versionInfo ? lifeData.vuex_versionInfo : {}, // 版本信息
+		vuex_socket: null, // 消息通知ws对象
+		vuex_wsMessageData: null, // 消息对象
+		vuex_heartInterId: null, // 心跳id
+		vuex_reConnectId: null, // 重连id
+		vuex_messagUnReadCount: 0, // 消息未读数
+		vuex_messagLaster: [], // 最新消息
 	},
 	mutations: {
 		$uStore(state, payload) {
@@ -66,6 +123,36 @@ const store = new Vuex.Store({
 			// 保存变量到本地,见顶部函数定义
 			saveLifeData(saveKey, state[saveKey])
 		},
+		// 创建通知消息websocket
+		$webSocket(state, params) {
+			let _this = this
+			let userInfo = state.vuex_userData
+			let url = getApp().globalData.baseUrl
+			let wsBaseUrl = url.indexOf("https:")>=0 ? url.replace("https:","wss:") : url.replace("http:","ws:")
+			let wsUrl = wsBaseUrl + 'websocket/app/' + 's' + userInfo.parentOrgId + 'o' + userInfo.orgId + 'u' + userInfo.userid + 'eapp'
+			SocketInit(_this,state,wsUrl)
+		},
+		// 关闭websocket
+		$closeWebsocket(state){
+			if(state.vuex_socket){
+				state.vuex_socket.close({
+					complete: function(e){
+						console.log('关闭websocket完成', e)
+						// 停止心跳
+						clearInterval(state.vuex_heartInterId)
+					}
+				})
+			}
+		},
+		// 发送消息
+		$sendWebsocket(state, msg) {
+		    state.vuex_socket.send({
+				data: msg,
+				complete: function(e){
+					console.log('ws发送完成', e)
+				}
+			})
+		},
 	}
 })