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.
147 lines
3.6 KiB
147 lines
3.6 KiB
|
1 year ago
|
// pages/component/TitleHeader.js
|
||
|
|
import commonApi from "../../../utils/https/common.js"
|
||
|
|
import util from '../../../utils/util'
|
||
|
|
var app = getApp()
|
||
|
|
Component({
|
||
|
|
options: {
|
||
|
|
styleIsolation: 'apply-shared',
|
||
|
|
addGlobalClass: true
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 组件的属性列表
|
||
|
|
*/
|
||
|
|
properties: {
|
||
|
|
ids:{
|
||
|
|
type: String,
|
||
|
|
value: ""
|
||
|
|
}
|
||
|
|
},
|
||
|
|
observers:{
|
||
|
|
'ids': function(newVal,oldVal){
|
||
|
|
console.log('newVal--------',newVal)
|
||
|
|
console.log('oldVal--------',oldVal)
|
||
|
|
if (newVal) {
|
||
|
|
this.getAdv(newVal)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
lifetimes: {
|
||
|
|
created() {
|
||
|
|
this.data.advList=[]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
/**
|
||
|
|
* 组件的初始数据
|
||
|
|
*/
|
||
|
|
data: {
|
||
|
|
advList: [],
|
||
|
|
},
|
||
|
|
/**
|
||
|
|
* 组件的方法列表
|
||
|
|
*/
|
||
|
|
methods: {
|
||
|
|
getAdv() {
|
||
|
|
this.data.advList = []
|
||
|
|
commonApi._post("adv/getAdv", {
|
||
|
|
position: 5,
|
||
|
|
type_id: 3,
|
||
|
|
product_id: this.data.ids
|
||
|
|
}).then(res => {
|
||
|
|
try {
|
||
|
|
this.setData({
|
||
|
|
advList: res.data
|
||
|
|
})
|
||
|
|
} catch (error) {
|
||
|
|
console.log(error);
|
||
|
|
}
|
||
|
|
console.log('advList',this.data.advList);
|
||
|
|
})
|
||
|
|
},
|
||
|
|
bannerClick: function(e) {
|
||
|
|
if (this.data.isTest) return;
|
||
|
|
let item = e.currentTarget.dataset.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.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) &&
|
||
|
|
item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) {
|
||
|
|
// 外部h5
|
||
|
|
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("?")
|
||
|
|
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;
|
||
|
|
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;
|
||
|
|
|
||
|
|
},
|
||
|
|
},
|
||
|
|
|
||
|
|
})
|