init project
This commit is contained in:
226
pages/myBookings/index.js
Normal file
226
pages/myBookings/index.js
Normal file
@@ -0,0 +1,226 @@
|
||||
// pages/myBookings/index.js
|
||||
const app = getApp();
|
||||
let orderSn = ""
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
isSignIn: false,
|
||||
memberLessonTicket: {},
|
||||
showDeleteDialog: false,
|
||||
isGoHome: false,
|
||||
endDate: false,
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function(options) {
|
||||
if (options.scene) {
|
||||
app.$api.memberLessonTicketsSing({
|
||||
coachId: options.scene
|
||||
}).then(res => {
|
||||
orderSn = res.orderSn;
|
||||
wx.showToast({
|
||||
title: '签到成功',
|
||||
duration: 2000
|
||||
})
|
||||
let that = this;
|
||||
setTimeout(function() {
|
||||
that.getData();
|
||||
}, 2000)
|
||||
}, err => {
|
||||
setTimeout(function() {
|
||||
if (!options.orderSn) {
|
||||
wx.redirectTo({
|
||||
url: '/pages/home/index',
|
||||
})
|
||||
} else {
|
||||
wx.redirectTo({
|
||||
url: '/pages/myBookings/index?orderSn=' + options.orderSn,
|
||||
})
|
||||
}
|
||||
}, 2000)
|
||||
})
|
||||
} else {
|
||||
orderSn = options.orderSn;
|
||||
this.getData();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function() {
|
||||
let pages = getCurrentPages();
|
||||
this.setData({
|
||||
isGoHome: pages.length == 1
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function() {
|
||||
return {
|
||||
title: '智慧云馆'
|
||||
}
|
||||
},
|
||||
|
||||
// 取消预约
|
||||
cancelBooking() {
|
||||
if (!this.data.isSignIn) {
|
||||
this.setData({
|
||||
showDeleteDialog: true
|
||||
})
|
||||
return;
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '距离开课48小时内不得取消',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 我要签到
|
||||
signIn() {
|
||||
let that = this;
|
||||
// if (!this.data.isSignIn) {
|
||||
// this.setData({
|
||||
// showDeleteDialog: true
|
||||
// })
|
||||
// return;
|
||||
// }
|
||||
// let currentDate = new Date().getTime();
|
||||
// let startDate = new Date(this.data.memberLessonTicket.venueLesson.date.replace(/-/g, "/") + ' ' + this.data.memberLessonTicket.venueLesson.startTime).getTime();
|
||||
|
||||
// if (currentDate < startDate) {
|
||||
// wx.showToast({
|
||||
// title: '课程还未开始',
|
||||
// icon: 'none',
|
||||
// })
|
||||
// return;
|
||||
// }
|
||||
wx.scanCode({
|
||||
onlyFromCamera: true,
|
||||
success: function(res) {
|
||||
if (!res.path) {
|
||||
wx.showToast({
|
||||
title: '二维码错误',
|
||||
icon: 'none',
|
||||
})
|
||||
return;
|
||||
}
|
||||
wx.redirectTo({
|
||||
url: '/' + res.path + '&orderSn=' + orderSn,
|
||||
})
|
||||
// that.setData({
|
||||
// isSignIn: true
|
||||
// })
|
||||
},
|
||||
})
|
||||
},
|
||||
// 获取数据
|
||||
getData() {
|
||||
app.$api.memberLessonTicketsDetail({
|
||||
orderSn: orderSn
|
||||
}).then(res => {
|
||||
let currentDate = new Date().getTime();
|
||||
let startDate = currentDate;
|
||||
if (res.memberLessonTicket) {
|
||||
startDate = new Date(res.memberLessonTicket.venueLesson.date.replace(/-/g, "/") + ' ' + res.memberLessonTicket.venueLesson.startTime).getTime();
|
||||
}
|
||||
if (!res.memberLessonTicket) {
|
||||
wx.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
memberLessonTicket: res.memberLessonTicket,
|
||||
isSignIn: (startDate - currentDate) / 1000 / 60 / 60 < 48,
|
||||
})
|
||||
}, err => {
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
// 取消弹框
|
||||
cancelDeleteDialog() {
|
||||
this.setData({
|
||||
showDeleteDialog: false
|
||||
})
|
||||
},
|
||||
|
||||
// 确认删除
|
||||
confirmDeleteDialog() {
|
||||
app.$api.memberLessonTicketsCancel({
|
||||
orderSn: this.data.memberLessonTicket.orderSn
|
||||
}).then(res => {
|
||||
wx.showToast({
|
||||
title: '取消成功',
|
||||
})
|
||||
this.setData({
|
||||
showDeleteDialog: false
|
||||
})
|
||||
this.getData();
|
||||
}, err => {
|
||||
this.setData({
|
||||
showDeleteDialog: false
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
// 打开导航,
|
||||
opnGPS() {
|
||||
wx.openLocation({
|
||||
latitude: Number(this.data.memberLessonTicket.venueLesson.latitude),
|
||||
longitude: Number(this.data.memberLessonTicket.venueLesson.longitude),
|
||||
name: this.data.memberLessonTicket.venueLesson.name,
|
||||
address: this.data.memberLessonTicket.venueLesson.address,
|
||||
})
|
||||
},
|
||||
|
||||
// 点击图片
|
||||
clickImage() {
|
||||
wx.previewImage({
|
||||
urls: [this.data.memberLessonTicket.venueLesson.coach.wechatCode],
|
||||
})
|
||||
}
|
||||
})
|
||||
7
pages/myBookings/index.json
Normal file
7
pages/myBookings/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"navigationBarTitleText": "我的预约",
|
||||
"usingComponents": {
|
||||
"confirm-dialog": "/component/confirmDialog/confirmDialog",
|
||||
"header": "/component/header/header"
|
||||
}
|
||||
}
|
||||
64
pages/myBookings/index.wxml
Normal file
64
pages/myBookings/index.wxml
Normal file
@@ -0,0 +1,64 @@
|
||||
<!--pages/myBookings/index.wxml-->
|
||||
<header title="我的预约" isGoHome="{{isGoHome}}"></header>
|
||||
<view class='container' wx:if="{{memberLessonTicket.venueLesson}}">
|
||||
<view class='cell-box'>
|
||||
<view class='cell'>
|
||||
<view class='title'>
|
||||
<text>{{memberLessonTicket.venueLesson.name}}</text>
|
||||
</view>
|
||||
<!-- <view class='state'>{{memberLessonTicket.status == 0 ? "已预约" : (memberLessonTicket.status == 1 ? "已完成" : "已取消")}}</view> -->
|
||||
<view class='state' wx:if="{{memberLessonTicket.status == 0}}">已预约</view>
|
||||
<view class='state' wx:if="{{memberLessonTicket.status == 3}}">未签到</view>
|
||||
<view class='state' wx:if="{{memberLessonTicket.status == 1}}">已签到</view>
|
||||
<view class='state' wx:if="{{memberLessonTicket.status == 2}}">已取消</view>
|
||||
</view>
|
||||
<view class='cell'>
|
||||
<image src='../../images/42@3x.png' mode='aspectFit'></image>
|
||||
<text>{{memberLessonTicket.venueLesson.date}} {{memberLessonTicket.venueLesson.startTime}} ~ {{memberLessonTicket.venueLesson.endTime}}</text>
|
||||
</view>
|
||||
<!-- <view class='cell'>
|
||||
<image src='../../images/41@3x.png' mode='aspectFit'></image>
|
||||
<text>{{memberLessonTicket.venueLesson.address}}</text>
|
||||
</view> -->
|
||||
<view class='cell' bindtap='opnGPS'>
|
||||
<image src='../../images/41@3x.png' mode='aspectFit'></image>
|
||||
<text>{{memberLessonTicket.venueLesson.address}}</text>
|
||||
<view class='cell-right'>
|
||||
<image src='../../images/34@3x.png' class='gps-img'></image>
|
||||
<text>导航</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class='cell'>
|
||||
<image src='../../images/40@3x.png' mode='aspectFit'></image>
|
||||
<text>{{memberLessonTicket.memberCard.cardType ? '已使用' + memberLessonTicket.memberCard.cardType : "未使用会员卡"}}</text>
|
||||
</view>
|
||||
<view class='cell '>
|
||||
<image src='../../images/39@3x.png' mode='aspectFit'></image>
|
||||
<text>人数</text>
|
||||
<view class='cell-right-white' bindtap='callPhone'>{{memberLessonTicket.lessonCount}}人</view>
|
||||
</view>
|
||||
<view class='cell '>
|
||||
<image src='../../images/33@3x.png' mode='aspectFit'></image>
|
||||
<text>费用</text>
|
||||
<view class='cell-right-white' bindtap='callPhone' wx:if="{{!memberLessonTicket.memberCard.cardType}}">已支付: ¥{{memberLessonTicket.order.price}}</view>
|
||||
</view>
|
||||
<view class='cell unline'>
|
||||
<image src='../../images/21@3x.png' mode='aspectFit'></image>
|
||||
<text>助理教练信息</text>
|
||||
</view>
|
||||
<view class='qrCode-box'>
|
||||
<image src='{{memberLessonTicket.venueLesson.coach.wechatCode}}' bindtap='clickImage'></image>
|
||||
<text>扫一扫加好友</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='footer-box' wx:if="{{memberLessonTicket.status == 0}}">
|
||||
<!-- {{isSignIn ? "" : "isActive"}} -->
|
||||
<view class='footer-btn ' bindtap='cancelBooking'>取消预约</view>
|
||||
<!-- {{isSignIn ? "isActive" : ""}} -->
|
||||
<view class='footer-btn isActive' bindtap='signIn'>我要签到</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<confirm-dialog title="{{'提示'}}" message="{{'退款成功后,将于2个工作日内到达微信账号或余额中,每天只有一次机会取消订单'}}" bindcancelselect="cancelDeleteDialog" bindconfirmselect="confirmDeleteDialog" wx:if="{{showDeleteDialog}}"></confirm-dialog>
|
||||
117
pages/myBookings/index.wxss
Normal file
117
pages/myBookings/index.wxss
Normal file
@@ -0,0 +1,117 @@
|
||||
/* pages/myBookings/index.wxss */
|
||||
|
||||
.container {
|
||||
min-height: calc(100vh - 290rpx);
|
||||
padding: 160rpx 30rpx 130rpx 30rpx;
|
||||
}
|
||||
|
||||
.cell-box {
|
||||
background: #1a191e;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.cell-box .cell {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 90rpx;
|
||||
padding: 0 20rpx;
|
||||
border-bottom: 2rpx solid #212025;
|
||||
}
|
||||
|
||||
.cell-box .cell.unline {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.cell-box .cell>image {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
margin-right: 26rpx;
|
||||
}
|
||||
|
||||
.cell-box .cell>text {
|
||||
flex: 1;
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.cell-box .cell .title {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.cell-box .cell .cell-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.cell-box .cell .cell-right .gps-img {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.cell-box .cell .cell-right>text {
|
||||
height: 20rpx;
|
||||
margin-top: 6rpx;
|
||||
line-height: 20rpx;
|
||||
}
|
||||
|
||||
.cell-box .cell .state {
|
||||
font-size: 22rpx;
|
||||
color: #ffda2e;
|
||||
}
|
||||
|
||||
.cell-box .cell .cell-right-white {
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.cell-box .qrCode-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
.cell-box .qrCode-box>image {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
}
|
||||
|
||||
.cell-box .qrCode-box>text {
|
||||
margin-top: 20rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 22rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.footer-box {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
}
|
||||
|
||||
.footer-btn {
|
||||
flex: 1;
|
||||
background: #767578;
|
||||
color: #1a191e;
|
||||
font-size: 32rpx;
|
||||
text-align: center;
|
||||
line-height: 100rpx;
|
||||
}
|
||||
|
||||
.footer-btn.isActive {
|
||||
background: #ffda2e;
|
||||
}
|
||||
Reference in New Issue
Block a user