webpackJsonp([19],{

/***/ 216:
/***/ (function(module, exports, __webpack_require__) {

"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {

var _config = __webpack_require__(9);

var _config2 = _interopRequireDefault(_config);

var _public = __webpack_require__(4);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
* v_unlockInfo.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c)  2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 绑定开锁信息页面
*/
_public.iot.ready(init);
function init() {
				//通用 侧滑列表、dialog、loading组件
				_public.uPublic.componentsInit(['u-swipe-list', 'u-dialog', 'u-loading']);
				_public.uPublic.closeSlideBack();
				var app = new Vue({
								data: {
												//配置组件
												componentsConfig: initComponentsConfig(),
												unlockInfoList: [],
												openLockInfoList: [],
												extras: {},
												role: null
								},
								mounted: function mounted() {
												this.extras = _public.iot.navigator.getExtras();
												this.role = this.extras.role;
												console.log(this.extras);
												//获取已绑定的开锁信息
												getBindedLockInfo(this);
												var self = this;
												window.addEventListener('returnPage', function (event) {
																console.log("returnPage");
																self.unlockInfoList = [];
																getBindedLockInfo(self);
												});
								},

								methods: {
												getUnlockInfoList: function getUnlockInfoList() {
																return this.unlockInfoList;
												},
												setUnlockInfoList: function setUnlockInfoList(list) {
																this.unlockInfoList = list;
												},
												getOpenLockInfoList: function getOpenLockInfoList() {
																return this.openLockInfoList;
												},
												setOpenLockInfoList: function setOpenLockInfoList(list) {
																this.openLockInfoList = list;
												},

												//tap <
												onBackTap: function onBackTap() {
																backTap();
												},
												onAddTap: function onAddTap() {
																//tap 添加
																addTap(this);
												},

												//tap list row btn 
												onUnlockInfoListButtonTap: function onUnlockInfoListButtonTap(value, buttonValue) {
																unlockInfoListButtonTap(this, value, buttonValue);
												}
								}
				}).$mount('#app');
}

//配置组件参数
function initComponentsConfig() {
				return {
								unlockInfoList: {
												initParam: {
																//              class: 'custom-unlockInfo-list',
																list: [],
																class: 'custom-swipe-list',
																//              list: [
																//                  {title: '指纹1', subtitle: 'ID:123456', buttons: [{'text': Vue.t('unlockInfo.setHijack')},{'text': Vue.t('unlockInfo.cancelAssociated')}]},
																//                  {title: '指纹2', subtitle: 'ID:123456', buttons: [{'text': Vue.t('unlockInfo.setHijack')},{'text': Vue.t('unlockInfo.cancelAssociated')}]},
																//                  {title: '劫持指纹1', subtitle: 'ID:123456', buttons: [{'text': Vue.t('unlockInfo.cancelHijack')},{'text': Vue.t('unlockInfo.cancelAssociated')}]}
																//              ],
																tip: Vue.t('unlockInfo.noInfoTip')
												}
								},
								dialog: {
												initParam: {
																class: 'custom-dialog'
												}
								},
								loading: {
												initParam: {
																class: 'custom-loading'
												}
								}
				};
}

//tap <
function backTap() {
				_public.iot.navigator.back();
}

//tap 添加 
function addTap(self) {
				_public.iot.navigator.openWindow({
								url: './addUnlockInfo.html',
								id: 'addUnlockInfo',
								extras: {
												deviceId: self.extras.deviceId,
												id: self.extras.id
								}
				});
}

//点击加载更多
function tapLoad() {
				if (!self.loadFlag) {
								self.loadText = Vue.t('scroll.loading');
								self.loadFlag = true;
								//再次发送获取用户列表请求
				}
}

//获取已绑定的开锁信息
function getBindedLockInfo(self) {
				_public.uComponents.showLoading(self);
				_public.iot.business.api.sendCustom('lock/getBindOpen', {
								data: {
												rel_id: self.extras.id,
												device_id: self.extras.deviceId
								},
								success: function success(response) {
												console.log(response);
												var data = _public.uPublic.checkResponseData(response.data);
												if (data) {
																console.log(data);
																self.setOpenLockInfoList(data);
																var list = [];
																var j = 1;
																var lastMode = null;
																for (var i = 0; i < data.length; i++) {
																				if (data[i].mode != lastMode) {
																								j = 1;
																				}
																				list[i] = {
																								title: Vue.t('unlockInfo.' + _config2.default.openDoorMode[data[i].mode] + '') + j + '',
																								subtitle: 'ID:' + data[i].openId,
																								buttons: self.extras.role ? [] : [{ 'text': data[i].mode == 20 ? Vue.t('unlockInfo.cancelHijack') : data[i].mode == 2 ? Vue.t('unlockInfo.setHijack') : '' }, { 'text': Vue.t('unlockInfo.cancelAssociated') }]
																				};
																				j++;
																				lastMode = data[i].mode;
																}
																self.setUnlockInfoList(self.getUnlockInfoList().concat(list));
																console.log(self.getUnlockInfoList());
																//更新列表数据
																_public.uComponents.changeSwipeList(self, self.getUnlockInfoList());
												} else {
																_public.uComponents.changeSwipeList(self, []);
												}
								},
								error: function error(_error) {
												console.log(_error);
												//  		if(window.iotDebug){
												//              iotDebug.push('end: 获取已绑定的开锁信息失败'+JSON.stringify(error));
												//         	}
												//	    	if (window.iotDebug) {
												//              iotDebug.upload(iot,'获取已绑定的开锁信息失败');
												//          }
												_public.uPublic.openRequestErrorAlert(self);
								},
								complete: function complete() {
												_public.uComponents.hideLoading(self);
								}
				});
}
function unlockInfoListButtonTap(self, value, buttonValue) {
				//设为劫持&取消劫持
				if (buttonValue == '0') {
								if (self.getOpenLockInfoList()[value].mode == 2) {
												_public.uComponents.openConfirm(self, Vue.t('unlockInfo.setHijackTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.confirm'), callback: function callback() {
																				console.log("设为劫持");
																				_public.uComponents.showLoading(self);
																				_public.iot.business.api.sendCustom('lock/updateBindLog', {
																								data: {
																												mode: 20,
																												id: self.getOpenLockInfoList()[value].id,
																												rel_id: self.extras.id
																								},
																								success: function success(response) {
																												console.log(response);
																												_public.uComponents.openAlert(self, Vue.t('unlockInfo.setHijackSuccess'), {
																																text: Vue.t('dialog.confirm'), callback: function callback() {
																																				self.unlockInfoList = [];
																																				getBindedLockInfo(self);
																																}
																												});
																								},
																								error: function error(_error2) {
																												console.log(_error2);
																												//							if(window.iotDebug){
																												//				                iotDebug.push('end: 设为劫持失败'+JSON.stringify(error));
																												//				           	}
																												//					    	if (window.iotDebug) {
																												//				                iotDebug.upload(iot,'设为劫持失败');
																												//				            }
																												_public.uComponents.openAlert(self, Vue.t('unlockInfo.setHijackFailue'), {
																																text: Vue.t('dialog.confirm'), callback: function callback() {}
																												});
																								},
																								complete: function complete() {
																												_public.uComponents.hideLoading(self);
																								}
																				});
																} });
								} else {
												_public.uComponents.openConfirm(self, Vue.t('unlockInfo.cancelHijackTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.confirm'), callback: function callback() {
																				console.log("取消劫持");
																				_public.uComponents.showLoading(self);
																				_public.iot.business.api.sendCustom('lock/updateBindLog', {
																								data: {
																												mode: 2,
																												id: self.getOpenLockInfoList()[value].id,
																												rel_id: self.extras.id
																								},
																								success: function success(response) {
																												console.log(response);
																												_public.uComponents.openAlert(self, Vue.t('unlockInfo.cancelHijackSuccess'), {
																																text: Vue.t('dialog.confirm'), callback: function callback() {
																																				self.unlockInfoList = [];
																																				getBindedLockInfo(self);
																																}
																												});
																								},
																								error: function error(_error3) {
																												console.log(_error3);
																												//							if(window.iotDebug){
																												//				                iotDebug.push('end: 取消劫持失败'+JSON.stringify(error));
																												//				           	}
																												//					    	if (window.iotDebug) {
																												//				                iotDebug.upload(iot,'取消劫持失败');
																												//				            }
																												_public.uComponents.openAlert(self, Vue.t('unlockInfo.cancelHijackFailue'), {
																																text: Vue.t('dialog.confirm'), callback: function callback() {}
																												});
																								},
																								complete: function complete() {
																												_public.uComponents.hideLoading(self);
																								}
																				});
																} });
								}
				}
				//取消关联
				else if (buttonValue == '1') {
												console.log(self.getOpenLockInfoList()[value]);
												_public.uComponents.openConfirm(self, Vue.t('unlockInfo.cancelAssociatedTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.confirm'), callback: function callback() {
																				_public.uComponents.showLoading(self);
																				_public.iot.business.api.sendCustom('lock/unbindOpenLog', {
																								data: {
																												device_id: self.extras.deviceId,
																												mode: self.getOpenLockInfoList()[value].mode,
																												openId: self.getOpenLockInfoList()[value].openId,
																												rel_id: self.extras.id
																								},
																								success: function success(response) {
																												console.log(response);
																												_public.uComponents.openAlert(self, Vue.t('unlockInfo.cancelAssociatedSuccess'), {
																																text: Vue.t('dialog.confirm'), callback: function callback() {
																																				self.unlockInfoList = [];
																																				getBindedLockInfo(self);
																																}
																												});
																								},
																								error: function error(_error4) {
																												console.log(_error4);
																												//						if(window.iotDebug){
																												//			                iotDebug.push('end: 取消关联失败'+JSON.stringify(error));
																												//			           	}
																												//				    	if (window.iotDebug) {
																												//			                iotDebug.upload(iot,'取消关联失败');
																												//			            }
																												_public.uComponents.openAlert(self, Vue.t('unlockInfo.cancelAssociatedFailue'), {
																																text: Vue.t('dialog.confirm'), callback: function callback() {}
																												});
																								},
																								complete: function complete() {
																												_public.uComponents.hideLoading(self);
																								}
																				});
																} });
								}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))

/***/ }),

/***/ 314:
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(216);


/***/ })

},[314]);
//# sourceMappingURL=unlockInfo.js.map