diff --git a/client/mp/app.js b/client/mp/app.js
index 4cb0bb2f..ad14f326 100644
--- a/client/mp/app.js
+++ b/client/mp/app.js
@@ -6,11 +6,12 @@ App({
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
console.log(msg)
- if (res.statusCode == 401) {delete(app.conf.userInfo)
- app.userinfo(function() {app.request(cmd, data, cb)})
+ if (res.statusCode == 401) {
+ app.usercode(function() {app.request(cmd, data, cb)})
return
}
msg.__proto__ = {
+ nRow() {return msg.append && msg.append[0] && msg[msg.append[0]].length || 0},
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++) {
@@ -33,17 +34,25 @@ App({
typeof cb == "function" && cb(res)
}})
},
+ usercode: function(cb) {var app = this
+ wx.login({success(res) {app.request("mp/login/code", {code: res.code}, function(msg) {
+ wx.setStorage({key: "sessid", data: msg.Result()})
+ app.conf.sessid = msg.Result(), typeof cb == "function" && cb()
+ })}})
+ },
userinfo: function(cb) {var app = this
if (app.conf.userInfo) {return typeof cb == "function" && cb(app.conf.userInfo)}
- wx.login({success(res) {app.request("mp/login/code", {code: res.code}, function(msg) {app.conf.sessid = msg.Result()
+ app.usercode(function() {
wx.getSetting({success(res) {res.authSetting['scope.userInfo'] && wx.getUserInfo({success(res) {
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})
+ wx.navigateTo({url: "/pages/"+utils.Args(url, args), success: cb})
},
toast: function(title) {wx.showToast({title: title})},
- onLaunch: function() {},
+ onLaunch: function() {
+ this.conf.sessid = wx.getStorageSync("sessid")
+ },
})
diff --git a/client/mp/app.json b/client/mp/app.json
index 8a45b5c0..c7cebf84 100644
--- a/client/mp/app.json
+++ b/client/mp/app.json
@@ -5,7 +5,7 @@
"pages/action/action",
"pages/active/active",
"pages/favor/favor",
- "pages/index/index"
+ "pages/scans/scans"
],
"window": {
"backgroundColor": "#000",
diff --git a/client/mp/app.wxml b/client/mp/app.wxml
new file mode 100644
index 00000000..88e04e02
--- /dev/null
+++ b/client/mp/app.wxml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/client/mp/app.wxss b/client/mp/app.wxss
index 93e3a156..d9504494 100644
--- a/client/mp/app.wxss
+++ b/client/mp/app.wxss
@@ -31,3 +31,11 @@ td {
text-align:center;
border:solid 1px green;
}
+td.item {
+ font-size:18px;
+ padding:10px;
+}
+
+.output {
+ border:solid 2px red;
+}
diff --git a/client/mp/pages/action/action.js b/client/mp/pages/action/action.js
index 5a6b6c2a..56c1f4fa 100644
--- a/client/mp/pages/action/action.js
+++ b/client/mp/pages/action/action.js
@@ -9,19 +9,43 @@ Page({
{name: "清屏", bind: "refresh"},
{name: "清空", bind: "refresh"},
{name: "共享", bind: "refresh"},
+ {name: "扫码", bind: "action"},
],
msg: {append: ["hi", "he"], hi: [1, 2], he: [3, 4]},
res: [],
+ his: {},
},
- run: function(order, cb) {var page = this
- app.request("action", {cmds: [page.data.river, page.data.storm, order]}, function(msg) {
+ run: function(order, cb) {var page = this, field = page.data.res[order]
+ var his = page.data.his[order] || []
+ var arg = []
+ field.inputs.forEach(function(input) {
+ if (input._input == "text") {
+ arg.push(input.value||"")
+ }
+ })
+ his.push(arg)
+ page.data.his[order] = his
+
+ var cmds = [page.data.river, page.data.storm, order]
+ field.inputs.forEach(function(input) {
+ if (input._input == "text") {
+ cmds.push(input.value||"")
+ }
+ })
+ for (var i = cmds.length-1; i > 0; i--) {
+ if (cmds[i] === "") {cmds.pop()} else {break}
+ }
+ app.request("action", {cmds: cmds}, function(msg) {
page.data.res[order].msg = msg
- typeof cb == "function" && cb(msg)
page.setData({res: page.data.res})
+ typeof cb == "function" && cb(msg)
})
},
action: function(event) {var page = this, name = event.target.dataset.name
switch (name) {
+ case "扫码":
+ app.jumps("scans/scans")
+ break
case "串行":
function cb(i) {
page.run(i, function() {i < page.data.res.length && cb(i+1)})
@@ -33,32 +57,67 @@ Page({
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)
+ refresh: function() {var page = this, data = []; page.data.his = {}
+ app.data[page.data.river+page.data.storm] = page.data.res = data
+ app.request("action", {cmds: [page.data.river, page.data.storm]}, function(msg) {
+ msg.Table(function(line, index) {
+ 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), line.inputs.forEach(function(input) {
+ input._input == "button" && input.action == "auto" && page.run(index)
})
- page.setData({res: app.data[page.data.river+page.data.storm] = page.data.res = data})
})
+ page.setData({res: data})
})
},
+ onBlur: function(event) {var page = this, data = event.target.dataset
+ page.data.res[data.order].inputs[data.index].value = event.detail.value
+ },
onFocus: function(event) {},
onInput: function(event) {},
onEnter: function(event) {var page = this, data = event.target.dataset
- console.log(event)
+ page.data.res[data.order].inputs[data.index].value = event.detail.value
+ },
+ onClick: function(event) {var page = this, data = event.target.dataset
+ var field = page.data.res[data.order]
+ switch (data.input.cb) {
+ case "Last":
+ var his = page.data.his[data.order] || []
+ his.pop()
+ var arg = his.pop()
+ if (arg) {
+ field.inputs.forEach(function(input, i) {
+ if (input._input == "text") {
+ input.value = arg[i] || ""
+ }
+ })
+ }
+ page.data.his[data.order] = his
+ default:
+ this.run(event.target.dataset.order)
+ }
+ },
+ onWhich: function(event) {var page = this, data = event.target.dataset
+ page.data.res[data.order].inputs.forEach(function(input) {
+ if (input.name == data.field) {
+ input.value = data.value
+ if (input.action == "auto") {
+ page.run(data.order)
+ }
+ page.setData({res: page.data.res})
+ }
+ })
},
- onClick: function(event) {this.run(event.target.dataset.order)},
onLoad: function (options) {var page = this
+ app.conf.sessid = app.conf.sessid || options.sessid
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()
diff --git a/client/mp/pages/action/action.wxml b/client/mp/pages/action/action.wxml
index 871fcd2f..31740f7c 100644
--- a/client/mp/pages/action/action.wxml
+++ b/client/mp/pages/action/action.wxml
@@ -9,18 +9,19 @@
{{field.name}}({{field.help}})
-
+
-
+
{{item}} |
- {{field.msg[item][line]}} |
+ {{field.msg[item][line]}} |
- {{item}}
+
+ {{item}}
diff --git a/client/mp/pages/river/river.js b/client/mp/pages/river/river.js
index 2b3a8550..417298a0 100644
--- a/client/mp/pages/river/river.js
+++ b/client/mp/pages/river/river.js
@@ -3,38 +3,30 @@ const app = getApp()
Page({
data: {
- cmd: "",
- msg: {append: ["hi", "he"], hi: [1, 2], he: [3, 4]},
+ msg: {append: ["key", "name"]},
+ },
+ refresh: function() {var page = this
+ app.request("river", {}, function(msg) {page.setData({msg: msg})
+ msg.nRow() == 1 && page.toStorm(0)
+ })
},
- onClick: function(event) {var page = this, index = event.currentTarget.dataset.index
- app.jumps("/pages/storm/storm", {river: page.data.msg.key[index]})
- },
+ toStorm: function(index) {app.jumps("storm/storm", {river: this.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]})
- }
- })
- })
+ onEnter: function(event) {},
+ onClick: function(event) {this.toStorm(event.currentTarget.dataset.index)},
+
+ onLoad: function (options) {
+ app.conf.sessid = app.conf.sessid || options.sessid
+ this.refresh()
},
onReady: function () {},
- onShow: function () {
- },
+ onShow: function () {},
onHide: function () {},
onUnload: function () {},
- onPullDownRefresh: function () {},
+ onPullDownRefresh: function () {this.refresh()},
onReachBottom: function () {},
onShareAppMessage: function () {}
})
diff --git a/client/mp/pages/river/river.wxml b/client/mp/pages/river/river.wxml
index 0037a8b9..2f33a9d6 100644
--- a/client/mp/pages/river/river.wxml
+++ b/client/mp/pages/river/river.wxml
@@ -1,5 +1,5 @@
+
+
-
+
diff --git a/client/mp/pages/river/river.wxss b/client/mp/pages/river/river.wxss
index 2e260f5d..e69de29b 100644
--- a/client/mp/pages/river/river.wxss
+++ b/client/mp/pages/river/river.wxss
@@ -1,5 +0,0 @@
-td {
- font-size:18px;
- padding:10px;
-}
-
diff --git a/client/mp/pages/index/index.js b/client/mp/pages/scans/scans.js
similarity index 99%
rename from client/mp/pages/index/index.js
rename to client/mp/pages/scans/scans.js
index f7169e44..b31ef63e 100644
--- a/client/mp/pages/index/index.js
+++ b/client/mp/pages/scans/scans.js
@@ -69,5 +69,6 @@ Page({
}
}})
},
+
onLoad() {this.show()},
})
diff --git a/client/mp/pages/index/index.json b/client/mp/pages/scans/scans.json
similarity index 100%
rename from client/mp/pages/index/index.json
rename to client/mp/pages/scans/scans.json
diff --git a/client/mp/pages/index/index.wxml b/client/mp/pages/scans/scans.wxml
similarity index 100%
rename from client/mp/pages/index/index.wxml
rename to client/mp/pages/scans/scans.wxml
diff --git a/client/mp/pages/index/index.wxss b/client/mp/pages/scans/scans.wxss
similarity index 88%
rename from client/mp/pages/index/index.wxss
rename to client/mp/pages/scans/scans.wxss
index 0828fa0b..e7811856 100644
--- a/client/mp/pages/index/index.wxss
+++ b/client/mp/pages/scans/scans.wxss
@@ -1,5 +1,6 @@
.display {
text-align:center;
+ width:calc(100% - 40px);
padding:20px;
}
.display button {
@@ -8,18 +9,12 @@
.picture {
border:solid 2px green;
}
-view.content {
+.content {
text-align:left;
font-size:14px;
color:gray;
}
-textarea {
- height:45px;
- overflow:auto;
- border:solid 2px gray;
- width:calc(100% - 4px);
-}
-view.comment {
+.comment {
text-align:left;
font-size:14px;
color:gray;
@@ -27,3 +22,10 @@ view.comment {
.output {
text-align:center;
}
+
+textarea {
+ height:45px;
+ overflow:auto;
+ border:solid 2px gray;
+ width:calc(100% - 4px);
+}
diff --git a/client/mp/pages/storm/storm.js b/client/mp/pages/storm/storm.js
index 8c524581..136e851a 100644
--- a/client/mp/pages/storm/storm.js
+++ b/client/mp/pages/storm/storm.js
@@ -3,40 +3,29 @@ const app = getApp()
Page({
data: {
- cmd: "",
- river: "",
- msg: {append: ["hi", "he"], hi: [1, 2], he: [3, 4]},
+ river: "", msg: {append: ["key", "name"]},
},
+ refresh: function() {var page = this
+ app.request("storm", {cmds: [page.data.river]}, function(msg) {
+ page.setData({msg: msg}), msg.nRow() == 1 && page.toAction(0)
+ })
+ },
+ toAction: function(index) {app.jumps("action/action", {river: this.data.river, storm: this.data.msg.key[index]})},
- 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]})
- }
- })
- })
+ onEnter: function(event) {},
+ onClick: function(event) {this.toAction(event.currentTarget.dataset.index)},
+
+ onLoad: function (options) {
+ app.conf.sessid = app.conf.sessid || options.sessid
+ this.data.river = options.river, this.refresh()
},
onReady: function () {},
- onShow: function (args) {
- },
+ onShow: function (args) {},
onHide: function () {},
onUnload: function () {},
- onPullDownRefresh: function () {},
+ onPullDownRefresh: function () {this.refresh()},
onReachBottom: function () {},
onShareAppMessage: function () {}
})
diff --git a/client/mp/pages/storm/storm.wxml b/client/mp/pages/storm/storm.wxml
index 0037a8b9..2f33a9d6 100644
--- a/client/mp/pages/storm/storm.wxml
+++ b/client/mp/pages/storm/storm.wxml
@@ -1,5 +1,5 @@
+
+
-
+
diff --git a/client/mp/pages/storm/storm.wxss b/client/mp/pages/storm/storm.wxss
index 8e2c8e7e..e69de29b 100644
--- a/client/mp/pages/storm/storm.wxss
+++ b/client/mp/pages/storm/storm.wxss
@@ -1,4 +0,0 @@
-td {
- font-size:18px;
- padding:10px;
-}
diff --git a/client/mp/project.config.json b/client/mp/project.config.json
index bcd03b75..0d270bc5 100644
--- a/client/mp/project.config.json
+++ b/client/mp/project.config.json
@@ -33,13 +33,50 @@
"current": -1,
"list": []
},
+ "plugin": {
+ "current": -1,
+ "list": []
+ },
"game": {
"currentL": -1,
"list": []
},
- "miniprogram": {
+ "gamePlugin": {
"current": -1,
"list": []
+ },
+ "miniprogram": {
+ "current": -1,
+ "list": [
+ {
+ "id": 0,
+ "name": "pages/action/action",
+ "pathName": "pages/action/action",
+ "query": "river=c796cd&storm=9092d5",
+ "scene": 1008
+ },
+ {
+ "id": 1,
+ "name": "pages/storm/storm",
+ "pathName": "pages/storm/storm",
+ "query": "river=c796cd&storm=9092d5",
+ "scene": null
+ },
+ {
+ "id": 2,
+ "name": "pages/river/river",
+ "pathName": "pages/river/river",
+ "query": "river=c796cd&storm=9092d5",
+ "scene": null
+ },
+ {
+ "id": -1,
+ "name": "pages/scans/scans",
+ "pathName": "pages/scans/scans",
+ "query": "river=c796cd&storm=9092d5",
+ "scene": null
+ }
+ ]
}
}
}
\ No newline at end of file