forked from x/ContextOS
add mp
This commit is contained in:
parent
38a548f187
commit
5af694bed4
38
usr/client/mp/app.js
Normal file
38
usr/client/mp/app.js
Normal file
@ -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()
|
||||||
|
},
|
||||||
|
})
|
14
usr/client/mp/app.json
Normal file
14
usr/client/mp/app.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"pages":[
|
||||||
|
"pages/index/index"
|
||||||
|
],
|
||||||
|
"window":{
|
||||||
|
"backgroundColor":"#000",
|
||||||
|
"backgroundColorTop":"#000",
|
||||||
|
"backgroundColorBottom":"#000",
|
||||||
|
"backgroundTextStyle":"light",
|
||||||
|
"navigationBarBackgroundColor": "#000",
|
||||||
|
"navigationBarTitleText": "context",
|
||||||
|
"navigationBarTextStyle":"white"
|
||||||
|
}
|
||||||
|
}
|
0
usr/client/mp/app.wxss
Normal file
0
usr/client/mp/app.wxss
Normal file
28
usr/client/mp/pages/index/index.js
Normal file
28
usr/client/mp/pages/index/index.js
Normal file
@ -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 () {},
|
||||||
|
})
|
3
usr/client/mp/pages/index/index.json
Normal file
3
usr/client/mp/pages/index/index.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
10
usr/client/mp/pages/index/index.wxml
Normal file
10
usr/client/mp/pages/index/index.wxml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<view class="container">
|
||||||
|
<view class="input">
|
||||||
|
<input class="command" type="text" bindconfirm="onCommand" confirm-hold="true" focus="true"/>
|
||||||
|
</view>
|
||||||
|
<scroll-view scroll-y class="table">
|
||||||
|
<view class="table-row" wx:if="{{append}}"><view class="table-th" wx:for="{{append}}">{{item}}</view></view>
|
||||||
|
<view class="table-row" wx:for="{{table}}"><view class="table-td" wx:for="{{item}}">{{item}}</view></view>
|
||||||
|
</scroll-view>
|
||||||
|
<view class="result">{{result}}</view>
|
||||||
|
</view>
|
35
usr/client/mp/pages/index/index.wxss
Normal file
35
usr/client/mp/pages/index/index.wxss
Normal file
@ -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%;
|
||||||
|
}
|
40
usr/client/mp/project.config.json
Normal file
40
usr/client/mp/project.config.json
Normal file
@ -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": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user