9 changed files with 200 additions and 4 deletions
@ -0,0 +1,147 @@ |
|||||
|
// 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; |
||||
|
|
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
}) |
||||
@ -0,0 +1,4 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": {} |
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
<view> |
||||
|
<view class="box" wx:if="{{advList.length > 0}}"> |
||||
|
<image src="{{advList[0].head_img}}" mode="scaleToFill" bindtap="bannerClick" data-item="{{advList[0]}}"></image> |
||||
|
</view> |
||||
|
</view> |
||||
@ -0,0 +1,12 @@ |
|||||
|
.box { |
||||
|
margin: 20rpx 30rpx; |
||||
|
height: 133rpx; |
||||
|
border-radius: 13rpx; |
||||
|
padding: 0; |
||||
|
} |
||||
|
|
||||
|
.box >image { |
||||
|
width: 100%; |
||||
|
height: 133rpx; |
||||
|
border-radius: 13rpx; |
||||
|
} |
||||
@ -1,7 +1,7 @@ |
|||||
{ |
{ |
||||
"usingComponents": { |
"usingComponents": { |
||||
"title":"/pages/component/TitleHeader", |
"title":"/pages/component/TitleHeader", |
||||
"sptj":"/pages/component/proRec/proRec" |
"sptj":"/pages/component/proRec/proRec", |
||||
|
"advBox":"/pages/component/orderAdv/orderAdv" |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue