1
0
forked from x/volcanos
This commit is contained in:
shaoying 2020-10-12 08:40:56 +08:00
parent aece57d66c
commit 2f5b02572f
6 changed files with 65 additions and 39 deletions

View File

@ -74,6 +74,20 @@ App({
wx.scanCode({success: function(res) { console.log("scan", res) wx.scanCode({success: function(res) { console.log("scan", res)
try { try {
var value = JSON.parse(res.result) var value = JSON.parse(res.result)
} catch(e) {
try {
var value = {"type": "url", "text": res.result}
var ls = res.result.split("?"); if (ls.length > 1) { ls = ls[1].split("&")
for (var i = 0; i < ls.length; i++) { var vs = ls[i].split("=")
value[vs[0]] = decodeURIComponent(vs[1])
}
}
} catch(e) {
typeof cb == "function" && cb({type: "", text: res.result})
return
}
}
switch (value.type) { switch (value.type) {
case "share": case "share":
switch (value.name) { switch (value.name) {
@ -110,9 +124,6 @@ App({
default: default:
typeof cb == "function" && cb(value) typeof cb == "function" && cb(value)
} }
} catch(e) {
typeof cb == "function" && cb({type: "", text: res.result})
}
}}) }})
}, },

View File

@ -33,6 +33,7 @@ Page({
list.push(line), line.inputs.forEach(function(input) { list.push(line), line.inputs.forEach(function(input) {
input.action = input.action || input.value input.action = input.action || input.value
input.value == "auto" && (input.value = "") input.value == "auto" && (input.value = "")
input.value = input.value || kit.Value(line, "feature.trans."+input.name)
if (input.value && input.value.startsWith("@")) { if (input.value && input.value.startsWith("@")) {
input.value = "" input.value = ""
} }
@ -124,8 +125,8 @@ Page({
return return
} }
switch (data.input.value) { switch (data.input.name) {
case "Last": case "返回":
// 恢复命令 // 恢复命令
page.data.his[data.order].pop() page.data.his[data.order].pop()
var line = page.data.his[data.order].pop() var line = page.data.his[data.order].pop()

View File

@ -23,7 +23,7 @@
</picker> </picker>
<!-- 按钮 --> <!-- 按钮 -->
<button wx:elif="{{item._input == 'button'}}" size="mini" bindtap="onClick" data-field="{{field}}" data-order="{{order}}" data-index="{{index}}" data-input="{{item}}">{{item.name||item.value}}</button> <button wx:elif="{{item._input == 'button'}}" size="mini" bindtap="onClick" data-field="{{field}}" data-order="{{order}}" data-index="{{index}}" data-input="{{item}}">{{item.value||item.name}}</button>
</view> </view>
</view> </view>

View File

@ -41,6 +41,7 @@ Page({
if (p.startsWith("@")) { if (p.startsWith("@")) {
var cb = this.plugin[p.slice(1,-1)]; cb && cb(this) var cb = this.plugin[p.slice(1,-1)]; cb && cb(this)
} }
var cb = this.plugin[p]; cb && cb(this)
kit.List(app.data.insert.list, function(item) { kit.List(app.data.insert.list, function(item) {
item.action = item.action || item.value item.action = item.action || item.value
item.value && item.value.startsWith("@") && (item.value = "") item.value && item.value.startsWith("@") && (item.value = "")

View File

@ -7,11 +7,17 @@ Page({
river: {}, river: {},
}, },
action: { action: {
"扫码": function(event, page, data) { "扫码": function(event, page, data) { app.scans(function(res) {
app.scans(function(res) { switch (res.type) {
page.onaction(event, res, res.name) case "url":
app.request("mp/login/scan", res, function(msg) {
page.onaction({}, {}, "刷新")
}) })
}, break
default:
res.name && page.onaction(event, res, res.name)
}
}) },
"刷新": function(event, page, data) { "刷新": function(event, page, data) {
wx.showLoading() wx.showLoading()
app.request("river", {}, function(msg) { app.request("river", {}, function(msg) {

View File

@ -31,5 +31,12 @@ module.exports = {
cb(k, list[k]) cb(k, list[k])
} }
}, },
Value: function(item, key) {
var p = item, ls = key.split(".")
while (p && ls.length > 0) {
p = p[ls[0]], ls = ls.slice(1)
}
return p
},
} }