Commit d31ac793 by 朱建香

1012

parent 3d49faac
......@@ -7,8 +7,6 @@ web/lib/dist
web/view/*.map
web/view/*.js
web/view/*/*.map
web/view/*/*.js
webpackJsonp([26],{
/***/ 136:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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__(1)["default"]))
/***/ }),
/***/ 252:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(136);
/***/ })
},[252]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
webpackJsonp([25],{
/***/ 137:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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() {
openScanCode(this);
},
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) {
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
//扫描成功
var qrKey = data.result;
//绑定设备
_public.iot.business.sds.scanqr({
data: {
qrKey: qrKey
},
success: function success(response) {
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
console.log(response);
_public.uComponents.openAlert(self, Vue.t('addDevice.bindSuccess'), {
text: Vue.t('btn.confirm'), callback: function callback() {
_public.iot.navigator.openWindow({
url: '../device/',
id: 'device'
});
}
});
} else {}
},
error: function error(_error) {
//请求失败
_public.uPublic.openRequestErrorAlert(self);
}
});
} else {}
},
error: function error(_error2) {
console.log(_error2);
//请求失败
_public.uPublic.openRequestErrorAlert(self);
}
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 253:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(137);
/***/ })
},[253]);
//# sourceMappingURL=scanCodeAdd.js.map
\ No newline at end of file
webpackJsonp([24],{
/***/ 138:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof 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页面
*/
var _public = __webpack_require__(2);
_public.iot.ready(init);
function init() {
//通用 input、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-button', 'u-comm-loading', 'u-dialog', 'u-loading']);
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: 'loading',
status: 0
}
}
};
}
function resolve(self) {
_public.iot.business.sds.getSSId({
success: function success(response) {
console.log(response);
var data = JSON.parse(response);
self.textWiFiName = data.ssid;
console.log(self.textWiFiName);
},
error: function error(_error) {
console.log(_error);
_public.uPublic.openRequestErrorAlert(self);
}
});
}
function passwordChange(self, text) {
self.textPassword = text;
console.log('passwordChange: ' + self.textPassword);
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 连接
function connectButtonTap(self) {
// uComponents.showCommstatusloading(self);
// setTimeout(function(){
// self.setTextLoading(Vue.t('commstatusLoading.connectSuccess'));
// setTimeout(function(){
// //绑定成功
// self.setStatus(1);
// self.setTextLoading(Vue.t('commstatusLoading.bindSuccess'));
// //绑定失败
// //self.setStatus(2);
// //self.setTextLoading(Vue.t('commstatusLoading.bindFailed'));
// //uComponents.changeCommstatusButtonText(self,Vue.t('btn.reBound'));
// },3000);
// },3000);
console.log(self.getTextWiFiName());
// self.setTextPassword('macro_scope00');
console.log(self.getTextPassword());
if (self.getTextPassword() == null || self.getTextPassword().trim() == '') {
self.setTextErrorTip(Vue.t('wifiAdd.passwordInputTip'));
} else {
_public.iot.business.sds.findWifi({
data: {
model: 'UGEN_LIVING_ELECTRICALBLANKET_THM_BL',
ssid: self.getTextWiFiName(),
wifiPwd: self.getTextPassword(),
timeout: 20000
},
success: function success(response) {
console.log("findWifi");
console.log(response);
if (response.data == 'onProvisioning') {
//wifi链接中
_public.uComponents.showCommLoading(self);
} else if (response.data == 'provisioned success') {
//wifi连接成功,停止连接wifi
// iot.business.sds.stopFindWifi({
// success: (response) => {},
// error: (error) => {}
// });
}
},
error: function error(_error2) {
console.log(_error2);
}
});
var deviceId = null;
_public.iot.business.sds.findDevices({
success: function success(response) {
console.log("findDevices");
console.log(response);
var parameters = {};
// let data = "DeviceInfo:[model = THM_LIVING_ELECTRICALBLANKET_TH_1507,xModel = null,mac = B0:F8:93:10:D5:09,sn = B0F89310D509,uuid = null,connectMode = alibaba_smartconfig_v3,supportRouterProvision = false,productName = null,gatewayUuid = null,deviceType = null,alinkJoinVersion = Bind, ]"
// console.log(data);
if (response.data) {
var info = response.data.split(':[');
if (info[1]) {
var query = info[1].split(',');
console.log(query);
for (var i = 0; i < query.length; i++) {
var pari = query[i].split(' = ');
console.log(pari);
parameters[pari[0]] = pari[1];
}
console.log(parameters.sn);
}
}
if (parameters.sn) {
deviceId = parameters.sn;
}
console.log(typeof deviceId === 'undefined' ? 'undefined' : _typeof(deviceId));
if (response.data == "joined success") {
//云端绑定
_public.iot.business.device.bind({
data: {
product_id: 2,
device_id: deviceId,
// mac: parameters.mac,
nickname: ''
},
success: function success(response) {
console.log(response);
//连接成功
_public.uComponents.changeCommLoadingStatusAndText(self, 1, '绑定成功');
self.setStatus(1);
},
error: function error(_error3) {
console.log(_error3);
},
complete: function complete() {}
});
//连接成功
// uComponents.changeCommLoadingStatusAndText(self, 1, '绑定成功');
// self.setStatus(1);
// //停止查找设备
_public.iot.business.sds.stopFindDevices({
success: function success(response) {},
error: function error(_error4) {}
});
} else if (response.data == "fail") {
//连接失败
_public.uComponents.changeCommLoadingStatusAndText(self, 2, '绑定失败');
self.setStatus(2);
_public.uComponents.changeCommButtonText('请重新绑定');
//停止查找设备
_public.iot.business.sds.stopFindDevices({
success: function success(response) {},
error: function error(_error5) {}
});
}
},
error: function error(_error6) {
console.log(_error6);
}
});
}
}
//tap loading button
function commLoadingButtonTap(self) {
if (self.getStatus() == 1) {
//绑定成功
_public.uComponents.hideCommLoading(self);
_public.iot.navigator.openWindow({
url: '../device/',
id: 'device'
});
} else if (self.getStatus() == 2) {
//绑定失败
_public.uComponents.hideCommLoading(self);
}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 254:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(138);
/***/ })
},[254]);
//# sourceMappingURL=wifiAdd.js.map
\ No newline at end of file
webpackJsonp([23],{
/***/ 139:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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() {},
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__(1)["default"]))
/***/ }),
/***/ 255:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(139);
/***/ })
},[255]);
//# sourceMappingURL=wifiAddHelp.js.map
\ No newline at end of file
webpackJsonp([5],{
/***/ 140:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _vueRouter = __webpack_require__(249);
var _vueRouter2 = _interopRequireDefault(_vueRouter);
var _public = __webpack_require__(2);
var _r_bindUserHelp = __webpack_require__(225);
var _r_bindUserHelp2 = _interopRequireDefault(_r_bindUserHelp);
var _r_bindUser = __webpack_require__(224);
var _r_bindUser2 = _interopRequireDefault(_r_bindUser);
var _r_userList = __webpack_require__(226);
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__(1)["default"]))
/***/ }),
/***/ 196:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _public = __webpack_require__(2);
//通用 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__(1)["default"]))
/***/ }),
/***/ 197:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _public = __webpack_require__(2);
//通用 按钮、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__(1)["default"]))
/***/ }),
/***/ 198:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _public = __webpack_require__(2);
//通用 侧滑列表、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__(1)["default"]))
/***/ }),
/***/ 224:
/***/ (function(module, exports, __webpack_require__) {
var Component = __webpack_require__(3)(
/* script */
__webpack_require__(196),
/* template */
__webpack_require__(246),
/* 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
/***/ }),
/***/ 225:
/***/ (function(module, exports, __webpack_require__) {
var Component = __webpack_require__(3)(
/* script */
__webpack_require__(197),
/* template */
__webpack_require__(244),
/* 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
/***/ }),
/***/ 226:
/***/ (function(module, exports, __webpack_require__) {
var Component = __webpack_require__(3)(
/* script */
__webpack_require__(198),
/* template */
__webpack_require__(229),
/* 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
/***/ }),
/***/ 229:
/***/ (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)
}
}
/***/ }),
/***/ 244:
/***/ (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)
}
}
/***/ }),
/***/ 246:
/***/ (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)
}
}
/***/ }),
/***/ 249:
/***/ (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__(125)))
/***/ }),
/***/ 256:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(140);
/***/ })
},[256]);
//# 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.
webpackJsonp([22],{
/***/ 145:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /**
* v_remoteOpendoor.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() {
var _methods;
//通用 input、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-button', 'u-commstatus-loading', 'u-dialog', 'u-loading']);
var app = new Vue({
data: {
textPassword: null,
textErrorTip: null,
textLoading: 'loading...',
status: 0,
//配置组件
componentsConfig: initComponentsConfig(),
//设备uuid
uuid: null
},
mounted: function mounted() {
resolve(this);
},
methods: (_methods = {
getTextPassword: function getTextPassword() {
return this.textPassword;
},
setTextPassword: function setTextPassword(pwd) {
this.textPassword = pwd;
},
setTextErrorTip: function setTextErrorTip(tip) {
this.textErrorTip = tip;
},
getTextLoading: function getTextLoading() {
return this.textLoading;
},
setTextLoading: function setTextLoading(text) {
this.textLoading = text;
},
getStatus: function getStatus() {
return this.status;
},
setStatus: function setStatus(value) {
this.status = value;
},
onPasswordChange: function onPasswordChange(text) {
passwordChange(this, text);
}
}, _defineProperty(_methods, 'onPasswordChange', function onPasswordChange(text) {
passwordChange(this, text);
}), _defineProperty(_methods, 'getUuid', function getUuid() {
return this.uuid;
}), _defineProperty(_methods, 'setUuid', function setUuid(id) {
this.uuid = id;
}), _defineProperty(_methods, 'onBackTap', function onBackTap() {
backTap();
}), _defineProperty(_methods, 'onConfirmButtonTap', function onConfirmButtonTap() {
confirmButtonTap(this);
}), _methods)
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
passwordInput: {
initParam: {
class: 'custom-text',
icon: '&#xe64d;',
placeholder: Vue.t('remoteOpendoor.passwordInputTip')
}
},
//确定 button 参数
confirmButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.confirm')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
},
ucommstatusloading: {
initParam: {
class: 'custom-commstatus-loading',
buttonText: Vue.t('btn.confirm')
}
}
};
}
function resolve(self) {
var extras = _public.iot.navigator.getExtras();
self.setUuid(extras.uuid);
console.log(self.getUuid());
}
function passwordChange(self, text) {
self.setTextPassword(text);
self.setTextErrorTip('');
console.log('passwordChange: ' + self.textPassword);
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 确定
function confirmButtonTap(self) {
console.log(self.getTextPassword());
if (self.getTextPassword() == null || self.getTextPassword().trim() == '') {
self.setTextErrorTip(Vue.t('remoteOpendoor.error.noPasswordTip'));
} else {
_public.uComponents.showLoading(self);
_public.iot.business.sds.setDeviceStatus({
data: {
uuid: self.getUuid(),
setParams: {
'lock_action': {
'value': '0'
// 'remote_open_door': {
// 'value': self.getTextPassword()
// }
} }
},
success: function success(response) {
console.log(response);
_public.uComponents.openAlert(self, Vue.t('remoteOpendoor.openDoorSuccess'), {
text: Vue.t('dialog.confirm'), callback: function callback() {
//返回首页
_public.iot.navigator.back();
}
});
},
error: function error(_error) {
console.log(_error);
_public.uComponents.openAlert(self, Vue.t('remoteOpendoor.openDoorFailure'), {
text: Vue.t('dialog.confirm'), callback: function callback() {}
});
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 261:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(145);
/***/ })
},[261]);
//# sourceMappingURL=remoteOpendoor.js.map
\ No newline at end of file
webpackJsonp([21],{
/***/ 146:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_public.iot.ready(init); /**
* v_editName.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: {
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')
}
},
//保存 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.setNickname({
data: {
device_id: self.extras.deviceId,
nickname: 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() {
var opener = plus.webview.currentWebview().opener();
var view = plus.webview.getWebviewById(opener.id);
console.log(view);
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
console.log('returnPage');
_public.iot.navigator.back();
}
});
}
},
error: function error(_error) {
console.log(_error);
_public.uComponents.hideLoading(self);
_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__(1)["default"]))
/***/ }),
/***/ 262:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(146);
/***/ })
},[262]);
//# sourceMappingURL=editName.js.map
\ No newline at end of file
webpackJsonp([6],{
/***/ 147:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
var _components = __webpack_require__(201);
/**
* v_index.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() {
//通用 按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading']);
//项目 list组件
_public.uPublic.componentsExtend(['grid-list']);
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig(),
//提示框是否显示
stateShowFlag: false,
//我的门锁
doorlock: null,
//提示框显示文字
showMsg: '',
textNickname: null,
extras: {},
unbindSucceess: false
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
console.log(this.extras);
//获取门锁
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;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 修改设备昵称
onEditNameTap: function onEditNameTap() {
editNameTap(this);
},
//tap 解绑门锁
onUnbindDoorlockButtonTap: function onUnbindDoorlockButtonTap() {
unbindDoorlockButtonTap(this);
},
//tap 隐藏提示框
onUnbindStateDialogTap: function onUnbindStateDialogTap() {
unbindStateDialogTap(this);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
unbindDoorlockButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.unbindDoorlock')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
function getDoorlockInfo(self) {
_public.uComponents.showLoading(self);
_public.iot.business.api.send('device/getList', {
data: {
sds: false,
device_id: self.extras.deviceId,
product_id: 2,
parent_id: 0,
start_id: 0,
number: 10
},
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
self.setDoorlock(response.data[0]);
self.setTextNickname(self.getDoorlock().nickname);
console.log(self.getDoorlock());
}
},
error: function error(_error) {
//请求失败
_public.uPublic.openRequestErrorAlert(self);
console.log(_error);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
}, true);
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 修改设备昵称
function editNameTap(self) {
_public.iot.navigator.openWindow({
url: './editName.html',
id: 'editName',
extras: {
deviceId: self.getDoorlock().id,
nickname: self.getTextNickname()
}
});
}
//tap 解绑门锁
function unbindDoorlockButtonTap(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() {
// uComponents.showLoading(self);
// //云端解绑
// iot.business.device.unbind({
// data: {
// device_id: self.getDoorlock().id
// },
// success: (response) => {
// console.log(response);
_public.iot.business.device.unbind({
data: {
sds: true,
uuid: self.extras.uuid,
device_id: self.getDoorlock().id
},
success: function success(response) {
console.log(response);
self.setStateShowFlag(true);
self.setShowMsg(Vue.t('doorlockUser.unbindSuccess'));
self.setUnbindSucceess(true);
},
error: function error(_error2) {
console.log(_error2);
self.setStateShowFlag(false);
self.setShowMsg(Vue.t('doorlockUser.unbindFailue'));
self.setUnbindSucceess(false);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
// },
// error: (error) => {
// console.log(error);
// self.setStateShowFlag(true);
// self.setShowMsg(Vue.t('doorlockUser.unbindFailue'));
// self.setUnbindSucceess(false);
// },
// complete: () => {
// uComponents.hideLoading(self);
// }
// });
} });
}
//tap 隐藏提示框
function unbindStateDialogTap(self) {
self.setStateShowFlag(false);
if (self.getUnbindSucceess) {
_public.iot.navigator.openWindow({
url: '../device/',
id: 'device'
});
}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 201:
/***/ (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;
/***/ }),
/***/ 263:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(147);
/***/ })
},[263]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
webpackJsonp([4],{
/***/ 119:
/***/ (function(module, exports, __webpack_require__) {
var Version = __webpack_require__(130)
var Regex = __webpack_require__(129)
/**
* 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
}
}
/***/ }),
/***/ 120:
/***/ (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)
}
/***/ }),
/***/ 123:
/***/ (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__(127)
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
/***/ }),
/***/ 126:
/***/ (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
}
}
/***/ }),
/***/ 127:
/***/ (function(module, exports) {
var toString = {}.toString;
module.exports = Array.isArray || function (arr) {
return toString.call(arr) == '[object Array]';
};
/***/ }),
/***/ 128:
/***/ (function(module, exports, __webpack_require__) {
var ECLevel = __webpack_require__(126)
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
}
}
/***/ }),
/***/ 129:
/***/ (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)
}
/***/ }),
/***/ 130:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(120)
var ECCode = __webpack_require__(128)
var ECLevel = __webpack_require__(126)
var Mode = __webpack_require__(119)
var isArray = __webpack_require__(127)
// 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
}
/***/ }),
/***/ 131:
/***/ (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
}
}
}
/***/ }),
/***/ 148:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
/**
* 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__(163);
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);
//请求失败
_public.uPublic.openRequestErrorAlert(self);
}
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 163:
/***/ (function(module, exports, __webpack_require__) {
var QRCode = __webpack_require__(176)
var CanvasRenderer = __webpack_require__(179)
var SvgRenderer = __webpack_require__(180)
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
}
}
/***/ }),
/***/ 164:
/***/ (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__(120).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
}
/***/ }),
/***/ 165:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(119)
/**
* 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
/***/ }),
/***/ 166:
/***/ (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
/***/ }),
/***/ 167:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(123)
/**
* 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
/***/ }),
/***/ 168:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(123)
var Mode = __webpack_require__(119)
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
/***/ }),
/***/ 169:
/***/ (function(module, exports, __webpack_require__) {
var getSymbolSize = __webpack_require__(120).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]
]
}
/***/ }),
/***/ 170:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(120)
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
}
/***/ }),
/***/ 171:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(123)
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]]
}
/***/ }),
/***/ 172:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(119)
var Utils = __webpack_require__(120)
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
/***/ }),
/***/ 173:
/***/ (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
}
/***/ }),
/***/ 174:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(119)
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
/***/ }),
/***/ 175:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(123)
var GF = __webpack_require__(171)
/**
* 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
}
/***/ }),
/***/ 176:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(123)
var Utils = __webpack_require__(120)
var ECLevel = __webpack_require__(126)
var BitBuffer = __webpack_require__(166)
var BitMatrix = __webpack_require__(167)
var AlignmentPattern = __webpack_require__(164)
var FinderPattern = __webpack_require__(169)
var MaskPattern = __webpack_require__(173)
var ECCode = __webpack_require__(128)
var ReedSolomonEncoder = __webpack_require__(177)
var Version = __webpack_require__(130)
var FormatInfo = __webpack_require__(170)
var Mode = __webpack_require__(119)
var Segments = __webpack_require__(178)
var isArray = __webpack_require__(127)
/**
* 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)
}
/***/ }),
/***/ 177:
/***/ (function(module, exports, __webpack_require__) {
var Buffer = __webpack_require__(123)
var Polynomial = __webpack_require__(175)
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
/***/ }),
/***/ 178:
/***/ (function(module, exports, __webpack_require__) {
var Mode = __webpack_require__(119)
var NumericData = __webpack_require__(174)
var AlphanumericData = __webpack_require__(165)
var ByteData = __webpack_require__(168)
var KanjiData = __webpack_require__(172)
var Regex = __webpack_require__(129)
var Utils = __webpack_require__(120)
var dijkstra = __webpack_require__(203)
/**
* 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())
)
}
/***/ }),
/***/ 179:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(131)
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)
}
/***/ }),
/***/ 180:
/***/ (function(module, exports, __webpack_require__) {
var Utils = __webpack_require__(131)
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
}
/***/ }),
/***/ 203:
/***/ (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;
}
/***/ }),
/***/ 264:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(148);
/***/ })
},[264]);
//# sourceMappingURL=qrcode.js.map
\ No newline at end of file
webpackJsonp([20],{
/***/ 149:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_public.iot.ready(init); /**
* v_addUnlockInfo.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 绑定开锁信息页面
*/
function init() {
//通用 select、按钮、dialog、loading组件
_public.uPublic.componentsInit(['u-select', 'u-button', 'u-dialog', 'u-loading']);
var app = new Vue({
data: {
recordSelectIndex: 0,
recordSelectList: [],
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
methods: {
//tap <
onBackTap: function onBackTap() {
backTap();
},
onRecordSelectChange: function onRecordSelectChange(value) {
recordSelectChange(this, value);
},
//tap 添加
onAddButtonTap: function onAddButtonTap() {
addButtonTap();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
recordSelect: {
initParam: {
class: 'custom-select',
list: [{ value: 1, title: '16:35', subtitle: 'ID:001' }, { value: 2, title: '15:33', subtitle: 'ID:002' }, { value: 3, title: '15:06', subtitle: 'ID:007' }],
pagesize: Number.MAX_VALUE
}
},
//添加 button 参数
addButton: {
initParam: {
class: 'custom-button',
text: Vue.t('btn.add')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
function recordSelectChange(self, value) {
self.recordSelectIndex = value;
console.log('recordSelectChange:' + self.recordSelectIndex);
}
//tap 添加
function addButtonTap() {
_public.iot.navigator.back();
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 265:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(149);
/***/ })
},[265]);
//# sourceMappingURL=addUnlockInfo.js.map
\ No newline at end of file
webpackJsonp([19],{
/***/ 150:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_public.iot.ready(init); /**
* v_addUser.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* 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: {
textName: null,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
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')
}
},
//确定 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/addUser', {
data: {
device_id: self.extras.deviceId
},
success: function success(response) {
console.log(response);
_public.uComponents.openAlert(self, Vue.t('addUser.addUserSuccess'), {
text: Vue.t('btn.confirm'), callback: function callback() {
console.log("添加用户成功");
_public.iot.storage.getMap('isFirstAdd', function (res) {
if (res) {
//跳转到门锁用户界面
_public.iot.navigator.openWindow({
url: './doorlockUser.html',
id: 'doorlockUser'
});
} else {}
}, function () {});
}
});
},
error: function error(_error) {
console.log(_error);
_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);
}
});
}
}
function showGuide() {}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 266:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(150);
/***/ })
},[266]);
//# sourceMappingURL=addUser.js.map
\ No newline at end of file
webpackJsonp([18],{
/***/ 151:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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']);
var app = new Vue({
data: {
userInfo: {
image: '../../resources/image/gray_unbindHead_icon.png',
role: 1,
title: '我是个用户二号',
subtitle: ''
},
bindShowFlag: true,
unbindShowFlag: false,
stateShowFlag: false,
guideShowFlag: false,
guideStep1ShowFlag: false,
guideStep2ShowFlag: false,
guideStep3ShowFlag: false,
guideStep4ShowFlag: false,
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
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;
},
//tap <
onBackTap: function onBackTap() {
backTap();
},
onEditNameTap: function onEditNameTap() {
editNameTap();
},
//tap 邀请绑定
onBindTap: function onBindTap() {
bindTap();
},
//tap 解绑
onUnbindButtonTap: function onUnbindButtonTap() {
unbindButtonTap(this);
},
//tap 绑定开锁信息
onBindUnlockInfoTap: function onBindUnlockInfoTap() {
bindUnlockInfoTap();
},
//tap 历史开门记录
onOpendoorRecordTap: function onOpendoorRecordTap() {
opendoorRecordTap();
},
//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'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
function editNameTap() {
_public.iot.navigator.openWindow({
url: './editName.html',
id: 'editName'
});
}
//tap 邀请绑定
function bindTap() {
_public.iot.navigator.openWindow({
url: './inviteBind.html',
id: 'inviteBind'
});
}
//tap 解绑
function unbindButtonTap(self) {
_public.uComponents.openConfirm(self, Vue.t('doorlockUsers.unbindDialogTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.unbind'), callback: function callback() {
self.setStateShowFlag(true);
} });
}
function unbindStateDialogTap(self) {
self.setStateShowFlag(false);
self.setBindShowFlag(true);
self.setUnbindShowFlag(false);
}
//tap 绑定开锁信息
function bindUnlockInfoTap() {
_public.iot.navigator.openWindow({
url: './unlockInfo.html',
id: 'unlockInfo'
});
}
//tap 历史开门记录
function opendoorRecordTap() {
_public.iot.navigator.openWindow({
url: '../device/opendoorRecord.html',
id: 'opendoorRecord'
});
}
//tap 删除该用户
function deleteUserButtonTap(self) {
_public.uComponents.openConfirm(self, Vue.t('doorlockUsers.deleteUserDialogTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.delete'), callback: function callback() {} });
}
//tap 下一步
function nextButtonTap(self) {
self.setGuideStep1ShowFlag(false);
self.setGuideStep2ShowFlag(false);
self.setGuideStep3ShowFlag(true);
self.setGuideStep4ShowFlag(true);
}
//tap 我知道了
function iSeeButtonTap(self) {
self.setGuideShowFlag(false);
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 267:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(151);
/***/ })
},[267]);
//# sourceMappingURL=doorlockUser.js.map
\ No newline at end of file
webpackJsonp([17],{
/***/ 152:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_public.iot.ready(init); /**
* v_editName.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c) 2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 修改名称页面
*/
function init() {
//通用 input、dialog、loading组件
_public.uPublic.componentsInit(['u-text', 'u-dialog', 'u-loading']);
var app = new Vue({
data: {
textName: '我是个用户二号',
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
methods: {
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 保存
onSaveTap: function onSaveTap() {
saveTap();
},
onNameChange: function onNameChange(text) {
nameChange(this, text);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
nameInput: {
initParam: {
class: 'custom-editName-text',
placeholder: Vue.t('editName.nameInputTip')
}
},
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 保存
function saveTap() {
_public.iot.navigator.back();
}
function nameChange(self, text) {
self.textName = text;
console.log('nameChange: ' + self.textName);
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 268:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(152);
/***/ })
},[268]);
//# sourceMappingURL=editName.js.map
\ No newline at end of file
webpackJsonp([16],{
/***/ 153:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _config = __webpack_require__(124);
var _config2 = _interopRequireDefault(_config);
var _public = __webpack_require__(2);
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']);
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig(),
//用户列表
userList: [],
userListIndex: null,
loadShowFlag: false,
loadFlag: false,
loadText: 'loading',
pagesize: 10,
tip: '无数据',
extras: {}
},
mounted: function mounted() {
this.extras = _public.iot.navigator.getExtras();
//获取用户列表
getUserList(this);
//
},
methods: {
getUserList: function getUserList() {
return this.userList;
},
setUserList: function setUserList(list) {
this.userList = list;
},
onBackTap: function onBackTap() {
backTap();
},
onAddUserTap: function onAddUserTap() {
addUserTap();
},
setLoadShowFlag: function setLoadShowFlag(number) {
this.loadShowFlag = number >= this.pagesize;
},
onSwipeLeftRow: function onSwipeLeftRow(index) {
swipeLeftRow(this, index);
},
onSwipeRightRow: function onSwipeRightRow() {
swipeRightRow(this);
},
onTapLoad: function onTapLoad() {
tapLoad();
},
onTapUserList: function onTapUserList(index) {
_onTapUserList(this, index);
},
onTapButton: function onTapButton(buttonIndex) {
tapButton(buttonIndex);
},
changeUserList: function changeUserList(list) {
_changeUserList(this, list);
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//获取用户列表
function getUserList(self) {
console.log(self.extras);
_public.uComponents.showLoading(self);
_public.iot.business.device.getUsers({
data: {
device_id: self.extras.deviceId
},
success: function success(response) {
console.log(response);
// let data = uPublic.checkResponseData(response.data);
// if(data){
// let list = [];
// for(let i = 0; i < data.length ; i++){
// list[i] = {
// value: data.userId,
// role: data.role,
// image: data.role == 0 ? '../../resources/image/green_admin_icon.png' : data.name == null ? '../../resources/image/gray_unbindHead_icon.png' : '../../resources/image/green_bindhead_icon.png',
// title: data.nickname,
// subTitle: data.name
// }
// }
var list = [{ value: 1, role: 0, image: '../../resources/image/green_admin_icon.png', title: '我是用户', subtitle: "MM" }, { value: 1, role: 1, image: '../../resources/image/green_bindhead_icon.png', title: '我是用户', subtitle: "MM" }];
self.setUserList(self.getUserList().concat(list));
console.log(self.getUserList());
// if(data.length > 0){
// self.setStartId(data[data.length-1].id);
// }
// }
},
error: function error(_error) {
console.log(_error);
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
//返回上一页
function backTap() {
_public.iot.navigator.back();
}
//添加用户
function addUserTap() {
_public.iot.navigator.openWindow({
url: '../doorlockUsers/addUser.html',
id: 'addUser'
});
}
// 向左滑动用户列表,修改用户列表下标
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'
});
if (self.userListIndex != null) {
self.userListIndex = null;
}
}
//点击加载更多
function tapLoad() {
if (!self.loadFlag) {
self.loadText = 'loading';
self.loadFlag = true;
//再次发送获取用户列表请求
}
}
//点击按钮
function tapButton(buttonIndex) {
console.log(buttonIndex);
}
// 修改userList列表
function _changeUserList(self, list) {
self.setLoadShowFlag(list.length - self.swipeList.length);
self.userList = list;
self.$nextTick(function () {
self.loadText = '点击加载更多';
self.loadFlag = false;
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 269:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(153);
/***/ })
},[269]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
webpackJsonp([15],{
/***/ 154:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_public.iot.ready(init); /**
* v_inviteBind.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']);
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
methods: {
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 重新生成二维码
onQRcodeButtonTap: function onQRcodeButtonTap() {
qrcodeButtonTap();
}
}
}).$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.back();
}
//tap 重新生成二维码
function qrcodeButtonTap() {
alert('重新生成二维码');
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 270:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(154);
/***/ })
},[270]);
//# sourceMappingURL=inviteBind.js.map
\ No newline at end of file
webpackJsonp([14],{
/***/ 155:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_public.iot.ready(init); /**
* v_unlockInfo.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-dialog', 'u-loading']);
var app = new Vue({
data: {
unlockInfoList: [{ value: 1, title: '指纹1', rightText: 123456 }, { value: 2, title: '指纹2', rightText: 123456 }],
loadShowFlag: false,
loadFlag: false,
loadText: Vue.t('scroll.clickToLoadMore'),
pagesize: 10,
tip: Vue.t('unlockInfo.noInfoTip'),
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {},
methods: {
//tap <
onBackTap: function onBackTap() {
backTap();
},
//tap 添加
onAddTap: function onAddTap() {
addTap();
},
onTapLoad: function onTapLoad() {
tapLoad();
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
dialog: {
initParam: {
class: 'custom-dialog'
}
},
loading: {
initParam: {
class: 'custom-loading'
}
}
};
}
//tap <
function backTap() {
_public.iot.navigator.back();
}
//tap 添加
function addTap() {
_public.iot.navigator.openWindow({
url: './addUnlockInfo.html',
id: 'addUnlockInfo'
});
}
//点击加载更多
function tapLoad() {
if (!self.loadFlag) {
self.loadText = Vue.t('scroll.loading');
self.loadFlag = true;
//再次发送获取用户列表请求
}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 271:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(155);
/***/ })
},[271]);
//# sourceMappingURL=unlockInfo.js.map
\ No newline at end of file
webpackJsonp([13],{
/***/ 156:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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__(1)["default"]))
/***/ }),
/***/ 272:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(156);
/***/ })
},[272]);
//# sourceMappingURL=forgetPassword.js.map
\ No newline at end of file
webpackJsonp([12],{
/***/ 157:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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']);
var app = new Vue({
data: {
//配置组件
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {
// setTimeout(function(){
// iot.navigator.openWindow({
// url: './login.html',
// id: 'login'
// });
// },2000)
var self = this;
},
methods: {
onLoginButtonTap: function onLoginButtonTap() {
loginButtonTap(this);
}
}
}).$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) {
_public.uComponents.showLoading(self);
_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) {
console.log("云端登陆");
cloudsLogin(self, data.UserID);
// iot.navigator.openWindow({
// url: '../device/',
// id: 'device'
// });
} else {}
},
error: function error(_error) {
console.log(_error);
//请求失败
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {}
});
},
error: function error(_error2) {
console.log(_error2);
//请求失败
_public.uPublic.openRequestErrorAlert(self);
}
});
}
//云端登陆
function cloudsLogin(self, id) {
_public.iot.business.user.autoLogin({
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
_public.uComponents.hideLoading(self);
_public.iot.navigator.openWindow({
url: '../device/',
id: 'device'
});
} else {}
},
error: function error(_error3) {
console.log(_error3);
_public.iot.business.user.login({
data: {
username: id,
pwd: id
},
success: function success(response) {
console.log(response);
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
_public.uComponents.hideLoading(self);
_public.iot.navigator.openWindow({
url: '../device/',
id: 'device'
});
} else {}
},
error: function error(_error4) {
console.log(_error4);
//不存在此用户
// if(code == 10002){
//用户注册
_public.iot.business.user.reg({
data: {
username: id,
pwd: id,
vcode: id
},
success: function success(response) {
console.log(response);
//注册成功
var data = _public.uPublic.checkResponseData(response.data);
if (data) {
_public.uComponents.hideLoading(self);
_public.iot.navigator.openWindow({
url: '../device/',
id: 'device'
});
} else {}
},
error: function error(_error5) {
console.log(_error5);
//注册失败
_public.uComponents.openAlert(self, Vue.t('login.failure'), {
text: Vue.t('dialog.confirm'), callback: function callback() {
plus.webview.currentWebview().reload();
}
});
},
complete: function complete() {}
});
// }
//请求失败
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {}
});
},
complete: function complete() {}
});
//
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 273:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(157);
/***/ })
},[273]);
//# sourceMappingURL=index.js.map
\ No newline at end of file
webpackJsonp([11],{
/***/ 158:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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/',
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/',
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__(1)["default"]))
/***/ }),
/***/ 274:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(158);
/***/ })
},[274]);
//# sourceMappingURL=login.js.map
\ No newline at end of file
webpackJsonp([10],{
/***/ 159:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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/',
id: 'device'
});
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 275:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(159);
/***/ })
},[275]);
//# sourceMappingURL=register.js.map
\ No newline at end of file
webpackJsonp([9],{
/***/ 160:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_public.iot.ready(init); /**
* v_editNickname.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: {
//配置组件
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')
}
},
//保存 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: '',
info: {}
},
success: function success(response) {
if (response.data = 'success') {
_public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {
// name: 'zhu'
});
_public.iot.navigator.back();
}
},
error: function error(_error) {
console.log(_error);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
}
}
//返回上一页
function backTap() {
_public.iot.navigator.back();
}
function nicknameChange(self, text) {
self.textNickName = text;
self.textErrorTip = '';
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 276:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(160);
/***/ })
},[276]);
//# sourceMappingURL=editNickname.js.map
\ No newline at end of file
webpackJsonp([8],{
/***/ 161:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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__(1)["default"]))
/***/ }),
/***/ 277:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(161);
/***/ })
},[277]);
//# sourceMappingURL=editPassword.js.map
\ No newline at end of file
webpackJsonp([7],{
/***/ 162:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {
var _public = __webpack_require__(2);
_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']);
var app = new Vue({
data: {
//配置组件
nickname: 'bank',
componentsConfig: initComponentsConfig()
},
mounted: function mounted() {
var self = this;
getInfo(this);
window.addEventListener('returnPage', function (event) {
console.log("in");
getInfo(self);
});
},
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) {},
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);
});
_public.iot.navigator.openWindow({
url: '../login/',
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) {},
complete: function complete() {
console.log("complete");
}
});
} });
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))
/***/ }),
/***/ 278:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(162);
/***/ })
},[278]);
//# 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