location-option.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta name="author" content=""/>
  6. <meta name="description" content=""/>
  7. <meta name="keywords" content="扫码支付,线上投币,运营数据,物联网"/>
  8. <meta name="format-detection" content="telphone=no,email=no"/>
  9. <meta name="viewport"
  10. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  11. <meta http-equiv="pragma" content="no-cache">
  12. <meta http-equiv="cache-control" content="no-cache">
  13. <meta http-equiv="expires" content="0">
  14. <title>投放地址</title>
  15. <link rel="stylesheet" href="https://cdn.washpayer.com/components/lib/mui.min.css"/>
  16. <link rel="stylesheet" href="../components/custom/css/common.css"/>
  17. <link rel="stylesheet" href="css/xyf.common.min.css">
  18. </head>
  19. <body>
  20. <div class="mui-input-group mui-reset">
  21. <form class="mui-row" action="">
  22. <div class="mui-col-xs-12 mui-col-sm-12">
  23. <div class="mui-input-row mui-search">
  24. <input type="search" class="mui-input-clear" id="searchKey" placeholder=" 请输入地址名称">
  25. </div>
  26. </div>
  27. </form>
  28. </div>
  29. <div id="pullrefresh" class="mui-content mui-scroll-wrapper location-bd" style="top:54px">
  30. <div class="mui-scroll">
  31. <ul class="mui-table-view interval"></ul>
  32. </div>
  33. </div>
  34. <div class="custom-btn-area custom-fixed-b">
  35. <a href="javascript:void(0);" class="custom-btn custom-btn-primary" onclick="toAddLocation()">添加投放地址</a>
  36. </div>
  37. <script src="https://cdn.washpayer.com/components/lib/jquery.min.js"></script>
  38. <script src="https://cdn.washpayer.com/components/lib/mui.min.js"></script>
  39. <script src="/components/custom/js/common.js"></script>
  40. <script src="js/xyf.common.js"></script>
  41. <script>
  42. (function () {
  43. //ios返回刷新
  44. var isPageHide = false;
  45. window.addEventListener('pageshow', function () {
  46. if (isPageHide) {
  47. window.location.reload();
  48. }
  49. });
  50. window.addEventListener('pagehide', function () {
  51. isPageHide = true;
  52. });
  53. })();
  54. //关键字搜索
  55. document.onkeydown = function (ev) {
  56. if (ev.keyCode == 13) {
  57. ev.preventDefault();
  58. search();
  59. }
  60. };
  61. var searchKey;
  62. function search() {
  63. pageIndex = 0;
  64. $('#pullrefresh .mui-table-view').html("");
  65. mui('#pullrefresh').pullRefresh().refresh(true);//重置上拉加载
  66. searchKey = $("#searchKey").val();
  67. //写入数据
  68. pullupRefresh();
  69. }
  70. mui.init({
  71. pullRefresh: {
  72. container: '#pullrefresh',
  73. up: {
  74. contentrefresh: '正在加载...',
  75. contentnomore: '没有更多数据了...',
  76. callback: pullupRefresh
  77. }
  78. }
  79. });
  80. var pageIndex = 0;
  81. var total = 0;
  82. function pullupRefresh() {
  83. pageIndex++;
  84. var url = "/device/groupList";
  85. var data = {"pageIndex": pageIndex, "pageSize": 10, searchKey: searchKey,};
  86. sendRequest(url, "GET", data, function (res) {
  87. if (res.result == 1) {
  88. if (pageIndex == 1) {
  89. total = res.para.total;
  90. if (total === 0) {
  91. $("body").append('<div class="nomore"></div>');
  92. $("#pullrefresh").hide()
  93. }
  94. }
  95. mui('#pullrefresh').pullRefresh().endPullupToRefresh((pageIndex * 10 >= total));
  96. var table = $('.mui-table-view');
  97. var length = res.para.dataList.length;
  98. for (var i = 0; i < length; i++) {
  99. var obj = res.para.dataList[i];
  100. //如果不是地址管理员,则不能选
  101. if(!obj.isManager){
  102. continue
  103. }
  104. var isDefault = "";
  105. if (obj.isDefault) {
  106. isDefault += " <em class='mark-blue'>默认</em>";
  107. }
  108. var liDom = $('<li class="mui-table-view-cell"><a href="javascript:void(0)">' +
  109. '<p>' + obj.groupName + isDefault + '<em class="total-mark"> ' + obj.equipmentCount + '台 </em></p>' +
  110. '<p class="mui-ellipsis">' + obj.address + '</p>' +
  111. '</a></li>');
  112. bindClick(liDom, {groupName: obj.groupName, groupId: obj.groupId});
  113. table.append(liDom);
  114. }
  115. } else {
  116. mui.toast(res.description);
  117. }
  118. });
  119. }
  120. if (mui.os.plus) {
  121. mui.plusReady(function () {
  122. setTimeout(function () {
  123. mui('#pullrefresh').pullRefresh().pullupLoading();
  124. }, 1000);
  125. });
  126. } else {
  127. mui.ready(function () {
  128. mui('#pullrefresh').pullRefresh().pullupLoading();
  129. });
  130. }
  131. function bindClick(dom, opt) {
  132. dom.on("tap",function () {
  133. //缓存数据,这样选择地址回退才不回丢失数据
  134. setSessionStorage("DEVICE_REG_PARAM", $.extend(true, getSessionStorage("DEVICE_REG_PARAM"), opt), 1000 * 60 * 30);
  135. window.history.back();
  136. });
  137. }
  138. function toAddLocation() {
  139. var url = "location-add.html";
  140. goPage(url);
  141. }
  142. </script>
  143. </body>
  144. </html>