请选择 进入手机版 | 继续访问电脑版
帖子
帖子
用户
博客
课程
12下一页
返回列表 发新帖
显示全部楼层
42
帖子
4
勋章
1万+
Y币

wifi模块Demo(新手教程)图文详解模块使用教程

[复制链接]
发表于 2019-5-9 16:32:40
本帖最后由 Mr.ZhouHeng 于 2019-5-17 09:32 编辑

浏览器打开开发控制台:


第一步我们需要在开发控制台创建一个Native App应用以及添模块的准备工作:



按照下图步骤



输入完点创建完成之后



最好点击添加按钮之后返回看看你是否添加了需要的模块,添加完模块之后在点击自定义的



然后云端操作就完成 接下来我们把云端代码拉取到本地







通过svn拉取本地  使用开发工具直接打开拉取到本地的代码进行开发;



如果你们使用的是官网工具apicloud-studio-2.exe
那么请看下面的链接教程把代码拉取到本地:

https://docs.apicloud.com/Dev-Tools/studio-dev-guide


拉取代码成功之后,自己修改成在工具的结构:




然后我们在打开wifi文档https://docs.apicloud.com/Client-API/Device-Access/wifi

这个路径其实直接在模块对应点击模块名字就能进入到模块文档的 ,每个模块都有这个;


