diff --git a/package2/group/groupBuyDetail.vue b/package2/group/groupBuyDetail.vue index 115a129..0e55ecb 100644 --- a/package2/group/groupBuyDetail.vue +++ b/package2/group/groupBuyDetail.vue @@ -16,15 +16,15 @@ - {{shopItem.shopName}} + {{shopItem.shopName || ''}} - {{shopItem.shopAddress}} + {{shopItem.shopAddress || '暂无地址'}} - 周一到周日 {{shopItem.shopTakeaway.businessHourBegin}}-{{shopItem.shopTakeaway.businessHourEnd}} + {{businessTimeText}} @@ -40,6 +40,7 @@ + 暂无资质图片 @@ -48,16 +49,10 @@ 商家公告 - 公告:{{shopItem.remark}} + 公告:{{shopItem.remark || '暂无公告'}} - - - - - - @@ -68,25 +63,77 @@ menuButtonInfo: {}, isPintuan:true, shopItem:{}, - shopImages:[], - bigImg:'' + shopImages:[] + } + }, + computed: { + businessTimeText() { + const takeaway = this.shopItem.shopTakeaway || {}; + if (!takeaway.businessHourBegin || !takeaway.businessHourEnd) return '营业时间暂无'; + return '周一到周日 ' + takeaway.businessHourBegin + '-' + takeaway.businessHourEnd; } }, components: { }, onLoad(option) { - this.shopItem = JSON.parse(option.item) - this.shopImages = this.shopItem.shopImages.split('@@') + this.initShopItem(option) }, onShow() { this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() }, methods: { + initShopItem(option) { + const cacheItem = uni.getStorageSync('groupShopDetail'); + if (cacheItem) { + this.shopItem = cacheItem; + } else if (option.item) { + this.shopItem = this.parseRouteItem(option.item) || {}; + } + this.setShopImages(); + if (option.id || this.shopItem.id) { + this.getShopDetail(option.id || this.shopItem.id); + } + }, + parseRouteItem(item) { + if (item == null || item === '') return null; + try { + return JSON.parse(decodeURIComponent(item)); + } catch (e) { + try { + return JSON.parse(item); + } catch (err) { + return null; + } + } + }, + setShopImages() { + if (!this.shopItem.shopImages) { + this.shopImages = []; + return; + } + this.shopImages = this.shopItem.shopImages.split('@@').filter(item => item && item !== 'undefined' && item !== 'null'); + }, + getShopDetail(id) { + this.tui.request("/app/shop/getShopInfoById", "POST", { + id: id, + regionId: JSON.parse(uni.getStorageSync('area')).id + }, false, false).then((res) => { + if (res.code == 200 && res.result) { + this.shopItem = res.result; + uni.setStorageSync('groupShopDetail', res.result); + this.setShopImages(); + } + uni.hideLoading(); + }).catch(() => {}); + }, //查看大图 largeImg(img) { - this.bigImg = img - this.$refs.imgPopup.open() + if (!img) return; + uni.previewImage({ + current: img, + urls: this.shopImages + }) }, //拨打电话 makeCall(phone) { @@ -164,8 +211,4 @@ width: 20%; height: 160rpx; } - .img-popup-content { - width: 500rpx; - height: 500rpx; - } \ No newline at end of file diff --git a/package2/group/groupBuySingle.vue b/package2/group/groupBuySingle.vue index db6619c..e5a35b8 100644 --- a/package2/group/groupBuySingle.vue +++ b/package2/group/groupBuySingle.vue @@ -1682,8 +1682,9 @@ }, goDetail(type) { if (type == 'shopDetail') { + uni.setStorageSync('groupShopDetail', this.shopItem) uni.navigateTo({ - url: '/package2/group/groupBuyDetail?item=' + JSON.stringify(this.shopItem) + url: '/package2/group/groupBuyDetail?id=' + this.shopItem.id }) } else if (type == 'shopEvaluate') { uni.navigateTo({