正在显示
98 个修改的文件
包含
525 行增加
和
0 行删除
app.js
0 → 100644
1 | +//app.js | ||
2 | +App({ | ||
3 | + onLaunch: function () { | ||
4 | + // 展示本地存储能力 | ||
5 | + var logs = wx.getStorageSync('logs') || [] | ||
6 | + logs.unshift(Date.now()) | ||
7 | + wx.setStorageSync('logs', logs) | ||
8 | + | ||
9 | + // 登录 | ||
10 | + wx.login({ | ||
11 | + success: res => { | ||
12 | + // 发送 res.code 到后台换取 openId, sessionKey, unionId | ||
13 | + } | ||
14 | + }) | ||
15 | + // 获取用户信息 | ||
16 | + wx.getSetting({ | ||
17 | + success: res => { | ||
18 | + if (res.authSetting['scope.userInfo']) { | ||
19 | + // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 | ||
20 | + wx.getUserInfo({ | ||
21 | + success: res => { | ||
22 | + // 可以将 res 发送给后台解码出 unionId | ||
23 | + this.globalData.userInfo = res.userInfo | ||
24 | + | ||
25 | + // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | ||
26 | + // 所以此处加入 callback 以防止这种情况 | ||
27 | + if (this.userInfoReadyCallback) { | ||
28 | + this.userInfoReadyCallback(res) | ||
29 | + } | ||
30 | + } | ||
31 | + }) | ||
32 | + } | ||
33 | + } | ||
34 | + }) | ||
35 | + }, | ||
36 | + globalData: { | ||
37 | + userInfo: null, | ||
38 | + baseUrl: '../../img/' | ||
39 | + } | ||
40 | +}) |
app.json
0 → 100644
1 | +{ | ||
2 | + "pages": [ | ||
3 | + "pages/homeindex/homeindex", | ||
4 | + "pages/index/index", | ||
5 | + "pages/logs/logs", | ||
6 | + | ||
7 | + "pages/kind/kind", | ||
8 | + "pages/mine/mine" | ||
9 | + ], | ||
10 | + "window": { | ||
11 | + "backgroundTextStyle": "light", | ||
12 | + "navigationBarBackgroundColor": "#fff", | ||
13 | + "navigationBarTitleText": "WeChat", | ||
14 | + "navigationBarTextStyle": "black" | ||
15 | + }, | ||
16 | + "tabBar": { | ||
17 | + "selectedColor": "#6EAC3D", | ||
18 | + "list": [ | ||
19 | + { | ||
20 | + "pagePath": "pages/homeindex/homeindex", | ||
21 | + "text": "首页", | ||
22 | + "selectedColor": "#6EAC3D", | ||
23 | + "iconPath": "img/01_nav@2x.png", | ||
24 | + "selectedIconPath": "img/01_nav_fill@2x.png" | ||
25 | + }, | ||
26 | + { | ||
27 | + "pagePath": "pages/kind/kind", | ||
28 | + "text": "分类", | ||
29 | + "selectedColor": "#6EAC3D", | ||
30 | + "iconPath": "img/02_nav@2x.png", | ||
31 | + "selectedIconPath": "img/02_nav_fill@2x.png" | ||
32 | + }, | ||
33 | + | ||
34 | + { | ||
35 | + "pagePath": "pages/mine/mine", | ||
36 | + "text": "我的", | ||
37 | + "selectedColor": "#6EAC3D", | ||
38 | + "iconPath": "img/03_nav@2x.png", | ||
39 | + "selectedIconPath": "img/03_nav_fill@2x.png" | ||
40 | + } | ||
41 | + ] | ||
42 | + } | ||
43 | +} |
app.wxss
0 → 100644
img/01_nav@2x.png
0 → 100644
1.0 KB
img/01_nav@3x.png
0 → 100644
1.5 KB
img/01_nav_fill@2x.png
0 → 100644
1.1 KB
img/01_nav_fill@3x.png
0 → 100644
1.5 KB
img/02_nav@2x.png
0 → 100644
942 字节
img/02_nav@3x.png
0 → 100644
1.3 KB
img/02_nav_fill@2x.png
0 → 100644
1.0 KB
img/02_nav_fill@3x.png
0 → 100644
1.4 KB
img/03_nav@2x.png
0 → 100644
1.1 KB
img/03_nav@3x.png
0 → 100644
1.6 KB
img/03_nav_fill@2x.png
0 → 100644
1.1 KB
img/03_nav_fill@3x.png
0 → 100644
1.6 KB
img/anquan@2x.png
0 → 100644
2.0 KB
img/anquan@3x.png
0 → 100644
3.3 KB
img/baozhang@2x.png
0 → 100644
1.1 KB
img/baozhang@3x.png
0 → 100644
1.5 KB
img/daifahuo@2x.png
0 → 100644
1.9 KB
img/daifahuo@3x.png
0 → 100644
3.2 KB
img/daifukuan@2x.png
0 → 100644
1.6 KB
img/daifukuan@3x.png
0 → 100644
2.7 KB
img/daipingjia@2x.png
0 → 100644
1.4 KB
img/daipingjia@3x.png
0 → 100644
2.2 KB
img/daipintuan@2x.png
0 → 100644
2.0 KB
img/daipintuan@3x.png
0 → 100644
3.0 KB
img/daiwancheng@2x.png
0 → 100644
2.7 KB
img/daiwancheng@3x.png
0 → 100644
4.4 KB
img/dakai@2x.png
0 → 100644
1.2 KB
img/dakai@3x.png
0 → 100644
1.9 KB
img/dingdan @3x.png
0 → 100644
1.2 KB
img/dingdan.png
0 → 100644
461 字节
img/edit@2x.png
0 → 100644
799 字节
img/edit@3x.png
0 → 100644
800 字节
img/fenlei@2x.png
0 → 100644
3.1 KB
img/fenlei@3x.png
0 → 100644
4.6 KB
img/gerenzhingxinbeijing@2x.png
0 → 100644
20.8 KB
img/gerenzhingxinbeijing@3x.png
0 → 100644
34.4 KB
不能预览此文件类型
img/guanbi@2x.png
0 → 100644
1.1 KB
img/guanbi@3x.png
0 → 100644
1.8 KB
img/jujia@2x.png
0 → 100644
3.9 KB
img/jujia@3x.png
0 → 100644
5.9 KB
img/kuaidi@2x.png
0 → 100644
1012 字节
img/kuaidi@3x.png
0 → 100644
1.1 KB
img/lianxiwomen@2x.png
0 → 100644
1.0 KB
img/lianxiwomen@3x.png
0 → 100644
1.8 KB
img/moren@2x.png
0 → 100644
403 字节
img/moren@3x.png
0 → 100644
590 字节
img/riyongsahngpin@2x.png
0 → 100644
3.1 KB
img/riyongsahngpin@3x.png
0 → 100644
4.8 KB
img/shanchu@2x.png
0 → 100644
737 字节
img/shanchu@3x.png
0 → 100644
1.0 KB
img/shanchu_fill@2x.png
0 → 100644
915 字节
img/shanchu_fill@3x.png
0 → 100644
1.3 KB
img/shangjia@2x.png
0 → 100644
545 字节
img/shangjia@3x.png
0 → 100644
612 字节
img/shoucang@2x.png
0 → 100644
1.2 KB
img/shoucang@3x.png
0 → 100644
1.8 KB
img/shuma@2x.png
0 → 100644
3.8 KB
img/shuma@3x.png
0 → 100644
5.8 KB
img/tianjiatupian@2x.png
0 → 100644
648 字节
img/tianjiatupian@3x.png
0 → 100644
937 字节
img/wancheng@2x.png
0 → 100644
7.3 KB
img/wancheng@3x.png
0 → 100644
10.7 KB
img/wde dizhi@2x.png
0 → 100644
1.3 KB
img/wde dizhi@3x.png
0 → 100644
2.1 KB
img/xuanzhong@2x.png
0 → 100644
159 字节
img/xuanzhong@3x.png
0 → 100644
191 字节
img/youxuan@2x.png
0 → 100644
1.6 KB
img/youxuan@3x.png
0 → 100644
2.3 KB
img/zhuzhi@2x.png
0 → 100644
11.0 KB
img/zhuzhi@3x.png
0 → 100644
19.5 KB
img/zuire@2x.png
0 → 100644
904 字节
img/zuire@3x.png
0 → 100644
1.3 KB
pages/homeindex/homeindex.js
0 → 100644
1 | +// pages/homeindex/homeindex.js | ||
2 | +const app=getApp() | ||
3 | +Page({ | ||
4 | + | ||
5 | + /** | ||
6 | + * 页面的初始数据 | ||
7 | + */ | ||
8 | + data: { | ||
9 | + url:'' | ||
10 | + }, | ||
11 | + | ||
12 | + /** | ||
13 | + * 生命周期函数--监听页面加载 | ||
14 | + */ | ||
15 | + onLoad: function (options) { | ||
16 | + this.setData({ | ||
17 | + url: app.globalData.baseUrl | ||
18 | + }) | ||
19 | + | ||
20 | + console.log(this.data.url) | ||
21 | + }, | ||
22 | + | ||
23 | + /** | ||
24 | + * 生命周期函数--监听页面初次渲染完成 | ||
25 | + */ | ||
26 | + onReady: function () { | ||
27 | + | ||
28 | + }, | ||
29 | + | ||
30 | + /** | ||
31 | + * 生命周期函数--监听页面显示 | ||
32 | + */ | ||
33 | + onShow: function () { | ||
34 | + | ||
35 | + }, | ||
36 | + | ||
37 | + /** | ||
38 | + * 生命周期函数--监听页面隐藏 | ||
39 | + */ | ||
40 | + onHide: function () { | ||
41 | + | ||
42 | + }, | ||
43 | + | ||
44 | + /** | ||
45 | + * 生命周期函数--监听页面卸载 | ||
46 | + */ | ||
47 | + onUnload: function () { | ||
48 | + | ||
49 | + }, | ||
50 | + | ||
51 | + /** | ||
52 | + * 页面相关事件处理函数--监听用户下拉动作 | ||
53 | + */ | ||
54 | + onPullDownRefresh: function () { | ||
55 | + | ||
56 | + }, | ||
57 | + | ||
58 | + /** | ||
59 | + * 页面上拉触底事件的处理函数 | ||
60 | + */ | ||
61 | + onReachBottom: function () { | ||
62 | + | ||
63 | + }, | ||
64 | + | ||
65 | + /** | ||
66 | + * 用户点击右上角分享 | ||
67 | + */ | ||
68 | + onShareAppMessage: function () { | ||
69 | + | ||
70 | + } | ||
71 | +}) |
pages/homeindex/homeindex.json
0 → 100644
pages/homeindex/homeindex.wxml
0 → 100644
pages/homeindex/homeindex.wxss
0 → 100644
1 | +/* pages/homeindex/homeindex.wxss */ |
pages/index/index.js
0 → 100644
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 | + | ||
19 | + | ||
20 | + start(e) { | ||
21 | + | ||
22 | + let that = this; | ||
23 | + console.log(e) | ||
24 | + | ||
25 | + // app.globalData.userInfo = e.detail.userInfo | ||
26 | + wx.login({ | ||
27 | + success: (res) => { | ||
28 | + console.log(res) | ||
29 | + | ||
30 | + wx.switchTab({ | ||
31 | + url: '../homeindex/homeindex', | ||
32 | + }) | ||
33 | + // let url = '/api/portal/common/getToken '; | ||
34 | + // let params = { | ||
35 | + // code: res.code, | ||
36 | + // user_nickname: e.detail.userInfo.nickName, | ||
37 | + // avatar: e.detail.userInfo.avatarUrl | ||
38 | + // // user_nickname: e.detail.userInfo.nickName, | ||
39 | + // // avatar: e.detail.userInfo.avatarUrl //分享进入的需要此参数 | ||
40 | + // } | ||
41 | + // app.post(url, params).then((res) => { | ||
42 | + // console.log(res) | ||
43 | + // wx.setStorageSync('token', res.token); | ||
44 | + | ||
45 | + // wx.navigateTo({ | ||
46 | + // url: '../mainindex/mainindex', | ||
47 | + // }) | ||
48 | + | ||
49 | + // }).catch((errMsg) => { | ||
50 | + // // console.log(errMsg) | ||
51 | + // }) | ||
52 | + | ||
53 | + } | ||
54 | + }); | ||
55 | + }, | ||
56 | + onLoad: function () { | ||
57 | + if (app.globalData.userInfo) { | ||
58 | + this.setData({ | ||
59 | + userInfo: app.globalData.userInfo, | ||
60 | + hasUserInfo: true | ||
61 | + }) | ||
62 | + } else if (this.data.canIUse){ | ||
63 | + // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | ||
64 | + // 所以此处加入 callback 以防止这种情况 | ||
65 | + app.userInfoReadyCallback = res => { | ||
66 | + this.setData({ | ||
67 | + userInfo: res.userInfo, | ||
68 | + hasUserInfo: true | ||
69 | + }) | ||
70 | + } | ||
71 | + } else { | ||
72 | + // 在没有 open-type=getUserInfo 版本的兼容处理 | ||
73 | + wx.getUserInfo({ | ||
74 | + success: res => { | ||
75 | + app.globalData.userInfo = res.userInfo | ||
76 | + this.setData({ | ||
77 | + userInfo: res.userInfo, | ||
78 | + hasUserInfo: true | ||
79 | + }) | ||
80 | + } | ||
81 | + }) | ||
82 | + } | ||
83 | + }, | ||
84 | + getUserInfo: function(e) { | ||
85 | + console.log(e) | ||
86 | + app.globalData.userInfo = e.detail.userInfo | ||
87 | + this.setData({ | ||
88 | + userInfo: e.detail.userInfo, | ||
89 | + hasUserInfo: true | ||
90 | + }) | ||
91 | + } | ||
92 | +}) |
pages/index/index.json
0 → 100644
pages/index/index.wxml
0 → 100644
1 | +<button open-type="getUserInfo" bindgetuserinfo='start' class="begin">启动小程序</button> |
pages/index/index.wxss
0 → 100644
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/kind/kind.js
0 → 100644
1 | +// pages/kind/kind.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/kind/kind.json
0 → 100644
pages/kind/kind.wxml
0 → 100644
pages/kind/kind.wxss
0 → 100644
1 | +/* pages/kind/kind.wxss */ |
pages/logs/logs.js
0 → 100644
pages/logs/logs.json
0 → 100644
pages/logs/logs.wxml
0 → 100644
pages/logs/logs.wxss
0 → 100644
pages/mine/mine.js
0 → 100644
1 | +// pages/mine/mine.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/mine/mine.json
0 → 100644
pages/mine/mine.wxml
0 → 100644
pages/mine/mine.wxss
0 → 100644
1 | +/* pages/mine/mine.wxss */ |
project.config.json
0 → 100644
1 | +{ | ||
2 | + "description": "项目配置文件", | ||
3 | + "packOptions": { | ||
4 | + "ignore": [] | ||
5 | + }, | ||
6 | + "setting": { | ||
7 | + "urlCheck": true, | ||
8 | + "es6": true, | ||
9 | + "postcss": true, | ||
10 | + "minified": true, | ||
11 | + "newFeature": true, | ||
12 | + "autoAudits": false | ||
13 | + }, | ||
14 | + "compileType": "miniprogram", | ||
15 | + "libVersion": "2.6.1", | ||
16 | + "appid": "wx909921bcbc810e6b", | ||
17 | + "projectname": "teamprogram", | ||
18 | + "debugOptions": { | ||
19 | + "hidedInDevtools": [] | ||
20 | + }, | ||
21 | + "isGameTourist": false, | ||
22 | + "condition": { | ||
23 | + "search": { | ||
24 | + "current": -1, | ||
25 | + "list": [] | ||
26 | + }, | ||
27 | + "conversation": { | ||
28 | + "current": -1, | ||
29 | + "list": [] | ||
30 | + }, | ||
31 | + "game": { | ||
32 | + "currentL": -1, | ||
33 | + "list": [] | ||
34 | + }, | ||
35 | + "miniprogram": { | ||
36 | + "current": -1, | ||
37 | + "list": [] | ||
38 | + } | ||
39 | + } | ||
40 | +} |
utils/util.js
0 → 100644
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 | +} |
-
请 注册 或 登录 后发表评论