diff --git a/usr/client/mp/app.js b/usr/client/mp/app.js new file mode 100644 index 00000000..272f6e64 --- /dev/null +++ b/usr/client/mp/app.js @@ -0,0 +1,38 @@ +//app.js +App({ + request: function(data, done, fail) { + var app = this + data = data || {} + data.sessid = app.sessid || "" + + wx.request({url: "https://shylinux.com/chat/mp", data: data, + success: function(res) { + typeof done == "function" && done(res.data) + }, + fail: function(res) { + typeof done == "function" && done(res.data) + }, + }) + }, + login: function(cb) { + var app = this + wx.login({success: res => { + app.request({code: res.code}, function(sessid) { + app.sessid = sessid + + wx.getSetting({success: res => { + if (res.authSetting['scope.userInfo']) { + wx.getUserInfo({success: res => { + app.userInfo = res.userInfo + app.request(res, cb) + }}) + } + }}) + }) + }}) + }, + + onLaunch: function () { + this.login() + }, +}) diff --git a/usr/client/mp/app.json b/usr/client/mp/app.json new file mode 100644 index 00000000..cef3d741 --- /dev/null +++ b/usr/client/mp/app.json @@ -0,0 +1,14 @@ +{ + "pages":[ + "pages/index/index" + ], + "window":{ + "backgroundColor":"#000", + "backgroundColorTop":"#000", + "backgroundColorBottom":"#000", + "backgroundTextStyle":"light", + "navigationBarBackgroundColor": "#000", + "navigationBarTitleText": "context", + "navigationBarTextStyle":"white" + } +} diff --git a/usr/client/mp/app.wxss b/usr/client/mp/app.wxss new file mode 100644 index 00000000..e69de29b diff --git a/usr/client/mp/pages/index/index.js b/usr/client/mp/pages/index/index.js new file mode 100644 index 00000000..e1659196 --- /dev/null +++ b/usr/client/mp/pages/index/index.js @@ -0,0 +1,28 @@ +const app = getApp() + +Page({ + data: { + cmd: "", + table: [], + append: [], + result: "", + }, + onCommand: function(e) { + var page = this + app.request({"cmd": e.detail.value}, function(res) { + if (res.append) { + var table = [] + for (var i = 0; i < res[res.append[0]].length; i++) { + var line = [] + for (var j = 0; j < res.append.length; j++) { + line.push(res[res.append[j]][i]) + } + table.push(line) + } + page.setData({append: res.append, table: table}) + } + page.setData({result: res.result? res.result.join("") :res}) + }) + }, + onLoad: function () {}, +}) diff --git a/usr/client/mp/pages/index/index.json b/usr/client/mp/pages/index/index.json new file mode 100644 index 00000000..8835af06 --- /dev/null +++ b/usr/client/mp/pages/index/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/usr/client/mp/pages/index/index.wxml b/usr/client/mp/pages/index/index.wxml new file mode 100644 index 00000000..703402b8 --- /dev/null +++ b/usr/client/mp/pages/index/index.wxml @@ -0,0 +1,10 @@ + + + + + + {{item}} + {{item}} + + {{result}} + diff --git a/usr/client/mp/pages/index/index.wxss b/usr/client/mp/pages/index/index.wxss new file mode 100644 index 00000000..4ef8e1f8 --- /dev/null +++ b/usr/client/mp/pages/index/index.wxss @@ -0,0 +1,35 @@ +.container { + color:cyan; + font-size:16px; + font-family:Courier; + background-color:black; + min-height:800px; +} +.command { + border:solid 2px green; + width:calc(100% - 4px); +} +.table { + border:solid 1px green; + display:table; + overflow:auto; + max-width:100%; +} +.table-row { + display:table-row; +} +.table-th { + background-color:red; + padding:4px; + border:solid 1px green; + display:table-cell; +} +.table-td { + padding:4px; + border:solid 1px green; + display:table-cell; +} +.result { + white-space:pre; + width:100%; +} diff --git a/usr/client/mp/project.config.json b/usr/client/mp/project.config.json new file mode 100644 index 00000000..51df82f9 --- /dev/null +++ b/usr/client/mp/project.config.json @@ -0,0 +1,40 @@ +{ + "description": "Project configuration file", + "packOptions": { + "ignore": [] + }, + "setting": { + "urlCheck": true, + "es6": true, + "postcss": true, + "minified": true, + "newFeature": true, + "autoAudits": false + }, + "compileType": "miniprogram", + "libVersion": "2.5.1", + "appid": "wxf4e5104d83476ed6", + "projectname": "mp", + "debugOptions": { + "hidedInDevtools": [] + }, + "isGameTourist": false, + "condition": { + "search": { + "current": -1, + "list": [] + }, + "conversation": { + "current": -1, + "list": [] + }, + "game": { + "currentL": -1, + "list": [] + }, + "miniprogram": { + "current": -1, + "list": [] + } + } +} \ No newline at end of file