123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774 |
- <template>
- <view class="goodsDetail">
- <zs-skeleton type="goodsDetail" :loading="pageLoading"></zs-skeleton>
- <image class="good-img" :src="info.goodsPath + '?x-oss-process=image/resize,h_750,w_750,m_fixed'" mode="aspectFit">
- </image>
- <view class="content">
- <view class="price-box">
- <view class="price">
- <view class="unit">¥</view>
- <view class="price">
- {{ info.realPrice }}
- </view>
- </view>
- <view class="old-price">
- 市场价{{ info.marketPrice }}
- </view>
- </view>
- <view class="title">
- {{ info.goodsName }}
- </view>
- <view class="desc">
- {{ info.goodsDescribe }}
- </view>
- <view class="ag">
- <u-avatar-group :urls="urls" size="44" gap="0.1" maxCount="10"></u-avatar-group>
- <view class="">{{ info.saleNum || 0 }} 人已购</view>
- </view>
- <view class="subtitle">
- 出发日期
- </view>
- <view class="reservation" @click="openCalendar">
- <view class="text">
- <text style="color:#AAAAAA;margin-right:28rpx;"> 预定 </text> {{ reserveTime ? '预定' + $u.timeFormat(new
- Date(reserveTime), 'yyyy年mm月dd日') + '出发' :
- info.reservationDate || '' }}
- </view>
- <view>
- <image class="more" src="../static/jiantou-icon.png" mode=""></image>
- </view>
- </view>
- <!-- <view class="share" v-if="total > 0">
- <view class="top">
- <view class="title">研学分享</view>
- <view class="more" @click="toShare">{{ total }}分享<image class="img" src="../static/jiantou-icon.png" mode="">
- </image>
- </view>
- </view>
- <view class="user">
- <view class="userinfo">
- <view class="avatar">
- <u-avatar size="60" :src="info.share.imgPath"></u-avatar>
- </view>
- <view class="username">{{ info.share.nickname }}</view>
- </view>
- <view class="date">{{ info.share.showTime }}</view>
- </view>
- <view class="share-content">
- <view class="content-text">{{ info.share.communityDetail }}</view>
- <view style="position: relative;" @click="clickImg">
- <image class="content-image" :src="info.share.coverImg">
- </image>
- <view class="overlay">+{{ info.share.urls.length }}</view>
- </view>
- </view>
- </view> -->
- </view>
- <view class="tab-group">
- <view class="tab" :class="[tab == 1 ? 'active' : '']" @click="handleTab(1)">
- 详情介绍
- </view>
- <view class="tab" :class="[tab == 2 ? 'active' : '']" @click="handleTab(2)">
- 购买须知
- </view>
- </view>
- <view class="desc-box" v-show="tab == 1">
- <rich-text class="goods-desc" :nodes="info.goodsDetail"></rich-text>
- </view>
- <view class="list" v-show="tab == 2">
- <view class="item" v-for="(item, index) in info.attrs" :key="index">
- <view class="label">
- {{ item.attrName == 'validDay' ? '有效期' : item.attrName }}
- </view>
- <view class="value" v-html="filterMsg(item.attrValue, item.attrName)">
- </view>
- </view>
- <!-- <view class="item">
- <view class="label">
- 使用时间
- </view>
- <view class="value">
- 营业时间内可用
- </view>
- </view> -->
- </view>
- <view class="buy-box">
- <!-- <image class="head" :src="shopInfo.logoPath" @click="goShopDetail(shopInfo)" mode=""></image> -->
- <view class="btn-box">
- <view class="buy-btn" :class="[info.realStockNum ? '' : 'none']" @click="handleQuery">
- <view class="label">
- 预约咨询
- </view>
- </view>
- <view class="buy-btn" :class="[info.realStockNum ? '' : 'none']" @click="handleBuy">
- <view class="label">
- {{ info.realStockNum ? '报名支付' : '售罄' }}
- </view>
- </view>
- </view>
- </view>
- <uni-calendar @monthSwitch="chnageMonth" :date="selectDate" :selected="selected" clearDate ref="calendar"
- :showMonth="false" style="z-index: 999;" @change="selectChange" :insert="false" @confirm="confirm"
- @close="closeCalendar">
- </uni-calendar>
- </view>
- </template>
- <script>
- import { detail, getStudyAbout, goodsBuyStatistic } from '@/api/goods.js'
- import { subscribe } from "@/api/study"
- export default {
- data() {
- return {
- pageLoading: false,
- active: 0,
- tab: 1,
- shopList: [],
- isSubscribe: false,
- info: {
- share: {
- urls: []
- }
- },
- total: 0,
- shopInfo: {},
- urls: [
- "https://fakeimg.pl/22x22/?text=🫡&font_size=22",
- "https://fakeimg.pl/22x22/?text=🤣&font_size=22",
- "https://fakeimg.pl/22x22/?text=😍&font_size=22",
- "https://fakeimg.pl/22x22/?text=😒&font_size=22",
- "https://fakeimg.pl/22x22/?text=😉&font_size=22",
- "https://fakeimg.pl/22x22/?text=😎&font_size=22",
- "https://fakeimg.pl/22x22/?text=😁&font_size=22",
- "https://fakeimg.pl/22x22/?text=😘&font_size=22",
- ],
- goodsId: "",
- selected: [],
- reserveTime: "",
- selectDate: "",
- id:'',
- }
- },
- methods: {
- choose(index) {
- this.active = index
- },
- filterMsg(val, name) {
- let msg = val.replace(/\n/g, "<br>")
- if (name == 'validDay') {
- msg = val + '天'
- }
- return msg
- },
- jump(url) {
- uni.navigateTo({
- url
- })
- },
- handleTab(val) {
- this.tab = val
- },
- handleQuery() {
- uni.showToast({
- title: '请选择需要咨询的日期',
- icon: 'none'
- });
- this.isSubscribe = true
- this.openCalendar()
- },
- handleBuy() {
- if (!this.reserveTime) {
- uni.showToast({
- title: '请选择出发日期',
- icon: 'none'
- });
- this.chnageMonth({
- year: new Date().getFullYear(),
- month: new Date().getMonth() + 1
- }, true)
- return
- }
- this.info.reserveTime = this.reserveTime
- if (!this.info.realStockNum) return
- let that = this
- if (uni.getStorageSync('token')) {
- if (JSON.parse(uni.getStorageSync('userInfo')).setMealCode != 0&&JSON.parse(uni.getStorageSync('userInfo')).setMealCode) {
- uni.navigateTo({
- url: `/study/pay/order`,
- success: function (res) {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('pay', that.info)
- }
- })
- } else {
- uni.showModal({
- title: '此商品需要开通会员才能购买',
- cancelText: '下次再说',
- confirmText: '立即开通',
- success(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/my/memberCenter/index'
- })
- }
- }
- })
- }
- } else {
- uni.showModal({
- title: '请登录',
- confirmText: '去登录',
- success(res) {
- console.log(res);
- if (res.confirm) {
- uni.navigateTo({
- url: `/login/login/login?redirect=/study/studyGoodsDetail&id=${that.info.goodsId}`
- })
- }
- }
- })
- }
- },
- detail(goodsId) {
- this.pageLoading = true
- this.goodsId = goodsId
- detail({ goodsId, resource: 2 }).then(res => {
- this.pageLoading = false
- if (res.state == 'Success') {
- this.info = res.content
- this.info.goodsDetail = res.content.goodsDetail.replace(/<img/gi, '<img class="img_class" ')
- this.shopId = res.content.shopId
- uni.setNavigationBarTitle({
- title: this.info.goodsName
- })
- this.chnageMonth({
- year: new Date().getFullYear(),
- month: new Date().getMonth() + 1
- })
- getStudyAbout({ goodsId }).then(({ content }) => {
- try {
- this.urls = content.buyStatisVo?.list?.map(e => e.imgPath);
- } catch (error) {
- }
- this.info.reservationDate = content.msg
- if (content.newlyTime) {
- this.selectDate = this.$u.timeFormat(new Date(content.newlyTime), 'yyyy-mm-dd')
- } else {
- uni.showToast({
- title: '无可购买日期',
- duration: 2000,
- icon: 'none'
- });
- this.info.realStockNum = 0
- }
- const { communityVo } = content
- const { list, total } = communityVo
- this.total = total
- const [item] = list
- this.info.share = {
- communityDetail: item.communityDetail,
- coverImg: item.coverImg,
- nickname: item.nickname,
- imgPath: item.imgPath,
- showTime: item.showTime,
- urls: item.urls
- }
- this.info.saleNum = content.buyStatisVo.total
- this.$forceUpdate()
- })
- }
- })
- },
- goShopDetail(shopInfo) {
- uni.setStorageSync('shopInfo', JSON.stringify(shopInfo))
- uni.navigateTo({
- url: `/detail/shopDetail/shopDetail`
- })
- },
- openCalendar() {
- this.$refs.calendar.open();
- },
- closeCalendar() {
- this.isSubscribe = false
- },
- selectChange({ fulldate }) {
- console.log(fulldate)
- this.selectDate = fulldate
- },
- confirm({ fulldate }) {
- this.reserveTime = fulldate
- this.selectDate = fulldate
- try {
- const user = JSON.parse(uni.getStorageSync('userInfo'))
- if (this.isSubscribe) {
- this.isSubscribe = false
- subscribe({
- userId: user.userId,
- goodsId: this.goodsId,
- shopId: this.shopId,
- reservationTime: fulldate,
- }).then(res => {
- if (res.state == 'Success') {
- uni.showToast({
- title: '预约成功,请您耐心等待客服电话',
- icon: 'none'
- });
- }
- })
- }
- } catch (error) {
- }
- },
- // 更改月份后获取新月份的可售卖日期
- chnageMonth({ year, month }, open = false) {
- goodsBuyStatistic({
- goodsId: this.info.goodsId,
- year,
- month
- }).then(res => {
- // console.log(res)
- this.selected = res.content.map(e => {
- if (e.isOpenSeal) {
- return {
- date: `${e.year}-${e.month}-${e.day}`,
- info: '可选',
- disable: false,
- notic: false,
- color: '#2979ff'
- }
- } else {
- return {
- date: `${e.year}-${e.month}-${e.day}`,
- disable: true,
- notic: false,
- color: '#2979ff'
- }
- }
- })
- if (open) {
- this.openCalendar()
- }
- // this.selectDate = this.selected.find(e => !e.disable)?.date;
- // console.log('this.selectDate', this.selectDate);
- // if (!this.selectDate) {
- // // 看下个月
- // let dateTime = new Date();
- // dateTime = dateTime.setMonth(dateTime.getMonth() + 1);
- // dateTime = new Date(dateTime);
- // this.chnageMonth({
- // year: dateTime.getFullYear(),
- // month: dateTime.getMonth() + 1
- // })
- // }
- })
- },
- clickImg() {
- uni.previewImage({
- urls: this.info.share.urls,
- longPressActions: {
- itemList: ['发送给朋友', '保存图片', '收藏'],
- success: function (data) {
- console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
- },
- fail: function (err) {
- console.log(err.errMsg);
- }
- }
- });
- },
- toShare() {
- uni.navigateTo({
- url: '/share/index?goodsId=' + this.goodsId
- });
- }
- },
- onLoad(option) {
- try {
- this.shopInfo = JSON.parse(uni.getStorageSync('shopInfo'))
- } catch (error) {
- console.log("未读取到对应缓存")
- }
- this.id = option.id
- this.detail(option.id)
- },
- onShareTimeline() {
- return {
- title: "慧研学惠生活-" + this.info.goodsName,
- query: "id=" + this.id,
- };
- },
- onShareAppMessage() {
- return {
- title: "慧研学惠生活-" + this.info.goodsName,
- path: "/study/studyGoodsDetail?id=" + this.id,
- };
- },
- }
- </script>
- <style lang="scss">
- .goodsDetail {
- background: #F9F9F9;
- padding-bottom: 200rpx;
- min-height: 100vh;
- .good-img {
- width: 100%;
- height: 750rpx;
- vertical-align: bottom;
- }
- .content {
- background-color: #FFFFFF;
- padding: 20rpx;
- border-radius: 16rpx 16rpx 0rpx 0rpx;
- margin-top: -16rpx;
- overflow: overlay;
- .price-box {
- display: flex;
- align-items: center;
- .price {
- display: flex;
- align-items: baseline;
- font-weight: bold;
- .unit {
- font-size: 20rpx;
- color: #FF4D3A;
- }
- .price {
- font-size: 56rpx;
- color: #FF4D3A;
- }
- }
- .old-price {
- font-size: 24rpx;
- color: #AAAAAA;
- text-decoration: line-through;
- margin-left: 22rpx;
- }
- }
- .title {
- margin-top: 16rpx;
- font-size: 36rpx;
- color: #222222;
- font-weight: bold;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- /* 显示的最大行数 */
- overflow: hidden;
- }
- .desc {
- margin-top: 16rpx;
- font-size: 24rpx;
- color: #AAAAAA;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- /* 显示的最大行数 */
- overflow: hidden;
- }
- .ag {
- margin: 28rpx 0;
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 24rpx;
- color: #AAAAAA;
- }
- .subtitle {
- margin-bottom: 20rpx;
- font-size: 32rpx;
- font-weight: bold;
- }
- .reservation {
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 28rpx;
- padding: 28rpx;
- background-color: #F9F9F9;
- // margin-bottom: 28rpx;
- border-radius: 8rpx;
- .text {
- color: #222222;
- }
- .more {
- width: 16rpx;
- height: 16rpx;
- }
- }
- .share {
- padding: 24rpx;
- background-color: #F9F9F9;
- .top {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .title {
- color: #222222;
- font-weight: bold;
- font-size: 32rpx;
- margin-top: 0;
- }
- .more {
- color: #AAAAAA;
- font-size: 24rpx;
- .img {
- width: 16rpx;
- height: 16rpx;
- margin-left: 20rpx;
- }
- }
- margin-bottom: 20rpx;
- }
- .user {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 16rpx;
- .userinfo {
- display: flex;
- align-items: center;
- .avatar {
- width: 60rpx;
- height: 60rpx;
- }
- .username {
- margin-left: 16rpx;
- font-size: 28rpx;
- color: #222222;
- }
- }
- .date {
- font-size: 20rpx;
- color: #AAAAAA;
- }
- }
- }
- .share-content {
- display: flex;
- justify-content: space-between;
- .content-text {
- padding: 8rpx;
- width: 70%;
- font-size: 24rpx;
- color: #222222;
- word-break: break-all;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 4;
- /* 显示的最大行数 */
- overflow: hidden;
- }
- .content-image {
- position: relative;
- width: 160rpx;
- height: 160rpx;
- margin-left: 28rpx;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- }
- .overlay {
- position: absolute;
- bottom: 10rpx;
- right: 0rpx;
- background: rgba(0, 0, 0, 0.6);
- color: white;
- border-radius: 16rpx 0 16rpx 0;
- text-align: center;
- line-height: 52rpx;
- font-size: 24rpx;
- font-weight: bold;
- width: 52rpx;
- height: 52rpx;
- }
- }
- }
- .tab-group {
- display: flex;
- background: #fff;
- .tab {
- flex: 1;
- padding: 0 0 24rpx 0;
- text-align: center;
- font-size: 28rpx;
- color: #222222;
- }
- .tab.active {
- font-weight: 600;
- }
- }
- .desc-box {
- .goods-desc {
- color: #222222;
- font-size: 24rpx;
- .img_class {
- max-width: 100% !important;
- vertical-align: bottom;
- }
- }
- }
- .list {
- background: #fff;
- .item {
- padding: 24rpx;
- border-top: 1rpx solid #F0F0F0;
- .label {
- font-weight: 600;
- font-size: 28rpx;
- color: #222222;
- }
- .value {
- font-size: 24rpx;
- color: #AAAAAA;
- margin-top: 16rpx;
- line-height: 40rpx;
- }
- }
- }
- .buy-box {
- position: fixed;
- bottom: 0%;
- left: 0%;
- width: 100%;
- background: #fff;
- padding: 10rpx 24rpx 76rpx;
- display: flex;
- justify-content: space-between;
- box-sizing: border-box;
- .head {
- width: 80rpx;
- height: 80rpx;
- background: #aaa;
- border-radius: 50%;
- }
- .btn-box {
- width: 100%;
- display: flex;
- text-align: center;
- justify-content: space-between;
- .group-btn {
- width: 280rpx;
- height: 80rpx;
- background: #6499FF;
- border-radius: 40rpx 0rpx 0rpx 40rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- .label {
- font-weight: 600;
- font-size: 28rpx;
- color: #FFFFFF;
- }
- .price {
- font-size: 24rpx;
- color: #FFFFFF;
- }
- }
- .buy-btn.none {
- filter: grayscale(1);
- }
- .buy-btn {
- width: 344rpx;
- // width: 560rpx;
- height: 80rpx;
- background: #3B83FF;
- border-radius: 40rpx;
- // border-radius: 0rpx 40rpx 40rpx 0rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- &:nth-child(1) {
- background: transparent;
- border: 1rpx solid #3B83FF;
- .label {
- color: #3B83FF;
- }
- }
- .label {
- font-weight: 600;
- font-size: 28rpx;
- color: #FFFFFF;
- }
- .price {
- font-size: 24rpx;
- color: #FFFFFF;
- }
- }
- }
- }
- }
- </style>
|