webpackJsonp([11],{

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

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

var _config = __webpack_require__(127);

var _config2 = _interopRequireDefault(_config);

var _public = __webpack_require__(4);

var _components = __webpack_require__(244);

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

_public.iot.ready(init); /**
                         * v_index.js
                         * Version: 0.1
                         * User: wy
                         * Date: 2017-09-06
                         * Copyright(c)  2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
                         * 门锁管理页面
                         */

function init() {
  //通用 按钮、dialog、loading组件
  _public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading', 'u-switch']);
  //项目 list组件
  _public.uPublic.componentsExtend(['grid-list']);
  var app = new Vue({
    data: {
      //配置组件
      componentsConfig: initComponentsConfig(),
      //提示框是否显示
      stateShowFlag: false,
      //我的门锁
      doorlock: null,
      //提示框显示文字
      showMsg: '',
      textNickname: null,
      extras: {},
      unbindSucceess: false,
      //门铃消息推送
      valueDoorbell: true,
      //报警消息推送
      valueAlarm: true,
      //开发消息推送
      valueOpendoor: true,
      role: null,
      valueIsClear: true,
      unbindShowDialog: false
    },
    mounted: function mounted() {
      this.extras = _public.iot.navigator.getExtras();
      console.log(this.extras);
      this.role = this.extras.role;
      //获取门锁
      getDoorlockInfo(this);
      //监听returnPage返回事件，重新获取最新数据
      var self = this;
      window.addEventListener('returnPage', function (event) {
        console.log("returnPage");
        getDoorlockInfo(self);
      });
    },

    methods: {
      getStateShowFlag: function getStateShowFlag() {
        return this.stateShowFlag;
      },
      setStateShowFlag: function setStateShowFlag(flag) {
        this.stateShowFlag = flag;
      },
      getDoorlock: function getDoorlock() {
        return this.doorlock;
      },
      setDoorlock: function setDoorlock(obj) {
        this.doorlock = obj;
      },
      getShowMsg: function getShowMsg() {
        return this.showMsg;
      },
      setShowMsg: function setShowMsg(msg) {
        this.showMsg = msg;
      },
      getTextNickname: function getTextNickname() {
        return this.textNickname;
      },
      setTextNickname: function setTextNickname(text) {
        this.textNickname = text;
      },
      getUnbindSucceess: function getUnbindSucceess() {
        return this.unbindSucceess;
      },
      setUnbindSucceess: function setUnbindSucceess(bool) {
        this.unbindSucceess = bool;
      },
      getValueDoorbell: function getValueDoorbell() {
        return this.valueDoorbell;
      },
      setValueDoorbell: function setValueDoorbell(value) {
        this.valueDoorbell = value;
      },
      getValueAlarm: function getValueAlarm() {
        return this.valueAlarm;
      },
      setValueAlarm: function setValueAlarm(value) {
        this.valueAlarm = value;
      },
      getValueOpendoor: function getValueOpendoor() {
        return this.valueOpendoor;
      },
      setValueOpendoor: function setValueOpendoor(value) {
        this.valueOpendoor = value;
      },
      getValueIsClear: function getValueIsClear() {
        return this.valueIsClear;
      },
      setValueIsClear: function setValueIsClear(value) {
        this.valueIsClear = value;
      },
      getUnbindShowDialog: function getUnbindShowDialog() {
        return this.unbindShowDialog;
      },
      setUnbindShowDialog: function setUnbindShowDialog(flag) {
        this.unbindShowDialog = flag;
      },

      //tap <
      onBackTap: function onBackTap() {
        backTap();
      },

      //tap 修改设备昵称
      onEditNameTap: function onEditNameTap() {
        editNameTap(this);
      },

      //tap 解绑门锁
      onUnbindDoorlockButtonTap: function onUnbindDoorlockButtonTap() {
        unbindDoorlockButtonTap(this);
      },

      //tap 隐藏提示框
      onUnbindStateDialogTap: function onUnbindStateDialogTap() {
        unbindStateDialogTap(this);
      },
      onDoorbellSwitchTap: function onDoorbellSwitchTap(value) {
        doorbellSwitchTap(this, value);
      },
      onAlarmSwitchTap: function onAlarmSwitchTap(value) {
        alarmSwitchTap(this, value);
      },
      onOpendoorSwitchTap: function onOpendoorSwitchTap(value) {
        opendoorSwitchTap(this, value);
      },
      onCancelTap: function onCancelTap() {
        cancelTap(this);
      },
      onConfirmTap: function onConfirmTap() {
        confirmTap(this);
      },
      onIsClearSwitchTap: function onIsClearSwitchTap(value) {
        isClearSwitchTap(this, value);
      }
    }
  }).$mount('#app');
}

//配置组件参数
function initComponentsConfig() {
  return {
    unbindDoorlockButton: {
      initParam: {
        class: 'custom-button',
        text: Vue.t('btn.unbindDoorlock')
      }
    },
    dialog: {
      initParam: {
        class: 'custom-dialog'
      }
    },
    isClearSwitch: {
      initParam: {
        class: 'custom-isClearSwitch-switch',
        text: Vue.t('doorlockManage.isClearRecord')
      }
    },
    loading: {
      initParam: {
        class: 'custom-loading'
      }
    },
    doorbellSwitch: {
      initParam: {
        class: 'custom-switch'
      }
    },
    alarmSwitch: {
      initParam: {
        class: 'custom-switch'
      }
    },
    opendoorSwitch: {
      initParam: {
        class: 'custom-switch'
      }
    }
  };
}

function getDoorlockInfo(self) {
  _public.uComponents.showLoading(self);
  var productId = _config2.default.mode.substr(_config2.default.mode_type.length, 6);
  _public.iot.business.device.getInfo({
    data: {
      device_id: self.extras.lockId
    },
    success: function success(response) {
      console.log(response);
      var data = _public.uPublic.checkResponseData(response.data);
      if (data) {
        self.setTextNickname(data.device_name);
        self.setValueDoorbell(data.device_info.options[0]);
        self.setValueAlarm(data.device_info.options[1]);
        self.setValueOpendoor(data.device_info.options[2]);
      }
    },
    error: function error(_error) {
      console.log(_error);
      _public.uPublic.openRequestErrorAlert(self);
    },
    complete: function complete() {
      _public.uComponents.hideLoading(self);
    }
  });
  //	iot.business.api.send('device/getList',{
  //	    data: {
  //	        sds: false,
  //	        device_id: self.extras.deviceId,
  //	        product_id: productId,
  //	        parent_id: 0,
  //	        start_id: 0,
  //	        number: 10
  //	    },
  //	    success: (response) => {
  //	    	console.log(response);
  //	    	let data = uPublic.checkResponseData(response.data);
  //	    	if(data){
  //	    		self.setDoorlock(response.data[0]);
  //	    		self.setTextNickname(self.getDoorlock().nickname);
  //	    		console.log(self.getDoorlock());
  //	    	}
  //	    },
  //	    error: (error) => {
  //	    	//请求失败
  //  		uPublic.openRequestErrorAlert(self);
  //	    	console.log(error);
  //	    },
  //	    complete: () => {
  //	    	uComponents.hideLoading(self);
  //	    }
  //	},true);
}

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

//tap 修改设备昵称
function editNameTap(self) {
  if (!self.role) {
    _public.iot.navigator.openWindow({
      url: './editName.html',
      id: 'editName',
      extras: {
        lockId: self.extras.lockId,
        nickname: self.getTextNickname()
      }
    });
  }
}

//tap 解绑门锁
function unbindDoorlockButtonTap(self) {
  self.setUnbindShowDialog(true);
  //uComponents.openConfirm(self, Vue.t('doorlockManage.unbindDialogTip'),
  //		{text: Vue.t('dialog.cancel'), callback: function () {}},
  //		{text: Vue.t('dialog.unbind'), callback: function () {
  //			uComponents.showLoading(self);
  //			iot.business.sds.unbindDevice({
  //              data: {
  //                  uuid: self.extras.uuid
  //              },
  //              success: (response) => {
  //                  console.log(response);
  //                  unbind(self);
  //              },
  //              error: (error) => {
  //              	console.log(error)
  //              },
  //              complete: () => {
  //              	
  //              }
  //          });
  //		}}
  //	);
}

//tap 隐藏提示框
function unbindStateDialogTap(self) {
  self.setStateShowFlag(false);
  if (self.getUnbindSucceess) {
    _public.iot.navigator.openWindow({
      url: '../device/index.html',
      id: 'device'
    });
  }
}

function unbind(self) {
  _public.iot.business.api.sendCustom('lock/unbind', {
    data: {
      device_sn: self.extras.deviceId,
      device_id: self.extras.lockId,
      needDelInfo: self.getValueIsClear()
    },
    success: function success(response) {
      console.log(response);
      self.setStateShowFlag(true);
      self.setShowMsg(Vue.t('doorlockManage.unbindSuccess'));
      self.setUnbindSucceess(true);
    },
    error: function error(_error2) {
      console.log(_error2);
      self.setStateShowFlag(false);
      self.setShowMsg(Vue.t('doorlockManage.unbindFailue'));
      self.setUnbindSucceess(false);
    },
    complete: function complete() {
      _public.uComponents.hideLoading(self);
    }
  });
}

//function unbindUser(self){
//	iot.business.api.sendCustom('lock/unbindUser',{
//  	data: {
//  		rel_id:  self.getDoorlock().id,
//  		device_id: self.getDoorlock().device_id,
//  		user_id:  self.getDoorlock().user_device_id
//  	},
//  	success: (response) => {
//  		self.setStateShowFlag(true);
//			self.setShowMsg(Vue.t('doorlockUser.unbindSuccess'));
//			self.setUnbindSucceess(true);
//  	},
//  	error: (error) => {
//  		console.log(error);
//  		self.setStateShowFlag(false);
//	    	self.setShowMsg(Vue.t('doorlockUser.unbindFailue'));
//	    	self.setUnbindSucceess(false);
//  	},
//  	complete: () => {
//			uComponents.hideLoading(self);
//  	}
//  });
//}


function doorbellSwitchTap(self, value) {
  self.setValueDoorbell(value);
  setOption(self);
}
function alarmSwitchTap(self, value) {
  self.setValueAlarm(value);
  setOption(self);
}
function opendoorSwitchTap(self, value) {
  self.setValueOpendoor(value);
  setOption(self);
}

function setOption(self) {
  _public.uComponents.showLoading(self);
  _public.iot.business.api.sendCustom('lock/setPushOption', {
    data: {
      device_id: self.extras.lockId,
      opt_ring: self.getValueDoorbell(),
      opt_alarm: self.getValueAlarm(),
      opt_open: self.getValueOpendoor()
    },
    success: function success(response) {
      console.log();
    },
    error: function error(err) {
      _public.uPublic.openRequestErrorAlert(self);
      console.log(err);
    },
    complete: function complete() {
      _public.uComponents.hideLoading(self);
    }
  });
}

function cancelTap(self) {
  self.setUnbindShowDialog(false);
}

function confirmTap(self) {
  self.setUnbindShowDialog(false);
  unbind(self);
}

function isClearSwitchTap(self, value) {
  self.setValueIsClear(value);
  console.log(self.getValueIsClear());
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))

/***/ }),

/***/ 244:
/***/ (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;

/***/ }),

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

module.exports = __webpack_require__(208);


/***/ })

},[306]);
//# sourceMappingURL=index.js.map