mirror of
https://shylinux.com/x/volcanos
synced 2025-04-26 01:04:06 +08:00
add action
This commit is contained in:
parent
0b198ad753
commit
ff0d27ee9b
@ -1,24 +1,49 @@
|
|||||||
|
const utils = require("utils/util.js")
|
||||||
|
|
||||||
App({
|
App({
|
||||||
conf: {serve: "https://shylinux.com/chat/mp"},
|
data: {},
|
||||||
request(cmd, data, cb) {var app = this; data.sessid = app.conf.sessid
|
conf: {serve: "https://shylinux.com/chat"},
|
||||||
|
request: function(cmd, data, cb) {var app = this; data.sessid = app.conf.sessid
|
||||||
wx.request({method: "POST", url: app.conf.serve+"/"+cmd, data: data, success(res) {var msg = res.data
|
wx.request({method: "POST", url: app.conf.serve+"/"+cmd, data: data, success(res) {var msg = res.data
|
||||||
|
console.log(msg)
|
||||||
|
if (res.statusCode == 401) {delete(app.conf.userInfo)
|
||||||
|
app.userinfo(function() {app.request(cmd, data, cb)})
|
||||||
|
return
|
||||||
|
}
|
||||||
msg.__proto__ = {
|
msg.__proto__ = {
|
||||||
Result() {return msg.result && msg.result.length > 0 && msg.result.join("") || ""},
|
Result() {return msg.result && msg.result.length > 0 && msg.result.join("") || ""},
|
||||||
|
Table(cb) {var row = 0
|
||||||
|
for (var i = 0; i < msg.append.length; i++) {
|
||||||
|
row = msg[msg.append[i]].length > row? msg[msg.append[i]].length: row
|
||||||
|
}
|
||||||
|
for (var i = 0; i < row; i++) {
|
||||||
|
var line = {}
|
||||||
|
for (var k in msg.append) {
|
||||||
|
line[msg.append[k]] = msg[msg.append[k]][i]
|
||||||
|
}
|
||||||
|
typeof cb == "function" && cb(line, i, row)
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
typeof cb == "function" && cb(msg)
|
typeof cb == "function" && cb(msg)
|
||||||
}})
|
}})
|
||||||
},
|
},
|
||||||
download(cmd, data, cb) {var app = this; data.sessid = app.conf.sessid
|
download: function(cmd, data, cb) {var app = this; data.sessid = app.conf.sessid
|
||||||
wx.downloadFile({url: app.conf.serve+"/"+cmd, data: data, success(res) {
|
wx.downloadFile({url: app.conf.serve+"/"+cmd, data: data, success(res) {
|
||||||
typeof cb == "function" && cb(res)
|
typeof cb == "function" && cb(res)
|
||||||
}})
|
}})
|
||||||
},
|
},
|
||||||
toast(title) {wx.showToast({title: title})},
|
userinfo: function(cb) {var app = this
|
||||||
onLaunch() {var app = this
|
if (app.conf.userInfo) {return typeof cb == "function" && cb(app.conf.userInfo)}
|
||||||
wx.login({success(res) {app.request("login", {code: res.code}, function(msg) {app.conf.sessid = msg.Result()
|
wx.login({success(res) {app.request("mp/login/code", {code: res.code}, function(msg) {app.conf.sessid = msg.Result()
|
||||||
wx.getSetting({success(res) {res.authSetting['scope.userInfo'] && wx.getUserInfo({success(res) {
|
wx.getSetting({success(res) {res.authSetting['scope.userInfo'] && wx.getUserInfo({success(res) {
|
||||||
app.request("login", res.userInfo, function(msg) {app.conf.userInfo = res.userInfo})
|
app.request("mp/login/info", res.userInfo, function(msg) {app.conf.userInfo = res.userInfo, typeof cb == "function" && cb(res.userInfo)})
|
||||||
}})}})
|
}})}})
|
||||||
})}})
|
})}})
|
||||||
},
|
},
|
||||||
|
jumps: function(url, args, cb) {
|
||||||
|
wx.navigateTo({url: utils.Args(url, args), success: cb})
|
||||||
|
},
|
||||||
|
toast: function(title) {wx.showToast({title: title})},
|
||||||
|
onLaunch: function() {},
|
||||||
})
|
})
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
"pages/index/index",
|
"pages/river/river",
|
||||||
"pages/logs/logs"
|
"pages/storm/storm",
|
||||||
|
"pages/action/action",
|
||||||
|
"pages/active/active",
|
||||||
|
"pages/favor/favor",
|
||||||
|
"pages/index/index"
|
||||||
],
|
],
|
||||||
"window": {
|
"window": {
|
||||||
"backgroundTextStyle": "light",
|
"backgroundColor": "#000",
|
||||||
"navigationBarBackgroundColor": "#fff",
|
"backgroundTextStyle": "dark",
|
||||||
|
"navigationBarBackgroundColor": "#000",
|
||||||
"navigationBarTitleText": "终端工具链",
|
"navigationBarTitleText": "终端工具链",
|
||||||
"navigationBarTextStyle": "black"
|
"navigationBarTextStyle": "white"
|
||||||
},
|
},
|
||||||
"style": "v2",
|
"style": "v2",
|
||||||
"sitemapLocation": "sitemap.json"
|
"sitemapLocation": "sitemap.json"
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
.display {
|
||||||
|
color:white;
|
||||||
|
font-size:14px;
|
||||||
|
font-family:monospace;
|
||||||
|
background-color:#272822;
|
||||||
|
position:absolute;
|
||||||
|
white-space:pre;
|
||||||
|
height:100%;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width:100%;
|
||||||
|
background-color:#272822;
|
||||||
|
}
|
||||||
|
tr {
|
||||||
|
background-color:#272822;
|
||||||
|
width:100%;
|
||||||
|
display:flex;
|
||||||
|
justify-content:space-between;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color:#272822;
|
||||||
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
|
border:solid 1px red;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
background-color:#272822;
|
||||||
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
|
border:solid 1px green;
|
||||||
|
}
|
73
client/mp/pages/action/action.js
Normal file
73
client/mp/pages/action/action.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
const utils = require("../../utils/util.js")
|
||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
button: [
|
||||||
|
{name: "串行", bind: "action"},
|
||||||
|
{name: "并行", bind: "action"},
|
||||||
|
{name: "清屏", bind: "refresh"},
|
||||||
|
{name: "清空", bind: "refresh"},
|
||||||
|
{name: "共享", bind: "refresh"},
|
||||||
|
],
|
||||||
|
msg: {append: ["hi", "he"], hi: [1, 2], he: [3, 4]},
|
||||||
|
res: [],
|
||||||
|
},
|
||||||
|
run: function(order, cb) {var page = this
|
||||||
|
app.request("action", {cmds: [page.data.river, page.data.storm, order]}, function(msg) {
|
||||||
|
page.data.res[order].msg = msg
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
action: function(event) {var page = this, name = event.target.dataset.name
|
||||||
|
switch (name) {
|
||||||
|
case "串行":
|
||||||
|
function cb(i) {
|
||||||
|
page.run(i, function() {i < page.data.res.length && cb(i+1)})
|
||||||
|
}
|
||||||
|
cb(0)
|
||||||
|
break
|
||||||
|
case "并行":
|
||||||
|
for (var i = 0; i < page.data.res.length; i++) {page.run(i)}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
},
|
||||||
|
refresh: function() {var page = this, data = []
|
||||||
|
app.userinfo(function(userinfo) {
|
||||||
|
app.request("action", {cmds: [page.data.river, page.data.storm]}, function(msg) {
|
||||||
|
msg.Table(function(line) {
|
||||||
|
line.feature = JSON.parse(line.feature)
|
||||||
|
line.inputs = JSON.parse(line.inputs)
|
||||||
|
if (!line.inputs || line.inputs.length === 0) {
|
||||||
|
line.inputs = [{_input: "text"}, {_input: "button", value: "执行"}]
|
||||||
|
}
|
||||||
|
data.push(line)
|
||||||
|
})
|
||||||
|
page.setData({res: app.data[page.data.river+page.data.storm] = page.data.res = data})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
onFocus: function(event) {},
|
||||||
|
onInput: function(event) {},
|
||||||
|
onEnter: function(event) {var page = this, data = event.target.dataset
|
||||||
|
console.log(event)
|
||||||
|
},
|
||||||
|
onClick: function(event) {this.run(event.target.dataset.order)},
|
||||||
|
|
||||||
|
onLoad: function (options) {var page = this
|
||||||
|
page.data.river = options.river
|
||||||
|
page.data.storm = options.storm
|
||||||
|
var data = app.data[options.river+options.storm]
|
||||||
|
if (data) {return page.setData({res: page.data.res = data})}
|
||||||
|
this.refresh()
|
||||||
|
},
|
||||||
|
onReady: function () {},
|
||||||
|
onShow: function () {},
|
||||||
|
onHide: function () {},
|
||||||
|
onUnload: function () {},
|
||||||
|
onPullDownRefresh: function () {this.refresh()},
|
||||||
|
onReachBottom: function () {},
|
||||||
|
onShareAppMessage: function () {}
|
||||||
|
})
|
3
client/mp/pages/action/action.json
Normal file
3
client/mp/pages/action/action.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
26
client/mp/pages/action/action.wxml
Normal file
26
client/mp/pages/action/action.wxml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<view class="display">
|
||||||
|
<view class="action">
|
||||||
|
<view wx:for="{{button}}">
|
||||||
|
<button size="mini" bindtap="{{item.bind}}" data-name="{{item.name}}">{{item.name}}</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="field" wx:for="{{res}}" wx:for-index="order" wx:for-item="field">
|
||||||
|
<view class="detail">
|
||||||
|
<view><text class="title">{{field.name}}({{field.help}})</text></view>
|
||||||
|
<view wx:for="{{field.inputs}}" class="inputs">
|
||||||
|
<view wx:if="{{item._input == 'text'}}">
|
||||||
|
<input type="text" placeholder="{{item.name}}" bindconfirm="onEnter" data-order="{{order}}" data-field="{{field}}"/>
|
||||||
|
</view>
|
||||||
|
<view wx:elif="{{item._input == 'button'}}" class="button">
|
||||||
|
<button size="mini" bindtap="onClick" data-order="{{order}}" data-field="{{field}}" data-index="{{index}}" data-input="{{item}}">{{item.value}}</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<table wx:if="{{field.msg}}">
|
||||||
|
<tr><th wx:for="{{field.msg.append}}">{{item}}</th></tr>
|
||||||
|
<tr wx:for="{{field.msg[field.msg.append[0]]}}" wx:for-index="line"><td wx:for="{{field.msg.append}}">{{field.msg[item][line]}}</td></tr>
|
||||||
|
</table>
|
||||||
|
<view class="output" wx:if="{{field.msg.result}}"><text wx:for="{{field.msg.result}}">{{item}}</text></view>
|
||||||
|
</view>
|
||||||
|
</view>
|
23
client/mp/pages/action/action.wxss
Normal file
23
client/mp/pages/action/action.wxss
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
view.action view {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
view.detail {
|
||||||
|
margin-top:10px;
|
||||||
|
clear:both;
|
||||||
|
}
|
||||||
|
input {
|
||||||
|
width:80px;
|
||||||
|
}
|
||||||
|
text.title {
|
||||||
|
font-weight:bold;
|
||||||
|
font-size:18px;
|
||||||
|
}
|
||||||
|
view.detail>view.inputs>view {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
.input {
|
||||||
|
border:solid 1px green;
|
||||||
|
}
|
||||||
|
.output {
|
||||||
|
background-color:#272822;
|
||||||
|
}
|
27
client/mp/pages/active/active.js
Normal file
27
client/mp/pages/active/active.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
const utils = require("../../utils/util.js")
|
||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
cmd: "",
|
||||||
|
msg: {append: ["hi", "he"], hi: [1, 2], he: [3, 4]},
|
||||||
|
},
|
||||||
|
|
||||||
|
onFocus: function(event) {},
|
||||||
|
onInput: function(event) {},
|
||||||
|
onEnter: function(event) {var page = this
|
||||||
|
app.userinfo(function(user) {
|
||||||
|
app.request("mp/login/", {cmds: ["cmds", event.detail.value]}, function(msg) {
|
||||||
|
page.setData({cmd: "", msg: msg})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onLoad: function (options) {},
|
||||||
|
onReady: function () {},
|
||||||
|
onShow: function () {},
|
||||||
|
onHide: function () {},
|
||||||
|
onUnload: function () {},
|
||||||
|
onPullDownRefresh: function () {},
|
||||||
|
onReachBottom: function () {},
|
||||||
|
onShareAppMessage: function () {}
|
||||||
|
})
|
3
client/mp/pages/active/active.json
Normal file
3
client/mp/pages/active/active.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
8
client/mp/pages/active/active.wxml
Normal file
8
client/mp/pages/active/active.wxml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<view class="display">
|
||||||
|
<input class="detail" type="text" value="{{cmd}}" focus bindfocus="onFocus" bindinput="onInput" bindconfirm="onEnter" confirm-hold/>
|
||||||
|
<table wx:if="{{msg.append && msg.append[0]}}">
|
||||||
|
<tr><th wx:for="{{msg.append}}">{{item}}</th></tr>
|
||||||
|
<tr wx:for="{{msg[msg.append[0]]}}" wx:for-index="line"><td wx:for="{{msg.append}}">{{msg[item][line]}}</td></tr>
|
||||||
|
</table>
|
||||||
|
<view class="output"><text wx:for="{{msg.result}}">{{item}}</text></view>
|
||||||
|
</view>
|
38
client/mp/pages/active/active.wxss
Normal file
38
client/mp/pages/active/active.wxss
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
.display {
|
||||||
|
color:white;
|
||||||
|
font-size:14px;
|
||||||
|
font-family:monospace;
|
||||||
|
background-color:#272822;
|
||||||
|
position:absolute;
|
||||||
|
white-space:pre;
|
||||||
|
height:100%;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
.output {
|
||||||
|
background-color:#272822;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width:100%;
|
||||||
|
background-color:#272822;
|
||||||
|
}
|
||||||
|
tr {
|
||||||
|
background-color:#272822;
|
||||||
|
width:100%;
|
||||||
|
display:flex;
|
||||||
|
justify-content:space-between;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color:#272822;
|
||||||
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
|
border:solid 1px red;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
background-color:#272822;
|
||||||
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
|
border:solid 1px green;
|
||||||
|
}
|
||||||
|
.detail {
|
||||||
|
border:solid 2px green;
|
||||||
|
}
|
27
client/mp/pages/favor/favor.js
Normal file
27
client/mp/pages/favor/favor.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
const utils = require("../../utils/util.js")
|
||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
cmd: "",
|
||||||
|
msg: {append: ["hi", "he"], hi: [1, 2], he: [3, 4]},
|
||||||
|
},
|
||||||
|
|
||||||
|
onFocus: function(event) {},
|
||||||
|
onInput: function(event) {},
|
||||||
|
onEnter: function(event) {var page = this
|
||||||
|
app.userinfo(function(user) {
|
||||||
|
app.request("mp/login/", {cmds: ["cmds", event.detail.value]}, function(msg) {
|
||||||
|
page.setData({cmd: "", msg: msg})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onLoad: function (options) {},
|
||||||
|
onReady: function () {},
|
||||||
|
onShow: function () {},
|
||||||
|
onHide: function () {},
|
||||||
|
onUnload: function () {},
|
||||||
|
onPullDownRefresh: function () {},
|
||||||
|
onReachBottom: function () {},
|
||||||
|
onShareAppMessage: function () {}
|
||||||
|
})
|
3
client/mp/pages/favor/favor.json
Normal file
3
client/mp/pages/favor/favor.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
8
client/mp/pages/favor/favor.wxml
Normal file
8
client/mp/pages/favor/favor.wxml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<view class="display">
|
||||||
|
<input class="detail" type="text" value="{{cmd}}" focus bindfocus="onFocus" bindinput="onInput" bindconfirm="onEnter" confirm-hold/>
|
||||||
|
<table wx:if="{{msg.append && msg.append[0]}}">
|
||||||
|
<tr><th wx:for="{{msg.append}}">{{item}}</th></tr>
|
||||||
|
<tr wx:for="{{msg[msg.append[0]]}}" wx:for-index="line"><td wx:for="{{msg.append}}">{{msg[item][line]}}</td></tr>
|
||||||
|
</table>
|
||||||
|
<view class="output"><text wx:for="{{msg.result}}">{{item}}</text></view>
|
||||||
|
</view>
|
38
client/mp/pages/favor/favor.wxss
Normal file
38
client/mp/pages/favor/favor.wxss
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
.display {
|
||||||
|
color:white;
|
||||||
|
font-size:14px;
|
||||||
|
font-family:monospace;
|
||||||
|
background-color:#272822;
|
||||||
|
position:absolute;
|
||||||
|
white-space:pre;
|
||||||
|
height:100%;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
.output {
|
||||||
|
background-color:#272822;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width:100%;
|
||||||
|
background-color:#272822;
|
||||||
|
}
|
||||||
|
tr {
|
||||||
|
background-color:#272822;
|
||||||
|
width:100%;
|
||||||
|
display:flex;
|
||||||
|
justify-content:space-between;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color:#272822;
|
||||||
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
|
border:solid 1px red;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
background-color:#272822;
|
||||||
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
|
border:solid 1px green;
|
||||||
|
}
|
||||||
|
.detail {
|
||||||
|
border:solid 2px green;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
|
const utils = require("../../utils/util.js")
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
|
|
||||||
var utils = require("../../utils/util.js")
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
picture: "",
|
picture: "",
|
||||||
@ -13,8 +13,17 @@ Page({
|
|||||||
},
|
},
|
||||||
onScan(event) {var page = this
|
onScan(event) {var page = this
|
||||||
wx.scanCode({success(res) {
|
wx.scanCode({success(res) {
|
||||||
|
try {
|
||||||
|
var value = JSON.parse(res.result)
|
||||||
|
switch (value.type) {
|
||||||
|
case "active":
|
||||||
|
app.userinfo(function(userInfo) {
|
||||||
|
app.request("mp/login/auth", {auth: value.name})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch(e) {}
|
||||||
page.setData({content: res.result})
|
page.setData({content: res.result})
|
||||||
app.download("login?type="+encodeURIComponent(res.scanType)+"&scan="+encodeURIComponent(res.result), {}, function(res) {
|
app.download("login/scan?type="+encodeURIComponent(res.scanType)+"&scan="+encodeURIComponent(res.result), {}, function(res) {
|
||||||
page.setData({picture: res.tempFilePath})
|
page.setData({picture: res.tempFilePath})
|
||||||
})
|
})
|
||||||
}})
|
}})
|
||||||
@ -60,17 +69,5 @@ Page({
|
|||||||
}
|
}
|
||||||
}})
|
}})
|
||||||
},
|
},
|
||||||
onscan(event) {var page = this
|
|
||||||
wx.scanCode({success(res) {
|
|
||||||
app.download("login?type="+encodeURIComponent(res.scanType)+"&scan="+encodeURIComponent(res.result), {}, function(res) {
|
|
||||||
wx.saveFile({tempFilePath: res.tempFilePath, success(res) {
|
|
||||||
var list = wx.getStorageSync("qrcode") || []
|
|
||||||
list.push({path: res.savedFilePath, index: list.length, time: utils.Time()})
|
|
||||||
wx.setStorageSync("qrcode", list)
|
|
||||||
page.show()
|
|
||||||
}})
|
|
||||||
})
|
|
||||||
}})
|
|
||||||
},
|
|
||||||
onLoad() {this.show()},
|
onLoad() {this.show()},
|
||||||
})
|
})
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
//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))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"navigationBarTitleText": "查看启动日志",
|
|
||||||
"usingComponents": {}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
<!--logs.wxml-->
|
|
||||||
<view class="container log-list">
|
|
||||||
<block wx:for="{{logs}}" wx:for-item="log">
|
|
||||||
<text class="log-item">{{index + 1}}. {{log}}</text>
|
|
||||||
</block>
|
|
||||||
</view>
|
|
@ -1,8 +0,0 @@
|
|||||||
.log-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
padding: 40rpx;
|
|
||||||
}
|
|
||||||
.log-item {
|
|
||||||
margin: 10rpx;
|
|
||||||
}
|
|
40
client/mp/pages/river/river.js
Normal file
40
client/mp/pages/river/river.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
const utils = require("../../utils/util.js")
|
||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
cmd: "",
|
||||||
|
msg: {append: ["hi", "he"], hi: [1, 2], he: [3, 4]},
|
||||||
|
},
|
||||||
|
|
||||||
|
onClick: function(event) {var page = this, index = event.currentTarget.dataset.index
|
||||||
|
app.jumps("/pages/storm/storm", {river: page.data.msg.key[index]})
|
||||||
|
},
|
||||||
|
onFocus: function(event) {},
|
||||||
|
onInput: function(event) {},
|
||||||
|
onEnter: function(event) {var page = this
|
||||||
|
app.userinfo(function(user) {
|
||||||
|
app.request("mp/login/", {cmds: ["cmds", event.detail.value]}, function(msg) {
|
||||||
|
page.setData({cmd: "", msg: msg})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onLoad: function (options) {var page = this
|
||||||
|
app.userinfo(function(userinfo) {
|
||||||
|
app.request("river", {}, function(msg) {
|
||||||
|
page.setData({msg: msg})
|
||||||
|
if (msg[msg.append[0]].length == 1) {
|
||||||
|
app.jumps("/pages/storm/storm", {river: page.data.msg.key[0]})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onReady: function () {},
|
||||||
|
onShow: function () {
|
||||||
|
},
|
||||||
|
onHide: function () {},
|
||||||
|
onUnload: function () {},
|
||||||
|
onPullDownRefresh: function () {},
|
||||||
|
onReachBottom: function () {},
|
||||||
|
onShareAppMessage: function () {}
|
||||||
|
})
|
3
client/mp/pages/river/river.json
Normal file
3
client/mp/pages/river/river.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
5
client/mp/pages/river/river.wxml
Normal file
5
client/mp/pages/river/river.wxml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<view class="display">
|
||||||
|
<table wx:if="{{msg.append && msg.append[0]}}">
|
||||||
|
<tr wx:for="{{msg[msg.append[0]]}}" wx:for-index="line" bindtap="onClick" data-index="{{line}}"><td>{{msg.name[line]}}</td></tr>
|
||||||
|
</table>
|
||||||
|
</view>
|
5
client/mp/pages/river/river.wxss
Normal file
5
client/mp/pages/river/river.wxss
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
td {
|
||||||
|
font-size:18px;
|
||||||
|
padding:10px;
|
||||||
|
}
|
||||||
|
|
42
client/mp/pages/storm/storm.js
Normal file
42
client/mp/pages/storm/storm.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
const utils = require("../../utils/util.js")
|
||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
cmd: "",
|
||||||
|
river: "",
|
||||||
|
msg: {append: ["hi", "he"], hi: [1, 2], he: [3, 4]},
|
||||||
|
},
|
||||||
|
|
||||||
|
onClick: function(event) {var page = this, index = event.currentTarget.dataset.index
|
||||||
|
app.jumps("/pages/action/action", {river: page.data.river, storm: page.data.msg.key[index]})
|
||||||
|
},
|
||||||
|
onFocus: function(event) {},
|
||||||
|
onInput: function(event) {},
|
||||||
|
onEnter: function(event) {var page = this
|
||||||
|
app.userinfo(function(user) {
|
||||||
|
app.request("mp/login/", {cmds: ["cmds", event.detail.value]}, function(msg) {
|
||||||
|
page.setData({cmd: "", msg: msg})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onLoad: function (options) {var page = this
|
||||||
|
page.data.river = options.river
|
||||||
|
app.userinfo(function(userinfo) {
|
||||||
|
app.request("storm", {cmds: [options.river]}, function(msg) {
|
||||||
|
page.setData({msg: msg})
|
||||||
|
if (msg[msg.append[0]].length == 1) {
|
||||||
|
app.jumps("/pages/action/action", {river: options.river, storm: page.data.msg.key[0]})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onReady: function () {},
|
||||||
|
onShow: function (args) {
|
||||||
|
},
|
||||||
|
onHide: function () {},
|
||||||
|
onUnload: function () {},
|
||||||
|
onPullDownRefresh: function () {},
|
||||||
|
onReachBottom: function () {},
|
||||||
|
onShareAppMessage: function () {}
|
||||||
|
})
|
3
client/mp/pages/storm/storm.json
Normal file
3
client/mp/pages/storm/storm.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
5
client/mp/pages/storm/storm.wxml
Normal file
5
client/mp/pages/storm/storm.wxml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<view class="display">
|
||||||
|
<table wx:if="{{msg.append && msg.append[0]}}">
|
||||||
|
<tr wx:for="{{msg[msg.append[0]]}}" wx:for-index="line" bindtap="onClick" data-index="{{line}}"><td>{{msg.name[line]}}</td></tr>
|
||||||
|
</table>
|
||||||
|
</view>
|
4
client/mp/pages/storm/storm.wxss
Normal file
4
client/mp/pages/storm/storm.wxss
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
td {
|
||||||
|
font-size:18px;
|
||||||
|
padding:10px;
|
||||||
|
}
|
@ -29,8 +29,15 @@ function Time(t, fmt) {var now = t? new Date(t): new Date();
|
|||||||
fmt = fmt.replace("%S", Number(now.getSeconds(), 2))
|
fmt = fmt.replace("%S", Number(now.getSeconds(), 2))
|
||||||
return fmt
|
return fmt
|
||||||
}
|
}
|
||||||
|
function Args(url, args) {var list = []
|
||||||
|
for (var k in args) {
|
||||||
|
list.push(encodeURIComponent(k)+"="+encodeURIComponent(args[k]))
|
||||||
|
}
|
||||||
|
return url+"?"+list.join("&")
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
formatTime: formatTime,
|
formatTime: formatTime,
|
||||||
Time: Time,
|
Time: Time,
|
||||||
|
Args: Args,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user