forked from x/icebergs
add some
This commit is contained in:
parent
555be526e3
commit
97bdf84965
@ -57,6 +57,8 @@ const (
|
|||||||
CHECKBOX = "checkbox"
|
CHECKBOX = "checkbox"
|
||||||
SELECT = "select"
|
SELECT = "select"
|
||||||
BUTTON = "button"
|
BUTTON = "button"
|
||||||
|
IMAGE = "image"
|
||||||
|
SUBMIT = "submit"
|
||||||
CHROME = "chrome"
|
CHROME = "chrome"
|
||||||
|
|
||||||
STYLE = "style"
|
STYLE = "style"
|
||||||
|
@ -165,7 +165,9 @@ func ShareLocalFile(m *ice.Message, arg ...string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if m.Option(ice.POD) == "" && !aaa.Right(m, ls) {
|
if m.Option(ice.MSG_USERNAME) != "" && strings.HasPrefix(p, nfs.USR_LOCAL_IMAGE+m.Option(ice.MSG_USERNAME)) {
|
||||||
|
|
||||||
|
} else if m.Option(ice.POD) == "" && !aaa.Right(m, ls) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,11 @@ func _spide_save(m *ice.Message, action, file, uri string, res *http.Response) {
|
|||||||
kit.For(data[ice.MSG_APPEND], func(k string) { kit.For(data[k], func(v string) { m.Push(k, v) }) })
|
kit.For(data[ice.MSG_APPEND], func(k string) { kit.For(data[k], func(v string) { m.Push(k, v) }) })
|
||||||
m.Resultv(data[ice.MSG_RESULT])
|
m.Resultv(data[ice.MSG_RESULT])
|
||||||
case SPIDE_SAVE:
|
case SPIDE_SAVE:
|
||||||
_cache_download(m, res, file, m.OptionCB(SPIDE))
|
if strings.HasSuffix(file, "/") {
|
||||||
|
file += kit.Select("", kit.Split(m.Option("Content-Disposition"), ";="), -1)
|
||||||
|
m.Info("save file %v", file)
|
||||||
|
}
|
||||||
|
m.Echo(_cache_download(m, res, file, m.OptionCB(SPIDE)))
|
||||||
case SPIDE_CACHE:
|
case SPIDE_CACHE:
|
||||||
m.Cmdy(CACHE, DOWNLOAD, res.Header.Get(html.ContentType), uri, kit.Dict(RESPONSE, res), m.OptionCB(SPIDE))
|
m.Cmdy(CACHE, DOWNLOAD, res.Header.Get(html.ContentType), uri, kit.Dict(RESPONSE, res), m.OptionCB(SPIDE))
|
||||||
m.Echo(m.Append(mdb.HASH))
|
m.Echo(m.Append(mdb.HASH))
|
||||||
|
@ -140,9 +140,8 @@ func (s Client) Login2(m *ice.Message, arg ...string) {
|
|||||||
if state, code := m.Option(STATE), m.Option(CODE); !m.WarnNotValid(state == "" || code == "") {
|
if state, code := m.Option(STATE), m.Option(CODE); !m.WarnNotValid(state == "" || code == "") {
|
||||||
s.Hash.List(m.Spawn(), m.Option(mdb.HASH, state)).Table(func(value ice.Maps) { m.Options(value) })
|
s.Hash.List(m.Spawn(), m.Option(mdb.HASH, state)).Table(func(value ice.Maps) { m.Options(value) })
|
||||||
m.Options(GRANT_TYPE, AUTHORIZATION_CODE, REDIRECT_URI, s.RedirectURI(m))
|
m.Options(GRANT_TYPE, AUTHORIZATION_CODE, REDIRECT_URI, s.RedirectURI(m))
|
||||||
if res := s.Get(m, m.Option(mdb.HASH), m.Option(GRANT_URL), kit.Simple(m.OptionSimple(GRANT_TYPE, CODE, CLIENT_ID),
|
m.Option(ACCESS_TOKEN, "")
|
||||||
"appid", m.Option(CLIENT_ID), "secret", m.Option(CLIENT_SECRET),
|
if res := s.Get(m, m.Option(mdb.HASH), m.Option(GRANT_URL), kit.Simple(m.OptionSimple(GRANT_TYPE, CODE), "appid", m.Option(CLIENT_ID), "secret", m.Option(CLIENT_SECRET))...); !m.WarnNotValid(res == nil) {
|
||||||
)...); !m.WarnNotValid(res == nil) {
|
|
||||||
kit.Value(res, EXPIRES_IN, m.Time(kit.Format("%vs", kit.Int(kit.Value(res, EXPIRES_IN)))))
|
kit.Value(res, EXPIRES_IN, m.Time(kit.Format("%vs", kit.Int(kit.Value(res, EXPIRES_IN)))))
|
||||||
m.Info("what %v", kit.Format(res))
|
m.Info("what %v", kit.Format(res))
|
||||||
m.Options(res)
|
m.Options(res)
|
||||||
|
@ -138,6 +138,7 @@ func init() {
|
|||||||
m.Cmdy(TEMPLATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
m.Cmdy(TEMPLATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
||||||
}},
|
}},
|
||||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
|
COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
return
|
||||||
m.Cmdy(COMPLETE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
m.Cmdy(COMPLETE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
||||||
}},
|
}},
|
||||||
COMPILE: {Hand: func(m *ice.Message, arg ...string) {
|
COMPILE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/gdb"
|
"shylinux.com/x/icebergs/base/gdb"
|
||||||
"shylinux.com/x/icebergs/base/log"
|
"shylinux.com/x/icebergs/base/log"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
"shylinux.com/x/icebergs/base/tcp"
|
"shylinux.com/x/icebergs/base/tcp"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
"shylinux.com/x/icebergs/base/web/html"
|
"shylinux.com/x/icebergs/base/web/html"
|
||||||
@ -23,9 +24,10 @@ const (
|
|||||||
CGI_BIN = "https://api.weixin.qq.com/cgi-bin/"
|
CGI_BIN = "https://api.weixin.qq.com/cgi-bin/"
|
||||||
TOKEN_CREDENTIAL = "token?grant_type=client_credential"
|
TOKEN_CREDENTIAL = "token?grant_type=client_credential"
|
||||||
TICKET_GETTICKET = "ticket/getticket?type=jsapi"
|
TICKET_GETTICKET = "ticket/getticket?type=jsapi"
|
||||||
QRCODE_CREATE = "qrcode/create"
|
|
||||||
WXACODE_UNLIMIT = "/wxa/getwxacodeunlimit"
|
WXACODE_UNLIMIT = "/wxa/getwxacodeunlimit"
|
||||||
|
QRCODE_CREATE = "qrcode/create"
|
||||||
MENU_CREATE = "menu/create"
|
MENU_CREATE = "menu/create"
|
||||||
|
MEDIA_GET = "media/get"
|
||||||
USER_REMARK = "user/info/updateremark"
|
USER_REMARK = "user/info/updateremark"
|
||||||
USER_INFO = "user/info"
|
USER_INFO = "user/info"
|
||||||
USER_GET = "user/get"
|
USER_GET = "user/get"
|
||||||
@ -45,6 +47,11 @@ const (
|
|||||||
EXPIRES = "expires"
|
EXPIRES = "expires"
|
||||||
EXPIRE = "expire"
|
EXPIRE = "expire"
|
||||||
TICKET = "ticket"
|
TICKET = "ticket"
|
||||||
|
OAUTH = "oauth"
|
||||||
|
MEDIA = "media"
|
||||||
|
|
||||||
|
STABLE_TOKEN = "stable_token"
|
||||||
|
STABLE_TOKEN_EXPIRE = "stable_token_expire"
|
||||||
)
|
)
|
||||||
const ACCESS = "access"
|
const ACCESS = "access"
|
||||||
|
|
||||||
@ -65,40 +72,41 @@ func init() {
|
|||||||
m.Echo(ice.TRUE)
|
m.Echo(ice.TRUE)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
STABLE_TOKEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
spideToken(m, STABLE_TOKEN, STABLE_TOKEN, STABLE_TOKEN_EXPIRE, "grant_type", "client_credential")
|
||||||
|
}},
|
||||||
TOKENS: {Hand: func(m *ice.Message, arg ...string) {
|
TOKENS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
msg := mdb.HashSelect(m.Spawn(), m.Option(ACCESS))
|
spideToken(m, TOKEN_CREDENTIAL, TOKENS, EXPIRES)
|
||||||
if msg.Append(TOKENS) == "" || m.Time() > msg.Append(EXPIRES) {
|
|
||||||
res := m.Cmd(web.SPIDE, WX, http.MethodGet, TOKEN_CREDENTIAL, msg.AppendSimple(APPID, SECRET))
|
|
||||||
mdb.HashModify(m, m.OptionSimple(ACCESS), EXPIRES, m.Time(kit.Format("%vs", res.Append(oauth.EXPIRES_IN))), TOKENS, res.Append(oauth.ACCESS_TOKEN))
|
|
||||||
msg = mdb.HashSelect(m.Spawn(), m.Option(ACCESS))
|
|
||||||
}
|
|
||||||
m.Echo(msg.Append(TOKENS)).Status(msg.AppendSimple(EXPIRES))
|
|
||||||
}},
|
}},
|
||||||
TICKET: {Hand: func(m *ice.Message, arg ...string) {
|
TICKET: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
msg := mdb.HashSelect(m.Spawn(), m.Option(ACCESS))
|
spideToken(m, TICKET_GETTICKET, TICKET, EXPIRE, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS))
|
||||||
if msg.Append(TICKET) == "" || m.Time() > msg.Append(EXPIRE) {
|
|
||||||
res := m.Cmd(web.SPIDE, WX, http.MethodGet, TICKET_GETTICKET, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS))
|
|
||||||
mdb.HashModify(m, m.OptionSimple(ACCESS), EXPIRE, m.Time(kit.Format("%vs", res.Append(oauth.EXPIRES_IN))), TICKET, res.Append(TICKET))
|
|
||||||
msg = mdb.HashSelect(m.Spawn(), m.Option(ACCESS))
|
|
||||||
}
|
|
||||||
m.Echo(msg.Append(TICKET)).Status(msg.AppendSimple(EXPIRE))
|
|
||||||
}},
|
}},
|
||||||
AGENT: {Hand: func(m *ice.Message, arg ...string) {
|
AGENT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
ctx.OptionFromConfig(m, ACCESS, APPID)
|
ctx.OptionFromConfig(m, ACCESS, APPID)
|
||||||
}},
|
}},
|
||||||
"oauth": {Icon: "bi bi-shield-fill-check", Hand: func(m *ice.Message, arg ...string) {
|
"api": {Name: "api method=GET,POST path params", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
switch m.Option("method") {
|
||||||
|
case "POST":
|
||||||
|
res := SpidePost(m, m.Option(nfs.PATH), kit.Split(m.Option("params")))
|
||||||
|
m.Echo(kit.Formats(res))
|
||||||
|
case "GET":
|
||||||
|
res := SpideGet(m, m.Option(nfs.PATH), kit.Split(m.Option("params")))
|
||||||
|
m.Echo(kit.Formats(res))
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
MEDIA: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.OptionDefault(ACCESS, mdb.Config(m, ACCESS))
|
||||||
|
m.Cmdy(web.SPIDE, WX, web.SPIDE_SAVE, arg[1], http.MethodGet, MEDIA_GET, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS), "media_id", arg[0])
|
||||||
|
}},
|
||||||
|
OAUTH: {Icon: "bi bi-shield-fill-check", Hand: func(m *ice.Message, arg ...string) {
|
||||||
oauth := m.Cmdx("web.chat.oauth.client", mdb.CREATE,
|
oauth := m.Cmdx("web.chat.oauth.client", mdb.CREATE,
|
||||||
"domain", "https://api.weixin.qq.com",
|
"domain", "https://api.weixin.qq.com", "client_id", m.Option(APPID), "client_secret", m.Option(SECRET),
|
||||||
"client_id", m.Option("appid"), "client_secret", m.Option("secret"),
|
"oauth_url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+m.Option(APPID), "scope", "snsapi_userinfo", "login", "login2",
|
||||||
"oauth_url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+m.Option("appid"),
|
|
||||||
"grant_url", "/sns/oauth2/access_token",
|
"grant_url", "/sns/oauth2/access_token",
|
||||||
"token_url", "/sns/oauth2/refresh_token",
|
"token_url", "/sns/oauth2/refresh_token",
|
||||||
"users_url", "/sns/userinfo",
|
"users_url", "/sns/userinfo", "user_key", "openid", "nick_key", "nickname", "icon_key", "headimgurl",
|
||||||
"scope", "snsapi_userinfo",
|
|
||||||
"login", "login2",
|
|
||||||
"user_key", "openid", "nick_key", "nickname", "icon_key", "headimgurl",
|
|
||||||
)
|
)
|
||||||
m.Cmd("agent", "oauth", m.Cmdx("web.chat.oauth.client", "link", oauth))
|
m.Cmd(AGENT, OAUTH, m.Cmdx("web.chat.oauth.client", web.LINK, oauth))
|
||||||
}},
|
}},
|
||||||
web.SSO: {Name: "sso name*=weixin help*=微信扫码 order=11 env=release,trial,develop wifi", Hand: func(m *ice.Message, arg ...string) {
|
web.SSO: {Name: "sso name*=weixin help*=微信扫码 order=11 env=release,trial,develop wifi", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(web.CHAT_HEADER, mdb.CREATE, mdb.TYPE, mdb.PLUGIN, m.OptionSimple(mdb.NAME, mdb.HELP, mdb.ORDER),
|
m.Cmd(web.CHAT_HEADER, mdb.CREATE, mdb.TYPE, mdb.PLUGIN, m.OptionSimple(mdb.NAME, mdb.HELP, mdb.ORDER),
|
||||||
@ -127,7 +135,7 @@ func init() {
|
|||||||
}, gdb.EventsAction(web.SPACE_GRANT, web.SPACE_LOGIN_CLOSE), mdb.ExportHashAction(
|
}, gdb.EventsAction(web.SPACE_GRANT, web.SPACE_LOGIN_CLOSE), mdb.ExportHashAction(
|
||||||
mdb.SHORT, ACCESS, mdb.FIELD, "time,type,access,icons,usernick,appid,secret,token", tcp.SERVER, CGI_BIN,
|
mdb.SHORT, ACCESS, mdb.FIELD, "time,type,access,icons,usernick,appid,secret,token", tcp.SERVER, CGI_BIN,
|
||||||
)), Hand: func(m *ice.Message, arg ...string) {
|
)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.HashSelect(m, arg...).PushAction("oauth", web.SSO, mdb.REMOVE).StatusTimeCount(mdb.ConfigSimple(m, ACCESS, APPID), web.SERVE, m.MergeLink("/chat/wx/login/"))
|
mdb.HashSelect(m, arg...).PushAction(OAUTH, web.SSO, TICKET, TOKENS, STABLE_TOKEN, "api", mdb.REMOVE).StatusTimeCount(mdb.ConfigSimple(m, ACCESS, APPID), web.SERVE, m.MergeLink("/chat/wx/login/"))
|
||||||
m.RewriteAppend(func(value, key string, index int) string {
|
m.RewriteAppend(func(value, key string, index int) string {
|
||||||
kit.If(key == cli.QRCODE, func() { value = ice.Render(m, ice.RENDER_QRCODE, value) })
|
kit.If(key == cli.QRCODE, func() { value = ice.Render(m, ice.RENDER_QRCODE, value) })
|
||||||
return value
|
return value
|
||||||
@ -135,14 +143,32 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
func spideToken(m *ice.Message, api string, token, expire string, arg ...string) {
|
||||||
|
msg := mdb.HashSelect(m.Spawn(), m.OptionDefault(ACCESS, mdb.Config(m, ACCESS)))
|
||||||
|
if msg.Append(token) == "" || m.Time() > msg.Append(expire) {
|
||||||
|
kit.If(api != TICKET_GETTICKET, func() { arg = append(arg, msg.AppendSimple(APPID, SECRET)...) })
|
||||||
|
res := m.Cmd(web.SPIDE, WX, kit.Select(http.MethodGet, http.MethodPost, api == STABLE_TOKEN), api, arg)
|
||||||
|
if m.Warn(!kit.IsIn(res.Append("errcode"), "0", ""), res.Append("errmsg")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Debug("res: %v", res.FormatMeta())
|
||||||
|
mdb.HashModify(m, m.OptionSimple(ACCESS), expire, m.Time(kit.Format("%vs", res.Append(oauth.EXPIRES_IN))), token, res.Append(kit.Select(oauth.ACCESS_TOKEN, TICKET, api == TICKET_GETTICKET)))
|
||||||
|
msg = mdb.HashSelect(m.Spawn(), m.Option(ACCESS))
|
||||||
|
}
|
||||||
|
m.Echo(msg.Append(token)).Status(msg.AppendSimple(expire))
|
||||||
|
}
|
||||||
func spidePost(m *ice.Message, api string, arg ...ice.Any) *ice.Message {
|
func spidePost(m *ice.Message, api string, arg ...ice.Any) *ice.Message {
|
||||||
return m.Cmd(web.SPIDE, WX, web.SPIDE_RAW, http.MethodPost, kit.MergeURL(api, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS)), arg)
|
return m.Cmd(web.SPIDE, WX, web.SPIDE_RAW, http.MethodPost, kit.MergeURL(api, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS)), arg)
|
||||||
}
|
}
|
||||||
func SpidePost(m *ice.Message, api string, arg ...ice.Any) ice.Any {
|
func SpidePost(m *ice.Message, api string, arg ...ice.Any) ice.Any {
|
||||||
return kit.UnMarshal(m.Cmdx(web.SPIDE, WX, web.SPIDE_RAW, http.MethodPost, kit.MergeURL(api, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS)), arg))
|
res := kit.UnMarshal(m.Cmdx(web.SPIDE, WX, web.SPIDE_RAW, http.MethodPost, kit.MergeURL(api, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS)), arg))
|
||||||
|
m.Info("res: %v", kit.Format(res))
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
func SpideGet(m *ice.Message, api string, arg ...ice.Any) ice.Any {
|
func SpideGet(m *ice.Message, api string, arg ...ice.Any) ice.Any {
|
||||||
return kit.UnMarshal(m.Cmdx(web.SPIDE, WX, web.SPIDE_RAW, http.MethodGet, kit.MergeURL(api, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS)), arg))
|
res := kit.UnMarshal(m.Cmdx(web.SPIDE, WX, web.SPIDE_RAW, http.MethodGet, kit.MergeURL(api, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS)), arg))
|
||||||
|
m.Info("res: %v", kit.Format(res))
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
func Meta() ice.Map {
|
func Meta() ice.Map {
|
||||||
return kit.Dict(ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(
|
return kit.Dict(ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(
|
||||||
|
146
misc/wx/agent.js
146
misc/wx/agent.js
@ -7,6 +7,7 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
msg.Option(ice.MSG_ACTION, ""), can.require([msg.Option(nfs.SCRIPT)], function(can) {
|
msg.Option(ice.MSG_ACTION, ""), can.require([msg.Option(nfs.SCRIPT)], function(can) {
|
||||||
var debug = msg.isDebug() && can.user.info.userrole == aaa.TECH; debug && can.onmotion.toggle(can, can._fields, true)
|
var debug = msg.isDebug() && can.user.info.userrole == aaa.TECH; debug && can.onmotion.toggle(can, can._fields, true)
|
||||||
wx.config({debug: debug, signature: msg.Option("signature"), timestamp: msg.Option("timestamp"), nonceStr: msg.Option("noncestr"), appId: msg.Option("appid"),
|
wx.config({debug: debug, signature: msg.Option("signature"), timestamp: msg.Option("timestamp"), nonceStr: msg.Option("noncestr"), appId: msg.Option("appid"),
|
||||||
|
openTagList: ["wx-open-subscribe"],
|
||||||
jsApiList: can.core.Item({
|
jsApiList: can.core.Item({
|
||||||
getLocation: function(can, cb) { wx.getLocation({type: "gcj02", success: function (res) {
|
getLocation: function(can, cb) { wx.getLocation({type: "gcj02", success: function (res) {
|
||||||
can.base.isFunc(cb) && cb({type: "gcj02", name: "当前位置", text: "当前位置", latitude: parseInt(res.latitude*100000), longitude: parseInt(res.longitude*100000) })
|
can.base.isFunc(cb) && cb({type: "gcj02", name: "当前位置", text: "当前位置", latitude: parseInt(res.latitude*100000), longitude: parseInt(res.longitude*100000) })
|
||||||
@ -21,6 +22,9 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
chooseImage: function(can, cb, count) { wx.chooseImage({count: count||9, sourceType: ["camera", "album"], sizeType: ["original", "compressed"], success: function (res) {
|
chooseImage: function(can, cb, count) { wx.chooseImage({count: count||9, sourceType: ["camera", "album"], sizeType: ["original", "compressed"], success: function (res) {
|
||||||
can.base.isFunc(cb) && cb(res.localIds)
|
can.base.isFunc(cb) && cb(res.localIds)
|
||||||
} }) },
|
} }) },
|
||||||
|
uploadImage: function(can, id, cb) { wx.uploadImage({ localId: id, isShowProgressTips: 1, success: function (res) {
|
||||||
|
can.base.isFunc(cb) && cb(res.serverId)
|
||||||
|
} }) },
|
||||||
}, function(key, value) { return can.user.agent[key] = value, key }).concat([
|
}, function(key, value) { return can.user.agent[key] = value, key }).concat([
|
||||||
// "updateAppMessageShareData", "updateTimelineShareData",
|
// "updateAppMessageShareData", "updateTimelineShareData",
|
||||||
]),
|
]),
|
||||||
@ -28,75 +32,77 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos(chat.ONACTION, {list: [
|
Volcanos(chat.ONACTION, {
|
||||||
"getLocation", "openLocation", "openAddress",
|
list: [
|
||||||
"scanQRCode", "scanQRCode1", "uploadImage", "chooseImage", "previewImage",
|
"getLocation", "openLocation", "openAddress",
|
||||||
"updateAppMessageShareData", "updateTimelineShareData",
|
"scanQRCode", "scanQRCode1",
|
||||||
],
|
"chooseImage", "uploadImage", "previewImage",
|
||||||
getLocation: function(event, can, button) {
|
"updateAppMessageShareData", "updateTimelineShareData",
|
||||||
wx.getLocation({type: "gcj02", success: function (res) {
|
],
|
||||||
can.run(event, [ctx.ACTION, button, mdb.NAME, "current", aaa.LONGITUDE, res.longitude.toFixed(6), aaa.LATITUDE, res.latitude.toFixed(6)], function() {})
|
getLocation: function(event, can, button) {
|
||||||
can._output.innerHTML = JSON.stringify(res)
|
wx.getLocation({type: "gcj02", success: function (res) {
|
||||||
} })
|
can.run(event, [ctx.ACTION, button, mdb.NAME, "current", aaa.LONGITUDE, res.longitude.toFixed(6), aaa.LATITUDE, res.latitude.toFixed(6)], function() {})
|
||||||
},
|
can._output.innerHTML = JSON.stringify(res)
|
||||||
openLocation: function(event, can, button) {
|
|
||||||
wx.getLocation({type: "gcj02", success: function (res) { wx.openLocation(res) }})
|
|
||||||
},
|
|
||||||
openAddress: function(event, can, button) {
|
|
||||||
wx.openAddress({success: function (res) {
|
|
||||||
can._output.innerHTML = JSON.stringify(res)
|
|
||||||
var userName = res.userName; // 收货人姓名
|
|
||||||
var cityName = res.cityName; // 国标收货地址第二级地址(市)
|
|
||||||
var provinceName = res.provinceName; // 国标收货地址第一级地址(省)
|
|
||||||
var countryName = res.countryName; // 国标收货地址第三级地址(国家)
|
|
||||||
var detailInfo = res.detailInfo; // 详细收货地址信息
|
|
||||||
var nationalCode = res.nationalCode; // 收货地址国家码
|
|
||||||
var postalCode = res.postalCode; // 邮编
|
|
||||||
var telNumber = res.telNumber; // 收货人手机号码
|
|
||||||
}})
|
|
||||||
},
|
|
||||||
scanQRCode: function(event, can, button) {
|
|
||||||
wx.scanQRCode({needResult: 0, scanType: ["qrCode","barCode"]})
|
|
||||||
},
|
|
||||||
scanQRCode1: function(event, can, button) {
|
|
||||||
wx.scanQRCode({needResult: 1, scanType: ["qrCode","barCode"], success: function (res) {
|
|
||||||
can.run(event, [ctx.ACTION, button, mdb.TEXT, res.resultStr], function() {})
|
|
||||||
can._output.innerHTML = res.resultStr
|
|
||||||
} })
|
|
||||||
},
|
|
||||||
uploadImage: function(event, can, button) {
|
|
||||||
wx.chooseImage({success: function (res) { can.core.List(res.localIds, function(item) {
|
|
||||||
wx.uploadImage({localId: item, isShowProgressTips: 1, success: function (res) {
|
|
||||||
var serverId = res.serverId;
|
|
||||||
can._output.innerHTML = serverId
|
|
||||||
} })
|
} })
|
||||||
}) }})
|
},
|
||||||
},
|
openLocation: function(event, can, button) {
|
||||||
chooseImage: function(event, can, button) {
|
wx.getLocation({type: "gcj02", success: function (res) { wx.openLocation(res) }})
|
||||||
wx.chooseImage({count: 9, sourceType: ["camera", "album"], sizeType: ["original", "compressed"], success: function (res) {
|
},
|
||||||
can.page.Append(can, can._output, can.core.List(res.localIds, function(item) {
|
openAddress: function(event, can, button) {
|
||||||
return {img: item, style: {"max-width": can.ConfWidth()}}
|
wx.openAddress({success: function (res) {
|
||||||
}))
|
can._output.innerHTML = JSON.stringify(res)
|
||||||
} })
|
var userName = res.userName; // 收货人姓名
|
||||||
},
|
var cityName = res.cityName; // 国标收货地址第二级地址(市)
|
||||||
previewImage: function(event, can, button) {
|
var provinceName = res.provinceName; // 国标收货地址第一级地址(省)
|
||||||
wx.previewImage({urls: [
|
var countryName = res.countryName; // 国标收货地址第三级地址(国家)
|
||||||
"https://2021.shylinux.com/share/local/usr/icons/timg.png",
|
var detailInfo = res.detailInfo; // 详细收货地址信息
|
||||||
"https://2021.shylinux.com/share/local/usr/icons/mall.png",
|
var nationalCode = res.nationalCode; // 收货地址国家码
|
||||||
]})
|
var postalCode = res.postalCode; // 邮编
|
||||||
},
|
var telNumber = res.telNumber; // 收货人手机号码
|
||||||
updateAppMessageShareData: function(event, can, button) {
|
}})
|
||||||
wx.updateAppMessageShareData({
|
},
|
||||||
title: document.title, desc: "工具系统", link: location.href,
|
scanQRCode: function(event, can, button) {
|
||||||
imgUrl: "https://2021.shylinux.com/share/local/usr/icons/timg.png",
|
wx.scanQRCode({needResult: 0, scanType: ["qrCode","barCode"]})
|
||||||
success: function (res) { can._output.innerHTML = JSON.stringify(res) },
|
},
|
||||||
})
|
scanQRCode1: function(event, can, button) {
|
||||||
},
|
wx.scanQRCode({needResult: 1, scanType: ["qrCode","barCode"], success: function (res) {
|
||||||
updateTimelineShareData: function(event, can, button) {
|
can.run(event, [ctx.ACTION, button, mdb.TEXT, res.resultStr], function() {})
|
||||||
wx.updateTimelineShareData({
|
can._output.innerHTML = res.resultStr
|
||||||
title: document.title, desc: "工具系统", link: location.href,
|
} })
|
||||||
imgUrl: "https://2021.shylinux.com/share/local/usr/icons/timg.png",
|
},
|
||||||
success: function (res) { can._output.innerHTML = JSON.stringify(res) },
|
uploadImage: function(event, can, button) {
|
||||||
})
|
wx.chooseImage({success: function (res) { can.core.List(res.localIds, function(item) {
|
||||||
},
|
wx.uploadImage({localId: item, isShowProgressTips: 1, success: function (res) {
|
||||||
|
var serverId = res.serverId;
|
||||||
|
can._output.innerHTML = serverId
|
||||||
|
} })
|
||||||
|
}) }})
|
||||||
|
},
|
||||||
|
chooseImage: function(event, can, button) {
|
||||||
|
wx.chooseImage({count: 9, sourceType: ["camera", "album"], sizeType: ["original", "compressed"], success: function (res) {
|
||||||
|
can.page.Append(can, can._output, can.core.List(res.localIds, function(item) {
|
||||||
|
return {img: item, style: {"max-width": can.ConfWidth()}}
|
||||||
|
}))
|
||||||
|
} })
|
||||||
|
},
|
||||||
|
previewImage: function(event, can, button) {
|
||||||
|
wx.previewImage({urls: [
|
||||||
|
"https://2021.shylinux.com/share/local/usr/icons/timg.png",
|
||||||
|
"https://2021.shylinux.com/share/local/usr/icons/mall.png",
|
||||||
|
]})
|
||||||
|
},
|
||||||
|
updateAppMessageShareData: function(event, can, button) {
|
||||||
|
wx.updateAppMessageShareData({
|
||||||
|
title: document.title, desc: "工具系统", link: location.href,
|
||||||
|
imgUrl: "https://2021.shylinux.com/share/local/usr/icons/timg.png",
|
||||||
|
success: function (res) { can._output.innerHTML = JSON.stringify(res) },
|
||||||
|
})
|
||||||
|
},
|
||||||
|
updateTimelineShareData: function(event, can, button) {
|
||||||
|
wx.updateTimelineShareData({
|
||||||
|
title: document.title, desc: "工具系统", link: location.href,
|
||||||
|
imgUrl: "https://2021.shylinux.com/share/local/usr/icons/timg.png",
|
||||||
|
success: function (res) { can._output.innerHTML = JSON.stringify(res) },
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
31
misc/wx/ocr.go
Normal file
31
misc/wx/ocr.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package wx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
"shylinux.com/x/icebergs/base/web"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.MergeCommands(ice.Commands{
|
||||||
|
"ocr": {Name: "ocr access path type auto", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.Cmdy(ACCESS)
|
||||||
|
} else if len(arg) == 1 || strings.HasSuffix(arg[1], "/") {
|
||||||
|
m.Cmdy(nfs.DIR, arg[1:])
|
||||||
|
} else if arg[1] != "" {
|
||||||
|
res := SpidePost(m, "/cv/ocr/"+kit.Select("idcard", arg, 2), web.SPIDE_PART, "img", "@"+arg[1])
|
||||||
|
if len(arg) > 2 && arg[2] == "comm" {
|
||||||
|
kit.For(kit.Value(res, "items"), func(value ice.Map) { m.Push(mdb.TEXT, value[mdb.TEXT]) })
|
||||||
|
} else {
|
||||||
|
m.PushDetail(res)
|
||||||
|
}
|
||||||
|
m.EchoImages(m.Resource(arg[1]))
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
}
|
28
misc/wx/template.go
Normal file
28
misc/wx/template.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package wx
|
||||||
|
|
||||||
|
import (
|
||||||
|
ice "shylinux.com/x/icebergs"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
const TEMPLATE = "template"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.MergeCommands(ice.Commands{
|
||||||
|
TEMPLATE: {Name: "template access template_id openid auto", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.Cmdy(ACCESS)
|
||||||
|
} else if m.Option(ACCESS, arg[0]); len(arg) == 1 {
|
||||||
|
res := SpideGet(m, "template/get_all_private_template")
|
||||||
|
kit.For(kit.Value(res, "template_list"), func(value ice.Map) {
|
||||||
|
m.Push("", value)
|
||||||
|
})
|
||||||
|
m.Cut("template_id,title,content,example")
|
||||||
|
} else if len(arg) > 4 {
|
||||||
|
args := []ice.Any{"template_id", arg[1], "touser", arg[2], "url", arg[3]}
|
||||||
|
kit.For(arg[4:], func(k, v string) { args = append(args, kit.Keys("data", k, "value"), v) })
|
||||||
|
SpidePost(m, "message/template/send", args...)
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user