Commit 08be9745 by 朱建香

1.1

parent 29132d8d
{
"presets": ["es2015"],
plugins: [
["transform-regenerator"],
["transform-object-assign"],
['transform-runtime', {
helpers: false,
polyfill: false,
regenerator: true}
]
]
}
\ No newline at end of file
dev/node_modules
node_modules
custom/custom01/dev/node_modules
web/lib/js/p.js
......@@ -15,3 +17,16 @@ web/view/*/*.map
web/view/*/*.js
web/custom/*/lib/js/p.js
web/custom/*/lib/js/p.js.map
web/custom/*/lib/dist
web/custom/*/view/*.map
web/custom/*/view/*.js
web/custom/*/view/*/*.map
web/custom/*/view/*/*.js
\ No newline at end of file
......@@ -24,5 +24,41 @@
<arguments>1.0-name-matches-false-false-node_modules</arguments>
</matcher>
</filter>
<filter>
<id>1514974720847</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-node_modules</arguments>
</matcher>
</filter>
<filter>
<id>1520415145697</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-node_modules</arguments>
</matcher>
</filter>
<filter>
<id>1520833945791</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-node_modules</arguments>
</matcher>
</filter>
<filter>
<id>1521178960995</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-node_modules</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
{
"presets": ["es2015"],
plugins: [
["transform-regenerator"],
["transform-object-assign"],
['transform-runtime', {
helpers: false,
polyfill: false,
regenerator: true}
]
]
}
\ No newline at end of file
const path = require('path');
const srcPath = path.join(__dirname,"..","src");
const outputPath = "../resources/lang/";
module.exports = {
lang:["zh","en"],
group:srcPath,
output:outputPath
};
\ No newline at end of file
const path = require('path');
const fs = require('fs');
const config = require('../config/lang');
const srcPath = path.join(__dirname,"..","src");
const langPath = path.join(srcPath,"lang");
const componentPath = path.join(srcPath,"lang","component");
let allFilePath = [];
function getAllLang(...dirs){
let langGroup = {};
for(let dir of dirs){
if(fs.existsSync(dir)){
for(let lang of config.lang){
let lPath = path.join(dir,"/",`${lang}.json`);
if(fs.existsSync(lPath)){
let arr;
if(langGroup[lang]!=null){
arr = langGroup[lang];
}else{
arr = new Array();
}
arr.push(lPath);
langGroup[lang] = arr;
allFilePath.push(lPath);
}
}
}
}
return langGroup;
}
let langGroup;
const watch = require('watch');
class I18NPackage{
constructor(options){
this.options = options;
this.watching = false;
}
apply(compiler){
langGroup = getAllLang(langPath,componentPath);
compiler.plugin("watch-run", (compilation, callback) => {
if(!this.watching){
this.watching = true;
langGroup = getAllLang(langPath,componentPath);
const onChange = () => {
langGroup = getAllLang(langPath,componentPath);
compiler.run((err) => {
if(err) {
throw err;
}
});
};
watch.createMonitor(srcPath, (monitor) => {
monitor.files[path.join(srcPath,".json")];
monitor.on("created", onChange);
monitor.on("changed", onChange);
monitor.on("removed", onChange);
callback();
});
}
});
compiler.plugin('emit', function(compilation, callback) {
let createFileName = [];
try{
for(let key of Object.keys(langGroup)){
let path = langGroup[key];
let obj = {};
for(let filePath of path){
obj = Object.assign(obj,JSON.parse(fs.readFileSync(filePath, 'utf8')));
}
let filelist = JSON.stringify(obj);
// Insert this list into the Webpack build as a new file asset:
let fileName = `../resources/lang/${key}.json`;
compilation.assets[fileName] = {
source: function() {
return filelist;
},
size: function() {
return filelist.length;
}
};
createFileName.push(fileName);
}
}catch(err){
console.log(err)
}
console.log("lang file merge success.")
for(let file of createFileName){
console.log(file)
}
callback();
});
}
}
module.exports = I18NPackage;
\ No newline at end of file
var webpack = require('webpack');
var path = require('path');
const vendors = [
'whatwg-fetch',
'es6-promise',
'vue',
'vuex'
];
let libsDir = path.join(__dirname,"libs");
module.exports = {
output: {
path: libsDir,
filename: '[name].[chunkhash].js',
library: '[name]_[chunkhash]',
},
entry: {
vendor: vendors,
},
plugins: [
new webpack.DllPlugin({
path: path.join(libsDir,"manifest.json"),
name: '[name]_[chunkhash]',
context: __dirname,
}),
],
};
{
"name": "vue-webpack",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"dependencies": {
"es6-promise": "4.1.0",
"es6-symbol": "3.1.1",
"hammerjs": "2.0.8",
"iscroll": "5.2.0",
"moment": "^2.18.1",
"qrcode": "^0.9.0",
"ugen-components": "^0.3.1",
"underscore": "1.8.3",
"vue": "2.2.6",
"vue-i18n": "5.0.3",
"vue-router": "2.1.1",
"vue-touch": "2.0.0-beta.4",
"vuex": "2.3.1"
},
"devDependencies": {
"babel-core": "6.24.1",
"babel-loader": "6.4.1",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-object-assign": "6.22.0",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-es2015": "6.24.1",
"crypto-js": "^3.1.9-1",
"css-loader": "0.28.0",
"es6-promise": "4.1.0",
"md5": "^2.2.1",
"style-loader": "0.16.1",
"vue-loader": "11.3.4",
"vue-template-compiler": "2.2.6",
"watch": "1.0.2",
"webpack": "2.3.3"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
class Barcode{
constructor() {
}
startQr(id,keyArrays,success,error){
console.log("开始扫描....");
this.scan = iot.navigator.barcode(id);
console.log(this.scan);
this.scan.start();
this.scan.onmarked = (type, result)=>{
if(result) {
let typeJson = this.formatUrlToJson(result);
let type = typeJson["type"];
let bool = this.isInArray(keyArrays,type);
if (bool) {
success(type);
}else{
error("当前扫描的二维码不和规范");
}
}
};
}
isInArray(arr,value){
for(var i = 0; i < arr.length; i++){
if(value === arr[i]){
return true;
}
}
return false;
}
formatUrlToJson(str){
console.log("测试字符串截取功能");
let index = str.indexOf("?");
let subStr = str.substr(index+1,str.length);
let subIndex = subStr.indexOf("=");
let keyStr = subStr.substr(0,subIndex);
console.log(keyStr);
let value = subStr.substr(subIndex+1,subStr.length);
let json = {};
json[keyStr] = value;
// alert(JSON.stringify(json));
return json;
}
}
export default new Barcode();
\ No newline at end of file
let projectMethods = {};
projectMethods.changeList = function (vmObj, list) {
vmObj.$refs.list.changeList(list);
};
export default projectMethods
\ No newline at end of file
export default {
"powerIcon":["&#xe6e5;", "&#xe62b;", "&#xe627;", "&#xe628;", "&#xe62a;", "&#xe629;"],
"openDoorMode": {
1: "passwordOpenDoor",
2: "fingerprintOpenDoor",
3: "ICcardOpenDoor",
4: "remoteOpenDoor",
5: "keyOpenDoor",
20: "hijackingAlarm",
30: "appRemoteOpenDoor"
},
"openDoorWay": {
1: "passwordOpenDoor",
2: "fingerprintOpenDoor",
3: "ICcardOpenDoor",
4: "remoteOpenDoor",
5: "keyOpenDoor"
},
"alarmMode": {
1: "tamperAlarm",
2: "trialAlarm",
3: "powerAlarm"
},
"hijackMode": {
2: "hijackingAlarm",
20: "hijackingAlarm"
},
"model": "USMARTLOCK_SECURITY_SMARTDOOR_SMART_LOCK",
"GET_MSG_INTERVAL": 5000,
"wifi_add_timeout": 150000,
"add_wifi_timeout": 90,
"findWifiTimeout": 60000,
// "active_device_timeout": 30,
//门铃晃动间隔时间
"await_time": 3000,
//门铃晃动次数
"shake_times": 3,
//门锁晃动总时间
"ring_time": 12000,
"remote_opendoor_timeout": 15000,
//二维码失效时间
"qrcode_timeout": 600000,
"remote_timeout": 120,
"input":{
"maxlength": 16
},
"password":{
"maxlength": 12,
"minlength": 6
},
"pushMsg_timeout": 300,
"intervalTime": 3,
//小红点超时时间,24小时之前的新消息没有小红点提示
"newMsg_timeout": 86400,
"getHistoryTimes": 3,
"audioUrl": "../../resources/audio/tipSound.mp3",
// "audioUrl": "_www/resources/audio/tipSound.mp3"
}
\ No newline at end of file
/**
* @class
* crypto
*/
import CryptoJS from "crypto-js";
import md5 from "md5";
class crypto{
static MD5(string){
console.log(string);
return md5(string);
}
static enkey(string){
let key = this.MD5(string).substr(8,16);
let iv = this.MD5(key).substr(8,16);
let keyIv = {
"key": key,
"iv": iv
}
return keyIv;
}
static encode(msg, keyIv){
let message = '';
if(typeof(msg) == 'object'){
message = JSON.stringify(msg);
}else{
message = msg;
}
console.log(message);
let key = CryptoJS.enc.Utf8.parse(keyIv.key);
let iv = CryptoJS.enc.Utf8.parse(keyIv.iv);
let code = CryptoJS.AES.encrypt(message, key, { iv: iv},{ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.nopadding });
return code.toString();
}
static decode(code, keyIv){
let key = CryptoJS.enc.Utf8.parse(keyIv.key);
let iv = CryptoJS.enc.Utf8.parse(keyIv.iv);;
let decryptedData = CryptoJS.AES.decrypt(code, key, { iv: iv},{ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.nopadding });
return decryptedData.toString(CryptoJS.enc.Utf8);
}
}
export default crypto;
\ No newline at end of file
var manage = 0; //1为正式地址,0为96地址
var modelManage = 0; //1为正式"USMARTLOCK_SECURITY_SMARTDOOR_SMART_LOCK",0为UGEN_SECURITY_SMARTDOOR_YJ2017
//(1,1)为正式版, (1,0)为内测版, (0,1)为96版
export default {
"url": manage ? "https://cloud.iot.u-gen.net/" : "http://192.168.2.96:20000",
"model": modelManage ? "USMARTLOCK_SECURITY_SMARTDOOR_SMART_LOCK" : "UGEN_SECURITY_SMARTDOOR_YJ2017",
"appId": modelManage ? "10004" : "10004",
"appSecret": modelManage ? "10004" : "10004"
}
\ No newline at end of file
import androidNotify from '../view/c_android-notify.vue';
import list from '../view/c_list.vue';
var components = {
'android-notify': androidNotify,
'list': list
};
export default components;
\ No newline at end of file
import config from './config.js';
import VueI18n from 'vue-i18n';
import defaultConfig from './defaultConfig';
var VueTouch = require('vue-touch');
Vue.use(VueTouch);
import ugenComponents from 'ugen-components';
var uComponents = ugenComponents.uComponents;
import projectComponents from './manage';
const iot = new UIOT({
lang: ['zh', 'en'],
vue: Vue,
i18n: VueI18n,
appId: defaultConfig.appId,
appSecret: defaultConfig.appSecret,
wx: {
appId: ''
},
cloud: {
// url: 'http://wx.iotface.com'
//96环境
url: defaultConfig.url
//96外网
// url: 'http://jycinema.u-gen.net'
//正式
// url: 'https://cloud.iot.u-gen.net/'
//正式测试
// url: 'https://cloud.iot.u-gen.net/test-openapi/'
},
plugin: {
log: {
url: 'https://admin.iot.u-gen.net/admin/api/debug'
}
}
});
var uPublic = {};
uPublic.console = function (res) {
console.log(res)
};
// 设置页面字体
uPublic.recalc = function () {
var docEl = document.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
docEl.style.fontSize = clientWidth / 10 + 'px';
};
window.addEventListener(resizeEvt, recalc, false);
recalc();
};
// 注册组件
uPublic.componentsInit = function (array) {
array.forEach(function (item, index) {
Vue.component(item, ugenComponents.manage[item]);
});
};
// 加载项目自定义组件
uPublic.componentsExtend = function (array) {
array.forEach(function (item, index) {
Vue.component(item, projectComponents[item]);
});
};
//请求发送失败弹框
uPublic.openRequestErrorAlert = function (vmObj, content = Vue.t('request.error')) {
uComponents.openAlert(vmObj, content, {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
};
// 检查请求成功后data参数
uPublic.checkResponseData = function (data) {
// json
if (data != null && typeof data === 'object') {
if (Object.keys(data).length == 0 || data.hasOwnProperty('msg')) {
return false;
} else {
return data;
}
// array
} else if (Array.isArray(data)) {
if (data.length > 0) {
return data;
} else {
return false;
}
}
};
// 检查输入文字是否含有特殊字符
uPublic.checkString = function (text){
var pattern = new RegExp("[~!@#$%^&*()_+=|\?/{}<>:;'`]+");
if(!pattern.test(text)){
return false
}else{
return true;
}
}
uPublic.openWindow = function (params){
console.log("innnnn");
var wv = plus.webview.create(params.url, params.id, {styles: params.styles || {} }, { IOTData: params.extras });
console.log(wv);
wv.addEventListener('titleUpdate', function(){
wv.show('slide-in-right');
});
}
//禁用ios侧滑返回
uPublic.closeSlideBack = function (){
var wv = plus.webview.currentWebview();
wv.setStyle({
popGesture: 'none'
});
}
//logout退出
uPublic.logout = function(opts){
iot.business.user.logout({
data: opts.data,
success: (response) => {
console.log("sdsLogout:"+response);
var sdsResponse = response;
iot.business.api.send('user/logout',{
data: {
key: ['clienId']
},
success: (response) => {
console.log("logout"+response)
iot.business.websql.delMaps(['utoken', 'userinfo'], (response) => {
iot.storage.delMaps(['notifyTime','alarmTime','openTime'], (response) => {
console.log("clearMap"+response);
opts.success(sdsResponse);
}, (error) => {
opts.error(error);
});
}, (error) => {
opts.error(error);
});
},
error: (error) => {
opts.error(error);
},
complete: () => {
opts.complete();
}
}, true, false);
},
error: (error) => {
opts.error(error);
},
complete: () => {}
});
}
// 更新缓存中history存储的isReadFlag 和 time
uPublic.upDateRead = async function(key, time){
let oldHistory = {
alarm: {
time: null,
isReadFlag: true
},
notify: {
time: null,
isReadFlag: true
},
open: {
time: null,
isReadFlag: true
}
};
try{
let history = await iot.storage.getMap('history');
oldHistory = history ? history : oldHistory;
console.log(oldHistory);
}
catch (error){
console.log(error);
}
let newHistory = oldHistory;
newHistory[key].isReadFlag = true;
newHistory[key].time = time;
let flag = await iot.storage.setMap('history', newHistory);
if(flag){
return false;
}
}
iot.ready(() => {
uPublic.recalc();
});
iot.navigator.getAllWebviw = function () {
return plus.webview.all();
}
iot.navigator.fire = function (webview, eventType, data) {
mui.fire(webview, eventType, data);
};
window.iot = iot;
iot.navigator.receive = function (eventType, data) {
console.log("receive。。。");
if (eventType) {
try {
if (data && typeof data === 'string') {
data = JSON.parse(data);
}
} catch (e) {
}
iot.navigator.trigger(document, eventType, data);
}
};
iot.navigator.trigger = function (element, eventType, eventData) {
console.log("trigger。。。");
console.log(element);
console.log(eventType);
element.dispatchEvent(new CustomEvent(eventType, {
detail: eventData,
bubbles: true,
cancelable: true
}));
return this;
};
iot.navigator.closeAllBesidesItself = function () {
setTimeout(function () {
var wvs = plus.webview.all();
var page = plus.webview.currentWebview();
for (var i = 0; i < wvs.length; i++) {
if (wvs[i].id != page.id && wvs[i]) {
// wvs[i].close();
plus.webview.close(wvs[i],"none",0,{});
}
}
var wvs = plus.webview.all();
}, 500);
}
iot.navigator.closeAll = function (){
var wvs = plus.webview.all();
var curWb = plus.webview.currentWebview();
for (var i = 0; i < wvs.length; i++) {
wvs[i].close();
}
}
iot.ready(function(){
// plus.key.addEventListener('backbutton',iot.navigator.aback,false);
})
iot.navigator.aback = function(){
mui.back();
}
var __back__first = null;
mui.back = function(){
var wobj = plus.webview.currentWebview();
var parent = wobj.parent();
var wbs = iot.navigator.getAllWebviw();
if (wbs.length>1) {
// console.log("不止一个webview...");
// return;
iot.navigator.back();
// console.log("有父webview...");
// return;
// parent.evalJS('iot.navigator.back()');
// parent.evalJS('mui&&mui.back();');
} else {
console.log("只有一个webView");
// return;
wobj.canBack(function(e) {
console.log("是否可以返回canback...");
console.log(window.history);
// window.history.back();
console.log(e);
//by chb 暂时注释,在碰到类似popover之类的锚点的时候,需多次点击才能返回;
if (e.canBack) { //webview history back
console.log("e.canback....");
// return;
// window.history.back();
// iot.navigator.back();
} else { //webview close or hide
console.log("不能back。。。");
if (!__back__first) {
__back__first = new Date().getTime();
console.log("给back_first设值....");
plus.nativeUI.toast( "再按一次退出应用");
// mui.toast('再按一次退出应用');
setTimeout(function() {
__back__first = null;
}, 2000);
} else {
console.log("back_first不为空....");
if (new Date().getTime() - __back__first < 2000) {
console.log("两次的间隔时间少于2秒");
plus.runtime.quit();
}else{
console.log("时间间隔大于2s");
}
}
return;
}
});
}
}
iot.navigator.getCurrentWebView = function (){
return plus.webview.currentWebview();
}
export {iot, uPublic, uComponents}
\ No newline at end of file
import {iot, uPublic, uComponents} from './public.js';
class Request{
constructor(json) {//当前版本号、最新版本号以及获取最新安装包地址
}
versionRequest(url,need,notneed){
this.getDownloadUrl(url,need,notneed);
}
getDownloadUrl(url,need,notneed){
let type = null;
if (iot.navigator.osName() == "iOS") {
type = "ios";
}else{
type = "android";
}
iot.business.api.send(url,
{
data: {
type:type
},
success: (response) => {
console.log(response);
if (response.code == 0) {
this.dealWithVersion(response,need,notneed);
}
},
error: (error) => {
console.log(error);
notneed(error);
},
complete: () => {}
},false);
}
dealWithVersion(response,need,notneed){
let type = null;
if (iot.navigator.osName() == "iOS") {
type = "ios";
}else{
type = "android";
}
let info = null;
if (type == "ios") {
info = response.data["ios"];
}else{
info = response.data["android"];
}
console.log(info);
let newVersion = info.version;// 新版本 无论是安卓还是iOS都用此变量存储
let downloadUrl = info.url;
let backinfo = {
url:downloadUrl,
version:newVersion
};
need(backinfo);
}
}
export default new Request();
\ No newline at end of file
/**
* @class
* loop
*/
//轮询通用方法:http://116.62.143.3:10080/iot-project-js/doorlock/issues/1
class Loop{
constructor(params) {
this.handle = null;
this.watcher = null;
this.time = null;
this.loopContent = params.loopContent;
this.times = params.times || 10;
this.fincb = params.fincb;
this.intervalTime = params.interval.delay;
this.intervalcb = params.interval.cb;
this.stopcondition = params.stopcondition;
this.canSend = true;
this.canDo = true;
this.i = 0;
}
clearTime(){
clearInterval(this.handle);
clearInterval(this.watcher);
clearTimeout(this.time);
}
async sendRequest(){
this.canSend = false;
try{
var response = null;
response = await this.loopContent();
console.log(response);
if(await this.stopcondition(response)){
if(this.fincb!= null){
this.fincb.success(response);
this.fincb.complete();
}
this.clearTime();
this.canSend = false;
}else{
if(this.intervalcb!= null){
this.intervalcb.success(response);
}
this.canSend = true;
}
}
catch (error){
if(this.intervalcb!= null){
if(this.intervalcb.error(error)){
this.canSend = true;
}else{
if(this.fincb!= null){
this.fincb.error(error);
this.fincb.complete();
this.clearTime();
}
}
}
}
}
start(){
console.log("开始");
console.log("第"+this.i+"次发送了请求");
console.log("发送时间"+new Date().getTime());
this.i++;
this.sendRequest();
this.watcher = setInterval(() => {
if(this.canSend && this.canDo){
this.canDo = false;
console.log("第"+this.i+"次发送了请求");
console.log("发送时间"+new Date().getTime());
this.i++;
this.sendRequest();
}
},1000);
let times = 1;
this.handle = setInterval(() => {
times++;
console.log('times'+times);
if(times > this.times){
this.clearTime();
this.canDo = false;
this.fincb.error('timeout');
this.fincb.complete();
this.intervalcb = null;
this.fincb = null;
}else{
this.canDo = true;
}
},this.intervalTime);
}
}
export default Loop;
/**
* @class
* unotify
*/
import uloop from './uloop';
//获取cid: http://116.62.143.3:10080/iot-project-js/doorlock/issues/4
class unotify{
//在一个周期内获取cid
static getCid(successCallback, errorCallback){
this.UpdateCid((response) => {
successCallback(response);
}, (error) => {
errorCallback(error);
});
}
//周期性获取cid,周期可调整
static getCidPeriotic(times){
var self = this;
return new Promise(function(resolve, reject){
new uloop({
loopContent: () => {
return self.getCidOnce();
},
times: times,
interval:{
delay: 1000,
cb: {
success: (response) => {
console.log('intervalcbSuccess:'+JSON.stringify(response));
},
error: (error) => {
console.log('intervalcbError:'+JSON.stringify(error));
}
}
},
fincb: {
success: (response) => {
console.log('fincbSuccess:'+JSON.stringify(response));
resolve(response);
},
error: (error) => {
console.log('fincbSuccess:'+JSON.stringify(error));
if(error == 'timeout'){
resolve(null);
}
},
complete: () => {}
},
stopcondition: async (response) => {
if(response != null && response != 'null' ){
return true;
}
}
}).start();
});
}
//单次获取cid
static getCidOnce(){
var clientInfo = plus.push.getClientInfo();
if(clientInfo && clientInfo.hasOwnProperty('clientid') && clientInfo.clientid){
return(clientInfo.clientid);
}else{
return(null);
}
}
//长期不断循环获取cid,并更新cid
static async UpdateCid(successCallback, errorCallback){
var cid = null;
var oldCid = null;
try{
cid = await this.getCidPeriotic(999);
if(cid != null && cid != oldCid){
iot.business.api.send('user/updateCid',{
data: {
clienId: cid
},
success: (response) => {
console.log(response);
if(typeof successCallback == 'function'){
successCallback('cid updateSuccess');
}
},
error: (error) => {
console.log(error);
errorCallback(error);
}
}, true, false);
}else{
successCallback('cid not updated');
}
}
catch (err){
console.log(err);
if(typeof errorCallback == 'function'){
errorCallback(err);
}
}
}
}
export default unotify;
\ No newline at end of file
/**
* 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',
imgClass: '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);
}
});
}
var webpack = require('webpack');
var path = require('path');
var viewDir = path.join(__dirname, "..", "..", "web", "custom", "custom1", "view");
var fs = require('fs');
const i18nPlguin = require('./core/I18NPackage')
//获取src目录下面的所有.js文件
let devViewDir = __dirname + "/src/view";
let files = fs.readdirSync(devViewDir);
let entry = {};
let regexp = new RegExp("v_\\w+[.]js", "g");
getAllViewJS(devViewDir);
function getAllViewJS(dir) {
let files = fs.readdirSync(dir);
for (let file of files) {
let filePath = dir + "/" + file;
let stat = fs.lstatSync(filePath);
if (stat.isDirectory()) {
getAllViewJS(filePath);
} else if (stat.isFile()) {
let fileName = path.basename(filePath);
if (fileName.match(regexp)) {
let fPath = filePath.replace(__dirname, "");
let name = filePath.replace(devViewDir + "/", "").replace('v_', '').replace('.js', '');
entry[name] = ["./custom/custom1" + fPath];
}
}
}
}
//entry['vendor'] = ['vue','vue-router','vue-i18n','vue-touch','vuex','underscore','es6-promise','es6-symbol'];
module.exports = {
entry: entry,
output: {
path: viewDir,
filename: '[name].js',
chunkFilename: "[name].js"
},
module: {
loaders: [{
test: /\.vue$/,
loader: 'vue-loader'
}, {
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader'
}, {
test: /\.css$/,
loader: 'style!css'
}]
},
node: {
Buffer: false
},
resolve: {
alias: {
'vue-i18n$': 'vue-i18n/dist/vue-i18n.common.js',
'mui': '../src/public/mui.js'
}
},
plugins: [
new webpack.ProvidePlugin({
'Promise': 'es6-promise',
Vue: ['vue/dist/vue.esm.js', 'default'],
}),
new webpack.optimize.CommonsChunkPlugin({name: "../lib/js/p"}),
new i18nPlguin()
],
devtool: 'source-map'
};
{
"presets": ["es2015"],
plugins: [
["transform-regenerator"],
["transform-object-assign"],
['transform-runtime', {
helpers: false,
polyfill: false,
regenerator: true}
]
]
}
\ No newline at end of file
const path = require('path');
const srcPath = path.join(__dirname,"..","src");
const outputPath = "../resources/lang/";
module.exports = {
lang:["zh","en"],
group:srcPath,
output:outputPath
};
\ No newline at end of file
const path = require('path');
const fs = require('fs');
const config = require('../config/lang');
const srcPath = path.join(__dirname,"..","src");
const langPath = path.join(srcPath,"lang");
const componentPath = path.join(srcPath,"lang","component");
let allFilePath = [];
function getAllLang(...dirs){
let langGroup = {};
for(let dir of dirs){
if(fs.existsSync(dir)){
for(let lang of config.lang){
let lPath = path.join(dir,"/",`${lang}.json`);
if(fs.existsSync(lPath)){
let arr;
if(langGroup[lang]!=null){
arr = langGroup[lang];
}else{
arr = new Array();
}
arr.push(lPath);
langGroup[lang] = arr;
allFilePath.push(lPath);
}
}
}
}
return langGroup;
}
let langGroup;
const watch = require('watch');
class I18NPackage{
constructor(options){
this.options = options;
this.watching = false;
}
apply(compiler){
langGroup = getAllLang(langPath,componentPath);
compiler.plugin("watch-run", (compilation, callback) => {
if(!this.watching){
this.watching = true;
langGroup = getAllLang(langPath,componentPath);
const onChange = () => {
langGroup = getAllLang(langPath,componentPath);
compiler.run((err) => {
if(err) {
throw err;
}
});
};
watch.createMonitor(srcPath, (monitor) => {
monitor.files[path.join(srcPath,".json")];
monitor.on("created", onChange);
monitor.on("changed", onChange);
monitor.on("removed", onChange);
callback();
});
}
});
compiler.plugin('emit', function(compilation, callback) {
let createFileName = [];
try{
for(let key of Object.keys(langGroup)){
let path = langGroup[key];
let obj = {};
for(let filePath of path){
obj = Object.assign(obj,JSON.parse(fs.readFileSync(filePath, 'utf8')));
}
let filelist = JSON.stringify(obj);
// Insert this list into the Webpack build as a new file asset:
let fileName = `../resources/lang/${key}.json`;
compilation.assets[fileName] = {
source: function() {
return filelist;
},
size: function() {
return filelist.length;
}
};
createFileName.push(fileName);
}
}catch(err){
console.log(err)
}
console.log("lang file merge success.")
for(let file of createFileName){
console.log(file)
}
callback();
});
}
}
module.exports = I18NPackage;
\ No newline at end of file
var webpack = require('webpack');
var path = require('path');
const vendors = [
'whatwg-fetch',
'es6-promise',
'vue',
'vuex'
];
let libsDir = path.join(__dirname,"libs");
module.exports = {
output: {
path: libsDir,
filename: '[name].[chunkhash].js',
library: '[name]_[chunkhash]',
},
entry: {
vendor: vendors,
},
plugins: [
new webpack.DllPlugin({
path: path.join(libsDir,"manifest.json"),
name: '[name]_[chunkhash]',
context: __dirname,
}),
],
};
{
"name": "vue-webpack",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"dependencies": {
"es6-promise": "4.1.0",
"es6-symbol": "3.1.1",
"hammerjs": "2.0.8",
"iscroll": "5.2.0",
"moment": "^2.18.1",
"qrcode": "^0.9.0",
"ugen-components": "^0.3.1",
"underscore": "1.8.3",
"vue": "2.2.6",
"vue-i18n": "5.0.3",
"vue-router": "2.1.1",
"vue-touch": "2.0.0-beta.4",
"vuex": "2.3.1"
},
"devDependencies": {
"babel-core": "6.24.1",
"babel-loader": "6.4.1",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-object-assign": "6.22.0",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-es2015": "6.24.1",
"crypto-js": "^3.1.9-1",
"css-loader": "0.28.0",
"es6-promise": "4.1.0",
"md5": "^2.2.1",
"style-loader": "0.16.1",
"vue-loader": "11.3.4",
"vue-template-compiler": "2.2.6",
"watch": "1.0.2",
"webpack": "2.3.3"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
class Barcode{
constructor() {
}
startQr(id,keyArrays,success,error){
console.log("开始扫描....");
this.scan = iot.navigator.barcode(id);
console.log(this.scan);
this.scan.start();
this.scan.onmarked = (type, result)=>{
if(result) {
let typeJson = this.formatUrlToJson(result);
let type = typeJson["type"];
let bool = this.isInArray(keyArrays,type);
if (bool) {
success(type);
}else{
error("当前扫描的二维码不和规范");
}
}
};
}
isInArray(arr,value){
for(var i = 0; i < arr.length; i++){
if(value === arr[i]){
return true;
}
}
return false;
}
formatUrlToJson(str){
console.log("测试字符串截取功能");
let index = str.indexOf("?");
let subStr = str.substr(index+1,str.length);
let subIndex = subStr.indexOf("=");
let keyStr = subStr.substr(0,subIndex);
console.log(keyStr);
let value = subStr.substr(subIndex+1,subStr.length);
let json = {};
json[keyStr] = value;
// alert(JSON.stringify(json));
return json;
}
}
export default new Barcode();
\ No newline at end of file
let projectMethods = {};
projectMethods.changeList = function (vmObj, list) {
vmObj.$refs.list.changeList(list);
};
export default projectMethods
\ No newline at end of file
export default {
"powerIcon":["&#xe6e5;", "&#xe62b;", "&#xe627;", "&#xe628;", "&#xe62a;", "&#xe629;"],
"openDoorMode": {
1: "passwordOpenDoor",
2: "fingerprintOpenDoor",
3: "ICcardOpenDoor",
4: "remoteOpenDoor",
5: "keyOpenDoor",
20: "hijackingAlarm",
30: "appRemoteOpenDoor"
},
"openDoorWay": {
1: "passwordOpenDoor",
2: "fingerprintOpenDoor",
3: "ICcardOpenDoor",
4: "remoteOpenDoor",
5: "keyOpenDoor"
},
"alarmMode": {
1: "tamperAlarm",
2: "trialAlarm",
3: "powerAlarm"
},
"hijackMode": {
2: "hijackingAlarm",
20: "hijackingAlarm"
},
"model": "USMARTLOCK_SECURITY_SMARTDOOR_SMART_LOCK",
"GET_MSG_INTERVAL": 5000,
"wifi_add_timeout": 150000,
"add_wifi_timeout": 90,
"findWifiTimeout": 60000,
// "active_device_timeout": 30,
//门铃晃动间隔时间
"await_time": 3000,
//门铃晃动次数
"shake_times": 3,
//门锁晃动总时间
"ring_time": 12000,
"remote_opendoor_timeout": 15000,
//二维码失效时间
"qrcode_timeout": 600000,
"remote_timeout": 120,
"input":{
"maxlength": 16
},
"password":{
"maxlength": 12,
"minlength": 6
},
"pushMsg_timeout": 300,
"intervalTime": 3,
//小红点超时时间,24小时之前的新消息没有小红点提示
"newMsg_timeout": 86400,
"getHistoryTimes": 3,
"audioUrl": "../../../../resources/audio/tipSound.mp3",
// "audioUrl": "_www/resources/audio/tipSound.mp3"
}
\ No newline at end of file
/**
* @class
* crypto
*/
import CryptoJS from "crypto-js";
import md5 from "md5";
class crypto{
static MD5(string){
console.log(string);
return md5(string);
}
static enkey(string){
let key = this.MD5(string).substr(8,16);
let iv = this.MD5(key).substr(8,16);
let keyIv = {
"key": key,
"iv": iv
}
return keyIv;
}
static encode(msg, keyIv){
let message = '';
if(typeof(msg) == 'object'){
message = JSON.stringify(msg);
}else{
message = msg;
}
console.log(message);
let key = CryptoJS.enc.Utf8.parse(keyIv.key);
let iv = CryptoJS.enc.Utf8.parse(keyIv.iv);
let code = CryptoJS.AES.encrypt(message, key, { iv: iv},{ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.nopadding });
return code.toString();
}
static decode(code, keyIv){
let key = CryptoJS.enc.Utf8.parse(keyIv.key);
let iv = CryptoJS.enc.Utf8.parse(keyIv.iv);;
let decryptedData = CryptoJS.AES.decrypt(code, key, { iv: iv},{ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.nopadding });
return decryptedData.toString(CryptoJS.enc.Utf8);
}
}
export default crypto;
\ No newline at end of file
var manage = 0; //1为正式地址,0为96地址
var modelManage = 0; //1为正式"USMARTLOCK_SECURITY_SMARTDOOR_SMART_LOCK",0为UGEN_SECURITY_SMARTDOOR_YJ2017
//(1,1)为正式版, (1,0)为内测版, (0,1)为96版
export default {
"url": manage ? "https://cloud.iot.u-gen.net/" : "http://192.168.2.96:20000",
"model": modelManage ? "USMARTLOCK_SECURITY_SMARTDOOR_SMART_LOCK" : "UGEN_SECURITY_SMARTDOOR_YJ2017",
"appId": modelManage ? "10004" : "10004",
"appSecret": modelManage ? "10004" : "10004"
}
\ No newline at end of file
import androidNotify from '../view/c_android-notify.vue';
import list from '../view/c_list.vue';
var components = {
'android-notify': androidNotify,
'list': list
};
export default components;
\ No newline at end of file
import config from './config.js';
import VueI18n from 'vue-i18n';
import defaultConfig from './defaultConfig';
var VueTouch = require('vue-touch');
Vue.use(VueTouch);
import ugenComponents from 'ugen-components';
var uComponents = ugenComponents.uComponents;
import projectComponents from './manage';
const iot = new UIOT({
lang: ['zh', 'en'],
vue: Vue,
i18n: VueI18n,
appId: defaultConfig.appId,
appSecret: defaultConfig.appSecret,
wx: {
appId: ''
},
cloud: {
// url: 'http://wx.iotface.com'
//96环境
url: defaultConfig.url
//96外网
// url: 'http://jycinema.u-gen.net'
//正式
// url: 'https://cloud.iot.u-gen.net/'
//正式测试
// url: 'https://cloud.iot.u-gen.net/test-openapi/'
},
plugin: {
log: {
url: 'https://admin.iot.u-gen.net/admin/api/debug'
}
}
});
var uPublic = {};
uPublic.console = function (res) {
console.log(res)
};
// 设置页面字体
uPublic.recalc = function () {
var docEl = document.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
docEl.style.fontSize = clientWidth / 10 + 'px';
};
window.addEventListener(resizeEvt, recalc, false);
recalc();
};
// 注册组件
uPublic.componentsInit = function (array) {
array.forEach(function (item, index) {
Vue.component(item, ugenComponents.manage[item]);
});
};
// 加载项目自定义组件
uPublic.componentsExtend = function (array) {
array.forEach(function (item, index) {
Vue.component(item, projectComponents[item]);
});
};
//请求发送失败弹框
uPublic.openRequestErrorAlert = function (vmObj, content = Vue.t('request.error')) {
uComponents.openAlert(vmObj, content, {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
};
// 检查请求成功后data参数
uPublic.checkResponseData = function (data) {
// json
if (data != null && typeof data === 'object') {
if (Object.keys(data).length == 0 || data.hasOwnProperty('msg')) {
return false;
} else {
return data;
}
// array
} else if (Array.isArray(data)) {
if (data.length > 0) {
return data;
} else {
return false;
}
}
};
// 检查输入文字是否含有特殊字符
uPublic.checkString = function (text){
var pattern = new RegExp("[~!@#$%^&*()_+=|\?/{}<>:;'`]+");
if(!pattern.test(text)){
return false
}else{
return true;
}
}
uPublic.openWindow = function (params){
console.log("innnnn");
var wv = plus.webview.create(params.url, params.id, {styles: params.styles || {} }, { IOTData: params.extras });
console.log(wv);
wv.addEventListener('titleUpdate', function(){
wv.show('slide-in-right');
});
}
//禁用ios侧滑返回
uPublic.closeSlideBack = function (){
var wv = plus.webview.currentWebview();
wv.setStyle({
popGesture: 'none'
});
}
//logout退出
uPublic.logout = function(opts){
iot.business.user.logout({
data: opts.data,
success: (response) => {
console.log("sdsLogout:"+response);
var sdsResponse = response;
iot.business.api.send('user/logout',{
data: {
key: ['clienId']
},
success: (response) => {
console.log("logout"+response)
iot.business.websql.delMaps(['utoken', 'userinfo'], (response) => {
iot.storage.delMaps(['notifyTime','alarmTime','openTime'], (response) => {
console.log("clearMap"+response);
opts.success(sdsResponse);
}, (error) => {
opts.error(error);
});
}, (error) => {
opts.error(error);
});
},
error: (error) => {
opts.error(error);
},
complete: () => {
opts.complete();
}
}, true, false);
},
error: (error) => {
opts.error(error);
},
complete: () => {}
});
}
// 更新缓存中history存储的isReadFlag 和 time
uPublic.upDateRead = async function(key, time){
let oldHistory = {
alarm: {
time: null,
isReadFlag: true
},
notify: {
time: null,
isReadFlag: true
},
open: {
time: null,
isReadFlag: true
}
};
try{
let history = await iot.storage.getMap('history');
oldHistory = history ? history : oldHistory;
console.log(oldHistory);
}
catch (error){
console.log(error);
}
let newHistory = oldHistory;
newHistory[key].isReadFlag = true;
newHistory[key].time = time;
let flag = await iot.storage.setMap('history', newHistory);
if(flag){
return false;
}
}
iot.ready(() => {
uPublic.recalc();
});
iot.navigator.getAllWebviw = function () {
return plus.webview.all();
}
iot.navigator.fire = function (webview, eventType, data) {
mui.fire(webview, eventType, data);
};
window.iot = iot;
iot.navigator.receive = function (eventType, data) {
console.log("receive。。。");
if (eventType) {
try {
if (data && typeof data === 'string') {
data = JSON.parse(data);
}
} catch (e) {
}
iot.navigator.trigger(document, eventType, data);
}
};
iot.navigator.trigger = function (element, eventType, eventData) {
console.log("trigger。。。");
console.log(element);
console.log(eventType);
element.dispatchEvent(new CustomEvent(eventType, {
detail: eventData,
bubbles: true,
cancelable: true
}));
return this;
};
iot.navigator.closeAllBesidesItself = function () {
setTimeout(function () {
var wvs = plus.webview.all();
var page = plus.webview.currentWebview();
for (var i = 0; i < wvs.length; i++) {
if (wvs[i].id != page.id && wvs[i]) {
// wvs[i].close();
plus.webview.close(wvs[i],"none",0,{});
}
}
var wvs = plus.webview.all();
}, 500);
}
iot.navigator.closeAll = function (){
var wvs = plus.webview.all();
var curWb = plus.webview.currentWebview();
for (var i = 0; i < wvs.length; i++) {
wvs[i].close();
}
}
iot.ready(function(){
// plus.key.addEventListener('backbutton',iot.navigator.aback,false);
})
iot.navigator.aback = function(){
mui.back();
}
var __back__first = null;
mui.back = function(){
var wobj = plus.webview.currentWebview();
var parent = wobj.parent();
var wbs = iot.navigator.getAllWebviw();
if (wbs.length>1) {
// console.log("不止一个webview...");
// return;
iot.navigator.back();
// console.log("有父webview...");
// return;
// parent.evalJS('iot.navigator.back()');
// parent.evalJS('mui&&mui.back();');
} else {
console.log("只有一个webView");
// return;
wobj.canBack(function(e) {
console.log("是否可以返回canback...");
console.log(window.history);
// window.history.back();
console.log(e);
//by chb 暂时注释,在碰到类似popover之类的锚点的时候,需多次点击才能返回;
if (e.canBack) { //webview history back
console.log("e.canback....");
// return;
// window.history.back();
// iot.navigator.back();
} else { //webview close or hide
console.log("不能back。。。");
if (!__back__first) {
__back__first = new Date().getTime();
console.log("给back_first设值....");
plus.nativeUI.toast( "再按一次退出应用");
// mui.toast('再按一次退出应用');
setTimeout(function() {
__back__first = null;
}, 2000);
} else {
console.log("back_first不为空....");
if (new Date().getTime() - __back__first < 2000) {
console.log("两次的间隔时间少于2秒");
plus.runtime.quit();
}else{
console.log("时间间隔大于2s");
}
}
return;
}
});
}
}
iot.navigator.getCurrentWebView = function (){
return plus.webview.currentWebview();
}
export {iot, uPublic, uComponents}
\ No newline at end of file
import {iot, uPublic, uComponents} from './public.js';
class Request{
constructor(json) {//当前版本号、最新版本号以及获取最新安装包地址
}
versionRequest(url,need,notneed){
this.getDownloadUrl(url,need,notneed);
}
getDownloadUrl(url,need,notneed){
let type = null;
if (iot.navigator.osName() == "iOS") {
type = "ios";
}else{
type = "android";
}
iot.business.api.send(url,
{
data: {
type:type
},
success: (response) => {
console.log(response);
if (response.code == 0) {
this.dealWithVersion(response,need,notneed);
}
},
error: (error) => {
console.log(error);
notneed(error);
},
complete: () => {}
},false);
}
dealWithVersion(response,need,notneed){
let type = null;
if (iot.navigator.osName() == "iOS") {
type = "ios";
}else{
type = "android";
}
let info = null;
if (type == "ios") {
info = response.data["ios"];
}else{
info = response.data["android"];
}
console.log(info);
let newVersion = info.version;// 新版本 无论是安卓还是iOS都用此变量存储
let downloadUrl = info.url;
let backinfo = {
url:downloadUrl,
version:newVersion
};
need(backinfo);
}
}
export default new Request();
\ No newline at end of file
/**
* @class
* loop
*/
//轮询通用方法:http://116.62.143.3:10080/iot-project-js/doorlock/issues/1
class Loop{
constructor(params) {
this.handle = null;
this.watcher = null;
this.time = null;
this.loopContent = params.loopContent;
this.times = params.times || 10;
this.fincb = params.fincb;
this.intervalTime = params.interval.delay;
this.intervalcb = params.interval.cb;
this.stopcondition = params.stopcondition;
this.canSend = true;
this.canDo = true;
this.i = 0;
}
clearTime(){
clearInterval(this.handle);
clearInterval(this.watcher);
clearTimeout(this.time);
}
async sendRequest(){
this.canSend = false;
try{
var response = null;
response = await this.loopContent();
console.log(response);
if(await this.stopcondition(response)){
if(this.fincb!= null){
this.fincb.success(response);
this.fincb.complete();
}
this.clearTime();
this.canSend = false;
}else{
if(this.intervalcb!= null){
this.intervalcb.success(response);
}
this.canSend = true;
}
}
catch (error){
if(this.intervalcb!= null){
if(this.intervalcb.error(error)){
this.canSend = true;
}else{
if(this.fincb!= null){
this.fincb.error(error);
this.fincb.complete();
this.clearTime();
}
}
}
}
}
start(){
console.log("开始");
console.log("第"+this.i+"次发送了请求");
console.log("发送时间"+new Date().getTime());
this.i++;
this.sendRequest();
this.watcher = setInterval(() => {
if(this.canSend && this.canDo){
this.canDo = false;
console.log("第"+this.i+"次发送了请求");
console.log("发送时间"+new Date().getTime());
this.i++;
this.sendRequest();
}
},1000);
let times = 1;
this.handle = setInterval(() => {
times++;
console.log('times'+times);
if(times > this.times){
this.clearTime();
this.canDo = false;
this.fincb.error('timeout');
this.fincb.complete();
this.intervalcb = null;
this.fincb = null;
}else{
this.canDo = true;
}
},this.intervalTime);
}
}
export default Loop;
/**
* @class
* unotify
*/
import uloop from './uloop';
//获取cid: http://116.62.143.3:10080/iot-project-js/doorlock/issues/4
class unotify{
//在一个周期内获取cid
static getCid(successCallback, errorCallback){
this.UpdateCid((response) => {
successCallback(response);
}, (error) => {
errorCallback(error);
});
}
//周期性获取cid,周期可调整
static getCidPeriotic(times){
var self = this;
return new Promise(function(resolve, reject){
new uloop({
loopContent: () => {
return self.getCidOnce();
},
times: times,
interval:{
delay: 1000,
cb: {
success: (response) => {
console.log('intervalcbSuccess:'+JSON.stringify(response));
},
error: (error) => {
console.log('intervalcbError:'+JSON.stringify(error));
}
}
},
fincb: {
success: (response) => {
console.log('fincbSuccess:'+JSON.stringify(response));
resolve(response);
},
error: (error) => {
console.log('fincbSuccess:'+JSON.stringify(error));
if(error == 'timeout'){
resolve(null);
}
},
complete: () => {}
},
stopcondition: async (response) => {
if(response != null && response != 'null' ){
return true;
}
}
}).start();
});
}
//单次获取cid
static getCidOnce(){
var clientInfo = plus.push.getClientInfo();
if(clientInfo && clientInfo.hasOwnProperty('clientid') && clientInfo.clientid){
return(clientInfo.clientid);
}else{
return(null);
}
}
//长期不断循环获取cid,并更新cid
static async UpdateCid(successCallback, errorCallback){
var cid = null;
var oldCid = null;
try{
cid = await this.getCidPeriotic(999);
if(cid != null && cid != oldCid){
iot.business.api.send('user/updateCid',{
data: {
clienId: cid
},
success: (response) => {
console.log(response);
if(typeof successCallback == 'function'){
successCallback('cid updateSuccess');
}
},
error: (error) => {
console.log(error);
errorCallback(error);
}
}, true, false);
}else{
successCallback('cid not updated');
}
}
catch (err){
console.log(err);
if(typeof errorCallback == 'function'){
errorCallback(err);
}
}
}
}
export default unotify;
\ No newline at end of file
/**
* 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',
imgClass: '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();
}
}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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