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.
 

123 lines
2.7 KiB

// 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:
// 外部h5
console.log(item)
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;
},
},
})