Browse Source

活动日历改版

master
chenkainan 2 months ago
parent
commit
aea043181d
  1. 118
      pages/component/newCalendar/index.wxml
  2. 70
      pages/component/newCalendar/index.wxss
  3. 72
      pages/list/activitynew/index.js
  4. 13
      pages/list/activitynew/index.wxml
  5. 117
      pages/list/activitynew/index.wxss
  6. 70
      pages/pbService/web/index.js
  7. 11
      project.private.config.json
  8. 4
      utils/filter.wxs

118
pages/component/newCalendar/index.wxml

@ -1,67 +1,71 @@
<!--components/xx-calendar/xx-calendar.wxml-->
<!-- 头部 -->
<view class="title-wrap">
<view class="change-date">
<view class="prev" bindtap="changeMonthFun" data-type="prev">
<image lazy-load style="margin-right: 10rpx;" src="https://static.ticket.sz-trip.com/uploads/20240327/283ac46c0fab03c04dad40f765854514.png" mode="" />
<text wx:if="{{currentViewType==='month'}}">上一月</text>
<text wx:else>上一周</text>
</view>
<view class="year-mouth">
{{year}}年 {{month}}月
</view>
<view class="next" bindtap="changeMonthFun" data-type="next" >
<text wx:if="{{currentViewType==='month'}}">下一月</text>
<text wx:else>下一周 </text>
<image lazy-load style="margin-left: 10rpx;" src="https://static.ticket.sz-trip.com/uploads/20240327/ab2097432f5c34915665cb376e72c4aa.png" mode="" />
</view>
</view>
</view>
<!-- 日期 -->
<view class="date-wrap">
<image lazy-load wx:if="{{currentViewType === 'month'}}" class="bottom-image" src="https://static.ticket.sz-trip.com/uploads/20250421/a0b731399b5c348ae4dc5199c9034ab5.png"></image>
<view class="{{currentViewType === 'month' ? 'bigBg' : 'smallBg'}}">
<!-- 头部 -->
<view class="title-wrap">
<view class="change-date">
<view class="year-mouth">
{{year}}年 {{month}}月
</view>
<view>
<view class="prev" bindtap="changeMonthFun" data-type="prev">
<!-- <image lazy-load style="margin-right: 10rpx;" src="https://static.ticket.sz-trip.com/uploads/20240327/283ac46c0fab03c04dad40f765854514.png" mode="" /> -->
<text wx:if="{{currentViewType==='month'}}">上一月</text>
<text wx:else>上一周</text>
</view>
<view class="next" bindtap="changeMonthFun" data-type="next" >
<text wx:if="{{currentViewType==='month'}}">下一月</text>
<text wx:else>下一周 </text>
<!-- <image lazy-load style="margin-left: 10rpx;" src="https://static.ticket.sz-trip.com/uploads/20240327/ab2097432f5c34915665cb376e72c4aa.png" mode="" /> -->
</view>
</view>
</view>
</view>
<!-- 日期 -->
<view class="date-wrap">
<image lazy-load wx:if="{{currentViewType === 'month'}}" class="bottom-image" src="https://static.ticket.sz-trip.com/uploads/20250421/a0b731399b5c348ae4dc5199c9034ab5.png"></image>
<view class="week">
<text wx:for="{{weeksArr}}" wx:key="*this">{{item}}</text>
</view>
<!-- 上个月日期 -->
<view wx:if="{{currentViewType === 'month'}}" wx:for="{{lastMonthDays}}" wx:key="*this" class="mouth-date last-mouth">
<text class="day-text">{{item.date}}</text>
</view>
<view class="week">
<text wx:for="{{weeksArr}}" wx:key="*this">{{item}}</text>
</view>
<!-- 上个月日期 -->
<view wx:if="{{currentViewType === 'month'}}" wx:for="{{lastMonthDays}}" wx:key="*this" class="mouth-date last-mouth">
<text class="day-text">{{item.date}}</text>
</view>
<!-- 当月日期 -->
<view class="mouth-date current-mouth " wx:for="{{currentViewType === 'month' ? nowMonthDays : weekDay}}" wx:key="*this" bindtap="selectDate"
data-item="{{item}}" data-type="nowMonthDays" data-index="{{index}}"
>
<view class="day-box {{item.isNowMonthDay?'active':''}} {{item.isHoliday ? 'holiday' : ''}}{{item.isHoliday&&item.isNowMonthDay ? 'active' : ''}}"
style="background: {{ item.isHoliday.background }};color: {{ item.isHoliday.color }};border-bottom: {{item.isHoliday.borderBottom||'none'}};">
<text class="day-text">
<!-- <text class="day-text {{item.isHoliday?'color':''}} "> -->
<text>{{item.date}}</text>
<text wx:if="{{item.isHoliday}}" class="xiu" >休</text>
</text>
<!-- day 后面会换成农历展示 -->
<text class="day-nongli" wx:if="{{item.isHoliday && item.holidayList2}}" style="color: {{ item.isHoliday.color }}">{{ item.isHoliday.name}} </text>
<text class="day-nongli" wx:else="" style="color: {{ item.isHoliday ? item.isHoliday.color : '#888888' }}">{{ item.day}}</text>
<text class=" {{item.color?'day-dot':'not-dot'}}"></text>
</view>
</view>
<!-- 当月日期 -->
<view class="mouth-date current-mouth " wx:for="{{currentViewType === 'month' ? nowMonthDays : weekDay}}" wx:key="*this" bindtap="selectDate"
data-item="{{item}}" data-type="nowMonthDays" data-index="{{index}}"
>
<view class="day-box {{item.isNowMonthDay?'active':''}} {{item.isHoliday ? 'holiday' : ''}}{{item.isHoliday&&item.isNowMonthDay ? 'active' : ''}}"
style="background: {{ item.isHoliday ? '#FAE3E3' : 'none' }} ;color: {{ item.isHoliday ? '#D10000' : '#888888' }};border-bottom: 'none';">
<text class="day-text">
<!-- <text class="day-text {{item.isHoliday?'color':''}} "> -->
<text>{{item.date}}</text>
<text wx:if="{{item.isHoliday}}" class="xiu" >休</text>
</text>
<!-- day 后面会换成农历展示 -->
<text class="day-nongli" wx:if="{{item.isHoliday && item.holidayList2}}" style="color: {{ item.isHoliday.color }}">{{ item.isHoliday.name}} </text>
<text class="day-nongli" wx:else="" style="color: {{ item.isHoliday ? '#D10000' : '#888888' }}">{{ item.day}}</text>
<text class=" {{item.color?'day-dot':'not-dot'}}"></text>
</view>
</view>
<!-- 下个月日期 -->
<view wx:if="{{currentViewType === 'month'}}" class="mouth-date next-mouth" wx:for="{{nextMonthDays}}" wx:key="*this">
<text class="day-text">{{item.date}}</text>
</view>
<!-- 下个月日期 -->
<view wx:if="{{currentViewType === 'month'}}" class="mouth-date next-mouth" wx:for="{{nextMonthDays}}" wx:key="*this">
<text class="day-text">{{item.date}}</text>
</view>
<view class="footer" bindtap="toggleMode">
<!-- <view class="arrow {{currentViewType==='month'?'arrow-up':'arrow-down'}}">></view>
<view> {{currentViewType==="month"?"收起":"更多"}} </view> -->
<image lazy-load wx:if="{{currentViewType==='week'}}" src="https://static.ticket.sz-trip.com/uploads/20240327/8b5f8a284de3831392560c367f8c59ca.png" mode=""/>
<image lazy-load wx:else src="https://static.ticket.sz-trip.com/uploads/20240327/d23c7a3d743e4fb9623c534adf10760b.png" mode=""/>
</view>
<!-- 节假日花样 -->
<!-- <image lazy-load wx:if="{{currentViewType==='month'}}" style="width: 250rpx;height: 144.67rpx;position: absolute;right: 0;bottom: 30.67rpx;" src="https://static.ticket.sz-trip.com/uploads/20240605/1dda9e2e0fbc5d64aef702b5e692b2e5.png" mode=""/> -->
<view class="footer" bindtap="toggleMode">
<!-- <view class="arrow {{currentViewType==='month'?'arrow-up':'arrow-down'}}">></view>
<view> {{currentViewType==="month"?"收起":"更多"}} </view> -->
<image lazy-load wx:if="{{currentViewType==='week'}}" src="https://static.ticket.sz-trip.com/jundaosuzhou/images/calendar2026/bot.png" mode=""/>
<image lazy-load wx:else src="https://static.ticket.sz-trip.com/jundaosuzhou/images/calendar2026/top.png" mode=""/>
</view>
<!-- 节假日花样 -->
<!-- <image lazy-load wx:if="{{currentViewType==='month'}}" style="width: 250rpx;height: 144.67rpx;position: absolute;right: 0;bottom: 30.67rpx;" src="https://static.ticket.sz-trip.com/uploads/20240605/1dda9e2e0fbc5d64aef702b5e692b2e5.png" mode=""/> -->
</view>
</view>

