123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- CustomBar: app.globalData.CustomBar,
- headerHeight: 0,
-
- default_marker: {
- iconPath: "/common/images/map_marker.png",
- latitude: 24.824768,
- longitude: 118.57343,
- width: 40,
- height: 40,
- title: '泉州(晋江)国际人才港',
- },
- markers: [],
- latitude: 24.824768,
- longitude: 118.57343,
- keyword: '',
- list: [],
- tab_index : 'business',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.getList();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- let query = wx.createSelectorQuery();
- let self = this;
- query.select('#header').boundingClientRect(rect=>{
- let height = rect.height;
- self.setData({headerHeight:height});
- }).exec();
- },
- getList() {
- let self = this;
- let url = 'business/business/index';
- if (this.data.tab_index == 'site') {
- url = 'activity/site/all';
- }
- app.post(url,{keyword:self.data.keyword},function(res){
- //首页
- let marker = JSON.parse(JSON.stringify(self.data.default_marker));
- if (res.length > 0) {
- let markers = [];
- for (var i = 0; i < res.length; i++) {
- markers.push({
- id: res[i].id,
- latitude: res[i].latitude,
- longitude: res[i].longitude,
- iconPath: "/common/images/map_marker.png",
- width: 40,
- height: 40,
- label: {
- content: res[i].title ? res[i].title : res[i].site_name,
- borderRadius: 3, //边框圆角
- borderWidth: 1, //边框宽度
- borderColor: '#ffffff', //边框颜色
- bgColor: '#ffffff', //背景色
- padding: 5, //文本边缘留白
- textAlign: 'center' //文本对齐方式。有效值: left, right, center
- }
- });
- }
- self.setData({latitude:markers[0].latitude,longitude:markers[0].longitude,markers:markers});
- } else {
- self.setData({latitude:marker.latitude,longitude:marker.longitude,markers:[marker]});
- }
- self.setData({list:res});
- });
- },
- changeTab(e) {
- this.setData({tab_index:e.currentTarget.dataset.index});
- this.getList();
- },
- bindSearch() {
- this.getList();
- },
- toBusiness() {
- wx.navigateTo({
- url: '/pages/business/home/home',
- })
- },
- toSite() {
- wx.navigateTo({
- url: '/pages/site/home/home',
- })
- },
- bindMarker(e) {
- if (this.data.tab_index == 'business') {
- wx.navigateTo({
- url: '/pages/business/detail/detail?id=' + e.detail.markerId,
- })
- } else {
- wx.navigateTo({
- url: '/pages/site/detail/detail?id=' + e.detail.markerId,
- })
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- title: "晋爱人才",
- path: "/pages/home/home/home",
- };
- }
- })
|