diff --git a/miniprogram-3/app.js b/miniprogram-3/app.js new file mode 100644 index 0000000000000000000000000000000000000000..d773a34e4fb45d62583f98d2d8b663a80ec95af9 --- /dev/null +++ b/miniprogram-3/app.js @@ -0,0 +1,10 @@ +// app.js +App({ + onLaunch() { + // 展示本地存储能力 + + }, + globalData: { + userInfo: null + } +}) diff --git a/miniprogram-3/app.json b/miniprogram-3/app.json new file mode 100644 index 0000000000000000000000000000000000000000..289c48907c7ca48e09050515d249be87cdbe3270 --- /dev/null +++ b/miniprogram-3/app.json @@ -0,0 +1,13 @@ +{ + "pages":[ + "pages/add/add" + ], + "window":{ + "backgroundTextStyle":"light", + "navigationBarBackgroundColor": "#fff", + "navigationBarTitleText": "计算器", + "navigationBarTextStyle":"black" + }, + "style": "v2", + "sitemapLocation": "sitemap.json" +} diff --git a/miniprogram-3/app.wxss b/miniprogram-3/app.wxss new file mode 100644 index 0000000000000000000000000000000000000000..06c6fc9ce35b7d02e031b1e8f4636147321dedc1 --- /dev/null +++ b/miniprogram-3/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/miniprogram-3/pages/add/add.js b/miniprogram-3/pages/add/add.js new file mode 100644 index 0000000000000000000000000000000000000000..b0868f7a4c7f1fc1601ff15b2ee5c862f348550e --- /dev/null +++ b/miniprogram-3/pages/add/add.js @@ -0,0 +1,193 @@ +// pages/add/add.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + input:'',//输入字符串 + outcome:'',//输出结果 + button:[ + {class:'style-one',tap:'taptwo',id:'sin'}, + {class:'style-one',tap:'taptwo',id:'cos'}, + {class:'style-one',tap:'taptwo',id:'tan'}, + {class:'style-one',tap:'taptwo',id:'lg'}, + {class:'style-one',tap:'taptwo',id:'ln'}, + {class:'style-one',tap:'taptwo',id:'e'}, + {class:'style-one',tap:'taptwo',id:'√'}, + {class:'style-two',tap:'clear',id:'C'}, + {class:'style-one',tap:'taptwo',id:'7'}, + {class:'style-one',tap:'taptwo',id:'4'}, + {class:'style-one',tap:'taptwo',id:'1'}, + {class:'style-one',tap:'taptwo',id:'%'}, + {class:'style-one',tap:'tapthree',id:'x^'}, + {class:'style-two',tap:'taptwo',id:'÷'}, + {class:'style-one',tap:'taptwo',id:'8'}, + {class:'style-one',tap:'taptwo',id:'5'}, + {class:'style-one',tap:'taptwo',id:'2'}, + {class:'style-one',tap:'taptwo',id:'0'}, + {class:'style-one',tap:'tapthree',id:'x²'}, + {class:'style-two',tap:'taptwo',id:'×'}, + {class:'style-one',tap:'taptwo',id:'9'}, + {class:'style-one',tap:'taptwo',id:'6'}, + {class:'style-one',tap:'taptwo',id:'3'}, + {class:'style-one',tap:'taptwo',id:'.'}, + {class:'style-one',tap:'taptwo',id:'Π'}, + {class:'style-two',tap:'delete',id:'<<'}, + {class:'style-two',tap:'taptwo',id:'-'}, + {class:'style-two',tap:'taptwo',id:'+'}, + {class:'style-three',tap:'finish',id:'='} + ] + }, + taptwo(e){ + // 通过id的确定按键并修改字符串 + this.setData({ + input:this.data.input+e.currentTarget.dataset.id + }) + }, + tapthree(e){ + // 单独处理次方输入 + var str=e.currentTarget.dataset.id + str=str==="x^"?"^":"²" + console.log(str); + this.setData({ + input:this.data.input+str + }) + }, + clear(){ + // 清空字符串 + this.setData({ + input:'' + }) + }, + delete(){ + // 后退一格 + var str=this.data.input + str=str.substring(0,str.length-1) + this.setData({ + input:str + }) + }, + finish(){ + // 字符串处理 + var str=this.data.input + if(str.charAt(0)=="-"&&str.charAt(1)=="-"){ + str=str.substring(2,) + } + str=str.replace(/(\d+)+\%/g,function(a,b){ + return Number(b)*0.01 + }).replace(/e/g,"2.7182818285").replace(/Π/g,"3.1415926535") + str=str.replace(/√+((\d+\.\d+)|(\d+))/g,function(a,b){ + return Math.sqrt(Number(b)) + }).replace(/((\d+\.\d+)|(\d+))+²/g,function(a,b){ + return Math.pow(Number(b),2) + }) + str=str.replace(/((\d+\.\d+)|(\d+))+\^(\d+)/g,function(a,b,c,d,e){ + console.log(a,b,c,d,e); + return Math.pow(Number(d),Number(e)) + }) + str=str.replace(/ln+((\d+\.\d+)|(\d+))/g,function(a,b){ + return Math.log(Number(b)) + }).replace(/lg+((\d+\.\d+)|(\d+))/g,function(a,b){ + return Math.log10(Number(b)) + }) + str=str.replace(/sin+((\d+\.\d+)|(\d+))/g,function(a,b){ + return Math.sin(Number(b)) + }).replace(/cos+((\d+\.\d+)|(\d+))/g,function(a,b){ + return Math.cos(Number(b)) + }).replace(/tan+((\d+\.\d+)|(\d+))/g,function(a,b){ + return Math.tan(Number(b)) + }) +// 处理乘除加减 + while(str.indexOf("\×")!=-1){ + //var out=str + str=str.replace(/((\d+\.\d+)|(\d+))+×+((\d+\.\d+)|(\d+))/,function(a,b,c,d,e){ + return Number(d)*Number(e) + }) + //if(out===str) break + } + while(str.indexOf("\÷")!=-1){ + str=str.replace(/((\d+\.\d+)|(\d+))+÷+((\d+\.\d+)|(\d+))/,function(a,b,c,d,e){ + return Number(d)/Number(e) + }) + } + while(1){ + var out=str + str=str.replace(/((\d+\.\d+)|(\d+))+((\+)|(\-))+((\d+\.\d+)|(\d+))/,function(a,b,c,d,e,f,g,h){ + if(str.indexOf("\-")!=0){ + if(e=="-"){ + return Number(d)-Number(h)} + else{ + return Number(d)+Number(h)} + }else{ + if(e=="-"){ + return Number(d)+Number(h)} + else{ + return Number(d)-Number(h)} + } + }) + if(str.charAt(0)=="-"&&str.charAt(1)=="-"){ + str=str.substring(2,) + } + if(out===str) break + } + this.setData({ + outcome:str + }) + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/pages/add/add.json b/miniprogram-3/pages/add/add.json new file mode 100644 index 0000000000000000000000000000000000000000..8835af0699ccec004cbe685ef938cd2d63ea7037 --- /dev/null +++ b/miniprogram-3/pages/add/add.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/pages/add/add.wxml b/miniprogram-3/pages/add/add.wxml new file mode 100644 index 0000000000000000000000000000000000000000..aae5dc30479bad574332c22e300f44e86a23bd43 --- /dev/null +++ b/miniprogram-3/pages/add/add.wxml @@ -0,0 +1,13 @@ + + + + {{input}} + {{outcome}} + + + + + {{item.id}} + + + diff --git a/miniprogram-3/pages/add/add.wxss b/miniprogram-3/pages/add/add.wxss new file mode 100644 index 0000000000000000000000000000000000000000..982b53cb09d8badc9d540f9430179de5b9a3e5b7 --- /dev/null +++ b/miniprogram-3/pages/add/add.wxss @@ -0,0 +1,74 @@ +/* pages/add/add.wxss */ +page{ + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + font-size: 48rpx; +} +.show{ + width: 100%; + height: 33%; + background-color: rgb(245,245,245); + font-size: 60rpx; + font-weight: lighter; +} +.input{ + width: 98%; + height: 50%; + margin-left: 2%; +} +.outcome{ + width: 98%; + height: 48%; + display: flex; + align-items: flex-end; + justify-content: flex-end; + margin: 1%; +} +.button{ + width: 100%; + height: 67%; + display: flex; + flex-direction: column; + flex-wrap: wrap; + white-space: wrap; +} +.button-block{ + width: 20%; + height: 16.6%; + display: flex; + align-items: center; + justify-content: center; +} +.button-block:last-child{ + height: 33.2%; +} +.style-one{ + width: 17vw; + height: 17vw; + background-color: rgb(245,245,245); + display: flex; + align-items: center; + justify-content: center; + border-radius: 9px; +} +.style-two{ + width: 17vw; + height: 17vw; + background-color: rgb(233,240,255); + color: rgb(82,121,239); + display: flex; + align-items: center; + justify-content: center; + border-radius: 9px; +} +.style-three{ + width: 17vw; + height: 34vw; + background-color: rgb(59,131,119); + display: flex; + align-items: center; + justify-content: center; + border-radius: 9px; +} \ No newline at end of file diff --git a/miniprogram-3/project.config.json b/miniprogram-3/project.config.json new file mode 100644 index 0000000000000000000000000000000000000000..50c9b4e853f258e76d9a8991246e256bba00d21d --- /dev/null +++ b/miniprogram-3/project.config.json @@ -0,0 +1,68 @@ +{ + "description": "项目配置文件", + "packOptions": { + "ignore": [] + }, + "setting": { + "bundle": false, + "userConfirmedBundleSwitch": false, + "urlCheck": true, + "scopeDataCheck": false, + "coverView": true, + "es6": true, + "postcss": true, + "compileHotReLoad": false, + "lazyloadPlaceholderEnable": false, + "preloadBackgroundData": false, + "minified": true, + "autoAudits": false, + "newFeature": false, + "uglifyFileName": false, + "uploadWithSourceMap": true, + "useIsolateContext": true, + "nodeModules": false, + "enhance": true, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": true, + "showShadowRootInWxmlPanel": true, + "packNpmManually": false, + "enableEngineNative": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "showES6CompileOption": false + }, + "compileType": "miniprogram", + "libVersion": "2.20.1", + "appid": "wx9c78cf2003a91b56", + "projectname": "calculate", + "debugOptions": { + "hidedInDevtools": [] + }, + "scripts": {}, + "staticServerOptions": { + "baseURL": "", + "servePath": "" + }, + "isGameTourist": false, + "condition": { + "search": { + "list": [] + }, + "conversation": { + "list": [] + }, + "game": { + "list": [] + }, + "plugin": { + "list": [] + }, + "gamePlugin": { + "list": [] + }, + "miniprogram": { + "list": [] + } + } +} \ No newline at end of file diff --git a/miniprogram-3/project.private.config.json b/miniprogram-3/project.private.config.json new file mode 100644 index 0000000000000000000000000000000000000000..66e668603f00a81a4c3f8fe9da0c07a290c11ab6 --- /dev/null +++ b/miniprogram-3/project.private.config.json @@ -0,0 +1,36 @@ +{ + "setting": {}, + "condition": { + "plugin": { + "list": [] + }, + "game": { + "list": [] + }, + "gamePlugin": { + "list": [] + }, + "miniprogram": { + "list": [ + { + "name": "pages/index1/index1", + "pathName": "pages/index1/index1", + "query": "", + "scene": null + }, + { + "name": "pages/index/index", + "pathName": "pages/index/index", + "query": "", + "scene": null + }, + { + "name": "pages/add/add", + "pathName": "pages/add/add", + "query": "", + "scene": null + } + ] + } + } +} \ No newline at end of file diff --git a/miniprogram-3/sitemap.json b/miniprogram-3/sitemap.json new file mode 100644 index 0000000000000000000000000000000000000000..ca02add20b581be471b8d17f887b8e8337070546 --- /dev/null +++ b/miniprogram-3/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/miniprogram-3/utils/util.js b/miniprogram-3/utils/util.js new file mode 100644 index 0000000000000000000000000000000000000000..764bc2ce26ab9b55a21cbb069dcf084a8418dffd --- /dev/null +++ b/miniprogram-3/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 +}