| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- default_marker: {
- iconPath: "/common/images/map_marker.png",
- latitude: 24.824768,
- longitude: 118.57343,
- width: 30,
- height: 30,
- title: '泉州(晋江)国际人才港',
- },
- markers: [],
- latitude: 24.824768,
- longitude: 118.57343,
- keyword: '',
- list: [],
- page: 1,
- no_more: false,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.getList();
- },
- getList() {
- let self = this;
- let page = self.data.page;
- app.post('business/business/index',{page:page,keyword:self.data.keyword},function(res){
- //尾页
- if (res.length < 10) {
- self.setData({no_more:true});
- }
- //首页
- let markers = self.data.markers;
- if (res.length > 0) {
- let default_marker = self.data.default_marker;
- for (let i = 0; i < res.length; i++) {
- let marker = {height:default_marker.height,iconPath:default_marker.iconPath,width:default_marker.width};
- marker.latitude = res[i].latitude;
- marker.longitude = res[i].longitude;
- marker.title = res[i].title;
- marker.id = res[i].id;
- markers.push(marker);
- }
- if (page == 1) {
- self.setData({latitude:res[0].latitude,longitude:res[0].longitude});
- }
- }
- //数据合并
- let list = self.data.list;
- list = list.concat(res);
- page++;
- self.setData({list:list,page:page,markers:markers});
- });
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.setData({markers:[],list:[],keyword:'',page:1,no_more:false});
- this.getList();
- wx.stopPullDownRefresh();
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.getList();
- },
- //设置地点
- setLocation(e) {
- let marker = this.data.default_marker;
- marker.latitude = e.currentTarget.dataset.lat;
- marker.longitude = e.currentTarget.dataset.lon;
- marker.title = e.currentTarget.dataset.title;
- this.setData({latitude:marker.latitude,longitude:marker.longitude});
- },
- //拔打电话
- callMobile(e){
- let mobile = e.currentTarget.dataset.mobile;
- if (mobile == '') {
- app.msg('暂无联系方式!');
- return false;
- }
- wx.makePhoneCall({
- phoneNumber: mobile
- })
- },
- //详情
- toDetail(e) {
- wx.navigateTo({
- url: '/pages/business/detail/detail?id=' + e.currentTarget.dataset.id,
- })
- },
- toAd() {
- wx.navigateTo({
- url: '/pages/business/ad/ad',
- })
- },
- //搜索
- bindSearch() {
- this.setData({list:[],markers:[],page:1,no_more:false});
- this.getList();
- },
- bindInput() {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- title: "晋爱人才",
- path: "/pages/home/home/home",
- };
- }
- })
|