Commit cdae6692 by 朱建香

云端绑定

parent 6e40dbb7
...@@ -91,7 +91,8 @@ ...@@ -91,7 +91,8 @@
"followCont2": "1.保存二维码-2.用微信从<span>相册选取扫码</span>-3.关注", "followCont2": "1.保存二维码-2.用微信从<span>相册选取扫码</span>-3.关注",
"laterFollow": "稍后关注", "laterFollow": "稍后关注",
"newMsgDoorlock": "门锁最新消息", "newMsgDoorlock": "门锁最新消息",
"doorLockRinging": "门铃响了" "doorLockRinging": "门铃响了",
"defaultNewMsg": "您尚未绑定门锁"
}, },
"opendoorRecord":{ "opendoorRecord":{
"noRecordTip": "暂无记录", "noRecordTip": "暂无记录",
......
...@@ -24,6 +24,7 @@ function init() { ...@@ -24,6 +24,7 @@ function init() {
}, },
mounted(){ mounted(){
resolve(this); resolve(this);
}, },
methods:{ methods:{
getTextWiFiName(){ getTextWiFiName(){
...@@ -180,19 +181,62 @@ function connectButtonTap(self){ ...@@ -180,19 +181,62 @@ function connectButtonTap(self){
console.log(error); console.log(error);
} }
}); });
let deviceId = null;
iot.business.sds.findDevices({ iot.business.sds.findDevices({
success: (response) => { success: (response) => {
console.log("findDevices"); console.log("findDevices");
console.log(response); console.log(response);
let parameters = {};
// let data = "DeviceInfo:[model = THM_LIVING_ELECTRICALBLANKET_TH_1507,xModel = null,mac = B0:F8:93:10:D5:09,sn = B0F89310D509,uuid = null,connectMode = alibaba_smartconfig_v3,supportRouterProvision = false,productName = null,gatewayUuid = null,deviceType = null,alinkJoinVersion = Bind, ]"
// console.log(data);
if (response.data) {
let info = response.data.split(':[');
if(info[1]){
let query = info[1].split(',');
console.log(query);
for(let i=0; i< query.length; i++){
let pari = query[i].split(' = ');
console.log(pari);
parameters[pari[0]] = pari[1];
}
console.log(parameters.sn);
}
}
if(parameters.sn){
deviceId = parameters.sn;
}
console.log(typeof(deviceId));
if(response.data == "joined success"){ if(response.data == "joined success"){
//云端绑定
iot.business.device.bind({
data: {
product_id: 2,
device_id: deviceId,
// mac: parameters.mac,
nickname: ''
},
success: (response) => {
console.log(response);
//连接成功
uComponents.changeCommLoadingStatusAndText(self, 1, '绑定成功');
self.setStatus(1);
},
error: (error) => {
console.log(error);
},
complete: () => {}
});
//连接成功 //连接成功
uComponents.changeCommLoadingStatusAndText(self, 1, '绑定成功'); // uComponents.changeCommLoadingStatusAndText(self, 1, '绑定成功');
self.setStatus(1); // self.setStatus(1);
// //停止查找设备 // //停止查找设备
iot.business.sds.stopFindDevices({ iot.business.sds.stopFindDevices({
success: (response) => {}, success: (response) => {},
error: (error) => {} error: (error) => {}
}); });
}else if(response.data == "fail"){ }else if(response.data == "fail"){
//连接失败 //连接失败
uComponents.changeCommLoadingStatusAndText(self, 2, '绑定失败'); uComponents.changeCommLoadingStatusAndText(self, 2, '绑定失败');
......
...@@ -45,7 +45,9 @@ function init() { ...@@ -45,7 +45,9 @@ function init() {
//设备ID //设备ID
deviceId: null, deviceId: null,
//设备uuid //设备uuid
uuid: null uuid: null,
//最新消息
newMsg: null
}, },
mounted(){ mounted(){
let self = this; let self = this;
...@@ -54,7 +56,9 @@ function init() { ...@@ -54,7 +56,9 @@ function init() {
iot.business.sds.getDevicesByUser({ iot.business.sds.getDevicesByUser({
success: (response) => { success: (response) => {
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
if(data){ if(response.data == 'success'){
// console.log(self.uuid);
}else if(data){
self.uuid = data[0].uuid; self.uuid = data[0].uuid;
self.deviceId = data[0].sn; self.deviceId = data[0].sn;
iot.business.sds.getDeviceStatus({ iot.business.sds.getDeviceStatus({
...@@ -69,30 +73,7 @@ function init() { ...@@ -69,30 +73,7 @@ function init() {
uPublic.openRequestErrorAlert(self); uPublic.openRequestErrorAlert(self);
} }
}); });
getLockInfo(self);
iot.business.api.sendCustom('lock/getLockInfo',{
data: {
// device_id:"600194283588"
device_id: self.deviceId
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
console.log(data.info);
let newMsg = moment(data.info[0].time).format("YY.MM.DD HH:mm") + data.info[0].nickname + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[0].mode]+'')
uComponents.changeMarqueeText(self, newMsg);
}else{
}
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
}
});
}else{
} }
}, },
error: (error) => {} error: (error) => {}
...@@ -101,10 +82,46 @@ function init() { ...@@ -101,10 +82,46 @@ function init() {
iot.business.sds.registerPushListener({ iot.business.sds.registerPushListener({
success: (response) => { success: (response) => {
console.log(response); console.log(response);
if(response.hasOwnProperty('params')){ if(typeof(response) == 'string'){
console.log(JSON.parse(response)); console.log("in");
setDevceInfo(self, response.params); let data = JSON.parse(response);
console.log(data);
console.log(moment(data.time, "YY-MM-DD-hh-mm-ss").format("HH:mm"));
switch(data.action){
case 'lock_log':
self.setBatteryPercent(data.battery);
self.setBatteryState(config.powerIcon[Math.round(data.battery/20)]);
//user_type: 0:密码用户 1:指纹用户 2:卡用户 3:遥控器 4:钥匙
//uid: 用户id
//time
if(lock_action == 0){
//再次获取最新记录
getLockInfo(self);
}
break;
case 'notify':
self.setBatteryPercent(data.battery);
self.setBatteryState(config.powerIcon[Math.round(data.battery/20)]);
if(data.notify_type == 3){
self.setDoorbellRingingFlag(true);
setTimeout(() => {
self.setDoorbellRingingFlag(false);
self.setRingingTime(moment(data.time, "YY-MM-DD-hh-mm-ss").format("HH:mm"));
},3000);
}else if(data.notify_type == 4){
self.setRemoteOpendoorFlag(true);
}
break;
case 'status':
self.setBatteryPercent(data.battery);
self.setBatteryState(config.powerIcon[Math.round(data.battery/20)]);
break;
case 'openDoor':
break;
}
} }
// setDevceInfo(self, response.params);
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
...@@ -114,13 +131,10 @@ function init() { ...@@ -114,13 +131,10 @@ function init() {
let power = 5; let power = 5;
this.batteryPercent = power/5*100; this.batteryPercent = power/5*100;
this.batteryState = config.powerIcon[power]; this.batteryState = config.powerIcon[power];
let newMsg = '2017.08.02 18:45 宝贝指纹开门'; // let newMsg = '2017.08.02 18:45 宝贝指纹开门';
// uComponents.changeMarqueeText(this, newMsg); // uComponents.changeMarqueeText(this, newMsg);
let time = new Date(); let time = new Date();
this.ringingTime = moment(time).format("HH:mm"); this.ringingTime = moment(time).format("HH:mm");
// getNewOpenDoorRecord(this);
}, },
methods:{ methods:{
getValueOpendoorRecord(){ getValueOpendoorRecord(){
...@@ -247,7 +261,7 @@ function initComponentsConfig() { ...@@ -247,7 +261,7 @@ function initComponentsConfig() {
marquee: { marquee: {
initParam: { initParam: {
class: "custom-marquee", class: "custom-marquee",
text: "2017.08.02 18:45 宝贝指纹开门<br>2017.08.02 18:45 宝贝指纹开门<br>2017.08.02 18:45 宝贝指纹开门" text: Vue.t('device.defaultNewMsg')
} }
}, },
//开门记录switch 参数 //开门记录switch 参数
...@@ -316,38 +330,51 @@ function initComponentsConfig() { ...@@ -316,38 +330,51 @@ function initComponentsConfig() {
} }
} }
//设置设备信息 function getLockInfo(self){
function setDevceInfo(self, data) { iot.business.api.sendCustom('lock/getLockInfo',{
self.setBatteryState(config.powerIcon[data.power]);
self.setBatteryPercent(data.power/5*100);
self.setRingingTime(moment(data.time).format("HH:mm"));
self.setDoorbellRingingFlag(data);
self.setRemoteOpendoorFlag(flag);
}
//获取最新开门记录
function getNewOpenDoorRecord(self){
iot.business.api.sendCustom('',{
data: { data: {
uuid: 'uuid', // device_id:"600194283588"
start_id: 0, device_id: self.deviceId
page_size: 0
}, },
success: (response) => { success: (response) => {
console.log(response); console.log(response);
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
if(data){ if(data){
uComponents.changeMarqueeText(self, data.message); self.setBatteryPercent(data.battery);
self.setBatteryState(config.powerIcon[Math.round(data.battery/20)]);
console.log(data.info);
self.newMsg = moment(data.info[0].time).format("YY.MM.DD HH:mm") + data.info[0].nickname + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[0].mode]+'');
uComponents.changeMarqueeText(self, self.newMsg);
}else{
} }
}, },
error: (error) => { error: (error) => {
uPublic.openRequestErrorAlert(self);
console.log(error); console.log(error);
}, uPublic.openRequestErrorAlert(self);
complete: () => {} }
}); });
} }
//设置设备信息
function setDevceInfo(self, data) {
console.log("监听到了");
self.setBatteryPercent(data.battery);
self.setBatteryState(config.powerIcon[Math.round(data.battery/20)]);
self.setRingingTime(moment(data.time).format("HH:mm"));
if(data.notify_type == 3){
self.setDoorbellRingingFlag(true);
setTimeout(() => {
self.setDoorbellRingingFlag(false);
},3000);
}else if(data.notify_type == 4){
self.setRemoteOpendoorFlag(false);
}
}
//tap 个人信息 //tap 个人信息
function myInfoTap(self){ function myInfoTap(self){
iot.navigator.openWindow({ iot.navigator.openWindow({
......
...@@ -137,8 +137,11 @@ function confirmButtonTap(self){ ...@@ -137,8 +137,11 @@ function confirmButtonTap(self){
data: { data: {
uuid: self.getUuid(), uuid: self.getUuid(),
setParams: { setParams: {
'POW': { 'action': {
'value': '20' 'value': 'openDoor'
},
'remote_open_door': {
'value': self.getTextPassword()
} }
} }
}, },
......
...@@ -51,27 +51,27 @@ ...@@ -51,27 +51,27 @@
// line-height: 1; // line-height: 1;
// .flex(); // .flex();
// } // }
&:first-child{ // &:first-child{
float: right; // float: right;
font-family: iconfont; // font-family: iconfont;
font-size: @TEXT-COMPONENT-ICON-FONTSIZE; // font-size: @TEXT-COMPONENT-ICON-FONTSIZE;
-webkit-font-smoothing: antialiased; // -webkit-font-smoothing: antialiased;
.transform(rotate(180deg)); // .transform(rotate(180deg));
} // }
&:last-child{ // &:last-child{
font-size: 12px; font-size: 12px;
float: right; float: right;
} // }
} }
} }
.editPassword{ .editPassword{
span{ span{
&:nth-child(2){ // &:nth-child(2){
font-family: iconfont; font-family: iconfont;
font-size: @TEXT-COMPONENT-ICON-FONTSIZE; font-size: @TEXT-COMPONENT-ICON-FONTSIZE;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} // }
} }
} }
} }
......
...@@ -33,10 +33,10 @@ ...@@ -33,10 +33,10 @@
</div> </div>
<div class="doorbellTip" v-bind:class="[{active: doorbellRingingFlag}]"><span>{{ ringingTime }}</span>{{ $t('device.doorLockRinging') }}</div> <div class="doorbellTip" v-bind:class="[{active: doorbellRingingFlag}]"><span>{{ ringingTime }}</span>{{ $t('device.doorLockRinging') }}</div>
</div> </div>
<p class="batteryState"><span v-html="batteryState"></span>{{ batteryPercent }}%</p> <p class="batteryState" v-show="uuid"><span v-html="batteryState"></span>{{ batteryPercent }}%</p>
</div> </div>
<div class="deviceHandle"> <div class="deviceHandle">
<p class="title">{{ $t('device.newMsgDoorlock') }}</p> <p class="title" v-if="uuid">{{ $t('device.newMsgDoorlock') }}</p>
<u-marquee ref="umarquee" :init-param="componentsConfig.marquee.initParam" :active="activeFlag"></u-marquee> <u-marquee ref="umarquee" :init-param="componentsConfig.marquee.initParam" :active="activeFlag"></u-marquee>
<div class="switchGroup"> <div class="switchGroup">
<div class="guoupRow"> <div class="guoupRow">
......
...@@ -26,13 +26,11 @@ ...@@ -26,13 +26,11 @@
<ul class="editMyInfo"> <ul class="editMyInfo">
<v-touch tag="li" class="editNickname" v-on:tap="onEditNicknameTap"> <v-touch tag="li" class="editNickname" v-on:tap="onEditNicknameTap">
{{ $t('myInfo.editNickname') }} {{ $t('myInfo.editNickname') }}
<span>{{ nickname }}</span>
<span>&#xe611;</span><span>{{ nickname }}</span>
</v-touch> </v-touch>
<v-touch tag="li" class="editPassword" v-on:tap="onEditPasswordTap"> <v-touch tag="li" class="editPassword" v-on:tap="onEditPasswordTap">
{{ $t('myInfo.editPassword') }} {{ $t('myInfo.editPassword') }}
<span>&#xe655;</span>
<span>&#xe611;</span><span>&#xe655;</span>
</v-touch> </v-touch>
</ul> </ul>
<u-loading ref="uloading" :init-param="componentsConfig.loading.initParam"></u-loading> <u-loading ref="uloading" :init-param="componentsConfig.loading.initParam"></u-loading>
......
...@@ -589,21 +589,12 @@ p { ...@@ -589,21 +589,12 @@ p {
background: linear-gradient(to right, #242635, #fff, #242635); background: linear-gradient(to right, #242635, #fff, #242635);
} }
.editMyInfo li span:first-child { .editMyInfo li span {
float: right;
font-family: iconfont;
font-size: 0.533rem;
-webkit-font-smoothing: antialiased;
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.editMyInfo li span:last-child {
font-size: 0.32rem; font-size: 0.32rem;
float: right; float: right;
} }
.editMyInfo .editPassword span:nth-child(2) { .editMyInfo .editPassword span {
font-family: iconfont; font-family: iconfont;
font-size: 0.533rem; font-size: 0.533rem;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment