123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- import request from '../../utils/request'
- Page({
-
- data: {
- subkey: 'U7XBZ-KCDLU-AUOVO-BO64B-BQ6F2-HNFEI',
- showlocation: "true",
- showcompass: "true",
- enabletraffic: "false",
- longitude: "103.70618",
- latitude: "30.51249",
-
- marks: [],
-
- searchmarks: [{
- latitude: 30.61249,
- longitude: 103.69618,
- title: "",
- iconPath: "../../images/location.png",
- width: 30,
- height: 30
- }],
- points: [],
- searchContent: '',
- showSearch: false
- },
-
- onLoad: async function (options) {
- let result = await request('/merchant/merchantAndCallout')
-
- var marker = [];
- for (let i = 0; i < result.length; i++) {
-
- if (result[i].status == 1) {
- marker[i] = {
- id: result[i].id,
- latitude: result[i].latitude,
- longitude: result[i].longitude,
- title: result[i].title,
- iconPath: "../../images/location.png",
- width: result[i].width,
- height: result[i].height,
- callout: result[i].callout
- }
- }
- }
-
- this.setData({
- marks:marker,
- longitude:marker[0].longitude,
- latitude:marker[0].latitude
- })
- let marks = this.data.marks
-
- var arr = new Array(marks.length)
- for (let i = 0; i < marks.length; i++) {
- let latitude = marks[i].latitude
- let longitude = marks[i].longitude
- arr[i] = {
- longitude,
- latitude
- }
- }
-
- this.setData({
- points: arr
- })
- },
-
- onReady() {
-
-
-
- },
-
- getList() {
- this.setData({
- showSearch: true,
- searchContent: ''
- })
- },
-
- findTarget(list, keyword, attribute = "name") {
- const reg = new RegExp(keyword)
- const arr = []
- for (let i = 0; i < list.length; i++) {
- if (reg.test(list[i][attribute])) {
- arr.push(list[i])
- }
- }
- return arr
- },
-
- getSearchInput(e) {
-
- this.setData({
- searchContent: e.detail.value
- })
-
- let marks = this.data.marks
- let searchContent = this.data.searchContent
- let arr = this.findTarget(marks, searchContent, 'title')
- if (arr.length) {
- this.setData({
- searchmarks: arr
- })
- }
-
- },
-
- myChosed(e) {
-
- let index = e.currentTarget.dataset.index
- let marks = this.data.marks
- let searchmarks = this.data.searchmarks
- let searchContent = this.data.searchContent
- if (!searchContent) {
- this.setData({
- searchContent: marks[index].title,
- showSearch: false
- })
- } else {
- this.setData({
- searchContent: searchmarks[index].title,
- showSearch: false
- })
- }
- let arr = this.findTarget(marks, this.data.searchContent, 'title')
- this.setData({
- searchmarks: arr
- })
-
- },
-
- shut() {
- this.setData({
- showSearch: false
- })
- },
-
- bmakt(e) {
-
- var id = e.markerId;
- let marks = this.data.marks
- var index
- for(let i = 0;i < marks.length;i++){
- if(id == marks[i].id){
- index = i
- }
- }
- let lati = Number(marks[index].latitude)
- let longti = Number(marks[index].longitude)
- console.log(lati,longti);
-
-
- wx.openLocation({
- latitude: lati,
- longitude: longti,
- name: marks[index].title
- })
- },
-
- myLocate() {
- const map = wx.createMapContext('map');
- map.moveToLocation();
- },
-
- returnBack() {
- let points = this.data.points
- const map = wx.createMapContext('map');
- map.includePoints({
- points: points,
- padding: [40, 40, 40, 40]
- });
- },
-
- onShow() {
- },
-
- onHide() {
- },
-
- onUnload() {
- },
-
- onPullDownRefresh() {
- },
-
- onReachBottom() {
- },
-
- onShareAppMessage() {
- }
- })
|