|
@@ -6,9 +6,12 @@
|
|
<u-swiper :list="picUrlArr" height="375" radius="0" :indicator="true" :circular="true"></u-swiper>
|
|
<u-swiper :list="picUrlArr" height="375" radius="0" :indicator="true" :circular="true"></u-swiper>
|
|
</view>
|
|
</view>
|
|
<view class="detail-info">
|
|
<view class="detail-info">
|
|
- <view class="content">零跑C11电动汽车新能源车整车国产中型SUV C11性能版</view>
|
|
|
|
|
|
+ <view class="content" v-text="info.title"></view>
|
|
</view>
|
|
</view>
|
|
<view class="detail-title">商品详情</view>
|
|
<view class="detail-title">商品详情</view>
|
|
|
|
+ <view class="detail-description">
|
|
|
|
+ <view class="" v-html="description"></view>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
@@ -20,13 +23,10 @@
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
boxId: '',
|
|
boxId: '',
|
|
- picUrlArr: [
|
|
|
|
- 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
|
|
|
|
- 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
|
|
|
|
- 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
|
|
|
|
- ],
|
|
|
|
|
|
+ picUrlArr: [],
|
|
info: {},
|
|
info: {},
|
|
prizeList: [],
|
|
prizeList: [],
|
|
|
|
+ description:'',
|
|
|
|
|
|
payShow: false,
|
|
payShow: false,
|
|
payInfo: {}
|
|
payInfo: {}
|
|
@@ -40,26 +40,19 @@
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
title: '加载中'
|
|
title: '加载中'
|
|
});
|
|
});
|
|
- $http.post('/api/v1/mp/channel/mall/ticket/detail', {
|
|
|
|
- boxId: id
|
|
|
|
|
|
+ $http.post('/api/v1/mp/user/exchange/goods/detail', {
|
|
|
|
+ noToken: true,
|
|
|
|
+ goodsId: id
|
|
}).then(res => {
|
|
}).then(res => {
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
- console.log(res);
|
|
|
|
- return
|
|
|
|
if (res.code == 0) {
|
|
if (res.code == 0) {
|
|
this.info = res.data
|
|
this.info = res.data
|
|
let picUrlArr = res.data.picUrl.split(',')
|
|
let picUrlArr = res.data.picUrl.split(',')
|
|
picUrlArr.forEach(item => {
|
|
picUrlArr.forEach(item => {
|
|
this.picUrlArr.push(env.filePublic + item)
|
|
this.picUrlArr.push(env.filePublic + item)
|
|
})
|
|
})
|
|
-
|
|
|
|
- let prizeList = res.data.prizeList
|
|
|
|
-
|
|
|
|
- prizeList.forEach(item => {
|
|
|
|
- item.picUrl = env.filePublic + item.picUrl
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- this.prizeList = prizeList
|
|
|
|
|
|
+ // 处理富文本
|
|
|
|
+ this.description = this.formatRichText(res.data.description);
|
|
}
|
|
}
|
|
}).catch(() => {
|
|
}).catch(() => {
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
@@ -90,6 +83,32 @@
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ /**
|
|
|
|
+ * 处理富文本里的图片宽度自适应
|
|
|
|
+ * 1.去掉img标签里的style、width、height属性
|
|
|
|
+ * 2.img标签添加style属性:max-width:100%;height:auto
|
|
|
|
+ * 3.修改所有style里的width属性为max-width:100%
|
|
|
|
+ * 4.去掉<br/>标签
|
|
|
|
+ * @param html
|
|
|
|
+ * @returns {void|string|*}
|
|
|
|
+ */
|
|
|
|
+ formatRichText(html) { //控制小程序中图片大小
|
|
|
|
+ let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
|
|
|
|
+ match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
|
|
|
|
+ match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
|
|
|
|
+ match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
|
|
|
|
+ return match;
|
|
|
|
+ });
|
|
|
|
+ newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
|
|
|
|
+ match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
|
|
|
|
+ 'max-width:100%;');
|
|
|
|
+ return match;
|
|
|
|
+ });
|
|
|
|
+ newContent = newContent.replace(/<br[^>]*\/>/gi, '');
|
|
|
|
+ newContent = newContent.replace(/\<img/gi,
|
|
|
|
+ '<img style="max-width:100%;height:auto;margin:10rpx auto;"');
|
|
|
|
+ return newContent;
|
|
|
|
+ },
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
@@ -116,6 +135,12 @@
|
|
font-weight: bold;
|
|
font-weight: bold;
|
|
background-color: #FFFFFF;
|
|
background-color: #FFFFFF;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ &-description {
|
|
|
|
+ image {
|
|
|
|
+ width: 100%;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|