Commit 80567164 by 朱建香

文件目录修改

parent 0cc3fe84
/**
* newnotify-dialog.vue
* Version: 0.1
* User: wujie
* Date: 2017-12-26
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* newnotify-dialog
*
******************************************************************************
* 依赖
通知栏插件 isNotifycationOpen toNotifycationSetting
多语言 需要配置多语言
* 支持环境
App
*
*/
<template>
<div id="app" v-cloak>
<div class="header">
<p>开启通知</p>
</div>
<div class="content">
<ul class="u-android-notify">
<li class="u-android-notify-row" v-bind:class = "setp1Active">
<span class="u-android-notify-icon">&#xe6c1;</span>
<span class="u-android-notify-finish-icon" v-show="isStep1Finish"></span>
<div class="u-android-notify-title">
{{toSettingTitle}}
<v-touch tag="div" class="u-android-notify-button" v-show="isToSetting" v-on:tap="onOpenNotify">{{toSettingsub}}
<span></span></v-touch>
</div>
</li>
<li class="u-android-notify-row" v-bind:class = "setp2Active">
<span class="u-android-notify-icon">&#xe6c0;</span>
<span class="u-android-notify-finish-icon" v-show="isStep2Finish"></span>
<div class="u-android-notify-title">
{{checkSetting}}
<v-touch tag="div" class="u-android-notify-button" v-show="isKnow" v-on:tap="onIKnow">{{IKonw}}</v-touch>
</div>
<div class="u-android-notify-tip">{{checkSettingsubTitle}}</div>
<div class="u-android-notify-subtitle">{{step1Title}}</div>
<div class="u-android-notify-subcontent">{{step1content}}</div>
<div class="u-android-notify-subtitle">{{step2Title}}</div>
<div class="u-android-notify-subcontent">{{step2content}}</div>
<div class="u-android-notify-subtitle">{{step3Title}}</div>
<div class="u-android-notify-subcontent">{{step3content}}</div>
</li>
<li class="u-android-notify-row" v-bind:class = "setp3Active">
<span class="u-android-notify-icon">&#xe6c2;</span>
<span class="u-android-notify-finish-icon" v-show="isStep3Finish"></span>
<div class="u-android-notify-title">
{{endSetting}}
<v-touch tag="div" class="u-android-notify-button" v-show="isToIndex" v-on:tap="onToIndex">{{toAppIndex}}
<span></span></v-touch>
</div>
</li>
</ul>
</div>
</div>
</template>
<script>
export default {
props: ['initParam','toIndex'],
data () {
return {
toSettingTitle:Vue.t('androidNotify.toSettingTitle'),
toSettingsub:Vue.t('androidNotify.toSettingsub'),
checkSetting:Vue.t('androidNotify.checkSetting'),
IKonw:Vue.t('androidNotify.IKonw'),
checkSettingsubTitle:Vue.t('androidNotify.checkSettingsubTitle'),
step1Title:Vue.t('androidNotify.step1Title'),
step1content:Vue.t('androidNotify.step1content'),
step2Title:Vue.t('androidNotify.step2Title'),
step2content:Vue.t('androidNotify.step2content'),
step3Title:Vue.t('androidNotify.step3Title'),
step3content:Vue.t('androidNotify.step3content'),
endSetting:Vue.t('androidNotify.endSetting'),
toAppIndex:Vue.t('androidNotify.toIndex'),
//notifyState:false, // 当前是否开启了通知
//gotoIndex:this.toIndex,// 处理点击到index按钮事件
//isKnow:iot.native.isNotifycationOpen(),//是否需要显示 我已阅读
//isToIndex:false,// 是否需要显示去首页按钮
isStep1Finish:iot.native.isNotifycationOpen(),//是否需要显示步骤1的勾
isStep2Finish:false,//是否需要显示步骤2的勾
isStep3Finish:false,//是否需要显示步骤3的勾
isToSetting:!iot.native.isNotifycationOpen(),//是否需要显示去设置按钮
setp1Active:null,
setp2Active:null,// 默认为灰色 不显示active
setp3Active:null,
notifyState:false, // 当前是否开启了通知
gotoIndex:this.toIndex,// 处理点击到index按钮事件
isKnow:iot.native.isNotifycationOpen(),//是否需要显示 我已阅读
isToIndex:false,// 是否需要显示去首页按钮
}
},
mounted: function () {
this.setp1Active=this.isStep1Finish?"active changeBorder":null;
this.setp2Active=this.isStep1Finish?"active changeBorder":null;
console.log("notifyState:"+iot.native.isNotifycationOpen());
onTest(this);
// 监听程序恢复前台
document.addEventListener("resume", ()=>{
onAppReume(this);
}, false);
},
watch: {
},
methods: {
// 点击按钮关闭弹出框
onOpenNotify(){
openNotify(this);
},
onIKnow(){
IKonw(this);
},
onToIndex(){
toIndex(this);
}
}
};
function onTest(self){
console.log(self.isStep1Finish);
console.log(self.setp2Active);
}
function openNotify(self) {
console.log("去开启");
iot.native.toNotifycationSetting("notify");
self.setp1Active = 'active changeBorder';
}
function IKonw(self){
console.log("点击了我已阅读");
self.isStep2Finish = true; // 点击阅读后显示步骤2的勾
// self.setp2Active = "active changeBorder";// 点击阅读后显示步骤2的字体亮度调高
self.setp3Active = "active";// 同时步骤3的字体亮度也调高
self.isStep3Finish = true; // 步骤3的勾勾选
self.isToIndex = true;//显示去首页按钮
self.isKnow = false; // 点击我已阅读隐藏我已阅读按钮
}
function toIndex(self){
console.log("gotoIndex...");
self.gotoIndex();
}
function onAppReume(self){
let notifyState = iot.native.isNotifycationOpen();
console.log("notifyState:"+notifyState);
if (notifyState) {
self.setp2Active = "active changeBorder";
}else{// 恢复默认
self.setp2Active = null;
self.setp3Active = null;
self.isStep2Finish = false;
self.isStep3Finish = false;
self.isToIndex = false;
}
self.isStep1Finish = iot.native.isNotifycationOpen();// 再次判断当前通知是否开启
self.isToSetting = !iot.native.isNotifycationOpen(); // 再次判断是否需要显示去设置按钮
self.isKnow = iot.native.isNotifycationOpen(),// 再次判断是否需要显示 我已阅读
self.$nextTick(function () {
console.log("重新渲染");
});
}
</script>
/**
* list.vue
* Version: 0.1
* User: shz
* Date: 2017-06-20
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* list
*/
<template>
<div class="u-list" v-bind:class="initClass">
<ul class="u-list-scroll" v-show="list.length">
<v-touch tag="li" class="u-list-row" v-for="(item, index) in list" :key="index"
v-bind:class="[item.class, {disabled: item.disabled}]" v-on:tap="onTapRow(index)">
<img class="u-list-left-image" v-if="item.leftImage" v-bind:src="item.leftImage">
<p class="u-list-left-bg-image" v-bind:class="item.imgClass" v-else-if="item.imgClass"></p>
<span class="u-list-left-icon" v-else-if="item.leftIcon" v-html="item.leftIcon"></span>
<div>
<p class="u-list-title">{{ item.title }}</p>
<p class="u-list-subtitle" v-if="item.subtitle">{{ item.subtitle }}</p>
</div>
<span class="u-list-right-text" v-if="item.rightText">{{ item.rightText }}</span>
<span class="u-list-right-icon" v-if="(item.rightIcon || item.disabled !== true)"
v-html="item.rightIcon"></span>
<img class="u-list-right-image" v-else-if="(item.rightImage || item.disabled !== true)"
v-bind:src="item.rightImage">
</v-touch>
<v-touch tag="li" class="u-list-load" v-on:tap="onTapLoad" v-show="loadShowFlag">
<span class="u-list-load-animation" v-show="loadFlag"></span>
{{ loadText }}
</v-touch>
</ul>
<p class="u-list-tip" v-show="tipShowFlag && (list.length == 0)">{{ tip }}</p>
</div>
</template>
<script>
export default {
props: ['initParam'],
data() {
return {
// 组件初始化列表
list: this.initParam.list || [],
// 组件初始化样式
initClass: this.initParam.class,
// 组件初始化无数据显示文字
tip: this.initParam.tip,
pagesize: this.initParam.pagesize,
pullup: this.initParam.pullup || false,
loadText: Vue.t('scroll.clickToLoadMore'),
// loading是否显示
loadShowFlag: false,
// 是否在loading
loadFlag: false,
tipShowFlag: false
}
},
mounted() {
this.setLoadShowFlag(this.list.length);
let ulistDom = this.$el;
let self = this;
ulistDom.onscroll = function () {
//在一些特殊情况下ulistDom.scrollHeight和ulistDom.offsetHeight + ulistDom.scrollTop会相差1px,这里考虑1px的误差
if (!self.loadFlag && self.pullup && (ulistDom.scrollHeight - (ulistDom.offsetHeight + ulistDom.scrollTop)) <= 1) {
self.loadText = Vue.t('scroll.loading');
self.loadFlag = true;
self.$emit('u-list-load');
}
}
},
methods: {
setLoadShowFlag(number) {
this.loadShowFlag = (number >= this.pagesize);
},
onTapRow(index) {
tapRow(this, index);
},
onTapLoad() {
tapLoad(this);
},
changeList(list) {
changeList(this, list);
}
}
}
// 通知事件和当前点击列表选项下标
function tapRow(self, index) {
if (self.list[index].disabled !== true) {
self.$emit('u-list-tap', index);
}
}
// 通知点击加载更多事件
function tapLoad(self) {
// loading
if (!self.loadFlag && !self.pullup) {
self.$emit('u-list-load');
self.loadText = Vue.t('scroll.loading');
self.loadFlag = true;
}
}
// 修改list组件列表
function changeList(self, list) {
let array = Array.isArray(list) ? list : [];
self.tipShowFlag = (array.length === 0);
self.setLoadShowFlag(array.length - self.list.length);
self.list = array;
self.$nextTick(function () {
self.loadText = Vue.t('scroll.clickToLoadMore');
self.loadFlag = false;
});
}
</script>
\ No newline at end of file
/**
* v_alarmInfo.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 报警信息页面
*/
const PAGE_SIZE = 10;
import moment from 'moment';
import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js';
import projectMethods from '../../public/components.js';
iot.ready(init);
function init() {
//通用 list、dialog、loading组件
uPublic.componentsInit(['u-list','u-dialog','u-loading']);
uPublic.componentsExtend(['list']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
componentsConfig: initComponentsConfig(),
list:[],
startId: 0,
deviceId: null,
flag: true,
noticeTipShowFlag: false
},
mounted(){
uComponents.showLoading(this);
this.noticeTipShowFlag = !iot.native.isNotifycationOpen();
resolve(this);
window.addEventListener('returnPage',() => {
this.noticeTipShowFlag = !iot.native.isNotifycationOpen();
});
},
methods:{
getList(){
return this.list;
},
setList(list){
this.list = list;
},
getStartId(){
return this.startId;
},
setStartId(id){
this.startId = id;
},
getDeviceId(){
return this.deviceId;
},
setDeviceId(id){
this.deviceId = id;
},
//tap 点击加载更多
onListLoad(){
listLoad(this);
},
onRefreshFresh(){
refreshFresh(this);
},
onNotifycationSetting(){
notifycationSetting();
},
//tap <
onBackTap(){
backTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
alarmInfoList:{
initParam: {
class: 'custom-list',
list: [],
tip: Vue.t('alarmInfo.noInfoTip'),
pagesize: PAGE_SIZE,
pullup: true
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
// 获取历史记录
function resolve(self) {
self.setDeviceId(iot.navigator.getExtras().deviceId);
// uComponents.showLoading(self);
iot.business.api.sendCustom('lock/getHistoryRecord',
{
data: {
device_id: self.getDeviceId(),
action: 2,
start_id: self.getStartId(),
page_size: PAGE_SIZE,
pullUpLoading: true
},
success: async (response) => {
console.log(response);
if(self.flag){
let data = uPublic.checkResponseData(response.data);
if(data && data.record.length > 0){
let record = data.record;
self.flag = await uPublic.upDateRead('notify', moment(record[0].time).unix());
}
}
let data = uPublic.checkResponseData(response.data);
if(data){
let list = [];
let record = data.record;
for(let i=0; i<record.length; i++){
list[i] = {
value: record[i].openId,
// leftImage: '../../resources/image/green_alarmInfo'+record[i].mode+'_icon.png',
imgClass: 'u-list-left-bg-alarm_'+record[i].mode,
subtitle: Vue.t('alarmInfo.'+config.alarmMode[record[i].mode]+''),
rightText: moment(record[i].time).format("YYYY.MM.DD HH:mm:ss")
};
}
self.setList(self.getList().concat(list));
if(record.length > 0){
self.setStartId(record[record.length-1].id);
}
//更新列表数据
projectMethods.changeList(self, self.getList());
}else{
}
uComponents.hideLoading(self);
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
//tap <
function backTap(){
iot.navigator.aback();
}
//重写mui.back
//mui.back = function(){
// iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
// console.log("fire");
// iot.navigator.back();
//}
//tap 点击加载更多
function listLoad(self) {
resolve(self);
}
//ios跳转到系统设置页面
//android跳转到通知页面
function notifycationSetting(){
if(plus.os.name == 'Android'){
// alert("打开通知页面");
iot.navigator.openWindow({
url: './notify.html',
id: 'notify',
styles: {
popGesture: 'none'
}
});
}else{
iot.native.toNotifycationSetting();
}
}
/**
* v_hijackRecord.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 劫持记录页面
*/
import moment from 'moment';
const PAGE_SIZE = 10;
import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js';
import projectMethods from '../../public/components.js';
iot.ready(init);
function init() {
//通用 list、dialog、loading组件
uPublic.componentsInit(['u-list','u-dialog','u-loading']);
uPublic.componentsExtend(['list']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
componentsConfig: initComponentsConfig(),
list: [],
startId: 0,
deviceId: null,
userInfo: [],
flag: true,
noticeTipShowFlag: false
},
mounted(){
uComponents.showLoading(this);
this.noticeTipShowFlag = !iot.native.isNotifycationOpen();
resolve(this);
window.addEventListener('returnPage',() => {
this.noticeTipShowFlag = !iot.native.isNotifycationOpen();
});
},
methods:{
getList(){
return this.list;
},
setList(list){
this.list = list;
},
getStartId(){
return this.startId;
},
setStartId(id){
this.startId = id;
},
getDeviceId(){
return this.deviceId;
},
setDeviceId(id){
this.deviceId = id;
},
getUserInfo(){
return this.userInfo;
},
setUserInfo(info){
this.userInfo = info;
},
onListLoad(){
listLoad(this);
},
onRefreshFresh(){
refreshFresh(this);
},
onNotifycationSetting(){
notifycationSetting();
},
//tap <
onBackTap(){
backTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
hijackRecordList:{
initParam: {
class: 'custom-list',
list: [],
tip: Vue.t('hijackRecord.noRecordTip'),
pagesize: PAGE_SIZE,
pullup: true
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
function resolve(self) {
self.setDeviceId(iot.navigator.getExtras().deviceId);
//
iot.business.api.sendCustom('lock/getHistoryRecord',
{
data: {
device_id: self.getDeviceId(),
action: 3,
start_id: self.getStartId(),
page_size: PAGE_SIZE
},
success: async (response) => {
if(self.flag){
let data = uPublic.checkResponseData(response.data);
if(data && data.record.length > 0){
let record = data.record;
self.flag = await uPublic.upDateRead('alarm', moment(record[0].time).unix());
}
}
let data = uPublic.checkResponseData(response.data);
if(data){
console.log(data);
let list = [];
let record = data.record;
if(data.hasOwnProperty('info')){
self.setUserInfo(data.info);
}
console.log(config.hijackMode[20]);
for(let i=0; i<record.length; i++){
list[i] = {
value: record[i].openId,
title: "ID:"+record[i].openId,
// leftImage: '../../resources/image/green_hijackMode20_icon.png',
imgClass: 'u-list-left-bg-hijack',
subtitle: Vue.t('hijackRecord.'+config.hijackMode[record[i].mode]+''),
// title: ('ID:'+record[i].id),
rightText: moment(record[i].time).format("YYYY.MM.DD HH:mm:ss")
};
for(let j=0; j<self.getUserInfo().length; j++){
if(record[i].openId == self.getUserInfo()[j].openId && record[i].mode == self.getUserInfo()[j].mode){
if(self.getUserInfo()[j].nickname != null){
list[i].title = self.getUserInfo()[j].nickname;
}
}
}
}
self.setList(self.getList().concat(list));
if(record.length > 0){
self.setStartId(record[record.length-1].id);
}
//更新列表数据
projectMethods.changeList(self, self.getList());
}else{
}
uComponents.hideLoading(self);
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
//tap <
function backTap(){
iot.navigator.aback();
}
//重写mui.back
//mui.back = function(){
// iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
// console.log("fire");
// iot.navigator.back();
//}
//tap 点击加载更多
function listLoad(self) {
resolve(self);
}
function refreshFresh(self){
resolve(self);
}
//ios跳转到系统设置页面
//android跳转到通知页面
function notifycationSetting(){
if(plus.os.name == 'Android'){
// alert("打开通知页面");
iot.navigator.openWindow({
url: './notify.html',
id: 'notify',
styles: {
popGesture: 'none'
}
});
}else{
iot.native.toNotifycationSetting();
}
}
import {iot, uPublic, uComponents} from '../../public/public.js';
import config from '../../public/public.js';
iot.ready(init);
function init() {
uPublic.componentsExtend(['android-notify']);
var form = new Vue({
el: '#content',
data:{
initButtonText: "测试按钮",
componentsConfig: initComponentsConfig(),//初始化数据
dialogFlag:true,
showFlags:false,
onNotifyToIndex:notifyToIndex //改方法传入
},
mounted:function(){
},
methods: {
onTapButton(){
tapButton(this);
},
onAddDeviceButtonTap(){
console.log("onAddDeviceButtonTap......");
},
onToSetting(){
console.log("点击了toSetting");
}
}
});
function notifyToIndex(){
iot.navigator.fire(plus.webview.getWebviewById('device'),'returnPage',{
needClose: true
});
iot.navigator.openWindow({
url: './index.html',
id: 'device',
styles: {
popGesture: 'none'
},
extras: {
needClose: true
}
});
}
function tapButton(self){
console.log("tapButton.......");
}
//初始化组件参数
function initComponentsConfig() {
return {
// 设置通知弹出框参数
notifyDialog: {
// 默认参数
initParam: {
// appName:"js.通用门锁",
// time:"js.刚刚",
// title:'js.开启通知',
// content1:'js.开启通知后您将可以及时获取门锁报警',
// content2:'js.提醒、门锁开门消息通知',
// accept:'js.我知道了!',
// buttonTitle:'js.前往开启通知设置'
}
},
addDeviceButton:{
// 默认参数
initParam: {
class: 'edit-name-button',
text: "这是测试button"
}
}
};
}
}
//重写mui.back
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
}
/**
* v_opendoorRecord.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 开门记录页面
*/
import moment from 'moment';
const PAGE_SIZE = 10;
import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js';
import projectMethods from '../../public/components.js';
iot.ready(init);
function init() {
//通用 list、dialog、loading组件
uPublic.componentsInit(['u-list','u-dialog','u-loading']);
uPublic.componentsExtend(['list']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
componentsConfig: initComponentsConfig(),
list: [],
startId: 0,
deviceId: null,
userInfo: [],
flag: true,
noticeTipShowFlag: false
},
mounted(){
uComponents.showLoading(this);
this.noticeTipShowFlag = !iot.native.isNotifycationOpen();
resolve(this);
window.addEventListener('returnPage',() => {
this.noticeTipShowFlag = !iot.native.isNotifycationOpen();
});
},
methods:{
getList(){
return this.list;
},
setList(list){
this.list = list;
},
getStartId(){
return this.startId;
},
setStartId(id){
this.startId = id;
},
getDeviceId(){
return this.deviceId;
},
getUserInfo(){
return this.userInfo;
},
setUserInfo(info){
this.userInfo = info;
},
setDeviceId(id){
this.deviceId = id;
},
onListLoad(){
listLoad(this);
},
onRefreshFresh(){
refreshFresh(this);
},
onNotifycationSetting(){
notifycationSetting();
},
//tap <
onBackTap(){
backTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
opendoorRecordList:{
initParam: {
class: 'custom-list',
list: [],
tip: Vue.t('opendoorRecord.noRecordTip'),
pagesize: PAGE_SIZE,
pullup: true
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
//调用接口获取开门记录
function resolve(self) {
console.log("in");
// uComponents.showLoading(self);
self.setDeviceId(iot.navigator.getExtras().deviceId);
console.log(iot.navigator.getExtras());
if(iot.navigator.getExtras().relId){
getPersonalHistory(self, iot.navigator.getExtras().relId);
}else{
getHistoryRecord(self);
}
}
//tap <
function backTap(){
iot.navigator.aback();
}
//重写mui.back
//mui.back = function(){
// iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
// console.log("fire");
// iot.navigator.back();
//}
//tap 点击加载更多
function listLoad(self) {
resolve(self);
}
//获取历史记录(整个设备)
function getHistoryRecord(self){
iot.business.api.sendCustom('lock/getHistoryRecord',
{
data: {
device_id: self.getDeviceId(),
action: 0,
start_id: self.getStartId(),
page_size: PAGE_SIZE
},
success: async (response) => {
setListData(self, response);
if(self.flag){
let data = uPublic.checkResponseData(response.data);
if(data && data.record.length > 0){
let record = data.record;
self.flag = await uPublic.upDateRead('open', moment(record[0].time).unix());
}
}
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
//获取个人历史记录
function getPersonalHistory(self, id){
iot.business.api.sendCustom('lock/getPersonalHistory',
{
data: {
device_id: self.getDeviceId(),
rel_id: id,
action: 0,
start_id: self.getStartId(),
page_size: PAGE_SIZE
},
success: (response) => {
setListData(self, response);
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
//设置历史记录渲染列表
function setListData(self, response){
let data = uPublic.checkResponseData(response.data);
if(data){
console.log(data);
let list = [];
let record = data.record;
if(data.hasOwnProperty('info')){
self.setUserInfo(data.info);
}
for(let i=0; i<record.length; i++){
list[i] = {
value: record[i].openId,
title: ((record[i].mode == 30 ) || (record[i].mode == 5 )) ? '':"ID:"+record[i].openId,
// leftImage: '../../resources/image/green_opendoor'+record[i].mode+'_icon.png',
class: 'u-list-left-bg-image_'+record[i].mode,
subtitle: Vue.t('opendoorRecord.'+config.openDoorMode[record[i].mode]+''),
rightText: moment(record[i].time).format("YYYY.MM.DD HH:mm:ss")
};
for(let j=0; j<self.getUserInfo().length; j++){
if(record[i].openId == self.getUserInfo()[j].openId && record[i].mode == self.getUserInfo()[j].mode){
if(self.getUserInfo()[j].nickname != null){
list[i].title = self.getUserInfo()[j].nickname;
}
}
}
}
self.setList(self.getList().concat(list));
if(record.length > 0){
self.setStartId(record[record.length-1].id);
}
//更新列表数据
projectMethods.changeList(self, self.getList());
console.log("in");
}else{
}
}
//ios跳转到系统设置页面
//android跳转到通知页面
function notifycationSetting(){
if(plus.os.name == 'Android'){
iot.navigator.openWindow({
url: './notify.html',
id: 'notify',
styles: {
popGesture: 'none'
}
});
}else{
iot.native.toNotifycationSetting();
}
}
/**
* v_remoteOpendoor.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 远程开门页面
*/
import CryptoJS from "crypto-js";
import {iot, uPublic, uComponents} from '../../public/public.js';
import crypto from '../../public/crypto.js';
iot.ready(init);
function init() {
//通用 input、按钮、dialog、loading组件
uPublic.componentsInit(['u-text','u-button','u-comm-loading','u-dialog','u-loading']);
const app = new Vue({
data:{
textPassword: null,
textErrorTip: null,
textLoading: 'loading...',
status: 0,
//配置组件
componentsConfig: initComponentsConfig(),
//设备uuid
uuid: null,
deviceId: null
},
mounted(){
resolve(this);
let a = {"mac":"B0F89310DDF2","productId":"10002","productSecret":"WABK8XXEEKKLL5MM"};
},
methods:{
getTextPassword(){
return this.textPassword;
},
setTextPassword(pwd){
this.textPassword = pwd;
},
setTextErrorTip(tip){
this.textErrorTip = tip;
},
getTextLoading(){
return this.textLoading;
},
setTextLoading(text){
this.textLoading = text;
},
getStatus(){
return this.status;
},
setStatus(value){
this.status = value;
},
onPasswordChange(text){
passwordChange(this,text);
},
onPasswordChange(text){
passwordChange(this,text);
},
getUuid(){
return this.uuid;
},
setUuid(id){
this.uuid = id;
},
getDeviceId(){
return this.deviceId;
},
setDeviceId(id){
this.deviceId = id;
},
//tap <
onBackTap(){
backTap();
},
//tap 确定
onConfirmButtonTap(){
confirmButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
passwordInput: {
initParam: {
class: 'custom-text',
icon: '&#xe64d;',
placeholder: Vue.t('remoteOpendoor.passwordInputTip')
}
},
//确定 button 参数
confirmButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.confirm')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
},
ucommstatusloading: {
initParam: {
class: 'custom-commstatus-loading',
buttonText: Vue.t('btn.confirm')
}
}
}
}
function resolve(self){
let extras = iot.navigator.getExtras();
self.setUuid(extras.uuid);
self.setDeviceId(extras.mac);
console.log(self.getUuid());
}
function passwordChange(self,text){
self.setTextPassword(text);
self.setTextErrorTip('');
console.log('passwordChange: ' + self.textPassword);
}
//tap <
function backTap(){
iot.navigator.back();
}
//tap 确定
function confirmButtonTap(self){
console.log(self.getTextPassword());
if(self.getTextPassword() == null || self.getTextPassword().trim() == ''){
self.setTextErrorTip(Vue.t('remoteOpendoor.error.noPasswordTip'));
}else{
uComponents.showLoading(self);
console.log(self.getDeviceId());
let keyIv = crypto.enkey(self.getDeviceId().replace(/:/g,''));
console.log(keyIv);
let pwd = crypto.encode(self.getTextPassword(), keyIv);
console.log(pwd);
let msg = crypto.decode(pwd, keyIv);
console.log(msg);
iot.business.sds.setDeviceStatus({
data: {
uuid: self.getUuid(),
setParams: {
'action': {
'value': 'openDoor'
},
'remote_open_door': {
// 'value': pwd
'value': self.getTextPassword()
}
}
},
success: (response) => {
console.log(response);
uComponents.openAlert(self, Vue.t('remoteOpendoor.openDoorSuccess'), {
text: Vue.t('dialog.confirm'), callback: function () {
//返回首页
// iot.navigator.back();
iot.navigator.openWindow({
url: 'index.html',
id: 'device',
});
}
});
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 远程开门失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'远程开门失败');
// }
uComponents.openAlert(self, Vue.t('remoteOpendoor.openDoorFailure'), {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
},
complete(){
uComponents.hideLoading(self);
}
});
}
}
/**
* v_addUser.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 添加用户页面
*/
import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js';
iot.ready(init);
function init() {
//通用 input、按钮、dialog、loading组件
uPublic.componentsInit(['u-text','u-button','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
textName: null,
textErrorTip: '',
//配置组件
componentsConfig: initComponentsConfig(),
extras: {}
},
mounted(){
this.extras = iot.navigator.getExtras();
console.log(this.extras);
},
methods:{
getTextName(){
return this.textName;
},
setTextName(text){
this.textName = text;
},
getTextErrorTip(){
return this.textErrorTip;
},
setTextErrorTip(tip){
this.textErrorTip = tip
},
//tap <
onBackTap(){
backTap();
},
onNameChange(text){
nameChange(this,text);
},
//tap 确定
onConfirmButtonTap(){
confirmButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
nameInput: {
initParam: {
class: 'custom-text',
icon: '&#xe6b0;',
placeholder: Vue.t('addUser.nameInputTip'),
maxlength: config.input.maxlength
}
},
//确定 button 参数
confirmButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.confirm')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
//tap <
function backTap() {
iot.navigator.aback();
}
function nameChange(self,text){
self.textName = text;
self.setTextErrorTip('');
console.log('nameChange: ' + self.textName);
}
//tap 确定
function confirmButtonTap(self){
if(self.getTextName() == null || self.getTextName().trim() == ''){
self.setTextErrorTip(Vue.t('addUser.error.nameCanNotEmpty'));
}else if(uPublic.checkString(self.getTextName())){
self.setTextErrorTip(Vue.t('textTip.textType'));
}else if(self.getTextErrorTip() == ''){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/addLockUser',{
data: {
device_id: self.extras.deviceId,
nickname: self.getTextName()
},
success: (response) => {
console.log(response);
if(response.data.id){
iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
uComponents.openAlert(self, Vue.t('addUser.addUserSuccess'), {
text: Vue.t('btn.confirm'), callback: function () {
console.log("添加用户成功");
//跳转到门锁用户界面
iot.navigator.openWindow({
url: './doorlockUser.html',
id: 'doorlockUser',
extras: {
id: response.data.id,
lockId: self.extras.lockId,
uuid: self.extras.uuid,
role: self.extras.role
}
});
}
});
}
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 添加用户成功'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'添加用户失败');
// }
uComponents.openAlert(self, Vue.t('addUser.addUserFailure'), {
text: Vue.t('btn.confirm'), callback: function () {
console.log("添加用户失败");
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
}
/**
* v_editName.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 修改名称页面
*/
import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js';
iot.ready(init);
function init() {
//通用 input、dialog、loading组件
uPublic.componentsInit(['u-text','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
textName: iot.navigator.getExtras().nickname,
textErrorTip: '',
//配置组件
componentsConfig: initComponentsConfig(),
extras: {},
role: null
},
mounted(){
this.extras = iot.navigator.getExtras();
this.role = this.extras.role;
},
methods:{
getTextName(){
return this.textName;
},
setTextName(text){
this.textName = text;
},
getTextErrorTip(){
return this.textErrorTip;
},
setTextErrorTip(tip){
this.textErrorTip = tip;
},
//tap <
onBackTap(){
backTap();
},
//tap 保存
onSaveTap(){
saveTap(this);
},
onNameChange(text){
nameChange(this,text);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
nameInput: {
initParam: {
class: 'custom-editName-text',
placeholder: Vue.t('editName.nickNameInputTip'),
maxlength: config.input.maxlength
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
//tap <
function backTap(){
iot.navigator.aback();
}
//tap 保存
function saveTap(self){
if(self.getTextName() == null || self.getTextName().trim() == ''){
self.setTextErrorTip(Vue.t('editName.error.nicknameCanNotBeBlank'));
}else if(uPublic.checkString(self.getTextName())){
self.setTextErrorTip(Vue.t('textTip.textType'));
}else if(self.getTextErrorTip() == ''){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/setLockUserName',{
data: {
rel_id: self.extras.id,
nickname: self.getTextName(),
device_id: self.extras.deviceId
},
success: (response) => {
console.log(response);
if(response.data.success){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
uComponents.openAlert(self, Vue.t('editName.editNameSuccess'), {
text: Vue.t('btn.confirm'), callback: function () {
let opener = plus.webview.currentWebview().opener();
let view = plus.webview.getWebviewById(opener.id);
console.log(view);
iot.navigator.aback();
}
});
}
// let data = uPublic.checkResponseData(response.data);
// if(data){
// uComponents.openAlert(self, Vue.t('editName.nicknameCanNotBeBlank'), {
// text: Vue.t('btn.confirm'), callback: function () {
// let opener = plus.webview.currentWebview().opener();
// let view = plus.webview.getWebviewById(opener.id);
// console.log(view);
// iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
// console.log('returnPage');
// iot.navigator.back();
// }
// });
// }
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 修改用户名称失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'修改用户名称失败');
// }
uComponents.openAlert(self, Vue.t('editName.editNameFailue'), {
text: Vue.t('btn.confirm'), callback: function () {
let opener = plus.webview.currentWebview().opener();
iot.navigator.back();
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
}
function nameChange(self,text){
self.textName = text;
self.setTextErrorTip('');
console.log('nameChange: ' + self.textName);
}
\ No newline at end of file
/**
* v_index.js
* Version: 0.1
* User: zjx
* Date: 2017-09-29
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 门锁用户
*/
import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js';
iot.ready(init);
function init() {
//通用 图片轮播、跑马灯、开关、按钮、dialog、loading组件
uPublic.componentsInit(['u-swipe-list','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
componentsConfig: initComponentsConfig(),
//用户列表
userList: [],
userListIndex: null,
loadShowFlag: false,
loadFlag: false,
loadText: '',
pagesize: 10,
tip: '无数据',
extras: {},
userListData: [],
startId: 0,
role: null,
//当前用户id
currentId: null
},
mounted(){
this.extras = iot.navigator.getExtras();
//获取用户列表
this.role = this.extras.role;
getUserList(this);
let self = this;
window.addEventListener('returnPage',function(event){
console.log("returnPage");
self.setUserList([]);
getUserList(self);
});
},
methods:{
getUserList(){
return this.userList;
},
setUserList(list){
this.userList = list;
},
onBackTap(){
backTap();
},
onAddUserTap(){
addUserTap(this);
},
setLoadShowFlag(number){
this.loadShowFlag = (number >= this.pagesize);
},
getUserListData(){
return this.userListData;
},
setUserListData(data){
this.userListData = data;
},
getStartId(){
return this.startId;
},
setStartId(id){
this.startId = id;
},
getRole(){
return this.role;
},
setRole(role){
this.role = role;
},
onTapLoad(){
// tapLoad();
},
onTapUserList(index){
onTapUserList(this, index);
},
onTapButton(index){
tapButton(this, index);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
//获取用户列表
function getUserList(self){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/getLockUser',{
data: {
device_id: self.extras.deviceId
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
console.log(data);
if(data){
sortUsers(self,data);
}
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
function sortRule(a,b){
return a.role - b.role;
}
function getUserInfoMap() {
return new Promise(function (resolve, reject) {
iot.business.websql.getMap('userinfo', (res) => {
if (res) {
resolve(res.id);
} else {
reject(res);
}
}, (err) => {
console.log(err);
});
})
}
async function sortUsers(self, data){
try {
self.currentId = await getUserInfoMap();
}
catch (err) {
console.log(err);
}
let users = [];
let manage = [];
for(let i=0;i<data.length;i++){
if(data[i].user_id == null ||data[i].role && data[i].user_id != self.currentId){
users.push(data[i]);
}else{
manage.push(data[i]);
}
}
manage = manage.sort(sortRule);
console.log(manage);
data = manage.concat(users);
setUserData(self, data);
}
function setUserData(self, data){
let list = [];
for(let i = 0; i < data.length ; i++){
list[i] = {
value: data[i].id,
role: data[i].role,
imgClass: data[i].role == 0 ? 'user-list-image-admin' : data[i].user_id == null ? 'user-list-image-unbind' : 'user-list-image-bind',
title: data[i].nickname,
subtitle: data[i].user_id ? Vue.t('userList.binded'):Vue.t('userList.unbind')
}
}
console.log(data);
self.setUserListData(data);
self.setUserList(list);
}
//返回上一页
function backTap(){
iot.navigator.aback();
}
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
}
//添加用户
function addUserTap(self){
iot.navigator.openWindow({
url: '../doorlockUsers/addUser.html',
id: 'addUser',
extras: {
deviceId: self.getUserListData()[0].device_id,
uuid: self.extras.uuid,
lockId: self.extras.lockId,
role: self.extras.role
}
});
}
// 点击组件列表 通知事件和当前点击列表下标
function onTapUserList(self, listIndex) {
iot.navigator.openWindow({
url: './doorlockUser.html',
id: 'doorlockUser',
extras: {
id: self.getUserListData()[listIndex].id,
uuid: self.extras.uuid,
userId: self.getUserListData()[listIndex].user_id,
lockId: self.extras.lockId,
role: self.extras.role
}
});
if (self.userListIndex != null) {
self.userListIndex = null;
}
}
//点击按钮
function tapButton(self, index){
console.log(index);
//tap 删除该用户
uComponents.openConfirm(self, Vue.t('doorlockUser.deleteUserDialogTip'),
{text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.delete'), callback: function () {
deleteUser(self, index);
}}
);
}
//删除用户
function deleteUser(self, index){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/delLockUser',{
data: {
rel_id: self.getUserListData()[index].id,
user_id: self.getUserListData()[index].user_id,
device_sn: self.getUserListData()[index].device_id,
device_id: self.extras.lockId
},
success: (response) => {
console.log(response);
if(response.data.success){
uComponents.openAlert(self, Vue.t('doorlockUser.deleteSuccess'), {
text: Vue.t('btn.confirm'), callback: function () {
self.setUserList([]);
getUserList(self);
}
});
}
},
error: (error) => {
console.log(error);
uComponents.openAlert(self, Vue.t('doorlockUser.deleteFailure'), {
text: Vue.t('btn.confirm'), callback: function () {
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
\ No newline at end of file
/**
* v_inviteBind.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 邀请绑定页面
*/
let QRCode = require('qrcode');
import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js';
iot.ready(init);
function init() {
//通用 按钮、dialog、loading组件
uPublic.componentsInit(['u-button','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
componentsConfig: initComponentsConfig(),
extras: [],
uuid: null,
qrCodeDisabled: false
},
mounted(){
this.extras = iot.navigator.getExtras();
console.log(this.extras);
this.setUuid(this.extras.uuid);
qrcodeButtonTap(this);
},
methods:{
getUuid(){
return this.uuid;
},
setUuid(id){
this.uuid = id;
},
setQrCodeDisabled(boolean){
this.qrCodeDisabled = boolean;
},
//tap <
onBackTap(){
backTap();
},
//tap 重新生成二维码
onQRcodeButtonTap(){
qrcodeButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
//重新生成二维码 button 参数
qrcodeButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.qrcodeReset')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
//tap <
function backTap(){
iot.navigator.aback();
}
//tap 重新生成二维码
function qrcodeButtonTap(self){
self.setQrCodeDisabled(false);
uComponents.showLoading(self);
iot.business.sds.saveqr({
data: {
uuid: self.getUuid()
},
success: (response) => {
let data = uPublic.checkResponseData(response.data);
if(data){
let qrKey = response.data.qrKey;
createQrcode(self, qrKey);
}else{}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 生成二维码失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'生成二维码失败');
}
//请求失败
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
setTimeout(() => {
self.setQrCodeDisabled(true);
},config.qrcode_timeout)
}
function createQrcode(self, qrKey){
let data = {
qrKey: qrKey,
lockId: self.extras.lockId,
relId: self.extras.id
}
data = JSON.stringify(data);
let qr = self.$refs.qrcode;
QRCode.toCanvas(qr, data, {
scale: 5,
margin: 2
},(error) => {
if (error) {
console.log(error);
} else {
console.log('success');
qr.style.width = "4.267rem";
qr.style.height = "4.267rem";
console.log(qr.style);
setTimeout(() => {
self.setQrCodeDisabled(true);
},config.qrcode_timeout);
}
});
}
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