Commit 2f30da06 by 朱建香

增加获取电话号码方法

parent f1b5ce2d
...@@ -192,7 +192,23 @@ uPublic.upDateRead = async function(key, time){ ...@@ -192,7 +192,23 @@ uPublic.upDateRead = async function(key, time){
} }
} }
//获取手机号码
uPublic.getPhoneNumber = function(data){
if(data.relAccounts){
let accounts = data.relAccounts;
let flag = false
for(let i=0; i<accounts.length; i++){
if(data.auid === accounts[i].auid){
return accounts[i].name;
flag = true;
}else if(flag === false){
return false;
}
}
}else{
return false;
}
}
iot.ready(() => { iot.ready(() => {
uPublic.recalc(); uPublic.recalc();
......
...@@ -195,8 +195,9 @@ function getInfo(self, lockId, relId, uuid){ ...@@ -195,8 +195,9 @@ function getInfo(self, lockId, relId, uuid){
console.log(response); console.log(response);
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
if(data){ if(data){
let name = uPublic.getPhoneNumber(data);
//云端绑定 //云端绑定
deviceBind(self, lockId, relId, data.auid); deviceBind(self, lockId, relId, data.auid, name);
// deviceBind(self, lockId, relId); // deviceBind(self, lockId, relId);
} }
}, },
...@@ -209,12 +210,13 @@ function getInfo(self, lockId, relId, uuid){ ...@@ -209,12 +210,13 @@ function getInfo(self, lockId, relId, uuid){
} }
// 云端绑定 // 云端绑定
function deviceBind(self, lockId, relId, auid){ function deviceBind(self, lockId, relId, auid, name){
iot.business.api.sendCustom('lock/bindUser',{ iot.business.api.sendCustom('lock/bindUser',{
data: { data: {
device_id: lockId, device_id: lockId,
rel_id: relId, rel_id: relId,
auid: auid, auid: auid,
name: name,
// mac: parameters.mac, // mac: parameters.mac,
nickname: '' nickname: ''
}, },
......
...@@ -362,8 +362,9 @@ function getInfo(self, deviceId, productId,uuid){ ...@@ -362,8 +362,9 @@ function getInfo(self, deviceId, productId,uuid){
console.log(response); console.log(response);
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
if(data){ if(data){
let name = uPublic.getPhoneNumber(data);
//云端绑定 //云端绑定
bind(self, deviceId, productId, data.auid); bind(self, deviceId, productId, data.auid, name);
// bind(self, deviceId, productId); // bind(self, deviceId, productId);
} }
}, },
...@@ -376,12 +377,13 @@ function getInfo(self, deviceId, productId,uuid){ ...@@ -376,12 +377,13 @@ function getInfo(self, deviceId, productId,uuid){
} }
//云端绑定 //云端绑定
function bind(self, deviceId, productId, auid){ function bind(self, deviceId, productId, auid, name){
iot.business.api.sendCustom('lock/bind',{ iot.business.api.sendCustom('lock/bind',{
data: { data: {
product_id: productId, product_id: productId,
device_id: deviceId, device_id: deviceId,
auid: auid, auid: auid,
name: name,
// mac: sn, // mac: sn,
nickname: '', nickname: '',
lockUserName: Vue.t('wifiAdd.defaultNickName') lockUserName: Vue.t('wifiAdd.defaultNickName')
......
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