(function() {

	Vue.component('device-banding', {
		template: '<div style="position:relative;height:100%;">\
						<div class="sk-spinner sk-spinner-chasing-dots" v-show="!isRequestEnd" style="top: 50%;left:50%;margin-left:-0.1rem;margin-top: -0.1rem;position:absolute;">\
				            <div class="sk-dot1"></div>\
				            <div class="sk-dot2"></div>\
				       </div>\
					<div class="f-tac f-clb div-banding-content" v-show="isRequestEnd">\
						<div class="mt20 div-all-bang-count" v-show="isProduction==0">\
							<div class="dis-inblock c-pr">\
								<div class="mt20 c-f14 c-B5E1FC div-yujing-name">预警人数（人）</div>\
								<div class="mr60 div-renshu_img">\
									<div class="c-f30 c-B5E1FC div-yujing-count">{{allYJCount}}</div>\
								</div>\
							</div>\
							<div class="dis-inblock c-pr">\
								<div class="mt20 c-f14 c-B5E1FC div-bangding-name">绑定人数（人）</div>\
								<div class="div-renshu_img">\
									<div class="c-f30 c-B5E1FC div-banding-count">{{allBDCount}}</div>\
								</div>\
							</div>\
						</div>\
						<div class="mt20 div-gxy-bang-count" v-show="isProduction==1">\
							<div class="dis-inblock c-pr">\
								<div class="mt20 c-f14 c-B5E1FC div-yujing-name">预警人数（人）</div>\
								<div class="mr60 div-renshu_img">\
									<div class="c-f30 c-B5E1FC div-yujing-count">{{xyjYJCount}}</div>\
								</div>\
							</div>\
							<div class="dis-inblock c-pr">\
								<div class="mt20 c-f14 c-B5E1FC div-bangding-name">绑定人数（人）</div>\
								<div class="div-renshu_img">\
									<div class="c-f30 c-B5E1FC div-banding-count">{{xyjBDCount}}</div>\
								</div>\
							</div>\
						</div>\
						<div class="mt20 div-tnb-bang-count" v-show="isProduction==2">\
							<div class="dis-inblock c-pr">\
								<div class="mt20 c-f14 c-B5E1FC div-yujing-name">预警人数（人）</div>\
								<div class="mr60 div-renshu_img">\
									<div class="c-f30 c-B5E1FC div-yujing-count">{{xtyYJCount}}</div>\
								</div>\
							</div>\
							<div class="dis-inblock c-pr">\
								<div class="mt20 c-f14 c-B5E1FC div-bangding-name">绑定人数（人）</div>\
								<div class="div-renshu_img">\
									<div class="c-f30 c-B5E1FC div-banding-count">{{xtyBDCount}}</div>\
								</div>\
							</div>\
						</div>\
					</div>\
			</div>',
		props: [],
		data: function() {
			return {
				isProduction: 0,
				allYJCount: null,
				allBDCount: null,
				xtyYJCount: null,
				xtyBDCount: null,
				xyjYJCount: null,
				xyjBDCount: null,
				isRequestEnd: false
			}
		},
		methods: {
			changeProduction: function(num) {
				this.isProduction = num;
			}
		},
		mounted: function() {
			var _self = this;

			EventBus.$on('get-banding-info', function(arg) {
				var type = arg.type;
				if(type == "") { //全部
					_self.changeProduction(0);
				} else if(type == "1") { //血压计
					_self.changeProduction(1);
				} else if(type == "2") { //血糖仪
					_self.changeProduction(2);
				}
			});

			var url = "/svr-iot/wlyy/deviceBinding";
			var reqUrl = [{
					url: url,
					reqType: 'get',
					data: {
						type: ""
					}
				},
				{
					url: url,
					reqType: 'get',
					data: {
						type: "1"
					}
				},
				{
					url: url,
					reqType: 'get',
					data: {
						type: "2"
					}
				}
			];

			httpRequest.getReqPromises(reqUrl).then(function(datas) {
				var allData = datas[0]; //全部tab数据
				var tangniaobingData = datas[1]; //糖尿病tab数据
				var gaoxueyaData = datas[2]; //高血压tab数据

				if(allData.status == 200) {
					var data = allData.data;
					_self.allYJCount = data[1].num;
					_self.allBDCount = data[0].num;
				}

				if(gaoxueyaData.status == 200) {
					var data = gaoxueyaData.data;
					_self.xyjYJCount = data[1].num;
					_self.xyjBDCount = data[0].num;
				}

				if(tangniaobingData.status == 200) {
					var data = tangniaobingData.data;
					_self.xtyYJCount = data[1].num;
					_self.xtyBDCount = data[0].num;
				}
				_self.isRequestEnd = true;

			})

		}
	})

})()