diff --git a/client/mp/app.json b/client/mp/app.json index c7cebf84..35adc4ae 100644 --- a/client/mp/app.json +++ b/client/mp/app.json @@ -1,11 +1,8 @@ { "pages": [ "pages/river/river", - "pages/storm/storm", "pages/action/action", - "pages/active/active", - "pages/favor/favor", - "pages/scans/scans" + "pages/insert/insert" ], "window": { "backgroundColor": "#000", diff --git a/client/mp/pages/action/action.js b/client/mp/pages/action/action.js index 702764b9..e9ac9b3c 100644 --- a/client/mp/pages/action/action.js +++ b/client/mp/pages/action/action.js @@ -3,7 +3,7 @@ const app = getApp() Page({ data: { - action: ["扫码", "清屏", "刷新", "串行", "并行", "共享"], + action: ["扫码", "刷新", "清屏", "串行", "并行"], river: "", storm: "", title: "", res: [], his: {}, inputs: {}, }, @@ -30,6 +30,14 @@ Page({ line.inputs = [{_input: "text"}, {_input: "button", value: "执行"}] } list.push(line), line.inputs.forEach(function(input) { + input.action = input.action || input.value + input.value == "auto" && (input.value = "") + if (input.value && input.value.startsWith("@")) { + input.value = "" + } + if (input._input == "select") { + input.values = input.values || input.value && input.value.split("|") + } input._input == "button" && input.action == "auto" && page.run(event, index) }) }) @@ -53,146 +61,12 @@ Page({ }) page.setData({res: page.data.res}) }, - "共享": function(event, page, data, name) { - }, - }, - plugin: { - paste: function(page, data) { - wx.getClipboardData({success: function(res) { - var cmds = [page.data.river, page.data.storm, data.order] - cmds = cmds.concat(["insert", "paste", "", res.data]) - app.request("action", {cmds: cmds}, function(msg) { - - }) - }}) - }, - qrcode: function(page) { - app.scans(function(res) { - res["sess.river"] = page.data.river - res["sess.storm"] = page.data.storm - app.request("mp/login/scan", res) - }) - }, - location: function(page, data) { - app.location({success: function(res) { - var cmds = [page.data.river, page.data.storm, data.order] - cmds = cmds.concat(["insert", "location", res.name, res.address, res.longitude*100000, res.latitude*100000]) - app.request("action", {cmds: cmds}, function(msg) { - - }) - }}) - }, }, onaction: function(event, data, name) { - console.log("action", "river", name) data = data || event.target.dataset, name = name || data.name + console.log("action", "action", name) this.action[name](event, this, data) }, - onfigure: { - location: {click: function(event, page, data, cmd, field) { - wx.chooseLocation({success: function(res) { - if (data.input._input != "button") { - field.inputs[data.index].value = res.name - page.setData({res: page.data.res}) - } - page.run(event, data.order, ["action", "device", "location", res.name, res.address, "latitude", res.latitude*100000, "longitude", res.longitude*100000]) - }}) - }}, - battery: {click: function(event, page, data, cmd, field) { - wx.getBatteryInfo({success: function(res) { - if (data.input._input != "button") { - field.inputs[data.index].value = res.level - page.setData({res: page.data.res}) - } - page.run(event, data.order, ["action", "device", "battery", res.level, res.isCharging]) - }}) - }}, - paste: {click: function(event, page, data, cmd, field) { - wx.getClipboardData({success: function(res) { - if (data.input._input != "button") { - field.inputs[data.index].value = res.data - page.setData({res: page.data.res}) - } - page.run(event, data.order, ["action", "device", "paste", res.data, res.data]) - }}) - }}, - scan: {click: function(event, page, data, cmd, field) { - app.scans(function(res) { - if (data.input._input != "button") { - field.inputs[data.index].value = res.text || res.name - page.setData({res: page.data.res}) - } - page.run(event, data.order, ["action", "device", res.type||"spide", res.name||"", res.text||"", JSON.stringify(res.extra||"")]) - }) - }}, - album: {click: function(event, page, data, cmd, field) { - wx.chooseImage({success: function(res) { - console.log(res) - const tempFilePaths = res.tempFilePaths - wx.uploadFile({ - url: app.conf.serve+"/mp/login/upload", - filePath: tempFilePaths[0], - name: 'upload', formData: {'user': 'test'}, - success: function(msg) { - console.log(msg) - if (data.input._input != "button") { - field.inputs[data.index].value = msg.data - page.setData({res: page.data.res}) - } - }, - fail: function(res) { - console.log(res) - }, - }) - }}) - }}, - finger: {click: function(event, page, data, cmd, field) { - wx.startSoterAuthentication({ - requestAuthModes: ['fingerPrint'], authContent: '请用指纹解锁', - challenge: '123456', success(res) { - console.log(res) - res = JSON.parse(res.resultJSON) - if (data.input._input != "button") { - field.inputs[data.index].value = res.cpu_id - page.setData({res: page.data.res}) - } - page.run(event, data.order, ["action", "device", "finger", res.uid, res.cpu_id, "counter", res.counter, "raw", res.raw]) - } - }) - }}, - wifi: {click: function(event, page, data, cmd, field) { - wx.getConnectedWifi({success: function(res) { - console.log(res) - if (data.input._input != "button") { - field.inputs[data.index].value = res.wifi.SSID - page.setData({res: page.data.res}) - } - page.run(event, data.order, ["action", "device", "wifi", res.wifi.SSID, res.wifi.signalStrength]) - }}) - }}, - wifiConn: {click: function(event, page, data, cmd, field) { - wx.connectWifi({ - SSID: data.SSID, password: data.password, - success: function(res) { - console.log(res) - }, - fail: function(res) { - console.log(res) - }, - }) - }}, - vibrate: {click: function(event, page, data, cmd, field) { - wx.vibrateShort() - }}, - key: {click: function(event, page, data, cmd, field) { - page.run(event, data.order, ["action", "input", data.input.name, data.input.value]) - }}, - share: {click: function(event, page, data, cmd, field) { - wx.showShareMenu({ - withShareTicket: true - }) - }}, - }, run: function(event, order, cmd, cb) {var page = this, field = page.data.res[order] var cmds = [page.data.river, page.data.storm, order] @@ -207,7 +81,7 @@ Page({ } wx.showLoading() - app.request("action", {cmds: cmds}, function(msg) { + app.request("action?="+field.name, {cmds: cmds}, function(msg) { wx.hideLoading() page.data.res[order].msg = msg page.setData({res: page.data.res}) @@ -233,16 +107,19 @@ Page({ onClick: function(event) {var page = this, data = event.target.dataset var field = page.data.res[data.order] - // 输入补全 - var figure = data && data.input && page.onfigure[data.input.cb||data.input.figure||data.input.name] - if (figure) { - return figure.click(event, page, data, data.input.name, field) - } switch (data.input.name) { case "添加": - var p = page.plugin[data.field.index] - if (typeof p == "function") { return p(page, data) } + app.data.field = field + app.data.insertCB = function(res) { + var list = ["action", "insert"]; + kit.Item(res, function(key, value) { + key && value && list.push(key, value) + }) + page.run(event, data.order, list) + } + app.jumps("insert/insert", {river: page.data.river, storm: page.data.storm, title: field.name, field: field}) + return } switch (data.input.value) { @@ -284,7 +161,7 @@ Page({ app.title(options.title) var data = app.data[options.river+options.storm] - if (data) {return this.setData({res: this.data.res = data})} + if (data) { return this.setData({res: this.data.res = data}) } this.onaction({}, {}, "刷新") }, onReady: function () {}, @@ -296,11 +173,38 @@ Page({ }, onReachBottom: function () {}, onShareAppMessage: function (res) { - console.log(res) + console.log("action", "share", res) return { title: this.data.title, path: "pages/action/action?river="+this.data.river+"&storm="+this.data.storm+"&title="+this.data.title, - success: function(res) { console.log(res) }, } - } + }, + + plugin: { + paste: function(page, data) { + wx.getClipboardData({success: function(res) { + var cmds = [page.data.river, page.data.storm, data.order] + cmds = cmds.concat(["insert", "paste", "", res.data]) + app.request("action", {cmds: cmds}, function(msg) { + + }) + }}) + }, + qrcode: function(page) { + app.scans(function(res) { + res["sess.river"] = page.data.river + res["sess.storm"] = page.data.storm + app.request("mp/login/scan", res) + }) + }, + location: function(page, data) { + app.location({success: function(res) { + var cmds = [page.data.river, page.data.storm, data.order] + cmds = cmds.concat(["insert", "location", res.name, res.address, res.longitude*100000, res.latitude*100000]) + app.request("action", {cmds: cmds}, function(msg) { + + }) + }}) + }, + }, }) diff --git a/client/mp/pages/action/action.wxml b/client/mp/pages/action/action.wxml index 6f61d41d..2ccc37d3 100644 --- a/client/mp/pages/action/action.wxml +++ b/client/mp/pages/action/action.wxml @@ -5,8 +5,8 @@ {{field.name}}({{field.help}}) - + + {{item.values[item.index||0]}} diff --git a/client/mp/pages/action/action.wxss b/client/mp/pages/action/action.wxss index e69de29b..8cef7a7f 100644 --- a/client/mp/pages/action/action.wxss +++ b/client/mp/pages/action/action.wxss @@ -0,0 +1,6 @@ +view.option view.item { + padding:0; +} +view.option view.item.select { + padding:3px; +} diff --git a/client/mp/pages/active/active.js b/client/mp/pages/active/active.js deleted file mode 100644 index be30cecb..00000000 --- a/client/mp/pages/active/active.js +++ /dev/null @@ -1,27 +0,0 @@ -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 () {} -}) diff --git a/client/mp/pages/active/active.json b/client/mp/pages/active/active.json deleted file mode 100644 index 5ed4543e..00000000 --- a/client/mp/pages/active/active.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} diff --git a/client/mp/pages/active/active.wxml b/client/mp/pages/active/active.wxml deleted file mode 100644 index 34bfe989..00000000 --- a/client/mp/pages/active/active.wxml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -
{{item}}
{{msg[item][line]}}
- {{item}} -
diff --git a/client/mp/pages/active/active.wxss b/client/mp/pages/active/active.wxss deleted file mode 100644 index 249cb658..00000000 --- a/client/mp/pages/active/active.wxss +++ /dev/null @@ -1,38 +0,0 @@ -.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; -} diff --git a/client/mp/pages/favor/favor.js b/client/mp/pages/favor/favor.js deleted file mode 100644 index be30cecb..00000000 --- a/client/mp/pages/favor/favor.js +++ /dev/null @@ -1,27 +0,0 @@ -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 () {} -}) diff --git a/client/mp/pages/favor/favor.json b/client/mp/pages/favor/favor.json deleted file mode 100644 index 5ed4543e..00000000 --- a/client/mp/pages/favor/favor.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} diff --git a/client/mp/pages/favor/favor.wxml b/client/mp/pages/favor/favor.wxml deleted file mode 100644 index 34bfe989..00000000 --- a/client/mp/pages/favor/favor.wxml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -
{{item}}
{{msg[item][line]}}
- {{item}} -
diff --git a/client/mp/pages/favor/favor.wxss b/client/mp/pages/favor/favor.wxss deleted file mode 100644 index 249cb658..00000000 --- a/client/mp/pages/favor/favor.wxss +++ /dev/null @@ -1,38 +0,0 @@ -.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; -} diff --git a/client/mp/pages/insert/insert.js b/client/mp/pages/insert/insert.js new file mode 100644 index 00000000..daddbb59 --- /dev/null +++ b/client/mp/pages/insert/insert.js @@ -0,0 +1,55 @@ +const kit = require("../../utils/kit.js") +const app = getApp() + +Page({ + data: { + action: ["扫码"], + field: {}, + insert: [], + }, + action: { + "扫码": function(event, page, data, name) { + app.scans(function(res) { + res["sess.river"] = page.data.river + res["sess.storm"] = page.data.storm + app.request("mp/login/scan", res) + page.onaction(event, res, res.name) + }) + }, + }, + onaction: function(event, data, name) { + data = data || event.target.dataset, name = name || data.name + console.log("action", "action", name) + this.action[name](event, this, data) + }, + + onInput: function(event) {var page = this, data = event.target.dataset + app.data.insert[data.input.name] = event.detail.value + }, + onFocus: function(event) {}, + onConfirm: function (event) { + console.log(app.data.insert) + app.data.insertCB(app.data.insert) + wx.navigateBack() + }, + onLoad: function (options) { + app.data.insert = {} + this.data.field = app.data.field + this.data.field = app.data.field + this.data.insert = app.data.field.feature.insert + console.log("page", "insert", options) + kit.List(this.data.insert, function(item) { + item.action = item.action || item.value + item.value && item.value.startsWith("@") && (item.value = "") + app.data.insert[item.name] = item.value + }) + app.title(options.title) + this.setData(this.data) + }, + onReady: function () {}, + onShow: function () {}, + onHide: function () {}, + onUnload: function () {}, + onPullDownRefresh: function () {}, + onReachBottom: function () {}, +}) diff --git a/client/mp/pages/scans/scans.json b/client/mp/pages/insert/insert.json similarity index 100% rename from client/mp/pages/scans/scans.json rename to client/mp/pages/insert/insert.json diff --git a/client/mp/pages/insert/insert.wxml b/client/mp/pages/insert/insert.wxml new file mode 100644 index 00000000..d412598b --- /dev/null +++ b/client/mp/pages/insert/insert.wxml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + {{item.values[item.index||0]}} + + + + + + + + + diff --git a/client/mp/pages/insert/insert.wxss b/client/mp/pages/insert/insert.wxss new file mode 100644 index 00000000..b96c7b27 --- /dev/null +++ b/client/mp/pages/insert/insert.wxss @@ -0,0 +1 @@ +/* pages/insert/insert.wxss */ \ No newline at end of file diff --git a/client/mp/pages/river/river.js b/client/mp/pages/river/river.js index bc0d356d..936d60eb 100644 --- a/client/mp/pages/river/river.js +++ b/client/mp/pages/river/river.js @@ -7,12 +7,12 @@ Page({ river: {}, }, action: { - "扫码": function(event, page, data, name) { + "扫码": function(event, page, data) { app.scans(function(res) { page.onaction(event, res, res.name) }) }, - "刷新": function(event, page, data, name) { + "刷新": function(event, page, data) { wx.showLoading() app.request("river", {}, function(msg) { wx.hideLoading() @@ -22,14 +22,14 @@ Page({ page.setData({river: river}) }) }, - "登录": function(event, page, data, name) { - app.conf.sessid = "", app.usercode(function() { + "登录": function(event, page, data) { app.conf.sessid = "", + app.usercode(function() { page.onaction(event, data, "刷新") }) }, - "授权": function(event, page, data, name) { + "授权": function(event, page, data) { app.userinfo(function(res) { - page.onaction(event, res, res.name) + page.onaction(event, data, "刷新") }) }, }, @@ -40,8 +40,8 @@ Page({ }, ondetail: function(event, data) { var page = this data = data || event.target.dataset.item - console.log("detail", "river", data) + var river = page.data.river[data.key] if (river.tool) { river.hidetool = !river.hidetool diff --git a/client/mp/pages/scans/scans.js b/client/mp/pages/scans/scans.js deleted file mode 100644 index b31ef63e..00000000 --- a/client/mp/pages/scans/scans.js +++ /dev/null @@ -1,74 +0,0 @@ -const utils = require("../../utils/util.js") -const app = getApp() - -Page({ - data: { - picture: "", - content: "", - comment: "", - list: [], - }, - show() {var page = this - page.setData({list: (wx.getStorageSync("qrcode")||[]).reverse()}) - }, - onScan(event) {var page = this - 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}) - app.download("login/scan?type="+encodeURIComponent(res.scanType)+"&scan="+encodeURIComponent(res.result), {}, function(res) { - page.setData({picture: res.tempFilePath}) - }) - }}) - }, - onCopy(event) {var page = this - wx.setClipboardData({data: page.data.content, success(res) { - app.toast("复制成功") - }}) - }, - onSave(event) {var page = this - wx.saveImageToPhotosAlbum({filePath: page.data.picture, success(res) { - app.toast("保存成功") - }}) - }, - onList(event) {var page = this - wx.saveFile({tempFilePath: page.data.picture, success(res) { - var list = wx.getStorageSync("qrcode") || [] - list.push({time: utils.Time(), index: list.length, - path: res.savedFilePath, content: page.data.content, comment: page.data.comment, - }) - wx.setStorageSync("qrcode", list) - app.toast("保存成功") - page.show() - }}) - }, - onClear(event) {var page = this - var list = wx.getStorageSync("qrcode") || [] - for (var i = 0; i < list.length; i++) { - wx.removeSavedFile({filePath: list[i].path, success(res) {}}) - } - wx.setStorageSync("qrcode", []) - app.toast("删除成功") - page.show() - }, - onClick(event) {var page = this, data = event.target.dataset - wx.showActionSheet({itemList:["显示", "删除", "复制文本", "保存图片"], success(res) { - switch (res.tapIndex) { - case 0: page.setData({picture: data.picture, content: data.content, comment: data.comment}); break - case 1: wx.removeSavedFile({filePath: data.picture, success(res) {app.toast("删除成功")}}); break - case 1: wx.setClipboardData({data: data.content, success(res) {app.toast("复制成功")}}); break - case 2: wx.saveImageToPhotosAlbum({filePath: data.picture, success(res) {app.toast("保存成功")}}); break - case 3: - } - }}) - }, - - onLoad() {this.show()}, -}) diff --git a/client/mp/pages/scans/scans.wxml b/client/mp/pages/scans/scans.wxml deleted file mode 100644 index d575bab2..00000000 --- a/client/mp/pages/scans/scans.wxml +++ /dev/null @@ -1,19 +0,0 @@ - - - 扫描内容: