正在显示
17 个修改的文件
包含
507 行增加
和
0 行删除
.idea/misc.xml
0 → 100644
.idea/modules.xml
0 → 100644
.idea/ruiwang.iml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<module type="WEB_MODULE" version="4"> | ||
3 | + <component name="NewModuleRootManager"> | ||
4 | + <content url="file://$MODULE_DIR$"> | ||
5 | + <excludeFolder url="file://$MODULE_DIR$/.tmp" /> | ||
6 | + <excludeFolder url="file://$MODULE_DIR$/temp" /> | ||
7 | + <excludeFolder url="file://$MODULE_DIR$/tmp" /> | ||
8 | + </content> | ||
9 | + <orderEntry type="inheritedJdk" /> | ||
10 | + <orderEntry type="sourceFolder" forTests="false" /> | ||
11 | + </component> | ||
12 | +</module> |
.idea/vcs.xml
0 → 100644
.idea/workspace.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project version="4"> | ||
3 | + <component name="ChangeListManager"> | ||
4 | + <list default="true" id="dcb555bd-0cc1-4389-9bd4-33f6409a2f5e" name="Default Changelist" comment=""> | ||
5 | + <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" /> | ||
6 | + <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" /> | ||
7 | + <change afterPath="$PROJECT_DIR$/.idea/ruiwang.iml" afterDir="false" /> | ||
8 | + <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" /> | ||
9 | + <change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> | ||
10 | + <change afterPath="$PROJECT_DIR$/app.js" afterDir="false" /> | ||
11 | + <change afterPath="$PROJECT_DIR$/app.json" afterDir="false" /> | ||
12 | + <change afterPath="$PROJECT_DIR$/app.wxss" afterDir="false" /> | ||
13 | + <change afterPath="$PROJECT_DIR$/pages/index/index.js" afterDir="false" /> | ||
14 | + <change afterPath="$PROJECT_DIR$/pages/index/index.wxml" afterDir="false" /> | ||
15 | + <change afterPath="$PROJECT_DIR$/pages/index/index.wxss" afterDir="false" /> | ||
16 | + <change afterPath="$PROJECT_DIR$/pages/logs/logs.js" afterDir="false" /> | ||
17 | + <change afterPath="$PROJECT_DIR$/pages/logs/logs.json" afterDir="false" /> | ||
18 | + <change afterPath="$PROJECT_DIR$/pages/logs/logs.wxml" afterDir="false" /> | ||
19 | + <change afterPath="$PROJECT_DIR$/pages/logs/logs.wxss" afterDir="false" /> | ||
20 | + <change afterPath="$PROJECT_DIR$/project.config.json" afterDir="false" /> | ||
21 | + <change afterPath="$PROJECT_DIR$/utils/util.js" afterDir="false" /> | ||
22 | + </list> | ||
23 | + <ignored path="$PROJECT_DIR$/.tmp/" /> | ||
24 | + <ignored path="$PROJECT_DIR$/temp/" /> | ||
25 | + <ignored path="$PROJECT_DIR$/tmp/" /> | ||
26 | + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> | ||
27 | + <option name="SHOW_DIALOG" value="false" /> | ||
28 | + <option name="HIGHLIGHT_CONFLICTS" value="true" /> | ||
29 | + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> | ||
30 | + <option name="LAST_RESOLUTION" value="IGNORE" /> | ||
31 | + </component> | ||
32 | + <component name="FUSProjectUsageTrigger"> | ||
33 | + <session id="-646321641"> | ||
34 | + <usages-collector id="statistics.lifecycle.project"> | ||
35 | + <counts> | ||
36 | + <entry key="project.open.time.0" value="1" /> | ||
37 | + <entry key="project.opened" value="1" /> | ||
38 | + </counts> | ||
39 | + </usages-collector> | ||
40 | + <usages-collector id="statistics.file.extensions.open"> | ||
41 | + <counts> | ||
42 | + <entry key="wxml" value="1" /> | ||
43 | + <entry key="wxss" value="1" /> | ||
44 | + </counts> | ||
45 | + </usages-collector> | ||
46 | + <usages-collector id="statistics.file.types.open"> | ||
47 | + <counts> | ||
48 | + <entry key="PLAIN_TEXT" value="2" /> | ||
49 | + </counts> | ||
50 | + </usages-collector> | ||
51 | + <usages-collector id="statistics.file.extensions.edit"> | ||
52 | + <counts> | ||
53 | + <entry key="wxml" value="33" /> | ||
54 | + </counts> | ||
55 | + </usages-collector> | ||
56 | + <usages-collector id="statistics.file.types.edit"> | ||
57 | + <counts> | ||
58 | + <entry key="PLAIN_TEXT" value="33" /> | ||
59 | + </counts> | ||
60 | + </usages-collector> | ||
61 | + </session> | ||
62 | + </component> | ||
63 | + <component name="FileEditorManager"> | ||
64 | + <leaf> | ||
65 | + <file pinned="false" current-in-tab="true"> | ||
66 | + <entry file="file://$PROJECT_DIR$/pages/index/index.wxml"> | ||
67 | + <provider selected="true" editor-type-id="text-editor"> | ||
68 | + <state relative-caret-position="209"> | ||
69 | + <caret line="11" column="19" selection-start-line="11" selection-start-column="19" selection-end-line="11" selection-end-column="19" /> | ||
70 | + </state> | ||
71 | + </provider> | ||
72 | + </entry> | ||
73 | + </file> | ||
74 | + <file pinned="false" current-in-tab="false"> | ||
75 | + <entry file="file://$PROJECT_DIR$/pages/index/index.wxss"> | ||
76 | + <provider selected="true" editor-type-id="text-editor" /> | ||
77 | + </entry> | ||
78 | + </file> | ||
79 | + </leaf> | ||
80 | + </component> | ||
81 | + <component name="Git.Settings"> | ||
82 | + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> | ||
83 | + </component> | ||
84 | + <component name="IdeDocumentHistory"> | ||
85 | + <option name="CHANGED_PATHS"> | ||
86 | + <list> | ||
87 | + <option value="$PROJECT_DIR$/pages/index/index.wxml" /> | ||
88 | + </list> | ||
89 | + </option> | ||
90 | + </component> | ||
91 | + <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" /> | ||
92 | + <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" /> | ||
93 | + <component name="JsGulpfileManager"> | ||
94 | + <detection-done>true</detection-done> | ||
95 | + <sorting>DEFINITION_ORDER</sorting> | ||
96 | + </component> | ||
97 | + <component name="ProjectFrameBounds" extendedState="6"> | ||
98 | + <option name="x" value="-8" /> | ||
99 | + <option name="y" value="-8" /> | ||
100 | + <option name="width" value="1936" /> | ||
101 | + <option name="height" value="1056" /> | ||
102 | + </component> | ||
103 | + <component name="ProjectView"> | ||
104 | + <navigator proportions="" version="1"> | ||
105 | + <foldersAlwaysOnTop value="true" /> | ||
106 | + </navigator> | ||
107 | + <panes> | ||
108 | + <pane id="ProjectPane"> | ||
109 | + <subPane> | ||
110 | + <expand> | ||
111 | + <path> | ||
112 | + <item name="ruiwang" type="b2602c69:ProjectViewProjectNode" /> | ||
113 | + <item name="ruiwang" type="462c0819:PsiDirectoryNode" /> | ||
114 | + </path> | ||
115 | + <path> | ||
116 | + <item name="ruiwang" type="b2602c69:ProjectViewProjectNode" /> | ||
117 | + <item name="ruiwang" type="462c0819:PsiDirectoryNode" /> | ||
118 | + <item name="pages" type="462c0819:PsiDirectoryNode" /> | ||
119 | + </path> | ||
120 | + <path> | ||
121 | + <item name="ruiwang" type="b2602c69:ProjectViewProjectNode" /> | ||
122 | + <item name="ruiwang" type="462c0819:PsiDirectoryNode" /> | ||
123 | + <item name="pages" type="462c0819:PsiDirectoryNode" /> | ||
124 | + <item name="index" type="462c0819:PsiDirectoryNode" /> | ||
125 | + </path> | ||
126 | + <path> | ||
127 | + <item name="ruiwang" type="b2602c69:ProjectViewProjectNode" /> | ||
128 | + <item name="ruiwang" type="462c0819:PsiDirectoryNode" /> | ||
129 | + <item name="pages" type="462c0819:PsiDirectoryNode" /> | ||
130 | + <item name="logs" type="462c0819:PsiDirectoryNode" /> | ||
131 | + </path> | ||
132 | + <path> | ||
133 | + <item name="ruiwang" type="b2602c69:ProjectViewProjectNode" /> | ||
134 | + <item name="ruiwang" type="462c0819:PsiDirectoryNode" /> | ||
135 | + <item name="utils" type="462c0819:PsiDirectoryNode" /> | ||
136 | + </path> | ||
137 | + </expand> | ||
138 | + <select /> | ||
139 | + </subPane> | ||
140 | + </pane> | ||
141 | + <pane id="Scope" /> | ||
142 | + </panes> | ||
143 | + </component> | ||
144 | + <component name="PropertiesComponent"> | ||
145 | + <property name="WebServerToolWindowFactoryState" value="false" /> | ||
146 | + <property name="last_opened_file_path" value="$PROJECT_DIR$" /> | ||
147 | + <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> | ||
148 | + <property name="nodejs_npm_path_reset_for_default_project" value="true" /> | ||
149 | + </component> | ||
150 | + <component name="RunDashboard"> | ||
151 | + <option name="ruleStates"> | ||
152 | + <list> | ||
153 | + <RuleState> | ||
154 | + <option name="name" value="ConfigurationTypeDashboardGroupingRule" /> | ||
155 | + </RuleState> | ||
156 | + <RuleState> | ||
157 | + <option name="name" value="StatusDashboardGroupingRule" /> | ||
158 | + </RuleState> | ||
159 | + </list> | ||
160 | + </option> | ||
161 | + </component> | ||
162 | + <component name="SvnConfiguration"> | ||
163 | + <configuration /> | ||
164 | + </component> | ||
165 | + <component name="TaskManager"> | ||
166 | + <task active="true" id="Default" summary="Default task"> | ||
167 | + <changelist id="dcb555bd-0cc1-4389-9bd4-33f6409a2f5e" name="Default Changelist" comment="" /> | ||
168 | + <created>1544498457248</created> | ||
169 | + <option name="number" value="Default" /> | ||
170 | + <option name="presentableId" value="Default" /> | ||
171 | + <updated>1544498457248</updated> | ||
172 | + <workItem from="1544498458684" duration="109000" /> | ||
173 | + </task> | ||
174 | + <servers /> | ||
175 | + </component> | ||
176 | + <component name="TimeTrackingManager"> | ||
177 | + <option name="totallyTimeSpent" value="109000" /> | ||
178 | + </component> | ||
179 | + <component name="ToolWindowManager"> | ||
180 | + <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" /> | ||
181 | + <editor active="true" /> | ||
182 | + <layout> | ||
183 | + <window_info id="Favorites" side_tool="true" /> | ||
184 | + <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.16280295" /> | ||
185 | + <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> | ||
186 | + <window_info anchor="bottom" id="Docker" show_stripe_button="false" /> | ||
187 | + <window_info anchor="bottom" id="Version Control" visible="true" weight="0.32899022" /> | ||
188 | + <window_info anchor="bottom" id="Terminal" /> | ||
189 | + <window_info anchor="bottom" id="Event Log" side_tool="true" /> | ||
190 | + <window_info anchor="bottom" id="Message" order="0" /> | ||
191 | + <window_info anchor="bottom" id="Find" order="1" /> | ||
192 | + <window_info anchor="bottom" id="Run" order="2" /> | ||
193 | + <window_info anchor="bottom" id="Debug" order="3" weight="0.4" /> | ||
194 | + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> | ||
195 | + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> | ||
196 | + <window_info anchor="bottom" id="TODO" order="6" /> | ||
197 | + <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> | ||
198 | + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> | ||
199 | + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> | ||
200 | + </layout> | ||
201 | + </component> | ||
202 | + <component name="TypeScriptGeneratedFilesManager"> | ||
203 | + <option name="version" value="1" /> | ||
204 | + </component> | ||
205 | + <component name="Vcs.Log.Tabs.Properties"> | ||
206 | + <option name="TAB_STATES"> | ||
207 | + <map> | ||
208 | + <entry key="MAIN"> | ||
209 | + <value> | ||
210 | + <State> | ||
211 | + <option name="RECENTLY_FILTERED_USER_GROUPS"> | ||
212 | + <collection /> | ||
213 | + </option> | ||
214 | + <option name="RECENTLY_FILTERED_BRANCH_GROUPS"> | ||
215 | + <collection /> | ||
216 | + </option> | ||
217 | + <option name="COLUMN_ORDER"> | ||
218 | + <list> | ||
219 | + <option value="0" /> | ||
220 | + <option value="1" /> | ||
221 | + <option value="2" /> | ||
222 | + <option value="3" /> | ||
223 | + </list> | ||
224 | + </option> | ||
225 | + </State> | ||
226 | + </value> | ||
227 | + </entry> | ||
228 | + </map> | ||
229 | + </option> | ||
230 | + </component> | ||
231 | + <component name="VcsContentAnnotationSettings"> | ||
232 | + <option name="myLimit" value="2678400000" /> | ||
233 | + </component> | ||
234 | + <component name="editorHistoryManager"> | ||
235 | + <entry file="file://$PROJECT_DIR$/pages/index/index.wxss"> | ||
236 | + <provider selected="true" editor-type-id="text-editor" /> | ||
237 | + </entry> | ||
238 | + <entry file="file://$PROJECT_DIR$/pages/index/index.wxml"> | ||
239 | + <provider selected="true" editor-type-id="text-editor"> | ||
240 | + <state relative-caret-position="209"> | ||
241 | + <caret line="11" column="19" selection-start-line="11" selection-start-column="19" selection-end-line="11" selection-end-column="19" /> | ||
242 | + </state> | ||
243 | + </provider> | ||
244 | + </entry> | ||
245 | + </component> | ||
246 | +</project> |
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 | + } | ||
39 | +}) |
app.json
0 → 100644
app.wxss
0 → 100644
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 | + 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 | +}) |
pages/index/index.wxml
0 → 100644
1 | +<!--index.wxml--> | ||
2 | +<view class="container"> | ||
3 | + <view class="userinfo"> | ||
4 | + <button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button> | ||
5 | + <block wx:else> | ||
6 | + <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image> | ||
7 | + <text class="userinfo-nickname">{{userInfo.nickName}}</text> | ||
8 | + </block> | ||
9 | + </view> | ||
10 | + <view class="usermotto"> | ||
11 | + <text class="user-motto">{{motto}}</text> | ||
12 | + <view>1q1111111s</view> | ||
13 | + </view> | ||
14 | +</view> |
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/logs/logs.js
0 → 100644
pages/logs/logs.json
0 → 100644
pages/logs/logs.wxml
0 → 100644
pages/logs/logs.wxss
0 → 100644
project.config.json
0 → 100644
1 | +{ | ||
2 | + "description": "项目配置文件。", | ||
3 | + "setting": { | ||
4 | + "urlCheck": true, | ||
5 | + "es6": true, | ||
6 | + "postcss": true, | ||
7 | + "minified": true, | ||
8 | + "newFeature": true | ||
9 | + }, | ||
10 | + "compileType": "miniprogram", | ||
11 | + "libVersion": "1.6.6", | ||
12 | + "appid": "wxd88427f7f68c3da4", | ||
13 | + "projectname": "ruiwang", | ||
14 | + "condition": { | ||
15 | + "search": { | ||
16 | + "current": -1, | ||
17 | + "list": [] | ||
18 | + }, | ||
19 | + "conversation": { | ||
20 | + "current": -1, | ||
21 | + "list": [] | ||
22 | + }, | ||
23 | + "miniprogram": { | ||
24 | + "current": -1, | ||
25 | + "list": [] | ||
26 | + } | ||
27 | + } | ||
28 | +} |
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 | +} |
-
请 注册 或 登录 后发表评论