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,44 +74,55 @@ 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)
switch (value.type) { } catch(e) {
case "share": try {
switch (value.name) { var value = {"type": "url", "text": res.result}
case "invite": var ls = res.result.split("?"); if (ls.length > 1) { ls = ls[1].split("&")
app.userinfo(function(userInfo) { for (var i = 0; i < ls.length; i++) { var vs = ls[i].split("=")
app.modal("接受邀请", value.name, function(res) { value[vs[0]] = decodeURIComponent(vs[1])
res.confirm && app.request("mp/login/auth", value, function(msg) { }
app.toast("回执成功") }
}) } catch(e) {
typeof cb == "function" && cb({type: "", text: res.result})
return
}
}
switch (value.type) {
case "share":
switch (value.name) {
case "invite":
app.userinfo(function(userInfo) {
app.modal("接受邀请", value.name, function(res) {
res.confirm && app.request("mp/login/auth", value, function(msg) {
app.toast("回执成功")
}) })
}) })
break })
} break
break }
break
case "login": case "login":
app.userinfo(function(userInfo) { app.userinfo(function(userInfo) {
app.modal("授权登录", value.name, function(res) { app.modal("授权登录", value.name, function(res) {
res.confirm && app.request("mp/login/auth", value, function(msg) { res.confirm && app.request("mp/login/auth", value, function(msg) {
app.toast("授权成功") app.toast("授权成功")
})
}) })
}) })
break })
case "active": break
app.userinfo(function(userInfo) { case "active":
app.modal("授权登录", value.name, function(res) { app.userinfo(function(userInfo) {
res.confirm && app.request("mp/login/auth", value, function(msg) { app.modal("授权登录", value.name, function(res) {
app.toast("授权成功") res.confirm && app.request("mp/login/auth", value, function(msg) {
}) app.toast("授权成功")
}) })
}) })
break })
default: break
typeof cb == "function" && cb(value) default:
} 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
},
} }