70
pages/component/newCalendar/index.wxss

@ -1,7 +1,28 @@
/* components/xx-calendar/xx-calendar.wxss */
page{
/* background: #F0B643; */
background: #F2F2F2;
background: #FFFBF3;
}
.bigBg {
background-image: url("https://static.ticket.sz-trip.com/jundaosuzhou/images/calendar2026/bigCalss.png");
background-size: 100% 100%;
width: 750rpx;
height: 893rpx;
padding-top: 70rpx;
box-sizing: border-box;
position: relative;
z-index: 2;
margin-top: 756rpx;
}
.smallBg {
background-image: url("https://static.ticket.sz-trip.com/jundaosuzhou/images/calendar2026/smallCal.png");
background-size: 100% 100%;
width: 740.67rpx;
height: 478rpx;
padding-top: 103rpx;
box-sizing: border-box;
position: relative;
z-index: 2;
margin-top: 756rpx;
}
/* 头部样式start */
.title-wrap{
@ -29,7 +50,7 @@ page{
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 22rpx;
margin: 0 50rpx;
}
.change-date image{
width: 50rpx;
@ -38,10 +59,9 @@ page{
display: flex;
}
.year-mouth{
margin: 0 60rpx;
font-weight: bold;
font-size: 35rpx;
color: #000;
font-weight: 600;
font-size: 36rpx;
color: #EF1C24;
}
.week{
width: 100%;
@ -59,13 +79,13 @@ page{
/* 日期区域样式start */
.date-wrap{
/* height: 500rpx; */
width: 697rpx;
width: 650rpx;
margin: 0 auto;
background-color: #fff;
background-color: none;
display: flex;
flex-wrap: wrap;
border-radius: 20rpx;
margin-top: -144rpx;
margin-top: -165rpx;
position: relative;
}
.mouth-date{
@ -75,7 +95,7 @@ page{
align-items: center;
width: calc(100% / 7);
/* border-bottom: 1rpx solid rgb(229, 234, 235); */
padding-top: 10rpx;
/* padding-top: 10rpx; */
}
.last-mouth text,.next-mouth text{
opacity: 0;
@ -108,16 +128,18 @@ page{
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 10rpx;
margin-bottom: 5rpx;
padding-bottom: 8rpx;
}
.mouth-date .active{
background-color: #0B898E !important;
background-color: #FFF168 !important;
border: 3rpx solid #EF1C24;
box-sizing: border-box;
}
.mouth-date .active text{
color: #fff !important;
color: #00A4FA !important;
}
@ -170,9 +192,9 @@ page{
}
.footer image {
width: 20rpx;
height: 20rpx;
margin: 12rpx auto 20rpx;
width: 34rpx;
height: 34rpx;
margin: 0 auto 20rpx;
}
.arrow-left{
@ -188,11 +210,17 @@ page{
transform: rotate(-90deg)
}
.next, .prev {
display: flex;
align-items: baseline;
font-size: 27rpx;
width: 128rpx;
liine-height: 43rpx;
text-align: center;
background: #FFF168;
border-radius: 21rpx 21rpx 21rpx 21rpx;
border: 3rpx solid #EF1C24;
font-weight: 500;
color: #000;
font-size: 27rpx;
color: #000000;
margin-left: 30rpx;
display: inline-block;
}
.next image, .prev image {
width: 20rpx;

72
pages/list/activitynew/index.js

@ -30,7 +30,8 @@ Page({
movieAreas:[],
movieArea:0,
defaultDate: "2020-3-31",
startDay: "sunday"
startDay: "sunday",
showDate: ""
},
/**
@ -43,14 +44,19 @@ Page({
})
this.getMovieArea()
let d = new Date();
let month = d.getMonth() + 1,
day = d.getDate();
month = month > 10 ? month : ("0" + month);
day = day >= 10 ? day : ("0" + day);
this.setData({
selectDay: d.getTime(),
date: d.getFullYear() + "-" + month + "-" + day
})
let year = d.getFullYear();
let month = d.getMonth() + 1;
let day = d.getDate();
// 接口用的格式 2026-02-09
let apiDate = [year, month > 9 ? month : '0' + month, day > 9 ? day : '0' + day].join('-');
// 显示用的格式 2026年2月9日
let showDateStr = `${year}${month}${day}`;
this.setData({
selectDay: d.getTime(),
date: apiDate,
showDate: showDateStr // 赋值给显示变量
})
this.getWeekDay();
commonApi._post("pbservice/Other/getSuzhouAreas").then(res => {
res.data.unshift({
@ -82,10 +88,16 @@ Page({
})
})
},
formatChineseDate(dateStr) {
if (!dateStr) return "";
let d = typeof dateStr === 'object' ? dateStr : new Date(dateStr.replace(/-/g, '/'));
return `${d.getFullYear()}${d.getMonth() + 1}${d.getDate()}`;
},
selectDate: function (e) {
console.log(e.detail);
this.setData({
date: e.detail,
showDate: this.formatChineseDate(e.detail),
pageNo: 1,
list: [],
total: 1,
@ -197,23 +209,30 @@ Page({
},
// 点击修改日期
changeDate: function (e) {
let times = e.currentTarget.dataset.times,
d = new Date(times);
let month = d.getMonth() + 1,
day = d.getDate();
month = month > 10 ? month : ('0' + month);
day = day > 10 ? day : ('0' + day);
this.setData({
selectDay: times,
date: d.getFullYear() + "-" + month + "-" + day,
list: [],
pageNo: 1,
total: 1,
moreFlag: true,
isYL: false
})
this.getList();
},
let times = e.currentTarget.dataset.times,
d = new Date(times);
let month = d.getMonth() + 1,
day = d.getDate();
let monthStr = month > 10 ? month : ('0' + month);
let dayStr = day > 10 ? day : ('0' + day);
// 接口格式
let apiDate = d.getFullYear() + "-" + monthStr + "-" + dayStr;
// 中文格式
let cnDate = `${d.getFullYear()}${month}${day}`;
this.setData({
selectDay: times,
date: apiDate,
showDate: cnDate, // 【新增】同步更新显示日期
list: [],
pageNo: 1,
total: 1,
moreFlag: true,
isYL: false
})
this.getList();
},
getList: function () {
let list = this.data.list;
if (this.data.isYL) {
@ -403,6 +422,7 @@ setCity(e){
total: 1,
moreFlag: true,
date:null,
// showDate: "",
isYL: this.data.type == 4 ? false: true,
selectDay: null

13
pages/list/activitynew/index.wxml

@ -1,6 +1,6 @@
<!--pages/activity/index.wxml-->
<title-header title="活动日历"></title-header>
<!-- <image lazy-load src="https://static.ticket.sz-trip.com/jundaosuzhou/images/calendar-top.png" mode=""/> -->
<image lazy-load src="https://static.ticket.sz-trip.com/jundaosuzhou/images/calendar2026/topImg.jpg" class="top-img" mode="widthFix" />
<new-calendar wx:if="{{type!=4}}" bind:selectDate="selectDate"></new-calendar>
<view class="top-fixed-box">
<!-- 节假日花样 -->
@ -19,6 +19,7 @@
<view class="search-btn" bindtap="search">搜索</view>
</view>
</view>
<view class="date-text">当日活动 <text>{{showDate}}</text></view>
<view class="types-box">
<view class="{{type==9?'types-item-active':'types-item'}}" bindtap="changeType" data-type="9">全部</view>
<view class="{{type==3?'types-item-active':'types-item'}}" bindtap="changeType" data-type="3">景区活动</view>
@ -103,14 +104,14 @@
<view class="{{sort=='distance'?'active':''}} m-sort" bindtap="setSort" data-sort="distance">离我最近</view>
<view class="{{sort=='price'?'active':''}} m-sort" bindtap="setSort" data-sort="price">价格最低</view>
</view>
<view wx:if="{{list.length>0 && type!=4}}" style="background:#fff;padding:1rpx 0">
<view wx:if="{{list.length>0 && type!=4}}" style="padding:1rpx 0">
<!-- <view wx:for="{{list}}" bindtap="gotoDetail" data-item="{{item}}" class="activity-item-out"> -->
<view class="activity-item" wx:for="{{list}}" bindtap="gotoDetail" data-item="{{item}}">
<common-image width="320rpx" height='220rpx' style="margin-right: 13rpx;" src="{{item.post_url || item.cover}}" defaultImage="https://static.ticket.sz-trip.com/uploads/20240909/c9a0029cc9426d2a17f1dbbb7a179762.jpg" mode="aspectFill"></common-image>
<common-image width="697rpx" height='411rpx' src="{{item.post_url || item.cover}}" defaultImage="https://static.ticket.sz-trip.com/uploads/20240909/c9a0029cc9426d2a17f1dbbb7a179762.jpg" mode="aspectFill"></common-image>
<view class="activity-info">
<view class="activity-title textOver2">{{item.name || item.title}}</view>
<view>
<view style="margin-bottom:10rpx">{{item.begin_date}}—{{item.end_date}}</view>
<view class="activity-title textOver">{{item.name || item.title}}</view>
<view style="display: flex;justify-content: space-between;align-items: center;">
<view>{{item.begin_date}}—{{item.end_date}}</view>
<view class="textOver2">{{item.from_platform}}</view>
<!-- <view class="textOver2">{{item.detail_address?item.detail_address:""}}</view> -->
</view>

117
pages/list/activitynew/index.wxss

@ -5,6 +5,10 @@ page {
/* 节假日花样 */
/* background: #CEEDDB; */
}
.top-img {
position: absolute;
width: 750rpx;
}
.types {
/* justify-content: space-between; */
background: #fff;
@ -122,8 +126,8 @@ background: rgba(11, 137, 142, .1);
z-index: 1;
}
.top-fixed-box {
background: #FFF;
width: 697rpx;
/* background: #FFF; */
width: 750rpx;
margin: 0 auto;
border-radius: 20rpx 20rpx 0 0;
margin-top: 20rpx;
@ -134,7 +138,7 @@ background: rgba(11, 137, 142, .1);
.activity-list {
width: 697rpx;
/* padding: 0 24rpx; */
background: #0B898E;
/* background: #0B898E; */
min-height:1300rpx;
margin: 0 auto;
}
@ -197,27 +201,27 @@ background: rgba(11, 137, 142, .1);
font-size: 27rpx;
}
.activity-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 22rpx;
/* padding: 27rpx 22rpx; */
margin: 30rpx auto;
position: relative;
width: 697rpx;
border-radius: 27rpx 27rpx 27rpx 27rpx;
background-color: #fff;
}
.end-mask {
position: absolute;
/* 产品需求24/5/20 已结束就是盖在图片上,按此需求调整 */
left: 22rpx;
left: 0;
/* right: 30rpx; */
/* top: 27rpx; */
text-align: center;
width: 320rpx;
height: 220rpx;
line-height: 220rpx;
width: 697rpx;
height: 411rpx;
line-height: 411rpx;
z-index: 1;
background:rgba(0, 0, 0, 0.5);
color:#fff;
border-radius: 10rpx;
border-radius: 27rpx;
top: 0;
}
.activity-item-out {
box-shadow: -1rpx 1rpx 16rpx 0px rgba(6, 0, 1, 0.1);
@ -226,9 +230,9 @@ background: rgba(11, 137, 142, .1);
background: white;
}
.activity-item image {
width: 320rpx;
height: 220rpx;
border-radius: 10rpx;
width: 697rpx;
height: 411rpx;
border-radius: 27rpx 27rpx 27rpx 27rpx;
flex-shrink: 0;
overflow: hidden;
}
@ -243,20 +247,20 @@ background: rgba(11, 137, 142, .1);
display: flex;
flex-direction: column;
justify-content: space-between;
/* font-size: 23rpx;
color: #999; */
flex: 1;
min-height: 220rpx;
/* margin-right: 28rpx; */
height: 141rpx;
font-weight: 400;
font-size: 24rpx;
color: #666;
color: #999999;
padding: 20rpx 26rpx 26rpx;
box-shadow: 0rpx 4rpx 7rpx 0rpx rgba(0,0,0,0.05);
box-sizing: border-box;
border-radius: 0rpx 0rpx 27rpx 27rpx;
}
.activity-title {
font-weight: 500;
font-size: 31rpx;
line-height: 45rpx;
color: #000;
/* color: #333; */
font-weight: 600;
font-size: 32rpx;
color: #000000;
}
.movie-types {
@ -304,7 +308,8 @@ background: rgba(11, 137, 142, .1);
border-radius: 30rpx;
height: 60rpx;
/* background: #ededed; */
background-color: rgba(204,204,204, .3);
background: #FFFFFF;
border: 3rpx solid #EB0000;
margin-bottom: 0;
font-size: 26rpx;
z-index: 9;
@ -323,8 +328,8 @@ background: rgba(11, 137, 142, .1);
width: 110rpx;
flex-shrink: 0;
line-height: 40rpx;
border-left: 1rpx solid #ccc;
color: #0B898E;
/* border-left: 1rpx solid #ccc; */
color: #EF1C24;
/* 节假日花样 */
/* color: #DE4126; */
}
@ -348,35 +353,31 @@ flex-shrink: 0;
font-weight: 500;
display: flex;
overflow-x: scroll;
padding: 31rpx 30rpx 30rpx;
padding: 31rpx 0rpx 30rpx;
position: relative;
z-index: 9;
align-items: center;
border-bottom: 2rpx solid rgba(0,0,0,0.1);
}
.types-item {
border: 1px solid #999999;
border-radius: 27rpx;
height: 53rpx;
padding: 0 25rpx;
/* border: 1px solid #999999; */
/* border-radius: 27rpx; */
margin: 0 30rpx;
display: inline-block;
line-height: 53rpx;
margin-right: 13rpx;
/* margin-right: 13rpx; */
flex-shrink: 0;
/* border: 1px solid #FFC987; */
}
.types-item-active {
/* padding: 0 79rpx; */
padding: 0 25rpx;
height: 57rpx;
/* 节假日花样 */
/* height: 91.33rpx; */
line-height: 57rpx;
margin: 0 30rpx;
display: inline-block;
background: #0B898E;
color: #FFFFFF;
/* background: #0B898E; */
/* color: #FFFFFF; */
font-weight: 600;
font-size: 27rpx;
color: #000000;
border-radius: 27rpx;
margin-right: 13rpx;
position: relative;
flex-shrink: 0;
/* 节假日花样 */
/* background-image: url("https://static.ticket.sz-trip.com/uploads/20240606/f4ff3a7f81b4be3508592f656e207497.png"); */
@ -393,6 +394,17 @@ flex-shrink: 0;
1px 1px 0 white;
background-image: url("https://static.ticket.sz-trip.com/uploads/20250421/48ce52adb4044d6b91bbce05047695a5.png"); */
}
.types-item-active::after {
content: '';
width: 100%;
height: 8rpx;
background: #EF1C24;
border-radius: 5rpx 5rpx 5rpx 5rpx;
position: absolute;
left: 0;
bottom: -33rpx;
z-index: 100;
}
/* 不显示滚动条 */
.types-box::-webkit-scrollbar {
display: none;
@ -404,3 +416,16 @@ flex-shrink: 0;
right: 0;
z-index: 2;
}
.date-text {
font-weight: 600;
font-size: 33rpx;
color: #000000;
margin: 20rpx 30rpx 0;
}
.date-text text {
font-weight: 400;
font-size: 24rpx;
color: #999999;
margin-left: 10rpx;
}

70
pages/pbService/web/index.js

@ -7,26 +7,26 @@ import https from "../../../utils/https.js"
Page({
data: {
webUrl: "",
shareTitle: "",
shareUrl: "",
shareTitle: "", // 给一个默认标题
shareUrl: "", // 暂时没用到,可以用 currentUrl 替代更清晰
currentShareUrl: "", // 【新增】用于存储 H5 传回来的最新 URL
currentShareImg: "", // 【新增】用于存储 H5 传回来的分享图片
cachedOptions: null,
isWaitingLogin: false,
},
onLoad: function (options) {
// onLoad 只负责存参数,不执行任何跳转逻辑,防止和页面初始化冲突
console.log('onLoad options:', options);
this.data.cachedOptions = options;
},
onShow: function () {
// 将所有逻辑移到 onShow,确保页面加载完毕后再执行跳转
this.checkLoginAndLoad();
},
checkLoginAndLoad: function() {
// 1. 防白屏容错:检查参数
// ... (你的原有逻辑保持不变) ...
let options = this.data.cachedOptions;
if (!options || !options.weburl) {
setTimeout(() => { wx.navigateBack(); }, 100);
@ -35,9 +35,7 @@ Page({
let token = wx.getStorageSync('jstrip_token');
// 2. 有 Token:正常加载
if (token) {
// 如果是刚登录回来,或者页面还没加载过 URL
if (this.data.isWaitingLogin || !this.data.webUrl) {
console.log('已登录,开始加载页面');
this.data.isWaitingLogin = false;
@ -46,37 +44,32 @@ Page({
return;
}
// 3. 无 Token:处理跳转
// 3.1 如果 isWaitingLogin 为 true,说明是刚从登录页返回(用户取消了登录)
if (this.data.isWaitingLogin) {
console.log('用户取消登录,返回上一页');
wx.navigateBack();
return;
}
// 3.2 第一次检测到未登录,跳转登录页
console.log('未登录,延时跳转登录页');
this.data.isWaitingLogin = true;
// ★关键修复★:使用 setTimeout 延迟跳转,解决 "navigateTo with an already exist webviewId" 报错
setTimeout(() => {
wx.navigateTo({
url: '/pages/login/index',
fail: (err) => {
console.error('跳转失败:', err);
this.data.isWaitingLogin = false; // 重置标记以便重试
this.data.isWaitingLogin = false;
}
});
}, 300); // 延迟 300ms 足够让页面初始化完成
}, 300);
},
handleUrlProcess: function () {
// ... (你的原有逻辑保持不变) ...
let options = this.data.cachedOptions;
// 双重检查
if (!options || !options.weburl) return;
let weburl = decodeURIComponent(options.weburl)
let webParam = {}
let baseUrl = ""
try {
@ -91,11 +84,8 @@ Page({
} catch (e) { console.log(e) }
let lowerUrl = weburl.toLowerCase()
// 此时 Token 肯定存在
let token = wx.getStorageSync('jstrip_token');
// 1. 宠你有礼
if (lowerUrl.indexOf('petyou2024') != -1 && webParam.cnylCode) {
commonApi._get("uservice/user/loginByCnyl", { cnylCode: webParam.cnylCode })
.then(res => {
@ -105,7 +95,6 @@ Page({
}
}).finally(() => { this.setUrl(weburl) })
}
// 2. 遇见昆山
else if (lowerUrl.indexOf('couponAndKs') != -1 && webParam.ksCode) {
commonApi._get("uservice/user/loginBykunshan", { code: webParam.ksCode })
.then(res => {
@ -115,9 +104,7 @@ Page({
}
}).finally(() => { this.setUrl(weburl) })
}
// 3. 君到苏州
else if (lowerUrl.indexOf('m.cloud.sz-trip.com') != -1) {
delete webParam.token
delete webParam.lon
delete webParam.lat
@ -139,13 +126,13 @@ Page({
this.handleLocationAndSetUrl(weburl, webParam, token);
}
// 4. 其他
else {
this.setUrl(weburl)
}
},
handleLocationAndSetUrl(weburl, webParam, token) {
// ... (你的原有逻辑保持不变) ...
let that = this;
try {
let lonAndLat = wx.getStorageSync('lonAndLat')
@ -180,6 +167,7 @@ Page({
},
appendLocation(url, lon, lat, webParam, token) {
// ... (你的原有逻辑保持不变) ...
if (Object.keys(webParam).length > 0 || token) {
return url + `&lon=${lon}&lat=${lat}`;
} else {
@ -188,6 +176,7 @@ Page({
},
saveLoginInfo(data) {
// ... (你的原有逻辑保持不变) ...
wx.setStorageSync("jstrip_userid", data.id)
wx.setStorageSync("jstrip_token", data.token)
wx.setStorageSync("jstrip_userInfo", data)
@ -199,20 +188,49 @@ Page({
this.setData({ webUrl: url })
},
handleMessage(data) {},
// 1. 【修改】处理 H5 传来的消息
handleMessage(e) {
console.log('接收到 H5 消息:', e.detail);
if (e.detail && e.detail.data) {
const dataArr = e.detail.data;
// 取最后一条消息(通常是最新的状态)
const lastMsg = dataArr[dataArr.length - 1];
if (lastMsg.type === 'share') {
this.setData({
shareTitle: lastMsg.title || this.data.shareTitle,
currentShareUrl: lastMsg.url,
currentShareImg: lastMsg.imgUrl || ""
});
}
}
},
loginByCode() {},
onShareAppMessage: function () {
// 2. 【修改】分享给好友
onShareAppMessage: function (options) {
// 优先使用 H5 传回来的 URL,其次使用 webViewUrl (微信自动捕获的),最后兜底使用初始 webUrl
let shareLink = this.data.currentShareUrl || options.webViewUrl || this.data.webUrl;
console.log('分享好友 URL:', shareLink);
return {
title: this.data.shareTitle,
path: `/pages/pbService/web/index?weburl=${encodeURIComponent(this.data.webUrl)}`,
path: `/pages/pbService/web/index?weburl=${encodeURIComponent(shareLink)}`,
imageUrl: this.data.currentShareImg || "" // 如果 H5 传了封面图就用,没有就默认截图
}
},
// 3. 【修改】分享到朋友圈
onShareTimeline: function () {
let shareLink = this.data.currentShareUrl || this.data.webUrl;
console.log('分享朋友圈 URL:', shareLink);
return {
title: this.data.shareTitle,
path: `/pages/pbService/web/index?weburl=${encodeURIComponent(this.data.webUrl)}`,
query: `weburl=${encodeURIComponent(shareLink)}`,
imageUrl: this.data.currentShareImg || ""
}
}
})

11
project.private.config.json

@ -6,12 +6,19 @@
"condition": {
"miniprogram": {
"list": [
{
"name": "pages/list/activitynew/index",
"pathName": "pages/list/activitynew/index",
"query": "",
"scene": null,
"launchMode": "default"
},
{
"name": "pages/info/postProductInfo/index",
"pathName": "pages/info/postProductInfo/index",
"query": "id=464726",
"scene": null,
"launchMode": "default"
"launchMode": "default",
"scene": null
},
{
"name": "pages/info/roadInfo/index",

4
utils/filter.wxs

@ -5,10 +5,10 @@ var formateRichText = function(str) {
// 处理img标签
var reg = getRegExp("<img", "g");
str = str.replace(reg, '<img class="sz-xcx-fwb-img" style="width:100%!important;height:auto!important;"');
str = str.replace(reg, '<img class="sz-xcx-fwb-img" style="width:100%!important;height:auto!important;display:block!important;"');
reg = getRegExp("<IMG", "g");
str = str.replace(reg, '<img class="sz-xcx-fwb-img" style="width:100%!important;height:auto!important;"');
str = str.replace(reg, '<img class="sz-xcx-fwb-img" style="width:100%!important;height:auto!important;display:block!important;"');
// 移除width和height属性
reg = getRegExp('width="[^"]*"', "gi");

Loading…
Cancel
Save