From 3f19571c0522b7f49f9ebfdcec4fc83ac968f468 Mon Sep 17 00:00:00 2001 From: shylinux Date: Sun, 22 Sep 2019 20:47:38 +0800 Subject: [PATCH] fix weixin --- src/contexts/cli/version.go | 2 +- src/contexts/ctx/core.go | 1 + src/examples/chat/chat.go | 13 ++++++++++++- src/plugin/love/index.shy | 6 ++++++ src/plugin/weixin/index.go | 2 ++ usr/librarys/example.js | 19 ++++++++++++++++--- 6 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index 7aa1c4d6..2f1693a7 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -4,5 +4,5 @@ var version = struct { host string self int }{ - "2019-09-22 16:06:14", "com", 628, + "2019-09-22 20:28:29", "com", 635, } diff --git a/src/contexts/ctx/core.go b/src/contexts/ctx/core.go index 84566cbd..ae9ad5de 100644 --- a/src/contexts/ctx/core.go +++ b/src/contexts/ctx/core.go @@ -17,6 +17,7 @@ func (c *Context) Register(s *Context, x Server, args ...interface{}) *Context { case bool: force = arg case string: + force = true name, s.Name = arg, arg } } diff --git a/src/examples/chat/chat.go b/src/examples/chat/chat.go index 70b2aa16..62cd53a5 100644 --- a/src/examples/chat/chat.go +++ b/src/examples/chat/chat.go @@ -89,6 +89,18 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心", }, Commands: map[string]*ctx.Command{ "login": &ctx.Command{Name: "login [username password]", Help: "登录", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + if len(arg) > 0 { + switch arg[0] { + case "weixin": + if msg := m.Find("cli.weixin", true); msg != nil { + msg.Cmd("js_token") + m.Copy(msg, "append") + m.Table() + } + return + } + } + // 非登录态 if !m.Options("sessid") || !m.Options("username") { if len(arg) > 0 { @@ -121,7 +133,6 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心", case "rename": m.Cmd("aaa.auth", "username", m.Option("username"), "data", "nickname", arg[1]) - case "weixin": } } diff --git a/src/plugin/love/index.shy b/src/plugin/love/index.shy index 53ac89bc..e1697b8e 100644 --- a/src/plugin/love/index.shy +++ b/src/plugin/love/index.shy @@ -55,3 +55,9 @@ kit wss "推送" private "web.wss" \ button "返回" click Last \ exports wss key +kit pos "位置" private \ + button "查看" click getLocation \ + button "显示" click openLocation \ + text "0.0062" name x \ + text "0.0014" name y \ + text "当前位置" name pos \ diff --git a/src/plugin/weixin/index.go b/src/plugin/weixin/index.go index feb9a484..e0deb030 100644 --- a/src/plugin/weixin/index.go +++ b/src/plugin/weixin/index.go @@ -57,6 +57,7 @@ var Index = &ctx.Context{Name: "weixin", Help: "微信后台", Commands: map[string]*ctx.Command{ "access": &ctx.Command{Name: "access", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { m.Option("format", "object") + m.Option("temp_expire", "1") now := kit.Int(time.Now().Unix()) access := m.Confm("chat", "access") @@ -70,6 +71,7 @@ var Index = &ctx.Context{Name: "weixin", Help: "微信后台", }}, "ticket": &ctx.Command{Name: "ticket", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { m.Option("format", "object") + m.Option("temp_expire", "1") now := kit.Int(time.Now().Unix()) ticket := m.Confm("chat", "ticket") diff --git a/usr/librarys/example.js b/usr/librarys/example.js index ee1a1a53..fc2d3f7f 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -150,13 +150,13 @@ function Page(page) { wx.error(function(res){}) wx.ready(function(){ page.getLocation = function(cb) { - wx.getLocation({success: function (res) {cb(res)}}) + wx.getLocation({success: function (res) { + cb(res) + }}) } page.openLocation = function(latitude, longitude, name) { wx.openLocation({latitude: parseFloat(latitude), longitude: parseFloat(longitude), name:name||"here"}) } - - wx.getNetworkType({success: function (res) {}}) wx.getLocation({success: function (res) { page.footer.Pane.State("site", parseInt(res.latitude*10000)+","+parseInt(res.longitude*10000)) }}) @@ -810,6 +810,19 @@ function Plugin(page, pane, field, runs) { }), plugin.Check() }, + getLocation: function(event, target, option, field, cb) { + page.getLocation && page.getLocation(cb || (function(res) { + page.ontoast(JSON.stringify(res)) + })) + }, + openLocation: function(event) { + var x = parseFloat(option.x.value) + var y = parseFloat(option.y.value) + page.getLocation && page.getLocation(function(res) { + page.openLocation && page.openLocation(res.latitude+y, res.longitude+x, option.pos.value) + }) + }, + Help: function(type, action) { var text = [] switch (type) {