From 3257626d817bf746b069c0fa16bc4fe72fbc4098 Mon Sep 17 00:00:00 2001 From: shaoying Date: Tue, 9 Feb 2021 10:50:19 +0800 Subject: [PATCH] opt mp --- frame.js | 2 +- publish/client/mp/app.js | 12 +- publish/client/mp/pages/action/action.js | 37 +++++- publish/client/mp/project.config.json | 156 +++++++++++------------ 4 files changed, 125 insertions(+), 82 deletions(-) diff --git a/frame.js b/frame.js index 8089f4cd..0361603b 100644 --- a/frame.js +++ b/frame.js @@ -761,7 +761,7 @@ Volcanos("onmotion", {help: "动态交互", list: [], _init: function(can, targe can.page.Modify(can, target||can._output, "") }, hidden: function(can, target) { - can.page.Modify(can, target, {style: {display: "none"}}) + can.page.Modify(can, target||can._target, {style: {display: "none"}}) }, toggle: function(can, target) { can.page.Toggle(can, target) diff --git a/publish/client/mp/app.js b/publish/client/mp/app.js index e1c2fe83..334e36ba 100644 --- a/publish/client/mp/app.js +++ b/publish/client/mp/app.js @@ -18,6 +18,14 @@ App({ }; return max }, Table: function(cb) { var res = [] + if (msg.append && msg.append[0] == "key" && msg.append[1] == "value") { + var line = {}; kit.List(msg.key, function(key, index) { + line[key] = msg.value[index] + }) + typeof cb == "function" && cb(line, 0, 1) + return res.push(line), res + } + for (var i = 0; i < msg.Length(); i++) { var line = {} for (var k in msg.append) { line[msg.append[k]] = msg[msg.append[k]][i] } typeof cb == "function" && cb(line, i, msg.Length()) @@ -107,9 +115,9 @@ App({ }}) }, location: function(cb) { wx.chooseLocation({success: function(res) { typeof cb == "function" && cb({ - name: res.name, text: res.address, - latitude: parseInt(res.latitude * 100000), + type: "gcj02", name: res.name, text: res.address, longitude: parseInt(res.longitude * 100000), + latitude: parseInt(res.latitude * 100000), }) }}) }, diff --git a/publish/client/mp/pages/action/action.js b/publish/client/mp/pages/action/action.js index 7e4c6ff2..3ad10595 100644 --- a/publish/client/mp/pages/action/action.js +++ b/publish/client/mp/pages/action/action.js @@ -148,13 +148,48 @@ Page({ app.toast("添加成功"), page.run(event, order) }) }) }, - upload: function() { + startLocalServiceDiscovery: function(event, page, order, cmd) { + wx.onLocalServiceFound(function(res) { + console.log(res) + }) + + wx.showLoading() + wx.startLocalServiceDiscovery({ + serviceType: '_http._tcp.', + success: function(res) { + wx.hideLoading() + console.log(res) + }, + }) }, + getLocation: function(event, page, order, cmd) { app.location(function(res) { page.run(event, order, kit.Simple("action", cmd, res), function() { app.toast("添加成功"), page.run(event, order) }) }) }, + chooseLocation: function(event, page, order, cmd) { + wx.chooseLocation({success: function(res) { res.text = res.address, delete(res.address) + page.run(event, order, kit.Simple("action", cmd, res), function() { + app.toast("添加成功"), page.run(event, order) + }) + }}) + }, + + getWifiList: function(event, page, order, cmd) { + wx.onGetWifiList(function(res) { + console.log(res) + }) + + wx.getWifiList(function(res) { + console.log(res) + }) + }, + openLocation: function(event, page, order, cmd) { + var list = page.data.list[order].msg.Table() + var data = list[event.currentTarget.dataset.index]||list[0] + wx.openLocation({name: data.name, address: data.text, latitude: parseInt(data.latitude)/100000.0, longitude: parseInt(data.longitude)/100000.0}) + }, }, onReady: function () {}, diff --git a/publish/client/mp/project.config.json b/publish/client/mp/project.config.json index f6e0f15b..c0e12128 100644 --- a/publish/client/mp/project.config.json +++ b/publish/client/mp/project.config.json @@ -1,80 +1,80 @@ { - "description": "项目配置文件", - "packOptions": { - "ignore": [] - }, - "setting": { - "urlCheck": true, - "es6": true, - "enhance": false, - "postcss": true, - "preloadBackgroundData": false, - "minified": true, - "newFeature": true, - "coverView": true, - "nodeModules": false, - "autoAudits": false, - "showShadowRootInWxmlPanel": true, - "scopeDataCheck": false, - "uglifyFileName": false, - "checkInvalidKey": true, - "checkSiteMap": true, - "uploadWithSourceMap": true, - "compileHotReLoad": false, - "useMultiFrameRuntime": false, - "useApiHook": true, - "babelSetting": { - "ignore": [], - "disablePlugins": [], - "outputPath": "" - }, - "enableEngineNative": false, - "bundle": false, - "useIsolateContext": true, - "useCompilerModule": true, - "userConfirmedUseCompilerModuleSwitch": false, - "userConfirmedBundleSwitch": false, - "packNpmManually": false, - "packNpmRelationList": [], - "minifyWXSS": true - }, - "compileType": "miniprogram", - "libVersion": "2.0.4", - "appid": "wxf4e5104d83476ed6", - "projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE", - "debugOptions": { - "hidedInDevtools": [] - }, - "isGameTourist": false, - "simulatorType": "wechat", - "simulatorPluginLibVersion": {}, - "condition": { - "search": { - "list": [] - }, - "conversation": { - "list": [] - }, - "plugin": { - "list": [] - }, - "game": { - "currentL": -1, - "list": [] - }, - "gamePlugin": { - "list": [] - }, - "miniprogram": { - "list": [ - { - "id": -1, - "name": "pages/action/action", - "pathName": "pages/action/action", - "query": "river=2d506d&storm=8271a3&title=hi.scan", - "scene": 1001 - } - ] - } - } + "description": "项目配置文件", + "packOptions": { + "ignore": [] + }, + "setting": { + "urlCheck": true, + "es6": true, + "enhance": false, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": true, + "coverView": true, + "nodeModules": false, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "uglifyFileName": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "compileHotReLoad": false, + "useMultiFrameRuntime": false, + "useApiHook": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "enableEngineNative": false, + "bundle": false, + "useIsolateContext": true, + "useCompilerModule": true, + "userConfirmedUseCompilerModuleSwitch": false, + "userConfirmedBundleSwitch": false, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true + }, + "compileType": "miniprogram", + "libVersion": "2.15.0", + "appid": "wxf4e5104d83476ed6", + "projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE", + "debugOptions": { + "hidedInDevtools": [] + }, + "isGameTourist": false, + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, + "condition": { + "search": { + "list": [] + }, + "conversation": { + "list": [] + }, + "plugin": { + "list": [] + }, + "game": { + "currentL": -1, + "list": [] + }, + "gamePlugin": { + "list": [] + }, + "miniprogram": { + "list": [ + { + "id": 0, + "name": "pages/action/action", + "pathName": "pages/action/action", + "query": "river= e0a1eb&storm=c23ae3&title=hi.scan", + "scene": 1001 + } + ] + } + } } \ No newline at end of file