diff --git a/app.js b/app.js
new file mode 100644
index 0000000..b545190
--- /dev/null
+++ b/app.js
@@ -0,0 +1,39 @@
+//app.js
+App({
+ onLaunch: function () {
+ // 展示本地存储能力
+ var logs = wx.getStorageSync('logs') || []
+ logs.unshift(Date.now())
+ wx.setStorageSync('logs', logs)
+
+ // 登录
+ wx.login({
+ success: res => {
+ // 发送 res.code 到后台换取 openId, sessionKey, unionId
+ }
+ })
+ // 获取用户信息
+ wx.getSetting({
+ success: res => {
+ if (res.authSetting['scope.userInfo']) {
+ // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
+ wx.getUserInfo({
+ success: res => {
+ // 可以将 res 发送给后台解码出 unionId
+ this.globalData.userInfo = res.userInfo
+
+ // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+ // 所以此处加入 callback 以防止这种情况
+ if (this.userInfoReadyCallback) {
+ this.userInfoReadyCallback(res)
+ }
+ }
+ })
+ }
+ }
+ })
+ },
+ globalData: {
+ userInfo: null
+ }
+})
\ No newline at end of file
diff --git a/app.json b/app.json
new file mode 100644
index 0000000..3d7616f
--- /dev/null
+++ b/app.json
@@ -0,0 +1,14 @@
+{
+ "pages":[
+ "pages/index/index",
+ "pages/logs/logs"
+ ],
+ "window":{
+ "backgroundTextStyle":"light",
+ "navigationBarBackgroundColor": "#fff",
+ "navigationBarTitleText": "Weixin",
+ "navigationBarTextStyle":"black"
+ },
+ "style": "v2",
+ "sitemapLocation": "sitemap.json"
+}
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..efdf9ee
--- /dev/null
+++ b/pages/index/index.js
@@ -0,0 +1,77 @@
+//index.js
+//获取应用实例
+const rpn = require("../../utils/rpn.js");
+const app = getApp()
+
+Page({
+ data: {
+ ztNum:[
+ 'C','⇦','%','÷',
+ '7','8','9','×',
+ '4','5','6','-',
+ '1','2','3','+',
+ ' ','0','.','='
+ ],
+ screenData:0
+ },
+ click:function(e){
+ var index = e.currentTarget.dataset.index;
+
+ var screenData = this.data.screenData;
+ if(index == 0){
+ this.setData({
+ screenData:'0'
+ })
+ }
+
+ if(index == 1){
+ var screenData = screenData + '';
+ var screenData = screenData.substr(0,screenData.length -1);
+ var screenData = screenData?screenData:'0';
+ this.setData({
+ screenData:screenData
+ })
+ }
+
+ if(index == 2){
+ var screenData = screenData / 100;
+ this.setData({
+ screenData:screenData
+ })
+ }
+
+ if((index % 4 == 3 && index != 19) || index == 18){
+ var arr = ['.','+','-','×','÷'];
+ var screenData = screenData + '';
+ if(arr.indexOf(screenData.substr(-1,1)) == '-1' && screenData!= '0'){
+ var screenData = screenData + e.currentTarget.dataset.text;
+ this.setData({
+ screenData:screenData
+ })
+ }
+ }
+ if(index >= 4 && index <18 && index %4 !=3 && index !=16){
+ if(screenData == 0){
+ var screenData = e.currentTarget.dataset.text;
+ }
+ else{
+ var screenData = screenData + e.currentTarget.dataset.text;
+ }
+ this.setData({
+ screenData:screenData
+ })
+ }
+ if(index == 19){
+ var result = rpn.calCommonExp(screenData);
+ this.setData({
+ screenData:result
+ })
+ }
+
+ }
+})
+/*写个小作文:
+整个小程序就是各种杂七杂八到处偷师学艺搞出来的,其实还有很多不行的地方。
+比如说:数字太多它不会自动跳行,我也找不到解决方法了。
+看了一下其他朋友的小程序 我沉默了。“我怎么不一开始就这样写!!我现在只能跪着走完这条路了 TAT ”
+*/
diff --git a/pages/index/index.json b/pages/index/index.json
new file mode 100644
index 0000000..8835af0
--- /dev/null
+++ b/pages/index/index.json
@@ -0,0 +1,3 @@
+{
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
new file mode 100644
index 0000000..137f5f6
--- /dev/null
+++ b/pages/index/index.wxml
@@ -0,0 +1,10 @@
+
+
+ {{screenData}}
+
+
+
+ {{item}}
+
+
+
diff --git a/pages/index/index.wxss b/pages/index/index.wxss
new file mode 100644
index 0000000..fdaa697
--- /dev/null
+++ b/pages/index/index.wxss
@@ -0,0 +1,36 @@
+/**index.wxss**/
+.screen{
+ width:95%;
+ margin:0 auto;
+ height:240px;
+ line-height:350px;
+ text-align:right;
+ font-size: 380%;
+}
+.zt{
+ font-family: Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Arial,sans-serif;
+ font-size: 200%;
+ width:95%;
+ margin:0 auto;
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: space-around;
+}
+.zt .ztit{
+width:170rpx;
+height:170rpx;
+line-height:170rpx;
+margin-bottom:15rpx;
+/*background:orange;*/
+text-align: center;
+border-radius: 50%;
+}
+.gray{
+ color:white;
+ background:orange;
+
+}
+.white{
+ color:rgb(46, 45, 45);
+ background: rgb(184, 183, 183);
+}
\ No newline at end of file
diff --git a/pages/logs/logs.js b/pages/logs/logs.js
new file mode 100644
index 0000000..b2b967d
--- /dev/null
+++ b/pages/logs/logs.js
@@ -0,0 +1,15 @@
+//logs.js
+const util = require('../../utils/util.js')
+
+Page({
+ data: {
+ logs: []
+ },
+ onLoad: function () {
+ this.setData({
+ logs: (wx.getStorageSync('logs') || []).map(log => {
+ return util.formatTime(new Date(log))
+ })
+ })
+ }
+})
diff --git a/pages/logs/logs.json b/pages/logs/logs.json
new file mode 100644
index 0000000..3ee76c1
--- /dev/null
+++ b/pages/logs/logs.json
@@ -0,0 +1,4 @@
+{
+ "navigationBarTitleText": "查看启动日志",
+ "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..b5a85ac
--- /dev/null
+++ b/pages/logs/logs.wxml
@@ -0,0 +1,6 @@
+
+
+
+ {{index + 1}}. {{log}}
+
+
diff --git a/pages/logs/logs.wxss b/pages/logs/logs.wxss
new file mode 100644
index 0000000..94d4b88
--- /dev/null
+++ b/pages/logs/logs.wxss
@@ -0,0 +1,8 @@
+.log-list {
+ display: flex;
+ flex-direction: column;
+ padding: 40rpx;
+}
+.log-item {
+ margin: 10rpx;
+}
diff --git a/project.config.json b/project.config.json
new file mode 100644
index 0000000..30f4f62
--- /dev/null
+++ b/project.config.json
@@ -0,0 +1,72 @@
+{
+ "description": "项目配置文件",
+ "packOptions": {
+ "ignore": []
+ },
+ "setting": {
+ "urlCheck": true,
+ "es6": true,
+ "enhance": false,
+ "postcss": true,
+ "preloadBackgroundData": false,
+ "minified": true,
+ "newFeature": false,
+ "coverView": true,
+ "nodeModules": false,
+ "autoAudits": false,
+ "showShadowRootInWxmlPanel": true,
+ "scopeDataCheck": false,
+ "uglifyFileName": false,
+ "checkInvalidKey": true,
+ "checkSiteMap": true,
+ "uploadWithSourceMap": true,
+ "compileHotReLoad": false,
+ "useMultiFrameRuntime": false,
+ "useApiHook": true,
+ "babelSetting": {
+ "ignore": [],
+ "disablePlugins": [],
+ "outputPath": ""
+ },
+ "enableEngineNative": false,
+ "bundle": false,
+ "useIsolateContext": true,
+ "useCompilerModule": true,
+ "userConfirmedUseCompilerModuleSwitch": false,
+ "userConfirmedBundleSwitch": false,
+ "packNpmManually": false,
+ "packNpmRelationList": [],
+ "minifyWXSS": true
+ },
+ "compileType": "miniprogram",
+ "libVersion": "2.14.1",
+ "appid": "wx6410544054da3d2a",
+ "projectname": "miniprogram-1",
+ "debugOptions": {
+ "hidedInDevtools": []
+ },
+ "scripts": {},
+ "isGameTourist": false,
+ "simulatorType": "wechat",
+ "simulatorPluginLibVersion": {},
+ "condition": {
+ "search": {
+ "list": []
+ },
+ "conversation": {
+ "list": []
+ },
+ "game": {
+ "list": []
+ },
+ "plugin": {
+ "list": []
+ },
+ "gamePlugin": {
+ "list": []
+ },
+ "miniprogram": {
+ "list": []
+ }
+ }
+}
\ No newline at end of file
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/rpn.js b/utils/rpn.js
new file mode 100644
index 0000000..2d1b5d3
--- /dev/null
+++ b/utils/rpn.js
@@ -0,0 +1,103 @@
+function isOperator(value) {
+ var operatorString = '+-*/()×÷';
+ return operatorString.indexOf(value) > -1;
+}
+
+function getPrioraty(value) {
+ if (value == '-' || value == '+') {
+ return 1;
+ } else if (value == '*' || value == '/' || value == '×' || value == '÷') {
+ return 2;
+ } else {
+ return 0;
+ }
+}
+
+function prioraty(v1, v2) {
+ return getPrioraty(v1) <= getPrioraty(v2);
+}
+
+function outputRpn(exp) {
+ var inputStack = [];
+ var outputStack = [];
+ var outputQueue = [];
+ var firstIsOperator = false;
+ exp.replace(/\s/g, '');
+ if (isOperator(exp[0])) {
+ exp = exp.substring(1);
+ firstIsOperator = true;
+ }
+ for (var i = 0, max = exp.length; i < max; i++) {
+ if (!isOperator(exp[i]) && !isOperator(exp[i - 1]) && (i != 0)) {
+ inputStack[inputStack.length - 1] = inputStack[inputStack.length - 1] + exp[i] + '';
+ } else {
+ inputStack.push(exp[i]);
+ }
+ }
+ if (firstIsOperator) {
+ inputStack[0] = -inputStack[0]
+ }
+ while (inputStack.length > 0) {
+ var cur = inputStack.shift();
+ if (isOperator(cur)) {
+ if (cur == '(') {
+ outputStack.push(cur);
+ } else if (cur == ')') {
+ var po = outputStack.pop();
+ while (po != '(' && outputStack.length > 0) {
+ outputQueue.push(po);
+ po = outputStack.pop();
+ }
+ } else {
+ while (prioraty(cur, outputStack[outputStack.length - 1]) && outputStack.length > 0) {
+ outputQueue.push(outputStack.pop());
+ }
+ outputStack.push(cur)
+ }
+ } else {
+ outputQueue.push(Number(cur));
+ }
+ }
+ if (outputStack.length > 0) {
+ while (outputStack.length > 0) {
+ outputQueue.push(outputStack.pop());
+ }
+ }
+ return outputQueue;
+}
+
+function calRpnExp(rpnArr) {
+ var stack = [];
+ for (var i = 0, max = rpnArr.length; i < max; i++) {
+ if (!isOperator(rpnArr[i])) {
+ stack.push(rpnArr[i]);
+ } else {
+ var num1 = stack.pop();
+ var num2 = stack.pop();
+ if (rpnArr[i] == '-') {
+ var num = num2 - num1;
+ } else if (rpnArr[i] == '+') {
+ var num = num2 + num1;
+ } else if (rpnArr[i] == '*' || rpnArr[i] == '×') {
+ var num = num2 * num1;
+ } else if (rpnArr[i] == '/' || rpnArr[i] == '÷') {
+ var num = num2 / num1;
+ }
+ stack.push(num);
+ }
+ }
+ return stack[0];
+}
+
+function calCommonExp(exp) {
+ var rpnArr = outputRpn(exp);
+ return calRpnExp(rpnArr)
+}
+
+module.exports = {
+ isOperator: isOperator,
+ getPrioraty: getPrioraty,
+ outputRpn: outputRpn,
+ calRpnExp: calRpnExp,
+ calCommonExp: calCommonExp
+}
\ No newline at end of file
diff --git a/utils/util.js b/utils/util.js
new file mode 100644
index 0000000..dbadbb8
--- /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: formatTime
+}