123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- id: 0,
- info: {},
- list: [],
- keyword: '',
- page: 1,
- no_more: false,
- is_first: true,
- tabCur:0,
- total:{},
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let id = options.id;
- this.setData({id:id});
- this.getSite();
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- if (this.data.tabCur == 1) {
- this.setData({list:[],page:1,no_more:false,keyword:''});
- this.getCount();
- this.getList();
- } else {
- this.getSite();
- }
- wx.stopPullDownRefresh();
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- if (this.data.tabCur == 1) {
- this.getList();
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- let info = this.data.info
- return {
- title: info.site_name,
- path: "/pages/site/detail/detail?id="+info.id,
- };
- },
- //切换
- tabSelect(e) {
- let tabCur = e.currentTarget.dataset.id;
- if (tabCur == 1 && this.data.is_first) {
- this.setData({is_first:false});
- this.getCount();
- this.getList();
- }
- this.setData({tabCur: tabCur});
- },
- //站点
- getSite(){
- let self = this;
- app.post('activity/site/detail',{id:this.data.id},function(res){
- if (res.image_display) {
- res.image_display = res.image_display.replace(/\<img/gi, '<img style="max-width:100%;display:block;" ');
- }
- self.setData({info:res});
- });
- },
- //统计
- getCount(){
- let self = this;
- app.post('activity/site/getCount',{id:this.data.id},function(res){
- self.setData({total:res});
- });
- },
- //列表
- getList() {
- var self = this;
- if (self.data.no_more) {
- return false;
- }
- app.post('activity/activity/index',{
- page:self.data.page,
- user_id:self.data.id,
- keyword: self.data.keyword,
- },function(res){
- if (res.length < 10) {
- self.setData({no_more:true});
- }
- let list = self.data.list;
- list = list.concat(res);
- let page = self.data.page;
- page++;
- self.setData({list:list,page:page});
- });
- },
- bindSearch(e){
- this.setData({list:[],page:1,no_more:false});
- this.getList();
- },
- nav() {
- let info = this.data.info;
- if (info.latitude > 0) {
- wx.openLocation({
- latitude: info.latitude - 0, //维度
- longitude: info.longitude - 0, //经度
- name: info.site_name, //目的地定位名称
- scale: 15, //缩放比例
- address: info.address //导航详细地址
- })
- } else {
- app.msg('该驿站管理员暂未录入地址!');
- }
- },
- })
|