<template>
|
<view>
|
<view class="banner">
|
<image class="backLeft" src="/static/imgs/blackleft.png" mode="" @click="$util.goBack"></image>
|
<swiper class="swiper" circular @change="durationChange" :indicator-dots="indicatorDots" :indicator-color="indicatorColor" :autoplay="autoplay" :indicator-active-color="indicatorActiveColor" :interval="interval" :duration="duration">
|
<swiper-item v-for="(item, index) in goodsData.banner">
|
<image lazy-load :src="item" mode=""></image>
|
</swiper-item>
|
</swiper>
|
<view class="bannerIndex">{{bannerIndex}}/{{goodsData.bannerCount}}</view>
|
</view>
|
<view class="gTitle">
|
<view class="">{{goodsData.title}}</view>
|
<view class="">
|
<text>原价</text>
|
<text>¥</text>
|
<text>{{goodsData.price}}</text>
|
<text>会员价</text>
|
<text>¥</text>
|
<text>{{goodsData.vprice}}</text>
|
<!-- <text>积分:{{goodsData.points}}</text> -->
|
<!-- <text>原价:¥{{goodsData.price}}</text> -->
|
</view>
|
<view class="collect" @tap="collectGoods">
|
<image :src="goodsData.collect == 1 ? '/static/imgs/colls.png' : '/static/imgs/coll.png'" mode=""></image>
|
</view>
|
</view>
|
<view class="gInfo-title">商品详情</view>
|
<view class="gInfo" v-html="goodsData.info"></view>
|
<view class="gBtn">
|
<view class="gBtn-view" @tap="$util.goSwitch('/pages/index/index')">
|
<view class="">
|
<image src="/static/imgs/home.png" mode=""></image>
|
<view>首页</view>
|
</view>
|
</view>
|
<view class="gBtn-view" @tap="goKefu">
|
<view class="">
|
<image src="/static/imgs/message.png" mode=""></image>
|
<view>客服</view>
|
</view>
|
</view>
|
<view class="gBtn-view" @tap="addCarts">
|
<view class="">
|
<image src="/static/imgs/carts.png" mode=""></image>
|
<view>购物车</view>
|
</view>
|
</view>
|
<view class="gBtn-buy" @click="goBuy">
|
<text>立即购买</text>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
indicatorDots: true,
|
indicatorColor: '#e3b400',
|
indicatorActiveColor: '#ffffff',
|
autoplay: true,
|
interval: 3000,
|
duration: 500,
|
goodsId: 0,
|
goodsData: {},
|
bannerIndex: 1,
|
userInfo: uni.getStorageSync('user-info') ? JSON.parse(uni.getStorageSync('user-info')) : null,
|
Config: uni.getStorageSync('Config') ? JSON.parse(uni.getStorageSync('Config')) : null,
|
}
|
},
|
onLoad(op){
|
this.getConfig()
|
this.goodsId = op.id ? op.id : 0
|
if(this.goodsId > 0) {
|
this.getGoodsInfo()
|
}
|
},
|
methods: {
|
goKefu() {
|
if(this.Config && this.Config.kefu_open == 1) {
|
this.wechatWork()
|
} else {
|
this.$util.checkLogin('/pages/customer/customer')
|
}
|
},
|
getConfig () {
|
let t = this
|
t.$util.post('Index/getConfig').then(res => {
|
t.Config = res.data
|
})
|
},
|
wechatWork () {
|
let t = this
|
if(t.Config){
|
if(t.Config.put_open == 1){
|
uni.showModal({
|
title: '联系客服',
|
content: '请联系客服电话:' + t.Config.kefu_phone,
|
showCancel: false,
|
success: function (res) {
|
if (res.confirm) {
|
}
|
}
|
});
|
} else {
|
uni.share({
|
provider: "weixin",
|
openCustomerServiceChat: true,
|
customerUrl: t.Config.work_url, //企业微信地址
|
corpid: t.Config.work_id, //企业id
|
success: (res) => {
|
console.log("success:" + JSON.stringify(res))
|
},
|
fail: (err) => {
|
console.log("fail:" + JSON.stringify(err))
|
}
|
})
|
}
|
}
|
},
|
durationChange (e) {
|
this.bannerIndex = e.detail.current + 1
|
},
|
getGoodsInfo () {
|
this.$util.post('Goods/getGoodsInfo', {goodsId: this.goodsId}).then(res => {
|
this.goodsData = res.data
|
this.goodsData.info = res.data.info.replace(/\<img/gi, '<img style="max-width:100%;height:auto;margin-bottom: -4px"')
|
})
|
},
|
collectGoods () {
|
let burl = '/pages/ginfo/ginfo?id=' + this.goodsData.id
|
if(!this.$util.checkGoPages('/pages/login/login', burl, 0)) {
|
return
|
}
|
this.$util.post('Collect/addCollect', {goodsid: this.goodsData.id}).then(res => {
|
if(res.code == 1) {
|
this.goodsData.collect = 1
|
uni.showToast({
|
title: res.msg || '收藏成功',
|
icon: 'success'
|
})
|
} else if(res.code == 2) {
|
this.goodsData.collect = 0
|
uni.showToast({
|
title: res.msg || '取消成功',
|
icon: 'success'
|
})
|
} else {
|
uni.showToast({
|
title: res.msg || '收藏失败',
|
icon: 'error'
|
})
|
}
|
})
|
},
|
goBuy () {
|
let t = this
|
let burl = '/pages/ginfo/ginfo?id=' + this.goodsData.id
|
if(!this.$util.checkLogin('', burl)) {
|
return
|
}
|
t.$util.post('Carts/addCarts', {goodsId: this.goodsData.id}).then(res => {
|
if(res.code == 1) {
|
uni.navigateTo({
|
url: '/pages/pays/pays?cartsIds=' + res.data.cartsId
|
})
|
} else {
|
uni.showToast({
|
title: res.msg || '操作失败',
|
icon: '',
|
})
|
}
|
})
|
},
|
addCarts () {
|
let t = this
|
let burl = '/pages/ginfo/ginfo?id=' + this.goodsData.id
|
if(!this.$util.checkGoPages('/pages/login/login', burl, 0)) {
|
return
|
}
|
this.$util.post('Carts/addCarts', {goodsId: this.goodsData.id}).then(res => {
|
if(res.code == 1) {
|
uni.showModal({
|
title: '温馨提示',
|
content: '添加购物车成功,是否去结算?',
|
success: function (res) {
|
if (res.confirm) {
|
t.$util.goSwitch('/pages/carts/carts')
|
}
|
}
|
})
|
} else {
|
uni.showToast({
|
title: res.msg || '添加购物车失败',
|
icon: 'error'
|
})
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style>
|
@import url(/static/css/ginfo.css);
|
</style>
|