真食物配套的电商小程序.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1546 lines
45 KiB

<template>
<view :class="productConClass">
<view class="header">
<cu-custom :isBack="true" :isCenter="true" :hasShadow="hasShadow">
<block slot="backText">
<view class="backImg">
<image src="@/static/images/back-btn.png" mode=""></image>
</view>
</block>
<block slot="content">
<view class="acea-row row-middle" v-if="showBrandTitle">
<view class="brand-img">
<image :src="brandInfo.pic" mode="aspectFill"></image>
</view>
<view class="tab-title">{{brandInfo.brandName}}</view>
</view>
</block>
</cu-custom>
</view>
<view v-if="storeInfo.id" style="padding-top: 4rpx;">
<view class="brand-info-box" @click="goBrand">
<view class="brand-logo-box">
<image class="img" :src="brandInfo.pic" mode="aspectFill"></image>
</view>
<view class="info-box">
<view class="acea-row row-between-wrapper">
<view class="brand-name">{{brandInfo.brandName}}</view>
<view class="brand-tips acea-row">
<view class="tip">甄选品牌</view>
</view>
</view>
<view class="info more-t">{{brandInfo.brandDescription}}</view>
</view>
</view>
<!-- 轮播图 -->
<product-con-swiper :img-urls="storeInfo.sliderImageArr"></product-con-swiper>
<!-- 商品信息描述 -->
<view class="wrapper">
<view class="top">
<view class="share acea-row row-between row-bottom">
<view class="money font-color-red">
<!-- <view class="money font-color-red" v-if="!isIntegral"> -->
<!-- <text>¥</text> -->
<text class="num">¥{{ attr.productSelect.price || storeInfo.price }}</text>
<text class="otPrice">¥{{ attr.productSelect.otPrice || storeInfo.otPrice }}</text>
<!-- <text class="vip-money" v-if="storeInfo.vipPrice && storeInfo.vipPrice > 0">¥{{ attr.productSelect.vipPrice || storeInfo.vipPrice }}</text>
<image :src="`${$VUE_APP_RESOURCES_URL}/images/vip.png`" class="image" v-if="storeInfo.vipPrice && storeInfo.vipPrice > 0" /> -->
</view>
<!-- <view class="money font-color-red" v-if="isIntegral">
<text class="num">{{ attr.productSelect.integral || storeInfo.integral }}积分</text>
</view> -->
<!-- <view class="iconfont icon-fenxiang" @click="listenerActionSheet"></view> -->
</view>
<view class="introduce">{{ storeInfo.storeName }}</view>
<view class="introduceInfo">{{ storeInfo.storeInfo }}</view>
<view class="label acea-row row-between-wrapper">
<view class="tips acea-row">
<view class="tip">甄选品牌</view>
</view>
<!-- <text v-if="!isIntegral">原价:¥{{ storeInfo.otPrice }}</text> -->
<text>库存:{{ storeInfo.stock }}{{ storeInfo.unitName }}</text>
<!-- <text>销量:{{ storeInfo.sales }}{{ storeInfo.unitName }}</text> -->
</view>
<!-- <view class="coupon acea-row row-between-wrapper" @click="couponTap" v-if="couponList.length">
<text class="hide line1">
<text>优惠券:</text>
<text class="activity" v-for="(item, couponListEq) in couponList" :key="couponListEq">满{{ item.useMinPrice }}减{{ item.couponPrice }}</text>
</text>
<view class="iconfont icon-jiantou"></view>
</view> -->
</view>
</view>
<!-- 运费 -->
<!-- <div class="attribute acea-row row-between-wrapper">
<div>
配送方式:
<span class="atterTxt">{{ tempName }}</span>
</div>
</div> -->
<!-- 规格 -->
<view class="attribute acea-row row-between-wrapper" @click="selecAttrTap">
<view>选规格</view>
<view class="acea-row attr-content">
<!-- <text>{{ attrTxt }}:</text> -->
<image v-if="item.image" :src="item.image" v-for="(item,index) in attrImages" :key="index" mode="aspectFill"></image>
<view class="attrs">
共{{attr.productAttr[0].attrValueArr.length}}个{{attr.productAttr.length == 1?attr.productAttr[0].attrName:attr.productAttr[0].attrValueArr.length == 1?attr.productAttr[1].attrName:attr.productAttr[0].attrName}}可选
</view>
<!-- <text class="atterTxt">{{ attrValue }}</text> -->
</view>
<view class="jiantou-right"></view>
<!-- <view class="iconfont icon-jiantou"></view> -->
</view>
<view class="safeguard-info acea-row" v-if="tempName || storeInfo.config">
<view class="safeguard-item" v-if="tempName">
<image class="img" src="../../../static/images/by.png" mode=""></image>
<view class="line1">{{tempName}}</view>
</view>
<view class="safeguard-item" v-for="(item,index) in storeInfo.config" :key="index">
<image class="img" :src="item.configuration" mode=""></image>
<view class="line1">{{item.content}}</view>
</view>
<!-- <view class="line"></view> -->
<!-- <view class="safeguard-item">
<image class="img" src="../../../static/images/fxt.png" mode=""></image>
<view>7天无理由</view>
<image class="img" src="../../../static/images/bj.png" mode=""></image>
<view>30天保价</view>
</view> -->
</view>
<!-- 门店信息 -->
<!-- <view class="store-info" v-if="systemStore">
<view class="title acea-row row-between-wrapper">
<view>门店信息</view>
<text @click="goStoreList()" class="praise">
更多
<text class="iconfont icon-jiantou"></text>
</text>
</view>
<view class="info acea-row row-between-wrapper">
<view class="picTxt acea-row row-between-wrapper">
<view class="pictrue">
<image :src="systemStore.image" />
</view>
<view class="text">
<view class="name line1">{{ systemStore.name }}</view>
<view class="address acea-row row-middle" @click="showChang(systemStore)">
<text class="addressTxt">{{ systemStore.address }}</text>
<text class="iconfont icon-youjian"></text>
</view>
</view>
<view class="addressBox">
<a class="iconfont icon-dadianhua01 font-color-red phone" @click="telPhone(systemStore.phone)"></a>
<view class="addressTxt corlor-yshop" v-if="systemStore.distance">距离{{ systemStore.distance }}千米</view>
</view>
</view>
</view>
</view> -->
<!-- 用户评价 -->
<view class="userEvaluation" v-if="replyCount">
<view class="title acea-row row-between-wrapper">
<view class="acea-row row-middle"><text>评价</text><text class="replyCount">{{ replyCount }}</text>
</view>
<view @click="goEvaluateList(id)" class="praise acea-row row-middle">
<view>好评率{{ replyChance }}%</view>
<view class="jiantou-right"></view>
</view>
</view>
<user-evaluation :reply="reply"></user-evaluation>
</view>
<view class="product-parameter" v-if="storeInfo.parameter.length > 0">
<view class="title">商品参数</view>
<view :class="'parameter-list ' + (isUnfold?'unfold':'')" :style="isUnfold?'height: auto;':'max-height: 184rpx;'">
<view class="parameter-item acea-row" v-for="(item,index) in storeInfo.parameter" :key="index">
<view class="parameter-name one-t">{{item.name}}</view>
<view class="parameter">{{item.details}}</view>
</view>
</view>
<view v-if="storeInfo.parameter.length > 4" class="more-box acea-row row-center-wrapper" @click="unfold" :style="isUnfold?'height: 50rpx;padding-top: 0rpx;':''">
<view>{{isUnfold?'收起':'展开'}}</view>
<view v-if="isUnfold" class="jiantou-up"></view>
<view v-else class="jiantou-down"></view>
</view>
</view>
<!-- 商品推荐 -->
<!-- <view class="superior">
<view class="title acea-row row-center-wrapper">
<image :src="`${$VUE_APP_RESOURCES_URL}/images/ling.png`" />
<text class="titleTxt">推荐</text>
<image :src="`${$VUE_APP_RESOURCES_URL}/images/ling.png`" />
</view>
<template>
<view class="slider-banner banner">
<swiper :options="swiperRecommend" v-if="goodList.length > 0">
<swiper-slide v-for="(item, eq2) in goodList" :key="eq2">
<view class="list acea-row row-middle">
<view class="item" v-for="val in item.list" :key="val.image">
<view class="pictrue">
<image :src="val.image" />
</view>
<view class="name line1">{{ val.store_name }}}</view>
<view class="money font-color-red">¥{{ val.price }}</view>
</view>
</view>
</swiper-slide>
<view class="swiper-pagination" slot="pagination"></view>
</swiper>
</view>
</template>
</view> -->
<!-- 商品详情 -->
<view class="product-intro">
<!-- <view class="title">商品展示</view> -->
<view class="conter">
<mp-html id="article" :setTitle="false" :lazy-load="true" :copy-link="false" :tag-style="tagStyle"
:content="storeInfo.description" @linktap="linktap" />
</view>
</view>
<view :style="'background:#FFFFFF;' + (addBottom?'height: 162rpx;':'height: 122rpx;')"></view>
<!-- 操作栏 -->
<view class="footer acea-row row-between" :style="addBottom?'height: 162rpx;':'height: 122rpx;'">
<!-- #ifdef MP-WEIXIN -->
<view class="item">
<button open-type="contact" class="contacButton">
<view class="item">
<view class="img">
<image src="../../../static/images/service-icon.png" mode=""></image>
</view>
<!-- <view class="iconfont icon-kefu"></view> -->
<text>客服</text>
</view>
</button>
</view>
<!-- #endif -->
<!-- <view class="item" @click="goHome">
<view class="iconfont icon-shouye-xianxing"></view>
<text>首页</text>
</view> -->
<view @click="goShoppingCart()" :class="'item animated ' + (animated?'bounceIn':'')">
<view class="img">
<image src="../../../static/images/cart-icon.png" mode=""></image>
<text class="num" v-if="CartCount > 0">{{ CartCount }}</text>
</view>
<!-- <view class="iconfont icon-gouwuche1">
<text class="num" v-if="CartCount > 0">{{ CartCount }}</text>
</view> -->
<text>购物车</text>
</view>
<view class="item" @click="setCollect">
<view class="img">
<image v-if="storeInfo.userCollect" src="../../../static/images/star-light.png" mode=""></image>
<image v-else src="../../../static/images/star.png" mode=""></image>
</view>
<!-- <view v-if="storeInfo.userCollect" class="iconfont icon-shoucang1"></view>
<view v-else class="iconfont icon-shoucang"></view> -->
<text>{{storeInfo.userCollect?'已收藏':'收藏'}}</text>
</view>
<view class="bnt acea-row row-between">
<view class="joinCart" @click="joinCart">
<text>加入购物车</text>
</view>
<view class="buy" @click="tapBuy">
<text>立即购买</text>
</view>
</view>
</view>
<!-- 词条弹框 -->
<view class="entry-mask" v-show="showEntry" @touchmove.stop.prevent @click="closeEntry">
<view class="entry-box">
<view class="entry">
{{entryInfo.entryInfo}}
</view>
</view>
</view>
<!-- 优惠券 -->
<!-- <CouponPop v-on:changeFun="changeFun" :coupon="coupon"></CouponPop> -->
<!-- 商品规格弹窗 -->
<ProductWindow :isIntegral="isIntegral" v-on:changeFun="changeFun" :attr="attr" :cartNum="cart_num"
:storeInfo="storeInfo.storeInfo" :unitName="storeInfo.unitName"></ProductWindow>
<!-- 分享海报 -->
<StorePoster v-on:setPosterImageStatus="setPosterImageStatus" :posterImageStatus="posterImageStatus"
:posterData="posterData" :goodId="id"></StorePoster>
<!-- 分享弹窗 -->
<ShareInfo v-on:setShareInfoStatus="setShareInfoStatus" :shareInfoStatus="shareInfoStatus"></ShareInfo>
<view class="generate-posters acea-row row-middle on" v-if="posters">
<view class="item" @click="setPosterImageStatus">
<view class="iconfont icon-haibao"></view>
<view>生成海报</view>
</view>
</view>
<view class="generate-posters acea-row row-middle" v-if="!posters">
<view class="item" @click="setPosterImageStatus">
<view class="iconfont icon-haibao"></view>
<view>生成海报</view>
</view>
</view>
<view class="mask" @touchmove.prevent @click="listenerActionClose" v-show="posters"></view>
<view class="posterCanvasWarp">
<canvas class="posterCanvas" canvas-id="myCanvas"></canvas>
</view>
</view>
</view>
</template>
<script>
// import { swiper, swiperSlide } from "vue-awesome-swiper";
import ProductConSwiper from '@/components/ProductConSwiper'
import UserEvaluation from '@/components/UserEvaluation'
// import CouponPop from '@/components/CouponPop'
import ProductWindow from '@/components/ProductWindow'
import StorePoster from '@/components/StorePoster'
import ShareInfo from '@/components/ShareInfo'
import {
getProductDetail,
postCartAdd,
getCartCount,
getProductCode,
getEntry
} from '@/api/store'
import {
getCoupon,
getCollectAdd,
getCollectDel,
getUserInfo
} from '@/api/user'
import cookie from '@/utils/store/cookie'
import {
isWeixin,
PosterCanvas,
handleQrCode,
handleUrlParam,
getCurrentPageUrlWithArgs
} from '@/utils'
import {
wechatEvevt
} from '@/libs/wechat'
import {
imageBase64
} from '@/api/public'
import {
mapGetters
} from 'vuex'
export default {
name: 'GoodsCon',
components: {
// swiper,
// swiperSlide,
ProductConSwiper,
UserEvaluation,
// CouponPop,
ProductWindow,
StorePoster,
ShareInfo,
},
data: function() {
return {
addBottom: this.addBottom,
hasShadow: false, // 顶部导航栏是否显示阴影
showBrandTitle: false, // 顶部导航栏是否显示品牌名
shareInfoStatus: false,
weixinStatus: false,
mapShow: false,
mapKey: '',
posterData: {
image: '',
title: '',
price: '',
code: '',
},
posterImageStatus: false,
animated: false,
coupon: {
coupon: false,
list: [],
},
brandInfo: {}, // 品牌信息
attr: {
cartAttr: false,
productAttr: [],
productSelect: {},
},
isOpen: false, //是否打开属性组件
productValue: [],
attrImages: [],
id: 0,
storeInfo: {},
couponList: [],
attrTxt: '请选择',
attrValue: '',
cart_num: 1, //购买数量
replyCount: '',
replyChance: '',
reply: [],
priceName: 0,
CartCount: 0,
posters: false,
banner: [{}, {}],
swiperRecommend: {
pagination: {
el: '.swiper-pagination',
clickable: true,
},
autoplay: false,
loop: false,
speed: 1000,
observer: true,
observeParents: true,
},
goodList: [],
systemStore: {},
qqmapsdk: null,
productConClass: 'product-con',
tempName: '',
isIntegral: false,
isUnfold: false, // 商品参数是否展开
entryInfo: {},
showEntry: false,
tagStyle: {
a: 'color:#0A59F7;text-decoration:underline;',
// p: 'text-indent:2em;',
// span: 'padding: 0rpx 30rpx;text-indent:2em;text-align: justify;text-justify: auto;'
// span: 'padding: 0rpx 30rpx;display: inline-block;',
img: 'padding:0;margin:0;font-size:0;display:block;'
}
}
},
computed: mapGetters(['isLogin', 'location']),
mounted: function() {
this.$store.commit('get_to', 'goodcon')
let url = handleQrCode()
if (!url) {
url = handleUrlParam(getCurrentPageUrlWithArgs())
}
const token = cookie.get('login_status')
if (url && url.id) {
this.id = url.id
let urlSpread = parseInt(url.spread)
if (urlSpread) {
cookie.set('spread', urlSpread)
}
} else {
this.id = this._route.query.id
}
this.isIntegral = url.isIntegral == 'true'
if (!token) {
this.productCon()
return
}
// this.coupons()
this.productCon()
this.setOpenShare()
},
watch: {
posterImageStatus(status) {
console.log(status)
if (status) {
this.productConClass = 'noscroll product-con'
} else {
this.productConClass = 'product-con'
}
},
},
onPageScroll(e) {
if (e.scrollTop > 60) {
this.hasShadow = true;
this.showBrandTitle = true;
} else {
this.hasShadow = false;
this.showBrandTitle = false;
};
},
methods: {
onShareAppMessage: function() {
return {
title: this.storeInfo.storeName,
imageUrl: this.storeInfo.image,
path: 'pages/shop/GoodsCon/index?id=' + this.storeInfo.id + '&spread=' + uni.getStorageSync(
'uid') + '&pageType=good&codeType=routine',
success(res) {
uni.showToast({
title: '分享成功',
})
},
fail(res) {
uni.showToast({
title: '分享失败',
icon: 'none',
})
},
}
},
goHome() {
this.$yrouter.switchTab('/pages/home/index')
},
goBrand() {
this.$yrouter.push({
path: '/pages/shop/brands/brandDetail/index',
query: {
id: this.brandInfo.id,
},
})
},
goShoppingCart() {
this.$yrouter.switchTab('/pages/shop/ShoppingCart/index')
},
goCustomerList() {
this.$yrouter.push({
path: '/pages/user/CustomerList/index',
})
},
goStoreList() {
this.$yrouter.push({
path: '/pages/shop/StoreList/index',
})
},
goEvaluateList(id) {
this.$yrouter.push({
path: '/pages/shop/EvaluateList/index',
query: {
id,
},
})
},
telPhone(phoneNumber) {
uni.makePhoneCall({
phoneNumber: phoneNumber,
fail() {
console.log('取消拨打')
},
})
},
showChang: function(data) {
this.$yrouter.push({
path: '/pages/map/index',
query: data,
})
},
updateTitle() {
// document.title = this.storeInfo.storeName || this.$yroute.meta.title;
},
setShareInfoStatus: function() {
this.shareInfoStatus = !this.shareInfoStatus
this.posters = false
},
shareCode: function() {
var that = this
getProductCode(that.id).then(res => {
that.posterData.code = res.data.code
that.listenerActionSheet()
})
},
setPosterImageStatus: function() {
this.posterImageStatus = !this.posterImageStatus
this.posters = false
},
// 展开商品参数
unfold() {
this.isUnfold = !this.isUnfold;
},
//产品详情接口;
productCon: function() {
let that = this
let from = this.location
if (this.$deviceType == 'app') {
from.from = 'app'
}
uni.showLoading({
title: '加载中',
mask: true,
})
getProductDetail(that.id, from)
.then(res => {
res.data.storeInfo.description = res.data.storeInfo.description.replace(/\<img/gi,
'<img style="max-width:100%;height:auto;"')
// res.data.storeInfo.description = res.data.storeInfo.description.replace(/&nbsp;/gi,'')
that.brandInfo = res.data.brandInfo;
that.$set(that, 'storeInfo', res.data.storeInfo)
// 给 attr 赋值,将请求回来的规格赋值给 attr
that.$set(that.attr, 'productAttr', res.data.productAttr)
that.$set(that, 'productValue', res.data.productValue)
that.$set(that, 'replyCount', res.data.replyCount)
that.$set(that, 'replyChance', res.data.replyChance)
that.reply = res.data.reply ? [res.data.reply] : []
that.$set(that, 'reply', that.reply)
that.$set(that, 'priceName', res.data.priceName)
that.$set(that, 'tempName', res.data.tempName)
that.posterData.image = that.storeInfo.image
if (that.storeInfo.storeName.length > 30) {
that.posterData.title = that.storeInfo.storeName.substring(0, 30) + '...'
} else {
that.posterData.title = that.storeInfo.storeName
}
that.posterData.price = that.storeInfo.price
that.posterData.code = that.storeInfo.codeBase
that.systemStore = res.data.systemStore
let good_list = res.data.goodList || []
let goodArray = []
let count = Math.ceil(good_list.length / 6)
for (let i = 0; i < count; i++) {
var list = good_list.slice(i * 6, 6)
if (list.length)
goodArray.push({
list: list,
})
}
that.mapKay = res.data.mapKay
that.$set(that, 'goodList', goodArray)
that.updateTitle()
that.DefaultSelect()
that.getCartCount()
for(let i in that.productValue) {
that.attrImages.push(that.productValue[i]);
if(that.attrImages.length == 2) return
}
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: 'none',
duration: 2000,
})
})
.finally(() => {
uni.hideLoading()
})
},
//默认选中属性;
DefaultSelect: function() {
let productAttr = this.attr.productAttr
let value = []
for (let i = 0; i < productAttr.length; i++) {
this.$set(productAttr[i], 'index', 0)
value.push(productAttr[i].attrValueArr[0])
}
//sort();排序函数:数字-英文-汉字;
let productSelect = this.productValue[value.sort().join(',')]
if (productSelect && productAttr.length) {
this.$set(this.attr.productSelect, 'store_name', this.storeInfo.storeName)
this.$set(this.attr.productSelect, 'image', productSelect.image)
this.$set(this.attr.productSelect, 'price', productSelect.price)
this.$set(this.attr.productSelect, 'otPrice', productSelect.otPrice)
this.$set(this.attr.productSelect, 'stock', productSelect.stock)
this.$set(this.attr.productSelect, 'unique', productSelect.unique)
this.$set(this.attr.productSelect, 'integral', productSelect.integral)
this.$set(this.attr.productSelect, 'cart_num', 1)
this.$set(this, 'attrValue', value.sort().join(','))
this.$set(this, 'attrTxt', '已选择')
} else if (!productSelect && productAttr.length) {
this.$set(this.attr.productSelect, 'store_name', this.storeInfo.storeName)
this.$set(this.attr.productSelect, 'image', this.storeInfo.image)
this.$set(this.attr.productSelect, 'price', this.storeInfo.price)
this.$set(this.attr.productSelect, 'otPrice', this.storeInfo.otPrice)
this.$set(this.attr.productSelect, 'integral', this.storeInfo.integral)
this.$set(this.attr.productSelect, 'stock', 0)
this.$set(this.attr.productSelect, 'unique', '')
this.$set(this.attr.productSelect, 'cart_num', 0)
this.$set(this, 'attrValue', '')
this.$set(this, 'attrTxt', '请选择')
} else if (!productSelect && !productAttr.length) {
this.$set(this.attr.productSelect, 'store_name', this.storeInfo.storeName)
this.$set(this.attr.productSelect, 'image', this.storeInfo.image)
this.$set(this.attr.productSelect, 'price', this.storeInfo.price)
this.$set(this.attr.productSelect, 'otPrice', this.storeInfo.otPrice)
this.$set(this.attr.productSelect, 'stock', this.storeInfo.stock)
this.$set(this.attr.productSelect, 'integral', this.storeInfo.integral)
this.$set(this.attr.productSelect, 'unique', this.storeInfo.unique || '')
this.$set(this.attr.productSelect, 'cart_num', 1)
this.$set(this, 'attrValue', '')
this.$set(this, 'attrTxt', '请选择')
}
},
//购物车;
ChangeCartNum: function(changeValue) {
//changeValue:是否 加|减
//获取当前变动属性
let productSelect = this.productValue[this.attrValue]
//如果没有属性,赋值给商品默认库存
if (productSelect === undefined && !this.attr.productAttr.length) {
productSelect = this.attr.productSelect
}
//无属性值即库存为0;不存在加减;
if (productSelect === undefined) return
let stock = productSelect.stock || 0
let num = this.attr.productSelect
if (changeValue) {
num.cart_num++
if (num.cart_num > stock) {
this.$set(this.attr.productSelect, 'cart_num', stock)
this.$set(this, 'cart_num', stock)
} else {
this.$set(this.attr.productSelect, 'cart_num', num.cart_num)
this.$set(this, 'cart_num', num.cart_num)
}
} else {
num.cart_num--
if (num.cart_num < 1) {
this.$set(this.attr.productSelect, 'cart_num', 1)
this.$set(this, 'cart_num', 1)
} else {
this.$set(this.attr.productSelect, 'cart_num', num.cart_num)
this.$set(this, 'cart_num', num.cart_num)
}
}
},
//将父级向子集多次传送的函数合二为一;
changeFun: function(opt) {
if (typeof opt !== 'object') opt = {}
let action = opt.action || ''
let value = opt.value === undefined ? '' : opt.value
this[action] && this[action](value)
},
//打开优惠券插件;
couponTap: function() {
let that = this
that.coupons()
that.coupon.coupon = true
},
changecoupon: function(msg) {
this.coupon.coupon = msg
this.coupons()
},
currentcoupon: function(res) {
let that = this
that.coupon.coupon = false
that.$set(that.coupon.list[res], 'is_use', true)
},
//可领取优惠券接口;
coupons: function() {
let that = this,
q = {
page: 1,
limit: 20,
}
getCoupon(q).then(res => {
that.$set(that, 'couponList', res.data || [])
that.$set(that.coupon, 'list', res.data)
})
},
//打开属性插件;
selecAttrTap: function() {
this.attr.cartAttr = true
this.isOpen = true
},
changeattr: function(msg) {
// 修改了规格
console.log(msg)
this.attr.cartAttr = msg
this.isOpen = false
},
//选择属性;
ChangeAttr: function(res) {
// 修改了规格
let productSelect = this.productValue[res.value]
console.log(productSelect)
if (productSelect) {
this.attr.productAttr[res.indexw].index = res.indexn
this.$set(this.attr.productSelect, 'image', productSelect.image)
this.$set(this.attr.productSelect, 'price', productSelect.price)
this.$set(this.attr.productSelect, 'otPrice', productSelect.otPrice)
this.$set(this.attr.productSelect, 'stock', productSelect.stock)
this.$set(this.attr.productSelect, 'unique', productSelect.unique)
this.$set(this.attr.productSelect, 'integral', productSelect.integral)
this.$set(this.attr.productSelect, 'cart_num', 1)
this.$set(this, 'attrValue', res.value)
this.$set(this, 'attrTxt', '已选择')
let stock = productSelect.stock || 0;
let num = this.attr.productSelect;
if (num.cart_num > stock) {
this.$set(this, 'cart_num', stock)
} else {
this.$set(this, 'cart_num', 1)
}
} else {
this.$set(this.attr.productSelect, 'image', this.storeInfo.image)
this.$set(this.attr.productSelect, 'price', this.storeInfo.price)
this.$set(this.attr.productSelect, 'otPrice', this.storeInfo.otPrice)
this.$set(this.attr.productSelect, 'integral', this.storeInfo.price)
this.$set(this.attr.productSelect, 'stock', 0)
this.$set(this.attr.productSelect, 'unique', '')
this.$set(this.attr.productSelect, 'cart_num', 0)
this.$set(this, 'attrValue', '')
this.$set(this, 'attrTxt', '请选择')
}
},
//收藏商品
setCollect: function() {
let that = this,
id = that.storeInfo.id,
category = 'collect'
if (that.storeInfo.userCollect) {
getCollectDel(id, category).then(function() {
that.storeInfo.userCollect = !that.storeInfo.userCollect
})
} else {
getCollectAdd(id, category).then(function() {
that.storeInfo.userCollect = !that.storeInfo.userCollect
})
}
},
// 点击加入购物车按钮
joinCart: function() {
//0=加入购物车
this.goCat(0)
},
// 加入购物车;
goCat: function(news) {
let that = this,
productSelect = that.productValue[this.attrValue]
//打开属性
if (that.attrValue) {
//默认选中了属性,但是没有打开过属性弹窗还是自动打开让用户查看默认选中的属性
that.attr.cartAttr = !that.isOpen ? true : false
} else {
if (that.isOpen) that.attr.cartAttr = true
else that.attr.cartAttr = !that.attr.cartAttr
}
//只有关闭属性弹窗时进行加入购物车
if (that.attr.cartAttr === true && that.isOpen === false) return (that.isOpen = true)
//如果有属性,没有选择,提示用户选择
if (that.attr.productAttr.length && productSelect === undefined && that.isOpen === true) {
uni.showToast({
title: '产品库存不足,请选择其它',
icon: 'none',
duration: 2000,
})
return
}
let q = {
productId: that.id,
cartNum: that.attr.productSelect.cart_num,
new: news,
uniqueId: that.attr.productSelect !== undefined ? that.attr.productSelect.unique : '',
}
postCartAdd(q)
.then(function(res) {
console.log(res)
that.isOpen = false
that.attr.cartAttr = false
if (news) {
if (!res.data) {
uni.showToast({
title: res.msg || res.data.msg || res.data.message,
icon: 'none',
duration: 2000,
})
return
}
that.$yrouter.push({
path: '/pages/order/OrderSubmission/index',
query: {
id: res.data.cartId,
isIntegral: that.isIntegral,
},
})
} else {
uni.showToast({
title: '添加购物车成功',
icon: 'success',
duration: 2000,
complete: () => {
that.getCartCount(true)
},
})
}
})
.catch(error => {
console.log(error)
that.isOpen = false
uni.showToast({
title: error.msg || error.response.data.msg || error.response.data.message,
icon: 'none',
duration: 2000,
})
})
},
//获取购物车数量
getCartCount: function(isAnima) {
let that = this
const isLogin = that.isLogin
if (isLogin) {
getCartCount({
numType: 0,
}).then(res => {
that.CartCount = res.data.count
//加入购物车后重置属性
if (isAnima) {
that.animated = true
setTimeout(function() {
that.animated = false
}, 500)
}
})
}
},
//立即购买;
tapBuy: function() {
// 1=直接购买
this.goCat(1)
},
linktap(e) {
console.log('description', e.innerText);
// var ctx = this.selectComponent('#article');
// console.log('description11111111', ctx);
if (e.innerText == this.entryInfo.entryName) {
this.showEntry = true;
return;
}
getEntry({
name: e.innerText
}).then(res => {
this.entryInfo = res.data;
this.showEntry = true;
})
},
closeEntry() {
this.showEntry = false;
},
listenerActionSheet: function() {
if (isWeixin() === true) {
this.weixinStatus = true
}
this.posters = true
},
listenerActionClose: function() {
this.posters = false
},
setOpenShare: function() {
var data = this.storeInfo
var href = this.location.href
if (this.$deviceType == 'weixin') {
if (this.isLogin) {
getUserInfo().then(res => {
href = href.indexOf('?') === -1 ? href + '?spread=' + res.data.uid : href +
'&spread=' + res.data.uid
var configAppMessage = {
desc: data.storeInfo,
title: data.storeName,
link: href,
imgUrl: data.image,
}
wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData'],
configAppMessage)
.then(res => {})
.catch(res => {
if (res.is_ready) {
res.wx.updateAppMessageShareData(configAppMessage)
res.wx.updateTimelineShareData(configAppMessage)
}
})
})
} else {
var configAppMessage = {
desc: data.storeInfo,
title: data.storeName,
link: href,
imgUrl: data.image,
}
wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData'], configAppMessage)
.then(res => {})
.catch(res => {
if (res.is_ready) {
res.wx.updateAppMessageShareData(configAppMessage)
res.wx.updateTimelineShareData(configAppMessage)
}
})
}
}
},
},
}
</script>
<style scoped lang="less">
// .geoPage {
// position: fixed;
// width: 100%;
// height: 100%;
// top: 0;
// z-index: 10000;
// }
.header {
.backImg {
width: 88rpx;
height: 62rpx;
padding-left: 26rpx;
image {
width: 100%;
height: 100%;
}
}
.tab-title {
font-size: 34rpx;
font-family: SourceHanSansSCVF;
font-weight: 500;
color: #3A3A3C;
line-height: 50rpx;
padding-left: 14rpx;
}
.brand-img {
width: 62rpx;
height: 62rpx;
padding: 4rpx;
box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.15);
border-radius: 50%;
background: linear-gradient(135deg, rgba(57, 211, 150, 1), rgba(27, 141, 204, 1));
image {
width: 100%;
height: 100%;
border-radius: 50%;
background-color: #FFFFFF;
}
}
}
.brand-info-box {
height: 108rpx;
// box-shadow: 0px 5px 8px 0px rgba(0,0,0,0.15);
position: relative;
margin: 2rpx 32rpx 32rpx;
.brand-logo-box {
position: absolute;
top: 8rpx;
left: 0;
width: 92rpx;
height: 92rpx;
box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.15);
padding: 4rpx;
background: linear-gradient(135deg, rgba(57, 211, 150, 1), rgba(27, 141, 204, 1));
border-radius: 50%;
.img {
width: 100%;
height: 100%;
background-color: #FFFFFF;
border-radius: 50%;
}
}
.info-box {
width: 638rpx;
height: 108rpx;
background: #F5F6F8;
box-shadow: 0rpx 10rpx 16rpx 0rpx rgba(0, 0, 0, 0.06);
border-radius: 16rpx;
margin-left: 46rpx;
padding: 4rpx 32rpx 6px 74rpx;
.brand-name {
font-size: 17px;
font-family: SourceHanSansSCVF-Bold, SourceHanSansSCVF;
font-weight: bold;
color: #3A3A3C;
line-height: 25px;
}
.brand-tips {
.tip {
width: 80rpx;
height: 26rpx;
background: #2DB5AE;
border-radius: 6rpx;
margin-right: 4rpx;
font-size: 16rpx;
font-family: PingFang SC;
color: #FFFFFF;
line-height: 26rpx;
text-align: center;
}
}
.info {
font-size: 20rpx;
font-family: PingFang SC;
color: #2DB5AE;
line-height: 22rpx;
}
}
}
.wrapper {
.introduceInfo {
font-size: 20rpx;
font-family: SourceHanSansSCVF;
font-weight: 600;
color: #999999;
line-height: 28rpx;
}
.tips {
padding-top: 4rpx;
.tip {
width: 80rpx;
height: 26rpx;
background: #2DB5AE;
border-radius: 6rpx;
margin-right: 4rpx;
font-size: 16rpx;
font-family: PingFang SC;
color: #FFFFFF;
line-height: 26rpx;
text-align: center;
margin-right: 20rpx;
}
}
}
.product-con .attribute {
.attr-content {
width: 548rpx;
padding-left: 20rpx;
padding-right: 12rpx;
image {
width: 46rpx;
height: 46rpx;
border-radius: 8rpx;
border: 2rpx solid #E3E3E3;
margin-right: 20rpx;
}
.attrs {
padding: 0rpx 8rpx;
min-width: 158rpx;
height: 46rpx;
background: #E3E3E3;
border-radius: 8rpx;
font-size: 20rpx;
font-family: PingFang SC;
font-weight: 500;
color: #999999;
line-height: 46rpx;
text-align: center;
}
}
}
.jiantou-right {
width: 0;
height: 0;
border-top: 6rpx solid transparent;
border-left: 10rpx solid #2DB5AE;
border-bottom: 6rpx solid transparent;
border-right: 0rpx solid transparent;
margin-left: 8rpx;
}
.safeguard-info {
width: 686rpx;
height: 120rpx;
background: #F5F6F8;
box-shadow: 0rpx 10rpx 16rpx 0rpx rgba(0, 0, 0, 0.06);
border-radius: 16rpx;
padding: 18rpx 0rpx;
margin: 0rpx 32rpx 20rpx;
.safeguard-item {
flex: 1;
// width: 226rpx;
height: 84rpx;
border-right: 2rpx solid #979797;
font-size: 20rpx;
font-family: SourceHanSansSCVF;
font-weight: 600;
color: #999999;
line-height: 28rpx;
text-align: center;
.img {
width: 46rpx;
height: 46rpx;
margin-top: 2rpx;
}
}
.safeguard-item:last-child {
border-right: 0;
}
// .line {
// width: 2rpx;
// height: 84rpx;
// background-color: #979797;
// }
}
.userEvaluation .title .replyCount {
font-size: 20rpx;
font-family: PingFang SC;
font-weight: 500;
color: #3A3A3C;
padding-left: 8rpx;
}
.product-parameter {
// max-height: 294rpx;
margin: 0rpx 32rpx 20rpx;
padding: 16rpx 24rpx;
background: #F5F6F8;
box-shadow: 0rpx 10rpx 16rpx 0rpx rgba(0, 0, 0, 0.06);
border-radius: 16rpx;
position: relative;
transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
.title {
font-size: 30rpx;
font-family: SourceHanSansSCVF;
font-weight: 600;
color: #3A3A3C;
line-height: 46rpx;
padding-bottom: 22rpx;
}
.parameter-list {
overflow: hidden;
// transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
.parameter-item {
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 500;
color: #3A3A3C;
line-height: 40rpx;
padding-bottom: 6rpx;
.parameter-name {
padding: 0rpx 20rpx;
width: 172rpx;
height: 40rpx;
background: #E3E3E3;
margin-right: 6rpx;
}
.parameter {
padding: 0rpx 20rpx;
width: 460rpx;
height: 40rpx;
background: #E3E3E3;
}
}
}
.unfold {
overflow: visible;
padding-bottom: 26rpx;
transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
}
.more-box {
width: 686rpx;
height: 76rpx;
border-radius: 0rpx 0rpx 16rpx 16rpx;
padding-top: 10rpx;
position: absolute;
left: 0;
bottom: 0;
// z-index: 1;
background: linear-gradient(180deg, rgba(243, 243, 243, 0.4) 0%, #FFFFFF 100%);
font-size: 20rpx;
font-family: PingFang SC;
font-weight: 500;
color: #999999;
line-height: 26rpx;
}
}
.jiantou-up {
width: 0;
height: 0;
border-top: 0rpx solid transparent;
border-left: 6rpx solid transparent;
border-bottom: 10rpx solid #999999;
border-right: 6rpx solid transparent;
margin-left: 8rpx;
}
.jiantou-down {
width: 0;
height: 0;
border-top: 10rpx solid #999999;
border-left: 6rpx solid transparent;
border-bottom: 0rpx solid transparent;
border-right: 6rpx solid transparent;
margin-left: 8rpx;
}
.product-con .footer .item {
width: 66rpx;
.img {
padding-top: 12rpx;
width: 50rpx;
height: 62rpx;
position: relative;
margin: 0rpx auto;
image {
width: 100%;
height: 100%;
}
.num {
position: absolute;
top: 10rpx;
right: -4rpx;
min-width: 20rpx;
height: 20rpx;
background: #F1F1F1;
border-radius: 12rpx;
border: 2rpx solid #2DB5AE;
font-size: 16rpx;
font-family: PingFang SC;
font-weight: 400;
color: #2DB5AE;
line-height: 20rpx;
text-align: center;
}
}
}
// .product-con .store-info {
// margin-top: 0.2 * 100rpx;
// background-color: #fff;
// }
// .product-con .store-info .title {
// padding: 0 0.3 * 100rpx;
// font-size: 0.28 * 100rpx;
// color: #282828;
// height: 0.8 * 100rpx;
// line-height: 0.8 * 100rpx;
// border-bottom: 0.01 * 100rpx solid #f5f5f5;
// }
// .product-con .store-info .info {
// padding: 0 0.3 * 100rpx;
// height: 1.26 * 100rpx;
// }
// .product-con .store-info .info .picTxt {
// width: 100%;
// display: flex;
// align-items: center;
// }
// .product-con .store-info .info .picTxt .pictrue {
// width: 0.76 * 100rpx;
// height: 0.76 * 100rpx;
// margin-right: 0.2 * 100rpx;
// }
// .product-con .store-info .info .picTxt .pictrue image {
// width: 100%;
// height: 100%;
// border-radius: 0.06 * 100rpx;
// }
// .product-con .store-info .info .picTxt .text {
// flex: 1;
// }
// .product-con .store-info .info .picTxt .text .name {
// font-size: 0.3 * 100rpx;
// color: #282828;
// }
// .product-con .store-info .info .picTxt .text .address {
// font-size: 0.24 * 100rpx;
// color: #666;
// margin-top: 0.03 * 100rpx;
// }
// .product-con .store-info .info .picTxt .text .address .iconfont {
// color: #707070;
// font-size: 0.18 * 100rpx;
// margin-left: 0.1 * 100rpx;
// }
// .product-con .store-info .info .picTxt .addressBox {
// display: flex;
// flex-direction: column;
// align-items: flex-end;
// }
// .product-con .store-info .info .picTxt .addressBox .iconfont {
// font-size: 0.4 * 100rpx;
// }
// .product-con .store-info .info .picTxt .addressBox .addressTxt {
// font-size: 0.24 * 100rpx;
// color: #eb3729;
// }
// .product-con .store-info .praise {
// font-size: 0.28 * 100rpx;
// color: #808080;
// }
// .product-con .store-info .praise .iconfont {
// font-size: 0.28 * 100rpx;
// }
// .product-con .superior {
// background-color: #fff;
// margin-top: 0.2 * 100rpx;
// }
// .product-con .superior .title {
// height: 0.98 * 100rpx;
// }
// .product-con .superior .title image {
// width: 0.3 * 100rpx;
// height: 0.3 * 100rpx;
// }
// .product-con .superior .title .titleTxt {
// margin: 0 0.2 * 100rpx;
// font-size: 0.3 * 100rpx;
// background-image: linear-gradient(to right, #f57a37 0%, #f21b07 100%);
// background-image: -webkit-linear-gradient(to right, #f57a37 0%, #f21b07 100%);
// background-image: -moz-linear-gradient(to right, #f57a37 0%, #f21b07 100%);
// -webkit-background-clip: text;
// -webkit-text-fill-color: transparent;
// }
// .product-con .superior .slider-banner {
// width: 6.9 * 100rpx;
// margin: 0 auto;
// padding-bottom: 0.2 * 100rpx;
// }
// .product-con .superior .slider-banner .list {
// width: 100%;
// padding-bottom: 0.2 * 100rpx;
// }
// .product-con .superior .slider-banner .list .item {
// width: 2.15 * 100rpx;
// margin: 0 0.22 * 100rpx 0.3 * 100rpx 0;
// font-size: 0.26 * 100rpx;
// }
// .product-con .superior .slider-banner .list .item:nth-of-type(3n) {
// margin-right: 0;
// }
// .product-con .superior .slider-banner .list .item .pictrue {
// width: 100%;
// height: 2.15 * 100rpx;
// }
// .product-con .superior .slider-banner .list .item .pictrue image {
// width: 100%;
// height: 100%;
// border-radius: 0.06 * 100rpx;
// }
// .product-con .superior .slider-banner .list .item .name {
// color: #282828;
// margin-top: 0.12 * 100rpx;
// }
// .product-con .superior .slider-banner .swiper-pagination-bullet {
// background-color: #999;
// }
// .product-con .superior .slider-banner .swiper-pagination-bullet-active {
// background-color: #e93323;
// }
.mask {
-webkit-filter: blur(2px);
-moz-filter: blur(2px);
-ms-filter: blur(2px);
filter: blur(2px);
}
.product-con .product-intro .conter {
background-color: #FFFFFF;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 500;
color: #3A3A3C;
// line-height: 32rpx;
padding: 0rpx 30rpx;
view {
width: 100% !important;
}
}
.generate-posters {
width: 100%;
height: 1.7 * 100rpx;
background-color: #fff;
position: fixed;
left: 0;
bottom: 0;
z-index: 99;
transform: translate3d(0, 100%, 0);
-webkit-transform: translate3d(0, 100%, 0);
-ms-transform: translate3d(0, 100%, 0);
-moz-transform: translate3d(0, 100%, 0);
-o-transform: translate3d(0, 100%, 0);
transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
-webkit-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
-moz-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
-o-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
}
.generate-posters.on {
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
}
.generate-posters .item {
flex: 50%;
-webkit-flex: 50%;
-ms-flex: 50%;
text-align: center;
}
.generate-posters .item .iconfont {
font-size: 0.8 * 100rpx;
color: #5eae72;
}
.generate-posters .item .iconfont.icon-haibao {
color: #5391f1;
}
.noscroll {
height: 100%;
overflow: hidden;
}
</style>