|
|
|
|
//index.js
|
|
|
|
|
//获取应用实例
|
|
|
|
|
let app = getApp()
|
|
|
|
|
import commonApi from "../../utils/https/common"
|
|
|
|
|
import userApi from "../../utils/https/user"
|
|
|
|
|
import util from "../../utils/util"
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
banner:[],
|
|
|
|
|
xiaobanner:[],
|
|
|
|
|
height:0,
|
|
|
|
|
padHeight:0,
|
|
|
|
|
right:0,
|
|
|
|
|
weather:null,
|
|
|
|
|
saleProduct:null,
|
|
|
|
|
roadProduct:null,
|
|
|
|
|
fourProduct:[],
|
|
|
|
|
hotIndex:0,
|
|
|
|
|
indexHot:[],
|
|
|
|
|
area_ids:["zhangjiagang","changshu","taicang","kunshan","wujiang","wuzhong","xiangcheng","gusu","gongyeyuanqu","gaoxin"],
|
|
|
|
|
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
|
|
|
|
|
},
|
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
if(options.from){
|
|
|
|
|
app.globalData.from = options.from;
|
|
|
|
|
}
|
|
|
|
|
let systemInfo = wx.getSystemInfoSync(),rect = wx.getMenuButtonBoundingClientRect();
|
|
|
|
|
let height = (rect.top - systemInfo.statusBarHeight) * 2 + rect.height;
|
|
|
|
|
wx.getLocation({
|
|
|
|
|
type: 'gcj02',
|
|
|
|
|
success:(res)=>{
|
|
|
|
|
this.setData({
|
|
|
|
|
lat:res.latitude,
|
|
|
|
|
lon:res.longitude
|
|
|
|
|
})
|
|
|
|
|
this.getList()
|
|
|
|
|
},
|
|
|
|
|
fail:(err)=>{
|
|
|
|
|
this.getList()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
height:height,
|
|
|
|
|
padHeight:systemInfo.statusBarHeight,
|
|
|
|
|
right:(systemInfo.screenWidth - rect.right) + rect.width
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
commonApi._post("pbservice/Other/getClientConfig",{
|
|
|
|
|
unique_key:"urltopage"
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
let data = JSON.parse(res.data)
|
|
|
|
|
this.setData({
|
|
|
|
|
urltopage:data
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
this.getTwoProduct()
|
|
|
|
|
this.getBanner()
|
|
|
|
|
this.getWeather()
|
|
|
|
|
// 获取今天的日期
|
|
|
|
|
let today = new Date();
|
|
|
|
|
this.setData({
|
|
|
|
|
month:(this.data.months[today.getMonth()]).toUpperCase(),
|
|
|
|
|
date:today.getDate()
|
|
|
|
|
})
|
|
|
|
|
this.getVideoPrize()
|
|
|
|
|
},
|
|
|
|
|
onTabItemTap:function(e){
|
|
|
|
|
console.log(e,99999999)
|
|
|
|
|
},
|
|
|
|
|
// 一城百馆
|
|
|
|
|
city:function(){
|
|
|
|
|
wx.navigateToMiniProgram({
|
|
|
|
|
appId: 'wx114d514f39cb1fed',
|
|
|
|
|
path:"pages/entry/index"
|
|
|
|
|
})
|
|
|
|
|
commonApi._post("browse/burying_point",{
|
|
|
|
|
drive:"mini",
|
|
|
|
|
title:"一城百馆",
|
|
|
|
|
uuid:app.globalData.uuid
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
changeHotIndex:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
hotIndex:e.currentTarget.dataset.index,
|
|
|
|
|
fourProduct:[]
|
|
|
|
|
})
|
|
|
|
|
this.getFourProduct()
|
|
|
|
|
},
|
|
|
|
|
getBanner:function(){
|
|
|
|
|
// commonApi._post("adv/getAdvByKey",{
|
|
|
|
|
// key:"xcxBanner"
|
|
|
|
|
// }).then(res=>{
|
|
|
|
|
// console.log(res)
|
|
|
|
|
// this.setData({
|
|
|
|
|
// banner:res.data.content || []
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// commonApi._post("adv/getAdvByKey",{
|
|
|
|
|
// key:"xiaobanner"
|
|
|
|
|
// }).then(res=>{
|
|
|
|
|
// this.setData({
|
|
|
|
|
// xiaobanner:res.data.content || []
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// return;
|
|
|
|
|
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 || []
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getWeather:function(){
|
|
|
|
|
commonApi._post('pbservice/Ztfw/getWeather').then(res=>{
|
|
|
|
|
console.log(res)
|
|
|
|
|
this.setData({
|
|
|
|
|
weather:res.data
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
saleDetail:function(){
|
|
|
|
|
},
|
|
|
|
|
getTwoProduct:function(){
|
|
|
|
|
// 获取首页限时特惠
|
|
|
|
|
commonApi._post('act/fast_sale_now',{
|
|
|
|
|
offset:0,
|
|
|
|
|
limit:1
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
if(res.data[0] && res.data[0].fast_sales_sku[0]){
|
|
|
|
|
if(res.data[0].fast_sales_sku.length > 0){
|
|
|
|
|
let price = res.data[0].fast_sales_sku[0].price
|
|
|
|
|
let data = res.data[0].fast_sales_sku[0]
|
|
|
|
|
for (let item of res.data[0].fast_sales_sku){
|
|
|
|
|
if (price > item.price) price = item.price
|
|
|
|
|
}
|
|
|
|
|
data.price = price
|
|
|
|
|
this.setData({
|
|
|
|
|
saleProduct:data
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.setData({
|
|
|
|
|
saleProduct:res.data[0].fast_sales_sku[0]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
commonApi._post("product/get_product_by_tag",{
|
|
|
|
|
tag_id:17,
|
|
|
|
|
offset:0,
|
|
|
|
|
limit:1,
|
|
|
|
|
sort: 'price',
|
|
|
|
|
order: 'asc'
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
if(res.data.list.length > 0){
|
|
|
|
|
let price = res.data.list[0].price
|
|
|
|
|
for(let item of res.data.list ){
|
|
|
|
|
if(item.price > price){
|
|
|
|
|
price = item.price
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let data = res.data.list[0]
|
|
|
|
|
data.price = price
|
|
|
|
|
this.setData({
|
|
|
|
|
roadProduct:data
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.setData({
|
|
|
|
|
roadProduct:[111]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getFourProduct:function(){
|
|
|
|
|
let item = this.data.indexHot[this.data.hotIndex],service="product/get_product_by_tag",data={
|
|
|
|
|
tag_id:item.id,
|
|
|
|
|
offset:0,
|
|
|
|
|
limit:4,
|
|
|
|
|
sort:'weight',
|
|
|
|
|
order:'desc'
|
|
|
|
|
};
|
|
|
|
|
if(item.type=='scene'){
|
|
|
|
|
service="scene/get_scene_by_tag";
|
|
|
|
|
}
|
|
|
|
|
else if(item.type=='movie'){
|
|
|
|
|
service="Cinema/getHotMovieList";
|
|
|
|
|
data = {
|
|
|
|
|
page:1,
|
|
|
|
|
pageSize:4
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
commonApi._post(service,data).then(res=>{
|
|
|
|
|
this.setData({
|
|
|
|
|
fourProduct:res.data.list || res.data
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
tagGotoDetail:function(e){
|
|
|
|
|
let item = e.currentTarget.dataset.item;
|
|
|
|
|
if(this.data.indexHot[this.data.hotIndex].type=='movie'){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/list/movieticket/list/info/index?id='+item.third_id+'&title='+item.title,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
util.gotoDetail(item)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
productGotoDetail:function(e){
|
|
|
|
|
let item = e.currentTarget.dataset.item;
|
|
|
|
|
util.gotoDetail(item)
|
|
|
|
|
},
|
|
|
|
|
gotoPath:function(e){
|
|
|
|
|
if(e.currentTarget.dataset.title=='书香借阅'){
|
|
|
|
|
wx.navigateToMiniProgram({
|
|
|
|
|
appId: 'wx165d4f1727f6bdb0',
|
|
|
|
|
path:'pages/home/home'
|
|
|
|
|
})
|
|
|
|
|
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){
|
|
|
|
|
let url = e.currentTarget.dataset.url;
|
|
|
|
|
app.globalData.weburl = url;
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url:"/pages/pbService/web/index"
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
garbage:function(){
|
|
|
|
|
wx.navigateToMiniProgram({
|
|
|
|
|
appId: 'wx13be821f3b1afed3',
|
|
|
|
|
path:'pages/home/home'
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
gotoSku:function(){
|
|
|
|
|
commonApi.user_post("pbservice/Ztfw/sukangCode").then(res=>{
|
|
|
|
|
console.log(res)
|
|
|
|
|
app.globalData.weburl = res.data.url;
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/pbService/web/index'
|
|
|
|
|
})
|
|
|
|
|
return;
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
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=>{
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 热门推荐
|
|
|
|
|
getList:function(){
|
|
|
|
|
if(!this.data.listMore) return;
|
|
|
|
|
commonApi._post("search/recommend",{
|
|
|
|
|
offset:this.data.list.length,
|
|
|
|
|
limit:16,
|
|
|
|
|
lon:this.data.lon,
|
|
|
|
|
lat:this.data.lat
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
res.data.map(item=>{
|
|
|
|
|
if(item.ext.display_tags){
|
|
|
|
|
item.ext.display_tags = item.ext.display_tags.split(",").splice(0,2)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
item.ext.display_tags = []
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if(res.data.length<15) {
|
|
|
|
|
this.setData({
|
|
|
|
|
listMore:false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
list:this.data.list.concat(res.data)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onReachBottom:function(){
|
|
|
|
|
// this.getList()
|
|
|
|
|
},
|
|
|
|
|
gotoDetail:function(e){
|
|
|
|
|
let item = e.currentTarget.dataset.item;
|
|
|
|
|
if(item.type=='travels'){
|
|
|
|
|
// 游记做特殊处理 其他都按照原来的来
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/info/strategyInfo/index?id='+item.s_id,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
util.gotoDetail(item.ext);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
meituan:function(){
|
|
|
|
|
wx.navigateToMiniProgram({
|
|
|
|
|
appId: 'wxde8ac0a21135c07d',
|
|
|
|
|
path:"hotel/pages/h5/index?q=https%3A%2F%2Ffenxiao.meituan.com%2Fopdtor%2Fh5%2Fhotel%2Fsearch%3FpartnerId%3D16829"
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 轮播图点击
|
|
|
|
|
bannerClick:function(e){
|
|
|
|
|
let item = e.currentTarget.dataset.item;
|
|
|
|
|
console.log(item)
|
|
|
|
|
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.indexOf('http://')!=-1 || item.tdata.indexOf('https://')!=-1) && item.tdata.indexOf('m.cloud.sz-trip.com')==-1){
|
|
|
|
|
// 外部h5
|
|
|
|
|
console.log(item.tdata)
|
|
|
|
|
app.globalData.weburl = item.tdata;
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url:"/pages/pbService/web/index"
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let page = item.tdata.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;
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url:"/pages/pbService/web/index"
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
bannerClick2:function(e){
|
|
|
|
|
let item = e.currentTarget.dataset.item;
|
|
|
|
|
if(item.action=='href'){
|
|
|
|
|
if(item.href.indexOf(",")!=-1){
|
|
|
|
|
let info = item.href.split(",");
|
|
|
|
|
wx.navigateToMiniProgram({
|
|
|
|
|
appId: info[0],
|
|
|
|
|
path:info[1]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else if(item.href.indexOf('map/index')!=-1){
|
|
|
|
|
wx.reLaunch({
|
|
|
|
|
url: item.href
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: item.href,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(item.action=="web"){
|
|
|
|
|
app.globalData.weburl = item.href;
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: "/pages/pbService/web/index",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 监听文旅查询的scroll
|
|
|
|
|
listenScroll(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
scrollLeft:e.detail.scrollLeft
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 获取短视频大赛是否中奖 中奖详情
|
|
|
|
|
getVideoPrize(){
|
|
|
|
|
let user_id = wx.getStorageSync('jstrip_userid');
|
|
|
|
|
if(!user_id || wx.getStorageSync('indexPriceNoTip')) return;
|
|
|
|
|
commonApi.user_post('actonline/video_act/getRaffle',{
|
|
|
|
|
act_id:5
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
this.setData({
|
|
|
|
|
videoPrize:res.data
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
noMoreTip(){
|
|
|
|
|
wx.setStorageSync('indexPriceNoTip', true)
|
|
|
|
|
this.closePrice()
|
|
|
|
|
},
|
|
|
|
|
closePrice(){
|
|
|
|
|
this.setData({
|
|
|
|
|
videoPrize:false,
|
|
|
|
|
prizeInfo:null
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 抽奖
|
|
|
|
|
choosePrize(){
|
|
|
|
|
commonApi.user_post('actonline/video_act/luckyDraw',{
|
|
|
|
|
act_id:5
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
this.setData({
|
|
|
|
|
prizeInfo:res.data
|
|
|
|
|
})
|
|
|
|
|
if(res.data.type!='none'){
|
|
|
|
|
// 抽奖成功的话 弹框
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title:"提示",
|
|
|
|
|
content:"中奖人员请联系君到苏州客服,领奖方式以客服通知为准",
|
|
|
|
|
showCancel:false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onReady:function(){
|
|
|
|
|
if(app.globalData.configJson){
|
|
|
|
|
this.setData({
|
|
|
|
|
indexHot:app.globalData.configJson.indexHot,
|
|
|
|
|
isTest:app.globalData.configJson.isTest
|
|
|
|
|
})
|
|
|
|
|
this.getFourProduct()
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.onReady()
|
|
|
|
|
},300)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|