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