123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <view class="share-buy-detail">
- <tui-skeleton v-if="isRequest" :loadingType="3" :isLoading="true"></tui-skeleton>
- <!-- 拼单信息 && 立即拼单 -->
- <view class="group-message">
- <share-buy-group-message :countDownTime="countDownTime" :hasEndTip="true">
- <template v-slot:head>
- <view class="message">
- 还差
- <text v-text="collageData.needNum"></text>
- 人参团,赶快邀请好友来拼单吧!
- </view>
- </template>
- <template v-slot:foot>
- <tui-button type="base" width="600rpx" height="90rpx" shape="circle" :size="30" @click="onShare">
- <text>邀请好友拼单</text>
- </tui-button>
- <view class="line"></view>
- <tui-button
- type="base"
- width="600rpx"
- height="90rpx"
- shape="circle"
- :plain="true"
- :size="30"
- @click="handleToHome"
- >
- <text>去首页逛逛</text>
- </tui-button>
- </template>
- </share-buy-group-message>
- </view>
- <!-- 商品基本信息 参与拼单用户信息-->
- <view class="member-info">
- <share-buy-member-info
- :memberNum="collageData.memberNum"
- :existNum="collageData.existNum"
- :shopInfo="collageData"
- ></share-buy-member-info>
- </view>
- <!-- 分享 -->
- <cm-share-popup ref="sharePopup" :data="posterData" type="product"></cm-share-popup>
- </view>
- </template>
- <script>
- import { fetchCollageOrderDetail } from '@/services/api/order.js'
- import { countDown, queryStringify } from '@/common/utils.js'
- import { mapGetters } from 'vuex'
- export default {
- data() {
- return {
- isRequest: true,
- collageId: '',
- collageData: {},
- // 海报生成数据
- posterData: {},
- timer: null,
- countDownTime: {}
- }
- },
- computed: {
- ...mapGetters(['userId'])
- },
- // 分享到微信用户
- onShareAppMessage() {
- const shareData = {
- type: 4,
- collageId: this.collageData.collageId,
- initiatorId: this.userId
- }
- const state_str = encodeURIComponent(this.$crypto.encrypt(shareData))
- console.log(state_str)
- return {
- title: '哈喽,赶快来参团吧!这件商品拼团买更便宜~',
- path: `/pages/index/index?state_str=${state_str}`,
- imageUrl: this.collageData.productImage
- }
- },
- onLoad(options) {
- this.collageId = options.collageId
- },
- onShow() {
- this.fetchOrderDetails()
- },
- methods: {
- // 分享
- async onShare() {
- const query = queryStringify({
- type: 4,
- collageId: this.collageData.collageId,
- initiatorId: this.userId
- })
- this.posterData = {
- porductName: '哈喽,赶快来参团吧!这件商品拼团买更便宜~',
- productPrice: this.collageData.price,
- productOriginPrice: this.collageData.normalPrice,
- productImage: this.collageData.productImage,
- query: query
- }
- this.$refs.sharePopup.open()
- },
- // 获取拼单详情
- async fetchOrderDetails() {
- try {
- const res = await fetchCollageOrderDetail({
- collageId: this.collageId,
- userId: this.userId
- })
- this.collageData = res.data
- const { memberNum, existNum, productName, productImage, price } = this.collageData
- // 验证拼单是否成功
- if (memberNum === existNum) {
- uni.setStorageSync('SHARE_BUY_COLLAGE_DATA', this.collageData)
- setTimeout(() => {
- this.$router.redirectTo('share-buy/share-buy-success')
- }, 500)
- return
- }
- // 设置分享海报商品信息
- this.posterData.porductName = productName
- this.posterData.productImage = productImage
- this.posterData.productPrice = price
- this.countDown()
- this.isRequest = false
- } catch (e) {
- console.log(e)
- }
- },
- // 去首页
- handleToHome() {
- this.$router.switchTab('home')
- },
- // 倒计时
- countDown() {
- const startTime = Date.now()
- const endTime = new Date(this.collageData.endTime).getTime()
- this.timer && clearTimeout(this.timer)
- countDown(endTime, startTime, {}, item => {
- this.countDownTime = item.conttainer
- this.timer = item.t
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .share-buy-detail {
- .line {
- height: 24rpx;
- }
- .member-info {
- margin-top: 24rpx;
- }
- .message {
- font-size: 30rpx;
- color: #333333;
- text {
- color: #ff457b;
- }
- }
- }
- </style>
|