|
@@ -170,7 +170,7 @@
|
|
|
</view>
|
|
|
<view class="type-desc" v-if="item.goodsSnapshot">{{item.goodsSnapshot}}</view>
|
|
|
<view class="ticket-control u-flex u-row-right">
|
|
|
- <view class="minus" :class="{disabled: !item.saleNum}"
|
|
|
+ <view class="minus" :class="{disabled: !item.saleNum||fromPage=='rebook'}"
|
|
|
@click.stop="changeTicketNum(item, 'minus')">-</view>
|
|
|
<!-- <view class="num">{{item.saleNum || 0}}</view> -->
|
|
|
<input
|
|
@@ -178,8 +178,9 @@
|
|
|
type="number"
|
|
|
style="width: 40px;text-align: center;"
|
|
|
v-model="item.saleNum"
|
|
|
- ></input>
|
|
|
- <view class="plus" :class="{disabled: item.stockNum === item.saleNum}"
|
|
|
+ :disabled="fromPage=='rebook'"
|
|
|
+ >
|
|
|
+ <view class="plus" :class="{disabled: item.stockNum === item.saleNum||fromPage=='rebook'}"
|
|
|
@click.stop="changeTicketNum(item, 'plus')">+</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -196,7 +197,10 @@
|
|
|
<text class="original">¥{{originalPrice}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="submit-btn" :class="{active: hasSelectedTicket}" @click="book">
|
|
|
+ <view v-if="fromPage=='rebook'" class="submit-btn" :class="{active: hasSelectedTicket}" @click="handelRebook">
|
|
|
+ {{hasSelectedTicket ? '确认改签并支付' : '请选择票'}}
|
|
|
+ </view>
|
|
|
+ <view v-else class="submit-btn" :class="{active: hasSelectedTicket}" @click="book">
|
|
|
{{hasSelectedTicket ? '去支付' : '请选择票'}}
|
|
|
</view>
|
|
|
</view>
|
|
@@ -358,7 +362,10 @@
|
|
|
label:null,//scene解析出来的
|
|
|
goodsSnapshot:null,//票务说明
|
|
|
retailId:null,
|
|
|
-
|
|
|
+ fromPage:null,
|
|
|
+ payResult:{},
|
|
|
+ cansubmit: true,
|
|
|
+ newOrderId:'',
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
@@ -367,7 +374,7 @@
|
|
|
}
|
|
|
},
|
|
|
onLoad(page) {
|
|
|
- // console.log('ticketlist page',page);
|
|
|
+ console.log('ticketlist page',page);
|
|
|
parentThis = this;
|
|
|
|
|
|
const scene = decodeURIComponent(page.scene);
|
|
@@ -393,7 +400,19 @@
|
|
|
}).catch(err=>{
|
|
|
console.log('uncompress',err);
|
|
|
})
|
|
|
- }else{
|
|
|
+ }else if(page.fromPage=='rebook'){
|
|
|
+ this.performId = page.performId;
|
|
|
+ this.orderId = page.orderId;
|
|
|
+ this.fromPage = page.fromPage;
|
|
|
+ sharePath=`/pages/ticketlist?id=${page.id}`;
|
|
|
+ this.getPerformData();
|
|
|
+ // this.getSystemInfo();
|
|
|
+ let today = new Date();
|
|
|
+ this.setDate(today);
|
|
|
+ this.getPerformInfo();
|
|
|
+ this.getPerformerNotice();
|
|
|
+ }
|
|
|
+ else{
|
|
|
this.performId = page.id;
|
|
|
sharePath=`/pages/ticketlist?id=${page.id}`;
|
|
|
this.getPerformData();
|
|
@@ -628,82 +647,81 @@
|
|
|
this.ticketTypeIndex = sellableTicketTypeIndex;
|
|
|
// console.log('sessionClick',this.sessionList[this.sessionIndex]);
|
|
|
},
|
|
|
- async getPositionData(){
|
|
|
- let _this = this;
|
|
|
- let retailId = null;
|
|
|
+ async getPositionData() {
|
|
|
try {
|
|
|
- retailId = await new Promise((resolve, reject) => {
|
|
|
- uni.getStorage({
|
|
|
- key: 'retailId',
|
|
|
- success: function (res) {
|
|
|
- // console.log('getPositionData retailId====', res.data);
|
|
|
- resolve(res.data);
|
|
|
- },
|
|
|
- fail: function (error) {
|
|
|
- reject(error);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- console.log('getPositionData retailId', retailId);
|
|
|
- } catch (error) {
|
|
|
- console.error('获取retailId失败', error);
|
|
|
- // 在这里可以添加处理失败的逻辑
|
|
|
- }
|
|
|
+ uni.showLoading();
|
|
|
+
|
|
|
+ // 获取 retailId
|
|
|
+ let retailId = null;
|
|
|
+ try {
|
|
|
+ const res = await uni.getStorage({ key: 'retailId' });
|
|
|
+ retailId = res.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.log('获取 retailId 失败:', error);
|
|
|
+ }
|
|
|
this.retailId = retailId;
|
|
|
- // console.log('getPositionData this.retailId',this.retailId);
|
|
|
- // if(this.scene&&this.scene!='undefined'){
|
|
|
- // await this.$u.api.uncompress({scene:this.scene}).then(res=>{
|
|
|
- // // data.performId = res.data.performId;
|
|
|
- // this.label = res.data.label;
|
|
|
- // this.retailId = res.data.retailId;
|
|
|
- // console.log('uncompress',res.data);
|
|
|
- // }).catch(err=>{
|
|
|
- // console.log('uncompress',err);
|
|
|
- // })
|
|
|
- // }
|
|
|
- let session = this.sessionList[this.sessionIndex]||{};
|
|
|
- let ticketType = this.ticketTypeList[this.ticketTypeIndex];
|
|
|
- let params ={
|
|
|
- performId:this.performId,
|
|
|
- // goodsId:ticketType.id,
|
|
|
- auditoriumId:this.auditoriumList[this.auditoriumIndex].id,
|
|
|
- performTimeId:session.id,
|
|
|
- label:this.label,
|
|
|
- retailId:this.retailId
|
|
|
- }
|
|
|
- // console.log('getPositionData params',params);
|
|
|
- this.$u.api.selectRegionV2(params).then(res=>{
|
|
|
- // console.log('getPositionData',res.data);
|
|
|
- this.positionData = res.data;
|
|
|
+
|
|
|
+ // 构建请求参数
|
|
|
+ const session = this.sessionList[this.sessionIndex] || {};
|
|
|
+ const params = {
|
|
|
+ performId: this.performId,
|
|
|
+ auditoriumId: this.auditoriumList[this.auditoriumIndex].id,
|
|
|
+ performTimeId: session.id,
|
|
|
+ label: this.label,
|
|
|
+ retailId: this.retailId,
|
|
|
+ timeId: session.id,
|
|
|
+ orderId: this.orderId
|
|
|
+ };
|
|
|
+
|
|
|
+ // 根据不同场景调用不同接口
|
|
|
+ const api = this.fromPage === 'rebook' ?
|
|
|
+ this.$u.api.selectRegionRebook :
|
|
|
+ this.$u.api.selectRegionV2;
|
|
|
|
|
|
- // this.positionArr = res.data.regionPriceList||[];
|
|
|
- this.ticketTypeList = res.data.seatList||[];
|
|
|
- let sellableTicketTypeIndex = this.findFirstSellableTicketTypeIndex();
|
|
|
- this.ticketTypeIndex = sellableTicketTypeIndex;
|
|
|
+ const res = await api(params,{custom:{toast:false,noload:true}});
|
|
|
|
|
|
- this.goodsSnapshot = this.ticketTypeList[this.ticketTypeIndex]?.goodsSnapshot;
|
|
|
- this.positionArr = this.ticketTypeList[this.ticketTypeIndex]?.goodsList||[];
|
|
|
- this.positionArr = this.positionArr.map(obj => {
|
|
|
- return {
|
|
|
- ...obj, // 保留原有的字段
|
|
|
- saleNum: 0 // 新增的字段
|
|
|
- };
|
|
|
- });
|
|
|
- // let sellableProductIndex = this.findFirstSellableProductIndex();
|
|
|
- // this.positionIndex = sellableProductIndex;
|
|
|
+ // 处理响应数据
|
|
|
+ this.positionData = res.data;
|
|
|
+ this.ticketTypeList = res.data.seatList || [];
|
|
|
|
|
|
+ // 设置默认选中的票档
|
|
|
+ const sellableTicketTypeIndex = this.findFirstSellableTicketTypeIndex();
|
|
|
+ this.ticketTypeIndex = sellableTicketTypeIndex;
|
|
|
|
|
|
+ // 设置票务说明
|
|
|
+ this.goodsSnapshot = this.ticketTypeList[this.ticketTypeIndex]?.goodsSnapshot;
|
|
|
|
|
|
- // console.log('this.positionIndex',this.positionIndex);
|
|
|
- uni.hideLoading();
|
|
|
- }).catch(err=>{
|
|
|
+ // 初始化座位数据
|
|
|
+ this.positionArr = (this.ticketTypeList[this.ticketTypeIndex]?.goodsList || [])
|
|
|
+ .map(obj => ({
|
|
|
+ ...obj,
|
|
|
+ saleNum: obj.saleNum||0 // 初始化选择数量为0
|
|
|
+ }));
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取座位数据失败:', error);
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: error.msg||'获取座位数据失败',
|
|
|
+ showCancel:false,
|
|
|
+ success: function (res) {
|
|
|
+ console.log('获取座位数据失败 提示',res);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // uni.showToast({
|
|
|
+ // title: error.msg||'获取座位数据失败',
|
|
|
+ // icon: 'none'
|
|
|
+ // });
|
|
|
+ } finally {
|
|
|
uni.hideLoading();
|
|
|
- console.log('getPositionData',err);
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
// 改变票数
|
|
|
changeTicketNum(item, type) {
|
|
|
// console.log('changeTicketNum===',item, type);
|
|
|
+ if(this.fromPage=='rebook'){
|
|
|
+ return
|
|
|
+ }
|
|
|
const currentNum = item.saleNum;
|
|
|
if(type === 'minus' && currentNum > 0) {
|
|
|
item.saleNum=item.saleNum-1
|
|
@@ -842,6 +860,172 @@
|
|
|
// auditoriumId:this.auditoriumList[this.auditoriumIndex].id
|
|
|
// })
|
|
|
},
|
|
|
+ getUserLocation() {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ uni.getLocation({
|
|
|
+ type: 'gcj02',
|
|
|
+ success: (res) => {
|
|
|
+ resolve(res);
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ reject(err);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async handelRebook(){
|
|
|
+ const location = await this.getUserLocation();
|
|
|
+ let session = this.sessionList[this.sessionIndex];
|
|
|
+ let params = {
|
|
|
+ orderId:this.orderId,
|
|
|
+ performTimeId:session.id,
|
|
|
+ longitude:location.longitude,
|
|
|
+ latitude:location.latitude
|
|
|
+ }
|
|
|
+ console.log('handelRebook params',params);
|
|
|
+ uni.showModal({
|
|
|
+ title: '温馨提示',
|
|
|
+ content: '每张票仅限改签一次,改签成功后原订单费用将会原路退还,您确定要改签吗?',
|
|
|
+ success: res => {
|
|
|
+ if (res.confirm) {
|
|
|
+ this.cansubmit = false;
|
|
|
+ this.$u.api.rebookApi(params)
|
|
|
+ .then(res => {
|
|
|
+ this.newOrderId = res.data.orderId;
|
|
|
+ // if(!res.data.needPay){
|
|
|
+ // //this.payQuery();
|
|
|
+ // uni.$u.route('/center/orderdetails', {
|
|
|
+ // type:'redirectTo',
|
|
|
+ // id: this.orderId
|
|
|
+ // });
|
|
|
+ // }else {
|
|
|
+ // this.payResult = res.data.payInfo;
|
|
|
+ // this.payResult.package = res.data.payInfo.packageValue;
|
|
|
+ // this.wxPay()
|
|
|
+ // }
|
|
|
+ this.gotoPay();
|
|
|
+ // uni.redirectTo({
|
|
|
+ // url: '/center/order'
|
|
|
+ // });
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ uni.showToast({
|
|
|
+ title: err.msg||'改签失败',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ gotoPay() {
|
|
|
+ this.$u.api.gotoPayV2({
|
|
|
+ orderId: this.newOrderId,
|
|
|
+ openid: ''
|
|
|
+ }).then(res => {
|
|
|
+ // this.payResult = res.data.payInfo;
|
|
|
+ // this.payResult.package = res.data.payInfo.packageValue;
|
|
|
+
|
|
|
+ // ygh
|
|
|
+ if(!res.data.needPay){
|
|
|
+ //this.payQuery();
|
|
|
+ uni.$u.route('/center/orderdetails', {
|
|
|
+ type:'redirectTo',
|
|
|
+ id: this.newOrderId
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ this.payResult = res.data.payInfo;
|
|
|
+ this.payResult.package = res.data.payInfo.packageValue;
|
|
|
+ this.wxPay()
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.cansubmit = true;
|
|
|
+ console.log('gotoPay', err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ wxPay() {
|
|
|
+ let that = this;
|
|
|
+ uni.requestPayment({
|
|
|
+ ...this.payResult,
|
|
|
+ "provider": "wxpay",
|
|
|
+ "orderInfo": {
|
|
|
+ // "appid": "wx499********7c70e", // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
|
|
|
+ // "noncestr": "c5sEwbaNPiXAF3iv", // 随机字符串
|
|
|
+ // "package": "Sign=WXPay", // 固定值
|
|
|
+ // "partnerid": "148*****52", // 微信支付商户号
|
|
|
+ // "prepayid": "wx202254********************fbe90000", // 统一下单订单号
|
|
|
+ // "timestamp": 1597935292, // 时间戳(单位:秒)
|
|
|
+ // "sign": "A842B45937F6EFF60DEC7A2EAA52D5A0" // 签名,这里用的 MD5/RSA 签名
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ that.payQuery();
|
|
|
+ },
|
|
|
+ fail(e) {
|
|
|
+ uni.$u.route('/center/order', {
|
|
|
+ status: 0
|
|
|
+ });
|
|
|
+ console.log('wxPayfail', e);
|
|
|
+ },
|
|
|
+ complete() {
|
|
|
+ this.cansubmit = true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ payQuery() {
|
|
|
+ let that = this;
|
|
|
+ let retryCount = 0;
|
|
|
+ let maxRetryCount = 5; // 设置最大重试次数
|
|
|
+ let interval = 2000; // 设置间隔时间为2秒
|
|
|
+ let timeout = 10000; // 设置超时时间为10秒
|
|
|
+ let timer;
|
|
|
+ uni.showLoading({
|
|
|
+ title: '支付结果查询中'
|
|
|
+ })
|
|
|
+ timer = setInterval(() => {
|
|
|
+ retryCount++;
|
|
|
+ if (retryCount > maxRetryCount || retryCount * interval > timeout) {
|
|
|
+ clearInterval(timer);
|
|
|
+ uni.hideLoading();
|
|
|
+ console.log("支付查询超时或达到最大重试次数");
|
|
|
+ // 在这里添加超时或达到最大重试次数的处理逻辑
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/center/order'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log("第" + retryCount + "次查询");
|
|
|
+ // 调用查询支付状态的方法
|
|
|
+ // 如果支付状态为成功,则清除定时器并处理成功的逻辑
|
|
|
+ // 如果支付状态为失败,则清除定时器并处理失败的逻辑
|
|
|
+ this.$u.api.payQueryV2({
|
|
|
+ orderId: this.newOrderId
|
|
|
+ }).then(res => {
|
|
|
+ // 0-未支付 1-已支付 2-支付中 3-支付失败 4-支付退款
|
|
|
+ let payStatus = res.data.payStatus;
|
|
|
+ if (payStatus === 1) {
|
|
|
+ // uni.$u.route('/center/orderdetails', {
|
|
|
+ // type:'redirectTo',
|
|
|
+ // id: res.data.orderId
|
|
|
+ // });
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/center/order?status=3'
|
|
|
+ });
|
|
|
+ // uni.$u.route('/center/paysuccess');
|
|
|
+ } else if (payStatus === 0 || payStatus === 2) {
|
|
|
+ this.payQuery()
|
|
|
+ } else if (payStatus === 3) {
|
|
|
+ uni.toast('支付失败')
|
|
|
+ }
|
|
|
+ clearInterval(timer);
|
|
|
+ }).catch(err => {
|
|
|
+ console.log('payQuery', err);
|
|
|
+ }).finally(() => {
|
|
|
+ uni.hideLoading()
|
|
|
+ this.cansubmit = true;
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, interval);
|
|
|
+ },
|
|
|
openShare(){
|
|
|
if(!this.performInfo.posterImg){
|
|
|
uni.$u.toast('没有节目信息');
|
|
@@ -1399,7 +1583,8 @@
|
|
|
}
|
|
|
|
|
|
.submit-btn {
|
|
|
- width: 200rpx;
|
|
|
+ // width: 200rpx;
|
|
|
+ padding: 0 24rpx;
|
|
|
height: 80rpx;
|
|
|
line-height: 80rpx;
|
|
|
text-align: center;
|