|
@@ -1,696 +0,0 @@
|
|
|
-<!DOCTYPE html>
|
|
|
-<html>
|
|
|
-<head>
|
|
|
- <meta charset="UTF-8">
|
|
|
- <title>我的设备</title>
|
|
|
- <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
|
|
|
- <meta name="apple-mobile-web-app-capable" content="yes">
|
|
|
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
|
- <link rel="stylesheet" type="text/css" href="//s.iamberry.com/watero/css/mui.min.css">
|
|
|
- <link rel="stylesheet" type="text/css" href="//s.iamberry.com/watero/css/iconfont.css" />
|
|
|
- <link rel="stylesheet" type="text/css" href="//s.iamberry.com/watero/css/style.css" />
|
|
|
- <style>
|
|
|
- .my-bar-nav {top: 0;-webkit-box-shadow: 0 0 0 #ccc;box-shadow: 0 0 0 #ccc;background: #fff;}
|
|
|
- .my-bar-nav .mui-btn-link{color: #1cc9f4;font-size: 14px;}
|
|
|
- .mui-content>.mui-table-view:first-child {margin-top: 50px;}
|
|
|
- .my-btn-bluetooth{color: #1cc9f4;padding:2px 18px;font-size: 15px;border-color: #1cc9f4;}
|
|
|
- .my-table-noline:after,.my-table-noline:before,.my-table-noline li:after,.my-table-noline:before{display: none;}
|
|
|
- .mui-btn-link{color: #1cc9f4;}
|
|
|
- .mui-btn-link.active{color:#999;}
|
|
|
- .my-btn-water-quality{padding:6px 38px;font-size: 15px;}
|
|
|
- .my-btn-water-quality.active{border: 1px solid rgba(78,215,249,.5);color: #1cc9f4;}
|
|
|
- .off_none{position: fixed;left: 0;right: 0;bottom: 0;top: 0;width: 100%;background: #fff;z-index: 99;text-align: center;padding-top: 35%;display:none;}
|
|
|
- .off_none .iconfont{font-size:80px;color:#ccc;}
|
|
|
- .off_none>div{padding-top:15px;}
|
|
|
- .off_none a{color:#1cc9f4;text-decoration: underline;}
|
|
|
- .number{position: absolute;bottom: 45px;width: 100%;text-align: center;left: 0;color:#fff;}
|
|
|
- </style>
|
|
|
- <script>
|
|
|
- // 屏蔽分享
|
|
|
- window.hiddenAllWechatMenu = true;
|
|
|
- </script>
|
|
|
-</head>
|
|
|
-<body style="background: #fff;">
|
|
|
-<div class="loading-bg" id="loadingbg">
|
|
|
- <div class="mui-loading">
|
|
|
- <div class="mui-spinner">
|
|
|
- </div>
|
|
|
- 加载中...
|
|
|
- </div>
|
|
|
-</div>
|
|
|
-<header id="header" class="mui-bar my-bar-nav">
|
|
|
- <button class="mui-btn mui-btn-blue mui-btn-link mui-btn-nav mui-pull-left" id="btn_map"><span class="mui-icon mui-icon-location"></span>水质地图</button>
|
|
|
- <button id="filterElement" class="mui-btn mui-btn-blue mui-btn-link mui-pull-right" onclick="functional();" style="display: none;">免费换滤芯</button>
|
|
|
-</header>
|
|
|
-<div class="mui-content" style="background: #fff;">
|
|
|
- <ul class="mui-table-view mui-text-center my-table-noline">
|
|
|
- <li class="mui-table-view-cell">
|
|
|
- <span class="mui-h6" id="dudToTime">2017年3月12日到期</span>
|
|
|
- <div><a class="mui-btn mui-btn-link" onclick="continueRenting();">我要续租</a></div>
|
|
|
- </li>
|
|
|
- <li class="mui-table-view-cell">
|
|
|
- <img id="my_equipment" src="//s.iamberry.com/watero/images/shop/my_equipment1.png" width="170px" />
|
|
|
- <div class="number" id="equipmentIdId">No:</div>
|
|
|
- </li>
|
|
|
- <li class="mui-table-view-cell" id="liclass">
|
|
|
- <button type="button" class="my-btn-bluetooth iconfont icon-lease10" onclick="openScanning();">
|
|
|
- 连接
|
|
|
- </button>
|
|
|
- </li>
|
|
|
- <li class="mui-table-view-cell" id="liclass2">
|
|
|
- 总净饮水量:0l
|
|
|
- <br/>
|
|
|
- <span class="mui-h6">约相当于0桶传统18.9L的桶装水</span>
|
|
|
- </li>
|
|
|
- <li class="mui-table-view-cell" id="liclass3">
|
|
|
- <span class="mui-h5">我家水质(tds):未知 ppm</span>
|
|
|
- </li>
|
|
|
- <li class="mui-table-view-cell">
|
|
|
- <button type="button" class="my-btn-water-quality active">
|
|
|
- 比拼水质
|
|
|
- </button>
|
|
|
- </li>
|
|
|
- <li class="mui-table-view-cell">
|
|
|
- <input type="hidden" value="" id="switchingEquipment">
|
|
|
- <input type="hidden" value="" id="machineId">
|
|
|
- <a style="text-decoration: underline;font-size: 13px;color: #999;" id="switching">切换设备</a>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- <div class="off_none">
|
|
|
- <span class="iconfont icon-shebeiliebiao"></span>
|
|
|
- <div>还没有机器?<a id="toActivate" href="" onclick="openScanning();">立即连接</a></div>
|
|
|
- <ul style="text-align: left;padding: 10% 0 0 10%;font-size: 13px;">
|
|
|
- <li> 第一步: 打开手机蓝牙,给净水机通电</li>
|
|
|
- <li> 第二步:靠近设备,点击“立即连接”</li>
|
|
|
- <li> 第三步:扫描设备上的二维码进行设备绑定</li>
|
|
|
- <li> 第四步:点击微信菜单“我的设备”进入设备信息页面 </li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
-</div>
|
|
|
-
|
|
|
-<script src="//s.iamberry.com/watero/js/mui.min.js"></script>
|
|
|
-<script src="//s.iamberry.com/watero/js/jquery-2.1.1.min.js"></script>
|
|
|
-<script src="//s.iamberry.com/watero/js/wechat_iot.js?v=6734343"></script>
|
|
|
-<script src="//s.iamberry.com/watero/js/shop/main.js"></script>
|
|
|
-<script type="text/javascript">
|
|
|
- var data = null;
|
|
|
- var datalength = null;
|
|
|
- var machineState = null
|
|
|
- var machineDeviceId = null;
|
|
|
- var info = null;
|
|
|
- function pullupRefresh() {
|
|
|
- mui.ajax(base_path + '/wechat/machine/machine_info?dates=' + new Date().getTime(), {
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- console.log(dt);
|
|
|
- if(dt.isRedirect) {
|
|
|
- location.href = dt.redirectURL;
|
|
|
- } else {
|
|
|
- if(dt.status) {
|
|
|
- data = dt.data;//赋值到全局变量
|
|
|
- datalength = dt.data.length;
|
|
|
- var renewal_data = [];
|
|
|
- renewal_data = dt.data;
|
|
|
- var table = document.body.querySelector('.liclass');
|
|
|
- info = renewal_data[0];
|
|
|
- //未初始化硬件
|
|
|
- if(!isInitialize){
|
|
|
- mui.ajax(base_path + '/wechat/machine/updateByDeviceId?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- state: 2,
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- mui.ajax(base_path + '/wechat/machine/select_machineByDeviceId?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- info = dt.data;
|
|
|
- isDueTo(info.machineStopDate,info.machineSurplusWater);
|
|
|
- //给页面填值
|
|
|
- $("#equipmentIdId").text("设备编号:"+(10000+info.machineId));
|
|
|
- $("#dudToTime").text(""+format(info.machineStopDate)+"到期");
|
|
|
- if(info.machineConnectState == "1"){
|
|
|
- $("#liclass").html('<span style="color:#1cc9f4;">已连接</span>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment.png");
|
|
|
- }else{
|
|
|
- $("#liclass").html('<button type="button" class="my-btn-bluetooth iconfont icon-lease10" onclick="openScanning();">连接</button>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment1.png");
|
|
|
- }
|
|
|
- var count = info.machineHaveWater/18.9;
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/>');
|
|
|
- if(info.machineHaveWater >= 18.9){
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/><span class="mui-h6">约相当于'+parseInt(count)+'桶传统18.9L的桶装水</span>');
|
|
|
- }
|
|
|
- if(info.machineTDS == 0){
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):未知 ppm</span> ');
|
|
|
- }else{
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):'+info.machineTDS+'ppm</span> ');
|
|
|
- }
|
|
|
-
|
|
|
- $("#switchingEquipment").val("0");
|
|
|
- $("#machineId").val(info.machineId);
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- machineState = info.machineConnectState;
|
|
|
- machineDeviceId = info.machineDeviceId;
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- //发送消息到设备,同步数据
|
|
|
- sendMsgAndReceiveData(info.machineDeviceId,"*getData#",function(state,res){
|
|
|
- if(200 == state){
|
|
|
- var arr = res.split(" ");
|
|
|
- //根据设备id查询数据库并更新当前页面设备
|
|
|
- mui.ajax(base_path + '/wechat/machine/sync_machine?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- tds: arr[0],
|
|
|
- water_num: arr[1],
|
|
|
- deviceId: info.machineDeviceId,
|
|
|
- state: 1
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.returnCode == "200") {
|
|
|
- mui.ajax(base_path + '/wechat/machine/select_machineByDeviceId?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- info = dt.data;
|
|
|
- isDueTo(info.machineStopDate,info.machineSurplusWater);
|
|
|
- //给页面填值
|
|
|
- $("#equipmentIdId").text("设备编号:"+(10000+info.machineId));
|
|
|
- $("#dudToTime").text(""+format(info.machineStopDate)+"到期");
|
|
|
- if(info.machineConnectState == "1"){
|
|
|
- $("#liclass").html('<span style="color:#1cc9f4;">已连接</span>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment.png");
|
|
|
- }else{
|
|
|
- $("#liclass").html('<button type="button" class="my-btn-bluetooth iconfont icon-lease10" onclick="openScanning();">连接</button>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment1.png");
|
|
|
- }
|
|
|
- var count = info.machineHaveWater/18.9;
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/>');
|
|
|
- if(info.machineHaveWater >= 18.9){
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/><span class="mui-h6">约相当于'+parseInt(count)+'桶传统18.9L的桶装水</span>');
|
|
|
- }
|
|
|
- if(info.machineTDS == 0){
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):未知 ppm</span> ');
|
|
|
- }else{
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):'+info.machineTDS+'ppm</span> ');
|
|
|
- }
|
|
|
-
|
|
|
- $("#switchingEquipment").val("0");
|
|
|
- $("#machineId").val(info.machineId);
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- machineState = info.machineConnectState;
|
|
|
- machineDeviceId = info.machineDeviceId;
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }else{
|
|
|
- isDueTo(info.machineStopDate,info.machineSurplusWater);
|
|
|
- //给页面填值
|
|
|
- $("#equipmentIdId").text("设备编号:"+(10000+info.machineId));
|
|
|
- $("#dudToTime").text(""+format(info.machineStopDate)+"到期");
|
|
|
- if(info.machineConnectState == "1"){
|
|
|
- $("#liclass").html('<span style="color:#1cc9f4;">已连接</span>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment.png");
|
|
|
- }else{
|
|
|
- $("#liclass").html('<button type="button" class="my-btn-bluetooth iconfont icon-lease10" onclick="openScanning();">连接</button>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment1.png");
|
|
|
- }
|
|
|
- var count = info.machineHaveWater/18.9;
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/>');
|
|
|
- if(info.machineHaveWater >= 18.9){
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/><span class="mui-h6">约相当于'+parseInt(count)+'桶传统18.9L的桶装水</span>');
|
|
|
- }
|
|
|
- if(info.machineTDS == 0){
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):未知 ppm</span> ');
|
|
|
- }else{
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):'+info.machineTDS+'ppm</span> ');
|
|
|
- }
|
|
|
-
|
|
|
- $("#switchingEquipment").val("0");
|
|
|
- $("#machineId").val(info.machineId);
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- machineState = info.machineConnectState;
|
|
|
- machineDeviceId = info.machineDeviceId;
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- if(500 == state){
|
|
|
- //根据设备id查询数据库并更新当前页面设备
|
|
|
- mui.ajax(base_path + '/wechat/machine/updateByDeviceId?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- state: 2,
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- mui.ajax(base_path + '/wechat/machine/select_machineByDeviceId?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- info = dt.data;
|
|
|
- isDueTo(info.machineStopDate,info.machineSurplusWater);
|
|
|
- //给页面填值
|
|
|
- $("#equipmentIdId").text("设备编号:"+(10000+info.machineId));
|
|
|
- $("#dudToTime").text(""+format(info.machineStopDate)+"到期");
|
|
|
- if(info.machineConnectState == "1"){
|
|
|
- $("#liclass").html('<span style="color:#1cc9f4;">已连接</span>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment.png");
|
|
|
- }else{
|
|
|
- $("#liclass").html('<button type="button" class="my-btn-bluetooth iconfont icon-lease10" onclick="openScanning();">连接</button>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment1.png");
|
|
|
- }
|
|
|
- var count = info.machineHaveWater/18.9;
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/>');
|
|
|
- if(info.machineHaveWater >= 18.9){
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/><span class="mui-h6">约相当于'+parseInt(count)+'桶传统18.9L的桶装水</span>');
|
|
|
- }
|
|
|
- if(info.machineTDS == 0){
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):未知 ppm</span> ');
|
|
|
- }else{
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):'+info.machineTDS+'ppm</span> ');
|
|
|
- }
|
|
|
-
|
|
|
- $("#switchingEquipment").val("0");
|
|
|
- $("#machineId").val(info.machineId);
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- machineState = info.machineConnectState;
|
|
|
- machineDeviceId = info.machineDeviceId;
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
- }else{
|
|
|
- $(".off_none").show();
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- mui.ready(function(){
|
|
|
- setTimeout("myInterval()",2000);
|
|
|
- });
|
|
|
- function myInterval()
|
|
|
- {
|
|
|
- pullupRefresh();
|
|
|
- }
|
|
|
- //切换设备
|
|
|
-
|
|
|
- mui('body').on('tap', '#switching', function() {
|
|
|
- if(datalength <= 1){
|
|
|
- mui.alert("当前只检测到一台设备,如有疑问,请咨询公众号客服!");
|
|
|
- return;
|
|
|
- }
|
|
|
- document.querySelector('.loading-bg').style.display='block';
|
|
|
- var num = $("#switchingEquipment").val();
|
|
|
- if(num*1+1 >= datalength){
|
|
|
- num = 0;
|
|
|
- info = data[num];
|
|
|
- $("#switchingEquipment").val(num);
|
|
|
- }else{
|
|
|
- info = data[num*1+1];
|
|
|
- $("#switchingEquipment").val(num*1+1);
|
|
|
- }
|
|
|
- //发送消息到设备,同步数据
|
|
|
- sendMsgAndReceiveData(info.machineDeviceId,"*getData#",function(state,res){
|
|
|
- if(200 == state){
|
|
|
- var arr = res.split(" ");
|
|
|
- //根据设备id查询数据库并更新当前页面设备
|
|
|
- mui.ajax(base_path + '/wechat/machine/sync_machine?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- tds: arr[0],
|
|
|
- water_num: arr[1],
|
|
|
- deviceId: info.machineDeviceId,
|
|
|
- state: 1
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.returnCode == "200") {
|
|
|
- mui.ajax(base_path + '/wechat/machine/select_machineByDeviceId?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- info = dt.data;
|
|
|
- isDueTo(info.machineStopDate,info.machineSurplusWater);
|
|
|
- $("#equipmentIdId").text("设备编号:"+(10000+info.machineId));
|
|
|
- $("#dudToTime").text(format(info.machineStopDate)+"到期");
|
|
|
- if(info.machineConnectState == "1"){
|
|
|
- $("#liclass").html('<span style="color:#1cc9f4;">已连接</span>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment.png");
|
|
|
- }else{
|
|
|
- $("#liclass").html('<button type="button" class="my-btn-bluetooth iconfont icon-lease10" onclick="openScanning();">连接</button>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment1.png");
|
|
|
- }
|
|
|
- var count = info.machineHaveWater/18.9;
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/>');
|
|
|
- if(info.machineHaveWater >= 18.9){
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/><span class="mui-h6">约相当于'+parseInt(count)+'桶传统18.9L的桶装水</span>');
|
|
|
- }
|
|
|
- if(info.machineTDS == 0){
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):未知 ppm</span> ');
|
|
|
- }else{
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):'+info.machineTDS+'ppm</span> ');
|
|
|
- }
|
|
|
-
|
|
|
- $("#machineId").val(info.machineId);
|
|
|
- document.querySelector('.loading-bg').style.display='none';
|
|
|
- machineState = info.machineConnectState;
|
|
|
- machineDeviceId = info.machineDeviceId;
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }else{
|
|
|
- //给页面填值
|
|
|
- isDueTo(info.machineStopDate,info.machineSurplusWater);
|
|
|
- $("#equipmentIdId").text("设备编号:"+(10000+info.machineId));
|
|
|
- $("#dudToTime").text(""+format(info.machineStopDate)+"到期");
|
|
|
- if(info.machineConnectState == "1"){
|
|
|
- $("#liclass").html('<span style="color:#1cc9f4;">已连接</span>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment.png");
|
|
|
- }else{
|
|
|
- $("#liclass").html('<button type="button" class="my-btn-bluetooth iconfont icon-lease10" onclick="openScanning();">连接</button>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment1.png");
|
|
|
- }
|
|
|
- var count = info.machineHaveWater/18.9;
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/>');
|
|
|
- if(info.machineHaveWater >= 18.9){
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/><span class="mui-h6">约相当于'+parseInt(count)+'桶传统18.9L的桶装水</span>');
|
|
|
- }
|
|
|
- if(info.machineTDS == 0){
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):未知 ppm</span> ');
|
|
|
- }else{
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):'+info.machineTDS+'ppm</span> ');
|
|
|
- }
|
|
|
-
|
|
|
- $("#switchingEquipment").val("0");
|
|
|
- $("#machineId").val(info.machineId);
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- machineState = info.machineConnectState;
|
|
|
- machineDeviceId = info.machineDeviceId;
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- if(500 == state){
|
|
|
- //根据设备id查询数据库并更新当前页面设备
|
|
|
- mui.ajax(base_path + '/wechat/machine/updateByDeviceId?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- state: 2,
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- mui.ajax(base_path + '/wechat/machine/select_machineByDeviceId?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- info = dt.data;
|
|
|
- isDueTo(info.machineStopDate,info.machineSurplusWater);
|
|
|
- //给页面填值
|
|
|
- $("#equipmentIdId").text("设备编号:"+(10000+info.machineId));
|
|
|
- $("#dudToTime").text(format(info.machineStopDate)+"到期");
|
|
|
- if(info.machineConnectState == "1"){
|
|
|
- $("#liclass").html('<span style="color:#1cc9f4;">已连接</span>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment.png");
|
|
|
- }else{
|
|
|
- $("#liclass").html('<button type="button" class="my-btn-bluetooth iconfont icon-lease10" onclick="openScanning();">连接</button>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment1.png");
|
|
|
- }
|
|
|
- var count = info.machineHaveWater/18.9;
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/>');
|
|
|
- if(info.machineHaveWater >= 18.9){
|
|
|
- $("#liclass2").html('总净饮水量:'+info.machineHaveWater+'L<br/><span class="mui-h6">约相当于'+parseInt(count)+'桶传统18.9L的桶装水</span>');
|
|
|
- }
|
|
|
- if(info.machineTDS == 0){
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):未知 ppm</span> ');
|
|
|
- }else{
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):'+info.machineTDS+'ppm</span> ');
|
|
|
- }
|
|
|
-
|
|
|
- $("#machineId").val(info.machineId);
|
|
|
- document.querySelector('.loading-bg').style.display='none';
|
|
|
- machineState = info.machineConnectState;
|
|
|
- machineDeviceId = info.machineDeviceId;
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- });
|
|
|
- function format(now) {
|
|
|
- now = now.replace(new RegExp("-","gm"),"/");
|
|
|
- var nowHaoMiao = (new Date(now)).getTime();
|
|
|
- now = new Date(nowHaoMiao);
|
|
|
- var year=now.getFullYear();
|
|
|
- var month=now.getMonth()+1;
|
|
|
- var date=now.getDate();
|
|
|
- var hour=now.getHours();
|
|
|
- var minute=now.getMinutes();
|
|
|
- var second=now.getSeconds();
|
|
|
- return year+"年"+month+"月"+date+"日";
|
|
|
- }
|
|
|
-
|
|
|
- base_path = "/watero";
|
|
|
- function continueRenting(){
|
|
|
- if(machineState == 1){
|
|
|
- var machineId = $("#machineId").val();//#gotopagenum是文本框的id属性
|
|
|
- location.href = base_path + '/view/i_want_to_renew.html?machineId='+machineId;
|
|
|
- }else{
|
|
|
- mui.alert("请保持机器在线后,再进行续租操作!");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //激活
|
|
|
- function openScanning() {
|
|
|
- //发送消息到设备,同步数据
|
|
|
- if(!isInitialize){
|
|
|
- //初始化硬件库
|
|
|
- getConfig();
|
|
|
- }else{
|
|
|
- sendMsgAndReceiveData(machineDeviceId,"*getData#",function(state,res){
|
|
|
- if(200 == state){
|
|
|
- var arr = res.split(" ");
|
|
|
- //根据设备id查询数据库并更新当前页面设备
|
|
|
- mui.ajax(base_path + '/wechat/machine/sync_machine?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- tds: arr[0],
|
|
|
- water_num: arr[1],
|
|
|
- deviceId: info.machineDeviceId,
|
|
|
- state: 1
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.returnCode == "200") {
|
|
|
- mui.ajax(base_path + '/wechat/machine/select_machineByDeviceId?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- var arr = res.split(" ");
|
|
|
- isDueTo(info.machineStopDate,info.machineTotalWater - arr[1]);
|
|
|
- $("#liclass").html('<span style="color:#1cc9f4;">已连接</span>');
|
|
|
- $("#my_equipment").prop("src","//s.iamberry.com/watero/images/shop/my_equipment.png");
|
|
|
-
|
|
|
- var count = arr[1]/18.9;
|
|
|
- $("#liclass2").html('总净饮水量:'+arr[1]+'L<br/>');
|
|
|
- if(info.machineHaveWater >= 18.9){
|
|
|
- $("#liclass2").html('<span class="mui-h6">约相当于'+parseInt(count)+'桶传统18.9L的桶装水</span>');
|
|
|
- }
|
|
|
- $("#liclass3").html('<span class="mui-h5">我家水质(tds):'+arr[0]+'ppm</span> ');
|
|
|
- machineState = 1;
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }else{
|
|
|
- mui.alert("请确保设备已通电、手机蓝牙打开,并且让手机靠近设备后,重试");
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- };
|
|
|
- var t1='',t2='',t3='',t4='';
|
|
|
- function isDueTo(dueToDate,Water){
|
|
|
- sendMsgAndReceiveData(info.machineDeviceId,"*isUse#",function(state,res){
|
|
|
- if(200 == state){
|
|
|
- mui.ajax(base_path + '/wechat/machine/check_change_filter?dates=' + new Date().getTime(), {
|
|
|
- data: {
|
|
|
- filterT1: res.substring(0,1),
|
|
|
- filterT2: res.substring(1,2),
|
|
|
- filterT3: res.substring(2,3),
|
|
|
- filterT4: res.substring(3,4),
|
|
|
- deviceId: info.machineDeviceId
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- type: 'post',
|
|
|
- timeout: 15000,
|
|
|
- success: function(dt) {
|
|
|
- if(dt.status) {
|
|
|
- var filters = dt.data;
|
|
|
- t1=filters.T1;
|
|
|
- t2= filters.T2;
|
|
|
- t3= filters.T3;
|
|
|
- t4=filters.T4;
|
|
|
- if(filters.T1 == 1 || filters.T2 == 1 || filters.T3 == 1 || filters.T4 == 1){
|
|
|
- document.getElementById("filterElement").style.display = "block";
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- console.log(xhr)
|
|
|
- document.querySelector('.loading-bg').style.display = 'none';
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- dueToDate = dueToDate.replace(new RegExp("-","gm"),"/");
|
|
|
- dueToDate = (new Date(dueToDate)).getTime();
|
|
|
- remainingTime = dueToDate - new Date().getTime();
|
|
|
- var days = remainingTime /1000/60/60/24;
|
|
|
- if(days <= 30){
|
|
|
- /*document.getElementById("filterElement").style.display = "block"; */
|
|
|
- document.getElementById("dudToTime").style.color = "#ff0000";
|
|
|
- mui.alert("您的设备剩余使用时间或水量不足,请尽快续费以免影响您的正常使用");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- function functional(){
|
|
|
- if(t1!='' && t2!='' && t3!='' && t4!=''){
|
|
|
- mui.openWindow({
|
|
|
- url: '/watero/view/replace_free_filter.html?t1='+t1+'&t2='+t2+'&t3='+t3+'&t4='+t4+'&deviceId='+machineDeviceId
|
|
|
- });
|
|
|
- }else{
|
|
|
- mui.alert('获取滤芯状态失败,请联系客服!')
|
|
|
- }
|
|
|
- }
|
|
|
- mui('body').on('tap', '.my-btn-water-quality', function() {
|
|
|
- location.href='/watero/view/water_competition_for_me.html?deviceId='+info.machineDeviceId;
|
|
|
- });
|
|
|
- mui('body').on('tap', '#btn_map', function() {
|
|
|
- mui.alert("功能正在完善中...");
|
|
|
- //location.href='/watero/view/water_competition_for_me.html?deviceId='+info.machineDeviceId;
|
|
|
- });
|
|
|
-</script>
|
|
|
-</body>
|
|
|
-</html>
|