mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-05 00:49:49 +08:00
【新增】增加[coreshop-advert]广告组件,对标后台管理功能的广告管理,前端可<coreshop-advert codes="广告位code"></coreshop-advert>来实现在前端任何地方引用广告。
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<template>
|
||||
<view>
|
||||
<!--提示框组件-->
|
||||
<u-toast ref="uToast" />
|
||||
<view v-for="item in advert">
|
||||
<u--image :showLoading="true" :src="item.imageUrl" mode="widthFix" width="100%" height="auto" @click="showSliderInfo(item.type, item.val)"></u--image>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { navLinkType } from '@/common/setting/constVarsHelper.js';
|
||||
export default {
|
||||
props: {
|
||||
codes: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: 'tpl1_class_banner1'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
advert: [],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
console.log(this.codes);
|
||||
this.getData();
|
||||
},
|
||||
methods: {
|
||||
getData() {
|
||||
this.$u.api.advert({
|
||||
codes: this.codes
|
||||
}).then(res => {
|
||||
this.advert = res.data;
|
||||
});
|
||||
},
|
||||
// 广告点击查看详情
|
||||
showSliderInfo(type, val) {
|
||||
if (!val) {
|
||||
return;
|
||||
}
|
||||
if (type == 1) {
|
||||
if (val.indexOf('http') != -1) {
|
||||
// #ifdef H5
|
||||
window.location.href = val
|
||||
// #endif
|
||||
// #ifdef H5 || APP-PLUS || APP-PLUS-NVUE || MP
|
||||
this.$u.route('/pages/webview/webview', { src: val });
|
||||
// #endif
|
||||
} else {
|
||||
// #ifdef H5 || APP-PLUS || APP-PLUS-NVUE || MP
|
||||
if (val == '/pages/index/default/default' || val == '/pages/category/index/index' || val == '/pages/index/cart/cart' || val == '/pages/index/member/member') {
|
||||
this.$u.route({ type: 'switchTab', url: val });
|
||||
return;
|
||||
} else if (val.indexOf('/pages/coupon/coupon') > -1) {
|
||||
var id = val.replace('/pages/coupon/coupon?id=', "");
|
||||
this.receiveCoupon(id)
|
||||
} else {
|
||||
this.$common.navigateTo(val);
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
} else if (type == 2) {
|
||||
// 商品详情
|
||||
this.$u.route('/pages/goods/goodDetails/goodDetails', { id: val });
|
||||
} else if (type == 3) {
|
||||
// 文章详情
|
||||
this.$u.route('/pages/article/details/details', { idType: 1, id: val });
|
||||
} else if (type == 4) {
|
||||
// 文章列表
|
||||
this.$u.route('/pages/article/list/list')
|
||||
} else if (type == navLinkType.intelligentForms) {
|
||||
this.$u.route('/pages/form/details/details', { id: val });
|
||||
} else {
|
||||
this.$u.route(val);
|
||||
}
|
||||
},
|
||||
// 用户领取优惠券
|
||||
receiveCoupon(couponId) {
|
||||
let _this = this;
|
||||
let coreshopdata = {
|
||||
id: couponId
|
||||
}
|
||||
this.$u.api.getCoupon(coreshopdata).then(res => {
|
||||
if (res.status) {
|
||||
_this.$refs.uToast.show({ message: res.msg, type: 'success', back: false })
|
||||
} else {
|
||||
_this.$u.toast(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
</style>
|
||||
@@ -36,6 +36,7 @@
|
||||
<block v-for="(item,index) in tabbar" :key="index">
|
||||
<scroll-view scroll-y class="right-box" v-if="current==index">
|
||||
<view class="coreshop-padding-10">
|
||||
<coreshop-advert codes="TplIndexBanner1"></coreshop-advert>
|
||||
<view class="class-item">
|
||||
<view class="item-title">
|
||||
<text>{{item.name}}</text>
|
||||
|
||||
Reference in New Issue
Block a user