diff --git a/lib/user.js b/lib/user.js index 4f6be94b..7f14d693 100644 --- a/lib/user.js +++ b/lib/user.js @@ -1,10 +1,10 @@ Volcanos("user", {help: "用户操作", info: {}, agent: { - scanQRCode: function(cb, can) { + scanQRCode: function(can, cb) { can.user.input(event, can, [{type: html.TEXTAREA, name: "text", text: ""}], function(list) { - cb(list[0], can.base.ParseJSON(list[0])) + cb(can.base.ParseJSON(list[0])) }) }, - getLocation: function(cb) { var call = arguments.callee + getLocation: function(can, cb) { var call = arguments.callee if (call._res) { return cb(call._res) } navigator.geolocation.getCurrentPosition(function(res) { @@ -13,11 +13,11 @@ Volcanos("user", {help: "用户操作", info: {}, agent: { typeof cb == lang.FUNCTION && cb({type: "unknown", name: "unknown", latitude: 3998412, longitude: 11630748}) } ); }, - openLocation: function(msg) { + openLocation: function(can, msg) { window.open("https://map.baidu.com/search/"+encodeURIComponent(msg.Option(mdb.TEXT)) +"/@12958750.085,4825785.55,16z?querytype=s&da_src=shareurl&wd="+encodeURIComponent(msg.Option(mdb.TEXT))) }, - chooseImage: function(cb) { + chooseImage: function(can, cb) { typeof cb == lang.FUNCTION && cb([]) }, }, diff --git a/plugin/local/chat/location.js b/plugin/local/chat/location.js index 5aa41fed..0760183c 100644 --- a/plugin/local/chat/location.js +++ b/plugin/local/chat/location.js @@ -15,7 +15,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar can.require([can.base.MergeURL("https://map.qq.com/api/gljs", "v", "1.exp", "libraries", "service", "key", can.Conf(aaa.TOKEN))], function() { var res = {type: "unknown", latitude: 3998412, longitude: 11630748}, current = can.base.Obj(msg.Option(chat.LOCATION)) if (current.status === 0) { res = can.onexport.point(can, current.result.location, current.result.ad_info), res.type = "ip", res.name = current.result.ip, can.Status(res) } - can._current = res, can.onimport._layout(can), can.user.agent.getLocation(function(res) { res.type = "current", can.onimport.center(can, can._current = res) }) + can._current = res, can.onimport._layout(can), can.user.agent.getLocation(can, function(res) { res.type = "current", can.onimport.center(can, can._current = res) }) }) }, _layout: function(can) { can.onmotion.clear(can, can.ui.content), can.onmotion.clear(can, can.ui.project) @@ -46,18 +46,18 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar can.runAction(can.request({}, {"boundary": "nearby("+can.base.join([p.lat, p.lng, "500"], ice.FS)+")", "page_index": 1, "keyword": keyword}), "search", [], function(msg) { var res = can.base.Obj(msg.Result()); can.core.List(res.data, function(item) { can.onimport._item(can, can.onexport.point(can, item.location, {type: item.category, name: item.title, text: item.address}), can.ui.explore._target) - }), can.misc.Debug(res) + }) }) }, _search: function(can, keyword) { var p = can.onimport.point(can, can.current.item) can.runAction(can.request({}, {"boundary": "region("+can.base.join([can.Status("city"), p.lat, p.lng], ice.FS)+")", "page_index": 1, "keyword": keyword}), "search", [], function(msg) { var res = can.base.Obj(msg.Result()); can.core.List(res.data, function(item) { can.onimport._item(can, can.onexport.point(can, item.location, {type: item.category, name: item.title, text: item.address}), can.ui.search._target) - }), can.misc.Debug(res) + }) }) }, - _list_result: function(can, msg, cb) { var res = can.base.Obj(msg.Result()); can.misc.Debug(res) + _list_result: function(can, msg, cb) { var res = can.base.Obj(msg.Result()) return can.core.List(res.result[0], function(item) { item.name = item.name||item.fullname; return can.base.isFunc(cb)? cb(item): item }) }, _district: function(can, id, cb) { @@ -259,7 +259,7 @@ Volcanos(chat.ONACTION, {help: "操作数据", list: [["mode", "select", "insert can.runAction(can.request({}, {"boundary": "nearby("+can.base.join([p.lat, p.lng, "500"], ice.FS)+")", "page_index": i}), button, [], function(msg) { var res = can.base.Obj(msg.Result()); can.core.List(res.data, function(item) { can.onimport._item(can, can.onexport.point(can, item.location, {type: item.category, name: item.title, text: item.address}), can.ui.explore._target) - }), can.misc.Debug(res) + }) }) } }, diff --git a/plugin/local/chat/wx.js b/plugin/local/chat/wx.js index a38751d3..980b2692 100644 --- a/plugin/local/chat/wx.js +++ b/plugin/local/chat/wx.js @@ -5,19 +5,19 @@ Volcanos(chat.ONACTION, {source: function(can, msg) { nonceStr: msg.Option("noncestr"), timestamp: msg.Option("timestamp"), jsApiList: can.core.Item({ - scanQRCode: function(cb) { wx.scanQRCode({needResult: cb? 1: 0, scanType: ["qrCode","barCode"], success: function (res) { - can.base.isFunc(cb) && cb(res.resultStr, can.base.ParseJSON(res.resultStr)) + scanQRCode: function(can, cb) { wx.scanQRCode({needResult: cb? 1: 0, scanType: ["qrCode","barCode"], success: function (res) { + can.base.isFunc(cb) && cb(can.base.ParseJSON(res.resultStr)) } }) }, - getLocation: function(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) }) } }) }, - openLocation: function(msg) { wx.openLocation({ + openLocation: function(can, msg) { wx.openLocation({ latitude: parseInt(msg.Option("latitude"))/100000, longitude: parseInt(msg.Option("longitude"))/100000, name: msg.Option(mdb.NAME), address: msg.Option(mdb.TEXT), scale: msg.Option("scale")||14, infoUrl: msg.Option(mdb.LINK), }) }, - chooseImage: function(cb, count) { wx.chooseImage({count: count||9, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: function (res) { + chooseImage: function(can, cb, count) { wx.chooseImage({count: count||9, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: function (res) { can.base.isFunc(cb) && cb(res.localIds) } }) }, }, function(key, value) { return can.user.agent[key] = value, key }), diff --git a/plugin/local/wiki/feel.js b/plugin/local/wiki/feel.js index 12e82106..bc7922b3 100644 --- a/plugin/local/wiki/feel.js +++ b/plugin/local/wiki/feel.js @@ -79,7 +79,7 @@ Volcanos(chat.ONACTION, {help: "组件菜单", list: [ limit: function(event, can, key, value) { can.Action(key, value), can.onimport.page(can, can.list) }, chooseImage: function(event, can) { var msg = can.request(event) - can.user.agent.chooseImage(function(list) { can.core.List(list, function(item) { + can.user.agent.chooseImage(can, function(list) { can.core.List(list, function(item) { can.page.Append(can, can._output, [{img: item, height: 200}]) }) }) }, diff --git a/plugin/state.js b/plugin/state.js index 63a0dbe0..cbe0528f 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -202,20 +202,25 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ } }) }, - - openLocation: function(event, can) { can.user.agent.openLocation(can.request(event)) }, + getClipboardData: function(event, can, button) { + function add(text) { can.runAction(event, button, can.base.Simple(can.base.ParseJSON(text)), function() { can.Update() }) } + navigator.clipboard? navigator.clipboard.readText().then(add).catch(function(err) { can.misc.Log(err) }): + can.user.input(event, can, [{type: html.TEXTAREA, name: mdb.TEXT}], function(list) { add(list[0]) }) + }, + scanQRCode0: function(event, can, button) { can.user.agent.scanQRCode(can) }, + scanQRCode: function(event, can, button) { + can.user.agent.scanQRCode(can, function(data) { + can.runAction(event, button, can.base.Simple(data), function() { can.Update() }) + }) + }, + openLocation: function(event, can) { can.user.agent.openLocation(can, can.request(event)) }, getLocation: function(event, can, button) { - can.user.agent.getLocation(function(data) { can.request(event, data) + can.user.agent.getLocation(can, function(data) { can.request(event, data) can.user.input(event, can, [mdb.TYPE, mdb.NAME, mdb.TEXT, "latitude", "longitude"], function(args) { can.runAction(event, button, args) }) }) }, - getClipboardData: function(event, can, button) { - function add(text) { can.runAction(event, button, [can.base.ParseJSON(text)]) } - navigator.clipboard? navigator.clipboard.readText().then(add).catch(function(err) { can.misc.Log(err) }): - can.user.input(event, can, [{type: html.TEXTAREA, name: mdb.TEXT}], function(list) { add(list[0]) }) - }, }) Volcanos(chat.ONEXPORT, {help: "导出数据", table: function(can) { var msg = can._msg; if (msg.Length() == 0) { return }