├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── api
├── api.js
├── baseApi.js
└── interfaces.js
├── app.js
├── app.json
├── app.wxss
├── config
├── chapters.js
└── projects.js
├── images
├── about.png
├── collect.png
├── head_def.png
├── ic_arrow.png
├── ic_arrow_down.png
├── ic_article.png
├── ic_article_fill.png
├── ic_btn_collect.png
├── ic_btn_collect_def.png
├── ic_category.png
├── ic_category_fill.png
├── ic_home.png
├── ic_home_fill.png
├── ic_knowledge_system.png
├── ic_me.png
├── ic_me_fill.png
├── ic_todo.png
└── search_gray.png
├── jsconfig.json
├── pages
├── article
│ ├── article.js
│ ├── article.json
│ ├── article.wxml
│ └── article.wxss
├── collect
│ ├── collect.js
│ ├── collect.json
│ ├── collect.wxml
│ └── collect.wxss
├── index
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
├── login
│ ├── login.js
│ ├── login.json
│ ├── login.wxml
│ └── login.wxss
├── logs
│ ├── logs.js
│ ├── logs.json
│ ├── logs.wxml
│ └── logs.wxss
├── me
│ ├── me.js
│ ├── me.json
│ ├── me.wxml
│ └── me.wxss
├── project
│ ├── project.js
│ ├── project.json
│ ├── project.wxml
│ └── project.wxss
├── register
│ ├── register.js
│ ├── register.json
│ ├── register.wxml
│ └── register.wxss
├── search
│ ├── search.js
│ ├── search.json
│ ├── search.wxml
│ └── search.wxss
├── todo
│ ├── todo.js
│ ├── todo.json
│ ├── todo.wxml
│ └── todo.wxss
├── todoadd
│ ├── add.js
│ ├── add.json
│ ├── add.wxml
│ └── add.wxss
├── tree
│ ├── tree.js
│ ├── tree.json
│ ├── tree.wxml
│ └── tree.wxss
├── treelist
│ ├── treelist.js
│ ├── treelist.json
│ ├── treelist.wxml
│ └── treelist.wxss
├── waterfall
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
└── web
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
├── project.config.json
├── screenshot
├── 1.jpg
├── 10.jpg
├── 11.jpg
├── 12.jpg
├── 13.jpg
├── 2.jpg
├── 3.jpg
├── 4.jpg
├── 5.jpg
├── 6.jpg
├── 7.jpg
├── 8.jpg
└── 9.jpg
├── typings
└── wx.d.ts
└── utils
└── util.js
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.associations": {
3 | "*.wxml": "html",
4 | "*.wxss": "css"
5 | }
6 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 玩Android-小程序版
2 |
3 | 关注[wanandroid](http://www.wanandroid.com)有些时日了,一直以来也是鸿洋大神的粉丝,一直都有用他开放的[api](http://www.wanandroid.com/blog/show/2)此前是使用kotlin完成了一个版本【[wanandroid](https://github.com/leiyun1993/WanAndroid)】,这次我们使用微信小程序完成一个版本。
4 |
5 | 没有申请公众号并且小程序只支持https所以不能发体验,仅作为交流之用,希望大家看的开心、玩的愉快~
6 |
7 | ## 简介
8 | 开发工具:小程序开发工具1.02.1811290---[下载地址](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)
9 |
10 | 调试基础版本:2.4.1
11 |
12 | ## 项目截图
13 |
14 | 
15 | 
16 | 
17 | 
18 | 
19 | 
20 | 
21 | 
22 | 
23 | 
24 | 
25 | 
26 | 
27 |
28 | ## 部分功能解析
29 |
30 | ### 1、网络请求
31 | 加入ES6 Promise 封装网络请求,同时处理登录时候的cookie保存,并持久化
32 | ``` JavaScript
33 | let request = (url, data, type) => new Promise((resolve, reject) => {
34 | wx.request({
35 | url: 'http://www.wanandroid.com' + url,
36 | data: data,
37 | method: type, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
38 | header: {
39 | 'content-type': 'application/x-www-form-urlencoded', // 默认值
40 | "cookie": wx.getStorageSync("cookie")
41 | },
42 | success: function(res) {
43 | // success
44 | if (res.data.errorCode === 0) {
45 | if (url == interfaces.INTERFACE_USER_LOGIN){
46 | wx.setStorageSync("cookie", res.header['Set-Cookie'])
47 | }
48 | resolve(res.data);
49 | } else {
50 | reject(res.data)
51 | }
52 | },
53 | fail: function(err) {
54 | // fail
55 | reject(err)
56 | },
57 | complete: function() {
58 | // complete
59 | }
60 | })
61 | })
62 | ```
63 | 这样处理回调的时候就可以很简单的如下处理:
64 | ```JavaScript
65 | import api from "../../api/api.js";
66 | api.IPostCollect(id)
67 | .then(res => {
68 | //success
69 | })
70 | .catch(e => {
71 | //fail
72 | })
73 | ```
74 |
75 | ## 版本信息
76 | ### v1.0.0
77 | - [x] 首页文章与Banner
78 | - [x] 微信文章
79 | - [x] 项目
80 | - [x] 登录
81 | - [x] 注册
82 | - [x] 我的收藏
83 | - [x] 知识体系
84 | - [x] TODO工具
85 | - [x] 搜索功能
86 | - [x] 优化项目页瀑布流显示
87 |
88 | ## TKS
89 | * 感谢鸿洋大神创建了这么好的学习网站[WanAndroid](http://www.wanandroid.com)
90 |
91 | ## License
92 | ```text
93 | Copyright 2018 YunLei
94 |
95 | Licensed under the Apache License, Version 2.0 (the "License");
96 | you may not use this file except in compliance with the License.
97 | You may obtain a copy of the License at
98 |
99 | http://www.apache.org/licenses/LICENSE-2.0
100 |
101 | Unless required by applicable law or agreed to in writing, software
102 | distributed under the License is distributed on an "AS IS" BASIS,
103 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104 | See the License for the specific language governing permissions and
105 | limitations under the License.
106 | ```
107 |
--------------------------------------------------------------------------------
/api/api.js:
--------------------------------------------------------------------------------
1 | import baseAPI from "./baseApi.js";
2 | import interfaces from "./interfaces.js";
3 | export default {
4 | IGetBanner(params) {
5 | const result = baseAPI.request(interfaces.INTERFACE_GET_BANNER, params, "GET");
6 | return result;
7 | },
8 | IGetArticle(page, params) {
9 | const result = baseAPI.request("/article/list/" + page + "/json", params, "GET");
10 | return result;
11 | },
12 | IGetWXArticle(userID, page, params) {
13 | const result = baseAPI.request("/wxarticle/list/" + userID + "/" + page + "/json", params, "GET");
14 | return result;
15 | },
16 | IGetNewProjects(page, params) {
17 | const result = baseAPI.request("/article/listproject/" + (page - 1) + "/json", params, "GET");
18 | return result;
19 | },
20 | IGetProjects(cid, page, params) {
21 | const result = baseAPI.request("/project/list/" + page + "/json?cid=" + cid, params, "GET");
22 | return result;
23 | },
24 | IGetCollectList(page, params) {
25 | const result = baseAPI.request("/lg/collect/list/" + (page-1) + "/json", params, "GET");
26 | return result;
27 | },
28 | IPostUserLogin(params) {
29 | const result = baseAPI.request(interfaces.INTERFACE_USER_LOGIN, params, "POST");
30 | return result;
31 | },
32 | IPostUserRegister(params) {
33 | const result = baseAPI.request(interfaces.INTERFACE_REGISTER, params, "POST");
34 | return result;
35 | },
36 | IGetArticleQuery(page,params) {
37 | const result = baseAPI.request("/article/query/" + (page - 1) + "/json", params, "POST");
38 | return result;
39 | },
40 | IGetHotKey(params) {
41 | const result = baseAPI.request(interfaces.INTERFACE_HOT_KEY, params, "GET");
42 | return result;
43 | },
44 | IGetTodo(status,page,params){
45 | const result = baseAPI.request("/lg/todo/v2/list/"+page+"/json?status="+status, params, "GET");
46 | return result;
47 | },
48 | IPostTodoDone(id,params){
49 | const result = baseAPI.request("/lg/todo/done/" + id + "/json", params, "POST");
50 | return result;
51 | },
52 | IPostTodoDelete(id, params) {
53 | const result = baseAPI.request("/lg/todo/delete/" + id + "/json", params, "POST");
54 | return result;
55 | },
56 | IPostTodoAdd(params) {
57 | const result = baseAPI.request("/lg/todo/add/json", params, "POST");
58 | return result;
59 | },
60 | IGetTree(params) {
61 | const result = baseAPI.request(interfaces.INTERFACE_TREE, params, "GET");
62 | return result;
63 | },
64 | IGetTreeArticle(cid,page, params) {
65 | const result = baseAPI.request("/article/list/" + (page-1) + "/json?cid="+cid, params, "GET");
66 | return result;
67 | },
68 | IPostCollect(id,params) {
69 | const result = baseAPI.request("/lg/collect/"+id+"/json", params, "POST");
70 | return result;
71 | },
72 | IPostArticleUnCollect(id,params) {
73 | const result = baseAPI.request("/lg/uncollect_originId/"+id+"/json", params, "POST");
74 | return result;
75 | },
76 | IPostArticleMyUnCollect(id, params) {
77 | const result = baseAPI.request("/lg/uncollect/" + id + "/json", params, "POST");
78 | return result;
79 | },
80 | }
--------------------------------------------------------------------------------
/api/baseApi.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | import interfaces from "./interfaces.js";
3 | let request = (url, data, type) => new Promise((resolve, reject) => {
4 | wx.request({
5 | url: 'http://www.wanandroid.com' + url,
6 | data: data,
7 | method: type, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
8 | header: {
9 | 'content-type': 'application/x-www-form-urlencoded', // 默认值
10 | "cookie": wx.getStorageSync("cookie")
11 | },
12 | success: function(res) {
13 | // success
14 | if (res.data.errorCode === 0) {
15 | if (url == interfaces.INTERFACE_USER_LOGIN || url == interfaces.INTERFACE_REGISTER) {
16 | wx.setStorageSync("cookie", res.header['Set-Cookie'])
17 | }
18 | resolve(res.data);
19 | } else {
20 | reject(res.data)
21 | }
22 | },
23 | fail: function(err) {
24 | // fail
25 | reject(err)
26 | },
27 | complete: function() {
28 | // complete
29 | }
30 | })
31 | })
32 | module.exports = {
33 | request
34 | }
--------------------------------------------------------------------------------
/api/interfaces.js:
--------------------------------------------------------------------------------
1 | "use strict"
2 | export default{
3 | INTERFACE_GET_BANNER:"/banner/json",
4 | INTERFACE_USER_LOGIN:"/user/login",
5 | INTERFACE_HOT_KEY:"/hotkey/json",
6 | INTERFACE_TREE:"/tree/json",
7 | INTERFACE_REGISTER:"/user/register",
8 | }
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function() {
4 | this.checkUpdata();
5 | },
6 | /**
7 | * 检查小程序是否有升级版本
8 | */
9 | checkUpdata() {
10 | // 获取小程序更新机制兼容
11 | if (wx.canIUse('getUpdateManager')) {
12 | let updateManager = wx.getUpdateManager()
13 | updateManager.onCheckForUpdate(function(res) {
14 | // 请求完新版本信息的回调
15 | if (res.hasUpdate) {
16 | updateManager.onUpdateReady(function() {
17 | wx.showModal({
18 | title: '更新提示',
19 | content: '新版本已经准备好,是否重启应用?',
20 | success: function(res) {
21 | if (res.confirm) {
22 | // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
23 | updateManager.applyUpdate()
24 | }
25 | }
26 | })
27 | })
28 | updateManager.onUpdateFailed(function() {
29 | // 新的版本下载失败
30 | wx.showModal({
31 | title: '已经有新版本了哟~',
32 | content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
33 | })
34 | })
35 | } else {
36 | console.log("无新版本", res)
37 | }
38 | })
39 | } else {
40 | // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
41 | wx.showModal({
42 | title: '提示',
43 | content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
44 | })
45 | }
46 | },
47 | isLogin(){
48 | if(wx.getStorageSync("cookie")){
49 | return true;
50 | }
51 | return false;
52 | },
53 | globalData: {
54 | userInfo: null
55 | }
56 | })
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/index/index",
4 | "pages/logs/logs",
5 | "pages/article/article",
6 | "pages/project/project",
7 | "pages/me/me",
8 | "pages/web/index",
9 | "pages/collect/collect",
10 | "pages/login/login",
11 | "pages/search/search",
12 | "pages/todo/todo",
13 | "pages/todoadd/add",
14 | "pages/waterfall/index",
15 | "pages/tree/tree",
16 | "pages/treelist/treelist",
17 | "pages/register/register"
18 | ],
19 | "window": {
20 | "backgroundTextStyle": "dark",
21 | "navigationBarBackgroundColor": "#fff",
22 | "navigationBarTitleText": "玩安卓Mini",
23 | "navigationBarTextStyle": "black"
24 | },
25 | "tabBar": {
26 | "color": "#666",
27 | "selectedColor": "#222",
28 | "list": [
29 | {
30 | "pagePath": "pages/index/index",
31 | "text": "首页",
32 | "iconPath": "/images/ic_home.png",
33 | "selectedIconPath": "/images/ic_home_fill.png"
34 | },
35 | {
36 | "pagePath": "pages/article/article",
37 | "text": "文章",
38 | "iconPath": "/images/ic_article.png",
39 | "selectedIconPath": "/images/ic_article_fill.png"
40 | },
41 | {
42 | "pagePath": "pages/project/project",
43 | "text": "项目",
44 | "iconPath": "/images/ic_category.png",
45 | "selectedIconPath": "/images/ic_category_fill.png"
46 | },
47 | {
48 | "pagePath": "pages/me/me",
49 | "text": "我的",
50 | "iconPath": "/images/ic_me.png",
51 | "selectedIconPath": "/images/ic_me_fill.png"
52 | }
53 | ]
54 | }
55 | }
--------------------------------------------------------------------------------
/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | page{
3 | background-color: #f5f5f5;
4 | }
5 |
6 | .container {
7 | height: 100%;
8 | display: flex;
9 | flex-direction: column;
10 | align-items: center;
11 | justify-content: space-between;
12 | padding: 200rpx 0;
13 | box-sizing: border-box;
14 | }
15 |
16 | view{
17 | font-size: 28rpx;
18 | color: #222;
19 | }
20 |
21 | /* 加载更多 */
22 |
23 | .weui-loading {
24 | margin: 0 5px;
25 | width: 20px;
26 | height: 20px;
27 | display: inline-block;
28 | vertical-align: middle;
29 | -webkit-animation: weuiLoading 1s steps(12, end) infinite;
30 | animation: weuiLoading 1s steps(12, end) infinite;
31 | background: transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat;
32 | background-size: 100%;
33 | }
34 |
35 | .weui-loadmore {
36 | width: 65%;
37 | margin: 25rpx auto;
38 | line-height: 1.6em;
39 | font-size: 14px;
40 | text-align: center;
41 | }
42 |
43 | .weui-loadmore__tips {
44 | display: inline-block;
45 | vertical-align: middle;
46 | color: #999;
47 | }
48 |
--------------------------------------------------------------------------------
/config/chapters.js:
--------------------------------------------------------------------------------
1 | "use strict"
2 | export default {
3 | chapters: [{
4 | "children": [],
5 | "courseId": 13,
6 | "id": 408,
7 | "name": "鸿洋",
8 | "order": 190000,
9 | "parentChapterId": 407,
10 | "userControlSetTop": false,
11 | "visible": 1
12 | },
13 | {
14 | "children": [],
15 | "courseId": 13,
16 | "id": 409,
17 | "name": "郭霖",
18 | "order": 190001,
19 | "parentChapterId": 407,
20 | "userControlSetTop": false,
21 | "visible": 1
22 | },
23 | {
24 | "children": [],
25 | "courseId": 13,
26 | "id": 410,
27 | "name": "玉刚说",
28 | "order": 190002,
29 | "parentChapterId": 407,
30 | "userControlSetTop": false,
31 | "visible": 1
32 | },
33 | {
34 | "children": [],
35 | "courseId": 13,
36 | "id": 411,
37 | "name": "承香墨影",
38 | "order": 190003,
39 | "parentChapterId": 407,
40 | "userControlSetTop": false,
41 | "visible": 1
42 | },
43 | {
44 | "children": [],
45 | "courseId": 13,
46 | "id": 413,
47 | "name": "Android群英传",
48 | "order": 190004,
49 | "parentChapterId": 407,
50 | "userControlSetTop": false,
51 | "visible": 1
52 | },
53 | {
54 | "children": [],
55 | "courseId": 13,
56 | "id": 414,
57 | "name": "code小生",
58 | "order": 190005,
59 | "parentChapterId": 407,
60 | "userControlSetTop": false,
61 | "visible": 1
62 | },
63 | {
64 | "children": [],
65 | "courseId": 13,
66 | "id": 415,
67 | "name": "谷歌开发者",
68 | "order": 190006,
69 | "parentChapterId": 407,
70 | "userControlSetTop": false,
71 | "visible": 1
72 | },
73 | {
74 | "children": [],
75 | "courseId": 13,
76 | "id": 416,
77 | "name": "奇卓社",
78 | "order": 190007,
79 | "parentChapterId": 407,
80 | "userControlSetTop": false,
81 | "visible": 1
82 | },
83 | {
84 | "children": [],
85 | "courseId": 13,
86 | "id": 417,
87 | "name": "美团技术团队",
88 | "order": 190008,
89 | "parentChapterId": 407,
90 | "userControlSetTop": false,
91 | "visible": 1
92 | }
93 | ]
94 | }
--------------------------------------------------------------------------------
/config/projects.js:
--------------------------------------------------------------------------------
1 | "use strict"
2 | export default{
3 | projects: [
4 | {
5 | "children": [
6 |
7 | ],
8 | "courseId": 13,
9 | "id": 99999,
10 | "name": "最新项目",
11 | "order": 145000,
12 | "parentChapterId": 293,
13 | "userControlSetTop": false,
14 | "visible": 0
15 | },
16 | {
17 | "children": [
18 |
19 | ],
20 | "courseId": 13,
21 | "id": 294,
22 | "name": "完整项目",
23 | "order": 145000,
24 | "parentChapterId": 293,
25 | "userControlSetTop": false,
26 | "visible": 0
27 | },
28 | {
29 | "children": [
30 |
31 | ],
32 | "courseId": 13,
33 | "id": 402,
34 | "name": "跨平台应用",
35 | "order": 145001,
36 | "parentChapterId": 293,
37 | "userControlSetTop": false,
38 | "visible": 1
39 | },
40 | {
41 | "children": [
42 |
43 | ],
44 | "courseId": 13,
45 | "id": 367,
46 | "name": "资源聚合类",
47 | "order": 145002,
48 | "parentChapterId": 293,
49 | "userControlSetTop": false,
50 | "visible": 1
51 | },
52 | {
53 | "children": [
54 |
55 | ],
56 | "courseId": 13,
57 | "id": 323,
58 | "name": "动画",
59 | "order": 145003,
60 | "parentChapterId": 293,
61 | "userControlSetTop": false,
62 | "visible": 1
63 | },
64 | {
65 | "children": [
66 |
67 | ],
68 | "courseId": 13,
69 | "id": 314,
70 | "name": "RV列表动效",
71 | "order": 145004,
72 | "parentChapterId": 293,
73 | "userControlSetTop": false,
74 | "visible": 1
75 | },
76 | {
77 | "children": [
78 |
79 | ],
80 | "courseId": 13,
81 | "id": 358,
82 | "name": "项目基础功能",
83 | "order": 145005,
84 | "parentChapterId": 293,
85 | "userControlSetTop": false,
86 | "visible": 1
87 | },
88 | {
89 | "children": [
90 |
91 | ],
92 | "courseId": 13,
93 | "id": 328,
94 | "name": "网络&文件下载",
95 | "order": 145011,
96 | "parentChapterId": 293,
97 | "userControlSetTop": false,
98 | "visible": 1
99 | },
100 | {
101 | "children": [
102 |
103 | ],
104 | "courseId": 13,
105 | "id": 331,
106 | "name": "TextView",
107 | "order": 145013,
108 | "parentChapterId": 293,
109 | "userControlSetTop": false,
110 | "visible": 1
111 | },
112 | {
113 | "children": [
114 |
115 | ],
116 | "courseId": 13,
117 | "id": 336,
118 | "name": "键盘",
119 | "order": 145015,
120 | "parentChapterId": 293,
121 | "userControlSetTop": false,
122 | "visible": 1
123 | },
124 | {
125 | "children": [
126 |
127 | ],
128 | "courseId": 13,
129 | "id": 337,
130 | "name": "快应用",
131 | "order": 145016,
132 | "parentChapterId": 293,
133 | "userControlSetTop": false,
134 | "visible": 1
135 | },
136 | {
137 | "children": [
138 |
139 | ],
140 | "courseId": 13,
141 | "id": 338,
142 | "name": "日历&时钟",
143 | "order": 145017,
144 | "parentChapterId": 293,
145 | "userControlSetTop": false,
146 | "visible": 1
147 | },
148 | {
149 | "children": [
150 |
151 | ],
152 | "courseId": 13,
153 | "id": 339,
154 | "name": "K线图",
155 | "order": 145018,
156 | "parentChapterId": 293,
157 | "userControlSetTop": false,
158 | "visible": 1
159 | },
160 | {
161 | "children": [
162 |
163 | ],
164 | "courseId": 13,
165 | "id": 340,
166 | "name": "硬件相关",
167 | "order": 145019,
168 | "parentChapterId": 293,
169 | "userControlSetTop": false,
170 | "visible": 1
171 | },
172 | {
173 | "children": [
174 |
175 | ],
176 | "courseId": 13,
177 | "id": 357,
178 | "name": "表格类",
179 | "order": 145022,
180 | "parentChapterId": 293,
181 | "userControlSetTop": false,
182 | "visible": 1
183 | },
184 | {
185 | "children": [
186 |
187 | ],
188 | "courseId": 13,
189 | "id": 363,
190 | "name": "创意汇",
191 | "order": 145024,
192 | "parentChapterId": 293,
193 | "userControlSetTop": false,
194 | "visible": 1
195 | },
196 | {
197 | "children": [
198 |
199 | ],
200 | "courseId": 13,
201 | "id": 380,
202 | "name": "ImageView",
203 | "order": 145029,
204 | "parentChapterId": 293,
205 | "userControlSetTop": false,
206 | "visible": 1
207 | },
208 | {
209 | "children": [
210 |
211 | ],
212 | "courseId": 13,
213 | "id": 382,
214 | "name": "音视频&相机",
215 | "order": 145030,
216 | "parentChapterId": 293,
217 | "userControlSetTop": false,
218 | "visible": 1
219 | },
220 | {
221 | "children": [
222 |
223 | ],
224 | "courseId": 13,
225 | "id": 383,
226 | "name": "相机",
227 | "order": 145031,
228 | "parentChapterId": 293,
229 | "userControlSetTop": false,
230 | "visible": 1
231 | },
232 | {
233 | "children": [
234 |
235 | ],
236 | "courseId": 13,
237 | "id": 310,
238 | "name": "下拉刷新",
239 | "order": 145032,
240 | "parentChapterId": 293,
241 | "userControlSetTop": false,
242 | "visible": 1
243 | },
244 | {
245 | "children": [
246 |
247 | ],
248 | "courseId": 13,
249 | "id": 385,
250 | "name": "架构",
251 | "order": 145033,
252 | "parentChapterId": 293,
253 | "userControlSetTop": false,
254 | "visible": 1
255 | },
256 | {
257 | "children": [
258 |
259 | ],
260 | "courseId": 13,
261 | "id": 387,
262 | "name": "对话框",
263 | "order": 145035,
264 | "parentChapterId": 293,
265 | "userControlSetTop": false,
266 | "visible": 1
267 | },
268 | {
269 | "children": [
270 |
271 | ],
272 | "courseId": 13,
273 | "id": 388,
274 | "name": "数据库",
275 | "order": 145036,
276 | "parentChapterId": 293,
277 | "userControlSetTop": false,
278 | "visible": 1
279 | },
280 | {
281 | "children": [
282 |
283 | ],
284 | "courseId": 13,
285 | "id": 391,
286 | "name": "AS插件",
287 | "order": 145037,
288 | "parentChapterId": 293,
289 | "userControlSetTop": false,
290 | "visible": 1
291 | },
292 | {
293 | "children": [
294 |
295 | ],
296 | "courseId": 13,
297 | "id": 400,
298 | "name": "ViewPager",
299 | "order": 145039,
300 | "parentChapterId": 293,
301 | "userControlSetTop": false,
302 | "visible": 1
303 | },
304 | {
305 | "children": [
306 |
307 | ],
308 | "courseId": 13,
309 | "id": 401,
310 | "name": "二维码",
311 | "order": 145040,
312 | "parentChapterId": 293,
313 | "userControlSetTop": false,
314 | "visible": 1
315 | },
316 | {
317 | "children": [
318 |
319 | ],
320 | "courseId": 13,
321 | "id": 312,
322 | "name": "富文本编辑器",
323 | "order": 145041,
324 | "parentChapterId": 293,
325 | "userControlSetTop": false,
326 | "visible": 1
327 | }
328 | ]
329 | }
--------------------------------------------------------------------------------
/images/about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/about.png
--------------------------------------------------------------------------------
/images/collect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/collect.png
--------------------------------------------------------------------------------
/images/head_def.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/head_def.png
--------------------------------------------------------------------------------
/images/ic_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_arrow.png
--------------------------------------------------------------------------------
/images/ic_arrow_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_arrow_down.png
--------------------------------------------------------------------------------
/images/ic_article.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_article.png
--------------------------------------------------------------------------------
/images/ic_article_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_article_fill.png
--------------------------------------------------------------------------------
/images/ic_btn_collect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_btn_collect.png
--------------------------------------------------------------------------------
/images/ic_btn_collect_def.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_btn_collect_def.png
--------------------------------------------------------------------------------
/images/ic_category.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_category.png
--------------------------------------------------------------------------------
/images/ic_category_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_category_fill.png
--------------------------------------------------------------------------------
/images/ic_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_home.png
--------------------------------------------------------------------------------
/images/ic_home_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_home_fill.png
--------------------------------------------------------------------------------
/images/ic_knowledge_system.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_knowledge_system.png
--------------------------------------------------------------------------------
/images/ic_me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_me.png
--------------------------------------------------------------------------------
/images/ic_me_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_me_fill.png
--------------------------------------------------------------------------------
/images/ic_todo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/ic_todo.png
--------------------------------------------------------------------------------
/images/search_gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/images/search_gray.png
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2015",
4 | "module": "commonjs"
5 | }
6 | }
--------------------------------------------------------------------------------
/pages/article/article.js:
--------------------------------------------------------------------------------
1 | // pages/article/article.js
2 | import chaptersConfig from "../../config/chapters.js";
3 | import api from "../../api/api.js";
4 | const app = getApp();
5 | Page({
6 |
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {
11 | chapters: [],
12 | articleList: [],
13 | currentTab: 0,
14 | scrollWidth: 0,
15 | page: 1,
16 | pageCount: 1,
17 | isLoadingMore: false,
18 | },
19 |
20 | /**
21 | * 生命周期函数--监听页面加载
22 | */
23 | onLoad: function(options) {
24 | this.setData({
25 | chapters: chaptersConfig.chapters,
26 | })
27 |
28 | this.getArticle(this.data.page);
29 | },
30 |
31 | getArticle(page) {
32 | let userId = this.data.chapters[this.data.currentTab].id;
33 | api.IGetWXArticle(userId, page)
34 | .then(res => {
35 | for (let item of res.data.datas) {
36 | item.headTetx = item.author.substring(0, 1)
37 | }
38 | wx.stopPullDownRefresh()
39 | this.setData({
40 | articleList: this.data.articleList.concat(res.data.datas),
41 | page: page,
42 | pageCount: res.data.pageCount,
43 | isLoadingMore: false,
44 | })
45 | })
46 | .catch(e => {
47 |
48 | })
49 | },
50 |
51 | /**
52 | * 生命周期函数--监听页面初次渲染完成
53 | */
54 | onReady: function() {
55 |
56 | },
57 |
58 | /**
59 | * 生命周期函数--监听页面显示
60 | */
61 | onShow: function() {
62 |
63 | },
64 |
65 | onTabClick(event) {
66 | console.log(event)
67 | let data = event.currentTarget.dataset;
68 | this.setData({
69 | currentTab: data.index,
70 | articleList: []
71 | })
72 | this.getArticle(1)
73 | },
74 |
75 | onItemClick(event) {
76 | let url = event.currentTarget.dataset.url;
77 | wx.navigateTo({
78 | url: "/pages/web/index?url=" + encodeURIComponent(url)
79 | })
80 | },
81 |
82 | /**
83 | * 生命周期函数--监听页面隐藏
84 | */
85 | onHide: function() {
86 |
87 | },
88 |
89 | /**
90 | * 生命周期函数--监听页面卸载
91 | */
92 | onUnload: function() {
93 |
94 | },
95 |
96 | /**
97 | * 页面相关事件处理函数--监听用户下拉动作
98 | */
99 | onPullDownRefresh: function() {
100 |
101 | },
102 |
103 | /**
104 | * 页面上拉触底事件的处理函数
105 | */
106 | onReachBottom: function() {
107 | if (this.data.pageCount <= this.data.page||this.data.isLoadingMore) {
108 | return false;
109 | }
110 | this.setData({
111 | isLoadingMore: true,
112 | })
113 | this.getArticle(this.data.page + 1)
114 | },
115 |
116 | /**
117 | * 用户点击右上角分享
118 | */
119 | onShareAppMessage: function() {
120 |
121 | },
122 | collectClick(event) {
123 | if(!app.isLogin()){
124 | wx.navigateTo({
125 | url: '/pages/login/login',
126 | })
127 | return false;
128 | }
129 | let id = event.currentTarget.dataset.id;
130 | let zan = event.currentTarget.dataset.zan;
131 | let index = event.currentTarget.dataset.index;
132 | if (!zan) {
133 | api.IPostCollect(id)
134 | .then(res => {
135 | this.data.articleList[index].collect = true;
136 | this.setData({
137 | articleList: this.data.articleList
138 | })
139 | wx.showToast({
140 | title: '收藏成功',
141 | })
142 | })
143 | .catch(e => {
144 |
145 | })
146 | } else {
147 | api.IPostArticleUnCollect(id)
148 | .then(res => {
149 | this.data.articleList[index].collect = false;
150 | this.setData({
151 | articleList: this.data.articleList
152 | })
153 | wx.showToast({
154 | title: '取消收藏',
155 | })
156 | })
157 | .catch(e => {
158 |
159 | })
160 | }
161 | }
162 | })
--------------------------------------------------------------------------------
/pages/article/article.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "文章"
3 | }
--------------------------------------------------------------------------------
/pages/article/article.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{item.name}}
5 |
6 |
7 |
8 |
9 |
10 | {{item.headTetx}}
11 | {{item.author}}
12 | {{item.chapterName}}/{{item.superChapterName}}
13 |
14 | {{item.title}}
15 | {{item.desc?item.desc:item.link}}
16 |
17 |
18 | {{item.niceDate}}
19 |
20 |
21 |
22 |
23 |
24 | 正在加载
25 |
--------------------------------------------------------------------------------
/pages/article/article.wxss:
--------------------------------------------------------------------------------
1 | /* pages/article/article.wxss */
2 |
3 | page {
4 | background-color: #f5f5f5;
5 | }
6 |
7 | .nav {
8 | width: 750rpx;
9 | box-sizing: border-box;
10 | overflow: hidden;
11 | white-space: nowrap;
12 | position: fixed;
13 | top: 0;
14 | left: 0;
15 | z-index: 99;
16 | background: #fff;
17 | -moz-box-shadow: 0px 4px 10rpx #ccc;
18 | -webkit-box-shadow: 0px 4px 10rpx #ccc;
19 | box-shadow: 0px 4px 10rpx #ccc;
20 | }
21 |
22 | .nav-item {
23 | padding: 15rpx 0;
24 | margin: 0 30rpx;
25 | font-size: 26rpx;
26 | color: #666;
27 | display: inline-block;
28 | }
29 |
30 | .active {
31 | border-bottom: 5rpx solid #222;
32 | color: #222;
33 | }
34 |
35 | .article-list-box{
36 | padding: 66rpx 0 0 0;
37 | }
38 |
39 | .article-box {
40 | padding: 10rpx 30rpx;
41 | box-sizing: border-box;
42 | background-color: #fff;
43 | border-top: 10rpx solid #f5f5f5;
44 | }
45 |
46 | .article-box .article-top {
47 | display: flex;
48 | align-items: center;
49 | }
50 |
51 | .article-box .head {
52 | background-color: #ff8635;
53 | border-radius: 50%;
54 | width: 30rpx;
55 | height: 30rpx;
56 | font-size: 20rpx;
57 | text-align: center;
58 | color: #fff;
59 | }
60 |
61 | .article-box .name {
62 | font-size: 22rpx;
63 | color: #333;
64 | flex: 1;
65 | margin-left: 10rpx;
66 | }
67 |
68 | .article-box .type {
69 | color: #666;
70 | font-size: 22rpx;
71 | }
72 |
73 | .article-box .title {
74 | display: block;
75 | font-size: 26rpx;
76 | color: #222;
77 | line-height: 40rpx;
78 | overflow: hidden;
79 | white-space: nowrap;
80 | text-overflow: ellipsis;
81 | margin-top: 15rpx;
82 | }
83 |
84 | .article-box .desc {
85 | display: -webkit-box;
86 | font-size: 22rpx;
87 | color: #999;
88 | line-height: 40rpx;
89 | word-break: break-all;
90 | -webkit-box-orient: vertical;
91 | -webkit-line-clamp: 2;
92 | overflow: hidden;
93 | text-overflow: ellipsis;
94 | margin-top: 10rpx;
95 | }
96 |
97 | .article-box .icon {
98 | vertical-align: middle;
99 | width: 32rpx;
100 | height: 32rpx;
101 | }
102 |
103 | .article-box .time {
104 | font-size: 22rpx;
105 | color: #666;
106 | vertical-align: middle;
107 | flex: 1;
108 | text-align: right;
109 | }
110 |
--------------------------------------------------------------------------------
/pages/collect/collect.js:
--------------------------------------------------------------------------------
1 | // pages/collect/collect.js
2 | import api from "../../api/api.js";
3 |
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | articleList:[],
11 | page:1,
12 | pageCount:0,
13 | isHideLoadMore:false,
14 | },
15 |
16 | /**
17 | * 生命周期函数--监听页面加载
18 | */
19 | onLoad: function (options) {
20 | this.getCollectList(1);
21 | },
22 |
23 | getCollectList(page) {
24 | api.IGetCollectList(page)
25 | .then(res => {
26 | for (let item of res.data.datas) {
27 | item.headTetx = item.author.substring(0, 1);
28 | item.collect = true;
29 | }
30 | wx.stopPullDownRefresh()
31 | this.setData({
32 | articleList: this.data.articleList.concat(res.data.datas),
33 | page: page,
34 | pageCount: res.data.pageCount,
35 | isHideLoadMore: false,
36 | })
37 | })
38 | .catch(e => {
39 |
40 | })
41 | },
42 |
43 | onItemClick(event){
44 | let url = event.currentTarget.dataset.url;
45 | wx.navigateTo({
46 | url: "/pages/web/index?url=" + encodeURIComponent(url)
47 | })
48 | },
49 |
50 | /**
51 | * 生命周期函数--监听页面初次渲染完成
52 | */
53 | onReady: function () {
54 |
55 | },
56 |
57 | /**
58 | * 生命周期函数--监听页面显示
59 | */
60 | onShow: function () {
61 |
62 | },
63 |
64 | /**
65 | * 生命周期函数--监听页面卸载
66 | */
67 | onUnload: function () {
68 |
69 | },
70 |
71 | /**
72 | * 页面相关事件处理函数--监听用户下拉动作
73 | */
74 | onPullDownRefresh: function () {
75 |
76 | },
77 |
78 | /**
79 | * 页面上拉触底事件的处理函数
80 | */
81 | onReachBottom: function () {
82 | if (this.data.pageCount <= this.data.page || this.data.isLoadingMore) {
83 | return false;
84 | }
85 | this.setData({
86 | isHideLoadMore: true,
87 | })
88 | this.getCollectList(this.data.page + 1)
89 | },
90 |
91 | /**
92 | * 用户点击右上角分享
93 | */
94 | onShareAppMessage: function () {
95 |
96 | },
97 | collectClick(event) {
98 | let id = event.currentTarget.dataset.id;
99 | let zan = event.currentTarget.dataset.zan;
100 | let index = event.currentTarget.dataset.index;
101 | let originId = event.currentTarget.dataset.originId;
102 | if (zan) {
103 | api.IPostArticleMyUnCollect(id,{
104 | originId: originId
105 | })
106 | .then(res => {
107 | this.data.articleList.splice(index,1)
108 | this.setData({
109 | articleList: this.data.articleList
110 | })
111 | wx.showToast({
112 | title: '取消收藏',
113 | })
114 | })
115 | .catch(e => {
116 |
117 | })
118 | }
119 | }
120 | })
--------------------------------------------------------------------------------
/pages/collect/collect.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "我的收藏"
3 | }
--------------------------------------------------------------------------------
/pages/collect/collect.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{item.headTetx}}
6 | {{item.author}}
7 | {{item.chapterName}}
8 |
9 | {{item.title}}
10 | {{item.desc?item.desc:item.link}}
11 |
12 |
13 | {{item.niceDate}}
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pages/collect/collect.wxss:
--------------------------------------------------------------------------------
1 | /* pages/collect/collect.wxss */
2 |
3 | page {
4 | background-color: #f5f5f5;
5 | }
6 |
7 | .article-list-box {
8 | padding: 0 0 0 0;
9 | }
10 |
11 | .article-box {
12 | padding: 10rpx 30rpx;
13 | box-sizing: border-box;
14 | background-color: #fff;
15 | border-top: 10rpx solid #f5f5f5;
16 | }
17 |
18 | .article-box .article-top {
19 | display: flex;
20 | align-items: center;
21 | }
22 |
23 | .article-box .head {
24 | background-color: #ff8635;
25 | border-radius: 50%;
26 | width: 30rpx;
27 | height: 30rpx;
28 | font-size: 20rpx;
29 | text-align: center;
30 | color: #fff;
31 | }
32 |
33 | .article-box .name {
34 | font-size: 22rpx;
35 | color: #333;
36 | flex: 1;
37 | margin-left: 10rpx;
38 | }
39 |
40 | .article-box .type {
41 | color: #666;
42 | font-size: 22rpx;
43 | }
44 |
45 | .article-box .title {
46 | display: block;
47 | font-size: 26rpx;
48 | color: #222;
49 | line-height: 40rpx;
50 | overflow: hidden;
51 | white-space: nowrap;
52 | text-overflow: ellipsis;
53 | margin-top: 15rpx;
54 | }
55 |
56 | .article-box .desc {
57 | display: -webkit-box;
58 | font-size: 22rpx;
59 | color: #999;
60 | line-height: 40rpx;
61 | word-break: break-all;
62 | -webkit-box-orient: vertical;
63 | -webkit-line-clamp: 2;
64 | overflow: hidden;
65 | text-overflow: ellipsis;
66 | margin-top: 10rpx;
67 | }
68 |
69 | .article-box .icon {
70 | vertical-align: middle;
71 | width: 32rpx;
72 | height: 32rpx;
73 | }
74 |
75 | .article-box .time {
76 | font-size: 22rpx;
77 | color: #666;
78 | vertical-align: middle;
79 | flex: 1;
80 | text-align: right;
81 | }
82 |
--------------------------------------------------------------------------------
/pages/index/index.js:
--------------------------------------------------------------------------------
1 | //index.js
2 | //获取应用实例
3 | const app = getApp();
4 | import api from "../../api/api.js";
5 | Page({
6 | data: {
7 | bannerList: [],
8 | articleList: [],
9 | isLoadingMore: false,
10 | page: 1,
11 | pageCount: 0,
12 | },
13 |
14 | onLoad() {
15 | api.IGetBanner()
16 | .then(res => {
17 | this.setData({
18 | bannerList: res.data
19 | })
20 | })
21 | .catch(e => {
22 |
23 | })
24 | this.setData({
25 | page: 1,
26 | articleList: [],
27 | })
28 | this.getArticle(this.data.page)
29 | },
30 |
31 | getArticle(page) {
32 | api.IGetArticle(page - 1)
33 | .then(res => {
34 | for (let item of res.data.datas) {
35 | item.headTetx = item.author.substring(0, 1)
36 | }
37 | wx.stopPullDownRefresh()
38 | this.setData({
39 | articleList: this.data.articleList.concat(res.data.datas),
40 | page: page,
41 | isLoadingMore: false,
42 | pageCount: res.data.pageCount,
43 | })
44 | })
45 | .catch(e => {
46 |
47 | })
48 | },
49 | /**
50 | * 下拉刷新
51 | */
52 | onPullDownRefresh() {
53 | this.onShow()
54 | },
55 |
56 | /**
57 | * 加载更多
58 | */
59 | onReachBottom() {
60 | if (this.data.pageCount <= this.data.page || this.data.isLoadingMore) {
61 | return false;
62 | }
63 | this.setData({
64 | isLoadingMore: true,
65 | })
66 | this.getArticle(this.data.page + 1)
67 | },
68 |
69 | onItemClick(event) {
70 | let url = event.currentTarget.dataset.url;
71 | wx.navigateTo({
72 | url: "/pages/web/index?url=" + encodeURIComponent(url)
73 | })
74 | },
75 |
76 | searchBarClick(){
77 | wx.navigateTo({
78 | url: '/pages/search/search',
79 | })
80 | },
81 |
82 | collectClick(event){
83 | if (!app.isLogin()) {
84 | wx.navigateTo({
85 | url: '/pages/login/login',
86 | })
87 | return false;
88 | }
89 | let id = event.currentTarget.dataset.id;
90 | let zan = event.currentTarget.dataset.zan;
91 | let index = event.currentTarget.dataset.index;
92 | if(!zan){
93 | api.IPostCollect(id)
94 | .then(res=>{
95 | this.data.articleList[index].collect = true;
96 | this.setData({
97 | articleList:this.data.articleList
98 | })
99 | wx.showToast({
100 | title: '收藏成功',
101 | })
102 | })
103 | .catch(e=>{
104 |
105 | })
106 | }else{
107 | api.IPostArticleUnCollect(id)
108 | .then(res => {
109 | this.data.articleList[index].collect = false;
110 | this.setData({
111 | articleList: this.data.articleList
112 | })
113 | wx.showToast({
114 | title: '取消收藏',
115 | })
116 | })
117 | .catch(e => {
118 |
119 | })
120 | }
121 | }
122 |
123 | })
--------------------------------------------------------------------------------
/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "首页",
3 | "enablePullDownRefresh": true
4 | }
--------------------------------------------------------------------------------
/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 搜索
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | {{item.headTetx}}
18 | {{item.author}}
19 | {{item.chapterName}}/{{item.superChapterName}}
20 |
21 | {{item.title}}
22 | {{item.desc?item.desc:item.link}}
23 |
24 |
25 | {{item.niceDate}}
26 |
27 |
28 |
29 |
30 | 正在加载
31 |
--------------------------------------------------------------------------------
/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 |
3 | page {
4 | background-color: #f5f5f5;
5 | box-sizing: border-box;
6 | }
7 |
8 | .weui-search-bar {
9 | position: relative;
10 | padding: 8px 0 8px 30rpx;
11 | display: -webkit-box;
12 | display: -webkit-flex;
13 | display: flex;
14 | box-sizing: border-box;
15 | background-color: #fff;
16 | }
17 |
18 | .weui-search-bar__form {
19 | position: relative;
20 | -webkit-box-flex: 1;
21 | -webkit-flex: auto;
22 | flex: auto;
23 | border-radius: 6rpx;
24 | background: #e5e5e5;
25 | border: 1rpx solid #e5e5e5;
26 | margin-right: 30rpx;
27 | font-size: 0;
28 | padding: 8rpx;
29 | }
30 |
31 | .weui-icon-search {
32 | width: 28rpx;
33 | height: 28rpx;
34 | margin-right: 8rpx;
35 | display: inline-block;
36 | vertical-align: middle;
37 | }
38 |
39 | .weui-search-bar__text {
40 | display: inline-block;
41 | color: #999;
42 | font-size: 28rpx;
43 | padding: 0;
44 | vertical-align: middle;
45 | }
46 |
47 | .banner-box {
48 | padding: 10rpx 30rpx;
49 | box-sizing: border-box;
50 | background-color: #fff;
51 | }
52 |
53 | .banner-image {
54 | width: 100%;
55 | height: 380rpx;
56 | }
57 |
58 | .article-box {
59 | padding: 10rpx 30rpx;
60 | box-sizing: border-box;
61 | background-color: #fff;
62 | border-top: 10rpx solid #f5f5f5;
63 | }
64 |
65 | .article-box .article-top {
66 | display: flex;
67 | align-items: center;
68 | }
69 |
70 | .article-box .head {
71 | background-color: #ff8635;
72 | border-radius: 50%;
73 | width: 30rpx;
74 | height: 30rpx;
75 | font-size: 20rpx;
76 | text-align: center;
77 | color: #fff;
78 | }
79 |
80 | .article-box .name {
81 | font-size: 22rpx;
82 | color: #333;
83 | flex: 1;
84 | margin-left: 10rpx;
85 | }
86 |
87 | .article-box .type {
88 | color: #666;
89 | font-size: 22rpx;
90 | }
91 |
92 | .article-box .title {
93 | display: block;
94 | font-size: 26rpx;
95 | color: #222;
96 | line-height: 40rpx;
97 | overflow: hidden;
98 | white-space: nowrap;
99 | text-overflow: ellipsis;
100 | margin-top: 15rpx;
101 | }
102 |
103 | .article-box .desc {
104 | display: -webkit-box;
105 | font-size: 22rpx;
106 | color: #999;
107 | line-height: 40rpx;
108 | word-break: break-all;
109 | -webkit-box-orient: vertical;
110 | -webkit-line-clamp: 2;
111 | overflow: hidden;
112 | text-overflow: ellipsis;
113 | margin-top: 10rpx;
114 | }
115 |
116 | .article-box .icon {
117 | vertical-align: middle;
118 | width: 32rpx;
119 | height: 32rpx;
120 | }
121 |
122 | .article-box .time {
123 | font-size: 22rpx;
124 | color: #666;
125 | vertical-align: middle;
126 | flex: 1;
127 | text-align: right;
128 | }
--------------------------------------------------------------------------------
/pages/login/login.js:
--------------------------------------------------------------------------------
1 | // pages/login/login.js
2 | import api from "../../api/api.js";
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | username: wx.getStorageSync("username"),
10 | password: wx.getStorageSync("password"),
11 | },
12 |
13 | /**
14 | * 生命周期函数--监听页面加载
15 | */
16 | onLoad: function(options) {
17 |
18 | },
19 |
20 | onNameChange(event) {
21 | console.log(event)
22 | this.setData({
23 | username: event.detail.value
24 | })
25 | },
26 |
27 | onPwdChange(event) {
28 | console.log(event)
29 | this.setData({
30 | password: event.detail.value
31 | })
32 | },
33 |
34 | login() {
35 | api.IPostUserLogin({
36 | username: this.data.username,
37 | password: this.data.password
38 | })
39 | .then(res => {
40 | wx.setStorageSync("user", res.data)
41 | wx.navigateBack({})
42 | })
43 | .catch(e => {
44 | wx.showToast({
45 | title: e.errorMsg,
46 | icon: "none"
47 | })
48 | })
49 | },
50 |
51 | registerClick(){
52 | wx.navigateTo({
53 | url: '/pages/register/register',
54 | })
55 | },
56 |
57 | /**
58 | * 生命周期函数--监听页面初次渲染完成
59 | */
60 | onReady: function() {
61 |
62 | },
63 |
64 | /**
65 | * 生命周期函数--监听页面显示
66 | */
67 | onShow: function() {
68 |
69 | },
70 |
71 | /**
72 | * 生命周期函数--监听页面隐藏
73 | */
74 | onHide: function() {
75 |
76 | },
77 |
78 | /**
79 | * 生命周期函数--监听页面卸载
80 | */
81 | onUnload: function() {
82 |
83 | },
84 |
85 | /**
86 | * 页面相关事件处理函数--监听用户下拉动作
87 | */
88 | onPullDownRefresh: function() {
89 |
90 | },
91 |
92 | /**
93 | * 页面上拉触底事件的处理函数
94 | */
95 | onReachBottom: function() {
96 |
97 | },
98 |
99 | /**
100 | * 用户点击右上角分享
101 | */
102 | onShareAppMessage: function() {
103 |
104 | }
105 | })
--------------------------------------------------------------------------------
/pages/login/login.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "登录"
3 | }
--------------------------------------------------------------------------------
/pages/login/login.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 去注册
6 | 登录
7 |
8 |
9 |
--------------------------------------------------------------------------------
/pages/login/login.wxss:
--------------------------------------------------------------------------------
1 | /* pages/login/login.wxss */
2 | .login{
3 | text-align: center;
4 | margin-top: 30%;
5 | }
6 |
7 | .text-input{
8 | width: 80%;
9 | height: 80rpx;
10 | border-bottom: 1rpx solid #222;
11 | display: inline-block;
12 | text-align: left;
13 | font-size: 28rpx;
14 | color: #222;
15 | }
16 |
17 | .text-register{
18 | text-decoration: underline;
19 | text-align: right;
20 | width: 80%;
21 | display: inline-block;
22 | margin-top: 10rpx;
23 | }
24 |
25 | .login-btn{
26 | width: 80%;
27 | padding: 10rpx 0;
28 | background-color: #222;
29 | border-radius: 40rpx;
30 | color: #fff;
31 | display: inline-block;
32 | margin-top: 30rpx;
33 | font-size: 28rpx;
34 | }
--------------------------------------------------------------------------------
/pages/logs/logs.js:
--------------------------------------------------------------------------------
1 | //logs.js
2 | const util = require('../../utils/util.js')
3 |
4 | Page({
5 | data: {
6 | logs: []
7 | },
8 | onLoad: function () {
9 | this.setData({
10 | logs: (wx.getStorageSync('logs') || []).map(log => {
11 | return util.formatTime(new Date(log))
12 | })
13 | })
14 | }
15 | })
16 |
--------------------------------------------------------------------------------
/pages/logs/logs.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "查看启动日志"
3 | }
--------------------------------------------------------------------------------
/pages/logs/logs.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{index + 1}}. {{log}}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/pages/logs/logs.wxss:
--------------------------------------------------------------------------------
1 | .log-list {
2 | display: flex;
3 | flex-direction: column;
4 | padding: 40rpx;
5 | }
6 | .log-item {
7 | margin: 10rpx;
8 | }
9 |
--------------------------------------------------------------------------------
/pages/me/me.js:
--------------------------------------------------------------------------------
1 | // pages/me/me.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | userInfo: {},
9 | },
10 |
11 | /**
12 | * 生命周期函数--监听页面加载
13 | */
14 | onLoad: function(options) {
15 |
16 | },
17 |
18 | /**
19 | * 生命周期函数--监听页面初次渲染完成
20 | */
21 | onReady: function() {
22 |
23 | },
24 |
25 | /**
26 | * 生命周期函数--监听页面显示
27 | */
28 | onShow: function() {
29 | this.setData({
30 | userInfo: wx.getStorageSync("user")
31 | })
32 | },
33 |
34 | /**
35 | * 生命周期函数--监听页面隐藏
36 | */
37 | onHide: function() {
38 |
39 | },
40 |
41 | /**
42 | * 生命周期函数--监听页面卸载
43 | */
44 | onUnload: function() {
45 |
46 | },
47 |
48 | /**
49 | * 页面相关事件处理函数--监听用户下拉动作
50 | */
51 | onPullDownRefresh: function() {
52 |
53 | },
54 |
55 | /**
56 | * 页面上拉触底事件的处理函数
57 | */
58 | onReachBottom: function() {
59 |
60 | },
61 |
62 | /**
63 | * 用户点击右上角分享
64 | */
65 | onShareAppMessage: function() {
66 |
67 | },
68 |
69 | onItemClick(event) {
70 | let itemType = event.currentTarget.dataset.itemType;
71 | switch (Number(itemType)) {
72 | case 0:
73 | if (this.data.userInfo) {
74 | wx.navigateTo({
75 | url: '/pages/collect/collect',
76 | })
77 | } else {
78 | this.onGotUserInfo()
79 | }
80 | break
81 | case 1:
82 | wx.navigateTo({
83 | url: '/pages/tree/tree'
84 | })
85 | break
86 | case 2:
87 | if (this.data.userInfo) {
88 | wx.navigateTo({
89 | url: '/pages/todo/todo'
90 | })
91 | } else {
92 | this.onGotUserInfo()
93 | }
94 | break
95 |
96 | case 3:
97 | wx.navigateTo({
98 | url: "/pages/web/index?url=" + encodeURIComponent("http://www.wanandroid.com/about")
99 | })
100 | break
101 | }
102 | },
103 | onGotUserInfo() {
104 | wx.navigateTo({
105 | url: '/pages/login/login',
106 | })
107 | }
108 | })
--------------------------------------------------------------------------------
/pages/me/me.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "我的"
3 | }
--------------------------------------------------------------------------------
/pages/me/me.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {{userInfo.username}}
7 |
8 |
9 |
10 |
11 | 我的收藏
12 |
13 |
14 |
15 |
16 |
17 | 知识体系
18 |
19 |
20 |
21 |
22 |
23 | 待办清单
24 |
25 |
26 |
27 |
28 |
29 | 关于我们
30 |
31 |
--------------------------------------------------------------------------------
/pages/me/me.wxss:
--------------------------------------------------------------------------------
1 | /* pages/me/me.wxss */
2 | page{background-color: #f5f5f5}
3 |
4 |
5 |
6 | /*------------------------------登录区域------------------------------*/
7 | .login{
8 | height: 270rpx;
9 | background: url("https://hzimg.huizhuang.com/mini/img/userinfo-bgimg.jpg") center;
10 | background-size: cover;
11 | overflow: hidden;
12 | }
13 | .login view{
14 | height: 126rpx;
15 | margin: 51rpx 0 0 40rpx;
16 | overflow: hidden;
17 | }
18 | .login view image{
19 | float: left;
20 | width: 120rpx;
21 | height: 120rpx;
22 | margin-right: 31rpx;
23 | border-radius: 50%;
24 | background-color: #fff
25 | }
26 | .login view button{
27 | float: left;
28 | height: 56rpx;
29 | border: 2rpx solid #333335;
30 | margin-top: 38rpx;
31 | line-height: 56rpx;
32 | font-size: 28rpx;
33 | color: #333335;
34 | border-radius: 56rpx;
35 | }
36 | .login view text{
37 | float: left;
38 | line-height: 126rpx;
39 | font-size: 40rpx;
40 | color: #333335
41 | }
42 | .line-box{
43 | background-color: #fff;
44 | }
45 | .bottom-line{
46 | border-bottom: 1rpx solid #e5e5e5;
47 | margin-left: 85rpx;
48 | }
49 |
50 | .top-20{
51 | margin-top: 20rpx;
52 | }
53 | .list-item{
54 | display: flex;
55 | align-items: center;
56 | background-color: #fff;
57 | padding:0 30rpx;
58 | height: 120rpx;
59 | }
60 | .list-item-img{
61 | width: 35rpx;
62 | height: 35rpx;
63 | }
64 | .list-item-name{
65 | font-size: 28rpx;
66 | color: #1a1a1a;
67 | margin-left: 20rpx;
68 | }
--------------------------------------------------------------------------------
/pages/project/project.js:
--------------------------------------------------------------------------------
1 | // pages/project/project.js
2 | import projectConfig from "../../config/projects.js";
3 | import api from "../../api/api.js";
4 | const app = getApp();
5 | Page({
6 |
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {
11 | projects:[],
12 | currentTab: 0,
13 | page:1,
14 | pageCount:0,
15 | projectList:[],
16 | isLoadingMore:false,
17 | },
18 |
19 | /**
20 | * 生命周期函数--监听页面加载
21 | */
22 | onLoad: function (options) {
23 | this.setData({
24 | projects: projectConfig.projects,
25 | })
26 | this.getProject(1)
27 | },
28 |
29 | getProject(page) {
30 | let userId = this.data.projects[this.data.currentTab].id;
31 | if (userId == 99999){
32 | api.IGetNewProjects(page)
33 | .then(res => {
34 | for (let item of res.data.datas) {
35 | item.headTetx = item.author.substring(0, 1)
36 | }
37 | wx.stopPullDownRefresh()
38 | this.setData({
39 | projectList: this.data.projectList.concat(res.data.datas),
40 | page: page,
41 | pageCount: res.data.pageCount,
42 | isLoadingMore: false,
43 | })
44 | })
45 | .catch(e => {
46 |
47 | })
48 | }else{
49 | api.IGetProjects(userId,page)
50 | .then(res => {
51 | for (let item of res.data.datas) {
52 | item.headTetx = item.author.substring(0, 1)
53 | }
54 | wx.stopPullDownRefresh()
55 | this.setData({
56 | projectList: this.data.projectList.concat(res.data.datas),
57 | page: page,
58 | pageCount: res.data.pageCount,
59 | isLoadingMore: false,
60 | })
61 | })
62 | .catch(e => {
63 |
64 | })
65 | }
66 |
67 | },
68 |
69 | onTabClick(event) {
70 | console.log(event)
71 | let data = event.currentTarget.dataset;
72 | this.setData({
73 | currentTab: data.index,
74 | projectList: []
75 | })
76 | this.getProject(1)
77 | },
78 |
79 | onItemClick(event){
80 | let url = event.currentTarget.dataset.url;
81 | wx.navigateTo({
82 | url: "/pages/web/index?url=" + encodeURIComponent(url)
83 | })
84 | },
85 |
86 | /**
87 | * 生命周期函数--监听页面初次渲染完成
88 | */
89 | onReady: function () {
90 |
91 | },
92 |
93 | /**
94 | * 生命周期函数--监听页面显示
95 | */
96 | onShow: function () {
97 |
98 | },
99 |
100 | /**
101 | * 生命周期函数--监听页面隐藏
102 | */
103 | onHide: function () {
104 |
105 | },
106 |
107 | /**
108 | * 生命周期函数--监听页面卸载
109 | */
110 | onUnload: function () {
111 |
112 | },
113 |
114 | /**
115 | * 页面相关事件处理函数--监听用户下拉动作
116 | */
117 | onPullDownRefresh: function () {
118 |
119 | },
120 |
121 | /**
122 | * 页面上拉触底事件的处理函数
123 | */
124 | onReachBottom: function () {
125 | if (this.data.pageCount <= this.data.page || this.data.isLoadingMore) {
126 | return false;
127 | }
128 | this.setData({
129 | isLoadingMore: true,
130 | })
131 | this.getProject(this.data.page + 1)
132 | },
133 |
134 | /**
135 | * 用户点击右上角分享
136 | */
137 | onShareAppMessage: function () {
138 |
139 | },
140 | collectClick(event) {
141 | if (!app.isLogin()) {
142 | wx.navigateTo({
143 | url: '/pages/login/login',
144 | })
145 | return false;
146 | }
147 | let id = event.currentTarget.dataset.id;
148 | let zan = event.currentTarget.dataset.zan;
149 | let index = event.currentTarget.dataset.index;
150 | if (!zan) {
151 | api.IPostCollect(id)
152 | .then(res => {
153 | this.data.projectList[index].collect = true;
154 | this.setData({
155 | projectList: this.data.projectList
156 | })
157 | wx.showToast({
158 | title: '收藏成功',
159 | })
160 | })
161 | .catch(e => {
162 |
163 | })
164 | } else {
165 | api.IPostArticleUnCollect(id)
166 | .then(res => {
167 | this.data.projectList[index].collect = false;
168 | this.setData({
169 | projectList: this.data.projectList
170 | })
171 | wx.showToast({
172 | title: '取消收藏',
173 | })
174 | })
175 | .catch(e => {
176 |
177 | })
178 | }
179 | }
180 | })
--------------------------------------------------------------------------------
/pages/project/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "项目"
3 | }
--------------------------------------------------------------------------------
/pages/project/project.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{item.name}}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{item.headTetx}}
13 | {{item.author}}
14 |
15 | {{item.title}}
16 | {{item.desc}}
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | {{item.chapterName}}/{{item.superChapterName}}
25 | {{item.niceDate}}
26 |
27 |
28 |
29 |
30 |
31 | 正在加载
32 |
--------------------------------------------------------------------------------
/pages/project/project.wxss:
--------------------------------------------------------------------------------
1 | /* pages/project/project.wxss */
2 |
3 | page {
4 | background-color: #fff;
5 | }
6 |
7 | .nav {
8 | width: 750rpx;
9 | box-sizing: border-box;
10 | overflow: hidden;
11 | white-space: nowrap;
12 | position: fixed;
13 | top: 0;
14 | left: 0;
15 | z-index: 99;
16 | background: #fff;
17 | -moz-box-shadow: 0px 4px 10rpx #ccc;
18 | -webkit-box-shadow: 0px 4px 10rpx #ccc;
19 | box-shadow: 0px 4px 10rpx #ccc;
20 | }
21 |
22 | .nav-item {
23 | padding: 15rpx 0;
24 | margin: 0 30rpx;
25 | font-size: 26rpx;
26 | color: #666;
27 | display: inline-block;
28 | }
29 |
30 | .active {
31 | border-bottom: 5rpx solid #222;
32 | color: #222;
33 | }
34 |
35 | .project-list-box {
36 | padding: 66rpx 0 0 0;
37 | }
38 |
39 | .project-box {
40 | margin: 20rpx 15rpx;
41 | padding: 15rpx;
42 | -moz-box-shadow: 0px 0px 10px #ccc;
43 | -webkit-box-shadow: 0px 0px 10px #ccc;
44 | box-shadow: 0px 0px 10px #ccc;
45 | background-color: #fff;
46 | border-radius: 8rpx;
47 | }
48 |
49 | .project-box .box-top{
50 | display: flex;
51 | }
52 |
53 | .project-left{
54 | flex: 1;
55 | }
56 |
57 | .project-right{
58 | flex: 1;
59 | box-sizing: border-box;
60 | }
61 | .project-box .user_name{
62 | display:flex;
63 | align-items:center;
64 | }
65 |
66 | .user_name .head {
67 | background-color: #ff8635;
68 | border-radius: 50%;
69 | width: 30rpx;
70 | height: 30rpx;
71 | font-size: 20rpx;
72 | text-align: center;
73 | color: #fff;
74 | }
75 |
76 | .user_name .name {
77 | font-size: 22rpx;
78 | color: #333;
79 | flex: 1;
80 | margin-left: 10rpx;
81 | }
82 |
83 | .project-box .title {
84 | display: -webkit-box;
85 | font-size: 26rpx;
86 | color: #222;
87 | line-height: 40rpx;
88 | word-break: break-all;
89 | -webkit-box-orient: vertical;
90 | -webkit-line-clamp: 1;
91 | overflow: hidden;
92 | text-overflow: ellipsis;
93 | margin-top: 10rpx;
94 | }
95 | .project-box .desc {
96 | display: -webkit-box;
97 | font-size: 22rpx;
98 | color: #999;
99 | line-height: 40rpx;
100 | word-break: break-all;
101 | -webkit-box-orient: vertical;
102 | -webkit-line-clamp: 2;
103 | overflow: hidden;
104 | text-overflow: ellipsis;
105 | margin-top: 10rpx;
106 | }
107 |
108 | .project-box .project-img{
109 | width: 320rpx;
110 | margin-left: 30rpx;
111 | height: 180rpx;
112 | -moz-box-shadow: 0px 0px 10px #ccc;
113 | -webkit-box-shadow: 0px 0px 10px #ccc;
114 | box-shadow: 0px 0px 10px #ccc;
115 | border-radius: 8rpx;
116 | }
117 |
118 | .project-box .icon {
119 | vertical-align: middle;
120 | width: 32rpx;
121 | height: 32rpx;
122 | }
123 |
124 | .project-box .time {
125 | font-size: 22rpx;
126 | color: #666;
127 | vertical-align: middle;
128 | }
129 |
130 | .project-box .article-top {
131 | display: flex;
132 | align-items: center;
133 | margin-top: 10rpx;
134 | }
135 |
136 | .project-box .type {
137 | color: #666;
138 | font-size: 22rpx;
139 | flex: 1;
140 | margin-left: 10rpx;
141 | }
--------------------------------------------------------------------------------
/pages/register/register.js:
--------------------------------------------------------------------------------
1 | // pages/register/register.js
2 | import api from "../../api/api.js";
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | username: "",
10 | password: "",
11 | repassword: "",
12 | },
13 |
14 | /**
15 | * 生命周期函数--监听页面加载
16 | */
17 | onLoad: function (options) {
18 |
19 | },
20 |
21 | onNameChange(event) {
22 | this.setData({
23 | username: event.detail.value
24 | })
25 | },
26 |
27 | onPwdChange(event) {
28 | this.setData({
29 | password: event.detail.value
30 | })
31 | },
32 |
33 | onRePwdChange(event) {
34 | this.setData({
35 | repassword: event.detail.value
36 | })
37 | },
38 | register() {
39 | api.IPostUserRegister({
40 | username: this.data.username,
41 | password: this.data.password,
42 | repassword: this.data.repassword
43 | })
44 | .then(res => {
45 | wx.setStorageSync("user", res.data)
46 | wx.navigateBack({
47 | delta:2
48 | })
49 | })
50 | .catch(e => {
51 | wx.showToast({
52 | title: e.errorMsg,
53 | icon: "none"
54 | })
55 | })
56 | },
57 | /**
58 | * 生命周期函数--监听页面初次渲染完成
59 | */
60 | onReady: function () {
61 |
62 | },
63 |
64 | /**
65 | * 生命周期函数--监听页面显示
66 | */
67 | onShow: function () {
68 |
69 | },
70 |
71 | /**
72 | * 生命周期函数--监听页面隐藏
73 | */
74 | onHide: function () {
75 |
76 | },
77 |
78 | /**
79 | * 生命周期函数--监听页面卸载
80 | */
81 | onUnload: function () {
82 |
83 | },
84 |
85 | /**
86 | * 页面相关事件处理函数--监听用户下拉动作
87 | */
88 | onPullDownRefresh: function () {
89 |
90 | },
91 |
92 | /**
93 | * 页面上拉触底事件的处理函数
94 | */
95 | onReachBottom: function () {
96 |
97 | },
98 |
99 | /**
100 | * 用户点击右上角分享
101 | */
102 | onShareAppMessage: function () {
103 |
104 | }
105 | })
--------------------------------------------------------------------------------
/pages/register/register.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "注册"
3 | }
--------------------------------------------------------------------------------
/pages/register/register.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 注册
7 |
8 |
--------------------------------------------------------------------------------
/pages/register/register.wxss:
--------------------------------------------------------------------------------
1 | /* pages/register/register.wxss */
2 | .login{
3 | text-align: center;
4 | margin-top: 30%;
5 | }
6 |
7 | .text-input{
8 | width: 80%;
9 | height: 80rpx;
10 | border-bottom: 1rpx solid #222;
11 | display: inline-block;
12 | text-align: left;
13 | font-size: 28rpx;
14 | color: #222;
15 | }
16 |
17 | .text-register{
18 | text-decoration: underline;
19 | text-align: right;
20 | width: 80%;
21 | display: inline-block;
22 | margin-top: 10rpx;
23 | }
24 |
25 | .login-btn{
26 | width: 80%;
27 | padding: 10rpx 0;
28 | background-color: #222;
29 | border-radius: 40rpx;
30 | color: #fff;
31 | display: inline-block;
32 | margin-top: 30rpx;
33 | font-size: 28rpx;
34 | }
--------------------------------------------------------------------------------
/pages/search/search.js:
--------------------------------------------------------------------------------
1 | // pages/search/search.js
2 | import api from "../../api/api.js";
3 | const app = getApp();
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | inputVal:"",
11 | articleList: [],
12 | page: 1,
13 | pageCount: 1,
14 | isLoadingMore:false,
15 | tipsList:[]
16 | },
17 |
18 | /**
19 | * 生命周期函数--监听页面加载
20 | */
21 | onLoad: function (options) {
22 | this.getHotKey()
23 | },
24 |
25 | getHotKey(){
26 | api.IGetHotKey()
27 | .then(res=>{
28 | this.setData({
29 | tipsList:res.data
30 | })
31 | })
32 | .catch(e=>{
33 |
34 | })
35 | },
36 |
37 | onHotKeyClick(event){
38 | let key = event.currentTarget.dataset.key;
39 | this.setData({
40 | inputVal:key
41 | })
42 | this.getArticle(1);
43 | },
44 |
45 | inputTyping(event){
46 | this.setData({
47 | inputVal:event.detail.value,
48 | })
49 | },
50 |
51 | clearInput(){
52 | this.setData({
53 | inputVal: "",
54 | })
55 | },
56 |
57 | searchClick(){
58 | if(this.data.inputVal){
59 | this.getArticle(1)
60 | }else{
61 |
62 | }
63 | },
64 |
65 | getArticle(page) {
66 | if(page==1){
67 | this.setData({
68 | articleList: [],
69 | page: 1,
70 | pageCount: 0,
71 | isLoadingMore: false,
72 | })
73 | }
74 | api.IGetArticleQuery(page,{
75 | k:this.data.inputVal
76 | })
77 | .then(res => {
78 | for (let item of res.data.datas) {
79 | item.headTetx = item.author.substring(0, 1)
80 | }
81 | wx.stopPullDownRefresh()
82 | this.setData({
83 | articleList: this.data.articleList.concat(res.data.datas),
84 | page: page,
85 | pageCount: res.data.pageCount,
86 | isLoadingMore: false,
87 | })
88 | })
89 | .catch(e => {
90 |
91 | })
92 | },
93 |
94 | onItemClick(event) {
95 | let url = event.currentTarget.dataset.url;
96 | wx.navigateTo({
97 | url: "/pages/web/index?url=" + encodeURIComponent(url)
98 | })
99 | },
100 |
101 | /**
102 | * 生命周期函数--监听页面初次渲染完成
103 | */
104 | onReady: function () {
105 |
106 | },
107 |
108 | /**
109 | * 生命周期函数--监听页面显示
110 | */
111 | onShow: function () {
112 |
113 | },
114 |
115 | /**
116 | * 生命周期函数--监听页面隐藏
117 | */
118 | onHide: function () {
119 |
120 | },
121 |
122 | /**
123 | * 生命周期函数--监听页面卸载
124 | */
125 | onUnload: function () {
126 |
127 | },
128 |
129 | /**
130 | * 页面相关事件处理函数--监听用户下拉动作
131 | */
132 | onPullDownRefresh: function () {
133 |
134 | },
135 |
136 | /**
137 | * 页面上拉触底事件的处理函数
138 | */
139 | onReachBottom: function () {
140 | if (this.data.pageCount <= this.data.page || this.data.isLoadingMore) {
141 | return false;
142 | }
143 | this.setData({
144 | isLoadingMore: true,
145 | })
146 | this.getArticle(this.data.page + 1)
147 | },
148 |
149 | /**
150 | * 用户点击右上角分享
151 | */
152 | onShareAppMessage: function () {
153 |
154 | },
155 | collectClick(event) {
156 | if (!app.isLogin()) {
157 | wx.navigateTo({
158 | url: '/pages/login/login',
159 | })
160 | return false;
161 | }
162 | let id = event.currentTarget.dataset.id;
163 | let zan = event.currentTarget.dataset.zan;
164 | let index = event.currentTarget.dataset.index;
165 | if (!zan) {
166 | api.IPostCollect(id)
167 | .then(res => {
168 | this.data.articleList[index].collect = true;
169 | this.setData({
170 | articleList: this.data.articleList
171 | })
172 | wx.showToast({
173 | title: '收藏成功',
174 | })
175 | })
176 | .catch(e => {
177 |
178 | })
179 | } else {
180 | api.IPostArticleUnCollect(id)
181 | .then(res => {
182 | this.data.articleList[index].collect = false;
183 | this.setData({
184 | articleList: this.data.articleList
185 | })
186 | wx.showToast({
187 | title: '取消收藏',
188 | })
189 | })
190 | .catch(e => {
191 |
192 | })
193 | }
194 | }
195 | })
--------------------------------------------------------------------------------
/pages/search/search.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "快速查找"
3 | }
--------------------------------------------------------------------------------
/pages/search/search.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 搜索
13 |
14 |
15 | 大家都在搜
16 |
17 | {{item.name}}
18 |
19 |
20 |
21 | {{item.headTetx}}
22 | {{item.author}}
23 | {{item.chapterName}}/{{item.superChapterName}}
24 |
25 |
26 | {{item.desc?item.desc:item.link}}
27 |
28 |
29 | {{item.niceDate}}
30 |
31 |
32 |
33 |
34 |
35 | 正在加载
36 |
--------------------------------------------------------------------------------
/pages/search/search.wxss:
--------------------------------------------------------------------------------
1 | /* pages/search/search.wxss */
2 | page{
3 | background-color: #f5f5f5;
4 | }
5 | .weui-search-bar {
6 | position: fixed;
7 | width: 100%;
8 | padding: 8px 0 8px 30rpx;
9 | display: -webkit-box;
10 | display: -webkit-flex;
11 | display: flex;
12 | box-sizing: border-box;
13 | background-color: #fff;
14 | }
15 |
16 | .weui-search-bar__form {
17 | position: relative;
18 | -webkit-box-flex: 1;
19 | -webkit-flex: auto;
20 | flex: auto;
21 | border-radius: 6rpx;
22 | background: #e5e5e5;
23 | border: 1rpx solid #e5e5e5;
24 | }
25 |
26 | .weui-search-bar__box {
27 | position: relative;
28 | padding-left: 30px;
29 | padding-right: 30px;
30 | width: 100%;
31 | box-sizing: border-box;
32 | z-index: 1;
33 | }
34 |
35 | .weui-icon-search {
36 | width: 14px;
37 | height: 14px;
38 | vertical-align: middle;
39 | margin-right: 8rpx;
40 | }
41 |
42 | .weui-icon-search_in-box {
43 | position: absolute;
44 | left: 10px;
45 | top: 7px;
46 | }
47 |
48 | .weui-search-bar__input {
49 | height: 28px;
50 | line-height: 28px;
51 | font-size: 14px;
52 | }
53 |
54 | .weui-icon-clear {
55 | position: absolute;
56 | top: 0;
57 | right: 0;
58 | padding: 7px 8px;
59 | font-size: 0;
60 | }
61 |
62 | .weui-search-bar__label {
63 | position: absolute;
64 | top: 0;
65 | right: 0;
66 | bottom: 0;
67 | left: 0;
68 | z-index: 2;
69 | border-radius: 3px;
70 | text-align: center;
71 | color: #999;
72 | background: #e5e5e5;
73 | line-height: 28px;
74 | }
75 |
76 | .weui-search-bar__text {
77 | display: inline-block;
78 | font-size: 14px;
79 | vertical-align: middle;
80 | color: #999;
81 | }
82 |
83 | .weui-search-bar__cancel-btn {
84 | padding: 0 30rpx;
85 | line-height: 28px;
86 | color: #666;
87 | white-space: nowrap;
88 | font-size: 28rpx;
89 | }
90 |
91 | .article-list-box{
92 | padding: 92rpx 0 0 0;
93 | }
94 |
95 | .tips-title{
96 | background-color: #fff;
97 | padding: 10rpx 30rpx;
98 | }
99 | .tips-box{
100 | padding: 30rpx 20rpx 10rpx 30rpx;
101 | }
102 | .tips-tag{
103 | padding: 5rpx 10rpx;
104 | border: 1rpx solid #222;
105 | border-radius: 25rpx;
106 | display: inline-block;
107 | background-color: #fff;
108 | margin: 0 10rpx 10rpx 0;
109 | font-size: 24rpx;
110 | }
111 |
112 | .article-box {
113 | padding: 10rpx 30rpx;
114 | box-sizing: border-box;
115 | background-color: #fff;
116 | border-top: 10rpx solid #f5f5f5;
117 | }
118 |
119 | .article-box .article-top {
120 | display: flex;
121 | align-items: center;
122 | }
123 |
124 | .article-box .head {
125 | background-color: #ff8635;
126 | border-radius: 50%;
127 | width: 30rpx;
128 | height: 30rpx;
129 | font-size: 20rpx;
130 | text-align: center;
131 | color: #fff;
132 | }
133 |
134 | .article-box .name {
135 | font-size: 22rpx;
136 | color: #333;
137 | flex: 1;
138 | margin-left: 10rpx;
139 | }
140 |
141 | .article-box .type {
142 | color: #666;
143 | font-size: 22rpx;
144 | }
145 |
146 | .article-box .title {
147 | display: block;
148 | font-size: 26rpx;
149 | color: #222;
150 | line-height: 40rpx;
151 | overflow: hidden;
152 | white-space: nowrap;
153 | text-overflow: ellipsis;
154 | margin-top: 15rpx;
155 | }
156 |
157 | .article-box .desc {
158 | display: -webkit-box;
159 | font-size: 22rpx;
160 | color: #999;
161 | line-height: 40rpx;
162 | word-break: break-all;
163 | -webkit-box-orient: vertical;
164 | -webkit-line-clamp: 2;
165 | overflow: hidden;
166 | text-overflow: ellipsis;
167 | margin-top: 10rpx;
168 | }
169 |
170 | .article-box .icon {
171 | vertical-align: middle;
172 | width: 32rpx;
173 | height: 32rpx;
174 | }
175 |
176 | .article-box .time {
177 | font-size: 22rpx;
178 | color: #666;
179 | vertical-align: middle;
180 | flex: 1;
181 | text-align: right;
182 | }
183 | .highlight{
184 | color: #ff4646;
185 | }
--------------------------------------------------------------------------------
/pages/todo/todo.js:
--------------------------------------------------------------------------------
1 | // pages/todo/todo.js
2 | import api from "../../api/api.js";
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | currTab: 1,
10 | status: 0,
11 | todoList: [],
12 | startX: 0,
13 | },
14 |
15 | /**
16 | * 生命周期函数--监听页面加载
17 | */
18 | onLoad: function(options) {
19 |
20 | },
21 |
22 | onTabItemClick(event) {
23 | let currTab = event.currentTarget.dataset.tab;
24 | this.setData({
25 | currTab: currTab,
26 | status: currTab == 1 ? 0 : 1,
27 | })
28 | this.getTodo(1)
29 | },
30 |
31 | getTodo(page) {
32 | api.IGetTodo(this.data.status, page, {})
33 | .then(res => {
34 | for (let item of res.data.datas) {
35 | item.leftDis = "0rpx"
36 | item.rightPadding = "15rpx"
37 | }
38 | this.setData({
39 | todoList: res.data.datas
40 | })
41 | })
42 | .catch(e => {
43 |
44 | })
45 | },
46 |
47 | onOpenClick(event) {
48 | let index = event.currentTarget.dataset.index;
49 | this.data.todoList[index].isOpen = !this.data.todoList[index].isOpen;
50 | this.setData({
51 | todoList: this.data.todoList
52 | })
53 | },
54 |
55 | touchS: function(event) {
56 | if (event.touches.length == 1) {
57 | this.setData({
58 | startX: event.touches[0].clientX
59 | });
60 | }
61 | },
62 |
63 | touchM: function(event) {
64 | var index = event.currentTarget.dataset.sid;
65 | var moveX = event.touches[0].clientX;
66 | var disX = this.data.startX - moveX;
67 | if (disX > 0 && disX < 80) {
68 | this.changeList(this.data.todoList, index, disX * 2)
69 | }
70 | },
71 |
72 | touchE: function(event) {
73 | var index = event.currentTarget.dataset.sid
74 | if (event.changedTouches.length == 1) {
75 | //手指移动结束后水平位置
76 | var endX = event.changedTouches[0].clientX;
77 | //触摸开始与结束,手指移动的距离
78 | var disX = this.data.startX - endX;
79 | if (disX > 40) {
80 | this.changeList(this.data.todoList, index, 160)
81 | } else {
82 | this.changeList(this.data.todoList, index, 0)
83 | }
84 | }
85 | },
86 | changeList: function(listData, index, leftData) {
87 | for (var i in listData) {
88 | if (i == index) {
89 | listData[i].leftDis = -leftData + 'rpx'
90 | if (leftData > 0) {
91 | listData[i].rightPadding = '0rpx'
92 | } else {
93 | listData[i].rightPadding = '15rpx'
94 | }
95 |
96 | }
97 | }
98 | this.setData({
99 | todoList: listData
100 | })
101 | console.log(this.data.todoList)
102 | },
103 |
104 | onItem1Click(event) {
105 | let id = event.currentTarget.dataset.id;
106 | api.IPostTodoDelete(id)
107 | .then(res => {
108 | this.getTodo(1)
109 | })
110 | .catch(e => {
111 |
112 | })
113 | },
114 |
115 | onItem2Click(event) {
116 | let id = event.currentTarget.dataset.id;
117 | api.IPostTodoDone(id, {
118 | status: this.data.currTab==1?1:0
119 | })
120 | .then(res => {
121 | this.getTodo(1)
122 | })
123 | .catch(e => {
124 |
125 | })
126 | },
127 |
128 | onAddClick(){
129 | wx.navigateTo({
130 | url: '/pages/todoadd/add',
131 | })
132 | },
133 |
134 | /**
135 | * 生命周期函数--监听页面初次渲染完成
136 | */
137 | onReady: function() {
138 |
139 | },
140 |
141 | /**
142 | * 生命周期函数--监听页面显示
143 | */
144 | onShow: function() {
145 | this.getTodo(1);
146 | },
147 |
148 | /**
149 | * 生命周期函数--监听页面隐藏
150 | */
151 | onHide: function() {
152 |
153 | },
154 |
155 | /**
156 | * 生命周期函数--监听页面卸载
157 | */
158 | onUnload: function() {
159 |
160 | },
161 |
162 | /**
163 | * 页面相关事件处理函数--监听用户下拉动作
164 | */
165 | onPullDownRefresh: function() {
166 |
167 | },
168 |
169 | /**
170 | * 页面上拉触底事件的处理函数
171 | */
172 | onReachBottom: function() {
173 |
174 | },
175 |
176 | /**
177 | * 用户点击右上角分享
178 | */
179 | onShareAppMessage: function() {
180 |
181 | }
182 | })
--------------------------------------------------------------------------------
/pages/todo/todo.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "待办清单"
3 | }
--------------------------------------------------------------------------------
/pages/todo/todo.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 待办列表
5 |
6 |
7 | 已完成
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | {{item.dateStr}}
17 | 完成时间:{{item.completeDateStr}}
18 | {{item.title}}
19 |
20 |
21 |
22 | {{item.content}}
23 |
24 |
25 |
26 | 删除
27 | {{currTab==2?"撤回":"完成"}}
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/pages/todo/todo.wxss:
--------------------------------------------------------------------------------
1 | /* pages/todo/todo.wxss */
2 |
3 | page {
4 | background-color: #f5f5f5;
5 | box-sizing: border-box;
6 | }
7 |
8 | .type-bar {
9 | display: flex;
10 | background: #fff;
11 | -moz-box-shadow: 0px 4px 10rpx #ccc;
12 | -webkit-box-shadow: 0px 4px 10rpx #ccc;
13 | box-shadow: 0px 4px 10rpx #ccc;
14 | }
15 |
16 | .type-bar .item {
17 | flex: 1;
18 | text-align: center;
19 | }
20 |
21 | .type-bar .title {
22 | padding: 10rpx 0rpx;
23 | display: inline-block;
24 | }
25 |
26 | .type-bar .active {
27 | border-bottom: 4rpx solid #222;
28 | }
29 |
30 | .add {
31 | position: fixed;
32 | width: 80rpx;
33 | height: 80rpx;
34 | text-align: center;
35 | background-color: #ff4646;
36 | border: 1prx solid #222;
37 | border-radius: 50%;
38 | right: 20rpx;
39 | bottom: 20rpx;
40 | line-height: 80rpx;
41 | font-size: 35rpx;
42 | color: #fff;
43 | }
44 |
45 | .todo-box {
46 | margin: 20rpx 15rpx 0 15rpx;
47 | -moz-box-shadow: 0px 0px 10px #ccc;
48 | -webkit-box-shadow: 0px 0px 10px #ccc;
49 | box-shadow: 0px 0px 10px #ccc;
50 | background-color: #fff;
51 | border-radius: 8rpx;
52 | font-size: 0;
53 | display: flex;
54 | align-items: center;
55 |
56 | }
57 |
58 | .todo-box .left-tips {
59 | width: 8rpx;
60 | background-color: #ff4646;
61 | border-top-left-radius: 8rpx;
62 | border-bottom-left-radius: 8rpx;
63 | height: 150rpx;
64 | display: inline-block;
65 | }
66 |
67 | .todo-box .green {
68 | background-color: green;
69 | }
70 |
71 | .todo-box .info-box {
72 | flex: 1;
73 | margin-left: 30rpx;
74 | }
75 |
76 | .info-box .time {
77 | font-size: 22rpx;
78 | color: #999;
79 | margin-top: 10rpx;
80 | }
81 |
82 | .info-box .title {
83 | font-size: 30rpx;
84 | color: #222;
85 | margin-top: 10rpx;
86 | margin-bottom: 10rpx;
87 | display: block;
88 | line-height: 40rpx;
89 | overflow: hidden;
90 | white-space: nowrap;
91 | text-overflow: ellipsis;
92 | }
93 |
94 | .content {
95 | margin: 0 23rpx;
96 | text-align: center;
97 | border-bottom-left-radius: 8rpx;
98 | border-bottom-right-radius: 8rpx;
99 | background-color: #ff4646;
100 | padding: 15rpx;
101 | -moz-box-shadow: 0px 0px 10px #ccc;
102 | -webkit-box-shadow: 0px 0px 10px #ccc;
103 | box-shadow: 0px 0px 10px #ccc;
104 | color: #fff;
105 | }
106 |
107 | .content-green {
108 | margin: 0 23rpx;
109 | text-align: center;
110 | border-bottom-left-radius: 8rpx;
111 | border-bottom-right-radius: 8rpx;
112 | background-color: green;
113 | padding: 15rpx;
114 | -moz-box-shadow: 0px 0px 10px #ccc;
115 | -webkit-box-shadow: 0px 0px 10px #ccc;
116 | box-shadow: 0px 0px 10px #ccc;
117 | color: #fff;
118 | }
119 |
120 | .todo-box .arrow {
121 | width: 32rpx;
122 | height: 32rpx;
123 | margin: 30rpx;
124 | }
125 |
126 | .todo-box .open {
127 | transform: rotate(180deg);
128 | }
129 |
130 | .scroll-box {
131 | display: flex;
132 | width: fit-content;
133 | position: relative;
134 | transition: left 0.2s ease-in-out;
135 | box-sizing: border-box;
136 | }
137 |
138 | .scroll-box .content-box {
139 | width: 750rpx;
140 | /* width: 720rpx; */
141 | }
142 |
143 | .scroll-box .delete {
144 | width: 160rpx;
145 | text-align: center;
146 | display: flex;
147 | left: -15rpx;
148 | }
149 |
150 | .delete .item1 {
151 | flex: 1;
152 | margin-top: 20rpx;
153 | background-color: #ff4646;
154 | display: flex;
155 | align-items: center;
156 | padding-left: 15rpx;
157 | color: #fff;
158 | font-size: 22rpx;
159 | }
160 |
161 | .delete .item2 {
162 | flex: 1;
163 | margin-top: 20rpx;
164 | background-color: green;
165 | display: flex;
166 | align-items: center;
167 | padding-left: 15rpx;
168 | color: #fff;
169 | font-size: 22rpx;
170 | border-left: 1rpx solid #fff;
171 | border-top-right-radius: 8rpx;
172 | border-bottom-right-radius: 8rpx;
173 | }
174 |
--------------------------------------------------------------------------------
/pages/todoadd/add.js:
--------------------------------------------------------------------------------
1 | // pages/todoadd/add.js
2 | import api from "../../api/api.js";
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | date: "",
10 | title: "",
11 | content: "",
12 | },
13 |
14 | /**
15 | * 生命周期函数--监听页面加载
16 | */
17 | onLoad: function(options) {
18 |
19 | },
20 |
21 | /**
22 | * 生命周期函数--监听页面初次渲染完成
23 | */
24 | onReady: function() {
25 |
26 | },
27 |
28 | /**
29 | * 生命周期函数--监听页面显示
30 | */
31 | onShow: function() {
32 |
33 | },
34 |
35 | /**
36 | * 生命周期函数--监听页面隐藏
37 | */
38 | onHide: function() {
39 |
40 | },
41 |
42 | /**
43 | * 生命周期函数--监听页面卸载
44 | */
45 | onUnload: function() {
46 |
47 | },
48 |
49 | /**
50 | * 页面相关事件处理函数--监听用户下拉动作
51 | */
52 | onPullDownRefresh: function() {
53 |
54 | },
55 |
56 | /**
57 | * 页面上拉触底事件的处理函数
58 | */
59 | onReachBottom: function() {
60 |
61 | },
62 |
63 | /**
64 | * 用户点击右上角分享
65 | */
66 | onShareAppMessage: function() {
67 |
68 | },
69 | bindDateChange: function(e) {
70 | this.setData({
71 | date: e.detail.value
72 | })
73 | },
74 | onTitleChange(e) {
75 | this.setData({
76 | title: e.detail.value
77 | })
78 | },
79 | onContentChange(e) {
80 | this.setData({
81 | content: e.detail.value
82 | })
83 | },
84 | submit(){
85 | if(!this.data.title){
86 | this.toast("请输入标题~")
87 | return false;
88 | }
89 | if (!this.data.content) {
90 | this.toast("请输入待办详情~")
91 | return false;
92 | }
93 | if (!this.data.content) {
94 | this.toast("请选择时间~")
95 | return false;
96 | }
97 | wx.showLoading({
98 | title: 'loading...',
99 | })
100 | api.IPostTodoAdd({
101 | title:this.data.title,
102 | content:this.data.content,
103 | date:this.data.date,
104 | })
105 | .then(res=>{
106 | wx.hideLoading()
107 | wx.navigateBack({
108 | delta:1
109 | })
110 | })
111 | .catch(e=>{
112 | wx.hideLoading()
113 | this.toast(e.errorMsg)
114 | })
115 | },
116 | toast(msg){
117 | wx.showToast({
118 | title: msg,
119 | icon:"none",
120 | duration:2000,
121 | })
122 | }
123 | })
--------------------------------------------------------------------------------
/pages/todoadd/add.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "添加待办事项"
3 | }
--------------------------------------------------------------------------------
/pages/todoadd/add.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 待办标题:
4 |
5 | 待办详情:
6 |
7 |
8 |
9 | 时间:
10 |
11 | {{date}}
12 |
13 |
14 | 立即添加
15 |
--------------------------------------------------------------------------------
/pages/todoadd/add.wxss:
--------------------------------------------------------------------------------
1 | /* pages/todoadd/add.wxss */
2 | page{
3 | background-color: #fff;
4 | box-sizing: border-box;
5 | padding: 30rpx;
6 | }
7 | .todo{
8 | margin-top: 10%;
9 | }
10 | .todo .title{
11 | margin-top: 30rpx;
12 | }
13 | .text-input{
14 | width: 100%;
15 | border: 1rpx solid #222;
16 | display: inline-block;
17 | text-align: left;
18 | font-size: 28rpx;
19 | color: #222;
20 | border-radius: 8rpx;
21 | margin-top: 30rpx;
22 | box-sizing: border-box;
23 | padding:30rpx 10rpx;
24 | }
25 |
26 | .text-time{
27 | width: 100%;
28 | height: 70rpx;
29 | border: 1rpx solid #222;
30 | display: inline-block;
31 | text-align: left;
32 | font-size: 28rpx;
33 | color: #222;
34 | border-radius: 8rpx;
35 | margin-top: 30rpx;
36 | box-sizing: border-box;
37 | padding:15rpx 10rpx;
38 | }
39 |
40 | .text-content-input{
41 | width: 100%;
42 | height: 180rpx;
43 | border: 1rpx solid #222;
44 | display: inline-block;
45 | text-align: left;
46 | padding:10rpx;
47 | font-size: 28rpx;
48 | color: #222;
49 | border-radius: 8rpx;
50 | margin-top: 30rpx;
51 | box-sizing: border-box;
52 | }
53 |
54 | .add-btn{
55 | width: 100%;
56 | padding: 20rpx 0;
57 | background-color: #222;
58 | border-radius: 40rpx;
59 | color: #fff;
60 | display: inline-block;
61 | margin-top: 30rpx;
62 | font-size: 28rpx;
63 | text-align: center;
64 | }
--------------------------------------------------------------------------------
/pages/tree/tree.js:
--------------------------------------------------------------------------------
1 | // pages/tree/tree.js
2 | import api from "../../api/api.js";
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | treeList:[],
10 | },
11 |
12 | /**
13 | * 生命周期函数--监听页面加载
14 | */
15 | onLoad: function (options) {
16 | this.getTree()
17 | },
18 |
19 | getTree(){
20 | api.IGetTree({})
21 | .then(res=>{
22 | this.setData({
23 | treeList: res.data
24 | })
25 | })
26 | .catch(e=>{
27 |
28 | })
29 | },
30 |
31 | onHotKeyClick(event) {
32 | let key = event.currentTarget.dataset.key;
33 | let name = event.currentTarget.dataset.name;
34 | wx.navigateTo({
35 | url: '/pages/treelist/treelist?cid='+key+"&name="+name,
36 | })
37 | },
38 |
39 | /**
40 | * 生命周期函数--监听页面初次渲染完成
41 | */
42 | onReady: function () {
43 |
44 | },
45 |
46 | /**
47 | * 生命周期函数--监听页面显示
48 | */
49 | onShow: function () {
50 |
51 | },
52 |
53 | /**
54 | * 生命周期函数--监听页面隐藏
55 | */
56 | onHide: function () {
57 |
58 | },
59 |
60 | /**
61 | * 生命周期函数--监听页面卸载
62 | */
63 | onUnload: function () {
64 |
65 | },
66 |
67 | /**
68 | * 页面相关事件处理函数--监听用户下拉动作
69 | */
70 | onPullDownRefresh: function () {
71 |
72 | },
73 |
74 | /**
75 | * 页面上拉触底事件的处理函数
76 | */
77 | onReachBottom: function () {
78 |
79 | },
80 |
81 | /**
82 | * 用户点击右上角分享
83 | */
84 | onShareAppMessage: function () {
85 |
86 | }
87 | })
--------------------------------------------------------------------------------
/pages/tree/tree.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "知识体系"
3 | }
--------------------------------------------------------------------------------
/pages/tree/tree.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{item.name}}
4 |
5 | {{item.name}}
6 |
7 |
--------------------------------------------------------------------------------
/pages/tree/tree.wxss:
--------------------------------------------------------------------------------
1 | /* pages/tree/tree.wxss */
2 | page{
3 | background-color: #f5f5f5;
4 | }
5 | .tips-title{
6 | background-color: #fff;
7 | padding: 10rpx 30rpx;
8 | }
9 | .tips-box{
10 | padding: 20rpx 20rpx 10rpx 30rpx;
11 | }
12 | .tips-tag{
13 | padding: 5rpx 10rpx;
14 | border: 1rpx solid #222;
15 | border-radius: 25rpx;
16 | display: inline-block;
17 | background-color: #fff;
18 | margin: 0 10rpx 10rpx 0;
19 | font-size: 24rpx;
20 | }
--------------------------------------------------------------------------------
/pages/treelist/treelist.js:
--------------------------------------------------------------------------------
1 | // pages/treelist/treelist.js
2 | import api from "../../api/api.js";
3 | const app = getApp();
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | cid:"",
11 | chapters: [],
12 | articleList: [],
13 | currentTab: 0,
14 | scrollWidth: 0,
15 | page: 1,
16 | pageCount: 1,
17 | isLoadingMore: false,
18 | },
19 |
20 | /**
21 | * 生命周期函数--监听页面加载
22 | */
23 | onLoad: function (options) {
24 | this.setData({
25 | cid:options.cid
26 | })
27 | wx.setNavigationBarTitle({
28 | title: options.name,
29 | success: function(res) {},
30 | fail: function(res) {},
31 | complete: function(res) {},
32 | })
33 | this.getArticle(1)
34 | },
35 |
36 | getArticle(page) {
37 | api.IGetTreeArticle(this.data.cid, page)
38 | .then(res => {
39 | for (let item of res.data.datas) {
40 | item.headTetx = item.author.substring(0, 1)
41 | }
42 | wx.stopPullDownRefresh()
43 | this.setData({
44 | articleList: this.data.articleList.concat(res.data.datas),
45 | page: page,
46 | pageCount: res.data.pageCount,
47 | isLoadingMore: false,
48 | })
49 | })
50 | .catch(e => {
51 |
52 | })
53 | },
54 |
55 | onItemClick(event) {
56 | let url = event.currentTarget.dataset.url;
57 | wx.navigateTo({
58 | url: "/pages/web/index?url=" + encodeURIComponent(url)
59 | })
60 | },
61 |
62 | /**
63 | * 生命周期函数--监听页面初次渲染完成
64 | */
65 | onReady: function () {
66 |
67 | },
68 |
69 | /**
70 | * 生命周期函数--监听页面显示
71 | */
72 | onShow: function () {
73 |
74 | },
75 |
76 | /**
77 | * 生命周期函数--监听页面隐藏
78 | */
79 | onHide: function () {
80 |
81 | },
82 |
83 | /**
84 | * 生命周期函数--监听页面卸载
85 | */
86 | onUnload: function () {
87 |
88 | },
89 |
90 | /**
91 | * 页面相关事件处理函数--监听用户下拉动作
92 | */
93 | onPullDownRefresh: function () {
94 |
95 | },
96 |
97 | /**
98 | * 页面上拉触底事件的处理函数
99 | */
100 | onReachBottom: function () {
101 | if (this.data.pageCount <= this.data.page || this.data.isLoadingMore) {
102 | return false;
103 | }
104 | this.setData({
105 | isLoadingMore: true,
106 | })
107 | this.getArticle(this.data.page + 1)
108 | },
109 |
110 | /**
111 | * 用户点击右上角分享
112 | */
113 | onShareAppMessage: function () {
114 |
115 | },
116 | collectClick(event) {
117 | if (!app.isLogin()) {
118 | wx.navigateTo({
119 | url: '/pages/login/login',
120 | })
121 | return false;
122 | }
123 | let id = event.currentTarget.dataset.id;
124 | let zan = event.currentTarget.dataset.zan;
125 | let index = event.currentTarget.dataset.index;
126 | if (!zan) {
127 | api.IPostCollect(id)
128 | .then(res => {
129 | this.data.articleList[index].collect = true;
130 | this.setData({
131 | articleList: this.data.articleList
132 | })
133 | wx.showToast({
134 | title: '收藏成功',
135 | })
136 | })
137 | .catch(e => {
138 |
139 | })
140 | } else {
141 | api.IPostArticleUnCollect(id)
142 | .then(res => {
143 | this.data.articleList[index].collect = false;
144 | this.setData({
145 | articleList: this.data.articleList
146 | })
147 | wx.showToast({
148 | title: '取消收藏',
149 | })
150 | })
151 | .catch(e => {
152 |
153 | })
154 | }
155 | }
156 | })
--------------------------------------------------------------------------------
/pages/treelist/treelist.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/treelist/treelist.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{item.headTetx}}
6 | {{item.author}}
7 | {{item.chapterName}}
8 |
9 | {{item.title}}
10 | {{item.desc?item.desc:item.link}}
11 |
12 |
13 | {{item.niceDate}}
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pages/treelist/treelist.wxss:
--------------------------------------------------------------------------------
1 | /* pages/treelist/treelist.wxss */
2 | page{
3 | background-color: #f5f5f5;
4 | }
5 | .article-list-box{
6 | padding: 0 0 0 0;
7 | }
8 |
9 | .article-box {
10 | padding: 10rpx 30rpx;
11 | box-sizing: border-box;
12 | background-color: #fff;
13 | border-top: 10rpx solid #f5f5f5;
14 | }
15 |
16 | .article-box .article-top {
17 | display: flex;
18 | align-items: center;
19 | }
20 |
21 | .article-box .head {
22 | background-color: #ff8635;
23 | border-radius: 50%;
24 | width: 30rpx;
25 | height: 30rpx;
26 | font-size: 20rpx;
27 | text-align: center;
28 | color: #fff;
29 | }
30 |
31 | .article-box .name {
32 | font-size: 22rpx;
33 | color: #333;
34 | flex: 1;
35 | margin-left: 10rpx;
36 | }
37 |
38 | .article-box .type {
39 | color: #666;
40 | font-size: 22rpx;
41 | }
42 |
43 | .article-box .title {
44 | display: block;
45 | font-size: 26rpx;
46 | color: #222;
47 | line-height: 40rpx;
48 | overflow: hidden;
49 | white-space: nowrap;
50 | text-overflow: ellipsis;
51 | margin-top: 15rpx;
52 | }
53 |
54 | .article-box .desc {
55 | display: -webkit-box;
56 | font-size: 22rpx;
57 | color: #999;
58 | line-height: 40rpx;
59 | word-break: break-all;
60 | -webkit-box-orient: vertical;
61 | -webkit-line-clamp: 2;
62 | overflow: hidden;
63 | text-overflow: ellipsis;
64 | margin-top: 10rpx;
65 | }
66 |
67 | .article-box .icon {
68 | vertical-align: middle;
69 | width: 32rpx;
70 | height: 32rpx;
71 | }
72 |
73 | .article-box .time {
74 | font-size: 22rpx;
75 | color: #666;
76 | vertical-align: middle;
77 | flex: 1;
78 | text-align: right;
79 | }
--------------------------------------------------------------------------------
/pages/waterfall/index.js:
--------------------------------------------------------------------------------
1 | // pages/waterfall/index.js
2 | var add = 0;
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | note: [{ "_id": "5bfe1a5b9d2122309624cbb7", "createdAt": "2018-11-28T04:32:27.338Z", "desc": "2018-11-28", "publishedAt": "2018-11-28T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqgy1fxno2dvxusj30sf10nqcm.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5bf22fd69d21223ddba8ca25", "createdAt": "2018-11-19T03:36:54.950Z", "desc": "2018-11-19", "publishedAt": "2018-11-19T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqgy1fxd7vcz86nj30qo0ybqc1.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5be14edb9d21223dd50660f8", "createdAt": "2018-11-06T08:20:43.656Z", "desc": "2018-11-06", "publishedAt": "2018-11-06T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqgy1fwyf0wr8hhj30ie0nhq6p.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5bcd71979d21220315c663fc", "createdAt": "2018-10-22T06:43:35.440Z", "desc": "2018-10-22", "publishedAt": "2018-10-22T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqgy1fwgzx8n1syj30sg15h7ew.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5bc434ac9d212279160c4c9e", "createdAt": "2018-10-15T06:33:16.497Z", "desc": "2018-10-15", "publishedAt": "2018-10-15T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqly1fw8wzdua6rj30sg0yc7gp.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5bbb0de09d21226111b86f1c", "createdAt": "2018-10-08T07:57:20.978Z", "desc": "2018-10-08", "publishedAt": "2018-10-08T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqly1fw0vdlg6xcj30j60mzdk7.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5ba206ec9d2122610aba3440", "createdAt": "2018-09-19T08:21:00.295Z", "desc": "2018-09-19", "publishedAt": "2018-09-19T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqly1fvexaq313uj30qo0wldr4.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b9771a29d212206c1b383d0", "createdAt": "2018-09-11T07:41:22.491Z", "desc": "2018-09-11", "publishedAt": "2018-09-11T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqly1fv5n6daacqj30sg10f1dw.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b830bba9d2122031f86ee51", "createdAt": "2018-08-27T04:21:14.703Z", "desc": "2018-08-27", "publishedAt": "2018-08-28T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqly1fuo54a6p0uj30sg0zdqnf.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b7b836c9d212201e982de6e", "createdAt": "2018-08-21T11:13:48.989Z", "desc": "2018-08-21", "publishedAt": "2018-08-21T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqly1fuh5fsvlqcj30sg10onjk.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b74e9409d21222c52ae4cb4", "createdAt": "2018-08-16T11:02:24.289Z", "desc": "2018-08-16", "publishedAt": "2018-08-16T00:00:00.0Z", "source": "api", "type": "\u798f\u5229", "url": "https://ws1.sinaimg.cn/large/0065oQSqly1fubd0blrbuj30ia0qp0yi.jpg", "used": true, "who": "lijinshan" }, { "_id": "5b7102749d2122341d563844", "createdAt": "2018-08-13T12:00:52.458Z", "desc": "2018-08-13", "publishedAt": "2018-08-13T00:00:00.0Z", "source": "api", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqly1fu7xueh1gbj30hs0uwtgb.jpg", "used": true, "who": "lijinshan" }, { "_id": "5b6bad449d21226f45755582", "createdAt": "2018-08-09T10:56:04.962Z", "desc": "2018-08-09", "publishedAt": "2018-08-09T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqgy1fu39hosiwoj30j60qyq96.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b67b7fd9d2122195bdbd806", "createdAt": "2018-08-06T10:52:45.809Z", "desc": "2018-08-06", "publishedAt": "2018-08-06T00:00:00.0Z", "source": "api", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqly1ftzsj15hgvj30sg15hkbw.jpg", "used": true, "who": "lijinshan" }, { "_id": "5b63cd4e9d21225e0d3f58c9", "createdAt": "2018-08-03T11:34:38.672Z", "desc": "2018-08-03", "publishedAt": "2018-08-03T00:00:00.0Z", "source": "api", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqgy1ftwcw4f4a5j30sg10j1g9.jpg", "used": true, "who": "lijinshan" }, { "_id": "5b6151509d21225206860f08", "createdAt": "2018-08-01T14:21:04.556Z", "desc": "2018-08-01", "publishedAt": "2018-08-01T00:00:00.0Z", "source": "api", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqly1ftu6gl83ewj30k80tites.jpg", "used": true, "who": "lijinshan" }, { "_id": "5b60356a9d212247776a2e0e", "createdAt": "2018-07-31T18:09:46.825Z", "desc": "2018-07-31", "publishedAt": "2018-07-31T00:00:00.0Z", "source": "api", "type": "\u798f\u5229", "url": "http://ww1.sinaimg.cn/large/0065oQSqgy1ftt7g8ntdyj30j60op7dq.jpg", "used": true, "who": "lijinshan" }, { "_id": "5b5e93499d21220fc64181a9", "createdAt": "2018-07-30T12:25:45.937Z", "desc": "2018-07-30", "publishedAt": "2018-07-30T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqgy1ftrrvwjqikj30go0rtn2i.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b50107f421aa917a31c0565", "createdAt": "2018-07-19T12:15:59.226Z", "desc": "2018-07-19", "publishedAt": "2018-07-19T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqly1ftf1snjrjuj30se10r1kx.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b4eaae4421aa93aa99bee16", "createdAt": "2018-07-18T11:14:55.648Z", "desc": "2018-07-18", "publishedAt": "2018-07-18T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqly1ftdtot8zd3j30ju0pt137.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b481d01421aa90bba87b9ae", "createdAt": "2018-07-13T11:31:13.266Z", "desc": "2018-07-13", "publishedAt": "2018-07-13T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "http://ww1.sinaimg.cn/large/0073sXn7ly1ft82s05kpaj30j50pjq9v.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b456f5d421aa92fc4eebe48", "createdAt": "2018-07-11T10:45:49.246Z", "desc": "2018-07-11", "publishedAt": "2018-07-11T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqly1ft5q7ys128j30sg10gnk5.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b441f06421aa92fccb520a2", "createdAt": "2018-07-10T10:50:46.379Z", "desc": "2018-07-10", "publishedAt": "2018-07-10T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "https://ww1.sinaimg.cn/large/0065oQSqgy1ft4kqrmb9bj30sg10fdzq.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b42d1aa421aa92d1cba2918", "createdAt": "2018-07-09T11:08:26.162Z", "desc": "2018-07-09", "publishedAt": "2018-07-09T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "http://ww1.sinaimg.cn/large/0065oQSqly1ft3fna1ef9j30s210skgd.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b3ed2d5421aa91cfe803e35", "createdAt": "2018-07-06T10:24:21.907Z", "desc": "2018-07-06", "publishedAt": "2018-07-06T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "http://ww1.sinaimg.cn/large/0065oQSqly1fszxi9lmmzj30f00jdadv.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b3d883f421aa906e5b3c6f1", "createdAt": "2018-07-05T10:53:51.361Z", "desc": "2018-07-05", "publishedAt": "2018-07-05T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "http://ww1.sinaimg.cn/large/0065oQSqly1fsysqszneoj30hi0pvqb7.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b3ae394421aa906e7db029b", "createdAt": "2018-07-03T10:46:44.112Z", "desc": "2018-07-03", "publishedAt": "2018-07-03T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "http://ww1.sinaimg.cn/large/0065oQSqly1fswhaqvnobj30sg14hka0.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b398cf8421aa95570db5491", "createdAt": "2018-07-02T10:24:56.546Z", "desc": "2018-07-02", "publishedAt": "2018-07-02T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "http://ww1.sinaimg.cn/large/0065oQSqly1fsvb1xduvaj30u013175p.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b33ccf2421aa95570db5478", "createdAt": "2018-06-28T01:44:18.488Z", "desc": "2018-06-28", "publishedAt": "2018-06-28T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "http://ww1.sinaimg.cn/large/0065oQSqly1fsq9iq8ttrj30k80q9wi4.jpg", "used": true, "who": "lijinshanmx" }, { "_id": "5b32807e421aa95570db5471", "createdAt": "2018-06-27T02:05:50.227Z", "desc": "2018-06-27", "publishedAt": "2018-06-27T00:00:00.0Z", "source": "web", "type": "\u798f\u5229", "url": "http://ww1.sinaimg.cn/large/0065oQSqly1fsp4iok6o4j30j60optbl.jpg", "used": true, "who": "lijinshanmx" }]
10 |
11 | },
12 |
13 | /**
14 | * 生命周期函数--监听页面加载
15 | */
16 | onLoad: function (options) {
17 |
18 | },
19 |
20 | /**
21 | * 生命周期函数--监听页面初次渲染完成
22 | */
23 | onReady: function () {
24 |
25 | },
26 |
27 | /**
28 | * 生命周期函数--监听页面显示
29 | */
30 | onShow: function () {
31 |
32 | },
33 |
34 | /**
35 | * 生命周期函数--监听页面隐藏
36 | */
37 | onHide: function () {
38 |
39 | },
40 |
41 | /**
42 | * 生命周期函数--监听页面卸载
43 | */
44 | onUnload: function () {
45 |
46 | },
47 |
48 | /**
49 | * 页面相关事件处理函数--监听用户下拉动作
50 | */
51 | onPullDownRefresh: function () {
52 |
53 | },
54 |
55 | /**
56 | * 页面上拉触底事件的处理函数
57 | */
58 |
59 | onReachBottom: function () {
60 | console.log("onReachBottom")
61 | let arr = [...this.data.note];
62 |
63 | this.setData({
64 | note: arr.concat(arr)
65 | })
66 | add++
67 | },
68 |
69 | /**
70 | * 用户点击右上角分享
71 | */
72 | onShareAppMessage: function () {
73 |
74 | }
75 | })
--------------------------------------------------------------------------------
/pages/waterfall/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/waterfall/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{item.desc}}{{index}}
11 |
12 |
13 |
14 |
15 |
16 | {{item.desc}}{{index}}
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
34 |
--------------------------------------------------------------------------------
/pages/waterfall/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/waterfall/index.wxss */
2 |
3 | .water-fall{
4 | width: 100%;
5 | }
6 |
7 | .item{
8 | display: inline-block;
9 | width: 48%;
10 | margin: 0.5%;
11 | vertical-align: top;
12 | }
13 |
14 |
15 | .img{
16 | width: 100%;
17 | height: auto;
18 | }
19 |
20 | .grid {
21 | margin: 50rpx;
22 | padding: 20rpx;
23 | background-color: #e3fafc;
24 | border: 1rpx solid #99e9f2;
25 | display: grid;
26 | grid-gap: 40rpx;
27 | grid-template-columns: repeat(2, 1fr);
28 | grid-auto-rows: minmax(50rpx, auto);
29 | }
30 |
31 | .grid > view {
32 | border: 1rpx solid #3bc9db;
33 | border-radius: 3rpx;
34 | background-color: #99e9f2;
35 | font-size:250%;
36 | color: #fff;
37 | display: flex;
38 | align-items: center;
39 | justify-content: center;
40 | }
41 |
42 | .grid > view:nth-child(1) {
43 | grid-row: 1 / 4;
44 | grid-column: 1;
45 | }
46 |
47 | .grid > view:nth-child(2) {
48 | grid-row: 1 / 3;
49 | grid-column: 2;
50 | }
51 |
52 | .grid > view:nth-child(3) {
53 | grid-row: 1 / 4;
54 | grid-column: 1;
55 | }
56 |
57 | .grid > view:nth-child(4) {
58 | grid-row: 4 / 7;
59 | grid-column: 2;
60 | }
61 |
62 | .grid > view:nth-child(5) {
63 | grid-row: 3 / 7;
64 | grid-column: 1;
65 | }
66 |
67 | .grid > view:nth-child(6) {
68 | grid-row: 4 / 6;
69 | grid-column: 2;
70 | }
71 |
72 |
73 | page{
74 | background-color: #eee;
75 | }
76 | .case-page{
77 | padding:20rpx;
78 | }
79 | .list-masonry{
80 | column-count: 2;
81 | column-gap: 20rpx;
82 | }
83 | .item-masonry{
84 | background-color: #fff;break-inside: avoid; box-sizing: border-box; padding: 20rpx;
85 | }
86 | .item-masonry image {
87 | width: 100%;
88 | }
89 |
--------------------------------------------------------------------------------
/pages/web/index.js:
--------------------------------------------------------------------------------
1 | // pages/web/index.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | pageurl: ""
9 | },
10 |
11 | /**
12 | * 生命周期函数--监听页面加载
13 | */
14 | onLoad: function (options) {
15 | let url = decodeURIComponent(options.url)
16 | console.log(url)
17 | this.setData({
18 | pageurl: url
19 | })
20 | },
21 |
22 | /**
23 | * 生命周期函数--监听页面初次渲染完成
24 | */
25 | onReady: function () {
26 |
27 | },
28 |
29 | /**
30 | * 生命周期函数--监听页面显示
31 | */
32 | onShow: function () {
33 |
34 | },
35 |
36 | /**
37 | * 生命周期函数--监听页面隐藏
38 | */
39 | onHide: function () {
40 |
41 | },
42 |
43 | /**
44 | * 生命周期函数--监听页面卸载
45 | */
46 | onUnload: function () {
47 |
48 | },
49 |
50 | /**
51 | * 页面相关事件处理函数--监听用户下拉动作
52 | */
53 | onPullDownRefresh: function () {
54 |
55 | },
56 |
57 | /**
58 | * 页面上拉触底事件的处理函数
59 | */
60 | onReachBottom: function () {
61 |
62 | },
63 |
64 | /**
65 | * 用户点击右上角分享
66 | */
67 | onShareAppMessage: function () {
68 |
69 | }
70 | })
--------------------------------------------------------------------------------
/pages/web/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/web/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/pages/web/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/web/index.wxss */
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件",
3 | "packOptions": {
4 | "ignore": []
5 | },
6 | "setting": {
7 | "urlCheck": false,
8 | "es6": true,
9 | "postcss": true,
10 | "minified": true,
11 | "newFeature": true
12 | },
13 | "compileType": "miniprogram",
14 | "libVersion": "2.4.1",
15 | "appid": "wx58cc31f7e8dea7d4",
16 | "projectname": "wanandroid-mini",
17 | "debugOptions": {
18 | "hidedInDevtools": []
19 | },
20 | "isGameTourist": false,
21 | "condition": {
22 | "search": {
23 | "current": -1,
24 | "list": []
25 | },
26 | "conversation": {
27 | "current": -1,
28 | "list": []
29 | },
30 | "plugin": {
31 | "current": -1,
32 | "list": []
33 | },
34 | "game": {
35 | "currentL": -1,
36 | "list": []
37 | },
38 | "miniprogram": {
39 | "current": 1,
40 | "list": [
41 | {
42 | "id": 0,
43 | "name": "1",
44 | "pathName": "pages/me/me",
45 | "query": ""
46 | },
47 | {
48 | "id": 1,
49 | "name": "2",
50 | "pathName": "pages/login/login",
51 | "query": ""
52 | }
53 | ]
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/screenshot/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/1.jpg
--------------------------------------------------------------------------------
/screenshot/10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/10.jpg
--------------------------------------------------------------------------------
/screenshot/11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/11.jpg
--------------------------------------------------------------------------------
/screenshot/12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/12.jpg
--------------------------------------------------------------------------------
/screenshot/13.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/13.jpg
--------------------------------------------------------------------------------
/screenshot/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/2.jpg
--------------------------------------------------------------------------------
/screenshot/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/3.jpg
--------------------------------------------------------------------------------
/screenshot/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/4.jpg
--------------------------------------------------------------------------------
/screenshot/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/5.jpg
--------------------------------------------------------------------------------
/screenshot/6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/6.jpg
--------------------------------------------------------------------------------
/screenshot/7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/7.jpg
--------------------------------------------------------------------------------
/screenshot/8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/8.jpg
--------------------------------------------------------------------------------
/screenshot/9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leiyun-studio/wanandroid-mini/5472d7a78379ebdd8ae5d90fccba1c9c2116ab24/screenshot/9.jpg
--------------------------------------------------------------------------------
/typings/wx.d.ts:
--------------------------------------------------------------------------------
1 | // generate time:2017-08-23 21:12:06
2 | // Type definitions for wx app
3 | // Definitions by: hellopao
4 |
5 | /************************************************
6 | * *
7 | * 微信小程序 API *
8 | * *
9 | ************************************************/
10 |
11 | interface IAnimation {
12 | /**
13 | * 透明度,参数范围 0~1
14 | */
15 | opacity(value: number): IAnimation;
16 | /**
17 | * 颜色值
18 | */
19 | backgroundColor(color: string): IAnimation;
20 | /**
21 | * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
22 | */
23 | width(length: number): IAnimation;
24 | /**
25 | * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
26 | */
27 | height(length: number): IAnimation;
28 | /**
29 | * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
30 | */
31 | top(length: number): IAnimation;
32 | /**
33 | * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
34 | */
35 | left(length: number): IAnimation;
36 | /**
37 | * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
38 | */
39 | bottom(length: number): IAnimation;
40 | /**
41 | * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
42 | */
43 | right(length: number): IAnimation;
44 | /**
45 | * deg的范围-180~180,从原点顺时针旋转一个deg角度
46 | */
47 | rotate(deg: number): IAnimation;
48 | /**
49 | * deg的范围-180~180,在X轴旋转一个deg角度
50 | */
51 | rotateX(deg: number): IAnimation;
52 | /**
53 | * deg的范围-180~180,在Y轴旋转一个deg角度
54 | */
55 | rotateY(deg: number): IAnimation;
56 | /**
57 | * deg的范围-180~180,在Z轴旋转一个deg角度
58 | */
59 | rotateZ(deg: number): IAnimation;
60 | /**
61 | * 同transform-function rotate3d
62 | */
63 | rotate3d(x: number, y: number, z: number, deg: number): IAnimation;
64 | /**
65 | * 一个参数时,表示在X轴、Y轴同时缩放sx倍数;两个参数时表示在X轴缩放sx倍数,在Y轴缩放sy倍数
66 | */
67 | scale(sx: number, sy?: number): IAnimation;
68 | /**
69 | * 在X轴缩放sx倍数
70 | */
71 | scaleX(sx: number): IAnimation;
72 | /**
73 | * 在Y轴缩放sy倍数
74 | */
75 | scaleY(sy: number): IAnimation;
76 | /**
77 | * 在Z轴缩放sy倍数
78 | */
79 | scaleZ(sz: number): IAnimation;
80 | /**
81 | * 在X轴缩放sx倍数,在Y轴缩放sy倍数,在Z轴缩放sz倍数
82 | */
83 | scale3d(sx: number, sy: number, sz: number): IAnimation;
84 | /**
85 | * 一个参数时,表示在X轴偏移tx,单位px;两个参数时,表示在X轴偏移tx,在Y轴偏移ty,单位px。
86 | */
87 | translate(tx: number, ty?: number): IAnimation;
88 | /**
89 | * 在X轴偏移tx,单位px
90 | */
91 | translateX(tx: number): IAnimation;
92 | /**
93 | * 在Y轴偏移tx,单位px
94 | */
95 | translateY(tx: number): IAnimation;
96 | /**
97 | * 在Z轴偏移tx,单位px
98 | */
99 | translateZ(tx: number): IAnimation;
100 | /**
101 | * 在X轴偏移tx,在Y轴偏移ty,在Z轴偏移tz,单位px
102 | */
103 | translate3d(tx: number, ty: number, tz: number): IAnimation;
104 | /**
105 | * 参数范围-180~180;一个参数时,Y轴坐标不变,X轴坐标延顺时针倾斜ax度;两个参数时,分别在X轴倾斜ax度,在Y轴倾斜ay度
106 | */
107 | skew(ax: number, ay?: number): IAnimation;
108 | /**
109 | * 参数范围-180~180;Y轴坐标不变,X轴坐标延顺时针倾斜ax度
110 | */
111 | skewX(ax: number): IAnimation;
112 | /**
113 | * 参数范围-180~180;X轴坐标不变,Y轴坐标延顺时针倾斜ay度
114 | */
115 | skewY(ay: number): IAnimation;
116 | /**
117 | * 同transform-function matrix
118 | */
119 | matrix(a, b, c, d, tx, ty): IAnimation;
120 | /**
121 | * 同transform-function matrix3d
122 | */
123 | matrix3d(): IAnimation;
124 | }
125 |
126 | interface ICanvasContext {
127 | /**
128 | * 设置填充色, 如果没有设置 fillStyle,默认颜色为 black。
129 | */
130 | setFillStyle(color: string): void;
131 | /**
132 | * 设置边框颜色, 如果没有设置 fillStyle,默认颜色为 black。
133 | */
134 | setStrokeStyle(color: string): void;
135 | /**
136 | * 设置阴影
137 | */
138 | setShadow(offsetX: number, offsetY: number, blur: number, color: string): void;
139 | /**
140 | * 创建一个线性的渐变颜色。需要使用 addColorStop() 来指定渐变点,至少要两个。
141 | */
142 | createLinearGradient(x0: number, y0: number, x1: number, y1: number): void;
143 | /**
144 | * 创建一个圆形的渐变颜色。 起点在圆心,终点在圆环。 需要使用 addColorStop() 来指定渐变点,至少要两个。
145 | */
146 | createCircularGradient(x: number, y: number, r: number): void;
147 | /**
148 | * 创建一个颜色的渐变点。小于最小 stop 的部分会按最小 stop 的 color 来渲染,大于最大 stop 的部分会按最大 stop 的 color 来渲染。需要使用 addColorStop() 来指定渐变点,至少要两个。
149 | */
150 | addColorStop(stop: number, color: string): void;
151 | /**
152 | * 设置线条端点的样式
153 | */
154 | setLineCap(lineCap: 'butt' | 'round' | 'square'): void;
155 | /**
156 | * 设置两线相交处的样式
157 | */
158 | setLineJoin(lineJoin: 'bevel' | 'round' | 'miter'): void;
159 | /**
160 | * 设置线条宽度
161 | */
162 | setLineWidth(lineWidth: number): void;
163 | /**
164 | * 设置最大倾斜
165 | */
166 | setMiterLimit(miterLimit: number): void;
167 | /**
168 | * 添加一个矩形路径到当前路径。
169 | */
170 | rect(x: number, y: number, width: number, height: number): void;
171 | /**
172 | * 填充一个矩形。用 setFillStyle() 设置矩形的填充色,如果没设置默认是黑色。
173 | */
174 | fillRect(x: number, y: number, width: number, height: number): void;
175 | /**
176 | * 一个矩形(非填充)。用 setFillStroke() 设置矩形线条的颜色,如果没设置默认是黑色。
177 | */
178 | strokeRect(x: number, y: number, width: number, height: number): void;
179 | /**
180 | * 在给定的矩形区域内,清除画布上的像素
181 | */
182 | clearRect(x: number, y: number, width: number, height: number): void;
183 | /**
184 | * 对当前路径进行填充
185 | */
186 | fill(): void;
187 | /**
188 | * 对当前路径进行描边
189 | */
190 | stroke(): void;
191 | /**
192 | * 开始一个路径
193 | */
194 | beginPath(): void;
195 | /**
196 | * 关闭一个路径
197 | */
198 | closePath(): void;
199 | /**
200 | * 把路径移动到画布中的指定点,但不创建线条。
201 | */
202 | moveTo(x: number, y: number): void;
203 | /**
204 | * 添加一个新点,然后在画布中创建从该点到最后指定点的线条。
205 | */
206 | lineTo(x: number, y: number): void;
207 | /**
208 | * 添加一个弧形路径到当前路径,顺时针绘制。
209 | */
210 | arc(x: number, y: number, radius: number, startAngle: number, sweepAngle: number): void;
211 | /**
212 | * 创建二次方贝塞尔曲线
213 | */
214 | quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
215 | /**
216 | * 创建三次方贝塞尔曲线
217 | */
218 | bezierCurveTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): void;
219 | /**
220 | * 对横纵坐标进行缩放
221 | */
222 | scale(scaleWidth: number/**横坐标缩放的倍数1 = 100%,0.5 = 50%,2 = 200%,依次类 */, scaleHeight: number/** 纵坐标轴缩放的倍数1 = 100%,0.5 = 50%,2 = 200%,依次类 */): void;
223 | /**
224 | * 对坐标轴进行顺时针旋转
225 | */
226 | rotate(deg: number/**degrees * Math.PI/180;degrees范围为0~360;旋转角度,以弧度计 */): void;
227 | /**
228 | * 对坐标原点进行缩放
229 | */
230 | translate(x: number/**水平坐标平移量 */, y: number/**竖直坐标平移量 */): void;
231 | /**
232 | * 在画布上绘制被填充的文本
233 | */
234 | fillText(text: string, x: number, y: number): void;
235 | /**
236 | * 设置字体大小
237 | */
238 | setFontSize(fontSize: number): void;
239 | /**
240 | * 在画布上绘制图像
241 | */
242 | drawImage(imageResource: string, x: number, y: number, width: number, height: number): void;
243 | /**
244 | * 设置全局画笔透明度。
245 | */
246 | setGlobalAlpha(alpha: number): void;
247 | /**
248 | * 保存当前坐标轴的缩放、旋转、平移信息
249 | */
250 | save(): void;
251 | /**
252 | * 恢复之前保存过的坐标轴的缩放、旋转、平移信息
253 | */
254 | restore(): void;
255 | /**
256 | * 进行绘图
257 | */
258 | draw(): void;
259 | }
260 |
261 | interface IAudioContext {
262 | /**
263 | * 播放
264 | */
265 | play: () => void;
266 | /**
267 | * 暂停
268 | */
269 | pause: () => void;
270 | /**
271 | * 跳转到指定位置,单位 s
272 | */
273 | seek: (position: number) => void;
274 | }
275 |
276 | interface IVideoContext {
277 | /**
278 | * 播放
279 | */
280 | play: () => void;
281 | /**
282 | * 暂停
283 | */
284 | pause: () => void;
285 | /**
286 | * 跳转到指定位置,单位 s
287 | */
288 | seek: (position: number) => void;
289 | /**
290 | * 发送弹幕,danmu 包含两个属性 text, color。
291 | */
292 | sendDanmu: (danmu: {text: string; color: string;}) => void;
293 | }
294 |
295 | interface IMapContext {
296 | /**
297 | * 获取当前地图中心的经纬度,返回的是 gcj02 坐标系,可以用于 wx.openLocation
298 | */
299 | getCenterLocation: (obj: {
300 | /**
301 | * 接口调用成功的回调函数 ,res = { longitude: "经度", latitude: "纬度"}
302 | */
303 | success?: (res: {longitude: string; latitude: string}) => void;
304 | /**
305 | * 接口调用失败的回调函数
306 | */
307 | fail?: () => void;
308 | /**
309 | * 接口调用结束的回调函数(调用成功、失败都会执行)
310 | */
311 | complete?: () => void;
312 | }) => void;
313 | /**
314 | * 将地图中心移动到当前定位点,需要配合map组件的show-location使用
315 | */
316 | moveToLocation: () => void;
317 | }
318 |
319 | interface Application {
320 | setData: (obj: any) => void;
321 | }
322 |
323 | interface AppConstructor {
324 | new (): Application;
325 | (opts: {
326 | /**
327 | * 生命周期函数--监听小程序初始化
328 | */
329 | onLaunch?: () => void;
330 | /**
331 | * 生命周期函数--监听小程序显示
332 | */
333 | onShow?: () => void;
334 | /**
335 | * 生命周期函数--监听小程序隐藏
336 | */
337 | onHide?: () => void;
338 |
339 | [key: string]: any;
340 | }): Application;
341 | }
342 |
343 | declare var App: AppConstructor;
344 | declare function getApp(): Application;
345 |
346 | declare function getCurrentPages(): Page[];
347 |
348 | interface Page {
349 | setData: (obj: any) => void;
350 | }
351 |
352 | interface PageConstructor {
353 | new (): Page;
354 | (opts: {
355 | /**
356 | * 页面的初始数据
357 | */
358 | data?: any;
359 | /**
360 | * 页面的初始数据
361 | */
362 | onLoad?: () => void;
363 | /**
364 | * 生命周期函数--监听页面初次渲染完成
365 | */
366 | onReady?: () => void;
367 | /**
368 | * 生命周期函数--监听页面显示
369 | */
370 | onShow?: () => void;
371 | /**
372 | * 生命周期函数--监听页面隐藏
373 | */
374 | onHide?: () => void;
375 | /**
376 | * 生命周期函数--监听页面卸载
377 | */
378 | onUnload?: () => void;
379 | /**
380 | * 页面相关事件处理函数--监听用户下拉动作
381 | */
382 | onPullDownRefreash?: () => void;
383 | /**
384 | * 页面上拉触底事件的处理函数
385 | */
386 | onReachBottom?: () => void;
387 | /**
388 | * 用户点击右上角分享
389 | */
390 | onShareAppMessage?: () => {
391 | /**
392 | * 分享标题, 默认值当前小程序名称
393 | */
394 | title: string;
395 | /**
396 | * 分享描述, 默认值当前小程序名称
397 | */
398 | desc: string;
399 | /**
400 | * 分享路径 默认值当前页面 path ,必须是以 / 开头的完整路径
401 | */
402 | path: string;
403 | };
404 |
405 | [key: string]: any;
406 | }): Page;
407 | }
408 |
409 | declare var Page: PageConstructor;
410 |
411 | declare var wx: {
412 | // # 网络 #
413 |
414 | request(obj: {
415 | /**
416 | * 开发者服务器接口地址
417 | */
418 | url: string;
419 | /**
420 | * 请求的参数
421 | */
422 | data?: any | string;
423 | /**
424 | * 设置请求的 header , header 中不能设置 Referer
425 | */
426 | header?: any;
427 | /**
428 | * 默认为 GET,有效值:OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
429 | */
430 | method?: string;
431 | /**
432 | * 默认为 json。如果设置了 dataType 为 json,则会尝试对响应的数据做一次 JSON.parse
433 | */
434 | dataType?: string;
435 | /**
436 | * 收到开发者服务成功返回的回调函数,res = {data: '开发者服务器返回的内容'}
437 | */
438 | success?: Function;
439 | /**
440 | * 接口调用失败的回调函数
441 | */
442 | fail?: Function;
443 | /**
444 | * 接口调用结束的回调函数(调用成功、失败都会执行)
445 | */
446 | complete?: Function;
447 | }): void;
448 |
449 | /**
450 | * 将本地资源上传到开发者服务器。如页面通过 wx.chooseImage 等接口获取到一个本地资源的临时文件路径后,可通过此接口将本地资源上传到指定服务器。客户端发起一个 HTTPS POST 请求,其中 content-type 为 multipart/form-data 。
451 | */
452 | uploadFile(obj: {
453 | /**
454 | * 开发者服务器 url
455 | */
456 | url: string;
457 | /**
458 | * 要上传文件资源的路径
459 | */
460 | filePath: string;
461 | /**
462 | * 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
463 | */
464 | name: string;
465 | /**
466 | * HTTP 请求 Header , header 中不能设置 Referer
467 | */
468 | header?: any;
469 | /**
470 | * HTTP 请求中其他额外的 form data
471 | */
472 | formData?: any;
473 | /**
474 | * 接口调用成功的回调函数
475 | */
476 | success?: Function;
477 | /**
478 | * 接口调用失败的回调函数
479 | */
480 | fail?: Function;
481 | /**
482 | * 接口调用结束的回调函数(调用成功、失败都会执行)
483 | */
484 | complete?: Function;
485 | }): void;
486 |
487 | /**
488 | * 下载文件资源到本地。客户端直接发起一个 HTTP GET 请求,返回文件的本地临时路径。
489 | */
490 | downloadFile(obj: {
491 | /**
492 | * 下载资源的 url
493 | */
494 | url: string;
495 | /**
496 | * HTTP 请求 Header
497 | */
498 | header?: any;
499 | /**
500 | * 下载成功后以 tempFilePath 的形式传给页面,res = {tempFilePath: '文件的临时路径'}
501 | */
502 | success?: Function;
503 | /**
504 | * 接口调用失败的回调函数
505 | */
506 | fail?: Function;
507 | /**
508 | * 接口调用结束的回调函数(调用成功、失败都会执行)
509 | */
510 | complete?: Function;
511 | }): void;
512 |
513 | /**
514 | * 创建一个 WebSocket 连接;一个微信小程序同时只能有一个 WebSocket 连接,如果当前已存在一个 WebSocket 连接,会自动关闭该连接,并重新创建一个 WebSocket 连接。
515 | */
516 | connectSocket(obj: {
517 | /**
518 | * 开发者服务器接口地址,必须是 wss 协议,且域名必须是后台配置的合法域名
519 | */
520 | url: string;
521 | /**
522 | * 请求的数据
523 | */
524 | data?: any;
525 | /**
526 | * HTTP Header , header 中不能设置 Referer
527 | */
528 | header?: any;
529 | /**
530 | * 默认是GET,有效值: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
531 | */
532 | method?: string;
533 | /**
534 | * 子协议数组
535 | */
536 | protocols?: string[];
537 | /**
538 | * 接口调用成功的回调函数
539 | */
540 | success?: Function;
541 | /**
542 | * 接口调用失败的回调函数
543 | */
544 | fail?: Function;
545 | /**
546 | * 接口调用结束的回调函数(调用成功、失败都会执行)
547 | */
548 | complete?: Function;
549 | }): void;
550 |
551 | /**
552 | * 监听WebSocket连接打开事件。
553 | */
554 | onSocketOpen(callback: Function): void;
555 |
556 | /**
557 | * 监听WebSocket错误。
558 | */
559 | onSocketError(callback: Function): void;
560 |
561 | /**
562 | * 通过 WebSocket 连接发送数据,需要先 wx.connectSocket,并在 wx.onSocketOpen 回调之后才能发送。
563 | */
564 | sendSocketMessage(obj: {
565 | /**
566 | * 需要发送的内容
567 | */
568 | data: undefined;
569 | /**
570 | * 接口调用成功的回调函数
571 | */
572 | success?: Function;
573 | /**
574 | * 接口调用失败的回调函数
575 | */
576 | fail?: Function;
577 | /**
578 | * 接口调用结束的回调函数(调用成功、失败都会执行)
579 | */
580 | complete?: Function;
581 | }): void;
582 |
583 | /**
584 | * 监听WebSocket接受到服务器的消息事件。
585 | */
586 | onSocketMessage(callback: Function): void;
587 |
588 | /**
589 | * 关闭WebSocket连接。
590 | */
591 | closeSocket(obj: {
592 | /**
593 | * 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。如果这个参数没有被指定,默认的取值是1000 (表示正常连接关闭)
594 | */
595 | code?: number;
596 | /**
597 | * 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于123字节的UTF-8 文本(不是字符)
598 | */
599 | reason?: string;
600 | /**
601 | * 接口调用成功的回调函数
602 | */
603 | success?: Function;
604 | /**
605 | * 接口调用失败的回调函数
606 | */
607 | fail?: Function;
608 | /**
609 | * 接口调用结束的回调函数(调用成功、失败都会执行)
610 | */
611 | complete?: Function;
612 | }): void;
613 |
614 | /**
615 | * 监听WebSocket关闭。
616 | */
617 | onSocketClose(callback: Function): void;
618 |
619 | // # 媒体 #
620 |
621 | /**
622 | * 从本地相册选择图片或使用相机拍照。
623 | */
624 | chooseImage(obj: {
625 | /**
626 | * 最多可以选择的图片张数,默认9
627 | */
628 | count?: number;
629 | /**
630 | * original 原图,compressed 压缩图,默认二者都有
631 | */
632 | sizeType?: string[];
633 | /**
634 | * album 从相册选图,camera 使用相机,默认二者都有
635 | */
636 | sourceType?: string[];
637 | /**
638 | * 成功则返回图片的本地文件路径列表 tempFilePaths
639 | */
640 | success: Function;
641 | /**
642 | * 接口调用失败的回调函数
643 | */
644 | fail?: Function;
645 | /**
646 | * 接口调用结束的回调函数(调用成功、失败都会执行)
647 | */
648 | complete?: Function;
649 | }): void;
650 |
651 | /**
652 | * 预览图片。
653 | */
654 | previewImage(obj: {
655 | /**
656 | * 当前显示图片的链接,不填则默认为 urls 的第一张
657 | */
658 | current?: string;
659 | /**
660 | * 需要预览的图片链接列表
661 | */
662 | urls: string[];
663 | /**
664 | * 接口调用成功的回调函数
665 | */
666 | success?: Function;
667 | /**
668 | * 接口调用失败的回调函数
669 | */
670 | fail?: Function;
671 | /**
672 | * 接口调用结束的回调函数(调用成功、失败都会执行)
673 | */
674 | complete?: Function;
675 | }): void;
676 |
677 | /**
678 | * 获取图片信息
679 | */
680 | getImageInfo(obj: {
681 | /**
682 | * 图片的路径,可以是相对路径,临时文件路径,存储文件路径,网络图片路径
683 | */
684 | src: string;
685 | /**
686 | * 接口调用成功的回调函数
687 | */
688 | success?: Function;
689 | /**
690 | * 接口调用失败的回调函数
691 | */
692 | fail?: Function;
693 | /**
694 | * 接口调用结束的回调函数(调用成功、失败都会执行)
695 | */
696 | complete?: Function;
697 | }): void;
698 |
699 | saveImageToPhotosAlbum(obj: {
700 | /**
701 | * 图片文件路径,可以是临时文件路径也可以是永久文件路径,不支持网络图片路径
702 | */
703 | filePath: string;
704 | /**
705 | * 接口调用成功的回调函数
706 | */
707 | success?: Function;
708 | /**
709 | * 接口调用失败的回调函数
710 | */
711 | fail?: Function;
712 | /**
713 | * 接口调用结束的回调函数(调用成功、失败都会执行)
714 | */
715 | complete?: Function;
716 | }): void;
717 |
718 | /**
719 | * 开始录音。当主动调用wx.stopRecord,或者录音超过1分钟时自动结束录音,返回录音文件的临时文件路径。当用户离开小程序时,此接口无法调用。
720 | */
721 | startRecord(obj: {
722 | /**
723 | * 录音成功后调用,返回录音文件的临时文件路径,res = {tempFilePath: '录音文件的临时路径'}
724 | */
725 | success?: Function;
726 | /**
727 | * 接口调用失败的回调函数
728 | */
729 | fail?: Function;
730 | /**
731 | * 接口调用结束的回调函数(调用成功、失败都会执行)
732 | */
733 | complete?: Function;
734 | }): void;
735 |
736 | /**
737 | * 主动调用停止录音。
738 | */
739 | stopRecord(): void;
740 |
741 | /**
742 | * 开始播放语音,同时只允许一个语音文件正在播放,如果前一个语音文件还没播放完,将中断前一个语音播放。
743 | */
744 | playVoice(obj: {
745 | /**
746 | * 需要播放的语音文件的文件路径
747 | */
748 | filePath: string;
749 | /**
750 | * 接口调用成功的回调函数
751 | */
752 | success?: Function;
753 | /**
754 | * 接口调用失败的回调函数
755 | */
756 | fail?: Function;
757 | /**
758 | * 接口调用结束的回调函数(调用成功、失败都会执行)
759 | */
760 | complete?: Function;
761 | }): void;
762 |
763 | /**
764 | * 暂停正在播放的语音。再次调用wx.playVoice播放同一个文件时,会从暂停处开始播放。如果想从头开始播放,需要先调用 wx.stopVoice。
765 | */
766 | pauseVoice(): void;
767 |
768 | /**
769 | * 结束播放语音。
770 | */
771 | stopVoice(): void;
772 |
773 | /**
774 | * 获取后台音乐播放状态。
775 | */
776 | getBackgroundAudioPlayerState(obj: {
777 | /**
778 | * 接口调用成功的回调函数
779 | */
780 | success?: Function;
781 | /**
782 | * 接口调用失败的回调函数
783 | */
784 | fail?: Function;
785 | /**
786 | * 接口调用结束的回调函数(调用成功、失败都会执行)
787 | */
788 | complete?: Function;
789 | }): void;
790 |
791 | /**
792 | * 使用后台播放器播放音乐,对于微信客户端来说,只能同时有一个后台音乐在播放。当用户离开小程序后,音乐将暂停播放;当用户点击“显示在聊天顶部”时,音乐不会暂停播放;当用户在其他小程序占用了音乐播放器,原有小程序内的音乐将停止播放。
793 | */
794 | playBackgroundAudio(obj: {
795 | /**
796 | * 音乐链接,目前支持的格式有 m4a, aac, mp3, wav
797 | */
798 | dataUrl: string;
799 | /**
800 | * 音乐标题
801 | */
802 | title?: string;
803 | /**
804 | * 封面URL
805 | */
806 | coverImgUrl?: string;
807 | /**
808 | * 接口调用成功的回调函数
809 | */
810 | success?: Function;
811 | /**
812 | * 接口调用失败的回调函数
813 | */
814 | fail?: Function;
815 | /**
816 | * 接口调用结束的回调函数(调用成功、失败都会执行)
817 | */
818 | complete?: Function;
819 | }): void;
820 |
821 | /**
822 | * 暂停播放音乐。
823 | */
824 | pauseBackgroundAudio(): void;
825 |
826 | /**
827 | * 控制音乐播放进度。
828 | */
829 | seekBackgroundAudio(obj: {
830 | /**
831 | * 音乐位置,单位:秒
832 | */
833 | position: number;
834 | /**
835 | * 接口调用成功的回调函数
836 | */
837 | success?: Function;
838 | /**
839 | * 接口调用失败的回调函数
840 | */
841 | fail?: Function;
842 | /**
843 | * 接口调用结束的回调函数(调用成功、失败都会执行)
844 | */
845 | complete?: Function;
846 | }): void;
847 |
848 | /**
849 | * 停止播放音乐。
850 | */
851 | stopBackgroundAudio(): void;
852 |
853 | /**
854 | * 监听音乐播放。
855 | */
856 | onBackgroundAudioPlay(callback: Function): void;
857 |
858 | /**
859 | * 监听音乐暂停。
860 | */
861 | onBackgroundAudioPause(callback: Function): void;
862 |
863 | /**
864 | * 监听音乐停止。
865 | */
866 | onBackgroundAudioStop(callback: Function): void;
867 |
868 | getBackgroundAudioManager(): void;
869 |
870 | /**
871 | * 创建并返回 audio 上下文 audioContext 对象
872 | */
873 | createAudioContext(audioId: string): IAudioContext;
874 |
875 | /**
876 | * 拍摄视频或从手机相册中选视频,返回视频的临时文件路径。
877 | */
878 | chooseVideo(obj: {
879 | /**
880 | * album 从相册选视频,camera 使用相机拍摄,默认为:['album', 'camera']
881 | */
882 | sourceType?: string[];
883 | /**
884 | * 拍摄视频最长拍摄时间,单位秒。最长支持 60 秒
885 | */
886 | maxDuration?: number;
887 | /**
888 | * 默认调起的为前置还是后置摄像头。front: 前置,back: 后置,默认 back
889 | */
890 | camera?: string;
891 | /**
892 | * 接口调用成功,返回视频文件的临时文件路径,详见返回参数说明
893 | */
894 | success?: Function;
895 | /**
896 | * 接口调用失败的回调函数
897 | */
898 | fail?: Function;
899 | /**
900 | * 接口调用结束的回调函数(调用成功、失败都会执行)
901 | */
902 | complete?: Function;
903 | }): void;
904 |
905 | saveVideoToPhotosAlbum(obj: {
906 | /**
907 | * 视频文件路径,可以是临时文件路径也可以是永久文件路径
908 | */
909 | filePath: string;
910 | /**
911 | * 接口调用成功的回调函数
912 | */
913 | success?: Function;
914 | /**
915 | * 接口调用失败的回调函数
916 | */
917 | fail?: Function;
918 | /**
919 | * 接口调用结束的回调函数(调用成功、失败都会执行)
920 | */
921 | complete?: Function;
922 | }): void;
923 |
924 | /**
925 | * 创建并返回 video 上下文 videoContext 对象
926 | */
927 | createVideoContext(videoId: string): IVideoContext;
928 |
929 | // # 文件 #
930 |
931 | /**
932 | * 保存文件到本地。
933 | */
934 | saveFile(obj: {
935 | /**
936 | * 需要保存的文件的临时路径
937 | */
938 | tempFilePath: string;
939 | /**
940 | * 返回文件的保存路径,res = {savedFilePath: '文件的保存路径'}
941 | */
942 | success?: Function;
943 | /**
944 | * 接口调用失败的回调函数
945 | */
946 | fail?: Function;
947 | /**
948 | * 接口调用结束的回调函数(调用成功、失败都会执行)
949 | */
950 | complete?: Function;
951 | }): void;
952 |
953 | /**
954 | * 获取本地已保存的文件列表
955 | */
956 | getSavedFileList(obj: {
957 | /**
958 | * 接口调用成功的回调函数,返回结果见success返回参数说明
959 | */
960 | success?: Function;
961 | /**
962 | * 接口调用失败的回调函数
963 | */
964 | fail?: Function;
965 | /**
966 | * 接口调用结束的回调函数(调用成功、失败都会执行)
967 | */
968 | complete?: Function;
969 | }): void;
970 |
971 | /**
972 | * 获取本地文件的文件信息。此接口只能用于获取已保存到本地的文件,若需要获取临时文件信息,请使用 wx.getFileInfo 接口。
973 | */
974 | getSavedFileInfo(obj: {
975 | /**
976 | * 文件路径
977 | */
978 | filePath: string;
979 | /**
980 | * 接口调用成功的回调函数,返回结果见success返回参数说明
981 | */
982 | success?: Function;
983 | /**
984 | * 接口调用失败的回调函数
985 | */
986 | fail?: Function;
987 | /**
988 | * 接口调用结束的回调函数(调用成功、失败都会执行)
989 | */
990 | complete?: Function;
991 | }): void;
992 |
993 | /**
994 | * 删除本地存储的文件
995 | */
996 | removeSavedFile(obj: {
997 | /**
998 | * 需要删除的文件路径
999 | */
1000 | filePath: string;
1001 | /**
1002 | * 接口调用成功的回调函数
1003 | */
1004 | success?: Function;
1005 | /**
1006 | * 接口调用失败的回调函数
1007 | */
1008 | fail?: Function;
1009 | /**
1010 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1011 | */
1012 | complete?: Function;
1013 | }): void;
1014 |
1015 | /**
1016 | * 新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx
1017 | */
1018 | openDocument(obj: {
1019 | /**
1020 | * 文件路径,可通过 downFile 获得
1021 | */
1022 | filePath: string;
1023 | /**
1024 | * 文件类型,指定文件类型打开文件,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx
1025 | */
1026 | fileType?: string;
1027 | /**
1028 | * 接口调用成功的回调函数
1029 | */
1030 | success?: Function;
1031 | /**
1032 | * 接口调用失败的回调函数
1033 | */
1034 | fail?: Function;
1035 | /**
1036 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1037 | */
1038 | complete?: Function;
1039 | }): void;
1040 |
1041 | getFileInfo(obj: {
1042 | /**
1043 | * 本地文件路径
1044 | */
1045 | filePath: string;
1046 | /**
1047 | * 计算文件摘要的算法,默认值 md5,有效值:md5,sha1
1048 | */
1049 | digestAlgorithm?: string;
1050 | /**
1051 | * 接口调用成功的回调函数
1052 | */
1053 | success?: Function;
1054 | /**
1055 | * 接口调用失败的回调函数
1056 | */
1057 | fail?: Function;
1058 | /**
1059 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1060 | */
1061 | complete?: Function;
1062 | }): void;
1063 |
1064 | // # 数据缓存 #
1065 |
1066 | /**
1067 | * 将数据存储在本地缓存中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个异步接口。
1068 | */
1069 | setStorage(obj: {
1070 | /**
1071 | * 本地缓存中的指定的 key
1072 | */
1073 | key: string;
1074 | /**
1075 | * 需要存储的内容
1076 | */
1077 | data: any;
1078 | /**
1079 | * 接口调用成功的回调函数
1080 | */
1081 | success?: Function;
1082 | /**
1083 | * 接口调用失败的回调函数
1084 | */
1085 | fail?: Function;
1086 | /**
1087 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1088 | */
1089 | complete?: Function;
1090 | }): void;
1091 |
1092 | /**
1093 | * 将 data 存储在本地缓存中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个同步接口。
1094 | */
1095 | setStorageSync(key: string, data: any, ): void;
1096 |
1097 | /**
1098 | * 从本地缓存中异步获取指定 key 对应的内容。
1099 | */
1100 | getStorage(obj: {
1101 | /**
1102 | * 本地缓存中的指定的 key
1103 | */
1104 | key: string;
1105 | /**
1106 | * 接口调用的回调函数,res = {data: key对应的内容}
1107 | */
1108 | success: Function;
1109 | /**
1110 | * 接口调用失败的回调函数
1111 | */
1112 | fail?: Function;
1113 | /**
1114 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1115 | */
1116 | complete?: Function;
1117 | }): void;
1118 |
1119 | /**
1120 | * 从本地缓存中同步获取指定 key 对应的内容。
1121 | */
1122 | getStorageSync(key: string): void;
1123 |
1124 | /**
1125 | * 异步获取当前storage的相关信息
1126 | */
1127 | getStorageInfo(obj: {
1128 | /**
1129 | * 接口调用的回调函数,详见返回参数说明
1130 | */
1131 | success: Function;
1132 | /**
1133 | * 接口调用失败的回调函数
1134 | */
1135 | fail?: Function;
1136 | /**
1137 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1138 | */
1139 | complete?: Function;
1140 | }): void;
1141 |
1142 | /**
1143 | * 同步获取当前storage的相关信息
1144 | */
1145 | getStorageInfoSync(): void;
1146 |
1147 | /**
1148 | * 从本地缓存中异步移除指定 key 。
1149 | */
1150 | removeStorage(obj: {
1151 | /**
1152 | * 本地缓存中的指定的 key
1153 | */
1154 | key: string;
1155 | /**
1156 | * 接口调用的回调函数
1157 | */
1158 | success: Function;
1159 | /**
1160 | * 接口调用失败的回调函数
1161 | */
1162 | fail?: Function;
1163 | /**
1164 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1165 | */
1166 | complete?: Function;
1167 | }): void;
1168 |
1169 | /**
1170 | * 从本地缓存中同步移除指定 key 。
1171 | */
1172 | removeStorageSync(key: string): void;
1173 |
1174 | /**
1175 | * 清理本地数据缓存。
1176 | */
1177 | clearStorage(): void;
1178 |
1179 | /**
1180 | * 同步清理本地数据缓存
1181 | */
1182 | clearStorageSync(): void;
1183 |
1184 | // # 位置 #
1185 |
1186 | /**
1187 | * 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用;当用户点击“显示在聊天顶部”时,此接口可继续调用。
1188 | */
1189 | getLocation(obj: {
1190 | /**
1191 | * 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于wx.openLocation的坐标
1192 | */
1193 | type?: string;
1194 | /**
1195 | * 接口调用成功的回调函数,返回内容详见返回参数说明。
1196 | */
1197 | success: Function;
1198 | /**
1199 | * 接口调用失败的回调函数
1200 | */
1201 | fail?: Function;
1202 | /**
1203 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1204 | */
1205 | complete?: Function;
1206 | }): void;
1207 |
1208 | /**
1209 | * 打开地图选择位置
1210 | */
1211 | chooseLocation(obj: {
1212 | /**
1213 | * 接口调用成功的回调函数,返回内容详见返回参数说明。
1214 | */
1215 | success: Function;
1216 | /**
1217 | * 用户取消时调用
1218 | */
1219 | cancel?: Function;
1220 | /**
1221 | * 接口调用失败的回调函数
1222 | */
1223 | fail?: Function;
1224 | /**
1225 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1226 | */
1227 | complete?: Function;
1228 | }): void;
1229 |
1230 | /**
1231 | * 使用微信内置地图查看位置
1232 | */
1233 | openLocation(obj: {
1234 | /**
1235 | * 纬度,范围为-90~90,负数表示南纬
1236 | */
1237 | latitude: number;
1238 | /**
1239 | * 经度,范围为-180~180,负数表示西经
1240 | */
1241 | longitude: number;
1242 | /**
1243 | * 缩放比例,范围5~18,默认为18
1244 | */
1245 | scale?: number;
1246 | /**
1247 | * 位置名
1248 | */
1249 | name?: string;
1250 | /**
1251 | * 地址的详细说明
1252 | */
1253 | address?: string;
1254 | /**
1255 | * 接口调用成功的回调函数
1256 | */
1257 | success?: Function;
1258 | /**
1259 | * 接口调用失败的回调函数
1260 | */
1261 | fail?: Function;
1262 | /**
1263 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1264 | */
1265 | complete?: Function;
1266 | }): void;
1267 |
1268 | /**
1269 | * 创建并返回 map 上下文 mapContext 对象
1270 | */
1271 | createMapContext(mapId: string): IMapContext;
1272 |
1273 | // # 设备 #
1274 |
1275 | /**
1276 | * 获取系统信息。
1277 | */
1278 | getSystemInfo(obj: {
1279 | /**
1280 | * 接口调用成功的回调
1281 | */
1282 | success: Function;
1283 | /**
1284 | * 接口调用失败的回调函数
1285 | */
1286 | fail?: Function;
1287 | /**
1288 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1289 | */
1290 | complete?: Function;
1291 | }): void;
1292 |
1293 | /**
1294 | * 获取系统信息同步接口
1295 | */
1296 | getSystemInfoSync(): void;
1297 |
1298 | /**
1299 | * 获取网络类型。
1300 | */
1301 | getNetworkType(obj: {
1302 | /**
1303 | * 接口调用成功,返回网络类型 networkType
1304 | */
1305 | success: Function;
1306 | /**
1307 | * 接口调用失败的回调函数
1308 | */
1309 | fail?: Function;
1310 | /**
1311 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1312 | */
1313 | complete?: Function;
1314 | }): void;
1315 |
1316 | onNetworkStatusChange(callback: Function): void;
1317 |
1318 | setScreenBrightness(obj: {
1319 | /**
1320 | * 屏幕亮度值,范围 0~1,0 最暗,1 最亮
1321 | */
1322 | value: number;
1323 | /**
1324 | * 接口调用成功
1325 | */
1326 | success?: Function;
1327 | /**
1328 | * 接口调用失败的回调函数
1329 | */
1330 | fail?: Function;
1331 | /**
1332 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1333 | */
1334 | complete?: Function;
1335 | }): void;
1336 |
1337 | getScreenBrightness(obj: {
1338 | /**
1339 | * 接口调用成功
1340 | */
1341 | success?: Function;
1342 | /**
1343 | * 接口调用失败的回调函数
1344 | */
1345 | fail?: Function;
1346 | /**
1347 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1348 | */
1349 | complete?: Function;
1350 | }): void;
1351 |
1352 | vibrateLong(obj: {
1353 | /**
1354 | * 接口调用成功的回调函数
1355 | */
1356 | success?: Function;
1357 | /**
1358 | * 接口调用失败的回调函数
1359 | */
1360 | fail?: Function;
1361 | /**
1362 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1363 | */
1364 | complete?: Function;
1365 | }): void;
1366 |
1367 | vibrateShort(obj: {
1368 | /**
1369 | * 接口调用成功的回调函数
1370 | */
1371 | success?: Function;
1372 | /**
1373 | * 接口调用失败的回调函数
1374 | */
1375 | fail?: Function;
1376 | /**
1377 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1378 | */
1379 | complete?: Function;
1380 | }): void;
1381 |
1382 | /**
1383 | * 监听加速度数据,频率:5次/秒,接口调用后会自动开始监听,可使用 wx.stopAccelerometer 停止监听。
1384 | */
1385 | onAccelerometerChange(callback: Function): void;
1386 |
1387 | startAccelerometer(obj: {
1388 | /**
1389 | * 接口调用成功的回调函数
1390 | */
1391 | success?: Function;
1392 | /**
1393 | * 接口调用失败的回调函数
1394 | */
1395 | fail?: Function;
1396 | /**
1397 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1398 | */
1399 | complete?: Function;
1400 | }): void;
1401 |
1402 | stopAccelerometer(obj: {
1403 | /**
1404 | * 接口调用成功的回调函数
1405 | */
1406 | success?: Function;
1407 | /**
1408 | * 接口调用失败的回调函数
1409 | */
1410 | fail?: Function;
1411 | /**
1412 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1413 | */
1414 | complete?: Function;
1415 | }): void;
1416 |
1417 | /**
1418 | * 监听罗盘数据,频率:5次/秒,接口调用后会自动开始监听,可使用wx.stopCompass停止监听。
1419 | */
1420 | onCompassChange(callback: Function): void;
1421 |
1422 | startCompass(obj: {
1423 | /**
1424 | * 接口调用成功的回调函数
1425 | */
1426 | success?: Function;
1427 | /**
1428 | * 接口调用失败的回调函数
1429 | */
1430 | fail?: Function;
1431 | /**
1432 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1433 | */
1434 | complete?: Function;
1435 | }): void;
1436 |
1437 | stopCompass(obj: {
1438 | /**
1439 | * 接口调用成功的回调函数
1440 | */
1441 | success?: Function;
1442 | /**
1443 | * 接口调用失败的回调函数
1444 | */
1445 | fail?: Function;
1446 | /**
1447 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1448 | */
1449 | complete?: Function;
1450 | }): void;
1451 |
1452 | makePhoneCall(obj: {
1453 | /**
1454 | * 需要拨打的电话号码
1455 | */
1456 | phoneNumber: string;
1457 | /**
1458 | * 接口调用成功的回调
1459 | */
1460 | success?: Function;
1461 | /**
1462 | * 接口调用失败的回调函数
1463 | */
1464 | fail?: Function;
1465 | /**
1466 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1467 | */
1468 | complete?: Function;
1469 | }): void;
1470 |
1471 | /**
1472 | * 调起客户端扫码界面,扫码成功后返回对应的结果
1473 | */
1474 | scanCode(obj: {
1475 | /**
1476 | * 是否只能从相机扫码,不允许从相册选择图片
1477 | */
1478 | onlyFromCamera?: boolean;
1479 | /**
1480 | * 接口调用成功的回调函数,返回内容详见返回参数说明。
1481 | */
1482 | success?: Function;
1483 | /**
1484 | * 接口调用失败的回调函数
1485 | */
1486 | fail?: Function;
1487 | /**
1488 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1489 | */
1490 | complete?: Function;
1491 | }): void;
1492 |
1493 | setClipboardData(obj: {
1494 | /**
1495 | * 需要设置的内容
1496 | */
1497 | data: string;
1498 | /**
1499 | * 接口调用成功的回调函数
1500 | */
1501 | success?: Function;
1502 | /**
1503 | * 接口调用失败的回调函数
1504 | */
1505 | fail?: Function;
1506 | /**
1507 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1508 | */
1509 | complete?: Function;
1510 | }): void;
1511 |
1512 | getClipboardData(obj: {
1513 | /**
1514 | * 接口调用成功的回调函数
1515 | */
1516 | success?: Function;
1517 | /**
1518 | * 接口调用失败的回调函数
1519 | */
1520 | fail?: Function;
1521 | /**
1522 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1523 | */
1524 | complete?: Function;
1525 | }): void;
1526 |
1527 | openBluetoothAdapter(obj: {
1528 | /**
1529 | * 成功则返回成功初始化信息
1530 | */
1531 | success: Function;
1532 | /**
1533 | * 接口调用失败的回调函数
1534 | */
1535 | fail?: Function;
1536 | /**
1537 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1538 | */
1539 | complete?: Function;
1540 | }): void;
1541 |
1542 | closeBluetoothAdapter(obj: {
1543 | /**
1544 | * 成功则返回成功关闭模块信息
1545 | */
1546 | success: Function;
1547 | /**
1548 | * 接口调用失败的回调函数
1549 | */
1550 | fail?: Function;
1551 | /**
1552 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1553 | */
1554 | complete?: Function;
1555 | }): void;
1556 |
1557 | getBluetoothAdapterState(obj: {
1558 | /**
1559 | * 成功则返回本机蓝牙适配器状态
1560 | */
1561 | success: Function;
1562 | /**
1563 | * 接口调用失败的回调函数
1564 | */
1565 | fail?: Function;
1566 | /**
1567 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1568 | */
1569 | complete?: Function;
1570 | }): void;
1571 |
1572 | onBluetoothAdapterStateChange(callback: Function): void;
1573 |
1574 | startBluetoothDevicesDiscovery(obj: {
1575 | /**
1576 | * 蓝牙设备主 service 的 uuid 列表
1577 | */
1578 | services?: Array;
1579 | /**
1580 | * 是否允许重复上报同一设备, 如果允许重复上报,则onDeviceFound 方法会多次上报同一设备,但是 RSSI 值会有不同
1581 | */
1582 | allowDuplicatesKey?: boolean;
1583 | /**
1584 | * 上报设备的间隔,默认为0,意思是找到新设备立即上报,否则根据传入的间隔上报
1585 | */
1586 | interval?: number;
1587 | /**
1588 | * 成功则返回本机蓝牙适配器状态
1589 | */
1590 | success: Function;
1591 | /**
1592 | * 接口调用失败的回调函数
1593 | */
1594 | fail?: Function;
1595 | /**
1596 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1597 | */
1598 | complete?: Function;
1599 | }): void;
1600 |
1601 | stopBluetoothDevicesDiscovery(obj: {
1602 | /**
1603 | * 成功则返回本机蓝牙适配器状态
1604 | */
1605 | success: Function;
1606 | /**
1607 | * 接口调用失败的回调函数
1608 | */
1609 | fail?: Function;
1610 | /**
1611 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1612 | */
1613 | complete?: Function;
1614 | }): void;
1615 |
1616 | getBluetoothDevices(obj: {
1617 | /**
1618 | * 成功则返回本机蓝牙适配器状态
1619 | */
1620 | success: Function;
1621 | /**
1622 | * 接口调用失败的回调函数
1623 | */
1624 | fail?: Function;
1625 | /**
1626 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1627 | */
1628 | complete?: Function;
1629 | }): void;
1630 |
1631 | onBluetoothDeviceFound(callback: Function): void;
1632 |
1633 | getConnectedBluetoothDevices(obj: {
1634 | /**
1635 | * 蓝牙设备主 service 的 uuid 列表
1636 | */
1637 | services: Array;
1638 | /**
1639 | * 成功则返回本机蓝牙适配器状态
1640 | */
1641 | success: Function;
1642 | /**
1643 | * 接口调用失败的回调函数
1644 | */
1645 | fail?: Function;
1646 | /**
1647 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1648 | */
1649 | complete?: Function;
1650 | }): void;
1651 |
1652 | createBLEConnection(obj: {
1653 | /**
1654 | * 蓝牙设备 id,参考 getDevices 接口
1655 | */
1656 | deviceId: string;
1657 | /**
1658 | * 成功则返回本机蓝牙适配器状态
1659 | */
1660 | success: Function;
1661 | /**
1662 | * 接口调用失败的回调函数
1663 | */
1664 | fail?: Function;
1665 | /**
1666 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1667 | */
1668 | complete?: Function;
1669 | }): void;
1670 |
1671 | closeBLEConnection(obj: {
1672 | /**
1673 | * 蓝牙设备 id,参考 getDevices 接口
1674 | */
1675 | deviceId: string;
1676 | /**
1677 | * 成功则返回本机蓝牙适配器状态
1678 | */
1679 | success: Function;
1680 | /**
1681 | * 接口调用失败的回调函数
1682 | */
1683 | fail?: Function;
1684 | /**
1685 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1686 | */
1687 | complete?: Function;
1688 | }): void;
1689 |
1690 | getBLEDeviceServices(obj: {
1691 | /**
1692 | * 蓝牙设备 id,参考 getDevices 接口
1693 | */
1694 | deviceId: string;
1695 | /**
1696 | * 成功则返回本机蓝牙适配器状态
1697 | */
1698 | success: Function;
1699 | /**
1700 | * 接口调用失败的回调函数
1701 | */
1702 | fail?: Function;
1703 | /**
1704 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1705 | */
1706 | complete?: Function;
1707 | }): void;
1708 |
1709 | getBLEDeviceCharacteristics(obj: {
1710 | /**
1711 | * 蓝牙设备 id,参考 device 对象
1712 | */
1713 | deviceId: string;
1714 | /**
1715 | * 蓝牙服务 uuid
1716 | */
1717 | serviceId: string;
1718 | /**
1719 | * 成功则返回本机蓝牙适配器状态
1720 | */
1721 | success: Function;
1722 | /**
1723 | * 接口调用失败的回调函数
1724 | */
1725 | fail?: Function;
1726 | /**
1727 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1728 | */
1729 | complete?: Function;
1730 | }): void;
1731 |
1732 | readBLECharacteristicValue(obj: {
1733 | /**
1734 | * 蓝牙设备 id,参考 device 对象
1735 | */
1736 | deviceId: string;
1737 | /**
1738 | * 蓝牙特征值对应服务的 uuid
1739 | */
1740 | serviceId: string;
1741 | /**
1742 | * 蓝牙特征值的 uuid
1743 | */
1744 | characteristicId: string;
1745 | /**
1746 | * 成功则返回本机蓝牙适配器状态
1747 | */
1748 | success: Function;
1749 | /**
1750 | * 接口调用失败的回调函数
1751 | */
1752 | fail?: Function;
1753 | /**
1754 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1755 | */
1756 | complete?: Function;
1757 | }): void;
1758 |
1759 | writeBLECharacteristicValue(obj: {
1760 | /**
1761 | * 蓝牙设备 id,参考 device 对象
1762 | */
1763 | deviceId: string;
1764 | /**
1765 | * 蓝牙特征值对应服务的 uuid
1766 | */
1767 | serviceId: string;
1768 | /**
1769 | * 蓝牙特征值的 uuid
1770 | */
1771 | characteristicId: string;
1772 | /**
1773 | * 蓝牙设备特征值对应的二进制值(注意:vConsole 无法打印出 ArrayBuffer 类型数据)
1774 | */
1775 | value: undefined;
1776 | /**
1777 | * 成功则返回本机蓝牙适配器状态
1778 | */
1779 | success: Function;
1780 | /**
1781 | * 接口调用失败的回调函数
1782 | */
1783 | fail?: Function;
1784 | /**
1785 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1786 | */
1787 | complete?: Function;
1788 | }): void;
1789 |
1790 | notifyBLECharacteristicValueChange(obj: {
1791 | /**
1792 | * 蓝牙设备 id,参考 device 对象
1793 | */
1794 | deviceId: string;
1795 | /**
1796 | * 蓝牙特征值对应服务的 uuid
1797 | */
1798 | serviceId: string;
1799 | /**
1800 | * 蓝牙特征值的 uuid
1801 | */
1802 | characteristicId: string;
1803 | /**
1804 | * true: 启用 notify; false: 停用 notify
1805 | */
1806 | state: boolean;
1807 | /**
1808 | * 成功则返回本机蓝牙适配器状态
1809 | */
1810 | success: Function;
1811 | /**
1812 | * 接口调用失败的回调函数
1813 | */
1814 | fail?: Function;
1815 | /**
1816 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1817 | */
1818 | complete?: Function;
1819 | }): void;
1820 |
1821 | onBLEConnectionStateChange(callback: Function): void;
1822 |
1823 | onBLECharacteristicValueChange(callback: Function): void;
1824 |
1825 | startBeaconDiscovery(obj: {
1826 | /**
1827 | * iBeacon设备广播的 uuids
1828 | */
1829 | uuids: string[];
1830 | /**
1831 | * 接口调用成功的回调函数
1832 | */
1833 | success?: Function;
1834 | /**
1835 | * 接口调用失败的回调函数
1836 | */
1837 | fail?: Function;
1838 | /**
1839 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1840 | */
1841 | complete?: Function;
1842 | }): void;
1843 |
1844 | stopBeaconDiscovery(obj: {
1845 | /**
1846 | * 接口调用成功的回调函数
1847 | */
1848 | success?: Function;
1849 | /**
1850 | * 接口调用失败的回调函数
1851 | */
1852 | fail?: Function;
1853 | /**
1854 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1855 | */
1856 | complete?: Function;
1857 | }): void;
1858 |
1859 | getBeacons(obj: {
1860 | /**
1861 | * 接口调用成功的回调函数
1862 | */
1863 | success?: Function;
1864 | /**
1865 | * 接口调用失败的回调函数
1866 | */
1867 | fail?: Function;
1868 | /**
1869 | * 接口调用结束的回调函数(调用成功、失败都会执行)
1870 | */
1871 | complete?: Function;
1872 | }): void;
1873 |
1874 | onBeaconUpdate(callback: Function): void;
1875 |
1876 | onBeaconServiceChange(callback: Function): void;
1877 |
1878 | onUserCaptureScreen(callback: Function): void;
1879 |
1880 | addPhoneContact(obj: {
1881 | /**
1882 | * 头像本地文件路径
1883 | */
1884 | photoFilePath?: string;
1885 | /**
1886 | * 昵称
1887 | */
1888 | nickName?: string;
1889 | /**
1890 | * 姓氏
1891 | */
1892 | lastName?: string;
1893 | /**
1894 | * 中间名
1895 | */
1896 | middleName?: string;
1897 | /**
1898 | * 名字
1899 | */
1900 | firstName: string;
1901 | /**
1902 | * 备注
1903 | */
1904 | remark?: string;
1905 | /**
1906 | * 手机号
1907 | */
1908 | mobilePhoneNumber?: string;
1909 | /**
1910 | * 微信号
1911 | */
1912 | weChatNumber?: string;
1913 | /**
1914 | * 联系地址国家
1915 | */
1916 | addressCountry?: string;
1917 | /**
1918 | * 联系地址省份
1919 | */
1920 | addressState?: string;
1921 | /**
1922 | * 联系地址城市
1923 | */
1924 | addressCity?: string;
1925 | /**
1926 | * 联系地址街道
1927 | */
1928 | addressStreet?: string;
1929 | /**
1930 | * 联系地址邮政编码
1931 | */
1932 | addressPostalCode?: string;
1933 | /**
1934 | * 公司
1935 | */
1936 | organization?: string;
1937 | /**
1938 | * 职位
1939 | */
1940 | title?: string;
1941 | /**
1942 | * 工作传真
1943 | */
1944 | workFaxNumber?: string;
1945 | /**
1946 | * 工作电话
1947 | */
1948 | workPhoneNumber?: string;
1949 | /**
1950 | * 公司电话
1951 | */
1952 | hostNumber?: string;
1953 | /**
1954 | * 电子邮件
1955 | */
1956 | email?: string;
1957 | /**
1958 | * 网站
1959 | */
1960 | url?: string;
1961 | /**
1962 | * 工作地址国家
1963 | */
1964 | workAddressCountry?: string;
1965 | /**
1966 | * 工作地址省份
1967 | */
1968 | workAddressState?: string;
1969 | /**
1970 | * 工作地址城市
1971 | */
1972 | workAddressCity?: string;
1973 | /**
1974 | * 工作地址街道
1975 | */
1976 | workAddressStreet?: string;
1977 | /**
1978 | * 工作地址邮政编码
1979 | */
1980 | workAddressPostalCode?: string;
1981 | /**
1982 | * 住宅传真
1983 | */
1984 | homeFaxNumber?: string;
1985 | /**
1986 | * 住宅电话
1987 | */
1988 | homePhoneNumber?: string;
1989 | /**
1990 | * 住宅地址国家
1991 | */
1992 | homeAddressCountry?: string;
1993 | /**
1994 | * 住宅地址省份
1995 | */
1996 | homeAddressState?: string;
1997 | /**
1998 | * 住宅地址城市
1999 | */
2000 | homeAddressCity?: string;
2001 | /**
2002 | * 住宅地址街道
2003 | */
2004 | homeAddressStreet?: string;
2005 | /**
2006 | * 住宅地址邮政编码
2007 | */
2008 | homeAddressPostalCode?: string;
2009 | /**
2010 | * 接口调用成功
2011 | */
2012 | success?: Function;
2013 | /**
2014 | * 接口调用失败的回调函数
2015 | */
2016 | fail?: Function;
2017 | /**
2018 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2019 | */
2020 | complete?: Function;
2021 | }): void;
2022 |
2023 | // # 界面 #
2024 |
2025 | /**
2026 | * 显示消息提示框
2027 | */
2028 | showToast(obj: {
2029 | /**
2030 | * 提示的内容
2031 | */
2032 | title: string;
2033 | /**
2034 | * 图标,有效值 "success", "loading"
2035 | */
2036 | icon?: string;
2037 | /**
2038 | * 自定义图标的本地路径,image 的优先级高于 icon
2039 | */
2040 | image?: string;
2041 | /**
2042 | * 提示的延迟时间,单位毫秒,默认:1500
2043 | */
2044 | duration?: number;
2045 | /**
2046 | * 是否显示透明蒙层,防止触摸穿透,默认:false
2047 | */
2048 | mask?: boolean;
2049 | /**
2050 | * 接口调用成功的回调函数
2051 | */
2052 | success?: Function;
2053 | /**
2054 | * 接口调用失败的回调函数
2055 | */
2056 | fail?: Function;
2057 | /**
2058 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2059 | */
2060 | complete?: Function;
2061 | }): void;
2062 |
2063 | showLoading(obj: {
2064 | /**
2065 | * 提示的内容
2066 | */
2067 | title: string;
2068 | /**
2069 | * 是否显示透明蒙层,防止触摸穿透,默认:false
2070 | */
2071 | mask?: boolean;
2072 | /**
2073 | * 接口调用成功的回调函数
2074 | */
2075 | success?: Function;
2076 | /**
2077 | * 接口调用失败的回调函数
2078 | */
2079 | fail?: Function;
2080 | /**
2081 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2082 | */
2083 | complete?: Function;
2084 | }): void;
2085 |
2086 | /**
2087 | * 隐藏消息提示框
2088 | */
2089 | hideToast(): void;
2090 |
2091 | hideLoading(): void;
2092 |
2093 | /**
2094 | * 显示模态弹窗
2095 | */
2096 | showModal(obj: {
2097 | /**
2098 | * 提示的标题
2099 | */
2100 | title: string;
2101 | /**
2102 | * 提示的内容
2103 | */
2104 | content: string;
2105 | /**
2106 | * 是否显示取消按钮,默认为 true
2107 | */
2108 | showCancel?: boolean;
2109 | /**
2110 | * 取消按钮的文字,默认为"取消",最多 4 个字符
2111 | */
2112 | cancelText?: string;
2113 | /**
2114 | * 取消按钮的文字颜色,默认为"#000000"
2115 | */
2116 | cancelColor?: undefined;
2117 | /**
2118 | * 确定按钮的文字,默认为"确定",最多 4 个字符
2119 | */
2120 | confirmText?: string;
2121 | /**
2122 | * 确定按钮的文字颜色,默认为"#3CC51F"
2123 | */
2124 | confirmColor?: undefined;
2125 | /**
2126 | * 接口调用成功的回调函数
2127 | */
2128 | success?: Function;
2129 | /**
2130 | * 接口调用失败的回调函数
2131 | */
2132 | fail?: Function;
2133 | /**
2134 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2135 | */
2136 | complete?: Function;
2137 | }): void;
2138 |
2139 | /**
2140 | * 显示操作菜单
2141 | */
2142 | showActionSheet(obj: {
2143 | /**
2144 | * 按钮的文字数组,数组长度最大为6个
2145 | */
2146 | itemList: undefined;
2147 | /**
2148 | * 按钮的文字颜色,默认为"#000000"
2149 | */
2150 | itemColor?: undefined;
2151 | /**
2152 | * 接口调用成功的回调函数,详见返回参数说明
2153 | */
2154 | success?: Function;
2155 | /**
2156 | * 接口调用失败的回调函数
2157 | */
2158 | fail?: Function;
2159 | /**
2160 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2161 | */
2162 | complete?: Function;
2163 | }): void;
2164 |
2165 | setTopBarText(obj: {
2166 | /**
2167 | * 置顶栏文字内容
2168 | */
2169 | text: string;
2170 | /**
2171 | * 接口调用成功的回调函数
2172 | */
2173 | success?: Function;
2174 | /**
2175 | * 接口调用失败的回调函数
2176 | */
2177 | fail?: Function;
2178 | /**
2179 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2180 | */
2181 | complete?: Function;
2182 | }): void;
2183 |
2184 | /**
2185 | * 动态设置当前页面的标题。
2186 | */
2187 | setNavigationBarTitle(obj: {
2188 | /**
2189 | * 页面标题
2190 | */
2191 | title: string;
2192 | /**
2193 | * 接口调用成功的回调函数
2194 | */
2195 | success?: Function;
2196 | /**
2197 | * 接口调用失败的回调函数
2198 | */
2199 | fail?: Function;
2200 | /**
2201 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2202 | */
2203 | complete?: Function;
2204 | }): void;
2205 |
2206 | /**
2207 | * 在当前页面显示导航条加载动画。
2208 | */
2209 | showNavigationBarLoading(): void;
2210 |
2211 | /**
2212 | * 隐藏导航条加载动画。
2213 | */
2214 | hideNavigationBarLoading(): void;
2215 |
2216 | /**
2217 | * 保留当前页面,跳转到应用内的某个页面,使用wx.navigateBack可以返回到原页面。
2218 | */
2219 | navigateTo(obj: {
2220 | /**
2221 | * 需要跳转的应用内非 tabBar 的页面的路径 , 路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2'
2222 | */
2223 | url: string;
2224 | /**
2225 | * 接口调用成功的回调函数
2226 | */
2227 | success?: Function;
2228 | /**
2229 | * 接口调用失败的回调函数
2230 | */
2231 | fail?: Function;
2232 | /**
2233 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2234 | */
2235 | complete?: Function;
2236 | }): void;
2237 |
2238 | /**
2239 | * 关闭当前页面,跳转到应用内的某个页面。
2240 | */
2241 | redirectTo(obj: {
2242 | /**
2243 | * 需要跳转的应用内非 tabBar 的页面的路径,路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2'
2244 | */
2245 | url: string;
2246 | /**
2247 | * 接口调用成功的回调函数
2248 | */
2249 | success?: Function;
2250 | /**
2251 | * 接口调用失败的回调函数
2252 | */
2253 | fail?: Function;
2254 | /**
2255 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2256 | */
2257 | complete?: Function;
2258 | }): void;
2259 |
2260 | reLaunch(obj: {
2261 | /**
2262 | * 需要跳转的应用内页面路径 , 路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2',如果跳转的页面路径是 tabBar 页面则不能带参数
2263 | */
2264 | url: string;
2265 | /**
2266 | * 接口调用成功的回调函数
2267 | */
2268 | success?: Function;
2269 | /**
2270 | * 接口调用失败的回调函数
2271 | */
2272 | fail?: Function;
2273 | /**
2274 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2275 | */
2276 | complete?: Function;
2277 | }): void;
2278 |
2279 | /**
2280 | * 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
2281 | */
2282 | switchTab(obj: {
2283 | /**
2284 | * 需要跳转的 tabBar 页面的路径(需在 app.json 的 tabBar 字段定义的页面),路径后不能带参数
2285 | */
2286 | url: string;
2287 | /**
2288 | * 接口调用成功的回调函数
2289 | */
2290 | success?: Function;
2291 | /**
2292 | * 接口调用失败的回调函数
2293 | */
2294 | fail?: Function;
2295 | /**
2296 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2297 | */
2298 | complete?: Function;
2299 | }): void;
2300 |
2301 | /**
2302 | * 关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages()) 获取当前的页面栈,决定需要返回几层。
2303 | */
2304 | navigateBack(obj: {
2305 | /**
2306 | * 返回的页面数,如果 delta 大于现有页面数,则返回到首页。
2307 | */
2308 | delta?: number;
2309 | }): void;
2310 |
2311 | /**
2312 | * 创建一个动画实例animation。调用实例的方法来描述动画。最后通过动画实例的export方法导出动画数据传递给组件的animation属性。
2313 | */
2314 | createAnimation(obj: {
2315 | /**
2316 | * 400
2317 | */
2318 | duration?: number;
2319 | /**
2320 | * "linear"
2321 | */
2322 | timingFunction?: string;
2323 | /**
2324 | * 0
2325 | */
2326 | delay?: number;
2327 | /**
2328 | * "50% 50% 0"
2329 | */
2330 | transformOrigin?: string;
2331 | }): IAnimation;
2332 |
2333 | pageScrollTo(obj: {
2334 | /**
2335 | * 滚动到页面的目标位置(单位px)
2336 | */
2337 | scrollTop: number;
2338 | }): void;
2339 |
2340 | /**
2341 | * 创建 canvas 绘图上下文(指定 canvasId).Tip: 需要指定 canvasId,该绘图上下文只作用于对应的
2342 | */
2343 | createCanvasContext(canvasId: string): ICanvasContext;
2344 |
2345 | /**
2346 | * 把当前画布的内容导出生成图片,并返回文件路径
2347 | */
2348 | canvasToTempFilePath(canvasId: string): void;
2349 |
2350 | startPullDownRefresh(obj: {
2351 | /**
2352 | * 接口调用成功的回调函数
2353 | */
2354 | success?: Function;
2355 | /**
2356 | * 接口调用失败的回调函数
2357 | */
2358 | fail?: Function;
2359 | /**
2360 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2361 | */
2362 | complete?: Function;
2363 | }): void;
2364 |
2365 | /**
2366 | * 停止当前页面下拉刷新。
2367 | */
2368 | stopPullDownRefresh(): void;
2369 |
2370 | // # WXML节点信息 #
2371 |
2372 | // # 第三方平台 #
2373 |
2374 | getExtConfig(obj: {
2375 | /**
2376 | * 返回第三方平台自定义的数据
2377 | */
2378 | success?: Function;
2379 | /**
2380 | * 接口调用失败的回调函数
2381 | */
2382 | fail?: Function;
2383 | /**
2384 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2385 | */
2386 | complete?: Function;
2387 | }): void;
2388 |
2389 | getExtConfigSync(): void;
2390 |
2391 | // # 开放接口 #
2392 |
2393 | /**
2394 | * 调用接口获取登录凭证(code)进而换取用户登录态信息,包括用户的唯一标识(openid) 及本次登录的 会话密钥(session_key)。用户数据的加解密通讯需要依赖会话密钥完成。
2395 | */
2396 | login(obj: {
2397 | /**
2398 | * 接口调用成功的回调函数
2399 | */
2400 | success?: Function;
2401 | /**
2402 | * 接口调用失败的回调函数
2403 | */
2404 | fail?: Function;
2405 | /**
2406 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2407 | */
2408 | complete?: Function;
2409 | }): void;
2410 |
2411 | /**
2412 | * 通过上述接口获得的用户登录态拥有一定的时效性。用户越久未使用小程序,用户登录态越有可能失效。反之如果用户一直在使用小程序,则用户登录态一直保持有效。具体时效逻辑由微信维护,对开发者透明。开发者只需要调用wx.checkSession接口检测当前用户登录态是否有效。登录态过期后开发者可以再调用wx.login获取新的用户登录态。
2413 | */
2414 | checkSession(obj: {
2415 | /**
2416 | * 接口调用成功的回调函数,登录态未过期
2417 | */
2418 | success?: Function;
2419 | /**
2420 | * 接口调用失败的回调函数,登录态已过期
2421 | */
2422 | fail?: Function;
2423 | /**
2424 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2425 | */
2426 | complete?: Function;
2427 | }): void;
2428 |
2429 | authorize(obj: {
2430 | /**
2431 | * 需要获取权限的scope,详见 scope 列表
2432 | */
2433 | scope: string;
2434 | /**
2435 | * 接口调用成功的回调函数
2436 | */
2437 | success?: Function;
2438 | /**
2439 | * 接口调用失败的回调函数
2440 | */
2441 | fail?: Function;
2442 | /**
2443 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2444 | */
2445 | complete?: Function;
2446 | }): void;
2447 |
2448 | /**
2449 | * 获取用户信息,withCredentials 为 true 时需要先调用 wx.login 接口。
2450 | */
2451 | getUserInfo(obj: {
2452 | /**
2453 | * 是否带上登录态信息
2454 | */
2455 | withCredentials?: boolean;
2456 | /**
2457 | * 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文
2458 | */
2459 | lang?: string;
2460 | /**
2461 | * 接口调用成功的回调函数
2462 | */
2463 | success?: Function;
2464 | /**
2465 | * 接口调用失败的回调函数
2466 | */
2467 | fail?: Function;
2468 | /**
2469 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2470 | */
2471 | complete?: Function;
2472 | }): void;
2473 |
2474 | /**
2475 | * 发起微信支付。
2476 | */
2477 | requestPayment(obj: {
2478 | /**
2479 | * 时间戳从1970年1月1日00:00:00至今的秒数,即当前的时间
2480 | */
2481 | timeStamp: string;
2482 | /**
2483 | * 随机字符串,长度为32个字符以下。
2484 | */
2485 | nonceStr: string;
2486 | /**
2487 | * 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*
2488 | */
2489 | package: string;
2490 | /**
2491 | * 签名算法,暂支持 MD5
2492 | */
2493 | signType: string;
2494 | /**
2495 | * 签名,具体签名方案参见小程序支付接口文档;
2496 | */
2497 | paySign: string;
2498 | /**
2499 | * 接口调用成功的回调函数
2500 | */
2501 | success?: Function;
2502 | /**
2503 | * 接口调用失败的回调函数
2504 | */
2505 | fail?: Function;
2506 | /**
2507 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2508 | */
2509 | complete?: Function;
2510 | }): void;
2511 |
2512 | chooseAddress(obj: {
2513 | /**
2514 | * 返回用户选择的收货地址信息
2515 | */
2516 | success?: Function;
2517 | /**
2518 | * 接口调用失败的回调函数
2519 | */
2520 | fail?: Function;
2521 | /**
2522 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2523 | */
2524 | complete?: Function;
2525 | }): void;
2526 |
2527 | addCard(obj: {
2528 | /**
2529 | * 需要添加的卡券列表,列表内对象说明请参见请求对象说明
2530 | */
2531 | cardList: undefined;
2532 | /**
2533 | * 接口调用成功的回调函数
2534 | */
2535 | success?: Function;
2536 | /**
2537 | * 接口调用失败的回调函数
2538 | */
2539 | fail?: Function;
2540 | /**
2541 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2542 | */
2543 | complete?: Function;
2544 | }): void;
2545 |
2546 | openCard(obj: {
2547 | /**
2548 | * 需要打开的卡券列表,列表内参数详见openCard 请求对象说明
2549 | */
2550 | cardList: undefined;
2551 | /**
2552 | * 接口调用成功的回调函数
2553 | */
2554 | success?: Function;
2555 | /**
2556 | * 接口调用失败的回调函数
2557 | */
2558 | fail?: Function;
2559 | /**
2560 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2561 | */
2562 | complete?: Function;
2563 | }): void;
2564 |
2565 | openSetting(obj: {
2566 | /**
2567 | * 接口调用成功的回调函数,返回内容详见返回参数说明。
2568 | */
2569 | success?: Function;
2570 | /**
2571 | * 接口调用失败的回调函数
2572 | */
2573 | fail?: Function;
2574 | /**
2575 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2576 | */
2577 | complete?: Function;
2578 | }): void;
2579 |
2580 | getSetting(obj: {
2581 | /**
2582 | * 接口调用成功的回调函数,返回内容详见返回参数说明。
2583 | */
2584 | success?: Function;
2585 | /**
2586 | * 接口调用失败的回调函数
2587 | */
2588 | fail?: Function;
2589 | /**
2590 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2591 | */
2592 | complete?: Function;
2593 | }): void;
2594 |
2595 | getWeRunData(obj: {
2596 | /**
2597 | * 接口调用成功的回调函数
2598 | */
2599 | success?: Function;
2600 | /**
2601 | * 接口调用失败的回调函数
2602 | */
2603 | fail?: Function;
2604 | /**
2605 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2606 | */
2607 | complete?: Function;
2608 | }): void;
2609 |
2610 | navigateToMiniProgram(obj: {
2611 | /**
2612 | * 要打开的小程序 appId
2613 | */
2614 | appId: string;
2615 | /**
2616 | * 打开的页面路径,如果为空则打开首页
2617 | */
2618 | path?: string;
2619 | /**
2620 | * 需要传递给目标小程序的数据,目标小程序可在 App.onLaunch(),App.onShow() 中获取到这份数据。详情
2621 | */
2622 | extraData?: any;
2623 | /**
2624 | * 要打开的小程序版本,有效值 develop(开发版),trial(体验版),release(正式版) ,仅在当前小程序为开发版或体验版时此参数有效;如果当前小程序是体验版或正式版,则打开的小程序必定是正式版。默认值 release
2625 | */
2626 | envVersion?: string;
2627 | /**
2628 | * 接口调用成功的回调函数
2629 | */
2630 | success?: Function;
2631 | /**
2632 | * 接口调用失败的回调函数
2633 | */
2634 | fail?: Function;
2635 | /**
2636 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2637 | */
2638 | complete?: Function;
2639 | }): void;
2640 |
2641 | chooseInvoiceTitle(obj: {
2642 | /**
2643 | * 接口调用成功的回调函数
2644 | */
2645 | success?: Function;
2646 | /**
2647 | * 接口调用失败的回调函数
2648 | */
2649 | fail?: Function;
2650 | /**
2651 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2652 | */
2653 | complete?: Function;
2654 | }): void;
2655 |
2656 | checkIsSupportSoterAuthentication(obj: {
2657 | /**
2658 | * 接口调用成功的回调函数
2659 | */
2660 | success?: Function;
2661 | /**
2662 | * 接口调用失败的回调函数
2663 | */
2664 | fail?: Function;
2665 | /**
2666 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2667 | */
2668 | complete?: Function;
2669 | }): void;
2670 |
2671 | // # 数据 #
2672 |
2673 | /**
2674 | * 自定义分析数据上报接口。使用前,需要在小程序管理后台自定义分析中新建事件,配置好事件名与字段。
2675 | */
2676 | reportAnalytics(eventName: string, data: string, ): void;
2677 |
2678 | // # 拓展接口 #
2679 |
2680 | arrayBufferToBase64(arrayBuffer: string): void;
2681 |
2682 | base64ToArrayBuffer(base64: string): void;
2683 |
2684 | // # 调试接口 #
2685 |
2686 | setEnableDebug(obj: {
2687 | /**
2688 | * 是否打开调试
2689 | */
2690 | enableDebug: boolean;
2691 | /**
2692 | * 接口调用成功的回调函数
2693 | */
2694 | success?: Function;
2695 | /**
2696 | * 接口调用失败的回调函数
2697 | */
2698 | fail?: Function;
2699 | /**
2700 | * 接口调用结束的回调函数(调用成功、失败都会执行)
2701 | */
2702 | complete?: Function;
2703 | }): void;
2704 |
2705 | }
--------------------------------------------------------------------------------
/utils/util.js:
--------------------------------------------------------------------------------
1 | const formatTime = date => {
2 | const year = date.getFullYear()
3 | const month = date.getMonth() + 1
4 | const day = date.getDate()
5 | const hour = date.getHours()
6 | const minute = date.getMinutes()
7 | const second = date.getSeconds()
8 |
9 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
10 | }
11 |
12 | const formatNumber = n => {
13 | n = n.toString()
14 | return n[1] ? n : '0' + n
15 | }
16 |
17 | module.exports = {
18 | formatTime: formatTime
19 | }
20 |
--------------------------------------------------------------------------------