main
shuxiaoquan 10 months ago
commit a5d32389ed
  1. 1
      config.js
  2. 7
      pages.json
  3. 40
      pages/goods/detail.vue
  4. 18
      pages/goods/list.vue
  5. 28
      pages/goods/webView.vue

@ -14,6 +14,7 @@ export default {
* 商城ID (必填) * 商城ID (必填)
* 可在超管后台-商城列表中查看10025 * 可在超管后台-商城列表中查看10025
*/ */
storeId: 10045, storeId: 10045,
// storeId: 10037, // storeId: 10037,

@ -759,6 +759,13 @@
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
}, },
{
"path": "webView",
"style": {
"navigationBarTitleText": "商品详情",
"enablePullDownRefresh": true
}
},
{ {
"path": "detail", "path": "detail",
"style": { "style": {

@ -204,7 +204,9 @@
</view> </view>
</view> </view>
</view> </view>
<view class="detail-content" v-html="goods.content"></view> <view class="detail-content" @click="onLook(goods.isLink,goods.contentLink)" v-if="goods.isLink"
v-html="goods.content"></view>
<view class="detail-content" v-else v-html="goods.content"></view>
<view class="footer"> <view class="footer">
<view class="fooLeft"> <view class="fooLeft">
<view class="footerCus firstBtn" v-if="isLogin == false" @click="addCar()"> <view class="footerCus firstBtn" v-if="isLogin == false" @click="addCar()">
@ -557,6 +559,13 @@
} }
}, },
methods: { methods: {
onLook(isLink, url) {
if (isLink) {
uni.navigateTo({
url: '/pages/goods/webView?src=' + encodeURIComponent(url) //urlh5pageB
})
}
},
async getGoodsStockInfor() { async getGoodsStockInfor() {
let params = { let params = {
list: [{ list: [{
@ -878,6 +887,29 @@
} }
}) })
}, },
getLinksFromRichText(richText) {
// ahref
const regex = /<a[^>]*href="?([^">]+)"?[^>]*>(.*?)<\/a>/gim;
let matches, links = '';
//
while ((matches = regex.exec(richText)) !== null) {
// matches[1]hrefmatches[2]
links = matches[1];
}
return links;
},
getValueAfterSymbol(str, symbol) {
const parts = str.split(symbol);
if (parts.length > 1) {
return parts[1].trim(); // 使trim()
}
return str; //
},
containsLetterMix(str, mix) {
return new RegExp(mix.split('').join('\\w*')).test(str)
},
// //
getGoodsDetail(type) { getGoodsDetail(type) {
const that = this const that = this
@ -897,10 +929,11 @@
.replace(/style=""/g, '') .replace(/style=""/g, '')
.replace(/<img " src=/g, '<img src=') .replace(/<img " src=/g, '<img src=')
.replace(/<img src=/g, '<img style="width: 100%; display:block" src=') .replace(/<img src=/g, '<img style="width: 100%; display:block" src=')
// that.goods = info; info.contentLink = that.getValueAfterSymbol(that.getLinksFromRichText(info
.content), 'client://')
info.isLink = that.containsLetterMix(info.contentLink, 'jd.com') ? true : false
Object.keys(info).forEach(item => { Object.keys(info).forEach(item => {
this.$set(this.goods, item, info[item]) this.$set(this.goods, item, info[item])
// that.goods[item] = info[item]
}) })
that.isTodo = true; that.isTodo = true;
@ -1009,7 +1042,6 @@
return; return;
} }
// //
console.log(this.token, '登录信息')
if (this.goods.stock_total == 0) { if (this.goods.stock_total == 0) {
return this.$toast('库存不足,请选择其他商品购买') return this.$toast('库存不足,请选择其他商品购买')
} }

@ -105,7 +105,7 @@
<view v-else> <view v-else>
<u-waterfall v-model="list.data" ref="uWaterfall1"> <u-waterfall v-model="list.data" ref="uWaterfall1">
<template v-slot:left="{leftList}"> <template v-slot:left="{leftList}">
<view class="goods-item" v-for="(item, index) in leftList" :key="index" <view class="goods-item goods-item1" v-for="(item, index) in leftList" :key="index"
@click="onTargetDetail(item.goods_id)"> @click="onTargetDetail(item.goods_id)">
<!-- 多列显示 --> <!-- 多列显示 -->
<view class=""> <view class="">
@ -127,7 +127,8 @@
<text v-if="item.line_price_min > 0" <text v-if="item.line_price_min > 0"
class="line-price col-9 f-24">{{ item.line_price_min>0?Number(item.line_price_min):0.00 }}</text> class="line-price col-9 f-24">{{ item.line_price_min>0?Number(item.line_price_min):0.00 }}</text>
</view> </view>
<image :src="$picUrl+'/static/detail/redShen.png'" v-if="item.is_check==1" mode=""> <image :src="$picUrl+'/static/detail/redShen.png'" v-if="item.is_check==1"
mode="">
</image> </image>
</view> </view>
<view class="goodsInfo"> <view class="goodsInfo">
@ -159,7 +160,7 @@
</view> </view>
</template> </template>
<template v-slot:right="{rightList}"> <template v-slot:right="{rightList}">
<view class="goods-item" v-for="(item, index) in rightList" :key="index" <view class="goods-item goods-item1" v-for="(item, index) in rightList" :key="index"
@click="onTargetDetail(item.goods_id)"> @click="onTargetDetail(item.goods_id)">
<!-- 多列显示 --> <!-- 多列显示 -->
<view class=""> <view class="">
@ -181,7 +182,8 @@
<text v-if="item.line_price_min > 0" <text v-if="item.line_price_min > 0"
class="line-price col-9 f-24">{{ item.line_price_min>0?Number(item.line_price_min):'' }}</text> class="line-price col-9 f-24">{{ item.line_price_min>0?Number(item.line_price_min):'' }}</text>
</view> </view>
<image :src="$picUrl+'/static/detail/redShen.png'" v-if="item.is_check==1" mode=""> <image :src="$picUrl+'/static/detail/redShen.png'" v-if="item.is_check==1"
mode="">
</image> </image>
</view> </view>
<view class="goodsInfo"> <view class="goodsInfo">
@ -693,8 +695,12 @@
} }
} }
.goods-item1 {
width: 365rpx;
}
.goods-item { .goods-item {
float: left; // float: left;
box-sizing: border-box; box-sizing: border-box;
padding: 12rpx 9rpx; padding: 12rpx 9rpx;
@ -968,4 +974,4 @@
} }
} }
</style> </style>

@ -0,0 +1,28 @@
//PageWebview.vue
<template>
<web-view v-if='src' :src='src' @message='message'></web-view>
</template>
<script>
export default {
data() {
return {
src: "",
};
},
onLoad(options) {
options.src = decodeURIComponent(options.src);
setTimeout(() => {
this.src = `${options.src}`;
}, 500);
},
methods: {
message(e) {
console.log(message, 'webView----message')
},
},
};
</script>
<style lang="scss" scoped>
</style>
Loading…
Cancel
Save