Browse Source

小程序开屏页

master
chenkainan 2 years ago
parent
commit
11b46caeba
  1. 2
      app.js
  2. 92
      pages/index/index.js
  3. 38
      pages/index/index.wxml
  4. 29
      pages/index/index.wxss
  5. 3
      utils/https.js

2
app.js

@ -21,7 +21,7 @@ App({
unique_key: "wechatxcx" unique_key: "wechatxcx"
}).then(res => { }).then(res => {
let data = JSON.parse(res.data); let data = JSON.parse(res.data);
data.isTest = data.isTest116? true : false; data.isTest = data.isTest117? true : false;
this.globalData.configJson = data this.globalData.configJson = data
}).then(() => { }).then(() => {
// 获取ui配置文件 // 获取ui配置文件

92
pages/index/index.js

@ -17,7 +17,9 @@ Page({
fourProduct: [], fourProduct: [],
hotIndex: 0, hotIndex: 0,
indexHot: [], indexHot: [],
area_ids: ["zhangjiagang", "changshu", "taicang", "kunshan", "wujiang", "wuzhong", "xiangcheng", "gusu", "gongyeyuanqu", "gaoxin"], area_ids: ["zhangjiagang", "changshu", "taicang", "kunshan", "wujiang", "wuzhong", "xiangcheng", "gusu",
"gongyeyuanqu", "gaoxin"
],
month: "", month: "",
months: ['JAN', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'oct', 'nov', 'dec'], months: ['JAN', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'oct', 'nov', 'dec'],
date: "", date: "",
@ -35,7 +37,9 @@ Page({
smBannerIndex: 0, smBannerIndex: 0,
indexSeason: {}, indexSeason: {},
// startList: [], // 启动页广告 // startList: [], // 启动页广告
startList: {head_img:''}, // 启动页广告 startList: {
head_img: ''
}, // 启动页广告
alertSwipeList: [], //弹窗广告 alertSwipeList: [], //弹窗广告
showAdv: false, //弹窗开关 showAdv: false, //弹窗开关
showFullAdv: true, //全屏广告开关 showFullAdv: true, //全屏广告开关
@ -58,6 +62,8 @@ Page({
'https://static.ticket.sz-trip.com/uploads/20240428/23e07551be831036116c2fedbbf7aea5.png', 'https://static.ticket.sz-trip.com/uploads/20240428/23e07551be831036116c2fedbbf7aea5.png',
], ],
viewHeight: "0px", viewHeight: "0px",
isMuted: true,
videoPlay: false,
}, },
onLoad: function(options) { onLoad: function(options) {
this.getHeight() this.getHeight()
@ -68,6 +74,22 @@ Page({
type_id: 3 type_id: 3
}).then(res => { }).then(res => {
if (res.data.length > 0) { if (res.data.length > 0) {
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({ this.setData({
showTime: true showTime: true
}) })
@ -91,18 +113,8 @@ Page({
}) })
} }
}, 1000) }, 1000)
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 { } else {
this.setData({ // 视频
startList:res.data[0]
})
} }
} else { } else {
this.setData({ this.setData({
@ -198,7 +210,11 @@ Page({
m = m < 10 ? "0" + m : m; m = m < 10 ? "0" + m : m;
s = s < 10 ? "0" + s : s; s = s < 10 ? "0" + s : s;
this.setData({ this.setData({
djs:{h:h,m:m,s:s} djs: {
h: h,
m: m,
s: s
}
}) })
return return
}, },
@ -323,6 +339,28 @@ Page({
}) })
} }
}, },
// 是否静音
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() { getWeather: function() {
commonApi._post('pbservice/Ztfw/getWeather').then(res => { commonApi._post('pbservice/Ztfw/getWeather').then(res => {
console.log(res) console.log(res)
@ -411,7 +449,8 @@ Page({
let item = e.currentTarget.dataset.item; let item = e.currentTarget.dataset.item;
if (this.data.indexHot[this.data.hotIndex].type == 'movie') { if (this.data.indexHot[this.data.hotIndex].type == 'movie') {
wx.navigateTo({ wx.navigateTo({
url: '/pages/list/movieticket/list/info/index?id=' + item.third_id + '&title=' + item.title, url: '/pages/list/movieticket/list/info/index?id=' + item.third_id + '&title=' +
item.title,
}) })
} else { } else {
util.gotoDetail(item) util.gotoDetail(item)
@ -633,12 +672,14 @@ Page({
} }
break; break;
case 3: 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) { if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) &&
item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) {
// 外部h5 // 外部h5
console.log(111, item.tdata) console.log(111, item.tdata)
app.globalData.weburl = item.tdata.url; app.globalData.weburl = item.tdata.url;
wx.navigateTo({ wx.navigateTo({
url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(item.tdata.url) url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(item.tdata
.url)
}) })
} else { } else {
let page = item.tdata.url.split("/"); let page = item.tdata.url.split("/");
@ -646,10 +687,13 @@ Page({
console.log(page[0]) console.log(page[0])
let url = this.data.urltopage[page[0]]; let url = this.data.urltopage[page[0]];
if (url && url.indexOf('map') != -1) { if (url && url.indexOf('map') != -1) {
let types = ['', 'scenic', 'venue', 'post', 'restaurant', 'relic', 'tenscenic', 'cinema', 'academes'], let types = ['', 'scenic', 'venue', 'post', 'restaurant', 'relic', 'tenscenic',
'cinema', 'academes'
],
type = page[1] ? page[1].split("=") : []; type = page[1] ? page[1].split("=") : [];
wx.reLaunch({ wx.reLaunch({
url: url + "?type=" + (type[1] ? types.findIndex(t => t == type[1]) : null) url: url + "?type=" + (type[1] ? types.findIndex(t => t == type[1]) :
null)
}) })
} else if (url) { } else if (url) {
wx.navigateTo({ wx.navigateTo({
@ -659,7 +703,8 @@ Page({
app.globalData.weburl = item.tdata.url; app.globalData.weburl = item.tdata.url;
console.log(2222, item.tdata.url, app.globalData.weburl) console.log(2222, item.tdata.url, app.globalData.weburl)
wx.navigateTo({ wx.navigateTo({
url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(item.tdata.url) url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(item
.tdata.url)
}) })
} }
} }
@ -800,7 +845,8 @@ Page({
} }
break; break;
case 3: 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) { if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) &&
item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) {
// 外部h5 // 外部h5
console.log(item.tdata) console.log(item.tdata)
app.globalData.weburl = item.tdata.url; app.globalData.weburl = item.tdata.url;
@ -813,7 +859,9 @@ Page({
console.log(page[0]) console.log(page[0])
let url = this.data.urltopage[page[0]]; let url = this.data.urltopage[page[0]];
if (url && url.indexOf('map') != -1) { if (url && url.indexOf('map') != -1) {
let types = ['', 'scenic', 'venue', 'post', 'restaurant', 'relic', 'tenscenic', 'cinema', 'academes'], let types = ['', 'scenic', 'venue', 'post', 'restaurant', 'relic', 'tenscenic',
'cinema', 'academes'
],
type = page[1] ? page[1].split("=") : []; type = page[1] ? page[1].split("=") : [];
wx.reLaunch({ wx.reLaunch({
url: url + "?type=" + (type[1] ? types.findIndex(t => t == type[1]) : null) url: url + "?type=" + (type[1] ? types.findIndex(t => t == type[1]) : null)

38
pages/index/index.wxml

@ -655,19 +655,35 @@
<image bindtap="closeAdv" style="width: 100rpx; height: 100rpx;transform: translate(200rpx,6rpx);" src="https://static.ticket.sz-trip.com/uploads/20220810/f4bb1a4f0b5eb394e6ca6e4f03aaa1e0.png"></image> <image bindtap="closeAdv" style="width: 100rpx; height: 100rpx;transform: translate(200rpx,6rpx);" src="https://static.ticket.sz-trip.com/uploads/20220810/f4bb1a4f0b5eb394e6ca6e4f03aaa1e0.png"></image>
</view> </view>
<!-- 广告弹窗结束 --> <!-- 广告弹窗结束 -->
<view class="fullavd" wx:if="{{showFullAdv}}" style="opacity: {{opacity}}"> <view class="fullavd" wx:if="{{showFullAdv && startList.head_img}}" style="opacity: {{opacity}}">
<view class="time" bindtap="closeFullAdv" wx:if="{{showTime}}">{{time}}s跳过</view> <view class="time" bindtap="closeFullAdv" wx:if="{{showTime && startList.media_type}}">{{time}}s跳过</view>
<!-- <view class="Qtop" style="height:{{viewHeight}}"> --> <view class="Qtop" style="min-height:100vh" wx:if="{{showTime && startList.media_type}}">
<view class="Qtop" style="min-height:100vh">
<image src="{{startList.head_img}}" mode="widthFix" style="width: 100%;height: 100%;"></image> <image src="{{startList.head_img}}" mode="widthFix" style="width: 100%;height: 100%;"></image>
</view> </view>
<!-- <swiper class="fullsp" autoplay="{{true}}" interval="{{3000}}" duration="{{300}}" indicator-active-color="white">
<block wx:for="{{startList}}" wx:key="*this"> <!-- 视频 -->
<swiper-item data-item="{{item}}" bindtap="bannerJumpNew" > <view style="width:100vw;height: 100vh;position: relative;" wx:if="{{!startList.media_type}}">
<image src="{{item.head_img}}" style="width: 100%;height: 100%;" mode="widthFix"></image> <video
</swiper-item> style="width:100vw;height:100vh;display:block;"
</block> id="myVideo"
</swiper> --> src="{{startList.head_img}}"
show-center-play-btn="{{false}}"
show-play-btn="{{true}}"
autoplay
controls="{{false}}"
bindended="videoend"
loop="{{true}}"
muted="{{isMuted}}"
object-fit="fill"
></video>
<!-- <image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/startPage/mute.png" class="muteImg" mode="widthFix" wx:if="{{isMuted}}" bindtap="closeMuted"></image> -->
<!-- <image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/startPage/sound.png" class="muteImg" mode="widthFix" wx:else bindtap="closeMuted"></image> -->
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/startPage/logo.png" class="logoImg" mode="widthFix"></image>
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/startPage/btn.png" class="btnImg" mode="widthFix" bindtap="closeFullAdv"></image>
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/startPage/play.png" class="playImg" mode="widthFix" wx:if="{{videoPlay}}" bindtap="videoPlay"></image>
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/startPage/pause.png" class="playImg" mode="widthFix" wx:else bindtap="videoPause"></image>
</view>
</view> </view>
<!-- <view class="topBox"> <!-- <view class="topBox">
<view class="Qtop" :style="{height:height}"> <view class="Qtop" :style="{height:height}">

29
pages/index/index.wxss

@ -1145,3 +1145,32 @@ page {
.time{ .time{
padding-right: 10rpx; padding-right: 10rpx;
} }
.muteImg {
width: 62rpx;
height: 62rpx;
position: absolute;
top: 194rpx;
right: 38rpx;
}
.logoImg {
width: 464.67rpx;
height: 342.67rpx;
position: absolute;
top: 406rpx;
left: 142rpx;
}
.btnImg {
width: 296.67rpx;
height: 79.33rpx;
position: absolute;
left: 226rpx;
bottom: 208rpx;
}
.playImg {
position: absolute;
width: 31.33rpx;
height: 38rpx;
left: 56.67rpx;
bottom: 64rpx;
}

3
utils/https.js

@ -7,7 +7,8 @@ const env = wx.getAccountInfoSync().miniProgram.envVersion
if (env == 'develop1') { if (env == 'develop1') {
baseUrl = "https://test.api.cloud.sz-trip.com/api/" baseUrl = "https://test.api.cloud.sz-trip.com/api/"
} else { } else {
baseUrl = "https://api.cloud.sz-trip.com/api/"; // baseUrl = "https://api.cloud.sz-trip.com/api/";
// baseUrl = "https://test.api.cloud.sz-trip.com/api/"
} }
const orders = ['', 'weight', 'distance', 'sale_number', 'sale_price', 'price']; const orders = ['', 'weight', 'distance', 'sale_number', 'sale_price', 'price'];
//封装GET请求 //封装GET请求

Loading…
Cancel
Save