mirror of https://github.com/IoTcat/wIoT.git
parent
10476c9cf2
commit
1ded75532e
22 changed files with 1835 additions and 0 deletions
@ -0,0 +1 @@ |
||||
{} |
@ -0,0 +1,212 @@ |
||||
<!DOCTYPE html> |
||||
<html> |
||||
|
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" /> |
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> |
||||
<meta name="renderer" content="webkit"> |
||||
<title>wIoT | 轻松物联</title> |
||||
<link rel="stylesheet" type="text/css" href="amWiki/css/markdownbody.github.css" /> |
||||
<link rel="stylesheet" type="text/css" href="amWiki/css/lhjs.github-gist.css" /> |
||||
<link rel="stylesheet" type="text/css" href="amWiki/css/amWiki.css" /> |
||||
|
||||
</head> |
||||
|
||||
<body> |
||||
<!-- 头部 --> |
||||
<header class="header"> |
||||
<div class="header-inner"> |
||||
<a class="logo" href="?file=首页"> |
||||
<img src="amWiki/images/logo.png" /><i></i> |
||||
<b>wIoT 开发文档</b> |
||||
<span>by Group A22</span> |
||||
</a> |
||||
<div class="menu-icon" id="menuIcon"> |
||||
<svg> |
||||
<use xlink:href="#icon:navStart"></use> |
||||
</svg> |
||||
</div> |
||||
</div> |
||||
</header> |
||||
<!-- 页面 --> |
||||
<div class="container" id="container"> |
||||
<div class="nav" id="nav"> |
||||
<div class="menu-filter"> |
||||
<svg> |
||||
<use xlink:href="#icon:navFilter"></use> |
||||
</svg> |
||||
<input type="text" id="menuFilter" value="" placeholder="请输入筛选条件" title="请输入筛选条件" /> |
||||
<i class="off" title="清空筛选">×</i> |
||||
</div> |
||||
<div class="menu-search" id="searchShow" title="全库搜索"> |
||||
<svg> |
||||
<use xlink:href="#icon:search"></use> |
||||
</svg> |
||||
</div> |
||||
<nav class="menubar scroller" id="menuBar" data-x-rolling="true"> |
||||
<div class="scroller-inner"> |
||||
<div class="scroller-content"></div> |
||||
</div> |
||||
</nav> |
||||
</div> |
||||
<div class="main scroller" id="main"> |
||||
<div class="main-inner scroller-inner"> |
||||
<!-- 正文 --> |
||||
<article class="markdown-body scroller-content" id="view"></article> |
||||
<script id="template:footnote" type="text/html"> |
||||
<sup><a href="#fn:foot{{index}}" name="fn:note{{index}}" title="{{title}}">[{{index}}]</a></sup> |
||||
<ol class="footnote"><i>[参考资料]:</i>{{list}}</ol> |
||||
<li id="fn:foot{{index}}">{{content}} {{back}}</li> |
||||
<li class="footnote-none" data-msg="匹配缺失">{{content}}</li> |
||||
<a href="#fn:note{{index}}"> |
||||
<svg> |
||||
<use xlink:href="#icon:footnoteBack"></use> |
||||
</svg> |
||||
</a> |
||||
</script> |
||||
<!-- 上下翻页 --> |
||||
<div class="main-sibling scroller-content" id="mainSibling"> |
||||
<p><span>上一篇:</span> |
||||
<a href="#"></a> |
||||
</p> |
||||
<p><span>下一篇:</span> |
||||
<a href="#"></a> |
||||
</p> |
||||
</div> |
||||
<!-- 全库搜索 --> |
||||
<div class="search-box" id="searchBox"> |
||||
<div class="search-update"> |
||||
<input type="button" id="searchUpdate" value="更新所有缓存" /> |
||||
<div class="text"> |
||||
<p>上次完全更新:<time id="cacheLasttime">0000-00-00 00:00:00</time></p> |
||||
<p>文档总数:<b id="cacheDocTotal">0</b> <i>/</i> <span>已缓存:<i id="cacheState">0%</i></span></p> |
||||
</div> |
||||
</div> |
||||
<h2>全库搜索</h2> |
||||
<div class="search-input"> |
||||
<input type="text" id="searchText" placeholder="请输入搜索内容" /> |
||||
<input type="button" id="search" value="搜 索" /> |
||||
</div> |
||||
<div class="search-results" id="results"> |
||||
<div class="search-result-message" id="resultMsg"></div> |
||||
<ul class="search-list"></ul> |
||||
<div class="search-result-more" id="resultMore">显示更多</div> |
||||
<script id="template:searchResult" type="text/html"> |
||||
<li class="search-item"> |
||||
<a href="?file={{path}}"> |
||||
<div class="content"> |
||||
<strong>{{title}}</strong> {{api}} {{content}} |
||||
</div> |
||||
<div class="bottom"> |
||||
<p>位置:<span>{{path}}</span></p> |
||||
<div class="time">最后缓存于 |
||||
<time>{{time}}</time> |
||||
</div> |
||||
</div> |
||||
</a> |
||||
</li> |
||||
</script> |
||||
</div> |
||||
</div> |
||||
<!-- 接口测试 --> |
||||
|
||||
</div> |
||||
</div> |
||||
</div> |
||||
<aside> |
||||
<!-- 侧边目录 --> |
||||
<div class="contents" id="contents"> |
||||
<div class="btn"> |
||||
<svg> |
||||
<use xlink:href="#icon:contents"></use> |
||||
</svg> |
||||
<span>目录</span> |
||||
</div> |
||||
<div class="contents-list"> |
||||
<p> |
||||
<a id="contentsTitle" href="#客户日志流水接口示例">客户日志流水接口示例</a> |
||||
</p> |
||||
<div class="markdown-contents"></div> |
||||
</div> |
||||
</div> |
||||
<!-- 返回顶部 --> |
||||
<div class="back-top" id="backTop"> |
||||
<a class="back-icon" href="#"> |
||||
<svg> |
||||
<use xlink:href="#icon:backTop"></use> |
||||
</svg> |
||||
</a> |
||||
<a class="back-text" href="#">返回顶部</a> |
||||
</div> |
||||
</aside> |
||||
<!-- 图片预览 --> |
||||
<section class="imgsv" id="imgsView"> |
||||
<div class="imgsv-background"></div> |
||||
<div class="imgsv-view" id="imgsViewInner"></div> |
||||
<ul class="imgsv-panel"> |
||||
<li class="prev off">Prev</li> |
||||
<li class="next">Next</li> |
||||
<li class="original">1:1</li> |
||||
<li class="suit">适合</li> |
||||
</ul> |
||||
</section> |
||||
<footer> |
||||
<!-- 签名 --> |
||||
<div class="signature">Powered by |
||||
<a href="https://github.com/TevinLi/amWiki" target="_blank">amWiki</a> |
||||
</div> |
||||
</footer> |
||||
<!-- mounts --> |
||||
<div class="hidden" aw-include="mountLinks"> |
||||
<script>AWConfig={"name":"amWiki轻文库","version":"by Tevin","logo":"amWiki/images/logo.png","testing":false,"colour":"#4296eb","pageMounts":false,"githubUrl":"","libraryPrefix":""}</script> |
||||
</div> |
||||
<!-- js --> |
||||
<div class="hidden"> |
||||
<script type="text/javascript" src="amWiki/js/gbk.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/pinyin.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/jquery-compat-3.1.0.min.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/marked.min.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/highlight.pack.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/raphael-min.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/flowchart.min.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/amWiki.tools.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/amWiki.storage.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/amWiki.search.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/amWiki.search.worker.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/amWiki.docs.js"></script> |
||||
|
||||
<script type="text/javascript" src="amWiki/js/amWiki.scrollbar.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/amWiki.imgsView.js"></script> |
||||
<script type="text/javascript" src="amWiki/js/amWiki.js"></script> |
||||
|
||||
</div> |
||||
<!-- svg --> |
||||
<div class="hidden" id="svgSymbols"></div> |
||||
<!-- 低版本浏览器警告 --> |
||||
<div id="lowBrowser"> |
||||
<div></div> |
||||
<p><span>您的浏览器版本过低,不支持浏览本Wiki,请升级或更换您的浏览器再试!</span></p> |
||||
<script> |
||||
(function(win) { |
||||
var notice = document.getElementById('lowBrowser'); |
||||
//jQuery 3.x 需要 addEventListener 方法支持 |
||||
if(typeof win.addEventListener == 'undefined') { |
||||
notice.style.display = 'block'; |
||||
} else { |
||||
var comments = notice.previousSibling; |
||||
if(comments.nodeType == 8) { |
||||
comments.parentNode.removeChild(comments); |
||||
} else if(comments.previousSibling.nodeType == 8) { |
||||
comments = comments.previousSibling; |
||||
comments.parentNode.removeChild(comments); |
||||
} |
||||
notice.parentNode.removeChild(notice); |
||||
} |
||||
notice = comments = null; |
||||
})(window); |
||||
</script> |
||||
</div> |
||||
</body> |
||||
|
||||
</html> |
@ -0,0 +1,36 @@ |
||||
# amWiki 轻文库简介 |
||||
|
||||
![amWiki logo](https://amwiki.xf09.net/docs/assets/logo.png) |
||||
amWiki 是一款基于 Javascript 脚本语言、依赖 Atom 编辑器、使用 Markdown 标记语法的轻量级开源 wiki 文库系统。 |
||||
amWiki 致力于让大家可以更简单、更便捷的建设个人和团队文库系统! |
||||
|
||||
[[view amWiki on Github](https://github.com/TevinLi/amWiki)] |
||||
|
||||
GitHub: |
||||
[![](https://img.shields.io/github/stars/TevinLi/amWiki.svg?style=social&label=Star)](https://github.com/TevinLi/amWiki "GitHub Stars") |
||||
[![](https://img.shields.io/github/forks/TevinLi/amWiki.svg?style=social&label=Fork)](https://github.com/TevinLi/amWiki "GitHub Forks") |
||||
[![](https://img.shields.io/github/issues-raw/TevinLi/amWiki.svg)](https://github.com/TevinLi/amWiki "GitHub Open Issues") |
||||
[![](https://img.shields.io/github/issues-closed-raw/TevinLi/amWiki.svg)](https://github.com/TevinLi/amWiki "GitHub Closed Issues") |
||||
[![](https://img.shields.io/github/contributors/TevinLi/amWiki.svg)](https://github.com/TevinLi/amWiki "GitHub Contributors") |
||||
Apm: |
||||
[![apm](https://img.shields.io/apm/v/amWiki.svg)](https://atom.io/packages/amWiki "Apm Version") |
||||
[![apm](https://img.shields.io/apm/dm/amWiki.svg)](https://atom.io/packages/amWiki "Apm Downloads") |
||||
[![apm](https://img.shields.io/apm/l/amWiki.svg)](https://atom.io/packages/amWiki "MIT License") |
||||
|
||||
## amWiki 优势 |
||||
- 文档系统采用 Markdown 语法 [>>Markdown 快速开始](?file=001-学习amWiki/05-学习markdown/01-Markdown快速开始) |
||||
- 无需服务端开发,只需支持 http 访问的静态网页空间 |
||||
- 不使用数据库,使用 `.md` 扩展名存储文档为本地文件 |
||||
- 一键创建新文库,自动生成一套 Html 页面 |
||||
- 自动更新文库导航目录 |
||||
- 支持截图直接粘帖为本地 png 并插入当前 Markdown 文档 |
||||
- Web 端页面自适应显示,适合各种 Web 平台与屏幕尺寸 |
||||
- 支持接口文档自动抓取内容生成简单的 Ajax 测试 |
||||
- ... (更多内容期待您的发现) |
||||
|
||||
## 效果演示 |
||||
**Web端** |
||||
一键创建新文库默认生成Web端效果一览:[https://tevinli.github.io/amWiki/](https://tevinli.github.io/amWiki/index.html) |
||||
|
||||
**工作端** |
||||
工作端需要您安装 Atom 与 amWiki 才能体验 |
@ -0,0 +1,5 @@ |
||||
# amWiki 功能导图 |
||||
|
||||
![amWiki功能导图](https://amwiki.xf09.net/docs/assets/mapping.png) |
||||
|
||||
**说明**:灰色文字代表的功能部分,表示目前版本没有,但是已经列入开发计划 |
@ -0,0 +1,74 @@ |
||||
# 如何开始一个新 amWiki 轻文库 |
||||
|
||||
## 开始一个新文库的步骤 |
||||
|
||||
1. ##### 下载 Github 出品的开源文本编辑器 [Atom](https://atom.io/ "打开Atom官网"),并安装 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/02-0e63f48d.png) |
||||
|
||||
2. ##### 安装 Atom 完成之后,再安装插件 amWiki,您可以通过以下三种途径安装: |
||||
- 【方式一】:通过 Atom 菜单,File -> Setting -> Install -> 搜索 `amWiki` |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/02-ec2b10b3.png) |
||||
<br> |
||||
- 【方式二】:运行:`apm install amWiki` |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/02-37a29814.png) |
||||
<br> |
||||
- 【方式三】:从Github的 [amWiki版本发布](https://github.com/TevinLi/amWiki/releases) 下载zip,(windows)解压到 `C:\Users\Administrator\.atom\packages`,并将文件夹名 `amWiki-x.x.x` 改为 `amWiki` |
||||
|
||||
3. ##### 重启 Atom (必须) |
||||
|
||||
4. ##### 在本地您需要创建文库的位置创建一个文件夹 (非 Atom 编辑器中) |
||||
|
||||
5. ##### 在 Atom 中 `Add Project Folder` (添加项目文件夹),并指向刚创建的文件夹 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/03-7ce48bba.png) |
||||
|
||||
6. ##### 在 Atom 刚创建的项目下新建 `config.json` 文件,并按 json 格式配置以下属性: |
||||
- **name**,您的文库名称,设置但为空或不设置将显示默认名 |
||||
- **ver**,文本版本号或维护者名号,设置但为空将不显示,注意诺不设置此属性将显示 amWiki 作者 |
||||
- **logo**,logo 的 url,设置但为空或不设置将显示默认 logo |
||||
- **colour**,自定义颜色,默认为蓝色 |
||||
- **testing**,是否启用接口测试模块,默认值 false |
||||
- 例如: |
||||
```javascript |
||||
{ |
||||
"name": "A3项目文档中心", |
||||
"ver": "", |
||||
"logo": "http://abc.com/logo.jpg", |
||||
"testing": true |
||||
} |
||||
``` |
||||
7. ##### 保持 `config.json` 处于当前打开状态,在 Atom 菜单点击: |
||||
|
||||
amWiki文库 -> 通过“config.json”创建新文库 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/02-78f2030d.png) |
||||
|
||||
8. ##### 此时项目中自动创建了许多内容,其中 library 文件夹即为您的文库文件夹 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/02-d72e59a9.png) |
||||
|
||||
9. ##### 使用 `F12` 启动本地静态服务器,访问刚刚自动创建的 index.html |
||||
|
||||
|
||||
## 文库目录结构 |
||||
项目目录自动生创建的内容如下 |
||||
|
||||
index.html // http 访问入口页面 |
||||
amWiki/ // amWiki Web 端程序文件夹 |
||||
library/ // 您的 Markdown 文库目录,所有文件必须使用 .md 格式 |
||||
├ $navigation.md // amWiki 文库目录导航文件,可自动/手动更新 |
||||
├ 首页.md // Web 端打开页面时页面页面默认显示的内容 |
||||
├ 001-学习amWiki/ // Markdown 文件夹01 |
||||
│ ├ 001-关于amWiki // 一些 Markdown 文档,支持二级目录 |
||||
│ └ 002-... |
||||
├ 002-文档示范/ // Markdown 文件夹02 |
||||
│ ├ 001-通用api // 一些 Markdown 文档,支持二级目录 |
||||
│ └ 002-... |
||||
└ 003-... // 更多 Markdown 文件夹 |
||||
(assetes/) // 如果您粘帖截图,图片文件将自动创建在此处 |
||||
|
||||
|
||||
## 如何使用 |
||||
一键创建新文库后,您可以通过以下方式开始 amWiki 文库之旅: |
||||
|
||||
1. 在 Atom 编辑器中使用快捷键 `F12` 或在浏览器中使用 http 访问刚刚创建的 index.html。 |
||||
2. PC 端使用左侧导航栏、移动端使用右上角弹出菜单来切换页面。 |
||||
3. 在导航栏顶部,可以使用筛选功能通过输入关键词对整个导航目录进行筛选。 |
||||
4. 如果存在页内目录,直接点击,页内目录使用 hash 滚动;同时您可以直接带 hash 分享,以方便他人快速浏览指定内容。 |
@ -0,0 +1,56 @@ |
||||
# 如何编辑 amWiki 轻文库 |
||||
|
||||
文库创建后,您就可以编辑自己的文库了 |
||||
|
||||
## 基本编辑 |
||||
|
||||
1. ##### 新建文件或文件夹,组织您自己的文库 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/04-88742d4f.png) |
||||
|
||||
2. ##### 每个文件夹或文件要求使用 `id-名称.md` 来命名,其中: |
||||
|
||||
1. id 仅允许 **整数** 或 **浮点数** 类型,且 **不可重复** |
||||
2. 必须使用连 **接符** 或 **下划线** 将 id 与后续具体名称相连 |
||||
3. 文件只能使用 **.md** 扩展名 |
||||
|
||||
如果未能满足以上条件,将弹出以下错误提示: |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/04-4801dadd.png) |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/04-79e0b528.png) |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/04-0c4d9e7d.png) |
||||
正确的命名,例如: |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/04-12e1b01c.png) |
||||
|
||||
3. ##### 使用 Markdown 语法编辑您的文档 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/04-b3be9411.png) |
||||
|
||||
## 扩展编辑 |
||||
|
||||
1. ##### library 文件夹下 `首页.md` 文档为默认打开时的显示内容 |
||||
您可以适当修改此文档内容以符合您的项目需求 |
||||
|
||||
5. ##### `$navigation.md` 导航文件无需人工维护,创建新文件夹或文件时将自动更新,也可以在菜单栏手动刷新: |
||||
|
||||
菜单栏 -> amWiki文库 -> 手动更新当前文库导航文件 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/04-b7efbbde.png) |
||||
|
||||
6. ##### 如果需要在 Markdown 文档中插入图片,**请先截图**,然后在文档对应位置使用快捷键:`Ctrl + Shift + V` |
||||
此时,光标位置将多出一段 Markdown 图片代码,例如: |
||||
|
||||
![](assets/001/04-b7efbbde.png) |
||||
|
||||
同时,将在项目目录依次创建文件夹 assets、001 (如果不存在的话),以及此文件夹下名称为 04-b7efbbde.png 的图片文件 |
||||
|
||||
7. ##### 对于较长文章,可以使用页内目录,依次进行如下操作,或使用快捷键 `Ctrl + D`,即可在光标处插入页内目录。 |
||||
菜单栏 -> amWiki文库 -> 提取h2、h3标题为页内目录 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/04-3eb34e61.png) |
||||
注意:请按顺序使用h1、h2、h3,且h1仅使用一次。 |
||||
|
||||
8. ##### 如果启用了测试模块,想对一篇文档激活接口测试功能,请参照 [使用测试模块测试接口](?file=001-学习amWiki/06-使用测试模块测试接口) |
||||
|
||||
|
||||
## 维护与延伸 |
||||
|
||||
1. 本插件升级后,您想更新 `(projectName)/amWiki/` 文件夹下 web 端的工作文件,您只需重新打开 `config.json` 文件,然后在 Atom 菜单上选择 `通过“config.json”创建新文库` 即可。 |
||||
这个二次创建操作不会影响您 library 与 assetes 文件夹下的内容。 |
||||
|
||||
2. 借助版本管理 SVN、Git、Hg,传输协议FTP/SFTP,文件同步Dropbox、百度云等等工具,便捷实现网络访问。 |
@ -0,0 +1,183 @@ |
||||
# Markdown 快速开始 |
||||
|
||||
>1. [简介](#简介 "简介") |
||||
1. [语法快速入门](#语法快速入门 "语法快速入门") |
||||
1. [【标题】](#【标题】 "【标题】") |
||||
1. [【修辞和强调】](#【修辞和强调】 "【修辞和强调】") |
||||
1. [【删除线】](#【删除线】 "【删除线】") |
||||
1. [【列表】](#【列表】 "【列表】") |
||||
1. [【链接】](#【链接】 "【链接】") |
||||
1. [【图片】](#【图片】 "【图片】") |
||||
1. [【代码】](#【代码】 "【代码】") |
||||
1. [【代码段】](#【代码段】 "【代码段】") |
||||
1. [【表格】](#【表格】 "【表格】") |
||||
1. [【引用】](#【引用】 "【引用】") |
||||
1. [【分割线】](#【分割线】 "【分割线】") |
||||
1. [【换行】](#【换行】 "【换行】") |
||||
1. [【html】](#【html】 "【html】") |
||||
1. [研究更多 markdown 语法详细细节](#研究更多 markdown 语法详细细节 "研究更多 markdown 语法详细细节") |
||||
|
||||
|
||||
## 简介 |
||||
Markdown是为那些需要经常码字或者进行文字排版的、对码字手速和排版顺畅度有要求的人群设计的,他们希望用键盘把文字内容啪啪啪地打出来后就已经排版好了,最好从头到尾都不要使用鼠标。 |
||||
这些人包括经常需要写文档的码农、博客写手、网站小编、出版业人士等等。 |
||||
Markdown的语法简洁明了、学习容易,得到了许多著名网络平台的支持,例如代码托管平台[Github](https://github.com/)、博客平台[WordPress](https://cn.wordpress.org/)等等。 |
||||
|
||||
## 语法快速入门 |
||||
|
||||
### <font color=#C71585>【标题】</font> |
||||
在行首插入1到6个#,对应1到6阶标题 |
||||
# 这是 H1 |
||||
## 这是 H2 |
||||
### 这是 H3 |
||||
#### 这是 H4 |
||||
##### 这是 H5 |
||||
###### 这是 H6 |
||||
渲染效果: |
||||
# 这是 H1 |
||||
## 这是 H2 |
||||
### 这是 H3 |
||||
#### 这是 H4 |
||||
##### 这是 H5 |
||||
###### 这是 H6 |
||||
|
||||
### <font color=#C71585>【修辞和强调】</font> |
||||
使用星号和底线来标记需要强调的区段 |
||||
|
||||
**加粗** |
||||
__加粗__ |
||||
*斜体* |
||||
_斜体_ |
||||
|
||||
渲染效果: |
||||
**加粗** |
||||
__加粗__ |
||||
*斜体* |
||||
_斜体_ |
||||
|
||||
### <font color=#C71585>【删除线】</font> |
||||
|
||||
~~要删掉的内容~~ |
||||
|
||||
渲染效果: |
||||
~~要删掉的内容~~ |
||||
|
||||
### <font color=#C71585>【列表】</font> |
||||
**无序列表** 使用星号、加号和减号来做为列表的项目标记 |
||||
* Candy. |
||||
* Gum. |
||||
+ Booze. |
||||
* Booze. 长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本 |
||||
这里是断行-文本长文本长文本长文本 |
||||
这里是断行-文本长文本长文本长文本 |
||||
- Booze. |
||||
+ 嵌套 |
||||
* 嵌套 |
||||
|
||||
渲染效果: |
||||
* Candy. |
||||
* Gum. |
||||
+ Booze. |
||||
* Booze. 长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本长文本 |
||||
这里是断行-文本长文本长文本长文本 |
||||
这里是断行-文本长文本长文本长文本 |
||||
- Booze. |
||||
+ 嵌套 |
||||
* 嵌套 |
||||
|
||||
**有序列表** 则是使用一般的数字接着一个英文句点作为项目标记 |
||||
1. Red |
||||
50. Green |
||||
1000. Blue |
||||
|
||||
渲染效果: |
||||
1. Red |
||||
50. Green |
||||
1000. Blue |
||||
|
||||
### <font color=#C71585>【链接】</font> |
||||
在方括号后面用圆括号接上链接 |
||||
|
||||
这是一个[链接显示文本](http://www.baidu.com "链接title文本") |
||||
|
||||
渲染效果: |
||||
这是一个[链接显示文本](http://www.baidu.com "链接title文本") |
||||
|
||||
### <font color=#C71585>【图片】</font> |
||||
图片的语法和链接很像 |
||||
|
||||
![alt文本](amWiki/images/logo.png "Title") |
||||
|
||||
渲染效果: |
||||
![alt文本](amWiki/images/logo.png "Title") |
||||
|
||||
### <font color=#C71585>【代码】</font> |
||||
使用反引号 \` 来标记代码区段 |
||||
|
||||
我是`code`,`<div>division</div>` |
||||
|
||||
渲染效果: |
||||
我是`code`,`<div>division</div>` |
||||
|
||||
### <font color=#C71585>【代码段】</font> |
||||
如果要建立一个已经格式化好的代码区块,只要每行都缩进 4 个空格或是一个 tab 就可以了 |
||||
|
||||
var name = 'Candy' |
||||
|
||||
渲染效果: |
||||
|
||||
var name = 'Candy' |
||||
|
||||
### <font color=#C71585>【表格】</font> |
||||
使用竖线分割内容,且同时使用“---”与“:”指定对齐方式 |
||||
|
||||
| Header01 | Header02 | Header03 |
||||
| -------- | :------: | ---: |
||||
| 默认 | 居中 | 右 |
||||
|
||||
渲染效果: |
||||
|
||||
| Header01 | Header02 | Header03 |
||||
| -------- | :------: | ---: |
||||
| 默认 | 居中 | 右 |
||||
|
||||
### <font color=#C71585>【引用】</font> |
||||
只需要在文本前加入 > 这种尖括号(大于号)即可 |
||||
|
||||
>这里是一段引用 |
||||
|
||||
渲染效果: |
||||
>这里是一段引用 |
||||
|
||||
### <font color=#C71585>【分割线】</font> |
||||
只需要三个 \- 号 |
||||
|
||||
--- |
||||
|
||||
渲染效果: |
||||
|
||||
--- |
||||
|
||||
### <font color=#C71585>【换行】</font> |
||||
只需要两个以上的空格然后回车 |
||||
|
||||
我是首行 |
||||
我换行了 |
||||
|
||||
渲染效果: |
||||
我是首行 |
||||
我换行了 |
||||
|
||||
### <font color=#C71585>【html】</font> |
||||
可以直接在文档里书写 HTML,不需要额外标注这是 HTML |
||||
|
||||
<div>division</div> |
||||
|
||||
渲染效果: |
||||
<div>division</div> |
||||
|
||||
|
||||
## 研究更多 markdown 语法详细细节 |
||||
|
||||
- [创始人 John Gruber 的 Markdown 语法说明](http://daringfireball.net/projects/markdown/syntax) |
||||
- [Markdown 中文版语法说明](http://wowubuntu.com/markdown/) |
@ -0,0 +1,179 @@ |
||||
# amWiki 与语法高亮 |
||||
|
||||
amWiki使用 [highlight.js](https://github.com/isagalaev/highlight.js) 进行预语法高亮渲染,它能对多达一百多种语言、样式提供语法高亮解析 |
||||
使用两组每组三个反引号分单独两行将代码包围起来,并在第一组反引号后写上语言类型即可使用语法高亮,例如: |
||||
```js |
||||
//some js code here |
||||
``` |
||||
|
||||
## javascript / js 代码 |
||||
普通代码块效果: |
||||
``` |
||||
//发送验证码 |
||||
function cd(num) { |
||||
$('#code').val(num + '秒后可重发'); |
||||
setTimeout(function() { |
||||
if (num - 1 >= 0) { |
||||
cd(num - 1); |
||||
} else { |
||||
$('#code').removeClass('bg-gray').prop('disabled', false).val('重新发送验证码'); |
||||
} |
||||
}, |
||||
1000); |
||||
} |
||||
``` |
||||
``` |
||||
{ |
||||
"state": { |
||||
"code": 10200, //code状态码 |
||||
"msg": "ok" //状态描述 |
||||
}, |
||||
"data": { |
||||
"team_num": 13, //队伍数 |
||||
"position": "海珠区新港中路" //位置 |
||||
} |
||||
} |
||||
``` |
||||
|
||||
添加 `js`、`javascript` 标记后的效果: |
||||
```javascript |
||||
//发送验证码 |
||||
function cd(num) { |
||||
$('#code').val(num + '秒后可重发'); |
||||
setTimeout(function() { |
||||
if (num - 1 >= 0) { |
||||
cd(num - 1); |
||||
} else { |
||||
$('#code').removeClass('bg-gray').prop('disabled', false).val('重新发送验证码'); |
||||
} |
||||
}, |
||||
1000); |
||||
} |
||||
``` |
||||
```js |
||||
{ |
||||
"state": { |
||||
"code": 10200, //code状态码 |
||||
"msg": "ok" //状态描述 |
||||
}, |
||||
"data": { |
||||
"team_num": 13, //队伍数 |
||||
"position": "海珠区新港中路" //位置 |
||||
} |
||||
} |
||||
``` |
||||
amWiki对javascript代码片段做了再次增强,可以点击代码块右上角按钮隐藏/显示注释 |
||||
当注释处于隐藏状态时不会被复制,比较适合模拟返回json数据的接口时直接拷贝(json不允许注释) |
||||
|
||||
## Html 代码 |
||||
普通代码段效果: |
||||
``` |
||||
<body> |
||||
<div class="loading"><img src="/assets/images/loading.gif"></div> |
||||
<header>some text</header> |
||||
<script type="text/javascript" src="/assets/js/jquery-2.1.4.min.js"></script> |
||||
</body> |
||||
``` |
||||
添加 `html` 标记后的效果: |
||||
```html |
||||
<body> |
||||
<div class="loading"><img src="/assets/images/loading.gif"></div> |
||||
<header>some text</header> |
||||
<script type="text/javascript" src="/assets/js/jquery-2.1.4.min.js"></script> |
||||
</body> |
||||
``` |
||||
|
||||
## css 代码 |
||||
普通代码段效果: |
||||
``` |
||||
/* 紧凑 */ |
||||
html,body{display:block;width:100%;height:100%;min-width:320px;} |
||||
a,img{-webkit-touch-callout:none;} |
||||
/* 展开 */ |
||||
input[type="button"], |
||||
input[type="submit"], |
||||
input[type="reset"], |
||||
textarea { |
||||
-webkit-appearance: none; |
||||
} |
||||
``` |
||||
|
||||
添加 `css` 标记后的效果: |
||||
```css |
||||
/* 紧凑 */ |
||||
html,body{display:block;width:100%;height:100%;min-width:320px;} |
||||
a,img{-webkit-touch-callout:none;} |
||||
/* 展开 */ |
||||
input[type="button"], |
||||
input[type="submit"], |
||||
input[type="reset"], |
||||
textarea { |
||||
-webkit-appearance: none; |
||||
} |
||||
``` |
||||
|
||||
## php 代码 |
||||
普通代码段效果: |
||||
``` |
||||
private function addQuestData($data, $filing_id) |
||||
{ |
||||
$quest_num = $data['status'] == 10 ? 1 : 2; |
||||
$where = [ |
||||
['user_filing_id', '=', $filing_id], |
||||
['project_id', '=', $data['project_id']], |
||||
['mobile','=', $data['mobile']], |
||||
['quest_num', '=', $quest_num] |
||||
]; |
||||
} |
||||
``` |
||||
添加 `php` 标记后的效果: |
||||
```php |
||||
private function addQuestData($data, $filing_id) |
||||
{ |
||||
$quest_num = $data['status'] == 10 ? 1 : 2; |
||||
$where = [ |
||||
['user_filing_id', '=', $filing_id], |
||||
['project_id', '=', $data['project_id']], |
||||
['mobile','=', $data['mobile']], |
||||
['quest_num', '=', $quest_num] |
||||
]; |
||||
} |
||||
``` |
||||
|
||||
## sql 代码 |
||||
普通代码段效果: |
||||
``` |
||||
SELECT Company, OrderNumber FROM Orders ORDER BY Company, OrderNumber |
||||
``` |
||||
添加 `sql` 标记后的效果: |
||||
```sql |
||||
SELECT Company, OrderNumber FROM Orders ORDER BY Company, OrderNumber |
||||
``` |
||||
|
||||
## java 代码 |
||||
普通代码段效果: |
||||
``` |
||||
public class Test { |
||||
public static void main(String args[]) { |
||||
int x = 10; |
||||
while( x < 20 ) { |
||||
System.out.print("value of x : " + x ); |
||||
x++; |
||||
System.out.print("\n"); |
||||
} |
||||
} |
||||
} |
||||
``` |
||||
添加 `java` 标记后的效果: |
||||
```java |
||||
public class Test { |
||||
public static void main(String args[]) { |
||||
int x = 10; |
||||
while( x < 20 ) { |
||||
System.out.print("value of x : " + x ); |
||||
x++; |
||||
System.out.print("\n"); |
||||
} |
||||
} |
||||
} |
||||
``` |
@ -0,0 +1,83 @@ |
||||
# amWiki 与流程图 |
||||
|
||||
amWiki 使用 [flowchart.js](https://github.com/adrai/flowchart.js) 进行流程图渲染,它是一款将文本表达式绘制为简单的 svg 流程图的图形库 |
||||
流程图代码块和语法高亮类似,不过类型声明须用 `flow` 关键字 |
||||
```flow |
||||
//your flow text here |
||||
``` |
||||
|
||||
## 流程图样例 |
||||
代码: |
||||
|
||||
```flow |
||||
st=>start: Start :>https://amwiki.xf09.net[blank] |
||||
e=>end: End :>https://amwiki.xf09.net[blank] |
||||
op1=>operation: My Operation |
||||
op2=>operation: Stuff |
||||
sub1=>subroutine: My Subroutine |
||||
cond=>condition: Yes or No? :>https://amwiki.xf09.net[blank] |
||||
c2=>condition: Good idea |
||||
io=>inputoutput: catch something... |
||||
|
||||
st->op1(right)->cond |
||||
cond(yes, right)->c2 |
||||
cond(no)->sub1(left)->op1 |
||||
c2(yes)->io->e |
||||
c2(no)->op2->e |
||||
``` |
||||
效果: |
||||
|
||||
```flow |
||||
st=>start: Start :>https://amwiki.xf09.net[blank] |
||||
e=>end: End :>https://amwiki.xf09.net[blank] |
||||
op1=>operation: My Operation |
||||
op2=>operation: Stuff |
||||
sub1=>subroutine: My Subroutine |
||||
cond=>condition: Yes or No? :>https://amwiki.xf09.net[blank] |
||||
c2=>condition: Good idea |
||||
io=>inputoutput: catch something... |
||||
|
||||
st->op1(right)->cond |
||||
cond(yes, right)->c2 |
||||
cond(no)->sub1(left)->op1 |
||||
c2(yes)->io->e |
||||
c2(no)->op2->e |
||||
``` |
||||
|
||||
## 流程图语法介绍 |
||||
流程图语法分两个部分,一个是声明元素,一个是定义流程 |
||||
|
||||
### 声明元素 |
||||
语法: |
||||
|
||||
tag=>type: content :>url |
||||
|
||||
1. `tag` 设置元素名称 |
||||
2. `=>` 元素定义符 |
||||
2. `type:` 设置元素类型,共分6种: |
||||
- **start**:开始,圆角矩形 |
||||
- **end**:结束,圆角矩形 |
||||
- **operation**:操作/行动方案,普通矩形 |
||||
- **subroutine**:子主题/模块,双边线矩形 |
||||
- **condition**:条件判断/问题审核,菱形 |
||||
- **inputoutput**:输入输出,平行四边形 |
||||
3. `content` 设置元素显示内容,中英均可 |
||||
4. `:>url` 设置元素连接,可选,后接 [blank] 可以新建窗口打开 |
||||
|
||||
提示:注意空格,`=>` 前后都不能接空格;`type:` 后必须接空格;`:>` 是语法标记,中间不能有空格 |
||||
|
||||
### 定义流程 |
||||
语法: |
||||
|
||||
tag1(branch,direction)->tag2 |
||||
|
||||
1. `->` 流程定义符,连接两个元素 |
||||
2. `branch` 设置 condition 类型元素的两个分支,有 `yes`/`no` 两个值,其他元素无效 |
||||
3. `direction` 定义流程走线方向,有 `left`/`right`/`top`/`bottom` 四个值,所有元素有效,此项配置可选 (ps:此属性容易造成渲染 bug) |
||||
|
||||
小提示: |
||||
- 继续注意空格,`->` 前后都不能有空格 |
||||
- 由于 condition 类型有两个分支,我们一般遇到 condition 元素就换行书写,比如: |
||||
st->op1-c2 |
||||
c2(yes)->io->e |
||||
c2(no)->op2->e |
@ -0,0 +1,52 @@ |
||||
# Atom 编辑器对 Markdown 的原生支持 |
||||
|
||||
Atom 是 Github 开发的开源跨平台的编辑器,原生支持编辑 Markdown 文档 |
||||
|
||||
## 自动完成 Markdown 语法标记 |
||||
|
||||
### 代码段效果-code |
||||
输入 `c + Enter` |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/13-2c594bb9.png) |
||||
|
||||
### 粗体效果-bold |
||||
输入 `b + Enter` |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/13-8620325c.png) |
||||
|
||||
### 斜体效果-italic |
||||
输入 `i + Enter` |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/13-0e8a6768.png) |
||||
|
||||
### 链接效果-link |
||||
输入 `l + Enter` |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/13-5bd90b0f.png) |
||||
|
||||
### 图片效果-img |
||||
输入 `im + Enter` |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/13-e03a0fc8.png) |
||||
|
||||
### 表格效果-table |
||||
输入 `ta + Enter` |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/13-fbed2544.png) |
||||
|
||||
<!-- |
||||
### todo效果-list |
||||
输入`t + Enter` |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/13-01a27e09.png) |
||||
--> |
||||
|
||||
## 自动补齐二次单词输入 |
||||
在第二次输入时,单词可以自动识别与补齐,回车即可完成输入 |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/13-efba45f0.png) |
||||
|
||||
## 内置 Markdown 即时预览插件 |
||||
编辑 Markdown 文档时,使用快捷键 `ctrl + shift + m` 即可在窗口右侧打开 Atom 内置的 markdown-preview 即时预览模块 |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/13-75213ccd.png) |
@ -0,0 +1,60 @@ |
||||
# 使用测试模块测试接口 |
||||
|
||||
让文档与测试一步搞定! |
||||
|
||||
## 激活测试的条件 |
||||
##### 当一篇文档中使用了 `“请求地址”`、`“请求类型”`、`“请求参数”` 三个字段作为 `h3标题` 并配套对应内容时,将激活接口测试功能 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/06-8a6d91f1.png) |
||||
(详细书写格式请参照[通用API接口文档示例](?file=002-文档示范/001-通用API接口文档示例)) |
||||
|
||||
##### 此时文档右上角将出现 `“接口测试”` 按钮,例如: |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/04-e412c7fd.png) |
||||
|
||||
## 接口测试的工作原理与步骤 |
||||
1. 当测试模块处于打开状态时,每次打开文档都会扫描文档转换 html 后的内容,满足三个 h3 时即开启测试功能 |
||||
2. 开启当前文档测试功能后,即会从页面上 **抓取** 符合一定格式的测试内容 |
||||
3. 格式化抓取的内容并生成可再次修改的表单 |
||||
4. 用户点击发送请求时,先并入全局参数到当前参数列表,再发送请求 |
||||
5. 收到请求结果,格式化显示 |
||||
|
||||
## 接口测试文档的格式要求 |
||||
|
||||
### 请求地址的格式 |
||||
请求地址可以使用带 http 与不带 http 两种,下面两种写法都是合适的 |
||||
|
||||
/api/customer-flow |
||||
http://localhost/api/customer-flow |
||||
|
||||
注意,不带 http 将自动和当前域名拼合为完整绝对路径,而不是使用相对路径 |
||||
|
||||
### 请求类型的格式 |
||||
amWiki 暂时只支持 **Get**、**Post**、**Put**、**Delete** 四种普通 ajax 请求,不支持文件上传和其他高级方式通讯 |
||||
|
||||
### 请求参数的格式 |
||||
- 当接口不需要参数时,直接使用 **“无”** 即可 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/06-e030ca95.png) |
||||
- 请求参数列表必须使用 **表格**,且必须按 `参数名`、`类型`、`必填`、`描述`、`默认值`、`参考值` 的栏目顺序建立表格,否则不能正常抓取。 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/06-5a7fda87.png) |
||||
其中: |
||||
- 默认值与参考值同属参数的值,但是优先显示默认值,只有当没有默认值时参考值才有效,参考值是为了方便测试之用 |
||||
- 参考值一栏可选,不写参考值的整个表格栏位,不会影响测试功能 |
||||
|
||||
## 测试功能应用 |
||||
|
||||
### 测试面板 |
||||
抓取测试内容生成测试表单如下 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/06-c0d8d3cb.png) |
||||
|
||||
### 全局参数面板 |
||||
全局参数影响所有接口,在全局参数面板可以进行新增、删除全局参数以及临时启用/禁用全局参数等操作 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/06-c19f1829.png) |
||||
|
||||
### 返回响应 |
||||
成功的响应: |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/06-6f851b27.png) |
||||
失败的响应: |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/06-bf211990.png) |
||||
|
||||
## 测试模块的问题 |
||||
- 测试模只能请求同域接口,不能跨域。 (跨域解决方案请参考[amWiki转接到任意域名进行接口测试](?file=001-学习amWiki/30-amWiki转接到任意域名进行接口测试)) |
||||
- 如果接口需要登录权限,请先登录您自己的系统。 |
@ -0,0 +1,73 @@ |
||||
# amWiki 转接到任意域名进行接口测试 |
||||
|
||||
我们分两种情况进行文档转接,一种是我们有域名服务器操作权限,一种是没有 |
||||
|
||||
## 有域名服务器操作权限的转接 |
||||
如果我们有域名服务器操作权限,那要把其他域名下的文档转接到当前域名下,其实很简单,就是一个 **反向代理** 的过程 |
||||
|
||||
以 nginx 为例,将地址 https://amwiki.xf09.net/docs/ 下所有文档转接到任意域名(_无需https_) /wiki 路径下 |
||||
```nginx |
||||
server { |
||||
listen 81; |
||||
server_name abc123.com; |
||||
location /wiki { |
||||
proxy_pass https://amwiki.xf09.net/docs/; |
||||
proxy_redirect off; |
||||
#proxy_set_header Host $host; |
||||
proxy_set_header X-Real-IP $remote_addr; |
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; |
||||
proxy_max_temp_file_size 0k; |
||||
proxy_connect_timeout 90; |
||||
proxy_send_timeout 90; |
||||
proxy_read_timeout 90; |
||||
proxy_buffer_size 4k; |
||||
proxy_buffers 4 32k; |
||||
proxy_busy_buffers_size 64k; |
||||
proxy_temp_file_write_size 64k; |
||||
} |
||||
# other settings ... |
||||
} |
||||
``` |
||||
|
||||
## 无域名服务器操作权限 |
||||
此时,如果想要将我们的文档转接到对应域名上去,需要利用抓包工具 Fiddler 进行 **请求代理** |
||||
(_请下载安装抓包工具 [Fiddler](http://www.telerik.com/fiddler),并了解 AutoResponder 面板的使用_) |
||||
|
||||
由于 https 特殊性,我们分两种情况来讨论: |
||||
|
||||
### http 请求代理 |
||||
当原域名基于 http 通信时,由于 http 请求是一种很开放的通信,我们可以直接用 fiddler 非常简单的进行转接 |
||||
|
||||
比如,我们继续把地址 https://amwiki.xf09.net/docs/ 下所有文档转接到任意域名 /wiki 路径下 |
||||
只需要如下配置 AutoResponder: |
||||
|
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/07-c1ef9812.png) |
||||
规则代码如下: |
||||
|
||||
regex:.+abc123\.com\/wiki\/(.+)$ |
||||
https://amwiki.xf09.net/docs/$1 |
||||
|
||||
第一行代码为请求匹配,其中 `regex:` 表示按正则表达式进行匹配,`.+abc123\.com\/wiki\/` 表示需要代理的路径,`(.+)$` (和第二行配合)表示转接后续的路径,即将后续路径替换到第二行代码中的 `$1` |
||||
|
||||
| | 转接地址 | 实际请求地址 | |
||||
| : ---| :--- | :--- | |
||||
| 例1 | http://abc123.com/wiki/index.html | https://amwiki.xf09.net/docs/index.html | |
||||
| 例2 | http://abc123.com/wiki/amWiki/js/amWiki.js | https://amwiki.xf09.net/docs/amWiki/js/amWiki.js | |
||||
|
||||
### https 请求代理 |
||||
当原域名基于 https 通讯是,我们需要更多的操作才能使用代理 (Fiddler 抓包 https 的原理,有兴趣可自行知乎一下) |
||||
|
||||
- **第一步,开启 https 解码** |
||||
Tools -> Fiddler Options -> HTTPS -> 依次勾选如下 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/07-ea6ad78e.png) |
||||
- **第二步,是安装 Fiddler 根证书** |
||||
打开 http://localhost:8888/ 下载Fiddler 根证书并安装 |
||||
![](https://amwiki.xf09.net/docs/assets/001.tiny/07-c59334fc.png) |
||||
- **第三步,按照 http 的方式进行代理** |
||||
例如,我们转接到百度域名的一个路径下 |
||||
|
||||
regex:.+www\.baidu\.com\/wiki\/(.+)$ |
||||
https://amwiki.xf09.net/docs/$1 |
||||
|
||||
此时,我们打开 https://www.baidu.com/wiki/index.html 会发现,不再是“很抱歉,您要访问的页面不存在!”了 |
@ -0,0 +1,55 @@ |
||||
# 客户日志流水接口示例 |
||||
>维护人员:**Tevin** |
||||
>创建时间:2016-04-06 |
||||
|
||||
## 接口简介 |
||||
实时查询客户各种操作(例如登录,拓客等)的流水日志 |
||||
|
||||
## 接口详情 |
||||
|
||||
### 请求地址 |
||||
/api/customer-flow |
||||
|
||||
### 请求类型 |
||||
GET |
||||
|
||||
### 请求参数 |
||||
| 参数名 | 类型 | 必填 | 描述 | 默认值 | 参考值 | |
||||
| --- | :---: | :---: | --- | --- | --- | |
||||
| customer_id | number | 是 | 客户id | - | 132 | |
||||
| type | number | 否 | 客户类型,0所有、1扩展、2报备、3成交 | - | 1 | |
||||
|
||||
### 返回正确JSON示例 |
||||
```javascript |
||||
{ |
||||
"state": { |
||||
"code": 10200, |
||||
"msg": "ok" |
||||
}, |
||||
"data": { |
||||
"id": 307, //流水id |
||||
"real_name": "Tevin", //用户名称 |
||||
"mobile": "暂无", //用户手机 |
||||
"origin": "暂无", //用户来源 |
||||
"created_at": "2016-04-04 20:00:00", //加入时间 |
||||
"last_login": "2016-05-22 15:30:21", //最后登录时间 |
||||
"log": [] //日志列表 |
||||
} |
||||
} |
||||
``` |
||||
### 返回错误JSON示例 |
||||
```javascript |
||||
{ |
||||
"state": { |
||||
"code": 10500 |
||||
"msg": "服务器未知报错" |
||||
} |
||||
} |
||||
``` |
||||
|
||||
### 备注说明 |
||||
无 |
||||
|
||||
### 修改日志 |
||||
- 【2016-05-22】 |
||||
新增了last_login最后登录时间字段 |
@ -0,0 +1,651 @@ |
||||
# 微信JS-SDK说明文档(超长文档页内目录示例) |
||||
|
||||
>1. [概述](#概述 "概述") |
||||
1. [JSSDK使用步骤](#JSSDK使用步骤 "JSSDK使用步骤") |
||||
1. [接口调用说明](#接口调用说明 "接口调用说明") |
||||
1. [基础接口](#基础接口 "基础接口") |
||||
1. [判断当前客户端版本是否支持指定JS接口](#判断当前客户端版本是否支持指定JS接口 "判断当前客户端版本是否支持指定JS接口") |
||||
1. [分享接口](#分享接口 "分享接口") |
||||
1. [获取“分享到朋友圈”按钮点击状态及自定义分享内容接口](#获取“分享到朋友圈”按钮点击状态及自定义分享内容接口 "获取“分享到朋友圈”按钮点击状态及自定义分享内容接口") |
||||
1. [获取“分享给朋友”按钮点击状态及自定义分享内容接口](#获取“分享给朋友”按钮点击状态及自定义分享内容接口 "获取“分享给朋友”按钮点击状态及自定义分享内容接口") |
||||
1. [获取“分享到QQ”按钮点击状态及自定义分享内容接口](#获取“分享到QQ”按钮点击状态及自定义分享内容接口 "获取“分享到QQ”按钮点击状态及自定义分享内容接口") |
||||
1. [获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口](#获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口 "获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口") |
||||
1. [获取“分享到QQ空间”按钮点击状态及自定义分享内容接口](#获取“分享到QQ空间”按钮点击状态及自定义分享内容接口 "获取“分享到QQ空间”按钮点击状态及自定义分享内容接口") |
||||
1. [图像接口](#图像接口 "图像接口") |
||||
1. [拍照或从手机相册中选图接口](#拍照或从手机相册中选图接口 "拍照或从手机相册中选图接口") |
||||
1. [预览图片接口](#预览图片接口 "预览图片接口") |
||||
1. [上传图片接口](#上传图片接口 "上传图片接口") |
||||
1. [下载图片接口](#下载图片接口 "下载图片接口") |
||||
1. [音频接口](#音频接口 "音频接口") |
||||
1. [开始录音接口](#开始录音接口 "开始录音接口") |
||||
1. [停止录音接口](#停止录音接口 "停止录音接口") |
||||
1. [监听录音自动停止接口](#监听录音自动停止接口 "监听录音自动停止接口") |
||||
1. [播放语音接口](#播放语音接口 "播放语音接口") |
||||
1. [暂停播放接口](#暂停播放接口 "暂停播放接口") |
||||
1. [停止播放接口](#停止播放接口 "停止播放接口") |
||||
1. [监听语音播放完毕接口](#监听语音播放完毕接口 "监听语音播放完毕接口") |
||||
1. [上传语音接口](#上传语音接口 "上传语音接口") |
||||
1. [下载语音接口](#下载语音接口 "下载语音接口") |
||||
1. [智能接口](#智能接口 "智能接口") |
||||
1. [识别音频并返回识别结果接口](#识别音频并返回识别结果接口 "识别音频并返回识别结果接口") |
||||
1. [设备信息](#设备信息 "设备信息") |
||||
1. [获取网络状态接口](#获取网络状态接口 "获取网络状态接口") |
||||
1. [地理位置](#地理位置 "地理位置") |
||||
1. [使用微信内置地图查看位置接口](#使用微信内置地图查看位置接口 "使用微信内置地图查看位置接口") |
||||
1. [获取地理位置接口](#获取地理位置接口 "获取地理位置接口") |
||||
1. [摇一摇周边](#摇一摇周边 "摇一摇周边") |
||||
1. [开启查找周边ibeacon设备接口](#开启查找周边ibeacon设备接口 "开启查找周边ibeacon设备接口") |
||||
1. [关闭查找周边ibeacon设备接口](#关闭查找周边ibeacon设备接口 "关闭查找周边ibeacon设备接口") |
||||
1. [监听周边ibeacon设备接口](#监听周边ibeacon设备接口 "监听周边ibeacon设备接口") |
||||
1. [界面操作](#界面操作 "界面操作") |
||||
1. [隐藏右上角菜单接口](#隐藏右上角菜单接口 "隐藏右上角菜单接口") |
||||
1. [显示右上角菜单接口](#显示右上角菜单接口 "显示右上角菜单接口") |
||||
1. [关闭当前网页窗口接口](#关闭当前网页窗口接口 "关闭当前网页窗口接口") |
||||
1. [批量隐藏功能按钮接口](#批量隐藏功能按钮接口 "批量隐藏功能按钮接口") |
||||
1. [批量显示功能按钮接口](#批量显示功能按钮接口 "批量显示功能按钮接口") |
||||
1. [隐藏所有非基础按钮接口](#隐藏所有非基础按钮接口 "隐藏所有非基础按钮接口") |
||||
1. [显示所有功能按钮接口](#显示所有功能按钮接口 "显示所有功能按钮接口") |
||||
1. [微信扫一扫](#微信扫一扫 "微信扫一扫") |
||||
1. [调起微信扫一扫接口](#调起微信扫一扫接口 "调起微信扫一扫接口") |
||||
1. [微信小店](#微信小店 "微信小店") |
||||
1. [跳转微信商品页接口](#跳转微信商品页接口 "跳转微信商品页接口") |
||||
1. [微信卡券](#微信卡券 "微信卡券") |
||||
1. [获取api_ticket](#获取api_ticket "获取api_ticket") |
||||
1. [拉取适用卡券列表并获取用户选择信息](#拉取适用卡券列表并获取用户选择信息 "拉取适用卡券列表并获取用户选择信息") |
||||
1. [批量添加卡券接口](#批量添加卡券接口 "批量添加卡券接口") |
||||
1. [查看微信卡包中的卡券接口](#查看微信卡包中的卡券接口 "查看微信卡包中的卡券接口") |
||||
1. [核销后再次赠送卡券接口](#核销后再次赠送卡券接口 "核销后再次赠送卡券接口") |
||||
1. [微信支付](#微信支付 "微信支付") |
||||
1. [发起一个微信支付请求](#发起一个微信支付请求 "发起一个微信支付请求") |
||||
|
||||
|
||||
## 概述 |
||||
|
||||
微信JS-SDK是微信公众平台面向网页开发者提供的基于微信内的网页开发工具包。 |
||||
|
||||
通过使用微信JS-SDK,网页开发者可借助微信高效地使用拍照、选图、语音、位置等手机系统的能力,同时可以直接使用微信分享、扫一扫、卡券、支付等微信特有的能力,为微信用户提供更优质的网页体验。 |
||||
|
||||
此文档面向网页开发者介绍微信JS-SDK如何使用及相关注意事项。 |
||||
|
||||
### JSSDK使用步骤 |
||||
|
||||
#### 步骤一:绑定域名 |
||||
|
||||
先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。**如果你使用了支付类接口,请确保支付目录在该安全域名下,否则将无法完成支付。** |
||||
|
||||
备注:登录后可在“开发者中心”查看对应的接口权限。 |
||||
|
||||
#### 步骤二:引入JS文件 |
||||
|
||||
在需要调用JS接口的页面引入如下JS文件,(支持https): |
||||
[http://res.wx.qq.com/open/js/jweixin-1.0.0.js](http://res.wx.qq.com/open/js/jweixin-1.0.0.js) |
||||
|
||||
**请注意,如果你的页面启用了https,务必引入** [https://res.wx.qq.com/open/js/jweixin-1.0.0.js](https://res.wx.qq.com/open/js/jweixin-1.0.0.js) ,**否则将无法在iOS9.0以上系统中成功使用JSSDK** |
||||
|
||||
如需使用摇一摇周边功能,请引入 jweixin-1.1.0.js |
||||
|
||||
备注:支持使用 AMD/CMD 标准模块加载方法加载 |
||||
|
||||
#### 步骤三:通过config接口注入权限验证配置 |
||||
|
||||
**所有需要使用JS-SDK的页面必须先注入配置信息,否则将无法调用**(同一个url仅需调用一次,对于变化url的SPA的web app可在每次url变化时进行调用,目前Android微信客户端不支持pushState的H5新特性,所以使用pushState来实现web app的页面会导致签名失败,此问题会在Android6.2中修复)。 |
||||
|
||||
```javascript |
||||
wx.config({ |
||||
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 |
||||
appId: '', // 必填,公众号的唯一标识 |
||||
timestamp: , // 必填,生成签名的时间戳 |
||||
nonceStr: '', // 必填,生成签名的随机串 |
||||
signature: '',// 必填,签名,见附录1 |
||||
jsApiList: [] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 |
||||
}); |
||||
``` |
||||
|
||||
#### 步骤四:通过ready接口处理成功验证 |
||||
```javascript |
||||
wx.ready(function(){ |
||||
// config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。 |
||||
}); |
||||
``` |
||||
|
||||
#### 步骤五:通过error接口处理失败验证 |
||||
```javascript |
||||
wx.error(function(res){ |
||||
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。 |
||||
}); |
||||
``` |
||||
### 接口调用说明 |
||||
|
||||
所有接口通过wx对象(也可使用jWeixin对象)来调用,参数是一个对象,除了每个接口本身需要传的参数之外,还有以下通用参数: |
||||
|
||||
1. success:接口调用成功时执行的回调函数。 |
||||
1. fail:接口调用失败时执行的回调函数。 |
||||
1. complete:接口调用完成时执行的回调函数,无论成功或失败都会执行。 |
||||
1. cancel:用户点击取消时的回调函数,仅部分有用户取消操作的api才会用到。 |
||||
1. trigger: 监听Menu中的按钮点击时触发的方法,该方法仅支持Menu中的相关接口。 |
||||
|
||||
备注:**不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回。** |
||||
|
||||
以上几个函数都带有一个参数,类型为对象,其中除了每个接口本身返回的数据之外,还有一个通用属性errMsg,其值格式如下: |
||||
|
||||
1. 调用成功时:"xxx:ok" ,其中xxx为调用的接口名 |
||||
1. 用户取消时:"xxx:cancel",其中xxx为调用的接口名 |
||||
1. 调用失败时:其值为具体错误信息 |
||||
|
||||
## 基础接口 |
||||
|
||||
### 判断当前客户端版本是否支持指定JS接口 |
||||
|
||||
```javascript |
||||
wx.checkJsApi({ |
||||
jsApiList: ['chooseImage'], // 需要检测的JS接口列表,所有JS接口列表见附录2, |
||||
success: function(res) { |
||||
// 以键值对的形式返回,可用的api值true,不可用为false |
||||
// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"} |
||||
} |
||||
}); |
||||
``` |
||||
备注:checkJsApi接口是客户端6.0.2新引入的一个预留接口,第一期开放的接口均可不使用checkJsApi来检测。 |
||||
|
||||
### 分享接口 |
||||
|
||||
请注意不要有诱导分享等违规行为,对于诱导分享行为将永久回收公众号接口权限,详细规则请查看:朋友圈管理常见问题。 |
||||
|
||||
### 获取“分享到朋友圈”按钮点击状态及自定义分享内容接口 |
||||
|
||||
```javascript |
||||
wx.onMenuShareTimeline({ |
||||
title: '', // 分享标题 |
||||
link: '', // 分享链接 |
||||
imgUrl: '', // 分享图标 |
||||
success: function () { |
||||
// 用户确认分享后执行的回调函数 |
||||
}, |
||||
cancel: function () { |
||||
// 用户取消分享后执行的回调函数 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
### 获取“分享给朋友”按钮点击状态及自定义分享内容接口 |
||||
```javascript |
||||
wx.onMenuShareAppMessage({ |
||||
title: '', // 分享标题 |
||||
desc: '', // 分享描述 |
||||
link: '', // 分享链接 |
||||
imgUrl: '', // 分享图标 |
||||
type: '', // 分享类型,music、video或link,不填默认为link |
||||
dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 |
||||
success: function () { |
||||
// 用户确认分享后执行的回调函数 |
||||
}, |
||||
cancel: function () { |
||||
// 用户取消分享后执行的回调函数 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
### 获取“分享到QQ”按钮点击状态及自定义分享内容接口 |
||||
```javascript |
||||
wx.onMenuShareQQ({ |
||||
title: '', // 分享标题 |
||||
desc: '', // 分享描述 |
||||
link: '', // 分享链接 |
||||
imgUrl: '', // 分享图标 |
||||
success: function () { |
||||
// 用户确认分享后执行的回调函数 |
||||
}, |
||||
cancel: function () { |
||||
// 用户取消分享后执行的回调函数 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
### 获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口 |
||||
```javascript |
||||
wx.onMenuShareWeibo({ |
||||
title: '', // 分享标题 |
||||
desc: '', // 分享描述 |
||||
link: '', // 分享链接 |
||||
imgUrl: '', // 分享图标 |
||||
success: function () { |
||||
// 用户确认分享后执行的回调函数 |
||||
}, |
||||
cancel: function () { |
||||
// 用户取消分享后执行的回调函数 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
### 获取“分享到QQ空间”按钮点击状态及自定义分享内容接口 |
||||
```javascript |
||||
wx.onMenuShareQZone({ |
||||
title: '', // 分享标题 |
||||
desc: '', // 分享描述 |
||||
link: '', // 分享链接 |
||||
imgUrl: '', // 分享图标 |
||||
success: function () { |
||||
// 用户确认分享后执行的回调函数 |
||||
}, |
||||
cancel: function () { |
||||
// 用户取消分享后执行的回调函数 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
## 图像接口 |
||||
|
||||
### 拍照或从手机相册中选图接口 |
||||
```javascript |
||||
wx.chooseImage({ |
||||
count: 1, // 默认9 |
||||
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 |
||||
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 |
||||
success: function (res) { |
||||
var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
### 预览图片接口 |
||||
```javascript |
||||
wx.previewImage({ |
||||
current: '', // 当前显示图片的http链接 |
||||
urls: [] // 需要预览的图片http链接列表 |
||||
}); |
||||
``` |
||||
|
||||
### 上传图片接口 |
||||
```javascript |
||||
wx.uploadImage({ |
||||
localId: '', // 需要上传的图片的本地ID,由chooseImage接口获得 |
||||
isShowProgressTips: 1, // 默认为1,显示进度提示 |
||||
success: function (res) { |
||||
var serverId = res.serverId; // 返回图片的服务器端ID |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
备注:上传图片有效期3天,可用微信多媒体接口下载图片到自己的服务器,此处获得的 serverId 即 media_id,参考文档 ../12/58bfcfabbd501c7cd77c19bd9cfa8354.html 目前多媒体文件下载接口的频率限制为10000次/天,如需要调高频率,请邮件weixin-open@qq.com,邮件主题为【申请多媒体接口调用量】,请对你的项目进行简单描述,附上产品体验链接,并对用户量和使用量进行说明。 |
||||
|
||||
### 下载图片接口 |
||||
```javascript |
||||
wx.downloadImage({ |
||||
serverId: '', // 需要下载的图片的服务器端ID,由uploadImage接口获得 |
||||
isShowProgressTips: 1, // 默认为1,显示进度提示 |
||||
success: function (res) { |
||||
var localId = res.localId; // 返回图片下载后的本地ID |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
## 音频接口 |
||||
|
||||
### 开始录音接口 |
||||
```javascript |
||||
wx.startRecord(); |
||||
``` |
||||
|
||||
### 停止录音接口 |
||||
```javascript |
||||
wx.stopRecord({ |
||||
success: function (res) { |
||||
var localId = res.localId; |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
### 监听录音自动停止接口 |
||||
```javascript |
||||
wx.onVoiceRecordEnd({ |
||||
// 录音时间超过一分钟没有停止的时候会执行 complete 回调 |
||||
complete: function (res) { |
||||
var localId = res.localId; |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
### 播放语音接口 |
||||
```javascript |
||||
wx.playVoice({ |
||||
localId: '' // 需要播放的音频的本地ID,由stopRecord接口获得 |
||||
}); |
||||
``` |
||||
|
||||
### 暂停播放接口 |
||||
```javascript |
||||
wx.pauseVoice({ |
||||
localId: '' // 需要暂停的音频的本地ID,由stopRecord接口获得 |
||||
}); |
||||
``` |
||||
|
||||
### 停止播放接口 |
||||
```javascript |
||||
wx.stopVoice({ |
||||
localId: '' // 需要停止的音频的本地ID,由stopRecord接口获得 |
||||
}); |
||||
``` |
||||
|
||||
### 监听语音播放完毕接口 |
||||
```javascript |
||||
wx.onVoicePlayEnd({ |
||||
success: function (res) { |
||||
var localId = res.localId; // 返回音频的本地ID |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
### 上传语音接口 |
||||
```javascript |
||||
wx.uploadVoice({ |
||||
localId: '', // 需要上传的音频的本地ID,由stopRecord接口获得 |
||||
isShowProgressTips: 1, // 默认为1,显示进度提示 |
||||
success: function (res) { |
||||
var serverId = res.serverId; // 返回音频的服务器端ID |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
备注:上传语音有效期3天,可用微信多媒体接口下载语音到自己的服务器,此处获得的 serverId 即 media_id,参考文档 ../12/58bfcfabbd501c7cd77c19bd9cfa8354.html 目前多媒体文件下载接口的频率限制为10000次/天,如需要调高频率,请邮件weixin-open@qq.com,邮件主题为【申请多媒体接口调用量】,请对你的项目进行简单描述,附上产品体验链接,并对用户量和使用量进行说明。 |
||||
|
||||
### 下载语音接口 |
||||
```javascript |
||||
wx.downloadVoice({ |
||||
serverId: '', // 需要下载的音频的服务器端ID,由uploadVoice接口获得 |
||||
isShowProgressTips: 1, // 默认为1,显示进度提示 |
||||
success: function (res) { |
||||
var localId = res.localId; // 返回音频的本地ID |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
## 智能接口 |
||||
|
||||
### 识别音频并返回识别结果接口 |
||||
```javascript |
||||
wx.translateVoice({ |
||||
localId: '', // 需要识别的音频的本地Id,由录音相关接口获得 |
||||
isShowProgressTips: 1, // 默认为1,显示进度提示 |
||||
success: function (res) { |
||||
alert(res.translateResult); // 语音识别的结果 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
## 设备信息 |
||||
|
||||
### 获取网络状态接口 |
||||
```javascript |
||||
wx.getNetworkType({ |
||||
success: function (res) { |
||||
var networkType = res.networkType; // 返回网络类型2g,3g,4g,wifi |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
## 地理位置 |
||||
|
||||
### 使用微信内置地图查看位置接口 |
||||
```javascript |
||||
wx.openLocation({ |
||||
latitude: 0, // 纬度,浮点数,范围为90 ~ -90 |
||||
longitude: 0, // 经度,浮点数,范围为180 ~ -180。 |
||||
name: '', // 位置名 |
||||
address: '', // 地址详情说明 |
||||
scale: 1, // 地图缩放级别,整形值,范围从1~28。默认为最大 |
||||
infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转 |
||||
}); |
||||
``` |
||||
|
||||
### 获取地理位置接口 |
||||
```javascript |
||||
wx.getLocation({ |
||||
type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' |
||||
success: function (res) { |
||||
var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90 |
||||
var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。 |
||||
var speed = res.speed; // 速度,以米/每秒计 |
||||
var accuracy = res.accuracy; // 位置精度 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
## 摇一摇周边 |
||||
|
||||
### 开启查找周边ibeacon设备接口 |
||||
```javascript |
||||
wx.startSearchBeacons({ |
||||
ticket: "", // 摇周边的业务ticket, 系统自动添加在摇出来的页面链接后面 |
||||
complete: function(argv) { |
||||
// 开启查找完成后的回调函数 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
备注:如需接入摇一摇周边功能,请参考:申请开通摇一摇周边 |
||||
|
||||
### 关闭查找周边ibeacon设备接口 |
||||
```javascript |
||||
wx.stopSearchBeacons({ |
||||
complete:function(res){ |
||||
//关闭查找完成后的回调函数 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
### 监听周边ibeacon设备接口 |
||||
```javascript |
||||
wx.onSearchBeacons({ |
||||
complete:function(argv){ |
||||
//回调函数,可以数组形式取得该商家注册的在周边的相关设备列表 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
备注:上述摇一摇周边接口使用注意事项及更多返回结果说明,请参考:摇一摇周边获取设备信息 |
||||
|
||||
## 界面操作 |
||||
|
||||
### 隐藏右上角菜单接口 |
||||
```javascript |
||||
wx.hideOptionMenu(); |
||||
``` |
||||
|
||||
### 显示右上角菜单接口 |
||||
```javascript |
||||
wx.showOptionMenu(); |
||||
``` |
||||
|
||||
### 关闭当前网页窗口接口 |
||||
```javascript |
||||
wx.closeWindow(); |
||||
``` |
||||
|
||||
### 批量隐藏功能按钮接口 |
||||
```javascript |
||||
wx.hideMenuItems({ |
||||
menuList: [] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3 |
||||
}); |
||||
``` |
||||
|
||||
### 批量显示功能按钮接口 |
||||
```javascript |
||||
wx.showMenuItems({ |
||||
menuList: [] // 要显示的菜单项,所有menu项见附录3 |
||||
}); |
||||
``` |
||||
|
||||
### 隐藏所有非基础按钮接口 |
||||
```javascript |
||||
wx.hideAllNonBaseMenuItem(); |
||||
// “基本类”按钮详见附录3 |
||||
``` |
||||
|
||||
### 显示所有功能按钮接口 |
||||
```javascript |
||||
wx.showAllNonBaseMenuItem(); |
||||
``` |
||||
|
||||
## 微信扫一扫 |
||||
|
||||
### 调起微信扫一扫接口 |
||||
```javascript |
||||
wx.scanQRCode({ |
||||
needResult: 0, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果, |
||||
scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码,默认二者都有 |
||||
success: function (res) { |
||||
var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
## 微信小店 |
||||
|
||||
### 跳转微信商品页接口 |
||||
```javascript |
||||
wx.openProductSpecificView({ |
||||
productId: '', // 商品id |
||||
viewType: '' // 0.默认值,普通商品详情页1.扫一扫商品详情页2.小店商品详情页 |
||||
}); |
||||
``` |
||||
|
||||
## 微信卡券 |
||||
|
||||
微信卡券接口中使用的签名凭证api_ticket,与步骤三中config使用的签名凭证jsapi_ticket不同,开发者在调用微信卡券JS-SDK的过程中需依次完成两次不同的签名,并确保凭证的缓存。 |
||||
|
||||
### 获取api_ticket |
||||
|
||||
api_ticket 是用于调用微信卡券JS API的临时票据,有效期为7200 秒,通过access_token 来获取。 |
||||
|
||||
开发者注意事项: |
||||
|
||||
1. **此用于卡券接口签名的api_ticket与步骤三中通过config接口注入权限验证配置使用的jsapi_ticket不同。** |
||||
2. 由于获取api_ticket 的api 调用次数非常有限,频繁刷新api_ticket 会导致api调用受限,影响自身业务,开发者需在自己的服务存储与更新api_ticket。 |
||||
|
||||
#### 接口调用请求说明 |
||||
|
||||
http请求方式: GET |
||||
https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=wx_card |
||||
|
||||
#### 参数说明 |
||||
| 参数 | 是否必须 | 说明 | |
||||
| --- | --- | --- | |
||||
| access_token | 是 | 调用接口凭证 | |
||||
|
||||
#### 返回数据 |
||||
|
||||
数据示例: |
||||
```JSON |
||||
{ |
||||
"errcode": 0, |
||||
"errmsg": "ok", |
||||
"ticket": "bxLdikRXVbTPdHSM05e5u5sUoXNKdvsdshFKA", |
||||
"expires_in": 7200 |
||||
} |
||||
``` |
||||
| 参数名 | 描述 |
||||
| --- | --- |
||||
| errcode | 错误码 |
||||
| errmsg | 错误信息 |
||||
| ticket | api_ticket,卡券接口中签名所需凭证 |
||||
| expires_in | 有效时间 |
||||
|
||||
### 拉取适用卡券列表并获取用户选择信息 |
||||
```javascript |
||||
wx.chooseCard({ |
||||
shopId: '', // 门店Id |
||||
cardType: '', // 卡券类型 |
||||
cardId: '', // 卡券Id |
||||
timestamp: 0, // 卡券签名时间戳 |
||||
nonceStr: '', // 卡券签名随机串 |
||||
signType: '', // 签名方式,默认'SHA1' |
||||
cardSign: '', // 卡券签名 |
||||
success: function (res) { |
||||
var cardList= res.cardList; // 用户选中的卡券列表信息 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
|参数名 |必填 |类型 |示例值 |描述 |
||||
| --- | --- | --- | --- | --- |
||||
|shopId |否 |string(24) |1234 |门店ID。shopID用于筛选出拉起带有指定location_list(shopID)的卡券列表,非必填。 |
||||
|cardType |否 |string(24) |GROUPON |卡券类型,用于拉起指定卡券类型的卡券列表。当cardType为空时,默认拉起所有卡券的列表,非必填。 |
||||
|cardId |否 |string(32) |p1Pj9jr90_SQRaVqYI239Ka1erk |卡券ID,用于拉起指定cardId的卡券列表,当cardId为空时,默认拉起所有卡券的列表,非必填。 |
||||
|timestamp |是 |string(32) |14300000000 |时间戳。 |
||||
|nonceStr |是 |string(32) |sduhi123 |随机字符串。 |
||||
|signType |是 |string(32) |SHA1 |签名方式,目前仅支持SHA1 |
||||
|cardSign |是 |string(64) |abcsdijcous123 |签名。 |
||||
|
||||
cardSign详见附录4。开发者特别注意:签名错误会导致拉取卡券列表异常为空,请仔细检查参与签名的参数有效性。 |
||||
|
||||
**特别提醒** |
||||
|
||||
拉取列表仅与用户本地卡券有关,拉起列表异常为空的情况通常有三种:签名错误、时间戳无效、筛选机制有误。请开发者依次排查定位原因。 |
||||
|
||||
### 批量添加卡券接口 |
||||
```javascript |
||||
wx.addCard({ |
||||
cardList: [{ |
||||
cardId: '', |
||||
cardExt: '' |
||||
}], // 需要添加的卡券列表 |
||||
success: function (res) { |
||||
var cardList = res.cardList; // 添加的卡券列表信息 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
cardExt详见附录4,值得注意的是,这里的card_ext参数必须与参与签名的参数一致,格式为字符串而不是Object,否则会报签名错误。 |
||||
|
||||
### 查看微信卡包中的卡券接口 |
||||
```javascript |
||||
wx.openCard({ |
||||
cardList: [{ |
||||
cardId: '', |
||||
code: '' |
||||
}]// 需要打开的卡券列表 |
||||
}); |
||||
``` |
||||
|
||||
### 核销后再次赠送卡券接口 |
||||
```javascript |
||||
wx.consumeAndShareCard({ |
||||
cardId: '', |
||||
code: '' |
||||
}); |
||||
``` |
||||
|
||||
参数说明: |
||||
|
||||
|参数 |说明 |
||||
| --- | --- |
||||
|cardId |上一步核销的card_id,若传入错误的card_id会报错 |
||||
|code |上一步核销的code,若传入错误的code会报错 |
||||
|
||||
注意: |
||||
该接口只支持微信6.3.6以上版本的客户端,开发者在调用时需要注意两点: |
||||
|
||||
1. 需要引入1.1.0版本的js文件: https://res.wx.qq.com/open/js/jweixin-1.1.0.js |
||||
2. 需要判断用户客户端版本号,做出容错处理,详情点击:判断当前客户端版本是否支持指定JS接口 |
||||
|
||||
## 微信支付 |
||||
|
||||
### 发起一个微信支付请求 |
||||
```javascript |
||||
wx.chooseWXPay({ |
||||
timestamp: 0, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 |
||||
nonceStr: '', // 支付签名随机串,不长于 32 位 |
||||
package: '', // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***) |
||||
signType: '', // 签名方式,默认为'SHA1',使用新版支付需传入'MD5' |
||||
paySign: '', // 支付签名 |
||||
success: function (res) { |
||||
// 支付成功后的回调函数 |
||||
} |
||||
}); |
||||
``` |
||||
|
||||
备注:prepay_id 通过微信支付统一下单接口拿到,paySign 采用统一的微信支付 Sign 签名生成方法,注意这里 appId 也要参与签名,appId 与 config 中传入的 appId 一致,即最后参与签名的参数有appId, timeStamp, nonceStr, package, signType。 |
||||
|
||||
**请注意该接口只能在你配置的支付目录下调用,同时需确保支付目录在JS接口安全域名下。** |
||||
|
||||
微信支付开发文档:[https://pay.weixin.qq.com/wiki/doc/api/index.html](https://pay.weixin.qq.com/wiki/doc/api/index.html) |
@ -0,0 +1,2 @@ |
||||
##目前支持的设备 Current Support devices |
||||
**D1 MINI** |
@ -0,0 +1,13 @@ |
||||
##°²×°Node.js Install Node.js |
||||
Node.js is a widely used programming language for web developers. To make use of wIoT, you should first install Node.js to your computer. |
||||
|
||||
For **windows** user, you can follow the instruction in [this website](https://www.jianshu.com/p/03a76b2e7e00) |
||||
|
||||
##ÒýÈëwIoTÒÀÀµ Install wIoT package |
||||
After install Node.js and configure npm successfully, you should then use npm to download wIoT package by enter following command in your command window. |
||||
Windows user can use cmd or powershell |
||||
`npm install wiot` |
||||
It should be notice that this may report error for some users. The solution is to open your cmd window as administrator. |
||||
You right click on cmd and choose *run as an administrator*. |
||||
You can also press windows+R and input *cmd* then press Ctrl+Shift+Enter to open it as administrator. |
||||
|
@ -0,0 +1,16 @@ |
||||
##Connect your device to D1 MINI |
||||
After burning the firmware, you should try to connect your device to D1 MINI |
||||
Follow the steps below, I'm sure it would not be a problem for such a smart person like you |
||||
|
||||
###1. Reset your D1 MINI |
||||
Find pin **D0** on your D1 MINI, it should be in the middle of A0 and D5. |
||||
Use a wire to connect **3V3** to **D0**. If your MINI works normally, you would see its BUILT-IN LED blink. |
||||
You **don't** have to wait until it stops blink, just stay for **2s**, then you can pull out the wire and your MINI would reset. |
||||
|
||||
###2.Find your D1 MINI on your device |
||||
After you finish step 1, your MINI would work in AP mode, which means you can search it with your smart phone or personal computer by scanning the Wi-Fi around |
||||
If your MINI was reset successfully, you would find a Wi-Fi with SSID in the form of **wiot-xx:xx:xx:xx:xx:xx**. |
||||
Example: |
||||
![altÎı¾](amWiki/images/ssid.png "Title") |
||||
"xx:xx:xx:xx:xx:xx" is the MAC address of this MINI, please try to remember the address for you may use it later |
||||
The default password for D1 MINI is **1234567890**, enter the password and you should be able to connect to your MINI. |
@ -0,0 +1,20 @@ |
||||
##Connect D1 MINI to your Wi-Fi |
||||
Congratulations, you have successfully connect your device to D1 MINI |
||||
However, this is not the end, you should now try to connect D1 MINI to your Wi-Fi |
||||
Use the device which had just been connected to D1 MINI and follow the steps below |
||||
|
||||
###1. Visit the control page of D1 MINI |
||||
Visit **http://192.168.0.1** with the browser on your device |
||||
Normally, you would see a webpage like this: |
||||
![altÎı¾](amWiki/images/webpage.png "Title") |
||||
In this page, you can see the MAC Address and wIoT version of your MINI |
||||
Again, please **remember** the MAC Address |
||||
|
||||
###2. Submit SSID and password to your MINI |
||||
From the page, you can see two blanks that ask the SSID and password of your Wi-Fi |
||||
Input information of the Wi-FI which you would like to connect your MINI, click *Submit* |
||||
If you have input the right SSID and password, you will see a page showing the message: **Set Successfully!! Rebooting!!** |
||||
Then, after a minute, you will see the SSID of D1 MINI has vanished |
||||
|
||||
If you submitted the wrong message, do not try to directly reconnect to D1 MINI. Restart the whole procedure from the reset part of the last section |
||||
|
@ -0,0 +1,35 @@ |
||||
##Execute Example Code |
||||
If you have successfully connect D1 MINI to your Wi-Fi, you can execute the example code below to realize a simple function of wIoT |
||||
Before executing the code, you should first connect a LED to D1 MINI with positive pole connect to pin D4 and negative pole connect to GND |
||||
|
||||
|
||||
``` |
||||
var wiot = require('wiot'); //Import wiot package from npm |
||||
|
||||
// Create an object of single chip |
||||
// Here are two parameters£¬MAC is the MAC adress of single chip£¬the output port should be defined in pin |
||||
// The MAC address should be editted by user |
||||
var MyMCU = new wiot.client({MAC: "3C:71:BF:3A:F6:CF", pin: {D4 : 1}, hint : true}); |
||||
|
||||
|
||||
// The following code can let the BUILTIN_LED turn on for one second and off for one second periodically |
||||
|
||||
// Wait for all the chips to get ready |
||||
wiot.begin([MyMCU], ()=>{ // First parameter is the name of chip£¬second parameter is the function that is going to be executed |
||||
// Set timer£¬pin 3 of MyMCU will pull up every 2 seconds |
||||
setInterval(()=>{ |
||||
MyMCU.write(wiot.D4, wiot.HIGH); |
||||
}, 2000); |
||||
|
||||
// Set timer£¬executer the command in {} after a one-second delay |
||||
setTimeout(()=>{ |
||||
|
||||
// Set timer£¬pin 3 of MyMCU will pull down every 2 seconds |
||||
setInterval(()=>{ |
||||
MyMCU.write(wiot.D4, wiot.LOW); |
||||
}, 2000); |
||||
}, 1000); |
||||
}); |
||||
``` |
||||
|
||||
The LED is expected to blink after you execute the code |
@ -0,0 +1,10 @@ |
||||
# wIoT 开发文档 |
||||
|
||||
<br> |
||||
|
||||
![欢迎使用wIoT!](amWiki/images/logo.png "欢迎使用wIoT!") |
||||
|
||||
### 欢迎使用 wIoT 说明文档! |
||||
—— **wIoT 重新定义物联网!** |
||||
|
||||
[ [wIoT 官网文档中心](https://wiot.eee.dog) ] |
Loading…
Reference in new issue