├── .DS_Store
├── .gitignore
├── .vscode
└── settings.json
├── README.md
├── app.js
├── app.json
├── app.wxss
├── dist
├── Bmob-1.1.1.min.js
├── Bmob-1.3.0.min.js
├── Bmob-1.3.1.min.js
├── Bmob-1.4.0.min.js
├── Bmob-1.4.1.min.js
├── Bmob-1.4.2.min.js
├── Bmob-1.4.3.min.js
├── Bmob-1.4.4.min.js
├── Bmob-2.2.5.min.js
├── Bmob-hap.1.1.1.js
├── Bmob-hap.1.1.1.min.js
├── bmob.js
├── bmobSocketIo.js
├── index.html
└── underscore.js
├── images
├── add.png
├── addAddress.png
├── autologin.png
├── banner.png
├── chatroom.png
├── checkCon.png
├── checkEmail.png
├── code.png
├── database.png
├── database1.png
├── dels.png
├── edit.png
├── edits.png
├── getInfo.png
├── getOpenid.png
├── green_tri.png
├── help.png
├── icon64_appwx_logo.png
├── icon_API.png
├── icon_API_HL copy.png
├── icon_API_HL.png
├── icon_component.png
├── icon_component_HL copy.png
├── icon_component_HL.png
├── icon_foot.png
├── icon_tabbar.png
├── liao.png
├── list.png
├── list1.png
├── location.png
├── login.png
├── logout.png
├── me.png
├── me1.png
├── open.png
├── openid.png
├── pause.png
├── pay.png
├── phone.png
├── pic.png
├── play.png
├── plus.png
├── pswdreset.jpg
├── pswdreset.png
├── record.png
├── reg.png
├── select.png
├── sms.png
├── stop.png
├── template.png
├── token.png
├── trash.png
├── updateInfo.png
├── wechat.png
├── wechatHL copy.png
└── wechatHL.png
├── jsconfig.json
├── package-lock.json
├── package.json
├── pages
├── .DS_Store
├── center
│ ├── feedback
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ ├── index.wxss
│ └── release
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
├── common
│ └── index.wxss
├── database
│ ├── detail
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
├── index
│ ├── index.js
│ ├── index.wxml
│ └── index.wxss
├── interface
│ ├── addAddress
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── chatai
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── chatroom
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── checkContent
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── code
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── decryption.js
│ ├── decryption.json
│ ├── decryption.wxml
│ ├── decryption.wxss
│ ├── decryption
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── getToken
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ ├── index.wxss
│ ├── main.go
│ ├── pay
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── select
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ ├── shop.js
│ ├── shop.json
│ ├── shop.wxml
│ ├── shop.wxss
│ ├── template
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ └── upload
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
├── logs
│ ├── logs.js
│ ├── logs.json
│ ├── logs.wxml
│ └── logs.wxss
└── user
│ ├── checkEmail
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
│ ├── getOpenid
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ ├── index.wxss
│ ├── interface
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
│ ├── login
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
│ ├── register
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
│ ├── resetPswd
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
│ ├── smsLogin
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
│ ├── updateInfo
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
│ └── userInfo
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
├── project.config.json
├── project.private.config.json
├── sitemap.json
├── style
├── footer.wxml
├── header.wxml
└── weui.wxss
├── typings
└── wx.d.ts
└── utils
├── .DS_Store
├── common.js
└── util.js
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /node_modules/*
3 | !/node_modules/axios/
4 | hydrogen-js-sdk
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.associations": {
3 | "*.wxml": "html",
4 | "*.wxss": "css"
5 | }
6 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Bmob 微信小程序 Demo
2 | ===================
3 |
4 | 打开Demo你可以这样操作:
5 |
6 |
7 | 
8 | 
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | // app.js
2 | // 源码引入方式,方便调试
3 | import Bmob from 'utils/hydrogen-js-sdk/src/lib/app.js'
4 | // import Bmob from 'utils/hydrogen-js-sdk/dist/Bmob-2.4.13.min.js'
5 |
6 | Bmob.initialize('bc7814ffb203da9f', '123456');
7 | // 初始化 Bmob.initialize('你的Application ID', '你的REST API Key');
8 | // Bmob.initialize('9731770784b8c006', '111111')
9 | // Bmob.domain('http://website-restful.bmobapp.com')
10 | // Bmob.domain('http://apitest.codenow.cn')
11 | // Bmob.domain('https://api.codenow.cn')
12 |
13 |
14 |
15 | App({
16 | onLaunch: function () {
17 |
18 |
19 |
20 | // 按钮点击发送消息
21 | setTimeout(()=>{
22 | // 发送消息
23 | // console.log(ChatAi,"x");
24 | // console.log(12);
25 | // session 会话id,可以传用户objectId,或者随机数
26 | // content 内容,提问的内容,如果希望上下文,可以这样传入
27 | // {"model":"gpt-3.5-turbo","messages":[{"content":"你好","role":"user"},{"content":"你好,有什么我可以为你提供的帮助吗?","role":"assistant"},{"content":"请问Bmob是什么产品","role":"user"}],"stream":true}
28 | // let datas = {"messages":[{"content":"你好","role":"user"}],"session":"b1"}
29 | // ChatAi.send(JSON.stringify(datas))
30 | },3000)
31 |
32 |
33 |
34 |
35 | const query = Bmob.Query('_User')
36 | // query.equalTo('username','!=','ff')
37 | query.find().then(res => {
38 | console.log(res)
39 | })
40 | // 一键登录
41 | Bmob.User.auth().then(res => {
42 | console.log(res);
43 | console.log('一键登录成功')
44 | var userData = { nickName: res.nickName, objectId: res.objectId, openid: res.openid, userPic: res.userPic, username: res.username };
45 | wx.setStorageSync('userData', userData);
46 | wx.setStorageSync('openid', res.openid)
47 | }).catch(err => {
48 | console.log(err);
49 | })
50 | },
51 | globalData: {
52 | userInfo: null
53 | }
54 | })
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/user/index",
4 | "pages/user/login/index",
5 | "pages/user/register/index",
6 | "pages/user/smsLogin/index",
7 | "pages/user/userInfo/index",
8 | "pages/user/checkEmail/index",
9 | "pages/user/resetPswd/index",
10 | "pages/user/updateInfo/index",
11 | "pages/user/getOpenid/index",
12 | "pages/interface/index",
13 | "pages/interface/shop",
14 | "pages/interface/upload/index",
15 | "pages/interface/code/index",
16 | "pages/interface/checkContent/index",
17 | "pages/interface/pay/index",
18 | "pages/interface/getToken/index",
19 | "pages/interface/template/index",
20 | "pages/interface/addAddress/index",
21 | "pages/interface/select/index",
22 | "pages/interface/chatroom/index",
23 | "pages/interface/chatai/index",
24 | "pages/database/index",
25 | "pages/database/detail/index",
26 | "pages/center/index",
27 | "pages/center/release/index",
28 | "pages/center/feedback/index",
29 | "pages/interface/decryption",
30 | "pages/interface/decryption/index"
31 | ],
32 | "window": {
33 | "backgroundTextStyle": "light",
34 | "navigationBarBackgroundColor": "#3891f8",
35 | "navigationBarTitleText": "增删改查-小程序Demo",
36 | "navigationBarTextStyle": "white"
37 | },
38 | "tabBar": {
39 | "color": "#7A7E83",
40 | "selectedColor": "#318efb",
41 | "borderStyle": "white",
42 | "backgroundColor": "#ffffff",
43 | "list": [
44 | {
45 | "pagePath": "pages/user/index",
46 | "iconPath": "images/icon_API.png",
47 | "selectedIconPath": "images/icon_API_HL.png",
48 | "text": "用户操作"
49 | },
50 | {
51 | "pagePath": "pages/interface/index",
52 | "iconPath": "images/list.png",
53 | "selectedIconPath": "images/list1.png",
54 | "text": "常用接口"
55 | },
56 | {
57 | "pagePath": "pages/database/index",
58 | "iconPath": "images/database.png",
59 | "selectedIconPath": "images/database1.png",
60 | "text": "数据库操作"
61 | },
62 | {
63 | "pagePath": "pages/center/index",
64 | "iconPath": "images/me.png",
65 | "selectedIconPath": "images/me1.png",
66 | "text": "我的"
67 | }
68 | ]
69 | },
70 | "sitemapLocation": "sitemap.json"
71 | }
--------------------------------------------------------------------------------
/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 |
3 | /* reset */
4 | page {
5 | background-color: #F8F8F8;
6 | height: 100%;
7 | font-size: 32rpx;
8 | line-height: 1.6;
9 | }
10 | checkbox, radio{
11 | margin-right: 10rpx;
12 | }
13 | button{
14 | margin-top: 20rpx;
15 | margin-bottom: 20rpx;
16 | }
17 | form{
18 | width: 100%;
19 | }
20 |
21 | /* lib */
22 | .strong{
23 | font-weight: bold;
24 | }
25 | .tc{
26 | text-align: center;
27 | }
28 | .f12{
29 | font-size: 12px;
30 | }
31 |
32 | /* page */
33 | .container {
34 | display: flex;
35 | flex-direction: column;
36 | min-height: 100%;
37 | justify-content: space-between;
38 | font-size: 32rpx;
39 | font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif;
40 | }
41 | .page-head{
42 | padding: 60rpx 50rpx 80rpx;
43 | text-align: center;
44 | }
45 | .page-head-title{
46 | display: inline-block;
47 | padding: 0 40rpx 20rpx 40rpx;
48 | font-size: 32rpx;
49 | color: #BEBEBE;
50 | }
51 | .page-head-line{
52 | margin: 0 auto;
53 | width: 150rpx;
54 | height: 2rpx;
55 | background-color: #D8D8D8;
56 | }
57 | .page-head-desc{
58 | padding-top: 20rpx;
59 | color: #9B9B9B;
60 | font-size: 32rpx;
61 | }
62 |
63 | .page-body {
64 | width: 100%;
65 | flex-grow: 1;
66 | overflow-x: hidden;
67 | }
68 | .page-body-wrapper {
69 | display: flex;
70 | flex-direction: column;
71 | align-items: center;
72 | width: 100%;
73 | }
74 | .page-body-wording {
75 | text-align: center;
76 | padding: 200rpx 100rpx;
77 | }
78 | .page-body-info {
79 | display: flex;
80 | flex-direction: column;
81 | align-items: center;
82 | background-color: #fff;
83 | width: 100%;
84 | padding: 50rpx 0 150rpx 0;
85 | }
86 | .page-body-title {
87 | margin-bottom: 100rpx;
88 | font-size: 32rpx;
89 | }
90 | .page-body-text {
91 | font-size: 30rpx;
92 | line-height: 26px;
93 | color: #ccc;
94 | }
95 | .page-body-text-small {
96 | font-size: 24rpx;
97 | color: #000;
98 | margin-bottom: 100rpx;
99 | }
100 |
101 | .page-foot{
102 | margin: 100rpx 0 30rpx 0;
103 | text-align: center;
104 | color: #1aad19;
105 | font-size: 0;
106 | }
107 | .icon-foot{
108 | width: 152rpx;
109 | height: 23rpx;
110 | }
111 |
112 | .page-section{
113 | width: 100%;
114 | margin-bottom: 60rpx;
115 | }
116 | .page-section_center{
117 | display: flex;
118 | flex-direction: column;
119 | align-items: center;
120 | }
121 | .page-section:last-child{
122 | margin-bottom: 0;
123 | }
124 | .page-section-gap{
125 | box-sizing: border-box;
126 | padding: 0 30rpx;
127 | }
128 | .page-section-spacing{
129 | box-sizing: border-box;
130 | padding: 0 80rpx;
131 | }
132 | .page-section-title{
133 | font-size: 28rpx;
134 | color: #999999;
135 | margin-bottom: 10rpx;
136 | padding-left: 30rpx;
137 | padding-right: 30rpx;
138 | }
139 | .page-section-gap .page-section-title{
140 | padding-left: 0;
141 | padding-right: 0;
142 | }
143 |
144 |
145 | /* widget */
146 | .btn-area{
147 | margin-top: 60rpx;
148 | box-sizing: border-box;
149 | width: 100%;
150 | padding: 0 30rpx;
151 | }
152 |
153 | .image-plus {
154 | width: 150rpx;
155 | height: 150rpx;
156 | border: 2rpx solid #D9D9D9;
157 | position: relative;
158 | }
159 | .image-plus-nb{
160 | border: 0;
161 | }
162 | .image-plus-text{
163 | color: #888888;
164 | font-size: 28rpx;
165 | }
166 | .image-plus-horizontal {
167 | position: absolute;
168 | top: 50%;
169 | left: 50%;
170 | background-color: #d9d9d9;
171 | width: 4rpx;
172 | height: 80rpx;
173 | transform: translate(-50%, -50%);
174 | }
175 | .image-plus-vertical {
176 | position: absolute;
177 | top: 50%;
178 | left: 50%;
179 | background-color: #d9d9d9;
180 | width: 80rpx;
181 | height: 4rpx;
182 | transform: translate(-50%, -50%);
183 | }
184 |
185 | .demo-text-1{
186 | position: relative;
187 | align-items: center;
188 | justify-content: center;
189 | background-color: #1AAD19;
190 | color: #FFFFFF;
191 | font-size: 36rpx;
192 | }
193 | .demo-text-1:before{
194 | content: 'A';
195 | position: absolute;
196 | top: 50%;
197 | left: 50%;
198 | transform: translate(-50%, -50%);
199 | }
200 | .demo-text-2{
201 | position: relative;
202 | align-items: center;
203 | justify-content: center;
204 | background-color: #2782D7;
205 | color: #FFFFFF;
206 | font-size: 36rpx;
207 | }
208 | .demo-text-2:before{
209 | content: 'B';
210 | position: absolute;
211 | top: 50%;
212 | left: 50%;
213 | transform: translate(-50%, -50%);
214 | }
215 | .demo-text-3{
216 | position: relative;
217 | align-items: center;
218 | justify-content: center;
219 | background-color: #F1F1F1;
220 | color: #353535;
221 | font-size: 36rpx;
222 | }
223 | .demo-text-3:before{
224 | content: 'C';
225 | position: absolute;
226 | top: 50%;
227 | left: 50%;
228 | transform: translate(-50%, -50%);
229 | }
230 | .i-header{
231 | height: 350rpx;
232 | background-color: #3891f8;
233 | text-align: center;
234 | }
235 | .i-header-h1{
236 | color:#fff;
237 | font-size: 40rpx;
238 | font-family: Georgia, 'Times New Roman', Times, serif;
239 | font-weight: bold;
240 | }
241 | .h50{
242 | padding-top: 50px;
243 | }
244 | .g-bda-userinfo {
245 | padding-top: 50rpx;
246 | display: flex;
247 | flex-direction: column;
248 | align-items: center;
249 | }
250 |
251 | .userinfo-avatar {
252 | width: 180rpx;
253 | height: 180rpx;
254 | margin: 20rpx;
255 | margin-bottom: 2rpx;
256 | border-radius: 50%;
257 | border: 2px solid #fff;
258 | }
259 | .userinfo-nickname{
260 | color: #fff;
261 | }
262 |
263 |
264 |
265 | .weui-dialog {
266 | position: fixed;
267 | z-index: 5000;
268 | width: 80%;
269 | max-width: 300px;
270 | top: 50%;
271 | left: 50%;
272 | -webkit-transform: translate(-50%, -50%);
273 | transform: translate(-50%, -50%);
274 | background-color: #FFFFFF;
275 | text-align: center;
276 | border-radius: 3px;
277 | overflow: hidden;
278 | }
279 | .weui-dialog__hd {
280 | padding: 1.3em 1.6em 0.5em;
281 | }
282 | .weui-dialog__title {
283 | font-weight: 400;
284 | font-size: 18px;
285 | }
286 | .weui-dialog__bd {
287 | padding: 0 1.6em 0.8em;
288 | min-height: 40px;
289 | font-size: 15px;
290 | line-height: 1.3;
291 | word-wrap: break-word;
292 | word-break: break-all;
293 | color: #999999;
294 | }
295 | .weui-dialog__bd:first-child {
296 | padding: 2.7em 20px 1.7em;
297 | color: #353535;
298 | }
299 | .weui-dialog__ft {
300 | position: relative;
301 | line-height: 48px;
302 | font-size: 18px;
303 | display: -webkit-box;
304 | display: -webkit-flex;
305 | display: flex;
306 | }
307 | .weui-dialog__ft:after {
308 | content: " ";
309 | position: absolute;
310 | left: 0;
311 | top: 0;
312 | right: 0;
313 | height: 1px;
314 | border-top: 1px solid #D5D5D6;
315 | color: #D5D5D6;
316 | -webkit-transform-origin: 0 0;
317 | transform-origin: 0 0;
318 | -webkit-transform: scaleY(0.5);
319 | transform: scaleY(0.5);
320 | }
321 | .weui-dialog__btn {
322 | display: block;
323 | -webkit-box-flex: 1;
324 | -webkit-flex: 1;
325 | flex: 1;
326 | color: #3CC51F;
327 | text-decoration: none;
328 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
329 | position: relative;
330 | }
331 | .weui-dialog__btn:active {
332 | background-color: #EEEEEE;
333 | }
334 | .weui-dialog__btn:after {
335 | content: " ";
336 | position: absolute;
337 | left: 0;
338 | top: 0;
339 | width: 1px;
340 | bottom: 0;
341 | border-left: 1px solid #D5D5D6;
342 | color: #D5D5D6;
343 | -webkit-transform-origin: 0 0;
344 | transform-origin: 0 0;
345 | -webkit-transform: scaleX(0.5);
346 | transform: scaleX(0.5);
347 | }
348 | .weui-dialog__btn:first-child:after {
349 | display: none;
350 | }
351 | .weui-dialog__btn_default {
352 | color: #353535;
353 | }
354 | .weui-dialog__btn_primary {
355 | color: #3cc51f;
356 | }
357 | .weui-mask {
358 | position: fixed;
359 | z-index: 1000;
360 | top: 0;
361 | right: 0;
362 | left: 0;
363 | bottom: 0;
364 | background: rgba(0, 0, 0, 0.6);
365 | }
366 | .notice {
367 | margin-top: 15px;
368 | }
369 |
370 | @import 'style/weui.wxss';
--------------------------------------------------------------------------------
/dist/bmobSocketIo.js:
--------------------------------------------------------------------------------
1 | const Emitter = {
2 | setup(target) {
3 | let listeners = []
4 |
5 | Object.assign(target, {
6 | on(type, handle) {
7 | if (typeof handle == 'function') {
8 | listeners.push([type, handle])
9 | }
10 | },
11 | emit(type, ...params) {
12 | listeners.forEach(
13 | ([listenType, handle]) => type == listenType && handle(...params)
14 | )
15 | },
16 | removeAllListeners() {
17 | listeners = []
18 | }
19 | })
20 | }
21 | }
22 |
23 | /**
24 | * 基于小程序 WebSocket 接口封装信道
25 | */
26 | module.exports = class BmobSocketIo {
27 | constructor(applicationId) {
28 |
29 | this.config = {
30 | host: 'wss.bmobcloud.com'
31 | }
32 | Emitter.setup((this.emitter = {}))
33 | this.applicationId = applicationId
34 | this.initialize()
35 | }
36 | handshake() {
37 | function complete(data) {
38 | if (data instanceof Error) {
39 | self.connecting = false
40 | self.onError(data.message)
41 | } else {
42 | return data.split(':')[0]
43 | }
44 | }
45 |
46 | var url = 'https://'+this.config.host+'/socket.io/1/?t=' + new Date().getTime()
47 | var dataObject = {}
48 | var data = JSON.stringify(dataObject)
49 |
50 | var method = 'GET'
51 |
52 | return new Promise((resolve, reject) => {
53 | wx.request({
54 | method: method,
55 | url: url,
56 | data: data,
57 | header: {
58 | 'content-type': 'text/plain'
59 | },
60 | success: function(res) {
61 | if (res.data && res.data.statusCode) {
62 | return resolve('request error', e)
63 | } else if (res.statusCode != 200) {
64 | return resolve('request error', e)
65 | } else {
66 | return resolve(complete(res.data))
67 | }
68 | },
69 | fail: function(e) {
70 | return resolve('request error', e)
71 | }
72 | })
73 | })
74 | }
75 | initialize() {
76 | this.handshake().then(protocol => {
77 | try {
78 | this.connect(
79 | `wss://${this.config.host}/socket.io/1/websocket/` + protocol,
80 | {}
81 | )
82 | } catch (connectError) {
83 | console.error({ connectError })
84 | throw connectError
85 | }
86 | })
87 | this.on('close', () => {
88 | console.log('连接已中断')
89 | })
90 |
91 | return new Promise((resolve, reject) => {
92 | this.on('server_pub', data => {
93 | switch (data.action) {
94 | case 'updateTable':
95 | this.onUpdateTable(data.tableName, data.data)
96 | break
97 | case 'updateRow':
98 | this.onUpdateRow(data.tableName, data.objectId, data.data)
99 | break
100 | case 'deleteTable':
101 | this.onDeleteTable(data.tableName, data.data)
102 | break
103 | case 'deleteRow':
104 | this.onDeleteRow(data.tableName, data.objectId, data.data)
105 | break
106 | }
107 | })
108 |
109 | //连接上socket.io服务器后触发的事件
110 | this.on('client_send_data', resp => {
111 | this.onInitListen()
112 | })
113 | })
114 | }
115 |
116 | onInitListen() {}
117 |
118 | connect(url, header) {
119 | // 小程序 wx.connectSocket() API header 参数无效,把会话信息附加在 URL 上
120 | const query = Object.keys(header)
121 | .map(key => `${key}=${encodeURIComponent(header[key])}`)
122 | .join('&')
123 | const seperator = url.indexOf('?') > -1 ? '&' : '?'
124 | url = [url, query].join(seperator)
125 |
126 | return new Promise((resolve, reject) => {
127 | wx.onSocketOpen(resolve)
128 | wx.onSocketError(reject)
129 | wx.onSocketMessage(packet => {
130 | try {
131 | let filter = function(str) {
132 | const { name, args } = JSON.parse(str)
133 | return { name, args }
134 | }
135 | let str = packet.data
136 | let startStr = str.slice(0,4)
137 | // 检测心跳
138 | if('2:::'===startStr){
139 | this.emit(false,true)
140 | }
141 | str = str.slice(4)
142 |
143 | // 截取后不能为空
144 | if (str == null || str == '') {
145 | return
146 | }
147 | const { name, args } = filter(str)
148 | let data = args == null ? '' : JSON.parse(args[0])
149 | this.emitter.emit(name, data)
150 | } catch (e) {
151 | console.log('Handle packet failed: ' + packet.data, e)
152 | }
153 | })
154 | wx.onSocketClose(() => this.emitter.emit('close'))
155 | wx.connectSocket({ url, header })
156 | })
157 | }
158 |
159 | on(message, handle) {
160 | this.emitter.on(message, handle)
161 | }
162 |
163 | emit(message, data) {
164 | data=data==undefined?'5:::':'2:::'
165 | message = message?JSON.stringify(message):''
166 | wx.sendSocketMessage({
167 | data: data + message
168 | })
169 | }
170 |
171 | emitData(name, data) {
172 | data = JSON.stringify(data)
173 | return { name: name, args: [data] }
174 | }
175 |
176 | //"unsub_updateTable" ,"unsub_updateRow", "unsub_deleteTable", "unsub_deleteRow"
177 | //订阅更新数据表的数据
178 | updateTable = function(tablename) {
179 | var data = {
180 | appKey: this.applicationId,
181 | tableName: tablename,
182 | objectId: '',
183 | action: 'updateTable'
184 | }
185 | data = this.emitData('client_sub', data)
186 | this.emit(data)
187 | }
188 |
189 | //取消订阅更新数据表的数据
190 | unsubUpdateTable = function(tablename) {
191 | var data = {
192 | appKey: this.applicationId,
193 | tableName: tablename,
194 | objectId: '',
195 | action: 'unsub_updateTable'
196 | }
197 | data = this.emitData('client_sub', data)
198 | this.emit(data)
199 | }
200 |
201 | //订阅行更新的数据
202 | updateRow = function(tablename, objectId) {
203 | var data = {
204 | appKey: this.applicationId,
205 | tableName: tablename,
206 | objectId: objectId,
207 | action: 'updateRow'
208 | }
209 | data = this.emitData('client_sub', data)
210 | this.emit(data)
211 | }
212 |
213 | //取消订阅行更新的数据
214 | unsubUpdateRow = function(tablename, objectId) {
215 | var data = {
216 | appKey: this.applicationId,
217 | tableName: tablename,
218 | objectId: objectId,
219 | action: 'unsub_updateRow'
220 | }
221 | data = this.emitData('client_sub', data)
222 | this.emit(data)
223 | }
224 |
225 | //订阅表删除的数据
226 | deleteTable = function(tablename) {
227 | var data = {
228 | appKey: this.applicationId,
229 | tableName: tablename,
230 | objectId: '',
231 | action: 'deleteTable'
232 | }
233 | data = this.emitData('client_sub', data)
234 | this.emit(data)
235 | }
236 |
237 | //取消订阅表删除的数据
238 | unsubDeleteTable = function(tablename) {
239 | var data = {
240 | appKey: this.applicationId,
241 | tableName: tablename,
242 | objectId: '',
243 | action: 'unsub_deleteTable'
244 | }
245 | data = this.emitData('client_sub', data)
246 | this.emit(data)
247 | }
248 |
249 | //订阅更新数据表的数据
250 | deleteRow = function(tablename, objectId) {
251 | var data = {
252 | appKey: this.applicationId,
253 | tableName: tablename,
254 | objectId: objectId,
255 | action: 'deleteRow'
256 | }
257 | data = this.emitData('client_sub', data)
258 | this.emit(data)
259 | }
260 |
261 | //订阅更新数据表的数据
262 | unsubDeleteRow = function(tablename, objectId) {
263 | var data = {
264 | appKey: this.applicationId,
265 | tableName: tablename,
266 | objectId: objectId,
267 | action: 'unsub_deleteRow'
268 | }
269 | data = this.emitData('client_sub', data)
270 | this.emit(data)
271 | }
272 |
273 | //监听服务器返回的更新数据表的数据,需要用户重写
274 | onUpdateTable = function(tablename, data) {}
275 |
276 | //监听服务器返回的更新数据表的数据,需要用户重写
277 | onUpdateRow = function(tablename, objectId, data) {}
278 |
279 | //监听服务器返回的更新数据表的数据,需要用户重写
280 | onDeleteTable = function(tablename, data) {}
281 |
282 | //监听服务器返回的更新数据表的数据,需要用户重写
283 | onDeleteRow = function(tablename, objectId, data) {}
284 | }
285 |
--------------------------------------------------------------------------------
/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/images/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/add.png
--------------------------------------------------------------------------------
/images/addAddress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/addAddress.png
--------------------------------------------------------------------------------
/images/autologin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/autologin.png
--------------------------------------------------------------------------------
/images/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/banner.png
--------------------------------------------------------------------------------
/images/chatroom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/chatroom.png
--------------------------------------------------------------------------------
/images/checkCon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/checkCon.png
--------------------------------------------------------------------------------
/images/checkEmail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/checkEmail.png
--------------------------------------------------------------------------------
/images/code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/code.png
--------------------------------------------------------------------------------
/images/database.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/database.png
--------------------------------------------------------------------------------
/images/database1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/database1.png
--------------------------------------------------------------------------------
/images/dels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/dels.png
--------------------------------------------------------------------------------
/images/edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/edit.png
--------------------------------------------------------------------------------
/images/edits.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/edits.png
--------------------------------------------------------------------------------
/images/getInfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/getInfo.png
--------------------------------------------------------------------------------
/images/getOpenid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/getOpenid.png
--------------------------------------------------------------------------------
/images/green_tri.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/green_tri.png
--------------------------------------------------------------------------------
/images/help.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/help.png
--------------------------------------------------------------------------------
/images/icon64_appwx_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/icon64_appwx_logo.png
--------------------------------------------------------------------------------
/images/icon_API.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/icon_API.png
--------------------------------------------------------------------------------
/images/icon_API_HL copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/icon_API_HL copy.png
--------------------------------------------------------------------------------
/images/icon_API_HL.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/icon_API_HL.png
--------------------------------------------------------------------------------
/images/icon_component.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/icon_component.png
--------------------------------------------------------------------------------
/images/icon_component_HL copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/icon_component_HL copy.png
--------------------------------------------------------------------------------
/images/icon_component_HL.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/icon_component_HL.png
--------------------------------------------------------------------------------
/images/icon_foot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/icon_foot.png
--------------------------------------------------------------------------------
/images/icon_tabbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/icon_tabbar.png
--------------------------------------------------------------------------------
/images/liao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/liao.png
--------------------------------------------------------------------------------
/images/list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/list.png
--------------------------------------------------------------------------------
/images/list1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/list1.png
--------------------------------------------------------------------------------
/images/location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/location.png
--------------------------------------------------------------------------------
/images/login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/login.png
--------------------------------------------------------------------------------
/images/logout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/logout.png
--------------------------------------------------------------------------------
/images/me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/me.png
--------------------------------------------------------------------------------
/images/me1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/me1.png
--------------------------------------------------------------------------------
/images/open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/open.png
--------------------------------------------------------------------------------
/images/openid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/openid.png
--------------------------------------------------------------------------------
/images/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/pause.png
--------------------------------------------------------------------------------
/images/pay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/pay.png
--------------------------------------------------------------------------------
/images/phone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/phone.png
--------------------------------------------------------------------------------
/images/pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/pic.png
--------------------------------------------------------------------------------
/images/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/play.png
--------------------------------------------------------------------------------
/images/plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/plus.png
--------------------------------------------------------------------------------
/images/pswdreset.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/pswdreset.jpg
--------------------------------------------------------------------------------
/images/pswdreset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/pswdreset.png
--------------------------------------------------------------------------------
/images/record.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/record.png
--------------------------------------------------------------------------------
/images/reg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/reg.png
--------------------------------------------------------------------------------
/images/select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/select.png
--------------------------------------------------------------------------------
/images/sms.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/sms.png
--------------------------------------------------------------------------------
/images/stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/stop.png
--------------------------------------------------------------------------------
/images/template.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/template.png
--------------------------------------------------------------------------------
/images/token.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/token.png
--------------------------------------------------------------------------------
/images/trash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/trash.png
--------------------------------------------------------------------------------
/images/updateInfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/updateInfo.png
--------------------------------------------------------------------------------
/images/wechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/wechat.png
--------------------------------------------------------------------------------
/images/wechatHL copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/wechatHL copy.png
--------------------------------------------------------------------------------
/images/wechatHL.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/images/wechatHL.png
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2015",
4 | "module": "commonjs"
5 | }
6 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "devDependencies": {
3 | "webpack": "^5.99.7",
4 | "webpack-cli": "^6.0.1"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/pages/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/pages/.DS_Store
--------------------------------------------------------------------------------
/pages/center/feedback/index.js:
--------------------------------------------------------------------------------
1 | // pages/center/feedback/index.js
2 | var common = require('../../../utils/common.js');
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | userInfo:{},
10 | },
11 |
12 | /**
13 | * 生命周期函数--监听页面加载
14 | */
15 | onLoad: function (options) {
16 | var that = this;
17 |
18 | let userData = wx.Bmob.User.current()
19 | that.setData({
20 | userInfo:userData
21 | })
22 | },
23 |
24 | /**
25 | * 生命周期函数--监听页面初次渲染完成
26 | */
27 | onReady: function () {
28 |
29 | },
30 |
31 | /**
32 | * 生命周期函数--监听页面显示
33 | */
34 | onShow: function () {
35 |
36 | },
37 |
38 | /**
39 | * 生命周期函数--监听页面隐藏
40 | */
41 | onHide: function () {
42 |
43 | },
44 |
45 | /**
46 | * 生命周期函数--监听页面卸载
47 | */
48 | onUnload: function () {
49 |
50 | },
51 |
52 | /**
53 | * 页面相关事件处理函数--监听用户下拉动作
54 | */
55 | onPullDownRefresh: function () {
56 |
57 | },
58 |
59 | /**
60 | * 页面上拉触底事件的处理函数
61 | */
62 | onReachBottom: function () {
63 |
64 | },
65 |
66 | /**
67 | * 用户点击右上角分享
68 | */
69 | onShareAppMessage: function () {
70 |
71 | },
72 | addFeedback: function (event) {
73 | var that = this;
74 | var contact = event.detail.value.contact;
75 | var content = event.detail.value.content;
76 |
77 | if (!contact) {
78 | common.showTip("标题不能为空", "loading");
79 | return false;
80 | }
81 | else if (!content) {
82 | common.showTip("内容不能为空", "loading");
83 | return false;
84 | }
85 | else {
86 | that.setData({
87 | loading: true
88 | })
89 | var query = wx.Bmob.Query("feedback");
90 | query.set("contact", contact);
91 | query.set("content", content);
92 | query.save().then(res => {
93 | common.showModal('保存反馈成功,点击确定返回。', '提示', function () {
94 | wx.navigateBack();
95 | });
96 | that.setData({
97 | loading: false
98 | })
99 | }).catch(err => {
100 | // 添加失败
101 | common.showModal('保存反馈失败,请重新发布');
102 |
103 | })
104 | }
105 |
106 | },
107 | })
--------------------------------------------------------------------------------
/pages/center/feedback/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "反馈建议"
3 | }
--------------------------------------------------------------------------------
/pages/center/feedback/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
36 |
37 |
--------------------------------------------------------------------------------
/pages/center/feedback/index.wxss:
--------------------------------------------------------------------------------
1 |
2 | .g-bda-userinfo {
3 | padding-top: 50rpx;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | }
8 |
9 | .userinfo-avatar {
10 | width: 180rpx;
11 | height: 180rpx;
12 | margin: 20rpx;
13 | margin-bottom: 2rpx;
14 | border-radius: 50%;
15 | border: 2px solid #fff;
16 | }
17 | .userinfo-nickname{
18 | color: #fff;
19 | }
20 |
--------------------------------------------------------------------------------
/pages/center/index.js:
--------------------------------------------------------------------------------
1 | // pages/center/index.js
2 | var common = require('../../utils/common.js');
3 | const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
4 |
5 | Page({
6 |
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {
11 | userInfo: {},
12 | avatarUrl: defaultAvatarUrl,
13 | loading: true
14 | },
15 |
16 | /**
17 | * 生命周期函数--监听页面加载
18 | */
19 | onLoad: function (options) {
20 | //页面初始化 options为页面跳转所带来的参数
21 | var that = this;
22 | var value = wx.getStorageSync('openid')
23 | let current = wx.Bmob.User.current();
24 | that.setData({
25 | userInfo: current
26 | })
27 | },
28 |
29 | /**
30 | * 生命周期函数--监听页面初次渲染完成
31 | */
32 | onReady: function () {
33 |
34 | },
35 |
36 | /**
37 | * 生命周期函数--监听页面显示
38 | */
39 | onShow: function () {
40 |
41 | },
42 | onChooseAvatar(e) {
43 | const { avatarUrl } = e.detail
44 | this.setData({
45 | avatarUrl,
46 | 'userInfo.userPic': avatarUrl
47 | })
48 | // 更新用户信息到后端
49 | let current = wx.Bmob.User.current();
50 | current.set('userPic', avatarUrl);
51 | current.save();
52 | },
53 |
54 | /**
55 | * 生命周期函数--监听页面隐藏
56 | */
57 | onHide: function () {
58 |
59 | },
60 |
61 | /**
62 | * 生命周期函数--监听页面卸载
63 | */
64 | onUnload: function () {
65 |
66 | },
67 |
68 | /**
69 | * 页面相关事件处理函数--监听用户下拉动作
70 | */
71 | onPullDownRefresh: function () {
72 |
73 | },
74 |
75 | /**
76 | * 页面上拉触底事件的处理函数
77 | */
78 | onReachBottom: function () {
79 |
80 | },
81 |
82 | /**
83 | * 用户点击右上角分享
84 | */
85 | onShareAppMessage: function () {
86 |
87 | },
88 | open: function () {
89 | var that = this;
90 |
91 | wx.login({
92 | success: function (res) {
93 | wx.Bmob.User.auth().then(res => {
94 | console.log(res);
95 | var objectId = res.objectId;
96 | var openid = res.authData.weapp.openid;
97 | if (res.nickName) {
98 | wx.setStorageSync('openid', openid);
99 | that.onLoad();
100 | } else {
101 | wx.getUserInfo({
102 | success: function (result) {
103 | that.setData({
104 | loading: false
105 | })
106 | var userInfo = result.userInfo;
107 | var nickName = userInfo.nickName;
108 | var userPic = userInfo.avatarUrl;
109 |
110 | var query = wx.Bmob.Query("_User");
111 | query.get(objectId).then(res => {
112 | console.log(res);
113 | res.set("nickName", nickName);
114 | res.set("userPic", userPic);
115 | res.set("openid", openid);
116 | res.save();
117 | wx.setStorageSync('openid', openid)
118 | setTimeout(function () {
119 | that.setData({
120 | loading: true
121 | })
122 | that.onLoad()
123 | }, 2000);
124 | })
125 | }
126 | })
127 | }
128 | }).catch(err => {
129 | console.log(err);
130 | })
131 | }, fail: function (res) {
132 | that.setData({
133 | loading: true
134 | })
135 | }
136 | });
137 | },
138 | about: function (e) {
139 | common.showModal('本程序后端使用Bmob简单实现,仅供学习使用,如想加入一起学习,请加QQ群:118541934');
140 | }
141 | })
--------------------------------------------------------------------------------
/pages/center/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "个人中心"
3 | }
--------------------------------------------------------------------------------
/pages/center/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 | 授权中...
20 |
21 |
22 |
23 | 解锁更多功能
24 |
25 |
26 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 账户中心
38 |
39 |
40 |
41 |
50 |
51 |
52 |
53 |
54 |
55 | 反馈建议
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | 关于本程序
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/pages/center/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/center/index.wxss */
2 | .open{
3 | background: none !important;
4 | color: #000 !important;
5 | }
6 | .open::after{
7 | border: none;
8 | }
9 |
10 | .open-img{
11 | width:50px;
12 | height:50px;
13 | }
14 | .open-word{
15 | font-size:13px;
16 | }
17 |
18 | .avatar-wrapper1 {
19 | padding: 0;
20 | width: 200rpx;
21 | height: 200rpx;
22 | background: none;
23 | border: none;
24 | margin: 0;
25 | margin-top: 20rpx;
26 | }
27 |
28 | .avatar-wrapper1::after {
29 | border: none;
30 | }
31 |
32 | .avatar {
33 | width: 200rpx;
34 | height: 200rpx;
35 | border-radius: 50%;
36 | }
--------------------------------------------------------------------------------
/pages/center/release/index.js:
--------------------------------------------------------------------------------
1 | // pages/center/release/index.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
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 |
30 | },
31 |
32 | /**
33 | * 生命周期函数--监听页面隐藏
34 | */
35 | onHide: function () {
36 |
37 | },
38 |
39 | /**
40 | * 生命周期函数--监听页面卸载
41 | */
42 | onUnload: function () {
43 |
44 | },
45 |
46 | /**
47 | * 页面相关事件处理函数--监听用户下拉动作
48 | */
49 | onPullDownRefresh: function () {
50 |
51 | },
52 |
53 | /**
54 | * 页面上拉触底事件的处理函数
55 | */
56 | onReachBottom: function () {
57 |
58 | },
59 |
60 | /**
61 | * 用户点击右上角分享
62 | */
63 | onShareAppMessage: function () {
64 |
65 | }
66 | })
--------------------------------------------------------------------------------
/pages/center/release/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "我发布的"
3 | }
--------------------------------------------------------------------------------
/pages/center/release/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/pages/center/release/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/center/release/index.wxss */
--------------------------------------------------------------------------------
/pages/common/index.wxss:
--------------------------------------------------------------------------------
1 | .index-hd {
2 | padding: 80rpx;
3 | text-align: center;
4 | }
5 | .index-bd {
6 | padding: 0 30rpx 40rpx;
7 | }
8 | .index-ft {
9 | padding-bottom: 20rpx;
10 | text-align: center;
11 | }
12 | .index-logo {
13 | width: 86rpx;
14 | height: 86rpx;
15 | }
16 | .index-desc {
17 | margin-top: 20rpx;
18 | color: #888888;
19 | font-size: 28rpx;
20 | }
21 |
22 |
23 | .navigator-box {
24 | opacity: 0;
25 | position: relative;
26 | background-color: #FFFFFF;
27 | line-height: 1.41176471;
28 | font-size: 34rpx;
29 |
30 | transform: translateY(-50%);
31 | transition: .3s;
32 | }
33 | .navigator-box-show {
34 | opacity: 1;
35 | transform: translateY(0);
36 | }
37 | .navigator {
38 | padding: 20rpx 30rpx;
39 | position: relative;
40 | display: flex;
41 | align-items: center;
42 | }
43 | .navigator:before {
44 | content: " ";
45 | position: absolute;
46 | left: 30rpx;
47 | top: 0;
48 | right: 30rpx;
49 | height: 1px;
50 | border-top: 1rpx solid #D8D8D8;
51 | color: #D8D8D8;
52 | }
53 | .navigator:first-child:before {
54 | display: none;
55 | }
56 | .navigator-text {
57 | flex: 1;
58 | }
59 | .navigator-arrow {
60 | padding-right: 26rpx;
61 | position: relative;
62 | }
63 | .navigator-arrow:after {
64 | content: " ";
65 | display: inline-block;
66 | height: 18rpx;
67 | width: 18rpx;
68 | border-width: 2rpx 2rpx 0 0;
69 | border-color: #888888;
70 | border-style: solid;
71 | transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
72 | position: absolute;
73 | top: 50%;
74 | margin-top: -8rpx;
75 | right: 28rpx;
76 | }
77 |
78 |
79 | .kind-list-item {
80 | margin: 20rpx 0;
81 | background-color: #FFFFFF;
82 | border-radius: 4rpx;
83 | overflow: hidden;
84 | }
85 | .kind-list-item:first-child {
86 | margin-top: 0;
87 | }
88 | .kind-list-text{
89 | flex: 1;
90 | }
91 | .kind-list-img {
92 | width: 60rpx;
93 | height: 60rpx;
94 | }
95 | .kind-list-item-hd {
96 | padding: 30rpx;
97 | display: flex;
98 | align-items: center;
99 |
100 | transition: opacity .3s;
101 | }
102 | .kind-list-item-hd-show {
103 | opacity: .2;
104 | }
105 | .kind-list-item-bd {
106 | height: 0;
107 | overflow: hidden;
108 | }
109 | .kind-list-item-bd-show {
110 | height: auto;
111 | }
--------------------------------------------------------------------------------
/pages/database/detail/index.js:
--------------------------------------------------------------------------------
1 | // pages/database/detail/index.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | rows:{}
9 | },
10 |
11 | /**
12 | * 生命周期函数--监听页面加载
13 | */
14 | onLoad: function (options) {
15 | //获取一行记录
16 | var objectId = options.objectId;
17 | var that =this;
18 | var query = wx.Bmob.Query("diary");
19 | //数据关联,查询Pointer
20 | query.include('own', '_User')
21 | query.get(objectId).then(res=>{
22 | that.setData({
23 | rows: res,
24 | })
25 | }).catch(err=>{
26 | console.log(err)
27 | })
28 | },
29 |
30 | /**
31 | * 生命周期函数--监听页面初次渲染完成
32 | */
33 | onReady: function () {
34 |
35 | },
36 |
37 | /**
38 | * 生命周期函数--监听页面显示
39 | */
40 | onShow: function () {
41 |
42 | },
43 |
44 | /**
45 | * 生命周期函数--监听页面隐藏
46 | */
47 | onHide: function () {
48 |
49 | },
50 |
51 | /**
52 | * 生命周期函数--监听页面卸载
53 | */
54 | onUnload: function () {
55 |
56 | },
57 |
58 | /**
59 | * 页面相关事件处理函数--监听用户下拉动作
60 | */
61 | onPullDownRefresh: function () {
62 |
63 | },
64 |
65 | /**
66 | * 页面上拉触底事件的处理函数
67 | */
68 | onReachBottom: function () {
69 |
70 | },
71 |
72 | /**
73 | * 用户点击右上角分享
74 | */
75 | onShareAppMessage: function () {
76 |
77 | }
78 | })
--------------------------------------------------------------------------------
/pages/database/detail/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "日记详情"
3 | }
--------------------------------------------------------------------------------
/pages/database/detail/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{rows.own.nickName}}
11 | {{rows.createdAt}}
12 |
13 |
14 | {{rows.title}}
15 |
16 |
17 | {{rows.content}}
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/pages/database/detail/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/database/detail/index.wxss */
2 |
3 | .userPic {
4 | width: 50px;
5 | height: 50px;
6 | display: inline-block;
7 | overflow: hidden;
8 | border-radius: 50%;
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/pages/database/index.js:
--------------------------------------------------------------------------------
1 | // pages/database/index.js
2 | var that;
3 | var common = require("../../utils/common.js");
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | writeDiary:false,
11 | modifyDiarys: false,
12 | limit: 10,
13 | windowHeight:0,
14 | windowWidth:0,
15 | diaryList:[],
16 | },
17 | buf2hex: function (buffer) { // buffer is an ArrayBuffer
18 | return Array.prototype.map.call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2)).join('');
19 | },
20 |
21 | hextoString: function (hex) {
22 | var arr = hex.split("")
23 | var out = ""
24 | for (var i = 0; i < arr.length / 2; i++) {
25 | var tmp = "0x" + arr[i * 2] + arr[i * 2 + 1]
26 | var charValue = String.fromCharCode(tmp);
27 | out += charValue
28 | }
29 | return out
30 | },
31 | stringtoHex: function (str) {
32 | var val = "";
33 | for (var i = 0; i < str.length; i++) {
34 | if (val == "")
35 | val = str.charCodeAt(i).toString(16);
36 | else
37 | val += str.charCodeAt(i).toString(16);
38 | }
39 | val += "0a"
40 | return val
41 | },
42 |
43 |
44 |
45 | /**
46 | * 生命周期函数--监听页面加载
47 | */
48 | onLoad: function (options) {
49 | that=this;
50 | // console.log("hllll")
51 | // const query = wx.Bmob.Query('diary');
52 | // // 单词最多删除50条
53 | // query.limit(50)
54 | // query.find().then(todos => {
55 |
56 | // todos.destroyAll().then(res => {
57 | // // 成功批量修改
58 | // console.log(res, 'ok')
59 | // }).catch(err => {
60 | // console.log(err)
61 | // });
62 | // })
63 |
64 | var a='abc'
65 | var s = this.stringtoHex(a)
66 |
67 | var k = this.hextoString(s)
68 | console.log(s,k)
69 |
70 |
71 | console.log('hello')
72 | },
73 |
74 | /**
75 | * 生命周期函数--监听页面初次渲染完成
76 | */
77 | onReady: function () {
78 |
79 | },
80 |
81 | /**
82 | * 生命周期函数--监听页面显示
83 | */
84 | onShow: function () {
85 | getList(this);
86 |
87 | wx.getSystemInfo({
88 | success: (res)=> {
89 | this.setData({
90 | windowHeight:res.windowHeight,
91 | windowWidth:res.windowWidth
92 | })
93 | },
94 | })
95 | },
96 |
97 | /**
98 | * 生命周期函数--监听页面隐藏
99 | */
100 | onHide: function () {
101 |
102 | },
103 |
104 | /**
105 | * 生命周期函数--监听页面卸载
106 | */
107 | onUnload: function () {
108 |
109 | },
110 |
111 | /**
112 | * 页面相关事件处理函数--监听用户下拉动作
113 | */
114 | onPullDownRefresh: function () {
115 |
116 | },
117 |
118 | /**
119 | * 页面上拉触底事件的处理函数
120 | */
121 | onReachBottom: function () {
122 |
123 | },
124 |
125 | /**
126 | * 用户点击右上角分享
127 | */
128 | onShareAppMessage: function () {
129 |
130 | },
131 | toAddDiary:function(){
132 | that.setData({
133 | writeDiary:true
134 | })
135 | },
136 | noneWindows:function(){
137 | that.setData({
138 | writeDiary:"",
139 | modifyDiarys:"",
140 | })
141 | },
142 | addDiary:function(event){
143 | console.log('add')
144 | var title = event.detail.value.title;
145 | var content = event.detail.value.content;
146 | var formId = event.detail.formId;
147 | if(title == "" || content == ""){
148 | common.showTip("请填写完整","loading");
149 | return false;
150 | }
151 |
152 | //获取用户当前信息
153 | let userData = wx.Bmob.User.current()
154 |
155 | console.log("userData",userData)
156 | //新增一行记录
157 | var diary = wx.Bmob.Query("diary");
158 | //添加数据关联
159 | var pointer = wx.Bmob.Pointer("_User");
160 | var poiID = pointer.set(userData.objectId);
161 | console.log("poiID",poiID)
162 | diary.set("title", title);
163 | // diary.set("formId", formId);//保存formId
164 | diary.set("content", content);
165 | diary.set("own",poiID);
166 | diary.save().then(res=>{
167 | common.showTip("添加成功");
168 | that.setData({
169 | writeDiary:false,
170 | loading:false
171 | })
172 | getList(that);
173 | }).catch(err=>{
174 | console.log(err);
175 | common.showTip("添加失败","loading");
176 | })
177 | },
178 | deleteDiary:function(event){
179 | var objectId = event.target.dataset.id;
180 | wx.showModal({
181 | title:"提示",
182 | content:"确定删除日记",
183 | success:function(res){
184 | if(res.confirm){
185 | //删除一行数据
186 | var query = wx.Bmob.Query("diary");
187 | query.destroy(objectId).then(res=>{
188 | common.showTip("删除成功","success",function(){
189 | getList(that);
190 | })
191 | }).catch(err=>{
192 | console.log(err);
193 | common.showTip("删除失败","loading");
194 | })
195 | }
196 | }
197 | })
198 | },
199 | toModifyDiary:function(event){
200 | var nowTitle = event.target.dataset.title;
201 | var nowContent = event.target.dataset.content;
202 | var nowId = event.target.dataset.id;
203 | that.setData({
204 | modifyDiarys:true,
205 | nowTitle:nowTitle,
206 | nowContent:nowContent,
207 | nowId:nowId
208 | })
209 |
210 | },
211 | modifyDiary:function(event){
212 | modify(that,event);
213 | },
214 | pullUpLoad:function(){
215 | var limit = that.data.limit+2;
216 | this.setData({
217 | limit:limit
218 | })
219 | this.onShow();
220 | },
221 | inputTyping:function(event){
222 | getList(this,event.detail.value);
223 | this.setData({
224 | inputVal: event.detail.value
225 | });
226 | },
227 | showInput:function(){
228 | this.setData({
229 | inputShowed:true
230 | })
231 | },
232 | hideInput:function(){
233 | this.setData({
234 | inputVal:"",
235 | inputShowed:false
236 | })
237 | getList(this)
238 | },
239 | clearInput: function () {
240 | this.setData({
241 | inputVal: ""
242 | });
243 | getList(this);
244 | }
245 | })
246 |
247 | function getList(t,k){
248 |
249 | const querya = wx.Bmob.Query('diary')
250 | querya.field('tags','11eb442e8a')
251 | querya.relation('tag').then(res => {
252 | console.log(res);
253 | })
254 |
255 | that = t;
256 | //条件查询,获取当前用户日记
257 | var query = wx.Bmob.Query("diary");
258 | var query1 = wx.Bmob.Query("diary");
259 | let userData = wx.Bmob.User.current()
260 | //模糊查询,付费应用可使用
261 | if(k){
262 | query.equalTo("title", "==", { "$regex": "" + k + ".*" });
263 | query1.equalTo("content", "==", { "$regex": "" + k + ".*" });
264 | }
265 | //数据关联,查询Pointer
266 | query.include('own', '_User')
267 | //条件查询
268 | query.equalTo("own","==",userData.objectId);
269 | //分页查询
270 | query.limit(that.data.limit);
271 | //结果排序
272 | query.order("-createdAt");
273 | query.statTo("groupby", "title");
274 | query.find().then(res=>{
275 | console.log(res);
276 | that.setData({
277 | diaryList: res
278 | })
279 | }).catch(err=>{
280 | console.log(err);
281 | });
282 | }
283 |
284 | function modify(t,e){
285 | var that = t;
286 | var newTitle = e.detail.value.title;
287 | var newContent = e.detail.value.content;
288 | var objectId = that.data.nowId;
289 | var oldTitle = that.data.nowTitle;
290 | var oldContent = that.data.nowContent;
291 | if((newTitle != oldTitle || newContent != oldContent)){
292 | //修改一行数据
293 | var query = wx.Bmob.Query("diary");
294 | query.set('id', objectId); //需要修改的objectId
295 | query.set('title',newTitle);
296 | query.set('content', newContent);
297 | query.save().then(res=>{
298 | console.log(res);
299 | common.showTip("修改成功","success",function(){
300 | that.onShow();
301 | that.setData({
302 | modifyDiarys:false
303 | })
304 | })
305 | }).catch(err=>{
306 | console.log(err)
307 | common.showTip("修改失败","loading");
308 | })
309 |
310 |
311 | }else if(newTitle == "" || newContent == ""){
312 | common.showTip("标题或内容不为空","loading");
313 | }else{
314 | that.setData({
315 | modifyDiarys: false
316 | })
317 | common.showTip('修改成功', 'loading');
318 | }
319 |
320 | }
--------------------------------------------------------------------------------
/pages/database/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "数据库操作"
3 | }
--------------------------------------------------------------------------------
/pages/database/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
22 |
23 | 取消
24 |
25 |
26 |
27 |
28 |
29 |
30 | 日记列表
31 |
32 |
33 |
34 |
35 | {{item.title}}
36 | {{item.content}}
37 |
38 | {{item.updatedAt}}
39 |
40 |
41 |
42 | 删除
43 |
44 | 编辑
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | 暂无内容,请点击右下角添加
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | 添加日记
74 |
99 |
100 |
101 |
102 |
103 |
104 | 修改日记
105 |
130 |
131 |
--------------------------------------------------------------------------------
/pages/database/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 | .userinfo {
3 | display: flex;
4 | flex-direction: column;
5 | align-items: center;
6 | }
7 |
8 | .userinfo-avatar {
9 | width: 128rpx;
10 | height: 128rpx;
11 | margin: 20rpx;
12 | border-radius: 50%;
13 | }
14 |
15 | .userinfo-nickname {
16 | color: #aaa;
17 | }
18 |
19 | .usermotto {
20 | margin-top: 200px;
21 | }
22 | .add_layer{width:100%;height:100%;background:rgba(66, 69, 72, 0.74);position:fixed;left:0;top:0;}
23 | .add_layer input,.add_layer textarea,.add_layer button{width:80%;margin:0 auto;margin:15px auto;font-size:14px;padding:10rpx;}
24 | .add_layer input,.add_layer textarea{
25 | background:#fff;
26 | }
27 | .diary_list{border-bottom:1px solid #ccc;margin:0px 0;padding:10px;position:relative;}
28 | .diary_list text{font-size:16px;color:#1e1e1e;}
29 | .diary_list view{font-size:14px;padding:5px 0}
30 | .diary_list button{
31 | position:absolute;
32 | right:15px;
33 | top:12px;
34 | }
35 | .diary_list button.modify{right:90px;}
36 |
37 |
38 | .weui-media-box__info__operate{
39 | float:right;
40 | color:#1e1e1e;
41 | padding-right:0em;
42 |
43 | }
44 | .weui-media-box__info__operate .del{
45 | margin-right: 15px;
46 | }
47 | .toWrite {
48 | width:80rpx;
49 | height:80rpx;
50 | display: block;
51 | /*background:url("/image/add.png") no-repeat;*/
52 | padding:0;
53 | background-size:cover;
54 | position:fixed;
55 | right:74rpx;
56 | bottom:100rpx;
57 | border-radius: 50%;
58 | z-index: 999;
59 | }
60 | .weui-media-box{
61 | padding-bottom: 0px;
62 | }
63 | .weui-media-time{
64 | width:150rpx;
65 | height: 1em;
66 | overflow: hidden;
67 | }
68 |
69 | .weui-cells__title{
70 | text-align: left;
71 | }
72 | textarea,input{
73 | text-align: left;
74 | color:#1e1e1e;
75 | }
76 | .weui-cells {
77 | border:1px solid #3891f8;
78 | }
79 | .weui-cells__title{
80 | padding-left: 0px;
81 | color:#1e1e1e;
82 | }
83 | .weui-dialog__ft button{
84 | background: none;
85 | padding: 0px;
86 | margin: 0px;
87 | }
88 | form .weui-dialog__bd:first-child {
89 | padding:0px 30rpx 1.7em;
90 |
91 | }
92 | .page__ft{
93 | padding-top: 40px;
94 | padding-bottom: 10px;
95 | }
96 |
97 |
98 | .searchbar-result{
99 | border:none;
100 | margin-top: 0;
101 | font-size: 14px;
102 | }
103 | .searchbar-result:before{
104 | display: none;
105 | }
106 | /*.dels{
107 | background-image:
108 | }
109 | .edits{}*/
--------------------------------------------------------------------------------
/pages/index/index.js:
--------------------------------------------------------------------------------
1 | //index.js
2 | //获取应用实例
3 | const app = getApp()
4 |
5 | Page({
6 | data: {
7 | motto: 'Hello World',
8 | userInfo: {},
9 | hasUserInfo: false,
10 | canIUse: wx.canIUse('button.open-type.getUserInfo')
11 | },
12 | //事件处理函数
13 | bindViewTap: function() {
14 | wx.navigateTo({
15 | url: '../logs/logs'
16 | })
17 | },
18 | onLoad: function () {
19 | if (app.globalData.userInfo) {
20 | this.setData({
21 | userInfo: app.globalData.userInfo,
22 | hasUserInfo: true
23 | })
24 | } else if (this.data.canIUse){
25 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
26 | // 所以此处加入 callback 以防止这种情况
27 | app.userInfoReadyCallback = res => {
28 | this.setData({
29 | userInfo: res.userInfo,
30 | hasUserInfo: true
31 | })
32 | }
33 | } else {
34 | // 在没有 open-type=getUserInfo 版本的兼容处理
35 | wx.getUserInfo({
36 | success: res => {
37 | app.globalData.userInfo = res.userInfo
38 | this.setData({
39 | userInfo: res.userInfo,
40 | hasUserInfo: true
41 | })
42 | }
43 | })
44 | }
45 | },
46 | getUserInfo: function(e) {
47 | console.log(e)
48 | app.globalData.userInfo = e.detail.userInfo
49 | this.setData({
50 | userInfo: e.detail.userInfo,
51 | hasUserInfo: true
52 | })
53 | }
54 | })
55 |
--------------------------------------------------------------------------------
/pages/index/index.wxml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/pages/index/index.wxml
--------------------------------------------------------------------------------
/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 | .userinfo {
3 | display: flex;
4 | flex-direction: column;
5 | align-items: center;
6 | }
7 |
8 | .userinfo-avatar {
9 | width: 128rpx;
10 | height: 128rpx;
11 | margin: 20rpx;
12 | border-radius: 50%;
13 | }
14 |
15 | .userinfo-nickname {
16 | color: #aaa;
17 | }
18 |
19 | .usermotto {
20 | margin-top: 200px;
21 | }
--------------------------------------------------------------------------------
/pages/interface/addAddress/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../../utils/common.js");
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
9 | },
10 | formSubmit: function (event) {
11 | var latitude = event.detail.value.latitude;
12 | var longitude = event.detail.value.longitude;
13 |
14 | if(latitude == "" || longitude == ""){
15 | common.showTip("请填写完整","loading");
16 | return false;
17 | }
18 |
19 | var point = wx.Bmob.GeoPoint({ latitude: parseFloat(latitude), longitude: parseFloat(longitude) }) //创建地理位置对象
20 | var query = wx.Bmob.Query('address'); //数据库名
21 | query.set("address", point) //字段名
22 | query.save().then(res => {
23 | console.log(res)
24 | common.showTip("添加成功", "success");
25 | }).catch(err => {
26 | console.log(err)
27 | })
28 | }
29 | })
--------------------------------------------------------------------------------
/pages/interface/addAddress/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/interface/addAddress/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/pages/interface/addAddress/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/addAddress/index.wxss */
--------------------------------------------------------------------------------
/pages/interface/chatai/index.js:
--------------------------------------------------------------------------------
1 | var app = getApp()
2 | let ChatAi = {}
3 | var that = this
4 | // var messages = [] //setdata 数据总是没刷新,使用变量解决
5 | /**
6 | * 生成一条聊天室的消息的唯一 ID
7 | */
8 | function msgUuid() {
9 | if (!msgUuid.next) {
10 | msgUuid.next = 0
11 | }
12 | return 'msg-' + (++msgUuid.next)
13 | }
14 |
15 | /**
16 | * 生成聊天室的系统消息
17 | */
18 | function createSystemMessage(content) {
19 | return {
20 | id: msgUuid(),
21 | type: 'system',
22 | content
23 | }
24 | }
25 |
26 | /**
27 | * 生成聊天室的聊天消息
28 | */
29 | function createUserMessage(content, user, isMe) {
30 | return {
31 | id: msgUuid(),
32 | type: 'speak',
33 | content,
34 | user,
35 | isMe
36 | }
37 | }
38 |
39 | // 声明聊天室页面
40 | Page({
41 |
42 | /**
43 | * 聊天室使用到的数据,主要是消息集合以及当前输入框的文本
44 | */
45 | data: {
46 | ChatAi: {},
47 | messages: [],
48 | inputContent: 'Bmob后端云是什么?',
49 | // inputContent: 'hi',
50 | lastMessageId: 'none',
51 | msgObjectId: '',
52 | userData: {}, //用户信息
53 | objectId: ''
54 | },
55 |
56 | /**
57 | * 页面渲染完成后,启动聊天室
58 | * */
59 | onReady() {
60 |
61 |
62 | },
63 |
64 | onShareAppMessage: function () {
65 | var that = this
66 | return {
67 | title: 'Bmob AI 问答',
68 | path: 'pages/interface/chatroom/chatai',
69 | success: function (res) {
70 | // 转发成功
71 | console.log('成功', res)
72 |
73 | var currentUser = wx.Bmob.User.current()
74 | that.pushMessage(createSystemMessage('恭喜' + currentUser.get('nickName') + '把聊天室成功分享给他人...'))
75 | wx.getShareInfo({
76 | shareTicket: res.shareTickets,
77 | success(res) {
78 |
79 |
80 |
81 | }
82 | })
83 | },
84 | fail: function (res) {
85 | // 转发失败
86 | }
87 | }
88 | },
89 |
90 | /**
91 | * 后续后台切换回前台的时候,也要重新启动聊天室
92 | */
93 | onShow() {
94 | if (this.pageReady) {
95 | // this.enter()
96 | }
97 | },
98 | onLoad() {
99 | // this.messages = []
100 | let that = this
101 | wx.setNavigationBarTitle({
102 | title: 'Bmob AI 问答'
103 | })
104 |
105 | let userData = wx.Bmob.User.current()
106 | this.setData({
107 | userData: userData
108 | })
109 |
110 | var pageReady = app.globalData.pageReady
111 |
112 | this.pageReady = pageReady
113 |
114 |
115 | this.enter()
116 |
117 |
118 | // AI测试
119 | // 初始化AI链接
120 | this.ChatAi = wx.Bmob.ChatAI()
121 |
122 |
123 | // 返回消息处理
124 | let msg = ''
125 | let isStart = true
126 | this.ChatAi.onMessage((res) => {
127 | if (isStart) {
128 | isStart = false
129 | // that.pushMessage(createUserMessage("loading...", this.data.userData, false))
130 |
131 | }
132 | if (res == "done") {
133 |
134 | // 完成
135 | if (msg != "") {
136 | isStart = true
137 | console.log("done1", msg);
138 | } else {
139 |
140 | console.log("done", msg);
141 | }
142 |
143 | msg = '';
144 | } else {
145 | msg = msg + res
146 |
147 | that.amendMessage(createUserMessage(msg, this.data.userData, false))
148 | }
149 | })
150 |
151 | this.ChatAi.onClose((c) => {
152 | console.log("连接被关闭");
153 | this.ChatAi.connect()
154 | })
155 |
156 | console.log(this.ChatAi, "xx");
157 | },
158 |
159 | /**
160 | * 页面卸载时,退出聊天室
161 | */
162 | onUnload() {
163 | this.quit()
164 | },
165 |
166 | /**
167 | * 页面切换到后台运行时,退出聊天室
168 | */
169 | onHide() {
170 | this.quit()
171 | },
172 |
173 | /**
174 | * 启动聊天室
175 | */
176 | enter() {
177 | // 如果登录过,会记录当前用户openid
178 | var newOpenid = wx.getStorageSync('openid')
179 | if (!newOpenid) {
180 | this.pushMessage(createSystemMessage('您当前未登陆...'))
181 | } else {
182 | var currentUser = wx.Bmob.User.current()
183 | let userData = wx.Bmob.User.current()
184 | this.setData({
185 | objectId: userData.objectId
186 | })
187 | console.log(userData.objectId)
188 | // 加载默认数据
189 | loadDefault(this)
190 | this.connect()
191 | }
192 | },
193 |
194 | /**
195 | * 连接到聊天室信道服务
196 | */
197 | connect() {
198 |
199 | var that = this
200 |
201 | that.pushMessage(createSystemMessage('欢迎使用Bmob后端云...'))
202 |
203 | // 记录进入房间
204 | welcome(that)
205 |
206 |
207 | that.pushMessage(createSystemMessage('成功链接上AI...'))
208 |
209 |
210 |
211 |
212 |
213 | },
214 |
215 | /**
216 | * 退出聊天室
217 | */
218 | quit() {
219 | // 更新在线状态
220 | editRow(this)
221 |
222 |
223 | },
224 |
225 | /**
226 | * 通用更新当前消息集合的方法
227 | */
228 | updateMessages(updater) {
229 | var messages = this.data.messages
230 |
231 | updater(messages)
232 |
233 | this.setData({
234 | messages:messages
235 | })
236 | this.messages = messages
237 |
238 | // 需要先更新 messagess 数据后再设置滚动位置,否则不能生效
239 | var lastMessageId = messages.length ? messages[messages.length - 1].id : 'none'
240 | // console.log(lastMessageId)
241 | this.setData({
242 | lastMessageId
243 | })
244 | },
245 | updateMessages2(messages) {
246 | // var messages = this.data.messages
247 |
248 | // updater(messages)
249 |
250 | this.setData({
251 | messages:messages
252 | })
253 |
254 |
255 | // 需要先更新 messagess 数据后再设置滚动位置,否则不能生效
256 | var lastMessageId = messages.length ? messages[messages.length - 1].id : 'none'
257 | console.log(lastMessageId)
258 | this.setData({
259 | lastMessageId
260 | })
261 | },
262 |
263 | /**
264 | * 追加一条消息
265 | */
266 | pushMessage(message) {
267 | this.updateMessages(messages => messages.push(message))
268 | },
269 |
270 | /**
271 | * 替换上一条消息
272 | */
273 | amendMessage(message) {
274 | if(message.content==""){
275 | return
276 | }
277 | // console.log('amendMessage',messages);
278 | this.updateMessages(messages => messages.splice(-1, 1, message))
279 | // let messages = this.data.messages
280 | // let l = messages.length
281 | // // let m = messages.splice(-1, 1, message)
282 | // console.log(666,l,messages,message);
283 | // messages[l-1] = message
284 | // this.updateMessages2(messages)
285 | },
286 |
287 | /**
288 | * 删除上一条消息
289 | */
290 | popMessage() {
291 | this.updateMessages(messages => messages.pop())
292 | },
293 |
294 | /**
295 | * 用户输入的内容改变之后
296 | */
297 | changeInputContent(e) {
298 | this.setData({
299 | inputContent: e.detail.value
300 | })
301 | },
302 |
303 | /**
304 | * 点击「发送」按钮,通过信道推送消息到服务器
305 | **/
306 | sendMessage(e) {
307 |
308 | var that = this
309 |
310 |
311 | var content = this.data.inputContent
312 | if (!content) {
313 | return false
314 | }
315 |
316 | console.log(content, e);
317 |
318 |
319 | let userData = wx.Bmob.User.current()
320 | var objectId = userData.objectId
321 |
322 | if (objectId == "") {
323 | this.pushMessage(createSystemMessage('您还没有连接上服务器,请稍后重试'))
324 |
325 | return
326 | }
327 |
328 | let datas = {
329 | "messages": [{
330 | "content": content,
331 | "role": "user"
332 | }],
333 | "session": objectId
334 | }
335 | console.log(this.ChatAi);
336 | this.ChatAi.send(JSON.stringify(datas))
337 |
338 | that.pushMessage(createUserMessage(content, userData, true))
339 | that.pushMessage(createUserMessage("loading...", userData, false))
340 | },
341 | })
342 |
343 |
344 | // 记录用户加入聊天
345 | function welcome(that) {
346 |
347 | var currentUser = wx.Bmob.User.current()
348 | let userData = wx.Bmob.User.current()
349 | var pointer = wx.Bmob.Pointer('_User')
350 |
351 | var objectId = that.data.objectId
352 | console.log(objectId)
353 | var poiID = pointer.set(objectId)
354 |
355 |
356 | // 添加一条记录
357 | var diary = wx.Bmob.Query('welcome')
358 |
359 | diary.set('own', poiID)
360 | diary.set('online', 0)
361 | diary.set('nickName', userData.nickName)
362 | // 添加数据,第一个入口参数是null
363 | diary.save().then(result => {
364 | // 添加成功,返回成功之后的objectId(注意:返回的属性名字是id,不是objectId),你还可以在Bmob的Web管理后台看到对应的数据
365 | console.log('日记创建成功, objectId:' + result.objectId)
366 | that.setData({
367 | msgObjectId: result.objectId
368 | })
369 | }).catch(error => {
370 | // 添加失败
371 | console.log('创建日记失败')
372 |
373 | })
374 |
375 | }
376 |
377 | function editRow(that) {
378 | var objectId = that.data.msgObjectId
379 | console.log(objectId)
380 | var query = wx.Bmob.Query('welcome')
381 | // 这个 id 是要修改条目的 id,你在生成这个存储并成功时可以获取到,请看前面的文档
382 | query.get(objectId).then(result => {
383 | // 回调中可以取得这个 diary 对象的一个实例,然后就可以修改它了
384 | result.set('online', 1)
385 | result.save()
386 | // The object was retrieved successfully.
387 | }).catch(error => {
388 |
389 | })
390 | }
391 |
392 |
393 | function loadDefault(t) {
394 |
395 | var that = t
396 | // 进入聊天室先加载之前最后3条聊天记录
397 | const query = wx.Bmob.Query('ai_log')
398 | query.equalTo("session","==",that.data.userData.objectId)
399 | query.order('-createdAt')
400 | query.limit(5)
401 | // 查询所有数据
402 | query.find().then(results => {
403 | console.log('共查询到 ' + results.length + ' 条记录')
404 | // 循环处理查询到的数据
405 | for (var i = results.length - 1; i >= 0; i--) {
406 | var object = results[i]
407 | console.log(results + ' - ' + object.objectId, object.messages, JSON.stringify(object))
408 | let isMe = object.role === 'assistant' ? false : true;
409 | that.pushMessage(createUserMessage(object.messages, object, isMe))
410 | }
411 | }).catch(error => {
412 | console.log('查询失败: ' + error.code + ' ' + error.message)
413 | })
414 | }
--------------------------------------------------------------------------------
/pages/interface/chatai/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob聊天室"
3 | }
--------------------------------------------------------------------------------
/pages/interface/chatai/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | {{message.user.nickName}}
10 | {{message.content}}
11 |
12 |
13 |
14 | {{message.content}}
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/pages/interface/chatai/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/chatroom/chatroom.wxss */
2 | button {
3 | margin-top:0rpx;
4 | margin-bottom:0rpx;
5 |
6 | }
7 |
8 | .page-wrap {
9 | display: flex;
10 | flex-direction: column;
11 | background: #ebebeb;
12 | position: absolute;
13 | top: 0;
14 | bottom: 0;
15 | left: 0;
16 | right: 0;
17 | overflow: hidden;
18 | }
19 | .chat-container {
20 | flex: 1;
21 | text-align: center;
22 | overflow-y:auto;
23 | }
24 | .system-message {
25 | font-size: 14px;
26 | line-height: 14px;
27 | color: #fff;
28 | background: #cecece;
29 | border-radius: 4px;
30 | display: inline-block;
31 | padding: 8rpx 15rpx;
32 | margin: 30rpx 0 10rpx;
33 |
34 | }
35 | .user-message {
36 | margin: 38rpx 20rpx 0;
37 | text-align: left;
38 | font-size: 0;
39 | display: flex
40 | }
41 | .user-message.me {
42 | flex-direction: row-reverse;
43 | }
44 | .avatar {
45 | width: 84rpx;
46 | height: 84rpx;
47 | border: #a5a5a7 1rpx solid;
48 | display: inline-block;
49 | vertical-align: top;
50 | }
51 | .text {
52 | display: inline-block;
53 | vertical-align: top;
54 | }
55 | .user-message.other .text {
56 | margin-left: 19rpx;
57 | }
58 | .user-message.me .text {
59 | margin-right: 19rpx;
60 | }
61 | .text .nickname {
62 | color: #737373;
63 | font-size: 14px;
64 | margin-bottom: 6rpx;
65 | }
66 | .text .content {
67 | border: #ccc 1rpx solid;
68 | border-radius: 4px;
69 | background: #fff;
70 | font-size: 36rpx;
71 | line-height: 36rpx;
72 | padding: 20rpx;
73 | position: relative;
74 | }
75 | .user-message.me .text .content {
76 | background: #a0e75b;
77 | border: #70b44d 1rpx solid;
78 | }
79 | .text .content::after,.text .content::before {
80 | font-size: 0;
81 | position: absolute;
82 | width: 0;
83 | height: 0;
84 | content: '';
85 | border: 13rpx dashed transparent;
86 | }
87 |
88 | .user-message.other .text .content::after,.user-message.other .text .content::before {
89 | right: 100%;
90 | border-right-style: solid;
91 | }
92 | .user-message.other .text .content::before {
93 | top: 18rpx;
94 | border-right-color: #ccc;
95 | }
96 | .user-message.other .text .content::after {
97 | border: 12rpx solid transparent;
98 | top: 19rpx;
99 | border-right-color: #fff;
100 | }
101 |
102 | .user-message.me .text .content::after,.user-message.me .text .content::before {
103 | left: 100%;
104 | border-left-style: solid;
105 | }
106 |
107 | .user-message.me .text .content::before {
108 | top: 18rpx;
109 | border-left-color: #70b44d;
110 | }
111 | .user-message.me .text .content::after {
112 | border: 12rpx solid transparent;
113 | top: 19rpx;
114 | border-left-color: #a0e75b;
115 | }
116 | .text .content.img {
117 | border: #ccc 1rpx solid;
118 | border-radius: 4px;
119 | background: #fff;
120 | font-size: 30rpx;
121 | line-height: normal;
122 | padding: 10rpx;
123 | position: relative;
124 | text-align: center;
125 | max-width: 560rpx;
126 | }
127 | .text .content.img image {
128 | max-width: 100%;
129 | }
130 |
131 | .input-panel {
132 | height: 100rpx;
133 | box-sizing: border-box;
134 | padding: 13rpx 20rpx 0;
135 | background: #f5f5f7;
136 | border-top:#d7d7d9 1rpx solid;
137 | box-sizing: border-box;
138 | display: flex;
139 | }
140 | .pic-icon {
141 | width: 60rpx;
142 | height: 44rpx;
143 | margin: 15rpx 20rpx 0 0;
144 | background:url(http://imgcache.qq.com/open_proj/proj_qcloud_v2/wechat_mc/pic/send.svg);
145 | display: none;
146 | }
147 | .send-input {
148 | flex: 1;
149 | height: 72rpx;
150 | background: #fff;
151 | border:#ddd 1rpx solid;
152 | border-radius: 3px;
153 | margin-right: 20rpx;
154 | box-sizing: border-box;
155 |
156 | padding: 0 10rpx;
157 | }
158 | .send-btn {
159 | width: 160rpx;
160 | height: 72rpx;
161 | line-height: 72rpx;
162 | background-color: #3891f8;
163 | font-size: 28rpx;
164 | color:#fff;
165 | }
166 | .me .nickname {
167 | display: none;
168 | }
169 |
170 | @media (max-width : 360px) {
171 | .avatar {
172 | width: 100rpx;
173 | height: 100rpx;
174 | }
175 | .text .content {
176 | border: #ccc 1rpx solid;
177 | border-radius: 4px;
178 | background: #fff;
179 | font-size: 42rpx;
180 | line-height: 44rpx;
181 | padding: 20rpx;
182 | position: relative;
183 | }
184 | .user-message.other .text .content::before {
185 | top: 22rpx;
186 | border-right-color: #ccc;
187 | }
188 | .user-message.other .text .content::after {
189 | border: 14rpx solid transparent;
190 | top: 23rpx;
191 | border-right-color: #fff;
192 | }
193 |
194 | .user-message.me .text .content::after,.user-message.me .text .content::before {
195 | left: 100%;
196 | border-left-style: solid;
197 | }
198 |
199 | .user-message.me .text .content::before {
200 | top: 22rpx;
201 | border-left-color: #70b44d;
202 | }
203 | .user-message.me .text .content::after {
204 | border: 14rpx solid transparent;
205 | top: 23rpx;
206 | border-left-color: #a0e75b;
207 | }
208 |
209 | .input-panel {
210 | height: 120rpx;
211 | box-sizing: border-box;
212 | padding: 13rpx 20rpx 0;
213 | background: #f5f5f7;
214 | border-top:#d7d7d9 1rpx solid;
215 | box-sizing: border-box;
216 | display: flex;
217 | }
218 | .pic-icon {
219 | display: none;
220 | width: 60rpx;
221 | height: 44rpx;
222 | margin: 25rpx 20rpx 0 0;
223 | background:url(http://imgcache.qq.com/open_proj/proj_qcloud_v2/wechat_mc/pic/send.svg);
224 | }
225 | .send-input {
226 | flex: 1;
227 | height: 92rpx;
228 | background: #fff;
229 | border:#ddd 1rpx solid;
230 | border-radius: 3px;
231 | margin-right: 20rpx;
232 | box-sizing: border-box;
233 | padding: 0 10rpx;
234 | }
235 | .send-btn {
236 | width: 180rpx;
237 | height: 92rpx;
238 | line-height: 92rpx;
239 | background-color: #a0e75a;
240 | font-size: 36rpx;
241 | }
242 | }
--------------------------------------------------------------------------------
/pages/interface/chatroom/index.js:
--------------------------------------------------------------------------------
1 | // 简单的小程序 WebSocket 信道封装
2 | var that = this
3 |
4 | var app = getApp()
5 |
6 | /**
7 | * 生成一条聊天室的消息的唯一 ID
8 | */
9 | function msgUuid () {
10 | if (!msgUuid.next) {
11 | msgUuid.next = 0
12 | }
13 | return 'msg-' + (++msgUuid.next)
14 | }
15 |
16 | /**
17 | * 生成聊天室的系统消息
18 | */
19 | function createSystemMessage (content) {
20 | return { id: msgUuid(), type: 'system', content }
21 | }
22 |
23 | /**
24 | * 生成聊天室的聊天消息
25 | */
26 | function createUserMessage (content, user, isMe) {
27 | return { id: msgUuid(), type: 'speak', content, user, isMe }
28 | }
29 |
30 | // 声明聊天室页面
31 | Page({
32 |
33 | /**
34 | * 聊天室使用到的数据,主要是消息集合以及当前输入框的文本
35 | */
36 | data: {
37 | messages: [],
38 | inputContent: '欢迎见到大家',
39 | lastMessageId: 'none',
40 | msgObjectId: '',
41 | objectId: ''
42 | },
43 |
44 | /**
45 | * 页面渲染完成后,启动聊天室
46 | * */
47 | onReady () {
48 |
49 | wx.setNavigationBarTitle({ title: 'Bmob聊天室' })
50 |
51 | var pageReady = app.globalData.pageReady
52 |
53 | this.pageReady = pageReady
54 |
55 |
56 | this.enter()
57 | // 开始连接Socket
58 |
59 |
60 | },
61 |
62 | onShareAppMessage: function () {
63 | var that = this
64 | return {
65 | title: 'Bmob 聊天室',
66 | path: 'pages/interface/chatroom/chatroom',
67 | success: function (res) {
68 | // 转发成功
69 | console.log('成功', res)
70 |
71 | var currentUser = wx.Bmob.User.current()
72 | that.pushMessage(createSystemMessage('恭喜' + currentUser.get('nickName') + '把聊天室成功分享给他人...'))
73 | wx.getShareInfo({
74 | shareTicket: res.shareTickets,
75 | success (res) {
76 |
77 |
78 |
79 | }
80 | })
81 | },
82 | fail: function (res) {
83 | // 转发失败
84 | }
85 | }
86 | },
87 |
88 | /**
89 | * 后续后台切换回前台的时候,也要重新启动聊天室
90 | */
91 | onShow () {
92 | if (this.pageReady) {
93 | // this.enter()
94 | }
95 | },
96 | onLoad () {
97 | var that = this
98 | },
99 |
100 | /**
101 | * 页面卸载时,退出聊天室
102 | */
103 | onUnload () {
104 | this.quit()
105 | },
106 |
107 | /**
108 | * 页面切换到后台运行时,退出聊天室
109 | */
110 | onHide () {
111 | this.quit()
112 | },
113 |
114 | /**
115 | * 启动聊天室
116 | */
117 | enter () {
118 |
119 |
120 | // 如果登录过,会记录当前用户openid
121 | var newOpenid = wx.getStorageSync('openid')
122 | if (!newOpenid) {
123 | this.pushMessage(createSystemMessage('您当前未登陆...'))
124 | } else {
125 | var currentUser = wx.Bmob.User.current()
126 | let userData = wx.Bmob.User.current()
127 | this.setData({ objectId: userData.objectId })
128 | console.log(userData.objectId)
129 | // 加载默认数据
130 | loadDefault(this)
131 | this.connect()
132 | }
133 | },
134 |
135 | /**
136 | * 连接到聊天室信道服务
137 | */
138 | connect () {
139 |
140 | var that = this
141 |
142 | that.pushMessage(createSystemMessage('欢迎加入群聊...'))
143 |
144 | // 记录进入房间
145 | welcome(that)
146 | const BmobSocketIo = new wx.Bmob.Socket()
147 | // 初始连接socket.io服务器后,需要监听的事件都写在这个函数内
148 | BmobSocketIo.onInitListen = function () {
149 | console.log('kkk')
150 | // 订阅GameScore表的数据更新事件
151 | BmobSocketIo.updateTable('Chat') // 聊天记录表
152 | BmobSocketIo.updateTable('welcome')// 欢迎进入表
153 | that.tunnel = true
154 | that.pushMessage(createSystemMessage('成功加入群聊...'))
155 |
156 | }
157 |
158 | // 监听服务器返回的更新表的数据
159 | BmobSocketIo.onUpdateTable = function (tablename, data) {
160 |
161 | if (tablename == 'Chat') {
162 | that.pushMessage(createUserMessage(data.content, data, data.own === that.data.objectId))
163 | }
164 |
165 | if (tablename == 'welcome') {
166 | if (data.online != 1) {
167 | that.pushMessage(createSystemMessage(`${data.nickName}已加入群聊。`))
168 | } else {
169 | that.pushMessage(createSystemMessage(`${data.nickName}已退出群聊。`))
170 | }
171 | }
172 | }
173 |
174 |
175 | if (!this.pageReady) {
176 | // BmobSocketIo.init()
177 | app.globalData.pageReady = true
178 | } else {
179 | // 第二次进来
180 | that.tunnel = true
181 | }
182 |
183 |
184 | },
185 |
186 | /**
187 | * 退出聊天室
188 | */
189 | quit () {
190 | // 更新在线状态
191 | editRow(this)
192 |
193 |
194 | // BmobSocketIo.unsubUpdateTable('Chat') //
195 | // BmobSocketIo.unsubUpdateTable('welcome')//
196 |
197 | // 退出聊天室
198 | // BmobSocketIo.obj.socket.disconnect()
199 |
200 | // BmobSocketIo.obj.socket.reconnect()
201 | },
202 |
203 | /**
204 | * 通用更新当前消息集合的方法
205 | */
206 | updateMessages (updater) {
207 | var messages = this.data.messages
208 | updater(messages)
209 |
210 | this.setData({ messages })
211 |
212 | // 需要先更新 messagess 数据后再设置滚动位置,否则不能生效
213 | var lastMessageId = messages.length ? messages[messages.length - 1].id : 'none'
214 | console.log(lastMessageId)
215 | this.setData({ lastMessageId })
216 | },
217 |
218 | /**
219 | * 追加一条消息
220 | */
221 | pushMessage (message) {
222 | this.updateMessages(messages => messages.push(message))
223 | },
224 |
225 | /**
226 | * 替换上一条消息
227 | */
228 | amendMessage (message) {
229 | this.updateMessages(messages => messages.splice(-1, 1, message))
230 | },
231 |
232 | /**
233 | * 删除上一条消息
234 | */
235 | popMessage () {
236 | this.updateMessages(messages => messages.pop())
237 | },
238 |
239 | /**
240 | * 用户输入的内容改变之后
241 | */
242 | changeInputContent (e) {
243 | this.setData({ inputContent: e.detail.value })
244 | },
245 |
246 | /**
247 | * 点击「发送」按钮,通过信道推送消息到服务器
248 | **/
249 | sendMessage (e) {
250 | // 信道当前不可用
251 | if (!this.tunnel) {
252 | this.pushMessage(createSystemMessage('您还没有加入群聊,请稍后重试'))
253 |
254 | return
255 | }
256 |
257 | var that = this
258 |
259 |
260 | var content = this.data.inputContent
261 | if (!content) {
262 | return false
263 | }
264 |
265 | var currentUser = wx.Bmob.User.current()
266 | let userData = wx.Bmob.User.current()
267 | var pointer = wx.Bmob.Pointer('_User')
268 | var objectId = userData.objectId
269 |
270 | // 添加一条记录
271 | var diary = wx.Bmob.Query('Chat')
272 | var poiID = pointer.set(objectId)
273 | diary.set('own', poiID)
274 |
275 | // 写入用户信息方便判断谁发送的消息
276 | diary.set('nickName', userData.nickName)
277 | diary.set('avatarUrl', userData.userPic)
278 |
279 |
280 |
281 | diary.set('content', content)
282 | // 添加数据,第一个入口参数是null
283 | diary.save().then(result => {
284 | console.log('日记创建成功, objectId:' + result.objectId)
285 | that.setData({ inputContent: '' })
286 | }).catch(err => {
287 | // 添加失败
288 | console.log('创建日记失败')
289 |
290 | })
291 | },
292 | })
293 |
294 |
295 | // 记录用户加入聊天
296 | function welcome (that) {
297 |
298 | var currentUser = wx.Bmob.User.current()
299 | let userData = wx.Bmob.User.current()
300 | var pointer = wx.Bmob.Pointer('_User')
301 |
302 | var objectId = that.data.objectId
303 | console.log(objectId)
304 | var poiID = pointer.set(objectId)
305 |
306 |
307 | // 添加一条记录
308 | var diary = wx.Bmob.Query('welcome')
309 |
310 | diary.set('own', poiID)
311 | diary.set('online', 0)
312 | diary.set('nickName', userData.nickName)
313 | // 添加数据,第一个入口参数是null
314 | diary.save().then(result => {
315 | // 添加成功,返回成功之后的objectId(注意:返回的属性名字是id,不是objectId),你还可以在Bmob的Web管理后台看到对应的数据
316 | console.log('日记创建成功, objectId:' + result.objectId)
317 | that.setData({ msgObjectId: result.objectId })
318 | }).catch(error => {
319 | // 添加失败
320 | console.log('创建日记失败')
321 |
322 | })
323 |
324 | }
325 |
326 | function editRow (that) {
327 | var objectId = that.data.msgObjectId
328 | console.log(objectId)
329 | var query = wx.Bmob.Query('welcome')
330 | // 这个 id 是要修改条目的 id,你在生成这个存储并成功时可以获取到,请看前面的文档
331 | query.get(objectId).then(result => {
332 | // 回调中可以取得这个 diary 对象的一个实例,然后就可以修改它了
333 | result.set('online', 1)
334 | result.save()
335 | // The object was retrieved successfully.
336 | }).catch(error => {
337 |
338 | })
339 | }
340 |
341 |
342 | function loadDefault (t) {
343 |
344 | var that = t
345 | // 进入聊天室先加载之前最后3条聊天记录
346 | const query = wx.Bmob.Query('Chat')
347 | query.order('-createdAt')
348 | query.limit(3)
349 | // 查询所有数据
350 | query.find().then(results => {
351 | console.log('共查询到 ' + results.length + ' 条记录')
352 | // 循环处理查询到的数据
353 | for (var i = results.length - 1; i >= 0; i--) {
354 | var object = results[i]
355 | console.log(results + ' - ' + object.own.objectId)
356 | that.pushMessage(createUserMessage(object.content, object, object.own.objectId === that.data.objectId))
357 | }
358 | }).catch(error => {
359 | console.log('查询失败: ' + error.code + ' ' + error.message)
360 | })
361 | }
--------------------------------------------------------------------------------
/pages/interface/chatroom/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob聊天室"
3 | }
--------------------------------------------------------------------------------
/pages/interface/chatroom/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | {{message.user.nickName}}
10 | {{message.content}}
11 |
12 |
13 |
14 | {{message.content}}
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/pages/interface/chatroom/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/chatroom/chatroom.wxss */
2 | button {
3 | margin-top:0rpx;
4 | margin-bottom:0rpx;
5 |
6 | }
7 |
8 | .page-wrap {
9 | display: flex;
10 | flex-direction: column;
11 | background: #ebebeb;
12 | position: absolute;
13 | top: 0;
14 | bottom: 0;
15 | left: 0;
16 | right: 0;
17 | overflow: hidden;
18 | }
19 | .chat-container {
20 | flex: 1;
21 | text-align: center;
22 | overflow-y:auto;
23 | }
24 | .system-message {
25 | font-size: 14px;
26 | line-height: 14px;
27 | color: #fff;
28 | background: #cecece;
29 | border-radius: 4px;
30 | display: inline-block;
31 | padding: 8rpx 15rpx;
32 | margin: 30rpx 0 10rpx;
33 |
34 | }
35 | .user-message {
36 | margin: 38rpx 20rpx 0;
37 | text-align: left;
38 | font-size: 0;
39 | display: flex
40 | }
41 | .user-message.me {
42 | flex-direction: row-reverse;
43 | }
44 | .avatar {
45 | width: 84rpx;
46 | height: 84rpx;
47 | border: #a5a5a7 1rpx solid;
48 | display: inline-block;
49 | vertical-align: top;
50 | }
51 | .text {
52 | display: inline-block;
53 | vertical-align: top;
54 | }
55 | .user-message.other .text {
56 | margin-left: 19rpx;
57 | }
58 | .user-message.me .text {
59 | margin-right: 19rpx;
60 | }
61 | .text .nickname {
62 | color: #737373;
63 | font-size: 14px;
64 | margin-bottom: 6rpx;
65 | }
66 | .text .content {
67 | border: #ccc 1rpx solid;
68 | border-radius: 4px;
69 | background: #fff;
70 | font-size: 36rpx;
71 | line-height: 36rpx;
72 | padding: 20rpx;
73 | position: relative;
74 | }
75 | .user-message.me .text .content {
76 | background: #a0e75b;
77 | border: #70b44d 1rpx solid;
78 | }
79 | .text .content::after,.text .content::before {
80 | font-size: 0;
81 | position: absolute;
82 | width: 0;
83 | height: 0;
84 | content: '';
85 | border: 13rpx dashed transparent;
86 | }
87 |
88 | .user-message.other .text .content::after,.user-message.other .text .content::before {
89 | right: 100%;
90 | border-right-style: solid;
91 | }
92 | .user-message.other .text .content::before {
93 | top: 18rpx;
94 | border-right-color: #ccc;
95 | }
96 | .user-message.other .text .content::after {
97 | border: 12rpx solid transparent;
98 | top: 19rpx;
99 | border-right-color: #fff;
100 | }
101 |
102 | .user-message.me .text .content::after,.user-message.me .text .content::before {
103 | left: 100%;
104 | border-left-style: solid;
105 | }
106 |
107 | .user-message.me .text .content::before {
108 | top: 18rpx;
109 | border-left-color: #70b44d;
110 | }
111 | .user-message.me .text .content::after {
112 | border: 12rpx solid transparent;
113 | top: 19rpx;
114 | border-left-color: #a0e75b;
115 | }
116 | .text .content.img {
117 | border: #ccc 1rpx solid;
118 | border-radius: 4px;
119 | background: #fff;
120 | font-size: 30rpx;
121 | line-height: normal;
122 | padding: 10rpx;
123 | position: relative;
124 | text-align: center;
125 | max-width: 560rpx;
126 | }
127 | .text .content.img image {
128 | max-width: 100%;
129 | }
130 |
131 | .input-panel {
132 | height: 100rpx;
133 | box-sizing: border-box;
134 | padding: 13rpx 20rpx 0;
135 | background: #f5f5f7;
136 | border-top:#d7d7d9 1rpx solid;
137 | box-sizing: border-box;
138 | display: flex;
139 | }
140 | .pic-icon {
141 | width: 60rpx;
142 | height: 44rpx;
143 | margin: 15rpx 20rpx 0 0;
144 | background:url(http://imgcache.qq.com/open_proj/proj_qcloud_v2/wechat_mc/pic/send.svg);
145 | display: none;
146 | }
147 | .send-input {
148 | flex: 1;
149 | height: 72rpx;
150 | background: #fff;
151 | border:#ddd 1rpx solid;
152 | border-radius: 3px;
153 | margin-right: 20rpx;
154 | box-sizing: border-box;
155 |
156 | padding: 0 10rpx;
157 | }
158 | .send-btn {
159 | width: 160rpx;
160 | height: 72rpx;
161 | line-height: 72rpx;
162 | background-color: #3891f8;
163 | font-size: 28rpx;
164 | color:#fff;
165 | }
166 | .me .nickname {
167 | display: none;
168 | }
169 |
170 | @media (max-width : 360px) {
171 | .avatar {
172 | width: 100rpx;
173 | height: 100rpx;
174 | }
175 | .text .content {
176 | border: #ccc 1rpx solid;
177 | border-radius: 4px;
178 | background: #fff;
179 | font-size: 42rpx;
180 | line-height: 44rpx;
181 | padding: 20rpx;
182 | position: relative;
183 | }
184 | .user-message.other .text .content::before {
185 | top: 22rpx;
186 | border-right-color: #ccc;
187 | }
188 | .user-message.other .text .content::after {
189 | border: 14rpx solid transparent;
190 | top: 23rpx;
191 | border-right-color: #fff;
192 | }
193 |
194 | .user-message.me .text .content::after,.user-message.me .text .content::before {
195 | left: 100%;
196 | border-left-style: solid;
197 | }
198 |
199 | .user-message.me .text .content::before {
200 | top: 22rpx;
201 | border-left-color: #70b44d;
202 | }
203 | .user-message.me .text .content::after {
204 | border: 14rpx solid transparent;
205 | top: 23rpx;
206 | border-left-color: #a0e75b;
207 | }
208 |
209 | .input-panel {
210 | height: 120rpx;
211 | box-sizing: border-box;
212 | padding: 13rpx 20rpx 0;
213 | background: #f5f5f7;
214 | border-top:#d7d7d9 1rpx solid;
215 | box-sizing: border-box;
216 | display: flex;
217 | }
218 | .pic-icon {
219 | display: none;
220 | width: 60rpx;
221 | height: 44rpx;
222 | margin: 25rpx 20rpx 0 0;
223 | background:url(http://imgcache.qq.com/open_proj/proj_qcloud_v2/wechat_mc/pic/send.svg);
224 | }
225 | .send-input {
226 | flex: 1;
227 | height: 92rpx;
228 | background: #fff;
229 | border:#ddd 1rpx solid;
230 | border-radius: 3px;
231 | margin-right: 20rpx;
232 | box-sizing: border-box;
233 | padding: 0 10rpx;
234 | }
235 | .send-btn {
236 | width: 180rpx;
237 | height: 92rpx;
238 | line-height: 92rpx;
239 | background-color: #a0e75a;
240 | font-size: 36rpx;
241 | }
242 | }
--------------------------------------------------------------------------------
/pages/interface/checkContent/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../../utils/common.js");
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
9 | },
10 | uploadCheck:function(){
11 | var that =this
12 | that.setData({
13 | loading: true
14 | })
15 | // 2.0图片检测
16 | wx.chooseImage({
17 | count:9,
18 | sizeType: ['compressed'], //original 原图,compressed 压缩图,默认二者都有
19 | success: function(res) {
20 | let userData = wx.Bmob.User.current()
21 | var open_Id = userData.openid;
22 | wx.showNavigationBarLoading()
23 | that.setData({
24 | loading:false
25 | })
26 | var urlArr = new Array();
27 | var tempFilePaths = res.tempFilePaths;
28 | var imgLength = tempFilePaths.length;
29 | if(imgLength > 0){
30 | var file;
31 | for (var i = 0; i < imgLength; i++){
32 | var tempFilePath = tempFilePaths[i];
33 | var timestamp = Date.parse(new Date());
34 | var extension = /\.([^.]*)$/.exec(tempFilePath);
35 | extension = extension[1].toLowerCase();
36 | var name = timestamp + "." +extension;
37 | var file = wx.Bmob.File(name, tempFilePath);
38 |
39 | }
40 | file.save().then(res => {
41 | that.setData({
42 | loading: false
43 | })
44 | console.log(res,99)
45 |
46 | for (const key in res) {
47 |
48 | const element = res[key];
49 | console.log(element,'element');
50 | let params = {
51 | media_url:element.url,
52 | media_type:2, //1:音频;2:图片
53 | openid:open_Id, //用户的openid(用户需在近两小时访问过小程序)
54 | scene:1,
55 | version:2
56 | }
57 | wx.Bmob.mediaCheckAsync(params).then(res=>{
58 | console.log('hh',res);
59 | })
60 | }
61 |
62 |
63 | wx.hideNavigationBarLoading();
64 | common.showTip("上传成功", "success");
65 | })
66 |
67 | }else{
68 | common.showTip("请选择图片","loading");
69 | }
70 | },
71 | })
72 | },
73 | upload:function(){
74 | wx.chooseImage({
75 | success: function (res) {
76 | console.log(res)
77 | var tempFilePaths = res.tempFilePaths
78 | var file;
79 | for (let item of tempFilePaths) {
80 | console.log('itemn',item)
81 | file = wx.Bmob.File('abc.jpg', item);
82 | }
83 | file.imgSecCheck().then(res => {
84 | console.log("legth",res.length);
85 | console.log(res);
86 | }).catch(err=>{
87 | console.log(err);
88 | })
89 |
90 | }
91 | })
92 | },
93 | formSubmit: function (e) {
94 | let content = e.detail.value.content;
95 | if (content == "") {
96 | common.showTip("请输入内容", "loading");
97 | return false;
98 | }
99 | // wx.Bmob.checkMsg(content).then(res => {
100 | // common.showTip(res.msg,"success");
101 | // }).catch(err => {
102 | // console.log(err);
103 | // });
104 | wx.Bmob.User.auth("openid").then(res=>{
105 | console.log(res);
106 | })
107 |
108 | let userData = wx.Bmob.User.current()
109 | var open_Id = userData.openid;
110 | let data = {
111 | openid: open_Id,
112 | scene: 2,
113 | content:content
114 | }
115 | wx.Bmob.checkMsg2(data).then(res => {
116 | console.log(res);
117 | common.showTip(res.errmsg,"success");
118 | }).catch(err => {
119 | console.log(err);
120 | });
121 | }
122 | })
--------------------------------------------------------------------------------
/pages/interface/checkContent/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob检测违规内容"
3 | }
--------------------------------------------------------------------------------
/pages/interface/checkContent/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 此接口需要用户在Bmob控制台授权小程序才可检测
4 |
--------------------------------------------------------------------------------
/pages/interface/checkContent/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/checkContent/index.wxss */
--------------------------------------------------------------------------------
/pages/interface/code/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../../utils/common.js");
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | "imageBytes": ""
9 | },
10 | noneWindows: function () {
11 | this.setData({
12 | imageBytes: ""
13 | })
14 | },
15 | formSubmit: function (event) {
16 | var path = event.detail.value.path;
17 | var width = event.detail.value.width;
18 | var that = this;
19 | if(path == ""){
20 | common.showTip("请输入路径","loading");
21 | return false;
22 | }
23 | let qrData = { path: path, width: width, type: 1 };
24 | wx.Bmob.generateCode(qrData).then(function (res) {
25 | console.log(res);
26 | that.setData({
27 | imageBytes: res.url
28 | })
29 | }).catch(function (err) {
30 | console.log(err);
31 | });
32 | }
33 |
34 |
35 | })
--------------------------------------------------------------------------------
/pages/interface/code/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/interface/code/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | 知道了
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/pages/interface/code/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/user/code/index.wxss */
--------------------------------------------------------------------------------
/pages/interface/decryption.js:
--------------------------------------------------------------------------------
1 | // pages/interface/decryption.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
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 |
30 | },
31 |
32 | /**
33 | * 生命周期函数--监听页面隐藏
34 | */
35 | onHide: function () {
36 |
37 | },
38 |
39 | /**
40 | * 生命周期函数--监听页面卸载
41 | */
42 | onUnload: function () {
43 |
44 | },
45 |
46 | /**
47 | * 页面相关事件处理函数--监听用户下拉动作
48 | */
49 | onPullDownRefresh: function () {
50 |
51 | },
52 |
53 | /**
54 | * 页面上拉触底事件的处理函数
55 | */
56 | onReachBottom: function () {
57 |
58 | },
59 |
60 | /**
61 | * 用户点击右上角分享
62 | */
63 | onShareAppMessage: function () {
64 |
65 | }
66 | })
--------------------------------------------------------------------------------
/pages/interface/decryption.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/interface/decryption.wxml:
--------------------------------------------------------------------------------
1 |
2 | pages/interface/decryption.wxml
3 |
--------------------------------------------------------------------------------
/pages/interface/decryption.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/decryption.wxss */
--------------------------------------------------------------------------------
/pages/interface/decryption/index.js:
--------------------------------------------------------------------------------
1 | // pages/interface/decryption/index.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
9 | },
10 |
11 | /**
12 | * 生命周期函数--监听页面加载
13 | */
14 | onLoad: function (options) {
15 | wx.Bmob.functions('getPhone').then(res => {
16 | console.log(res, res.result, 333);
17 | })
18 | wx.request({
19 | url: 'http://cloud.bmob.cn/4109ef68482912cb/getPhone',
20 | success: res => {
21 | console.log(res, 777)
22 | }
23 | })
24 | },
25 | weRun: function (e) {
26 | console.log(e)
27 |
28 |
29 |
30 | wx.getWeRunData({
31 | success(res) {
32 | wx.Bmob.User.decryption(res).then(res => {
33 | console.log(res)
34 | })
35 | }
36 | })
37 | },
38 | getPhoneNumber: function (res) {
39 | wx.Bmob.User.decryption(res).then(res => {
40 | console.log(res, 444)
41 | })
42 | // 解密后云函数返回数据格式如下
43 | // { "phoneNumber":"137xxxx6579", "purePhoneNumber":"137xxxx6579", "countryCode":"86", "watermark":{ "timestamp":1516762168, "appid":"wx094ede192e7efff" } }
44 | },
45 |
46 | /**
47 | * 生命周期函数--监听页面初次渲染完成
48 | */
49 | onReady: function () {
50 |
51 | },
52 |
53 | /**
54 | * 生命周期函数--监听页面显示
55 | */
56 | onShow: function () {
57 |
58 | },
59 |
60 | /**
61 | * 生命周期函数--监听页面隐藏
62 | */
63 | onHide: function () {
64 |
65 | },
66 |
67 | /**
68 | * 生命周期函数--监听页面卸载
69 | */
70 | onUnload: function () {
71 |
72 | },
73 |
74 | /**
75 | * 页面相关事件处理函数--监听用户下拉动作
76 | */
77 | onPullDownRefresh: function () {
78 |
79 | },
80 |
81 | /**
82 | * 页面上拉触底事件的处理函数
83 | */
84 | onReachBottom: function () {
85 |
86 | },
87 |
88 | /**
89 | * 用户点击右上角分享
90 | */
91 |
92 | onShareAppMessage: function (res) {
93 | wx.showShareMenu({
94 | withShareTicket: true
95 | })
96 | var that = this;
97 | if (res.from === 'button') {
98 | // 来自页面内转发按钮
99 | console.log(res.target)
100 | }
101 | return {
102 | title: 'Bmob 示例',
103 | path: 'pages/index/index',
104 | success: function (res) {
105 | wx.getShareInfo({
106 | shareTicket: res.shareTickets,
107 | success(res) {
108 | // 调用解密
109 | wx.Bmob.User.decryption(res).then(res => {
110 | console.log(res, 444)
111 | })
112 | }
113 | })
114 | },
115 | fail: function (res) {
116 | // 转发失败
117 | }
118 | }
119 | }
120 | })
--------------------------------------------------------------------------------
/pages/interface/decryption/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/interface/decryption/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 | 支持微信运动、手机、群号等各类微信官方解密
10 |
11 |
12 |
13 |
14 | 返回的手机信息:{{phoneInfo}}
15 |
16 |
17 | 返回的转发群Id信息:{{shareInfo}}
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/pages/interface/decryption/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/decryption/index.wxss */
--------------------------------------------------------------------------------
/pages/interface/getToken/index.js:
--------------------------------------------------------------------------------
1 | // pages/interface/getToken/index.js
2 | var common = require("../../../utils/common.js");
3 |
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | loading: true
11 | },
12 | getToken: function () {
13 | var that = this;
14 | wx.Bmob.getAccessToken().then(function (response) {
15 | that.setData({
16 | loading: true,
17 | accessToken:response.access_token
18 | });
19 | console.log(response);
20 | }).catch(function (error) {
21 | console.log(error);
22 | });
23 | }
24 | })
--------------------------------------------------------------------------------
/pages/interface/getToken/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob获取access_token"
3 | }
--------------------------------------------------------------------------------
/pages/interface/getToken/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 微信access_token,业务场景,当其他平台需要使用你小程序的token,并不想与Bmob的平台冲突,可以通过此API实现。
6 |
7 |
8 |
9 |
10 | 获取中...
11 |
12 |
13 | access_token:{{accessToken}}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/pages/interface/getToken/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/getToken/index.wxss */
--------------------------------------------------------------------------------
/pages/interface/index.js:
--------------------------------------------------------------------------------
1 | // pages/interface/index.js
2 | var common = require("../../utils/common.js");
3 | var Bmob = require("../../utils/hydrogen-js-sdk/src/lib/app.js");
4 | var grids = [
5 | { "name": "上传图片", "ico": "pic.png", "url": "../interface/upload/index" },
6 | { "name": "生成二维码", "ico": "code.png", "url": "../interface/code/index" },
7 | { "name": "检测违规内容", "ico": "checkCon.png", "url": "../interface/checkContent/index" },
8 | { "name": "access_token", "ico": "token.png", "url": "../interface/getToken/index" },
9 | { "name": "微信支付", "ico": "pay.png", "url": "../interface/pay/index" },
10 | { "name": "小程序模板信息", "ico": "template.png", "url": "../interface/template/index" },
11 | { "name": "添加地理位置", "ico": "addAddress.png", "url": "../interface/addAddress/index" },
12 | { "name": "查询地理位置", "ico": "select.png", "url": "../interface/select/index" },
13 | { "name": "聊天室", "ico": "chatroom.png", "url": "../interface/chatroom/index" },
14 | { "name": "ai", "ico": "chatroom.png", "url": "../interface/chatai/index" }
15 | ];
16 |
17 | Page({
18 |
19 | /**
20 | * 页面的初始数据
21 | */
22 | data: {
23 | grids: grids,
24 | phoneNumber: ''
25 | },
26 |
27 | // 获取手机号
28 | getPhoneNumber: function(e) {
29 | console.log('获取手机号回调:', e);
30 | console.log(e.detail.code); // 动态令牌
31 | console.log(e.detail.errMsg); // 回调信息(成功失败都会返回)
32 | console.log(e.detail.errno); // 错误码(失败时返回)
33 |
34 | // 判断是否获取成功
35 | if (e.detail.errMsg !== 'getPhoneNumber:ok') {
36 | wx.showToast({
37 | title: '获取失败',
38 | icon: 'none'
39 | });
40 | this.setData({
41 | phoneNumber: '用户拒绝授权'
42 | });
43 | return;
44 | }
45 |
46 | // 获取成功,通过Bmob API获取手机号
47 | if (e.detail.code) {
48 | let code = e.detail.code
49 | // 调用Bmob获取手机号接口
50 | Bmob.getPhoneNumber({
51 | code: code
52 | }).then(result => {
53 | console.log('获取手机号成功:', result);
54 | // 更新页面数据
55 | this.setData({
56 | phoneNumber: result.phoneNumber || JSON.stringify(result)
57 | });
58 | wx.showToast({
59 | title: '获取成功',
60 | icon: 'success'
61 | });
62 | }).catch(err => {
63 | console.log('获取手机号失败:', err);
64 | this.setData({
65 | phoneNumber: '获取失败: ' + JSON.stringify(err)
66 | });
67 | wx.showToast({
68 | title: '获取失败',
69 | icon: 'none'
70 | });
71 | });
72 | } else {
73 | console.log('没有获取到code');
74 | this.setData({
75 | phoneNumber: '没有获取到code'
76 | });
77 | wx.showToast({
78 | title: '获取失败',
79 | icon: 'none'
80 | });
81 | }
82 | }
83 | })
--------------------------------------------------------------------------------
/pages/interface/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "接口中心Demo"
3 | }
--------------------------------------------------------------------------------
/pages/interface/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | {{item.name}}
10 |
11 |
12 |
13 | {{item.name}}
14 |
15 |
16 |
17 |
18 |
19 | 获取手机号
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | 获取到的手机号
30 |
31 |
32 | {{phoneNumber}}
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/pages/interface/index.wxss:
--------------------------------------------------------------------------------
1 | @import "../common/index.wxss";
--------------------------------------------------------------------------------
/pages/interface/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "bmob/library/file"
6 | )
7 |
8 | func main(){
9 |
10 |
11 | appPath := GetCurPath()
12 |
13 |
14 | fmt.Println("hello",appPath)
15 | }
16 |
17 | /*获取当前文件执行的路径*/
18 | func GetCurPath() string {
19 | file, _ := exec.LookPath(os.Args[0])
20 |
21 | //得到全路径,比如在windows下E:\\golang\\test\\a.exe
22 | path, _ := filepath.Abs(file)
23 |
24 | rst := filepath.Dir(path)
25 |
26 | return rst
27 | }
--------------------------------------------------------------------------------
/pages/interface/pay/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../../utils/common.js");
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
9 | },
10 | pay: function () {
11 | var openId = wx.getStorageSync('openid');
12 | //传参数金额,名称,描述,openid
13 | wx.Bmob.Pay.weApp(0.01, '哇哈哈1瓶', '哇哈哈饮料,杭州生产', openId).then(function (resp) {
14 | console.log(resp);
15 |
16 | that.setData({
17 | loading: true,
18 | dataInfo: resp
19 | })
20 |
21 | //服务端返回成功
22 | var timeStamp = resp.timestamp,
23 | nonceStr = resp.noncestr,
24 | packages = resp.package,
25 | orderId = resp.out_trade_no,//订单号,如需保存请建表保存。
26 | sign = resp.sign;
27 |
28 | //打印订单号
29 | console.log(orderId);
30 |
31 | //发起支付
32 | wx.requestPayment({
33 | 'timeStamp': timeStamp,
34 | 'nonceStr': nonceStr,
35 | 'package': packages,
36 | 'signType': 'MD5',
37 | 'paySign': sign,
38 | 'success': function (res) {
39 | //付款成功,这里可以写你的业务代码
40 | console.log(res);
41 | },
42 | 'fail': function (res) {
43 | //付款失败
44 | console.log('付款失败');
45 | console.log(res);
46 | }
47 | })
48 |
49 | }, function (err) {
50 | common.showTip("暂不支持支付","loading");
51 | console.log('服务端返回失败');
52 | console.log(err);
53 | });
54 |
55 | }
56 | })
--------------------------------------------------------------------------------
/pages/interface/pay/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/interface/pay/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 简介:
9 | 微信小程序支付,用户付款到微信支付账户。
10 | 使用条件:
11 | 1.需企业用户提前开通微信支付
12 | 2.填写支付商户id到Bmob控制台
13 | 3.开通Bmob专业版或以上版本(可开通试用,工单联系)
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/pages/interface/pay/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/pay/index.wxss */
--------------------------------------------------------------------------------
/pages/interface/select/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../../utils/common.js");
2 |
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 |
10 | },
11 | formSubmit: function (event) {
12 | var point = wx.Bmob.GeoPoint({ latitude: 22.052033, longitude: 112.405447 })
13 | var point1 = wx.Bmob.GeoPoint({ latitude: 24.052033, longitude: 114.405447 })
14 | var query = wx.Bmob.Query("address");
15 | query.withinGeoBox("address", point, point1); //10指的是公里
16 | query.find().then(res => {
17 | console.log(res)
18 | common.showTip(res[0].objectId,"success");
19 | }).catch(err => {
20 | console.log(err)
21 | })
22 | }
23 | })
--------------------------------------------------------------------------------
/pages/interface/select/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/interface/select/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/pages/interface/select/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/select/index.wxss */
--------------------------------------------------------------------------------
/pages/interface/shop.js:
--------------------------------------------------------------------------------
1 | // pages/interface/shop.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | tabContentData: []
9 | },
10 |
11 | /**
12 | * 生命周期函数--监听页面加载
13 | */
14 | onLoad: function (options) {
15 | // const relation = wx.Bmob.Relation('_User') // 需要关联的表
16 | // const relID = relation.add(['azHoBBBM', '97d593426d','e399ba2176']) //关联表中需要关联的objectId, 返回一个Relation对象, add方法接受string和array的类型参数
17 | // const query = wx.Bmob.Query('diary')
18 | // query.get('de51db4659').then(res => {
19 | // res.set('zan', relID); // 将Relation对象保存到two字段中,即实现了一对多的关联
20 | // res.save()
21 | // })
22 |
23 | const query = wx.Bmob.Query('diary')
24 | query.field('zan','de51db4659')
25 | query.select('username')
26 | query.statTo('count',1)
27 | query.find().then(res => {
28 | console.log(res);
29 | })
30 |
31 | // query.count().then(res => {
32 | // console.log(res,998);
33 | // })
34 |
35 | },
36 |
37 | navigateBack: function navigateBack () {
38 |
39 | },
40 | handleChange: function handleChange (e) {
41 |
42 | },
43 |
44 | onReady: function onReady () {
45 | this.setData({
46 | });
47 | },
48 |
49 | /**
50 | * 生命周期函数--监听页面显示
51 | */
52 | onShow: function () {
53 |
54 | },
55 |
56 | /**
57 | * 生命周期函数--监听页面隐藏
58 | */
59 | onHide: function () {
60 |
61 | },
62 |
63 | /**
64 | * 生命周期函数--监听页面卸载
65 | */
66 | onUnload: function () {
67 |
68 | },
69 |
70 | /**
71 | * 页面相关事件处理函数--监听用户下拉动作
72 | */
73 | onPullDownRefresh: function () {
74 |
75 | },
76 |
77 | /**
78 | * 页面上拉触底事件的处理函数
79 | */
80 | onReachBottom: function () {
81 |
82 | },
83 |
84 | /**
85 | * 用户点击右上角分享
86 | */
87 | onShareAppMessage: function () {
88 |
89 | }
90 | })
--------------------------------------------------------------------------------
/pages/interface/shop.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/interface/shop.wxml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/pages/interface/shop.wxss:
--------------------------------------------------------------------------------
1 | /* 1像素解决方案 */
2 | /*
3 | * 清除1px
4 | */
5 | /*
6 | * 清除浮动
7 | */
8 | /*
9 | * mobile
10 | */
11 | /*
12 | * 1px
13 | */
14 | /*
15 | * text
16 | */
17 | /* 垂直居中 */
18 | /* 水平居中 */
19 | /* 水平垂直居中 */
20 | /* 超出部分出省略号 */
21 | /* 多行文本超出部分省略号 */
22 | .container {
23 | display: flex;
24 | }
25 | .imgbox {
26 | width: 64px;
27 | height: 64px;
28 | border-radius: 50%;
29 | overflow: hidden;
30 | margin: 0 auto;
31 | border: 1px solid #ccc;
32 | border-style: rgba(231, 231, 231, 0.6);
33 | }
34 | .imgbox .ui-image {
35 | width: 100%;
36 | }
37 | .small-title {
38 | font-size: 24rpx;
39 | text-align: center;
40 | margin-top: 20rpx;
41 | }
42 | .goods-box {
43 | display: flex;
44 | flex-wrap: wrap;
45 | align-content: flex-start;
46 | }
47 | .goods-box .goods-list {
48 | flex: 0 0 33.33%;
49 | margin-top: 40rpx;
50 | }
51 |
52 |
53 | .ui-row {
54 | position: relative;
55 | flex: 1;
56 | display: flex;
57 | justify-content: center;
58 | }
59 | .ui-row-border-top:before {
60 | content: " ";
61 | position: absolute;
62 | left: 0;
63 | top: 0;
64 | right: 0;
65 | height: 1px;
66 | border-top: 1px solid #C7C7C7;
67 | color: #C7C7C7;
68 | transform-origin: 0 0;
69 | transform: scaleY(0.5);
70 | }
71 | .ui-row-border-bottom:after {
72 | content: " ";
73 | position: absolute;
74 | left: 0;
75 | bottom: 0;
76 | right: 0;
77 | height: 1px;
78 | border-bottom: 1px solid #C7C7C7;
79 | color: #C7C7C7;
80 | transform-origin: 0 100%;
81 | transform: scaleY(0.5);
82 | }
83 |
84 |
85 | .ui-col {
86 | position: relative;
87 | min-width: 0;
88 | display: flex;
89 | flex: 1;
90 | height: 100%;
91 | }
92 | .ui-col-3 {
93 | float: left;
94 | height: 100%;
95 | width: 25%;
96 | }
97 |
98 | .ui-col-content {
99 | height: 100%;
100 | min-width: 0;
101 | flex-direction: column;
102 | width: 100%;
103 | display: flex;
104 | }
105 |
106 |
107 | ui-v-tab {
108 | position: relative;
109 | align-items: center;
110 | justify-content: center;
111 | }
112 | .ui-v-tab {
113 | padding: 14px 18px;
114 | position: relative;
115 | font-size: 14px;
116 | display: flex;
117 | align-items: center;
118 | justify-content: center;
119 | text-align: center;
120 | width: 100%;
121 | }
122 | .ui-v-tab.active {
123 | color: #39f;
124 | border-right: 1px solid #39f;
125 | }
126 |
--------------------------------------------------------------------------------
/pages/interface/template/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../../utils/common.js");
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
9 | },
10 | formSubmit: function (e) {
11 |
12 | let userData = wx.Bmob.User.current()
13 | var open_Id = userData.openid;
14 | var template_Id = "63rsBPjJqaaCMUeLAMjO01tq2-XVN46Jaq-AMq1RzYo";
15 | var form_Id = e.detail.formId;
16 | var keyword1 = e.detail.value.name;
17 | var keyword2 = e.detail.value.company;
18 | var keyword3 = e.detail.value.remark;
19 | if(keyword1=="" || keyword2=="" || keyword3==""){
20 | common.showTip("请填写完整","loading");
21 | return false;
22 | }
23 | console.log(open_Id);
24 | let modelData = {
25 | "touser": open_Id,
26 | "template_id": template_Id,
27 | "page": "/pages/user/index",
28 | "form_id": form_Id,
29 | "data": {
30 | "keyword1": {
31 | "value": keyword1
32 | },
33 | "keyword2": {
34 | "value": keyword2
35 | },
36 | "keyword3": {
37 | "value": keyword3
38 | }
39 | },
40 | "emphasis_keyword": "keyword1.DATA"
41 | }
42 | console.log(modelData);
43 | wx.Bmob.sendWeAppMessage(modelData).then(function (response) {
44 | console.log(response);
45 | common.showTip("发送成功","success");
46 | }).catch(function (error) {
47 | console.log(error);
48 | common.showTip("发送失败", "loading");
49 | });
50 | }
51 | });
--------------------------------------------------------------------------------
/pages/interface/template/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/interface/template/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/pages/interface/template/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/interface/template/index.wxss */
--------------------------------------------------------------------------------
/pages/interface/upload/index.js:
--------------------------------------------------------------------------------
1 | var that;
2 | var common = require("../../../utils/common.js");
3 | Page({
4 |
5 | data:{
6 | loading:true
7 | },
8 | onLoad:function(){
9 | that = this;
10 | },
11 | upload:function(){
12 | wx.chooseImage({
13 | count:9,
14 | sizeType: ['compressed'], //original 原图,compressed 压缩图,默认二者都有
15 | success: function(res) {
16 | wx.showNavigationBarLoading()
17 | that.setData({
18 | loading:false
19 | })
20 | var urlArr = new Array();
21 | var tempFilePaths = res.tempFilePaths;
22 | var imgLength = tempFilePaths.length;
23 | if(imgLength > 0){
24 | var file;
25 | for (var i = 0; i < imgLength; i++){
26 | var tempFilePath = tempFilePaths[i];
27 | var timestamp = Date.parse(new Date());
28 | var extension = /\.([^.]*)$/.exec(tempFilePath);
29 | extension = extension[1].toLowerCase();
30 | var name = timestamp + "." +extension;
31 | var file = wx.Bmob.File(name, tempFilePath);
32 |
33 | }
34 | file.save().then(res => {
35 | that.setData({
36 | loading: true
37 | })
38 | console.log(res,99)
39 |
40 |
41 | const query = wx.Bmob.Query('diary');
42 | query.set("distfile",res[0])
43 |
44 |
45 | query.save().then(res => {
46 | console.log(res)
47 | }).catch(err => {
48 | console.log(err)
49 | })
50 |
51 | wx.hideNavigationBarLoading();
52 | common.showTip("上传成功", "success");
53 | })
54 |
55 | }else{
56 | common.showTip("请选择图片","loading");
57 | }
58 | },
59 | })
60 | }
61 | })
--------------------------------------------------------------------------------
/pages/interface/upload/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob文件上传"
3 | }
--------------------------------------------------------------------------------
/pages/interface/upload/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 图片上传成功后可以在Bmob控制台->应用->素材 里面查看
5 |
6 |
7 |
8 |
9 | 图片上传中...
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/pages/interface/upload/index.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/pages/interface/upload/index.wxss
--------------------------------------------------------------------------------
/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/user/checkEmail/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../../utils/common.js");
2 |
3 | Page({
4 | onLoad: function () {
5 |
6 | },
7 | checkEmail:function(event){
8 | var email = event.detail.value.email;
9 | if(email!=""){
10 | wx.Bmob.User.requestEmailVerify(email).then(res=>{
11 | common.showTip("邮件已发送","success");
12 | }).catch(err=>{
13 | console.log(err);
14 | })
15 | }else{
16 | common.showTip("请输入邮箱","loading");
17 | }
18 | }
19 |
20 | })
--------------------------------------------------------------------------------
/pages/user/checkEmail/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob验证Email"
3 | }
--------------------------------------------------------------------------------
/pages/user/checkEmail/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/pages/user/checkEmail/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/user/checkEmail/index.wxss */
--------------------------------------------------------------------------------
/pages/user/getOpenid/index.js:
--------------------------------------------------------------------------------
1 | // pages/other/other.js
2 | var that;
3 | var common = require('../../../utils/common.js');
4 | Page({
5 | data: {
6 | loading: true
7 | },
8 | onLoad: function () {
9 | that = this;
10 | // 页面初始化 options为页面跳转所带来的参数
11 | },
12 | getOpenId: function () {
13 | //获取open id,请在官网填写微信小程序key
14 | wx.login({
15 | success: function (res) {
16 | if (res.code) {
17 | //发起网络请求
18 | console.log(res.code)
19 | wx.Bmob.User.requestOpenId(res.code).then(result=>{
20 | that.setData({
21 | loading: true,
22 | url: result.openid
23 | })
24 | }).catch(err => {
25 | console.log(err)
26 | })
27 | } else {
28 | console.log('获取用户登录态失败!' + res.errMsg)
29 | common.showTip('获取用户登录态失败!', 'loading');
30 | }
31 | }
32 | });
33 | }
34 | })
--------------------------------------------------------------------------------
/pages/user/getOpenid/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob获取Openid"
3 | }
--------------------------------------------------------------------------------
/pages/user/getOpenid/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 获取中...
8 |
9 |
10 | 返回OpenId:{{url}}
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/pages/user/getOpenid/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/user/getOpenid/index.wxss */
--------------------------------------------------------------------------------
/pages/user/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../utils/common.js");
2 | var grids = [{
3 | "name": "登录",
4 | "ico": "login.png",
5 | "url": "../user/login/index"
6 | },
7 | {
8 | "name": "注册",
9 | "ico": "reg.png",
10 | "url": "../user/register/index"
11 | },
12 | {
13 | "name": "验证码登录",
14 | "ico": "sms.png",
15 | "url": "../user/smsLogin/index"
16 | },
17 | {
18 | "name": "一键登录",
19 | "ico": "autologin.png",
20 | "click": "autoLogin"
21 | },
22 | {
23 | "name": "获取用户登录信息",
24 | "ico": "getInfo.png",
25 | "url": "../user/userInfo/index"
26 | },
27 | {
28 | "name": "验证Email",
29 | "ico": "checkEmail.png",
30 | "url": "../user/checkEmail/index"
31 | },
32 | {
33 | "name": "密码重置",
34 | "ico": "pswdreset.png",
35 | "url": "../user/resetPswd/index"
36 | },
37 | {
38 | "name": "更新用户信息",
39 | "ico": "updateInfo.png",
40 | "url": "../user/updateInfo/index"
41 | },
42 | {
43 | "name": "获取openId",
44 | "ico": "getOpenid.png",
45 | "url": "../user/getOpenid/index"
46 | },
47 |
48 |
49 | ];
50 |
51 | Page({
52 | data: {
53 | grids: grids,
54 | },
55 | autoLogin: function () {
56 | common.showModal("App.js实现小程序访问将数据写入系统User表,具体代码请查看App.js。")
57 | },
58 | onLoad: () => {
59 | // console.log(GetUrlRelativePath(), 'mmm')
60 |
61 | }
62 | })
--------------------------------------------------------------------------------
/pages/user/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText":"接口中心Demo"
3 | }
--------------------------------------------------------------------------------
/pages/user/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{item.name}}
11 |
12 |
13 |
14 | {{item.name}}
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/pages/user/index.wxss:
--------------------------------------------------------------------------------
1 | @import "../common/index.wxss";
--------------------------------------------------------------------------------
/pages/user/interface/index.js:
--------------------------------------------------------------------------------
1 | // pages/user/interface/index.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
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 |
30 | },
31 |
32 | /**
33 | * 生命周期函数--监听页面隐藏
34 | */
35 | onHide: function () {
36 |
37 | },
38 |
39 | /**
40 | * 生命周期函数--监听页面卸载
41 | */
42 | onUnload: function () {
43 |
44 | },
45 |
46 | /**
47 | * 页面相关事件处理函数--监听用户下拉动作
48 | */
49 | onPullDownRefresh: function () {
50 |
51 | },
52 |
53 | /**
54 | * 页面上拉触底事件的处理函数
55 | */
56 | onReachBottom: function () {
57 |
58 | },
59 |
60 | /**
61 | * 用户点击右上角分享
62 | */
63 | onShareAppMessage: function () {
64 |
65 | }
66 | })
--------------------------------------------------------------------------------
/pages/user/interface/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/user/interface/index.wxml:
--------------------------------------------------------------------------------
1 |
2 | pages/user/interface/index.wxml
3 |
--------------------------------------------------------------------------------
/pages/user/interface/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/user/interface/index.wxss */
--------------------------------------------------------------------------------
/pages/user/login/index.js:
--------------------------------------------------------------------------------
1 | // pages/login/index.js
2 | const common = require("../../../utils/common.js");
3 |
4 | Page({
5 | formsubmit:function(event){
6 | wx.Bmob.User.login(event.detail.value.username,event.detail.value.password).then(res=>{
7 | common.showTip("登录成功");
8 | wx.setStorageSync("objectId", res['objectId']);
9 | setTimeout(function () {
10 | wx.switchTab({
11 | url: '/pages/user/index',
12 | })
13 | }, 2000);
14 | }).catch(err=>{
15 | console.log(err);
16 | common.showTip("登录失败", "loading");
17 | })
18 | },
19 | getUserInfo:function(){
20 | let current = wx.Bmob.User.current();
21 | if(current){
22 | console.log(current);
23 | }else{
24 | common.showTip("请先登录","loading");
25 | }
26 | }
27 | })
--------------------------------------------------------------------------------
/pages/user/login/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob-登录"
3 | }
--------------------------------------------------------------------------------
/pages/user/login/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
20 |
--------------------------------------------------------------------------------
/pages/user/login/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/login/index.wxss */
2 | .section{border:1px solid #ccc;margin:10px auto;width:80%;font-size:14px;}
3 | .section input{padding-left:15px;}
4 | .btn-area{width:80%;margin:0 auto;display:flex;}
5 | .btn-area button{flex:1;max-width:40%;font-size:14px;}
6 | .reg{width:100%;text-align:center;margin-top:10px;font-size:14px;color:dodgerblue;}
--------------------------------------------------------------------------------
/pages/user/register/index.js:
--------------------------------------------------------------------------------
1 | // pages/register/index.js
2 |
3 | var common = require("../../../utils/common.js");
4 | var that;
5 | Page({
6 |
7 | onLoad: function () {
8 | that = this;
9 | },
10 |
11 | formSubmit: function (event) {
12 | var username = event.detail.value.username;
13 | var email = event.detail.value.email;
14 | var phone = event.detail.value.phone;
15 | var password = event.detail.value.password;
16 | var password1 = event.detail.value.password1;
17 |
18 | if(username !=""&&password!=""&&password1!=""&&email !=""&&phone!=""){
19 | if(password!=password1){
20 | common.showTip("密码不一致", "loading", 1500);
21 | return false;
22 | }
23 | let params = {
24 | username:username,
25 | password:password,
26 | email:email,
27 | mobilePhoneNumber:phone
28 | }
29 | wx.Bmob.User.register(params).then(res=>{
30 | common.showTip("注册成功");
31 | setTimeout(function () {
32 | wx.switchTab({
33 | url: '/pages/user/index',
34 | })
35 | }, 2000);
36 | }).catch(err=>{
37 | console.log(err);
38 | })
39 | }else{
40 | common.showTip("请填写完整","loading",1500);
41 | }
42 | }
43 |
44 | })
--------------------------------------------------------------------------------
/pages/user/register/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob注册"
3 | }
--------------------------------------------------------------------------------
/pages/user/register/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/pages/user/register/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/register/index.wxss */
--------------------------------------------------------------------------------
/pages/user/resetPswd/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../../utils/common.js");
2 | var that;
3 | Page({
4 | data: {
5 | phone: '',
6 | },
7 | onLoad: function () {
8 | that = this;
9 | },
10 | resetByEmail:function(event){
11 | var email = event.detail.value.email;
12 | if(email == ""){
13 | common.showTip("请输入邮箱","loading",2000);
14 | return false;
15 | }
16 |
17 | let data = {email:email};
18 | wx.Bmob.requestPasswordReset(data).then(res=>{
19 | common.showTip("邮件已发送","success",function(){
20 | wx.switchTab({
21 | url: '/pages/user/index',
22 | })
23 | },1500);
24 | }).catch(err=>{
25 | console.log(err);
26 | })
27 | },
28 | sendSms: function (event) {
29 | var phone = event.detail.value.phone;
30 |
31 | if (phone == "") {
32 | common.showTip("请输入号码", "loading");
33 | return false;
34 | }
35 | let params = {
36 | mobilePhoneNumber: phone
37 | }
38 | wx.Bmob.requestSmsCode(params).then(function (response) {
39 | that.setData({
40 | phone: phone
41 | })
42 | common.showTip("发送成功", "success");
43 | }).catch(function (error) {
44 | common.showTip("发送失败", "success");
45 | })
46 | },
47 | verifySmsCode: function (event) {
48 | var phone = parseInt(this.data.phone);
49 | var password = event.detail.value.password;
50 | var smsCode = event.detail.value.verifyCode;
51 | if (!phone) {
52 | // common.showTip("请发送验证码", "loading");
53 | // return false;
54 | } else if (!smsCode) {
55 | common.showTip("请输入验证码", "loading");
56 | return false
57 | }else if(!password){
58 | common.showTip("请输入密码", "loading");
59 | return false
60 | }
61 |
62 | let data = { password: password};
63 | wx.Bmob.resetPasswordBySmsCode(smsCode,data).then(res => {
64 | common.showTip("修改成功", "success", function () {
65 | wx.switchTab({
66 | url: '/pages/user/index',
67 | })
68 | }, 1500);
69 | }).catch(err => {
70 | console.log(err);
71 | })
72 |
73 | }
74 |
75 | })
--------------------------------------------------------------------------------
/pages/user/resetPswd/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob密码重置"
3 | }
--------------------------------------------------------------------------------
/pages/user/resetPswd/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
26 |
27 |
28 |
40 |
--------------------------------------------------------------------------------
/pages/user/resetPswd/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/user/resetPswd/index.wxss */
--------------------------------------------------------------------------------
/pages/user/smsLogin/index.js:
--------------------------------------------------------------------------------
1 | var common = require("../../../utils/common.js");
2 | var that;
3 | Page({
4 | data:{
5 | phone:'',
6 | },
7 | onLoad:function(){
8 | that = this;
9 | },
10 | sendSms:function(event){
11 | var phone = event.detail.value.phone;
12 |
13 | if(phone == ""){
14 | common.showTip("请输入号码","loading");
15 | return false;
16 | }
17 | let params = {
18 | mobilePhoneNumber:phone
19 | }
20 | wx.Bmob.requestSmsCode(params).then(function(response){
21 | that.setData({
22 | phone: phone
23 | })
24 | common.showTip("发送成功", "success");
25 | }).catch(function(error){
26 | common.showTip("发送失败", "success");
27 | })
28 | },
29 | verifySmsCode:function(event){
30 | var phone = parseInt(this.data.phone);
31 | var smsCode = parseInt(event.detail.value.verifyCode);
32 | if(!phone){
33 | common.showTip("请发送验证码","loading");
34 | return false;
35 | }else if(!smsCode){
36 | common.showTip("请输入验证码","loading");
37 | return false;
38 | }
39 |
40 | wx.Bmob.User.signOrLoginByMobilePhone(phone,smsCode).then(res=>{
41 | common.showTip("登录成功","success");
42 | }).catch(err=>{
43 | console.log(err);
44 | })
45 |
46 | }
47 | })
--------------------------------------------------------------------------------
/pages/user/smsLogin/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob短信验证码登录"
3 | }
--------------------------------------------------------------------------------
/pages/user/smsLogin/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 此代码会发送一个示例短信验证码,目前每个测试账号有一定的免费短信,测试账号也有用完的可能,如接收不到,可切换自己的Bmob APP key,默认收到的短信签名是【比目科技】,签名可以在后台自定义
6 |
7 |
18 |
19 |
20 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/pages/user/smsLogin/index.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/pages/user/smsLogin/index.wxss
--------------------------------------------------------------------------------
/pages/user/updateInfo/index.js:
--------------------------------------------------------------------------------
1 | Page({
2 |
3 | /**
4 | * 页面的初始数据
5 | */
6 | data: {
7 | userInfo:null,
8 | hasUserInfo:true
9 | },
10 |
11 | getUserInfo: function (e) {
12 | this.setData({
13 | userInfo: e.detail.userInfo,
14 | hasUserInfo: false
15 | })
16 | wx.Bmob.User.upInfo(e.detail.userInfo).then(result => {
17 | console.log(result)
18 | }).catch(err => {
19 | console.log(err)
20 | })
21 | }
22 | })
--------------------------------------------------------------------------------
/pages/user/updateInfo/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob更新用户信息"
3 | }
--------------------------------------------------------------------------------
/pages/user/updateInfo/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {{userInfo.nickName}}
7 |
8 |
--------------------------------------------------------------------------------
/pages/user/updateInfo/index.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/pages/user/updateInfo/index.wxss
--------------------------------------------------------------------------------
/pages/user/userInfo/index.js:
--------------------------------------------------------------------------------
1 | // pages/user/userInfo/index.js
2 | var common = require("../../../utils/common.js");
3 | var that;
4 | Page({
5 | data:{
6 | loading:true
7 | },
8 | onLoad:function(){
9 | that=this;
10 | },
11 | getUserInfo:function(){
12 | let current = wx.Bmob.User.current();
13 | if(current){
14 | that.setData({
15 | loading:true,
16 | username:current['username'],
17 | objectId:current['objectId'],
18 | });
19 | console.log(current);
20 | }else{
21 | common.showTip("请先登录","loading");
22 | }
23 | }
24 | })
--------------------------------------------------------------------------------
/pages/user/userInfo/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "Bmob获取用户信息"
3 | }
--------------------------------------------------------------------------------
/pages/user/userInfo/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 获取中...
10 |
11 |
12 | 用户名:{{username}}
13 |
14 |
15 | objectId:{{objectId}}
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/pages/user/userInfo/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/user/userInfo/index.wxss */
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件。",
3 | "setting": {
4 | "urlCheck": false,
5 | "es6": true,
6 | "enhance": true,
7 | "postcss": true,
8 | "preloadBackgroundData": false,
9 | "minified": true,
10 | "newFeature": true,
11 | "coverView": true,
12 | "nodeModules": false,
13 | "autoAudits": false,
14 | "showShadowRootInWxmlPanel": true,
15 | "scopeDataCheck": false,
16 | "uglifyFileName": false,
17 | "checkInvalidKey": true,
18 | "checkSiteMap": true,
19 | "uploadWithSourceMap": true,
20 | "compileHotReLoad": false,
21 | "lazyloadPlaceholderEnable": false,
22 | "useMultiFrameRuntime": true,
23 | "useApiHook": true,
24 | "useApiHostProcess": true,
25 | "babelSetting": {
26 | "ignore": [],
27 | "disablePlugins": [],
28 | "outputPath": ""
29 | },
30 | "enableEngineNative": false,
31 | "useIsolateContext": false,
32 | "userConfirmedBundleSwitch": false,
33 | "packNpmManually": false,
34 | "packNpmRelationList": [],
35 | "minifyWXSS": true,
36 | "disableUseStrict": false,
37 | "minifyWXML": true,
38 | "showES6CompileOption": false,
39 | "useCompilerPlugins": false,
40 | "condition": false
41 | },
42 | "compileType": "miniprogram",
43 | "libVersion": "2.16.1",
44 | "appid": "wx094ede192e7e64b5",
45 | "projectname": "bmob%E7%A4%BA%E4%BE%8B",
46 | "condition": {
47 | "search": {
48 | "list": []
49 | },
50 | "conversation": {
51 | "list": []
52 | },
53 | "plugin": {
54 | "list": []
55 | },
56 | "game": {
57 | "currentL": -1,
58 | "list": []
59 | },
60 | "miniprogram": {
61 | "list": [
62 | {
63 | "id": -1,
64 | "name": "shop",
65 | "pathName": "pages/interface/shop",
66 | "query": ""
67 | },
68 | {
69 | "id": -1,
70 | "name": "解密",
71 | "pathName": "pages/interface/decryption/index",
72 | "query": ""
73 | },
74 | {
75 | "id": -1,
76 | "name": "da",
77 | "pathName": "pages/database/index",
78 | "query": ""
79 | }
80 | ]
81 | }
82 | },
83 | "packOptions": {
84 | "ignore": [],
85 | "include": []
86 | },
87 | "editorSetting": {
88 | "tabIndent": "insertSpaces",
89 | "tabSize": 2
90 | }
91 | }
--------------------------------------------------------------------------------
/project.private.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "setting": {
3 | "compileHotReLoad": true
4 | },
5 | "condition": {
6 | "miniprogram": {
7 | "list": [
8 | {
9 | "name": "pages/center/index",
10 | "pathName": "pages/center/index",
11 | "query": "",
12 | "launchMode": "default",
13 | "scene": null
14 | },
15 | {
16 | "name": "shop",
17 | "pathName": "pages/interface/shop",
18 | "query": ""
19 | },
20 | {
21 | "name": "解密",
22 | "pathName": "pages/interface/decryption/index",
23 | "query": ""
24 | },
25 | {
26 | "name": "da",
27 | "pathName": "pages/database/index",
28 | "query": ""
29 | },
30 | {
31 | "name": "pages/interface/checkContent/index",
32 | "pathName": "pages/interface/checkContent/index",
33 | "query": "",
34 | "scene": null
35 | },
36 | {
37 | "name": "违规图检测",
38 | "pathName": "pages/interface/checkContent/index",
39 | "query": "",
40 | "scene": null
41 | },
42 | {
43 | "name": "room",
44 | "pathName": "pages/interface/chatroom/index",
45 | "query": "",
46 | "launchMode": "default",
47 | "scene": null
48 | },
49 | {
50 | "name": "",
51 | "pathName": "pages/interface/chatai/index",
52 | "query": "",
53 | "launchMode": "default",
54 | "scene": null
55 | }
56 | ]
57 | }
58 | },
59 | "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
60 | "projectname": "bmob%E7%A4%BA%E4%BE%8B",
61 | "libVersion": "3.8.1"
62 | }
--------------------------------------------------------------------------------
/sitemap.json:
--------------------------------------------------------------------------------
1 | {
2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3 | "rules": [{
4 | "action": "allow",
5 | "page": "*"
6 | }]
7 | }
--------------------------------------------------------------------------------
/style/footer.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
--------------------------------------------------------------------------------
/style/header.wxml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/style/weui.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | line-height: 1.6;
3 | font-family: -apple-system-font, "Helvetica Neue", sans-serif;
4 | }
5 | icon {
6 | vertical-align: middle;
7 | }
8 | .weui-cells {
9 | position: relative;
10 | margin-top: 1.17647059em;
11 | background-color: #FFFFFF;
12 | line-height: 1.41176471;
13 | font-size: 17px;
14 | }
15 | .weui-cells:before {
16 | content: " ";
17 | position: absolute;
18 | left: 0;
19 | top: 0;
20 | right: 0;
21 | height: 1px;
22 | border-top: 1rpx solid #D9D9D9;
23 | color: #D9D9D9;
24 | }
25 | .weui-cells:after {
26 | content: " ";
27 | position: absolute;
28 | left: 0;
29 | bottom: 0;
30 | right: 0;
31 | height: 1px;
32 | border-bottom: 1rpx solid #D9D9D9;
33 | color: #D9D9D9;
34 | }
35 | .weui-cells__title {
36 | margin-top: .77em;
37 | margin-bottom: .3em;
38 | padding-left: 15px;
39 | padding-right: 15px;
40 | color: #999999;
41 | font-size: 14px;
42 | }
43 | .weui-cells_after-title {
44 | margin-top: 0;
45 | }
46 | .weui-cells__tips {
47 | margin-top: .3em;
48 | color: #999999;
49 | padding-left: 15px;
50 | padding-right: 15px;
51 | font-size: 14px;
52 | }
53 | .weui-cell {
54 | padding: 10px 15px;
55 | position: relative;
56 | display: -webkit-box;
57 | display: -webkit-flex;
58 | display: flex;
59 | -webkit-box-align: center;
60 | -webkit-align-items: center;
61 | align-items: center;
62 | }
63 | .weui-cell:before {
64 | content: " ";
65 | position: absolute;
66 | left: 0;
67 | top: 0;
68 | right: 0;
69 | height: 1px;
70 | border-top: 1rpx solid #D9D9D9;
71 | color: #D9D9D9;
72 | left: 15px;
73 | }
74 | .weui-cell:first-child:before {
75 | display: none;
76 | }
77 | .weui-cell_active {
78 | background-color: #ECECEC;
79 | }
80 | .weui-cell_primary {
81 | -webkit-box-align: start;
82 | -webkit-align-items: flex-start;
83 | align-items: flex-start;
84 | }
85 | .weui-cell__bd {
86 | -webkit-box-flex: 1;
87 | -webkit-flex: 1;
88 | flex: 1;
89 | }
90 | .weui-cell__ft {
91 | text-align: right;
92 | color: #999999;
93 | }
94 | .weui-cell_access {
95 | color: inherit;
96 | }
97 | .weui-cell__ft_in-access {
98 | padding-right: 13px;
99 | position: relative;
100 | }
101 | .weui-cell__ft_in-access:after {
102 | content: " ";
103 | display: inline-block;
104 | height: 6px;
105 | width: 6px;
106 | border-width: 2px 2px 0 0;
107 | border-color: #C8C8CD;
108 | border-style: solid;
109 | -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
110 | transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
111 | position: relative;
112 | top: -2px;
113 | position: absolute;
114 | top: 50%;
115 | margin-top: -4px;
116 | right: 2px;
117 | }
118 | .weui-cell_link {
119 | color: #586C94;
120 | font-size: 14px;
121 | }
122 | .weui-cell_link:active {
123 | background-color: #ECECEC;
124 | }
125 | .weui-cell_link:first-child:before {
126 | display: block;
127 | }
128 | .weui-icon-radio {
129 | margin-left: 3.2px;
130 | margin-right: 3.2px;
131 | }
132 | .weui-icon-checkbox_circle,
133 | .weui-icon-checkbox_success {
134 | margin-left: 4.6px;
135 | margin-right: 4.6px;
136 | }
137 | .weui-check__label:active {
138 | background-color: #ECECEC;
139 | }
140 | .weui-check {
141 | position: absolute;
142 | left: -9999px;
143 | }
144 | .weui-check__hd_in-checkbox {
145 | padding-right: 0.35em;
146 | }
147 | .weui-cell__ft_in-radio {
148 | padding-left: 0.35em;
149 | }
150 | .weui-cell_input {
151 | padding-top: 0;
152 | padding-bottom: 0;
153 | }
154 | .weui-label {
155 | width: 105px;
156 | word-wrap: break-word;
157 | word-break: break-all;
158 | }
159 | .weui-input {
160 | height: 2.58823529em;
161 | min-height: 2.58823529em;
162 | line-height: 2.58823529em;
163 | }
164 | .weui-toptips {
165 | position: fixed;
166 | -webkit-transform: translateZ(0);
167 | transform: translateZ(0);
168 | top: 0;
169 | left: 0;
170 | right: 0;
171 | padding: 5px;
172 | font-size: 14px;
173 | text-align: center;
174 | color: #FFFFFF;
175 | z-index: 5000;
176 | word-wrap: break-word;
177 | word-break: break-all;
178 | }
179 | .weui-toptips_warn {
180 | background-color: #E64340;
181 | }
182 | .weui-textarea {
183 | display: block;
184 | width: 100%;
185 | }
186 | .weui-textarea-counter {
187 | color: #B2B2B2;
188 | text-align: right;
189 | }
190 | .weui-textarea-counter_warn {
191 | color: #E64340;
192 | }
193 | .weui-cell_warn {
194 | color: #E64340;
195 | }
196 | .weui-form-preview {
197 | position: relative;
198 | background-color: #FFFFFF;
199 | }
200 | .weui-form-preview:before {
201 | content: " ";
202 | position: absolute;
203 | left: 0;
204 | top: 0;
205 | right: 0;
206 | height: 1px;
207 | border-top: 1rpx solid #D9D9D9;
208 | color: #D9D9D9;
209 | }
210 | .weui-form-preview:after {
211 | content: " ";
212 | position: absolute;
213 | left: 0;
214 | bottom: 0;
215 | right: 0;
216 | height: 1px;
217 | border-bottom: 1rpx solid #D9D9D9;
218 | color: #D9D9D9;
219 | }
220 | .weui-form-preview__value {
221 | font-size: 14px;
222 | }
223 | .weui-form-preview__value_in-hd {
224 | font-size: 26px;
225 | }
226 | .weui-form-preview__hd {
227 | position: relative;
228 | padding: 10px 15px;
229 | text-align: right;
230 | line-height: 2.5em;
231 | }
232 | .weui-form-preview__hd:after {
233 | content: " ";
234 | position: absolute;
235 | left: 0;
236 | bottom: 0;
237 | right: 0;
238 | height: 1px;
239 | border-bottom: 1rpx solid #D9D9D9;
240 | color: #D9D9D9;
241 | left: 15px;
242 | }
243 | .weui-form-preview__bd {
244 | padding: 10px 15px;
245 | font-size: .9em;
246 | text-align: right;
247 | color: #999999;
248 | line-height: 2;
249 | }
250 | .weui-form-preview__ft {
251 | position: relative;
252 | line-height: 50px;
253 | display: -webkit-box;
254 | display: -webkit-flex;
255 | display: flex;
256 | }
257 | .weui-form-preview__ft:after {
258 | content: " ";
259 | position: absolute;
260 | left: 0;
261 | top: 0;
262 | right: 0;
263 | height: 1px;
264 | border-top: 1rpx solid #D5D5D6;
265 | color: #D5D5D6;
266 | }
267 | .weui-form-preview__item {
268 | overflow: hidden;
269 | }
270 | .weui-form-preview__label {
271 | float: left;
272 | margin-right: 1em;
273 | min-width: 4em;
274 | color: #999999;
275 | text-align: justify;
276 | text-align-last: justify;
277 | }
278 | .weui-form-preview__value {
279 | display: block;
280 | overflow: hidden;
281 | word-break: normal;
282 | word-wrap: break-word;
283 | }
284 | .weui-form-preview__btn {
285 | position: relative;
286 | display: block;
287 | -webkit-box-flex: 1;
288 | -webkit-flex: 1;
289 | flex: 1;
290 | color: #3CC51F;
291 | text-align: center;
292 | }
293 | .weui-form-preview__btn:after {
294 | content: " ";
295 | position: absolute;
296 | left: 0;
297 | top: 0;
298 | width: 1px;
299 | bottom: 0;
300 | border-left: 1rpx solid #D5D5D6;
301 | color: #D5D5D6;
302 | }
303 | .weui-form-preview__btn:first-child:after {
304 | display: none;
305 | }
306 | .weui-form-preview__btn_active {
307 | background-color: #EEEEEE;
308 | }
309 | .weui-form-preview__btn_default {
310 | color: #999999;
311 | }
312 | .weui-form-preview__btn_primary {
313 | color: #0BB20C;
314 | }
315 | .weui-cell_select {
316 | padding: 0;
317 | }
318 | .weui-select {
319 | position: relative;
320 | padding-left: 15px;
321 | padding-right: 30px;
322 | height: 2.58823529em;
323 | min-height: 2.58823529em;
324 | line-height: 2.58823529em;
325 | border-right: 1rpx solid #D9D9D9;
326 | }
327 | .weui-select:before {
328 | content: " ";
329 | display: inline-block;
330 | height: 6px;
331 | width: 6px;
332 | border-width: 2px 2px 0 0;
333 | border-color: #C8C8CD;
334 | border-style: solid;
335 | -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
336 | transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
337 | position: relative;
338 | top: -2px;
339 | position: absolute;
340 | top: 50%;
341 | right: 15px;
342 | margin-top: -4px;
343 | }
344 | .weui-select_in-select-after {
345 | padding-left: 0;
346 | }
347 | .weui-cell__hd_in-select-after,
348 | .weui-cell__bd_in-select-before {
349 | padding-left: 15px;
350 | }
351 | .weui-cell_vcode {
352 | padding-right: 0;
353 | }
354 | .weui-vcode-img {
355 | margin-left: 5px;
356 | height: 2.58823529em;
357 | vertical-align: middle;
358 | }
359 | .weui-vcode-btn {
360 | display: inline-block;
361 | height: 2.58823529em;
362 | margin-left: 5px;
363 | padding: 0 0.6em 0 0.7em;
364 | border-left: 1px solid #E5E5E5;
365 | line-height: 2.58823529em;
366 | vertical-align: middle;
367 | font-size: 17px;
368 | color: #3CC51F;
369 | white-space: nowrap;
370 | }
371 | .weui-vcode-btn:active {
372 | color: #52a341;
373 | }
374 | .weui-cell_switch {
375 | padding-top: 6px;
376 | padding-bottom: 6px;
377 | }
378 | .weui-uploader__hd {
379 | display: -webkit-box;
380 | display: -webkit-flex;
381 | display: flex;
382 | padding-bottom: 10px;
383 | -webkit-box-align: center;
384 | -webkit-align-items: center;
385 | align-items: center;
386 | }
387 | .weui-uploader__title {
388 | -webkit-box-flex: 1;
389 | -webkit-flex: 1;
390 | flex: 1;
391 | }
392 | .weui-uploader__info {
393 | color: #B2B2B2;
394 | }
395 | .weui-uploader__bd {
396 | margin-bottom: -4px;
397 | margin-right: -9px;
398 | overflow: hidden;
399 | }
400 | .weui-uploader__file {
401 | float: left;
402 | margin-right: 9px;
403 | margin-bottom: 9px;
404 | }
405 | .weui-uploader__img {
406 | display: block;
407 | width: 79px;
408 | height: 79px;
409 | }
410 | .weui-uploader__file_status {
411 | position: relative;
412 | }
413 | .weui-uploader__file_status:before {
414 | content: " ";
415 | position: absolute;
416 | top: 0;
417 | right: 0;
418 | bottom: 0;
419 | left: 0;
420 | background-color: rgba(0, 0, 0, 0.5);
421 | }
422 | .weui-uploader__file-content {
423 | position: absolute;
424 | top: 50%;
425 | left: 50%;
426 | -webkit-transform: translate(-50%, -50%);
427 | transform: translate(-50%, -50%);
428 | color: #FFFFFF;
429 | }
430 | .weui-uploader__input-box {
431 | float: left;
432 | position: relative;
433 | margin-right: 9px;
434 | margin-bottom: 9px;
435 | width: 77px;
436 | height: 77px;
437 | border: 1px solid #D9D9D9;
438 | }
439 | .weui-uploader__input-box:before,
440 | .weui-uploader__input-box:after {
441 | content: " ";
442 | position: absolute;
443 | top: 50%;
444 | left: 50%;
445 | -webkit-transform: translate(-50%, -50%);
446 | transform: translate(-50%, -50%);
447 | background-color: #D9D9D9;
448 | }
449 | .weui-uploader__input-box:before {
450 | width: 2px;
451 | height: 39.5px;
452 | }
453 | .weui-uploader__input-box:after {
454 | width: 39.5px;
455 | height: 2px;
456 | }
457 | .weui-uploader__input-box:active {
458 | border-color: #999999;
459 | }
460 | .weui-uploader__input-box:active:before,
461 | .weui-uploader__input-box:active:after {
462 | background-color: #999999;
463 | }
464 | .weui-uploader__input {
465 | position: absolute;
466 | z-index: 1;
467 | top: 0;
468 | left: 0;
469 | width: 100%;
470 | height: 100%;
471 | opacity: 0;
472 | }
473 | .weui-article {
474 | padding: 20px 15px;
475 | font-size: 15px;
476 | }
477 | .weui-article__section {
478 | margin-bottom: 1.5em;
479 | }
480 | .weui-article__h1 {
481 | font-size: 18px;
482 | font-weight: 400;
483 | margin-bottom: .9em;
484 | }
485 | .weui-article__h2 {
486 | font-size: 16px;
487 | font-weight: 400;
488 | margin-bottom: .34em;
489 | }
490 | .weui-article__h3 {
491 | font-weight: 400;
492 | font-size: 15px;
493 | margin-bottom: .34em;
494 | }
495 | .weui-article__p {
496 | margin: 0 0 .8em;
497 | }
498 | .weui-msg {
499 | padding-top: 36px;
500 | text-align: center;
501 | }
502 | .weui-msg__link {
503 | display: inline;
504 | color: #586C94;
505 | }
506 | .weui-msg__icon-area {
507 | margin-bottom: 30px;
508 | }
509 | .weui-msg__text-area {
510 | margin-bottom: 25px;
511 | padding: 0 20px;
512 | }
513 | .weui-msg__title {
514 | margin-bottom: 5px;
515 | font-weight: 400;
516 | font-size: 20px;
517 | }
518 | .weui-msg__desc {
519 | font-size: 14px;
520 | color: #999999;
521 | }
522 | .weui-msg__opr-area {
523 | margin-bottom: 25px;
524 | }
525 | .weui-msg__extra-area {
526 | margin-bottom: 15px;
527 | font-size: 14px;
528 | color: #999999;
529 | }
530 | @media screen and (min-height: 438px) {
531 | .weui-msg__extra-area {
532 | position: fixed;
533 | left: 0;
534 | bottom: 0;
535 | width: 100%;
536 | text-align: center;
537 | }
538 | }
539 | .weui-flex {
540 | display: -webkit-box;
541 | display: -webkit-flex;
542 | display: flex;
543 | }
544 | .weui-flex__item {
545 | -webkit-box-flex: 1;
546 | -webkit-flex: 1;
547 | flex: 1;
548 | }
549 | .weui-btn {
550 | margin-top: 15px;
551 | }
552 | .weui-btn:first-child {
553 | margin-top: 0;
554 | }
555 | .weui-btn-area {
556 | margin: 1.17647059em 15px 0.3em;
557 | }
558 | .weui-agree {
559 | display: block;
560 | padding: .5em 15px;
561 | font-size: 13px;
562 | }
563 | .weui-agree__text {
564 | color: #999999;
565 | }
566 | .weui-agree__link {
567 | display: inline;
568 | color: #586C94;
569 | }
570 | .weui-agree__checkbox {
571 | position: absolute;
572 | left: -9999px;
573 | }
574 | .weui-agree__checkbox-icon {
575 | position: relative;
576 | top: 2px;
577 | display: inline-block;
578 | border: 1px solid #D1D1D1;
579 | background-color: #FFFFFF;
580 | border-radius: 3px;
581 | width: 11px;
582 | height: 11px;
583 | }
584 | .weui-agree__checkbox-icon-check {
585 | position: absolute;
586 | top: 1px;
587 | left: 1px;
588 | }
589 | .weui-footer {
590 | color: #999999;
591 | font-size: 14px;
592 | text-align: center;
593 | }
594 | .weui-footer_fixed-bottom {
595 | position: fixed;
596 | bottom: .52em;
597 | left: 0;
598 | right: 0;
599 | }
600 | .weui-footer__links {
601 | font-size: 0;
602 | }
603 | .weui-footer__link {
604 | display: inline-block;
605 | vertical-align: top;
606 | margin: 0 .62em;
607 | position: relative;
608 | font-size: 14px;
609 | color: #586C94;
610 | }
611 | .weui-footer__link:before {
612 | content: " ";
613 | position: absolute;
614 | left: 0;
615 | top: 0;
616 | width: 1px;
617 | bottom: 0;
618 | border-left: 1rpx solid #C7C7C7;
619 | color: #C7C7C7;
620 | left: -0.65em;
621 | top: .36em;
622 | bottom: .36em;
623 | }
624 | .weui-footer__link:first-child:before {
625 | display: none;
626 | }
627 | .weui-footer__text {
628 | padding: 0 .34em;
629 | font-size: 12px;
630 | }
631 | .weui-grids {
632 | border-top: 1rpx solid #D9D9D9;
633 | border-left: 1rpx solid #D9D9D9;
634 | overflow: hidden;
635 | }
636 | .weui-grid {
637 | position: relative;
638 | float: left;
639 | padding: 20px 10px;
640 | width: 33.33333333%;
641 | box-sizing: border-box;
642 | border-right: 1rpx solid #D9D9D9;
643 | border-bottom: 1rpx solid #D9D9D9;
644 | }
645 | .weui-grid_active {
646 | background-color: #ECECEC;
647 | }
648 | .weui-grid__icon {
649 | display: block;
650 | width: 28px;
651 | height: 28px;
652 | margin: 0 auto;
653 | }
654 | .weui-grid__label {
655 | margin-top: 5px;
656 | display: block;
657 | text-align: center;
658 | color: #000000;
659 | font-size: 14px;
660 | white-space: nowrap;
661 | text-overflow: ellipsis;
662 | overflow: hidden;
663 | }
664 | .weui-loading {
665 | margin: 0 5px;
666 | width: 20px;
667 | height: 20px;
668 | display: inline-block;
669 | vertical-align: middle;
670 | -webkit-animation: weuiLoading 1s steps(12, end) infinite;
671 | animation: weuiLoading 1s steps(12, end) infinite;
672 | background: transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat;
673 | background-size: 100%;
674 | }
675 | .weui-loading.weui-loading_transparent {
676 | background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 100 100'%3E%3Cpath fill='none' d='M0 0h100v100H0z'/%3E%3Crect xmlns='http://www.w3.org/2000/svg' width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.56)' rx='5' ry='5' transform='translate(0 -30)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.5)' rx='5' ry='5' transform='rotate(30 105.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.43)' rx='5' ry='5' transform='rotate(60 75.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.38)' rx='5' ry='5' transform='rotate(90 65 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.32)' rx='5' ry='5' transform='rotate(120 58.66 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.28)' rx='5' ry='5' transform='rotate(150 54.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.25)' rx='5' ry='5' transform='rotate(180 50 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.2)' rx='5' ry='5' transform='rotate(-150 45.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.17)' rx='5' ry='5' transform='rotate(-120 41.34 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.14)' rx='5' ry='5' transform='rotate(-90 35 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.1)' rx='5' ry='5' transform='rotate(-60 24.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='rgba(255,255,255,.03)' rx='5' ry='5' transform='rotate(-30 -5.98 65)'/%3E%3C/svg%3E");
677 | }
678 | @-webkit-keyframes weuiLoading {
679 | 0% {
680 | -webkit-transform: rotate3d(0, 0, 1, 0deg);
681 | transform: rotate3d(0, 0, 1, 0deg);
682 | }
683 | 100% {
684 | -webkit-transform: rotate3d(0, 0, 1, 360deg);
685 | transform: rotate3d(0, 0, 1, 360deg);
686 | }
687 | }
688 | @keyframes weuiLoading {
689 | 0% {
690 | -webkit-transform: rotate3d(0, 0, 1, 0deg);
691 | transform: rotate3d(0, 0, 1, 0deg);
692 | }
693 | 100% {
694 | -webkit-transform: rotate3d(0, 0, 1, 360deg);
695 | transform: rotate3d(0, 0, 1, 360deg);
696 | }
697 | }
698 | .weui-badge {
699 | display: inline-block;
700 | padding: .15em .4em;
701 | min-width: 8px;
702 | border-radius: 18px;
703 | background-color: #E64340;
704 | color: #FFFFFF;
705 | line-height: 1.2;
706 | text-align: center;
707 | font-size: 12px;
708 | vertical-align: middle;
709 | }
710 | .weui-badge_dot {
711 | padding: .4em;
712 | min-width: 0;
713 | }
714 | .weui-loadmore {
715 | width: 65%;
716 | margin: 1.5em auto;
717 | line-height: 1.6em;
718 | font-size: 14px;
719 | text-align: center;
720 | }
721 | .weui-loadmore__tips {
722 | display: inline-block;
723 | vertical-align: middle;
724 | }
725 | .weui-loadmore_line {
726 | border-top: 1px solid #E5E5E5;
727 | margin-top: 2.4em;
728 | }
729 | .weui-loadmore__tips_in-line {
730 | position: relative;
731 | top: -0.9em;
732 | padding: 0 .55em;
733 | background-color: #FFFFFF;
734 | color: #999999;
735 | }
736 | .weui-loadmore__tips_in-dot {
737 | position: relative;
738 | padding: 0 .16em;
739 | width: 4px;
740 | height: 1.6em;
741 | }
742 | .weui-loadmore__tips_in-dot:before {
743 | content: " ";
744 | position: absolute;
745 | top: 50%;
746 | left: 50%;
747 | margin-top: -1px;
748 | margin-left: -2px;
749 | width: 4px;
750 | height: 4px;
751 | border-radius: 50%;
752 | background-color: #E5E5E5;
753 | }
754 | .weui-panel {
755 | background-color: #FFFFFF;
756 | margin-top: 10px;
757 | position: relative;
758 | overflow: hidden;
759 | }
760 | .weui-panel:first-child {
761 | margin-top: 0;
762 | }
763 | .weui-panel:before {
764 | content: " ";
765 | position: absolute;
766 | left: 0;
767 | top: 0;
768 | right: 0;
769 | height: 1px;
770 | border-top: 1rpx solid #E5E5E5;
771 | color: #E5E5E5;
772 | }
773 | .weui-panel:after {
774 | content: " ";
775 | position: absolute;
776 | left: 0;
777 | bottom: 0;
778 | right: 0;
779 | height: 1px;
780 | border-bottom: 1rpx solid #E5E5E5;
781 | color: #E5E5E5;
782 | }
783 | .weui-panel__hd {
784 | padding: 14px 15px 10px;
785 | color: #999999;
786 | font-size: 13px;
787 | position: relative;
788 | }
789 | .weui-panel__hd:after {
790 | content: " ";
791 | position: absolute;
792 | left: 0;
793 | bottom: 0;
794 | right: 0;
795 | height: 1px;
796 | border-bottom: 1rpx solid #E5E5E5;
797 | color: #E5E5E5;
798 | left: 15px;
799 | }
800 | .weui-media-box {
801 | padding: 15px;
802 | position: relative;
803 | }
804 | .weui-media-box:before {
805 | content: " ";
806 | position: absolute;
807 | left: 0;
808 | top: 0;
809 | right: 0;
810 | height: 1px;
811 | border-top: 1rpx solid #E5E5E5;
812 | color: #E5E5E5;
813 | left: 15px;
814 | }
815 | .weui-media-box:first-child:before {
816 | display: none;
817 | }
818 | .weui-media-box__title {
819 | font-weight: 400;
820 | font-size: 17px;
821 | width: auto;
822 | overflow: hidden;
823 | text-overflow: ellipsis;
824 | white-space: nowrap;
825 | word-wrap: normal;
826 | word-wrap: break-word;
827 | word-break: break-all;
828 | }
829 | .weui-media-box__desc {
830 | color: #999999;
831 | font-size: 13px;
832 | line-height: 1.2;
833 | overflow: hidden;
834 | text-overflow: ellipsis;
835 | display: -webkit-box;
836 | -webkit-box-orient: vertical;
837 | -webkit-line-clamp: 2;
838 | }
839 | .weui-media-box__info {
840 | margin-top: 15px;
841 | padding-bottom: 5px;
842 | font-size: 13px;
843 | color: #CECECE;
844 | line-height: 1em;
845 | list-style: none;
846 | overflow: hidden;
847 | }
848 | .weui-media-box__info__meta {
849 | float: left;
850 | padding-right: 1em;
851 | }
852 | .weui-media-box__info__meta_extra {
853 | padding-left: 1em;
854 | border-left: 1px solid #CECECE;
855 | }
856 | .weui-media-box__title_in-text {
857 | margin-bottom: 8px;
858 | }
859 | .weui-media-box_appmsg {
860 | display: -webkit-box;
861 | display: -webkit-flex;
862 | display: flex;
863 | -webkit-box-align: center;
864 | -webkit-align-items: center;
865 | align-items: center;
866 | }
867 | .weui-media-box__thumb {
868 | width: 100%;
869 | height: 100%;
870 | vertical-align: top;
871 | }
872 | .weui-media-box__hd_in-appmsg {
873 | margin-right: .8em;
874 | width: 60px;
875 | height: 60px;
876 | line-height: 60px;
877 | text-align: center;
878 | }
879 | .weui-media-box__bd_in-appmsg {
880 | -webkit-box-flex: 1;
881 | -webkit-flex: 1;
882 | flex: 1;
883 | min-width: 0;
884 | }
885 | .weui-media-box_small-appmsg {
886 | padding: 0;
887 | }
888 | .weui-cells_in-small-appmsg {
889 | margin-top: 0;
890 | }
891 | .weui-cells_in-small-appmsg:before {
892 | display: none;
893 | }
894 | .weui-progress {
895 | display: -webkit-box;
896 | display: -webkit-flex;
897 | display: flex;
898 | -webkit-box-align: center;
899 | -webkit-align-items: center;
900 | align-items: center;
901 | }
902 | .weui-progress__bar {
903 | -webkit-box-flex: 1;
904 | -webkit-flex: 1;
905 | flex: 1;
906 | }
907 | .weui-progress__opr {
908 | margin-left: 15px;
909 | font-size: 0;
910 | }
911 | .weui-navbar {
912 | display: -webkit-box;
913 | display: -webkit-flex;
914 | display: flex;
915 | position: absolute;
916 | z-index: 500;
917 | top: 0;
918 | width: 100%;
919 | border-bottom: 1rpx solid #CCCCCC;
920 | }
921 | .weui-navbar__item {
922 | position: relative;
923 | display: block;
924 | -webkit-box-flex: 1;
925 | -webkit-flex: 1;
926 | flex: 1;
927 | padding: 13px 0;
928 | text-align: center;
929 | font-size: 0;
930 | }
931 | .weui-navbar__item.weui-bar__item_on {
932 | color: #1AAD19;
933 | }
934 | .weui-navbar__slider {
935 | position: absolute;
936 | content: " ";
937 | left: 0;
938 | bottom: 0;
939 | width: 6em;
940 | height: 3px;
941 | background-color: #1AAD19;
942 | -webkit-transition: -webkit-transform .3s;
943 | transition: -webkit-transform .3s;
944 | transition: transform .3s;
945 | transition: transform .3s, -webkit-transform .3s;
946 | }
947 | .weui-navbar__title {
948 | display: inline-block;
949 | font-size: 15px;
950 | max-width: 8em;
951 | width: auto;
952 | overflow: hidden;
953 | text-overflow: ellipsis;
954 | white-space: nowrap;
955 | word-wrap: normal;
956 | }
957 | .weui-tab {
958 | position: relative;
959 | height: 100%;
960 | }
961 | .weui-tab__panel {
962 | box-sizing: border-box;
963 | height: 100%;
964 | padding-top: 50px;
965 | overflow: auto;
966 | -webkit-overflow-scrolling: touch;
967 | }
968 | .weui-search-bar {
969 | position: relative;
970 | padding: 8px 10px;
971 | display: -webkit-box;
972 | display: -webkit-flex;
973 | display: flex;
974 | box-sizing: border-box;
975 | background-color: #EFEFF4;
976 | border-top: 1rpx solid #D7D6DC;
977 | border-bottom: 1rpx solid #D7D6DC;
978 | }
979 | .weui-icon-search {
980 | margin-right: 8px;
981 | font-size: inherit;
982 | }
983 | .weui-icon-search_in-box {
984 | position: absolute;
985 | left: 10px;
986 | top: 7px;
987 | }
988 | .weui-search-bar__text {
989 | display: inline-block;
990 | font-size: 14px;
991 | vertical-align: middle;
992 | }
993 | .weui-search-bar__form {
994 | position: relative;
995 | -webkit-box-flex: 1;
996 | -webkit-flex: auto;
997 | flex: auto;
998 | border-radius: 5px;
999 | background: #FFFFFF;
1000 | border: 1rpx solid #E6E6EA;
1001 | }
1002 | .weui-search-bar__box {
1003 | position: relative;
1004 | padding-left: 30px;
1005 | padding-right: 30px;
1006 | width: 100%;
1007 | box-sizing: border-box;
1008 | z-index: 1;
1009 | }
1010 | .weui-search-bar__input {
1011 | height: 28px;
1012 | line-height: 28px;
1013 | font-size: 14px;
1014 | }
1015 | .weui-icon-clear {
1016 | position: absolute;
1017 | top: 0;
1018 | right: 0;
1019 | padding: 7px 8px;
1020 | font-size: 0;
1021 | }
1022 | .weui-search-bar__label {
1023 | position: absolute;
1024 | top: 0;
1025 | right: 0;
1026 | bottom: 0;
1027 | left: 0;
1028 | z-index: 2;
1029 | border-radius: 3px;
1030 | text-align: center;
1031 | color: #9B9B9B;
1032 | background: #FFFFFF;
1033 | line-height: 28px;
1034 | }
1035 | .weui-search-bar__cancel-btn {
1036 | margin-left: 10px;
1037 | line-height: 28px;
1038 | color: #09BB07;
1039 | white-space: nowrap;
1040 | }
1041 |
--------------------------------------------------------------------------------
/utils/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bmob/wechatapp-demo/5f3300f09cf9d7ccdd4330de9409160d1c83e491/utils/.DS_Store
--------------------------------------------------------------------------------
/utils/common.js:
--------------------------------------------------------------------------------
1 | function showTip(sms, icon, fun, t) {
2 | if (!t) {
3 | t = 1000;
4 | }
5 | wx.showToast({
6 | title: sms,
7 | icon: icon,
8 | duration: t,
9 | success: fun
10 | })
11 | }
12 |
13 | function showModal(c,t,fun) {
14 | if(!t)
15 | t='提示'
16 | wx.showModal({
17 | title: t,
18 | content: c,
19 | showCancel:false,
20 | success: fun
21 | })
22 | }
23 |
24 |
25 | module.exports.showTip = showTip;
26 | module.exports.showModal = showModal;
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------