init project
This commit is contained in:
178
pages/sportsGroundList/index.js
Normal file
178
pages/sportsGroundList/index.js
Normal file
@@ -0,0 +1,178 @@
|
||||
// pages/sportsGroundList/index.js
|
||||
const app = getApp();
|
||||
let latitude = 0; // 纬度
|
||||
let longitude = 0; // 经度
|
||||
let page = 1;
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
state: 1,
|
||||
venues: [],
|
||||
isShowAuth: false,
|
||||
isShowNewplot: false,
|
||||
isGoHome: false,
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function(options) {
|
||||
let that = this;
|
||||
this.setData({
|
||||
state: options.state
|
||||
})
|
||||
this.getLocation();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function() {
|
||||
let pages = getCurrentPages();
|
||||
this.setData({
|
||||
isGoHome: pages.length == 1
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function() {
|
||||
this.getData();
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function() {
|
||||
this.getData(++page);
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function() {
|
||||
return {
|
||||
title: '智慧云馆'
|
||||
}
|
||||
},
|
||||
|
||||
// 切换列表
|
||||
changeTip(e) {
|
||||
let state = e.currentTarget.dataset.state;
|
||||
this.setData({
|
||||
state: state
|
||||
})
|
||||
|
||||
this.getData();
|
||||
},
|
||||
|
||||
// 点击cell
|
||||
clickCell(e) {
|
||||
let id = e.currentTarget.dataset.id;
|
||||
if (this.data.state == 1) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/basketballGym/index?id=${id}`,
|
||||
})
|
||||
}
|
||||
if (this.data.state == 2) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/gymnasium/index?id=${id}`,
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
getData(e) {
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true,
|
||||
})
|
||||
app.$api.venues({
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
page: e ? e : 1,
|
||||
pageSize: 10,
|
||||
type: this.data.state
|
||||
}).then(res => {
|
||||
page = res.page.data.length > 0 ? res.page.page : page--;
|
||||
let list = [];
|
||||
if (e) {
|
||||
list = this.data.venues
|
||||
}
|
||||
for (let i = 0; i < res.page.data.length; i++) {
|
||||
list.push(res.page.data[i]);
|
||||
}
|
||||
this.setData({
|
||||
venues: list,
|
||||
isShowNewplot: true
|
||||
})
|
||||
if (this.data.state == 3) {
|
||||
wx.showToast({
|
||||
title: '暂未开放,敬请期待',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
wx.stopPullDownRefresh();
|
||||
}, err => {
|
||||
wx.stopPullDownRefresh();
|
||||
this.setData({
|
||||
isShowNewplot: true
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 活动当前坐标
|
||||
getLocation() {
|
||||
let that = this;
|
||||
wx.getLocation({
|
||||
type: 'gcj02',
|
||||
success: function(res) {
|
||||
latitude = res.latitude;
|
||||
longitude = res.longitude;
|
||||
that.getData()
|
||||
},
|
||||
fail: function(res) {
|
||||
if (res.errMsg == 'getLocation:fail auth deny' || res.errMsg == 'getLocation:fail:auth denied') {
|
||||
that.setData({
|
||||
isShowAuth: true
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
// 获取授权
|
||||
setAuthSuccess(e) {
|
||||
if (e.detail.authSetting['scope.userLocation']) {
|
||||
this.getLocation();
|
||||
this.setData({
|
||||
isShowAuth: false
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
7
pages/sportsGroundList/index.json
Normal file
7
pages/sportsGroundList/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"enablePullDownRefresh": true,
|
||||
"usingComponents": {
|
||||
"confirm-dialog": "/component/confirmDialog/confirmDialog",
|
||||
"header": "/component/header/header"
|
||||
}
|
||||
}
|
||||
42
pages/sportsGroundList/index.wxml
Normal file
42
pages/sportsGroundList/index.wxml
Normal file
@@ -0,0 +1,42 @@
|
||||
<!--pages/sportsGroundList/index.wxml-->
|
||||
<header isGoHome="{{isGoHome}}"></header>
|
||||
<view class='container'>
|
||||
<view class='header'>
|
||||
<view class='item-box {{state == 1 ? "isActive" : ""}}' bindtap='changeTip' data-state='1'>
|
||||
<image src='../../images/31@3x.png' mode='aspectFit' wx:if="{{state == 1}}"></image>
|
||||
<image src='../../images/30@3x.png' mode='aspectFit' wx:else></image>
|
||||
<text>篮球场</text>
|
||||
</view>
|
||||
<view class='item-box {{state == 2 ? "isActive" : ""}}' bindtap='changeTip' data-state='2'>
|
||||
<image src='../../images/27@3x.png' mode='aspectFit' wx:if="{{state == 2}}"></image>
|
||||
<image src='../../images/29@3x.png' mode='aspectFit' wx:else></image>
|
||||
|
||||
<text>健身</text>
|
||||
</view>
|
||||
<view class='item-box {{state == 3 ? "isActive" : ""}}' bindtap='changeTip' data-state='3'>
|
||||
<image src='../../images/26@3x.png' mode='aspectFit' wx:if="{{state == 3}}"></image>
|
||||
<image src='../../images/28@3x.png' mode='aspectFit' wx:else></image>
|
||||
<text>足球场</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='list'>
|
||||
<view class='cell-box' wx:for='{{venues}}' wx:key='{{index}}' bindtap='clickCell' data-id='{{item.id}}'>
|
||||
<image src='{{item.listImage}}' mode='aspectFill'></image>
|
||||
<view class='cell'>
|
||||
<view class='title'>{{item.name}}</view>
|
||||
<view class='address'>
|
||||
<text>{{item.address}}</text>
|
||||
<text>{{item.distance}}km</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<confirm-dialog title="{{'提示'}}" message="{{'需要获取使用地理位置权限'}}" bindopensetting="setAuthSuccess" wx:if="{{isShowAuth}}" isAuth="{{true}}" show-cancel="{{false}}"></confirm-dialog>
|
||||
|
||||
<view class='newplot' wx:if="{{isShowNewplot && venues.length == 0}}">
|
||||
<image src='../../images/noContent.png'></image>
|
||||
<text>暂无运动场馆 ~</text>
|
||||
</view>
|
||||
96
pages/sportsGroundList/index.wxss
Normal file
96
pages/sportsGroundList/index.wxss
Normal file
@@ -0,0 +1,96 @@
|
||||
/* pages/sportsGroundList/index.wxss */
|
||||
|
||||
.container {
|
||||
min-height: calc(100vh - 300rpx);
|
||||
padding-top: 270rpx;
|
||||
padding-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.header {
|
||||
position: fixed;
|
||||
top: 120rpx;
|
||||
left: 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 140rpx;
|
||||
background: #1a191e;
|
||||
border-bottom: 2rpx solid #212025;
|
||||
}
|
||||
|
||||
.header .item-box {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 24rpx;
|
||||
line-height: 24rpx;
|
||||
}
|
||||
|
||||
.header .item-box.isActive {
|
||||
color: #ffca00;
|
||||
}
|
||||
|
||||
.header .item-box>image {
|
||||
width: 66rpx;
|
||||
height: 58rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.list .cell-box {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 140rpx;
|
||||
margin-bottom: 30rpx;
|
||||
padding: 0 26rpx 0 16rpx;
|
||||
background: #1a191e;
|
||||
}
|
||||
|
||||
.list .cell-box>image {
|
||||
width: 130rpx;
|
||||
height: 110rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.list .cell-box .cell {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.list .cell-box .cell .title {
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
line-height: 28rpx;
|
||||
}
|
||||
|
||||
.list .cell-box .cell .address {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 30rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.newplot {
|
||||
position: fixed;
|
||||
top: 260rpx;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #FFF;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.newplot>image {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
margin-top: -200rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user