ios需要特别注意文档里面提示需要添加的文件:













  1. <!DOCTYPE HTML>
  2. <html>

  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
  6.     <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
  7.     <title>wifi_frm</title>
  8.     <link rel="stylesheet" type="text/css" href="../css/api.css" />
  9.     <link rel="stylesheet" type="text/css" href="../css/box.css" />
  10.     <style media="screen">
  11.         <style>html,
  12.         body {
  13.             background-color: #ededed;
  14.         }

  15.         .list-item {
  16.             margin-top: 1px;
  17.             padding: 15px 10px;
  18.             font-size: 14px;
  19.             line-height: 180%;
  20.             position: relative;
  21.             background-color: #fff;
  22.         }

  23.         .list-item:after {
  24.             content: "  ";
  25.             position: absolute;
  26.             z-index: 77;
  27.             left: 0;
  28.             top: 0;
  29.             width: 200%;
  30.             height: 200%;
  31.             border-bottom: 1px solid #d4d4d4;
  32.             -webkit-transform-origin: 0 0;
  33.             transform-origin: 0 0;
  34.             -webkit-transform: scale(.5, .5);
  35.             transform: scale(.5, .5);
  36.         }

  37.         .left {
  38.             padding: 0px 10px;
  39.             line-height: 220%;
  40.             color: #333;
  41.         }

  42.         .list-item .title {
  43.             padding: 0px 10px;
  44.             line-height: 220%;
  45.             color: #333;
  46.             position: relative;
  47.             z-index: 88;
  48.         }

  49.         .list-item .right {
  50.             position: relative;
  51.             z-index: 99;
  52.         }

  53.         .list-item .right .state {
  54.             display: inline-block;
  55.             vertical-align: middle;
  56.             border-radius: 20px;
  57.             width: 38px;
  58.             height: 21px;
  59.             text-align: center;
  60.             line-height: 20px;
  61.             font-size: 12px;
  62.             color: #fff;
  63.         }

  64.         .list-item .right .open {
  65.             background-color: #00acff;
  66.         }

  67.         .list-item .right .open::after {
  68.             content: " ";
  69.             float: right;
  70.             margin-top: 1px;
  71.             margin-right: 1px;
  72.             width: 19px;
  73.             height: 19px;
  74.             border-radius: 50%;
  75.             background-color: #fff;
  76.             box-shadow: 0px 0px 1px 1px #d4d4d4;
  77.             -webkit-transition: all 0.2s linear;
  78.             transition: all 0.2s linear;
  79.         }

  80.         .list-item .right .close {
  81.             background-color: #ededed;
  82.         }

  83.         .list-item .right .close::after {
  84.             content: " ";
  85.             float: left;
  86.             margin-top: 1px;
  87.             margin-left: 1px;
  88.             width: 19px;
  89.             height: 19px;
  90.             border-radius: 50%;
  91.             background-color: #fff;
  92.             box-shadow: 0px 0px 1px 1px #d4d4d4;
  93.             -webkit-transition: all 0.2s linear;
  94.             transition: all 0.2s linear;
  95.         }

  96.         .center {
  97.             text-align: center;
  98.         }

  99.         .list-item .active {
  100.             color: #00acff
  101.         }
  102.     </style>

  103. </head>

  104. <body>
  105.     <!-- v-cloak -->
  106.     <div class="list" v-cloak>
  107.         <div class="list-item flex-wrap">
  108.             <div class="title flex-con ellipsis-1">{{state == true ? '已经开启WLAN' : '已经关闭WLAN'}}</div>
  109.             <div class="right" v-if="show===true" @click="fnSwitch(state)">
  110.                 <div class="state" :class="state == true ? 'open' : 'close'"></div>
  111.             </div>
  112.         </div>
  113.         <div class="list-item flex-wrap">
  114.             <div class="left">设备当前连接的wifi:</div>
  115.             <div class="title flex-con ellipsis-1">{{current}}</div>
  116.         </div>
  117.         <div class="list-item flex-wrap center" v-if="show===true">
  118.             <div class="title flex-con " :class="tab == false ? 'active' : ''" @click="fnScanWifi()">获取附近的wifi</div>
  119.             <div class="title flex-con" :class="tab == true ? 'active' : ''" @click="fnGetWifi()">获取已经配置过的wifi</div>
  120.         </div>
  121.         <div class="list-item flex-wrap" v-if="show===true&&state===true" v-for="(list,index) in items">
  122.             <div class="left">{{tab == false ? '附近' : '已经配置'}}wifi:</div>
  123.             <div class="title flex-con ellipsis-1">{{list.ssid}}</div>
  124.         </div>
  125.     </div>
  126. </body>
  127. <script src="../script/api.js"></script>
  128. <script src="../script/fastclick.js"></script>
  129. <script src="../script/vue.min.js"></script>
  130. <script>
  131.     var eWifi;
  132.     apiready = function() {
  133.         fnInVue();
  134.     }

  135.     function fnInVue() {
  136.         window.ListVue = new Vue({
  137.             el: ".list",
  138.             data: {
  139.                 current: '',
  140.                 items: [],
  141.                 show: false,
  142.                 state: false,
  143.                 tab: false
  144.             },
  145.             mounted: function() {
  146.                 this.$nextTick(function() {
  147.                     fnInit();
  148.                 });
  149.             },
  150.             methods: {
  151.                 fnSwitch: function(states) {
  152.                     console.warn(states);
  153.                     if (states) {
  154.                         fnCloseWifi();
  155.                     } else {
  156.                         fnOpenWifi();
  157.                     }
  158.                 },
  159.                 fnScanWifi: function() {
  160.                     if (this.tab === false) {
  161.                         return;
  162.                     }
  163.                     this.tab = false;
  164.                     fnScanWifiList();
  165.                 },
  166.                 fnGetWifi: function() {
  167.                     if (this.tab === true) {
  168.                         return;
  169.                     }
  170.                     this.tab = true;
  171.                     fnGetConfiguredNetworks();
  172.                 },
  173.             }
  174.         });
  175.     }

  176.     function fnInit() {
  177.         eWifi = api.require('wifi');
  178.         // 判断是ios还是安卓  从而是否显示对应权限
  179.         window.ListVue.show = api.systemType == 'ios' ? false : true;
  180.         // 获取当前wifi
  181.         fnObtainCurrent();
  182.         // 获取附近链接的wifi
  183.         fnScanWifiList();
  184.     };

  185.     // 获取当前wifi
  186.     function fnObtainCurrent() {
  187.       
  188.     后面代码请下载源码自行研究
  189. </script>

  190. </html>
复制代码






本帖子中包含更多资源,您需要 登录 才可以下载或查看,没有帐号?立即注册

X
214
帖子
5
勋章
5493
Y币
搬凳子。。。。
42
帖子
4
勋章
1万+
Y币
明天在完善一下
2
帖子
0
勋章
15
Y币
这个包下载运行报错Cannot read property 'openWifi' of undefined at wifi_frm.html : 296  我也新建了native app,加了模块,换了id。这跟vue 有关吗
2
帖子
0
勋章
15
Y币
找到原因了,另外请问你这边有做过店内wifi打卡吗
3
帖子
0
勋章
34
Y币
描述文件已经勾选了Access WiFi Information,重新生成了,代码中已经配置了entitlement 为啥还是获取失败?
42
帖子
4
勋章
1万+
Y币
谨宸科技 发表于 2019-9-8 11:52
描述文件已经勾选了Access WiFi Information,重新生成了,代码中已经配置了entitlement 为啥还是获取失败 ...

仔细看文档需要配置的东西是否漏掉了
1
帖子
0
勋章
16
Y币
可以设置wifi的密码吗,可以获取mac值吗
1
帖子
0
勋章
16
Y币
可以设置wifi发射器的密码和名称吗
42
帖子
4
勋章
1万+
Y币
ficksx 发表于 2019-12-10 11:44
可以设置wifi发射器的密码和名称吗

模块不支持更换wifi密码  账号名称
12下一页
您需要登录后才可以回帖 登录

本版积分规则