init project
This commit is contained in:
227
pages/gymnasium/index.js
Normal file
227
pages/gymnasium/index.js
Normal file
@@ -0,0 +1,227 @@
|
||||
// pages/gymnasium/index.js
|
||||
const app = getApp();
|
||||
import {
|
||||
getCurrentPageUrl
|
||||
} from './../../utils/util.js'
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
isShowBuyVip: false,
|
||||
venues: {},
|
||||
buyVipObj: {},
|
||||
showUnclickMask: false,
|
||||
showCardMask: false,
|
||||
isWxLogin: false,
|
||||
isGoHome: false,
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function(options) {
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
})
|
||||
app.$api.venueDetail({
|
||||
venueId: options.id
|
||||
}).then(res => {
|
||||
this.setData({
|
||||
venues: res.venues
|
||||
})
|
||||
}, err => {
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function() {
|
||||
let pages = getCurrentPages();
|
||||
this.setData({
|
||||
isGoHome: pages.length == 1
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function() {
|
||||
this.setData({
|
||||
showUnclickMask: false
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function() {
|
||||
return {
|
||||
title: this.data.venues.name,
|
||||
imageUrl: this.data.venues.images[0].url
|
||||
}
|
||||
},
|
||||
|
||||
// 打开导航,
|
||||
opnGPS() {
|
||||
wx.openLocation({
|
||||
latitude: Number(this.data.venues.latitude),
|
||||
longitude: Number(this.data.venues.longitude),
|
||||
name: this.data.venues.name,
|
||||
address: this.data.venues.address,
|
||||
})
|
||||
},
|
||||
|
||||
// 打电话
|
||||
callPhone() {
|
||||
wx.makePhoneCall({
|
||||
phoneNumber: this.data.venues.phone,
|
||||
success: function(res) {},
|
||||
fail: function(res) {},
|
||||
complete: function(res) {},
|
||||
})
|
||||
},
|
||||
|
||||
// 购买套餐
|
||||
nowBuy(e) {
|
||||
let index = e.currentTarget.dataset.index;
|
||||
if (!wx.getStorageSync('accessToken')) {
|
||||
wx.setStorageSync('history', getCurrentPageUrl());
|
||||
wx.redirectTo({
|
||||
url: '/pages/login/index',
|
||||
})
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
isShowBuyVip: true,
|
||||
buyVipObj: this.data.venues.cards[index]
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
// 跳转预约课程
|
||||
pushBookClasses() {
|
||||
wx.navigateTo({
|
||||
url: `/pages/bookClasses/index?type=${this.data.venues.type}&venueId=${this.data.venues.id}`,
|
||||
})
|
||||
},
|
||||
|
||||
// 弹框背景禁止滑动
|
||||
unMove() {
|
||||
return;
|
||||
},
|
||||
|
||||
// 关闭购买vip弹框
|
||||
closeBuyVipPopup() {
|
||||
this.setData({
|
||||
isShowBuyVip: false
|
||||
})
|
||||
},
|
||||
|
||||
// 购买Vip
|
||||
buyVip() {
|
||||
this.setData({
|
||||
showUnclickMask: true
|
||||
})
|
||||
app.$api.memberCardOrderCreate({
|
||||
cardType: this.data.buyVipObj.cardType,
|
||||
num: 1,
|
||||
type: this.data.venues.type,
|
||||
venueId: this.data.venues.id
|
||||
}).then(res => {
|
||||
app.$pay.wxPay(res.pay).then(res => {
|
||||
this.setData({
|
||||
isShowBuyVip: false,
|
||||
showUnclickMask: false
|
||||
})
|
||||
}, err => {
|
||||
this.setData({
|
||||
showUnclickMask: false,
|
||||
isShowBuyVip: false
|
||||
})
|
||||
})
|
||||
}, err => {
|
||||
this.setData({
|
||||
showUnclickMask: false,
|
||||
isShowBuyVip: false
|
||||
})
|
||||
if (err.data.err_code == 30022) {
|
||||
this.setData({
|
||||
isWxLogin: true,
|
||||
isShowBuyVip: false
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 关闭
|
||||
cancelCardMask() {
|
||||
this.setData({
|
||||
showCardMask: false
|
||||
})
|
||||
},
|
||||
|
||||
// 开启会员卡提示
|
||||
showCardContent() {
|
||||
this.setData({
|
||||
showCardMask: true
|
||||
})
|
||||
},
|
||||
|
||||
// 取消授权登录
|
||||
cancelDeleteDialog() {
|
||||
this.setData({
|
||||
isWxLogin: false
|
||||
})
|
||||
},
|
||||
|
||||
// 授权微信
|
||||
getUserInfo(e) {
|
||||
app.$pay.payWxLoing(e.detail).then(res => {
|
||||
wx.showToast({
|
||||
title: '绑定成功',
|
||||
duration: 2000,
|
||||
|
||||
})
|
||||
this.setData({
|
||||
isWxLogin: false
|
||||
})
|
||||
}, err => {
|
||||
this.setData({
|
||||
isWxLogin: false
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user