Commit 4d8d1f04 by 朱建香

2

parent 7a4614fa
{
"presets": ["es2015"],
plugins: [
["transform-regenerator"],
["transform-object-assign"],
['transform-runtime', {
helpers: false,
polyfill: false,
regenerator: true}
]
]
}
\ 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"
}
{
"loading": "数据加载中...",
"scroll": {
"clickToLoadMore": "上拉加载更多",
"loading": "loading"
},
"btn": {
"confirm": "确定",
"guideLogin": "账号/密码登录",
"login": "登录",
"getCode": "获取验证码",
"register": "注册",
"logout": "退出系统",
"save": "保存",
"qrcode": "生成二维码",
"wifiAdd": "开始配置Wi-Fi",
"connect": "连接",
"bindUser": "绑定姓名",
"bind": "我要绑定",
"startNow": "立即体验",
"ignore": "暂不开启",
"openNotify": "开启推送通知",
"reBound": "重新绑定",
"saveQRcode": "保存二维码到相册",
"unbind": "解除授权",
"deleteUser": "删除该用户",
"qrcodeReset": "重新生成二维码",
"add": "添加",
"next": "下一步",
"iSee": "我知道了",
"unbindDoorlock": "解绑门锁",
"finish": "完成",
"cancel": "取消",
"search": "搜索"
},
"dialog":{
"confirm": "确认",
"cancel": "取消",
"unbind": "解除授权",
"delete": "删除"
},
"title":{
"login": "登录",
"register": "注册",
"forgetPassword": "忘记密码",
"device": "U智锁",
"opendoorRecord": "开门记录",
"alarmInfo": "报警记录",
"remoteOpendoor": "远程开门",
"hijackRecord": "劫持记录",
"doorlockManage": "门锁管理",
"editName": "修改名称",
"qrcode": "生成绑定二维码",
"addDevice": "添加设备",
"scanCodeAdd": "扫码添加设备",
"wifiAddHelp": "配网添加设备",
"wifiAdd": "搜索设备",
"bindUserHelp": "ID-姓名绑定",
"bindUser": "绑定用户",
"userList": "用户列表",
"doorlockUser": "门锁用户",
"addUser": "添加用户",
"inviteBind": "邀请授权",
"unlockInfo": "关联开锁信息",
"myInfo": "个人信息",
"editNickname": "修改昵称",
"editPassword": "修改密码",
"addUnlockInfo": "关联开锁ID",
"deviceList": "产品型号"
},
"guide":{
"footer": "指纹改变生活"
},
"login":{
"telInputTip": "请输入手机号",
"passwordInputTip": "请输入密码",
"register": "快速注册",
"forgetPassword": "忘记密码",
"failure": "登陆失败",
"defaultUser": "用户{0}",
"error": {
"telNull": "请输入手机号",
"passWordNull": "请输入密码"
}
},
"register":{
"telInputTip": "请输入手机号",
"codeInputTip": "请输入验证码",
"passwordInputTip": "请输入6位登录密码",
"error": {
"telNull": "请输入手机号",
"codeNull": "请输入验证码",
"passWordNull": "请输入密码"
}
},
"forgetPassword":{
"telInputTip": "请输入手机号",
"codeInputTip": "请输入验证码",
"passwordInputTip": "请输入6位登录密码",
"error": {
"telNull": "请输入手机号",
"codeNull": "请输入验证码",
"passWordNull": "请输入密码"
}
},
"device":{
"opendoorRecord": "开门记录",
"securityAlarm": "安全报警",
"doorlockUser": "门锁用户",
"remoteOpendoor": "远程开门",
"hijackAlarm": "劫持报警",
"doorlockManage": "门锁管理",
"followTitle": "关注服务号",
"followCont1": "关注 “i智信” 微信服务号可随时随地掌握设备动态<br>再也不担心错过重要通知,赶紧按下方提示试试吧",
"followCont2": "1.保存二维码-2.用微信从<span>相册选取扫码</span>-3.关注",
"laterFollow": "稍后关注",
"newMsgDoorlock": "门锁最新消息",
"doorLockRinging": "门铃响了",
"defaultNewMsg": "您尚未绑定门锁",
"noNewMsg": "暂无开门记录",
"bindDoorlock": "绑定门锁",
"use": "使用",
"networkError": "检测到您网络连接异常,请关闭APP重新打开后再次尝试"
},
"opendoorRecord":{
"noRecordTip": "暂无记录",
"passwordOpenDoor": "密码开门",
"fingerprintOpenDoor": "指纹开门",
"ICcardOpenDoor": "IC卡开门",
"remoteOpenDoor": "遥控器开门",
"keyOpenDoor": "钥匙开门",
"hijackingAlarm": "劫持报警",
"appRemoteOpenDoor": "app远程开门"
},
"alarmInfo":{
"noInfoTip": "暂无信息",
"tamperAlarm": "防撬报警",
"trialAlarm": "试错报警",
"powerAlarm": "欠电报警"
},
"remoteOpendoor":{
"loading": "远程开门中",
"passwordInputTip": "请输入远程开门密码",
"openDoorSuccess": "远程开门成功",
"openDoorFailure": "远程开门失败",
"remoteTimeout": "远程开门超时",
"remoteOpendoorAgain": "请尝试重试",
"offlineTip": "设备已离线,收到远程开门请求后,请尽快处理",
"textlengthTip": "密码长度为6~12位数字",
"error": {
"noPasswordTip": "远程密码不能为空"
}
},
"hijackRecord":{
"noRecordTip": "暂无记录",
"hijackingAlarm": "劫持指纹报警"
},
"doorlockManage":{
"name": "名称",
"logoutDialogTip": "确定要退出系统吗?",
"defaultNickname": "门锁",
"isClearRecord": "清除所有信息",
"doorbellMsgPush": "门铃消息推送",
"alarmMsgPush": "报警消息推送",
"opendoorMsgPush": "开门消息推送",
"unbindDialogTip": "确认解除绑定",
"unbindSuccess": "<img src='../../resources/image/green_unbindSuccess_icon.png'>解除绑定成功",
"unbindFailue": "<img src='../../resources/image/green_unbindSuccess_icon.png'>解除绑定失败"
},
"editName":{
"nameInputTip": "请输入门锁名称",
"editNameSuccess": "名字修改成功",
"editNameFailue": "名字修改失败",
"error": {
"nameCanNotBeBlank": "昵称不能为空"
}
},
"qrcode":{
"helpTitle": "注意事项:",
"helpCont1": "1.仅超级管理员(通过Wi-Fi配网绑定的用户为超级管理员)可以生成绑定二维码",
"helpCont2": "2.二维码有效时间为10分钟且只能使用一次",
"helpCont3": "3.用户只需要扫描该二维码即可绑定指纹锁",
"helpCont4": "4.绑定失败则需要重新生成二维码进行绑定"
},
"addDevice": {
"scanCodeAdd": "扫码添加",
"wifiAdd": "配网添加",
"scanCodeAddTip": "注:扫描门锁主人分享的邀请授权二维码,完成添加。",
"wifiAddTip": "注:门锁尚未联网时,配置门锁联网信息,完成添加。",
"loading": "loading",
"bindSuccess": "绑定成功",
"bindFailure": "绑定失败",
"reBindDevice": "请重新绑定",
"addDeviceTip": "扫描授权设备:受邀用户扫描“邀请授权”二维码。配置Wi-Fi:激活智能锁,激活成功后默认成为门锁管理员。",
"openCameraTip": "摄像头权限被关闭,请开启权限后重试",
"openCamera": "去开启"
},
"wifiAddHelp": {
"helpTitle": "配置Wi-Fi说明:",
"helpCont1": "确认设备端进入配网模式(详情操作请见产品说明书)",
"helpCont2": "点击页面下方“开始配置Wi-Fi”按钮,输入正确Wi-Fi密码后开始搜索设备",
"helpCont3": "当系统搜索到设备后,设备将会连接Wi-Fi并完成激活",
"helpCont4": "提示:重新配网后,系统将会自动解除已授权用户"
},
"wifiAdd": {
"unbindWifiTip": "当前无Wi-Fi",
"wifiBinding": "正在搜索设备...",
"wifiBindSuccess": "设备正在连接Wi-Fi...",
"wifiBindFailue": "设备连接Wi-Fi失败",
"deviceActivating": "正在等待设备激活...",
"deviceActivateSuccess":"激活成功",
"deviceActivateFailure":"激活失败",
"bindTimeout":"连接超时",
"passwordInputTip": "请输入Wi-Fi密码",
"remindTitle": "配置Wi-Fi提醒:",
"remindCont1": "1. 请确保Wi-Fi信号良好",
"remindCont2": "2. 本产品暂不支持5GHz无线网络",
"noticeTip": "检测到您还未开启通知,将无法及时<br>接收安全推送",
"countDownText": "{0}s",
"defaultNickName": "主用户",
"error": {
}
},
"bindUserHelp": {
"helpTitle": "配对姓名说明:",
"helpCont1": "1.在指纹锁上录入指纹、密码、卡并获得相应ID",
"helpCont2": "2.通过姓名绑定将该ID绑定对应用户姓名",
"helpCont3": "3.绑定成功后,开门记录中将会显示已绑定的用户姓名",
"helpCont4": "4.用户姓名信息只保存在APP端,不影响锁端设置",
"boundUser": "查看已绑定ID姓名"
},
"bindUser": {
"editHeadTip": "点击编辑用户头像",
"nameTitle": "姓名",
"fingerprintIDTitle": "指纹ID",
"passwordIDTitle": "密码ID",
"ICCardIDTitle": "IC卡ID",
"requiredInputTip": "(必填)",
"optionalInputTip": "(选填)",
"error": {
}
},
"commstatusLoading":{
"connectSuccess": "Wi-Fi连接成功,正在绑定...",
"bindSuccess": "绑定成功",
"bindFailed": "绑定失败"
},
"userList":{
"name": "昵称:",
"noUserTip": "暂无用户",
"defaultName": "管理员",
"binded": "已绑定",
"unbind": "未绑定"
},
"addUser":{
"nameInputTip": "请为门锁用户创建显示昵称",
"addUserSuccess": "添加用户成功",
"addUserFailure": "添加用户失败",
"error": {
"nameCanNotEmpty": "用户名不能为空"
}
},
"doorlockUser":{
"name": "昵称:",
"inviteBind": "邀请授权",
"bindUnlockInfo": "关联开锁信息",
"editUsername": "编辑用户昵称",
"opendoorRecord": "历史开门记录",
"unbindDialogTip": "<img src='../../resources/image/green_unbind_icon.png'>解除授权后,该用户不能对门锁下的信息进行查看",
"deleteUserDialogTip": "删除后,用户对应的开锁id取消关联,同时失去信息查看权限。",
"unbindSuccess": "<img src='../../resources/image/green_unbindSuccess_icon.png'>解除授权成功",
"unbindFailue": "<img src='../../resources/image/green_unbindSuccess_icon.png'>解除授权失败",
"guideStep1Tip1": "邀请授权成功",
"guideStep1Tip2": "(受邀用户可查看开门记录,报警记录等<br>相关门锁信息)",
"guideStep3Tip": "关联后可了解<br>该用户的开门情况",
"deleteSuccess": "删除成功",
"deleteFailure": "删除失败",
"defaultName": "管理员",
"bindedTip": "当前用户已授权,不可重复授权"
},
"editName":{
"nameInputTip": "请输入设备名称",
"nickNameInputTip": "请输入用户名",
"editNameSuccess": "修改名称成功",
"editNameFailue": "修改名称失败",
"error": {
"nameCanNotBeBlank": "设备名称不能为空",
"nicknameCanNotBeBlank": "用户名不能为空"
}
},
"inviteBind":{
"qrcodeExpireTip": "二维码已过期,请重新生成",
"title": "绑定方法:",
"cont1": "受邀用户登录“U智锁”APP",
"cont2": "选择“扫描绑定设备”",
"cont3": "扫描上方二维码完成绑定",
"tip": "注: 二维码有效时间为10分钟,过期请",
"buttonText": "重新生成",
"userTip": "授权用户仅可查看开门、报警等记录,无法进行远程开门操作。"
},
"unlockInfo":{
"noInfoTip": "尚未关联开锁信息",
"bindSoon": "快速关联",
"passwordOpenDoor": "密码",
"fingerprintOpenDoor": "指纹",
"ICcardOpenDoor": "IC卡",
"remoteOpenDoor": "遥控器",
"keyOpenDoor": "钥匙",
"appRemoteOpenDoor": "app远程",
"hijackingAlarm": "劫持指纹",
"setHijack": "设为劫持",
"bindUnlockInfo": "关联",
"bindedLockInfo": "已关联的开锁信息",
"addInfoSuccess": "关联开锁信息成功",
"setHijackTip": "确定设为劫持指纹? 设定成功后用该指<br>纹开锁时,系统将会视为劫持报警。",
"cancelHijack": "取消劫持",
"cancelHijackTip": "确定取消劫持指纹? 取消后用该指纹开<br>锁时,系统将会视为正常开锁。",
"cancelAssociated": "取消关联",
"cancelAssociatedTip": "取消关联后,开门记录中将不再显示关联的用户信息。",
"cancelAssociatedSuccess": "取消关联成功",
"cancelAssociatedFailue": "取消关联失败",
"setHijackSuccess": "设为劫持指纹成功",
"setHijackFailue": "设为劫持指纹失败",
"cancelHijackSuccess": "取消劫持指纹成功",
"cancelHijackFailue": "取消劫持指纹失败",
"unlockInfoListTip": "暂无关联信息",
"noHistoryTip": "今日尚无未关联的开门记录"
},
"addUnlockInfo":{
"opendoorMode": "选择要关联的开锁方式",
"fingerprint": "指纹",
"password": "密码",
"icCard": "IC卡",
"key": "钥匙",
"remote":"遥控器",
"hijackFingerprint": "劫持指纹",
"opendoorRecord": "选择要关联的开锁ID",
"tip": "仅显示未绑定开门记录",
"addInfoSuccess": "关联开锁信息成功",
"addInfoFailue": "关联开锁信息失败",
"noRecordTip": "暂无记录",
"setHijackSwitch": "设为劫持指纹",
"guideStep1Tip": "选择需要添加关联的开门方式",
"guideStep3Tip": "根据开门记录中的开门时间,选择关联的<br>开门ID<span>(一个ID只能被一个用户绑定)</span>",
"guideStep5Tip": "使用劫持指纹开门时,会以报警形式<br>通知到该门锁名下的其他绑定用户",
"bindedUnlockInfo": "查看已关联信息",
"stay": "继续关联"
},
"myInfo":{
"editNickname": "修改昵称",
"editPassword": "修改密码",
"logoutDialogTip": "确定要退出系统吗?"
},
"editNickname": {
"nickNameInputTip": "请输入昵称",
"nickNameTypeTip": "请输入中文、字母和数字"
},
"editPassword": {
"newPasswordInputTip": "请输入新密码",
"oldPasswordInputTip": "请输入旧密码",
"oldPasswordInputTipAgain": "请再次输入旧密码"
},
"request":{
"error": "数据加载失败",
"initError": "初始化失败,请关闭APP重试"
},
"deviceList":{
"model": "型号:",
"noDeviceTip": "暂无产品型号"
},
"notice":{
"tip": "您还未开启通知,将无法及时接收安全推送!",
"button": "去开启"
},
"help": {
"title": "如何解决安卓手机收不到消息提醒?",
"contTip": "因部分安卓系统会在锁屏时自动清理后台运行的应用导致无法及时通知,需根据引导进行以下设置后即可随时随地收到消息推送。",
"contTitle": "如何设置:",
"contSubtitle1": "1.设置自启动",
"contText1-1": "安卓5.0以上系统需要设置应用自启动,未加入自启动的应用在杀进程或重新开机后无法推送通知。",
"contText1-2": "在软件授权管理或启动管理中(通常在手机管家或设置菜单中)找到本app并开启自启动。",
"step": "操作步骤:",
"contSubtitle2": "2.设置后台保活",
"contText2-1": "安卓7.0以上系统需要设置受保护的后台应用,未设置的应用在设备进入睡眠后会自动杀掉,只有手动开启应用才能恢复消息推送。",
"contText2-2": "在设置中找到电量与性能,点击受保护的后台应用,找到本app并开启保护。",
"contText3-1": "安卓手机须将应用加入白名单中,否则清理后台杀掉应用进程后,只有手动开启应用才能恢复消息推送。",
"contText3-2": "启动本app后打开多任务页面(清理后台应用的页面),将本app加入白名单。"
},
"androidNotify":{
"toSettingTitle":"开启系统通知",
"toSettingsub":"去开启",
"checkSetting":"检查Android系统设置",
"IKonw":"我已阅读",
"checkSettingsubTitle":"部分安卓系统的手机在开启通知后仍无法收到推送信息,您可以依次检查以下几项设置",
"step1Title":"1. 应用是否设置为自启动状态",
"step1content":"操作步骤:在软件授权管理或启动管理中(通常在手机管家或设置菜单中)找到本APP并开启自启动。",
"step2Title":"2. 应用是否已开启后台保护",
"step2content":"操作步骤:在设置中找到电量与性能,点击受保护的后台应用,找到本APP并开启保护。",
"step3Title":"3. 是否已将应用加入系统白名单",
"step3content":"操作步骤:启动本APP后打开多任务页面(清理后台应用的页面),将本APP加入白名单。",
"endSetting":"保存设置并开启应用",
"toIndex":"进入首页"
},
"newFeature":{
"newVersion":"您有新的版本更新",
"tip": "版本更新",
"update":"更新",
"miss": "暂不更新"
},
"textTip":{
"textType": "请输入中文、字母和数字"
}
}
\ No newline at end of file
{
"loading": "数据加载中...",
"scroll": {
"clickToLoadMore": "上拉加载更多",
"loading": "loading"
},
"btn": {
"confirm": "确定",
"guideLogin": "账号/密码登录",
"login": "登录",
"getCode": "获取验证码",
"register": "注册",
"logout": "退出系统",
"save": "保存",
"qrcode": "生成二维码",
"wifiAdd": "开始配置Wi-Fi",
"connect": "连接",
"bindUser": "绑定姓名",
"bind": "我要绑定",
"startNow": "立即体验",
"ignore": "暂不开启",
"openNotify": "开启推送通知",
"reBound": "重新绑定",
"saveQRcode": "保存二维码到相册",
"unbind": "解除授权",
"deleteUser": "删除该用户",
"qrcodeReset": "重新生成二维码",
"add": "添加",
"next": "下一步",
"iSee": "我知道了",
"unbindDoorlock": "解绑门锁",
"finish": "完成",
"cancel": "取消",
"search": "搜索"
},
"dialog":{
"confirm": "确认",
"cancel": "取消",
"unbind": "解除授权",
"delete": "删除"
},
"title":{
"login": "登录",
"register": "注册",
"forgetPassword": "忘记密码",
"device": "U智锁",
"opendoorRecord": "开门记录",
"alarmInfo": "报警记录",
"remoteOpendoor": "远程开门",
"hijackRecord": "劫持记录",
"doorlockManage": "门锁管理",
"editName": "修改名称",
"qrcode": "生成绑定二维码",
"addDevice": "添加设备",
"scanCodeAdd": "扫码添加设备",
"wifiAddHelp": "配网添加设备",
"wifiAdd": "搜索设备",
"bindUserHelp": "ID-姓名绑定",
"bindUser": "绑定用户",
"userList": "用户列表",
"doorlockUser": "门锁用户",
"addUser": "添加用户",
"inviteBind": "邀请授权",
"unlockInfo": "关联开锁信息",
"myInfo": "个人信息",
"editNickname": "修改昵称",
"editPassword": "修改密码",
"addUnlockInfo": "关联开锁ID",
"deviceList": "产品型号"
},
"guide":{
"footer": "指纹改变生活"
},
"login":{
"telInputTip": "请输入手机号",
"passwordInputTip": "请输入密码",
"register": "快速注册",
"forgetPassword": "忘记密码",
"failure": "登陆失败",
"defaultUser": "用户{0}",
"error": {
"telNull": "请输入手机号",
"passWordNull": "请输入密码"
}
},
"register":{
"telInputTip": "请输入手机号",
"codeInputTip": "请输入验证码",
"passwordInputTip": "请输入6位登录密码",
"error": {
"telNull": "请输入手机号",
"codeNull": "请输入验证码",
"passWordNull": "请输入密码"
}
},
"forgetPassword":{
"telInputTip": "请输入手机号",
"codeInputTip": "请输入验证码",
"passwordInputTip": "请输入6位登录密码",
"error": {
"telNull": "请输入手机号",
"codeNull": "请输入验证码",
"passWordNull": "请输入密码"
}
},
"device":{
"opendoorRecord": "开门记录",
"securityAlarm": "安全报警",
"doorlockUser": "门锁用户",
"remoteOpendoor": "远程开门",
"hijackAlarm": "劫持报警",
"doorlockManage": "门锁管理",
"followTitle": "关注服务号",
"followCont1": "关注 “i智信” 微信服务号可随时随地掌握设备动态<br>再也不担心错过重要通知,赶紧按下方提示试试吧",
"followCont2": "1.保存二维码-2.用微信从<span>相册选取扫码</span>-3.关注",
"laterFollow": "稍后关注",
"newMsgDoorlock": "门锁最新消息",
"doorLockRinging": "门铃响了",
"defaultNewMsg": "您尚未绑定门锁",
"noNewMsg": "暂无开门记录",
"bindDoorlock": "绑定门锁",
"use": "使用",
"networkError": "检测到您网络连接异常,请关闭APP重新打开后再次尝试"
},
"opendoorRecord":{
"noRecordTip": "暂无记录",
"passwordOpenDoor": "密码开门",
"fingerprintOpenDoor": "指纹开门",
"ICcardOpenDoor": "IC卡开门",
"remoteOpenDoor": "遥控器开门",
"keyOpenDoor": "钥匙开门",
"hijackingAlarm": "劫持报警",
"appRemoteOpenDoor": "app远程开门"
},
"alarmInfo":{
"noInfoTip": "暂无信息",
"tamperAlarm": "防撬报警",
"trialAlarm": "试错报警",
"powerAlarm": "欠电报警"
},
"remoteOpendoor":{
"loading": "远程开门中",
"passwordInputTip": "请输入远程开门密码",
"openDoorSuccess": "远程开门成功",
"openDoorFailure": "远程开门失败",
"remoteTimeout": "远程开门超时",
"remoteOpendoorAgain": "请尝试重试",
"offlineTip": "设备已离线,收到远程开门请求后,请尽快处理",
"textlengthTip": "密码长度为6~12位数字",
"error": {
"noPasswordTip": "远程密码不能为空"
}
},
"hijackRecord":{
"noRecordTip": "暂无记录",
"hijackingAlarm": "劫持指纹报警"
},
"doorlockManage":{
"name": "名称",
"logoutDialogTip": "确定要退出系统吗?",
"defaultNickname": "门锁",
"isClearRecord": "清除所有信息",
"doorbellMsgPush": "门铃消息推送",
"alarmMsgPush": "报警消息推送",
"opendoorMsgPush": "开门消息推送",
"unbindDialogTip": "确认解除绑定",
"unbindSuccess": "<img src='../../resources/image/green_unbindSuccess_icon.png'>解除绑定成功",
"unbindFailue": "<img src='../../resources/image/green_unbindSuccess_icon.png'>解除绑定失败"
},
"editName":{
"nameInputTip": "请输入门锁名称",
"editNameSuccess": "名字修改成功",
"editNameFailue": "名字修改失败",
"error": {
"nameCanNotBeBlank": "昵称不能为空"
}
},
"qrcode":{
"helpTitle": "注意事项:",
"helpCont1": "1.仅超级管理员(通过Wi-Fi配网绑定的用户为超级管理员)可以生成绑定二维码",
"helpCont2": "2.二维码有效时间为10分钟且只能使用一次",
"helpCont3": "3.用户只需要扫描该二维码即可绑定指纹锁",
"helpCont4": "4.绑定失败则需要重新生成二维码进行绑定"
},
"addDevice": {
"scanCodeAdd": "扫码添加",
"wifiAdd": "配网添加",
"scanCodeAddTip": "注:扫描门锁主人分享的邀请授权二维码,完成添加。",
"wifiAddTip": "注:门锁尚未联网时,配置门锁联网信息,完成添加。",
"loading": "loading",
"bindSuccess": "绑定成功",
"bindFailure": "绑定失败",
"reBindDevice": "请重新绑定",
"addDeviceTip": "扫描授权设备:受邀用户扫描“邀请授权”二维码。配置Wi-Fi:激活智能锁,激活成功后默认成为门锁管理员。",
"openCameraTip": "摄像头权限被关闭,请开启权限后重试",
"openCamera": "去开启"
},
"wifiAddHelp": {
"helpTitle": "配置Wi-Fi说明:",
"helpCont1": "确认设备端进入配网模式(详情操作请见产品说明书)",
"helpCont2": "点击页面下方“开始配置Wi-Fi”按钮,输入正确Wi-Fi密码后开始搜索设备",
"helpCont3": "当系统搜索到设备后,设备将会连接Wi-Fi并完成激活",
"helpCont4": "提示:重新配网后,系统将会自动解除已授权用户"
},
"wifiAdd": {
"unbindWifiTip": "当前无Wi-Fi",
"wifiBinding": "正在搜索设备...",
"wifiBindSuccess": "设备正在连接Wi-Fi...",
"wifiBindFailue": "设备连接Wi-Fi失败",
"deviceActivating": "正在等待设备激活...",
"deviceActivateSuccess":"激活成功",
"deviceActivateFailure":"激活失败",
"bindTimeout":"连接超时",
"passwordInputTip": "请输入Wi-Fi密码",
"remindTitle": "配置Wi-Fi提醒:",
"remindCont1": "1. 请确保Wi-Fi信号良好",
"remindCont2": "2. 本产品暂不支持5GHz无线网络",
"noticeTip": "检测到您还未开启通知,将无法及时<br>接收安全推送",
"countDownText": "{0}s",
"defaultNickName": "主用户",
"error": {
}
},
"bindUserHelp": {
"helpTitle": "配对姓名说明:",
"helpCont1": "1.在指纹锁上录入指纹、密码、卡并获得相应ID",
"helpCont2": "2.通过姓名绑定将该ID绑定对应用户姓名",
"helpCont3": "3.绑定成功后,开门记录中将会显示已绑定的用户姓名",
"helpCont4": "4.用户姓名信息只保存在APP端,不影响锁端设置",
"boundUser": "查看已绑定ID姓名"
},
"bindUser": {
"editHeadTip": "点击编辑用户头像",
"nameTitle": "姓名",
"fingerprintIDTitle": "指纹ID",
"passwordIDTitle": "密码ID",
"ICCardIDTitle": "IC卡ID",
"requiredInputTip": "(必填)",
"optionalInputTip": "(选填)",
"error": {
}
},
"commstatusLoading":{
"connectSuccess": "Wi-Fi连接成功,正在绑定...",
"bindSuccess": "绑定成功",
"bindFailed": "绑定失败"
},
"userList":{
"name": "昵称:",
"noUserTip": "暂无用户",
"defaultName": "管理员",
"binded": "已绑定",
"unbind": "未绑定"
},
"addUser":{
"nameInputTip": "请为门锁用户创建显示昵称",
"addUserSuccess": "添加用户成功",
"addUserFailure": "添加用户失败",
"error": {
"nameCanNotEmpty": "用户名不能为空"
}
},
"doorlockUser":{
"name": "昵称:",
"inviteBind": "邀请授权",
"bindUnlockInfo": "关联开锁信息",
"editUsername": "编辑用户昵称",
"opendoorRecord": "历史开门记录",
"unbindDialogTip": "<img src='../../resources/image/green_unbind_icon.png'>解除授权后,该用户不能对门锁下的信息进行查看",
"deleteUserDialogTip": "删除后,用户对应的开锁id取消关联,同时失去信息查看权限。",
"unbindSuccess": "<img src='../../resources/image/green_unbindSuccess_icon.png'>解除授权成功",
"unbindFailue": "<img src='../../resources/image/green_unbindSuccess_icon.png'>解除授权失败",
"guideStep1Tip1": "邀请授权成功",
"guideStep1Tip2": "(受邀用户可查看开门记录,报警记录等<br>相关门锁信息)",
"guideStep3Tip": "关联后可了解<br>该用户的开门情况",
"deleteSuccess": "删除成功",
"deleteFailure": "删除失败",
"defaultName": "管理员",
"bindedTip": "当前用户已授权,不可重复授权"
},
"editName":{
"nameInputTip": "请输入设备名称",
"nickNameInputTip": "请输入用户名",
"editNameSuccess": "修改名称成功",
"editNameFailue": "修改名称失败",
"error": {
"nameCanNotBeBlank": "设备名称不能为空",
"nicknameCanNotBeBlank": "用户名不能为空"
}
},
"inviteBind":{
"qrcodeExpireTip": "二维码已过期,请重新生成",
"title": "绑定方法:",
"cont1": "受邀用户登录“U智锁”APP",
"cont2": "选择“扫描绑定设备”",
"cont3": "扫描上方二维码完成绑定",
"tip": "注: 二维码有效时间为10分钟,过期请",
"buttonText": "重新生成",
"userTip": "授权用户仅可查看开门、报警等记录,无法进行远程开门操作。"
},
"unlockInfo":{
"noInfoTip": "尚未关联开锁信息",
"bindSoon": "快速关联",
"passwordOpenDoor": "密码",
"fingerprintOpenDoor": "指纹",
"ICcardOpenDoor": "IC卡",
"remoteOpenDoor": "遥控器",
"keyOpenDoor": "钥匙",
"appRemoteOpenDoor": "app远程",
"hijackingAlarm": "劫持指纹",
"setHijack": "设为劫持",
"bindUnlockInfo": "关联",
"bindedLockInfo": "已关联的开锁信息",
"addInfoSuccess": "关联开锁信息成功",
"setHijackTip": "确定设为劫持指纹? 设定成功后用该指<br>纹开锁时,系统将会视为劫持报警。",
"cancelHijack": "取消劫持",
"cancelHijackTip": "确定取消劫持指纹? 取消后用该指纹开<br>锁时,系统将会视为正常开锁。",
"cancelAssociated": "取消关联",
"cancelAssociatedTip": "取消关联后,开门记录中将不再显示关联的用户信息。",
"cancelAssociatedSuccess": "取消关联成功",
"cancelAssociatedFailue": "取消关联失败",
"setHijackSuccess": "设为劫持指纹成功",
"setHijackFailue": "设为劫持指纹失败",
"cancelHijackSuccess": "取消劫持指纹成功",
"cancelHijackFailue": "取消劫持指纹失败",
"unlockInfoListTip": "暂无关联信息",
"noHistoryTip": "今日尚无未关联的开门记录"
},
"addUnlockInfo":{
"opendoorMode": "选择要关联的开锁方式",
"fingerprint": "指纹",
"password": "密码",
"icCard": "IC卡",
"key": "钥匙",
"remote":"遥控器",
"hijackFingerprint": "劫持指纹",
"opendoorRecord": "选择要关联的开锁ID",
"tip": "仅显示未绑定开门记录",
"addInfoSuccess": "关联开锁信息成功",
"addInfoFailue": "关联开锁信息失败",
"noRecordTip": "暂无记录",
"setHijackSwitch": "设为劫持指纹",
"guideStep1Tip": "选择需要添加关联的开门方式",
"guideStep3Tip": "根据开门记录中的开门时间,选择关联的<br>开门ID<span>(一个ID只能被一个用户绑定)</span>",
"guideStep5Tip": "使用劫持指纹开门时,会以报警形式<br>通知到该门锁名下的其他绑定用户",
"bindedUnlockInfo": "查看已关联信息",
"stay": "继续关联"
},
"myInfo":{
"editNickname": "修改昵称",
"editPassword": "修改密码",
"logoutDialogTip": "确定要退出系统吗?"
},
"editNickname": {
"nickNameInputTip": "请输入昵称",
"nickNameTypeTip": "请输入中文、字母和数字"
},
"editPassword": {
"newPasswordInputTip": "请输入新密码",
"oldPasswordInputTip": "请输入旧密码",
"oldPasswordInputTipAgain": "请再次输入旧密码"
},
"request":{
"error": "数据加载失败",
"initError": "初始化失败,请关闭APP重试"
},
"deviceList":{
"model": "型号:",
"noDeviceTip": "暂无产品型号"
},
"notice":{
"tip": "您还未开启通知,将无法及时接收安全推送!",
"button": "去开启"
},
"help": {
"title": "如何解决安卓手机收不到消息提醒?",
"contTip": "因部分安卓系统会在锁屏时自动清理后台运行的应用导致无法及时通知,需根据引导进行以下设置后即可随时随地收到消息推送。",
"contTitle": "如何设置:",
"contSubtitle1": "1.设置自启动",
"contText1-1": "安卓5.0以上系统需要设置应用自启动,未加入自启动的应用在杀进程或重新开机后无法推送通知。",
"contText1-2": "在软件授权管理或启动管理中(通常在手机管家或设置菜单中)找到本app并开启自启动。",
"step": "操作步骤:",
"contSubtitle2": "2.设置后台保活",
"contText2-1": "安卓7.0以上系统需要设置受保护的后台应用,未设置的应用在设备进入睡眠后会自动杀掉,只有手动开启应用才能恢复消息推送。",
"contText2-2": "在设置中找到电量与性能,点击受保护的后台应用,找到本app并开启保护。",
"contText3-1": "安卓手机须将应用加入白名单中,否则清理后台杀掉应用进程后,只有手动开启应用才能恢复消息推送。",
"contText3-2": "启动本app后打开多任务页面(清理后台应用的页面),将本app加入白名单。"
},
"androidNotify":{
"toSettingTitle":"开启系统通知",
"toSettingsub":"去开启",
"checkSetting":"检查Android系统设置",
"IKonw":"我已阅读",
"checkSettingsubTitle":"部分安卓系统的手机在开启通知后仍无法收到推送信息,您可以依次检查以下几项设置",
"step1Title":"1. 应用是否设置为自启动状态",
"step1content":"操作步骤:在软件授权管理或启动管理中(通常在手机管家或设置菜单中)找到本APP并开启自启动。",
"step2Title":"2. 应用是否已开启后台保护",
"step2content":"操作步骤:在设置中找到电量与性能,点击受保护的后台应用,找到本APP并开启保护。",
"step3Title":"3. 是否已将应用加入系统白名单",
"step3content":"操作步骤:启动本APP后打开多任务页面(清理后台应用的页面),将本APP加入白名单。",
"endSetting":"保存设置并开启应用",
"toIndex":"进入首页"
},
"newFeature":{
"newVersion":"您有新的版本更新",
"tip": "版本更新",
"update":"更新",
"miss": "暂不更新"
},
"textTip":{
"textType": "请输入中文、字母和数字"
}
}
\ No newline at end of file
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();
}
}
/**
* v_index.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 Request from "../../public/request.js";
import moment from 'moment';
import crypto from '../../public/crypto.js';
import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js';
import uloop from '../../public/uloop.js';
import unotify from '../../public/unotify.js';
const ON_LINE = 'on';
const OFF_LINE = 'off';
iot.ready(init);
function init() {
uPublic.closeSlideBack();
//通用 图片轮播、跑马灯、开关、按钮、dialog、loading组件
uPublic.componentsInit(['u-carousel','u-marquee','u-switch','u-button','u-dialog','u-loading','u-text','u-comm-loading']);
// uPublic.componentsExtend(['update-app']);
Request.versionRequest('device/getVersion',(info)=>{
let json = {
downloadUrl : info.url,
version: info.version,
title :Vue.t('newFeature.tip'),
content :Vue.t('newFeature.newVersion'),
ok :Vue.t('newFeature.update'),
cancel :Vue.t('newFeature.miss')
};
iot.native.checkUpdate(json);
},(err)=>{
console(err);
});
if(iot.navigator.getExtras().needClose){
iot.navigator.closeAllBesidesItself();
}
// console.log(iot.native.isNotifycationOpen());
// iot.native.toNotifycationSetting();
const app = new Vue({
data:{
//开门记录
valueOpendoorRecord: 0,
//安全报警
valueSecurityAlarm: 0,
//门锁用户
valueDoorlockUser: 0,
//劫持报警
valueHijackAlarm: 0,
//远程开门
valueRemoteOpendoor: 0,
//门锁管理
valueDoorlockManage: 0,
//开门记录
opendoorRecordDisabledFlag: false,
//安全报警
securityAlarmDisabledFlag: false,
//门锁用户
doorlockUserDisabledFlag: false,
//劫持报警
hijackAlarmDisabledFlag: false,
//远程开门
remoteOpendoorDisabledFlag: true,
//门锁管理
doorlockManageDisabledFlag: false,
//门锁最新消息是否滚动
activeFlag: true,
//配置组件
componentsConfig: initComponentsConfig(),
//
followShowFlag: false,
//电量icon
batteryState: '',
//电量百分比
batteryPercent: 100,
//消息时间
msgTime: null,
//消息文本提示
msgText: '',
//门铃是否响起
doorbellRingingFlag: false,
ringTime: null,
//点击远程开门提示
remoteOpendoorFlag: false,
//设备ID
deviceId: null,
//设备mac
mac: null,
//设备uuid
uuid: null,
//设备model
model: null,
//sds设备用户信息
userInfo: null,
//门锁id
lockId: null,
//获取用户的身份
role: null,
lockInfo: {},
//最新消息
newMsg: [],
//是否第一次获取门锁信息
// isFirstGetLockInfo: true,
opendoorRecordFlag: false,
securityAlarmFlag: false,
hijackAlarmFlag: false,
msgClass: "default_img",
warmingShowFlag: false,
normalApertureShow: false,
warmingApertureShow: false,
//是否显示远程开门页面
remoteOpendoorShowFlag: false,
//远程开门密码
textPassword: null,
//远程开门错误提示
textErrorTip: null,
//当前状态
status: 0,
flag: true,
//门铃等待计时器
time: null,
//门铃总计时器
timeout: null,
//远程开门计时器
remoteTime: null,
boolPasswordMinlength: false
},
mounted(){
//显示loading
uComponents.showLoading(this);
//监听推送
notificationListener(this);
//获取设备信息
getDevices(this);
unotify.getCid((response) => {
console.log(response);
},(error) => {
console.log(error);
});
let self = this;
window.addEventListener('returnPage',function(event){
console.log('returnPage');
//获取设备信息
getDevices(self);
//注册监听上报
// registerPushListener(self);
if(event.detail.needClose){
iot.navigator.closeAllBesidesItself();
}
});
// ringBell(self);
// setTimeout(() => {
// ringBell(self);
// setTimeout(() =>{
// ringBell(self);
// },1000);
// },1000);
},
methods:{
setValueRemoteOpendoor(value){
this.valueRemoteOpendoor = value;
},
getOpendoorRecordDisabledFlag(){
return this.opendoorRecordDisabledFlag;
},
setOpendoorRecordDisabledFlag(flag){
this.opendoorRecordDisabledFlag = flag;
},
getSecurityAlarmDisabledFlag(){
return this.securityAlarmDisabledFlag;
},
setSecurityAlarmDisabledFlag(flag){
this.securityAlarmDisabledFlag = flag;
},
getDoorlockUserDisabledFlag(){
return this.doorlockUserDisabledFlag;
},
setDoorlockUserDisabledFlag(flag){
this.doorlockUserDisabledFlag = flag;
},
getHijackAlarmDisabledFlag(){
return this.hijackAlarmDisabledFlag;
},
setHijackAlarmDisabledFlag(flag){
this.hijackAlarmDisabledFlag = flag;
},
getRemoteOpendoorDisabledFlag(){
return this.remoteOpendoorDisabledFlag;
},
setRemoteOpendoorDisabledFlag(flag){
this.remoteOpendoorDisabledFlag = flag;
},
getDoorlockManageDisabledFlag(){
return this.doorlockManageDisabledFlag;
},
setDoorlockManageDisabledFlag(flag){
this.doorlockManageDisabledFlag = flag;
},
getFollowShowFlag(){
return this.followShowFlag;
},
setFollowShowFlag(boolean){
this.followShowFlag = boolean;
},
getBatteryState(){
return this.batteryState();
},
setBatteryState(number){
this.batteryState = number
},
getBatteryPercent(){
return this.batteryPercent;
},
setBatteryPercent(percent){
this.batteryPercent = percent;
},
getMsgTime(){
return this.msgTime;
},
setMsgTime(time){
this.msgTime = time
},
getMsgText(){
return this.msgText;
},
setMsgText(text){
this.msgText = text;
},
getDoorbellRingingFlag(){
return this.doorbellRingingFlag;
},
setDoorbellRingingFlag(boolean){
this.doorbellRingingFlag = boolean;
},
getRingTime(){
return this.ringTime;
},
setRingTime(time){
this.ringTime = time;
},
getRemoteOpendoorFlag(){
return this.remoteOpendoorFlag;
},
setRemoteOpendoorFlag(flag){
this.remoteOpendoorFlag = flag;
},
getUuid(){
return this.uuid;
},
setUuid(){
this.uuid = id;
},
// getIsFirstGetLockInfo(){
// return this.isFirstGetLockInfo;
// },
// setIsFirstGetLockInfo(flag){
// this.isFirstGetLockInfo = flag
// },
getLockId(){
return this.lockId;
},
setLockId(id){
this.lockId = id;
},
getRole(){
return this.role;
},
setRole(bool){
this.role = bool;
},
getLockInfo(){
return this.lockInfo;
},
setLockInfo(info){
this.lockInfo = info;
},
getMsgClass(){
return this.msgClass;
},
setMsgClass(src){
this.msgClass = src;
},
getWarmingShowFlag(){
return this.warmingShowFlag;
},
setWarmingShowFlag(flag){
this.warmingShowFlag = flag;
},
getNormalApertureShow(){
return this.normalApertureShow;
},
setNormalApertureShow(flag){
this.normalApertureShow = flag;
},
getWarmingApertureShow(){
return this.warmingApertureShow;
},
setWarmingApertureShow(flag){
this.warmingApertureShow = flag;
},
getRemoteOpendoorShowFlag(){
return this.remoteOpendoorShowFlag;
},
setRemoteOpendoorShowFlag(flag){
this.remoteOpendoorShowFlag = flag;
},
getTextPassword(){
return this.textPassword;
},
setTextPassword(pwd){
this.textPassword = pwd;
},
setTextErrorTip(tip){
this.textErrorTip = tip;
},
getStatus(){
return this.status;
},
setStatus(status){
this.status = status;
},
//tap 个人信息
onMyInfoTap(){
myInfoTap(this);
},
//tap 绑定门锁
onBindDoorlockTap(){
bindDoorlockTap();
},
//tap 门锁管理
onDoorlockManageTap(){
doorlockManageTap(this);
},
//tap 开门记录
onOpendoorRecordTap(){
opendoorRecordTap(this);
},
//tap 安全报警
onSecurityAlarmTap(){
securityAlarmTap(this);
},
//tap 门锁用户
onDoorlockUserTap(){
doorlockUserTap(this);
},
//tap 远程开门
onRemoteOpendoorTap(){
remoteOpendoorTap(this);
},
//tap 劫持报警
onHijackAlarmTap(){
hijackAlarmTap(this);
},
//tap 保存二维码到相册
onSaveQRcodeButtonTap(){
saveQRcodeButtonTap();
},
//tap 稍后关注
onLaterFollowTap(){
laterFollowTap(this);
},
//tap <
onBackTap(){
backTap(this);
},
onPasswordChange(text){
passwordChange(this,text);
},
//tap 确定
onConfirmButtonTap(){
confirmButtonTap(this);
},
onCommLoadingButtonTap(){
commLoadingButtonTap(this);
},
//tap 停止闪铃
onStopDoorbellRing(){
stopDoorbellRing(this);
},
onPasswordMatchlength(value){
passwordMatchlength(this, value);
},
//tap 退出系统
onLogoutButtonTap(){
logoutButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
//图片轮播
carousel: {
initParam: {
class:'custom-carousel',
list: [{image: '../../resources/image/image1.png'},
{image: '../../resources/image/image2.png'},
{image: '../../resources/image/image3.png'}],
auto: true,
autoTime: 2000,
loop: true
}
},
marquee: {
initParam: {
class: "custom-marquee",
text: [Vue.t('device.defaultNewMsg')],
pauseTime: 0.8,
speed: 0,
intervalTime: 2000,
horizental: 0,
direction: 1
}
},
//开门记录switch 参数
opendoorRecordSwitch: {
initParam: {
class: 'custom-switch',
text: Vue.t('device.opendoorRecord'),
autoChange: false
}
},
//安全报警switch 参数
securityAlarmSwitch: {
initParam: {
class: 'custom-switch',
text: Vue.t('device.securityAlarm'),
autoChange: false
}
},
doorlockUserSwitch: {
initParam: {
class: 'custom-switch',
text: Vue.t('device.doorlockUser'),
autoChange: false
}
},
//远程开门switch 参数
remoteOpendoorSwitch: {
initParam: {
class: 'custom-switch',
text: Vue.t('device.remoteOpendoor'),
autoChange: false
}
},
//劫持报警switch 参数
hijackAlarmSwitch: {
initParam: {
class: 'custom-switch',
text: Vue.t('device.hijackAlarm'),
autoChange: false
}
},
doorlockManageSwitch: {
initParam: {
class: 'custom-switch',
text: Vue.t('device.doorlockManage'),
autoChange: false
}
},
//确定 button 参数
saveQRcodeButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.saveQRcode')
}
},
confirmButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.confirm')
}
},
passwordInput: {
initParam: {
class: 'custom-text',
icon: '&#xe64d;',
placeholder: Vue.t('remoteOpendoor.passwordInputTip'),
maxlength: config.password.maxlength,
minlength: config.password.minlength
}
},
ucommloading: {
initParam: {
class: 'custom-comm-loading',
buttonText: Vue.t('btn.confirm'),
text: Vue.t('remoteOpendoor.loading'),
status: 0
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
//根据用户信息获取设备
function getDevices(self){
iot.business.sds.getDevicesByUser({
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
getDevicesSuccess(self, data);
}else{
initDeviceInfo(self);
uComponents.hideLoading(self);
}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 获取设备信息'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'获取设备信息');
}
// uPublic.openRequestErrorAlert(self);
uComponents.openAlert(self, Vue.t('device.networkError'), {
text: Vue.t('btn.iSee'), callback: function () {
plus.runtime.quit();
}
});
uComponents.hideLoading(self);
},
complete: () => {}
});
}
//获取设备成功,获取设备详细信息
function getDevicesSuccess(self, data){
self.mac = data[0].mac;
self.deviceId = data[0].sn;
self.uuid = data[0].uuid;
self.model = data[0].model;
if(self.uuid){
iot.business.device.getInfo({
data: {
sds: true,
uuid: self.uuid
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
getLockInfo(self);
}
},
error: (error) => {
console.log(error);
},
complete: () => {}
});
}
}
//从云端获取该设备详细信息
function getLockInfo(self){
console.log("getLockInfo");
iot.business.api.sendCustom('lock/getLockInfo',{
data: {
device_id: self.deviceId
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
getLockInfoSuccess(self, data);
}else{
initDeviceInfo(self);
}
},
error: (error) => {
uPublic.openRequestErrorAlert(self);
initDeviceInfo(self);
console.log(error);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
//获取设备成功,更改页面渲染
function getLockInfoSuccess(self, data){
//判断云端是否绑定
if(data.lock_id){
//更改按钮为‘可点击’样式
setValueOfSwitch(self, false);
//设置门锁信息
self.setLockInfo(data);
self.setLockId(data.lock_id);
self.setRole(data.role);
//判断是否第一次获取门锁信息
// if(self.isFirstGetLockInfo){
loopGetLockInfo(self, 10, 999, false);
getDeviceStatus(self);
// self.setIsFirstGetLockInfo(false);
// }
//存储最后一条历史记录的ID
let historyId = null
historyId = data.info.historyId ? data.info.historyId : null;
iot.storage.setMap('historyId', historyId, (res) => {
console.log(res);
}, () => {
});
//存储历史、安全、劫持记录的时间
let historyRecord = data.info.history;
if((historyRecord.open.length != 0) || Boolean(historyRecord.alarm) || Boolean(historyRecord.notify)){
updateHistoryMap(self, historyRecord);
}else{
iot.storage.delMaps(['historyId','history'], (response) => {
console.log(response);
updateHistoryMap(self, historyRecord);
}, (error) => {
console.log(error);
});
}
//拼接首页滚动的三条记录
getTreenRecord(self, data.info.history.open);
}else{
uComponents.changeMarqueeText(self, [Vue.t('device.defaultNewMsg')]);
self.activeFlag = false;
}
}
//拼接首页滚动的三条记录
function getTreenRecord(self, record){
if(record && record.length){
self.newMsg = [];
console.log(self.newMsg);
for(let i = record.length - 1; i >= 0; i--){
let msg = '';
if((record[i].mode != 30) && (record[i].mode != 5)){
msg = record[i].nickname;
}
self.newMsg.push(moment(record[i].time).format("YY.MM.DD HH:mm")+ ' ' + msg + Vue.t('device.use') + Vue.t('opendoorRecord.'+config.openDoorMode[record[i].mode]+''));
}
console.log(self.newMsg);
uComponents.changeMarqueeText(self, self.newMsg);
if(self.newMsg.length >= 2){
self.activeFlag = true;
}else{
self.activeFlag = false;
}
}else{
uComponents.changeMarqueeText(self, [Vue.t('device.noNewMsg')]);
self.activeFlag = false;
}
}
//获取设备的初始状态
function getDeviceStatus(self){
iot.business.sds.getDeviceStatus({
data: {
uuid: self.uuid
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
setBatteryPercentAndIcon(self, data.BatteryPercentage.value);
iot.storage.setMap('onLineState', data.onlineState.value, (response) => {
console.log(res);
}, () => {});
registerPushListener(self);
}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 获取设备状态'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'获取设备状态');
}
uPublic.openRequestErrorAlert(self);
}
});
}
async function updateHistoryMap(self, historyRecord){
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;
}
catch (error) {
console.log(error);
}
let openHistory = historyRecord.open;
let newHistory = oldHistory;
let now = moment(new Date()).unix();
if(openHistory.length && oldHistory.open.time < moment(openHistory[0].time).unix() && now - moment(openHistory[0].time).unix() < config.newMsg_timeout){
newHistory.open.time = moment(openHistory[0].time).unix();
newHistory.open.isReadFlag = false;
let record = openHistory;
if(record && record.length){
for(let i=0; i< record.length; i++){
let msg = '';
if((record[i].mode != 30) && (record[i].mode != 5)){
msg = record[i].nickname;
}
if(self.newMsg.length >= 3){
self.newMsg.shift();
self.newMsg.push(moment(record[i].time).format("YY.MM.DD HH:mm")+ ' ' + msg + Vue.t('device.use') + Vue.t('opendoorRecord.'+config.openDoorMode[record[i].mode]+''));
}else{
self.newMsg.push(moment(record[i].time).format("YY.MM.DD HH:mm")+ ' ' + msg + Vue.t('device.use') + Vue.t('opendoorRecord.'+config.openDoorMode[record[i].mode]+''));
}
}
uComponents.changeMarqueeText(self, self.newMsg);
if(self.newMsg.length >= 2){
self.activeFlag = true;
}else{
self.activeFlag = false;
}
}else{
uComponents.changeMarqueeText(self, [Vue.t('device.noNewMsg')]);
self.activeFlag = false;
}
}
let historyType = ['alarm','notify'];
for(let i=0 ; i < historyType.length; i++){
if(historyRecord.hasOwnProperty(historyType[i]) && oldHistory[historyType[i]].time < moment(historyRecord[historyType[i]]).unix() && now - moment(historyRecord[historyType[i]]).unix() < config.newMsg_timeout){
newHistory[historyType[i]].time = moment(historyRecord[historyType[i]]).unix();
newHistory[historyType[i]].isReadFlag = false;
console.log(moment(historyRecord[historyType[i]]).unix());
}
}
console.log(oldHistory);
console.log(newHistory);
iot.storage.setMap('history', newHistory, (response) => {
console.log(res);
}, () => {
});
iot.storage.getMap('history', (response) => {
self.securityAlarmFlag = !response.notify.isReadFlag;
self.hijackAlarmFlag = !response.alarm.isReadFlag;
self.opendoorRecordFlag = !response.open.isReadFlag;
console.log(self.securityAlarmFlag);
if(self.hijackAlarmFlag == true){
//停止响铃
stopDoorbellRing(self);
//当前数据是新获取的数据时,有historyRecord.alarm,再次获取时无historyRecord.alarm,此时使用缓存时间
if(historyRecord.alarm){
//显示劫持报警
setMsgStatus(self, true, "hijack_img", false, true, moment(historyRecord.alarm,"YYYY-MM-DD hh:mm:ss").format("HH:mm"), Vue.t('device.hijackAlarm'));
}else{
//显示劫持报警
setMsgStatus(self, true, "hijack_img", false, true, moment.unix(response.alarm.time).format("HH:mm"), Vue.t('device.hijackAlarm'));
}
}else if(self.securityAlarmFlag == true){
//停止响铃
stopDoorbellRing(self);
//当前数据是新获取的数据时,有historyRecord.notify,再次获取时无historyRecord.notify,此时使用缓存时间
if(historyRecord.notify){
//显示安全报警
setMsgStatus(self, true, "securityAlarm_img", false, true, moment(historyRecord.notify,"YYYY-MM-DD hh:mm:ss").format("HH:mm"), Vue.t('device.securityAlarm'));
}else{
//显示安全报警
setMsgStatus(self, true, "securityAlarm_img", false, true, moment.unix(response.notify.time).format("HH:mm"), Vue.t('device.securityAlarm'));
}
}else{
//停止响铃
stopDoorbellRing(self);
if((self.getMsgClass() == 'hijack_img') || (self.getMsgClass() == 'securityAlarm_img')){
setMsgStatus(self, false, "default_img", false, false, '', '');
}
}
}, () => {
});
}
//云端获取设备信息失败
function initDeviceInfo(self){
setValueOfSwitch(self, true);
self.setLockId(null);
self.mac = null;
self.deviceId = null;
self.uuid = null;
uComponents.changeMarqueeText(self, [Vue.t('device.defaultNewMsg')]);
self.activeFlag = false;
self.opendoorRecordFlag = false;
self.securityAlarmFlag = false;
self.hijackAlarmFlag = false;
self.setRemoteOpendoorDisabledFlag(true);
self.setValueRemoteOpendoor(0);
setMsgStatus(self, false, "default_img", false, false, '', '');
}
//轮训获取门锁记录
async function loopGetLockInfo(self, delay, times, needStop){
let oldHistoryId = null;
try{
let historyId = await iot.storage.getMap('historyId');
if(historyId){
oldHistoryId = historyId;
}
}
catch (error){
console.log(error);
}
console.log(oldHistoryId);
new uloop({
loopContent: () => {
var urlParams = {
type: 'post',
data: {
history_id: oldHistoryId,
device_id: self.deviceId
}
};
return iot.business.api.send('lock/getNewInfo', urlParams, true, false);
// return plus.push.getClientInfo().clientid;
},
times: times,
interval:{
delay: delay*1000,
cb: {
success: (response) => {
console.log('intervalcbSuccess:'+JSON.stringify(response));
if(!needStop){
let historyRecord = response.data.history;
updateHistoryMap(self, historyRecord);
}
},
error: (error) => {
console.log('intervalcbError:'+JSON.stringify(error));
}
}
},
fincb: {
success:(response) => {
console.log(response);
let historyRecord = response.data.history;
updateHistoryMap(self, historyRecord);
},
error: (error) => {
console.log(error);
},
complete: () => {
uComponents.hideLoading(self);
}
},
stopcondition: async (response) => {
console.log(response);
let data = response.data;
if(data.hasOwnProperty('historyId')){
let newHistoryId = data.historyId;
if(oldHistoryId != newHistoryId){
iot.storage.setMap('historyId', newHistoryId, (res) => {
console.log(res);
oldHistoryId = newHistoryId;
}, () => {
});
return needStop;
}
}
}
}).start();
}
function setValueOfSwitch(self, flag){
self.setOpendoorRecordDisabledFlag(flag);
self.setSecurityAlarmDisabledFlag(flag);
self.setDoorlockUserDisabledFlag(flag);
self.setHijackAlarmDisabledFlag(flag);
self.setDoorlockManageDisabledFlag(flag);
self.valueOpendoorRecord = !flag;
self.valueSecurityAlarm = !flag;
self.valueDoorlockUser = !flag;
self.valueHijackAlarm = !flag;
self.valueDoorlockManage = !flag;
}
//sds监听
function registerPushListener(self){
iot.business.sds.registerPushListener({
success: (response) => {
console.log("registerPushListener");
console.log(response);
let data = uPublic.checkResponseData(response.data.params.data);
if(data){
sdsDataPorcessing(self, data);
}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 常链接失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'常链接失败');
}
uPublic.openRequestErrorAlert(self);
}
});
}
//sds消息处理方法
async function sdsDataPorcessing(self, data){
let onlineState = await iot.storage.getMap('onLineState');
console.log(data);
//设置电量百分比和icon
setBatteryPercentAndIcon(self, data.BatteryPercentage.value);
if(onlineState == data.onlineState.value){
switch(data.action.value){
case 'notify':
switch(data.notify_type.value){
case '104':
//门铃
setBellRing(self, moment(new Date(), "YYYY-MM-DD hh:mm:ss"));
break;
case '5':
//远程开门请求
setRemoteOpendoor(self, moment(new Date(), "YYYY-MM-DD hh:mm:ss"));
break;
case '1':
case '2':
case '3':
//防撬、试错、欠电报警
//轮循获取最新的历史记录
loopGetLockInfo(self, config.intervalTime, config.getHistoryTimes, true);
break;
}
break;
case 'lock_log':
switch(data.lock_action.value){
case '4':
//远程开门成功
//切换轮循loading样式
setRemoteOpenDoorLoading(self, 1, Vue.t('remoteOpendoor.openDoorSuccess'), Vue.t('btn.confirm'));
case '1':
//轮循获取最新的历史记录
loopGetLockInfo(self, config.intervalTime, config.getHistoryTimes, true);
break;
case '5':
//远程开门失败
setRemoteOpenDoorLoading(self, 2, Vue.t('remoteOpendoor.openDoorFailure'), Vue.t('remoteOpendoor.remoteOpendoorAgain'));
break;
case '6':
//远程开门超时
if(self.getRemoteOpendoorShowFlag()){
uComponents.openAlert(self, Vue.t('remoteOpendoor.remoteTimeout'), {
text: Vue.t('dialog.confirm'), callback: function () {
self.setValueRemoteOpendoor(false);
self.setRemoteOpendoorDisabledFlag(true);
self.setRemoteOpendoorShowFlag(false);
if(self.getMsgClass() == 'remoteOpendoor_img'){
setMsgStatus(self, false, "default_img", false, false, '', '');
}
window.clearTimeout(self.remoteTime);
uComponents.hideCommLoading(self);
}
});
}else{
self.setValueRemoteOpendoor(false);
self.setRemoteOpendoorDisabledFlag(true);
if(self.getMsgClass() == 'remoteOpendoor_img'){
setMsgStatus(self, false, "default_img", false, false, '', '');
}
}
break;
}
break;
}
}else{
iot.storage.setMap('onLineState', data.onlineState.value, (response) => {
console.log(res);
}, () => {});
}
}
//设置电量百分比、电量icon
function setBatteryPercentAndIcon(self, value){
console.log('setBatteryPercentAndIcon'+value);
self.setBatteryPercent(value);
let state = 5;
if(value >= 10){
//向上取整
state = config.powerIcon[Math.ceil(value/20)];
}else{
state = config.powerIcon[Math.round(value/20)];
}
self.setBatteryState(state);
}
//设置门铃
function setBellRing(self, time){
let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
time = moment(time, "YYYY-MM-DD hh:mm:ss");
if(now.diff(time,'seconds') < config.pushMsg_timeout && now.diff(time,'seconds') >= 0){
ringBell(self, time);
}
}
//设置远程开门
function setRemoteOpendoor(self, time){
let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
time = moment(time, "YYYY-MM-DD hh:mm:ss");
console.log(now.diff(time,'seconds'));
if(now.diff(time,'seconds') < config.pushMsg_timeout && now.diff(time,'seconds') >= 0 && (self.getRole() == 0)){
self.setValueRemoteOpendoor(true);
self.setRemoteOpendoorDisabledFlag(false);
//停止响铃
stopDoorbellRing(self);
if((self.getMsgClass() != 'hijack_img') && (self.getMsgClass() != 'securityAlarm_img')){
setMsgStatus(self, false, "remoteOpendoor_img", true, false, time.format("HH:mm"), Vue.t('device.remoteOpendoor'));
}
// //设置当前为普通状态
// self.setWarmingShowFlag(false);
// //更换icon
// self.setMsgIconSrc("../../resources/image/green_remoteOpendoor_icon.png");
// //开启普通动画效果
// self.setNormalApertureShow(true);
// self.setMsgTime(time.format("HH:mm"));
// self.setMsgText(Vue.t('device.remoteOpendoor'));
setTimeout(function(){
self.setValueRemoteOpendoor(false);
self.setRemoteOpendoorDisabledFlag(true);
if(self.getMsgClass() == 'remoteOpendoor_img'){
setMsgStatus(self, false, "default_img", false, false, '', '');
}
},(config.remote_timeout-now.diff(time,'seconds'))*1000);
}
}
//设置信息提示
function setMsgStatus(self, warmingShow, imgClass, normalAperture, warmingAperture, msgTime, msgText){
//设置当前为普通状态
self.setWarmingShowFlag(warmingShow);
//更换icon
self.setMsgClass(imgClass);
//开启普通动画效果
self.setNormalApertureShow(normalAperture);
self.setWarmingApertureShow(warmingAperture);
self.setMsgTime(msgTime);
self.setMsgText(msgText);
}
//设置远程开门样式
function setRemoteOpenDoorLoading(self, status, text, buttonText){
switch(status){
case 1:
self.setValueRemoteOpendoor(false);
self.setRemoteOpendoorDisabledFlag(true);
setMsgStatus(self,false, "default_img", false, false, '', '');
case 2:
window.clearTimeout(self.remoteTime);
uComponents.changeCommButtonText(self, buttonText);
case 0:
self.setStatus(status);
uComponents.changeCommLoadingStatusAndText(self, status, text);
break;
}
}
//响铃动画和铃声设置
function ringBell(self, time){
if(self.getDoorbellRingingFlag() === false && (self.getMsgClass() != 'remoteOpendoor_img') && (self.getMsgClass() != 'hijack_img') && (self.getMsgClass() != 'securityAlarm_img')){
self.setDoorbellRingingFlag(true);
setMsgStatus(self, false, "doorbell_img", true, false, time.format("HH:mm"), Vue.t('device.doorLockRinging'));
let p = plus.audio.createPlayer(config.audioUrl);
self.timeout = setTimeout(() => {
p = plus.audio.createPlayer(config.audioUrl);
p.play( function () {
console.log( "Audio play success!" );
}, function ( e ) {
console.log( "Audio play error: " + e.message );
});
console.log(self.timeout);
self.timeout = setTimeout(() => {
console.log("in2");
p = plus.audio.createPlayer(config.audioUrl);
p.play( function () {
console.log( "Audio play success!" );
}, function ( e ) {
console.log( "Audio play error: " + e.message );
});
console.log(self.timeout);
self.timeout = setTimeout(() => {
self.setDoorbellRingingFlag(false);
self.setNormalApertureShow(false);
console.log(self.timeout);
},1500);
},2000);
},500);
}
}
function pushAction(self, msg) {
var payload = msg.payload;
if (typeof payload == 'string') {
payload = JSON.parse(msg.payload);
}
notifyDataProcessing(self, payload);
}
//推送消息处理方法
function notifyDataProcessing(self, payload){
switch(payload.type){
// case 'open':
// case 'notify':
// case 'alarm':
// //开门推送、安全报警、劫持报警
// //历史记录信息只拿一遍,不需要轮询
// getLockInfo(self);
// break;
case 'ring':
//门铃
setBellRing(self, payload.time);
break;
case 'remoteOpen':
//远程开门
setRemoteOpendoor(self, payload.time);
break;
}
}
function notificationListener(self) {
// 从系统消息中心点击消息启动应用事件
plus.push.addEventListener('click', function (msg) {
pushAction(self, msg);
}, false);
// 应用从推送服务器接收到推送消息事件
plus.push.addEventListener('receive', function (msg) {
}, false);
}
//tap 个人信息
function myInfoTap(self){
iot.navigator.openWindow({
url: '../myInfo/index.html',
id: 'myInfo',
extras: {
nickname: self.nickname
}
});
}
//tap 绑定门锁
function bindDoorlockTap(){
iot.navigator.openWindow({
url: '../../../../view/addDevice/index.html',
id: 'addDevice'
});
}
//tap 开门记录
function opendoorRecordTap(self){
if(self.valueOpendoorRecord){
self.opendoorRecordFlag = false;
setMsgStatus(self, false, "default_img", false, false, '', '');
iot.navigator.openWindow({
url: './opendoorRecord.html',
id: 'opendoorRecord',
extras: {
deviceId: self.deviceId
}
});
}
}
//tap 安全报警
function securityAlarmTap(self){
if(self.valueSecurityAlarm){
self.securityAlarmFlag = false;
setMsgStatus(self, false, "default_img", false, false, '', '');
iot.navigator.openWindow({
url: './alarmInfo.html',
id: 'alarmInfo',
extras: {
deviceId: self.deviceId
}
});
}
}
//tap 劫持报警
function hijackAlarmTap(self){
if(self.valueHijackAlarm){
self.hijackAlarmFlag = false;
setMsgStatus(self, false, "default_img", false, false, '', '');
iot.navigator.openWindow({
url: './hijackRecord.html',
id: 'hijackRecord',
extras: {
deviceId: self.deviceId
}
});
}
}
//tap 门锁用户
function doorlockUserTap(self){
if(self.valueDoorlockUser){
iot.navigator.openWindow({
url: '../doorlockUsers/index.html',
id: 'doorlockUsers',
extras: {
deviceId: self.deviceId,
uuid: self.getUuid(),
lockId: self.getLockId(),
role: self.getRole(),
}
});
}
}
//tap 远程开门
function remoteOpendoorTap(self){
iot.business.sds.getDeviceStatus({
data: {
uuid: self.uuid
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
if(data.onlineState.value == ON_LINE){
if(self.valueRemoteOpendoor){
self.setTextPassword('');
self.setRemoteOpendoorShowFlag(true);
}
}else{
uComponents.openAlert(self, Vue.t('remoteOpendoor.offlineTip'), {
text: Vue.t('dialog.confirm'), callback: function () {
self.setValueRemoteOpendoor(false);
self.setRemoteOpendoorDisabledFlag(true);
if(self.getMsgClass() == 'remoteOpendoor_img'){
setMsgStatus(self, false, "default_img", false, false, '', '');
}
}
});
}
}
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
}
});
}
//tap 门锁管理
function doorlockManageTap(self){
if(self.valueDoorlockManage){
iot.navigator.openWindow({
url: '../../../../view/doorlockManage/index.html',
id: 'doorlockManage',
extras: {
deviceId: self.deviceId,
uuid: self.getUuid(),
lockInfo: self.getLockInfo()
}
});
}
}
//tap 门铃(停止响铃)
function stopDoorbellRing(self){
if(self.getMsgClass() == 'doorbell_img'){
self.setDoorbellRingingFlag(false);
self.setNormalApertureShow(false);
self.setRingTime(0);
window.clearInterval(self.time);
window.clearTimeout(self.timeout);
}
}
//tap 保存二维码到相册
function saveQRcodeButtonTap(){
alert('保存二维码到相册');
}
//tap 稍后关注
function laterFollowTap(self){
self.setFollowShowFlag(false);
}
//tap 远程开门页面返回
function backTap(self){
self.setRemoteOpendoorShowFlag(false);
}
//远程开门密码
function passwordChange(self,text){
self.setTextPassword(text);
self.setTextErrorTip('');
console.log('passwordChange: ' + self.textPassword);
}
//获取远程密码是否达到最小长度
function passwordMatchlength(self, bool) {
console.log(bool);
self.boolPasswordMinlength = bool;
}
//tap 确定(远程开门密码)
function confirmButtonTap(self){
iot.business.sds.getDeviceStatus({
data: {
uuid: self.uuid
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
if(data.onlineState.value == ON_LINE){
if(self.boolPasswordMinlength){
if(self.getTextPassword() == null || self.getTextPassword().trim() == ''){
self.setTextErrorTip(Vue.t('remoteOpendoor.error.noPasswordTip'));
}else if(uPublic.checkString(self.getTextPassword())){
self.setTextErrorTip(Vue.t('remoteOpendoor.textlengthTip'));
}else if(self.textErrorTip == ''){
uComponents.showCommLoading(self);
setRemoteOpenDoorLoading(self, 0, Vue.t('remoteOpendoor.loading'));
let keyIv = crypto.enkey(self.mac.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
}
}
},
success: (response) => {
//密码下发成功
console.log(response);
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 远程开门密码下发失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'远程开门密码下发失败');
}
uPublic.openRequestErrorAlert(self);
uComponents.hideCommLoading(self);
},
complete(){
}
});
}
self.remoteTime = setTimeout(function (){
if(self.getStatus() == 0){
setRemoteOpenDoorLoading(self, 2, Vue.t('remoteOpendoor.remoteTimeout'), Vue.t('remoteOpendoor.remoteOpendoorAgain'));
}
},config.remote_opendoor_timeout);
}else{
self.setTextErrorTip(Vue.t('remoteOpendoor.textlengthTip'));
// uComponents.openAlert(self, Vue.t('remoteOpendoor.textlengthTip'), {
// text: Vue.t('dialog.confirm'), callback: function () {
//
// }
// });
}
}else{
uComponents.openAlert(self, Vue.t('remoteOpendoor.offlineTip'), {
text: Vue.t('dialog.confirm'), callback: function () {
self.setRemoteOpendoorShowFlag(false);
self.setValueRemoteOpendoor(false);
self.setRemoteOpendoorDisabledFlag(true);
if(self.getMsgClass() == 'remoteOpendoor_img'){
setMsgStatus(self, false, "default_img", false, false, '', '');
}
}
});
}
}else{}
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
uComponents.hideCommLoading(self);
}
});
}
//tap comm-loading ‘确认’
function commLoadingButtonTap(self){
if(self.getStatus() == 1){
//远程开门成功
self.setRemoteOpendoorShowFlag(false);
}
uComponents.hideCommLoading(self);
}
//tap 退出系统
function logoutButtonTap(self){
uComponents.openConfirm(self, Vue.t('myInfo.logoutDialogTip'),
{text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.confirm'), callback: function () {
iot.business.user.logout({
data: {
// sds: false
},
success: (response) => {
console.log("sdsLogout:"+response);
let sdsResponse = response;
iot.business.websql.delMaps(['utoken', 'userinfo'], (response) => {
iot.storage.delMaps(['historyId','history','isFirstAddUser','isFristAddUnlockInfo'], (response) => {
console.log("clearMap"+response);
//打开登录页面
iot.navigator.openWindow({
url: '../login/index.html',
id: 'login',
extras: {
needClose: true
}
});
}, (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
});
}, (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
});
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
},
complete: () => {}
});
}}
);
}
\ No newline at end of file
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_addUnlockInfo.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 绑定开锁信息页面
*/
import moment from 'moment';
import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js';
iot.ready(init);
function init() {
//通用 select、开关、按钮、dialog、loading组件
uPublic.componentsInit(['u-select','u-switch','u-button','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
recordSelectIndex: 0,
openId: null,
mode: 1,
recordSelectList: [],
waysOpenDoor: [],
selectedMode: 1,
valueSetHijack: 0,
guideShowFlag: false,
guideStep1ShowFlag: false,
guideStep2ShowFlag: false,
guideStep3ShowFlag: false,
guideStep4ShowFlag: false,
guideStep5ShowFlag: false,
guideStep6ShowFlag: false,
//配置组件
componentsConfig: initComponentsConfig(),
extras: {}
},
mounted(){
this.extras = iot.navigator.getExtras();
console.log(this.extras);
let self = this;
for( let i =1 ; config.openDoorWay.hasOwnProperty(i) ;i++){
self.waysOpenDoor.push(
{
mode: i,
text: Vue.t('unlockInfo.'+config.openDoorWay[i]+'')
}
)
}
resolve(this);
},
methods:{
getRecordSelectIndex(){
return this.recordSelectIndex;
},
setRecordSelectIndex(index){
this.recordSelectIndex = index;
},
getOpenId(){
return this.openId;
},
setOpenId(id){
this.openId = id;
},
getMode(){
return this.mode;
},
setMode(mode){
this.mode = mode;
},
getRecordSelectList(){
return this.recordSelectList;
},
setRecordSelectList(list){
this.recordSelectList = list;
},
getSelectedMode(){
return this.selectedMode;
},
setSelectedMode(mode){
this.selectedMode = mode
},
getGuideShowFlag(){
return this.guideShowFlag;
},
setGuideShowFlag(boolean){
this.guideShowFlag = boolean;
},
getGuideStep1ShowFlag(){
return this.guideStep1ShowFlag;
},
setGuideStep1ShowFlag(boolean){
this.guideStep1ShowFlag = boolean;
},
getGuideStep2ShowFlag(){
return this.guideStep2ShowFlag;
},
setGuideStep2ShowFlag(boolean){
this.guideStep2ShowFlag = boolean;
},
getGuideStep3ShowFlag(){
return this.guideStep3ShowFlag;
},
setGuideStep3ShowFlag(boolean){
this.guideStep3ShowFlag = boolean;
},
getGuideStep4ShowFlag(){
return this.guideStep4ShowFlag;
},
setGuideStep4ShowFlag(boolean){
this.guideStep4ShowFlag = boolean;
},
getGuideStep5ShowFlag(){
return this.guideStep5ShowFlag;
},
setGuideStep5ShowFlag(boolean){
this.guideStep5ShowFlag = boolean;
},
getGuideStep6ShowFlag(){
return this.guideStep6ShowFlag;
},
setGuideStep6ShowFlag(boolean){
this.guideStep6ShowFlag = boolean;
},
//tap <
onBackTap(){
backTap();
},
onRecordSelectChange(value) {
recordSelectChange(this, value);
},
//tap 添加
onAddButtonTap(){
addButtonTap(this);
},
onSelectOpenDoorModeTap(index){
selectOpenDoorModeTap(this, index);
},
//tap 下一步
onNextButtonTap(){
nextButtonTap(this);
},
onNextStepButtonTap(){
nextStepButtonTap(this);
},
//tap 我知道了
onISeeButtonTap(){
iSeeButtonTap(this);
},
onSetHijackTap(value){
setHijackTap(this, value);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
recordSelect: {
initParam: {
class: 'custom-select',
list: [],
pagesize: Number.MAX_VALUE,
tip: Vue.t('addUnlockInfo.noRecordTip')
}
},
//设为劫持指纹
setHijackSwitch: {
initParam: {
class: 'custom-setHijack-switch',
text: Vue.t('addUnlockInfo.setHijackSwitch')
}
},
//添加 button 参数
addButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.add')
}
},
//下一步 button 参数
nextButton: {
initParam: {
class: 'custom-dialog-button',
text: Vue.t('btn.next')
}
},
//我知道了 button 参数
iSeeButton: {
initParam: {
class: 'custom-dialog-button',
text: Vue.t('btn.iSee')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
function resolve(self){
getTodayReccordByMode(self,self.getSelectedMode());
iot.storage.getMap('isFristAddUnlockInfo', (res) => {
if(res){
}else{
showGuide(self);
}
}, () => {
showGuide(self);
});
}
async function showGuide(self){
self.setGuideShowFlag(true);
try{
let time = await sleep(500);
self.setGuideStep1ShowFlag(true);
time = await sleep(500);
self.setGuideStep2ShowFlag(true);
}
catch (err){
console.log(err);
}
}
//tap 下一步
function nextButtonTap(self){
self.setGuideStep1ShowFlag(false);
self.setGuideStep2ShowFlag(false);
nextGuide(self);
}
async function nextGuide(self){
try{
let time = await sleep(500);
self.setGuideStep3ShowFlag(true);
time = await sleep(500);
self.setGuideStep4ShowFlag(true);
}
catch (err){
console.log(err);
}
}
//tap 下一步
function nextStepButtonTap(self){
self.setGuideStep3ShowFlag(false);
self.setGuideStep4ShowFlag(false);
nextStepGuide(self);
}
async function nextStepGuide(self){
try{
let time = await sleep(500);
self.setGuideStep5ShowFlag(true);
time = await sleep(500);
self.setGuideStep6ShowFlag(true);
}
catch (err){
console.log(err);
}
}
//tap 我知道了
function iSeeButtonTap(self){
self.setGuideShowFlag(false);
iot.storage.setMap('isFristAddUnlockInfo', true,() => {
}, () => {});
}
function sleep(time){
return new Promise(function(resolve, reject){
setTimeout(()=>{
resolve(time);
},time);
})
}
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("returnPage");
iot.navigator.back();
}
//tap <
function backTap(){
iot.navigator.aback();
}
//
function recordSelectChange(self, value) {
console.log(value);
self.recordSelectIndex = value;
console.log('recordSelectChange:' + self.recordSelectIndex);
for(let i=0; i< self.getRecordSelectList().length; i++){
if(self.recordSelectIndex == self.getRecordSelectList()[i].id){
self.setOpenId(parseInt(self.getRecordSelectList()[i].openId));
}
}
}
//tap 添加
function addButtonTap(self){
if(self.getOpenId()){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/bindOpenLog',{
data: {
device_id: self.extras.deviceId,
mode: self.getMode(),
openId: self.getOpenId(),
rel_id: self.extras.id
},
success: (response) => {
console.log(response);
if(response.data.success){
uComponents.openAlert(self, Vue.t('addUnlockInfo.addInfoSuccess'), {
text: Vue.t('dialog.confirm'), callback: function () {
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{ });
iot.navigator.back();
}
});
}else{}
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 绑定开门方式失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'绑定开门方式失败');
// }
uComponents.openAlert(vmObj, Vue.t('addUnlockInfo.addInfoFailue'), {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
setTimeout(function(){
uComponents.openAlert(vmObj, Vue.t('addUnlockInfo.addInfoFailue'), {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
uComponents.hideLoading(self);
},config.wifi_add_timeout);
}
}
function selectOpenDoorModeTap(self, index){
self.setSelectedMode(index);
self.setMode(index);
getTodayReccordByMode(self,index);
}
function getTodayReccordByMode(self, mode){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/getUnbindOpen',{
data: {
mode: self.getSelectedMode(),
device_id: self.extras.deviceId
},
success: (response) => {
console.log(response);
let data = response.data;
self.setRecordSelectList(data);
let list = [];
for(let i = 0; i < data.length; i++){
list[i] = {
value: data[i].id,
title: moment(data[i].time).format("HH:mm"),
subtitle: 'ID:'+data[i].openId
}
}
if(data.length){
self.setRecordSelectIndex(data[0].id);
for(let i=0; i< self.getRecordSelectList().length; i++){
if(self.recordSelectIndex == self.getRecordSelectList()[i].id){
self.setOpenId(parseInt(self.getRecordSelectList()[i].openId));
}
}
}
uComponents.changeSelectList(self,list);
},
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);
}
});
}
function setHijackTap(self, value){
if(value){
self.setMode(20);
}else{
self.setMode(2);
}
console.log(self.getMode());
}
/**
* 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_doorlockUsers.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 门锁用户页面
*/
import {iot, uPublic, uComponents} from '../../public/public.js';
iot.ready(init);
function init() {
//通用 按钮、dialog、loading组件
uPublic.componentsInit(['u-button','u-dialog','u-loading']);
let opener = plus.webview.currentWebview().opener();
if(opener.id == 'addUser'){
setTimeout(function () {
plus.webview.close(opener,"none",0,{});
}, 500);
}
const app = new Vue({
data:{
userInfo: {},
bindShowFlag: true,
unbindShowFlag: false,
// stateShowFlag: false,
guideShowFlag: false,
guideStep1ShowFlag: false,
guideStep2ShowFlag: false,
guideStep3ShowFlag: false,
guideStep4ShowFlag: false,
//配置组件
componentsConfig: initComponentsConfig(),
extras: {},
imageSrc: '../../resources/image/green_unbindSuccess_icon.png',
// textBindTip: Vue.t('doorlockUser.unbindSuccess'),
role: null,
info: null,
isFirstAddUser: true
},
mounted(){
this.extras = iot.navigator.getExtras();
this.role = this.extras.role;
let self = this;
window.addEventListener('returnPage',function(event){
console.log("returnPage");
iot.navigator.fire(plus.webview.getWebviewById('doorlockUsers'),'returnPage',{});
getUserInfo(self);
});
getUserInfo(this);
let opener = plus.webview.currentWebview().opener();
if(opener.id == 'addUser'){
self.isFirstAddUser = true;
}else{
self.isFirstAddUser = false;
}
},
methods:{
getBindShowFlag(){
return this.bindShowFlag;
},
setBindShowFlag(boolean){
this.bindShowFlag = boolean;
},
getUnbindShowFlag(){
return this.unbindShowFlag;
},
setUnbindShowFlag(boolean){
this.unbindShowFlag = boolean;
},
// getStateShowFlag(){
// return this.stateShowFlag;
// },
// setStateShowFlag(boolean){
// this.stateShowFlag = boolean;
// },
getGuideShowFlag(){
return this.guideShowFlag;
},
setGuideShowFlag(boolean){
this.guideShowFlag = boolean;
},
getGuideStep1ShowFlag(){
return this.guideStep1ShowFlag;
},
setGuideStep1ShowFlag(boolean){
this.guideStep1ShowFlag = boolean;
},
getGuideStep2ShowFlag(){
return this.guideStep2ShowFlag;
},
setGuideStep2ShowFlag(boolean){
this.guideStep2ShowFlag = boolean;
},
getGuideStep3ShowFlag(){
return this.guideStep3ShowFlag;
},
setGuideStep3ShowFlag(boolean){
this.guideStep3ShowFlag = boolean;
},
getGuideStep4ShowFlag(){
return this.guideStep4ShowFlag;
},
setGuideStep4ShowFlag(boolean){
this.guideStep4ShowFlag = boolean;
},
setImageSrc(src){
this.imageSrc = src;
},
// setTextBindTip(tip){
// this.textBindTip = tip;
// },
getInfo(){
return this.info;
},
setInfo(object){
this.info = object;
},
//tap <
onBackTap(){
backTap();
},
//tap 邀请绑定
onBindButtonTap(){
bindButtonTap(this);
},
//tap 解绑
onUnbindButtonTap(){
unbindButtonTap(this);
},
//tap 绑定开锁信息
onBindUnlockInfoTap(){
bindUnlockInfoTap(this);
},
//tap 编辑用户昵称
onEditNameTap(){
editNameTap(this);
},
//tap 历史开门记录
onOpendoorRecordTap(){
opendoorRecordTap(this);
},
//tap 删除该用户
onDeleteUserButtonTap(){
deleteUserButtonTap(this);
},
// onUnbindStateDialogTap(){
// unbindStateDialogTap(this);
// },
//tap 下一步
onNextButtonTap(){
nextButtonTap(this);
},
//tap 我知道了
onISeeButtonTap(){
iSeeButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
//绑定 button 参数
bindButton: {
initParam: {
class: 'custom-unbind-button',
text: Vue.t('doorlockUser.inviteBind')
}
},
//解绑 button 参数
unbindButton: {
initParam: {
class: 'custom-unbind-button',
text: Vue.t('btn.unbind')
}
},
//解绑 button 参数
unbindButton: {
initParam: {
class: 'custom-unbind-button',
text: Vue.t('btn.unbind')
}
},
//解绑 button 参数
unbindButton: {
initParam: {
class: 'custom-unbind-button',
text: Vue.t('btn.unbind')
}
},
//删除该用户 button 参数
deleteUserButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.deleteUser')
}
},
//下一步 button 参数
nextButton: {
initParam: {
class: 'custom-dialog-button',
text: Vue.t('btn.next')
}
},
//我知道了 button 参数
iSeeButton: {
initParam: {
class: 'custom-dialog-button',
text: Vue.t('btn.iSee')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
//判断是否第一次添加用户
function checkFirstAddUser(self){
iot.storage.getMap('isFirstAddUser', (res) => {
if (res) {
} else {
//显示引导动画
showGuide(self);
}
}, () => {
//显示 引导动画
showGuide(self);
});
}
//显示动画
async function showGuide(self){
self.setGuideShowFlag(true);
let time = null
console.log(self.userInfo.role);
if(self.userInfo.role == 0){
try{
time = await sleep(500);
self.setGuideStep3ShowFlag(true),
time = await sleep(500);
self.setGuideStep4ShowFlag(true);
}
catch (err){
console.log(err);
}
}else{
try{
time =await sleep(500);
self.setGuideStep1ShowFlag(true);
time = await sleep(500);
self.setGuideStep2ShowFlag(true);
}
catch (err){
console.log(err);
}
}
}
async function nextGuide(self){
try{
let time = await sleep(500);
self.setGuideStep3ShowFlag(true),
time = await sleep(500);
self.setGuideStep4ShowFlag(true);
}
catch (err){
console.log(err);
}
}
function sleep(time){
return new Promise(function(resolve, reject){
setTimeout(()=>{
resolve(time);
},time);
})
}
function getUserInfo(self){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/getUserInfo',{
data: {
rel_id: self.extras.id,
device_id: self.extras.lockId
},
success: (response) => {
let data = uPublic.checkResponseData(response.data);
console.log(data);
if(data){
if(data.user_id != self.extras){
iot.navigator.fire(plus.webview.getWebviewById('doorlockUsers'),'returnPage',{});
}
self.setInfo(data);
setUserInfo(self, data);
if(self.role == 0){
checkFirstAddUser(self);
}
}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);
}
});
}
//设置用户信息
function setUserInfo(self, data){
self.userInfo = {
imgClass: data.role == 0 ? 'userInfo-image-admin' : data.user_id == null ? 'userInfo-image-unbind' : 'userInfo-image-bind',
role: data.role,
title: data.nickname,
subtitle: ''
}
self.setBindShowFlag(data.user_id ? false : true);
self.setUnbindShowFlag(data.user_id ? true : false);
}
//tap <
function backTap(){
iot.navigator.aback();
}
//tap 编辑用户昵称
function editNameTap(self){
if(!self.role && !self.isFirstAddUser){
iot.navigator.openWindow({
url: './editName.html',
id: 'editName',
extras: {
id: self.getInfo().id,
nickname: self.getInfo().nickname,
deviceId: self.getInfo().device_id,
role: self.extras.role
}
});
}
}
//tap 邀请绑定
function bindButtonTap(self){
checkUser(self, (data) => {
if(data.auids){
uComponents.openAlert(self, Vue.t('doorlockUser.bindedTip'), {
text: Vue.t('dialog.confirm'), callback: function () {
self.setInfo(data);
setUserInfo(self, data);
}
});
}else{
iot.navigator.openWindow({
url: './inviteBind.html',
id: 'inviteBind',
extras: {
uuid: self.extras.uuid,
id: self.extras.id,
deviceId: self.getInfo().device_id,
lockId: self.extras.lockId
}
});
}
});
}
//tap 解绑
function unbindButtonTap(self){
uComponents.openConfirm(self, Vue.t('doorlockUser.unbindDialogTip'),
{text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.unbind'), callback: function () {
iot.business.sds.unbindByManager({
data: {
uuid: self.extras.uuid,
destAuid: self.info.auids
},
success: (response) => {
console.log(response);
iot.business.api.sendCustom('lock/unbindUser',{
data: {
user_id: self.getInfo().user_id,
device_sn: self.getInfo().device_id,
device_id: self.extras.lockId
},
success: (response) => {
console.log(response);
iot.navigator.fire(plus.webview.getWebviewById('doorlockUsers'),'returnPage',{});
// self.setStateShowFlag(true);
uComponents.openAlert(self, Vue.t('doorlockUser.unbindSuccess'), {
text: Vue.t('dialog.confirm'), callback: function () {
getUserInfo(self);
}
});
},
error: (error) => {
console.log(error);
// uPublic.openRequestErrorAlert(self);
// self.setImageSrc('../../resources/image/green_unbindFail_icon.png');
// self.setTextBindTip(Vue.t('doorlockUser.unbindFailue'));
// self.setStateShowFlag(true);
uComponents.openAlert(self, Vue.t('doorlockUser.unbindFailue'), {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
// self.setImageSrc('../../resources/image/green_unbindFail_icon.png');
// self.setTextBindTip(Vue.t('doorlockUser.unbindFailue'));
// self.setStateShowFlag(true);
uComponents.openAlert(self, Vue.t('doorlockUser.unbindSuccess'), {
text: Vue.t('dialog.confirm'), callback: function () {
getUserInfo(self);
}
});
},
complete: () => {
}
});
}}
);
}
//function unbindStateDialogTap(self){
// self.setStateShowFlag(false);
// self.setBindShowFlag(true);
// self.setUnbindShowFlag(false);
// self.userInfo.image = '../../resources/image/gray_unbindHead_icon.png';
//}
//tap 绑定开锁信息
function bindUnlockInfoTap(self){
iot.navigator.openWindow({
url: './unlockInfo.html',
id: 'unlockInfo',
extras: {
id: self.extras.id,
userId: self.getInfo().user_id,
deviceId: self.getInfo().device_id,
lockId: self.extras.lockId,
role: self.extras.role
}
});
}
//tap 历史开门记录
function opendoorRecordTap(self){
if(!self.isFirstAddUser){
iot.navigator.openWindow({
url: '../device/opendoorRecord.html',
id: 'opendoorRecord',
extras: {
relId: self.extras.id,
deviceId: self.getInfo().device_id
}
});
}
}
//tap 删除该用户
function deleteUserButtonTap(self){
uComponents.openConfirm(self, Vue.t('doorlockUser.deleteUserDialogTip'),
{text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.delete'), callback: function () {
deleteUser(self);
}}
);
}
//tap 下一步
function nextButtonTap(self){
self.setGuideStep1ShowFlag(false);
self.setGuideStep2ShowFlag(false);
nextGuide(self);
}
//tap 我知道了
function iSeeButtonTap(self){
self.setGuideShowFlag(false);
iot.storage.setMap('isFirstAddUser', true,() => {
}, (err) => {});
}
//删除用户
function deleteUser(self){
uComponents.showLoading(self);
//确认该用户是否被绑定
checkUser(self, (data) => {
self.setInfo(data);
//判断该用户是否绑定
if(self.info.auids){
iot.business.sds.unbindByManager({
data: {
uuid: self.extras.uuid,
destAuid: self.info.auids
},
success: (response) => {
deleteCloudeUser(self);
},
error: (error) => {
console.log(error);
uComponents.openAlert(self, Vue.t('doorlockUser.deleteFailure'), {
text: Vue.t('btn.confirm'), callback: function () {
}
});
},
complete: () => {
}
});
}else{
deleteCloudeUser(self);
}
})
}
function checkUser(self, callback){
iot.business.api.sendCustom('lock/getUserInfo',{
data: {
rel_id: self.extras.id,
device_id: self.extras.lockId
},
success: (response) => {
let data = uPublic.checkResponseData(response.data);
console.log(data);
if(data){
if(data.user_id != self.extras){
iot.navigator.fire(plus.webview.getWebviewById('doorlockUsers'),'returnPage',{});
}
callback(data);
}else{}
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
},
complete: () => {
}
});
}
function deleteCloudeUser(self){
iot.business.api.sendCustom('lock/delLockUser',{
data: {
rel_id: self.extras.id,
user_id: self.getInfo().user_id,
device_sn: self.getInfo().device_id,
device_id: self.extras.lockId
},
success: (response) => {
console.log(response);
if(response.data.success){
iot.navigator.fire(plus.webview.getWebviewById('doorlockUsers'),'returnPage',{});
uComponents.openAlert(self, Vue.t('doorlockUser.deleteSuccess'), {
text: Vue.t('btn.confirm'), callback: function () {
iot.navigator.aback();
}
});
}
},
error: (error) => {
console.log(error);
uComponents.openAlert(self, Vue.t('doorlockUser.deleteFailure'), {
text: Vue.t('btn.confirm'), callback: function () {
}
});
},
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);
}
});
}
/**
* v_unlockInfo.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 绑定开锁信息页面
*/
import moment from 'moment';
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(),
unlockInfoList: [],
openLockInfoList: [],
extras: {},
role: null,
lockItems: [],
selectItem: 0,
unlockInfoListTip: Vue.t('unlockInfo.unlockInfoListTip'),
noHistoryTip: Vue.t('unlockInfo.noHistoryTip'),
tipShowFlag: true,
infoList: [],
newUnlockInfo: false
// list: [],
// pullup: false,
// loadText: Vue.t('scroll.clickToLoadMore'),
// // loading是否显示
// loadShowFlag: false,
// // 是否在loading
// loadFlag: false,
// tipShowFlag: false
},
mounted(){
this.extras = iot.navigator.getExtras();
this.role = this.extras.role;
console.log(this.extras);
let self = this;
this.lockItems = [{text: Vue.t('unlockInfo.bindSoon')},{text: Vue.t('unlockInfo.bindedLockInfo')}];
itemChange(this, this.selectItem);
// this.setLoadShowFlag(this.infoList.length);
// let ulistDom = this.$refs.infoList;
// ulistDom.onscroll = function () {
// //在一些特殊情况下ulistDom.scrollHeight和ulistDom.offsetHeight + ulistDom.scrollTop会相差1px,这里考虑1px的误差
// console.log(self.loadFlag+'+'+self.pullup+'+'+ulistDom.scrollHeight+'+'+ulistDom.scrollTop);
// if (!self.loadFlag && self.pullup && (ulistDom.scrollHeight - (ulistDom.offsetHeight + ulistDom.scrollTop)) <= 1) {
// self.loadText = Vue.t('scroll.loading');
// self.loadFlag = true;
// getBindedLockInfo(self);
// }
// }
},
methods:{
getUnlockInfoList(){
return this.unlockInfoList;
},
setUnlockInfoList(list){
this.unlockInfoList = list
},
getOpenLockInfoList(){
return this.openLockInfoList;
},
setOpenLockInfoList(list){
this.openLockInfoList = list;
},
getSelectItem(){
return this.selectItem;
},
setSelectItem(index){
this.selectItem = index;
},
getInfoList(){
return this.infoList;
},
setInfoList(list){
this.infoList = list;
},
getNewUnlockInfo(){
return this.newUnlockInfo;
},
setNewUnlockInfo(info){
this.newUnlockInfo = info;
},
//tap <
onBackTap(){
backTap();
},
// onAddTap(){
// //tap 添加
// addTap(this);
// },
onItemChange(key){
itemChange(this, key);
},
onImgButtonTap(index, buttonIndex){
imgButtonTap(this, index, buttonIndex);
},
setLoadShowFlag(number) {
this.loadShowFlag = (number >= this.pagesize);
},
onTapLoad() {
tapLoad(this);
},
changeList(list) {
changeList(this, list);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
}
}
//tap <
function backTap(){
iot.navigator.back();
}
//tap 添加
function addTap(self){
iot.navigator.openWindow({
url: './addUnlockInfo.html',
id: 'addUnlockInfo',
extras: {
deviceId: self.extras.deviceId,
id: self.extras.id
}
});
}
//点击加载更多
function tapLoad(){
if (!self.loadFlag) {
self.loadText = Vue.t('scroll.loading');
self.loadFlag = true;
//再次发送获取用户列表请求
}
}
//获取已绑定的开锁信息
function getBindedLockInfo(self){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/getBindOpen',{
data: {
rel_id: self.extras.id,
device_id: self.extras.deviceId
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
console.log(data);
self.setOpenLockInfoList(data);
let list = [];
let j = 1;
let lastMode = null;
for(let i=0; i<data.length; i++){
if(data[i].mode != lastMode){
j = 1;
}
list[i] = {
title: Vue.t('unlockInfo.'+config.openDoorMode[data[i].mode]+'')+j+'',
subtitle: 'ID:'+data[i].openId,
// buttons: self.extras.role ? [] : [{'text': data[i].mode == 20 ? Vue.t('unlockInfo.cancelHijack') : data[i].mode == 2 ? Vue.t('unlockInfo.setHijack') : ''},{'text': Vue.t('unlockInfo.cancelAssociated')}]
buttons: self.extras.role ? [] : (data[i].mode == 20 || data[i].mode == 2) ? [{"imgClass": data[i].mode == 20 ? "button-image-deleteHijack" : "button-image-setHijack"},{"imgClass": "button-image-deleteUnlockInfo"}] : [{"imgClass": null},{"imgClass": "button-image-deleteUnlockInfo"}]
};
j++;
lastMode = data[i].mode;
}
//更新列表
self.setInfoList(list);
// changeList(self, list);
}else{
//当已绑定信息为空时,列表渲染为空
self.setInfoList([]);
}
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
function unlockInfoListButtonTap(self, value, buttonValue) {
//设为劫持&取消劫持
if(buttonValue == '0'){
if(self.getOpenLockInfoList()[value].mode == 2){
uComponents.openConfirm(self, Vue.t('unlockInfo.setHijackTip'),
{text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.confirm'), callback: function () {
console.log("设为劫持");
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/updateBindLog',{
data: {
mode: 20,
id: self.getOpenLockInfoList()[value].id,
rel_id: self.extras.id
},
success: (response) => {
console.log(response);
uComponents.openAlert(self, Vue.t('unlockInfo.setHijackSuccess'), {
text: Vue.t('dialog.confirm'), callback: function () {
getBindedLockInfo(self);
}
});
},
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('unlockInfo.setHijackFailue'), {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
}});
}else{
uComponents.openConfirm(self, Vue.t('unlockInfo.cancelHijackTip'),
{text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.confirm'), callback: function () {
console.log("取消劫持");
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/updateBindLog',{
data: {
mode: 2,
id: self.getOpenLockInfoList()[value].id,
rel_id: self.extras.id
},
success: (response) => {
console.log(response);
uComponents.openAlert(self, Vue.t('unlockInfo.cancelHijackSuccess'), {
text: Vue.t('dialog.confirm'), callback: function () {
getBindedLockInfo(self);
}
});
},
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('unlockInfo.cancelHijackFailue'), {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
}});
}
}
//取消关联
else if(buttonValue == '1'){
console.log(self.getOpenLockInfoList()[value]);
uComponents.openConfirm(self, Vue.t('unlockInfo.cancelAssociatedTip'),
{text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.confirm'), callback: function () {
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/unbindOpenLog',{
data: {
device_id: self.extras.deviceId,
mode: self.getOpenLockInfoList()[value].mode,
openId: self.getOpenLockInfoList()[value].openId,
rel_id: self.extras.id
},
success: (response) => {
console.log(response);
uComponents.openAlert(self, Vue.t('unlockInfo.cancelAssociatedSuccess'), {
text: Vue.t('dialog.confirm'), callback: function () {
getBindedLockInfo(self);
}
});
},
error: (error) => {
console.log(error);
uComponents.openAlert(self, Vue.t('unlockInfo.cancelAssociatedFailue'), {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
}}
);
}
}
function itemChange(self, key){
self.setInfoList([]);
if(key == 0){
//获取未关联的开门记录
getTodayReccord(self);
}else if(key == 1){
//获取已关联的开门记录
self.setNewUnlockInfo(false);
getBindedLockInfo(self);
}
self.setSelectItem(key);
}
function imgButtonTap(self, index, buttonIndex){
if(self.getSelectItem() == 0){
addButtonTap(self, index);
}else if(self.getSelectItem() == 1){
unlockInfoListButtonTap(self, index, buttonIndex);
}
}
//获取当天未绑定的开门记录
function getTodayReccord(self){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/getUnbindOpen',{
data: {
device_id: self.extras.deviceId
},
success: (response) => {
console.log(response);
let data = response.data;
self.setUnlockInfoList(data);
let list = [];
for(let i = 0; i < data.length; i++){
list[i] = {
value: data[i].id,
title: 'ID:'+data[i].openId,
subtitle: moment(data[i].time).format("HH:mm")+' '+Vue.t('opendoorRecord.'+config.openDoorMode[data[i].mode]+''),
buttons: [{"text": Vue.t('unlockInfo.bindUnlockInfo')}]
}
}
self.setInfoList(list);
},
error: (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
//tap 添加
function addButtonTap(self, index){
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/bindOpenLog',{
data: {
device_id: self.extras.deviceId,
mode: parseInt(self.getUnlockInfoList()[index].mode),
openId: parseInt(self.getUnlockInfoList()[index].openId),
rel_id: self.extras.id
},
success: (response) => {
console.log(response);
if(response.data.success){
uComponents.openAlert(self, Vue.t('unlockInfo.addInfoSuccess'),
{text: Vue.t('btn.confirm'), callback: function () {
getTodayReccord(self);
self.setNewUnlockInfo(true);
}});
}else{}
},
error: (error) => {
console.log(error);
uComponents.openAlert(vmObj, Vue.t('addUnlockInfo.addInfoFailue'), {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
// // 通知点击加载更多事件
//function tapLoad(self) {
// // loading
// if (!self.loadFlag && !self.pullup) {
// getBindedLockInfo(self);
// 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;
// });
//}
\ No newline at end of file
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] = ["." + 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'
};
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