zhengkaixin 3 years ago
parent
commit
6fd9194eb8
7 changed files with 407 additions and 122 deletions
  1. 13 0
      App.vue
  2. 1 1
      README.md
  3. 1 1
      bobo-router/index.js
  4. 3 3
      manifest.json
  5. 9 7
      pages.json
  6. 170 31
      pages/charge/index.vue
  7. 210 79
      pages/login/index.vue

+ 13 - 0
App.vue

@@ -32,4 +32,17 @@
 	    content: "" !important ;
 		display: none;
 	}
+	.uni-toast .uni-toast__content{
+		margin: -10px 1px 10px 1px;
+	}
+	.uni-modal .uni-modal__btn{
+			  flex: 1;
+			  height: 43px;
+			  line-height: 43px !important;;
+			  font-size: 13px !important;
+			  box-sizing: border-box;
+			  cursor: pointer;
+			  text-align: center;
+			  border-radius: 1px;
+	}
 </style>

+ 1 - 1
README.md

@@ -1,4 +1,4 @@
-#  jp_employment_kfq  荆开求职在线
+#   智能充电系统
 
 ## 运行与安装
 建议使用uniapp的官方推荐开发工具HBuilder最新版本

+ 1 - 1
bobo-router/index.js

@@ -20,7 +20,7 @@ uniCrazyRouter.afterEach((to, from) => {
 	console.log("afterEach")
 	if(process.car.NODE_ENV=='dev'||process.car.NODE_ENV=='test'){
 		    uni.setNavigationBarTitle({
-		       		title:'荆开就业在线('+process.car.NODE_ENV+')',
+		       		title:'智能充电系统('+process.car.NODE_ENV+')',
 		    						
 		    }) 
 		}

+ 3 - 3
manifest.json

@@ -1,6 +1,6 @@
 {
-    "name" : "jp-employment-kfq",
-    "appid" : "__UNI__B831E6D",
+    "name" : "jp-charge",
+    "appid" : "__UNI__2D3A5D0",
     "description" : "",
     "versionName" : "1.0.0",
     "versionCode" : "100",
@@ -79,7 +79,7 @@
                 "enable" : true
             }
         },
-        "title" : "荆开就业在线",
+        "title" : "智能充电系统",
         "router" : {
             "base" : "./"
         }

+ 9 - 7
pages.json

@@ -4,6 +4,14 @@
 		},
 	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages	
 		
+		{
+			"name":"充电",
+			"path": "pages/charge/index",
+			"style": {
+				//"navigationStyle": "custom" // 隐藏系统导航栏
+			}
+		},
+		
 		{
 			"name":"充电中",
 			"path": "pages/index/index",
@@ -12,13 +20,7 @@
 				//"navigationStyle": "custom" // 隐藏系统导航栏
 			}
 		},
-		{
-			"name":"充电",
-			"path": "pages/charge/index",
-			"style": {
-				//"navigationStyle": "custom" // 隐藏系统导航栏
-			}
-		},
+		
 		{
 			"name":"切换充电桩",
 			"path": "pages/charge/switchCharge",

+ 170 - 31
pages/charge/index.vue

@@ -23,38 +23,55 @@
 					<view class="u-flex"><p>模式:</p><h4>0.25元(0-200W)1小时0.33元</h4></view>
 					<view class="u-flex">
 						<span>费用说明</span>
-						<u-icon name="error-circle" color="#1677ff" size="32"></u-icon>
+						<u-icon name="error-circle" color="#1677ff" size="32" @click="showTips()"></u-icon>
 					</view>
 				</view>
 			</view>
 			<view class="chargeMain">
-				<view class="chargeMain-item active"><p>1</p><p>空闲</p></view>
-				<view class="chargeMain-item occupy"><p>2</p><p>占用</p></view>
-				<view class="chargeMain-item"><p>3</p><p>占用</p></view>
-				<view class="chargeMain-item"><p>4</p><p>空闲</p></view>
-				<view class="chargeMain-item"><p>5</p><p>空闲</p></view>
-				<view class="chargeMain-item"><p>6</p><p>空闲</p></view>
-				<view class="chargeMain-item"><p>7</p><p>空闲</p></view>
-				<view class="chargeMain-item"><p>8</p><p>空闲</p></view>
-				<view class="chargeMain-item"><p>9</p><p>空闲</p></view>
-				<view class="chargeMain-item fault"><p>10</p><p>故障</p></view>
+				<template v-for="(item,i) in list">
+					
+					<view :key="i" class="chargeMain-item "
+					@click="selectItem(item)"
+					:class="{
+						'active':item.id==submitForm.detailItem,
+						'occupy':item.status==2,
+						'fault':item.status==3,
+					}"
+					
+					><p>{{i+1}}</p>
+					<p v-if="item.status==1">空闲</p>
+					<p v-else-if="item.status==2">占用</p>
+					<p v-else-if="item.status==3">故障</p>
+					</view>
+					
+				</template>
+				 
 			</view>
 		</view>
 		<view class="charge">
 			<view class="chargeTime">
