mirror of
https://shylinux.com/x/community
synced 2025-07-01 13:14:44 +08:00
83 lines
3.0 KiB
Go
83 lines
3.0 KiB
Go
package gonganxitong
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"shylinux.com/x/ice"
|
|
"shylinux.com/x/icebergs/base/web"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/community/src/gonganxitong/model"
|
|
)
|
|
|
|
type qrcode struct {
|
|
Tables
|
|
apply apply
|
|
portal Portal
|
|
order string `data:"501"`
|
|
role string `data:"leader"`
|
|
applyQRCode string `name:"applyQRCode" help:"邀请码" role:"void"`
|
|
placeQRCode string `name:"placeQRCode" help:"场景码" role:"void"`
|
|
scanQRCode string `name:"scanQRCode" help:"扫码" role:"void"`
|
|
enter string `name:"enter" help:"进入" role:"void"`
|
|
open string `name:"open" help:"打开" role:"void"`
|
|
}
|
|
|
|
func (s qrcode) ApplyQRCode(m *ice.Message, arg ...string) {
|
|
s.info(m.Options(ice.MSG_FG, "blue"), arg[0], "apply")
|
|
s.EchoQRCode(m, arg[0], s.Prefix(m, s.apply)).Echo("请让申请人扫码,然后审批权限")
|
|
}
|
|
func (s qrcode) PlaceQRCode(m *ice.Message, arg ...string) {
|
|
s.info(m, arg[0], "portal")
|
|
s.EchoQRCode(m, arg[0]).Echo(kit.JoinWord(m.Append(model.CITY_NAME), m.Append(s.Keys(s.Street, model.NAME)), m.Append(s.Keys(s.Place, model.NAME))))
|
|
}
|
|
func (s qrcode) ScanQRCode(m *ice.Message, arg ...string) {
|
|
m.FieldsSetDetail()
|
|
for i := 0; i < len(arg); i += 2 {
|
|
if arg[i] != "_origin" {
|
|
m.Push(arg[i], arg[i+1])
|
|
}
|
|
}
|
|
if strings.HasPrefix(m.Append("text"), "http") {
|
|
msg := m.Spawn()
|
|
web.ParseURL(msg.Message, m.Append("text"))
|
|
m.Push("space", msg.Option("pod"))
|
|
if strings.Contains(m.Append("text"), "#") {
|
|
ls := strings.Split(strings.Split(m.Append("text"), "#")[1], ":")
|
|
m.Push("index", ls[1])
|
|
m.Push("args", strings.TrimSuffix(kit.Join([]string{ls[0], kit.Select("", ls, 2)}, ","), ","))
|
|
} else {
|
|
m.Push("index", msg.Option("cmd"))
|
|
m.Push("args", m.Append(m.Cmdx(web.SPACE, msg.Option("pod"), msg.Option("cmd"), "placeUIDKey")))
|
|
}
|
|
m.PushAction(s.Enter, s.Open, "copyText")
|
|
} else {
|
|
m.PushAction("copyText")
|
|
}
|
|
m.EchoQRCode(m.Append("text")).Action(s.ApplyQRCode, s.PlaceQRCode, s.ScanQRCode)
|
|
m.Display("/plugin/table.js")
|
|
}
|
|
func (s qrcode) Enter(m *ice.Message, arg ...string) {
|
|
m.ProcessPodCmd(m.Option("space"), m.Option("index"), kit.Split(m.Option("args")), arg...)
|
|
}
|
|
func (s qrcode) Open(m *ice.Message, arg ...string) {
|
|
m.ProcessOpen(m.Option("text"))
|
|
}
|
|
func (s qrcode) List(m *ice.Message, arg ...string) {
|
|
s.PlaceQRCode(m, arg[0])
|
|
}
|
|
|
|
func init() { ice.TeamCtxCmd(qrcode{Tables: newTables()}) }
|
|
|
|
func (s Table) EchoQRCode(m *ice.Message, arg ...string) *ice.Message {
|
|
m.EchoQRCode(s.Link(m, arg...)).Echo("<img class='avatar' src='%s'/>", m.Resource(kit.Select(ice.Info.NodeIcon, m.Option(model.AUTH_AVATAR))))
|
|
return m
|
|
}
|
|
func (s qrcode) info(m *ice.Message, place_uid, cmd string) *ice.Message {
|
|
m.Cmdy(s.Prefix(m, s.portal), s.portal.PlaceList, m.Option(model.USER_UID), place_uid)
|
|
m.Option(model.AUTH_AVATAR, m.Append(model.AUTH_AVATAR))
|
|
m.Cut(model.CITY_NAME, s.Keys(s.Street, model.NAME), s.Keys(s.Place, model.NAME))
|
|
m.Push(model.QRCODE_TYPE, cmd).Action(s.ApplyQRCode, s.PlaceQRCode, s.ScanQRCode)
|
|
return m
|
|
}
|