Commit 6e46873f by 朱建香

1207删除web里的js

parent ae658cb9
dev/node_modules dev/node_modules
web/lib/js/p.js
web/lib/js/p.js.map web/lib/js/p.js.map
web/lib/dist web/lib/dist
web/view/*.map web/view/*.map
web/view/*.js
web/view/*/*.map web/view/*/*.map
web/view/*/*.js
This source diff could not be displayed because it is too large. You can view the blob instead.
webpackJsonp([27],{
/***/ 196:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_deviceList.js
* Version: 0.1
* User: wy
* Date: 2017-11-03
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 产品型号页面
*/
function init() {
//通用 list、dialog、loading组件
_public.uPublic.componentsInit(['u-list', 'u-dialog', 'u-loading']);
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig(),
deviceList: null
},
mounted: function mounted() {
getDeviceList(this);
},
methods: {
getDeviceList: function getDeviceList() {
return this.deviceList;
},
setDeviceList: function setDeviceList(list) {
this.deviceList = list;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
onDeviceListRowTap: function onDeviceListRowTap(value) {
deviceListRowTap(this, value);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
var model = Vue.t('deviceList.model');
return {
deviceList: {
initParam: {
class: 'custom-device-list',
list: [],
tip: ''
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
function getDeviceList(self) {
_public.iot.business.sds.getProductList({
success: function success(response) {
console.log(response);
var list = [];
var data = response.data;
self.setDeviceList(data);
for (var i = 0; i < data.length; i++) {
list[i] = {
leftImage: data[i].icon,
title: data[i].deviceName,
subtitle: Vue.t('deviceList.model') + data[i].model,
rightIcon: '&#xe6a7;'
};
}
_public.uComponents.changeList(self, list);
},
error: function error(_error) {
if (window.iotDebug) {
iotDebug.push('end: 获取设备列表失败' + JSON.stringify(_error));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '获取设备列表失败');
}
}
});
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
function deviceListRowTap(self, value) {
console.log(self.getDeviceList()[value].model);
_public.iot.navigator.openWindow({
url: './wifiAddHelp.html',
id: 'wifiAddHelp',
extras: {
model: self.getDeviceList()[value].model
}
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 297:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(196);
/***/ })
},[297]);
//# sourceMappingURL=deviceList.js.map
\ No newline at end of file
webpackJsonp([26],{
/***/ 197:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_index.js
* Version: 0.1
* User: wy
* Date: 2017-09-07
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 添加设备页面
*/
function init() {
//通用 dialog、loading组件
_public.uPublic.componentsInit(['u-dialog', 'u-loading']);
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
methods: {
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 扫描绑定设备
onScanAddTap: function onScanAddTap() {
scanAddTap();
},
//tap 配置Wi-Fi
onWifiAddTap: function onWifiAddTap() {
wifiAddTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 扫描绑定设备
function scanAddTap() {
_public.iot.navigator.openWindow({
url: './scanCodeAdd.html',
id: 'scanCodeAdd'
});
}
//tap 配置Wi-Fi
function wifiAddTap() {
_public.iot.navigator.openWindow({
url: './wifiAddHelp.html',
id: 'wifiAddHelp'
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 298:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(197);
/***/ })
},[298]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
webpackJsonp([25],{
/***/ 198:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_scanCodeAdd.js
* Version: 0.1
* User: wy
* Date: 2017-09-07
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 扫描绑定设备页面
*/
function init() {
//通用 dialog、loading组件
_public.uPublic.componentsInit(['u-dialog', 'u-loading']);
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {
var self = this;
if (plus.os.name == 'Android') {
_public.iot.permission.checkPermission(['CAMERA'], function (res) {
console.log('success', res);
openScanCode(self);
}, function (err) {
console.log('error', err);
});
} else {
openScanCode(self);
}
},
methods: {
//tap <
onBackTap: function onBackTap() {
backTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
function openScanCode(self) {
_public.iot.utils.scanBarcode({
data: {
id: 'bcid',
styles: {
frameColor: '#00ffff',
scanbarColor: '#00ffff',
background: '#242b35'
}
},
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
//扫描成功
var result = JSON.parse(data.result);
var qrKey = result.qrKey;
var lockId = result.lockId;
var relId = result.relId;
//绑定设备
_public.iot.business.sds.scanqr({
data: {
qrKey: qrKey
},
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
//云端绑定
deviceBind(self, lockId, relId);
} else {}
},
error: function error(_error) {
//绑定失败
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 绑定失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'绑定失败');
// }
_public.uComponents.openAlert(self, Vue.t('addDevice.bindFailure'), {
text: Vue.t('dialog.confirm'), callback: function callback() {}
});
}
});
} else {}
},
error: function error(_error2) {
//请求失败
console.log(_error2);
// if(window.iotDebug){
// iotDebug.push('end: 扫描失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'扫描失败');
// }
_public.uPublic.openRequestErrorAlert(self);
}
});
}
function deviceBind(self, lockId, relId) {
_public.iot.business.api.sendCustom('lock/bindUser', {
data: {
device_id: lockId,
rel_id: relId,
// mac: parameters.mac,
nickname: ''
},
success: function success(response) {
console.log(response);
var data = response.data;
if (data.success) {
_public.uComponents.openAlert(self, Vue.t('addDevice.bindSuccess'), {
text: Vue.t('dialog.confirm'), callback: function callback() {
_public.iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
}
});
}
},
error: function error(_error3) {
console.log(_error3);
// if(window.iotDebug){
// iotDebug.push('end: 云端绑定失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'云端绑定失败');
// }
_public.uComponents.openAlert(self, Vue.t('addDevice.bindFailure'), {
text: Vue.t('dialog.confirm'), callback: function callback() {}
});
},
complete: function complete() {}
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 299:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(198);
/***/ })
},[299]);
//# sourceMappingURL=scanCodeAdd.js.map
\ No newline at end of file
webpackJsonp([24],{
/***/ 199:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _config = __webpack_require__(9);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* v_wifiAdd.js
* Version: 0.1
* User: wy
* Date: 2017-09-07
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 连接Wi-Fi页面
*/
_public.iot.ready(init);
function init() {
//通用 input、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-button', 'u-comm-loading', 'u-dialog', 'u-loading']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
textWiFiName: null,
textPassword: null,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig(),
status: 0
},
mounted: function mounted() {
resolve(this);
},
methods: {
getTextWiFiName: function getTextWiFiName() {
return this.textWiFiName;
},
setTextWiFiName: function setTextWiFiName(text) {
this.textWiFiName = text;
},
getTextPassword: function getTextPassword() {
return this.textPassword;
},
setTextPassword: function setTextPassword(pwd) {
this.textPassword = pwd;
},
gettTextErrorTip: function gettTextErrorTip() {
return this.textErrorTip;
},
setTextErrorTip: function setTextErrorTip(tip) {
this.textErrorTip = tip;
},
getStatus: function getStatus() {
return this.status;
},
setStatus: function setStatus(status) {
this.status = status;
},
onPasswordChange: function onPasswordChange(text) {
passwordChange(this, text);
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 连接
onConnectButtonTap: function onConnectButtonTap() {
connectButtonTap(this);
},
//tap loading button
onCommLoadingButtonTap: function onCommLoadingButtonTap() {
commLoadingButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
passwordInput: {
initParam: {
class: 'custom-password-text',
icon: '&#xe64d;',
placeholder: Vue.t('wifiAdd.passwordInputTip'),
type: 'password'
}
},
//连接 button 参数
connectButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.connect')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
},
ucommloading: {
initParam: {
class: 'custom-comm-loading',
buttonText: Vue.t('btn.confirm'),
text: Vue.t('addDevice.loading'),
status: 0
}
}
};
}
function resolve(self) {
_public.iot.business.sds.getSSId({
success: function success(response) {
console.log(response);
self.textWiFiName = response.data.ssid;
console.log(self.textWiFiName);
},
error: function error(_error) {
console.log(_error);
if (window.iotDebug) {
iotDebug.push('end: 获取wifi失败' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '获取wifi失败');
}
_public.uPublic.openRequestErrorAlert(self);
}
});
}
function passwordChange(self, text) {
self.textPassword = text;
console.log('passwordChange: ' + self.textPassword);
}
_public.iot.navigator.aback = function () {
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
_public.iot.navigator.back();
};
//tap <
function backTap() {
_public.iot.navigator.aback();
}
//tap 连接
function connectButtonTap(self) {
// console.log(self.getTextWiFiName());
// console.log(self.getTextPassword());
if (self.getTextWiFiName() == null || self.getTextWiFiName().trim() == '') {
self.setTextErrorTip(Vue.t('wifiAdd.unbindWifiTip'));
} else if (self.getTextPassword() == null || self.getTextPassword().trim() == '') {
self.setTextErrorTip(Vue.t('wifiAdd.passwordInputTip'));
} else {
_public.uComponents.showCommLoading(self);
_public.iot.business.sds.findWifi({
data: {
model: _config2.default.model,
ssid: self.getTextWiFiName(),
wifiPwd: self.getTextPassword(),
timeout: 20000
},
success: function success(response) {
console.log("findWifi");
console.log(response);
if (window.iotDebug) {
iotDebug.push('end: 找WIFI' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '找WIFI');
}
if (response.data == 'onProvisioning') {
//wifi链接中
if (window.iotDebug) {
iotDebug.push('end: 配网中' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '配网中');
}
_public.uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.wifiBinding'));
} else if (response.data == 'provisioned success') {
if (window.iotDebug) {
iotDebug.push('end: 配网成功' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '配网成功');
}
//wifi连接成功,停止连接wifi
_public.uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.wifiBindSuccess'));
// iot.business.sds.stopFindWifi({
// success: (response) => {},
// error: (error) => {}
// });
}
},
error: function error(_error2) {
console.log(_error2);
if (window.iotDebug) {
iotDebug.push('end: 配网失败' + JSON.stringify(_error2));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '配网失败');
}
_public.uPublic.openRequestErrorAlert(self);
}
});
_public.iot.business.sds.findDevices({
success: function success(response) {
console.log('findDevices');
if (window.iotDebug) {
iotDebug.push('end: 找设备' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '找设备');
}
var productId = _config2.default.model;
if (response.data == "onJoining") {
if (window.iotDebug) {
iotDebug.push('end: 激活中' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '激活中');
}
_public.uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.deviceActivating'));
} else if (response.data == "joined success") {
if (window.iotDebug) {
iotDebug.push('end: 激活成功' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '激活成功');
}
var deviceId = response.info.sn;
unbind(self, deviceId, productId);
// bind(self, deviceId, productId);
} else if (response.data == "fail") {
//连接失败
if (window.iotDebug) {
iotDebug.push('end: 激活失败' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '激活失败');
}
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.deviceActivateFailure'));
self.setStatus(2);
_public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备
_public.iot.business.sds.stopFindDevices({
success: function success(response) {},
error: function error(_error3) {}
});
}
},
error: function error(_error4) {
console.log(_error4);
if (window.iotDebug) {
iotDebug.push('end: findDevicesError' + JSON.stringify(_error4));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot);
}
_public.uPublic.openRequestErrorAlert(self);
}
});
}
setTimeout(function () {
if (self.getStatus() == 0) {
console.log("timeout");
//连接失败
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.bindTimeout'));
self.setStatus(2);
_public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备
_public.iot.business.sds.stopFindDevices({
success: function success(response) {},
error: function error(_error5) {}
});
}
}, _config2.default.wifi_add_timeout);
}
//tap loading button
function commLoadingButtonTap(self) {
if (self.getStatus() == 1) {
//绑定成功
_public.uComponents.hideCommLoading(self);
_public.iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
} else if (self.getStatus() == 2) {
//绑定失败
_public.uComponents.hideCommLoading(self);
self.setStatus(0);
_public.uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('addDevice.loading'));
}
}
function unbind(self, deviceId, productId) {
console.log(deviceId);
_public.iot.business.api.sendCustom('lock/unbindDevice', {
data: {
device_sn: deviceId
},
success: function success(response) {
console.log(response);
bind(self, deviceId, productId);
if (window.iotDebug) {
iotDebug.push('end: 解绑成功' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '解绑成功');
}
},
error: function error(_error6) {
console.log(_error6);
if (window.iotDebug) {
iotDebug.push('end: 解绑失败' + JSON.stringify(_error6));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '解绑失败');
}
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.deviceActivateFailure'));
_public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
self.setStatus(2);
},
complete: function complete() {}
});
}
function bind(self, deviceId, productId) {
_public.iot.business.api.sendCustom('lock/bind', {
data: {
product_id: productId,
device_id: deviceId,
// mac: sn,
nickname: ''
},
success: function success(response) {
console.log(response);
var data = response.data;
if (data.success) {
_public.uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('wifiAdd.deviceActivateSuccess'));
_public.uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
self.setStatus(1);
}
if (window.iotDebug) {
iotDebug.push('end: 绑定成功' + JSON.stringify(response));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '绑定成功');
}
},
error: function error(_error7) {
console.log(_error7);
if (window.iotDebug) {
iotDebug.push('end: 绑定失败' + JSON.stringify(_error7));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '绑定失败');
}
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.deviceActivateFailure'));
_public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
self.setStatus(2);
},
complete: function complete() {}
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 300:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(199);
/***/ })
},[300]);
//# sourceMappingURL=wifiAdd.js.map
\ No newline at end of file
webpackJsonp([23],{
/***/ 200:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_wifiAddHelp.js
* Version: 0.1
* User: wy
* Date: 2017-09-07
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 配置Wi-Fi页面
*/
function init() {
//通用 按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading']);
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {
window.addEventListener('returnPage', function (event) {
console.log("stopFindDevice");
_public.iot.business.sds.stopFindDevices({
success: function success(response) {
console.log(response);
},
error: function error(_error) {
console.log(_error);
}
});
});
},
methods: {
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 开始配置Wi-Fi
onWifiAddButtonTap: function onWifiAddButtonTap() {
wifiAddButtonTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
//开始配置Wi-Fi button 参数
wifiAddButton: {
initParam: {
class: 'custom-help-button',
text: Vue.t('btn.wifiAdd')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 开始配置Wi-Fi
function wifiAddButtonTap() {
_public.iot.navigator.openWindow({
url: './wifiAdd.html',
id: 'wifiAdd'
});
console.log("in");
// iot.business.sds.wifiDeviceConfig({
// success: function (response) {
// console.log('wifiDeviceConfig success');
// console.log(response);
// },
// error: function (error) {
// console.log('wifiDeviceConfig error');
// console.log(error);
// }
// });
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 301:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(200);
/***/ })
},[301]);
//# sourceMappingURL=wifiAddHelp.js.map
\ No newline at end of file
webpackJsonp([8],{
/***/ 201:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _vueRouter = __webpack_require__(294);
var _vueRouter2 = _interopRequireDefault(_vueRouter);
var _public = __webpack_require__(4);
var _r_bindUserHelp = __webpack_require__(269);
var _r_bindUserHelp2 = _interopRequireDefault(_r_bindUserHelp);
var _r_bindUser = __webpack_require__(268);
var _r_bindUser2 = _interopRequireDefault(_r_bindUser);
var _r_userList = __webpack_require__(270);
var _r_userList2 = _interopRequireDefault(_r_userList);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Vue.use(_vueRouter2.default); /**
* v_index.js
* Version: 0.1
* User: wy
* Date: 2017-09-07
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* router bindUser
*/
//ID-姓名绑定路由
//绑定用户路由
//用户列表路由
_public.iot.ready(init);
function init() {
var routes = [{ path: '/', component: _r_bindUserHelp2.default }, { path: '/bindUser', component: _r_bindUser2.default }, { path: '/userList', component: _r_userList2.default }];
var router = new _vueRouter2.default({
routes: routes
});
var app = new Vue({
router: router
}).$mount('#app');
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 243:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _public = __webpack_require__(4);
//通用 input、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-button', 'u-dialog', 'u-loading']); //
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
exports.default = {
data: function data() {
return {
imageHead: '../../resources/image/gray_head_icon.png',
textName: null,
numberFingerprintID: null,
numberPasswordID: null,
numberICCardID: null,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig()
};
},
beforeRouteEnter: function beforeRouteEnter(to, from, next) {
//alert('beforeRouteEnter 路由bindUser');
next(function (vm) {});
},
beforeRouteUpdate: function beforeRouteUpdate(to, from, next) {
//alert('beforeRouteUpdate 路由bindUser');
},
mounted: function mounted() {},
methods: {
onNameChange: function onNameChange(text) {
nameChange(this, text);
},
onFingerprintIDChange: function onFingerprintIDChange(number) {
fingerprintIDChange(this, number);
},
onPasswordIDChange: function onPasswordIDChange(number) {
passwordIDChange(this, number);
},
onICCardIDChange: function onICCardIDChange(number) {
ICCardIDChange(this, number);
},
//tap <
onBackTap: function onBackTap() {
backTap(this);
},
//编辑头像
onEditHeadTap: function onEditHeadTap() {
editHeadTap();
},
//tap 我要绑定
onBindButtonTap: function onBindButtonTap() {
bindButtonTap(this);
}
}
//配置组件参数
};
function initComponentsConfig() {
return {
nameInput: {
initParam: {
class: 'custom-bindUser-text',
title: Vue.t('bindUser.nameTitle'),
placeholder: Vue.t('bindUser.requiredInputTip')
}
},
fingerprintIDInput: {
initParam: {
class: 'custom-bindUser-text',
title: Vue.t('bindUser.fingerprintIDTitle'),
placeholder: Vue.t('bindUser.optionalInputTip')
}
},
passwordIDInput: {
initParam: {
class: 'custom-bindUser-text',
title: Vue.t('bindUser.passwordIDTitle'),
placeholder: Vue.t('bindUser.optionalInputTip')
}
},
ICCardIDInput: {
initParam: {
class: 'custom-bindUser-text',
title: Vue.t('bindUser.ICCardIDTitle'),
placeholder: Vue.t('bindUser.optionalInputTip')
}
},
//我要绑定 button 参数
bindButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.bind')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
function nameChange(self, text) {
self.textName = text;
console.log('nameChange: ' + self.textName);
}
function fingerprintIDChange(self, number) {
self.numberFingerprintID = number;
console.log('fingerprintIDChange' + self.numberFingerprintID);
}
function passwordIDChange(self, number) {
self.numberPasswordID = number;
console.log('passwordIDChange' + self.numberPasswordID);
}
function ICCardIDChange(self, number) {
self.numberICCardID = number;
console.log('ICcardIDChange' + self.numberICCardID);
}
//tap <
function backTap(self) {
self.$router.go(-1);
}
//编辑头像
function editHeadTap() {
alert('编辑头像');
}
//tap 我要绑定
function bindButtonTap(self) {
self.$router.push({ path: '/userList', query: { pageName: 'bindUser' } });
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 244:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _public = __webpack_require__(4);
//通用 按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading']); //
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
exports.default = {
data: function data() {
return {
//配置组件
componentsConfig: initComponentsConfig()
};
},
beforeRouteEnter: function beforeRouteEnter(to, from, next) {
//alert('beforeRouteEnter 路由bindUserHelp');
next(function (vm) {});
},
beforeRouteUpdate: function beforeRouteUpdate(to, from, next) {
//alert('beforeRouteUpdate 路由bindUserHelp');
},
mounted: function mounted() {},
methods: {
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 绑定姓名
onBindUserButtonTap: function onBindUserButtonTap() {
bindUserButtonTap(this);
},
//tap 查看已绑定ID姓名
onBoundUserTap: function onBoundUserTap() {
boundUserTap(this);
}
}
//配置组件参数
};
function initComponentsConfig() {
return {
//绑定姓名 button 参数
bindUserButton: {
initParam: {
class: 'custom-help-button',
text: Vue.t('btn.bindUser')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 绑定姓名
function bindUserButtonTap(self) {
self.$router.push({ path: '/bindUser' });
}
//tap 查看已绑定ID姓名
function boundUserTap(self) {
self.$router.push({ path: '/userList' });
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 245:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _public = __webpack_require__(4);
//通用 侧滑列表、dialog、loading组件
_public.uPublic.componentsInit(['u-swipe-list', 'u-dialog', 'u-loading']); //
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
exports.default = {
data: function data() {
return {
//配置组件
componentsConfig: initComponentsConfig(),
pageFrom: null
};
},
beforeRouteEnter: function beforeRouteEnter(to, from, next) {
//alert('beforeRouteEnter 路由userList');
next(function (vm) {
resolve(vm, to);
});
},
beforeRouteUpdate: function beforeRouteUpdate(to, from, next) {
//alert('beforeRouteUpdate 路由userList');
},
mounted: function mounted() {},
methods: {
getPageFrom: function getPageFrom() {
return this.pageFrom;
},
setPageFrom: function setPageFrom(string) {
this.pageFrom = string;
},
//tap <
onBackTap: function onBackTap() {
backTap(this);
},
//tap list row delete
onUserListButtonTap: function onUserListButtonTap(value, buttonValue) {
userListButtonTap(this, value, buttonValue);
}
}
//配置组件参数
};
function initComponentsConfig() {
var title = Vue.t('userList.name', ['迷失者']);
var subtitle = Vue.t('userList.id', [1, 1, 1]);
return {
userList: {
initParam: {
class: 'custom-swipe-list',
list: [{ value: 1, image: '../../resources/image/white_head_icon.png', title: '姓名:迷失者', subtitle: subtitle, buttons: [{ "text": "" }] }, { value: 2, image: '../../resources/image/white_head_icon.png', title: '姓名:漫步者', subtitle: subtitle, buttons: [{ "text": "" }] }, { value: 3, image: '../../resources/image/white_head_icon.png', title: '姓名:太空旅行者', subtitle: subtitle, buttons: [{ "text": "" }] }, { value: 4, image: '../../resources/image/white_head_icon.png', title: '姓名:探索迷失者', subtitle: subtitle, buttons: [{ "text": "" }] }, { value: 5, image: '../../resources/image/white_head_icon.png', title: '姓名:麻麻272', subtitle: subtitle, buttons: [{ "text": "" }] }, { value: 6, image: '../../resources/image/white_head_icon.png', title: '姓名:代号小黄人', subtitle: subtitle, buttons: [{ "text": "" }] }],
tip: Vue.t('userList.noUserTip')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap(self) {
if (self.getPageFrom() == 'bindUser') {
self.$router.go(-3);
} else {
self.$router.go(-1);
}
}
function resolve(self, to) {
var query = to.query;
self.setPageFrom(query.pageName);
}
//tap list row delete
function userListButtonTap(self, value, buttonValue) {
if (buttonValue == '0') {
_public.uComponents.openConfirm(self, '确认删除用户xxx吗?', { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.confirm'), callback: function callback() {} });
}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 268:
/***/ (function(module, exports, __webpack_require__) {
var Component = __webpack_require__(5)(
/* script */
__webpack_require__(243),
/* template */
__webpack_require__(291),
/* scopeId */
null,
/* cssModules */
null
)
Component.options.__file = "D:\\git_zhu\\doorlock\\dev\\src\\view\\bindUser\\r_bindUser.vue"
if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key !== "__esModule"})) {console.error("named exports are not supported in *.vue files.")}
if (Component.options.functional) {console.error("[vue-loader] r_bindUser.vue: functional components are not supported with templates, they should use render functions.")}
/* hot reload */
if (false) {(function () {
var hotAPI = require("vue-hot-reload-api")
hotAPI.install(require("vue"), false)
if (!hotAPI.compatible) return
module.hot.accept()
if (!module.hot.data) {
hotAPI.createRecord("data-v-90cb1676", Component.options)
} else {
hotAPI.reload("data-v-90cb1676", Component.options)
}
})()}
module.exports = Component.exports
/***/ }),
/***/ 269:
/***/ (function(module, exports, __webpack_require__) {
var Component = __webpack_require__(5)(
/* script */
__webpack_require__(244),
/* template */
__webpack_require__(287),
/* scopeId */
null,
/* cssModules */
null
)
Component.options.__file = "D:\\git_zhu\\doorlock\\dev\\src\\view\\bindUser\\r_bindUserHelp.vue"
if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key !== "__esModule"})) {console.error("named exports are not supported in *.vue files.")}
if (Component.options.functional) {console.error("[vue-loader] r_bindUserHelp.vue: functional components are not supported with templates, they should use render functions.")}
/* hot reload */
if (false) {(function () {
var hotAPI = require("vue-hot-reload-api")
hotAPI.install(require("vue"), false)
if (!hotAPI.compatible) return
module.hot.accept()
if (!module.hot.data) {
hotAPI.createRecord("data-v-79f97db4", Component.options)
} else {
hotAPI.reload("data-v-79f97db4", Component.options)
}
})()}
module.exports = Component.exports
/***/ }),
/***/ 270:
/***/ (function(module, exports, __webpack_require__) {
var Component = __webpack_require__(5)(
/* script */
__webpack_require__(245),
/* template */
__webpack_require__(273),
/* scopeId */
null,
/* cssModules */
null
)
Component.options.__file = "D:\\git_zhu\\doorlock\\dev\\src\\view\\bindUser\\r_userList.vue"
if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key !== "__esModule"})) {console.error("named exports are not supported in *.vue files.")}
if (Component.options.functional) {console.error("[vue-loader] r_userList.vue: functional components are not supported with templates, they should use render functions.")}
/* hot reload */
if (false) {(function () {
var hotAPI = require("vue-hot-reload-api")
hotAPI.install(require("vue"), false)
if (!hotAPI.compatible) return
module.hot.accept()
if (!module.hot.data) {
hotAPI.createRecord("data-v-000e1cb4", Component.options)
} else {
hotAPI.reload("data-v-000e1cb4", Component.options)
}
})()}
module.exports = Component.exports
/***/ }),
/***/ 273:
/***/ (function(module, exports, __webpack_require__) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('div', [_c('div', {
staticClass: "header"
}, [_c('v-touch', {
staticClass: "header-left icon",
attrs: {
"tag": "span"
},
on: {
"tap": _vm.onBackTap
}
}, [_vm._v("")]), _vm._v(" "), _c('p', [_vm._v(_vm._s(_vm.$t('title.userList')))])], 1), _vm._v(" "), _c('u-swipe-list', {
ref: "uswipelist",
attrs: {
"init-param": _vm.componentsConfig.userList.initParam
},
on: {
"u-swipe-list-button-tap": function($event) {
_vm.onUserListButtonTap(arguments[0], arguments[1])
}
}
}), _vm._v(" "), _c('u-dialog', {
ref: "udialog",
attrs: {
"init-param": _vm.componentsConfig.dialog.initParam
}
}), _vm._v(" "), _c('u-loading', {
ref: "uloading",
attrs: {
"init-param": _vm.componentsConfig.loading.initParam
}
})], 1)
},staticRenderFns: []}
module.exports.render._withStripped = true
if (false) {
module.hot.accept()
if (module.hot.data) {
require("vue-hot-reload-api").rerender("data-v-000e1cb4", module.exports)
}
}
/***/ }),
/***/ 287:
/***/ (function(module, exports, __webpack_require__) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('div', [_c('div', {
staticClass: "header"
}, [_c('v-touch', {
staticClass: "header-left icon",
attrs: {
"tag": "span"
},
on: {
"tap": _vm.onBackTap
}
}, [_vm._v("")]), _vm._v(" "), _c('p', [_vm._v(_vm._s(_vm.$t('title.bindUserHelp')))])], 1), _vm._v(" "), _c('div', {
staticClass: "content"
}, [_c('ul', {
staticClass: "bindUserHelp"
}, [_c('li', [_vm._v(_vm._s(_vm.$t('bindUserHelp.helpTitle')))]), _vm._v(" "), _c('li', [_vm._v(_vm._s(_vm.$t('bindUserHelp.helpCont1')))]), _vm._v(" "), _c('li', [_vm._v(_vm._s(_vm.$t('bindUserHelp.helpCont2')))]), _vm._v(" "), _c('li', [_vm._v(_vm._s(_vm.$t('bindUserHelp.helpCont3')))]), _vm._v(" "), _c('li', [_vm._v(_vm._s(_vm.$t('bindUserHelp.helpCont4')))])]), _vm._v(" "), _c('u-button', {
attrs: {
"init-param": _vm.componentsConfig.bindUserButton.initParam
},
on: {
"u-button-tap": _vm.onBindUserButtonTap
}
}), _vm._v(" "), _c('p', {
staticClass: "linkText"
}, [_c('v-touch', {
attrs: {
"tag": "span"
},
on: {
"tap": _vm.onBoundUserTap
}
}, [_vm._v(_vm._s(_vm.$t('bindUserHelp.boundUser')))])], 1)], 1), _vm._v(" "), _c('u-dialog', {
ref: "udialog",
attrs: {
"init-param": _vm.componentsConfig.dialog.initParam
}
}), _vm._v(" "), _c('u-loading', {
ref: "uloading",
attrs: {
"init-param": _vm.componentsConfig.loading.initParam
}
})], 1)
},staticRenderFns: []}
module.exports.render._withStripped = true
if (false) {
module.hot.accept()
if (module.hot.data) {
require("vue-hot-reload-api").rerender("data-v-79f97db4", module.exports)
}
}
/***/ }),
/***/ 291:
/***/ (function(module, exports, __webpack_require__) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('div', [_c('div', {
staticClass: "header"
}, [_c('v-touch', {
staticClass: "header-left icon",
attrs: {
"tag": "span"
},
on: {
"tap": _vm.onBackTap
}
}, [_vm._v("")]), _vm._v(" "), _c('p', [_vm._v(_vm._s(_vm.$t('title.bindUser')))])], 1), _vm._v(" "), _c('div', {
staticClass: "content"
}, [_c('v-touch', {
staticClass: "editHead",
attrs: {
"tag": "ul"
},
on: {
"tap": _vm.onEditHeadTap
}
}, [_c('li', [_c('img', {
attrs: {
"src": _vm.imageHead
}
})]), _vm._v(" "), _c('li', [_vm._v(_vm._s(_vm.$t('bindUser.editHeadTip')))])]), _vm._v(" "), _c('div', {
staticClass: "inputBox"
}, [_c('u-text', {
attrs: {
"init-param": _vm.componentsConfig.nameInput.initParam,
"text": _vm.textName
},
on: {
"u-text-change": function($event) {
_vm.onNameChange(arguments[0])
}
}
}), _vm._v(" "), _c('u-text', {
attrs: {
"init-param": _vm.componentsConfig.fingerprintIDInput.initParam,
"text": _vm.numberFingerprintID
},
on: {
"u-text-change": function($event) {
_vm.onFingerprintIDChange(arguments[0])
}
}
}), _vm._v(" "), _c('u-text', {
attrs: {
"init-param": _vm.componentsConfig.passwordIDInput.initParam,
"text": _vm.numberPasswordID
},
on: {
"u-text-change": function($event) {
_vm.onPasswordIDChange(arguments[0])
}
}
}), _vm._v(" "), _c('u-text', {
attrs: {
"init-param": _vm.componentsConfig.ICCardIDInput.initParam,
"text": _vm.numberICCardID
},
on: {
"u-text-change": function($event) {
_vm.onICCardIDChange(arguments[0])
}
}
}), _vm._v(" "), (_vm.textErrorTip) ? _c('p', {
staticClass: "errorTip"
}, [_vm._v(_vm._s(_vm.textErrorTip))]) : _vm._e()], 1), _vm._v(" "), _c('u-button', {
attrs: {
"init-param": _vm.componentsConfig.bindButton.initParam
},
on: {
"u-button-tap": _vm.onBindButtonTap
}
})], 1), _vm._v(" "), _c('u-dialog', {
ref: "udialog",
attrs: {
"init-param": _vm.componentsConfig.dialog.initParam
}
}), _vm._v(" "), _c('u-loading', {
ref: "uloading",
attrs: {
"init-param": _vm.componentsConfig.loading.initParam
}
})], 1)
},staticRenderFns: []}
module.exports.render._withStripped = true
if (false) {
module.hot.accept()
if (module.hot.data) {
require("vue-hot-reload-api").rerender("data-v-90cb1676", module.exports)
}
}
/***/ }),
/***/ 294:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* vue-router v2.1.1
* (c) 2016 Evan You
* @license MIT
*/
var View = {
name: 'router-view',
functional: true,
props: {
name: {
type: String,
default: 'default'
}
},
render: function render (h, ref) {
var props = ref.props;
var children = ref.children;
var parent = ref.parent;
var data = ref.data;
data.routerView = true
var route = parent.$route
var cache = parent._routerViewCache || (parent._routerViewCache = {})
var depth = 0
var inactive = false
while (parent) {
if (parent.$vnode && parent.$vnode.data.routerView) {
depth++
}
if (parent._inactive) {
inactive = true
}
parent = parent.$parent
}
data.routerViewDepth = depth
var matched = route.matched[depth]
if (!matched) {
return h()
}
var name = props.name
var component = inactive
? cache[name]
: (cache[name] = matched.components[name])
if (!inactive) {
var hooks = data.hook || (data.hook = {})
hooks.init = function (vnode) {
matched.instances[name] = vnode.child
}
hooks.prepatch = function (oldVnode, vnode) {
matched.instances[name] = vnode.child
}
hooks.destroy = function (vnode) {
if (matched.instances[name] === vnode.child) {
matched.instances[name] = undefined
}
}
}
return h(component, data, children)
}
}
/* */
function assert (condition, message) {
if (!condition) {
throw new Error(("[vue-router] " + message))
}
}
function warn (condition, message) {
if (!condition) {
typeof console !== 'undefined' && console.warn(("[vue-router] " + message))
}
}
/* */
var encode = encodeURIComponent
var decode = decodeURIComponent
function resolveQuery (
query,
extraQuery
) {
if ( extraQuery === void 0 ) extraQuery = {};
if (query) {
var parsedQuery
try {
parsedQuery = parseQuery(query)
} catch (e) {
process.env.NODE_ENV !== 'production' && warn(false, e.message)
parsedQuery = {}
}
for (var key in extraQuery) {
parsedQuery[key] = extraQuery[key]
}
return parsedQuery
} else {
return extraQuery
}
}
function parseQuery (query) {
var res = {}
query = query.trim().replace(/^(\?|#|&)/, '')
if (!query) {
return res
}
query.split('&').forEach(function (param) {
var parts = param.replace(/\+/g, ' ').split('=')
var key = decode(parts.shift())
var val = parts.length > 0
? decode(parts.join('='))
: null
if (res[key] === undefined) {
res[key] = val
} else if (Array.isArray(res[key])) {
res[key].push(val)
} else {
res[key] = [res[key], val]
}
})
return res
}
function stringifyQuery (obj) {
var res = obj ? Object.keys(obj).map(function (key) {
var val = obj[key]
if (val === undefined) {
return ''
}
if (val === null) {
return encode(key)
}
if (Array.isArray(val)) {
var result = []
val.slice().forEach(function (val2) {
if (val2 === undefined) {
return
}
if (val2 === null) {
result.push(encode(key))
} else {
result.push(encode(key) + '=' + encode(val2))
}
})
return result.join('&')
}
return encode(key) + '=' + encode(val)
}).filter(function (x) { return x.length > 0; }).join('&') : null
return res ? ("?" + res) : ''
}
/* */
function createRoute (
record,
location,
redirectedFrom
) {
var route = {
name: location.name || (record && record.name),
meta: (record && record.meta) || {},
path: location.path || '/',
hash: location.hash || '',
query: location.query || {},
params: location.params || {},
fullPath: getFullPath(location),
matched: record ? formatMatch(record) : []
}
if (redirectedFrom) {
route.redirectedFrom = getFullPath(redirectedFrom)
}
return Object.freeze(route)
}
// the starting route that represents the initial state
var START = createRoute(null, {
path: '/'
})
function formatMatch (record) {
var res = []
while (record) {
res.unshift(record)
record = record.parent
}
return res
}
function getFullPath (ref) {
var path = ref.path;
var query = ref.query; if ( query === void 0 ) query = {};
var hash = ref.hash; if ( hash === void 0 ) hash = '';
return (path || '/') + stringifyQuery(query) + hash
}
var trailingSlashRE = /\/$/
function isSameRoute (a, b) {
if (b === START) {
return a === b
} else if (!b) {
return false
} else if (a.path && b.path) {
return (
a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') &&
a.hash === b.hash &&
isObjectEqual(a.query, b.query)
)
} else if (a.name && b.name) {
return (
a.name === b.name &&
a.hash === b.hash &&
isObjectEqual(a.query, b.query) &&
isObjectEqual(a.params, b.params)
)
} else {
return false
}
}
function isObjectEqual (a, b) {
if ( a === void 0 ) a = {};
if ( b === void 0 ) b = {};
var aKeys = Object.keys(a)
var bKeys = Object.keys(b)
if (aKeys.length !== bKeys.length) {
return false
}
return aKeys.every(function (key) { return String(a[key]) === String(b[key]); })
}
function isIncludedRoute (current, target) {
return (
current.path.indexOf(target.path.replace(/\/$/, '')) === 0 &&
(!target.hash || current.hash === target.hash) &&
queryIncludes(current.query, target.query)
)
}
function queryIncludes (current, target) {
for (var key in target) {
if (!(key in current)) {
return false
}
}
return true
}
/* */
// work around weird flow bug
var toTypes = [String, Object]
var Link = {
name: 'router-link',
props: {
to: {
type: toTypes,
required: true
},
tag: {
type: String,
default: 'a'
},
exact: Boolean,
append: Boolean,
replace: Boolean,
activeClass: String,
event: {
type: [String, Array],
default: 'click'
}
},
render: function render (h) {
var this$1 = this;
var router = this.$router
var current = this.$route
var ref = router.resolve(this.to, current, this.append);
var normalizedTo = ref.normalizedTo;
var resolved = ref.resolved;
var href = ref.href;
var classes = {}
var activeClass = this.activeClass || router.options.linkActiveClass || 'router-link-active'
var compareTarget = normalizedTo.path ? createRoute(null, normalizedTo) : resolved
classes[activeClass] = this.exact
? isSameRoute(current, compareTarget)
: isIncludedRoute(current, compareTarget)
var handler = function (e) {
if (guardEvent(e)) {
if (this$1.replace) {
router.replace(normalizedTo)
} else {
router.push(normalizedTo)
}
}
}
var on = { click: guardEvent }
if (Array.isArray(this.event)) {
this.event.forEach(function (e) { on[e] = handler })
} else {
on[this.event] = handler
}
var data = {
class: classes
}
if (this.tag === 'a') {
data.on = on
data.attrs = { href: href }
} else {
// find the first <a> child and apply listener and href
var a = findAnchor(this.$slots.default)
if (a) {
// in case the <a> is a static node
a.isStatic = false
var extend = _Vue.util.extend
var aData = a.data = extend({}, a.data)
aData.on = on
var aAttrs = a.data.attrs = extend({}, a.data.attrs)
aAttrs.href = href
} else {
// doesn't have <a> child, apply listener to self
data.on = on
}
}
return h(this.tag, data, this.$slots.default)
}
}
function guardEvent (e) {
// don't redirect with control keys
/* istanbul ignore if */
if (e.metaKey || e.ctrlKey || e.shiftKey) { return }
// don't redirect when preventDefault called
/* istanbul ignore if */
if (e.defaultPrevented) { return }
// don't redirect on right click
/* istanbul ignore if */
if (e.button !== 0) { return }
// don't redirect if `target="_blank"`
/* istanbul ignore if */
var target = e.target.getAttribute('target')
if (/\b_blank\b/i.test(target)) { return }
e.preventDefault()
return true
}
function findAnchor (children) {
if (children) {
var child
for (var i = 0; i < children.length; i++) {
child = children[i]
if (child.tag === 'a') {
return child
}
if (child.children && (child = findAnchor(child.children))) {
return child
}
}
}
}
var _Vue
function install (Vue) {
if (install.installed) { return }
install.installed = true
_Vue = Vue
Object.defineProperty(Vue.prototype, '$router', {
get: function get () { return this.$root._router }
})
Object.defineProperty(Vue.prototype, '$route', {
get: function get$1 () { return this.$root._route }
})
Vue.mixin({
beforeCreate: function beforeCreate () {
if (this.$options.router) {
this._router = this.$options.router
this._router.init(this)
Vue.util.defineReactive(this, '_route', this._router.history.current)
}
}
})
Vue.component('router-view', View)
Vue.component('router-link', Link)
var strats = Vue.config.optionMergeStrategies
// use the same hook merging strategy for route hooks
strats.beforeRouteEnter = strats.beforeRouteLeave = strats.created
}
/* */
function resolvePath (
relative,
base,
append
) {
if (relative.charAt(0) === '/') {
return relative
}
if (relative.charAt(0) === '?' || relative.charAt(0) === '#') {
return base + relative
}
var stack = base.split('/')
// remove trailing segment if:
// - not appending
// - appending to trailing slash (last segment is empty)
if (!append || !stack[stack.length - 1]) {
stack.pop()
}
// resolve relative path
var segments = relative.replace(/^\//, '').split('/')
for (var i = 0; i < segments.length; i++) {
var segment = segments[i]
if (segment === '.') {
continue
} else if (segment === '..') {
stack.pop()
} else {
stack.push(segment)
}
}
// ensure leading slash
if (stack[0] !== '') {
stack.unshift('')
}
return stack.join('/')
}
function parsePath (path) {
var hash = ''
var query = ''
var hashIndex = path.indexOf('#')
if (hashIndex >= 0) {
hash = path.slice(hashIndex)
path = path.slice(0, hashIndex)
}
var queryIndex = path.indexOf('?')
if (queryIndex >= 0) {
query = path.slice(queryIndex + 1)
path = path.slice(0, queryIndex)
}
return {
path: path,
query: query,
hash: hash
}
}
function cleanPath (path) {
return path.replace(/\/\//g, '/')
}
/* */
function createRouteMap (routes) {
var pathMap = Object.create(null)
var nameMap = Object.create(null)
routes.forEach(function (route) {
addRouteRecord(pathMap, nameMap, route)
})
return {
pathMap: pathMap,
nameMap: nameMap
}
}
function addRouteRecord (
pathMap,
nameMap,
route,
parent,
matchAs
) {
var path = route.path;
var name = route.name;
if (process.env.NODE_ENV !== 'production') {
assert(path != null, "\"path\" is required in a route configuration.")
assert(
typeof route.component !== 'string',
"route config \"component\" for path: " + (String(path || name)) + " cannot be a " +
"string id. Use an actual component instead."
)
}
var record = {
path: normalizePath(path, parent),
components: route.components || { default: route.component },
instances: {},
name: name,
parent: parent,
matchAs: matchAs,
redirect: route.redirect,
beforeEnter: route.beforeEnter,
meta: route.meta || {}
}
if (route.children) {
// Warn if route is named and has a default child route.
// If users navigate to this route by name, the default child will
// not be rendered (GH Issue #629)
if (process.env.NODE_ENV !== 'production') {
if (route.name && route.children.some(function (child) { return /^\/?$/.test(child.path); })) {
warn(false, ("Named Route '" + (route.name) + "' has a default child route.\n When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), the default child route will not be rendered.\n Remove the name from this route and use the name of the default child route for named links instead.")
)
}
}
route.children.forEach(function (child) {
addRouteRecord(pathMap, nameMap, child, record)
})
}
if (route.alias !== undefined) {
if (Array.isArray(route.alias)) {
route.alias.forEach(function (alias) {
addRouteRecord(pathMap, nameMap, { path: alias }, parent, record.path)
})
} else {
addRouteRecord(pathMap, nameMap, { path: route.alias }, parent, record.path)
}
}
if (!pathMap[record.path]) {
pathMap[record.path] = record
}
if (name) {
if (!nameMap[name]) {
nameMap[name] = record
} else if (process.env.NODE_ENV !== 'production') {
warn(false, ("Duplicate named routes definition: { name: \"" + name + "\", path: \"" + (record.path) + "\" }"))
}
}
}
function normalizePath (path, parent) {
path = path.replace(/\/$/, '')
if (path[0] === '/') { return path }
if (parent == null) { return path }
return cleanPath(((parent.path) + "/" + path))
}
var __moduleExports = Array.isArray || function (arr) {
return Object.prototype.toString.call(arr) == '[object Array]';
};
var isarray = __moduleExports
/**
* Expose `pathToRegexp`.
*/
var index = pathToRegexp
var parse_1 = parse
var compile_1 = compile
var tokensToFunction_1 = tokensToFunction
var tokensToRegExp_1 = tokensToRegExp
/**
* The main path matching regexp utility.
*
* @type {RegExp}
*/
var PATH_REGEXP = new RegExp([
// Match escaped characters that would otherwise appear in future matches.
// This allows the user to escape special characters that won't transform.
'(\\\\.)',
// Match Express-style parameters and un-named parameters with a prefix
// and optional suffixes. Matches appear as:
//
// "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
// "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
// "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
'([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
].join('|'), 'g')
/**
* Parse a string for the raw tokens.
*
* @param {string} str
* @param {Object=} options
* @return {!Array}
*/
function parse (str, options) {
var tokens = []
var key = 0
var index = 0
var path = ''
var defaultDelimiter = options && options.delimiter || '/'
var res
while ((res = PATH_REGEXP.exec(str)) != null) {
var m = res[0]
var escaped = res[1]
var offset = res.index
path += str.slice(index, offset)
index = offset + m.length
// Ignore already escaped sequences.
if (escaped) {
path += escaped[1]
continue
}
var next = str[index]
var prefix = res[2]
var name = res[3]
var capture = res[4]
var group = res[5]
var modifier = res[6]
var asterisk = res[7]
// Push the current path onto the tokens.
if (path) {
tokens.push(path)
path = ''
}
var partial = prefix != null && next != null && next !== prefix
var repeat = modifier === '+' || modifier === '*'
var optional = modifier === '?' || modifier === '*'
var delimiter = res[2] || defaultDelimiter
var pattern = capture || group
tokens.push({
name: name || key++,
prefix: prefix || '',
delimiter: delimiter,
optional: optional,
repeat: repeat,
partial: partial,
asterisk: !!asterisk,
pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
})
}
// Match any characters still remaining.
if (index < str.length) {
path += str.substr(index)
}
// If the path exists, push it onto the end.
if (path) {
tokens.push(path)
}
return tokens
}
/**
* Compile a string to a template function for the path.
*
* @param {string} str
* @param {Object=} options
* @return {!function(Object=, Object=)}
*/
function compile (str, options) {
return tokensToFunction(parse(str, options))
}
/**
* Prettier encoding of URI path segments.
*
* @param {string}
* @return {string}
*/
function encodeURIComponentPretty (str) {
return encodeURI(str).replace(/[\/?#]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
})
}
/**
* Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
*
* @param {string}
* @return {string}
*/
function encodeAsterisk (str) {
return encodeURI(str).replace(/[?#]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
})
}
/**
* Expose a method for transforming tokens into the path function.
*/
function tokensToFunction (tokens) {
// Compile all the tokens into regexps.
var matches = new Array(tokens.length)
// Compile all the patterns before compilation.
for (var i = 0; i < tokens.length; i++) {
if (typeof tokens[i] === 'object') {
matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$')
}
}
return function (obj, opts) {
var path = ''
var data = obj || {}
var options = opts || {}
var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i]
if (typeof token === 'string') {
path += token
continue
}
var value = data[token.name]
var segment
if (value == null) {
if (token.optional) {
// Prepend partial segment prefixes.
if (token.partial) {
path += token.prefix
}
continue
} else {
throw new TypeError('Expected "' + token.name + '" to be defined')
}
}
if (isarray(value)) {
if (!token.repeat) {
throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
}
if (value.length === 0) {
if (token.optional) {
continue
} else {
throw new TypeError('Expected "' + token.name + '" to not be empty')
}
}
for (var j = 0; j < value.length; j++) {
segment = encode(value[j])
if (!matches[i].test(segment)) {
throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
}
path += (j === 0 ? token.prefix : token.delimiter) + segment
}
continue
}
segment = token.asterisk ? encodeAsterisk(value) : encode(value)
if (!matches[i].test(segment)) {
throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
}
path += token.prefix + segment
}
return path
}
}
/**
* Escape a regular expression string.
*
* @param {string} str
* @return {string}
*/
function escapeString (str) {
return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
}
/**
* Escape the capturing group by escaping special characters and meaning.
*
* @param {string} group
* @return {string}
*/
function escapeGroup (group) {
return group.replace(/([=!:$\/()])/g, '\\$1')
}
/**
* Attach the keys as a property of the regexp.
*
* @param {!RegExp} re
* @param {Array} keys
* @return {!RegExp}
*/
function attachKeys (re, keys) {
re.keys = keys
return re
}
/**
* Get the flags for a regexp from the options.
*
* @param {Object} options
* @return {string}
*/
function flags (options) {
return options.sensitive ? '' : 'i'
}
/**
* Pull out keys from a regexp.
*
* @param {!RegExp} path
* @param {!Array} keys
* @return {!RegExp}
*/
function regexpToRegexp (path, keys) {
// Use a negative lookahead to match only capturing groups.
var groups = path.source.match(/\((?!\?)/g)
if (groups) {
for (var i = 0; i < groups.length; i++) {
keys.push({
name: i,
prefix: null,
delimiter: null,
optional: false,
repeat: false,
partial: false,
asterisk: false,
pattern: null
})
}
}
return attachKeys(path, keys)
}
/**
* Transform an array into a regexp.
*
* @param {!Array} path
* @param {Array} keys
* @param {!Object} options
* @return {!RegExp}
*/
function arrayToRegexp (path, keys, options) {
var parts = []
for (var i = 0; i < path.length; i++) {
parts.push(pathToRegexp(path[i], keys, options).source)
}
var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options))
return attachKeys(regexp, keys)
}
/**
* Create a path regexp from string input.
*
* @param {string} path
* @param {!Array} keys
* @param {!Object} options
* @return {!RegExp}
*/
function stringToRegexp (path, keys, options) {
return tokensToRegExp(parse(path, options), keys, options)
}
/**
* Expose a function for taking tokens and returning a RegExp.
*
* @param {!Array} tokens
* @param {(Array|Object)=} keys
* @param {Object=} options
* @return {!RegExp}
*/
function tokensToRegExp (tokens, keys, options) {
if (!isarray(keys)) {
options = /** @type {!Object} */ (keys || options)
keys = []
}
options = options || {}
var strict = options.strict
var end = options.end !== false
var route = ''
// Iterate over the tokens and create our regexp string.
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i]
if (typeof token === 'string') {
route += escapeString(token)
} else {
var prefix = escapeString(token.prefix)
var capture = '(?:' + token.pattern + ')'
keys.push(token)
if (token.repeat) {
capture += '(?:' + prefix + capture + ')*'
}
if (token.optional) {
if (!token.partial) {
capture = '(?:' + prefix + '(' + capture + '))?'
} else {
capture = prefix + '(' + capture + ')?'
}
} else {
capture = prefix + '(' + capture + ')'
}
route += capture
}
}
var delimiter = escapeString(options.delimiter || '/')
var endsWithDelimiter = route.slice(-delimiter.length) === delimiter
// In non-strict mode we allow a slash at the end of match. If the path to
// match already ends with a slash, we remove it for consistency. The slash
// is valid at the end of a path match, not in the middle. This is important
// in non-ending mode, where "/test/" shouldn't match "/test//route".
if (!strict) {
route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?'
}
if (end) {
route += '$'
} else {
// In non-ending mode, we need the capturing groups to match as much as
// possible by using a positive lookahead to the end or next path segment.
route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)'
}
return attachKeys(new RegExp('^' + route, flags(options)), keys)
}
/**
* Normalize the given path string, returning a regular expression.
*
* An empty array can be passed in for the keys, which will hold the
* placeholder key descriptions. For example, using `/user/:id`, `keys` will
* contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
*
* @param {(string|RegExp|Array)} path
* @param {(Array|Object)=} keys
* @param {Object=} options
* @return {!RegExp}
*/
function pathToRegexp (path, keys, options) {
if (!isarray(keys)) {
options = /** @type {!Object} */ (keys || options)
keys = []
}
options = options || {}
if (path instanceof RegExp) {
return regexpToRegexp(path, /** @type {!Array} */ (keys))
}
if (isarray(path)) {
return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
}
return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
}
index.parse = parse_1;
index.compile = compile_1;
index.tokensToFunction = tokensToFunction_1;
index.tokensToRegExp = tokensToRegExp_1;
/* */
var regexpCache = Object.create(null)
function getRouteRegex (path) {
var hit = regexpCache[path]
var keys, regexp
if (hit) {
keys = hit.keys
regexp = hit.regexp
} else {
keys = []
regexp = index(path, keys)
regexpCache[path] = { keys: keys, regexp: regexp }
}
return { keys: keys, regexp: regexp }
}
var regexpCompileCache = Object.create(null)
function fillParams (
path,
params,
routeMsg
) {
try {
var filler =
regexpCompileCache[path] ||
(regexpCompileCache[path] = index.compile(path))
return filler(params || {}, { pretty: true })
} catch (e) {
if (process.env.NODE_ENV !== 'production') {
warn(false, ("missing param for " + routeMsg + ": " + (e.message)))
}
return ''
}
}
/* */
function normalizeLocation (
raw,
current,
append
) {
var next = typeof raw === 'string' ? { path: raw } : raw
// named target
if (next.name || next._normalized) {
return next
}
// relative params
if (!next.path && next.params && current) {
next = assign({}, next)
next._normalized = true
var params = assign(assign({}, current.params), next.params)
if (current.name) {
next.name = current.name
next.params = params
} else if (current.matched) {
var rawPath = current.matched[current.matched.length - 1].path
next.path = fillParams(rawPath, params, ("path " + (current.path)))
} else if (process.env.NODE_ENV !== 'production') {
warn(false, "relative params navigation requires a current route.")
}
return next
}
var parsedPath = parsePath(next.path || '')
var basePath = (current && current.path) || '/'
var path = parsedPath.path
? resolvePath(parsedPath.path, basePath, append || next.append)
: (current && current.path) || '/'
var query = resolveQuery(parsedPath.query, next.query)
var hash = next.hash || parsedPath.hash
if (hash && hash.charAt(0) !== '#') {
hash = "#" + hash
}
return {
_normalized: true,
path: path,
query: query,
hash: hash
}
}
function assign (a, b) {
for (var key in b) {
a[key] = b[key]
}
return a
}
/* */
function createMatcher (routes) {
var ref = createRouteMap(routes);
var pathMap = ref.pathMap;
var nameMap = ref.nameMap;
function match (
raw,
currentRoute,
redirectedFrom
) {
var location = normalizeLocation(raw, currentRoute)
var name = location.name;
if (name) {
var record = nameMap[name]
var paramNames = getRouteRegex(record.path).keys
.filter(function (key) { return !key.optional; })
.map(function (key) { return key.name; })
if (typeof location.params !== 'object') {
location.params = {}
}
if (currentRoute && typeof currentRoute.params === 'object') {
for (var key in currentRoute.params) {
if (!(key in location.params) && paramNames.indexOf(key) > -1) {
location.params[key] = currentRoute.params[key]
}
}
}
if (record) {
location.path = fillParams(record.path, location.params, ("named route \"" + name + "\""))
return _createRoute(record, location, redirectedFrom)
}
} else if (location.path) {
location.params = {}
for (var path in pathMap) {
if (matchRoute(path, location.params, location.path)) {
return _createRoute(pathMap[path], location, redirectedFrom)
}
}
}
// no match
return _createRoute(null, location)
}
function redirect (
record,
location
) {
var originalRedirect = record.redirect
var redirect = typeof originalRedirect === 'function'
? originalRedirect(createRoute(record, location))
: originalRedirect
if (typeof redirect === 'string') {
redirect = { path: redirect }
}
if (!redirect || typeof redirect !== 'object') {
process.env.NODE_ENV !== 'production' && warn(
false, ("invalid redirect option: " + (JSON.stringify(redirect)))
)
return _createRoute(null, location)
}
var re = redirect
var name = re.name;
var path = re.path;
var query = location.query;
var hash = location.hash;
var params = location.params;
query = re.hasOwnProperty('query') ? re.query : query
hash = re.hasOwnProperty('hash') ? re.hash : hash
params = re.hasOwnProperty('params') ? re.params : params
if (name) {
// resolved named direct
var targetRecord = nameMap[name]
if (process.env.NODE_ENV !== 'production') {
assert(targetRecord, ("redirect failed: named route \"" + name + "\" not found."))
}
return match({
_normalized: true,
name: name,
query: query,
hash: hash,
params: params
}, undefined, location)
} else if (path) {
// 1. resolve relative redirect
var rawPath = resolveRecordPath(path, record)
// 2. resolve params
var resolvedPath = fillParams(rawPath, params, ("redirect route with path \"" + rawPath + "\""))
// 3. rematch with existing query and hash
return match({
_normalized: true,
path: resolvedPath,
query: query,
hash: hash
}, undefined, location)
} else {
warn(false, ("invalid redirect option: " + (JSON.stringify(redirect))))
return _createRoute(null, location)
}
}
function alias (
record,
location,
matchAs
) {
var aliasedPath = fillParams(matchAs, location.params, ("aliased route with path \"" + matchAs + "\""))
var aliasedMatch = match({
_normalized: true,
path: aliasedPath
})
if (aliasedMatch) {
var matched = aliasedMatch.matched
var aliasedRecord = matched[matched.length - 1]
location.params = aliasedMatch.params
return _createRoute(aliasedRecord, location)
}
return _createRoute(null, location)
}
function _createRoute (
record,
location,
redirectedFrom
) {
if (record && record.redirect) {
return redirect(record, redirectedFrom || location)
}
if (record && record.matchAs) {
return alias(record, location, record.matchAs)
}
return createRoute(record, location, redirectedFrom)
}
return match
}
function matchRoute (
path,
params,
pathname
) {
var ref = getRouteRegex(path);
var regexp = ref.regexp;
var keys = ref.keys;
var m = pathname.match(regexp)
if (!m) {
return false
} else if (!params) {
return true
}
for (var i = 1, len = m.length; i < len; ++i) {
var key = keys[i - 1]
var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i]
if (key) { params[key.name] = val }
}
return true
}
function resolveRecordPath (path, record) {
return resolvePath(path, record.parent ? record.parent.path : '/', true)
}
/* */
var inBrowser = typeof window !== 'undefined'
var supportsHistory = inBrowser && (function () {
var ua = window.navigator.userAgent
if (
(ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
ua.indexOf('Mobile Safari') !== -1 &&
ua.indexOf('Chrome') === -1 &&
ua.indexOf('Windows Phone') === -1
) {
return false
}
return window.history && 'pushState' in window.history
})()
/* */
function runQueue (queue, fn, cb) {
var step = function (index) {
if (index >= queue.length) {
cb()
} else {
if (queue[index]) {
fn(queue[index], function () {
step(index + 1)
})
} else {
step(index + 1)
}
}
}
step(0)
}
/* */
var History = function History (router, base) {
this.router = router
this.base = normalizeBase(base)
// start with a route object that stands for "nowhere"
this.current = START
this.pending = null
};
History.prototype.listen = function listen (cb) {
this.cb = cb
};
History.prototype.transitionTo = function transitionTo (location, onComplete, onAbort) {
var this$1 = this;
var route = this.router.match(location, this.current)
this.confirmTransition(route, function () {
this$1.updateRoute(route)
onComplete && onComplete(route)
this$1.ensureURL()
}, onAbort)
};
History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) {
var this$1 = this;
var current = this.current
var abort = function () { onAbort && onAbort() }
if (isSameRoute(route, current)) {
this.ensureURL()
return abort()
}
var ref = resolveQueue(this.current.matched, route.matched);
var deactivated = ref.deactivated;
var activated = ref.activated;
var queue = [].concat(
// in-component leave guards
extractLeaveGuards(deactivated),
// global before hooks
this.router.beforeHooks,
// enter guards
activated.map(function (m) { return m.beforeEnter; }),
// async components
resolveAsyncComponents(activated)
)
this.pending = route
var iterator = function (hook, next) {
if (this$1.pending !== route) {
return abort()
}
hook(route, current, function (to) {
if (to === false) {
// next(false) -> abort navigation, ensure current URL
this$1.ensureURL(true)
abort()
} else if (typeof to === 'string' || typeof to === 'object') {
// next('/') or next({ path: '/' }) -> redirect
(typeof to === 'object' && to.replace) ? this$1.replace(to) : this$1.push(to)
abort()
} else {
// confirm transition and pass on the value
next(to)
}
})
}
runQueue(queue, iterator, function () {
var postEnterCbs = []
var enterGuards = extractEnterGuards(activated, postEnterCbs, function () {
return this$1.current === route
})
// wait until async components are resolved before
// extracting in-component enter guards
runQueue(enterGuards, iterator, function () {
if (this$1.pending !== route) {
return abort()
}
this$1.pending = null
onComplete(route)
if (this$1.router.app) {
this$1.router.app.$nextTick(function () {
postEnterCbs.forEach(function (cb) { return cb(); })
})
}
})
})
};
History.prototype.updateRoute = function updateRoute (route) {
var prev = this.current
this.current = route
this.cb && this.cb(route)
this.router.afterHooks.forEach(function (hook) {
hook && hook(route, prev)
})
};
function normalizeBase (base) {
if (!base) {
if (inBrowser) {
// respect <base> tag
var baseEl = document.querySelector('base')
base = baseEl ? baseEl.getAttribute('href') : '/'
} else {
base = '/'
}
}
// make sure there's the starting slash
if (base.charAt(0) !== '/') {
base = '/' + base
}
// remove trailing slash
return base.replace(/\/$/, '')
}
function resolveQueue (
current,
next
) {
var i
var max = Math.max(current.length, next.length)
for (i = 0; i < max; i++) {
if (current[i] !== next[i]) {
break
}
}
return {
activated: next.slice(i),
deactivated: current.slice(i)
}
}
function extractGuard (
def,
key
) {
if (typeof def !== 'function') {
// extend now so that global mixins are applied.
def = _Vue.extend(def)
}
return def.options[key]
}
function extractLeaveGuards (matched) {
return flatten(flatMapComponents(matched, function (def, instance) {
var guard = extractGuard(def, 'beforeRouteLeave')
if (guard) {
return Array.isArray(guard)
? guard.map(function (guard) { return wrapLeaveGuard(guard, instance); })
: wrapLeaveGuard(guard, instance)
}
}).reverse())
}
function wrapLeaveGuard (
guard,
instance
) {
return function routeLeaveGuard () {
return guard.apply(instance, arguments)
}
}
function extractEnterGuards (
matched,
cbs,
isValid
) {
return flatten(flatMapComponents(matched, function (def, _, match, key) {
var guard = extractGuard(def, 'beforeRouteEnter')
if (guard) {
return Array.isArray(guard)
? guard.map(function (guard) { return wrapEnterGuard(guard, cbs, match, key, isValid); })
: wrapEnterGuard(guard, cbs, match, key, isValid)
}
}))
}
function wrapEnterGuard (
guard,
cbs,
match,
key,
isValid
) {
return function routeEnterGuard (to, from, next) {
return guard(to, from, function (cb) {
next(cb)
if (typeof cb === 'function') {
cbs.push(function () {
// #750
// if a router-view is wrapped with an out-in transition,
// the instance may not have been registered at this time.
// we will need to poll for registration until current route
// is no longer valid.
poll(cb, match.instances, key, isValid)
})
}
})
}
}
function poll (
cb, // somehow flow cannot infer this is a function
instances,
key,
isValid
) {
if (instances[key]) {
cb(instances[key])
} else if (isValid()) {
setTimeout(function () {
poll(cb, instances, key, isValid)
}, 16)
}
}
function resolveAsyncComponents (matched) {
return flatMapComponents(matched, function (def, _, match, key) {
// if it's a function and doesn't have Vue options attached,
// assume it's an async component resolve function.
// we are not using Vue's default async resolving mechanism because
// we want to halt the navigation until the incoming component has been
// resolved.
if (typeof def === 'function' && !def.options) {
return function (to, from, next) {
var resolve = function (resolvedDef) {
match.components[key] = resolvedDef
next()
}
var reject = function (reason) {
warn(false, ("Failed to resolve async component " + key + ": " + reason))
next(false)
}
var res = def(resolve, reject)
if (res && typeof res.then === 'function') {
res.then(resolve, reject)
}
}
}
})
}
function flatMapComponents (
matched,
fn
) {
return flatten(matched.map(function (m) {
return Object.keys(m.components).map(function (key) { return fn(
m.components[key],
m.instances[key],
m, key
); })
}))
}
function flatten (arr) {
return Array.prototype.concat.apply([], arr)
}
/* */
var positionStore = Object.create(null)
function saveScrollPosition (key) {
if (!key) { return }
positionStore[key] = {
x: window.pageXOffset,
y: window.pageYOffset
}
}
function getScrollPosition (key) {
if (!key) { return }
return positionStore[key]
}
function getElementPosition (el) {
var docRect = document.documentElement.getBoundingClientRect()
var elRect = el.getBoundingClientRect()
return {
x: elRect.left - docRect.left,
y: elRect.top - docRect.top
}
}
function isValidPosition (obj) {
return isNumber(obj.x) || isNumber(obj.y)
}
function normalizePosition (obj) {
return {
x: isNumber(obj.x) ? obj.x : window.pageXOffset,
y: isNumber(obj.y) ? obj.y : window.pageYOffset
}
}
function isNumber (v) {
return typeof v === 'number'
}
/* */
var genKey = function () { return String(Date.now()); }
var _key = genKey()
var HTML5History = (function (History) {
function HTML5History (router, base) {
var this$1 = this;
History.call(this, router, base)
var expectScroll = router.options.scrollBehavior
window.addEventListener('popstate', function (e) {
_key = e.state && e.state.key
var current = this$1.current
this$1.transitionTo(getLocation(this$1.base), function (next) {
if (expectScroll) {
this$1.handleScroll(next, current, true)
}
})
})
if (expectScroll) {
window.addEventListener('scroll', function () {
saveScrollPosition(_key)
})
}
}
if ( History ) HTML5History.__proto__ = History;
HTML5History.prototype = Object.create( History && History.prototype );
HTML5History.prototype.constructor = HTML5History;
HTML5History.prototype.go = function go (n) {
window.history.go(n)
};
HTML5History.prototype.push = function push (location) {
var this$1 = this;
var current = this.current
this.transitionTo(location, function (route) {
pushState(cleanPath(this$1.base + route.fullPath))
this$1.handleScroll(route, current, false)
})
};
HTML5History.prototype.replace = function replace (location) {
var this$1 = this;
var current = this.current
this.transitionTo(location, function (route) {
replaceState(cleanPath(this$1.base + route.fullPath))
this$1.handleScroll(route, current, false)
})
};
HTML5History.prototype.ensureURL = function ensureURL (push) {
if (getLocation(this.base) !== this.current.fullPath) {
var current = cleanPath(this.base + this.current.fullPath)
push ? pushState(current) : replaceState(current)
}
};
HTML5History.prototype.handleScroll = function handleScroll (to, from, isPop) {
var router = this.router
if (!router.app) {
return
}
var behavior = router.options.scrollBehavior
if (!behavior) {
return
}
if (process.env.NODE_ENV !== 'production') {
assert(typeof behavior === 'function', "scrollBehavior must be a function")
}
// wait until re-render finishes before scrolling
router.app.$nextTick(function () {
var position = getScrollPosition(_key)
var shouldScroll = behavior(to, from, isPop ? position : null)
if (!shouldScroll) {
return
}
var isObject = typeof shouldScroll === 'object'
if (isObject && typeof shouldScroll.selector === 'string') {
var el = document.querySelector(shouldScroll.selector)
if (el) {
position = getElementPosition(el)
} else if (isValidPosition(shouldScroll)) {
position = normalizePosition(shouldScroll)
}
} else if (isObject && isValidPosition(shouldScroll)) {
position = normalizePosition(shouldScroll)
}
if (position) {
window.scrollTo(position.x, position.y)
}
})
};
return HTML5History;
}(History));
function getLocation (base) {
var path = window.location.pathname
if (base && path.indexOf(base) === 0) {
path = path.slice(base.length)
}
return (path || '/') + window.location.search + window.location.hash
}
function pushState (url, replace) {
// try...catch the pushState call to get around Safari
// DOM Exception 18 where it limits to 100 pushState calls
var history = window.history
try {
if (replace) {
history.replaceState({ key: _key }, '', url)
} else {
_key = genKey()
history.pushState({ key: _key }, '', url)
}
saveScrollPosition(_key)
} catch (e) {
window.location[replace ? 'assign' : 'replace'](url)
}
}
function replaceState (url) {
pushState(url, true)
}
/* */
var HashHistory = (function (History) {
function HashHistory (router, base, fallback) {
History.call(this, router, base)
// check history fallback deeplinking
if (fallback && this.checkFallback()) {
return
}
ensureSlash()
}
if ( History ) HashHistory.__proto__ = History;
HashHistory.prototype = Object.create( History && History.prototype );
HashHistory.prototype.constructor = HashHistory;
HashHistory.prototype.checkFallback = function checkFallback () {
var location = getLocation(this.base)
if (!/^\/#/.test(location)) {
window.location.replace(
cleanPath(this.base + '/#' + location)
)
return true
}
};
HashHistory.prototype.onHashChange = function onHashChange () {
if (!ensureSlash()) {
return
}
this.transitionTo(getHash(), function (route) {
replaceHash(route.fullPath)
})
};
HashHistory.prototype.push = function push (location) {
this.transitionTo(location, function (route) {
pushHash(route.fullPath)
})
};
HashHistory.prototype.replace = function replace (location) {
this.transitionTo(location, function (route) {
replaceHash(route.fullPath)
})
};
HashHistory.prototype.go = function go (n) {
window.history.go(n)
};
HashHistory.prototype.ensureURL = function ensureURL (push) {
var current = this.current.fullPath
if (getHash() !== current) {
push ? pushHash(current) : replaceHash(current)
}
};
return HashHistory;
}(History));
function ensureSlash () {
var path = getHash()
if (path.charAt(0) === '/') {
return true
}
replaceHash('/' + path)
return false
}
function getHash () {
// We can't use window.location.hash here because it's not
// consistent across browsers - Firefox will pre-decode it!
var href = window.location.href
var index = href.indexOf('#')
return index === -1 ? '' : href.slice(index + 1)
}
function pushHash (path) {
window.location.hash = path
}
function replaceHash (path) {
var i = window.location.href.indexOf('#')
window.location.replace(
window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path
)
}
/* */
var AbstractHistory = (function (History) {
function AbstractHistory (router) {
History.call(this, router)
this.stack = []
this.index = -1
}
if ( History ) AbstractHistory.__proto__ = History;
AbstractHistory.prototype = Object.create( History && History.prototype );
AbstractHistory.prototype.constructor = AbstractHistory;
AbstractHistory.prototype.push = function push (location) {
var this$1 = this;
this.transitionTo(location, function (route) {
this$1.stack = this$1.stack.slice(0, this$1.index + 1).concat(route)
this$1.index++
})
};
AbstractHistory.prototype.replace = function replace (location) {
var this$1 = this;
this.transitionTo(location, function (route) {
this$1.stack = this$1.stack.slice(0, this$1.index).concat(route)
})
};
AbstractHistory.prototype.go = function go (n) {
var this$1 = this;
var targetIndex = this.index + n
if (targetIndex < 0 || targetIndex >= this.stack.length) {
return
}
var route = this.stack[targetIndex]
this.confirmTransition(route, function () {
this$1.index = targetIndex
this$1.updateRoute(route)
})
};
AbstractHistory.prototype.ensureURL = function ensureURL () {
// noop
};
return AbstractHistory;
}(History));
/* */
var VueRouter = function VueRouter (options) {
if ( options === void 0 ) options = {};
this.app = null
this.options = options
this.beforeHooks = []
this.afterHooks = []
this.match = createMatcher(options.routes || [])
var mode = options.mode || 'hash'
this.fallback = mode === 'history' && !supportsHistory
if (this.fallback) {
mode = 'hash'
}
if (!inBrowser) {
mode = 'abstract'
}
this.mode = mode
switch (mode) {
case 'history':
this.history = new HTML5History(this, options.base)
break
case 'hash':
this.history = new HashHistory(this, options.base, this.fallback)
break
case 'abstract':
this.history = new AbstractHistory(this)
break
default:
process.env.NODE_ENV !== 'production' && assert(false, ("invalid mode: " + mode))
}
};
var prototypeAccessors = { currentRoute: {} };
prototypeAccessors.currentRoute.get = function () {
return this.history && this.history.current
};
VueRouter.prototype.init = function init (app /* Vue component instance */) {
var this$1 = this;
process.env.NODE_ENV !== 'production' && assert(
install.installed,
"not installed. Make sure to call `Vue.use(VueRouter)` " +
"before creating root instance."
)
this.app = app
var history = this.history
if (history instanceof HTML5History) {
history.transitionTo(getLocation(history.base))
} else if (history instanceof HashHistory) {
var setupHashListener = function () {
window.addEventListener('hashchange', function () {
history.onHashChange()
})
}
history.transitionTo(getHash(), setupHashListener, setupHashListener)
}
history.listen(function (route) {
this$1.app._route = route
})
};
VueRouter.prototype.beforeEach = function beforeEach (fn) {
this.beforeHooks.push(fn)
};
VueRouter.prototype.afterEach = function afterEach (fn) {
this.afterHooks.push(fn)
};
VueRouter.prototype.push = function push (location) {
this.history.push(location)
};
VueRouter.prototype.replace = function replace (location) {
this.history.replace(location)
};
VueRouter.prototype.go = function go (n) {
this.history.go(n)
};
VueRouter.prototype.back = function back () {
this.go(-1)
};
VueRouter.prototype.forward = function forward () {
this.go(1)
};
VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) {
var route = to
? this.resolve(to).resolved
: this.currentRoute
if (!route) {
return []
}
return [].concat.apply([], route.matched.map(function (m) {
return Object.keys(m.components).map(function (key) {
return m.components[key]
})
}))
};
VueRouter.prototype.resolve = function resolve (
to,
current,
append
) {
var normalizedTo = normalizeLocation(to, current || this.history.current, append)
var resolved = this.match(normalizedTo, current)
var fullPath = resolved.redirectedFrom || resolved.fullPath
var base = this.history.base
var href = createHref(base, fullPath, this.mode)
return {
normalizedTo: normalizedTo,
resolved: resolved,
href: href
}
};
Object.defineProperties( VueRouter.prototype, prototypeAccessors );
function createHref (base, fullPath, mode) {
var path = mode === 'hash' ? '#' + fullPath : fullPath
return base ? cleanPath(base + '/' + path) : path
}
VueRouter.install = install
if (inBrowser && window.Vue) {
window.Vue.use(VueRouter)
}
module.exports = VueRouter;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(147)))
/***/ }),
/***/ 302:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(201);
/***/ })
},[302]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
webpackJsonp([22],{
/***/ 207:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _config = __webpack_require__(9);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* v_editName.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 修改名称页面
*/
_public.iot.ready(init);
function init() {
//通用 input、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-button', 'u-dialog', 'u-loading']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
textName: _public.iot.navigator.getExtras().nickname,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig(),
extras: {}
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
console.log(this.extras);
},
methods: {
getTextName: function getTextName() {
return this.textName;
},
setTextName: function setTextName(text) {
this.textName = text;
},
setTextErrorTip: function setTextErrorTip(text) {
this.textErrorTip = text;
},
onNameChange: function onNameChange(text) {
nameChange(this, text);
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 保存
onSaveTap: function onSaveTap() {
saveTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
nameInput: {
initParam: {
class: 'custom-editName-text',
placeholder: Vue.t('editName.nameInputTip'),
maxlength: _config2.default.input.maxlength
}
},
//保存 button 参数
saveButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.save')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
function alert() {
alert('aaa');
}
function nameChange(self, text) {
self.setTextName(text);
self.setTextErrorTip('');
console.log('nameChange: ' + self.textName);
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 保存
function saveTap(self) {
if (self.getTextName() == null || self.getTextName().trim() == '') {
self.setTextErrorTip(Vue.t('editName.error.nameCanNotBeBlank'));
} else {
_public.uComponents.showLoading(self);
_public.iot.business.device.setName({
data: {
device_id: self.extras.lockId,
device_name: self.getTextName()
},
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
_public.uComponents.openAlert(self, Vue.t('editName.editNameSuccess'), {
text: Vue.t('btn.confirm'), callback: function callback() {
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
console.log('returnPage');
_public.iot.navigator.back();
}
});
}
},
error: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 修改设备名称失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'修改设备名称失败');
// }
_public.uComponents.openAlert(self, Vue.t('editName.editNameFailue'), {
text: Vue.t('btn.confirm'), callback: function callback() {
var opener = plus.webview.currentWebview().opener();
_public.iot.navigator.back();
}
});
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 308:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(207);
/***/ })
},[308]);
//# sourceMappingURL=editName.js.map
\ No newline at end of file
webpackJsonp([11],{
/***/ 208:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _config = __webpack_require__(9);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(4);
var _components = __webpack_require__(248);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_public.iot.ready(init); /**
* v_index.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 门锁管理页面
*/
function init() {
//通用 按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading', 'u-switch']);
//项目 list组件
_public.uPublic.componentsExtend(['grid-list']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig(),
//提示框是否显示
stateShowFlag: false,
//我的门锁
doorlock: null,
//提示框显示文字
showMsg: '',
textNickname: _public.iot.navigator.getExtras().lockInfo.device_name,
extras: {},
unbindSucceess: false,
//门铃消息推送
valueDoorbell: _public.iot.navigator.getExtras().lockInfo.options[0],
//报警消息推送
valueAlarm: _public.iot.navigator.getExtras().lockInfo.options[1],
//开发消息推送
valueOpendoor: _public.iot.navigator.getExtras().lockInfo.options[2],
role: null,
valueIsClear: true,
unbindShowDialog: false
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
console.log(this.extras);
this.role = this.extras.lockInfo.role;
//获取门锁
// getDoorlockInfo(this);
//监听returnPage返回事件,重新获取最新数据
var self = this;
window.addEventListener('returnPage', function (event) {
console.log("returnPage");
getDoorlockInfo(self);
});
},
methods: {
getStateShowFlag: function getStateShowFlag() {
return this.stateShowFlag;
},
setStateShowFlag: function setStateShowFlag(flag) {
this.stateShowFlag = flag;
},
getDoorlock: function getDoorlock() {
return this.doorlock;
},
setDoorlock: function setDoorlock(obj) {
this.doorlock = obj;
},
getShowMsg: function getShowMsg() {
return this.showMsg;
},
setShowMsg: function setShowMsg(msg) {
this.showMsg = msg;
},
getTextNickname: function getTextNickname() {
return this.textNickname;
},
setTextNickname: function setTextNickname(text) {
this.textNickname = text;
},
getUnbindSucceess: function getUnbindSucceess() {
return this.unbindSucceess;
},
setUnbindSucceess: function setUnbindSucceess(bool) {
this.unbindSucceess = bool;
},
getValueDoorbell: function getValueDoorbell() {
return this.valueDoorbell;
},
setValueDoorbell: function setValueDoorbell(value) {
this.valueDoorbell = value;
},
getValueAlarm: function getValueAlarm() {
return this.valueAlarm;
},
setValueAlarm: function setValueAlarm(value) {
this.valueAlarm = value;
},
getValueOpendoor: function getValueOpendoor() {
return this.valueOpendoor;
},
setValueOpendoor: function setValueOpendoor(value) {
this.valueOpendoor = value;
},
getValueIsClear: function getValueIsClear() {
return this.valueIsClear;
},
setValueIsClear: function setValueIsClear(value) {
this.valueIsClear = value;
},
getUnbindShowDialog: function getUnbindShowDialog() {
return this.unbindShowDialog;
},
setUnbindShowDialog: function setUnbindShowDialog(flag) {
this.unbindShowDialog = flag;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 修改设备昵称
onEditNameTap: function onEditNameTap() {
editNameTap(this);
},
//tap 解绑门锁
onUnbindDoorlockButtonTap: function onUnbindDoorlockButtonTap() {
unbindDoorlockButtonTap(this);
},
//tap 隐藏提示框
onUnbindStateDialogTap: function onUnbindStateDialogTap() {
unbindStateDialogTap(this);
},
onDoorbellSwitchTap: function onDoorbellSwitchTap(value) {
doorbellSwitchTap(this, value);
},
onAlarmSwitchTap: function onAlarmSwitchTap(value) {
alarmSwitchTap(this, value);
},
onOpendoorSwitchTap: function onOpendoorSwitchTap(value) {
opendoorSwitchTap(this, value);
},
onCancelTap: function onCancelTap() {
cancelTap(this);
},
onConfirmTap: function onConfirmTap() {
confirmTap(this);
},
onIsClearSwitchTap: function onIsClearSwitchTap(value) {
isClearSwitchTap(this, value);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
unbindDoorlockButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.unbindDoorlock')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
isClearSwitch: {
initParam: {
class: 'custom-isClearSwitch-switch',
text: Vue.t('doorlockManage.isClearRecord')
}
},
loading: {
initParam: {
class: 'custom-loading'
}
},
doorbellSwitch: {
initParam: {
class: 'custom-switch'
}
},
alarmSwitch: {
initParam: {
class: 'custom-switch'
}
},
opendoorSwitch: {
initParam: {
class: 'custom-switch'
}
}
};
}
function getDoorlockInfo(self) {
_public.uComponents.showLoading(self);
var productId = _config2.default.model;
_public.iot.business.device.getInfo({
data: {
device_id: self.extras.lockInfo.lock_id
},
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
self.setTextNickname(data.device_name);
self.setValueDoorbell(data.device_info.options[0]);
self.setValueAlarm(data.device_info.options[1]);
self.setValueOpendoor(data.device_info.options[2]);
}
},
error: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 获取门锁信息失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取门锁信息失败');
// }
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
// iot.business.api.send('device/getList',{
// data: {
// sds: false,
// device_id: self.extras.deviceId,
// product_id: productId,
// parent_id: 0,
// start_id: 0,
// number: 10
// },
// success: (response) => {
// console.log(response);
// let data = uPublic.checkResponseData(response.data);
// if(data){
// self.setDoorlock(response.data[0]);
// self.setTextNickname(self.getDoorlock().nickname);
// console.log(self.getDoorlock());
// }
// },
// error: (error) => {
// //请求失败
// uPublic.openRequestErrorAlert(self);
// console.log(error);
// },
// complete: () => {
// uComponents.hideLoading(self);
// }
// },true);
}
//tap <
function backTap() {
_public.iot.navigator.aback();
}
_public.iot.navigator.aback = function () {
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
console.log("fire");
_public.iot.navigator.back();
};
//tap 修改设备昵称
function editNameTap(self) {
if (!self.role) {
_public.iot.navigator.openWindow({
url: './editName.html',
id: 'editName',
extras: {
lockId: self.extras.lockInfo.lock_id,
nickname: self.getTextNickname()
}
});
}
}
//tap 解绑门锁
function unbindDoorlockButtonTap(self) {
self.setUnbindShowDialog(true);
//uComponents.openConfirm(self, Vue.t('doorlockManage.unbindDialogTip'),
// {text: Vue.t('dialog.cancel'), callback: function () {}},
// {text: Vue.t('dialog.unbind'), callback: function () {
// uComponents.showLoading(self);
// iot.business.sds.unbindDevice({
// data: {
// uuid: self.extras.uuid
// },
// success: (response) => {
// console.log(response);
// unbind(self);
// },
// error: (error) => {
// console.log(error)
// },
// complete: () => {
//
// }
// });
// }}
// );
}
//tap 隐藏提示框
function unbindStateDialogTap(self) {
self.setStateShowFlag(false);
if (self.getUnbindSucceess) {
_public.iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
}
}
function unbind(self) {
_public.iot.business.api.sendCustom('lock/unbind', {
data: {
device_sn: self.extras.deviceId,
device_id: self.extras.lockInfo.lock_id,
needDelInfo: self.getValueIsClear()
},
success: function success(response) {
console.log(response);
self.setStateShowFlag(true);
self.setShowMsg(Vue.t('doorlockManage.unbindSuccess'));
self.setUnbindSucceess(true);
},
error: function error(_error2) {
console.log(_error2);
// if(window.iotDebug){
// iotDebug.push('end: 云端解绑失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'云端解绑失败');
// }
self.setStateShowFlag(false);
self.setShowMsg(Vue.t('doorlockManage.unbindFailue'));
self.setUnbindSucceess(false);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
//function unbindUser(self){
// iot.business.api.sendCustom('lock/unbindUser',{
// data: {
// rel_id: self.getDoorlock().id,
// device_id: self.getDoorlock().device_id,
// user_id: self.getDoorlock().user_device_id
// },
// success: (response) => {
// self.setStateShowFlag(true);
// self.setShowMsg(Vue.t('doorlockUser.unbindSuccess'));
// self.setUnbindSucceess(true);
// },
// error: (error) => {
// console.log(error);
// self.setStateShowFlag(false);
// self.setShowMsg(Vue.t('doorlockUser.unbindFailue'));
// self.setUnbindSucceess(false);
// },
// complete: () => {
// uComponents.hideLoading(self);
// }
// });
//}
function doorbellSwitchTap(self, value) {
self.setValueDoorbell(value);
setOption(self);
}
function alarmSwitchTap(self, value) {
self.setValueAlarm(value);
setOption(self);
}
function opendoorSwitchTap(self, value) {
self.setValueOpendoor(value);
setOption(self);
}
function setOption(self) {
// uComponents.showLoading(self);
_public.iot.business.api.sendCustom('lock/setPushOption', {
data: {
device_id: self.extras.lockInfo.lock_id,
opt_ring: self.getValueDoorbell(),
opt_alarm: self.getValueAlarm(),
opt_open: self.getValueOpendoor()
},
success: function success(response) {
console.log();
},
error: function error(_error3) {
console.log(_error3);
// if(window.iotDebug){
// iotDebug.push('end: 设置推送失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'设置推送失败');
// }
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
// uComponents.hideLoading(self);
}
});
}
function cancelTap(self) {
self.setUnbindShowDialog(false);
}
function confirmTap(self) {
self.setUnbindShowDialog(false);
_public.iot.business.sds.unbindDevice({
data: {
uuid: self.extras.uuid
},
success: function success(response) {
console.log(response);
unbind(self);
},
error: function error(_error4) {
console.log(_error4);
if (window.iotDebug) {
iotDebug.push('end: sds解绑设备失败' + JSON.stringify(_error4));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, 'sds解绑设备失败');
}
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {}
});
// unbind(self);
}
function isClearSwitchTap(self, value) {
self.setValueIsClear(value);
console.log(self.getValueIsClear());
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 248:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var projectMethods = {};
projectMethods.changeGridList = function (vmObj, list) {
vmObj.$refs.gridlist.changeList(list);
};
projectMethods.changeTimeline = function (vmObj, list) {
vmObj.$refs.timeline.changeList(list);
};
exports.projectMethods = projectMethods;
/***/ }),
/***/ 309:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(208);
/***/ })
},[309]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
webpackJsonp([7],{
/***/ 127:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Implementation of a subset of node.js Buffer methods for the browser.
* Based on https://github.com/feross/buffer
*/
/* eslint-disable no-proto */
var isArray = __webpack_require__(136)
var K_MAX_LENGTH = 0x7fffffff
function Buffer (arg, offset, length) {
if (typeof arg === 'number') {
return allocUnsafe(arg)
}
return from(arg, offset, length)
}
Buffer.prototype.__proto__ = Uint8Array.prototype
Buffer.__proto__ = Uint8Array
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
if (typeof Symbol !== 'undefined' && Symbol.species &&
Buffer[Symbol.species] === Buffer) {
Object.defineProperty(Buffer, Symbol.species, {
value: null,
configurable: true,
enumerable: false,
writable: false
})
}
function checked (length) {
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if (length >= K_MAX_LENGTH) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
}
return length | 0
}
function isnan (val) {
return val !== val // eslint-disable-line no-self-compare
}
function createBuffer (length) {
var buf = new Uint8Array(length)
buf.__proto__ = Buffer.prototype
return buf
}
function allocUnsafe (size) {
return createBuffer(size < 0 ? 0 : checked(size) | 0)
}
function fromString (string) {
var length = byteLength(string) | 0
var buf = createBuffer(length)
var actual = buf.write(string)
if (actual !== length) {
// Writing a hex string, for example, that contains invalid characters will
// cause everything after the first invalid character to be ignored. (e.g.
// 'abxxcd' will be treated as 'ab')
buf = buf.slice(0, actual)
}
return buf
}
function fromArrayLike (array) {
var length = array.length < 0 ? 0 : checked(array.length) | 0
var buf = createBuffer(length)
for (var i = 0; i < length; i += 1) {
buf[i] = array[i] & 255
}
return buf
}
function fromArrayBuffer (array, byteOffset, length) {
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError('\'offset\' is out of bounds')
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError('\'length\' is out of bounds')
}
var buf
if (byteOffset === undefined && length === undefined) {
buf = new Uint8Array(array)
} else if (length === undefined) {
buf = new Uint8Array(array, byteOffset)
} else {
buf = new Uint8Array(array, byteOffset, length)
}
// Return an augmented `Uint8Array` instance
buf.__proto__ = Buffer.prototype
return buf
}
function fromObject (obj) {
if (Buffer.isBuffer(obj)) {
var len = checked(obj.length) | 0
var buf = createBuffer(len)
if (buf.length === 0) {
return buf
}
obj.copy(buf, 0, 0, len)
return buf
}
if (obj) {
if ((typeof ArrayBuffer !== 'undefined' &&
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
if (typeof obj.length !== 'number' || isnan(obj.length)) {
return createBuffer(0)
}
return fromArrayLike(obj)
}
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
return fromArrayLike(obj.data)
}
}
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
}
function utf8ToBytes (string, units) {
units = units || Infinity
var codePoint
var length = string.length
var leadSurrogate = null
var bytes = []
for (var i = 0; i < length; ++i) {
codePoint = string.charCodeAt(i)
// is surrogate component
if (codePoint > 0xD7FF && codePoint < 0xE000) {
// last char was a lead
if (!leadSurrogate) {
// no lead yet
if (codePoint > 0xDBFF) {
// unexpected trail
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
} else if (i + 1 === length) {
// unpaired lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
}
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if (codePoint < 0xDC00) {
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
leadSurrogate = codePoint
continue
}
// valid surrogate pair
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
} else if (leadSurrogate) {
// valid bmp char, but last char was a lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
}
leadSurrogate = null
// encode utf8
if (codePoint < 0x80) {
if ((units -= 1) < 0) break
bytes.push(codePoint)
} else if (codePoint < 0x800) {
if ((units -= 2) < 0) break
bytes.push(
codePoint >> 0x6 | 0xC0,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x10000) {
if ((units -= 3) < 0) break
bytes.push(
codePoint >> 0xC | 0xE0,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x110000) {
if ((units -= 4) < 0) break
bytes.push(
codePoint >> 0x12 | 0xF0,
codePoint >> 0xC & 0x3F | 0x80,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else {
throw new Error('Invalid code point')
}
}
return bytes
}
function byteLength (string) {
if (Buffer.isBuffer(string)) {
return string.length
}
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
return string.byteLength
}
if (typeof string !== 'string') {
string = '' + string
}
var len = string.length
if (len === 0) return 0
return utf8ToBytes(string).length
}
function blitBuffer (src, dst, offset, length) {
for (var i = 0; i < length; ++i) {
if ((i + offset >= dst.length) || (i >= src.length)) break
dst[i + offset] = src[i]
}
return i
}
function utf8Write (buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
}
function from (value, offset, length) {
if (typeof value === 'number') {
throw new TypeError('"value" argument must not be a number')
}
if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
return fromArrayBuffer(value, offset, length)
}
if (typeof value === 'string') {
return fromString(value, offset)
}
return fromObject(value)
}
Buffer.prototype.write = function write (string, offset, length) {
// Buffer#write(string)
if (offset === undefined) {
length = this.length
offset = 0
// Buffer#write(string, encoding)
} else if (length === undefined && typeof offset === 'string') {
length = this.length
offset = 0
// Buffer#write(string, offset[, length])
} else if (isFinite(offset)) {
offset = offset | 0
if (isFinite(length)) {
length = length | 0
} else {
length = undefined
}
}
var remaining = this.length - offset
if (length === undefined || length > remaining) length = remaining
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
throw new RangeError('Attempt to write outside buffer bounds')
}
return utf8Write(this, string, offset, length)
}
Buffer.prototype.slice = function slice (start, end) {
var len = this.length
start = ~~start
end = end === undefined ? len : ~~end
if (start < 0) {
start += len
if (start < 0) start = 0
} else if (start > len) {
start = len
}
if (end < 0) {
end += len
if (end < 0) end = 0
} else if (end > len) {
end = len
}
if (end < start) end = start
var newBuf = this.subarray(start, end)
// Return an augmented `Uint8Array` instance
newBuf.__proto__ = Buffer.prototype
return newBuf
}
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
if (!start) start = 0
if (!end && end !== 0) end = this.length
if (targetStart >= target.length) targetStart = target.length
if (!targetStart) targetStart = 0
if (end > 0 && end < start) end = start
// Copy 0 bytes; we're done
if (end === start) return 0
if (target.length === 0 || this.length === 0) return 0
// Fatal error conditions
if (targetStart < 0) {
throw new RangeError('targetStart out of bounds')
}
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
if (end < 0) throw new RangeError('sourceEnd out of bounds')
// Are we oob?
if (end > this.length) end = this.length
if (target.length - targetStart < end - start) {
end = target.length - targetStart + start
}
var len = end - start
var i
if (this === target && start < targetStart && targetStart < end) {
// descending copy from end
for (i = len - 1; i >= 0; --i) {
target[i + targetStart] = this[i + start]
}
} else if (len < 1000) {
// ascending copy from start
for (i = 0; i < len; ++i) {
target[i + targetStart] = this[i + start]
}
} else {
Uint8Array.prototype.set.call(
target,
this.subarray(start, start + len),
targetStart
)
}
return len
}
Buffer.prototype.fill = function fill (val, start, end) {
// Handle string cases:
if (typeof val === 'string') {
if (typeof start === 'string') {
start = 0
end = this.length
} else if (typeof end === 'string') {
end = this.length
}
if (val.length === 1) {
var code = val.charCodeAt(0)
if (code < 256) {
val = code
}
}
} else if (typeof val === 'number') {
val = val & 255
}
// Invalid ranges are not set to a default, so can range check early.
if (start < 0 || this.length < start || this.length < end) {
throw new RangeError('Out of range index')
}
if (end <= start) {
return this
}
start = start >>> 0
end = end === undefined ? this.length : end >>> 0
if (!val) val = 0
var i
if (typeof val === 'number') {
for (i = start; i < end; ++i) {
this[i] = val
}
} else {
var bytes = Buffer.isBuffer(val)
? val
: new Buffer(val)
var len = bytes.length
for (i = 0; i < end - start; ++i) {
this[i + start] = bytes[i % len]
}
}
return this
}
Buffer.concat = function concat (list, length) {
if (!isArray(list)) {
throw new TypeError('"list" argument must be an Array of Buffers')
}
if (list.length === 0) {
return createBuffer(null, 0)
}
var i
if (length === undefined) {
length = 0
for (i = 0; i < list.length; ++i) {
length += list[i].length
}
}
var buffer = allocUnsafe(length)
var pos = 0
for (i = 0; i < list.length; ++i) {
var buf = list[i]
if (!Buffer.isBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers')
}
buf.copy(buffer, pos)
pos += buf.length
}
return buffer
}
Buffer.byteLength = byteLength
Buffer.prototype._isBuffer = true
Buffer.isBuffer = function isBuffer (b) {
return !!(b != null && b._isBuffer)
}
module.exports = Buffer
/***/ }),
/***/ 134:
/***/ (function(module, exports) {
exports.L = { bit: 1 }
exports.M = { bit: 0 }
exports.Q = { bit: 3 }
exports.H = { bit: 2 }
function fromString (string) {
if (typeof string !== 'string') {
throw new Error('Param is not a string')
}
var lcStr = string.toLowerCase()
switch (lcStr) {
case 'l':
case 'low':
return exports.L
case 'm':
case 'medium':
return exports.M
case 'q':
case 'quartile':
return exports.Q
case 'h':
case 'high':
return exports.H
default:
throw new Error('Unknown EC Level: ' + string)
}
}
exports.isValid = function isValid (level) {
return level && typeof level.bit !== 'undefined' &&
level.bit >= 0 && level.bit < 4
}
exports.from = function from (value, defaultValue) {
if (exports.isValid(value)) {
return value
}
try {
return fromString(value)
} catch (e) {
return defaultValue
}
}
/***/ }),
/***/ 136:
/***/ (function(module, exports) {
var toString = {}.toString;
module.exports = Array.isArray || function (arr) {
return toString.call(arr) == '[object Array]';
};
/***/ }),
/***/ 143:
/***/ (function(module, exports, __webpack_require__) {
var ECLevel = __webpack_require__(134)
var EC_BLOCKS_TABLE = [
// L M Q H
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 2, 2,
1, 2, 2, 4,
1, 2, 4, 4,
2, 4, 4, 4,
2, 4, 6, 5,
2, 4, 6, 6,
2, 5, 8, 8,
4, 5, 8, 8,
4, 5, 8, 11,
4, 8, 10, 11,
4, 9, 12, 16,
4, 9, 16, 16,
6, 10, 12, 18,
6, 10, 17, 16,
6, 11, 16, 19,
6, 13, 18, 21,
7, 14, 21, 25,
8, 16, 20, 25,
8, 17, 23, 25,
9, 17, 23, 34,
9, 18, 25, 30,
10, 20, 27, 32,
12, 21, 29, 35,
12, 23, 34, 37,
12, 25, 34, 40,
13, 26, 35, 42,
14, 28, 38, 45,
15, 29, 40, 48,
16, 31, 43, 51,
17, 33, 45, 54,
18, 35, 48, 57,
19, 37, 51, 60,
19, 38, 53, 63,
20, 40, 56, 66,
21, 43, 59, 70,
22, 45, 62, 74,
24, 47, 65, 77,
25, 49, 68, 81
]
var EC_CODEWORDS_TABLE = [
// L M Q H
7, 10, 13, 17,
10, 16, 22, 28,
15, 26, 36, 44,
20, 36, 52, 64,
26, 48, 72, 88,
36, 64, 96, 112,
40, 72, 108, 130,
48, 88, 132, 156,
60, 110, 160, 192,
72, 130, 192, 224,
80, 150, 224, 264,
96, 176, 260, 308,
104, 198, 288, 352,
120, 216, 320, 384,
132, 240, 360, 432,
144, 280, 408, 480,
168, 308, 448, 532,
180, 338, 504, 588,
196, 364, 546, 650,
224, 416, 600, 700,
224, 442, 644, 750,
252, 476, 690, 816,
270, 504, 750, 900,
300, 560, 810, 960,
312, 588, 870, 1050,
336, 644, 952, 1110,
360, 700, 1020, 1200,
390, 728, 1050, 1260,
420, 784, 1140, 1350,
450, 812, 1200, 1440,
480, 868, 1290, 1530,
510, 924, 1350, 1620,
540, 980, 1440, 1710,
570, 1036, 1530, 1800,
570, 1064, 1590, 1890,
600, 1120, 1680, 1980,
630, 1204, 1770, 2100,
660, 1260, 1860, 2220,
720, 1316, 1950, 2310,
750, 1372, 2040, 2430
]
/**
* Returns the number of error correction block that the QR Code should contain
* for the specified version and error correction level.
*
* @param {Number} version QR Code version
* @param {Number} errorCorrectionLevel Error correction level
* @return {Number} Number of error correction blocks
*/
exports.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {
switch (errorCorrectionLevel) {
case ECLevel.L:
return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]
case ECLevel.M:
return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]
case ECLevel.Q:
return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]
case ECLevel.H:
return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]
default:
return undefined
}
}
/**
* Returns the number of error correction codewords to use for the specified
* version and error correction level.
*
* @param {Number} version QR Code version
* @param {Number} errorCorrectionLevel Error correction level
* @return {Number} Number of error correction codewords
*/
exports.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {
switch (errorCorrectionLevel) {
case ECLevel.L:
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]
case ECLevel.M:
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]
case ECLevel.Q:
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]
case ECLevel.H:
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]
default:
return undefined
}
}
/***/ }),
/***/ 144:
/***/ (function(module, exports) {
var numeric = '[0-9]+'
var alphanumeric = '[A-Z $%*+-./:]+'
var kanji = '(?:[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|' +
'[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B|' +
'[\u2010\u2015\u2018\u2019\u2025\u2026\u201C\u201D\u2225\u2260]|' +
'[\u0391-\u0451]|[\u00A7\u00A8\u00B1\u00B4\u00D7\u00F7])+'
var byte = '(?:(?![A-Z0-9 $%*+-./:]|' + kanji + ').)+'
exports.KANJI = new RegExp(kanji, 'g')
exports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+-./:]+', 'g')
exports.BYTE = new RegExp(byte, 'g')
exports.NUMERIC = new RegExp(numeric, 'g')
exports.ALPHANUMERIC = new RegExp(alphanumeric, 'g')
var TEST_KANJI = new RegExp('^' + kanji + '$')
var TEST_NUMERIC = new RegExp('^' + numeric + '$')
var TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+-./:]+$')
exports.testKanji = function testKanji (str) {
return TEST_KANJI.test(str)
}
exports.testNumeric = function testNumeric (str) {
return TEST_NUMERIC.test(str)
}
exports.testAlphanumeric = function testAlphanumeric (str) {
return TEST_ALPHANUMERIC.test(str)
}
/***/ }),
/***/ 145:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(8)
var ECCode = __webpack_require__(143)
var ECLevel = __webpack_require__(134)
var Mode = __webpack_require__(7)
var isArray = __webpack_require__(136)
// Generator polynomial used to encode version information
var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)
var G18_BCH = Utils.getBCHDigit(G18)
function getBestVersionForDataLength (mode, length, errorCorrectionLevel) {
for (var currentVersion = 1; currentVersion <= 40; currentVersion++) {
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
return currentVersion
}
}
return undefined
}
function getReservedBitsCount (mode, version) {
// Character count indicator + mode indicator bits
return Mode.getCharCountIndicator(mode, version) + 4
}
function getTotalBitsFromDataArray (segments, version) {
var totalBits = 0
segments.forEach(function (data) {
var reservedBits = getReservedBitsCount(data.mode, version)
totalBits += reservedBits + data.getBitsLength()
})
return totalBits
}
function getBestVersionForMixedData (segments, errorCorrectionLevel) {
for (var currentVersion = 1; currentVersion <= 40; currentVersion++) {
var length = getTotalBitsFromDataArray(segments, currentVersion)
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
return currentVersion
}
}
return undefined
}
/**
* Check if QR Code version is valid
*
* @param {Number} version QR Code version
* @return {Boolean} true if valid version, false otherwise
*/
exports.isValid = function isValid (version) {
return !isNaN(version) && version >= 1 && version <= 40
}
/**
* Returns version number from a value.
* If value is not a valid version, returns defaultValue
*
* @param {Number|String} value QR Code version
* @param {Number} defaultValue Fallback value
* @return {Number} QR Code version number
*/
exports.from = function from (value, defaultValue) {
if (exports.isValid(value)) {
return parseInt(value, 10)
}
return defaultValue
}
/**
* Returns how much data can be stored with the specified QR code version
* and error correction level
*
* @param {Number} version QR Code version (1-40)
* @param {Number} errorCorrectionLevel Error correction level
* @param {Mode} mode Data mode
* @return {Number} Quantity of storable data
*/
exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {
if (!exports.isValid(version)) {
throw new Error('Invalid QR Code version')
}
// Use Byte mode as default
if (typeof mode === 'undefined') mode = Mode.BYTE
// Total codewords for this QR code version (Data + Error correction)
var totalCodewords = Utils.getSymbolTotalCodewords(version)
// Total number of error correction codewords
var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
// Total number of data codewords
var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
if (mode === Mode.MIXED) return dataTotalCodewordsBits
var usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version)
// Return max number of storable codewords
switch (mode) {
case Mode.NUMERIC:
return Math.floor((usableBits / 10) * 3)
case Mode.ALPHANUMERIC:
return Math.floor((usableBits / 11) * 2)
case Mode.KANJI:
return Math.floor(usableBits / 13)
case Mode.BYTE:
default:
return Math.floor(usableBits / 8)
}
}
/**
* Returns the minimum version needed to contain the amount of data
*
* @param {Segment} data Segment of data
* @param {Number} [errorCorrectionLevel=H] Error correction level
* @param {Mode} mode Data mode
* @return {Number} QR Code version
*/
exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {
var seg
var ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M)
if (isArray(data)) {
if (data.length > 1) {
return getBestVersionForMixedData(data, ecl)
}
if (data.length === 0) {
return 1
}
seg = data[0]
} else {
seg = data
}
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)
}
/**
* Returns version information with relative error correction bits
*
* The version information is included in QR Code symbols of version 7 or larger.
* It consists of an 18-bit sequence containing 6 data bits,
* with 12 error correction bits calculated using the (18, 6) Golay code.
*
* @param {Number} version QR Code version
* @return {Number} Encoded version info bits
*/
exports.getEncodedBits = function getEncodedBits (version) {
if (!exports.isValid(version) || version < 7) {
throw new Error('Invalid QR Code version')
}
var d = version << 12
while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH))
}
return (version << 12) | d
}
/***/ }),
/***/ 146:
/***/ (function(module, exports) {
function hex2rgba (hex) {
if (typeof hex !== 'string') {
throw new Error('Color should be defined as hex string')
}
var hexCode = hex.slice().replace('#', '').split('')
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
throw new Error('Invalid hex color: ' + hex)
}
// Convert from short to long form (fff -> ffffff)
if (hexCode.length === 3 || hexCode.length === 4) {
hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
return [c, c]
}))
}
// Add default alpha value
if (hexCode.length === 6) hexCode.push('F', 'F')
var hexValue = parseInt(hexCode.join(''), 16)
return {
r: (hexValue >> 24) & 255,
g: (hexValue >> 16) & 255,
b: (hexValue >> 8) & 255,
a: hexValue & 255
}
}
exports.getOptions = function getOptions (options) {
if (!options) options = {}
if (!options.color) options.color = {}
var margin = typeof options.margin === 'undefined' ||
options.margin === null ||
options.margin < 0 ? 4 : options.margin
return {
scale: options.scale || 4,
margin: margin,
color: {
dark: hex2rgba(options.color.dark || '#000000ff'),
light: hex2rgba(options.color.light || '#ffffffff')
},
type: options.type,
rendererOpts: options.rendererOpts || {}
}
}
exports.qrToImageData = function qrToImageData (imgData, qr, margin, scale, color) {
var size = qr.modules.size
var data = qr.modules.data
var scaledMargin = margin * scale
var symbolSize = size * scale + scaledMargin * 2
var palette = [color.light, color.dark]
for (var i = 0; i < symbolSize; i++) {
for (var j = 0; j < symbolSize; j++) {
var posDst = (i * symbolSize + j) * 4
var pxColor = color.light
if (i >= scaledMargin && j >= scaledMargin &&
i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
var iSrc = Math.floor((i - scaledMargin) / scale)
var jSrc = Math.floor((j - scaledMargin) / scale)
pxColor = palette[data[iSrc * size + jSrc]]
}
imgData[posDst++] = pxColor.r
imgData[posDst++] = pxColor.g
imgData[posDst++] = pxColor.b
imgData[posDst] = pxColor.a
}
}
}
/***/ }),
/***/ 174:
/***/ (function(module, exports, __webpack_require__) {
var QRCode = __webpack_require__(187)
var CanvasRenderer = __webpack_require__(190)
var SvgRenderer = __webpack_require__(191)
function renderCanvas (renderFunc, canvas, text, opts, cb) {
var argsNum = arguments.length - 1
if (argsNum < 2) {
throw new Error('Too few arguments provided')
}
if (argsNum === 2) {
cb = text
text = canvas
canvas = opts = undefined
} else if (argsNum === 3) {
if (canvas.getContext && typeof cb === 'undefined') {
cb = opts
opts = undefined
} else {
cb = opts
opts = text
text = canvas
canvas = undefined
}
}
if (typeof cb !== 'function') {
throw new Error('Callback required as last argument')
}
try {
var data = QRCode.create(text, opts)
cb(null, renderFunc(data, canvas, opts))
} catch (e) {
cb(e)
}
}
exports.create = QRCode.create
exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render)
exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL)
// only svg for now.
exports.toString = renderCanvas.bind(null, function (data, _, opts) {
return SvgRenderer.render(data, opts)
})
/**
* Legacy API
*/
exports.qrcodedraw = function () {
return {
draw: exports.toCanvas
}
}
/***/ }),
/***/ 175:
/***/ (function(module, exports, __webpack_require__) {
/**
* Alignment pattern are fixed reference pattern in defined positions
* in a matrix symbology, which enables the decode software to re-synchronise
* the coordinate mapping of the image modules in the event of moderate amounts
* of distortion of the image.
*
* Alignment patterns are present only in QR Code symbols of version 2 or larger
* and their number depends on the symbol version.
*/
var getSymbolSize = __webpack_require__(8).getSymbolSize
/**
* Calculate the row/column coordinates of the center module of each alignment pattern
* for the specified QR Code version.
*
* The alignment patterns are positioned symmetrically on either side of the diagonal
* running from the top left corner of the symbol to the bottom right corner.
*
* Since positions are simmetrical only half of the coordinates are returned.
* Each item of the array will represent in turn the x and y coordinate.
* @see {@link getPositions}
*
* @param {Number} version QR Code version
* @return {Array} Array of coordinate
*/
exports.getRowColCoords = function getRowColCoords (version) {
if (version === 1) return []
var posCount = Math.floor(version / 7) + 2
var size = getSymbolSize(version)
var intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2
var positions = [size - 7] // Last coord is always (size - 7)
for (var i = 1; i < posCount - 1; i++) {
positions[i] = positions[i - 1] - intervals
}
positions.push(6) // First coord is always 6
return positions.reverse()
}
/**
* Returns an array containing the positions of each alignment pattern.
* Each array's element represent the center point of the pattern as (x, y) coordinates
*
* Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
* and filtering out the items that overlaps with finder pattern
*
* @example
* For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
* The alignment patterns, therefore, are to be centered on (row, column)
* positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
* Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
* and are not therefore used for alignment patterns.
*
* var pos = getPositions(7)
* // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
*
* @param {Number} version QR Code version
* @return {Array} Array of coordinates
*/
exports.getPositions = function getPositions (version) {
var coords = []
var pos = exports.getRowColCoords(version)
var posLength = pos.length
for (var i = 0; i < posLength; i++) {
for (var j = 0; j < posLength; j++) {
// Skip if position is occupied by finder patterns
if ((i === 0 && j === 0) || // top-left
(i === 0 && j === posLength - 1) || // bottom-left
(i === posLength - 1 && j === 0)) { // top-right
continue
}
coords.push([pos[i], pos[j]])
}
}
return coords
}
/***/ }),
/***/ 176:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(7)
/**
* Array of characters available in alphanumeric mode
*
* As per QR Code specification, to each character
* is assigned a value from 0 to 44 which in this case coincides
* with the array index
*
* @type {Array}
*/
var ALPHA_NUM_CHARS = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
' ', '$', '%', '*', '+', '-', '.', '/', ':'
]
function AlphanumericData (data) {
this.mode = Mode.ALPHANUMERIC
this.data = data
}
AlphanumericData.getBitsLength = function getBitsLength (length) {
return 11 * Math.floor(length / 2) + 6 * (length % 2)
}
AlphanumericData.prototype.getLength = function getLength () {
return this.data.length
}
AlphanumericData.prototype.getBitsLength = function getBitsLength () {
return AlphanumericData.getBitsLength(this.data.length)
}
AlphanumericData.prototype.write = function write (bitBuffer) {
var i
// Input data characters are divided into groups of two characters
// and encoded as 11-bit binary codes.
for (i = 0; i + 2 <= this.data.length; i += 2) {
// The character value of the first character is multiplied by 45
var value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45
// The character value of the second digit is added to the product
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1])
// The sum is then stored as 11-bit binary number
bitBuffer.put(value, 11)
}
// If the number of input data characters is not a multiple of two,
// the character value of the final character is encoded as a 6-bit binary number.
if (this.data.length % 2) {
bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6)
}
}
module.exports = AlphanumericData
/***/ }),
/***/ 177:
/***/ (function(module, exports) {
function BitBuffer () {
this.buffer = []
this.length = 0
}
BitBuffer.prototype = {
get: function (index) {
var bufIndex = Math.floor(index / 8)
return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
},
put: function (num, length) {
for (var i = 0; i < length; i++) {
this.putBit(((num >>> (length - i - 1)) & 1) === 1)
}
},
getLengthInBits: function () {
return this.length
},
putBit: function (bit) {
var bufIndex = Math.floor(this.length / 8)
if (this.buffer.length <= bufIndex) {
this.buffer.push(0)
}
if (bit) {
this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))
}
this.length++
}
}
module.exports = BitBuffer
/***/ }),
/***/ 178:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
/**
* Helper class to handle QR Code symbol modules
*
* @param {Number} size Symbol size
*/
function BitMatrix (size) {
if (!size || size < 1) {
throw new Error('BitMatrix size must be defined and greater than 0')
}
this.size = size
this.data = new Buffer(size * size)
this.data.fill(0)
this.reservedBit = new Buffer(size * size)
this.reservedBit.fill(0)
}
/**
* Set bit value at specified location
* If reserved flag is set, this bit will be ignored during masking process
*
* @param {Number} row
* @param {Number} col
* @param {Boolean} value
* @param {Boolean} reserved
*/
BitMatrix.prototype.set = function (row, col, value, reserved) {
var index = row * this.size + col
this.data[index] = value
if (reserved) this.reservedBit[index] = true
}
/**
* Returns bit value at specified location
*
* @param {Number} row
* @param {Number} col
* @return {Boolean}
*/
BitMatrix.prototype.get = function (row, col) {
return this.data[row * this.size + col]
}
/**
* Applies xor operator at specified location
* (used during masking process)
*
* @param {Number} row
* @param {Number} col
* @param {Boolean} value
*/
BitMatrix.prototype.xor = function (row, col, value) {
this.data[row * this.size + col] ^= value
}
/**
* Check if bit at specified location is reserved
*
* @param {Number} row
* @param {Number} col
* @return {Boolean}
*/
BitMatrix.prototype.isReserved = function (row, col) {
return this.reservedBit[row * this.size + col]
}
module.exports = BitMatrix
/***/ }),
/***/ 179:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var Mode = __webpack_require__(7)
function ByteData (data) {
this.mode = Mode.BYTE
this.data = new Buffer(data)
}
ByteData.getBitsLength = function getBitsLength (length) {
return length * 8
}
ByteData.prototype.getLength = function getLength () {
return this.data.length
}
ByteData.prototype.getBitsLength = function getBitsLength () {
return ByteData.getBitsLength(this.data.length)
}
ByteData.prototype.write = function (bitBuffer) {
for (var i = 0, l = this.data.length; i < l; i++) {
bitBuffer.put(this.data[i], 8)
}
}
module.exports = ByteData
/***/ }),
/***/ 180:
/***/ (function(module, exports, __webpack_require__) {
var getSymbolSize = __webpack_require__(8).getSymbolSize
var FINDER_PATTERN_SIZE = 7
/**
* Returns an array containing the positions of each finder pattern.
* Each array's element represent the top-left point of the pattern as (x, y) coordinates
*
* @param {Number} version QR Code version
* @return {Array} Array of coordinates
*/
exports.getPositions = function getPositions (version) {
var size = getSymbolSize(version)
return [
// top-left
[0, 0],
// top-right
[size - FINDER_PATTERN_SIZE, 0],
// bottom-left
[0, size - FINDER_PATTERN_SIZE]
]
}
/***/ }),
/***/ 181:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(8)
var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)
var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)
var G15_BCH = Utils.getBCHDigit(G15)
/**
* Returns format information with relative error correction bits
*
* The format information is a 15-bit sequence containing 5 data bits,
* with 10 error correction bits calculated using the (15, 5) BCH code.
*
* @param {Number} errorCorrectionLevel Error correction level
* @param {Number} mask Mask pattern
* @return {Number} Encoded format information bits
*/
exports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {
var data = ((errorCorrectionLevel.bit << 3) | mask)
var d = data << 10
while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH))
}
// xor final data with mask pattern in order to ensure that
// no combination of Error Correction Level and data mask pattern
// will result in an all-zero data string
return ((data << 10) | d) ^ G15_MASK
}
/***/ }),
/***/ 182:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var EXP_TABLE = new Buffer(512)
var LOG_TABLE = new Buffer(256)
/**
* Precompute the log and anti-log tables for faster computation later
*
* For each possible value in the galois field 2^8, we will pre-compute
* the logarithm and anti-logarithm (exponential) of this value
*
* ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
*/
;(function initTables () {
var x = 1
for (var i = 0; i < 255; i++) {
EXP_TABLE[i] = x
LOG_TABLE[x] = i
x <<= 1 // multiply by 2
// The QR code specification says to use byte-wise modulo 100011101 arithmetic.
// This means that when a number is 256 or larger, it should be XORed with 0x11D.
if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)
x ^= 0x11D
}
}
// Optimization: double the size of the anti-log table so that we don't need to mod 255 to
// stay inside the bounds (because we will mainly use this table for the multiplication of
// two GF numbers, no more).
// @see {@link mul}
for (i = 255; i < 512; i++) {
EXP_TABLE[i] = EXP_TABLE[i - 255]
}
}())
/**
* Returns log value of n inside Galois Field
*
* @param {Number} n
* @return {Number}
*/
exports.log = function log (n) {
if (n < 1) throw new Error('log(' + n + ')')
return LOG_TABLE[n]
}
/**
* Returns anti-log value of n inside Galois Field
*
* @param {Number} n
* @return {Number}
*/
exports.exp = function exp (n) {
return EXP_TABLE[n]
}
/**
* Multiplies two number inside Galois Field
*
* @param {Number} x
* @param {Number} y
* @return {Number}
*/
exports.mul = function mul (x, y) {
if (x === 0 || y === 0) return 0
// should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
// @see {@link initTables}
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]
}
/***/ }),
/***/ 183:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(7)
var Utils = __webpack_require__(8)
function KanjiData (data) {
this.mode = Mode.KANJI
this.data = data
}
KanjiData.getBitsLength = function getBitsLength (length) {
return length * 13
}
KanjiData.prototype.getLength = function getLength () {
return this.data.length
}
KanjiData.prototype.getBitsLength = function getBitsLength () {
return KanjiData.getBitsLength(this.data.length)
}
KanjiData.prototype.write = function (bitBuffer) {
var i
// In the Shift JIS system, Kanji characters are represented by a two byte combination.
// These byte values are shifted from the JIS X 0208 values.
// JIS X 0208 gives details of the shift coded representation.
for (i = 0; i < this.data.length; i++) {
var value = Utils.toSJIS(this.data[i])
// For characters with Shift JIS values from 0x8140 to 0x9FFC:
if (value >= 0x8140 && value <= 0x9FFC) {
// Subtract 0x8140 from Shift JIS value
value -= 0x8140
// For characters with Shift JIS values from 0xE040 to 0xEBBF
} else if (value >= 0xE040 && value <= 0xEBBF) {
// Subtract 0xC140 from Shift JIS value
value -= 0xC140
} else {
throw new Error(
'Invalid SJIS character: ' + this.data[i] + '\n' +
'Make sure your charset is UTF-8')
}
// Multiply most significant byte of result by 0xC0
// and add least significant byte to product
value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff)
// Convert result to a 13-bit binary string
bitBuffer.put(value, 13)
}
}
module.exports = KanjiData
/***/ }),
/***/ 184:
/***/ (function(module, exports) {
/**
* Data mask pattern reference
* @type {Object}
*/
exports.Patterns = {
PATTERN000: 0,
PATTERN001: 1,
PATTERN010: 2,
PATTERN011: 3,
PATTERN100: 4,
PATTERN101: 5,
PATTERN110: 6,
PATTERN111: 7
}
/**
* Weighted penalty scores for the undesirable features
* @type {Object}
*/
var PenaltyScores = {
N1: 3,
N2: 3,
N3: 40,
N4: 10
}
/**
* Find adjacent modules in row/column with the same color
* and assign a penalty value.
*
* Points: N1 + i
* i is the amount by which the number of adjacent modules of the same color exceeds 5
*/
exports.getPenaltyN1 = function getPenaltyN1 (data) {
var size = data.size
var points = 0
var sameCountCol = 0
var sameCountRow = 0
var lastCol = null
var lastRow = null
for (var row = 0; row < size; row++) {
sameCountCol = sameCountRow = 0
lastCol = lastRow = null
for (var col = 0; col < size; col++) {
var module = data.get(row, col)
if (module === lastCol) {
sameCountCol++
} else {
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
lastCol = module
sameCountCol = 1
}
module = data.get(col, row)
if (module === lastRow) {
sameCountRow++
} else {
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
lastRow = module
sameCountRow = 1
}
}
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
}
return points
}
/**
* Find 2x2 blocks with the same color and assign a penalty value
*
* Points: N2 * (m - 1) * (n - 1)
*/
exports.getPenaltyN2 = function getPenaltyN2 (data) {
var size = data.size
var points = 0
for (var row = 0; row < size - 1; row++) {
for (var col = 0; col < size - 1; col++) {
var last = data.get(row, col) +
data.get(row, col + 1) +
data.get(row + 1, col) +
data.get(row + 1, col + 1)
if (last === 4 || last === 0) points++
}
}
return points * PenaltyScores.N2
}
/**
* Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
* preceded or followed by light area 4 modules wide
*
* Points: N3 * number of pattern found
*/
exports.getPenaltyN3 = function getPenaltyN3 (data) {
var size = data.size
var points = 0
var bitsCol = 0
var bitsRow = 0
for (var row = 0; row < size; row++) {
bitsCol = bitsRow = 0
for (var col = 0; col < size; col++) {
bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col)
if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++
bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row)
if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++
}
}
return points * PenaltyScores.N3
}
/**
* Calculate proportion of dark modules in entire symbol
*
* Points: N4 * k
*
* k is the rating of the deviation of the proportion of dark modules
* in the symbol from 50% in steps of 5%
*/
exports.getPenaltyN4 = function getPenaltyN4 (data) {
var darkCount = 0
var modulesCount = data.data.length
for (var i = 0; i < modulesCount; i++) darkCount += data.data[i]
var k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10)
return k * PenaltyScores.N4
}
/**
* Return mask value at given position
*
* @param {Number} maskPattern Pattern reference value
* @param {Number} i Row
* @param {Number} j Column
* @return {Boolean} Mask value
*/
function getMaskAt (maskPattern, i, j) {
switch (maskPattern) {
case exports.Patterns.PATTERN000: return (i + j) % 2 === 0
case exports.Patterns.PATTERN001: return i % 2 === 0
case exports.Patterns.PATTERN010: return j % 3 === 0
case exports.Patterns.PATTERN011: return (i + j) % 3 === 0
case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0
case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0
case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0
case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0
default: throw new Error('bad maskPattern:' + maskPattern)
}
}
/**
* Apply a mask pattern to a BitMatrix
*
* @param {Number} pattern Pattern reference number
* @param {BitMatrix} data BitMatrix data
*/
exports.applyMask = function applyMask (pattern, data) {
var size = data.size
for (var col = 0; col < size; col++) {
for (var row = 0; row < size; row++) {
if (data.isReserved(row, col)) continue
data.xor(row, col, getMaskAt(pattern, row, col))
}
}
}
/**
* Returns the best mask pattern for data
*
* @param {BitMatrix} data
* @return {Number} Mask pattern reference number
*/
exports.getBestMask = function getBestMask (data, setupFormatFunc) {
var numPatterns = Object.keys(exports.Patterns).length
var bestPattern = 0
var lowerPenalty = Infinity
for (var p = 0; p < numPatterns; p++) {
setupFormatFunc(p)
exports.applyMask(p, data)
// Calculate penalty
var penalty =
exports.getPenaltyN1(data) +
exports.getPenaltyN2(data) +
exports.getPenaltyN3(data) +
exports.getPenaltyN4(data)
// Undo previously applied mask
exports.applyMask(p, data)
if (penalty < lowerPenalty) {
lowerPenalty = penalty
bestPattern = p
}
}
return bestPattern
}
/***/ }),
/***/ 185:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(7)
function NumericData (data) {
this.mode = Mode.NUMERIC
this.data = data.toString()
}
NumericData.getBitsLength = function getBitsLength (length) {
return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
}
NumericData.prototype.getLength = function getLength () {
return this.data.length
}
NumericData.prototype.getBitsLength = function getBitsLength () {
return NumericData.getBitsLength(this.data.length)
}
NumericData.prototype.write = function write (bitBuffer) {
var i, group, value
// The input data string is divided into groups of three digits,
// and each group is converted to its 10-bit binary equivalent.
for (i = 0; i + 3 <= this.data.length; i += 3) {
group = this.data.substr(i, 3)
value = parseInt(group, 10)
bitBuffer.put(value, 10)
}
// If the number of input digits is not an exact multiple of three,
// the final one or two digits are converted to 4 or 7 bits respectively.
var remainingNum = this.data.length - i
if (remainingNum > 0) {
group = this.data.substr(i)
value = parseInt(group, 10)
bitBuffer.put(value, remainingNum * 3 + 1)
}
}
module.exports = NumericData
/***/ }),
/***/ 186:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var GF = __webpack_require__(182)
/**
* Multiplies two polynomials inside Galois Field
*
* @param {Buffer} p1 Polynomial
* @param {Buffer} p2 Polynomial
* @return {Buffer} Product of p1 and p2
*/
exports.mul = function mul (p1, p2) {
var coeff = new Buffer(p1.length + p2.length - 1)
coeff.fill(0)
for (var i = 0; i < p1.length; i++) {
for (var j = 0; j < p2.length; j++) {
coeff[i + j] ^= GF.mul(p1[i], p2[j])
}
}
return coeff
}
/**
* Calculate the remainder of polynomials division
*
* @param {Buffer} divident Polynomial
* @param {Buffer} divisor Polynomial
* @return {Buffer} Remainder
*/
exports.mod = function mod (divident, divisor) {
var result = new Buffer(divident)
while ((result.length - divisor.length) >= 0) {
var coeff = result[0]
for (var i = 0; i < divisor.length; i++) {
result[i] ^= GF.mul(divisor[i], coeff)
}
// remove all zeros from buffer head
var offset = 0
while (offset < result.length && result[offset] === 0) offset++
result = result.slice(offset)
}
return result
}
/**
* Generate an irreducible generator polynomial of specified degree
* (used by Reed-Solomon encoder)
*
* @param {Number} degree Degree of the generator polynomial
* @return {Buffer} Buffer containing polynomial coefficients
*/
exports.generateECPolynomial = function generateECPolynomial (degree) {
var poly = new Buffer([1])
for (var i = 0; i < degree; i++) {
poly = exports.mul(poly, [1, GF.exp(i)])
}
return poly
}
/***/ }),
/***/ 187:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var Utils = __webpack_require__(8)
var ECLevel = __webpack_require__(134)
var BitBuffer = __webpack_require__(177)
var BitMatrix = __webpack_require__(178)
var AlignmentPattern = __webpack_require__(175)
var FinderPattern = __webpack_require__(180)
var MaskPattern = __webpack_require__(184)
var ECCode = __webpack_require__(143)
var ReedSolomonEncoder = __webpack_require__(188)
var Version = __webpack_require__(145)
var FormatInfo = __webpack_require__(181)
var Mode = __webpack_require__(7)
var Segments = __webpack_require__(189)
var isArray = __webpack_require__(136)
/**
* QRCode for JavaScript
*
* modified by Ryan Day for nodejs support
* Copyright (c) 2011 Ryan Day
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
//---------------------------------------------------------------------
// QRCode for JavaScript
//
// Copyright (c) 2009 Kazuhiko Arase
//
// URL: http://www.d-project.com/
//
// Licensed under the MIT license:
// http://www.opensource.org/licenses/mit-license.php
//
// The word "QR Code" is registered trademark of
// DENSO WAVE INCORPORATED
// http://www.denso-wave.com/qrcode/faqpatent-e.html
//
//---------------------------------------------------------------------
*/
/**
* Add finder patterns bits to matrix
*
* @param {BitMatrix} matrix Modules matrix
* @param {Number} version QR Code version
*/
function setupFinderPattern (matrix, version) {
var size = matrix.size
var pos = FinderPattern.getPositions(version)
for (var i = 0; i < pos.length; i++) {
var row = pos[i][0]
var col = pos[i][1]
for (var r = -1; r <= 7; r++) {
if (row + r <= -1 || size <= row + r) continue
for (var c = -1; c <= 7; c++) {
if (col + c <= -1 || size <= col + c) continue
if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||
(c >= 0 && c <= 6 && (r === 0 || r === 6)) ||
(r >= 2 && r <= 4 && c >= 2 && c <= 4)) {
matrix.set(row + r, col + c, true, true)
} else {
matrix.set(row + r, col + c, false, true)
}
}
}
}
}
/**
* Add timing pattern bits to matrix
*
* Note: this function must be called before {@link setupAlignmentPattern}
*
* @param {BitMatrix} matrix Modules matrix
*/
function setupTimingPattern (matrix) {
var size = matrix.size
for (var r = 8; r < size - 8; r++) {
var value = r % 2 === 0
matrix.set(r, 6, value, true)
matrix.set(6, r, value, true)
}
}
/**
* Add alignment patterns bits to matrix
*
* Note: this function must be called after {@link setupTimingPattern}
*
* @param {BitMatrix} matrix Modules matrix
* @param {Number} version QR Code version
*/
function setupAlignmentPattern (matrix, version) {
var pos = AlignmentPattern.getPositions(version)
for (var i = 0; i < pos.length; i++) {
var row = pos[i][0]
var col = pos[i][1]
for (var r = -2; r <= 2; r++) {
for (var c = -2; c <= 2; c++) {
if (r === -2 || r === 2 || c === -2 || c === 2 ||
(r === 0 && c === 0)) {
matrix.set(row + r, col + c, true, true)
} else {
matrix.set(row + r, col + c, false, true)
}
}
}
}
}
/**
* Add version info bits to matrix
*
* @param {BitMatrix} matrix Modules matrix
* @param {Number} version QR Code version
*/
function setupVersionInfo (matrix, version) {
var size = matrix.size
var bits = Version.getEncodedBits(version)
var row, col, mod
for (var i = 0; i < 18; i++) {
row = Math.floor(i / 3)
col = i % 3 + size - 8 - 3
mod = ((bits >> i) & 1) === 1
matrix.set(row, col, mod, true)
matrix.set(col, row, mod, true)
}
}
/**
* Add format info bits to matrix
*
* @param {BitMatrix} matrix Modules matrix
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
* @param {Number} maskPattern Mask pattern reference value
*/
function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {
var size = matrix.size
var bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern)
var i, mod
for (i = 0; i < 15; i++) {
mod = ((bits >> i) & 1) === 1
// vertical
if (i < 6) {
matrix.set(i, 8, mod, true)
} else if (i < 8) {
matrix.set(i + 1, 8, mod, true)
} else {
matrix.set(size - 15 + i, 8, mod, true)
}
// horizontal
if (i < 8) {
matrix.set(8, size - i - 1, mod, true)
} else if (i < 9) {
matrix.set(8, 15 - i - 1 + 1, mod, true)
} else {
matrix.set(8, 15 - i - 1, mod, true)
}
}
// fixed module
matrix.set(size - 8, 8, 1, true)
}
/**
* Add encoded data bits to matrix
*
* @param {BitMatrix} matrix Modules matrix
* @param {Buffer} data Data codewords
*/
function setupData (matrix, data) {
var size = matrix.size
var inc = -1
var row = size - 1
var bitIndex = 7
var byteIndex = 0
for (var col = size - 1; col > 0; col -= 2) {
if (col === 6) col--
while (true) {
for (var c = 0; c < 2; c++) {
if (!matrix.isReserved(row, col - c)) {
var dark = false
if (byteIndex < data.length) {
dark = (((data[byteIndex] >>> bitIndex) & 1) === 1)
}
matrix.set(row, col - c, dark)
bitIndex--
if (bitIndex === -1) {
byteIndex++
bitIndex = 7
}
}
}
row += inc
if (row < 0 || size <= row) {
row -= inc
inc = -inc
break
}
}
}
}
/**
* Create encoded codewords from data input
*
* @param {Number} version QR Code version
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
* @param {ByteData} data Data input
* @return {Buffer} Buffer containing encoded codewords
*/
function createData (version, errorCorrectionLevel, segments) {
// Prepare data buffer
var buffer = new BitBuffer()
segments.forEach(function (data) {
// prefix data with mode indicator (4 bits)
buffer.put(data.mode.bit, 4)
// Prefix data with character count indicator.
// The character count indicator is a string of bits that represents the
// number of characters that are being encoded.
// The character count indicator must be placed after the mode indicator
// and must be a certain number of bits long, depending on the QR version
// and data mode
// @see {@link Mode.getCharCountIndicator}.
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version))
// add binary data sequence to buffer
data.write(buffer)
})
// Calculate required number of bits
var totalCodewords = Utils.getSymbolTotalCodewords(version)
var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
// Add a terminator.
// If the bit string is shorter than the total number of required bits,
// a terminator of up to four 0s must be added to the right side of the string.
// If the bit string is more than four bits shorter than the required number of bits,
// add four 0s to the end.
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
buffer.put(0, 4)
}
// If the bit string is fewer than four bits shorter, add only the number of 0s that
// are needed to reach the required number of bits.
// After adding the terminator, if the number of bits in the string is not a multiple of 8,
// pad the string on the right with 0s to make the string's length a multiple of 8.
while (buffer.getLengthInBits() % 8 !== 0) {
buffer.putBit(0)
}
// Add pad bytes if the string is still shorter than the total number of required bits.
// Extend the buffer to fill the data capacity of the symbol corresponding to
// the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
// and 00010001 (0x11) alternately.
var remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8
for (var i = 0; i < remainingByte; i++) {
buffer.put(i % 2 ? 0x11 : 0xEC, 8)
}
return createCodewords(buffer, version, errorCorrectionLevel)
}
/**
* Encode input data with Reed-Solomon and return codewords with
* relative error correction bits
*
* @param {BitBuffer} bitBuffer Data to encode
* @param {Number} version QR Code version
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
* @return {Buffer} Buffer containing encoded codewords
*/
function createCodewords (bitBuffer, version, errorCorrectionLevel) {
// Total codewords for this QR code version (Data + Error correction)
var totalCodewords = Utils.getSymbolTotalCodewords(version)
// Total number of error correction codewords
var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
// Total number of data codewords
var dataTotalCodewords = totalCodewords - ecTotalCodewords
// Total number of blocks
var ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel)
// Calculate how many blocks each group should contain
var blocksInGroup2 = totalCodewords % ecTotalBlocks
var blocksInGroup1 = ecTotalBlocks - blocksInGroup2
var totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks)
var dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks)
var dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1
// Number of EC codewords is the same for both groups
var ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1
// Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
var rs = new ReedSolomonEncoder(ecCount)
var offset = 0
var dcData = new Array(ecTotalBlocks)
var ecData = new Array(ecTotalBlocks)
var maxDataSize = 0
var buffer = new Buffer(bitBuffer.buffer)
// Divide the buffer into the required number of blocks
for (var b = 0; b < ecTotalBlocks; b++) {
var dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2
// extract a block of data from buffer
dcData[b] = buffer.slice(offset, offset + dataSize)
// Calculate EC codewords for this data block
ecData[b] = rs.encode(dcData[b])
offset += dataSize
maxDataSize = Math.max(maxDataSize, dataSize)
}
// Create final data
// Interleave the data and error correction codewords from each block
var data = new Buffer(totalCodewords)
var index = 0
var i, r
// Add data codewords
for (i = 0; i < maxDataSize; i++) {
for (r = 0; r < ecTotalBlocks; r++) {
if (i < dcData[r].length) {
data[index++] = dcData[r][i]
}
}
}
// Apped EC codewords
for (i = 0; i < ecCount; i++) {
for (r = 0; r < ecTotalBlocks; r++) {
data[index++] = ecData[r][i]
}
}
return data
}
/**
* Build QR Code symbol
*
* @param {String} data Input string
* @param {Number} version QR Code version
* @param {ErrorCorretionLevel} errorCorrectionLevel Error level
* @return {Object} Object containing symbol data
*/
function createSymbol (data, version, errorCorrectionLevel) {
var segments
if (isArray(data)) {
segments = Segments.fromArray(data)
} else if (typeof data === 'string') {
var estimatedVersion = version
if (!estimatedVersion) {
var rawSegments = Segments.rawSplit(data)
// Estimate best version that can contain raw splitted segments
estimatedVersion = Version.getBestVersionForData(rawSegments,
errorCorrectionLevel)
}
// Build optimized segments
// If estimated version is undefined, try with the highest version
segments = Segments.fromString(data, estimatedVersion || 40)
} else {
throw new Error('Invalid data')
}
// Get the min version that can contain data
var bestVersion = Version.getBestVersionForData(segments,
errorCorrectionLevel)
// If no version is found, data cannot be stored
if (!bestVersion) {
throw new Error('The amount of data is too big to be stored in a QR Code')
}
// If not specified, use min version as default
if (!version) {
version = bestVersion
// Check if the specified version can contain the data
} else if (version < bestVersion) {
throw new Error('\n' +
'The chosen QR Code version cannot contain this amount of data.\n' +
'Minimum version required to store current data is: ' + bestVersion + '.\n'
)
}
var dataBits = createData(version, errorCorrectionLevel, segments)
// Allocate matrix buffer
var moduleCount = Utils.getSymbolSize(version)
var modules = new BitMatrix(moduleCount)
// Add function modules
setupFinderPattern(modules, version)
setupTimingPattern(modules)
setupAlignmentPattern(modules, version)
// Add temporary dummy bits for format info just to set them as reserved.
// This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
// since the masking operation must be performed only on the encoding region.
// These blocks will be replaced with correct values later in code.
setupFormatInfo(modules, errorCorrectionLevel, 0)
if (version >= 7) {
setupVersionInfo(modules, version)
}
// Add data codewords
setupData(modules, dataBits)
// Find best mask pattern
var maskPattern = MaskPattern.getBestMask(modules,
setupFormatInfo.bind(null, modules, errorCorrectionLevel))
// Apply mask pattern
MaskPattern.applyMask(maskPattern, modules)
// Replace format info bits with correct values
setupFormatInfo(modules, errorCorrectionLevel, maskPattern)
return {
modules: modules,
version: version,
errorCorrectionLevel: errorCorrectionLevel,
maskPattern: maskPattern,
segments: segments
}
}
/**
* QR Code
*
* @param {String | Array} data Input data
* @param {Object} options Optional configurations
* @param {Number} options.version QR Code version
* @param {String} options.errorCorrectionLevel Error correction level
* @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
*/
exports.create = function create (data, options) {
if (typeof data === 'undefined' || data === '') {
throw new Error('No input text')
}
var errorCorrectionLevel = ECLevel.M
var version
if (typeof options !== 'undefined') {
// Use higher error correction level as default
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M)
version = Version.from(options.version)
if (options.toSJISFunc) {
Utils.setToSJISFunction(options.toSJISFunc)
}
}
return createSymbol(data, version, errorCorrectionLevel)
}
/***/ }),
/***/ 188:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var Polynomial = __webpack_require__(186)
function ReedSolomonEncoder (degree) {
this.genPoly = undefined
this.degree = degree
if (this.degree) this.initialize(this.degree)
}
/**
* Initialize the encoder.
* The input param should correspond to the number of error correction codewords.
*
* @param {Number} degree
*/
ReedSolomonEncoder.prototype.initialize = function initialize (degree) {
// create an irreducible generator polynomial
this.degree = degree
this.genPoly = Polynomial.generateECPolynomial(this.degree)
}
/**
* Encodes a chunk of data
*
* @param {Buffer} data Buffer containing input data
* @return {Buffer} Buffer containing encoded data
*/
ReedSolomonEncoder.prototype.encode = function encode (data) {
if (!this.genPoly) {
throw new Error('Encoder not initialized')
}
// Calculate EC for this data block
// extends data size to data+genPoly size
var pad = new Buffer(this.degree)
pad.fill(0)
var paddedData = Buffer.concat([data, pad], data.length + this.degree)
// The error correction codewords are the remainder after dividing the data codewords
// by a generator polynomial
var remainder = Polynomial.mod(paddedData, this.genPoly)
// return EC data blocks (last n byte, where n is the degree of genPoly)
// If coefficients number in remainder are less than genPoly degree,
// pad with 0s to the left to reach the needed number of coefficients
var start = this.degree - remainder.length
if (start > 0) {
var buff = new Buffer(this.degree)
buff.fill(0)
remainder.copy(buff, start)
return buff
}
return remainder
}
module.exports = ReedSolomonEncoder
/***/ }),
/***/ 189:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(7)
var NumericData = __webpack_require__(185)
var AlphanumericData = __webpack_require__(176)
var ByteData = __webpack_require__(179)
var KanjiData = __webpack_require__(183)
var Regex = __webpack_require__(144)
var Utils = __webpack_require__(8)
var dijkstra = __webpack_require__(193)
/**
* Returns UTF8 byte length
*
* @param {String} str Input string
* @return {Number} Number of byte
*/
function getStringByteLength (str) {
return unescape(encodeURIComponent(str)).length
}
/**
* Get a list of segments of the specified mode
* from a string
*
* @param {Mode} mode Segment mode
* @param {String} str String to process
* @return {Array} Array of object with segments data
*/
function getSegments (regex, mode, str) {
var segments = []
var result
while ((result = regex.exec(str)) !== null) {
segments.push({
data: result[0],
index: result.index,
mode: mode,
length: result[0].length
})
}
return segments
}
/**
* Extracts a series of segments with the appropriate
* modes from a string
*
* @param {String} dataStr Input string
* @return {Array} Array of object with segments data
*/
function getSegmentsFromString (dataStr) {
var numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr)
var alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr)
var byteSegs
var kanjiSegs
if (Utils.isKanjiModeEnabled()) {
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr)
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr)
} else {
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr)
kanjiSegs = []
}
var segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs)
return segs
.sort(function (s1, s2) {
return s1.index - s2.index
})
.map(function (obj) {
return {
data: obj.data,
mode: obj.mode,
length: obj.length
}
})
}
/**
* Returns how many bits are needed to encode a string of
* specified length with the specified mode
*
* @param {Number} length String length
* @param {Mode} mode Segment mode
* @return {Number} Bit length
*/
function getSegmentBitsLength (length, mode) {
switch (mode) {
case Mode.NUMERIC:
return NumericData.getBitsLength(length)
case Mode.ALPHANUMERIC:
return AlphanumericData.getBitsLength(length)
case Mode.KANJI:
return KanjiData.getBitsLength(length)
case Mode.BYTE:
return ByteData.getBitsLength(length)
}
}
/**
* Merges adjacent segments which have the same mode
*
* @param {Array} segs Array of object with segments data
* @return {Array} Array of object with segments data
*/
function mergeSegments (segs) {
return segs.reduce(function (acc, curr) {
var prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null
if (prevSeg && prevSeg.mode === curr.mode) {
acc[acc.length - 1].data += curr.data
return acc
}
acc.push(curr)
return acc
}, [])
}
/**
* Generates a list of all possible nodes combination which
* will be used to build a segments graph.
*
* Nodes are divided by groups. Each group will contain a list of all the modes
* in which is possible to encode the given text.
*
* For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
* The group for '12345' will contain then 3 objects, one for each
* possible encoding mode.
*
* Each node represents a possible segment.
*
* @param {Array} segs Array of object with segments data
* @return {Array} Array of object with segments data
*/
function buildNodes (segs) {
var nodes = []
for (var i = 0; i < segs.length; i++) {
var seg = segs[i]
switch (seg.mode) {
case Mode.NUMERIC:
nodes.push([seg,
{ data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
])
break
case Mode.ALPHANUMERIC:
nodes.push([seg,
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
])
break
case Mode.KANJI:
nodes.push([seg,
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
])
break
case Mode.BYTE:
nodes.push([
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
])
}
}
return nodes
}
/**
* Builds a graph from a list of nodes.
* All segments in each node group will be connected with all the segments of
* the next group and so on.
*
* At each connection will be assigned a weight depending on the
* segment's byte length.
*
* @param {Array} nodes Array of object with segments data
* @param {Number} version QR Code version
* @return {Object} Graph of all possible segments
*/
function buildGraph (nodes, version) {
var table = {}
var graph = {'start': {}}
var prevNodeIds = ['start']
for (var i = 0; i < nodes.length; i++) {
var nodeGroup = nodes[i]
var currentNodeIds = []
for (var j = 0; j < nodeGroup.length; j++) {
var node = nodeGroup[j]
var key = '' + i + j
currentNodeIds.push(key)
table[key] = { node: node, lastCount: 0 }
graph[key] = {}
for (var n = 0; n < prevNodeIds.length; n++) {
var prevNodeId = prevNodeIds[n]
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
graph[prevNodeId][key] =
getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -
getSegmentBitsLength(table[prevNodeId].lastCount, node.mode)
table[prevNodeId].lastCount += node.length
} else {
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +
4 + Mode.getCharCountIndicator(node.mode, version) // switch cost
}
}
}
prevNodeIds = currentNodeIds
}
for (n = 0; n < prevNodeIds.length; n++) {
graph[prevNodeIds[n]]['end'] = 0
}
return { map: graph, table: table }
}
/**
* Builds a segment from a specified data and mode.
* If a mode is not specified, the more suitable will be used.
*
* @param {String} data Input data
* @param {Mode | String} modesHint Data mode
* @return {Segment} Segment
*/
function buildSingleSegment (data, modesHint) {
var mode
var bestMode = Mode.getBestModeForData(data)
mode = Mode.from(modesHint, bestMode)
// Make sure data can be encoded
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
throw new Error('"' + data + '"' +
' cannot be encoded with mode ' + Mode.toString(mode) +
'.\n Suggested mode is: ' + Mode.toString(bestMode))
}
// Use Mode.BYTE if Kanji support is disabled
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
mode = Mode.BYTE
}
switch (mode) {
case Mode.NUMERIC:
return new NumericData(data)
case Mode.ALPHANUMERIC:
return new AlphanumericData(data)
case Mode.KANJI:
return new KanjiData(data)
case Mode.BYTE:
return new ByteData(data)
}
}
/**
* Builds a list of segments from an array.
* Array can contain Strings or Objects with segment's info.
*
* For each item which is a string, will be generated a segment with the given
* string and the more appropriate encoding mode.
*
* For each item which is an object, will be generated a segment with the given
* data and mode.
* Objects must contain at least the property "data".
* If property "mode" is not present, the more suitable mode will be used.
*
* @param {Array} array Array of objects with segments data
* @return {Array} Array of Segments
*/
exports.fromArray = function fromArray (array) {
return array.reduce(function (acc, seg) {
if (typeof seg === 'string') {
acc.push(buildSingleSegment(seg, null))
} else if (seg.data) {
acc.push(buildSingleSegment(seg.data, seg.mode))
}
return acc
}, [])
}
/**
* Builds an optimized sequence of segments from a string,
* which will produce the shortest possible bitstream.
*
* @param {String} data Input string
* @param {Number} version QR Code version
* @return {Array} Array of segments
*/
exports.fromString = function fromString (data, version) {
var segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled())
var nodes = buildNodes(segs)
var graph = buildGraph(nodes, version)
var path = dijkstra.find_path(graph.map, 'start', 'end')
var optimizedSegs = []
for (var i = 1; i < path.length - 1; i++) {
optimizedSegs.push(graph.table[path[i]].node)
}
return exports.fromArray(mergeSegments(optimizedSegs))
}
/**
* Splits a string in various segments with the modes which
* best represent their content.
* The produced segments are far from being optimized.
* The output of this function is only used to estimate a QR Code version
* which may contain the data.
*
* @param {string} data Input string
* @return {Array} Array of segments
*/
exports.rawSplit = function rawSplit (data) {
return exports.fromArray(
getSegmentsFromString(data, Utils.isKanjiModeEnabled())
)
}
/***/ }),
/***/ 190:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(146)
function clearCanvas (ctx, canvas, size) {
ctx.clearRect(0, 0, canvas.width, canvas.height)
if (!canvas.style) canvas.style = {}
canvas.height = size
canvas.width = size
canvas.style.height = size + 'px'
canvas.style.width = size + 'px'
}
function getCanvasElement () {
try {
return document.createElement('canvas')
} catch (e) {
throw new Error('You need to specify a canvas element')
}
}
exports.render = function render (qrData, canvas, options) {
var opts = options
var canvasEl = canvas
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
opts = canvas
canvas = undefined
}
if (!canvas) {
canvasEl = getCanvasElement()
}
opts = Utils.getOptions(opts)
var size = (qrData.modules.size + opts.margin * 2) * opts.scale
var ctx = canvasEl.getContext('2d')
var image = ctx.createImageData(size, size)
Utils.qrToImageData(image.data, qrData, opts.margin, opts.scale, opts.color)
clearCanvas(ctx, canvasEl, size)
ctx.putImageData(image, 0, 0)
return canvasEl
}
exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
var opts = options
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
opts = canvas
canvas = undefined
}
if (!opts) opts = {}
var canvasEl = exports.render(qrData, canvas, opts)
var type = opts.type || 'image/png'
var rendererOpts = opts.rendererOpts || {}
return canvasEl.toDataURL(type, rendererOpts.quality)
}
/***/ }),
/***/ 191:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(146)
function getColorAttrib (color) {
return 'fill="rgb(' + [color.r, color.g, color.b].join(',') + ')" ' +
'fill-opacity="' + (color.a / 255).toFixed(2) + '"'
}
exports.render = function render (qrData, options) {
var opts = Utils.getOptions(options)
var size = qrData.modules.size
var data = qrData.modules.data
var qrcodesize = (size + opts.margin * 2) * opts.scale
var xmlStr = '<?xml version="1.0" encoding="utf-8"?>\n'
xmlStr += '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n'
xmlStr += '<svg version="1.1" baseProfile="full"'
xmlStr += ' width="' + qrcodesize + '" height="' + qrcodesize + '"'
xmlStr += ' viewBox="0 0 ' + qrcodesize + ' ' + qrcodesize + '"'
xmlStr += ' xmlns="http://www.w3.org/2000/svg"'
xmlStr += ' xmlns:xlink="http://www.w3.org/1999/xlink"'
xmlStr += ' xmlns:ev="http://www.w3.org/2001/xml-events">\n'
xmlStr += '<rect x="0" y="0" width="' + qrcodesize + '" height="' + qrcodesize + '" ' + getColorAttrib(opts.color.light) + ' />\n'
xmlStr += '<defs><rect id="p" width="' + opts.scale + '" height="' + opts.scale + '" /></defs>\n'
xmlStr += '<g ' + getColorAttrib(opts.color.dark) + '>\n'
for (var i = 0; i < size; i++) {
for (var j = 0; j < size; j++) {
if (!data[i * size + j]) continue
var x = (opts.margin + j) * opts.scale
var y = (opts.margin + i) * opts.scale
xmlStr += '<use x="' + x + '" y="' + y + '" xlink:href="#p" />\n'
}
}
xmlStr += '</g>\n'
xmlStr += '</svg>'
return xmlStr
}
/***/ }),
/***/ 193:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/******************************************************************************
* Created 2008-08-19.
*
* Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
*
* Copyright (C) 2008
* Wyatt Baldwin <self@wyattbaldwin.com>
* All rights reserved
*
* Licensed under the MIT license.
*
* http://www.opensource.org/licenses/mit-license.php
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*****************************************************************************/
var dijkstra = {
single_source_shortest_paths: function(graph, s, d) {
// Predecessor map for each node that has been encountered.
// node ID => predecessor node ID
var predecessors = {};
// Costs of shortest paths from s to all nodes encountered.
// node ID => cost
var costs = {};
costs[s] = 0;
// Costs of shortest paths from s to all nodes encountered; differs from
// `costs` in that it provides easy access to the node that currently has
// the known shortest path from s.
// XXX: Do we actually need both `costs` and `open`?
var open = dijkstra.PriorityQueue.make();
open.push(s, 0);
var closest,
u, v,
cost_of_s_to_u,
adjacent_nodes,
cost_of_e,
cost_of_s_to_u_plus_cost_of_e,
cost_of_s_to_v,
first_visit;
while (!open.empty()) {
// In the nodes remaining in graph that have a known cost from s,
// find the node, u, that currently has the shortest path from s.
closest = open.pop();
u = closest.value;
cost_of_s_to_u = closest.cost;
// Get nodes adjacent to u...
adjacent_nodes = graph[u] || {};
// ...and explore the edges that connect u to those nodes, updating
// the cost of the shortest paths to any or all of those nodes as
// necessary. v is the node across the current edge from u.
for (v in adjacent_nodes) {
if (adjacent_nodes.hasOwnProperty(v)) {
// Get the cost of the edge running from u to v.
cost_of_e = adjacent_nodes[v];
// Cost of s to u plus the cost of u to v across e--this is *a*
// cost from s to v that may or may not be less than the current
// known cost to v.
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
// If we haven't visited v yet OR if the current known cost from s to
// v is greater than the new cost we just found (cost of s to u plus
// cost of u to v across e), update v's cost in the cost list and
// update v's predecessor in the predecessor list (it's now u).
cost_of_s_to_v = costs[v];
first_visit = (typeof costs[v] === 'undefined');
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
costs[v] = cost_of_s_to_u_plus_cost_of_e;
open.push(v, cost_of_s_to_u_plus_cost_of_e);
predecessors[v] = u;
}
}
}
}
if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
throw new Error(msg);
}
return predecessors;
},
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
var nodes = [];
var u = d;
var predecessor;
while (u) {
nodes.push(u);
predecessor = predecessors[u];
u = predecessors[u];
}
nodes.reverse();
return nodes;
},
find_path: function(graph, s, d) {
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
return dijkstra.extract_shortest_path_from_predecessor_list(
predecessors, d);
},
/**
* A very naive priority queue implementation.
*/
PriorityQueue: {
make: function (opts) {
var T = dijkstra.PriorityQueue,
t = {},
key;
opts = opts || {};
for (key in T) {
if (T.hasOwnProperty(key)) {
t[key] = T[key];
}
}
t.queue = [];
t.sorter = opts.sorter || T.default_sorter;
return t;
},
default_sorter: function (a, b) {
return a.cost - b.cost;
},
/**
* Add a new item to the queue and ensure the highest priority element
* is at the front of the queue.
*/
push: function (value, cost) {
var item = {value: value, cost: cost};
this.queue.push(item);
this.queue.sort(this.sorter);
},
/**
* Return the highest priority element in the queue.
*/
pop: function () {
return this.queue.shift();
},
empty: function () {
return this.queue.length === 0;
}
}
};
// node.js module exports
if (true) {
module.exports = dijkstra;
}
/***/ }),
/***/ 209:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
/**
* v_qrcode.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 生成绑定二维码页面
*/
var QRCode = __webpack_require__(174);
console.log(QRCode);
_public.iot.ready(init);
function init() {
//通用 按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading']);
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig(),
//页面传递参数
extras: [],
uuid: null,
qrCodeDisabled: false
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
console.log(this.extras);
this.setUuid(this.extras.uuid);
},
methods: {
getUuid: function getUuid() {
return this.uuid;
},
setUuid: function setUuid(id) {
this.uuid = id;
},
setQrCodeDisabled: function setQrCodeDisabled(boolean) {
this.qrCodeDisabled = boolean;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 生成二维码
onQRcodeButtonTap: function onQRcodeButtonTap() {
qrcodeButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
//生成二维码 button 参数
qrcodeButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.qrcode')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 生成二维码
function qrcodeButtonTap(self) {
_public.uComponents.showLoading(self);
_public.iot.business.sds.saveqr({
data: {
uuid: self.getUuid()
},
success: function success(response) {
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
var qrKey = response.data.qrKey;
var qr = self.$refs.qrcode;
QRCode.toCanvas(qr, qrKey, {
scale: 5,
margin: 2
}, function (error) {
if (error) {
console.log(error);
} else {
console.log('success');
_public.uComponents.hideLoading(self);
qr.style.width = "5.280rem";
qr.style.height = "5.280rem";
console.log(qr.style);
setTimeout(function () {
self.setQrCodeDisabled(true);
}, 1000 * 60 * 10);
}
});
} else {}
},
error: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 生成二维码失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'生成二维码失败');
// }
//请求失败
_public.uPublic.openRequestErrorAlert(self);
}
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 310:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(209);
/***/ }),
/***/ 7:
/***/ (function(module, exports, __webpack_require__) {
var Version = __webpack_require__(145)
var Regex = __webpack_require__(144)
/**
* Numeric mode encodes data from the decimal digit set (0 - 9)
* (byte values 30HEX to 39HEX).
* Normally, 3 data characters are represented by 10 bits.
*
* @type {Object}
*/
exports.NUMERIC = {
id: 'Numeric',
bit: 1 << 0,
ccBits: [10, 12, 14]
}
/**
* Alphanumeric mode encodes data from a set of 45 characters,
* i.e. 10 numeric digits (0 - 9),
* 26 alphabetic characters (A - Z),
* and 9 symbols (SP, $, %, *, +, -, ., /, :).
* Normally, two input characters are represented by 11 bits.
*
* @type {Object}
*/
exports.ALPHANUMERIC = {
id: 'Alphanumeric',
bit: 1 << 1,
ccBits: [9, 11, 13]
}
/**
* In byte mode, data is encoded at 8 bits per character.
*
* @type {Object}
*/
exports.BYTE = {
id: 'Byte',
bit: 1 << 2,
ccBits: [8, 16, 16]
}
/**
* The Kanji mode efficiently encodes Kanji characters in accordance with
* the Shift JIS system based on JIS X 0208.
* The Shift JIS values are shifted from the JIS X 0208 values.
* JIS X 0208 gives details of the shift coded representation.
* Each two-byte character value is compacted to a 13-bit binary codeword.
*
* @type {Object}
*/
exports.KANJI = {
id: 'Kanji',
bit: 1 << 3,
ccBits: [8, 10, 12]
}
/**
* Mixed mode will contain a sequences of data in a combination of any of
* the modes described above
*
* @type {Object}
*/
exports.MIXED = {
bit: -1
}
/**
* Returns the number of bits needed to store the data length
* according to QR Code specifications.
*
* @param {Mode} mode Data mode
* @param {Number} version QR Code version
* @return {Number} Number of bits
*/
exports.getCharCountIndicator = function getCharCountIndicator (mode, version) {
if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)
if (!Version.isValid(version)) {
throw new Error('Invalid version: ' + version)
}
if (version >= 1 && version < 10) return mode.ccBits[0]
else if (version < 27) return mode.ccBits[1]
return mode.ccBits[2]
}
/**
* Returns the most efficient mode to store the specified data
*
* @param {String} dataStr Input data string
* @return {Mode} Best mode
*/
exports.getBestModeForData = function getBestModeForData (dataStr) {
if (Regex.testNumeric(dataStr)) return exports.NUMERIC
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC
else if (Regex.testKanji(dataStr)) return exports.KANJI
else return exports.BYTE
}
/**
* Return mode name as string
*
* @param {Mode} mode Mode object
* @returns {String} Mode name
*/
exports.toString = function toString (mode) {
if (mode && mode.id) return mode.id
throw new Error('Invalid mode')
}
/**
* Check if input param is a valid mode object
*
* @param {Mode} mode Mode object
* @returns {Boolean} True if valid mode, false otherwise
*/
exports.isValid = function isValid (mode) {
return mode && mode.bit && mode.ccBits
}
/**
* Get mode object from its name
*
* @param {String} string Mode name
* @returns {Mode} Mode object
*/
function fromString (string) {
if (typeof string !== 'string') {
throw new Error('Param is not a string')
}
var lcStr = string.toLowerCase()
switch (lcStr) {
case 'numeric':
return exports.NUMERIC
case 'alphanumeric':
return exports.ALPHANUMERIC
case 'kanji':
return exports.KANJI
case 'byte':
return exports.BYTE
default:
throw new Error('Unknown mode: ' + string)
}
}
/**
* Returns mode from a value.
* If value is not a valid mode, returns defaultValue
*
* @param {Mode|String} value Encoding mode
* @param {Mode} defaultValue Fallback value
* @return {Mode} Encoding mode
*/
exports.from = function from (value, defaultValue) {
if (exports.isValid(value)) {
return value
}
try {
return fromString(value)
} catch (e) {
return defaultValue
}
}
/***/ }),
/***/ 8:
/***/ (function(module, exports) {
var toSJISFunction
var CODEWORDS_COUNT = [
0, // Not used
26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
]
/**
* Returns the QR Code size for the specified version
*
* @param {Number} version QR Code version
* @return {Number} size of QR code
*/
exports.getSymbolSize = function getSymbolSize (version) {
if (!version) throw new Error('"version" cannot be null or undefined')
if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
return version * 4 + 17
}
/**
* Returns the total number of codewords used to store data and EC information.
*
* @param {Number} version QR Code version
* @return {Number} Data length in bits
*/
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
return CODEWORDS_COUNT[version]
}
/**
* Encode data with Bose-Chaudhuri-Hocquenghem
*
* @param {Number} data Value to encode
* @return {Number} Encoded value
*/
exports.getBCHDigit = function (data) {
var digit = 0
while (data !== 0) {
digit++
data >>>= 1
}
return digit
}
exports.setToSJISFunction = function setToSJISFunction (f) {
if (typeof f !== 'function') {
throw new Error('"toSJISFunc" is not a valid function.')
}
toSJISFunction = f
}
exports.isKanjiModeEnabled = function () {
return typeof toSJISFunction !== 'undefined'
}
exports.toSJIS = function toSJIS (kanji) {
return toSJISFunction(kanji)
}
/***/ })
},[310]);
//# sourceMappingURL=qrcode.js.map
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
webpackJsonp([21],{
/***/ 211:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _config = __webpack_require__(9);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* v_addUser.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 添加用户页面
*/
_public.iot.ready(init);
function init() {
//通用 input、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-button', 'u-dialog', 'u-loading']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
textName: null,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig(),
extras: {}
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
console.log(this.extras);
},
methods: {
getTextName: function getTextName() {
return this.textName;
},
setTextName: function setTextName(text) {
this.textName = text;
},
getTextErrorTip: function getTextErrorTip() {
return this.textErrorTip;
},
setTextErrorTip: function setTextErrorTip(tip) {
this.textErrorTip = tip;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
onNameChange: function onNameChange(text) {
nameChange(this, text);
},
//tap 确定
onConfirmButtonTap: function onConfirmButtonTap() {
confirmButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
nameInput: {
initParam: {
class: 'custom-text',
icon: '&#xe6b0;',
placeholder: Vue.t('addUser.nameInputTip'),
maxlength: _config2.default.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() {
_public.iot.navigator.back();
}
function nameChange(self, text) {
self.textName = text;
self.setTextErrorTip(null);
console.log('nameChange: ' + self.textName);
}
//tap 确定
function confirmButtonTap(self) {
if (self.getTextName() == null || self.getTextName().trim() == '') {
self.setTextErrorTip(Vue.t('addUser.error.nameCanNotEmpty'));
} else {
_public.uComponents.showLoading(self);
_public.iot.business.api.sendCustom('lock/addLockUser', {
data: {
device_id: self.extras.deviceId,
nickname: self.getTextName()
},
success: function success(response) {
console.log(response);
if (response.data.id) {
_public.uComponents.openAlert(self, Vue.t('addUser.addUserSuccess'), {
text: Vue.t('btn.confirm'), callback: function callback() {
console.log("添加用户成功");
//跳转到门锁用户界面
_public.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: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 添加用户成功'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'添加用户失败');
// }
_public.uComponents.openAlert(self, Vue.t('addUser.addUserFailure'), {
text: Vue.t('btn.confirm'), callback: function callback() {
console.log("添加用户失败");
}
});
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 312:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(211);
/***/ })
},[312]);
//# sourceMappingURL=addUser.js.map
\ No newline at end of file
@font-face {
font-family: 'defaultIconfont';
src: url('../../resources/font/defaultIconfont.ttf') format('truetype');
}
@font-face {
font-family: 'iconfont';
src: url('../../resources/font/iconfont.ttf') format('truetype');
}
html,
body {
width: 100%;
height: 100%;
}
body {
-webkit-user-select: none;
user-select: none;
color: #fff;
font-size: 0.373rem;
background: -webkit-linear-gradient(left, #242635, #fff, #242635);
background: linear-gradient(to right, #242635, #fff, #242635);
background-color: #242635;
-webkit-background-size: 100% 1px;
background-size: 100% 1px;
background-repeat: no-repeat;
background-position: bottom center;
}
ul {
padding-left: 0;
list-style: none;
margin-bottom: 0;
}
p {
margin-bottom: 0;
}
.u-loading {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1050;
background-color: rgba(0, 0, 0, 0.8);
}
.u-loading .u-loading-box {
position: absolute;
top: 50%;
left: 0;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
right: 0;
}
.u-loading .u-loading-box .u-loading-icon {
width: 30px;
height: 30px;
background-position: center;
background-repeat: no-repeat;
background-image: url("../../resources/image/white_loading_icon.png");
-webkit-background-size: cover;
background-size: cover;
margin: 0 auto;
-webkit-animation: loading 1s steps(12, end) infinite;
animation: loading 1s steps(12, end) infinite;
}
.u-loading .u-loading-box .u-loading-text {
color: #fff;
margin-top: 0.32rem;
text-align: center;
}
@-webkit-keyframes loading {
0% {
-webkit-transform: rotate3d(0, 0, 1, 0deg);
transform: rotate3d(0, 0, 1, 0deg);
}
100% {
-webkit-transform: rotate3d(0, 0, 1, 360deg);
transform: rotate3d(0, 0, 1, 360deg);
}
}
@keyframes loading {
0% {
-webkit-transform: rotate3d(0, 0, 1, 0deg);
transform: rotate3d(0, 0, 1, 0deg);
}
100% {
-webkit-transform: rotate3d(0, 0, 1, 360deg);
transform: rotate3d(0, 0, 1, 360deg);
}
}
.custom-loading {
background-color: rgba(36, 38, 53, 0.9);
}
.custom-loading .u-loading-box {
color: #00ffff;
}
.custom-loading .u-loading-box .u-loading-icon {
font-size: 0.427rem;
margin: 0 auto;
width: 3.750em;
height: 3.750em;
position: relative;
background: none;
-webkit-animation: none;
animation: none;
}
.custom-loading .u-loading-box .u-loading-icon:before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 0.5em;
height: 0.5em;
margin: auto;
border-radius: 50%;
-webkit-transform: translateZ(0) scale(0.55);
transform: translateZ(0) scale(0.55);
-webkit-animation: loading 1.3s infinite linear;
animation: loading 1.3s infinite linear;
}
.custom-loading .u-loading-box .u-loading-text {
color: inherit;
font-size: 0.427rem;
margin-top: 0.533rem;
}
@-webkit-keyframes loading {
0%, 100% {
-webkit-box-shadow: 0 -3em 0 0.2em, 2em -2em 0 0em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 0;
box-shadow: 0 -3em 0 0.2em, 2em -2em 0 0em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 0;
}
12.5% {
-webkit-box-shadow: 0 -3em 0 0, 2em -2em 0 0.2em, 3em 0 0 0, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 0, 2em -2em 0 0.2em, 3em 0 0 0, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 -1em;
}
25% {
-webkit-box-shadow: 0 -3em 0 -0.5em, 2em -2em 0 0, 3em 0 0 0.2em, 2em 2em 0 0, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 -0.5em, 2em -2em 0 0, 3em 0 0 0.2em, 2em 2em 0 0, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 -1em;
}
37.5% {
-webkit-box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0em 0 0, 2em 2em 0 0.2em, 0 3em 0 0em, -2em 2em 0 -1em, -3em 0em 0 -1em, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0em 0 0, 2em 2em 0 0.2em, 0 3em 0 0em, -2em 2em 0 -1em, -3em 0em 0 -1em, -2em -2em 0 -1em;
}
50% {
-webkit-box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 0em, 0 3em 0 0.2em, -2em 2em 0 0, -3em 0em 0 -1em, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 0em, 0 3em 0 0.2em, -2em 2em 0 0, -3em 0em 0 -1em, -2em -2em 0 -1em;
}
62.5% {
-webkit-box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 0, -2em 2em 0 0.2em, -3em 0 0 0, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 0, -2em 2em 0 0.2em, -3em 0 0 0, -2em -2em 0 -1em;
}
75% {
-webkit-box-shadow: 0em -3em 0 -1em, 2em -2em 0 -1em, 3em 0em 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 0, -3em 0em 0 0.2em, -2em -2em 0 0;
box-shadow: 0em -3em 0 -1em, 2em -2em 0 -1em, 3em 0em 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 0, -3em 0em 0 0.2em, -2em -2em 0 0;
}
87.5% {
-webkit-box-shadow: 0em -3em 0 0, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 0, -3em 0em 0 0, -2em -2em 0 0.2em;
box-shadow: 0em -3em 0 0, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 0, -3em 0em 0 0, -2em -2em 0 0.2em;
}
}
@keyframes loading {
0%, 100% {
-webkit-box-shadow: 0 -3em 0 0.2em, 2em -2em 0 0em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 0;
box-shadow: 0 -3em 0 0.2em, 2em -2em 0 0em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 0;
}
12.5% {
-webkit-box-shadow: 0 -3em 0 0, 2em -2em 0 0.2em, 3em 0 0 0, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 0, 2em -2em 0 0.2em, 3em 0 0 0, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 -1em;
}
25% {
-webkit-box-shadow: 0 -3em 0 -0.5em, 2em -2em 0 0, 3em 0 0 0.2em, 2em 2em 0 0, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 -0.5em, 2em -2em 0 0, 3em 0 0 0.2em, 2em 2em 0 0, 0 3em 0 -1em, -2em 2em 0 -1em, -3em 0 0 -1em, -2em -2em 0 -1em;
}
37.5% {
-webkit-box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0em 0 0, 2em 2em 0 0.2em, 0 3em 0 0em, -2em 2em 0 -1em, -3em 0em 0 -1em, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0em 0 0, 2em 2em 0 0.2em, 0 3em 0 0em, -2em 2em 0 -1em, -3em 0em 0 -1em, -2em -2em 0 -1em;
}
50% {
-webkit-box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 0em, 0 3em 0 0.2em, -2em 2em 0 0, -3em 0em 0 -1em, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 0em, 0 3em 0 0.2em, -2em 2em 0 0, -3em 0em 0 -1em, -2em -2em 0 -1em;
}
62.5% {
-webkit-box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 0, -2em 2em 0 0.2em, -3em 0 0 0, -2em -2em 0 -1em;
box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 0, -2em 2em 0 0.2em, -3em 0 0 0, -2em -2em 0 -1em;
}
75% {
-webkit-box-shadow: 0em -3em 0 -1em, 2em -2em 0 -1em, 3em 0em 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 0, -3em 0em 0 0.2em, -2em -2em 0 0;
box-shadow: 0em -3em 0 -1em, 2em -2em 0 -1em, 3em 0em 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 0, -3em 0em 0 0.2em, -2em -2em 0 0;
}
87.5% {
-webkit-box-shadow: 0em -3em 0 0, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 0, -3em 0em 0 0, -2em -2em 0 0.2em;
box-shadow: 0em -3em 0 0, 2em -2em 0 -1em, 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, -2em 2em 0 0, -3em 0em 0 0, -2em -2em 0 0.2em;
}
}
.u-dialog {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1051;
background-color: rgba(0, 0, 0, 0.8);
}
.u-dialog .u-dialog-box {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 6.667rem;
background-color: #fff;
border-radius: 0.32rem;
}
.u-dialog .u-dialog-box .u-dialog-content {
padding: 0.4rem;
text-align: center;
position: relative;
}
.u-dialog .u-dialog-box .u-dialog-content:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 1px;
background: #bbb;
}
.u-dialog .u-dialog-box .u-dialog-button {
display: table;
width: 100%;
table-layout: fixed;
border-collapse: separate;
}
.u-dialog .u-dialog-box .u-dialog-button .u-dialog-cancel,
.u-dialog .u-dialog-box .u-dialog-button .u-dialog-confirm {
display: table-cell;
color: #007aff;
text-align: center;
padding: 0.4rem 0;
line-height: 1;
position: relative;
}
.u-dialog .u-dialog-box .u-dialog-button .u-dialog-cancel:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 1px;
-webkit-transform: scaleX(0.5);
transform: scaleX(0.5);
background-color: #bbb;
}
.fade-enter-active,
.fade-leave-active {
-webkit-transition: opacity 0.5s linear;
transition: opacity 0.5s linear;
}
.fade-enter,
.fade-leave-active {
opacity: 0;
}
.custom-dialog {
background-color: rgba(36, 38, 53, 0.9);
}
.custom-dialog .u-dialog-box {
width: 9.467rem;
border-radius: 0.133rem;
background-color: transparent;
border: 1px solid;
color: #00ffff;
padding-bottom: 0.933rem;
}
.custom-dialog .u-dialog-box .u-dialog-content {
width: 100%;
height: 3.733rem;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
font-size: 0.48rem;
line-height: 0.587rem;
padding: 0 0.4rem;
}
.custom-dialog .u-dialog-box .u-dialog-content span {
margin-right: 0.32rem;
}
.custom-dialog .u-dialog-box .u-dialog-content:after {
display: none;
}
.custom-dialog .u-dialog-box .u-dialog-button {
display: block;
text-align: center;
}
.custom-dialog .u-dialog-box .u-dialog-button .u-dialog-cancel,
.custom-dialog .u-dialog-box .u-dialog-button .u-dialog-confirm {
width: 3.6rem;
border-radius: 0.133rem;
background-color: transparent;
border: 1px solid;
color: #00ffff;
font-size: 0.427rem;
padding: 0.267rem 0;
display: inline-block;
}
.custom-dialog .u-dialog-box .u-dialog-button .u-dialog-cancel:active,
.custom-dialog .u-dialog-box .u-dialog-button .u-dialog-confirm:active {
background-color: #153D4C;
}
.custom-dialog .u-dialog-box .u-dialog-button .u-dialog-cancel.disabled,
.custom-dialog .u-dialog-box .u-dialog-button .u-dialog-confirm.disabled {
background-color: transparent;
color: #999;
}
.custom-dialog .u-dialog-box .u-dialog-button .u-dialog-cancel:after {
display: none;
}
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 1.173rem;
z-index: 1030;
background-color: #010d19;
}
.header p {
position: absolute;
top: 0;
left: 1.467rem;
right: 1.467rem;
line-height: 1.173rem;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: #fff;
font-size: 0.507rem;
text-align: center;
}
.header span {
color: #fff;
width: 1.467rem;
line-height: 1.173rem;
display: block;
}
.header span:active {
opacity: 0.5;
}
.header .header-left {
float: left;
padding-left: 0.133rem;
}
.header .header-right {
float: right;
padding-right: 0.133rem;
text-align: right;
}
.header .icon {
font-family: iconfont;
font-size: 0.667rem;
-webkit-font-smoothing: antialiased;
line-height: 1.173rem;
}
.header ~ .content {
padding-top: 1.173rem;
}
.user-list {
width: 100%;
height: 100%;
overflow: auto;
position: absolute;
top: 1.173rem;
bottom: 0;
left: 0;
height: auto;
}
.user-list-scroll .user-list-row {
position: relative;
overflow: hidden;
}
.user-list-scroll .user-list-row .user-list-handle {
position: relative;
-webkit-transition: left 0.4s ease;
transition: left 0.4s ease;
left: 0;
background-color: #242635;
padding: 0.4rem 0.533rem;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
z-index: 2;
}
.user-list-scroll .user-list-row .user-list-handle .user-list-image {
width: 1.333rem;
height: 1.333rem;
margin-right: 0.267rem;
}
.user-list-scroll .user-list-row .user-list-handle .user-list-icon {
margin-right: 0.267rem;
font-family: iconfont;
font-size: 0.533rem;
-webkit-font-smoothing: antialiased;
line-height: 1;
}
.user-list-scroll .user-list-row .user-list-handle div {
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
min-width: 0;
}
.user-list-scroll .user-list-row .user-list-handle .user-list-title {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.user-list-scroll .user-list-row .user-list-handle .user-sub-image {
width: 0.453rem;
height: 0.453rem;
}
.user-list-scroll .user-list-row .user-list-handle .user-list-subtitle {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: inline-block;
}
.user-list-scroll .user-list-row .user-list-handle.user-list-selected {
left: -3.2rem;
}
.user-list-scroll .user-list-row .user-list-handle:after {
content: "\e611";
display: block;
font-family: iconfont;
font-size: 0.533rem;
-webkit-font-smoothing: antialiased;
line-height: 1;
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.user-list-scroll .user-list-row .user-list-button {
position: absolute;
top: 0;
bottom: 0;
right: 0;
z-index: 1;
}
.user-list-scroll .user-list-row .user-list-button div {
width: 1.6rem;
height: 100%;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
color: #fff;
float: left;
}
.user-list-scroll .user-list-row .user-list-button div:nth-last-of-type(1) {
background-color: transparent;
font-family: iconfont;
font-size: 0.533rem;
-webkit-font-smoothing: antialiased;
line-height: 1;
color: #00FFFF;
}
.user-list-scroll .user-list-row:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 1px;
background: #bbb;
z-index: 2;
background: -webkit-linear-gradient(left, #242635, #fff, #242635);
background: linear-gradient(to right, #242635, #fff, #242635);
}
\ No newline at end of file
webpackJsonp([10],{
/***/ 135:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(137);
/***/ }),
/***/ 137:
/***/ (function(module, exports, __webpack_require__) {
// This method of obtaining a reference to the global object needs to be
// kept identical to the way it is obtained in runtime.js
var g = (function() { return this })() || Function("return this")();
// Use `getOwnPropertyNames` because not all browsers support calling
// `hasOwnProperty` on the global `self` object in a worker. See #183.
var hadRuntime = g.regeneratorRuntime &&
Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
// Save the old regeneratorRuntime in case it needs to be restored later.
var oldRuntime = hadRuntime && g.regeneratorRuntime;
// Force reevalutation of runtime.js.
g.regeneratorRuntime = undefined;
module.exports = __webpack_require__(138);
if (hadRuntime) {
// Restore the original runtime.
g.regeneratorRuntime = oldRuntime;
} else {
// Remove the global property added by runtime.js.
try {
delete g.regeneratorRuntime;
} catch(e) {
g.regeneratorRuntime = undefined;
}
}
/***/ }),
/***/ 138:
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(Promise) {/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* https://raw.github.com/facebook/regenerator/master/LICENSE file. An
* additional grant of patent rights can be found in the PATENTS file in
* the same directory.
*/
!(function(global) {
"use strict";
var Op = Object.prototype;
var hasOwn = Op.hasOwnProperty;
var undefined; // More compressible than void 0.
var $Symbol = typeof Symbol === "function" ? Symbol : {};
var iteratorSymbol = $Symbol.iterator || "@@iterator";
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
var inModule = typeof module === "object";
var runtime = global.regeneratorRuntime;
if (runtime) {
if (inModule) {
// If regeneratorRuntime is defined globally and we're in a module,
// make the exports object identical to regeneratorRuntime.
module.exports = runtime;
}
// Don't bother evaluating the rest of this file if the runtime was
// already defined globally.
return;
}
// Define the runtime globally (as expected by generated code) as either
// module.exports (if we're in a module) or a new, empty object.
runtime = global.regeneratorRuntime = inModule ? module.exports : {};
function wrap(innerFn, outerFn, self, tryLocsList) {
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
var generator = Object.create(protoGenerator.prototype);
var context = new Context(tryLocsList || []);
// The ._invoke method unifies the implementations of the .next,
// .throw, and .return methods.
generator._invoke = makeInvokeMethod(innerFn, self, context);
return generator;
}
runtime.wrap = wrap;
// Try/catch helper to minimize deoptimizations. Returns a completion
// record like context.tryEntries[i].completion. This interface could
// have been (and was previously) designed to take a closure to be
// invoked without arguments, but in all the cases we care about we
// already have an existing method we want to call, so there's no need
// to create a new function object. We can even get away with assuming
// the method takes exactly one argument, since that happens to be true
// in every case, so we don't have to touch the arguments object. The
// only additional allocation required is the completion record, which
// has a stable shape and so hopefully should be cheap to allocate.
function tryCatch(fn, obj, arg) {
try {
return { type: "normal", arg: fn.call(obj, arg) };
} catch (err) {
return { type: "throw", arg: err };
}
}
var GenStateSuspendedStart = "suspendedStart";
var GenStateSuspendedYield = "suspendedYield";
var GenStateExecuting = "executing";
var GenStateCompleted = "completed";
// Returning this object from the innerFn has the same effect as
// breaking out of the dispatch switch statement.
var ContinueSentinel = {};
// Dummy constructor functions that we use as the .constructor and
// .constructor.prototype properties for functions that return Generator
// objects. For full spec compliance, you may wish to configure your
// minifier not to mangle the names of these two functions.
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
var IteratorPrototype = {};
IteratorPrototype[iteratorSymbol] = function () {
return this;
};
var getProto = Object.getPrototypeOf;
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
if (NativeIteratorPrototype &&
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
// This environment has a native %IteratorPrototype%; use it instead
// of the polyfill.
IteratorPrototype = NativeIteratorPrototype;
}
var Gp = GeneratorFunctionPrototype.prototype =
Generator.prototype = Object.create(IteratorPrototype);
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
GeneratorFunctionPrototype.constructor = GeneratorFunction;
GeneratorFunctionPrototype[toStringTagSymbol] =
GeneratorFunction.displayName = "GeneratorFunction";
// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function(method) {
prototype[method] = function(arg) {
return this._invoke(method, arg);
};
});
}
runtime.isGeneratorFunction = function(genFun) {
var ctor = typeof genFun === "function" && genFun.constructor;
return ctor
? ctor === GeneratorFunction ||
// For the native GeneratorFunction constructor, the best we can
// do is to check its .name property.
(ctor.displayName || ctor.name) === "GeneratorFunction"
: false;
};
runtime.mark = function(genFun) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
} else {
genFun.__proto__ = GeneratorFunctionPrototype;
if (!(toStringTagSymbol in genFun)) {
genFun[toStringTagSymbol] = "GeneratorFunction";
}
}
genFun.prototype = Object.create(Gp);
return genFun;
};
// Within the body of any async function, `await x` is transformed to
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
// `hasOwn.call(value, "__await")` to determine if the yielded value is
// meant to be awaited.
runtime.awrap = function(arg) {
return { __await: arg };
};
function AsyncIterator(generator) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if (record.type === "throw") {
reject(record.arg);
} else {
var result = record.arg;
var value = result.value;
if (value &&
typeof value === "object" &&
hasOwn.call(value, "__await")) {
return Promise.resolve(value.__await).then(function(value) {
invoke("next", value, resolve, reject);
}, function(err) {
invoke("throw", err, resolve, reject);
});
}
return Promise.resolve(value).then(function(unwrapped) {
// When a yielded Promise is resolved, its final value becomes
// the .value of the Promise<{value,done}> result for the
// current iteration. If the Promise is rejected, however, the
// result for this iteration will be rejected with the same
// reason. Note that rejections of yielded Promises are not
// thrown back into the generator function, as is the case
// when an awaited Promise is rejected. This difference in
// behavior between yield and await is important, because it
// allows the consumer to decide what to do with the yielded
// rejection (swallow it and continue, manually .throw it back
// into the generator, abandon iteration, whatever). With
// await, by contrast, there is no opportunity to examine the
// rejection reason outside the generator function, so the
// only option is to throw it from the await expression, and
// let the generator function handle the exception.
result.value = unwrapped;
resolve(result);
}, reject);
}
}
var previousPromise;
function enqueue(method, arg) {
function callInvokeWithMethodAndArg() {
return new Promise(function(resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise =
// If enqueue has been called before, then we want to wait until
// all previous Promises have been resolved before calling invoke,
// so that results are always delivered in the correct order. If
// enqueue has not been called before, then it is important to
// call invoke immediately, without waiting on a callback to fire,
// so that the async generator function has the opportunity to do
// any necessary setup in a predictable way. This predictability
// is why the Promise constructor synchronously invokes its
// executor callback, and why async functions synchronously
// execute code before the first await. Since we implement simple
// async functions in terms of async generators, it is especially
// important to get this right, even though it requires care.
previousPromise ? previousPromise.then(
callInvokeWithMethodAndArg,
// Avoid propagating failures to Promises returned by later
// invocations of the iterator.
callInvokeWithMethodAndArg
) : callInvokeWithMethodAndArg();
}
// Define the unified helper method that is used to implement .next,
// .throw, and .return (see defineIteratorMethods).
this._invoke = enqueue;
}
defineIteratorMethods(AsyncIterator.prototype);
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
return this;
};
runtime.AsyncIterator = AsyncIterator;
// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
runtime.async = function(innerFn, outerFn, self, tryLocsList) {
var iter = new AsyncIterator(
wrap(innerFn, outerFn, self, tryLocsList)
);
return runtime.isGeneratorFunction(outerFn)
? iter // If outerFn is a generator, return the full iterator.
: iter.next().then(function(result) {
return result.done ? result.value : iter.next();
});
};
function makeInvokeMethod(innerFn, self, context) {
var state = GenStateSuspendedStart;
return function invoke(method, arg) {
if (state === GenStateExecuting) {
throw new Error("Generator is already running");
}
if (state === GenStateCompleted) {
if (method === "throw") {
throw arg;
}
// Be forgiving, per 25.3.3.3.3 of the spec:
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
return doneResult();
}
context.method = method;
context.arg = arg;
while (true) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if (context.method === "next") {
// Setting context._sent for legacy support of Babel's
// function.sent implementation.
context.sent = context._sent = context.arg;
} else if (context.method === "throw") {
if (state === GenStateSuspendedStart) {
state = GenStateCompleted;
throw context.arg;
}
context.dispatchException(context.arg);
} else if (context.method === "return") {
context.abrupt("return", context.arg);
}
state = GenStateExecuting;
var record = tryCatch(innerFn, self, context);
if (record.type === "normal") {
// If an exception is thrown from innerFn, we leave state ===
// GenStateExecuting and loop back for another invocation.
state = context.done
? GenStateCompleted
: GenStateSuspendedYield;
if (record.arg === ContinueSentinel) {
continue;
}
return {
value: record.arg,
done: context.done
};
} else if (record.type === "throw") {
state = GenStateCompleted;
// Dispatch the exception by looping back around to the
// context.dispatchException(context.arg) call above.
context.method = "throw";
context.arg = record.arg;
}
}
};
}
// Call delegate.iterator[context.method](context.arg) and handle the
// result, either by returning a { value, done } result from the
// delegate iterator, or by modifying context.method and context.arg,
// setting context.delegate to null, and returning the ContinueSentinel.
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (method === undefined) {
// A .throw or .return when the delegate iterator has no .throw
// method always terminates the yield* loop.
context.delegate = null;
if (context.method === "throw") {
if (delegate.iterator.return) {
// If the delegate iterator has a return method, give it a
// chance to clean up.
context.method = "return";
context.arg = undefined;
maybeInvokeDelegate(delegate, context);
if (context.method === "throw") {
// If maybeInvokeDelegate(context) changed context.method from
// "return" to "throw", let that override the TypeError below.
return ContinueSentinel;
}
}
context.method = "throw";
context.arg = new TypeError(
"The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
}
var record = tryCatch(method, delegate.iterator, context.arg);
if (record.type === "throw") {
context.method = "throw";
context.arg = record.arg;
context.delegate = null;
return ContinueSentinel;
}
var info = record.arg;
if (! info) {
context.method = "throw";
context.arg = new TypeError("iterator result is not an object");
context.delegate = null;
return ContinueSentinel;
}
if (info.done) {
// Assign the result of the finished delegate to the temporary
// variable specified by delegate.resultName (see delegateYield).
context[delegate.resultName] = info.value;
// Resume execution at the desired location (see delegateYield).
context.next = delegate.nextLoc;
// If context.method was "throw" but the delegate handled the
// exception, let the outer generator proceed normally. If
// context.method was "next", forget context.arg since it has been
// "consumed" by the delegate iterator. If context.method was
// "return", allow the original .return call to continue in the
// outer generator.
if (context.method !== "return") {
context.method = "next";
context.arg = undefined;
}
} else {
// Re-yield the result returned by the delegate method.
return info;
}
// The delegate iterator is finished, so forget it and continue with
// the outer generator.
context.delegate = null;
return ContinueSentinel;
}
// Define Generator.prototype.{next,throw,return} in terms of the
// unified ._invoke helper method.
defineIteratorMethods(Gp);
Gp[toStringTagSymbol] = "Generator";
// A Generator should always return itself as the iterator object when the
// @@iterator function is called on it. Some browsers' implementations of the
// iterator prototype chain incorrectly implement this, causing the Generator
// object to not be returned from this call. This ensures that doesn't happen.
// See https://github.com/facebook/regenerator/issues/274 for more details.
Gp[iteratorSymbol] = function() {
return this;
};
Gp.toString = function() {
return "[object Generator]";
};
function pushTryEntry(locs) {
var entry = { tryLoc: locs[0] };
if (1 in locs) {
entry.catchLoc = locs[1];
}
if (2 in locs) {
entry.finallyLoc = locs[2];
entry.afterLoc = locs[3];
}
this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal";
delete record.arg;
entry.completion = record;
}
function Context(tryLocsList) {
// The root entry object (effectively a try statement without a catch
// or a finally block) gives us a place to store values thrown from
// locations where there is no enclosing try statement.
this.tryEntries = [{ tryLoc: "root" }];
tryLocsList.forEach(pushTryEntry, this);
this.reset(true);
}
runtime.keys = function(object) {
var keys = [];
for (var key in object) {
keys.push(key);
}
keys.reverse();
// Rather than returning an object with a next method, we keep
// things simple and return the next function itself.
return function next() {
while (keys.length) {
var key = keys.pop();
if (key in object) {
next.value = key;
next.done = false;
return next;
}
}
// To avoid creating an additional object, we just hang the .value
// and .done properties off the next function object itself. This
// also ensures that the minifier will not anonymize the function.
next.done = true;
return next;
};
};
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) {
return iteratorMethod.call(iterable);
}
if (typeof iterable.next === "function") {
return iterable;
}
if (!isNaN(iterable.length)) {
var i = -1, next = function next() {
while (++i < iterable.length) {
if (hasOwn.call(iterable, i)) {
next.value = iterable[i];
next.done = false;
return next;
}
}
next.value = undefined;
next.done = true;
return next;
};
return next.next = next;
}
}
// Return an iterator with no values.
return { next: doneResult };
}
runtime.values = values;
function doneResult() {
return { value: undefined, done: true };
}
Context.prototype = {
constructor: Context,
reset: function(skipTempReset) {
this.prev = 0;
this.next = 0;
// Resetting context._sent for legacy support of Babel's
// function.sent implementation.
this.sent = this._sent = undefined;
this.done = false;
this.delegate = null;
this.method = "next";
this.arg = undefined;
this.tryEntries.forEach(resetTryEntry);
if (!skipTempReset) {
for (var name in this) {
// Not sure about the optimal order of these conditions:
if (name.charAt(0) === "t" &&
hasOwn.call(this, name) &&
!isNaN(+name.slice(1))) {
this[name] = undefined;
}
}
}
},
stop: function() {
this.done = true;
var rootEntry = this.tryEntries[0];
var rootRecord = rootEntry.completion;
if (rootRecord.type === "throw") {
throw rootRecord.arg;
}
return this.rval;
},
dispatchException: function(exception) {
if (this.done) {
throw exception;
}
var context = this;
function handle(loc, caught) {
record.type = "throw";
record.arg = exception;
context.next = loc;
if (caught) {
// If the dispatched exception was caught by a catch block,
// then let that catch block handle the exception normally.
context.method = "next";
context.arg = undefined;
}
return !! caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
var record = entry.completion;
if (entry.tryLoc === "root") {
// Exception thrown outside of any try block that could handle
// it, so set the completion value of the entire function to
// throw the exception.
return handle("end");
}
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc");
var hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
} else if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else if (hasCatch) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
}
} else if (hasFinally) {
if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else {
throw new Error("try statement without catch or finally");
}
}
}
},
abrupt: function(type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev &&
hasOwn.call(entry, "finallyLoc") &&
this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
if (finallyEntry &&
(type === "break" ||
type === "continue") &&
finallyEntry.tryLoc <= arg &&
arg <= finallyEntry.finallyLoc) {
// Ignore the finally entry if control is not jumping to a
// location outside the try/catch block.
finallyEntry = null;
}
var record = finallyEntry ? finallyEntry.completion : {};
record.type = type;
record.arg = arg;
if (finallyEntry) {
this.method = "next";
this.next = finallyEntry.finallyLoc;
return ContinueSentinel;
}
return this.complete(record);
},
complete: function(record, afterLoc) {
if (record.type === "throw") {
throw record.arg;
}
if (record.type === "break" ||
record.type === "continue") {
this.next = record.arg;
} else if (record.type === "return") {
this.rval = this.arg = record.arg;
this.method = "return";
this.next = "end";
} else if (record.type === "normal" && afterLoc) {
this.next = afterLoc;
}
return ContinueSentinel;
},
finish: function(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) {
this.complete(entry.completion, entry.afterLoc);
resetTryEntry(entry);
return ContinueSentinel;
}
}
},
"catch": function(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if (record.type === "throw") {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
// The context.catch method must only be called with a location
// argument that corresponds to a known catch block.
throw new Error("illegal catch attempt");
},
delegateYield: function(iterable, resultName, nextLoc) {
this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
};
if (this.method === "next") {
// Deliberately forget the last sent value so that we don't
// accidentally pass it on to the delegate.
this.arg = undefined;
}
return ContinueSentinel;
}
};
})(
// In sloppy mode, unbound `this` refers to the global object, fallback to
// Function constructor if we're in global strict mode. That is sadly a form
// of indirect eval which violates Content Security Policy.
(function() { return this })() || Function("return this")()
);
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(128)))
/***/ }),
/***/ 212:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue, Promise) {
var _regenerator = __webpack_require__(135);
var _regenerator2 = _interopRequireDefault(_regenerator);
var _public = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_public.iot.ready(init); /**
* v_doorlockUsers.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 门锁用户页面
*/
function init() {
//通用 按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading']);
_public.uPublic.closeSlideBack();
var 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
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
this.role = this.extras.role;
var self = this;
window.addEventListener('returnPage', function (event) {
console.log("returnPage");
getUserInfo(self);
});
getUserInfo(this);
checkFirstAddUser(this);
},
methods: {
getBindShowFlag: function getBindShowFlag() {
return this.bindShowFlag;
},
setBindShowFlag: function setBindShowFlag(boolean) {
this.bindShowFlag = boolean;
},
getUnbindShowFlag: function getUnbindShowFlag() {
return this.unbindShowFlag;
},
setUnbindShowFlag: function setUnbindShowFlag(boolean) {
this.unbindShowFlag = boolean;
},
getStateShowFlag: function getStateShowFlag() {
return this.stateShowFlag;
},
setStateShowFlag: function setStateShowFlag(boolean) {
this.stateShowFlag = boolean;
},
getGuideShowFlag: function getGuideShowFlag() {
return this.guideShowFlag;
},
setGuideShowFlag: function setGuideShowFlag(boolean) {
this.guideShowFlag = boolean;
},
getGuideStep1ShowFlag: function getGuideStep1ShowFlag() {
return this.guideStep1ShowFlag;
},
setGuideStep1ShowFlag: function setGuideStep1ShowFlag(boolean) {
this.guideStep1ShowFlag = boolean;
},
getGuideStep2ShowFlag: function getGuideStep2ShowFlag() {
return this.guideStep2ShowFlag;
},
setGuideStep2ShowFlag: function setGuideStep2ShowFlag(boolean) {
this.guideStep2ShowFlag = boolean;
},
getGuideStep3ShowFlag: function getGuideStep3ShowFlag() {
return this.guideStep3ShowFlag;
},
setGuideStep3ShowFlag: function setGuideStep3ShowFlag(boolean) {
this.guideStep3ShowFlag = boolean;
},
getGuideStep4ShowFlag: function getGuideStep4ShowFlag() {
return this.guideStep4ShowFlag;
},
setGuideStep4ShowFlag: function setGuideStep4ShowFlag(boolean) {
this.guideStep4ShowFlag = boolean;
},
setImageSrc: function setImageSrc(src) {
this.imageSrc = src;
},
setTextBindTip: function setTextBindTip(tip) {
this.textBindTip = tip;
},
getInfo: function getInfo() {
return this.info;
},
setInfo: function setInfo(object) {
this.info = object;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
onEditNameTap: function onEditNameTap() {
editNameTap(this);
},
//tap 邀请绑定
onBindTap: function onBindTap() {
bindTap(this);
},
//tap 解绑
onUnbindButtonTap: function onUnbindButtonTap() {
unbindButtonTap(this);
},
//tap 绑定开锁信息
onBindUnlockInfoTap: function onBindUnlockInfoTap() {
bindUnlockInfoTap(this);
},
//tap 历史开门记录
onOpendoorRecordTap: function onOpendoorRecordTap() {
opendoorRecordTap(this);
},
//tap 删除该用户
onDeleteUserButtonTap: function onDeleteUserButtonTap() {
deleteUserButtonTap(this);
},
onUnbindStateDialogTap: function onUnbindStateDialogTap() {
unbindStateDialogTap(this);
},
//tap 下一步
onNextButtonTap: function onNextButtonTap() {
nextButtonTap(this);
},
//tap 我知道了
onISeeButtonTap: function onISeeButtonTap() {
iSeeButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
//解绑 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) {
_public.iot.storage.getMap('isFirstAddUser', function (res) {
if (res) {} else {
//显示引导动画
showGuide(self);
}
}, function () {
//显示 引导动画
showGuide(self);
});
}
//显示动画
function showGuide(self) {
var time;
return _regenerator2.default.async(function showGuide$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
self.setGuideShowFlag(true);
_context.prev = 1;
_context.next = 4;
return _regenerator2.default.awrap(sleep(1000));
case 4:
time = _context.sent;
self.setGuideStep1ShowFlag(true);
_context.next = 8;
return _regenerator2.default.awrap(sleep(1000));
case 8:
time = _context.sent;
self.setGuideStep2ShowFlag(true);
// time = await sleep(1000);
// self.setGuideStep3ShowFlag(true),
//
// time = await sleep(1000);
// self.setGuideStep4ShowFlag(true);
_context.next = 15;
break;
case 12:
_context.prev = 12;
_context.t0 = _context['catch'](1);
console.log(_context.t0);
case 15:
case 'end':
return _context.stop();
}
}
}, null, this, [[1, 12]]);
}
function nextGuide(self) {
var time;
return _regenerator2.default.async(function nextGuide$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
_context2.next = 3;
return _regenerator2.default.awrap(sleep(1000));
case 3:
time = _context2.sent;
self.setGuideStep3ShowFlag(true);
_context2.next = 7;
return _regenerator2.default.awrap(sleep(1000));
case 7:
time = _context2.sent;
self.setGuideStep4ShowFlag(true);
_context2.next = 14;
break;
case 11:
_context2.prev = 11;
_context2.t0 = _context2['catch'](0);
console.log(_context2.t0);
case 14:
case 'end':
return _context2.stop();
}
}
}, null, this, [[0, 11]]);
}
function sleep(time) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve(time);
}, time);
});
}
function getUserInfo(self) {
_public.uComponents.showLoading(self);
_public.iot.business.api.sendCustom('lock/getUserInfo', {
data: {
rel_id: self.extras.id,
device_id: self.extras.lockId
},
success: function success(response) {
var data = _public.uPublic.checkResponseData(response.data);
console.log(data);
if (data) {
self.setInfo(data);
setUserInfo(self, data);
} else {}
},
error: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 获取用户信息'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取用户信息');
// }
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
//设置用户信息
function setUserInfo(self, data) {
self.userInfo = {
image: data.role == 0 ? '../../resources/image/green_admin_icon.png' : data.user_id == null ? '../../resources/image/gray_unbindHead_icon.png' : '../../resources/image/green_bindHead_icon.png',
role: data.role,
title: data.nickname,
subtitle: ''
};
self.setBindShowFlag(data.user_id ? false : true);
self.setUnbindShowFlag(data.user_id ? true : false);
}
_public.iot.navigator.aback = function () {
var opener = plus.webview.currentWebview().opener();
if (opener.id == 'addUser') {
opener.close();
_public.iot.navigator.fire(plus.webview.getWebviewById('doorlockUsers'), 'returnPage', {});
_public.iot.navigator.back();
} else {
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
console.log('returnPage');
_public.iot.navigator.back();
}
};
//tap <
function backTap() {
_public.iot.navigator.aback();
}
//修改用户名称
function editNameTap(self) {
if (!self.role) {
_public.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 bindTap(self) {
_public.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) {
_public.uComponents.openConfirm(self, Vue.t('doorlockUser.unbindDialogTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.unbind'), callback: function callback() {
// alert(self.extras.account);
// iot.business.sds.unbindByManager({
// data: {
// uuid: self.extras.uuid,
// destAuid: self.extras.account
// },
// success: (response) => {
//// alert(JSON.stringify(response));
_public.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: function success(response) {
console.log(response);
// alert(JSON.stringify(response));
self.setStateShowFlag(true);
getUserInfo(self);
},
error: function error(_error2) {
console.log(_error2);
// if(window.iotDebug){
// iotDebug.push('end: 解绑失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'解绑失败');
// }
_public.uPublic.openRequestErrorAlert(self);
self.setImageSrc('../../resources/image/green_unbindFail_icon.png');
self.setTextBindTip(Vue.t('doorlockUser.unbindFailue'));
self.setStateShowFlag(true);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
// },
// error: (error) => {
// console.log(error);
// alert(error);
//// if(window.iotDebug){
//// iotDebug.push('end: sds解绑普通用户失败'+JSON.stringify(error));
//// }
//// if (window.iotDebug) {
//// iotDebug.upload(iot,'sds解绑普通用户失败');
//// }
// uPublic.openRequestErrorAlert(self);
// self.setImageSrc('../../resources/image/green_unbindFail_icon.png');
// self.setTextBindTip(Vue.t('doorlockUser.unbindFailue'));
// self.setStateShowFlag(true);
// },
// 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) {
_public.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) {
_public.iot.navigator.openWindow({
url: '../device/opendoorRecord.html',
id: 'opendoorRecord',
extras: {
relId: self.extras.id,
deviceId: self.getInfo().device_id
}
});
}
//tap 删除该用户
function deleteUserButtonTap(self) {
_public.uComponents.openConfirm(self, Vue.t('doorlockUser.deleteUserDialogTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.delete'), callback: function callback() {
deleteUser(self);
} });
}
//tap 下一步
function nextButtonTap(self) {
self.setGuideStep1ShowFlag(false);
self.setGuideStep2ShowFlag(false);
nextGuide(self);
}
//tap 我知道了
function iSeeButtonTap(self) {
self.setGuideShowFlag(false);
_public.iot.storage.setMap('isFirstAddUser', true, function () {}, function (err) {});
}
//删除用户
function deleteUser(self) {
_public.uComponents.showLoading(self);
// iot.business.sds.unbindByManager({
// data: {
// uuid: self.extras.uuid,
// destAuid: self.extras.account
// },
// success: (response) => {
//// alert(JSON.stringify(response));
_public.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: function success(response) {
console.log(response);
if (response.data.success) {
_public.uComponents.openAlert(self, Vue.t('doorlockUser.deleteSuccess'), {
text: Vue.t('btn.confirm'), callback: function callback() {
_public.iot.navigator.aback();
}
});
}
},
error: function error(_error3) {
console.log(_error3);
// if(window.iotDebug){
// iotDebug.push('end: 删除用户失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'删除用户失败');
// }
_public.uComponents.openAlert(self, Vue.t('doorlockUser.deleteFailure'), {
text: Vue.t('btn.confirm'), callback: function callback() {}
});
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
// },
// error: (error) => {
// console.log(error);
// alert(error);
//// if(window.iotDebug){
//// iotDebug.push('end: sds解绑普通用户失败'+JSON.stringify(error));
//// }
//// if (window.iotDebug) {
//// iotDebug.upload(iot,'sds解绑普通用户失败');
//// }
// uPublic.openRequestErrorAlert(self);
// self.setImageSrc('../../resources/image/green_unbindFail_icon.png');
// self.setTextBindTip(Vue.t('doorlockUser.unbindFailue'));
// self.setStateShowFlag(true);
// },
// complete: () => {
// }
// });
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"], __webpack_require__(128)))
/***/ }),
/***/ 313:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(212);
/***/ })
},[313]);
//# sourceMappingURL=doorlockUser.js.map
\ No newline at end of file
webpackJsonp([20],{
/***/ 213:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _config = __webpack_require__(9);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* v_editName.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 修改名称页面
*/
_public.iot.ready(init);
function init() {
//通用 input、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-dialog', 'u-loading']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
textName: _public.iot.navigator.getExtras().nickname,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig(),
extras: {},
role: null
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
this.role = this.extras.role;
},
methods: {
getTextName: function getTextName() {
return this.textName;
},
setTextName: function setTextName(text) {
this.textName = text;
},
getTextErrorTip: function getTextErrorTip() {
return this.textErrorTip;
},
setTextErrorTip: function setTextErrorTip(tip) {
this.textErrorTip = tip;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 保存
onSaveTap: function onSaveTap() {
saveTap(this);
},
onNameChange: function onNameChange(text) {
nameChange(this, text);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
nameInput: {
initParam: {
class: 'custom-editName-text',
placeholder: Vue.t('editName.nickNameInputTip'),
maxlength: _config2.default.input.maxlength
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
_public.iot.navigator.aback = function () {
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
_public.iot.navigator.back();
};
//tap <
function backTap() {
_public.iot.navigator.aback();
}
//tap 保存
function saveTap(self) {
if (self.getTextName() == null || self.getTextName().trim() == '') {
self.setTextErrorTip(Vue.t('editName.error.nicknameCanNotBeBlank'));
} else {
_public.uComponents.showLoading(self);
_public.iot.business.api.sendCustom('lock/setLockUserName', {
data: {
rel_id: self.extras.id,
nickname: self.getTextName(),
device_id: self.extras.deviceId
},
success: function success(response) {
console.log(response);
if (response.data.success) {
_public.uComponents.openAlert(self, Vue.t('editName.editNameSuccess'), {
text: Vue.t('btn.confirm'), callback: function callback() {
var opener = plus.webview.currentWebview().opener();
var view = plus.webview.getWebviewById(opener.id);
console.log(view);
_public.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: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 修改用户名称失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'修改用户名称失败');
// }
_public.uComponents.openAlert(self, Vue.t('editName.editNameFailue'), {
text: Vue.t('btn.confirm'), callback: function callback() {
var opener = plus.webview.currentWebview().opener();
_public.iot.navigator.back();
}
});
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
}
function nameChange(self, text) {
self.textName = text;
self.setTextErrorTip(null);
console.log('nameChange: ' + self.textName);
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 314:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(213);
/***/ })
},[314]);
//# sourceMappingURL=editName.js.map
\ No newline at end of file
webpackJsonp([9],{
/***/ 135:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(137);
/***/ }),
/***/ 137:
/***/ (function(module, exports, __webpack_require__) {
// This method of obtaining a reference to the global object needs to be
// kept identical to the way it is obtained in runtime.js
var g = (function() { return this })() || Function("return this")();
// Use `getOwnPropertyNames` because not all browsers support calling
// `hasOwnProperty` on the global `self` object in a worker. See #183.
var hadRuntime = g.regeneratorRuntime &&
Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
// Save the old regeneratorRuntime in case it needs to be restored later.
var oldRuntime = hadRuntime && g.regeneratorRuntime;
// Force reevalutation of runtime.js.
g.regeneratorRuntime = undefined;
module.exports = __webpack_require__(138);
if (hadRuntime) {
// Restore the original runtime.
g.regeneratorRuntime = oldRuntime;
} else {
// Remove the global property added by runtime.js.
try {
delete g.regeneratorRuntime;
} catch(e) {
g.regeneratorRuntime = undefined;
}
}
/***/ }),
/***/ 138:
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(Promise) {/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* https://raw.github.com/facebook/regenerator/master/LICENSE file. An
* additional grant of patent rights can be found in the PATENTS file in
* the same directory.
*/
!(function(global) {
"use strict";
var Op = Object.prototype;
var hasOwn = Op.hasOwnProperty;
var undefined; // More compressible than void 0.
var $Symbol = typeof Symbol === "function" ? Symbol : {};
var iteratorSymbol = $Symbol.iterator || "@@iterator";
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
var inModule = typeof module === "object";
var runtime = global.regeneratorRuntime;
if (runtime) {
if (inModule) {
// If regeneratorRuntime is defined globally and we're in a module,
// make the exports object identical to regeneratorRuntime.
module.exports = runtime;
}
// Don't bother evaluating the rest of this file if the runtime was
// already defined globally.
return;
}
// Define the runtime globally (as expected by generated code) as either
// module.exports (if we're in a module) or a new, empty object.
runtime = global.regeneratorRuntime = inModule ? module.exports : {};
function wrap(innerFn, outerFn, self, tryLocsList) {
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
var generator = Object.create(protoGenerator.prototype);
var context = new Context(tryLocsList || []);
// The ._invoke method unifies the implementations of the .next,
// .throw, and .return methods.
generator._invoke = makeInvokeMethod(innerFn, self, context);
return generator;
}
runtime.wrap = wrap;
// Try/catch helper to minimize deoptimizations. Returns a completion
// record like context.tryEntries[i].completion. This interface could
// have been (and was previously) designed to take a closure to be
// invoked without arguments, but in all the cases we care about we
// already have an existing method we want to call, so there's no need
// to create a new function object. We can even get away with assuming
// the method takes exactly one argument, since that happens to be true
// in every case, so we don't have to touch the arguments object. The
// only additional allocation required is the completion record, which
// has a stable shape and so hopefully should be cheap to allocate.
function tryCatch(fn, obj, arg) {
try {
return { type: "normal", arg: fn.call(obj, arg) };
} catch (err) {
return { type: "throw", arg: err };
}
}
var GenStateSuspendedStart = "suspendedStart";
var GenStateSuspendedYield = "suspendedYield";
var GenStateExecuting = "executing";
var GenStateCompleted = "completed";
// Returning this object from the innerFn has the same effect as
// breaking out of the dispatch switch statement.
var ContinueSentinel = {};
// Dummy constructor functions that we use as the .constructor and
// .constructor.prototype properties for functions that return Generator
// objects. For full spec compliance, you may wish to configure your
// minifier not to mangle the names of these two functions.
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
var IteratorPrototype = {};
IteratorPrototype[iteratorSymbol] = function () {
return this;
};
var getProto = Object.getPrototypeOf;
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
if (NativeIteratorPrototype &&
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
// This environment has a native %IteratorPrototype%; use it instead
// of the polyfill.
IteratorPrototype = NativeIteratorPrototype;
}
var Gp = GeneratorFunctionPrototype.prototype =
Generator.prototype = Object.create(IteratorPrototype);
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
GeneratorFunctionPrototype.constructor = GeneratorFunction;
GeneratorFunctionPrototype[toStringTagSymbol] =
GeneratorFunction.displayName = "GeneratorFunction";
// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function(method) {
prototype[method] = function(arg) {
return this._invoke(method, arg);
};
});
}
runtime.isGeneratorFunction = function(genFun) {
var ctor = typeof genFun === "function" && genFun.constructor;
return ctor
? ctor === GeneratorFunction ||
// For the native GeneratorFunction constructor, the best we can
// do is to check its .name property.
(ctor.displayName || ctor.name) === "GeneratorFunction"
: false;
};
runtime.mark = function(genFun) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
} else {
genFun.__proto__ = GeneratorFunctionPrototype;
if (!(toStringTagSymbol in genFun)) {
genFun[toStringTagSymbol] = "GeneratorFunction";
}
}
genFun.prototype = Object.create(Gp);
return genFun;
};
// Within the body of any async function, `await x` is transformed to
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
// `hasOwn.call(value, "__await")` to determine if the yielded value is
// meant to be awaited.
runtime.awrap = function(arg) {
return { __await: arg };
};
function AsyncIterator(generator) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if (record.type === "throw") {
reject(record.arg);
} else {
var result = record.arg;
var value = result.value;
if (value &&
typeof value === "object" &&
hasOwn.call(value, "__await")) {
return Promise.resolve(value.__await).then(function(value) {
invoke("next", value, resolve, reject);
}, function(err) {
invoke("throw", err, resolve, reject);
});
}
return Promise.resolve(value).then(function(unwrapped) {
// When a yielded Promise is resolved, its final value becomes
// the .value of the Promise<{value,done}> result for the
// current iteration. If the Promise is rejected, however, the
// result for this iteration will be rejected with the same
// reason. Note that rejections of yielded Promises are not
// thrown back into the generator function, as is the case
// when an awaited Promise is rejected. This difference in
// behavior between yield and await is important, because it
// allows the consumer to decide what to do with the yielded
// rejection (swallow it and continue, manually .throw it back
// into the generator, abandon iteration, whatever). With
// await, by contrast, there is no opportunity to examine the
// rejection reason outside the generator function, so the
// only option is to throw it from the await expression, and
// let the generator function handle the exception.
result.value = unwrapped;
resolve(result);
}, reject);
}
}
var previousPromise;
function enqueue(method, arg) {
function callInvokeWithMethodAndArg() {
return new Promise(function(resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise =
// If enqueue has been called before, then we want to wait until
// all previous Promises have been resolved before calling invoke,
// so that results are always delivered in the correct order. If
// enqueue has not been called before, then it is important to
// call invoke immediately, without waiting on a callback to fire,
// so that the async generator function has the opportunity to do
// any necessary setup in a predictable way. This predictability
// is why the Promise constructor synchronously invokes its
// executor callback, and why async functions synchronously
// execute code before the first await. Since we implement simple
// async functions in terms of async generators, it is especially
// important to get this right, even though it requires care.
previousPromise ? previousPromise.then(
callInvokeWithMethodAndArg,
// Avoid propagating failures to Promises returned by later
// invocations of the iterator.
callInvokeWithMethodAndArg
) : callInvokeWithMethodAndArg();
}
// Define the unified helper method that is used to implement .next,
// .throw, and .return (see defineIteratorMethods).
this._invoke = enqueue;
}
defineIteratorMethods(AsyncIterator.prototype);
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
return this;
};
runtime.AsyncIterator = AsyncIterator;
// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
runtime.async = function(innerFn, outerFn, self, tryLocsList) {
var iter = new AsyncIterator(
wrap(innerFn, outerFn, self, tryLocsList)
);
return runtime.isGeneratorFunction(outerFn)
? iter // If outerFn is a generator, return the full iterator.
: iter.next().then(function(result) {
return result.done ? result.value : iter.next();
});
};
function makeInvokeMethod(innerFn, self, context) {
var state = GenStateSuspendedStart;
return function invoke(method, arg) {
if (state === GenStateExecuting) {
throw new Error("Generator is already running");
}
if (state === GenStateCompleted) {
if (method === "throw") {
throw arg;
}
// Be forgiving, per 25.3.3.3.3 of the spec:
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
return doneResult();
}
context.method = method;
context.arg = arg;
while (true) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if (context.method === "next") {
// Setting context._sent for legacy support of Babel's
// function.sent implementation.
context.sent = context._sent = context.arg;
} else if (context.method === "throw") {
if (state === GenStateSuspendedStart) {
state = GenStateCompleted;
throw context.arg;
}
context.dispatchException(context.arg);
} else if (context.method === "return") {
context.abrupt("return", context.arg);
}
state = GenStateExecuting;
var record = tryCatch(innerFn, self, context);
if (record.type === "normal") {
// If an exception is thrown from innerFn, we leave state ===
// GenStateExecuting and loop back for another invocation.
state = context.done
? GenStateCompleted
: GenStateSuspendedYield;
if (record.arg === ContinueSentinel) {
continue;
}
return {
value: record.arg,
done: context.done
};
} else if (record.type === "throw") {
state = GenStateCompleted;
// Dispatch the exception by looping back around to the
// context.dispatchException(context.arg) call above.
context.method = "throw";
context.arg = record.arg;
}
}
};
}
// Call delegate.iterator[context.method](context.arg) and handle the
// result, either by returning a { value, done } result from the
// delegate iterator, or by modifying context.method and context.arg,
// setting context.delegate to null, and returning the ContinueSentinel.
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (method === undefined) {
// A .throw or .return when the delegate iterator has no .throw
// method always terminates the yield* loop.
context.delegate = null;
if (context.method === "throw") {
if (delegate.iterator.return) {
// If the delegate iterator has a return method, give it a
// chance to clean up.
context.method = "return";
context.arg = undefined;
maybeInvokeDelegate(delegate, context);
if (context.method === "throw") {
// If maybeInvokeDelegate(context) changed context.method from
// "return" to "throw", let that override the TypeError below.
return ContinueSentinel;
}
}
context.method = "throw";
context.arg = new TypeError(
"The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
}
var record = tryCatch(method, delegate.iterator, context.arg);
if (record.type === "throw") {
context.method = "throw";
context.arg = record.arg;
context.delegate = null;
return ContinueSentinel;
}
var info = record.arg;
if (! info) {
context.method = "throw";
context.arg = new TypeError("iterator result is not an object");
context.delegate = null;
return ContinueSentinel;
}
if (info.done) {
// Assign the result of the finished delegate to the temporary
// variable specified by delegate.resultName (see delegateYield).
context[delegate.resultName] = info.value;
// Resume execution at the desired location (see delegateYield).
context.next = delegate.nextLoc;
// If context.method was "throw" but the delegate handled the
// exception, let the outer generator proceed normally. If
// context.method was "next", forget context.arg since it has been
// "consumed" by the delegate iterator. If context.method was
// "return", allow the original .return call to continue in the
// outer generator.
if (context.method !== "return") {
context.method = "next";
context.arg = undefined;
}
} else {
// Re-yield the result returned by the delegate method.
return info;
}
// The delegate iterator is finished, so forget it and continue with
// the outer generator.
context.delegate = null;
return ContinueSentinel;
}
// Define Generator.prototype.{next,throw,return} in terms of the
// unified ._invoke helper method.
defineIteratorMethods(Gp);
Gp[toStringTagSymbol] = "Generator";
// A Generator should always return itself as the iterator object when the
// @@iterator function is called on it. Some browsers' implementations of the
// iterator prototype chain incorrectly implement this, causing the Generator
// object to not be returned from this call. This ensures that doesn't happen.
// See https://github.com/facebook/regenerator/issues/274 for more details.
Gp[iteratorSymbol] = function() {
return this;
};
Gp.toString = function() {
return "[object Generator]";
};
function pushTryEntry(locs) {
var entry = { tryLoc: locs[0] };
if (1 in locs) {
entry.catchLoc = locs[1];
}
if (2 in locs) {
entry.finallyLoc = locs[2];
entry.afterLoc = locs[3];
}
this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal";
delete record.arg;
entry.completion = record;
}
function Context(tryLocsList) {
// The root entry object (effectively a try statement without a catch
// or a finally block) gives us a place to store values thrown from
// locations where there is no enclosing try statement.
this.tryEntries = [{ tryLoc: "root" }];
tryLocsList.forEach(pushTryEntry, this);
this.reset(true);
}
runtime.keys = function(object) {
var keys = [];
for (var key in object) {
keys.push(key);
}
keys.reverse();
// Rather than returning an object with a next method, we keep
// things simple and return the next function itself.
return function next() {
while (keys.length) {
var key = keys.pop();
if (key in object) {
next.value = key;
next.done = false;
return next;
}
}
// To avoid creating an additional object, we just hang the .value
// and .done properties off the next function object itself. This
// also ensures that the minifier will not anonymize the function.
next.done = true;
return next;
};
};
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) {
return iteratorMethod.call(iterable);
}
if (typeof iterable.next === "function") {
return iterable;
}
if (!isNaN(iterable.length)) {
var i = -1, next = function next() {
while (++i < iterable.length) {
if (hasOwn.call(iterable, i)) {
next.value = iterable[i];
next.done = false;
return next;
}
}
next.value = undefined;
next.done = true;
return next;
};
return next.next = next;
}
}
// Return an iterator with no values.
return { next: doneResult };
}
runtime.values = values;
function doneResult() {
return { value: undefined, done: true };
}
Context.prototype = {
constructor: Context,
reset: function(skipTempReset) {
this.prev = 0;
this.next = 0;
// Resetting context._sent for legacy support of Babel's
// function.sent implementation.
this.sent = this._sent = undefined;
this.done = false;
this.delegate = null;
this.method = "next";
this.arg = undefined;
this.tryEntries.forEach(resetTryEntry);
if (!skipTempReset) {
for (var name in this) {
// Not sure about the optimal order of these conditions:
if (name.charAt(0) === "t" &&
hasOwn.call(this, name) &&
!isNaN(+name.slice(1))) {
this[name] = undefined;
}
}
}
},
stop: function() {
this.done = true;
var rootEntry = this.tryEntries[0];
var rootRecord = rootEntry.completion;
if (rootRecord.type === "throw") {
throw rootRecord.arg;
}
return this.rval;
},
dispatchException: function(exception) {
if (this.done) {
throw exception;
}
var context = this;
function handle(loc, caught) {
record.type = "throw";
record.arg = exception;
context.next = loc;
if (caught) {
// If the dispatched exception was caught by a catch block,
// then let that catch block handle the exception normally.
context.method = "next";
context.arg = undefined;
}
return !! caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
var record = entry.completion;
if (entry.tryLoc === "root") {
// Exception thrown outside of any try block that could handle
// it, so set the completion value of the entire function to
// throw the exception.
return handle("end");
}
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc");
var hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
} else if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else if (hasCatch) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
}
} else if (hasFinally) {
if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else {
throw new Error("try statement without catch or finally");
}
}
}
},
abrupt: function(type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev &&
hasOwn.call(entry, "finallyLoc") &&
this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
if (finallyEntry &&
(type === "break" ||
type === "continue") &&
finallyEntry.tryLoc <= arg &&
arg <= finallyEntry.finallyLoc) {
// Ignore the finally entry if control is not jumping to a
// location outside the try/catch block.
finallyEntry = null;
}
var record = finallyEntry ? finallyEntry.completion : {};
record.type = type;
record.arg = arg;
if (finallyEntry) {
this.method = "next";
this.next = finallyEntry.finallyLoc;
return ContinueSentinel;
}
return this.complete(record);
},
complete: function(record, afterLoc) {
if (record.type === "throw") {
throw record.arg;
}
if (record.type === "break" ||
record.type === "continue") {
this.next = record.arg;
} else if (record.type === "return") {
this.rval = this.arg = record.arg;
this.method = "return";
this.next = "end";
} else if (record.type === "normal" && afterLoc) {
this.next = afterLoc;
}
return ContinueSentinel;
},
finish: function(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) {
this.complete(entry.completion, entry.afterLoc);
resetTryEntry(entry);
return ContinueSentinel;
}
}
},
"catch": function(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if (record.type === "throw") {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
// The context.catch method must only be called with a location
// argument that corresponds to a known catch block.
throw new Error("illegal catch attempt");
},
delegateYield: function(iterable, resultName, nextLoc) {
this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
};
if (this.method === "next") {
// Deliberately forget the last sent value so that we don't
// accidentally pass it on to the delegate.
this.arg = undefined;
}
return ContinueSentinel;
}
};
})(
// In sloppy mode, unbound `this` refers to the global object, fallback to
// Function constructor if we're in global strict mode. That is sadly a form
// of indirect eval which violates Content Security Policy.
(function() { return this })() || Function("return this")()
);
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(128)))
/***/ }),
/***/ 214:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue, Promise) {
var _regenerator = __webpack_require__(135);
var _regenerator2 = _interopRequireDefault(_regenerator);
var _config = __webpack_require__(9);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* v_index.js
* Version: 0.1
* User: zjx
* Date: 2017-09-29
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 门锁用户
*/
_public.iot.ready(init);
function init() {
//通用 图片轮播、跑马灯、开关、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-swipe-list', 'u-dialog', 'u-loading']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig(),
//用户列表
userList: [],
userListIndex: null,
loadShowFlag: false,
loadFlag: false,
loadText: '',
pagesize: 10,
tip: '无数据',
extras: {},
userListData: [],
startId: 0,
role: null
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
//获取用户列表
this.role = this.extras.role;
getUserList(this);
var self = this;
window.addEventListener('returnPage', function (event) {
console.log("returnPage");
self.setUserList([]);
getUserList(self);
});
},
methods: {
getUserList: function getUserList() {
return this.userList;
},
setUserList: function setUserList(list) {
this.userList = list;
},
onBackTap: function onBackTap() {
backTap();
},
onAddUserTap: function onAddUserTap() {
addUserTap(this);
},
setLoadShowFlag: function setLoadShowFlag(number) {
this.loadShowFlag = number >= this.pagesize;
},
getUserListData: function getUserListData() {
return this.userListData;
},
setUserListData: function setUserListData(data) {
this.userListData = data;
},
getStartId: function getStartId() {
return this.startId;
},
setStartId: function setStartId(id) {
this.startId = id;
},
getRole: function getRole() {
return this.role;
},
setRole: function setRole(role) {
this.role = role;
},
//
// onSwipeLeftRow(index){
// swipeLeftRow(this, index);
// },
// onSwipeRightRow(){
// swipeRightRow(this);
// },
//
onTapLoad: function onTapLoad() {
// tapLoad();
},
onTapUserList: function onTapUserList(index) {
_onTapUserList(this, index);
},
onTapButton: function onTapButton(index) {
tapButton(this, index);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//获取用户列表
function getUserList(self) {
_public.uComponents.showLoading(self);
_public.iot.business.api.sendCustom('lock/getLockUser', {
data: {
device_id: self.extras.deviceId
},
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
console.log(data);
if (data) {
sortUsers(self, data);
}
},
error: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 获取用户列表失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取用户列表失败');
// }
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
//
function sortRule(a, b) {
return a.role - b.role;
}
function getUserInfoMap() {
return new Promise(function (resolve, reject) {
_public.iot.business.websql.getMap('userinfo', function (res) {
if (res) {
resolve(res.id);
} else {
reject(res);
}
}, function (err) {
console.log(err);
});
});
}
function sortUsers(self, data) {
var id, users, manage, i;
return _regenerator2.default.async(function sortUsers$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
id = [];
_context.prev = 1;
_context.next = 4;
return _regenerator2.default.awrap(getUserInfoMap());
case 4:
id = _context.sent;
_context.next = 10;
break;
case 7:
_context.prev = 7;
_context.t0 = _context['catch'](1);
console.log(_context.t0);
case 10:
users = [];
manage = [];
for (i = 0; i < data.length; i++) {
if (data[i].user_id == null || data[i].role && data[i].user_id != id) {
users.push(data[i]);
} else {
manage.push(data[i]);
}
}
manage = manage.sort(sortRule);
console.log(manage);
data = manage.concat(users);
setUserData(self, data);
case 17:
case 'end':
return _context.stop();
}
}
}, null, this, [[1, 7]]);
}
function setUserData(self, data) {
var list = [];
for (var i = 0; i < data.length; i++) {
list[i] = {
value: data[i].id,
role: data[i].role,
image: data[i].role == 0 ? '../../resources/image/green_admin_icon.png' : data[i].user_id == null ? '../../resources/image/gray_unbindHead_icon.png' : '../../resources/image/green_bindHead_icon.png',
title: data[i].nickname,
subtitle: data[i].username ? Vue.t('userList.binded') : Vue.t('userList.unbind')
};
}
console.log(data);
self.setUserListData(data);
self.setUserList(list);
}
//返回上一页
function backTap() {
_public.iot.navigator.aback();
}
_public.iot.navigator.aback = function () {
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
console.log("fire");
_public.iot.navigator.back();
};
//添加用户
function addUserTap(self) {
_public.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 swipeLeftRow(self, index) {
// self.userListIndex = index;
//}
//// 向右滑动用户列表,修改用户列表下标
//function swipeRightRow(self) {
// self.userListIndex = null;
//}
//
// 点击组件列表 通知事件和当前点击列表下标
function _onTapUserList(self, listIndex) {
_public.iot.navigator.openWindow({
url: './doorlockUser.html',
id: 'doorlockUser',
extras: {
id: self.getUserListData()[listIndex].id,
uuid: self.extras.uuid,
account: self.getUserListData()[listIndex].account,
lockId: self.extras.lockId,
role: self.extras.role
}
});
if (self.userListIndex != null) {
self.userListIndex = null;
}
}
//点击按钮
function tapButton(self, index) {
console.log(index);
//tap 删除该用户
_public.uComponents.openConfirm(self, Vue.t('doorlockUser.deleteUserDialogTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.delete'), callback: function callback() {
deleteUser(self, index);
} });
}
//删除用户
function deleteUser(self, index) {
_public.uComponents.showLoading(self);
_public.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: function success(response) {
console.log(response);
if (response.data.success) {
_public.uComponents.openAlert(self, Vue.t('doorlockUser.deleteSuccess'), {
text: Vue.t('btn.confirm'), callback: function callback() {
self.setUserList([]);
getUserList(self);
}
});
}
},
error: function error(_error2) {
console.log(_error2);
// if(window.iotDebug){
// iotDebug.push('end: 删除用户失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'删除用户失败');
// }
_public.uComponents.openAlert(self, Vue.t('doorlockUser.deleteFailure'), {
text: Vue.t('btn.confirm'), callback: function callback() {}
});
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"], __webpack_require__(128)))
/***/ }),
/***/ 315:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(214);
/***/ })
},[315]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
webpackJsonp([6],{
/***/ 127:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Implementation of a subset of node.js Buffer methods for the browser.
* Based on https://github.com/feross/buffer
*/
/* eslint-disable no-proto */
var isArray = __webpack_require__(136)
var K_MAX_LENGTH = 0x7fffffff
function Buffer (arg, offset, length) {
if (typeof arg === 'number') {
return allocUnsafe(arg)
}
return from(arg, offset, length)
}
Buffer.prototype.__proto__ = Uint8Array.prototype
Buffer.__proto__ = Uint8Array
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
if (typeof Symbol !== 'undefined' && Symbol.species &&
Buffer[Symbol.species] === Buffer) {
Object.defineProperty(Buffer, Symbol.species, {
value: null,
configurable: true,
enumerable: false,
writable: false
})
}
function checked (length) {
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if (length >= K_MAX_LENGTH) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
}
return length | 0
}
function isnan (val) {
return val !== val // eslint-disable-line no-self-compare
}
function createBuffer (length) {
var buf = new Uint8Array(length)
buf.__proto__ = Buffer.prototype
return buf
}
function allocUnsafe (size) {
return createBuffer(size < 0 ? 0 : checked(size) | 0)
}
function fromString (string) {
var length = byteLength(string) | 0
var buf = createBuffer(length)
var actual = buf.write(string)
if (actual !== length) {
// Writing a hex string, for example, that contains invalid characters will
// cause everything after the first invalid character to be ignored. (e.g.
// 'abxxcd' will be treated as 'ab')
buf = buf.slice(0, actual)
}
return buf
}
function fromArrayLike (array) {
var length = array.length < 0 ? 0 : checked(array.length) | 0
var buf = createBuffer(length)
for (var i = 0; i < length; i += 1) {
buf[i] = array[i] & 255
}
return buf
}
function fromArrayBuffer (array, byteOffset, length) {
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError('\'offset\' is out of bounds')
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError('\'length\' is out of bounds')
}
var buf
if (byteOffset === undefined && length === undefined) {
buf = new Uint8Array(array)
} else if (length === undefined) {
buf = new Uint8Array(array, byteOffset)
} else {
buf = new Uint8Array(array, byteOffset, length)
}
// Return an augmented `Uint8Array` instance
buf.__proto__ = Buffer.prototype
return buf
}
function fromObject (obj) {
if (Buffer.isBuffer(obj)) {
var len = checked(obj.length) | 0
var buf = createBuffer(len)
if (buf.length === 0) {
return buf
}
obj.copy(buf, 0, 0, len)
return buf
}
if (obj) {
if ((typeof ArrayBuffer !== 'undefined' &&
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
if (typeof obj.length !== 'number' || isnan(obj.length)) {
return createBuffer(0)
}
return fromArrayLike(obj)
}
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
return fromArrayLike(obj.data)
}
}
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
}
function utf8ToBytes (string, units) {
units = units || Infinity
var codePoint
var length = string.length
var leadSurrogate = null
var bytes = []
for (var i = 0; i < length; ++i) {
codePoint = string.charCodeAt(i)
// is surrogate component
if (codePoint > 0xD7FF && codePoint < 0xE000) {
// last char was a lead
if (!leadSurrogate) {
// no lead yet
if (codePoint > 0xDBFF) {
// unexpected trail
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
} else if (i + 1 === length) {
// unpaired lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
}
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if (codePoint < 0xDC00) {
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
leadSurrogate = codePoint
continue
}
// valid surrogate pair
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
} else if (leadSurrogate) {
// valid bmp char, but last char was a lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
}
leadSurrogate = null
// encode utf8
if (codePoint < 0x80) {
if ((units -= 1) < 0) break
bytes.push(codePoint)
} else if (codePoint < 0x800) {
if ((units -= 2) < 0) break
bytes.push(
codePoint >> 0x6 | 0xC0,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x10000) {
if ((units -= 3) < 0) break
bytes.push(
codePoint >> 0xC | 0xE0,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x110000) {
if ((units -= 4) < 0) break
bytes.push(
codePoint >> 0x12 | 0xF0,
codePoint >> 0xC & 0x3F | 0x80,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else {
throw new Error('Invalid code point')
}
}
return bytes
}
function byteLength (string) {
if (Buffer.isBuffer(string)) {
return string.length
}
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
return string.byteLength
}
if (typeof string !== 'string') {
string = '' + string
}
var len = string.length
if (len === 0) return 0
return utf8ToBytes(string).length
}
function blitBuffer (src, dst, offset, length) {
for (var i = 0; i < length; ++i) {
if ((i + offset >= dst.length) || (i >= src.length)) break
dst[i + offset] = src[i]
}
return i
}
function utf8Write (buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
}
function from (value, offset, length) {
if (typeof value === 'number') {
throw new TypeError('"value" argument must not be a number')
}
if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
return fromArrayBuffer(value, offset, length)
}
if (typeof value === 'string') {
return fromString(value, offset)
}
return fromObject(value)
}
Buffer.prototype.write = function write (string, offset, length) {
// Buffer#write(string)
if (offset === undefined) {
length = this.length
offset = 0
// Buffer#write(string, encoding)
} else if (length === undefined && typeof offset === 'string') {
length = this.length
offset = 0
// Buffer#write(string, offset[, length])
} else if (isFinite(offset)) {
offset = offset | 0
if (isFinite(length)) {
length = length | 0
} else {
length = undefined
}
}
var remaining = this.length - offset
if (length === undefined || length > remaining) length = remaining
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
throw new RangeError('Attempt to write outside buffer bounds')
}
return utf8Write(this, string, offset, length)
}
Buffer.prototype.slice = function slice (start, end) {
var len = this.length
start = ~~start
end = end === undefined ? len : ~~end
if (start < 0) {
start += len
if (start < 0) start = 0
} else if (start > len) {
start = len
}
if (end < 0) {
end += len
if (end < 0) end = 0
} else if (end > len) {
end = len
}
if (end < start) end = start
var newBuf = this.subarray(start, end)
// Return an augmented `Uint8Array` instance
newBuf.__proto__ = Buffer.prototype
return newBuf
}
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
if (!start) start = 0
if (!end && end !== 0) end = this.length
if (targetStart >= target.length) targetStart = target.length
if (!targetStart) targetStart = 0
if (end > 0 && end < start) end = start
// Copy 0 bytes; we're done
if (end === start) return 0
if (target.length === 0 || this.length === 0) return 0
// Fatal error conditions
if (targetStart < 0) {
throw new RangeError('targetStart out of bounds')
}
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
if (end < 0) throw new RangeError('sourceEnd out of bounds')
// Are we oob?
if (end > this.length) end = this.length
if (target.length - targetStart < end - start) {
end = target.length - targetStart + start
}
var len = end - start
var i
if (this === target && start < targetStart && targetStart < end) {
// descending copy from end
for (i = len - 1; i >= 0; --i) {
target[i + targetStart] = this[i + start]
}
} else if (len < 1000) {
// ascending copy from start
for (i = 0; i < len; ++i) {
target[i + targetStart] = this[i + start]
}
} else {
Uint8Array.prototype.set.call(
target,
this.subarray(start, start + len),
targetStart
)
}
return len
}
Buffer.prototype.fill = function fill (val, start, end) {
// Handle string cases:
if (typeof val === 'string') {
if (typeof start === 'string') {
start = 0
end = this.length
} else if (typeof end === 'string') {
end = this.length
}
if (val.length === 1) {
var code = val.charCodeAt(0)
if (code < 256) {
val = code
}
}
} else if (typeof val === 'number') {
val = val & 255
}
// Invalid ranges are not set to a default, so can range check early.
if (start < 0 || this.length < start || this.length < end) {
throw new RangeError('Out of range index')
}
if (end <= start) {
return this
}
start = start >>> 0
end = end === undefined ? this.length : end >>> 0
if (!val) val = 0
var i
if (typeof val === 'number') {
for (i = start; i < end; ++i) {
this[i] = val
}
} else {
var bytes = Buffer.isBuffer(val)
? val
: new Buffer(val)
var len = bytes.length
for (i = 0; i < end - start; ++i) {
this[i + start] = bytes[i % len]
}
}
return this
}
Buffer.concat = function concat (list, length) {
if (!isArray(list)) {
throw new TypeError('"list" argument must be an Array of Buffers')
}
if (list.length === 0) {
return createBuffer(null, 0)
}
var i
if (length === undefined) {
length = 0
for (i = 0; i < list.length; ++i) {
length += list[i].length
}
}
var buffer = allocUnsafe(length)
var pos = 0
for (i = 0; i < list.length; ++i) {
var buf = list[i]
if (!Buffer.isBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers')
}
buf.copy(buffer, pos)
pos += buf.length
}
return buffer
}
Buffer.byteLength = byteLength
Buffer.prototype._isBuffer = true
Buffer.isBuffer = function isBuffer (b) {
return !!(b != null && b._isBuffer)
}
module.exports = Buffer
/***/ }),
/***/ 134:
/***/ (function(module, exports) {
exports.L = { bit: 1 }
exports.M = { bit: 0 }
exports.Q = { bit: 3 }
exports.H = { bit: 2 }
function fromString (string) {
if (typeof string !== 'string') {
throw new Error('Param is not a string')
}
var lcStr = string.toLowerCase()
switch (lcStr) {
case 'l':
case 'low':
return exports.L
case 'm':
case 'medium':
return exports.M
case 'q':
case 'quartile':
return exports.Q
case 'h':
case 'high':
return exports.H
default:
throw new Error('Unknown EC Level: ' + string)
}
}
exports.isValid = function isValid (level) {
return level && typeof level.bit !== 'undefined' &&
level.bit >= 0 && level.bit < 4
}
exports.from = function from (value, defaultValue) {
if (exports.isValid(value)) {
return value
}
try {
return fromString(value)
} catch (e) {
return defaultValue
}
}
/***/ }),
/***/ 136:
/***/ (function(module, exports) {
var toString = {}.toString;
module.exports = Array.isArray || function (arr) {
return toString.call(arr) == '[object Array]';
};
/***/ }),
/***/ 143:
/***/ (function(module, exports, __webpack_require__) {
var ECLevel = __webpack_require__(134)
var EC_BLOCKS_TABLE = [
// L M Q H
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 2, 2,
1, 2, 2, 4,
1, 2, 4, 4,
2, 4, 4, 4,
2, 4, 6, 5,
2, 4, 6, 6,
2, 5, 8, 8,
4, 5, 8, 8,
4, 5, 8, 11,
4, 8, 10, 11,
4, 9, 12, 16,
4, 9, 16, 16,
6, 10, 12, 18,
6, 10, 17, 16,
6, 11, 16, 19,
6, 13, 18, 21,
7, 14, 21, 25,
8, 16, 20, 25,
8, 17, 23, 25,
9, 17, 23, 34,
9, 18, 25, 30,
10, 20, 27, 32,
12, 21, 29, 35,
12, 23, 34, 37,
12, 25, 34, 40,
13, 26, 35, 42,
14, 28, 38, 45,
15, 29, 40, 48,
16, 31, 43, 51,
17, 33, 45, 54,
18, 35, 48, 57,
19, 37, 51, 60,
19, 38, 53, 63,
20, 40, 56, 66,
21, 43, 59, 70,
22, 45, 62, 74,
24, 47, 65, 77,
25, 49, 68, 81
]
var EC_CODEWORDS_TABLE = [
// L M Q H
7, 10, 13, 17,
10, 16, 22, 28,
15, 26, 36, 44,
20, 36, 52, 64,
26, 48, 72, 88,
36, 64, 96, 112,
40, 72, 108, 130,
48, 88, 132, 156,
60, 110, 160, 192,
72, 130, 192, 224,
80, 150, 224, 264,
96, 176, 260, 308,
104, 198, 288, 352,
120, 216, 320, 384,
132, 240, 360, 432,
144, 280, 408, 480,
168, 308, 448, 532,
180, 338, 504, 588,
196, 364, 546, 650,
224, 416, 600, 700,
224, 442, 644, 750,
252, 476, 690, 816,
270, 504, 750, 900,
300, 560, 810, 960,
312, 588, 870, 1050,
336, 644, 952, 1110,
360, 700, 1020, 1200,
390, 728, 1050, 1260,
420, 784, 1140, 1350,
450, 812, 1200, 1440,
480, 868, 1290, 1530,
510, 924, 1350, 1620,
540, 980, 1440, 1710,
570, 1036, 1530, 1800,
570, 1064, 1590, 1890,
600, 1120, 1680, 1980,
630, 1204, 1770, 2100,
660, 1260, 1860, 2220,
720, 1316, 1950, 2310,
750, 1372, 2040, 2430
]
/**
* Returns the number of error correction block that the QR Code should contain
* for the specified version and error correction level.
*
* @param {Number} version QR Code version
* @param {Number} errorCorrectionLevel Error correction level
* @return {Number} Number of error correction blocks
*/
exports.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {
switch (errorCorrectionLevel) {
case ECLevel.L:
return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]
case ECLevel.M:
return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]
case ECLevel.Q:
return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]
case ECLevel.H:
return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]
default:
return undefined
}
}
/**
* Returns the number of error correction codewords to use for the specified
* version and error correction level.
*
* @param {Number} version QR Code version
* @param {Number} errorCorrectionLevel Error correction level
* @return {Number} Number of error correction codewords
*/
exports.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {
switch (errorCorrectionLevel) {
case ECLevel.L:
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]
case ECLevel.M:
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]
case ECLevel.Q:
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]
case ECLevel.H:
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]
default:
return undefined
}
}
/***/ }),
/***/ 144:
/***/ (function(module, exports) {
var numeric = '[0-9]+'
var alphanumeric = '[A-Z $%*+-./:]+'
var kanji = '(?:[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|' +
'[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B|' +
'[\u2010\u2015\u2018\u2019\u2025\u2026\u201C\u201D\u2225\u2260]|' +
'[\u0391-\u0451]|[\u00A7\u00A8\u00B1\u00B4\u00D7\u00F7])+'
var byte = '(?:(?![A-Z0-9 $%*+-./:]|' + kanji + ').)+'
exports.KANJI = new RegExp(kanji, 'g')
exports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+-./:]+', 'g')
exports.BYTE = new RegExp(byte, 'g')
exports.NUMERIC = new RegExp(numeric, 'g')
exports.ALPHANUMERIC = new RegExp(alphanumeric, 'g')
var TEST_KANJI = new RegExp('^' + kanji + '$')
var TEST_NUMERIC = new RegExp('^' + numeric + '$')
var TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+-./:]+$')
exports.testKanji = function testKanji (str) {
return TEST_KANJI.test(str)
}
exports.testNumeric = function testNumeric (str) {
return TEST_NUMERIC.test(str)
}
exports.testAlphanumeric = function testAlphanumeric (str) {
return TEST_ALPHANUMERIC.test(str)
}
/***/ }),
/***/ 145:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(8)
var ECCode = __webpack_require__(143)
var ECLevel = __webpack_require__(134)
var Mode = __webpack_require__(7)
var isArray = __webpack_require__(136)
// Generator polynomial used to encode version information
var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)
var G18_BCH = Utils.getBCHDigit(G18)
function getBestVersionForDataLength (mode, length, errorCorrectionLevel) {
for (var currentVersion = 1; currentVersion <= 40; currentVersion++) {
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
return currentVersion
}
}
return undefined
}
function getReservedBitsCount (mode, version) {
// Character count indicator + mode indicator bits
return Mode.getCharCountIndicator(mode, version) + 4
}
function getTotalBitsFromDataArray (segments, version) {
var totalBits = 0
segments.forEach(function (data) {
var reservedBits = getReservedBitsCount(data.mode, version)
totalBits += reservedBits + data.getBitsLength()
})
return totalBits
}
function getBestVersionForMixedData (segments, errorCorrectionLevel) {
for (var currentVersion = 1; currentVersion <= 40; currentVersion++) {
var length = getTotalBitsFromDataArray(segments, currentVersion)
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
return currentVersion
}
}
return undefined
}
/**
* Check if QR Code version is valid
*
* @param {Number} version QR Code version
* @return {Boolean} true if valid version, false otherwise
*/
exports.isValid = function isValid (version) {
return !isNaN(version) && version >= 1 && version <= 40
}
/**
* Returns version number from a value.
* If value is not a valid version, returns defaultValue
*
* @param {Number|String} value QR Code version
* @param {Number} defaultValue Fallback value
* @return {Number} QR Code version number
*/
exports.from = function from (value, defaultValue) {
if (exports.isValid(value)) {
return parseInt(value, 10)
}
return defaultValue
}
/**
* Returns how much data can be stored with the specified QR code version
* and error correction level
*
* @param {Number} version QR Code version (1-40)
* @param {Number} errorCorrectionLevel Error correction level
* @param {Mode} mode Data mode
* @return {Number} Quantity of storable data
*/
exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {
if (!exports.isValid(version)) {
throw new Error('Invalid QR Code version')
}
// Use Byte mode as default
if (typeof mode === 'undefined') mode = Mode.BYTE
// Total codewords for this QR code version (Data + Error correction)
var totalCodewords = Utils.getSymbolTotalCodewords(version)
// Total number of error correction codewords
var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
// Total number of data codewords
var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
if (mode === Mode.MIXED) return dataTotalCodewordsBits
var usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version)
// Return max number of storable codewords
switch (mode) {
case Mode.NUMERIC:
return Math.floor((usableBits / 10) * 3)
case Mode.ALPHANUMERIC:
return Math.floor((usableBits / 11) * 2)
case Mode.KANJI:
return Math.floor(usableBits / 13)
case Mode.BYTE:
default:
return Math.floor(usableBits / 8)
}
}
/**
* Returns the minimum version needed to contain the amount of data
*
* @param {Segment} data Segment of data
* @param {Number} [errorCorrectionLevel=H] Error correction level
* @param {Mode} mode Data mode
* @return {Number} QR Code version
*/
exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {
var seg
var ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M)
if (isArray(data)) {
if (data.length > 1) {
return getBestVersionForMixedData(data, ecl)
}
if (data.length === 0) {
return 1
}
seg = data[0]
} else {
seg = data
}
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)
}
/**
* Returns version information with relative error correction bits
*
* The version information is included in QR Code symbols of version 7 or larger.
* It consists of an 18-bit sequence containing 6 data bits,
* with 12 error correction bits calculated using the (18, 6) Golay code.
*
* @param {Number} version QR Code version
* @return {Number} Encoded version info bits
*/
exports.getEncodedBits = function getEncodedBits (version) {
if (!exports.isValid(version) || version < 7) {
throw new Error('Invalid QR Code version')
}
var d = version << 12
while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH))
}
return (version << 12) | d
}
/***/ }),
/***/ 146:
/***/ (function(module, exports) {
function hex2rgba (hex) {
if (typeof hex !== 'string') {
throw new Error('Color should be defined as hex string')
}
var hexCode = hex.slice().replace('#', '').split('')
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
throw new Error('Invalid hex color: ' + hex)
}
// Convert from short to long form (fff -> ffffff)
if (hexCode.length === 3 || hexCode.length === 4) {
hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
return [c, c]
}))
}
// Add default alpha value
if (hexCode.length === 6) hexCode.push('F', 'F')
var hexValue = parseInt(hexCode.join(''), 16)
return {
r: (hexValue >> 24) & 255,
g: (hexValue >> 16) & 255,
b: (hexValue >> 8) & 255,
a: hexValue & 255
}
}
exports.getOptions = function getOptions (options) {
if (!options) options = {}
if (!options.color) options.color = {}
var margin = typeof options.margin === 'undefined' ||
options.margin === null ||
options.margin < 0 ? 4 : options.margin
return {
scale: options.scale || 4,
margin: margin,
color: {
dark: hex2rgba(options.color.dark || '#000000ff'),
light: hex2rgba(options.color.light || '#ffffffff')
},
type: options.type,
rendererOpts: options.rendererOpts || {}
}
}
exports.qrToImageData = function qrToImageData (imgData, qr, margin, scale, color) {
var size = qr.modules.size
var data = qr.modules.data
var scaledMargin = margin * scale
var symbolSize = size * scale + scaledMargin * 2
var palette = [color.light, color.dark]
for (var i = 0; i < symbolSize; i++) {
for (var j = 0; j < symbolSize; j++) {
var posDst = (i * symbolSize + j) * 4
var pxColor = color.light
if (i >= scaledMargin && j >= scaledMargin &&
i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
var iSrc = Math.floor((i - scaledMargin) / scale)
var jSrc = Math.floor((j - scaledMargin) / scale)
pxColor = palette[data[iSrc * size + jSrc]]
}
imgData[posDst++] = pxColor.r
imgData[posDst++] = pxColor.g
imgData[posDst++] = pxColor.b
imgData[posDst] = pxColor.a
}
}
}
/***/ }),
/***/ 174:
/***/ (function(module, exports, __webpack_require__) {
var QRCode = __webpack_require__(187)
var CanvasRenderer = __webpack_require__(190)
var SvgRenderer = __webpack_require__(191)
function renderCanvas (renderFunc, canvas, text, opts, cb) {
var argsNum = arguments.length - 1
if (argsNum < 2) {
throw new Error('Too few arguments provided')
}
if (argsNum === 2) {
cb = text
text = canvas
canvas = opts = undefined
} else if (argsNum === 3) {
if (canvas.getContext && typeof cb === 'undefined') {
cb = opts
opts = undefined
} else {
cb = opts
opts = text
text = canvas
canvas = undefined
}
}
if (typeof cb !== 'function') {
throw new Error('Callback required as last argument')
}
try {
var data = QRCode.create(text, opts)
cb(null, renderFunc(data, canvas, opts))
} catch (e) {
cb(e)
}
}
exports.create = QRCode.create
exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render)
exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL)
// only svg for now.
exports.toString = renderCanvas.bind(null, function (data, _, opts) {
return SvgRenderer.render(data, opts)
})
/**
* Legacy API
*/
exports.qrcodedraw = function () {
return {
draw: exports.toCanvas
}
}
/***/ }),
/***/ 175:
/***/ (function(module, exports, __webpack_require__) {
/**
* Alignment pattern are fixed reference pattern in defined positions
* in a matrix symbology, which enables the decode software to re-synchronise
* the coordinate mapping of the image modules in the event of moderate amounts
* of distortion of the image.
*
* Alignment patterns are present only in QR Code symbols of version 2 or larger
* and their number depends on the symbol version.
*/
var getSymbolSize = __webpack_require__(8).getSymbolSize
/**
* Calculate the row/column coordinates of the center module of each alignment pattern
* for the specified QR Code version.
*
* The alignment patterns are positioned symmetrically on either side of the diagonal
* running from the top left corner of the symbol to the bottom right corner.
*
* Since positions are simmetrical only half of the coordinates are returned.
* Each item of the array will represent in turn the x and y coordinate.
* @see {@link getPositions}
*
* @param {Number} version QR Code version
* @return {Array} Array of coordinate
*/
exports.getRowColCoords = function getRowColCoords (version) {
if (version === 1) return []
var posCount = Math.floor(version / 7) + 2
var size = getSymbolSize(version)
var intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2
var positions = [size - 7] // Last coord is always (size - 7)
for (var i = 1; i < posCount - 1; i++) {
positions[i] = positions[i - 1] - intervals
}
positions.push(6) // First coord is always 6
return positions.reverse()
}
/**
* Returns an array containing the positions of each alignment pattern.
* Each array's element represent the center point of the pattern as (x, y) coordinates
*
* Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
* and filtering out the items that overlaps with finder pattern
*
* @example
* For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
* The alignment patterns, therefore, are to be centered on (row, column)
* positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
* Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
* and are not therefore used for alignment patterns.
*
* var pos = getPositions(7)
* // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
*
* @param {Number} version QR Code version
* @return {Array} Array of coordinates
*/
exports.getPositions = function getPositions (version) {
var coords = []
var pos = exports.getRowColCoords(version)
var posLength = pos.length
for (var i = 0; i < posLength; i++) {
for (var j = 0; j < posLength; j++) {
// Skip if position is occupied by finder patterns
if ((i === 0 && j === 0) || // top-left
(i === 0 && j === posLength - 1) || // bottom-left
(i === posLength - 1 && j === 0)) { // top-right
continue
}
coords.push([pos[i], pos[j]])
}
}
return coords
}
/***/ }),
/***/ 176:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(7)
/**
* Array of characters available in alphanumeric mode
*
* As per QR Code specification, to each character
* is assigned a value from 0 to 44 which in this case coincides
* with the array index
*
* @type {Array}
*/
var ALPHA_NUM_CHARS = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
' ', '$', '%', '*', '+', '-', '.', '/', ':'
]
function AlphanumericData (data) {
this.mode = Mode.ALPHANUMERIC
this.data = data
}
AlphanumericData.getBitsLength = function getBitsLength (length) {
return 11 * Math.floor(length / 2) + 6 * (length % 2)
}
AlphanumericData.prototype.getLength = function getLength () {
return this.data.length
}
AlphanumericData.prototype.getBitsLength = function getBitsLength () {
return AlphanumericData.getBitsLength(this.data.length)
}
AlphanumericData.prototype.write = function write (bitBuffer) {
var i
// Input data characters are divided into groups of two characters
// and encoded as 11-bit binary codes.
for (i = 0; i + 2 <= this.data.length; i += 2) {
// The character value of the first character is multiplied by 45
var value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45
// The character value of the second digit is added to the product
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1])
// The sum is then stored as 11-bit binary number
bitBuffer.put(value, 11)
}
// If the number of input data characters is not a multiple of two,
// the character value of the final character is encoded as a 6-bit binary number.
if (this.data.length % 2) {
bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6)
}
}
module.exports = AlphanumericData
/***/ }),
/***/ 177:
/***/ (function(module, exports) {
function BitBuffer () {
this.buffer = []
this.length = 0
}
BitBuffer.prototype = {
get: function (index) {
var bufIndex = Math.floor(index / 8)
return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
},
put: function (num, length) {
for (var i = 0; i < length; i++) {
this.putBit(((num >>> (length - i - 1)) & 1) === 1)
}
},
getLengthInBits: function () {
return this.length
},
putBit: function (bit) {
var bufIndex = Math.floor(this.length / 8)
if (this.buffer.length <= bufIndex) {
this.buffer.push(0)
}
if (bit) {
this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))
}
this.length++
}
}
module.exports = BitBuffer
/***/ }),
/***/ 178:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
/**
* Helper class to handle QR Code symbol modules
*
* @param {Number} size Symbol size
*/
function BitMatrix (size) {
if (!size || size < 1) {
throw new Error('BitMatrix size must be defined and greater than 0')
}
this.size = size
this.data = new Buffer(size * size)
this.data.fill(0)
this.reservedBit = new Buffer(size * size)
this.reservedBit.fill(0)
}
/**
* Set bit value at specified location
* If reserved flag is set, this bit will be ignored during masking process
*
* @param {Number} row
* @param {Number} col
* @param {Boolean} value
* @param {Boolean} reserved
*/
BitMatrix.prototype.set = function (row, col, value, reserved) {
var index = row * this.size + col
this.data[index] = value
if (reserved) this.reservedBit[index] = true
}
/**
* Returns bit value at specified location
*
* @param {Number} row
* @param {Number} col
* @return {Boolean}
*/
BitMatrix.prototype.get = function (row, col) {
return this.data[row * this.size + col]
}
/**
* Applies xor operator at specified location
* (used during masking process)
*
* @param {Number} row
* @param {Number} col
* @param {Boolean} value
*/
BitMatrix.prototype.xor = function (row, col, value) {
this.data[row * this.size + col] ^= value
}
/**
* Check if bit at specified location is reserved
*
* @param {Number} row
* @param {Number} col
* @return {Boolean}
*/
BitMatrix.prototype.isReserved = function (row, col) {
return this.reservedBit[row * this.size + col]
}
module.exports = BitMatrix
/***/ }),
/***/ 179:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var Mode = __webpack_require__(7)
function ByteData (data) {
this.mode = Mode.BYTE
this.data = new Buffer(data)
}
ByteData.getBitsLength = function getBitsLength (length) {
return length * 8
}
ByteData.prototype.getLength = function getLength () {
return this.data.length
}
ByteData.prototype.getBitsLength = function getBitsLength () {
return ByteData.getBitsLength(this.data.length)
}
ByteData.prototype.write = function (bitBuffer) {
for (var i = 0, l = this.data.length; i < l; i++) {
bitBuffer.put(this.data[i], 8)
}
}
module.exports = ByteData
/***/ }),
/***/ 180:
/***/ (function(module, exports, __webpack_require__) {
var getSymbolSize = __webpack_require__(8).getSymbolSize
var FINDER_PATTERN_SIZE = 7
/**
* Returns an array containing the positions of each finder pattern.
* Each array's element represent the top-left point of the pattern as (x, y) coordinates
*
* @param {Number} version QR Code version
* @return {Array} Array of coordinates
*/
exports.getPositions = function getPositions (version) {
var size = getSymbolSize(version)
return [
// top-left
[0, 0],
// top-right
[size - FINDER_PATTERN_SIZE, 0],
// bottom-left
[0, size - FINDER_PATTERN_SIZE]
]
}
/***/ }),
/***/ 181:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(8)
var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)
var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)
var G15_BCH = Utils.getBCHDigit(G15)
/**
* Returns format information with relative error correction bits
*
* The format information is a 15-bit sequence containing 5 data bits,
* with 10 error correction bits calculated using the (15, 5) BCH code.
*
* @param {Number} errorCorrectionLevel Error correction level
* @param {Number} mask Mask pattern
* @return {Number} Encoded format information bits
*/
exports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {
var data = ((errorCorrectionLevel.bit << 3) | mask)
var d = data << 10
while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH))
}
// xor final data with mask pattern in order to ensure that
// no combination of Error Correction Level and data mask pattern
// will result in an all-zero data string
return ((data << 10) | d) ^ G15_MASK
}
/***/ }),
/***/ 182:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var EXP_TABLE = new Buffer(512)
var LOG_TABLE = new Buffer(256)
/**
* Precompute the log and anti-log tables for faster computation later
*
* For each possible value in the galois field 2^8, we will pre-compute
* the logarithm and anti-logarithm (exponential) of this value
*
* ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
*/
;(function initTables () {
var x = 1
for (var i = 0; i < 255; i++) {
EXP_TABLE[i] = x
LOG_TABLE[x] = i
x <<= 1 // multiply by 2
// The QR code specification says to use byte-wise modulo 100011101 arithmetic.
// This means that when a number is 256 or larger, it should be XORed with 0x11D.
if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)
x ^= 0x11D
}
}
// Optimization: double the size of the anti-log table so that we don't need to mod 255 to
// stay inside the bounds (because we will mainly use this table for the multiplication of
// two GF numbers, no more).
// @see {@link mul}
for (i = 255; i < 512; i++) {
EXP_TABLE[i] = EXP_TABLE[i - 255]
}
}())
/**
* Returns log value of n inside Galois Field
*
* @param {Number} n
* @return {Number}
*/
exports.log = function log (n) {
if (n < 1) throw new Error('log(' + n + ')')
return LOG_TABLE[n]
}
/**
* Returns anti-log value of n inside Galois Field
*
* @param {Number} n
* @return {Number}
*/
exports.exp = function exp (n) {
return EXP_TABLE[n]
}
/**
* Multiplies two number inside Galois Field
*
* @param {Number} x
* @param {Number} y
* @return {Number}
*/
exports.mul = function mul (x, y) {
if (x === 0 || y === 0) return 0
// should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
// @see {@link initTables}
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]
}
/***/ }),
/***/ 183:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(7)
var Utils = __webpack_require__(8)
function KanjiData (data) {
this.mode = Mode.KANJI
this.data = data
}
KanjiData.getBitsLength = function getBitsLength (length) {
return length * 13
}
KanjiData.prototype.getLength = function getLength () {
return this.data.length
}
KanjiData.prototype.getBitsLength = function getBitsLength () {
return KanjiData.getBitsLength(this.data.length)
}
KanjiData.prototype.write = function (bitBuffer) {
var i
// In the Shift JIS system, Kanji characters are represented by a two byte combination.
// These byte values are shifted from the JIS X 0208 values.
// JIS X 0208 gives details of the shift coded representation.
for (i = 0; i < this.data.length; i++) {
var value = Utils.toSJIS(this.data[i])
// For characters with Shift JIS values from 0x8140 to 0x9FFC:
if (value >= 0x8140 && value <= 0x9FFC) {
// Subtract 0x8140 from Shift JIS value
value -= 0x8140
// For characters with Shift JIS values from 0xE040 to 0xEBBF
} else if (value >= 0xE040 && value <= 0xEBBF) {
// Subtract 0xC140 from Shift JIS value
value -= 0xC140
} else {
throw new Error(
'Invalid SJIS character: ' + this.data[i] + '\n' +
'Make sure your charset is UTF-8')
}
// Multiply most significant byte of result by 0xC0
// and add least significant byte to product
value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff)
// Convert result to a 13-bit binary string
bitBuffer.put(value, 13)
}
}
module.exports = KanjiData
/***/ }),
/***/ 184:
/***/ (function(module, exports) {
/**
* Data mask pattern reference
* @type {Object}
*/
exports.Patterns = {
PATTERN000: 0,
PATTERN001: 1,
PATTERN010: 2,
PATTERN011: 3,
PATTERN100: 4,
PATTERN101: 5,
PATTERN110: 6,
PATTERN111: 7
}
/**
* Weighted penalty scores for the undesirable features
* @type {Object}
*/
var PenaltyScores = {
N1: 3,
N2: 3,
N3: 40,
N4: 10
}
/**
* Find adjacent modules in row/column with the same color
* and assign a penalty value.
*
* Points: N1 + i
* i is the amount by which the number of adjacent modules of the same color exceeds 5
*/
exports.getPenaltyN1 = function getPenaltyN1 (data) {
var size = data.size
var points = 0
var sameCountCol = 0
var sameCountRow = 0
var lastCol = null
var lastRow = null
for (var row = 0; row < size; row++) {
sameCountCol = sameCountRow = 0
lastCol = lastRow = null
for (var col = 0; col < size; col++) {
var module = data.get(row, col)
if (module === lastCol) {
sameCountCol++
} else {
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
lastCol = module
sameCountCol = 1
}
module = data.get(col, row)
if (module === lastRow) {
sameCountRow++
} else {
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
lastRow = module
sameCountRow = 1
}
}
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
}
return points
}
/**
* Find 2x2 blocks with the same color and assign a penalty value
*
* Points: N2 * (m - 1) * (n - 1)
*/
exports.getPenaltyN2 = function getPenaltyN2 (data) {
var size = data.size
var points = 0
for (var row = 0; row < size - 1; row++) {
for (var col = 0; col < size - 1; col++) {
var last = data.get(row, col) +
data.get(row, col + 1) +
data.get(row + 1, col) +
data.get(row + 1, col + 1)
if (last === 4 || last === 0) points++
}
}
return points * PenaltyScores.N2
}
/**
* Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
* preceded or followed by light area 4 modules wide
*
* Points: N3 * number of pattern found
*/
exports.getPenaltyN3 = function getPenaltyN3 (data) {
var size = data.size
var points = 0
var bitsCol = 0
var bitsRow = 0
for (var row = 0; row < size; row++) {
bitsCol = bitsRow = 0
for (var col = 0; col < size; col++) {
bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col)
if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++
bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row)
if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++
}
}
return points * PenaltyScores.N3
}
/**
* Calculate proportion of dark modules in entire symbol
*
* Points: N4 * k
*
* k is the rating of the deviation of the proportion of dark modules
* in the symbol from 50% in steps of 5%
*/
exports.getPenaltyN4 = function getPenaltyN4 (data) {
var darkCount = 0
var modulesCount = data.data.length
for (var i = 0; i < modulesCount; i++) darkCount += data.data[i]
var k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10)
return k * PenaltyScores.N4
}
/**
* Return mask value at given position
*
* @param {Number} maskPattern Pattern reference value
* @param {Number} i Row
* @param {Number} j Column
* @return {Boolean} Mask value
*/
function getMaskAt (maskPattern, i, j) {
switch (maskPattern) {
case exports.Patterns.PATTERN000: return (i + j) % 2 === 0
case exports.Patterns.PATTERN001: return i % 2 === 0
case exports.Patterns.PATTERN010: return j % 3 === 0
case exports.Patterns.PATTERN011: return (i + j) % 3 === 0
case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0
case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0
case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0
case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0
default: throw new Error('bad maskPattern:' + maskPattern)
}
}
/**
* Apply a mask pattern to a BitMatrix
*
* @param {Number} pattern Pattern reference number
* @param {BitMatrix} data BitMatrix data
*/
exports.applyMask = function applyMask (pattern, data) {
var size = data.size
for (var col = 0; col < size; col++) {
for (var row = 0; row < size; row++) {
if (data.isReserved(row, col)) continue
data.xor(row, col, getMaskAt(pattern, row, col))
}
}
}
/**
* Returns the best mask pattern for data
*
* @param {BitMatrix} data
* @return {Number} Mask pattern reference number
*/
exports.getBestMask = function getBestMask (data, setupFormatFunc) {
var numPatterns = Object.keys(exports.Patterns).length
var bestPattern = 0
var lowerPenalty = Infinity
for (var p = 0; p < numPatterns; p++) {
setupFormatFunc(p)
exports.applyMask(p, data)
// Calculate penalty
var penalty =
exports.getPenaltyN1(data) +
exports.getPenaltyN2(data) +
exports.getPenaltyN3(data) +
exports.getPenaltyN4(data)
// Undo previously applied mask
exports.applyMask(p, data)
if (penalty < lowerPenalty) {
lowerPenalty = penalty
bestPattern = p
}
}
return bestPattern
}
/***/ }),
/***/ 185:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(7)
function NumericData (data) {
this.mode = Mode.NUMERIC
this.data = data.toString()
}
NumericData.getBitsLength = function getBitsLength (length) {
return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
}
NumericData.prototype.getLength = function getLength () {
return this.data.length
}
NumericData.prototype.getBitsLength = function getBitsLength () {
return NumericData.getBitsLength(this.data.length)
}
NumericData.prototype.write = function write (bitBuffer) {
var i, group, value
// The input data string is divided into groups of three digits,
// and each group is converted to its 10-bit binary equivalent.
for (i = 0; i + 3 <= this.data.length; i += 3) {
group = this.data.substr(i, 3)
value = parseInt(group, 10)
bitBuffer.put(value, 10)
}
// If the number of input digits is not an exact multiple of three,
// the final one or two digits are converted to 4 or 7 bits respectively.
var remainingNum = this.data.length - i
if (remainingNum > 0) {
group = this.data.substr(i)
value = parseInt(group, 10)
bitBuffer.put(value, remainingNum * 3 + 1)
}
}
module.exports = NumericData
/***/ }),
/***/ 186:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var GF = __webpack_require__(182)
/**
* Multiplies two polynomials inside Galois Field
*
* @param {Buffer} p1 Polynomial
* @param {Buffer} p2 Polynomial
* @return {Buffer} Product of p1 and p2
*/
exports.mul = function mul (p1, p2) {
var coeff = new Buffer(p1.length + p2.length - 1)
coeff.fill(0)
for (var i = 0; i < p1.length; i++) {
for (var j = 0; j < p2.length; j++) {
coeff[i + j] ^= GF.mul(p1[i], p2[j])
}
}
return coeff
}
/**
* Calculate the remainder of polynomials division
*
* @param {Buffer} divident Polynomial
* @param {Buffer} divisor Polynomial
* @return {Buffer} Remainder
*/
exports.mod = function mod (divident, divisor) {
var result = new Buffer(divident)
while ((result.length - divisor.length) >= 0) {
var coeff = result[0]
for (var i = 0; i < divisor.length; i++) {
result[i] ^= GF.mul(divisor[i], coeff)
}
// remove all zeros from buffer head
var offset = 0
while (offset < result.length && result[offset] === 0) offset++
result = result.slice(offset)
}
return result
}
/**
* Generate an irreducible generator polynomial of specified degree
* (used by Reed-Solomon encoder)
*
* @param {Number} degree Degree of the generator polynomial
* @return {Buffer} Buffer containing polynomial coefficients
*/
exports.generateECPolynomial = function generateECPolynomial (degree) {
var poly = new Buffer([1])
for (var i = 0; i < degree; i++) {
poly = exports.mul(poly, [1, GF.exp(i)])
}
return poly
}
/***/ }),
/***/ 187:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var Utils = __webpack_require__(8)
var ECLevel = __webpack_require__(134)
var BitBuffer = __webpack_require__(177)
var BitMatrix = __webpack_require__(178)
var AlignmentPattern = __webpack_require__(175)
var FinderPattern = __webpack_require__(180)
var MaskPattern = __webpack_require__(184)
var ECCode = __webpack_require__(143)
var ReedSolomonEncoder = __webpack_require__(188)
var Version = __webpack_require__(145)
var FormatInfo = __webpack_require__(181)
var Mode = __webpack_require__(7)
var Segments = __webpack_require__(189)
var isArray = __webpack_require__(136)
/**
* QRCode for JavaScript
*
* modified by Ryan Day for nodejs support
* Copyright (c) 2011 Ryan Day
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
//---------------------------------------------------------------------
// QRCode for JavaScript
//
// Copyright (c) 2009 Kazuhiko Arase
//
// URL: http://www.d-project.com/
//
// Licensed under the MIT license:
// http://www.opensource.org/licenses/mit-license.php
//
// The word "QR Code" is registered trademark of
// DENSO WAVE INCORPORATED
// http://www.denso-wave.com/qrcode/faqpatent-e.html
//
//---------------------------------------------------------------------
*/
/**
* Add finder patterns bits to matrix
*
* @param {BitMatrix} matrix Modules matrix
* @param {Number} version QR Code version
*/
function setupFinderPattern (matrix, version) {
var size = matrix.size
var pos = FinderPattern.getPositions(version)
for (var i = 0; i < pos.length; i++) {
var row = pos[i][0]
var col = pos[i][1]
for (var r = -1; r <= 7; r++) {
if (row + r <= -1 || size <= row + r) continue
for (var c = -1; c <= 7; c++) {
if (col + c <= -1 || size <= col + c) continue
if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||
(c >= 0 && c <= 6 && (r === 0 || r === 6)) ||
(r >= 2 && r <= 4 && c >= 2 && c <= 4)) {
matrix.set(row + r, col + c, true, true)
} else {
matrix.set(row + r, col + c, false, true)
}
}
}
}
}
/**
* Add timing pattern bits to matrix
*
* Note: this function must be called before {@link setupAlignmentPattern}
*
* @param {BitMatrix} matrix Modules matrix
*/
function setupTimingPattern (matrix) {
var size = matrix.size
for (var r = 8; r < size - 8; r++) {
var value = r % 2 === 0
matrix.set(r, 6, value, true)
matrix.set(6, r, value, true)
}
}
/**
* Add alignment patterns bits to matrix
*
* Note: this function must be called after {@link setupTimingPattern}
*
* @param {BitMatrix} matrix Modules matrix
* @param {Number} version QR Code version
*/
function setupAlignmentPattern (matrix, version) {
var pos = AlignmentPattern.getPositions(version)
for (var i = 0; i < pos.length; i++) {
var row = pos[i][0]
var col = pos[i][1]
for (var r = -2; r <= 2; r++) {
for (var c = -2; c <= 2; c++) {
if (r === -2 || r === 2 || c === -2 || c === 2 ||
(r === 0 && c === 0)) {
matrix.set(row + r, col + c, true, true)
} else {
matrix.set(row + r, col + c, false, true)
}
}
}
}
}
/**
* Add version info bits to matrix
*
* @param {BitMatrix} matrix Modules matrix
* @param {Number} version QR Code version
*/
function setupVersionInfo (matrix, version) {
var size = matrix.size
var bits = Version.getEncodedBits(version)
var row, col, mod
for (var i = 0; i < 18; i++) {
row = Math.floor(i / 3)
col = i % 3 + size - 8 - 3
mod = ((bits >> i) & 1) === 1
matrix.set(row, col, mod, true)
matrix.set(col, row, mod, true)
}
}
/**
* Add format info bits to matrix
*
* @param {BitMatrix} matrix Modules matrix
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
* @param {Number} maskPattern Mask pattern reference value
*/
function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {
var size = matrix.size
var bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern)
var i, mod
for (i = 0; i < 15; i++) {
mod = ((bits >> i) & 1) === 1
// vertical
if (i < 6) {
matrix.set(i, 8, mod, true)
} else if (i < 8) {
matrix.set(i + 1, 8, mod, true)
} else {
matrix.set(size - 15 + i, 8, mod, true)
}
// horizontal
if (i < 8) {
matrix.set(8, size - i - 1, mod, true)
} else if (i < 9) {
matrix.set(8, 15 - i - 1 + 1, mod, true)
} else {
matrix.set(8, 15 - i - 1, mod, true)
}
}
// fixed module
matrix.set(size - 8, 8, 1, true)
}
/**
* Add encoded data bits to matrix
*
* @param {BitMatrix} matrix Modules matrix
* @param {Buffer} data Data codewords
*/
function setupData (matrix, data) {
var size = matrix.size
var inc = -1
var row = size - 1
var bitIndex = 7
var byteIndex = 0
for (var col = size - 1; col > 0; col -= 2) {
if (col === 6) col--
while (true) {
for (var c = 0; c < 2; c++) {
if (!matrix.isReserved(row, col - c)) {
var dark = false
if (byteIndex < data.length) {
dark = (((data[byteIndex] >>> bitIndex) & 1) === 1)
}
matrix.set(row, col - c, dark)
bitIndex--
if (bitIndex === -1) {
byteIndex++
bitIndex = 7
}
}
}
row += inc
if (row < 0 || size <= row) {
row -= inc
inc = -inc
break
}
}
}
}
/**
* Create encoded codewords from data input
*
* @param {Number} version QR Code version
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
* @param {ByteData} data Data input
* @return {Buffer} Buffer containing encoded codewords
*/
function createData (version, errorCorrectionLevel, segments) {
// Prepare data buffer
var buffer = new BitBuffer()
segments.forEach(function (data) {
// prefix data with mode indicator (4 bits)
buffer.put(data.mode.bit, 4)
// Prefix data with character count indicator.
// The character count indicator is a string of bits that represents the
// number of characters that are being encoded.
// The character count indicator must be placed after the mode indicator
// and must be a certain number of bits long, depending on the QR version
// and data mode
// @see {@link Mode.getCharCountIndicator}.
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version))
// add binary data sequence to buffer
data.write(buffer)
})
// Calculate required number of bits
var totalCodewords = Utils.getSymbolTotalCodewords(version)
var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
// Add a terminator.
// If the bit string is shorter than the total number of required bits,
// a terminator of up to four 0s must be added to the right side of the string.
// If the bit string is more than four bits shorter than the required number of bits,
// add four 0s to the end.
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
buffer.put(0, 4)
}
// If the bit string is fewer than four bits shorter, add only the number of 0s that
// are needed to reach the required number of bits.
// After adding the terminator, if the number of bits in the string is not a multiple of 8,
// pad the string on the right with 0s to make the string's length a multiple of 8.
while (buffer.getLengthInBits() % 8 !== 0) {
buffer.putBit(0)
}
// Add pad bytes if the string is still shorter than the total number of required bits.
// Extend the buffer to fill the data capacity of the symbol corresponding to
// the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
// and 00010001 (0x11) alternately.
var remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8
for (var i = 0; i < remainingByte; i++) {
buffer.put(i % 2 ? 0x11 : 0xEC, 8)
}
return createCodewords(buffer, version, errorCorrectionLevel)
}
/**
* Encode input data with Reed-Solomon and return codewords with
* relative error correction bits
*
* @param {BitBuffer} bitBuffer Data to encode
* @param {Number} version QR Code version
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
* @return {Buffer} Buffer containing encoded codewords
*/
function createCodewords (bitBuffer, version, errorCorrectionLevel) {
// Total codewords for this QR code version (Data + Error correction)
var totalCodewords = Utils.getSymbolTotalCodewords(version)
// Total number of error correction codewords
var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
// Total number of data codewords
var dataTotalCodewords = totalCodewords - ecTotalCodewords
// Total number of blocks
var ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel)
// Calculate how many blocks each group should contain
var blocksInGroup2 = totalCodewords % ecTotalBlocks
var blocksInGroup1 = ecTotalBlocks - blocksInGroup2
var totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks)
var dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks)
var dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1
// Number of EC codewords is the same for both groups
var ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1
// Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
var rs = new ReedSolomonEncoder(ecCount)
var offset = 0
var dcData = new Array(ecTotalBlocks)
var ecData = new Array(ecTotalBlocks)
var maxDataSize = 0
var buffer = new Buffer(bitBuffer.buffer)
// Divide the buffer into the required number of blocks
for (var b = 0; b < ecTotalBlocks; b++) {
var dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2
// extract a block of data from buffer
dcData[b] = buffer.slice(offset, offset + dataSize)
// Calculate EC codewords for this data block
ecData[b] = rs.encode(dcData[b])
offset += dataSize
maxDataSize = Math.max(maxDataSize, dataSize)
}
// Create final data
// Interleave the data and error correction codewords from each block
var data = new Buffer(totalCodewords)
var index = 0
var i, r
// Add data codewords
for (i = 0; i < maxDataSize; i++) {
for (r = 0; r < ecTotalBlocks; r++) {
if (i < dcData[r].length) {
data[index++] = dcData[r][i]
}
}
}
// Apped EC codewords
for (i = 0; i < ecCount; i++) {
for (r = 0; r < ecTotalBlocks; r++) {
data[index++] = ecData[r][i]
}
}
return data
}
/**
* Build QR Code symbol
*
* @param {String} data Input string
* @param {Number} version QR Code version
* @param {ErrorCorretionLevel} errorCorrectionLevel Error level
* @return {Object} Object containing symbol data
*/
function createSymbol (data, version, errorCorrectionLevel) {
var segments
if (isArray(data)) {
segments = Segments.fromArray(data)
} else if (typeof data === 'string') {
var estimatedVersion = version
if (!estimatedVersion) {
var rawSegments = Segments.rawSplit(data)
// Estimate best version that can contain raw splitted segments
estimatedVersion = Version.getBestVersionForData(rawSegments,
errorCorrectionLevel)
}
// Build optimized segments
// If estimated version is undefined, try with the highest version
segments = Segments.fromString(data, estimatedVersion || 40)
} else {
throw new Error('Invalid data')
}
// Get the min version that can contain data
var bestVersion = Version.getBestVersionForData(segments,
errorCorrectionLevel)
// If no version is found, data cannot be stored
if (!bestVersion) {
throw new Error('The amount of data is too big to be stored in a QR Code')
}
// If not specified, use min version as default
if (!version) {
version = bestVersion
// Check if the specified version can contain the data
} else if (version < bestVersion) {
throw new Error('\n' +
'The chosen QR Code version cannot contain this amount of data.\n' +
'Minimum version required to store current data is: ' + bestVersion + '.\n'
)
}
var dataBits = createData(version, errorCorrectionLevel, segments)
// Allocate matrix buffer
var moduleCount = Utils.getSymbolSize(version)
var modules = new BitMatrix(moduleCount)
// Add function modules
setupFinderPattern(modules, version)
setupTimingPattern(modules)
setupAlignmentPattern(modules, version)
// Add temporary dummy bits for format info just to set them as reserved.
// This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
// since the masking operation must be performed only on the encoding region.
// These blocks will be replaced with correct values later in code.
setupFormatInfo(modules, errorCorrectionLevel, 0)
if (version >= 7) {
setupVersionInfo(modules, version)
}
// Add data codewords
setupData(modules, dataBits)
// Find best mask pattern
var maskPattern = MaskPattern.getBestMask(modules,
setupFormatInfo.bind(null, modules, errorCorrectionLevel))
// Apply mask pattern
MaskPattern.applyMask(maskPattern, modules)
// Replace format info bits with correct values
setupFormatInfo(modules, errorCorrectionLevel, maskPattern)
return {
modules: modules,
version: version,
errorCorrectionLevel: errorCorrectionLevel,
maskPattern: maskPattern,
segments: segments
}
}
/**
* QR Code
*
* @param {String | Array} data Input data
* @param {Object} options Optional configurations
* @param {Number} options.version QR Code version
* @param {String} options.errorCorrectionLevel Error correction level
* @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
*/
exports.create = function create (data, options) {
if (typeof data === 'undefined' || data === '') {
throw new Error('No input text')
}
var errorCorrectionLevel = ECLevel.M
var version
if (typeof options !== 'undefined') {
// Use higher error correction level as default
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M)
version = Version.from(options.version)
if (options.toSJISFunc) {
Utils.setToSJISFunction(options.toSJISFunc)
}
}
return createSymbol(data, version, errorCorrectionLevel)
}
/***/ }),
/***/ 188:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(127)
var Polynomial = __webpack_require__(186)
function ReedSolomonEncoder (degree) {
this.genPoly = undefined
this.degree = degree
if (this.degree) this.initialize(this.degree)
}
/**
* Initialize the encoder.
* The input param should correspond to the number of error correction codewords.
*
* @param {Number} degree
*/
ReedSolomonEncoder.prototype.initialize = function initialize (degree) {
// create an irreducible generator polynomial
this.degree = degree
this.genPoly = Polynomial.generateECPolynomial(this.degree)
}
/**
* Encodes a chunk of data
*
* @param {Buffer} data Buffer containing input data
* @return {Buffer} Buffer containing encoded data
*/
ReedSolomonEncoder.prototype.encode = function encode (data) {
if (!this.genPoly) {
throw new Error('Encoder not initialized')
}
// Calculate EC for this data block
// extends data size to data+genPoly size
var pad = new Buffer(this.degree)
pad.fill(0)
var paddedData = Buffer.concat([data, pad], data.length + this.degree)
// The error correction codewords are the remainder after dividing the data codewords
// by a generator polynomial
var remainder = Polynomial.mod(paddedData, this.genPoly)
// return EC data blocks (last n byte, where n is the degree of genPoly)
// If coefficients number in remainder are less than genPoly degree,
// pad with 0s to the left to reach the needed number of coefficients
var start = this.degree - remainder.length
if (start > 0) {
var buff = new Buffer(this.degree)
buff.fill(0)
remainder.copy(buff, start)
return buff
}
return remainder
}
module.exports = ReedSolomonEncoder
/***/ }),
/***/ 189:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(7)
var NumericData = __webpack_require__(185)
var AlphanumericData = __webpack_require__(176)
var ByteData = __webpack_require__(179)
var KanjiData = __webpack_require__(183)
var Regex = __webpack_require__(144)
var Utils = __webpack_require__(8)
var dijkstra = __webpack_require__(193)
/**
* Returns UTF8 byte length
*
* @param {String} str Input string
* @return {Number} Number of byte
*/
function getStringByteLength (str) {
return unescape(encodeURIComponent(str)).length
}
/**
* Get a list of segments of the specified mode
* from a string
*
* @param {Mode} mode Segment mode
* @param {String} str String to process
* @return {Array} Array of object with segments data
*/
function getSegments (regex, mode, str) {
var segments = []
var result
while ((result = regex.exec(str)) !== null) {
segments.push({
data: result[0],
index: result.index,
mode: mode,
length: result[0].length
})
}
return segments
}
/**
* Extracts a series of segments with the appropriate
* modes from a string
*
* @param {String} dataStr Input string
* @return {Array} Array of object with segments data
*/
function getSegmentsFromString (dataStr) {
var numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr)
var alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr)
var byteSegs
var kanjiSegs
if (Utils.isKanjiModeEnabled()) {
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr)
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr)
} else {
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr)
kanjiSegs = []
}
var segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs)
return segs
.sort(function (s1, s2) {
return s1.index - s2.index
})
.map(function (obj) {
return {
data: obj.data,
mode: obj.mode,
length: obj.length
}
})
}
/**
* Returns how many bits are needed to encode a string of
* specified length with the specified mode
*
* @param {Number} length String length
* @param {Mode} mode Segment mode
* @return {Number} Bit length
*/
function getSegmentBitsLength (length, mode) {
switch (mode) {
case Mode.NUMERIC:
return NumericData.getBitsLength(length)
case Mode.ALPHANUMERIC:
return AlphanumericData.getBitsLength(length)
case Mode.KANJI:
return KanjiData.getBitsLength(length)
case Mode.BYTE:
return ByteData.getBitsLength(length)
}
}
/**
* Merges adjacent segments which have the same mode
*
* @param {Array} segs Array of object with segments data
* @return {Array} Array of object with segments data
*/
function mergeSegments (segs) {
return segs.reduce(function (acc, curr) {
var prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null
if (prevSeg && prevSeg.mode === curr.mode) {
acc[acc.length - 1].data += curr.data
return acc
}
acc.push(curr)
return acc
}, [])
}
/**
* Generates a list of all possible nodes combination which
* will be used to build a segments graph.
*
* Nodes are divided by groups. Each group will contain a list of all the modes
* in which is possible to encode the given text.
*
* For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
* The group for '12345' will contain then 3 objects, one for each
* possible encoding mode.
*
* Each node represents a possible segment.
*
* @param {Array} segs Array of object with segments data
* @return {Array} Array of object with segments data
*/
function buildNodes (segs) {
var nodes = []
for (var i = 0; i < segs.length; i++) {
var seg = segs[i]
switch (seg.mode) {
case Mode.NUMERIC:
nodes.push([seg,
{ data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
])
break
case Mode.ALPHANUMERIC:
nodes.push([seg,
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
])
break
case Mode.KANJI:
nodes.push([seg,
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
])
break
case Mode.BYTE:
nodes.push([
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
])
}
}
return nodes
}
/**
* Builds a graph from a list of nodes.
* All segments in each node group will be connected with all the segments of
* the next group and so on.
*
* At each connection will be assigned a weight depending on the
* segment's byte length.
*
* @param {Array} nodes Array of object with segments data
* @param {Number} version QR Code version
* @return {Object} Graph of all possible segments
*/
function buildGraph (nodes, version) {
var table = {}
var graph = {'start': {}}
var prevNodeIds = ['start']
for (var i = 0; i < nodes.length; i++) {
var nodeGroup = nodes[i]
var currentNodeIds = []
for (var j = 0; j < nodeGroup.length; j++) {
var node = nodeGroup[j]
var key = '' + i + j
currentNodeIds.push(key)
table[key] = { node: node, lastCount: 0 }
graph[key] = {}
for (var n = 0; n < prevNodeIds.length; n++) {
var prevNodeId = prevNodeIds[n]
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
graph[prevNodeId][key] =
getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -
getSegmentBitsLength(table[prevNodeId].lastCount, node.mode)
table[prevNodeId].lastCount += node.length
} else {
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +
4 + Mode.getCharCountIndicator(node.mode, version) // switch cost
}
}
}
prevNodeIds = currentNodeIds
}
for (n = 0; n < prevNodeIds.length; n++) {
graph[prevNodeIds[n]]['end'] = 0
}
return { map: graph, table: table }
}
/**
* Builds a segment from a specified data and mode.
* If a mode is not specified, the more suitable will be used.
*
* @param {String} data Input data
* @param {Mode | String} modesHint Data mode
* @return {Segment} Segment
*/
function buildSingleSegment (data, modesHint) {
var mode
var bestMode = Mode.getBestModeForData(data)
mode = Mode.from(modesHint, bestMode)
// Make sure data can be encoded
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
throw new Error('"' + data + '"' +
' cannot be encoded with mode ' + Mode.toString(mode) +
'.\n Suggested mode is: ' + Mode.toString(bestMode))
}
// Use Mode.BYTE if Kanji support is disabled
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
mode = Mode.BYTE
}
switch (mode) {
case Mode.NUMERIC:
return new NumericData(data)
case Mode.ALPHANUMERIC:
return new AlphanumericData(data)
case Mode.KANJI:
return new KanjiData(data)
case Mode.BYTE:
return new ByteData(data)
}
}
/**
* Builds a list of segments from an array.
* Array can contain Strings or Objects with segment's info.
*
* For each item which is a string, will be generated a segment with the given
* string and the more appropriate encoding mode.
*
* For each item which is an object, will be generated a segment with the given
* data and mode.
* Objects must contain at least the property "data".
* If property "mode" is not present, the more suitable mode will be used.
*
* @param {Array} array Array of objects with segments data
* @return {Array} Array of Segments
*/
exports.fromArray = function fromArray (array) {
return array.reduce(function (acc, seg) {
if (typeof seg === 'string') {
acc.push(buildSingleSegment(seg, null))
} else if (seg.data) {
acc.push(buildSingleSegment(seg.data, seg.mode))
}
return acc
}, [])
}
/**
* Builds an optimized sequence of segments from a string,
* which will produce the shortest possible bitstream.
*
* @param {String} data Input string
* @param {Number} version QR Code version
* @return {Array} Array of segments
*/
exports.fromString = function fromString (data, version) {
var segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled())
var nodes = buildNodes(segs)
var graph = buildGraph(nodes, version)
var path = dijkstra.find_path(graph.map, 'start', 'end')
var optimizedSegs = []
for (var i = 1; i < path.length - 1; i++) {
optimizedSegs.push(graph.table[path[i]].node)
}
return exports.fromArray(mergeSegments(optimizedSegs))
}
/**
* Splits a string in various segments with the modes which
* best represent their content.
* The produced segments are far from being optimized.
* The output of this function is only used to estimate a QR Code version
* which may contain the data.
*
* @param {string} data Input string
* @return {Array} Array of segments
*/
exports.rawSplit = function rawSplit (data) {
return exports.fromArray(
getSegmentsFromString(data, Utils.isKanjiModeEnabled())
)
}
/***/ }),
/***/ 190:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(146)
function clearCanvas (ctx, canvas, size) {
ctx.clearRect(0, 0, canvas.width, canvas.height)
if (!canvas.style) canvas.style = {}
canvas.height = size
canvas.width = size
canvas.style.height = size + 'px'
canvas.style.width = size + 'px'
}
function getCanvasElement () {
try {
return document.createElement('canvas')
} catch (e) {
throw new Error('You need to specify a canvas element')
}
}
exports.render = function render (qrData, canvas, options) {
var opts = options
var canvasEl = canvas
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
opts = canvas
canvas = undefined
}
if (!canvas) {
canvasEl = getCanvasElement()
}
opts = Utils.getOptions(opts)
var size = (qrData.modules.size + opts.margin * 2) * opts.scale
var ctx = canvasEl.getContext('2d')
var image = ctx.createImageData(size, size)
Utils.qrToImageData(image.data, qrData, opts.margin, opts.scale, opts.color)
clearCanvas(ctx, canvasEl, size)
ctx.putImageData(image, 0, 0)
return canvasEl
}
exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
var opts = options
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
opts = canvas
canvas = undefined
}
if (!opts) opts = {}
var canvasEl = exports.render(qrData, canvas, opts)
var type = opts.type || 'image/png'
var rendererOpts = opts.rendererOpts || {}
return canvasEl.toDataURL(type, rendererOpts.quality)
}
/***/ }),
/***/ 191:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(146)
function getColorAttrib (color) {
return 'fill="rgb(' + [color.r, color.g, color.b].join(',') + ')" ' +
'fill-opacity="' + (color.a / 255).toFixed(2) + '"'
}
exports.render = function render (qrData, options) {
var opts = Utils.getOptions(options)
var size = qrData.modules.size
var data = qrData.modules.data
var qrcodesize = (size + opts.margin * 2) * opts.scale
var xmlStr = '<?xml version="1.0" encoding="utf-8"?>\n'
xmlStr += '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n'
xmlStr += '<svg version="1.1" baseProfile="full"'
xmlStr += ' width="' + qrcodesize + '" height="' + qrcodesize + '"'
xmlStr += ' viewBox="0 0 ' + qrcodesize + ' ' + qrcodesize + '"'
xmlStr += ' xmlns="http://www.w3.org/2000/svg"'
xmlStr += ' xmlns:xlink="http://www.w3.org/1999/xlink"'
xmlStr += ' xmlns:ev="http://www.w3.org/2001/xml-events">\n'
xmlStr += '<rect x="0" y="0" width="' + qrcodesize + '" height="' + qrcodesize + '" ' + getColorAttrib(opts.color.light) + ' />\n'
xmlStr += '<defs><rect id="p" width="' + opts.scale + '" height="' + opts.scale + '" /></defs>\n'
xmlStr += '<g ' + getColorAttrib(opts.color.dark) + '>\n'
for (var i = 0; i < size; i++) {
for (var j = 0; j < size; j++) {
if (!data[i * size + j]) continue
var x = (opts.margin + j) * opts.scale
var y = (opts.margin + i) * opts.scale
xmlStr += '<use x="' + x + '" y="' + y + '" xlink:href="#p" />\n'
}
}
xmlStr += '</g>\n'
xmlStr += '</svg>'
return xmlStr
}
/***/ }),
/***/ 193:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/******************************************************************************
* Created 2008-08-19.
*
* Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
*
* Copyright (C) 2008
* Wyatt Baldwin <self@wyattbaldwin.com>
* All rights reserved
*
* Licensed under the MIT license.
*
* http://www.opensource.org/licenses/mit-license.php
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*****************************************************************************/
var dijkstra = {
single_source_shortest_paths: function(graph, s, d) {
// Predecessor map for each node that has been encountered.
// node ID => predecessor node ID
var predecessors = {};
// Costs of shortest paths from s to all nodes encountered.
// node ID => cost
var costs = {};
costs[s] = 0;
// Costs of shortest paths from s to all nodes encountered; differs from
// `costs` in that it provides easy access to the node that currently has
// the known shortest path from s.
// XXX: Do we actually need both `costs` and `open`?
var open = dijkstra.PriorityQueue.make();
open.push(s, 0);
var closest,
u, v,
cost_of_s_to_u,
adjacent_nodes,
cost_of_e,
cost_of_s_to_u_plus_cost_of_e,
cost_of_s_to_v,
first_visit;
while (!open.empty()) {
// In the nodes remaining in graph that have a known cost from s,
// find the node, u, that currently has the shortest path from s.
closest = open.pop();
u = closest.value;
cost_of_s_to_u = closest.cost;
// Get nodes adjacent to u...
adjacent_nodes = graph[u] || {};
// ...and explore the edges that connect u to those nodes, updating
// the cost of the shortest paths to any or all of those nodes as
// necessary. v is the node across the current edge from u.
for (v in adjacent_nodes) {
if (adjacent_nodes.hasOwnProperty(v)) {
// Get the cost of the edge running from u to v.
cost_of_e = adjacent_nodes[v];
// Cost of s to u plus the cost of u to v across e--this is *a*
// cost from s to v that may or may not be less than the current
// known cost to v.
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
// If we haven't visited v yet OR if the current known cost from s to
// v is greater than the new cost we just found (cost of s to u plus
// cost of u to v across e), update v's cost in the cost list and
// update v's predecessor in the predecessor list (it's now u).
cost_of_s_to_v = costs[v];
first_visit = (typeof costs[v] === 'undefined');
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
costs[v] = cost_of_s_to_u_plus_cost_of_e;
open.push(v, cost_of_s_to_u_plus_cost_of_e);
predecessors[v] = u;
}
}
}
}
if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
throw new Error(msg);
}
return predecessors;
},
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
var nodes = [];
var u = d;
var predecessor;
while (u) {
nodes.push(u);
predecessor = predecessors[u];
u = predecessors[u];
}
nodes.reverse();
return nodes;
},
find_path: function(graph, s, d) {
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
return dijkstra.extract_shortest_path_from_predecessor_list(
predecessors, d);
},
/**
* A very naive priority queue implementation.
*/
PriorityQueue: {
make: function (opts) {
var T = dijkstra.PriorityQueue,
t = {},
key;
opts = opts || {};
for (key in T) {
if (T.hasOwnProperty(key)) {
t[key] = T[key];
}
}
t.queue = [];
t.sorter = opts.sorter || T.default_sorter;
return t;
},
default_sorter: function (a, b) {
return a.cost - b.cost;
},
/**
* Add a new item to the queue and ensure the highest priority element
* is at the front of the queue.
*/
push: function (value, cost) {
var item = {value: value, cost: cost};
this.queue.push(item);
this.queue.sort(this.sorter);
},
/**
* Return the highest priority element in the queue.
*/
pop: function () {
return this.queue.shift();
},
empty: function () {
return this.queue.length === 0;
}
}
};
// node.js module exports
if (true) {
module.exports = dijkstra;
}
/***/ }),
/***/ 215:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _config = __webpack_require__(9);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* v_inviteBind.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 邀请绑定页面
*/
var QRCode = __webpack_require__(174);
_public.iot.ready(init);
function init() {
//通用 按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig(),
extras: [],
uuid: null,
qrCodeDisabled: false
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
console.log(this.extras);
this.setUuid(this.extras.uuid);
qrcodeButtonTap(this);
},
methods: {
getUuid: function getUuid() {
return this.uuid;
},
setUuid: function setUuid(id) {
this.uuid = id;
},
setQrCodeDisabled: function setQrCodeDisabled(boolean) {
this.qrCodeDisabled = boolean;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 重新生成二维码
onQRcodeButtonTap: function 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() {
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
console.log('returnPage');
_public.iot.navigator.back();
}
//tap 重新生成二维码
function qrcodeButtonTap(self) {
self.setQrCodeDisabled(false);
_public.uComponents.showLoading(self);
_public.iot.business.sds.saveqr({
data: {
uuid: self.getUuid()
},
success: function success(response) {
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
var qrKey = response.data.qrKey;
var _data = {
qrKey: qrKey,
lockId: self.extras.lockId,
relId: self.extras.id
};
_data = JSON.stringify(_data);
var qr = self.$refs.qrcode;
QRCode.toCanvas(qr, _data, {
scale: 5,
margin: 2
}, function (error) {
if (error) {
console.log(error);
} else {
console.log('success');
_public.uComponents.hideLoading(self);
qr.style.width = "5.333rem";
qr.style.height = "5.333rem";
console.log(qr.style);
setTimeout(function () {
self.setQrCodeDisabled(true);
}, qrcode_timeout);
}
});
} else {}
},
error: function error(_error) {
console.log(_error);
if (window.iotDebug) {
iotDebug.push('end: 生成二维码失败' + JSON.stringify(_error));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '生成二维码失败');
}
//请求失败
_public.uPublic.openRequestErrorAlert(self);
}
});
setTimeout(function () {
self.setQrCodeDisabled(true);
}, _config2.default.qrcode_timeout);
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 316:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(215);
/***/ }),
/***/ 7:
/***/ (function(module, exports, __webpack_require__) {
var Version = __webpack_require__(145)
var Regex = __webpack_require__(144)
/**
* Numeric mode encodes data from the decimal digit set (0 - 9)
* (byte values 30HEX to 39HEX).
* Normally, 3 data characters are represented by 10 bits.
*
* @type {Object}
*/
exports.NUMERIC = {
id: 'Numeric',
bit: 1 << 0,
ccBits: [10, 12, 14]
}
/**
* Alphanumeric mode encodes data from a set of 45 characters,
* i.e. 10 numeric digits (0 - 9),
* 26 alphabetic characters (A - Z),
* and 9 symbols (SP, $, %, *, +, -, ., /, :).
* Normally, two input characters are represented by 11 bits.
*
* @type {Object}
*/
exports.ALPHANUMERIC = {
id: 'Alphanumeric',
bit: 1 << 1,
ccBits: [9, 11, 13]
}
/**
* In byte mode, data is encoded at 8 bits per character.
*
* @type {Object}
*/
exports.BYTE = {
id: 'Byte',
bit: 1 << 2,
ccBits: [8, 16, 16]
}
/**
* The Kanji mode efficiently encodes Kanji characters in accordance with
* the Shift JIS system based on JIS X 0208.
* The Shift JIS values are shifted from the JIS X 0208 values.
* JIS X 0208 gives details of the shift coded representation.
* Each two-byte character value is compacted to a 13-bit binary codeword.
*
* @type {Object}
*/
exports.KANJI = {
id: 'Kanji',
bit: 1 << 3,
ccBits: [8, 10, 12]
}
/**
* Mixed mode will contain a sequences of data in a combination of any of
* the modes described above
*
* @type {Object}
*/
exports.MIXED = {
bit: -1
}
/**
* Returns the number of bits needed to store the data length
* according to QR Code specifications.
*
* @param {Mode} mode Data mode
* @param {Number} version QR Code version
* @return {Number} Number of bits
*/
exports.getCharCountIndicator = function getCharCountIndicator (mode, version) {
if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)
if (!Version.isValid(version)) {
throw new Error('Invalid version: ' + version)
}
if (version >= 1 && version < 10) return mode.ccBits[0]
else if (version < 27) return mode.ccBits[1]
return mode.ccBits[2]
}
/**
* Returns the most efficient mode to store the specified data
*
* @param {String} dataStr Input data string
* @return {Mode} Best mode
*/
exports.getBestModeForData = function getBestModeForData (dataStr) {
if (Regex.testNumeric(dataStr)) return exports.NUMERIC
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC
else if (Regex.testKanji(dataStr)) return exports.KANJI
else return exports.BYTE
}
/**
* Return mode name as string
*
* @param {Mode} mode Mode object
* @returns {String} Mode name
*/
exports.toString = function toString (mode) {
if (mode && mode.id) return mode.id
throw new Error('Invalid mode')
}
/**
* Check if input param is a valid mode object
*
* @param {Mode} mode Mode object
* @returns {Boolean} True if valid mode, false otherwise
*/
exports.isValid = function isValid (mode) {
return mode && mode.bit && mode.ccBits
}
/**
* Get mode object from its name
*
* @param {String} string Mode name
* @returns {Mode} Mode object
*/
function fromString (string) {
if (typeof string !== 'string') {
throw new Error('Param is not a string')
}
var lcStr = string.toLowerCase()
switch (lcStr) {
case 'numeric':
return exports.NUMERIC
case 'alphanumeric':
return exports.ALPHANUMERIC
case 'kanji':
return exports.KANJI
case 'byte':
return exports.BYTE
default:
throw new Error('Unknown mode: ' + string)
}
}
/**
* Returns mode from a value.
* If value is not a valid mode, returns defaultValue
*
* @param {Mode|String} value Encoding mode
* @param {Mode} defaultValue Fallback value
* @return {Mode} Encoding mode
*/
exports.from = function from (value, defaultValue) {
if (exports.isValid(value)) {
return value
}
try {
return fromString(value)
} catch (e) {
return defaultValue
}
}
/***/ }),
/***/ 8:
/***/ (function(module, exports) {
var toSJISFunction
var CODEWORDS_COUNT = [
0, // Not used
26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
]
/**
* Returns the QR Code size for the specified version
*
* @param {Number} version QR Code version
* @return {Number} size of QR code
*/
exports.getSymbolSize = function getSymbolSize (version) {
if (!version) throw new Error('"version" cannot be null or undefined')
if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
return version * 4 + 17
}
/**
* Returns the total number of codewords used to store data and EC information.
*
* @param {Number} version QR Code version
* @return {Number} Data length in bits
*/
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
return CODEWORDS_COUNT[version]
}
/**
* Encode data with Bose-Chaudhuri-Hocquenghem
*
* @param {Number} data Value to encode
* @return {Number} Encoded value
*/
exports.getBCHDigit = function (data) {
var digit = 0
while (data !== 0) {
digit++
data >>>= 1
}
return digit
}
exports.setToSJISFunction = function setToSJISFunction (f) {
if (typeof f !== 'function') {
throw new Error('"toSJISFunc" is not a valid function.')
}
toSJISFunction = f
}
exports.isKanjiModeEnabled = function () {
return typeof toSJISFunction !== 'undefined'
}
exports.toSJIS = function toSJIS (kanji) {
return toSJISFunction(kanji)
}
/***/ })
},[316]);
//# sourceMappingURL=inviteBind.js.map
\ No newline at end of file
webpackJsonp([19],{
/***/ 216:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _config = __webpack_require__(9);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* v_unlockInfo.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 绑定开锁信息页面
*/
_public.iot.ready(init);
function init() {
//通用 侧滑列表、dialog、loading组件
_public.uPublic.componentsInit(['u-swipe-list', 'u-dialog', 'u-loading']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig(),
unlockInfoList: [],
openLockInfoList: [],
extras: {},
role: null
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
this.role = this.extras.role;
console.log(this.extras);
//获取已绑定的开锁信息
getBindedLockInfo(this);
var self = this;
window.addEventListener('returnPage', function (event) {
console.log("returnPage");
self.unlockInfoList = [];
getBindedLockInfo(self);
});
},
methods: {
getUnlockInfoList: function getUnlockInfoList() {
return this.unlockInfoList;
},
setUnlockInfoList: function setUnlockInfoList(list) {
this.unlockInfoList = list;
},
getOpenLockInfoList: function getOpenLockInfoList() {
return this.openLockInfoList;
},
setOpenLockInfoList: function setOpenLockInfoList(list) {
this.openLockInfoList = list;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
onAddTap: function onAddTap() {
//tap 添加
addTap(this);
},
//tap list row btn
onUnlockInfoListButtonTap: function onUnlockInfoListButtonTap(value, buttonValue) {
unlockInfoListButtonTap(this, value, buttonValue);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
unlockInfoList: {
initParam: {
// class: 'custom-unlockInfo-list',
list: [],
class: 'custom-swipe-list',
// list: [
// {title: '指纹1', subtitle: 'ID:123456', buttons: [{'text': Vue.t('unlockInfo.setHijack')},{'text': Vue.t('unlockInfo.cancelAssociated')}]},
// {title: '指纹2', subtitle: 'ID:123456', buttons: [{'text': Vue.t('unlockInfo.setHijack')},{'text': Vue.t('unlockInfo.cancelAssociated')}]},
// {title: '劫持指纹1', subtitle: 'ID:123456', buttons: [{'text': Vue.t('unlockInfo.cancelHijack')},{'text': Vue.t('unlockInfo.cancelAssociated')}]}
// ],
tip: Vue.t('unlockInfo.noInfoTip')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 添加
function addTap(self) {
_public.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) {
_public.uComponents.showLoading(self);
_public.iot.business.api.sendCustom('lock/getBindOpen', {
data: {
rel_id: self.extras.id,
device_id: self.extras.deviceId
},
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
console.log(data);
self.setOpenLockInfoList(data);
var list = [];
var j = 1;
var lastMode = null;
for (var i = 0; i < data.length; i++) {
if (data[i].mode != lastMode) {
j = 1;
}
list[i] = {
title: Vue.t('unlockInfo.' + _config2.default.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') }]
};
j++;
lastMode = data[i].mode;
}
self.setUnlockInfoList(self.getUnlockInfoList().concat(list));
console.log(self.getUnlockInfoList());
//更新列表数据
_public.uComponents.changeSwipeList(self, self.getUnlockInfoList());
} else {
_public.uComponents.changeSwipeList(self, []);
}
},
error: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 获取已绑定的开锁信息失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取已绑定的开锁信息失败');
// }
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
function unlockInfoListButtonTap(self, value, buttonValue) {
//设为劫持&取消劫持
if (buttonValue == '0') {
if (self.getOpenLockInfoList()[value].mode == 2) {
_public.uComponents.openConfirm(self, Vue.t('unlockInfo.setHijackTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.confirm'), callback: function callback() {
console.log("设为劫持");
_public.uComponents.showLoading(self);
_public.iot.business.api.sendCustom('lock/updateBindLog', {
data: {
mode: 20,
id: self.getOpenLockInfoList()[value].id,
rel_id: self.extras.id
},
success: function success(response) {
console.log(response);
_public.uComponents.openAlert(self, Vue.t('unlockInfo.setHijackSuccess'), {
text: Vue.t('dialog.confirm'), callback: function callback() {
self.unlockInfoList = [];
getBindedLockInfo(self);
}
});
},
error: function error(_error2) {
console.log(_error2);
// if(window.iotDebug){
// iotDebug.push('end: 设为劫持失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'设为劫持失败');
// }
_public.uComponents.openAlert(self, Vue.t('unlockInfo.setHijackFailue'), {
text: Vue.t('dialog.confirm'), callback: function callback() {}
});
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
} });
} else {
_public.uComponents.openConfirm(self, Vue.t('unlockInfo.cancelHijackTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.confirm'), callback: function callback() {
console.log("取消劫持");
_public.uComponents.showLoading(self);
_public.iot.business.api.sendCustom('lock/updateBindLog', {
data: {
mode: 2,
id: self.getOpenLockInfoList()[value].id,
rel_id: self.extras.id
},
success: function success(response) {
console.log(response);
_public.uComponents.openAlert(self, Vue.t('unlockInfo.cancelHijackSuccess'), {
text: Vue.t('dialog.confirm'), callback: function callback() {
self.unlockInfoList = [];
getBindedLockInfo(self);
}
});
},
error: function error(_error3) {
console.log(_error3);
// if(window.iotDebug){
// iotDebug.push('end: 取消劫持失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'取消劫持失败');
// }
_public.uComponents.openAlert(self, Vue.t('unlockInfo.cancelHijackFailue'), {
text: Vue.t('dialog.confirm'), callback: function callback() {}
});
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
} });
}
}
//取消关联
else if (buttonValue == '1') {
console.log(self.getOpenLockInfoList()[value]);
_public.uComponents.openConfirm(self, Vue.t('unlockInfo.cancelAssociatedTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.confirm'), callback: function callback() {
_public.uComponents.showLoading(self);
_public.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: function success(response) {
console.log(response);
_public.uComponents.openAlert(self, Vue.t('unlockInfo.cancelAssociatedSuccess'), {
text: Vue.t('dialog.confirm'), callback: function callback() {
self.unlockInfoList = [];
getBindedLockInfo(self);
}
});
},
error: function error(_error4) {
console.log(_error4);
// if(window.iotDebug){
// iotDebug.push('end: 取消关联失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'取消关联失败');
// }
_public.uComponents.openAlert(self, Vue.t('unlockInfo.cancelAssociatedFailue'), {
text: Vue.t('dialog.confirm'), callback: function callback() {}
});
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
} });
}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 317:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(216);
/***/ })
},[317]);
//# sourceMappingURL=unlockInfo.js.map
\ No newline at end of file
webpackJsonp([18],{
/***/ 217:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_forgetPassword.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 忘记密码页面
*/
function init() {
//通用 input、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-button', 'u-dialog', 'u-loading']);
var app = new Vue({
data: {
numberTel: null,
textCode: null,
codeDisabledFlag: false,
textPassword: null,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
methods: {
getCodeDisabledFlag: function getCodeDisabledFlag() {
return this.codeDisabledFlag;
},
setCodeDisabledFlag: function setCodeDisabledFlag(boolean) {
this.codeDisabledFlag = boolean;
},
onTelChange: function onTelChange(number) {
telChange(this, number);
},
onCodeChange: function onCodeChange(text) {
codeChange(this, text);
},
onPasswordChange: function onPasswordChange(text) {
passwordChange(this, text);
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 获取验证码
onCodeButtonTap: function onCodeButtonTap() {
codeButtonTap(this);
},
//tap 确定
onConfirmButtonTap: function onConfirmButtonTap() {
confirmButtonTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
telInput: {
initParam: {
class: 'custom-text',
icon: '&#xe6e8;',
placeholder: Vue.t('forgetPassword.telInputTip'),
maxlength: 11,
minlength: 11
}
},
codeInput: {
initParam: {
class: 'custom-code-text',
icon: '&#xe805;',
placeholder: Vue.t('forgetPassword.codeInputTip')
}
},
//获取验证码 button 参数
codeButton: {
initParam: {
class: 'custom-code-button',
text: Vue.t('btn.getCode')
}
},
passwordInput: {
initParam: {
class: 'custom-password-text',
icon: '&#xe64d;',
placeholder: Vue.t('forgetPassword.passwordInputTip'),
type: 'password',
maxlength: 6,
minlength: 6
}
},
//确定 button 参数
confirmButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.confirm')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
function telChange(self, number) {
self.numberTel = number;
console.log('telChange: ' + self.numberTel);
}
function codeChange(self, text) {
self.textCode = text;
console.log('codeChange: ' + self.textCode);
}
//tap 获取验证码
function codeButtonTap(self) {
self.setCodeDisabledFlag(true);
}
function passwordChange(self, text) {
self.textPassword = text;
console.log('passwordChange: ' + self.textPassword);
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 确定
function confirmButtonTap() {
_public.iot.navigator.back();
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 318:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(217);
/***/ })
},[318]);
//# sourceMappingURL=forgetPassword.js.map
\ No newline at end of file
webpackJsonp([17],{
/***/ 218:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_index.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 引导页面
*/
function init() {
//通用 dialog、loading组件
_public.uPublic.componentsInit(['u-dialog', 'u-loading', 'u-button']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig(),
clientId: null,
showLoginButtonFlag: true
},
mounted: function mounted() {
if (window.iotDebug) {
iotDebug.push('start: Debug');
}
var clientInfo = plus.push.getClientInfo();
this.setClientId(clientInfo.clientid);
var self = this;
if (plus.os.name == 'Android') {
_public.iot.permission.checkPermission(['READ_EXTERNAL_STORAGE'], function (res) {
console.log('success', res);
loginButtonTap(self);
}, function (err) {
console.log('error', err);
});
} else {
loginButtonTap(self);
}
},
methods: {
getShowLoginButtonFlag: function getShowLoginButtonFlag() {
return this.showLoginButtonFlag;
},
setShowLoginButtonFlag: function setShowLoginButtonFlag(flag) {
this.showLoginButtonFlag = flag;
},
onLoginButtonTap: function onLoginButtonTap() {
_public.uComponents.showLoading(this);
loginButtonTap(this);
},
getClientId: function getClientId() {
return this.clientId;
},
setClientId: function setClientId(id) {
this.clientId = id;
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
//登录 button 参数
loginButton: {
initParam: {
class: 'custom-guide-button',
text: Vue.t('btn.guideLogin')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
function loginButtonTap(self) {
// if(window.iotDebug){
// iotDebug.push('start: initSDSLogin');
// }
// window.SDSPlugin.login({},(res)=>{
// console.log(res);
// var data = uPublic.checkResponseData(res.data);
// if(data){
// cloudsLogin(self, data.UserID);
// }
// },(err)=>{
// console.log(err);
// })
_public.iot.business.sds.login({
data: {
userinfo: {}
},
success: function success(response) {
// alert(JSON.stringify(response));
console.log(response);
if (window.iotDebug) {
iotDebug.push('end: SDSloginSuccees');
}
// alert(JSON.stringify(response));
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
self.setShowLoginButtonFlag(false);
if (data.hasOwnProperty('UserID')) {
console.log("sds登陆成功了");
cloudsLogin(self, data.UserID);
}
} else {}
},
error: function error(_error) {
console.log(_error);
// alert(JSON.stringify(error));
if (window.iotDebug) {
iotDebug.push('end: sds登陆失败' + JSON.stringify(_error));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, 'sds登陆失败');
}
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
function cloudsLogin(self, id) {
_public.uComponents.showLoading(self);
if (window.iotDebug) {
iotDebug.push('start: cloudsLogin');
}
_public.iot.business.api.send('user/sds_login', {
// iot.business.user.simpleLogin({
data: {
username: id,
clienId: self.getClientId()
},
success: function success(response) {
if (window.iotDebug) {
iotDebug.push('end: cloudsLogin');
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '登陆流程时间');
}
var data = _public.uPublic.checkResponseData(response.data);
var infoArray = [];
if (data) {
infoArray.push(['utoken', data.utoken]);
infoArray.push(['userinfo', data]);
_public.iot.business.websql.setMaps(infoArray, function () {
_public.iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
}, function (error) {
console.log(error);
});
plus.navigator.closeSplashscreen();
}
},
error: function error(_error2) {
console.log(_error2);
if (window.iotDebug) {
iotDebug.push('end: 云端登陆失败' + JSON.stringify(_error2));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '云端登陆失败');
}
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
// uComponents.hideLoading(self);
}
}, false);
// });
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 319:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(218);
/***/ })
},[319]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
webpackJsonp([16],{
/***/ 219:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_login.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 登录页面
*/
function init() {
//通用 input、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-button', 'u-dialog', 'u-loading']);
var app = new Vue({
data: {
numberTel: null,
textPassword: null,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {
_public.iot.business.sds.init({
data: {
oa: true
},
success: function success(response) {
console.log(response);
_public.iot.business.user.login({
data: {
sds: true
},
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
_public.iot.business.user.login({
data: {
username: data.UserId,
pwd: data.UserId
},
success: function success(response) {
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
_public.iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
} else {}
},
error: function error(_error) {},
complete: function complete() {}
});
} else {}
},
error: function error(_error2) {
console.log(_error2);
},
complete: function complete() {}
});
},
error: function error(_error3) {
console.log(_error3);
}
});
},
methods: {
onTelChange: function onTelChange(number) {
telChange(this, number);
},
onPasswordChange: function onPasswordChange(text) {
passwordChange(this, text);
},
//tap 登录
onLoginButtonTap: function onLoginButtonTap() {
loginButtonTap();
},
//tap 快速注册
onRegisterTap: function onRegisterTap() {
registerTap();
},
//tap 忘记密码
onForgetPasswordTap: function onForgetPasswordTap() {
forgetPasswordTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
telInput: {
initParam: {
class: 'custom-text',
icon: '&#xe6e8;',
placeholder: Vue.t('login.telInputTip'),
maxlength: 11,
minlength: 11
}
},
passwordInput: {
initParam: {
class: 'custom-password-text',
icon: '&#xe64d;',
placeholder: Vue.t('login.passwordInputTip'),
type: 'password'
}
},
//登录 button 参数
loginButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.login')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
function telChange(self, number) {
self.numberTel = number;
console.log('telChange: ' + self.numberTel);
}
function passwordChange(self, text) {
self.textPassword = text;
console.log('passwordChange: ' + self.textPassword);
}
//tap 登录
function loginButtonTap() {
_public.iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
}
//tap 快速注册
function registerTap() {}
// iot.navigator.openWindow({
// url: './register.html',
// id: 'register'
// });
//tap 忘记密码
function forgetPasswordTap() {
_public.iot.navigator.openWindow({
url: './forgetPassword.html',
id: 'forgetPassword'
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 320:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(219);
/***/ })
},[320]);
//# sourceMappingURL=login.js.map
\ No newline at end of file
webpackJsonp([15],{
/***/ 220:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_register.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 注册页面
*/
function init() {
//通用 input、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-button', 'u-dialog', 'u-loading']);
var app = new Vue({
data: {
numberTel: null,
textCode: null,
codeDisabledFlag: false,
textPassword: null,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
methods: {
getCodeDisabledFlag: function getCodeDisabledFlag() {
return this.codeDisabledFlag;
},
setCodeDisabledFlag: function setCodeDisabledFlag(boolean) {
this.codeDisabledFlag = boolean;
},
onTelChange: function onTelChange(number) {
telChange(this, number);
},
onCodeChange: function onCodeChange(text) {
codeChange(this, text);
},
onPasswordChange: function onPasswordChange(text) {
passwordChange(this, text);
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 获取验证码
onCodeButtonTap: function onCodeButtonTap() {
codeButtonTap(this);
},
//tap 注册
onRegisterButtonTap: function onRegisterButtonTap() {
registerButtonTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
telInput: {
initParam: {
class: 'custom-text',
icon: '&#xe6e8;',
placeholder: Vue.t('register.telInputTip'),
maxlength: 11,
minlength: 11
}
},
codeInput: {
initParam: {
class: 'custom-code-text',
icon: '&#xe805;',
placeholder: Vue.t('register.codeInputTip')
}
},
//获取验证码 button 参数
codeButton: {
initParam: {
class: 'custom-code-button',
text: Vue.t('btn.getCode')
}
},
passwordInput: {
initParam: {
class: 'custom-password-text',
icon: '&#xe64d;',
placeholder: Vue.t('register.passwordInputTip'),
type: 'password',
maxlength: 6,
minlength: 6
}
},
//注册 button 参数
registerButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.register')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
function telChange(self, number) {
self.numberTel = number;
console.log('telChange: ' + self.numberTel);
}
function codeChange(self, text) {
self.textCode = text;
console.log('codeChange: ' + self.textCode);
}
//tap 获取验证码
function codeButtonTap(self) {
self.setCodeDisabledFlag(true);
}
function passwordChange(self, text) {
self.textPassword = text;
console.log('passwordChange: ' + self.textPassword);
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 注册
function registerButtonTap() {
_public.iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 321:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(220);
/***/ })
},[321]);
//# sourceMappingURL=register.js.map
\ No newline at end of file
webpackJsonp([27],{
/***/ 238:
/***/ (function(module, exports) {
"use strict";
throw new Error("Module build failed: Error: ENOENT: no such file or directory, open 'D:\\git_zhu\\doorlock\\dev\\src\\view\\login\\v_unlockInfo.js'");
/***/ }),
/***/ 280:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(238);
/***/ })
},[280]);
//# sourceMappingURL=unlockInfo.js.map
\ No newline at end of file
webpackJsonp([14],{
/***/ 221:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _config = __webpack_require__(9);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* v_editNickname.js
* Version: 0.1
* User: zjx
* Date: 2017-09-29
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 引导页面
*/
_public.iot.ready(init);
function init() {
//通用 dialog、loading组件
_public.uPublic.componentsInit(['u-dialog', 'u-loading', 'u-text']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
//配置组件
textNickName: _public.iot.navigator.getExtras().nickname,
textErrorTip: null,
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
methods: {
getTextNickName: function getTextNickName() {
return this.textNickName;
},
setTextNickName: function setTextNickName(text) {
this.textNickName = this;
},
onSaveTap: function onSaveTap() {
saveTap(this);
},
onBackTap: function onBackTap() {
backTap();
},
onNicknameChange: function onNicknameChange(text) {
nicknameChange(this, text);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
nameInput: {
initParam: {
class: 'custom-editNickname-text',
placeholder: Vue.t('editNickname.nickNameInputTip'),
maxlength: _config2.default.input.maxlength
}
},
//保存 button 参数
saveButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.save')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//保存昵称
function saveTap(self) {
if (self.textNickName == null || self.textNickName.trim() == '') {
self.textErrorTip = Vue.t('editNickname.nickNameInputTip');
} else {
_public.uComponents.showLoading(self);
_public.iot.business.user.setInfo({
data: {
nickname: self.textNickName,
head: ''
},
success: function success(response) {
if (response.data = 'success') {
_public.iot.navigator.aback();
}
},
error: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 保存用户昵称失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'保存用户昵称失败');
// }
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
}
_public.iot.navigator.aback = function () {
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
_public.iot.navigator.back();
};
//返回上一页
function backTap() {
_public.iot.navigator.aback();
}
function nicknameChange(self, text) {
self.textNickName = text;
self.textErrorTip = '';
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 322:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(221);
/***/ })
},[322]);
//# sourceMappingURL=editNickname.js.map
\ No newline at end of file
webpackJsonp([13],{
/***/ 222:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_editPassword.js
* Version: 0.1
* User: zjx
* Date: 2017-09-29
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 引导页面
*/
function init() {
//通用 dialog、loading组件
_public.uPublic.componentsInit(['u-dialog', 'u-loading', 'u-text']);
var app = new Vue({
data: {
//配置组件
textNewPassword: null,
textOldPassword: null,
textOldPasswordAgain: null,
textErrorTip: '密码不能为空',
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
methods: {
onSaveTap: function onSaveTap() {
saveTap();
},
onBackTap: function onBackTap() {
backTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
newPassword: {
initParam: {
class: 'custom-editPassword-text',
placeholder: Vue.t('editPassword.newPasswordInputTip')
}
},
oldPassword: {
initParam: {
class: 'custom-editPassword-text',
placeholder: Vue.t('editPassword.oldPasswordInputTip')
}
},
oldPasswordAgain: {
initParam: {
class: 'custom-editPassword-text',
placeholder: Vue.t('editPassword.oldPasswordInputTipAgain')
}
},
//保存 button 参数
saveButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.save')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//保存昵称
function saveTap() {}
//返回上一页
function backTap() {
_public.iot.navigator.back();
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 323:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(222);
/***/ })
},[323]);
//# sourceMappingURL=editPassword.js.map
\ No newline at end of file
webpackJsonp([12],{
/***/ 223:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(4);
_public.iot.ready(init); /**
* v_index.js
* Version: 0.1
* User: zjx
* Date: 2017-09-26
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 引导页面
*/
function init() {
//通用 dialog、loading组件
_public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading']);
_public.uPublic.closeSlideBack();
var app = new Vue({
data: {
//配置组件
nickname: null,
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {
var self = this;
getInfo(this);
window.addEventListener('returnPage', function (event) {
console.log("in");
getInfo(self);
});
var wv = _public.iot.navigator.getCurrentWebView();
console.log(wv);
},
methods: {
//tap 修改昵称
onEditNicknameTap: function onEditNicknameTap() {
editNicknameTap(this);
},
//tap 修改密码
onEditPasswordTap: function onEditPasswordTap() {
editPasswordTap();
},
onBackTap: function onBackTap() {
backTap();
},
//tap 退出系统
onLogoutButtonTap: function onLogoutButtonTap() {
logoutButtonTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
logoutButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.logout')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap 修改昵称
function editNicknameTap(self) {
_public.iot.navigator.openWindow({
url: '../myInfo/editNickname.html',
id: 'editNickname',
extras: {
nickname: self.nickname
}
});
}
//tap 修改密码
function editPasswordTap() {
_public.iot.navigator.openWindow({
url: '../myInfo/editPassword.html',
id: 'editPassword'
});
}
function backTap() {
_public.iot.navigator.back();
}
function getInfo(self) {
_public.iot.business.user.getInfo({
success: function success(response) {
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
console.log(data);
self.nickname = data.nickname;
} else {}
},
error: function error(_error) {
console.log(_error);
// if(window.iotDebug){
// iotDebug.push('end: 获取用户信息'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取用户信息');
// }
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {}
});
}
//tap 退出系统
function logoutButtonTap(self) {
_public.uComponents.openConfirm(self, Vue.t('myInfo.logoutDialogTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.confirm'), callback: function callback() {
_public.iot.business.user.logout({
data: {
sds: true
},
success: function success(response) {
_public.iot.business.websql.delMaps(['utoken', 'userinfo'], function (response) {
console.log(response);
}, function (error) {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 清除tocken失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'清除tocken失败');
// }
_public.uPublic.openRequestErrorAlert(self);
});
_public.iot.storage.delMaps(['notifyTime', 'alarmTime', 'openTime'], function (response) {
console.log(response);
}, function () {});
_public.iot.navigator.openWindow({
url: '../login/index.html',
id: 'login'
});
var wvs = plus.webview.all();
for (var i = 0; i < wvs.length - 1; i++) {
plus.webview.close(wvs[i]);
}
},
error: function error(_error2) {
console.log(_error2);
if (window.iotDebug) {
iotDebug.push('end: 退出登陆失败' + JSON.stringify(_error2));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, '退出登陆失败');
}
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
console.log("complete");
}
});
} });
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
/***/ }),
/***/ 324:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(223);
/***/ })
},[324]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
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