init project

This commit is contained in:
limqhz
2020-06-21 16:27:58 +08:00
commit e8fe10b5fb
178 changed files with 9964 additions and 0 deletions

333
pages/confirmOrder/index.js Normal file
View File

@@ -0,0 +1,333 @@
// pages/confirmOrder/index.js
const app = getApp();
import {
getCurrentPageUrl
} from './../../utils/util.js'
let id = '';
let venueId = '';
let venueType = '';
Page({
/**
* 页面的初始数据
*/
data: {
count: 1,
lessonOrder: {},
memberCard: {},
memberCardNum: 0,
showUnclickMask: false,
memberCardList: [],
showCardPopup: false,
isWxLogin: false,
payType: 2
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
id = options.id;
venueId = options.venueId;
venueType = options.venueType;
this.getData();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
this.setData({
showUnclickMask: false
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
return {
title: '智慧云馆'
}
},
// 选择会员卡
selectMembershipCard() {
if (this.data.memberCardNum == 0) {
return;
}
this.setData({
showCardPopup: true
})
},
// 增加数量
add() {
if (this.data.count >= (this.data.lessonOrder.num - this.data.lessonOrder.saleNum)) {
wx.showToast({
title: '库存不足',
icon: 'none',
duration: 2000,
})
return;
}
if (this.data.memberCard.cardType) {
wx.showToast({
title: '使用会员卡仅能预约一人',
icon: 'none',
duration: 2000,
})
return;
}
if (this.data.count >= 4) {
wx.showToast({
title: '每单最多预约四人',
icon: 'none',
duration: 2000,
})
return;
}
if (this.data.count >= 1 && this.data.lessonOrder.price == 0) {
wx.showToast({
title: '免费课程仅能预约一人',
icon: 'none',
duration: 2000,
})
return;
}
this.setData({
count: ++this.data.count
})
},
// 减少人数
sub() {
if (this.data.count == 1) {
return;
}
this.setData({
count: --this.data.count
})
},
// 确认订单
confirmOrder() {
let that = this;
this.setData({
showUnclickMask: true
})
wx.showLoading({
title: '加载中...',
})
if (this.data.memberCard.cardType) {
app.$api.memberLessonTicketOrderMemberCard({
lessonId: id,
memberCardId: this.data.memberCard.id,
num: this.data.count
}).then(res => {
wx.showToast({
title: '预约成功',
icon: 'success',
duration: 2000
})
setTimeout(function() {
that.setData({
showUnclickMask: false
})
wx.redirectTo({
url: '/pages/myBookings/index?orderSn=' + res.orderSn,
})
}, 2000)
}, err => {
that.setData({
showUnclickMask: false
})
})
} else {
app.$api.memberLessonTicketOrderWX({
lessonId: id,
num: this.data.count,
type:this.data.payType
}).then(res => {
if (!res.pay.time_stamp) {
wx.showToast({
title: '预约成功',
icon: 'success',
duration: 2000
})
setTimeout(function() {
that.setData({
showUnclickMask: false
})
wx.redirectTo({
url: '/pages/myBookings/index?orderSn=' + res.pay.orderSn,
})
}, 2000)
return;
}
app.$pay.wxPay(res.pay).then(data => {
setTimeout(function() {
that.setData({
showUnclickMask: false
})
wx.redirectTo({
url: '/pages/myBookings/index?orderSn=' + res.pay.orderSn,
})
}, 2000)
}, err => {
console.log("SSSSS")
wx.showToast({
title: '取消支付,预约失败',
icon: 'none'
})
this.setData({
showUnclickMask: false
})
});
}, err => {
this.setData({
showUnclickMask: false,
})
if (err.data.err_code == 30022) {
this.setData({
isWxLogin: true,
isShowBuyVip: false
})
}
})
}
},
getData() {
wx.showLoading({
title: '加载中...',
})
app.$api.venueLessonOrder({
lessonId: id,
venueId: venueId,
venueType: venueType
}).then(res => {
for (let i = 0; i < res.memberCard.length; i++) {
if (res.memberCard[i].status == 1 && res.memberCard[i].cardFlg == 0) {
this.data.memberCard = res.memberCard[i];
}
if (res.memberCard[i].cardFlg == 0) {
this.data.memberCardNum++;
}
res.memberCard[i].startTime = res.memberCard[i].startTime.split(' ')[0];
res.memberCard[i].endTime = res.memberCard[i].endTime.split(' ')[0];
}
this.setData({
lessonOrder: res.lessonOrder,
memberCardList: res.memberCard,
memberCard: this.data.memberCard,
memberCardNum: this.data.memberCardNum
})
}, err => {
})
},
// 隐藏会员卡弹框
cencalCardBox() {
this.setData({
showCardPopup: false
})
},
unTap() {
return;
},
unUserCard() {
this.setData({
memberCard: {},
showCardPopup: false
})
},
// 选择会员卡
changeCard(e) {
let id = e.currentTarget.dataset.id;
let obj = {};
for (let i = 0; i < this.data.memberCardList.length; i++) {
if (id == this.data.memberCardList[i].id) {
obj = this.data.memberCardList[i]
}
}
this.setData({
memberCard: obj,
showCardPopup: false,
count: 1
})
},
// 取消授权登录
cancelDeleteDialog() {
this.setData({
isWxLogin: false
})
},
// 授权微信
getUserInfo(e) {
console.log(e.detail);
app.$pay.payWxLoing(e.detail).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
},
// 选中支付方式
changePayType(e) {
this.setData({
payType: e.currentTarget.dataset.type
})
}
})

View File

@@ -0,0 +1,7 @@
{
"navigationBarTitleText": "确认订单",
"usingComponents": {
"header": "/component/header/header",
"confirm-dialog": "/component/confirmDialog/confirmDialog"
}
}

View File

@@ -0,0 +1,87 @@
<!--pages/confirmOrder/index.wxml-->
<header title="确认订单"></header>
<view class='container' wx:if="{{lessonOrder.name}}">
<view class='title'>{{lessonOrder.name}}</view>
<view class='box'>
<view class='cell'>
<image src='../../images/42@3x.png' mode='aspectFit'></image>
<text>开课时间: {{lessonOrder.date}} {{lessonOrder.startTime}} ~ {{lessonOrder.endTime}}</text>
</view>
<view class='cell'>
<image src='../../images/41@3x.png' mode='aspectFit'></image>
<text>{{lessonOrder.address}}</text>
</view>
<view class='cell' bindtap='selectMembershipCard'>
<image src='../../images/40@3x.png' mode='aspectFit'></image>
<text>{{memberCardNum == 0? "暂无会员卡" : (memberCard.cardType ? "已使用" + memberCard.cardType : "未使用会员卡")}}</text>
<image class='right-img' src='../../images/46@3x.png' wx:if="{{memberCardNum > 0}}"></image>
</view>
<view class='cell'>
<image src='../../images/39@3x.png' mode='aspectFit'></image>
<text>人数</text>
<view class='change-quantities'>
<view class='operator' bindtap='sub'>
<image src='../../images/38@3x.png'></image>
</view>
<view class='number'>{{count}}</view>
<view class='operator' bindtap='add'>
<image src='../../images/37@3x.png'></image>
</view>
</view>
</view>
<view class='box-footer'>
{{memberCard.cardType ? "已使用" + memberCard.cardType : "合计: ¥" + (lessonOrder.price * count)}}
</view>
<!-- wx:if="{{lesson.note}}" -->
</view>
<view class="box" style="margin-top: 30rpx;">
<view class="cell" bindtap="changePayType" data-type="2">
<image src='../../images/42.png' mode='aspectFit' wx:if="{{payType == 2}}"></image>
<image src='../../images/43.png' mode='aspectFit' wx:else></image>
<text>微信支付</text>
</view>
<view class="cell" bindtap="changePayType" data-type="1">
<image src='../../images/42.png' mode='aspectFit' wx:if="{{payType == 1}}"></image>
<image src='../../images/43.png' mode='aspectFit' wx:else></image>
<text>余额支付</text>
</view>
</view>
<view class='box' style='margin-top: 30rpx;'>
<view class='cell'>
<image src='../../images/32@3x.png' mode='aspectFit'></image>
<view class='title'>
<text>注意事项</text>
</view>
</view>
<view class='rich-box'>
<rich-text nodes="{{lessonOrder.note}}"></rich-text>
</view>
</view>
<view class='footer-btn' bindtap='confirmOrder'>确认订单</view>
</view>
<view class='unclick-mask' wx:if="{{showUnclickMask}}"></view>
<view class='card-box' wx:if="{{showCardPopup}}" bindtap='cencalCardBox'>
<view class='body-box' catchtap='unTap'>
<view class='cell' catchtap='unUserCard'>
<view class='buy-btn'>不使用会员卡</view>
<view class='buy-btn'>取消</view>
<!-- <image src='../../images/3@3x.png' wx:if="{{memberCard.cardType}}"></image>
<image src='../../images/4@3x.png' wx:else></image> -->
</view>
<view class='cell' wx:for="{{memberCardList}}" wx:key="{{index}}" wx:if="{{item.cardFlg == 0}}" data-id='{{item.id}}' catchtap="changeCard">
<text class='tip'>{{item.cardType}}</text>
<text class='indate'>有效期: {{item.startTime}} ~ {{item.endTime}}</text>
<image src='../../images/4@3x.png' wx:if="{{memberCard.id == item.id}}"></image>
<image src='../../images/3@3x.png' wx:else></image>
</view>
</view>
<view class='cencal-btn'>取消</view>
</view>
<confirm-dialog title="提示" message="请先绑定微信" confirmBtnTitle="绑定" isUserInfo="{{true}}" bindcancelselect="cancelDeleteDialog" bindgetuserinfo="getUserInfo" wx:if="{{isWxLogin}}"></confirm-dialog>

View File

@@ -0,0 +1,185 @@
/* pages/confirmOrder/index.wxss */
.container {
padding-right: 30rpx;
padding-left: 30rpx;
padding-bottom: 130rpx;
min-height: calc(100vh - 260rpx);
}
.title {
height: 100rpx;
padding: 0 20rpx;
line-height: 100rpx;
color: #fff;
font-size: 26rpx;
}
.box {
background: #1a191e;
border-radius: 12rpx;
}
.box .cell {
display: flex;
justify-content: space-between;
align-items: center;
height: 90rpx;
padding: 0 20rpx;
border-bottom: 2rpx solid #212025;
}
.box .cell.unline {
border: none;
}
.box .cell .title {
flex: 1;
height: 90rpx;
padding: 0;
line-height: 90rpx;
}
.box .cell>image {
width: 34rpx;
height: 34rpx;
margin-right: 26rpx;
}
.box .cell .right-img {
width: 12rpx;
height: 22rpx;
margin-right: 0;
}
.box .cell .change-quantities {
display: flex;
align-items: center;
height: 100%;
}
.box .cell .change-quantities .operator {
display: flex;
align-items: center;
width: 40rpx;
height: 40rpx;
}
.box .cell .change-quantities .operator>image {
width: 100%;
height: 100%;
}
.box .cell .change-quantities .number {
font-size: 22rpx;
color: #fff;
margin: 0 16rpx;
}
.box .cell>text {
flex: 1;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.6);
}
.box .rich-box {
display: flex;
padding: 20rpx;
color: rgba(255, 255, 255, 0.6);
font-size: 24rpx;
line-height: 36rpx;
}
.box .box-footer {
height: 90rpx;
padding: 0 20rpx;
text-align: right;
line-height: 90rpx;
color: #fff;
font-size: 24rpx;
}
.footer-btn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 100rpx;
background: #ffda2e;
color: #1a191e;
font-size: 32rpx;
text-align: center;
line-height: 100rpx;
}
.unclick-mask {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0);
}
.card-box {
position: fixed;
top: 0;
left: 0;
display: flex;
flex-direction: column;
justify-content: flex-end;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
}
.card-box .body-box {
background: #252330;
width: 100%;
min-height: 400rpx;
}
.card-box .cencal-btn {
background: #ffda2e;
height: 80rpx;
width: 100%;
color: #252330;
line-height: 80rpx;
text-align: center;
font-size: 32rpx;
}
.card-box .body-box .cell {
display: flex;
justify-content: space-between;
align-items: center;
height: 90rpx;
padding: 0 20rpx;
}
.card-box .body-box .cell .tip {
height: 30rpx;
padding: 0 4rpx;
margin-right: 22rpx;
font-size: 20rpx;
line-height: 30rpx;
border: 2rpx solid #ffda2e;
color: #ffda2e;
border-radius: 6rpx;
}
.card-box .body-box .cell .indate {
flex: 1;
font-size: 20rpx;
color: rgba(255, 255, 255, 0.6);
}
.card-box .body-box .cell .buy-btn {
font-size: 26rpx;
color: #ffda2e;
}
.card-box .body-box .cell>image {
width: 30rpx;
height: 30rpx;
}