diff --git a/app.js b/app.js index e8613fa..b0da6b2 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,7 @@ //app.js App({ - onLaunch: function () { + onLaunch: function (opt) { + console.log('onLaunch: ', opt) // 展示本地存储能力 var logs = wx.getStorageSync('logs') || [] logs.unshift(Date.now()) diff --git a/app.json b/app.json index a1759e7..ea94f5e 100644 --- a/app.json +++ b/app.json @@ -32,8 +32,14 @@ "pages/component/movable/movable", "pages/component/doc-web-view/doc-web-view", "pages/component/page-meta/page-meta", + "pages/component/map/map", + "pages/component/multiple-map/multiple-map", + "pages/component/keyboard-accessory/keyboard-accessory", "pages/component/camera/camera", - "pages/component/cover-view/cover-view" + "pages/component/cover-view/cover-view", + "pages/component/webrtc/webrtc", + "pages/component/page-container/page-container", + "pages/component/share-element/share-element" ], "subpackages": [ { @@ -83,7 +89,10 @@ "pages/FileSystemManager/writefile", "pages/EventChannel/firstpage/index", "pages/EventChannel/secondpage/index", - "pages/Accelerometer/index" + "pages/Accelerometer/index", + "pages/getRandomValues/getRandomValues", + "pages/checkIsOpenAccessibility/index", + "pages/locationapi/index" ] } ], diff --git a/fide.project.config.json b/fide.project.config.json new file mode 100644 index 0000000..edc8dad --- /dev/null +++ b/fide.project.config.json @@ -0,0 +1,12 @@ +{ + "description": "项目配置文件", + "packOptions": { + "ignore": [] + }, + "setting": { + "useOldBuilder": false + }, + "compileType": "miniprogram", + "projectname": "applet-demo", + "isGameTourist": false +} \ No newline at end of file diff --git a/image/duck.gif b/image/duck.gif new file mode 100755 index 0000000..5bcdced Binary files /dev/null and b/image/duck.gif differ diff --git a/image/logo.png b/image/logo.png new file mode 100644 index 0000000..ac567d4 Binary files /dev/null and b/image/logo.png differ diff --git a/packageAPI/pages/FileSystemManager/writefile.js b/packageAPI/pages/FileSystemManager/writefile.js index 9e678cc..93aa8d3 100644 --- a/packageAPI/pages/FileSystemManager/writefile.js +++ b/packageAPI/pages/FileSystemManager/writefile.js @@ -1,526 +1,167 @@ // pages/writefile/index.js console.log('page 打印', wx.env.USER_DATA_PATH); + +// const base64 = require('../../utils/data') +let fs = null Page({ /** * 页面的初始数据 */ data: { - filePath: `${wx.env.USER_DATA_PATH}/d`, + // base64, + // 配置路径循环生成 + paths: [ + `finfile://usr/a.txt`, + `finfile://usr/b.txt`, + `finfile://usr/c.txt`, + `finfile://usr/test`, + `finfile://usr/1.zip`, + `finfile://usr/test/a.txt`, + `finfile://usr/test/b.txt`, + `finfile://usr/test/c.txt`, + `finfile://temp/c.txt`, + `finfile://temp/a/b/c`, + `finfile://store/c.txt`, + `http://usr/1.zip`, + `http://usr/aa`, + `http://usr/aa/ab.txt`, + `http://store/a.txt`, + `http://store/b.txt`, + `http://store/test`, + `wxfile://usr/aa`, + `wxfile://usr/aa/abc.txt`, + + ], + + + filePath: '', data: "", - encoding: "utf-8", - source: "", - readencoding:"utf-8" - + encoding: "", + recursive: null, + path1: '', + path2: '', + flag: '', + position: '', + offset:'', + entries:'' }, - readFileFunc(path, encoding,position,length) { - console.log('readFile encoding:', encoding, '; path:', path); - - const fs = wx.getFileSystemManager() - fs.readFile({ - filePath: path, - encoding, - position, - length, - - success(res) { - console.log('readFile success:', res) - }, - fail(res) { - console.log('readFile fail:', res) - } + onLoad() { + this.setData({ + filePath: `${wx.env.USER_DATA_PATH}` }) + fs = wx.getFileSystemManager() }, - readFileSyncFunc(path, encoding, position, length) { - console.log('readFileSync encoding:', encoding, '; path:', path); - - const fs = wx.getFileSystemManager() - - try { - const res = fs.readFileSync(path, encoding,position,length) - console.log('readFileSync res:', res) - } catch (e) { - console.log('readFileSync error:', e) - } - }, - - //同步 - writeFileSync() { - const fs = wx.getFileSystemManager() - try { - const res = fs.writeFileSync( - /* `${wx.env.USER_DATA_PATH}/hello.mp3` */null, "", 'utf8' - ) - console.log('writeFileSync:', res) - - } catch (e) { - console.error('writeFileSync err:', e) - } - }, - - //异步文件测试 - writeFile() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: this.data.filePath, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,1,3) - this.readFileFunc(this.data.filePath, this.data.encoding,2,4) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - writeFileStartRange() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: this.data.filePath, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,3,1) - this.readFileFunc(this.data.filePath, this.data.encoding,3,1) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - writeFileLength0() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: this.data.filePath, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,2,0) - this.readFileFunc(this.data.filePath, this.data.encoding,2,0) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - writeFileLengthPoint() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: this.data.filePath, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,2,1.2) - this.readFileFunc(this.data.filePath, this.data.encoding,2,1.2) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } + setParams(e) { + const { key } = e.currentTarget.dataset + this.setData({ + [key]: e.detail.value }) }, - writeFileReadnoEncoding() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - const path = `${wx.env.USER_DATA_PATH}/nc` - fs.writeFile({ - filePath:path, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log('写文件路径:' ,path), - this.readFileSyncFunc(path) - this.readFileFunc(path) - }, - fail(res) { - console.log('writeFile fail:', res) -// console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, + - writeFilePermission() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - - data: this.data.data, - filePath:`${wx.env.USER_DATA_PATH}/d`, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(this.data.filePath, this.data.encoding,1,3) - this.readFileFunc(this.data.filePath, this.data.encoding,2,4) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - writeFileNotFound() { - console.log("打印地址", this.data.filePath) - console.log("当前选中deta:",this.data.data) - const fs = wx.getFileSystemManager() - fs.writeFile({ - - data: this.data.data, - filePath:`${wx.env.USER_DATA_PATH}/d`, - encoding: this.data.encoding, - success: (res) => { - console.log('writeFile success:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - this.readFileSyncFunc(`${wx.env.USER_DATA_PATH}/dl`,this.data.encoding,1,3) - this.readFileFunc(`${wx.env.USER_DATA_PATH}/dl`, this.data.encoding,2,4) - }, - fail(res) { - console.log('writeFile fail:', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - } - }) - }, - - base64File() { - const path = `${wx.env.USER_DATA_PATH}/d` - wx.fileToBase64({ - url: path, - success: (res) => { - console.log('fileToBase64 success: ', res) - console.log(res.data) - }, - fail(res) { - console.log('fileToBase64 fail: ', res) - } - }) - }, - - saveFile() { - wx.saveFile({ - filePath: `${wx.env.USER_DATA_PATH}/d`, - success(res) { - console.log("保存成功", res) - }, - fail(res) { - console.log("保存失败", res) - } - }) - }, - - - - downFile() { + downZipSave(){ + const fs=wx.getFileSystemManager() wx.downloadFile({ - url: `${wx.env.USER_DATA_PATH}/d`, - success(res) { - console.log("下载成功", res) - }, - fail(res) { - console.log("下载失败", res) - } - }) - }, - - //图片 - writeImage() { - const fs = wx.getFileSystemManager() - const path = `${wx.env.USER_DATA_PATH}/a` - fs.writeFile({ - filePath: path, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeImagSuccess', res) - console.log(path) - this.readFileSyncFunc(path, 'base64') - this.readFileFunc(path, 'base64') - }, - fail(res) { - console.log('writeImageFail', res) - } - }) - }, - - imagePreview() { - wx.previewImage({ - urls: [`${wx.env.USER_DATA_PATH}/a`], - success(res) { - console.log("图片预览成功", res) - }, - fail(res) { - console.log("图片预览失败", res) - } - }) - }, - - - imageCompress() { - - wx.compressImage({ - src: '`${wx.env.USER_DATA_PATH}/a`', - - success(res) { - console.log("图片压缩成功", res) - }, - fail(res) { - console.log("图片压缩失败", res) - } - }) - }, - - - imageSaveToPhotosAlbum() { - wx.saveImageToPhotosAlbum({ - filePath: `${wx.env.USER_DATA_PATH}/a`, - - success(res) { - console.log("图片保存到相册成功", res) - }, - fail(res) { - console.log("图片保存到相册失败", res) - } - }) - }, - - fileUpload() { - - wx.uploadFile({ - filePath: `${wx.env.USER_DATA_PATH}/a`, - name: 'file', - url: 'https://finchat-mop-b.finogeeks.club/api/v1/mop/finstore/dev/files?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjUxOTQyMjgsImZjaWQiOiI1ZmYzZDhmZWU3YzNiNTAwMDExYWQxMmEiLCJpYXQiOjE2MjUxODcwMjgsImlzcyI6Ijc1NWUxNnFrNVZLUnBlcWhKM1IySVFwV2NOdlQ5TWJOIn0.IQXdjiH5One-GVsU9E5KTze0fXJ7InJE-BrmcQs9yIc', - success(res) { - console.log("文件上传成功", res) - }, - fail(res) { - console.log("文件上传失败", res) - } - }) - }, - - - - //视频 - writeVideo() { - const fs = wx.getFileSystemManager() - const path = `${wx.env.USER_DATA_PATH}/b.mp4` - fs.writeFile({ - filePath: path, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeVideo Success', res) - console.log(`${wx.env.USER_DATA_PATH}/b.mp4`) - - this.readFileSyncFunc(path, 'base64') - this.readFileFunc(path, 'base64') - }, - - fail(res) { - console.log('writeFail', res) - } - }) - }, - - videoSaveToPhotosAlbum() { - wx.saveVideoToPhotosAlbum({ - filePath: `${wx.env.USER_DATA_PATH}/b.mp4`, - success(res) { - console.log("视频保存到相册成功", res) - }, - fail(res) { - console.log("视频保存到相册失败", res) - } - }) - }, - - - mediaPreview() { - wx.previewMedia({ - sources: [ - { - "url": `${wx.env.USER_DATA_PATH}/b.mp4`, - "type": "video" - } - ], - success(res) { - console.log("视频播放成功", res) - }, - fail(res) { - console.log("视频播放失败", res) - } - }) - }, - - - videoPreview() { - wx.previewVideo({ - - url: `${wx.env.USER_DATA_PATH}/b.mp4`, - autoplay: true, - success(res) { - console.log('视频播放成功', res) - }, - fail(res) { - console.log('播放失败', res) - } - }) - - }, - - //语音 - writeAudio() { - const fs = wx.getFileSystemManager() - const path = `${wx.env.USER_DATA_PATH}/c.mp3` - fs.writeFile({ - filePath: path, - data: this.data.data, - encoding: this.data.encoding, - success: (res) => { - console.log('writeAudio Success', res) - console.log(`${wx.env.USER_DATA_PATH}/c.mp3`) - this.readFileSyncFunc(path, 'base64',10,13) - this.readFileFunc(path, 'base64',20,15) - }, - - fail(res) { - console.log('writeFail', res) - } - }) - }, - - innerAudioPlay() { - const ctx = wx.createInnerAudioContext() - ctx.src = `${wx.env.USER_DATA_PATH}/c.mp3` - /* ctx.seek(20) */ - ctx.play() - ctx.onPlay(() => { - console.log('开始播放') - }) - ctx.onError((res) => { - console.log(res.errMsg) - console.log(res.errCode) - console.log(res) - }) - }, - - - voicePlay() { - - wx.playVoice({ - filePath: `${wx.env.USER_DATA_PATH}/c.mp3`, - success(res) { - console.log("播放成功", res) - }, - fail(res) { - console.log("播放失败", res) - } - }) - }, - - - documentOpen() { - const fs = wx.getFileSystemManager() - fs.writeFile({ - filePath: `${wx.env.USER_DATA_PATH}/wd.doc`, - data: this.data.data, - encoding: this.data.encoding, - success(res) { - console.log('writeSuccess', res) - console.log(`${wx.env.USER_DATA_PATH}/wd.doc`) - wx.openDocument({ - filePath: `${wx.env.USER_DATA_PATH}/wd.doc`, - - success(res) { - console.log("文件打开成功", res) + url: 'https://app.finogeeks.com/finchat/sdk/FinApplet-dev-2.34.0-alpha20210826v06.zip', + success(res){ + console.log("文件下载成功",res) + fs.saveFile({ + tempFilePath: res.tempFilePath, + filePath: `${wx.env.USER_DATA_PATH}/1.zip`, + success(res){ + console.log("zip保存成功",res) }, - fail(res) { - console.log("文件打开失败", res) + fail(res){ + console.log("zip保存失败",res) } }) - }, - fail(res) { - console.log('writeFail', res) } }) }, + invokeApi(e) { + console.log('点击了 button') + const { api, encoding, data, recursive, flag, length, entries, position, offset, arr = [], set, arrayBuffer, ...params } = e.currentTarget.dataset + if (api) { + // 将配置的参数转换为 data 参数 + Object.keys(params).forEach(value => { + const key = params[value] + params[value] = this.data[key] + }) - - - - - writeFileArrayBuffer() { - console.log("打印地址", this.data.filePath) - /* console.log("打印data",this.data.data) */ - const fs = wx.getFileSystemManager() - fs.writeFile({ - data: wx.base64ToArrayBuffer(this.data.data), - filePath: `${wx.env.USER_DATA_PATH}/d`, - encoding: this.data.encoding, - success(res) { - console.log('writeSuccess', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) - }, - fail(res) { - console.log('writeFail', res) - console.log(`${wx.env.USER_DATA_PATH}/d`) + // encoding 和 data 有配置就是 true,直接赋值 + if (encoding !== undefined) { + params.encoding = this.data.encoding + } + + if (entries !== undefined) { + params.entries = this.data.entries + } + + if (length !== undefined) { + params.length = this.data.length + } + if (position !== undefined) { + params.position = this.data.position + } + + if (data !== undefined) { + params.data = this.data.data + } + if (recursive !== undefined) { + params.recursive = this.data.recursive + } + + if (flag !== undefined) { + params.flag = this.data.flag + } + + if (arrayBuffer !== undefined) { + params.arrayBuffer = new ArrayBuffer(arrayBuffer) + } + + if (api.endsWith('Sync') && arr && arr.length) { + let list = arr.split(',').map(key => this.data[key]) + console.log('准备执行同步 api:', api, list) + fs[api].apply(this, list) + } else { + console.log('准备执行 api:', api, params) + const res = fs[api]({ + ...params, + success: (res) =>{ + if (set && res[set]) { + this.setData({ + [set]: res[set] + }) + } + console.log('调用成功 success') + console.log(res) + }, + fail (res) { + console.log('调用失败 fail') + console.log(res) + } + }) + if (res) { + console.log('调用成功 success:', res) + } + if (set) { + this.setData({ + [set]: res + }) + } } - }) - }, - - bindchangepath(e) { - this.setData({ - filePath: e.detail.value - }) - }, - - bindchangeencoding(e) { - this.setData({ - encoding: e.detail.value - }) - }, - - bindchangedata(e) { - this.setData({ - data: e.detail.value - }) - }, - - + } + } }) + \ No newline at end of file diff --git a/packageAPI/pages/FileSystemManager/writefile.json b/packageAPI/pages/FileSystemManager/writefile.json index 59917b8..8835af0 100644 --- a/packageAPI/pages/FileSystemManager/writefile.json +++ b/packageAPI/pages/FileSystemManager/writefile.json @@ -1,4 +1,3 @@ { - "usingComponents": {}, - "disableScroll":false + "usingComponents": {} } \ No newline at end of file diff --git a/packageAPI/pages/FileSystemManager/writefile.wxml b/packageAPI/pages/FileSystemManager/writefile.wxml index d1d768b..646006a 100644 --- a/packageAPI/pages/FileSystemManager/writefile.wxml +++ b/packageAPI/pages/FileSystemManager/writefile.wxml @@ -1,133 +1,383 @@ - - - - -设置 - -验证filePath允许设置的值(打开页面初始化时,设置的是本地路径) - -http地址 -代码包中的一个图片路径 -设置为空 -本地路径 -null + +路径参数 path 1 + + http地址 + 代码包中的一个图片路径 + 本地路径 + 设置为空 + null + {{item}} -修改writeFile encoding类型 - -ascii -base64 -binary -hex -ucs2(以小端序读取) -ucs-2(以小端序读取) -utf16le(以小端序读取) -utf-16le(以小端序读取) -utf-8 -utf8 -latin1 - -123 +修改 entries 参数 + + true + 111 + 设置为空 -修改data类型 - -空值 -abc -中文 -[] -null - -image_base64 - - - -video_base64 - -audio_base64 - - -wenjian - - -新文件 +修改 recursive 参数 + + true + 111 + 设置为空 - - - - +修改 flag 参数 + + a + ax + a+ + ax+ + as + as+ + r + r+ + w + wx + w+ + wx+ + null + 111 + 设置为空 + - - - - - - - - - - +修改 length 参数 + + -1 + + 0.5 + 1 + 3 + 3.1zsad + 3.9 + 50 + sss + null + - - +修改 position 参数 + + -1 + + 0.5 + 3 + 3.1zsad + 3.9 + 50 + sss + null + + +修改 offset 参数 + + -1 + + 0.5 + 3 + 3.1zsad + 3.9 + 50 + sss + null + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -image - - - - - +修改 encoding 参数 + + ascii + base64 + binary + hex + ucs2(以小端序读取) + ucs-2(以小端序读取) + utf16le(以小端序读取) + utf-16le(以小端序读取) + utf-8 + utf8 + latin1 + + 123 + -video - - - - +修改 data 参数 + + 空值 + abc + 中文 + [] + null + + image_base64 + + video_base64 + + audio_base64 + + wenjian + 新文件 + -audio - - - - + 路径参数 path 2 + + http地址 + 代码包中的一个图片路径 + 本地路径 + 设置为空 + null + {{item}} + \ No newline at end of file diff --git a/packageAPI/pages/FileSystemManager/writefile.wxss b/packageAPI/pages/FileSystemManager/writefile.wxss index b2b35dc..1ac0271 100644 --- a/packageAPI/pages/FileSystemManager/writefile.wxss +++ b/packageAPI/pages/FileSystemManager/writefile.wxss @@ -1,8 +1,6 @@ -/* pages/writefile/index.wxss */ - -.title { - padding: 10rpx 20rpx; - font-size: 30rpx; - font-weight: bold; - text-align: center; +/* pages/file-2/index.wxss */ +.box { + display: flex; + flex-wrap: wrap; + padding-bottom: 300rpx; } diff --git a/packageAPI/pages/checkIsOpenAccessibility/index.js b/packageAPI/pages/checkIsOpenAccessibility/index.js new file mode 100644 index 0000000..6a4c370 --- /dev/null +++ b/packageAPI/pages/checkIsOpenAccessibility/index.js @@ -0,0 +1,21 @@ + +Page({ + + /** + * 页面的初始数据 + */ + data: { + status: '' + }, + checkIsOpenAccessibility () { + const self = this + wx.checkIsOpenAccessibility({ + complete (res) { + console.log('checkIsOpenAccessibility complete: ', res) + self.setData({ + status: res.open + }) + } + }) + } +}) \ No newline at end of file diff --git a/packageAPI/pages/checkIsOpenAccessibility/index.json b/packageAPI/pages/checkIsOpenAccessibility/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/packageAPI/pages/checkIsOpenAccessibility/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/packageAPI/pages/checkIsOpenAccessibility/index.wxml b/packageAPI/pages/checkIsOpenAccessibility/index.wxml new file mode 100644 index 0000000..adf3236 --- /dev/null +++ b/packageAPI/pages/checkIsOpenAccessibility/index.wxml @@ -0,0 +1,6 @@ + + + 无障碍功能开启状态: {{status}} + + + \ No newline at end of file diff --git a/packageAPI/pages/checkIsOpenAccessibility/index.wxss b/packageAPI/pages/checkIsOpenAccessibility/index.wxss new file mode 100644 index 0000000..acd85a8 --- /dev/null +++ b/packageAPI/pages/checkIsOpenAccessibility/index.wxss @@ -0,0 +1 @@ +/* pages/navcustom/navcustom.wxss */ \ No newline at end of file diff --git a/packageAPI/pages/get-system-info/get-system-info.js b/packageAPI/pages/get-system-info/get-system-info.js index 1e2e432..7f45bbc 100644 --- a/packageAPI/pages/get-system-info/get-system-info.js +++ b/packageAPI/pages/get-system-info/get-system-info.js @@ -32,6 +32,21 @@ Page({ // Do something when catch error } }, + getSystemInfoAsync () { + const that = this; + console.log('getSystemInfoAsync start') + wx.getSystemInfoAsync({ + success(res) { + that.setData({ + systemInfo: res + }) + }, + complete (res) { + console.log('getSystemInfoAsync complete: ', res) + } + }) + console.log('getSystemInfoAsync end') + }, clearInfo() { this.setData({ systemInfo: {} diff --git a/packageAPI/pages/get-system-info/get-system-info.wxml b/packageAPI/pages/get-system-info/get-system-info.wxml index 591e3b5..11daf65 100644 --- a/packageAPI/pages/get-system-info/get-system-info.wxml +++ b/packageAPI/pages/get-system-info/get-system-info.wxml @@ -76,6 +76,7 @@ + diff --git a/packageAPI/pages/getRandomValues/getRandomValues.js b/packageAPI/pages/getRandomValues/getRandomValues.js new file mode 100644 index 0000000..1c3a450 --- /dev/null +++ b/packageAPI/pages/getRandomValues/getRandomValues.js @@ -0,0 +1,15 @@ +const app = getApp() + +Page({ + data: { + + }, + getRandomValues () { + wx.getRandomValues({ + length: 20, + complete (res) { + console.log('getRandomValues complete: ', res) + } + }) + } +}) diff --git a/packageAPI/pages/getRandomValues/getRandomValues.json b/packageAPI/pages/getRandomValues/getRandomValues.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/packageAPI/pages/getRandomValues/getRandomValues.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/packageAPI/pages/getRandomValues/getRandomValues.wxml b/packageAPI/pages/getRandomValues/getRandomValues.wxml new file mode 100644 index 0000000..c2f3008 --- /dev/null +++ b/packageAPI/pages/getRandomValues/getRandomValues.wxml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packageAPI/pages/getRandomValues/getRandomValues.wxss b/packageAPI/pages/getRandomValues/getRandomValues.wxss new file mode 100644 index 0000000..e69de29 diff --git a/packageAPI/pages/locationapi/index.js b/packageAPI/pages/locationapi/index.js new file mode 100644 index 0000000..880e737 --- /dev/null +++ b/packageAPI/pages/locationapi/index.js @@ -0,0 +1,149 @@ + +Page({ + data: { + openLocation_latitude: 22.53332, + openLocation_longitude: 113.93041, + openLocation_scale: 18, + openLocation_name: 'testname', + openLocation_address: 'addressaddressaddressaddress', + getLocation_type: 'gcj02', + getLocation_altitude: 'false', + getLocation_isHighAccuracy: 'false', + getLocation_highAccuracyExpireTime: 3000, + chooseLocation_latitude: 22.53332, + chooseLocation_longitude: 113.93041 + }, + onLoad() { + + }, + valueChange (e) { + const { changekey } = e.target.dataset + const { value } = e.detail + const obj = {} + obj[changekey] = value + this.setData(obj) + }, + emitopenLocation () { + let { + openLocation_latitude: latitude, + openLocation_longitude: longitude, + openLocation_scale: scale, + openLocation_name: name, + openLocation_address: address + } = this.data + const args = {} + try { + latitude = JSON.parse(latitude) + } catch (e) {} + try { + longitude = JSON.parse(longitude) + } catch (e) {} + try { + scale = JSON.parse(scale) + } catch (e) {} + // try { + // name = JSON.parse(name) + // } catch (e) {} + // try { + // address = JSON.parse(address) + // } catch (e) {} + latitude !== 'no' && (args.latitude = latitude) + longitude !== 'no' && (args.longitude = longitude) + scale !== 'no' && (args.scale = scale) + name !== 'no' && (args.name = name) + address !== 'no' && (args.address = address) + console.log('openLocation 参数: ', args) + wx.openLocation({ + ...args, + success (res) { + console.log('openLocation success: ', res) + }, + fail (res) { + console.log('openLocation fail: ', res) + }, + complete (res) { + console.log('openLocation complete: ', res) + } + }) + }, + emitgetLocation () { + let { + getLocation_type: type, + getLocation_altitude: altitude, + getLocation_isHighAccuracy: isHighAccuracy, + getLocation_highAccuracyExpireTime: highAccuracyExpireTime, + } = this.data + const args = {} + try { + type = JSON.parse(type) + } catch (e) {} + try { + altitude = JSON.parse(altitude) + } catch (e) {} + try { + isHighAccuracy = JSON.parse(isHighAccuracy) + } catch (e) {} + try { + highAccuracyExpireTime = JSON.parse(highAccuracyExpireTime) + } catch (e) {} + type !== 'no' && (args.type = type) + altitude !== 'no' && (args.altitude = altitude) + isHighAccuracy !== 'no' && (args.isHighAccuracy = isHighAccuracy) + highAccuracyExpireTime !== 'no' && (args.highAccuracyExpireTime = highAccuracyExpireTime) + console.log('getLocation 参数: ', args) + wx.getLocation({ + ...args, + success (res) { + console.log('getLocation success: ', res) + }, + fail (res) { + console.log('getLocation fail: ', res) + }, + complete (res) { + console.log('getLocation complete: ', res) + } + }) + }, + emitchoosePoi () { + wx.choosePoi({ + success (res) { + console.log('emitchoosePoi success: ', res) + }, + fail (res) { + console.log('emitchoosePoi fail: ', res) + }, + complete (res) { + console.log('emitchoosePoi complete: ', res) + } + }) + }, + emitchooseLocation () { + let { + chooseLocation_latitude: latitude, + chooseLocation_longitude: longitude + } = this.data + const args = {} + try { + latitude = JSON.parse(latitude) + } catch (e) {} + try { + longitude = JSON.parse(longitude) + } catch (e) {} + + latitude !== 'no' && (args.latitude = latitude) + longitude !== 'no' && (args.longitude = longitude) + console.log('chooseLocation 参数: ', args) + wx.chooseLocation({ + ...args, + success (res) { + console.log('chooseLocation success: ', res) + }, + fail (res) { + console.log('chooseLocation fail: ', res) + }, + complete (res) { + console.log('chooseLocation complete: ', res) + } + }) + } +}) diff --git a/packageAPI/pages/locationapi/index.json b/packageAPI/pages/locationapi/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/packageAPI/pages/locationapi/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/packageAPI/pages/locationapi/index.wxml b/packageAPI/pages/locationapi/index.wxml new file mode 100644 index 0000000..e99f277 --- /dev/null +++ b/packageAPI/pages/locationapi/index.wxml @@ -0,0 +1,59 @@ + + + 输入框规则与map组件的一致,可以输入json串解析成各种类型的数据,no不传参 + + + + + latitude: + + + longitude: + + + scale: + + + name: + + + address: + + + + + + + + type: + + + altitude: + + + isHighAccuracy: + + + highAccuracyExpireTime: + + + + + + + + + + + + latitude: + + + longitude: + + + + + + + \ No newline at end of file diff --git a/packageAPI/pages/locationapi/index.wxss b/packageAPI/pages/locationapi/index.wxss new file mode 100644 index 0000000..9928597 --- /dev/null +++ b/packageAPI/pages/locationapi/index.wxss @@ -0,0 +1,34 @@ +/**index.wxss**/ +.userinfo { + display: flex; + flex-direction: column; + align-items: center; + color: #aaa; +} + +.userinfo-avatar { + overflow: hidden; + width: 128rpx; + height: 128rpx; + margin: 20rpx; + border-radius: 50%; +} + +.usermotto { + margin-top: 200px; +} + +.item{ + border-bottom: 1px solid #dddddd; + padding: 20rpx; + margin-top: 20rpx; +} + +.key-change{ + display: flex; + padding: 7rpx; +} +.key-change input{ + border: 1px solid #abcdef; + flex-grow: 1; +} diff --git a/packageAPI/pages/on-network-status-change/on-network-status-change.js b/packageAPI/pages/on-network-status-change/on-network-status-change.js index a3df7c1..a900e9d 100644 --- a/packageAPI/pages/on-network-status-change/on-network-status-change.js +++ b/packageAPI/pages/on-network-status-change/on-network-status-change.js @@ -12,12 +12,13 @@ Page({ }, onLoad() { const that = this - wx.onNetworkStatusChange(function (res) { - that.setData({ - isConnected: res.isConnected, - networkType: res.networkType - }) - }) + this.onNetworkStatusChange() + // wx.onNetworkStatusChange(function (res) { + // that.setData({ + // isConnected: res.isConnected, + // networkType: res.networkType + // }) + // }) }, onShow() { const that = this @@ -29,5 +30,17 @@ Page({ }) } }) + }, + networkstatuschangehandler (res) { + this.setData({ + isConnected: res.isConnected, + networkType: res.networkType + }) + }, + onNetworkStatusChange () { + wx.onNetworkStatusChange(this.networkstatuschangehandler) + }, + offNetworkStatusChange () { + wx.offNetworkStatusChange(this.networkstatuschangehandler) } }) diff --git a/packageAPI/pages/on-network-status-change/on-network-status-change.wxml b/packageAPI/pages/on-network-status-change/on-network-status-change.wxml index 9d9ca6a..1936a86 100644 --- a/packageAPI/pages/on-network-status-change/on-network-status-change.wxml +++ b/packageAPI/pages/on-network-status-change/on-network-status-change.wxml @@ -16,6 +16,10 @@ {{networkType}} + + + + diff --git a/pages/API/index/index.js b/pages/API/index/index.js index 60c363c..bde284d 100644 --- a/pages/API/index/index.js +++ b/pages/API/index/index.js @@ -190,6 +190,9 @@ Page({ }, { zh: '使用原生地图选择位置', url: 'choose-location/choose-location' + }, { + zh: 'locationapi', + url: 'locationapi/index' } ] }, { @@ -236,6 +239,24 @@ Page({ url: 'Accelerometer/index' } ], + }, { + id: 'encryption', + name: '加密', + pages: [ + { + zh: 'getRandomValues', + url: 'getRandomValues/getRandomValues' + } + ], + }, { + id: 'checkIsOpenAccessibility', + name: '无障碍', + pages: [ + { + zh: 'checkIsOpenAccessibility', + url: 'checkIsOpenAccessibility/index' + } + ], } ], isSetTabBarPage: false, diff --git a/pages/component/index/index.js b/pages/component/index/index.js index eceab2b..6f3a43b 100644 --- a/pages/component/index/index.js +++ b/pages/component/index/index.js @@ -12,7 +12,7 @@ Page({ id: 'view', name: '视图容器', open: false, - pages: ['view', 'scroll-view', 'swiper', 'match-media', 'movable', 'cover-view'] + pages: ['view', 'scroll-view', 'swiper', 'match-media', 'movable', 'cover-view','page-container', 'share-element'] }, { id: 'content', name: '基础内容', @@ -22,7 +22,7 @@ Page({ id: 'form', name: '表单组件', open: false, - pages: ['button', 'checkbox', 'form', 'input', 'label', 'picker', 'picker-view', 'radio', 'slider', 'switch', 'textarea','editor'] + pages: ['button', 'checkbox', 'form', 'input', 'label', 'picker', 'picker-view', 'radio', 'slider', 'switch', 'textarea','editor','keyboard-accessory'] }, { id: 'nav', name: '导航', @@ -32,7 +32,7 @@ Page({ id: 'media', name: '媒体组件', open: false, - pages: ['image', 'video', 'camera'] + pages: ['image', 'video', 'camera', 'webrtc'] }, { id: 'canvas', name: '画布', @@ -47,6 +47,10 @@ Page({ id: 'page-attr', name: '页面属性配置节点', pages: ['page-meta'] + }, { + id: 'map', + name: '地图', + pages: ['map','multiple-map'] } ], theme: 'light' diff --git a/pages/component/keyboard-accessory/keyboard-accessory.js b/pages/component/keyboard-accessory/keyboard-accessory.js new file mode 100644 index 0000000..0f94c6f --- /dev/null +++ b/pages/component/keyboard-accessory/keyboard-accessory.js @@ -0,0 +1,78 @@ +const app = getApp() + +Page({ + data: { + height: 50, + flex: 1, + show: true, + position: 0, + kbastyle: `height: 66px;position:44;`, + editingvalue: `height: 66px;`, + covershow: false + }, + onLoad: function () { + + }, + + focus1() { + console.log('focus input\n') + }, + + blur1() { + console.log('blur input') + }, + + focus2() { + console.log('focus textarea') + }, + + blur2() { + console.log('blur textarea') + }, + + tap (e) { + console.log('bindtap', e) + }, + + positionchange (e) { + console.log(e.detail.value) + this.setData({ + position: e.detail.value + }) + }, + + textareainput (e) { + const value = e.detail.value || '' + console.log('textareainput', value) + // const reg = new RegExp(`(?<=;)position:.*?(?=;)`) + // const hasp = reg.exec(value) + const hasp = value.indexOf('position:') + console.log('textareainput', hasp) + if (hasp > -1) { + console.log('textareainput hasp ', value.slice((hasp+9), -1)) + this.setData({ + position: value.slice((hasp+9), -1) + }) + } + this.setData({ + kbastyle: value + }) + }, + + kbheightchange (e) { + console.log('~~~~~~~~~~kbheightchange~~~~~~~~', e) + }, + + kbfocus () { + console.log('~~~~~~~~~~kbfocus~~~~~~~~') + }, + + kbblur () { + console.log('~~~~~~~~~~kbblur~~~~~~~~') + }, + changecovershow () { + this.setData({ + covershow: !this.data.covershow + }) + } +}) diff --git a/pages/component/keyboard-accessory/keyboard-accessory.json b/pages/component/keyboard-accessory/keyboard-accessory.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/component/keyboard-accessory/keyboard-accessory.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/component/keyboard-accessory/keyboard-accessory.wxml b/pages/component/keyboard-accessory/keyboard-accessory.wxml new file mode 100644 index 0000000..42b43cb --- /dev/null +++ b/pages/component/keyboard-accessory/keyboard-accessory.wxml @@ -0,0 +1,36 @@ + + + + + + + + click + + + + + + + + + 测试update。 以下输入框的内容将会作为keyboard-accessory的style属性。 匹配position改变position值。 例如:height: 66px;position:44; + + + \ No newline at end of file diff --git a/pages/component/keyboard-accessory/keyboard-accessory.wxss b/pages/component/keyboard-accessory/keyboard-accessory.wxss new file mode 100644 index 0000000..d55ea20 --- /dev/null +++ b/pages/component/keyboard-accessory/keyboard-accessory.wxss @@ -0,0 +1,8 @@ +.intro { + margin: 30px; + text-align: center; +} + +.container { + display: flex; +} \ No newline at end of file diff --git a/pages/component/map/map.js b/pages/component/map/map.js new file mode 100644 index 0000000..660da87 --- /dev/null +++ b/pages/component/map/map.js @@ -0,0 +1,1724 @@ +// pages/component/map/map.js +let mapcontext +let unde + +const data = { + maptype: '3', + maptypes: ['amap','google','baidu','auto'], + booleanArray: [true, false, 'no'], + showingSence: 'latlong', + mapShow: true, + editingLongitude: '113.93041', + editingLatitude: '22.53332', + // longitude: '114.063848', + // latitude: '22.551365', + // longitude: '85.1318117790985', + // latitude: '45.69139458288415', + latitude: 22.53332, + longitude: 113.93041, + // latitude: 200, + // longitude: 200, + scale: 12, + editingScale: 12, + minScale: 3, + editingMinscale: 3, + maxScale: 20, + editingMaxscale: 20, + markers:[ + { + "id": 1, + "latitude": 22.54332, + "longitude": 113.94041, + "joinCluster": true, + "title": "title1", + "zIndex": 1, + "iconPath": "/assets/images/logo.png", + "rotate": 0, + "alpha": 1, + "width": 30, + "height": 30, + "callout": { + "content": "point1", + "color": "#ff0000", + "fontSize": 14, + "borderRadius": 7, + "borderWidth": 2, + "borderColor": "#000000", + "bgColor": "#ffffff", + "padding": 1, + "display": "ALWAYS", + "textAlign": "center", + "anchorX": 0, + "anchorY": 0 + }, + "customCallout": { + "display": "BYCLICK", + "anchorX": 0, + "anchorY": 0 + }, + "label": { + "content": "label1", + "color": "", + "fontSize": 16, + "anchorX": 0, + "anchorY": 0, + "borderWidth": 30, + "borderColor": "", + "borderRadius": 10, + "bgColor": "", + "padding": 10, + "textAlign": "center" + }, + "anchor": { + "x": 0, + "y": 0 + }, + "aria-label": "marker1 aria-label" + }, + { + "id": 2, + "latitude": 22.52332, + "longitude": 113.92041 + }, + { + "id": 3, + "latitude": 22.52332, + "longitude": 113.93041 + }, + { + "id":4, + "latitude": 22.53332, + "longitude": 113.93041, + "callout": { + "content": "point4", + }, + "label": { + "content": "label4" + } + }, + { + "id":5, + "latitude": 22.51332, + "longitude": 113.92041, + "joinCluster": true, + "callout": { + "content": "point5", + }, + "label": { + "content": "label5" + } + }, + { + "id":6, + "latitude": 22.51332, + "longitude": 113.91041, + "joinCluster": true, + "label": { + "content": "label6" + } + }, + { + "id":7, + "latitude": 22.50332, + "longitude": 113.90041, + "joinCluster": true, + "callout": { + "content": "point7", + }, + "label": { + "content": "label7" + } + } + ], + editingMarkers: ` + [ + { + "id": 1, + "latitude": 22.54332, + "longitude": 113.94041, + "joinCluster": true, + "title": "title1", + "zIndex": 1, + "iconPath": "/assets/images/logo.png", + "rotate": 0, + "alpha": 1, + "width": 30, + "height": 30, + "callout": { + "content": "point1", + "color": "#ff0000", + "fontSize": 14, + "borderRadius": 7, + "borderWidth": 2, + "borderColor": "#000000", + "bgColor": "#ffffff", + "padding": 1, + "display": "ALWAYS", + "textAlign": "center", + "anchorX": 0, + "anchorY": 0 + }, + "customCallout": { + "display": "BYCLICK", + "anchorX": 0, + "anchorY": 0 + }, + "label": { + "content": "label1", + "color": "", + "fontSize": 16, + "anchorX": 0, + "anchorY": 0, + "borderWidth": 30, + "borderColor": "", + "borderRadius": 10, + "bgColor": "", + "padding": 10, + "textAlign": "center" + }, + "anchor": { + "x": 0, + "y": 0 + }, + "aria-label": "marker1 aria-label" + }, + { + "id": 2, + "latitude": 22.52332, + "longitude": 113.92041 + }, + { + "id": 3, + "latitude": 22.52332, + "longitude": 113.93041 + }, + { + "id":4, + "latitude": 22.53332, + "longitude": 113.93041, + "callout": { + "content": "point4" + }, + "label": { + "content": "label4" + } + }, + { + "id":5, + "latitude": 22.51332, + "longitude": 113.92041, + "joinCluster": true, + "callout": { + "content": "point5" + }, + "label": { + "content": "label5" + } + }, + { + "id":6, + "latitude": 22.51332, + "longitude": 113.91041, + "joinCluster": true, + "label": { + "content": "label6" + } + }, + { + "id":7, + "latitude": 22.50332, + "longitude": 113.90041, + "joinCluster": true, + "callout": { + "content": "point7" + }, + "label": { + "content": "label7" + } + } + ] + `, + polyline: [{ + "points": [{ + "latitude": 22.53332, + "longitude": 113.93041 + },{ + "latitude": 22.52332, + "longitude": 113.92041 + },{ + "latitude": 22.52332, + "longitude": 113.93041 + }], + "color": "#02ecff", + "colorList": ["#00bcd4","#ff9800"], + "dottedLine": false, + "arrowIconPath": "", + "width": 6, + "arrowLine": true, + "borderColor": "#000000", + "borderWidth": 6, + "level": "abovelabels" + }], + editingPolyline: ` + [{ + "points": [{ + "latitude": 22.52332, + "longitude": 113.93041 + },{ + "latitude": 22.51332, + "longitude": 113.92041 + },{ + "latitude": 22.51332, + "longitude": 113.93041 + }], + "color": "#02ecff", + "colorList": ["#00bcd4","#ff9800"], + "dottedLine": false, + "arrowIconPath": "", + "width": 6, + "arrowLine": true, + "borderColor": "#000000", + "borderWidth": 6, + "level": "abovelabels" + }] + `, + circles: [{ + "latitude": 22.53932, + "longitude": 113.93641, + "color": "#ff455b", + "fillColor": "#acfd00", + "radius": 500, + "strokeWidth": 5, + "level": "abovelabels" + }], + editingCircles: `[{ + "latitude": 22.53932, + "longitude": 113.93641, + "color": "#ff455b", + "fillColor": "#acfd00", + "radius": 500, + "strokeWidth": 5, + "level": "abovelabels" + }]`, + controls: [{ + "id": 4, + "position": { + "left": 20, + "top": 60, + "width": 30, + "height": 30 + }, + iconPath: "https://img2.baidu.com/it/u=1558944015,1677859960&fm=26&fmt=auto", + clickable: true + },{ + "id": 5, + "position": { + "left": 20, + "top": 100, + "width": 30, + "height": 30 + }, + iconPath: "/image/duck.gif", + clickable: true + }], + editingControls: ` + [{ + "id": 4, + "position": { + "left": 20, + "top": 60, + "width": 30, + "height": 30 + }, + "iconPath": "/assets/images/logo.png", + "clickable": true + },{ + "id": 5, + "position": { + "left": 20, + "top": 100, + "width": 30, + "height": 30 + }, + "iconPath": "/image/duck.gif", + "clickable": true + }] + `, + includePoints: [ + { + "id": 1, + "latitude": 22.03332, + "longitude": 113.03041, + },{ + "id": 2, + "latitude": 21.53332, + "longitude": 112.93041, + },{ + "id": 3, + "latitude": 23.53332, + "longitude": 114.93041, + } + ], + editingIncludePoints: `[ + { + "id": 1, + "latitude": 22.03332, + "longitude": 113.03041 + },{ + "id": 2, + "latitude": 21.53332, + "longitude": 112.93041 + },{ + "id": 3, + "latitude": 23.53332, + "longitude": 114.93041 + } + ]`, + showLocation: false, + polygons: [{ + "points": [ + { + "latitude": 22.53932, + "longitude": 113.93641 + }, + { + "latitude": 22.53932, + "longitude": 113.92641 + }, + { + "latitude": 22.52932, + "longitude": 113.92641 + }, + { + "latitude": 22.52932, + "longitude": 113.93641 + } + ], + "strokeWidth": 4, + "strokeColor": "#9C27B0", + "fillColor": "#fff202", + "zIndex": 1, + "level": "abovelabels" + }], + editingPolygons: ` + [{ + "points": [ + { + "latitude": 22.53932, + "longitude": 113.93641 + }, + { + "latitude": 22.53932, + "longitude": 113.92641 + }, + { + "latitude": 22.52932, + "longitude": 113.92641 + }, + { + "latitude": 22.52932, + "longitude": 113.93641 + } + ], + "strokeWidth": 4, + "strokeColor": "#9C27B0", + "fillColor": "#fff202", + "zIndex": 1, + "level": "abovelabels" + }] + `, + rotate: 90, + editingrotate: 90, + skew: 20, + editingskew: 20, + enable3D: true, + showCompass: false, + showScale: true, + enableOverlooking: true, + enableZoom: true, + enableScroll: true, + enableRotate: true, + enableSatellite: true, + enableTraffic: false, + enablePoi: true, + enableBuilding: true, + setting: { + "skew": 0, + "rotate": 0, + "showLocation": false, + "showScale": false, + "enableZoom": true, + "enableScroll": true, + "enableRotate": true, + "showCompass": false, + "enable3D": false, + "enableOverlooking": false, + "enableSatellite": false, + "enableTraffic": false, + }, + eidtingSetting: ` + { + "skew": 0, + "rotate": 0, + "showLocation": false, + "showScale": false, + "enableZoom": true, + "enableScroll": true, + "enableRotate": true, + "showCompass": false, + "enable3D": false, + "enableOverlooking": false, + "enableSatellite": false, + "enableTraffic": false + } + `, + controlAreaHeight: '400px', + latlong: `[22.53332,113.93041]`, + translatemarkerMarkerid: 'no', + translatemarker_marker_autoRotate: 2, + translatemarker_rotate: 'no', + translatemarker_duration: 'no', + translatemarker_marker_moveWithRotate: 2, + translatemarker_destination: `{"latitude": 22.33332, "longitude": 113.83041 }`, + markerIconPath: '/assets/images/logo.png', + toNumber: true, + moveAlong_path: `[ + { + "latitude": 22.54332, + "longitude": 113.94041 + }, + { + "latitude": 22.53332, + "longitude": 113.93041 + }, + { + "latitude": 22.51332, + "longitude": 113.93041 + }, + { + "latitude": 22.51332, + "longitude": 113.95041 + }, + { + "latitude": 22.53332, + "longitude": 113.95041 + }, + { + "latitude": 22.54332, + "longitude": 113.94041 + } + ]`, + moveAlongMarkerid: 'no', + moveAlong_autoRotate: 2, + moveAlong_duration: 'no', + moveAlong2_path: `[ + { + "latitude": 22.54332, + "longitude": 113.94041 + }, + { + "latitude": 22.53332, + "longitude": 113.93041 + }, + { + "latitude": 22.51332, + "longitude": 113.93041 + }, + { + "latitude": 22.51332, + "longitude": 113.95041 + }, + { + "latitude": 22.53332, + "longitude": 113.95041 + }, + { + "latitude": 22.54332, + "longitude": 113.94041 + } + ]`, + moveAlong2Markerid: 'no', + moveAlong2_autoRotate: 2, + moveAlong2_duration: 'no', + centerOffset: [0.5,0.5], + editingcenterOffset : `[0.5,0.5]`, + controls_id: 'no', + controls_position: `{ + "left": 20, + "top": 20, + "width": 30, + "height": 30 + }`, + controls_iconPath: '', + controls_clickable: 2, + polyline_points: `[{ + "latitude": 22.53332, + "longitude": 113.93041 + },{ + "latitude": 22.52332, + "longitude": 113.92041 + },{ + "latitude": 22.52332, + "longitude": 113.93041 + }]`, + polyline_color: "no", + polyline_colorList: `["#00bcd4","#ff9800"]`, + polyline_dottedLine: 2, + polyline_arrowIconPath: "no", + polyline_width: 'no', + polyline_arrowLine: false, + polyline_borderColor: 'no', + polyline_borderWidth: 'no', + polyline_level: 'abovelabels', + circle_latitude: 'no', + circle_longitude: 'no', + circle_color: 'no', + circle_fillColor: 'no', + circle_radius: 'no', + circle_strokeWidth: 'no', + circle_level: 'abovelabels', + includePoints_points: `[ + { + "id": 1, + "latitude": 22.03332, + "longitude": 113.03041 + },{ + "id": 2, + "latitude": 21.53332, + "longitude": 112.93041 + },{ + "id": 3, + "latitude": 23.53332, + "longitude": 114.93041 + } + ]`, + includePoints_padding: `[10,10,10,10]`, + polygons_points: `[ + { + "latitude": 22.53932, + "longitude": 113.93641 + }, + { + "latitude": 22.53932, + "longitude": 113.92641 + }, + { + "latitude": 22.52932, + "longitude": 113.92641 + }, + { + "latitude": 22.52932, + "longitude": 113.93641 + } + ]`, + polygons_strokeWidth: 'no', + polygons_strokeColor: 'no', + polygons_fillColor: 'no', + polygons_zIndex: 'no', + polygons_level: 'no', + markers_id: '5', + markers_latitude: '22.51932', + markers_longitude: '113.92641', + markers_joinCluster: 2, + markers_title: 'no', + markers_zIndex: 'no', + markers_iconPath: 'no', + markers_rotate: 'no', + markers_alpha: 'no', + markers_width: 'no', + markers_height: 'no', + markers_callout: ` + { + "content": "point1", + "color": "#ff0000", + "fontSize": 14, + "borderRadius": 7, + "borderWidth": 2, + "borderColor": "#000000", + "bgColor": "#ffffff", + "padding": 1, + "display": "ALWAYS", + "textAlign": "center", + "anchorX": 0, + "anchorY": 0 + } + `, + markers_customCallout: ` + { + "display": "BYCLICK", + "anchorX": 0, + "anchorY": 0 + } + `, + markers_label: ` + { + "content": "label1", + "color": "#ff0000", + "fontSize": 5, + "anchorX": 0, + "anchorY": 0, + "borderWidth": 1, + "borderColor": "#000000", + "borderRadius": 2, + "bgColor": "#ffffff", + "padding": 1, + "textAlign": "center" + } + `, + markers_anchor: ` + { + "x": 0, + "y": 0 + } + `, + markers_arialabel: 'no', + addmarkers_clear: 2, + addmarkers_markers: `[ + { + "id": 666, + "latitude": 22.51332, + "longitude": 113.92041 + }, + { + "id": 667, + "latitude": 22.50332, + "longitude": 113.93041 + } + ]`, + removemarker_markerIds: `[]`, + initmarkercluster_enableDefaultStyle: 2, + initmarkercluster_zoomOnClick: 2, + initmarkercluster_gridSize: 60, + movetolocation_longitude: '113.93041', + movetolocation_latitude: '22.53332', + openmapapp_longitude: '113.93041', + openmapapp_latitude: '22.53332', + openmapapp_destination: '目的地' +} + +Page({ + + /** + * 页面的初始数据 + */ + data: { + ...data + }, + + resetData () { + this.setData(data) + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + // const {windowHeight} = wx.getSystemInfoSync() + const windowHeight = 650 + this.setData({ + controlAreaHeight: (windowHeight - 324) + 'px', + // latlong: `[${this.data.latitude}, ${this.data.longitude}]` + }) + this.emitCreateMapContext() + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + emitCreateMapContext() { + mapcontext = wx.createMapContext('maplearn') + console.log(mapcontext) + }, + bindtapHandler (res) { + console.log('debug: bindtapHandler ', res) + }, + bindmarkertapHandler (res) { + console.log('debug: bindmarkertapHandler ', res) + }, + bindlabeltapHandler (res) { + console.log('debug: bindlabeltapHandler ', res) + }, + bindcontroltapHandler (res) { + console.log('debug: bindcontroltapHandler ', res) + }, + bindcallouttapHandler (res) { + console.log('debug: bindcallouttapHandler ', res) + }, + bindupdatedHandler (res) { + console.log('debug: bindupdatedHandler ', res) + }, + bindregionchangeHandler (res) { + console.log('debug: bindregionchangeHandler ', res) + }, + bindpoitapHandler (res) { + console.log('debug: bindpoitapHandler ', res) + }, + bindanchorpointtapHandler (res) { + console.log('debug: bindanchorpointtapHandler ', res) + }, + countMarker () { + let { + markers_id, + markers_latitude, + markers_longitude, + markers_joinCluster, + markers_title, + markers_zIndex, + markers_iconPath, + markers_rotate, + markers_alpha, + markers_width, + markers_height, + markers_callout, + markers_customCallout, + markers_label, + markers_anchor, + markers_arialabel, + booleanArray, + toNumber + } = this.data + + markers_joinCluster = booleanArray[markers_joinCluster] + + try { + markers_callout = JSON.parse(markers_callout) + } catch (e) {} + try { + markers_customCallout = JSON.parse(markers_customCallout) + } catch (e) {} + try { + markers_label = JSON.parse(markers_label) + } catch (e) {} + try { + markers_anchor = JSON.parse(markers_anchor) + } catch (e) {} + + const params = {} + + markers_id !== 'no' && (params.id = toNumber ? Number(markers_id) : String(markers_id)) + markers_latitude !== 'no' && (params.latitude = toNumber ? Number(markers_latitude) : String(markers_latitude)) + markers_longitude !== 'no' && (params.longitude = toNumber ? Number(markers_longitude) : String(markers_longitude)) + markers_zIndex !== 'no' && (params.zIndex = toNumber ? Number(markers_zIndex) : String(markers_zIndex)) + markers_rotate !== 'no' && (params.rotate = toNumber ? Number(markers_rotate) : String(markers_rotate)) + markers_alpha !== 'no' && (params.alpha = toNumber ? Number(markers_alpha) : String(markers_alpha)) + markers_width !== 'no' && (params.width = toNumber ? Number(markers_width) : String(markers_width)) + markers_height !== 'no' && (params.height = toNumber ? Number(markers_height) : String(markers_height)) + markers_callout !== 'no' && (params.callout = markers_callout) + markers_customCallout !== 'no' && (params.customCallout = markers_customCallout) + markers_label !== 'no' && (params.label = markers_label) + markers_anchor !== 'no' && (params.anchor = markers_anchor) + markers_joinCluster !== 'no' && (params.joinCluster = markers_joinCluster) + markers_title !== 'no' && (params.title = markers_title) + markers_iconPath !== 'no' && (params.iconPath = markers_iconPath) + markers_arialabel !== 'no' && (params['aria-label'] = markers_arialabel) + + return params + }, + addMarker () { + const params = this.countMarker() + + console.log('添加markers: ', params) + const markers = this.data.markers + markers.push(params) + + this.setData({ + markers + }) + }, + changeMarker () { + let { editingMarkers } = this.data + try { + editingMarkers = JSON.parse(editingMarkers) + } catch (e) { + console.log(e) + } + console.log('changeMarker: ', editingMarkers) + this.setData({ + markers: editingMarkers + }) + }, + randomHexColor() { + var hex = Math.floor(Math.random() * 16777216).toString(16); //生成ffffff以内16进制数 + while (hex.length < 6) { //while循环判断hex位数,少于6位前面加0凑够6位 + hex = '0' + hex; + } + return '#' + hex; //返回‘#'开头16进制颜色 + }, + randomRadius() { + return Math.floor(Math.random() * 3000) + }, + changePolyline () { + let polyline + try { + polyline = JSON.parse(this.data.editingPolyline) + } catch(e) { + polyline = this.data.editingPolyline + } + this.setData({ + polyline + }) + console.log('当前polyline: ', this.data.polyline) + }, + addPolyline () { + let { + polyline_points, + polyline_color, + polyline_colorList, + polyline_dottedLine, + polyline_arrowIconPath, + polyline_width, + polyline_arrowLine, + polyline_borderColor, + polyline_borderWidth, + polyline_level, + booleanArray, + toNumber + } = this.data + + polyline_dottedLine = booleanArray[polyline_dottedLine] + polyline_arrowLine = booleanArray[polyline_arrowLine] + + const params = {} + try { + polyline_points = JSON.parse(polyline_points) + } catch (e) {} + try { + polyline_colorList = JSON.parse(polyline_colorList) + } catch (e) {} + + polyline_points !== 'no' && (params.points = polyline_points) + polyline_color !== 'no' && (params.color = polyline_color) + polyline_colorList !== 'no' && (params.colorList = polyline_colorList) + polyline_dottedLine !== 'no' && (params.dottedLine = polyline_dottedLine) + polyline_arrowIconPath !== 'no' && (params.arrowIconPath = polyline_arrowIconPath) + polyline_width !== 'no' && (params.width = toNumber ? Number(polyline_width) : String(polyline_width)) + polyline_arrowLine !== 'no' && (params.arrowLine = polyline_arrowLine) + polyline_borderColor !== 'no' && (params.borderColor = polyline_borderColor) + polyline_borderWidth !== 'no' && (params.borderWidth = toNumber ? Number(polyline_borderWidth) : String(polyline_borderWidth)) + polyline_level !== 'no' && (params.level = polyline_level) + + console.log('添加polyline : ', params) + + const polyline = this.data.polyline + polyline.push(params) + this.setData({ + polyline + }) + }, + addCircles () { + let { + circle_latitude, + circle_longitude, + circle_color, + circle_fillColor, + circle_radius, + circle_strokeWidth, + circle_level, + toNumber + } = this.data + + const params = {} + + circle_latitude !== 'no' && (params.latitude = toNumber ? Number(circle_latitude) : String(circle_latitude)) + circle_longitude !== 'no' && (params.longitude = toNumber ? Number(circle_longitude) : String(circle_longitude)) + circle_color !== 'no' && (params.color = circle_color) + circle_fillColor !== 'no' && (params.fillColor = circle_fillColor) + circle_radius !== 'no' && (params.radius = circle_radius) + circle_strokeWidth !== 'no' && (params.strokeWidth = circle_strokeWidth) + circle_level !== 'no' && (params.level = circle_level) + + console.log('添加circle : ', params) + + const circles = this.data.circles + circles.push(params) + this.setData({ + circles + }) + }, + changeCircles () { + let { editingCircles } = this.data + try { + editingCircles = JSON.parse(editingCircles) + } catch (e) {} + this.setData({ + circles: editingCircles + }) + }, + addControls () { + let { controls_id, controls_iconPath, controls_position, controls_clickable, toNumber, booleanArray } = this.data + + controls_clickable = booleanArray[controls_clickable] + + try { + controls_position = JSON.parse(controls_position) + } catch(e) {} + + const params = {} + controls_id !== 'no' && (params.id = toNumber ? Number(controls_id) : String(controls_id)) + controls_iconPath !== 'no' && (params.iconPath = controls_iconPath) + controls_position !== 'no' && (params.position = controls_position) + controls_clickable !== 'no' && (params.clickable = controls_clickable) + const controls = this.data.controls + controls.push(params) + console.log('添加controls 参数: ', params) + this.setData({ + controls + }) + }, + consoleControls () { + console.log('当前controls: ', this.data.controls) + this.setData({ + editingControls: JSON.stringify(this.data.controls) + }) + }, + changeControls () { + let controls + try { + controls = JSON.parse(this.data.editingControls) + } catch(e) { + controls = this.data.editingControls + } + this.setData({ + controls + }) + console.log('当前controls: ', this.data.controls) + }, + changeIncludePoints () { + let { editingIncludePoints } = this.data + try { + editingIncludePoints = JSON.parse(editingIncludePoints) + } catch (e) {} + console.log('includePoints : ', editingIncludePoints) + this.setData({ + includePoints: editingIncludePoints + }) + }, + switchtoNumber (event) { + this.setData({ + toNumber: event.detail.value + }); + }, + changeAttribute (e) { + const attribute = e.target.dataset.attribute + const obj = {} + obj[attribute] = !!!this.data[attribute] + console.log('修改参数 ', obj) + this.setData(obj) + }, + attributePickerChange(e) { + const attribute = e.target.dataset.attribute + const obj = {} + obj[attribute] = e.detail.value + console.log('修改参数 ', obj) + this.setData(obj) + }, + changeInputValue (e) { + const attribute = e.target.dataset.attribute + const obj = {} + obj[attribute] = e.detail.value + console.log('修改数据 ', obj) + this.setData(obj) + }, + changePolygons () { + let { editingPolygons } = this.data + try { + editingPolygons = JSON.parse(editingPolygons) + } catch (e) {} + console.log('改变polygons: ', editingPolygons) + this.setData({ + polygons: editingPolygons + }) + }, + addPolygons () { + let { + polygons_points, + polygons_strokeWidth, + polygons_strokeColor, + polygons_fillColor, + polygons_zIndex, + polygons_level, + toNumber + } = this.data + + try { + polygons_points = JSON.parse(polygons_points) + } catch (e) {} + + const params = {} + polygons_points !== 'no' && (params.points = polygons_points) + polygons_strokeWidth !== 'no' && (params.strokeWidth = toNumber ? Number(polygons_strokeWidth) : String(polygons_strokeWidth)) + polygons_zIndex !== 'no' && (params.zIndex = toNumber ? Number(polygons_zIndex) : String(polygons_zIndex)) + polygons_strokeColor !== 'no' && (params.strokeColor = polygons_strokeColor) + polygons_fillColor !== 'no' && (params.fillColor = polygons_fillColor) + polygons_level !== 'no' && (params.level = polygons_level) + + console.log('添加polygons: ', params) + + const polygons = this.data.polygons + polygons.push(params) + + this.setData({ + polygons + }) + }, + changeSetting () { + + let {eidtingSetting} = this.data + try { + eidtingSetting = JSON.parse(eidtingSetting) + } catch (e) {} + + console.log('修改setting: ', eidtingSetting) + + this.setData({ + setting: eidtingSetting + }) + }, + switchType (e) { + const type = e.target.dataset.sencetype + this.setData({ + showingSence: type + }) + }, + emitAddMarkers () { + let { + addmarkers_clear, + booleanArray + } = this.data + + addmarkers_clear = booleanArray[addmarkers_clear] + + const marker = this.countMarker() + + const params = { + markers: [marker] + } + + addmarkers_clear !== 'no' && (params.clear = addmarkers_clear) + + console.log('addMarkers 参数: ', params) + + mapcontext.addMarkers(Object.assign({ + success: (res) => { + console.log('debug: addMarkers succcess ', res) + }, + fail: (res) => { + console.log('debug: addMarkers fail ', res) + }, + complete: (res) => { + console.log('debug: addMarkers complete ', res) + } + }, params)) + }, + emitAddMarkers2 () { + let { + addmarkers_markers, + addmarkers_clear, + booleanArray + } = this.data + + addmarkers_clear = booleanArray[addmarkers_clear] + + try { + addmarkers_markers = JSON.parse(addmarkers_markers) + } catch(e) {} + + const params = {} + + addmarkers_markers !== 'no' && (params.markers = addmarkers_markers) + addmarkers_clear !== 'no' && (params.clear = addmarkers_clear) + + console.log('addMarkers 参数: ', params) + + mapcontext.addMarkers(Object.assign({ + success: (res) => { + console.log('debug: addMarkers succcess ', res) + }, + fail: (res) => { + console.log('debug: addMarkers fail ', res) + }, + complete: (res) => { + console.log('debug: addMarkers complete ', res) + } + }, params)) + + }, + emitFromScreenLocation () { + mapcontext.fromScreenLocation({ + success: (res) => { + console.log('debug: fromScreenLocation succcess ', res) + }, + fail: (res) => { + console.log('debug: fromScreenLocation fail ', res) + }, + complete: (res) => { + console.log('debug: fromScreenLocation complete ', res) + } + }) + }, + emitGetCenterLocation () { + mapcontext.getCenterLocation({ + iconPath: '/assets/images/logo.png', + success: (res) => { + console.log('debug: getCenterLocation succcess ', res) + }, + fail: (res) => { + console.log('debug: getCenterLocation fail ', res) + }, + complete: (res) => { + console.log('debug: getCenterLocation complete ', res) + } + }) + }, + emitApi (e) { + const apiname = e.target.dataset.apiname + mapcontext[apiname]({ + success: (res) => { + console.log(`debug: ${apiname} succcess `, res) + }, + fail: (res) => { + console.log(`debug: ${apiname} fail `, res) + }, + complete: (res) => { + console.log(`debug: ${apiname} complete `, res) + } + }) + }, + emitIncludePoints () { + + let { + includePoints_points, + includePoints_padding + } = this.data + + try { + includePoints_points = JSON.parse(includePoints_points) + includePoints_padding = JSON.parse(includePoints_padding) + } catch (e) {} + + const params = {} + + includePoints_points !== 'no' && (params.points = includePoints_points) + includePoints_padding !== 'no' && (params.padding = includePoints_padding) + + console.log('includePoints 参数: ', params) + + mapcontext.includePoints(Object.assign({ + success: (res) => { + console.log(`debug: includePoints succcess `, res) + }, + fail: (res) => { + console.log(`debug: includePoints fail `, res) + }, + complete: (res) => { + console.log(`debug: includePoints complete `, res) + } + }, params)) + }, + emitInitMarkerCluster () { + + let { + initmarkercluster_enableDefaultStyle, + initmarkercluster_zoomOnClick, + initmarkercluster_gridSize, + booleanArray, + toNumber + } = this.data + + initmarkercluster_enableDefaultStyle = booleanArray[initmarkercluster_enableDefaultStyle] + initmarkercluster_zoomOnClick = booleanArray[initmarkercluster_zoomOnClick] + + const params = {} + + initmarkercluster_enableDefaultStyle !== 'no' && (params.enableDefaultStyle = initmarkercluster_enableDefaultStyle) + initmarkercluster_zoomOnClick !== 'no' && (params.zoomOnClick = initmarkercluster_zoomOnClick) + initmarkercluster_gridSize !== 'no' && (params.gridSize = toNumber ? Number(initmarkercluster_gridSize) : String(initmarkercluster_gridSize)) + + console.log('initMarkerCluster 参数: ', params) + + mapcontext.initMarkerCluster(Object.assign({ + success: (res) => { + console.log(`debug: initMarkerCluster succcess `, res) + }, + fail: (res) => { + console.log(`debug: initMarkerCluster fail `, res) + }, + complete: (res) => { + console.log(`debug: initMarkerCluster complete `, res) + } + }, params)) + }, + emitMoveAlong2 () { + let { + moveAlong2_path, + moveAlong2Markerid, + moveAlong2_autoRotate, + moveAlong2_duration, + booleanArray, + toNumber + } = this.data + + moveAlong2_autoRotate = booleanArray[moveAlong2_autoRotate] + + let path = moveAlong2_path + // if (moveAlong2_path === '{}') { + // path = {} + // } else if (moveAlong2_path === '[]') { + // path = [] + // } else { + // try { + // path = moveAlong2_path.replace('[', '').replace(']', '').split('},').map(e => { + // const str = e.indexOf('}') > -1 ? e : (e + '}') + // return JSON.parse(str) + // }) + // } catch (e) {} + // } + try { + path = JSON.parse(moveAlong2_path) + } catch (e) {} + + try { + moveAlong2Markerid = JSON.parse(moveAlong2Markerid) + } catch(e) { + if (!isNaN(moveAlong2Markerid)) { + moveAlong2Markerid = toNumber ? Number(moveAlong2Markerid) : String(moveAlong2Markerid) + } + } + + const params = {} + moveAlong2Markerid !== 'no' && (params.markerId = moveAlong2Markerid) + moveAlong2_autoRotate !== 'no' && (params.autoRotate = moveAlong2_autoRotate) + moveAlong2_duration !== 'no' && (params.duration = toNumber ? Number(moveAlong2_duration) : String(moveAlong2_duration)) + moveAlong2_path !== 'no' && (params.path = path) + + console.log('moveAlong 参数: ', params) + + mapcontext.moveAlong(Object.assign({ + success: (res) => { + console.log(`debug: moveAlong succcess `, res) + }, + fail: (res) => { + console.log(`debug: moveAlong fail `, res) + }, + complete: (res) => { + console.log(`debug: moveAlong complete `, res) + } + }, params)) + }, + emitMoveAlong () { + let { + moveAlong_path, + moveAlongMarkerid, + moveAlong_autoRotate, + moveAlong_duration, + booleanArray, + toNumber + } = this.data + + moveAlong_autoRotate = booleanArray[moveAlong_autoRotate] + + let path = moveAlong_path + // if (moveAlong_path === '{}') { + // path = {} + // } else if (moveAlong_path === '[]') { + // path = [] + // } else { + // try { + // path = moveAlong_path.replace('[', '').replace(']', '').split('},').map(e => { + // const str = e.indexOf('}') > -1 ? e : (e + '}') + // return JSON.parse(str) + // }) + // } catch (e) {} + // } + + try { + path = JSON.parse(moveAlong_path) + } catch (e) {} + + try { + moveAlongMarkerid = JSON.parse(moveAlongMarkerid) + } catch (e) { + if (!isNaN(moveAlongMarkerid)) { + moveAlongMarkerid = toNumber ? Number(moveAlongMarkerid) : String(moveAlongMarkerid) + } + } + + const params = {} + moveAlongMarkerid !== 'no' && (params.markerId = moveAlongMarkerid) + moveAlong_autoRotate !== 'no' && (params.autoRotate = moveAlong_autoRotate) + moveAlong_duration !== 'no' && (params.duration = toNumber ? Number(moveAlong_duration) : String(moveAlong_duration)) + moveAlong_path !== 'no' && (params.path = path) + + console.log('moveAlong 参数: ', params) + + mapcontext.moveAlong(Object.assign({ + success: (res) => { + console.log(`debug: moveAlong succcess `, res) + }, + fail: (res) => { + console.log(`debug: moveAlong fail `, res) + }, + complete: (res) => { + console.log(`debug: moveAlong complete `, res) + } + }, params)) + }, + emitMoveToLocation () { + let { + movetolocation_longitude, + movetolocation_latitude, + toNumber + } = this.data + const params = {} + + movetolocation_longitude !== 'no' && (params.longitude = toNumber ? Number(movetolocation_longitude) : String(movetolocation_longitude)) + movetolocation_latitude !== 'no' && (params.latitude = toNumber ? Number(movetolocation_latitude) : String(movetolocation_latitude)) + + console.log('moveToLocation 参数: ', params) + + mapcontext.moveToLocation(Object.assign({ + success: (res) => { + console.log(`debug: moveToLocation succcess `, res) + }, + fail: (res) => { + console.log(`debug: moveToLocation fail `, res) + }, + complete: (res) => { + console.log(`debug: moveToLocation complete `, res) + } + }, params)) + }, + emitOn () { + mapcontext.on('markerClusterCreate', (res) => { + console.log('debug: mapcontext.on markerClusterCreate ',res) + }) + mapcontext.on('markerClusterClick', (res) => { + console.log('debug: mapcontext.on markerClusterClick ',res) + }) + }, + emitOpenMapApp () { + let { + openmapapp_longitude, + openmapapp_latitude, + openmapapp_destination, + toNumber + } = this.data + const params = {} + + openmapapp_longitude !== 'no' && (params.longitude = toNumber ? Number(openmapapp_longitude) : String(openmapapp_longitude)) + openmapapp_latitude !== 'no' && (params.latitude = toNumber ? Number(openmapapp_latitude) : String(openmapapp_latitude)) + openmapapp_destination !== 'no' && (params.destination = openmapapp_destination) + + console.log('openMapApp 参数: ', params) + + mapcontext.openMapApp(Object.assign({ + success: (res) => { + console.log(`debug: openMapApp succcess `, res) + }, + fail: (res) => { + console.log(`debug: openMapApp fail `, res) + }, + complete: (res) => { + console.log(`debug: openMapApp complete `, res) + } + }, params)) + }, + emitRemoveMarkers () { + let { removemarker_markerIds } = this.data + try { + removemarker_markerIds = JSON.parse(removemarker_markerIds) + } catch (e) {} + + const params = {} + + removemarker_markerIds !== 'no' && (params.markerIds = removemarker_markerIds) + + console.log('removeMarkers 参数: ', params) + + mapcontext.removeMarkers(Object.assign({ + success: (res) => { + console.log(`debug: removeMarkers succcess `, res) + }, + fail: (res) => { + console.log(`debug: removeMarkers fail `, res) + }, + complete: (res) => { + console.log(`debug: removeMarkers complete `, res) + } + }, params)) + }, + emitSetCenterOffset () { + const params = {} + let { centerOffset } = this.data + try { + centerOffset = JSON.parse(centerOffset) + } catch (e) {} + centerOffset !== 'no' && (params.offset = centerOffset) + console.log('setCenterOffset 参数: ', params) + mapcontext.setCenterOffset(Object.assign({ + success: (res) => { + console.log(`debug: setCenterOffset succcess `, res) + }, + fail: (res) => { + console.log(`debug: setCenterOffset fail `, res) + }, + complete: (res) => { + console.log(`debug: setCenterOffset complete `, res) + } + }, params)) + }, + emitSetLocMarkerIcon () { + const params = {} + this.data.markerIconPath !== 'no' && (params.iconPath = this.data.markerIconPath) + console.log('setLocMarkerIcon 参数: ', params) + mapcontext.setLocMarkerIcon({ + iconPath: '/assets/images/logo.png', + success: (res) => { + console.log(`debug: setLocMarkerIcon succcess `, res) + }, + fail: (res) => { + console.log(`debug: setLocMarkerIcon fail `, res) + }, + complete: (res) => { + console.log(`debug: setLocMarkerIcon complete `, res) + } + }) + }, + emitTranslateMarker ({nodest}) { + let { + translatemarkerMarkerid, + translatemarker_marker_autoRotate, + translatemarker_rotate, + translatemarker_duration, + translatemarker_marker_moveWithRotate, + translatemarker_destination, + booleanArray, + toNumber + } = this.data + translatemarker_marker_autoRotate = booleanArray[translatemarker_marker_autoRotate] + translatemarker_marker_moveWithRotate = booleanArray[translatemarker_marker_moveWithRotate] + let destination = translatemarker_destination + if (translatemarker_destination === 'null') { + destination = null + } else if (translatemarker_destination === '[]') { + destination = [] + } else { + try { + destination = JSON.parse(translatemarker_destination) + } catch (e) {} + } + try { + translatemarkerMarkerid = JSON.parse(translatemarkerMarkerid) + } catch(e) { + if (!isNaN(translatemarkerMarkerid)) { + translatemarkerMarkerid = toNumber ? Number(translatemarkerMarkerid) : String(translatemarkerMarkerid) + } + } + const params = {} + translatemarkerMarkerid !== 'no' && (params.markerId = translatemarkerMarkerid) + translatemarker_marker_autoRotate !== 'no' && (params.autoRotate = translatemarker_marker_autoRotate) + translatemarker_rotate !== 'no' && (params.rotate = toNumber ? Number(translatemarker_rotate) : String(translatemarker_rotate)) + translatemarker_duration !== 'no' && (params.duration = toNumber ? Number(translatemarker_duration) : String(translatemarker_duration)) + translatemarker_marker_moveWithRotate !== 'no' && (params.moveWithRotate = translatemarker_marker_moveWithRotate) + destination !== 'no' && (params.destination = destination) + console.log('translateMarker 参数: ', params) + mapcontext.translateMarker(Object.assign({ + animationEnd: (res) => { + console.log(`debug: translateMarker animationEnd `, res) + }, + success: (res) => { + console.log(`debug: translateMarker succcess `, res) + }, + fail: (res) => { + console.log(`debug: translateMarker fail `, res) + }, + complete: (res) => { + console.log(`debug: translateMarker complete `, res) + } + }, params)) + }, + goBack () { + wx.redirectTo({ + url: '/pages/jumppage/index', + }) + }, + latlongChange (e) { + // const {toNumber} = this.data + let latlong = e.detail.value + try { + if (latlong === '') { + latlong = ['',''] + } else if (latlong === 'null') { + latlong = [null, null] + } else { + latlong = JSON.parse(e.detail.value) + } + } catch (e) { + latlong = [latlong, null] + } + console.log(latlong) + // const latitude = toNumber ? Number(latlong[0]) : String(latlong[0]) + // const longitude = toNumber ? Number(latlong[1]) : String(latlong[1]) + const latitude = latlong[0] + const longitude = latlong[1] + console.log(`改变latitude、longitude : ` ) + console.log(latitude, longitude) + this.setData({ + latitude, + longitude + }) + }, + chooseLocalImage () { + wx.chooseImage({ + count: 1, + success: (res) => { + console.log(res) + this.setData({ + markerIconPath: res.tempFilePaths[0], + controls_iconPath: res.tempFilePaths[0], + polyline_arrowIconPath: res.tempFilePaths[0], + markers_iconPath: res.tempFilePaths[0] + }) + } + }) + }, + getstorepath () { + wx.saveFile({ + tempFilePath: this.data.markerIconPath, + success: (res) => { + console.log(res) + this.setData({ + markerIconPath: res.savedFilePath, + controls_iconPath: res.savedFilePath, + polyline_arrowIconPath: res.savedFilePath, + markers_iconPath: res.savedFilePath + }) + } + }) + }, + getusrpath () { + wx.getFileSystemManager().saveFile({ + tempFilePath: this.data.markerIconPath, + filePath: `${wx.env.USER_DATA_PATH}/markericon/test.jpg`, + success: (res) => { + console.log(res) + this.setData({ + markerIconPath: res.savedFilePath, + controls_iconPath: res.savedFilePath, + polyline_arrowIconPath: res.savedFilePath, + markers_iconPath: res.savedFilePath + }) + }, + complete: (res) => { + console.log(res) + } + }) + }, + attributeKeyChange (e) { + const { toNumber } = this.data + const { attribute, defaultnum, orginalattribute } = e.target.dataset + let value = e.detail.value + const orginalval = e.detail.value + try { + value = JSON.parse(value) + } catch (e) { + if (defaultnum) { + value = toNumber ? (isNaN(value) ? value : Number(value)) : String(value) + } + } + if (typeof value === 'number' && !toNumber) { + value = String(value) + } + const obj = {} + obj[attribute] = value + orginalattribute && (obj[orginalattribute] = orginalval) + console.log('改变的属性: ', obj) + this.setData(obj) + }, + showMap () { + this.setData({ + mapShow: !this.data.mapShow + }) + }, + emitchooseLocation () { + wx.chooseLocation({ + longitude: '85.1318117790985', + latitude: '45.69139458288415', + complete (res) { + console.log('chooseLocation complete ', res) + } + }) + }, + emitinvokeMapTask: function () { + wx.invokeMapTask({ + complete: (res) => { + console.log(res) + } + }) + }, + emitchooseimage () { + wx.chooseImage({ + count: 3, + // sizeType: 'original', + sourceType: ['album', 'camera'], + complete: function complete(res) { + console.log(res) + } + }) + }, + goPage () { + wx.navigateTo({ + url: '/pages/mapmultiple/mapmultiple' + }) + }, + testundefined () { + this.setData({ + latitude: undefined + }) + } +}) \ No newline at end of file diff --git a/pages/component/map/map.json b/pages/component/map/map.json new file mode 100644 index 0000000..50907b6 --- /dev/null +++ b/pages/component/map/map.json @@ -0,0 +1,5 @@ +{ + "usingComponents": {}, + "enablePullDownRefresh": false, + "navigationBarTitleText": "map组件用例" +} \ No newline at end of file diff --git a/pages/component/map/map.wxml b/pages/component/map/map.wxml new file mode 100644 index 0000000..2e56da8 --- /dev/null +++ b/pages/component/map/map.wxml @@ -0,0 +1,1061 @@ + + + + marker 1 customcallout + marker 2 customcallout + + + + + + 经纬、缩放、角度 + + + 图形、线条 + + + 控制属性 + + + markers + + + 其他参数及api + + + + + + 数字类型: {{toNumber}} + + + + + + + + + + 选择maptype: {{maptypes[maptype]}} + + + + + + + latitude : {{latitude}} + + + + + + + + longitude : {{longitude}} + + + + + + + + + + + + + + + + + markerIconPath: (输入no不传) + + + + + 说明:赋值no不传参 + + 经度: + + + 纬度: + + + + + 说明:支持对象、数字、字符串、数字 + + scale: + + + + minScale: + + + + maxScale: + + + + + + + + + + + + centerOffset: + offset 说明:赋值no不传参; 按照json格式解析 + + + + + + rotate:{{rotate}} + 说明:支持对象、数字、字符串、数字 + + + + + + + skew: + + + + + + + + + + + + controls: + + id: + 说明:赋值no不传参 + + + + position + + 说明: 赋值no不传参; {} => {} ; [] => [] ; '' => '' ; null => null + + + + + strokeWidth: + 说明:赋值no不传参 + + + + strokeColor: + 说明:赋值no不传参 + + + + fillColor: + 说明:赋值no不传参 + + + + zIndex: + 说明:赋值no不传参 + + + + level: + 说明:赋值no不传参 + + + + + + polygons: + + 说明:可验证字符串、数组、对象类型 + + + + + + padding: + 说明:赋值no不传参 + + + + + + + 经度: + + + 纬度: + + + 目的地: + + + + + + + + + + + + + + setting: + + 说明:可验证字符串、数组、对象类型 + + +