作者 吴孟雨

first commit

  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="JavaScriptSettings">
  4 + <option name="languageLevel" value="ES6" />
  5 + </component>
  6 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ProjectModuleManager">
  4 + <modules>
  5 + <module fileurl="file://$PROJECT_DIR$/.idea/科学队长.iml" filepath="$PROJECT_DIR$/.idea/科学队长.iml" />
  6 + </modules>
  7 + </component>
  8 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="VcsDirectoryMappings">
  4 + <mapping directory="$PROJECT_DIR$" vcs="Git" />
  5 + </component>
  6 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ChangeListManager">
  4 + <list default="true" id="75f2dbf1-3658-44f1-8934-8f4aa7a66688" 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/workspace.xml" afterDir="false" />
  8 + <change afterPath="$PROJECT_DIR$/.idea/科学队长.iml" afterDir="false" />
  9 + <change afterPath="$PROJECT_DIR$/app.js" afterDir="false" />
  10 + <change afterPath="$PROJECT_DIR$/app.json" afterDir="false" />
  11 + <change afterPath="$PROJECT_DIR$/app.wxss" afterDir="false" />
  12 + <change afterPath="$PROJECT_DIR$/pages/index/index.js" afterDir="false" />
  13 + <change afterPath="$PROJECT_DIR$/pages/index/index.wxml" afterDir="false" />
  14 + <change afterPath="$PROJECT_DIR$/pages/index/index.wxss" afterDir="false" />
  15 + <change afterPath="$PROJECT_DIR$/pages/logs/logs.js" afterDir="false" />
  16 + <change afterPath="$PROJECT_DIR$/pages/logs/logs.json" afterDir="false" />
  17 + <change afterPath="$PROJECT_DIR$/pages/logs/logs.wxml" afterDir="false" />
  18 + <change afterPath="$PROJECT_DIR$/pages/logs/logs.wxss" afterDir="false" />
  19 + <change afterPath="$PROJECT_DIR$/project.config.json" afterDir="false" />
  20 + <change afterPath="$PROJECT_DIR$/utils/util.js" afterDir="false" />
  21 + </list>
  22 + <ignored path="$PROJECT_DIR$/.tmp/" />
  23 + <ignored path="$PROJECT_DIR$/temp/" />
  24 + <ignored path="$PROJECT_DIR$/tmp/" />
  25 + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
  26 + <option name="SHOW_DIALOG" value="false" />
  27 + <option name="HIGHLIGHT_CONFLICTS" value="true" />
  28 + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
  29 + <option name="LAST_RESOLUTION" value="IGNORE" />
  30 + </component>
  31 + <component name="FUSProjectUsageTrigger">
  32 + <session id="-1325251825">
  33 + <usages-collector id="statistics.lifecycle.project">
  34 + <counts>
  35 + <entry key="project.open.time.1" value="1" />
  36 + <entry key="project.opened" value="1" />
  37 + </counts>
  38 + </usages-collector>
  39 + <usages-collector id="statistics.file.extensions.open">
  40 + <counts>
  41 + <entry key="wxml" value="1" />
  42 + </counts>
  43 + </usages-collector>
  44 + <usages-collector id="statistics.file.types.open">
  45 + <counts>
  46 + <entry key="HTML" value="1" />
  47 + </counts>
  48 + </usages-collector>
  49 + </session>
  50 + </component>
  51 + <component name="FileEditorManager">
  52 + <leaf>
  53 + <file pinned="false" current-in-tab="true">
  54 + <entry file="file://$PROJECT_DIR$/pages/index/index.wxml">
  55 + <provider selected="true" editor-type-id="text-editor">
  56 + <state relative-caret-position="286">
  57 + <caret line="13" lean-forward="true" selection-start-line="13" selection-end-line="13" />
  58 + </state>
  59 + </provider>
  60 + </entry>
  61 + </file>
  62 + </leaf>
  63 + </component>
  64 + <component name="Git.Settings">
  65 + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  66 + </component>
  67 + <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
  68 + <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
  69 + <component name="JsGulpfileManager">
  70 + <detection-done>true</detection-done>
  71 + <sorting>DEFINITION_ORDER</sorting>
  72 + </component>
  73 + <component name="ProjectFrameBounds" extendedState="6">
  74 + <option name="x" value="-8" />
  75 + <option name="width" value="1936" />
  76 + <option name="height" value="1047" />
  77 + </component>
  78 + <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
  79 + <component name="ProjectView">
  80 + <navigator proportions="" version="1">
  81 + <foldersAlwaysOnTop value="true" />
  82 + </navigator>
  83 + <panes>
  84 + <pane id="ProjectPane">
  85 + <subPane>
  86 + <expand>
  87 + <path>
  88 + <item name="科学队长" type="b2602c69:ProjectViewProjectNode" />
  89 + <item name="科学队长" type="462c0819:PsiDirectoryNode" />
  90 + </path>
  91 + <path>
  92 + <item name="科学队长" type="b2602c69:ProjectViewProjectNode" />
  93 + <item name="科学队长" type="462c0819:PsiDirectoryNode" />
  94 + <item name="pages" type="462c0819:PsiDirectoryNode" />
  95 + </path>
  96 + <path>
  97 + <item name="科学队长" type="b2602c69:ProjectViewProjectNode" />
  98 + <item name="科学队长" type="462c0819:PsiDirectoryNode" />
  99 + <item name="pages" type="462c0819:PsiDirectoryNode" />
  100 + <item name="index" type="462c0819:PsiDirectoryNode" />
  101 + </path>
  102 + </expand>
  103 + <select />
  104 + </subPane>
  105 + </pane>
  106 + <pane id="Scope" />
  107 + </panes>
  108 + </component>
  109 + <component name="PropertiesComponent">
  110 + <property name="WebServerToolWindowFactoryState" value="false" />
  111 + <property name="last_opened_file_path" value="$PROJECT_DIR$" />
  112 + <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
  113 + <property name="nodejs_npm_path_reset_for_default_project" value="true" />
  114 + </component>
  115 + <component name="RunDashboard">
  116 + <option name="ruleStates">
  117 + <list>
  118 + <RuleState>
  119 + <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
  120 + </RuleState>
  121 + <RuleState>
  122 + <option name="name" value="StatusDashboardGroupingRule" />
  123 + </RuleState>
  124 + </list>
  125 + </option>
  126 + </component>
  127 + <component name="SvnConfiguration">
  128 + <configuration />
  129 + </component>
  130 + <component name="TaskManager">
  131 + <task active="true" id="Default" summary="Default task">
  132 + <changelist id="75f2dbf1-3658-44f1-8934-8f4aa7a66688" name="Default Changelist" comment="" />
  133 + <created>1541813457161</created>
  134 + <option name="number" value="Default" />
  135 + <option name="presentableId" value="Default" />
  136 + <updated>1541813457161</updated>
  137 + <workItem from="1541813458425" duration="326000" />
  138 + </task>
  139 + <servers />
  140 + </component>
  141 + <component name="TimeTrackingManager">
  142 + <option name="totallyTimeSpent" value="326000" />
  143 + </component>
  144 + <component name="ToolWindowManager">
  145 + <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
  146 + <editor active="true" />
  147 + <layout>
  148 + <window_info id="Favorites" side_tool="true" />
  149 + <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.12170706" />
  150 + <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
  151 + <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
  152 + <window_info active="true" anchor="bottom" id="Version Control" visible="true" weight="0.329718" />
  153 + <window_info anchor="bottom" id="Terminal" />
  154 + <window_info anchor="bottom" id="Event Log" side_tool="true" />
  155 + <window_info anchor="bottom" id="Message" order="0" />
  156 + <window_info anchor="bottom" id="Find" order="1" />
  157 + <window_info anchor="bottom" id="Run" order="2" />
  158 + <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
  159 + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
  160 + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
  161 + <window_info anchor="bottom" id="TODO" order="6" />
  162 + <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
  163 + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
  164 + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
  165 + </layout>
  166 + </component>
  167 + <component name="TypeScriptGeneratedFilesManager">
  168 + <option name="version" value="1" />
  169 + </component>
  170 + <component name="Vcs.Log.Tabs.Properties">
  171 + <option name="TAB_STATES">
  172 + <map>
  173 + <entry key="MAIN">
  174 + <value>
  175 + <State>
  176 + <option name="RECENTLY_FILTERED_USER_GROUPS">
  177 + <collection />
  178 + </option>
  179 + <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
  180 + <collection />
  181 + </option>
  182 + <option name="COLUMN_ORDER">
  183 + <list>
  184 + <option value="0" />
  185 + <option value="1" />
  186 + <option value="2" />
  187 + <option value="3" />
  188 + </list>
  189 + </option>
  190 + </State>
  191 + </value>
  192 + </entry>
  193 + </map>
  194 + </option>
  195 + </component>
  196 + <component name="VcsContentAnnotationSettings">
  197 + <option name="myLimit" value="2678400000" />
  198 + </component>
  199 + <component name="editorHistoryManager">
  200 + <entry file="file://$PROJECT_DIR$/pages/index/index.wxml">
  201 + <provider selected="true" editor-type-id="text-editor">
  202 + <state relative-caret-position="286">
  203 + <caret line="13" lean-forward="true" selection-start-line="13" selection-end-line="13" />
  204 + </state>
  205 + </provider>
  206 + </entry>
  207 + </component>
  208 +</project>
  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>
  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 +})
  1 +{
  2 + "pages":[
  3 + "pages/index/index",
  4 + "pages/logs/logs"
  5 + ],
  6 + "window":{
  7 + "backgroundTextStyle":"light",
  8 + "navigationBarBackgroundColor": "#fff",
  9 + "navigationBarTitleText": "WeChat",
  10 + "navigationBarTextStyle":"black"
  11 + }
  12 +}
  1 +/**app.wxss**/
  2 +.container {
  3 + height: 100%;
  4 + display: flex;
  5 + flex-direction: column;
  6 + align-items: center;
  7 + justify-content: space-between;
  8 + padding: 200rpx 0;
  9 + box-sizing: border-box;
  10 +}
  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 +})
  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}}" mode="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>
  13 +</view>
  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 +}
  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 +})
  1 +{
  2 + "navigationBarTitleText": "查看启动日志"
  3 +}
  1 +<!--logs.wxml-->
  2 +<view class="container log-list">
  3 + <block wx:for="{{logs}}" wx:for-item="log">
  4 + <text class="log-item">{{index + 1}}. {{log}}</text>
  5 + </block>
  6 +</view>
  1 +.log-list {
  2 + display: flex;
  3 + flex-direction: column;
  4 + padding: 40rpx;
  5 +}
  6 +.log-item {
  7 + margin: 10rpx;
  8 +}
  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 + },
  13 + "compileType": "miniprogram",
  14 + "libVersion": "2.4.0",
  15 + "appid": "wxaab44bbcfc0e5bc5",
  16 + "projectname": "%E7%A7%91%E5%AD%A6%E9%98%9F%E9%95%BF",
  17 + "debugOptions": {
  18 + "hidedInDevtools": []
  19 + },
  20 + "isGameTourist": false,
  21 + "condition": {
  22 + "search": {
  23 + "current": -1,
  24 + "list": []
  25 + },
  26 + "conversation": {
  27 + "current": -1,
  28 + "list": []
  29 + },
  30 + "game": {
  31 + "currentL": -1,
  32 + "list": []
  33 + },
  34 + "miniprogram": {
  35 + "current": -1,
  36 + "list": []
  37 + }
  38 + }
  39 +}
  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 +}