diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..115cc02
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,31 @@
+/*
+ * Eslint config file
+ * Documentation: https://eslint.org/docs/user-guide/configuring/
+ * Install the Eslint extension before using this feature.
+ */
+module.exports = {
+ env: {
+ es6: true,
+ browser: true,
+ node: true,
+ },
+ ecmaFeatures: {
+ modules: true,
+ },
+ parserOptions: {
+ ecmaVersion: 2018,
+ sourceType: 'module',
+ },
+ globals: {
+ wx: true,
+ App: true,
+ Page: true,
+ getCurrentPages: true,
+ getApp: true,
+ Component: true,
+ requirePlugin: true,
+ requireMiniProgram: true,
+ },
+ // extends: 'eslint:recommended',
+ rules: {},
+}
diff --git a/README.md b/README.md
index 22b5860..a11daef 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,2 @@
# exercise
-
+
diff --git a/app.js b/app.js
new file mode 100644
index 0000000..1ed57c4
--- /dev/null
+++ b/app.js
@@ -0,0 +1,19 @@
+// app.js
+App({
+ onLaunch() {
+ // 展示本地存储能力
+ const logs = wx.getStorageSync('logs') || []
+ logs.unshift(Date.now())
+ wx.setStorageSync('logs', logs)
+
+ // 登录
+ wx.login({
+ success: res => {
+ // 发送 res.code 到后台换取 openId, sessionKey, unionId
+ }
+ })
+ },
+ globalData: {
+ userInfo: null
+ }
+})
diff --git a/app.json b/app.json
new file mode 100644
index 0000000..042e029
--- /dev/null
+++ b/app.json
@@ -0,0 +1,15 @@
+{
+ "pages": [
+ "pages/index/index",
+ "pages/logs/logs"
+ ],
+ "window": {
+ "navigationBarTextStyle": "black",
+ "navigationBarTitleText": "Weixin",
+ "navigationBarBackgroundColor": "#ffffff"
+ },
+ "style": "v2",
+ "componentFramework": "glass-easel",
+ "sitemapLocation": "sitemap.json",
+ "lazyCodeLoading": "requiredComponents"
+}
diff --git a/app.wxss b/app.wxss
new file mode 100644
index 0000000..06c6fc9
--- /dev/null
+++ b/app.wxss
@@ -0,0 +1,10 @@
+/**app.wxss**/
+.container {
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: space-between;
+ padding: 200rpx 0;
+ box-sizing: border-box;
+}
diff --git a/pages/index/index.js b/pages/index/index.js
new file mode 100644
index 0000000..ed14087
--- /dev/null
+++ b/pages/index/index.js
@@ -0,0 +1,75 @@
+// index.js
+const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
+
+Page({
+ data: {
+ motto: 'Hello World',
+ userInfo: {
+ avatarUrl: defaultAvatarUrl,
+ nickName: '',
+ },
+ hasUserInfo: false,
+ canIUseGetUserProfile: wx.canIUse('getUserProfile'),
+ canIUseNicknameComp: wx.canIUse('input.type.nickname'),
+ },
+ bindViewTap() {
+ wx.navigateTo({
+ url: '../logs/logs'
+ })
+ },
+ onChooseAvatar(e) {
+ const { avatarUrl } = e.detail
+ const { nickName } = this.data.userInfo
+ this.setData({
+ "userInfo.avatarUrl": avatarUrl,
+ hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
+ })
+ },
+ onInputChange(e) {
+ const nickName = e.detail.value
+ const { avatarUrl } = this.data.userInfo
+ this.setData({
+ "userInfo.nickName": nickName,
+ hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
+ })
+ },
+ getUserProfile(e) {
+ // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
+ wx.getUserProfile({
+ desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+ success: (res) => {
+ console.log(res)
+ this.setData({
+ userInfo: res.userInfo,
+ hasUserInfo: true
+ })
+ }
+ })
+ },
+
+ num1: 0,
+ num2: 0,
+ num1Input:function(e){
+ this.num1 = Number(e.detail.value)
+ },
+ num2Input:function(e){
+ this.num2 = Number(e.detail.value)
+ },
+
+ data: {
+ result:''
+ },
+ compare: function (){
+ var str = ''
+ if(this.num1 > this.num2){
+ str = '第1个数大'
+ }else if(this.num1 < this.num2){
+ str = '第2个数大'
+ }else{
+ str = '两数相等'
+ }
+ this.setData({
+ result:str
+ })
+ }
+})
diff --git a/pages/index/index.json b/pages/index/index.json
new file mode 100644
index 0000000..f9b9aa3
--- /dev/null
+++ b/pages/index/index.json
@@ -0,0 +1,3 @@
+{
+ "navigationBarTitleText":"比较数字大小"
+}
\ No newline at end of file
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
new file mode 100644
index 0000000..0ec7f08
--- /dev/null
+++ b/pages/index/index.wxml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+ 昵称
+
+
+
+
+
+ 请使用2.10.4及以上版本基础库
+
+
+
+ {{userInfo.nickName}}
+
+
+
+ {{motto}}
+
+
+
+ 请输入第1个数字:
+
+
+
+ 请输入第2个数字:
+
+
+
+ 比较结果: {{ result }}
+
+
+
+
diff --git a/pages/index/index.wxss b/pages/index/index.wxss
new file mode 100644
index 0000000..3232cb1
--- /dev/null
+++ b/pages/index/index.wxss
@@ -0,0 +1,20 @@
+/**index.wxss**/
+view {
+ margin: 50rpx;
+}
+
+input {
+ width: 600rpx;
+ margin-top: 20rpx;
+ border-bottom: 2rpx solid #ccc;
+}
+
+button {
+ margin: 50rpx;
+}
+
+button {
+ color: #fff;
+ background: #369;
+ letter-spacing: 12rpx;
+}
diff --git a/pages/logs/logs.js b/pages/logs/logs.js
new file mode 100644
index 0000000..85f6aac
--- /dev/null
+++ b/pages/logs/logs.js
@@ -0,0 +1,18 @@
+// logs.js
+const util = require('../../utils/util.js')
+
+Page({
+ data: {
+ logs: []
+ },
+ onLoad() {
+ this.setData({
+ logs: (wx.getStorageSync('logs') || []).map(log => {
+ return {
+ date: util.formatTime(new Date(log)),
+ timeStamp: log
+ }
+ })
+ })
+ }
+})
diff --git a/pages/logs/logs.json b/pages/logs/logs.json
new file mode 100644
index 0000000..b55b5a2
--- /dev/null
+++ b/pages/logs/logs.json
@@ -0,0 +1,4 @@
+{
+ "usingComponents": {
+ }
+}
\ No newline at end of file
diff --git a/pages/logs/logs.wxml b/pages/logs/logs.wxml
new file mode 100644
index 0000000..85cf1bf
--- /dev/null
+++ b/pages/logs/logs.wxml
@@ -0,0 +1,6 @@
+
+
+
+ {{index + 1}}. {{log.date}}
+
+
diff --git a/pages/logs/logs.wxss b/pages/logs/logs.wxss
new file mode 100644
index 0000000..33f9d9e
--- /dev/null
+++ b/pages/logs/logs.wxss
@@ -0,0 +1,16 @@
+page {
+ height: 100vh;
+ display: flex;
+ flex-direction: column;
+}
+.scrollarea {
+ flex: 1;
+ overflow-y: hidden;
+}
+.log-item {
+ margin-top: 20rpx;
+ text-align: center;
+}
+.log-item:last-child {
+ padding-bottom: env(safe-area-inset-bottom);
+}
diff --git a/project.config.json b/project.config.json
new file mode 100644
index 0000000..fb8ab9b
--- /dev/null
+++ b/project.config.json
@@ -0,0 +1,28 @@
+{
+ "compileType": "miniprogram",
+ "libVersion": "trial",
+ "packOptions": {
+ "ignore": [],
+ "include": []
+ },
+ "setting": {
+ "coverView": true,
+ "es6": true,
+ "postcss": true,
+ "minified": true,
+ "enhance": true,
+ "showShadowRootInWxmlPanel": true,
+ "packNpmRelationList": [],
+ "babelSetting": {
+ "ignore": [],
+ "disablePlugins": [],
+ "outputPath": ""
+ }
+ },
+ "condition": {},
+ "editorSetting": {
+ "tabIndent": "auto",
+ "tabSize": 2
+ },
+ "appid": "wx48a8c8faed899379"
+}
\ No newline at end of file
diff --git a/project.private.config.json b/project.private.config.json
new file mode 100644
index 0000000..fd490cf
--- /dev/null
+++ b/project.private.config.json
@@ -0,0 +1,7 @@
+{
+ "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+ "projectname": "miniprogram-6",
+ "setting": {
+ "compileHotReLoad": true
+ }
+}
\ No newline at end of file
diff --git a/rr.png b/rr.png
new file mode 100644
index 0000000..19436eb
Binary files /dev/null and b/rr.png differ
diff --git a/sitemap.json b/sitemap.json
new file mode 100644
index 0000000..ca02add
--- /dev/null
+++ b/sitemap.json
@@ -0,0 +1,7 @@
+{
+ "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
+ "rules": [{
+ "action": "allow",
+ "page": "*"
+ }]
+}
\ No newline at end of file
diff --git a/utils/util.js b/utils/util.js
new file mode 100644
index 0000000..764bc2c
--- /dev/null
+++ b/utils/util.js
@@ -0,0 +1,19 @@
+const formatTime = date => {
+ const year = date.getFullYear()
+ const month = date.getMonth() + 1
+ const day = date.getDate()
+ const hour = date.getHours()
+ const minute = date.getMinutes()
+ const second = date.getSeconds()
+
+ return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
+}
+
+const formatNumber = n => {
+ n = n.toString()
+ return n[1] ? n : `0${n}`
+}
+
+module.exports = {
+ formatTime
+}