-				<view class="chargeTime-first"><p>充满</p><p>自停</p></view>
-				<view class="chargeTime-item">1小时</view>
-				<view class="chargeTime-item">2小时</view>
-				<view class="chargeTime-item">3小时</view>
-				<view class="chargeTime-item">4小时</view>
-				<view class="chargeTime-item">5小时</view>
-				<view class="chargeTime-item">6小时</view>
-				<view class="chargeTime-item">7小时</view>
-				<view class="chargeTime-item">8小时</view>
+				
+				<view v-for="(item,i) in timelist" 
+					class="chargeTime-item " :key="i"
+					@click="submitForm.selectTime=item.id"
+					:class="{
+						'chargeTime-active':submitForm.selectTime==item.id,
+						
+						'chargeTime-first':i==0
+					}"
+					>
+					<template v-if="i==0">
+						<p>充满</p><p>自停</p>
+					</template>
+						<template v-else>
+							{{item.name}}
+						</template>
+				</view>
+					
 			</view>
 			<view class="chargeTime-text">
 				<p>充电时长</p>
-				<span>充电自满</span>
+				<span>{{timelist[submitForm.selectTime].name}}</span>
 			</view>
 		</view>
 		<view class="charge">
@@ -72,22 +89,143 @@
 			</view>
 		</view>
 		<view class="foot-btn">
-			<u-button type="primary" :custom-style="customStyle" shape="square">开始充电</u-button>
+			<u-button type="primary" :custom-style="customStyle" 
+				@click="submit"
+			shape="square">开始充电</u-button>
 		</view>
+		<u-modal v-model="showmodel" title="title" >
+			<h1>111</h1>
+			
+		</u-modal>
+
 	</view>
 </template>
 
 <script>
+	import * as API_common from '@/apis/common.js'
+	
 	export default {
 		data() {
 			return {
+				showmodel:false,
+				//充电桩信息
+				detail:{
+					money:4.00,
+				},
+				//充电位子list
+				list:[
+					{
+						id:'1',
+						status:'1',
+					},
+					{
+						id:'2',
+						status:'2',
+					},{
+						id:'3',
+						status:'3',
+					},{
+						id:'4',
+						status:'1',
+					},
+					{
+						id:'5',
+						status:'1',
+					},
+				],
+				timelist:[
+					{
+						id:'0',
+						name:'充满自停'
+					},
+					{
+						id:'1',
+						name:'1小时'
+					},
+					{
+						id:'2',
+						name:'2小时'
+					},
+					{
+						id:'3',
+						name:'3小时'
+					},
+					{
+						id:'4',
+						name:'4小时'
+					},
+					{
+						id:'5',
+						name:'5小时'
+					},
+					{
+						id:'6',
+						name:'6小时'
+					},
+					{
+						id:'7',
+						name:'7小时'
+					},
+					{
+						id:'8',
+						name:'8小时'
+					},
+				],
+				//提交信息
+				submitForm:{
+					detailNo:'',
+					detailItem:'',
+					selectTime:'0',
+					paytype:'YE',
+				},
 				customStyle: {
 					background: '#1677ff'
 				}
 			}
 		},
 		methods: {
-
+			selectItem(row){
+				if(row.status==1){
+					this.submitForm.detailItem=row.id
+				}else{
+					
+					uni.showToast({
+						title:'当前设备不可选'
+					})
+				}
+			},
+			submit(){
+				if(true){
+					this.showmodel=true;
+				}else{
+					uni.showModal({
+					    title: '订单信息',
+					    content: '<h1>111</h1>',
+					    success: function (res) {
+					        if (res.confirm) {
+					            console.log('用户点击确定');
+					        } else if (res.cancel) {
+					            console.log('用户点击取消');
+					        }
+					    }
+					});
+				}
+				
+			},
+			showTips(){
+				uni.showModal({
+				    title: '提示',
+					showCancel:true,
+				    content: '这是一个模态弹窗',
+				    success: function (res) {
+				        if (res.confirm) {
+				            console.log('用户点击确定');
+				        } else if (res.cancel) {
+				            console.log('用户点击取消');
+				        }
+				    }
+				});
+			}
 		}
 	}
 </script>
