forked from x/volcanos
opt mp
This commit is contained in:
parent
aece57d66c
commit
2f5b02572f
@ -74,6 +74,20 @@ App({
|
||||
wx.scanCode({success: function(res) { console.log("scan", res)
|
||||
try {
|
||||
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) {
|
||||
case "share":
|
||||
switch (value.name) {
|
||||
@ -110,9 +124,6 @@ App({
|
||||
default:
|
||||
typeof cb == "function" && cb(value)
|
||||
}
|
||||
} catch(e) {
|
||||
typeof cb == "function" && cb({type: "", text: res.result})
|
||||
}
|
||||
}})
|
||||
},
|
||||
|
||||
|
@ -33,6 +33,7 @@ Page({
|
||||
list.push(line), line.inputs.forEach(function(input) {
|
||||
input.action = input.action || input.value
|
||||
input.value == "auto" && (input.value = "")
|
||||
input.value = input.value || kit.Value(line, "feature.trans."+input.name)
|
||||
if (input.value && input.value.startsWith("@")) {
|
||||
input.value = ""
|
||||
}
|
||||
@ -124,8 +125,8 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
switch (data.input.value) {
|
||||
case "Last":
|
||||
switch (data.input.name) {
|
||||
case "返回":
|
||||
// 恢复命令
|
||||
page.data.his[data.order].pop()
|
||||
var line = page.data.his[data.order].pop()
|
||||
|
@ -23,7 +23,7 @@
|
||||
</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>
|
||||
|
||||
|
@ -41,6 +41,7 @@ Page({
|
||||
if (p.startsWith("@")) {
|
||||
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) {
|
||||
item.action = item.action || item.value
|
||||
item.value && item.value.startsWith("@") && (item.value = "")
|
||||
|
@ -7,11 +7,17 @@ Page({
|
||||
river: {},
|
||||
},
|
||||
action: {
|
||||
"扫码": function(event, page, data) {
|
||||
app.scans(function(res) {
|
||||
page.onaction(event, res, res.name)
|
||||
"扫码": function(event, page, data) { app.scans(function(res) {
|
||||
switch (res.type) {
|
||||
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) {
|
||||
wx.showLoading()
|
||||
app.request("river", {}, function(msg) {
|
||||
|
@ -31,5 +31,12 @@ module.exports = {
|
||||
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
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user