Ver Código Fonte

@guohh@修复内蒙项目配置页面样式及js问题

guohh 3 anos atrás
pai
commit
5698d793da

+ 75 - 1
2021/nm-zsyt/ipu/connect-config.html

@ -5,10 +5,10 @@
5 5
  <meta charset="utf-8">
6 6
  <meta name="viewport"
7 7
        content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
8
9 8
  <link rel="stylesheet" type="text/css" href="./css/ipuUI.css">
10 9
  <link rel="stylesheet" type="text/css" href="./css/connect-config.css">
11 10
11
12 12
  <!-- 顺序要先ipu-mobile.js 再android-webview.js-->
13 13
  <script src="./js/frame/ipu-mobile.js"></script>
14 14
  <script src="./js/frame/android-webview.js"></script>
@ -30,6 +30,80 @@
30 30
  </div>
31 31
  <div class="ipu-flex-col ipu-flex-col-auto">
32 32
    <div class="ipu-flex-content" id="content">
33
      <div class="demo-item"><p class="demo-title">类型</p>
34
        <div class="demo-body">
35
          <div class="ipu-list">
36
            <ul>
37
              <li class="ipu-list-item">
38
                <div class="ipu-list-item-inner">
39
                  <label class="ipu-radio">
40
                    <input type="radio" name="DEVICE_BRAND_TYPE" value="SR">森锐
41
                  </label>
42
                </div>
43
              </li>
44
              <li class="ipu-list-item">
45
                <div class="ipu-list-item-inner">
46
                  <label class="ipu-radio">
47
                    <input type="radio" name="DEVICE_BRAND_TYPE" value="SYD">三元达
48
                  </label>
49
                </div>
50
              </li>
51
              <li class="ipu-list-item">
52
                <div class="ipu-list-item-inner">
53
                  <label class="ipu-radio">
54
                    <input type="radio" name="DEVICE_BRAND_TYPE" value="ZYZX">中移在线
55
                  </label>
56
                </div>
57
              </li>
58
            </ul>
59
          </div>
60
        </div>
61
      </div>
62
      <div class="demo-item"><p class="demo-title">连接方式</p>
63
        <div class="demo-body">
64
          <div class="ipu-list">
65
            <ul>
66
              <li class="ipu-list-item">
67
                <div class="ipu-list-item-inner">
68
                  <label class="ipu-radio">
69
                    <input type="radio" name="DEVICE_CONNECT_TYPE" value="bt">蓝牙
70
                  </label>
71
                </div>
72
              </li>
73
              <li class="ipu-list-item">
74
                <div class="ipu-list-item-inner">
75
                  <label class="ipu-radio">
76
                    <input type="radio" name="DEVICE_CONNECT_TYPE" value="otg">OTG
77
                  </label>
78
                </div>
79
              </li>
80
              <li class="ipu-list-item">
81
                <div class="ipu-list-item-inner">
82
                  <label class="ipu-radio">
83
                    <input type="radio" name="DEVICE_CONNECT_TYPE" value="nfc">NFC
84
                  </label>
85
                </div>
86
              </li>
87
            </ul>
88
          </div>
89
        </div>
90
      </div>
91
      <div class="demo-item"><p class="demo-title">蓝牙地址</p>
92
        <div class="demo-body">
93
          <div class="ipu-list">
94
            <ul>
95
              <li class="ipu-list-item">
96
                <div class="ipu-list-item-inner">
97
                  <div class="ipu-list-item-input-wrap">
98
                    <input class="ipu-list-item-input" name="DEVICE_BT_ADDRESS" type="text"
99
                           placeholder="请选择" readonly="">
100
                  </div>
101
                </div>
102
              </li>
103
            </ul>
104
          </div>
105
        </div>
106
      </div>
33 107
    </div>
34 108
  </div>
35 109
</div>

+ 2 - 2
2021/nm-zsyt/ipu/css/ipuUI.css

