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.
777 lines
16 KiB
777 lines
16 KiB
<template>
|
|
<view class="goods-details">
|
|
<u-navbar id="navbar" :border-bottom="false"
|
|
:background="{ background: 'rgba(256,256,256, '+ navStyle.backgroundBg +')', }"
|
|
:back-bg="'rgba(0,0,0,' + navStyle.backBg + ')'" :back-icon-color="navStyle.backColor" :immersive="true">
|
|
<tabs sticky-bg-color="transparent" v-if="navStyle.backgroundBg > 0.1" :show-bar="true" :bar-width="60"
|
|
:is-scroll="false" :current="active" bg-color="transparent"
|
|
:style="{width: '100%', opacity: navStyle.backgroundBg}" @change="changeActive">
|
|
<tab name="资料"></tab>
|
|
<tab name="详情"></tab>
|
|
</tabs>
|
|
</u-navbar>
|
|
|
|
<view class="contain" v-if="!isNull" id="goods" @touchstart="isTouchStart = true">
|
|
|
|
<bubble-tips top="200rpx"></bubble-tips>
|
|
|
|
<product-swiper :imgUrls="swiperList" ></product-swiper>
|
|
|
|
|
|
<view class="goods-info bg-white">
|
|
<view class="info-header flex">
|
|
<view class="price flex flex-1">
|
|
<view class="primary m-r-10">
|
|
<text style="font-weight: 500" class="price-format">
|
|
<text style="font-size: 46rpx;margin-right: 1rpx" >{{resourceDetail.price_str}}</text>
|
|
</text>
|
|
</view>
|
|
</view>
|
|
<!-- <image class="icon-share" src="/static/images/icon_share.png" @tap="showShareBtn = true"></image> -->
|
|
</view>
|
|
<view class="flex">
|
|
<view class="name lg bold">{{ resourceDetail.title }}</view>
|
|
</view>
|
|
<view class="flex row-between xs lighter" style="padding: 0 24rpx 20rpx">
|
|
<text>区域: {{ resourceDetail.address }}</text>
|
|
<text>下载量: {{ resourceDetail.download }}</text>
|
|
<text>浏览量: {{ resourceDetail.visit }}</text>
|
|
|
|
</view>
|
|
</view>
|
|
|
|
<view>
|
|
<get-coupon :wrap-style="{'margin-top': '20rpx'}" :goods-id="resourceDetail.id"></get-coupon>
|
|
</view>
|
|
|
|
<view class="details m-t-20 bg-white" id="details">
|
|
<view class="title lg">资料简介</view>
|
|
<view class="content">
|
|
<u-parse :html="resourceDetail.content" :lazy-load="true" :show-with-animation="true"></u-parse>
|
|
</view>
|
|
</view>
|
|
<view class="footer flex bg-white fixed">
|
|
|
|
<template>
|
|
<view class="right-buy br60 white m-r-20 m-l-10 md" @click="doFun()" >{{ btnText.red }}</view>
|
|
</template>
|
|
|
|
</view>
|
|
</view>
|
|
<view v-else>
|
|
<view class="details-null flex-col col-center">
|
|
<image class="img-null" src="/static/images/goods_null.png"></image>
|
|
<view class="xs muted">该资料已经去星球外啦,去看看别的吧~</view>
|
|
</view>
|
|
<goods-column></goods-column>
|
|
</view>
|
|
|
|
<share-popup :show="showShareBtn" @close="showShareBtn = false" :goods-id="id" :img-url="resourceDetail.image"
|
|
:summary="resourceDetail.intro" :share-title="resourceDetail.title"></share-popup>
|
|
<!-- 悬浮按钮 -->
|
|
<float-tab></float-tab>
|
|
|
|
<loading-view v-if="isFirstLoading"></loading-view>
|
|
</view>
|
|
</template>
|
|
team_min_price
|
|
<script>
|
|
import {
|
|
resourceOrderBuy
|
|
} from '@/api/order';
|
|
import {
|
|
prepay,
|
|
getMnpNotice,
|
|
getPayway
|
|
} from '@/api/app';
|
|
import {
|
|
getResourceDetail,
|
|
getGoodsDetail,
|
|
resourcedownload
|
|
} from '@/api/store';
|
|
import {
|
|
collectGoods
|
|
} from '@/api/user';
|
|
import {
|
|
getCouponList,
|
|
teamCheck
|
|
} from '@/api/activity';
|
|
import {
|
|
mapActions,
|
|
mapGetters
|
|
} from 'vuex';
|
|
import {
|
|
toLogin
|
|
} from '@/utils/login';
|
|
import Cache from '@/utils/cache';
|
|
import {
|
|
strToParams,
|
|
arraySlice,
|
|
getRect,
|
|
getcu
|
|
} from '@/utils/tools'
|
|
const app = getApp()
|
|
export default {
|
|
data() {
|
|
return {
|
|
active: 0,
|
|
isTouchStart: false,
|
|
topArr: [],
|
|
isFirstLoading: true,
|
|
isNull: false,
|
|
isGroup: 0,
|
|
showSpec: false,
|
|
showCoupon: false,
|
|
showShareBtn: false,
|
|
showCommission: true,
|
|
popupType: '',
|
|
swiperList: [],
|
|
goodsDetail: {},
|
|
goodsType: 0,
|
|
checkedGoods: {},
|
|
comment: {},
|
|
countTime: 0,
|
|
team: {},
|
|
teamFound: [],
|
|
showtxt:[],
|
|
resourceDetail:{},
|
|
navStyle: {
|
|
backBg: 0.4,
|
|
backgroundBg: 0,
|
|
backColor: 'rgba(256,256,256,1)'
|
|
},
|
|
id: '',
|
|
shop: {},
|
|
// 分销
|
|
distribution: {}
|
|
};
|
|
},
|
|
onLoad() {
|
|
const options = this.$Route.query;
|
|
if (options && options.scene) {
|
|
const scene = strToParams(decodeURIComponent(options.scene));
|
|
options.id = scene.id;
|
|
}
|
|
this.id = options.id;
|
|
this.getResourceDetailFun();
|
|
},
|
|
onShow() {
|
|
|
|
},
|
|
onPageScroll(e) {
|
|
const top = uni.upx2px(500)
|
|
const {
|
|
scrollTop
|
|
} = e
|
|
const percent = scrollTop / top
|
|
this.navStyle.backgroundBg = percent
|
|
this.navStyle.backBg = 0.4 * (0.5 - percent)
|
|
this.navStyle.backColor = percent < 0.5 ? 'rgba(256,256,256,' + (0.5 - percent) * 2 + ')' : 'rgba(0,0,0,' +
|
|
(
|
|
percent - 0.5) * 2 + ')'
|
|
if (!this.isTouchStart) return
|
|
const topList = this.topArr.map((item, index) => ({
|
|
index,
|
|
top: item
|
|
}))
|
|
.filter(item => item.top <= scrollTop)
|
|
|
|
if (topList.length) {
|
|
const index = topList.sort((a, b) => b.top - a.top)[0].index
|
|
if (this.active == index) return
|
|
this.active = index
|
|
}
|
|
},
|
|
methods: {
|
|
...mapActions([ 'wxShare']),
|
|
doFun(){
|
|
console.log(1111)
|
|
const {
|
|
goodsType,
|
|
isLogin
|
|
} = this
|
|
if (!isLogin) {
|
|
uni.navigateTo({
|
|
url: '/pages/login/login'
|
|
});
|
|
return true;
|
|
}
|
|
|
|
//免费下载
|
|
if(goodsType == 0){
|
|
|
|
let msg = "下载中...";
|
|
this.showLoading = false
|
|
uni.showLoading({
|
|
title: msg
|
|
});
|
|
let that = this;
|
|
uni.downloadFile({
|
|
url: this.resourceDetail.path, //仅为示例,并非真实的资源
|
|
success: (res) => {
|
|
if (res.statusCode === 200) {
|
|
uni.saveFile({
|
|
tempFilePath: res.tempFilePath,
|
|
success: function (res2) {
|
|
that.downloadLog(that.resourceDetail.id);
|
|
var savedFilePath = res2.savedFilePath;
|
|
let msg = "文件存储到"+savedFilePath;
|
|
uni.showLoading({
|
|
title: msg
|
|
});
|
|
setTimeout(function () {
|
|
uni.hideLoading()
|
|
}, 2000);
|
|
},
|
|
fail: function(err) {
|
|
uni.showLoading({
|
|
title: "下载失败"
|
|
});
|
|
setTimeout(function () {
|
|
uni.hideLoading()
|
|
}, 2000);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
// uni.downloadFile({
|
|
// url: this.resourceDetail.path,//文件的下载路径
|
|
// success(res) {
|
|
// //保存到本地
|
|
// uni.saveFile({
|
|
// tempFilePath: res.tempFilePath,//文件的临时路径
|
|
// success: function(res) {
|
|
// const savedFilePath = res.savedFilePath;
|
|
// // 打开文件
|
|
// uni.openDocument({
|
|
// filePath: savedFilePath,
|
|
// success: function(res) {
|
|
// uni.hideLoading()
|
|
// },
|
|
// fail: function(res) {},
|
|
// complete: function(res) {
|
|
// setTimeout(uni.hideLoading(), 4000)
|
|
// },
|
|
// });
|
|
// },
|
|
// fail: function(err) { }
|
|
// });
|
|
// },
|
|
// fail(res) {}
|
|
// })
|
|
}else if(goodsType == 1){ //vip会员开通页面
|
|
uni.navigateTo({
|
|
url: '/pages/user/vip'
|
|
});
|
|
}else if(goodsType == 2){ //下单购买页面
|
|
console.log('购买页')
|
|
this.onSubmitOrder();
|
|
}
|
|
},
|
|
async downloadLog(id){
|
|
console.log("id:",id)
|
|
await resourcedownload({
|
|
id: id
|
|
});
|
|
setTimeout(() => {
|
|
this.getResourceDetailFun();
|
|
}, 500)
|
|
},
|
|
changeActive(index) {
|
|
this.isTouchStart = false
|
|
uni.pageScrollTo({
|
|
scrollTop: this.topArr[index],
|
|
duration: 200
|
|
});
|
|
},
|
|
getRectInfo() {
|
|
if (this.topArr.length) return
|
|
getRect('#goods').then((res) => {
|
|
this.topArr[0] = res.top - this.navHeight
|
|
})
|
|
getRect('#evaluation').then((res) => {
|
|
this.topArr[1] = res.top - this.navHeight
|
|
})
|
|
getRect('#details').then((res) => {
|
|
this.topArr[2] = res.top - this.navHeight
|
|
})
|
|
},
|
|
async getResourceDetailFun() {
|
|
const {
|
|
data,
|
|
code
|
|
} = await getResourceDetail({
|
|
id: this.id
|
|
});
|
|
if (code == 1) {
|
|
const {
|
|
image,
|
|
title,
|
|
content,
|
|
visit,
|
|
likes,
|
|
intro,
|
|
path,
|
|
price_str,
|
|
type,
|
|
goodsType,
|
|
address
|
|
} = data;
|
|
|
|
this.intro = intro || {}
|
|
this.image = image
|
|
this.resourceDetail = data;
|
|
this.swiperList = [{id:data.id,uri:image}];
|
|
console.log(this.swiperList)
|
|
this.goodsType = goodsType;
|
|
console.log(goodsType)
|
|
this.$nextTick(() => {
|
|
// 滚动到顶部,防止h5端出现问题
|
|
uni.pageScrollTo({
|
|
scrollTop: 0,
|
|
duration: 0,
|
|
});
|
|
this.isFirstLoading = false;
|
|
this.getRectInfo()
|
|
});
|
|
// #ifdef H5
|
|
const options = {
|
|
shareTitle: data.title,
|
|
shareImage: data.image,
|
|
shareDesc: data.intro
|
|
};
|
|
this.wxShare(options);
|
|
// #endif
|
|
} else {
|
|
this.isNull = true
|
|
this.isFirstLoading = false;
|
|
}
|
|
},
|
|
showCouponFun() {
|
|
if (!this.isLogin) return toLogin();
|
|
this.showCoupon = true;
|
|
},
|
|
|
|
showSpecFun(type) {
|
|
this.popupType = type;
|
|
this.showSpec = true;
|
|
},
|
|
|
|
getAuthMsg() {
|
|
return new Promise(resolve => {
|
|
getMnpNotice({
|
|
scene: 1
|
|
}).then(res => {
|
|
if (res.code == 1) {
|
|
uni.requestSubscribeMessage({
|
|
tmplIds: res.data,
|
|
|
|
fail(res) {
|
|
console.log(res.errMsg);
|
|
},
|
|
|
|
complete() {
|
|
resolve();
|
|
}
|
|
|
|
});
|
|
} else {
|
|
resolve();
|
|
}
|
|
});
|
|
});
|
|
},
|
|
onSubmitOrder() {
|
|
uni.showModal({
|
|
title: '温馨提示',
|
|
content: '是否确认购买?',
|
|
confirmColor: '#FF2C3C',
|
|
confirmText:"前往支付",
|
|
success: async res => {
|
|
let {
|
|
confirm
|
|
} = res;
|
|
if (confirm) {
|
|
// #ifdef MP-WEIXIN
|
|
await this.getAuthMsg();
|
|
//#endif
|
|
this.showLoading = true
|
|
this.orderBuyFun('submit');
|
|
}
|
|
}
|
|
});
|
|
},
|
|
async orderBuyFun() {
|
|
const submitObj = {
|
|
org_id: this.id //当前购买的资料id
|
|
};
|
|
let {
|
|
data: orderData,
|
|
code: orderCode,
|
|
msg: orderMsg
|
|
} = await resourceOrderBuy(submitObj)
|
|
|
|
if (orderCode !== 1) return this.showLoading = false
|
|
this.showLoading = false
|
|
let order_id = orderData.trade_id;
|
|
|
|
uni.$on('payment', params => {
|
|
setTimeout(() => {
|
|
if (params.result) {
|
|
console.log('Jason', this)
|
|
this.$Router.replace({
|
|
path: '/pages/pay_result/pay_result',
|
|
query: {
|
|
id: params.order_id,
|
|
type:2,
|
|
org_id:this.id,
|
|
from: "trade"
|
|
}
|
|
})
|
|
} else {
|
|
location.reload()
|
|
}
|
|
}, 1 * 500)
|
|
})
|
|
|
|
uni.navigateTo({
|
|
url: `/pages/payment/payment?from=trade&order_id=${order_id}`
|
|
})
|
|
}
|
|
},
|
|
async onShareAppMessage() {
|
|
const {
|
|
resourceDetail,
|
|
inviteCode,
|
|
team
|
|
} = this;
|
|
return {
|
|
title: resourceDetail.title,
|
|
imageUrl: resourceDetail.image,
|
|
path: '/bundle/pages/resource_details/resource_details?id=' + this.id
|
|
};
|
|
},
|
|
computed: {
|
|
...mapGetters(['cartNum', 'inviteCode', 'sysInfo', 'appConfig', 'userInfo']),
|
|
btnText() {
|
|
const {
|
|
goodsType
|
|
} = this;
|
|
console.log(goodsType,222333)
|
|
switch (goodsType) {
|
|
case 0:
|
|
return {
|
|
red: '立即下载'
|
|
};
|
|
case 1:
|
|
return {
|
|
red: '开通vip'
|
|
};
|
|
default:
|
|
return {
|
|
red: '立即购买'
|
|
};
|
|
}
|
|
},
|
|
getTeamCountTime() {
|
|
return time => time - Date.now() / 1000;
|
|
},
|
|
navHeight() {
|
|
return this.sysInfo.navHeight
|
|
},
|
|
enableCommission() {
|
|
const {
|
|
goodsType,
|
|
distribution: {
|
|
earnings,
|
|
is_show
|
|
}
|
|
} = this
|
|
return goodsType == 0 && earnings > 0 && is_show == 1
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '@/styles/base.scss';
|
|
|
|
.goods-details {
|
|
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
|
|
|
|
.seckill {
|
|
height: 100rpx;
|
|
background: #ffd4d8;
|
|
|
|
.price {
|
|
width: 504rpx;
|
|
height: 100%;
|
|
background: url(../../../static/images/bg_seckill.png) no-repeat;
|
|
background-size: 100%;
|
|
}
|
|
|
|
.down {
|
|
flex: 1;
|
|
}
|
|
}
|
|
|
|
.group {
|
|
height: 100rpx;
|
|
width: 100%;
|
|
background-image: url(../../../static/images/pintuan_bg.png);
|
|
background-size: 100%;
|
|
|
|
.group-num {
|
|
border: 1px solid #ffffff;
|
|
border-radius: 4rpx;
|
|
|
|
.group-icon {
|
|
background: #fff;
|
|
padding: 3rpx 7rpx;
|
|
}
|
|
}
|
|
|
|
.down {
|
|
height: 100%;
|
|
background-color: #fff5e1;
|
|
padding: 0 20rpx;
|
|
}
|
|
}
|
|
|
|
.goods-info {
|
|
position: relative;
|
|
|
|
.info-header {
|
|
padding: 20rpx 0 0rpx 24rpx;
|
|
|
|
.price {
|
|
align-items: baseline;
|
|
}
|
|
}
|
|
|
|
.name {
|
|
padding: 20rpx 24rpx;
|
|
flex: 1;
|
|
}
|
|
|
|
.icon-share {
|
|
width: 134rpx;
|
|
height: 60rpx;
|
|
}
|
|
.vip-price {
|
|
margin: 0 24rpx;
|
|
background-color: #FFE9BA;
|
|
line-height: 36rpx;
|
|
border-radius: 6rpx;
|
|
overflow: hidden;
|
|
|
|
.price-name {
|
|
background-color: #101010;
|
|
padding: 3rpx 12rpx;
|
|
color: #FFD4B7;
|
|
position: relative;
|
|
overflow: hidden;
|
|
|
|
&::after {
|
|
content: '';
|
|
display: block;
|
|
width: 20rpx;
|
|
height: 20rpx;
|
|
position: absolute;
|
|
right: -15rpx;
|
|
background-color: #FFE9BA;
|
|
border-radius: 50%;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
box-sizing: border-box;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.details-null {
|
|
padding-top: 140rpx;
|
|
margin-bottom: 100rpx;
|
|
}
|
|
|
|
.spec {
|
|
padding: 24rpx 24rpx;
|
|
|
|
.text {
|
|
width: 100rpx;
|
|
}
|
|
}
|
|
|
|
.evaluation {
|
|
.title {
|
|
height: 100rpx;
|
|
border-bottom: $-solid-border;
|
|
padding: 0 24rpx;
|
|
}
|
|
|
|
.con {
|
|
padding: 30rpx 24rpx;
|
|
}
|
|
|
|
.user-info .avatar {
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
border-radius: 50%;
|
|
}
|
|
}
|
|
|
|
.details {
|
|
|
|
// overflow: hidden;
|
|
.title {
|
|
line-height: 88rpx;
|
|
text-align: center;
|
|
}
|
|
|
|
&>.content {
|
|
padding: 0 20rpx 20rpx;
|
|
|
|
::v-deep image {
|
|
vertical-align: middle;
|
|
}
|
|
|
|
// #ifdef H5
|
|
::v-deep img {
|
|
vertical-align: middle;
|
|
}
|
|
|
|
// #endif
|
|
// #ifdef MP-WEIXIN || APP-PLUS
|
|
::v-deep ._img {
|
|
display: block;
|
|
}
|
|
|
|
// #endif
|
|
}
|
|
}
|
|
|
|
.footer {
|
|
height: 100rpx;
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
box-sizing: content-box;
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
|
|
.btn {
|
|
width: 100rpx;
|
|
height: 100rpx;
|
|
position: relative;
|
|
line-height: 1.3;
|
|
}
|
|
|
|
.cart-num {
|
|
position: absolute;
|
|
left: 60rpx;
|
|
top: 6rpx;
|
|
}
|
|
|
|
.add-cart,
|
|
.right-buy,
|
|
.consult-btn{
|
|
flex: 1;
|
|
text-align: center;
|
|
padding: 16rpx 0;
|
|
}
|
|
|
|
.add-cart {
|
|
background-color: #ffa630;
|
|
}
|
|
|
|
.right-buy {
|
|
background-color: $-color-primary;
|
|
}
|
|
.consult-btn {
|
|
background: linear-gradient(to right, #ff8e00 0%, #ff2c3c 100%);
|
|
}
|
|
}
|
|
|
|
.group-play {
|
|
.title {
|
|
padding: 20rpx 28rpx;
|
|
border-bottom: $-solid-border;
|
|
}
|
|
|
|
.steps {
|
|
padding: 20rpx 28rpx;
|
|
|
|
.step {
|
|
flex: none;
|
|
}
|
|
|
|
.line {
|
|
flex: 1;
|
|
border: 1px dashed #999999;
|
|
margin: 0 20rpx;
|
|
}
|
|
|
|
.number {
|
|
border: 1rpx solid #707070;
|
|
width: 28rpx;
|
|
height: 28rpx;
|
|
border-radius: 50%;
|
|
line-height: 28rpx;
|
|
text-align: center;
|
|
margin-right: 6rpx;
|
|
}
|
|
}
|
|
}
|
|
|
|
.group-list {
|
|
.group-item {
|
|
padding: 20rpx 24rpx;
|
|
|
|
&:not(:last-of-type) {
|
|
border-bottom: $-solid-border;
|
|
}
|
|
|
|
.group-btn {
|
|
background: linear-gradient(90deg, #f95f2f 0%, #ff2c3c 100%);
|
|
height: 58rpx;
|
|
padding-left: 28rpx;
|
|
padding-right: 28rpx;
|
|
margin-left: 30rpx;
|
|
box-shadow: 0px 6rpx 12rpx rgba(249, 47, 138, 0.4);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
.share-money {
|
|
position: fixed;
|
|
left: 20rpx;
|
|
bottom: calc(130rpx + env(safe-area-inset-bottom));
|
|
transform: scale(0);
|
|
transition: all .3s;
|
|
|
|
&.show {
|
|
transform: scale(1);
|
|
}
|
|
|
|
.share-close {
|
|
width: 34rpx;
|
|
height: 34rpx;
|
|
background: #a7a7a7;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
.share-con {
|
|
background: url('../../../static/images/bg_packet_img.png');
|
|
width: 241rpx;
|
|
height: 208rpx;
|
|
background-size: 100%;
|
|
padding-top: 20rpx;
|
|
text-align: center;
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|