|
|
<template><view id="detail"> <!--<wxparser rich-text="{{richText}}" bind:tapLink="jumpDetail" />--> <u-parse :content="richText" v-if="richText" @navigate="navigate" /> <!-- #ifdef MP-WEIXIN --> <button class="share-box" open-type="share"> <span class="iconfont icon--fenxiang"></span> 分享好友 </button> <!-- #endif --> <!-- #ifdef APP-PLUS --> <button class="share-box" @click="shareapp"> <span class="iconfont icon--fenxiang"></span> 分享好友 </button> <!-- #endif --> <!-- #ifdef H5 --> <view > <uni-popup :show="type === 'middle-img'" position="top" mode="fixed" @hidePopup="togglePopup('')"> <view class="uni-center center-box"> <image style="position: absolute; top: 0;right:0" @tap="togglePopup('')" class="image" src="/static/ico-share-wechat.png" /> </view> </uni-popup> </view> <!-- #endif -->
</view></template><script>import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';import uParse from '@/components/gaoyia-parse/parse.vue';import uniPopup from '@/components/uni-popup/uni-popup.vue';
export default { data() { return { richText: '', id: '', title: ''
}; },
components:{ uParse},
//监听用户点击页面内转发按钮
onShareAppMessage(res) { return { title: this.title, path: '/pages/article/detail/detail?id=' + this.id }; },
onLoad(e) { if (e.id) { this.queryVipList(e.id); this.setData({ id: e.id }); } }, methods: { togglePopup(type) { this.type = type; }, ShearUser(){ this.togglePopup('middle-img') }, // 获取文章页详情 getArticleDetail
queryVipList(id) { wx.showLoading({ title: "加载中", mask: true }); this.$http.get({ api: 'api/article/detail/' + id }).then(res => { if (res.statusCode == 200) { res = res.data;
if (res.status) { var goods = res.data.goods_list;
for (var i in goods) { // var str = `<a href="/pages/store/detail/detail?id=${goods[i].id}" style="display:block;overflow:visible">
// <div style="width: 100%; background: url('${goods[i].img}');
// padding-top: 100%; background-size: cover; position: relative">
// <div style="position: absolute; top: 15px; right: 15px; width: 40px; height: 40px;
// background: url('https://cdn.ibrand.cc/%20%E5%B0%8F%E7%A8%8B%E5%BA%8Fii7.png');
// background-size: cover"></div></div><div style="color: #000000; display: flex;
// align-items: center; justify-content: flex-end; margin-top: 10px">
// <div style="width: 20px; height: 20px;margin-right: 10px;
// background: url('https://cdn.ibrand.cc/%E7%AE%AD%E5%A4%B4434.png') no-repeat; background-size: 100%; "></div>点击图片立即购买</div></a>`;
//
var str = `<div style="position: relative"><div style="width: 100%; background: url('${goods[i].img}');
padding-top: 100%; background-size: cover; position: relative"><div style="position: absolute; top: 15px; right: 15px; width: 40px; height: 40px;background: url('https://cdn.ibrand.cc/%20%E5%B0%8F%E7%A8%8B%E5%BA%8Fii7.png'); background-size: cover"></div></div><div style="color: #000000; display: flex;align-items: center; justify-content: flex-end; margin-top: 10px"><div style="width: 20px; height: 20px;margin-right: 10px; background: url('https://cdn.ibrand.cc/%E7%AE%AD%E5%A4%B4434.png') no-repeat; background-size: 100%; "></div> <a href="/pages/store/detail/detail?id=${goods[i].id}">点击图片立即购买</a></div><a href="/pages/store/detail/detail?id=${goods[i].id}" style="display:block;overflow:visible; position: absolute; top: 0; left: 0; right: 0; bottom: 0"></a></div>`;
res.data.article.article_detail = res.data.article.article_detail.replace("goods_" + goods[i].id, str); }
this.setData({ richText: res.data.article.article_detail, title: res.data.article.title }); wx.setNavigationBarTitle({ title: res.data.article.title }); // #ifdef H5
if (this.$wechat && this.$wechat.isWechat()) { var title=this.title; this.$wechat.share({ title: title, img:'https://cdn.guojiang.club/h5_share_logo.png', dec:'果酱小店' }); } // #endif
} else { wx.showModal({ content: res.message || '请求失败', showCancel: false }); } } else { wx.showModal({ content: res.message || '请求失败', showCancel: false }); }
wx.hideLoading(); }).catch(rej => { wx.hideLoading(); wx.showModal({ content: rej.message || '请求失败', showCancel: false }); }); },
jumpDetail(e) { console.log(e); wx.navigateTo({ url: e.detail.href }); }, navigate(href, e) { console.log(href,e); wx.navigateTo({ url: href }); },
setData: function (obj) { let that = this; let keys = []; let val, data; Object.keys(obj).forEach(function (key) { keys = key.split('.'); val = obj[key]; data = that.$data; keys.forEach(function (key2, index) { if (index + 1 == keys.length) { that.$set(data, key2, val); } else { if (!data[key2]) { that.$set(data, key2, {}); } }
data = data[key2]; }); }); } }, computed: {}, watch: {}};</script><style rel="stylesheet/less" lang="less"> @import "detail";</style>
|