@@ -126,25 +264,26 @@
 		display: flex;
 		overflow: scroll;
 		padding-bottom: 15px;
+	
 		.chargeTime-item{
+			border: 1px solid #1677ff;
+			border-radius: 50%;
 			min-width: 56px;
 			height: 56px;
-			border-radius: 50%;
-			border: 1px solid #1677ff;
 			text-align: center;
 			line-height: 56px;
 			margin-right: 20px;
 		}
 		.chargeTime-first{
-			min-width: 56px;
-			height: 56px;
-			border-radius: 50%;
-			color:#fff;
-			background-color: #1677ff;
-			text-align: center;
+			line-height: 20px !important;
+			
 			padding-top: 6px;
 			margin-right: 20px;
 		}
+		.chargeTime-active{
+			color:#fff;
+			background-color: #1677ff;
+		}
 	}
 	.chargeTime-text{
 		border-top: 1px solid #f7f7f7;

+ 210 - 79
pages/login/index.vue

@@ -1,89 +1,220 @@
-<template>
-	<view>
-		<view class="login-title">
-			<u-icon name="qichexiangguan-chongdianzhan" custom-prefix="custom-icon" color="#1677ff" size="56"></u-icon>
-			<h3>电动自行车智能充电系统</h3>
-		</view>
-		<view class="login-main">
-			<u-form :model="form" ref="uForm" >
-				<u-form-item label="手机号码" prop="phone" label-width="150" label-position="top">
-					<u-input :border="border" placeholder="请输入手机号" v-model="form.phone" type="number"></u-input>
-				</u-form-item>
-				<u-form-item label="验证码" prop="code" label-width="150" label-position="top">
-					<u-input :border="border" placeholder="请输入验证码" v-model="form.code" type="text"></u-input>
-					<view class="login-code" @click="getCode">
-						{{codeTips}}
-					</view>
-				</u-form-item>
-			</u-form>
-		</view>
-		<view class="login-btn">
-			<u-button type="primary" :custom-style="customStyle" shape="square">登录</u-button>
-		</view>
-		<u-verification-code seconds="60" ref="uCode" @change="codeChange"></u-verification-code>
-	</view>
-</template>
-
-<script>
-	export default {
-		data() {
-			return {
-				form: {
-					phone: '',
-					code: '',
+<template>
+	<view>
+		<view class="login-title">
+			<u-icon name="qichexiangguan-chongdianzhan" custom-prefix="custom-icon" color="#1677ff" size="56"></u-icon>
+			<h3>电动自行车智能充电系统</h3>
+		</view>
+		<view class="login-main">
+			<u-form :model="form" ref="uForm">
+				<u-form-item label="手机号码" prop="phone" label-width="150" label-position="top">
+					<u-input   placeholder="请输入手机号" v-model="form.phone" type="number"></u-input>
+				</u-form-item>
+				<u-form-item label="验证码" prop="code" label-width="150" label-position="top">
+					<u-input  placeholder="请输入验证码" v-model="form.code" type="text"></u-input>
+					<view class="login-code" @click="getCode">
+						{{codeTips}}
+					</view>
+				</u-form-item>
+			</u-form>
+		</view>
+		<view class="login-btn">
+			<u-button type="primary" :custom-style="customStyle" @click="finish" shape="square">登录</u-button>
+		</view>
+		<u-verification-code :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start">
+		</u-verification-code>
+	</view>
+</template>
+
+<script>
+	import * as API from '@/apis/login.js'
+
+	import {
+		checkPhone
+	} from '@/utils'
+	export default {
+		data() {
+			return {
+				form: {
+					phone: '',
+					code: '',
 				},
-				codeTips: '',
-				customStyle: {
-					background: '#1677ff'
-				}
-			}
+					backUrl:"",
+						message:"",
+				codeTips: '',
+				isSendMsgIng: false,
+				sendMsgSecond: 60 * 2,
+				customStyle: {
+					background: '#1677ff'
+				}
+			}
 		},
-		methods: {
-			codeChange(text) {
-				this.codeTips = text;
+		onLoad(op){
+			
+			this.message=op.message;
+			this.backUrl=op.back;
+		
+		},
+		methods: {
+			codeChange(text) {
+				this.codeTips = text;
+			},
+			//倒计时
+
+			end() {
+				this.sendMsgSecond = 2 * 60;
+				this.isSendMsgIng = false;
 			},
-			// 获取验证码
-			getCode() {
-				if(this.$refs.uCode.canGetCode) {
-					// 模拟向后端请求验证码
+			finish(){
+				uni.redirectTo({
+						url:'pages/user/index'
+					})
+				return
+				if(!this.carhelp.getOpenId()){
+					uni.showToast({
+						title:"请使用“微信”访问本系统登录"
+					})
+					return
+				}
+				 uni.showLoading({
+				   	title:"加载中",mask:true,
+				   })
+				  API.validateCode({
+					verifyCode: this.form.code,
+					telephone:this.form.phone,
+					openId:this.carhelp.getOpenId(),
+				
+				  }).then((response) => {
+				 		 var token = response ? response.data.token : '';
+				 		 this.carhelp.setToken(token);
+						 this.carhelp.setPersonInfo(response.data.jobUser );
+						//this.gotoUrl("pages/user/index")
+						uni.redirectTo({
+								url:'/pages/user/index'
+							})
+						// if(this.backUrl){
+						// 	window.location.href="#"+this.backUrl.split(",").find(function(item){
+						// 		return item.indexOf("pages/login/")==-1
+						// 	});
+						// }else{
+							
+						// }
+				 }).catch(error => {
+				 	uni.showToast({
+				 				title:error,
+				 				icon:"none"
+				 	})
+				 })
+			},
+			start() {
+				if (!this.isSendMsgIng) {
+					this.carhelp.set("getvcodetime", new Date().getTime());
+					console.log("模拟发送成功")
+					return
+					
 					uni.showLoading({
-						title: '正在获取验证码',
-						mask: true
+						title: "加载中",
+						mask: true,
 					})
-					setTimeout(() => {
+					API.getVerifyCode(this.form.phone).then((response) => {
+					
+					
 						uni.hideLoading();
-						// 这里此提示会被this.start()方法中的提示覆盖
-						this.$u.toast('验证码已发送');
-						// 通知验证码组件内部开始倒计时
-						this.$refs.uCode.start();
-					}, 2000);
+						this.carhelp.set("getvcodetime", new Date().getTime());
+						
+						if (!"") {
+							//倒计时
+							uni.showToast({
+								title: "发送成功"
+							})
+						} else {
+							uni.showToast({
+								title: "您的验证码已经发送[5分钟有效],请勿重复点击"
+							})
+						}
+					}).catch(error => {
+						uni.showToast({
+							title: error,
+							icon: "none"
+						})
+					})
+
+
+				}
+			},
+			// 获取验证码
+			getCode() {
+				if(this.$refs.uCode.canGetCode) {
+								
 				} else {
-					this.$u.toast('倒计时结束后再发送');
+					
+					uni.showToast({
+						title: '倒计时结束后再发送',
+						icon: "none"
+					})
+					return
+				}
+				
+				var checkPhoneResult = checkPhone(this.form.phone);
+				
+				if (false&&checkPhoneResult !== true) {
+					uni.showToast({
+						title: checkPhoneResult,
+				
+					})
+					return;
+				}
+				this.$refs.uCode.start();
+			}
+		},onReady(){ 
+			if(!this.carhelp.getOpenId()){
+				uni.showToast({
+					title:"请使用“微信”访问本系统登录"
+				})
+				return
+			}else if(this.message){
+				uni.showToast({
+					title:this.message.split(",")[0],
+					icon:"none"
+				})
+			}
+			var time = this.carhelp.get("getvcodetime");
+			if (time) {
+				//this.$refs.uCode.start();
+				var nowtime = new Date().getTime()
+				var differ = (nowtime - time) / 1000
+				if (differ < 2 * 60) {
+					this.sendMsgSecond = 2 * 60 - parseInt(differ)
+					this.isSendMsgIng = true;
+					this.$refs.uCode.start();
 				}
 			}
-		}
-	}
-</script>
-
-<style lang="scss" scoped>
-	.login-title{
-		display: flex;
-		align-items: center;
-		margin: 40px 30px;
-		h3{
-			font-size: 20px;
-			margin-left: 10rpx;
-			color:#1677ff;
-			font-weight: normal;
-		}
-	}
-	.login-main{
-		margin: 0 30px;
-	}
-	.login-btn{
-		margin: 30px;
-	}
-	.login-code{
-		color:#1677ff;
-	}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.login-title {
+		display: flex;
+		align-items: center;
+		margin: 40px 30px;
+
+		h3 {
+			font-size: 20px;
+			margin-left: 10rpx;
+			color: #1677ff;
+			font-weight: normal;
+		}
+	}
+
+	.login-main {
+		margin: 0 30px;
+	}
+
+	.login-btn {
+		margin: 30px;
+	}
+
+	.login-code {
+		color: #1677ff;
+	}
 </style>