You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

808 lines
22 KiB

//index.js
//获取应用实例
let app = getApp()
import commonApi from "../../utils/https/common"
import userApi from "../../utils/https/user"
import util from "../../utils/util"
Page({
data: {
fullAdvTimer: null, // 全屏timer
banner: [],
xiaobanner: [],
height: 0,
padHeight: 0,
right: 0,
weather: null,
month: "",
months: ['JAN', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'oct', 'nov', 'dec'],
date: "",
list: [],
listMore: true,
isTest: false,
lat: "",
lon: "",
urltopage: {},
scrollLeft: 0,
videoPrize: false,
prizeInfo: null,
otherPlat: null,
activeBannerIndex: 5,
smBannerIndex: 0,
indexSeason: {},
// startList: [], // 启动页广告
startList: {
head_img: ''
}, // 启动页广告
alertSwipeList: [], //弹窗广告
showAdv: false, //弹窗开关
showFullAdv: true, //全屏广告开关
opacity: 1,
time: 3, //全屏广告剩余时间
showTime: false,
viewHeight: "0px",
isMuted: true,
videoPlay: false,
hdrlNavList:[
{
type:null,
title:'全部'
},
{
type:'scene',
title:'景区活动'
},
{
type:'show',
title:'演出'
},
{
type:'exhibition',
title:'展览'
},
{
type:'movie',
title:'电影'
},
{
type:'other',
title:'其他'
}
], //活动日历板块导航分类
hdrlNavIndex:0,//活动日历默认选中第一个全部分类
today:null,
hdrlList:[],
yszNav:['公共服务','旅游助手'],
yszIndex:0,
bdList:[
{
color: '#FFE4BC',
bg: 'linear-gradient(172deg, #F08528, #D1201B);',
icon:'https://static.ticket.sz-trip.com/uploads/20250429/069ab247bb2ab5a08fa7707d671b1ac5.png', //游 景点
url:'',
path:'/pages/list/scene/index',
list: [],
},
{
color: '#DBD8F6',
bg: 'linear-gradient(172deg, #A49CE9, #353A68);',
icon:'https://static.ticket.sz-trip.com/uploads/20250429/8c023b9c626d3821b64d105ae6e65f2d.png', //非玩不可 景点产品
// path:'/pages/list/night/index',
url:'https://m.cloud.sz-trip.com/nightTour2025',
path: '',
list: [],
},
{
color: '#FFE4BC',
bg: 'linear-gradient(172deg, #F08528, #D1201B);',
icon:'https://static.ticket.sz-trip.com/uploads/20250429/9928f46523fd57233b6ef3371a6ba460.png', //非看不可
url:'',
path:'/pages/list/theatre/index',
list: [],
},
{
color: '#DBD8F6',
bg: 'linear-gradient(172deg, #A49CE9, #353A68);',
icon:'https://static.ticket.sz-trip.com/uploads/20250429/a4f53072aa51a387593a183799b902e6.png', //非买不可
path:'/subPackages/techanNew/index',
url:'',
list: [],
},
],
nowDate: [('0' + (new Date().getMonth() + 1)).slice(-2) , ('0' + new Date().getDate()).slice(-2)],
isMayDay: new Date().getTime()>new Date('2025/05/01 00:00:00').getTime()
},
onLoad: function(options) {
//全屏广告
let _this = this
commonApi._post("adv/getAdv", {
position: 2,
type_id: 3
}).then(res => {
if (res.data.length > 0) {
wx.hideTabBar() //这里隐藏了底部导航栏
let length = res.data.length
if (res.data.length > 1) {
let num = Math.floor(Math.random() * length);
console.log('num', num);
this.setData({
startList: res.data[num]
})
console.log(this.data.startList.head_img);
} else {
this.setData({
startList: res.data[0]
})
}
// 图片
if (this.data.startList.media_type) {
this.setData({
showTime: true
})
this.data.fullAdvTimer = setInterval(() => {
_this.data.time-=0.5
if (Number.isInteger(_this.data.time)) {
_this.setData({time: _this.data.time})
}
if (_this.data.time <= 0) {
// 可以css 优化
_this.setData({opacity: 0})
}
if (_this.data.time <= -1) {
clearInterval(_this.data.fullAdvTimer)
wx.showTabBar() //倒计时结束清除定时器显示导航栏
_this.setData({showFullAdv: false})
}
}, 500)
} else {
// 视频
}
} else {
this.setData({
showFullAdv: false
})
}
})
if (options.from) {
app.globalData.from = options.from;
}
this.getHeight()
// 获取今天的日期
let today = new Date();
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({
month: (this.data.months[today.getMonth()]).toUpperCase(),
date: today.getDate(),
today: d.getFullYear() + "-" + month + "-" + day
})
},
gobdDetail(e) {
let item = e.currentTarget.dataset.item
util.gotoDetail(item)
},
getList() {
let bdList = this.data.bdList
// 游--景点
commonApi._post("scene/get_scene_by_tag",{
tag_id:"4",
limit:6,
lon:this.data.lon,
lat:this.data.lat,
offset:0,
sort:"weight",
title:'',
area_id:''
}).then(res=>{
console.log('景点', res)
res.data.list.map(item => {
if (item.distance || item.distance == 0) {
if (item.distance >= 1000) {
item.distance = (item.distance / 1000).toFixed(2) + 'km';
} else {
item.distance = (item.distance).toFixed(2) + 'm';
}
}
})
bdList[0].list = res.data.list
this.setData({
bdList: bdList
})
})
// 非买不可--文创
commonApi._post('product/get_product_by_tag_subject',{
offset: 0,
limit: 6,
tag_id: 60,
}).then(res=>{
bdList[3].list = res.data.list
this.setData({
bdList: bdList
})
})
// 非玩不可--线路一日游
commonApi._post('product/get_product_by_tag_subject',{
tag_id: "58",
offset: 0,
limit: 6,
}).then(res=>{
bdList[1].list = res.data.list
this.setData({
bdList: bdList
})
})
// 非看不可--剧场演出
commonApi._post("product/get_product_by_tag_subject",{
tag_id:"59",
offset:0,
limit:6,
}).then(res=>{
bdList[2].list = res.data.list
this.setData({
bdList: bdList
})
})
},
goDetail(e) {
let item = e.currentTarget.dataset.item;
let type = this.data.hdrlNavList[this.data.hdrlNavIndex].type
if (type == 'movie') {
// wx.navigateTo({
// // url: '/pages/list/movieticket/list/info/index?id=' + item.third_id
// })
util.goMovieDetail(item.third_id || item.id)
}else {
wx.navigateTo({
url: '/pages/info/activityInfo/index?id=' + item.id,
})
}
},
// 分类为电影时调这个接口
getMovieList() {
let service = "Cinema/getHotChannelMovieList";
let data = {
page: 1,
pageSize: 5
};
commonApi._post(service, data).then(res => {
console.log(res.data);
this.setData({
hdrlList: res.data
})
})
console.log(this.data.hdrlList);
},
// 推荐榜单更多跳转
moreBtn(e) {
console.log(e)
let item = e.currentTarget.dataset.item
if (item.path!='') {
wx.navigateTo({
url: item.path,
})
} else {
// if (e.currentTarget.dataset.event) {
// this.pagePoint({
// event: e.currentTarget.dataset.event
// }, 1)
// }
console.log('error', item)
let url = item.url;
app.globalData.weburl = url;
wx.navigateTo({
url: '/pages/pbService/web/index?weburl=' + encodeURIComponent(url),
})
}
},
// 活动日历下的列表
getHdrlList() {
commonApi._post('pbservice/Actcalendar/getActList', {
page_no: 1,
date: this.data.today,
category: this.data.hdrlNavList[this.data.hdrlNavIndex].type,
keywords: '',
area_key: '',
lat: this.data.lat,
lon: this.data.lon,
page_num: 5
}).then(res => {
res.data.rows.forEach(v=>{
if (!v.post_url) {
v.post_url = "https://static.ticket.sz-trip.com/uploads/20240909/c9a0029cc9426d2a17f1dbbb7a179762.jpg"
}
})
this.setData({
hdrlList:res.data.rows
})
})
},
// 切换活动日历分类
changeHdrlNav(e) {
console.log(e.currentTarget.dataset);
this.setData({
hdrlList:[],
hdrlNavIndex:e.currentTarget.dataset.index,
})
if (this.data.hdrlNavIndex == 4) {
this.getMovieList()
} else {
this.getHdrlList() //切换分类重新获取活动日历列表
}
},
// 游苏州下的公共服务和旅游助手切换
changeType(e) {
this.setData({
yszIndex:e.currentTarget.dataset.index,
})
},
xlzs: function (e) {
wx.navigateToMiniProgram({
appId: 'wx757dd1ee184e75e9',
page: "pages/tabBar/index/index"
})
},
// 获取导航栏项目标题高度
getHeight() {
let that = this
let systemInfo = wx.getStorageSync('systemInfo'),rect = wx.getMenuButtonBoundingClientRect();
if (!systemInfo) {systemInfo = wx.getSystemInfoSync()}
if (!rect) {rect = wx.getMenuButtonBoundingClientRect()}
let height = (rect.top - systemInfo.statusBarHeight) * 2 + rect.height;
that.setData({
viewHeight: systemInfo.windowHeight + 'px',
height: height,
padHeight: systemInfo.statusBarHeight,
right: (systemInfo.screenWidth - rect.right) + rect.width
})
},
// 大轮播的监听方法
changeBannerIndex: function(e) {
this.setData({
activeBannerIndex: e.detail.current
})
},
// 小轮播监听方法
changeSmBannerIndex: function(e) {
this.setData({
smBannerIndex: e.detail.current
})
},
getBanner: function() {
commonApi._post("adv/getAdv", {
position: 0,
type_id: 3
}).then(res => {
this.setData({
banner: res.data || []
})
})
commonApi._post("adv/getAdv", {
position: 1,
type_id: 3
}).then(res => {
this.setData({
xiaobanner: res.data || []
})
})
//弹窗广告
commonApi._post("adv/getAdv", {
position: 3,
type_id: 3
}).then(res => {
if (res.data.length > 0) {
this.setData({
alertSwipeList: res.data || [],
showAdv: true
})
} else if (!this.data.showFullAdv) {
wx.showTabBar({
animation: true,
})
}
})
},
//获取季节配置
getIndexSeason() {
if (app.globalData.configJson.indexSeason) {
this.setData({
isTest: app.globalData.configJson.isTest,
otherPlat: app.globalData.configJson.otherPlats,
indexSeason: app.globalData.configJson.indexSeason
})
} else {
commonApi._post("adv/get_home_ui", {type_id: 3}).then(res => {
let obj = {}
res.data.content.forEach(item => {
obj[item.id] = item.image
});
app.globalData.configJson.indexSeason = obj
app.globalData.loadIndexSeason = true
this.setData({
isTest: app.globalData.configJson.isTest,
otherPlat: app.globalData.configJson.otherPlats,
indexSeason: app.globalData.configJson.indexSeason
})
})
}
},
//关闭弹窗广告
closeAdv: function() {
this.setData({
showAdv: false
})
wx.showTabBar({
animation: true,
})
},
//关闭全屏广告
closeFullAdv: function() {
this.setData({
showFullAdv: false
})
clearInterval(this.data.fullAdvTimer)
if (!this.data.alertSwipeList.length > 0) {
wx.showTabBar({
animation: true,
})
}
},
// 是否静音
closeMuted: function() {
this.setData({
isMuted: this.data.isMuted = !this.data.isMuted
})
},
// 播放视频
videoPlay: function() {
let videoplay = wx.createVideoContext('myVideo', this)
videoplay.play();
this.setData({
videoPlay: false
})
},
// 暂停视频
videoPause: function() {
let videoplay = wx.createVideoContext('myVideo', this)
videoplay.pause();
this.setData({
videoPlay: true
})
},
getWeather: function() {
commonApi._post('pbservice/Ztfw/getWeather').then(res => {
console.log(res)
this.setData({
weather: res.data
})
})
},
gotoPath: function(e) {
console.log(e)
if (e.currentTarget.dataset.title == '书香借阅') {
wx.navigateToMiniProgram({
appId: 'wx165d4f1727f6bdb0',
path: 'pages/home/home'
})
return;
} else if (e.currentTarget.dataset.title == '12348') {
wx.navigateToMiniProgram({
appId: 'wxcdfd45c001466ba3',
path: 'pages/index/index'
})
return;
} else if (e.currentTarget.dataset.event == 'wuzhong_click') {
wx.navigateToMiniProgram({
appId: 'wxdd39069b9a91dbfe',
path: 'pages/index/index'
})
return;
} else if (e.currentTarget.dataset.event == 'kunshan_click') {
wx.navigateToMiniProgram({
appId: 'wx8888a3fd0862b4c8',
path: 'pages/index/index'
})
return;
} else if (e.currentTarget.dataset.event == 'taicang_click') {
wx.navigateToMiniProgram({
appId: 'wx8853b0d93cbca75e',
path: 'pages/home/home'
})
return;
} else if (e.currentTarget.dataset.event == 'changshu_click') {
wx.navigateToMiniProgram({
appId: 'wx4df5fd9a6a5ea123',
path: 'pages/index'
})
return;
} else if (e.currentTarget.dataset.event == 'gongyeyuanqu_click') {
wx.navigateToMiniProgram({
appId: 'wxd323e63a10aa6865',
path: 'pages/home/index'
})
return;
} else if (e.currentTarget.dataset.event == 'wujiang_click') {
wx.navigateToMiniProgram({
appId: 'wx8eadea4ee2d42d4b',
path: 'pages/index/index'
})
return;
}
wx.navigateTo({
url: e.currentTarget.dataset.path,
})
if (e.currentTarget.dataset.title) {
commonApi._post("browse/burying_point", {
uuid: app.globalData.uuid,
drive: "mini",
title: e.currentTarget.dataset.title
}).then(res => {
})
}
},
gotoUrl: function(e) {
console.log(e)
if (e.currentTarget.dataset.event) {
this.pagePoint({
event: e.currentTarget.dataset.event
}, 1)
}
let url = e.currentTarget.dataset.url;
app.globalData.weburl = url;
wx.navigateTo({
// url: '/pages/pbService/web/index?weburl='+encodeURIComponent('https://m.cloud.sz-trip.com/Cloudperform2022'),
url: '/pages/pbService/web/index?weburl=' + encodeURIComponent(url),
})
},
// 实时路况跳转外链
gotoUrls() {
// 判断是否登录
var token = wx.getStorageSync("jstrip_token"), userId = wx.getStorageSync("jstrip_userid");
if(!token || !userId) {
let url = 'https://wlsjzx.zdhxwl.cn/kt_h5/index.html'
app.globalData.weburl = url;
wx.navigateTo({
url: '/pages/pbService/web/index?weburl=' + encodeURIComponent(url),
})
}else {
commonApi.user_post("uservice/user/userEncry").then(res => {
if(res.code == 1) {
let url = 'https://wlsjzx.zdhxwl.cn/kt_h5/index.html?userEncry=' + res.data
app.globalData.weburl = url;
wx.navigateTo({
url: '/pages/pbService/web/index?weburl=' + encodeURIComponent(url),
})
}
})
}
},
gotoMini: function(e) {
let appid = e.currentTarget.dataset.appid,
path = e.currentTarget.dataset.path
wx.navigateToMiniProgram({
appId: appid,
path: path
})
},
audioGuide: function() {
wx.navigateToMiniProgram({
appId: 'wx74f380bc721a0379',
path: '/pages/listen/listen?title=君到苏州'
})
commonApi._post("browse/burying_point", {
drive: "mini",
title: "语音导览",
uuid: app.globalData.uuid
}).then(res => {
})
},
onReachBottom: function() {
},
gotoDetail: function(e) {
let item = e.currentTarget.dataset.item;
util.pagePoint({
event: 'recommend_click',
param: {
id: item.id,
type: item.type
}
}, 1)
if (item.type == 'travels') {
// 游记做特殊处理 其他都按照原来的来
wx.navigateTo({
url: '/pages/info/strategyInfo/index?id=' + item.s_id,
})
} else {
util.gotoDetail(item.ext);
}
},
// 轮播图点击
bannerClick: function(e) {
if (this.data.isTest) return;
let item = e.currentTarget.dataset.item;
this.pagePoint({
event: "banner_click",
type: 'banner'
}, 1)
switch (item.jump_type) {
case 0:
break;
case 1:
util.gotoDetail(item.product_model)
break;
case 2:
if (item.front_model && item.front_model.mini) {
wx.navigateTo({
url: "/" + item.front_model.mini
})
}
break;
case 3:
if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) &&
item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) {
// 外部h5
console.log(111, item.tdata)
app.globalData.weburl = item.tdata.url;
wx.navigateTo({
url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(item.tdata
.url)
})
} else {
let page = item.tdata.url.split("/");
page = page[page.length - 1].split("?")
console.log(page[0])
let url = this.data.urltopage[page[0]];
if (url && url.indexOf('map') != -1) {
let types = ['', 'scenic', 'venue', 'post', 'restaurant', 'relic', 'tenscenic',
'cinema', 'academes'
],
type = page[1] ? page[1].split("=") : [];
wx.reLaunch({
url: url + "?type=" + (type[1] ? types.findIndex(t => t == type[1]) :
null)
})
} else if (url) {
wx.navigateTo({
url: url,
})
} else {
app.globalData.weburl = item.tdata.url;
console.log(2222, item.tdata.url, app.globalData.weburl)
wx.navigateTo({
url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(item
.tdata.url)
})
}
}
break;
case 4:
if (item.tdata.appid == 'wxe5ca0f71e918e352' && wx.getStorageSync('jstrip_userid')) {
// 如果是苏心游的小程序 直接把authCode带过去
userApi.user_post("user/getJumpThirdAppCode", {}).then(res => {
let weburl = item.tdata.page
if (weburl.indexOf('?') != -1) {
weburl += '&authCode=' + res.data;
} else {
weburl += '?authCode=' + res.data
}
wx.navigateToMiniProgram({
appId: item.tdata.appid,
path: weburl
})
}).catch(err => {
wx.navigateToMiniProgram({
appId: item.tdata.appid,
path: item.tdata.page
})
})
} else {
wx.navigateToMiniProgram({
appId: item.tdata.appid,
path: item.tdata.page
})
}
break;
default:
break;
}
return;
},
//博物馆跳转 直接跳君到苏州H5
goH5: function(e) {
console.log(e.currentTarget.dataset.path);
let weburl = 'https://m.cloud.sz-trip.com/' + e.currentTarget.dataset.path;
// app.globalData.weburl ='https://m.cloud.sz-trip.com/' + e.currentTarget.dataset.path;
wx.navigateTo({
// url: "/pages/pbService/web/index"
url: '/pages/pbService/web/index?weburl=' + encodeURIComponent(weburl),
})
},
// 监听文旅查询的scroll
listenScroll(e) {
this.setData({
scrollLeft: e.detail.scrollLeft
})
},
onReady: function() {
wx.getLocation({
type: 'gcj02',
success: (res) => {
this.setData({
lat: res.latitude,
lon: res.longitude
})
this.getList()
this.getHdrlList()
let tempData = JSON.stringify({lat: res.latitude,lon: res.longitude})
wx.setStorageSync('lonAndLat', tempData)
},
fail: (err) => {
this.getList()
this.getHdrlList()
}
})
commonApi._post("pbservice/Other/getClientConfig", {
unique_key: "urltopage"
}).then(res => {
let data = JSON.parse(res.data)
this.data.urltopage = data
})
this.getBanner()
this.getWeather()
this.getIndexSeason()
},
pagePoint: function(e, type) {
util.pagePoint(e, type)
},
onShow: function() {
// this.getIndexSeason()
this.pagePoint({
event: 'home_view'
}, 1)
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
onShareTimeline: function() {
return {
title: '君到苏州(文化旅游总入口)',
query: '',
imageUrl: 'https://static.ticket.sz-trip.com/xcxImages/zwt/logo.png'
}
}
})