forked from x/volcanos
opt mp.insert
This commit is contained in:
parent
af564ea26a
commit
45c6cc05be
@ -1,8 +1,8 @@
|
||||
const kit = require("utils/kit.js")
|
||||
|
||||
App({
|
||||
data: {}, conf: {serve: "https://shylinux.com/chat", space: "mac"},
|
||||
// data: {}, conf: {serve: "https://shylinux.com/chat", space: ""},
|
||||
// data: {}, conf: {serve: "https://shylinux.com/chat", space: "mac"},
|
||||
data: {}, conf: {serve: "https://shylinux.com/chat", space: ""},
|
||||
request: function(cmd, data, cb) { var app = this; data.sessid = app.conf.sessid, data.pod = app.conf.space
|
||||
wx.request({method: "POST", url: app.conf.serve+"/"+cmd, data: data, success: function(res) { var msg = res.data
|
||||
if (res.statusCode == 401) { return app.usercode(function() {app.request(cmd, data, cb)}) }
|
||||
|
@ -23,9 +23,10 @@ Page({
|
||||
app.request("action", {cmds: [page.data.river, page.data.storm]}, function(msg) {
|
||||
wx.hideLoading()
|
||||
msg.Table(function(line, index) {
|
||||
line.name = line.name.split(" ")[0]
|
||||
page.data.his[index] = []
|
||||
line.inputs = JSON.parse(line.inputs)
|
||||
line.feature = JSON.parse(line.feature)
|
||||
line.inputs = JSON.parse(line.list)
|
||||
line.feature = JSON.parse(line.meta)
|
||||
if (!line.inputs || line.inputs.length === 0) {
|
||||
line.inputs = [{_input: "text"}, {_input: "button", value: "执行"}]
|
||||
}
|
||||
@ -69,7 +70,7 @@ Page({
|
||||
},
|
||||
|
||||
run: function(event, order, cmd, cb) {var page = this, field = page.data.res[order]
|
||||
var cmds = [page.data.river, page.data.storm, order]
|
||||
var cmds = [page.data.river, page.data.storm, field.id || field.key]
|
||||
cmds = cmds.concat(cmd||kit.List(field.inputs, function(input) {
|
||||
if (["text", "textarea", "select"].indexOf(input._input) > -1) {
|
||||
return input.value || ""
|
||||
@ -108,18 +109,19 @@ Page({
|
||||
onClick: function(event) {var page = this, data = event.target.dataset
|
||||
var field = page.data.res[data.order]
|
||||
|
||||
switch (data.input.name) {
|
||||
case "添加":
|
||||
app.data.field = field
|
||||
app.data.insertCB = function(res) {
|
||||
var list = ["action", "insert"];
|
||||
if (field.feature[data.input.name]) {
|
||||
app.data.insert = {
|
||||
field: field, input: data.input,
|
||||
data: {}, list: field.feature[data.input.name], cb: function(res) {
|
||||
var list = ["action", data.input.name]
|
||||
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
|
||||
}
|
||||
app.jumps("insert/insert", {river: page.data.river, storm: page.data.storm, title: field.name})
|
||||
return
|
||||
}
|
||||
|
||||
switch (data.input.value) {
|
||||
@ -179,32 +181,4 @@ Page({
|
||||
path: "pages/action/action?river="+this.data.river+"&storm="+this.data.storm+"&title="+this.data.title,
|
||||
}
|
||||
},
|
||||
|
||||
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) {
|
||||
|
||||
})
|
||||
}})
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -24,25 +24,29 @@ Page({
|
||||
},
|
||||
|
||||
onInput: function(event) {var page = this, data = event.target.dataset
|
||||
app.data.insert[data.input.name] = event.detail.value
|
||||
app.data.insert[data.index].value = event.detail.value
|
||||
},
|
||||
onFocus: function(event) {},
|
||||
onConfirm: function (event) {
|
||||
console.log(app.data.insert)
|
||||
app.data.insertCB(app.data.insert)
|
||||
onConfirm: function (event) { var page = this
|
||||
kit.List(page.data.insert, function(item) {
|
||||
app.data.insert.data[item.name] = item.value
|
||||
})
|
||||
app.data.insert.cb(app.data.insert.data)
|
||||
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) {
|
||||
this.data.insert = app.data.insert.list
|
||||
|
||||
var p = app.data.insert.input.action
|
||||
if (p.startsWith("@")) {
|
||||
var cb = this.plugin[p.slice(1,-1)]; cb && cb(this)
|
||||
}
|
||||
kit.List(app.data.insert.list, function(item) {
|
||||
item.action = item.action || item.value
|
||||
item.value && item.value.startsWith("@") && (item.value = "")
|
||||
app.data.insert[item.name] = item.value
|
||||
app.data.insert.data[item.name] = item.value
|
||||
})
|
||||
console.log("page", "insert", options)
|
||||
app.title(options.title)
|
||||
this.setData(this.data)
|
||||
},
|
||||
@ -52,4 +56,24 @@ Page({
|
||||
onUnload: function () {},
|
||||
onPullDownRefresh: function () {},
|
||||
onReachBottom: function () {},
|
||||
|
||||
plugin: {
|
||||
scan: function(page) { app.scans(function(res) {
|
||||
kit.List(page.data.insert, function(item) {
|
||||
res[item.name] && (item.value = res[item.name])
|
||||
}), page.setData(page.data)
|
||||
}) },
|
||||
paste: function(page, data) { wx.getClipboardData({success: function(res) {
|
||||
kit.List(page.data.insert, function(item) {
|
||||
res[item.name] && (item.value = res[item.name])
|
||||
}), page.setData(page.data)
|
||||
}}) },
|
||||
location: function(page, data) { app.location({success: function(res) {
|
||||
res.latitude = parseInt(res.latitude * 100000)
|
||||
res.longitude = parseInt(res.longitude * 100000)
|
||||
kit.List(page.data.insert, function(item) {
|
||||
res[item.name] && (item.value = res[item.name])
|
||||
}), page.setData(page.data)
|
||||
}}) },
|
||||
},
|
||||
})
|
||||
|
@ -17,7 +17,7 @@ Page({
|
||||
app.request("river", {}, function(msg) {
|
||||
wx.hideLoading()
|
||||
var river = {}; msg.Table(function(value) {
|
||||
river[value.key] = value
|
||||
river[value.hash] = value
|
||||
})
|
||||
page.setData({river: river})
|
||||
})
|
||||
@ -37,7 +37,7 @@ Page({
|
||||
data = data || event.target.dataset.item
|
||||
console.log("detail", "river", data)
|
||||
|
||||
var river = page.data.river[data.key]
|
||||
var river = page.data.river[data.hash]
|
||||
if (river.tool) {
|
||||
river.hidetool = !river.hidetool
|
||||
page.setData({river: page.data.river})
|
||||
@ -45,10 +45,10 @@ Page({
|
||||
}
|
||||
|
||||
wx.showLoading()
|
||||
app.request("storm", {cmds: [data.key]}, function(msg) {
|
||||
app.request("river", {cmds: [data.hash, "tool"]}, function(msg) {
|
||||
wx.hideLoading()
|
||||
river.tool = {}; msg.Table(function(value) {
|
||||
river.tool[value.key] = value
|
||||
river.tool[value.hash] = value
|
||||
value.river = data
|
||||
})
|
||||
page.setData({river: page.data.river})
|
||||
@ -56,7 +56,7 @@ Page({
|
||||
},
|
||||
onchange: function(event, data) { var page = this
|
||||
data = data || event.target.dataset.item
|
||||
app.jumps("action/action", {river: data.river.key, storm: data.key, title: data.river.name+"."+data.name})
|
||||
app.jumps("action/action", {river: data.river.hash, storm: data.hash, title: data.river.name+"."+data.name})
|
||||
},
|
||||
|
||||
onLoad: function (options) { var page = this
|
||||
|
Loading…
x
Reference in New Issue
Block a user