webpackJsonp([7],{

/***/ 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/index.html',
            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;

/***/ }),

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

module.exports = __webpack_require__(147);


/***/ })

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