@ -568,7 +568,7 @@ a:active {
568 568
.ipu-radio {
569 569
  display: inline-block;
570 570
}
571
.ipu-radio input {
571
/*.ipu-radio input {
572 572
  -webkit-appearance: none;
573 573
  position: relative;
574 574
  display: inline-block;
@ -600,7 +600,7 @@ a:active {
600 600
  height: 50%;
601 601
  background: #0083d3;
602 602
  border-radius: 50%;
603
}
603
}*/
604 604
.ipu-checkbox {
605 605
  display: inline-block;
606 606
}

+ 12 - 82
2021/nm-zsyt/ipu/js/connect-config.js

@ -2,88 +2,11 @@ $(function () {
2 2
3 3
  var contentRoot = $("#content");
4 4
5
  // 设备连接配置项
6
  var configItems = [{
7
    label: '类型',
8
    name: 'DEVICE_BRAND_TYPE',
9
    options: [{
10
      name: '森锐', value: 'SR',
11
    }, {
12
      name: '三元达', value: 'SYD',
13
    }, {
14
      name: '中移在线', value: 'ZYZX',
15
    }]
16
  }, {
17
    label: '连接方式',
18
    name: 'DEVICE_CONNECT_TYPE',
19
    options: [{
20
      name: '蓝牙', value: 'bt',
21
    }, {
22
      name: 'OTG', value: 'otg',
23
    }, {
24
      name: 'NFC', value: 'nfc',
25
    }]
26
  }, {
27
    label: '蓝牙地址',
28
    name: 'DEVICE_BT_ADDRESS',
29
    type: 'input',
30
    clickFun: function (callback) {
31
      AndroidWebView.btDeviceList(callback)
32
    }
33
  }];
34
35 5
  // 设置连接信息
36 6
  function setConnectConfig(name, value) {
37 7
    AndroidWebView.setCache(name, value);
38 8
  }
39 9
40
  // 初始化配置项
41
  function iniConfigItem(items) {
42
    var contentHtml = '';
43
    $(items).each(function (i, item) {
44
      var optionStr = '';
45
46
      if ($.isArray(item.options)) {
47
        $(item.options).each(function (i, option) {
48
          optionStr = optionStr + '<li class="ipu-list-item">\n' +
49
            '                        <div class="ipu-list-item-inner">\n' +
50
            '                          <label class="ipu-radio">\n' +
51
            '                            <input type="radio" name="' + item.name + '" value="' + option.value + '">' + option.name + '\n' +
52
            '                        </label>\n' +
53
            '                      </div>\n' +
54
            '                    </li>'
55
        });
56
57
      } else if (item.type == 'input') {
58
        var readonly = item.clickFun ? 'readonly' : '';
59
        optionStr = optionStr + '<li class="ipu-list-item">\n' +
60
          '                <div class="ipu-list-item-inner">\n' +
61
          '                  <div class="ipu-list-item-input-wrap">\n' +
62
          '                    <input class="ipu-list-item-input"name="' + item.name + '" type="text"' +
63
          '                     placeholder="请选择" ' + readonly + '>\n' +
64
          '                  </div>\n' +
65
          '                </div>\n' +
66
          '              </li>';
67
68
        // 绑定事件
69
        if (item.clickFun) {
70
          contentRoot.on("click", "input[name='" + item.name + "']", function () {
71
            var input = $(this);
72
            item.clickFun(function (result) {
73
              input.val(result);
74
              setConnectConfig(input.attr("name"), input.val());
75
            });
76
          });
77
        }
78
      }
79
80
      contentHtml = contentHtml + '<div class="demo-item"><p class="demo-title">' + item.label + '</p>' +
81
        '<div class="demo-body"><div class="ipu-list"><ul>' + optionStr + '</ul></div></div></div>';
82
    });
83
84
    $(contentHtml).appendTo(contentRoot);
85
  }
86
87 10
  // 初始化配置项值
88 11
  function initConfigItemValue() {
89 12
    AndroidWebView.getDeviceConfig(function (obj) {
@ -92,7 +15,7 @@ $(function () {
92 15
          var inputs = $("input[name='" + key + "']");
93 16
94 17
          if (inputs.length != 1) { // radio之类
95
            $("input[name='" + key + "'][value='" + obj[key] + "']").prop("checked", true);
18
            $("input[name='" + key + "'][value='" + obj[key] + "']").attr("checked", true);
96 19
          } else {
97 20
            inputs.val(obj[key]);
98 21
          }
@ -103,15 +26,22 @@ $(function () {
103 26
104 27
  // 页面初始化
105 28
  function init() {
106
    // 初始化配置项
107
    iniConfigItem(configItems);
108
109
    // 读取身份证缓存数据,更新配置初始值
29
    // 读取配置数据,更新到页面
110 30
    initConfigItemValue();
111 31
  }
112 32
113 33
  // 页面事件绑定
114 34
  function bindEvent() {
35
36
    // 选择蓝牙
37
    $("input[name='DEVICE_BT_ADDRESS']").click(function () {
38
      var input = $(this);
39
      AndroidWebView.btDeviceList(function (result) {
40
        input.val(result);
41
        setConnectConfig(input.attr("name"), input.val());
42
      });
43
    });
44
115 45
    // 保存配置项变动
116 46
    $("input", contentRoot).change(function () {
117 47
      setConnectConfig($(this).attr("name"), $(this).val());