tmp: 部分代码与UnishopV5结合,但是代码有严重缺陷

This commit is contained in:
2025-12-20 15:30:39 +08:00
parent ed5181b382
commit e263a616f6
183 changed files with 31316 additions and 18590 deletions

View File

@@ -0,0 +1,471 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view class="bargain">
<view class="bargain_top" :style="{ backgroundImage: 'url(' + $util.img('public/uniapp/bargain/bargain_background.png') + ')' }">
<view>{{ goodsDetail ? goodsDetail.browse_num : 0 }}人查看</view>
<view>|</view>
<view>{{ goodsDetail ? goodsDetail.share_num : 0 }}人分享</view>
<view>|</view>
<view>{{ goodsDetail ? goodsDetail.join_num : 0 }}人参与</view>
</view>
<view class="rule-mark-enter" @click="openRulePopup">活动规则</view>
<view class="bargin_content">
<view class="uer_info_base" v-if="launchInfo">
<view class="user_info_img">
<image :src="launchInfo.headimg == '' ? $util.img($util.getDefaultImage().head) : $util.img(launchInfo.headimg)" mode="widthFix"></image>
</view>
<text class="user_info_name">{{ launchInfo.nickname }}</text>
</view>
<!-- 宣传语 -->
<view class="bargin_propaganda" v-if="launchInfo">
<text class="marks"></text>
<text>我发现一件好物快来帮我砍一刀</text>
<text class="marks"></text>
</view>
<!-- 商品 -->
<view class="goods" v-if="goodsDetail">
<view class="goods_img"><image :src="$util.img(goodsDetail.sku_image, { size: 'mid' })" mode="aspectFit"></image></view>
<view class="goods_content" v-if="launchInfo">
<view class="goods_title">{{ goodsDetail.sku_name }}</view>
<view class="goods_price">
<view>
原价
<text class="original_price">{{ $lang('common.currencySymbol') }}{{ launchInfo.price }}</text>
</view>
<view>
最低可砍至
<text class="bottom_price">{{ $lang('common.currencySymbol') }}{{ launchInfo.floor_price }}</text>
</view>
</view>
<view class="partake_num" v-if="launchInfo">
已有
<text class="ident">{{ launchInfo.curr_num }}</text>
人帮砍
<text class="residue-num">
剩余库存
<text class="ident">{{ goodsDetail.bargain_stock }}{{ goodsDetail.unit }}</text>
</text>
</view>
<view v-if="launchInfo && timeMachine && goodsDetail.bargain_status == 1" class="count-down">
<uni-count-down
:day="timeMachine.d"
:hour="timeMachine.h"
:minute="timeMachine.i"
:second="timeMachine.s"
color="#fff"
splitorColor="#333 !important"
backgroundColor="#000"
border-color="transparent"
@timeup="timeUp()"
></uni-count-down>
<text>后结束</text>
</view>
</view>
<view class="goods_content launch" v-else>
<view class="goods_title">{{ goodsDetail.sku_name }}</view>
<view class="goods_price">
<view>
原价
<text class="original_price price-font">
<text class="price-style small">{{ $lang('common.currencySymbol') }}</text>
<text class="price price-style small">{{ parseFloat(goodsDetail.price).toFixed(2).split('.')[0] }}</text>
<text class="price-symbol price-style small">.{{ parseFloat(goodsDetail.price).toFixed(2).split('.')[1] }}</text>
</text>
</view>
<view>
最低可砍至
<text class="bottom_price price-style small">{{ $lang('common.currencySymbol') }}{{ goodsDetail.floor_price }}</text>
</view>
</view>
</view>
</view>
<!-- 进度 -->
<view class="progress">
<view class="progress_item" :style="{ width: (progress > 2 ? progress : 2) + '%' }"><text class="icon-futou iconfont"></text></view>
<view class="progress-point"></view>
</view>
<view class="info-bottom" v-if="goodsDetail">
<view class="price-box" v-if="launchInfo">
<view class="discount-price">
已砍
<text class="price price-font">
{{ $lang('common.currencySymbol') }}{{ parseFloat(parseFloat(launchInfo.price) - parseFloat(launchInfo.curr_price)).toFixed(2) }}
</text>
</view>
<view class="delete-price ">
还剩
<text class="price price-font">
{{ $lang('common.currencySymbol')
}}{{
parseFloat(
parseFloat(launchInfo.price) - parseFloat(launchInfo.floor_price) - (parseFloat(launchInfo.price) - parseFloat(launchInfo.curr_price))
).toFixed(2)
}}
</text>
</view>
</view>
<view class="price-box" v-else>
<view class="discount-price">
已砍
<text class="price price-font">{{ $lang('common.currencySymbol') }}0</text>
</view>
<view class="delete-price ">
还剩
<text class="price price-font">
{{ $lang('common.currencySymbol') }} {{ parseFloat(parseFloat(goodsDetail.price) - parseFloat(goodsDetail.floor_price)).toFixed(2) }}
</text>
</view>
</view>
<view class="pro-info" v-if="!parseFloat(goodsDetail.floor_price)"><view class="button-border">免费拿</view></view>
</view>
<!-- 邀请新用户 -->
<view class="invitation_peo" v-if="launchInfo">
<!-- <view class="tip">邀请新用户砍掉金额更多哦~</view> -->
<block v-if="launchInfo.self">
<view class="bargain-success" v-if="launchInfo.status == 1">
<text class="iconfont icon-kanjiachenggong"></text>
<text>恭喜您砍价成功快去支付吧</text>
</view>
<view class="bargain-success" v-if="launchInfo.status == 2">
<text class="iconfont icon-biaoqing_nanguo"></text>
<text v-if="launchInfo.buy_type == 0 && launchInfo.order_id == 0">很遗憾未能砍至最低价可立即支付带走您心仪的宝贝</text>
<text v-else-if="launchInfo.buy_type == 0 && launchInfo.order_id > 0">很遗憾未能砍至最低价</text>
<text v-else>很遗憾砍价未成单</text>
</view>
<view class="launch-success" v-if="launchInfo.status == 2 && launchInfo.buy_type == 0 && launchInfo.order_id > 0">恭喜您通过立即支付带走您心仪的宝贝</view>
</block>
<block v-if="goodsDetail.bargain_status == 1">
<view v-if="launchInfo.self" class="flex-box" :class="{ success: launchInfo.status == 1 }">
<block v-if="launchInfo.status != 1 && (goodsDetail.bargain_status != 1 || goodsDetail.bargain_stock == 0)">
<block v-if="goodsDetail.bargain_status != 1">
<button class="btn-vice disabled">活动已结束</button>
<button class="btn" @click="$util.redirectTo('/pages_promotion/bargain/list')">更多砍价商品</button>
</block>
<block v-else-if="goodsDetail.bargain_stock == 0">
<button class="btn-vice disabled">已售罄</button>
<button class="btn" @click="$util.redirectTo('/pages_promotion/bargain/list')">更多砍价商品</button>
</block>
</block>
<block v-else>
<block v-if="launchInfo.status == 0">
<button class="btn-vice" v-if="launchInfo.buy_type == 0" @click="buyNow">不砍了直接买</button>
<button class="btn" @click="openSharePopup">喊好友砍一刀</button>
</block>
<block v-if="launchInfo.status == 1">
<button class="btn" @click="buyNow" v-if="launchInfo.order_id == 0">立即支付</button>
<button class="btn" v-if="launchInfo.order_id > 0" @click="$util.redirectTo('/pages/order/detail', { order_id: launchInfo.order_id })">
查看订单
</button>
<button class="btn-vice" @click="$util.redirectTo('/pages/index/index')">低价拿更多商品</button>
</block>
<block v-if="launchInfo.status == 2">
<button class="btn" v-if="launchInfo.order_id > 0" @click="$util.redirectTo('/pages/order/detail', { order_id: launchInfo.order_id })">
查看订单
</button>
<button class="btn" @click="$util.redirectTo('/pages/index/index')">低价拿更多商品</button>
</block>
</block>
</view>
<view v-else class="flex-box">
<block v-if="launchInfo.status == 0">
<button class="btn" @click="bargain" v-if="!launchInfo.cut">帮好友砍一刀</button>
<button class="btn-vice" @click="$util.redirectTo('/pages_promotion/bargain/list')" v-else>我也要低价拿</button>
</block>
<button v-else class="btn" @click="$util.redirectTo('/pages_promotion/bargain/list')">我也要低价拿</button>
</view>
</block>
<block v-else>
<view class="flex-box success">
<button class="btn" v-if="launchInfo.self && launchInfo.order_id > 0" @click="$util.redirectTo('/pages/order/detail', { order_id: launchInfo.order_id })">
查看订单
</button>
<button class="btn-vice disabled">活动已结束</button>
</view>
</block>
</view>
<view class="invitation_peo" v-else>
<view class="flex-box">
<button class="btn" v-if="goodsDetail && goodsDetail.bargain_status == 1" @click="createBargain()">立即参与砍价</button>
<button class="btn-vice disabled" v-else>活动已结束</button>
</view>
</view>
</view>
<view class="bargin_introduction" v-if="launchInfo">
<view class="bargin_introduction_title">帮砍记录</view>
<view class="bargin_introduction_content">
<view class="bargin_invitation" v-if="bargainRecord.length">
<view class="item" v-for="(item, index) in bargainRecord" :key="index">
<view class="item_left">
<image :src="item.headimg == '' ? $util.img($util.getDefaultImage().head) : $util.img(item.headimg)"></image>
<view class="bargin_info">
<view>{{ item.nickname[0] }}*{{ item.nickname[item.nickname.length - 1] }}</view>
<view>{{ $util.timeStampTurnTime(item.bargain_time) }}</view>
</view>
</view>
<view class="item_right">
<image :src="$util.img('public/uniapp/bargain/bargain-icon.png')" class="bargain-icon"></image>
帮砍
<text>{{ item.money }}</text>
</view>
</view>
<view class="item_more" v-if="showMore" @click="scrolltolower()">加载更多</view>
</view>
<view v-else class="record-empty">现在还没有砍价记录</view>
</view>
</view>
<view class="bargin_introduction">
<view class="bargin_introduction_title">砍价流程</view>
<view class="bargin_introduction_content">
<view class="flow">
<view class="flow_item">
<image :src="$util.img('public/uniapp/bargain/bargain_kanjia.png')"></image>
<view>发起商品砍价</view>
</view>
<view class="flow_item">
<image :src="$util.img('public/uniapp/bargain/bargain_friend.png')"></image>
<view>邀请好友砍价达要求</view>
</view>
<view class="flow_item">
<image :src="$util.img('public/uniapp/bargain/bargain_good.png')"></image>
<view>领取商品带回家</view>
</view>
</view>
</view>
</view>
<view class="bargin_introduction" v-if="launchList && launchList.length > 0">
<view class="bargin_introduction_title">砍成晒单</view>
<view class="bargin_introduction_content">
<view class="bargain-list">
<swiper vertical="true" autoplay="true" interval="3000" :display-multiple-items="showNum" :circular="true" :class="'swiper-' + launchList.length">
<swiper-item v-for="(item, index) in launchList" :key="index">
<view class="bargain-item">
<view>
<view class="bargain-head"><image :src="item.headimg == '' ? $util.img($util.getDefaultImage().head) : $util.img(item.headimg)"></image></view>
<view class="bargain-info">
<view class="bargain-title">{{ item.nickname[0] }}*{{ item.nickname[item.nickname.length - 1] }}</view>
<view class="bargain-desc">{{ $util.timeStampTurnTime(item.end_time) }}</view>
</view>
</view>
<view class="bargain-price">
成功砍至
<text>{{ parseFloat(item.curr_price).toFixed(2) }}</text>
</view>
</view>
</swiper-item>
</swiper>
</view>
</view>
</view>
<view class="bargin_introduction">
<view class="bargin_introduction_title">商品详情</view>
<view class="bargin_introduction_content">
<view class="detail-content">
<view class="goods-details" v-if="goodsDetail && goodsDetail.goods_content">
<ns-mp-html :content="goodsDetail.goods_content"></ns-mp-html>
</view>
<view class="goods-details active" v-else>该商家暂无上传相关详情哦</view>
</view>
</view>
</view>
<ns-goods-sku
ref="goodsSku"
v-if="goodsDetail"
@refresh="refreshGoodsSkuDetail"
:goods-id="goodsDetail.goods_id"
:goods-detail="goodsDetail"
:maxBuy="maxBuy"
></ns-goods-sku>
<!-- 帮砍弹出 -->
<uni-popup ref="uniHelpPopup" type="center" :maskClick="false">
<view class="bargain-popup self help">
<image :src="$util.img('public/uniapp/bargain/bargain-pop-1.png')" mode="widthFix" class="head"></image>
<view class="bargain-content">
<view class="uer_info_base" v-if="launchInfo">
<view class="user_info_img">
<image :src="launchInfo.headimg == '' ? $util.img($util.getDefaultImage().head) : $util.img(launchInfo.headimg)" mode="widthFix"></image>
</view>
<text class="user_info_name">{{ launchInfo.nickname }}</text>
</view>
<view v-if="goodsDetail && launchInfo && timeMachine && goodsDetail.bargain_status == 1" class="count-down">
<text>还剩</text>
<uni-count-down
:day="timeMachine.d"
:hour="timeMachine.h"
:minute="timeMachine.i"
:second="timeMachine.s"
color="#fff"
splitorColor="#333 !important"
backgroundColor="#000"
border-color="transparent"
@timeup="timeUp()"
></uni-count-down>
<text>结束</text>
</view>
</view>
<button class="bargain-btn" type="primary" @click="bargain()">帮他砍价</button>
</view>
<text class="iconfont icon-round-close" @click="$refs.uniHelpPopup.close()"></text>
</uni-popup>
<!-- 帮砍成功 -->
<uni-popup ref="uniPopup" type="center" :maskClick="false">
<view class="bargain-popup self">
<image :src="$util.img('public/uniapp/bargain/bargain-pop-2.png')" mode="widthFix" class="head"></image>
<view class="bargain-content">
<text>您已帮砍</text>
<text class="money color-base-text">{{ bargainMoney }}</text>
<text>您也可以参与砍价快去挑选心仪的宝贝吧~~~</text>
</view>
<button class="bargain-btn" type="primary" @click="$util.redirectTo('/pages_promotion/bargain/list')">我也要参与</button>
</view>
<text class="iconfont icon-round-close" @click="closePopup"></text>
</uni-popup>
<!-- 自砍一刀展示 -->
<uni-popup ref="uniSelfBargainPopup" type="center" :maskClick="false">
<view class="bargain-popup self">
<image :src="$util.img('public/uniapp/bargain/bargain-pop-2.png')" mode="widthFix" class="head"></image>
<view class="bargain-content">
<text>您已砍掉</text>
<text class="money color-base-text">{{ my_bargain_money }}</text>
<text>听说分享次数越多砍价成功的机会越大哦</text>
</view>
<button class="bargain-btn" type="primary" @click="openSharePopup">邀请好友帮砍价</button>
</view>
<text class="iconfont icon-round-close" @click="closeSelfPop"></text>
</uni-popup>
<!-- 分享弹窗 -->
<view @touchmove.prevent.stop>
<uni-popup ref="sharePopup" type="bottom" class="share-popup">
<view>
<view class="share-title">分享</view>
<view class="share-content">
<!-- #ifdef MP -->
<view class="share-box">
<button class="share-btn" :plain="true" open-type="share">
<view class="iconfont icon-share-friend"></view>
<text>分享给好友</text>
</button>
</view>
<!-- #endif -->
<!-- #ifdef H5 -->
<view class="share-box" @click="copyUrl">
<button class="share-btn" :plain="true">
<view class="iconfont icon-fuzhilianjie"></view>
<text>复制链接</text>
</button>
</view>
<!-- #endif -->
<view class="share-box" @click="openPosterPopup">
<button class="share-btn" :plain="true">
<view class="iconfont icon-pengyouquan"></view>
<text>生成分享海报</text>
</button>
</view>
</view>
<view class="share-footer" @click="closeSharePopup"><text>取消分享</text></view>
</view>
</uni-popup>
</view>
<!-- 海报 -->
<view @touchmove.prevent.stop class="poster-layer">
<uni-popup ref="posterPopup" type="center">
<template v-if="poster != '-1'">
<view class="poster-wrap">
<view class="image-wrap">
<image :src="$util.img(poster)" :show-menu-by-longpress="true" mode="widthFix" />
<view class="close iconfont icon-close" @click="closePosterPopup()"></view>
</view>
<!-- #ifdef MP || APP-PLUS -->
<view class="save-btn" @click="saveGoodsPoster()">保存图片</view>
<!-- #endif -->
<!-- #ifdef H5 -->
<view class="save-btn">长按图片进行保存</view>
<!-- #endif -->
</view>
</template>
</uni-popup>
</view>
<!-- 悬浮按钮 -->
<hover-nav :need="true"></hover-nav>
<!-- 活动规则 -->
<uni-popup ref="rulePopup" type="center" :maskClick="false">
<view class="rule-wrap">
<view class="content-wrap">
<image :src="$util.img('public/uniapp/common/promotion_rule_head.png')" mode="widthFix" class="rule-head"></image>
<scroll-view scroll-y="true" class="rule">
<view class="text" v-if="goodsDetail && goodsDetail.remark != ''">{{ goodsDetail.remark }}</view>
</scroll-view>
<text class="iconfont icon-round-close" @click="closeRulePopup"></text>
</view>
</view>
</uni-popup>
<loading-cover ref="loadingCover"></loading-cover>
<ns-login ref="login"></ns-login>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
import LTime from '@/pages_promotion/components/l-time/l-time.vue';
import uniPopup from '@/components/uni-popup/uni-popup.vue';
import goodsSku from '@/components/ns-goods-sku/ns-goods-sku.vue';
import detail from './public/js/detail.js';
export default {
components: {
LTime,
goodsSku,
uniPopup
},
mixins: [detail]
};
</script>
<style lang="scss">
@import './public/css/detail.scss';
</style>
<style scoped>
/deep/ .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
max-height: unset !important;
}
/deep/.uni-popup__wrapper.uni-custom.center .uni-popup__wrapper-box {
overflow-y: unset;
background: none !important;
}
.detail-content >>> img {
max-width: 100% !important;
}
.detail-content >>> image {
max-width: 100% !important;
}
/deep/.uni-countdown__number {
padding: 0 4rpx;
line-height: 36rpx;
height: 36rpx;
}
/deep/ .uni-countdown__splitor.day {
line-height: 36rpx;
}
</style>

View File

@@ -0,0 +1,357 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view class="page" :style="{ background: bgColor }">
<mescroll-uni @getData="getData" ref="mescroll" :size="10" v-if="addonIsExist.bargain">
<block slot="list">
<ns-adv keyword="NS_BARGAIN" class-name="adv-wrap"></ns-adv>
<block v-if="dataList.length > 0 || dataListing.length > 0">
<view class="goods-list single-column" v-if="dataListing.length">
<view class="goods-item margin-bottom" v-for="(item, index) in dataListing" :key="index">
<view class="goods-item-content">
<view class="goods-img" @click="toDetailP(item)">
<image :src="goodsImg(item.goods_image)" mode="widthFix" @error="imgError(index)"/>
<view class="color-base-bg goods-tag" v-if="goodsTag(item) != ''">{{ goodsTag(item) }}</view>
</view>
<view class="info-wrap">
<view class="name-wrap">
<view class="goods-name" @click="toDetailP(item)">{{ item.goods_name }}</view>
<text class="info-sub-title">已有{{ item.join_num }}人参与</text>
<view class="progress-wrap">
<progress percent="20" :show-info="false" stroke-width="8"
backgroundColor="#FFF4F4" :activeColor="themeStyle.main_color"
border-radius="6" :percent="progressP(item)" />
<view class="progress-point"></view>
<view class="progress-select icon"
:style="{ left: 'calc(' + progressP(item) + '% - 16rpx)' }">
<text class="iconfont icon-futou"></text>
</view>
</view>
</view>
<view class="info-bottom">
<view class="price-box">
<view class="discount-price">已砍<text class="price price-font">{{ (item.price - item.curr_price).toFixed(2) }}</text></view>
<view class="delete-price ">还剩<text class="price price-font">{{ $lang('common.currencySymbol') }}{{ (item.curr_price - item.floor_price).toFixed(2) }}</text></view>
</view>
<view class="pro-info">
<view class="button-border">免费拿</view>
</view>
</view>
</view>
</view>
<view class="goods-item-bottom">
<view class="item-bottom-left">
<uni-count-down :day="item.time.d" :hour="item.time.h" :minute="item.time.i" :second="item.time.s" color="#fff" borderColor="none" splitorColor="#303133" backgroundColor="#303133" />
<view class="color-sub txt">后结束</view>
</view>
<view class="item-bottom-right">
<button type="primary" @click="toDetailP(item)" size="mini" class="mini">继续砍价</button>
</view>
</view>
</view>
</view>
<view class="goods-list single-column" v-if="dataList.length">
<view class="goods-item margin-bottom" v-for="(item, index) in dataList" :key="index">
<view class="goods-item-content">
<view class="goods-img" @click="toDetail(item)">
<image :src="goodsImg(item.goods_image)" mode="widthFix" @error="imgError(index)"/>
<view class="color-base-bg goods-tag" v-if="goodsTag(item) != ''">{{ goodsTag(item) }}</view>
</view>
<view class="info-wrap">
<view class="name-wrap">
<view class="goods-name" @click="toDetail(item)">{{ item.sku_name }}</view>
<text class="info-sub-title">已有{{ item.join_num }}人参与</text>
<view class="progress-wrap"><progress percent="20" :show-info="false" stroke-width="8" backgroundColor="#FFF4F4" :activeColor="themeStyle.main_color" border-radius="6" :percent="progress(item)" />
<view class="progress-point"></view>
<view class="progress-select icon" :style="{ left: 'calc(' + progress(item) + '% - 8rpx)' }">
<text class="iconfont icon-futou"></text>
</view>
</view>
</view>
<view class="info-bottom">
<view class="sale-box price-font">已砍{{ item.sale_num }}</view>
<view class="pro-info">
<view class="button-border">免费拿</view>
</view>
</view>
</view>
</view>
<view class="goods-item-bottom">
<view class="item-bottom-left">
<view class="txt">底价</view>
<text class="unit price-style small">{{ $lang('common.currencySymbol') }}</text>
<text class="price price-style large">{{ parseFloat(item.floor_price).toFixed(2).split('.')[0] }}</text>
<text class="unit price-style large">.{{ parseFloat(item.floor_price).toFixed(2).split('.')[1] }}</text>
<view class="delete-pirce">{{ $lang('common.currencySymbol') }}{{ item.price }}</view>
</view>
<view class="item-bottom-right">
<button type="primary" @click="toDetail(item)" size="mini" class="mini">去砍价</button>
</view>
</view>
</view>
</view>
</block>
<ns-empty v-else-if="isLoad && isLoading" textColor="#fff" :isIndex="false" text="暂无砍价商品"></ns-empty>
</block>
</mescroll-uni>
<!-- 悬浮按钮 -->
<hover-nav></hover-nav>
<loading-cover ref="loadingCover"></loading-cover>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
import uniCountDown from '@/components/uni-count-down/uni-count-down.vue';
export default {
components: {
uniCountDown
},
data() {
return {
dataList: [],
dataListing: [],
isLoading: false,
isLoad: false,
skuId: 0,
mpShareData: null, //小程序分享数据
progressBorder: '10',
bgColor: ''
};
},
onLoad(option) {
//小程序分享接收source_member
if (option.source_member) {
uni.setStorageSync('source_member', option.source_member);
}
// 小程序扫码进入接收source_member
if (option.scene) {
var sceneParams = decodeURIComponent(option.scene);
sceneParams = sceneParams.split('&');
if (sceneParams.length) {
sceneParams.forEach(item => {
if (item.indexOf('sku_id') != -1) this.skuId = item.split('-')[1];
if (item.indexOf('m') != -1) uni.setStorageSync('source_member', item.split('-')[1]);
if (item.indexOf('is_test') != -1) uni.setStorageSync('is_test', 1);
});
}
}
},
async onShow() {
setTimeout( () => {
if (!this.addonIsExist.bargain) {
this.$util.showToast({
title: '商家未开启砍价',
mask: true,
duration: 2000
});
setTimeout(() => {
this.$util.redirectTo('/pages/index/index');
}, 2000);
}
},1000);
//记录分享关系
if (this.storeToken && uni.getStorageSync('source_member')) {
this.$util.onSourceMember(uni.getStorageSync('source_member'));
}
//小程序分享
// #ifdef MP-WEIXIN
this.$util.getMpShare().then(res => {
this.mpShareData = res;
});
// #endif
await this.getZoneConfig();
if (this.$refs.mescroll) this.$refs.mescroll.refresh();
this.getDataing();
},
//分享给好友
onShareAppMessage() {
return this.mpShareData.appMessage;
},
//分享到朋友圈
onShareTimeline() {
return this.mpShareData.timeLine;
},
methods: {
// 活动页面配置
async getZoneConfig() {
let res = await this.$api.sendRequest({
url: '/api/config/promotionZoneConfig',
data: {
name: 'bargain'
},
async: false
});
let data = res.data;
if (data) {
this.bgColor = data.bg_color;
}
},
getData(mescroll) {
this.$api.sendRequest({
url: '/bargain/api/goods/page',
data: {
page_size: mescroll.size,
page: mescroll.num,
is_exclude_bargaining: 1
},
success: res => {
let newArr = [];
let msg = res.message;
if (res.code == 0 && res.data) {
newArr = res.data.list;
} else {
this.$util.showToast({
title: msg
});
}
if (mescroll.endSuccess) mescroll.endSuccess(newArr.length);
//设置列表数据
if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
this.dataList = this.dataList.concat(newArr); //追加新数据
this.isLoad = true;
this.$forceUpdate();
setTimeout(() => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}, 300);
},
fail() {
//联网失败的回调
if (mescroll.endErr) mescroll.endErr();
setTimeout(() => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}, 300);
}
});
},
getDataing() {
this.$api.sendRequest({
url: '/bargain/api/goods/bargainingList',
data: {},
success: res => {
this.dataListing = res.data;
for (var index in res.data) {
this.dataListing[index].time = this.$util.countDown(res.data[index].end_time - res.timestamp);
}
this.isLoading = true;
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail() {
//联网失败的回调
mescroll.endErr();
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
toDetail(e) {
this.$util.redirectTo('/pages_promotion/bargain/detail', {
b_id: e.bargain_id
});
},
toDetailP(e) {
this.$util.redirectTo('/pages_promotion/bargain/detail', {
b_id: e.bargain_id,
l_id: e.launch_id
});
},
imgError(index) {
this.dataList[index].goods_image = this.$util.getDefaultImage().goods;
this.$forceUpdate();
},
goodsImg(imgStr) {
let imgs = imgStr.split(',');
return imgs[0] ? this.$util.img(imgs[0], {
size: 'mid'
}) : this.$util.getDefaultImage().goods;
},
progress(data) {
let progress = ((parseInt(data.sale_num) / (parseInt(data.bargain_stock) + parseInt(data.sale_num))) * 100).toFixed();
if (progress == 'NaN') {
progress = 0;
}
return progress;
},
progressP(data) {
let progress = (((parseFloat(data.price) - parseFloat(data.curr_price)) / parseFloat(data.price)) * 100).toFixed();
if (progress == 'NaN') {
progress = 0;
}
return progress;
},
goodsTag(data) {
return data.label_name || '';
}
},
onHide() {
if (this.$refs.loadingCover) this.$refs.loadingCover.show();
}
};
</script>
<style lang="scss">
@import './public/css/list.scss';
</style>
<style lang="scss" scoped>
/deep/ .fixed {
position: relative;
top: 0;
}
/deep/ .empty {
margin-top: 0 !important;
}
.clockrun {
.delete-price {
max-width: 60%;
}
}
/deep/ .uni-countdown__number {
min-width: 32rpx;
height: 32rpx;
text-align: center;
line-height: 32rpx;
border-radius: 4px;
display: inline-block;
padding: 4rpx;
margin: 0;
border: none !important;
}
/deep/ .uni-countdown__splitor {
width: 10rpx;
height: 32rpx;
line-height: 36rpx;
text-align: center;
display: inline-block;
}
/deep/ .uni-countdown__splitor.day {
width: initial;
}
</style>
<style>
.progress-wrap>>>.uni-progress .uni-progress-bar {
border-radius: 16rpx;
overflow: hidden;
}
.progress-wrap>>>.uni-progress-bar .uni-progress-inner-bar {
background: linear-gradient(to left, var(--bargain-promotion-color), var(--bargain-promotion-aux-color)) !important;
}
</style>

View File

@@ -0,0 +1,432 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view>
<view class="my_spell_category" v-if="storeToken">
<view class="category-item" v-for="(item, index) in statusList" :key="index" @click="categoryChange(item.id)">
<view class="item-con" :class="item.id == status ? 'active color-base-text color-base-bg-before' : ''">{{ item.name }}</view>
</view>
</view>
<mescroll-uni @getData="getData" top="90" ref="mescroll" :size="10" v-if="storeToken">
<block slot="list">
<view class="goods-list" v-for="(item, index) in dataList" :key="index">
<view class="goods-item-content" @click="goBargainDetail(item)">
<view class="goods-item-state">
<text class="state-time">发起砍价 {{ $util.timeStampTurnTime(item.start_time) }}</text>
<text class="state-sign" :style="{ color: bargainState[item.status].color }">{{ bargainState[item.status].text }}</text>
</view>
<view class="goods-item-wrap">
<view class="image-wrap">
<image :src="$util.img(item.sku_image,{'size':'mid'})" mode="aspectFit" @error="imageError(index)"></image>
</view>
<view class="content">
<view class="title">{{ item.sku_name }}</view>
<text class="residue-price color-base-text">已砍至{{ item.curr_price }}</text>
<view class="price-box">
<text class="original-price" v-if="item.status">{{ $lang('common.currencySymbol') }}{{ item.price }}</text>
<view class="time" v-if="item.timeMachine && item.status == 0">
<uni-count-down :day="item.timeMachine.d" :hour="item.timeMachine.h"
:minute="item.timeMachine.i" :second="item.timeMachine.s" color="#fff"
splitorColor="#000 !important" backgroundColorClass="color-base-bg"
border-color="transparent" />
<text class="end-txt">后结束</text>
</view>
</view>
</view>
</view>
</view>
<view class="goods-item-action">
<view class="invitation-bargain">
<image :src="recordItem.headimg == '' ? $util.img($util.getDefaultImage().head) : $util.img(recordItem.headimg)" v-for="(recordItem, recordIndex) in item.bargain_record" :key="recordIndex" @error="memberImageError(index, recordIndex)"/>
<text class="invitation-bargain-end color-base-text color-base-border" v-if="item.status == 0">+</text>
<text class="invitation-bargain-end color-base-text color-base-border " v-else>
<text class="icon-ellipsis iconfont"></text>
</text>
</view>
<button class="btn" type="default" v-if="item.status == 0 && item.bargain_status == 1" @click="goBargainDetail(item)">继续砍价</button>
<block v-if="item.status == 1 && item.bargain_status == 1">
<button class="btn" type="default" v-if="item.order_id == 0" @click="goBargainDetail(item)">购买商品</button>
<button class="btn" type="default" v-else @click="goBargainDetail(item)">查看详情</button>
</block>
<button class="btn" type="default" v-if="item.status == 2 && item.bargain_status == 1" @click="$util.redirectTo('/pages_promotion/bargain/list')">重新砍价</button>
</view>
</view>
<ns-empty v-if="dataList.length == 0" :isIndex="true" :emptyBtn="{url: '/pages_promotion/bargain/list',text: '去逛逛'}" text="暂无砍价订单"></ns-empty>
</block>
</mescroll-uni>
<ns-login ref="login"></ns-login>
<loading-cover ref="loadingCover"></loading-cover>
</view>
</template>
<script>
import uniCountDown from '@/components/uni-count-down/uni-count-down.vue';
export default {
components: {
uniCountDown
},
data() {
return {
mescroll: null,
dataList: [],
statusList: [{
id: 'all',
name: '全部'
},
{
id: 0,
name: '正在砍价'
},
{
id: 1,
name: '砍价成功'
},
{
id: 2,
name: '砍价失败'
}
],
status: 'all',
bargainState: [{
color: '#FFA044',
text: '正在砍价'
},
{
color: '#11BD64',
text: '砍价成功'
},
{
color: '#FF4544',
text: '砍价失败'
}
],
};
},
onShow() {
setTimeout( () => {
if (!this.addonIsExist.bargain) {
this.$util.showToast({
title: '商家未开启砍价',
mask: true,
duration: 2000
});
setTimeout(() => {
this.$util.redirectTo('/pages/index/index');
}, 2000);
}
},1000);
if (!this.storeToken) {
this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/bargain/my_bargain');
});
}
},
methods: {
//请求列表数据
getData(mescroll) {
this.mescroll = mescroll;
this.$api.sendRequest({
url: '/bargain/api/bargain/launchPage',
data: {
page_size: mescroll.size,
page: mescroll.num,
status: this.status
},
success: res => {
let newArr = [];
let msg = res.message;
if (res.code == 0 && res.data) {
newArr = res.data.list;
} else {
this.$util.showToast({
title: msg
});
}
mescroll.endSuccess(newArr.length);
//设置列表数据
if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
newArr.forEach(v => {
if (v.end_time > res.timestamp) {
v.timeMachine = this.$util.countDown(v.end_time - res.timestamp);
} else {
v.timeMachine = null;
}
});
this.dataList = this.dataList.concat(newArr); //追加新数据
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail() {
//联网失败的回调
mescroll.endErr();
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
//砍价详情
goBargainDetail(data) {
this.$util.redirectTo('/pages_promotion/bargain/detail', {
l_id: data.launch_id,
b_id: data.bargain_id
});
},
//切换分类
categoryChange(e) {
this.status = e;
this.mescroll.resetUpScroll();
},
imageError(index) {
this.dataList[index].sku_image = this.$util.getDefaultImage().goods;
this.$forceUpdate();
},
memberImageError(index, j) {
this.dataList[index].bargain_record[j].headimg = this.$util.getDefaultImage().head;
this.$forceUpdate();
}
},
onBackPress(options) {
if (options.from === 'navigateBack') {
return false;
}
this.$util.redirectTo('/pages/member/index');
return true;
},
watch: {
storeToken: function(nVal, oVal) {
if (nVal) {
this.$refs.mescroll.refresh();
}
}
}
};
</script>
<style lang="scss">
.my_spell_category {
width: 100%;
height: 88rpx;
display: flex;
justify-content: space-around;
background: #fff;
position: fixed;
top: 0;
z-index: 999;
box-sizing: border-box;
.category-item {
width: 130rpx;
text-align: center;
.item-con {
display: inline-block;
height: 88rpx;
font-size: 30rpx;
position: relative;
line-height: 88rpx;
}
.item-con.active:after {
content: '';
display: block;
width: 100%;
height: 4rpx;
border-radius: 6rpx;
position: absolute;
left: 0;
bottom: 0;
}
&:last-of-type {
margin-right: 0;
}
}
}
.goods-list {
margin: 20rpx 30rpx 20rpx;
background-color: #fff;
border-radius: 10rpx;
height: 358rpx;
padding: 30rpx;
}
.goods-list .goods-item-content {
background-color: #fff;
border-radius: 10rpx;
box-sizing: border-box;
.goods-item-state {
display: flex;
align-items: center;
justify-content: space-between;
.state-time {
font-size: $font-size-base;
color: $color-title;
}
.state-sign {
font-size: $font-size-tag;
}
}
.goods-item-wrap {
display: flex;
margin-top: 42rpx;
}
.image-wrap {
display: flex;
align-items: center;
justify-content: center;
width: 170rpx;
height: 170rpx;
margin-right: 18rpx;
border-radius: 10rpx;
overflow: hidden;
image {
width: 170rpx;
height: 170rpx;
}
}
.content {
flex: 1;
position: relative;
line-height: 1;
width: calc(100% - 220rpx);
.title {
margin-top: -8rpx;
height: 84rpx;
font-size: $font-size-base;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
line-height: 42rpx;
color: $color-title;
}
.residue-price {
display: inline-block;
margin-top: 16rpx;
font-size: $font-size-sub;
padding: 2rpx 4rpx;
}
.price-box {
position: absolute;
bottom: 0;
line-height: 1.6;
font-size: $font-size-tag;
width: 100%;
.original-price {
color: $color-tip;
font-size: $font-size-tag;
text-decoration: line-through;
}
.time {
display: flex;
align-items: center;
margin-bottom: -12rpx;
font-size: $font-size-goods-tag;
.uni-countdown {
display: flex;
align-items: center;
}
.end-txt {
font-size: $font-size-base;
margin-left: 10rpx;
}
}
}
}
}
.goods-list .goods-item-action {
display: flex;
align-items: center;
justify-content: space-between;
height: 120rpx;
box-sizing: border-box;
.invitation-bargain {
display: flex;
flex-flow: wrap;
width: 510rpx;
image {
border: 2rpx solid #fff;
}
image,
.invitation-bargain-end {
margin-right: -24rpx;
width: 50rpx;
height: 50rpx;
border-radius: 50%;
border: 2rpx solid #fff;
}
.invitation-bargain-end {
display: flex;
align-items: center;
justify-content: center;
border: 2rpx dashed;
font-size: 24rpx;
background-color: #fff;
z-index: 999;
}
}
.btn {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
width: 130rpx;
height: 60rpx;
line-height: 1;
font-size: $font-size-tag;
border-radius: 60rpx;
border-color: #999999;
&.fail {
background-color: #aaa;
}
}
}
</style>
<style scoped>
>>>.uni-countdown__number,
>>>.uni-countdown__splitor {
margin: 0;
padding: 0;
}
.time>>>.uni-countdown__number {
min-width: 28rpx;
height: 28rpx;
text-align: center;
line-height: 28rpx;
background: #000;
border-radius: 4px;
display: inline-block;
padding: 4rpx;
margin: 0;
border: none;
}
.time>>>.uni-countdown__splitor {
margin: 0 4rpx;
}
</style>

View File

@@ -0,0 +1,52 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view>
<common-payment :api="api" create-data-key="bargainOrderCreateData" ref="payment"></common-payment>
</view>
</template>
<script>
export default {
data() {
return {
api: {
payment: '/bargain/api/ordercreate/payment',
calculate: '/bargain/api/ordercreate/calculate',
create: '/bargain/api/ordercreate/create'
}
}
},
provide() {
return {
promotion: this.promotion.bind(this)
}
},
onShow() {
if (this.$refs.payment) this.$refs.payment.pageShow();
},
methods:{
/**
* 处理活动信息 如不需要则留空
*/
promotion(data){
if(data.bargain_info){
return {title: '砍价活动', content: '该商品参与砍价活动'}
}
}
}
};
</script>
<style scoped lang="scss">
/deep/ .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
background: none;
max-height: unset !important;
overflow-y: hidden !important;
}
/deep/ .uni-popup__wrapper {
border-radius: 20rpx 20rpx 0 0;
}
/deep/ .uni-popup {
z-index: 8;
}
</style>

View File

@@ -0,0 +1,989 @@
.bargain {
background-size: cover;
background-repeat: repeat-y;
padding-bottom: 100rpx;
background: var(--bargain-promotion-color);
.bargain_top {
height: 360rpx;
background-size: 100% auto;
background-repeat: no-repeat;
display: flex;
color: #fff;
justify-content: center;
position: relative;
line-height: 1;
view {
color: #fff;
line-height: 50rpx;
height: 50rpx;
display: flex;
align-items: center;
font-size: 24rpx;
margin: 26rpx 2rpx;
}
}
.bargin_content {
background-color: #fff;
border-radius: 20rpx;
margin: 24rpx;
padding-bottom: 60rpx;
padding-top: 30rpx;
margin-top: 0;
.uer_info_base {
display: flex;
position: relative;
padding: 0 0;
flex-direction: column;
align-items: center;
justify-content: center;
margin-bottom: 20rpx;
.user_info_img {
background-color: #fff;
width: 120rpx;
height: 120rpx;
margin-top: -80rpx;
margin-left: 0;
border-radius: 50%;
border: 2px solid #fff;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.user_info_name {
margin-left: 0;
color: $color-tip;
align-self: center;
}
.rule_detail {
position: absolute;
height: 34rpx;
line-height: 34rpx;
padding: 0 12rpx;
font-size: 18rpx;
border: 1px solid;
right: 24rpx;
top: 30rpx;
border-radius: 34rpx;
}
}
.bargin_propaganda {
display: flex;
justify-content: space-between;
margin: 0 27rpx 30rpx;
font-size: 34rpx;
color: #333333;
font-weight: bold;
.marks {
font-size: 60rpx;
line-height: 1;
color: #b0b0b0;
}
}
.goods {
display: flex;
margin-top: 0;
margin-left: 24rpx;
margin-right: 24rpx;
padding: 24rpx;
background-color: #fafafa;
border-radius: 10rpx;
overflow: hidden;
.goods_img {
min-width: 180rpx;
width: 230rpx;
height: 230rpx;
margin-right: 20rpx;
border-radius: 10rpx;
image {
width: 100%;
height: 100%;
}
}
.goods_content {
flex: 1;
overflow: hidden;
.goods_title {
line-height: 1.3;
font-size: 30rpx;
margin-bottom: 10rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
display: -moz-box;
-moz-line-clamp: 2;
-moz-box-orient: vertical;
word-wrap: break-word;
word-break: break-all;
white-space: normal;
height: 78rpx;
}
.goods_price {
display: flex;
> view {
color: #666666;
font-size: 22rpx;
.original_price {
margin-left: 3rpx;
}
.bottom_price {
color: var(--price-color);
margin-left: 3rpx;
}
&:first-child {
margin-right: 10rpx;
}
}
}
.partake_num {
font-size: 22rpx;
color: #666666;
margin-top: 4rpx;
.residue-num {
margin-left: 10rpx;
}
.ident {
color: #fe0b42;
margin: 0 4rpx;
}
}
.count-down {
color: #666666;
margin-top: 6rpx;
text {
margin-left: 16rpx;
}
}
&.launch {
.goods_price {
flex-direction: column;
.original_price {
text-decoration: unset;
color: var(--price-color);
}
}
}
}
}
.progress_info {
display: flex;
justify-content: space-between;
margin: 40rpx 24rpx 0;
> view {
font-size: $font-size-tag;
color: #666666;
text {
color: var(--price-color);
}
}
}
.progress {
position: relative;
margin: 40rpx 35rpx 0;
height: 20rpx;
background-color: #fff4f4;
border-radius: 30rpx;
.progress_item {
width: 5%;
position: absolute;
left: 0;
border-radius: 30rpx;
height: 20rpx;
background: linear-gradient(to left, var(--bargain-promotion-color), var(--bargain-promotion-aux-color));
animation: all 1s forwards;
.iconfont {
position: absolute;
right: -20rpx;
top: -10rpx;
height: 40rpx;
width: 40rpx;
color: #fff;
background-color: var(--bargain-promotion-color);
display: flex;
align-items: center;
justify-content: center;
line-height: 1;
border-radius: 50%;
font-size: 24rpx;
z-index: 1;
}
}
.progress-point {
position: absolute;
background-color: var(--bargain-promotion-color);
height: 26rpx;
width: 26rpx;
border-radius: 50%;
right: -13rpx;
top: -4rpx;
}
}
.info-bottom {
display: flex;
justify-content: space-between;
margin: 10px 12px 0;
align-items: center;
.sale-box {
color: var(--bargain-promotion-color);
}
.price-box {
display: flex;
line-height: 1;
.discount-price {
display: flex;
font-size: 26rpx;
line-height: 1;
margin-top: 4rpx;
.price {
}
}
.delete-price {
display: flex;
font-size: 26rpx;
line-height: 1;
margin-top: 4rpx;
}
.price {
line-height: 1.2;
color: var(--bargain-promotion-color);
}
}
.pro-info {
line-height: 1;
display: flex;
align-items: center;
.button-border {
border: 2rpx solid var(--bargain-promotion-color);
color: var(--bargain-promotion-color);
font-size: 24rpx;
padding: 4rpx 6rpx;
line-height: 1;
border-radius: 4rpx;
background-color: #fff4f4;
position: relative;
border-top-right-radius: 0;
}
.button-border::before {
content: '';
display: block;
position: absolute;
top: -10rpx;
right: -2rpx;
border-left: 10rpx solid transparent;
border-right: 0 solid transparent;
border-bottom: 10rpx solid var(--bargain-promotion-color);
}
.button-border::after {
content: '';
display: block;
position: absolute;
top: -6rpx;
right: 0rpx;
border-left: 10rpx solid transparent;
border-right: 0 solid transparent;
border-bottom: 10rpx solid #fff4f4;
}
}
}
.bragain_recode {
display: flex;
align-items: center;
justify-content: space-between;
margin: 58rpx 24rpx 20rpx;
.bragain_recode_list {
display: flex;
margin: 0 26rpx;
.bragain_recode_add {
margin-left: 44rpx;
}
image {
width: 84rpx;
height: 84rpx;
border: 4rpx solid #fe0b42;
border-radius: 50%;
margin-left: -22rpx;
&:first-child {
margin-left: 0;
}
}
}
.bragain_recode_more {
width: 84rpx;
height: 84rpx;
line-height: 84rpx;
text-align: center;
font-size: 12rpx;
color: #999999;
}
.bragain_recode_add {
width: 84rpx;
height: 84rpx;
line-height: 76rpx;
text-align: center;
border-radius: 50%;
border: 1px dashed #e6e6e6;
font-size: 60rpx;
color: #e6e6e6;
}
}
.bragain_recode_detail {
font-size: 24rpx;
color: #000;
margin: 0 34rpx 0;
.iconfont {
font-size: 24rpx;
color: #333333;
}
}
.invitation_peo {
margin: 28rpx 30rpx 0;
.bargain-success {
display: flex;
align-items: center;
justify-content: center;
font-size: $font-size-tag;
margin: 40rpx 0 0;
.iconfont {
margin-right: 8rpx;
color: rgb(250, 26, 26);
}
> view {
text-align: center;
}
}
.launch-success {
text-align: center;
font-size: $font-size-tag;
}
.tip {
text-align: center;
color: #fe0b42;
font-size: $font-size-goods-tag;
}
.flex-box {
display: flex;
margin-top: 20rpx;
button {
flex: 1;
&:nth-child(2) {
margin-left: 20rpx;
}
}
&.success {
flex-direction: column;
.btn {
margin: 0 !important;
}
.btn-vice {
background-color: #fff;
border: 2rpx solid var(--bargain-promotion-color);
color: var(--bargain-promotion-color);
margin: 0 !important;
margin-top: 20rpx !important;
}
}
}
.btn {
height: 80rpx;
line-height: 80rpx;
background: var(--bargain-promotion-color);
border-radius: $border-radius;
text-align: center;
font-size: 30rpx;
color: #fff;
font-weight: bold;
margin: 20rpx 0;
}
.btn-vice {
height: 80rpx;
line-height: 80rpx;
background: var(--bargain-promotion-aux-color);
border-radius: $border-radius;
text-align: center;
font-size: 30rpx;
color: #fff;
font-weight: bold;
margin: 20rpx 0;
}
}
}
.bargin_introduction {
margin: 24rpx;
background-color: #fff;
border-radius: 20rpx;
.record-empty {
text-align: center;
font-size: $font-size-tag;
color: #999;
padding: 100rpx 0;
background-color: #fff;
border-radius: 20rpx;
}
.bargin_introduction_title {
display: flex;
align-items: center;
justify-content: center;
font-size: 34rpx;
color: #222222;
padding: 36rpx 0 0;
font-weight: bold;
&::before {
content: '';
background-color: #222222;
width: 20rpx;
height: 5rpx;
display: block;
margin-right: 10rpx;
}
&::after {
content: '';
background-color: #222222;
width: 20rpx;
height: 5rpx;
display: block;
margin-left: 10rpx;
}
}
.detail-content {
padding: 20rpx;
overflow: hidden;
* {
max-width: 100%;
}
img {
width: 100%;
}
}
.flow {
display: flex;
background-color: #fff;
border-radius: 20rpx;
padding: 40rpx 0;
.flow_item {
position: relative;
flex: 1;
text-align: center;
image {
width: 88rpx;
height: 88rpx;
margin-bottom: 20rpx;
}
> view {
color: #333333;
font-size: 24rpx;
}
&::after {
position: absolute;
content: '';
height: 2rpx;
width: 100rpx;
background-color: #fd0742;
top: 44rpx;
right: -22%;
}
&:last-child::after {
width: 0;
}
}
}
.bargin_invitation {
background-color: #fff;
border-radius: 20rpx;
padding: 27rpx;
.item {
display: flex;
align-items: center;
padding: 20rpx 0;
border-bottom: 2rpx solid rgba(237, 237, 237, 0.5);
&:last-child {
border-bottom: 0;
}
.item_left {
flex: 1;
display: flex;
overflow: hidden;
align-items: center;
image {
height: 70rpx;
width: 70rpx;
border: 2rpx solid #979797;
border-radius: 50%;
margin-right: 20rpx;
}
> view {
overflow: hidden;
align-items: center;
display: flex;
color: #6d7278;
white-space: nowrap;
/* 不换行 */
text-overflow: ellipsis;
.tip {
font-size: 20rpx;
color: #666666;
}
}
.bargin_info {
display: flex;
flex-direction: column;
justify-content: left;
align-items: flex-start;
> view:last-child {
color: #999999;
font-size: $font-size-tag;
}
}
}
.item_right {
min-width: 100rpx;
color: var(--bargain-promotion-color);
font-size: $font-size-base;
font-weight: bold;
display: flex;
align-items: center;
text {
font-size: $font-size-base;
color: var(--bargain-promotion-color);
font-weight: bold;
}
.bargain-icon {
width: 44rpx;
height: 44rpx;
margin-right: 14rpx;
}
}
}
.item_more {
margin-top: 20rpx;
text-align: center;
font-size: $font-size-tag;
color: #999999;
}
}
.bargain-list {
padding: 40rpx 0;
margin: 0 24rpx;
swiper {
height: 360rpx;
&.swiper-1 {
height: 120rpx;
}
&.swiper-2 {
height: 240rpx;
}
}
.bargain-item {
background-color: #f2f2f2;
display: flex;
align-items: center;
justify-content: space-between;
padding: 16rpx 24rpx;
> view:first-child {
display: flex;
align-items: center;
}
.bargain-head {
width: 60rpx;
height: 60rpx;
margin-right: 20rpx;
border: 2rpx solid #979797;
border-radius: 50%;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.bargain-info {
.bargain-title {
font-size: 24rpx;
color: #333333;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
width: 260rpx;
}
.bargain-desc {
font-size: 22rpx;
color: #6d7278;
}
}
.bargain-price {
text {
color: var(--bargain-promotion-color);
margin-left: 4rpx;
}
}
}
}
}
}
.bargain-popup {
width: 70vw;
background-color: #fff;
position: relative;
box-sizing: border-box;
border-radius: 20rpx;
height: 650rpx;
.head {
width: 55%;
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, -70%);
}
.title {
text-align: center;
font-size: 38rpx;
margin-top: 40rpx;
}
.money {
text-align: center;
.num {
font-size: 36rpx;
font-weight: 600;
}
.unit {
font-size: 24rpx;
margin-left: 8rpx;
}
}
&.self {
.head {
position: unset;
transform: unset;
top: 0;
left: 0;
width: 100%;
max-height: 350rpx;
}
.bargain-content {
text-align: center;
padding: 60rpx 40rpx;
.money {
font-weight: bold;
}
}
.bargain-btn {
width: max-content;
margin: 0 auto;
font-weight: bold;
padding: 0 60rpx;
background-color: var(--bargain-promotion-color);
color: #ffffff;
}
}
&.help {
.bargain-content {
.uer_info_base {
display: flex;
position: relative;
padding: 0 0;
flex-direction: column;
align-items: center;
justify-content: center;
margin-bottom: 20rpx;
.user_info_img {
background-color: #fff;
width: 120rpx;
height: 120rpx;
margin-top: -240rpx;
margin-left: 0;
border-radius: 50%;
border: 2px solid var(--bargain-promotion-color);
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.user_info_name {
margin-left: 0;
align-self: center;
font-size: 30rpx;
font-weight: bold;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
width: 100%;
}
}
.count-down {
> text {
color: #666;
margin: 0 6rpx;
}
}
}
}
}
.icon-round-close {
display: block;
font-size: 60rpx;
color: #ffffff;
text-align: center;
}
.share-popup,
.uni-popup__wrapper-box {
.share-title {
line-height: 60rpx;
font-size: $font-size-toolbar;
padding: 15rpx 0;
text-align: center;
}
.share-content {
display: flex;
display: -webkit-flex;
-webkit-flex-wrap: wrap;
-moz-flex-wrap: wrap;
-ms-flex-wrap: wrap;
-o-flex-wrap: wrap;
flex-wrap: wrap;
padding: 15rpx;
.share-box {
flex: 1;
text-align: center;
.share-btn {
margin: 0;
padding: 0;
border: none;
line-height: 1;
height: auto;
background-color: unset;
text {
margin-top: 20rpx;
font-size: $font-size-tag;
display: block;
color: $color-title;
}
}
.iconfont {
font-size: 80rpx;
line-height: initial;
}
.icon-fuzhilianjie,
.icon-pengyouquan,
.icon-haowuquan,
.icon-share-friend {
color: #07c160;
}
}
}
.share-footer {
height: 90rpx;
line-height: 90rpx;
border-top: 2rpx #f5f5f5 solid;
text-align: center;
color: #666;
}
}
.poster-layer {
/deep/ .uni-popup__wrapper.center {
width: 100vw!important;
height: 100vh!important;
background: none!important;
}
/deep/ .uni-popup__wrapper.uni-custom.center .uni-popup__wrapper-box {
max-width: 100vw!important;
max-height: 100vh!important;
background: none!important;
width: 100vw;
height: 100vh;
}
.poster-wrap {
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
flex-direction: column;
}
.generate-poster {
padding: 40rpx 0;
.iconfont {
font-size: 80rpx;
color: #07c160;
line-height: initial;
}
> view {
text-align: center;
&:last-child {
margin-top: 20rpx;
}
}
}
.image-wrap {
width: 80%;
position: relative;
image {
width: 100%;
line-height: 1;
border-radius: 10rpx;
overflow: hidden;
}
}
.msg {
padding: 40rpx;
}
.save-btn {
text-align: center;
height: 80rpx;
line-height: 80rpx;
background-color: $base-color;
border-radius: 10rpx;
width: 80%;
color: #fff;
margin-top: 30rpx;
}
.save-text {
color: #fff;
margin-top: 10rpx;
}
.close {
position: absolute;
top: 0;
right: 20rpx;
width: 40rpx;
height: 80rpx;
font-size: 50rpx;
color: #999;
}
}
.goods-details img {
max-width: 100%;
}
.rule-mark-enter {
position: absolute;
top: 120rpx;
right: 0;
width: 20rpx;
height: 100rpx;
line-height: 1;
background: #fff4f4;
padding: 10rpx 20rpx 10rpx 20rpx;
border-radius: 20rpx 0 0 20rpx;
color: var(--bargain-promotion-color);
font-size: $font-size-tag;
z-index: 100;
}
.rule-wrap {
border-radius: 10rpx;
background-color: #fff;
width: 80vw;
padding: 12rpx;
box-sizing: border-box;
.content-wrap {
width: 100%;
border-radius: 8rpx;
position: relative;
.rule-head {
width: 100%;
position: absolute;
transform: translateY(-50%);
left: 0;
top: 0;
}
.rule {
max-height: 880rpx;
overflow: hidden;
padding: 80rpx 30rpx 0 30rpx;
box-sizing: border-box;
.text {
font-size: $font-size-sub;
}
}
.icon-round-close {
color: #fff;
text-align: center;
position: absolute;
bottom: -150rpx;
left: 50%;
transform: translateX(-50%);
font-size: 70rpx;
}
}
}

View File

@@ -0,0 +1,243 @@
.page {
width: 100%;
min-height: 100vh;
background: var(--bargain-promotion-color);
}
.adv-wrap {
margin: $margin-updown $margin-both;
width: auto;
}
.lineheight-clear {
line-height: 1 !important;
}
// 商品列表单列样式
.goods-list.single-column {
.goods-item {
padding: 26rpx 26rpx 20rpx;
background: #fff;
margin: $margin-updown $margin-both;
border-radius: 24rpx;
display: flex;
position: relative;
flex-direction: column;
.goods-item-content {
display: flex;
}
.goods-item-bottom {
display: flex;
justify-content: space-between;
margin-top: 10rpx;
line-height: 1;
.item-bottom-left {
display: flex;
align-items: baseline;
margin-top: 10rpx;
.delete-pirce {
text-decoration: line-through;
color: $color-sub;
margin-left: 20rpx;
}
.txt {
margin-left: 10rpx;
font-weight: 26rpx;
}
.unit,
.price {
color: var(--bargain-promotion-color) !important;
}
}
.item-bottom-right {
display: flex;
align-items: center;
font-weight: bold;
button {
color: #fff;
background-color: var(--bargain-promotion-color);
}
}
}
.goods-img {
width: 200rpx;
height: 200rpx;
overflow: hidden;
border-radius: $border-radius;
margin-right: 20rpx;
image {
width: 100%;
height: 100%;
}
}
.goods-tag {
color: #fff;
line-height: 1;
padding: 8rpx 12rpx;
position: absolute;
border-top-left-radius: $border-radius;
border-bottom-right-radius: $border-radius;
top: 26rpx;
left: 26rpx;
font-size: $font-size-goods-tag;
}
.info-wrap {
flex: 1;
display: flex;
flex-direction: column;
width: calc(100% - 220rpx);
.info-sub-title {
color: $color-tip;
font-size: $font-size-tag;
margin-top: 6rpx;
}
}
.info-bottom {
display: flex;
justify-content: space-between;
margin-top: 10rpx;
align-items: center;
.sale-box {
color: var(--bargain-promotion-color);
}
.price-box {
display: flex;
line-height: 1;
.discount-price {
display: flex;
font-size: 26rpx;
line-height: 1;
margin-top: 4rpx;
}
.delete-price {
display: flex;
font-size: 26rpx;
line-height: 1;
margin-top: 4rpx;
}
.price {
line-height: 1.2;
color: var(--bargain-promotion-color);
}
}
.pro-info {
line-height: 1;
display: flex;
align-items: center;
.button-border {
border: 2rpx solid var(--bargain-promotion-color);
color: var(--bargain-promotion-color);
font-size: 24rpx;
padding: 4rpx 6rpx;
line-height: 1;
border-radius: 4rpx;
background-color: var(--bargain-promotion-color-shallow);
position: relative;
border-top-right-radius: 0;
}
.button-border::before {
content: '';
display: block;
position: absolute;
top: -10rpx;
right: -2rpx;
border-left: 10rpx solid transparent;
border-right: 0 solid transparent;
border-bottom: 10rpx solid var(--bargain-promotion-color);
}
.button-border::after {
content: '';
display: block;
position: absolute;
top: -6rpx;
right: 0rpx;
border-left: 10rpx solid transparent;
border-right: 0 solid transparent;
border-bottom: 10rpx solid var(--bargain-promotion-color-shallow);
}
}
}
.name-wrap {
flex: 1;
}
.goods-name {
font-size: $font-size-base;
line-height: 1.4;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-weight: bold;
word-wrap: break-word;
height: 80rpx;
}
.progress-wrap {
display: flex;
position: relative;
width: calc(100% - 32rpx);
margin: 10rpx auto;
progress {
flex: 1;
}
.progress-point {
background: var(--bargain-promotion-color);
width: 24rpx;
height: 24rpx;
border-radius: 50%;
position: absolute;
right: -12rpx;
top: -4rpx;
z-index: 1;
}
.progress-select {
background-color: var(--bargain-promotion-color);
color: var(--bargain-promotion-aux-color);
width: 24rpx;
height: 24rpx;
border-radius: 50%;
position: absolute;
left: 0;
top: -4rpx;
font-size: 24rpx;
z-index: 11;
&.icon {
width: 34rpx;
height: 34rpx;
display: flex;
align-items: center;
justify-content: center;
top: -10rpx;
}
.iconfont {
background-color: unset;
color: #fff;
font-size: 20rpx;
}
}
.txt {
margin: 0 100rpx 0 20rpx;
}
}
.member-price-tag {
display: inline-block;
width: 60rpx;
line-height: 1;
margin-left: 6rpx;
image {
width: 100%;
}
}
}
}

View File

@@ -0,0 +1,537 @@
import htmlParser from '@/common/js/html-parser';
export default {
data() {
return {
windowHeight: 0,
launch_id: 0,
bargain_id: 0,
info: {
headimg: ''
},
bargainRecord: [],
page: 1,
totalPage: 1,
load: false,
timeMachine: null,
bargainMoney: '0.00',
poster: '-1', //海报
posterMsg: '', //海报错误信息
posterHeight: 0,
goodsDetail: null,
launchInfo: null,
maxBuy: 1,
launchList: null,
showMore: false,
isOwn: 0, //是否自己砍了一刀
my_bargain_money: 0,
shareImg: ''
};
},
onLoad(data) {
setTimeout(() => {
if (!this.addonIsExist.bargain) {
this.$util.showToast({
title: '商家未开启砍价',
mask: true,
duration: 2000
});
setTimeout(() => {
this.$util.redirectTo('/pages/index/index');
}, 2000);
}
}, 1000);
// #ifdef MP-ALIPAY
let options = my.getLaunchOptionsSync();
options.query && Object.assign(data, options.query);
// #endif
this.getHeight();
if (data.l_id) this.launch_id = data.l_id;
if (data.b_id) this.bargain_id = data.b_id;
if (data.is_own) this.isOwn = data.is_own;
if (data.scene) {
var sceneParams = decodeURIComponent(data.scene);
sceneParams = sceneParams.split('&');
if (sceneParams.length) {
sceneParams.forEach(item => {
if (item.indexOf('m') != -1) uni.setStorageSync('source_member', item.split('-')[1]);
if (item.indexOf('l_id') != -1) this.id = item.split('-')[1];
if (item.indexOf('b_id') != -1) this.bargain_id = item.split('-')[1];
if (item.indexOf('is_own') != -1) this.isOwn = item.split('-')[1];
});
}
}
// #ifdef MP-WEIXIN
this.getShareImg();
// #endif
},
onShow() {
this.getBargainInfo();
},
computed: {
progress() {
if (this.launchInfo && this.goodsDetail) {
let total = this.goodsDetail.price - this.launchInfo.floor_price,
progress = parseInt(((this.goodsDetail.price - this.launchInfo.curr_price) / total) * 100);
return isNaN(progress) ? 0 : progress;
} else {
return 0;
}
},
showNum() {
if (this.launchList && this.launchList.length < 3) {
return this.launchList.length;
} else {
return 3;
}
}
},
methods: {
timeUp() {
this.getBargainInfo();
},
getHeight() {
var self = this;
uni.getSystemInfo({
success: function (res) {
self.windowHeight = res.windowHeight - 44;
if (self.iphoneX) {
self.windowHeight = self.windowHeight - 33;
}
}
});
},
getBargainInfo() {
if (this.load) return;
this.load = true;
this.$api.sendRequest({
url: '/bargain/api/bargain/detail',
data: {
launch_id: this.launch_id,
bargain_id: this.bargain_id
},
success: res => {
if (res.code == 0) {
this.goodsDetail = res.data.goods_sku_detail;
if (this.goodsDetail.sku_spec_format) this.goodsDetail.sku_spec_format = JSON.parse(this.goodsDetail.sku_spec_format);
this.$langConfig.title(this.goodsDetail.sku_name);
this.goodsDetail.unit = this.goodsDetail.unit || "件";
// 商品SKU格式
if (this.goodsDetail.goods_spec_format) this.goodsDetail.goods_spec_format = JSON.parse(this.goodsDetail.goods_spec_format);
// if (this.goodsDetail.goods_content) this.goodsDetail.goods_content = htmlParser(this.goodsDetail.goods_content);
if (this.addonIsExist.form) {
this.getGoodsForm();
}
if (res.data.launch_info && Object.keys(res.data.launch_info).length > 0) {
this.launchInfo = res.data.launch_info;
if (this.launchInfo.status == 0) {
this.timeMachine = this.$util.countDown(this.launchInfo.end_time - res.timestamp);
}
this.launch_id = this.launchInfo.launch_id;
}
if (res.data.launch_list && Object.keys(res.data.launch_list).length > 0) {
this.launchList = res.data.launch_list;
}
//发起砍价后自砍一刀展示
if (this.isOwn && this.goodsDetail.is_own > 0 && this.launchInfo && this.launchInfo.self && this.launchInfo.my_bargain_money) {
this.my_bargain_money = this.launchInfo.my_bargain_money;
this.$refs.uniSelfBargainPopup.open();
}
//好友进来后帮砍弹出
if (this.launchInfo && !this.launchInfo.self && !this.launchInfo.cut && this.goodsDetail.bargain_status == 1) this.$refs.uniHelpPopup.open();
this.load = false;
this.getBargainRecord(1);
this.setPublicShare();
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
} else {
this.load = false;
this.$util.redirectTo('/pages_promotion/bargain/my_bargain');
}
},
fail: res => {
this.load = false;
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
getBargainRecord(page) {
if (this.load) return;
if (!this.launchInfo) return;
this.load = true;
this.$api.sendRequest({
url: '/bargain/api/bargain/record',
data: {
page: page,
id: this.launchInfo.launch_id
},
success: res => {
this.load = false;
this.totalPage = res.data.page_count;
this.page = page;
if (res.code == 0 && res.data.list.length) {
if (page == 1) {
this.bargainRecord = res.data.list;
} else {
this.bargainRecord = this.bargainRecord.concat(res.data.list);
}
}
this.showMore = false;
if (page < this.totalPage) {
this.showMore = true;
}
}
});
},
scrolltolower() {
let next = this.page + 1;
if (!this.load && next <= this.totalPage) {
this.getBargainRecord(next);
}
},
browse() {
this.$api.sendRequest({
url: '/bargain/api/bargain/browse',
data: {
bargain_id: this.goodsDetail.bargain_id
},
success: res => {
}
});
},
share() {
this.$api.sendRequest({
url: '/bargain/api/bargain/share',
data: {
bargain_id: this.goodsDetail.bargain_id
},
success: res => {
}
});
},
/**
* 刷新商品详情数据
* @param {Object} goodsSkuDetail
*/
refreshGoodsSkuDetail(goodsSkuDetail) {
Object.assign(this.goodsDetail, goodsSkuDetail);
},
// 发起砍价
createBargain() {
if (!this.storeToken) {
this.$refs.login.open('/pages_promotion/bargain/detail?l_id=' + this.launch_id + '&b_id=' + this.bargain_id);
return;
}
// #ifdef MP
this.$util.subscribeMessage('BARGAIN_COMPLETE');
// #endif
if (this.goodsDetail.sku_spec_format || this.goodsDetail.goods_form) {
this.$refs.goodsSku.show('bargain');
} else {
this.$api.sendRequest({
url: '/bargain/api/bargain/launch',
data: {
id: this.goodsDetail.id
},
success: res => {
if (res.code == 0) {
let params = {
l_id: res.data,
b_id: this.bargain_id
};
if (this.goodsDetail.is_own) params.is_own = 1;
this.$util.redirectTo('/pages_promotion/bargain/detail', params, 'redirectTo');
} else {
this.$util.showToast({
title: res.message
});
}
}
});
}
},
/**
* 立即购买,不砍了,直接买
*/
buyNow() {
let goodsFormData = uni.getStorageSync('goodFormData');
let fn = ()=>{
uni.setStorage({
key: 'bargainOrderCreateData',
data: {
launch_id: this.launchInfo.launch_id
},
success: () => {
this.$util.redirectTo('/pages_promotion/bargain/payment');
}
});
};
if(!goodsFormData && this.goodsDetail.goods_form){
this.$refs.goodsSku.show('bargain',()=>{
fn();
});
}else{
fn();
}
},
/**
* 帮好友砍价
*/
bargain() {
if (this.storeToken) {
this.$api.sendRequest({
url: '/bargain/api/bargain/bargain',
data: {
id: this.launchInfo.launch_id
},
success: res => {
if (res.code == 0) {
this.bargainMoney = parseFloat(res.data.bargain_money).toFixed(2);
this.$refs.uniHelpPopup.close();
this.$refs.uniPopup.open();
this.getBargainInfo();
} else {
this.$util.showToast({
title: res.message
});
}
}
});
} else {
this.$refs.login.open('/pages_promotion/bargain/detail?l_id=' + this.launch_id + '&b_id=' + this.bargain_id);
}
},
closePopup() {
this.$refs.uniPopup.close();
},
closeSelfPop() {
this.$refs.uniSelfBargainPopup.close();
},
// 打开分享弹出层
openSharePopup() {
this.$refs.uniSelfBargainPopup.close();
this.$refs.sharePopup.open();
this.share();
},
// 关闭分享弹出层
closeSharePopup() {
this.$refs.sharePopup.close();
},
copyUrl() {
let text = '嘿!朋友就差你这一刀了,帮一下忙呗~' + this.$config.h5Domain + '/pages_promotion/bargain/detail?l_id=' + this.launch_id + '&b_id=' + this.bargain_id;
if (this.memberInfo && this.memberInfo.member_id) text += '&source_member=' + this.memberInfo.member_id;
this.$util.copy(text, () => {
this.closeSharePopup();
});
},
toBargainRecode() {
let view = uni.createSelectorQuery().select('.bargin_introduction');
view.boundingClientRect(data => {
uni.pageScrollTo({
duration: 100,
scrollTop: data.top + 100
});
}).exec();
},
/**
* 设置公众号分享
*/
setPublicShare() {
let shareUrl = this.$config.h5Domain + '/pages_promotion/bargain/detail?l_id=' + this.launch_id + '&b_id=' + this.bargain_id;
if (this.memberInfo && this.memberInfo.member_id) shareUrl += '&source_member=' + this.memberInfo.member_id;
this.$util.setPublicShare({
title: this.goodsDetail.sku_name,
desc: '嘿!朋友就差你这一刀了,帮一下忙呗~',
link: shareUrl,
imgUrl: this.goodsDetail.sku_image
},
res => {
// console.log('公众号分享成功');
// this.share();
}
);
},
//-------------------------------------海报-------------------------------------
// 打开海报弹出层
openPosterPopup() {
this.getGoodsPoster();
this.$refs.sharePopup.close();
},
// 关闭海报弹出层
closePosterPopup() {
this.$refs.posterPopup.close();
},
/**
* 获取海报
*/
getGoodsPoster() {
uni.showLoading({
title: '海报生成中...'
});
//活动海报信息
let posterParams = {
l_id: this.launch_id,
b_id: this.bargain_id,
bargain_id: this.goodsDetail.bargain_id
};
if (this.memberInfo && this.memberInfo.member_id) posterParams.source_member = this.memberInfo.member_id;
this.$api.sendRequest({
url: '/bargain/api/goods/poster',
data: {
page: '/pages_promotion/bargain/detail',
qrcode_param: JSON.stringify(posterParams)
},
success: res => {
if (res.code == 0) {
this.poster = res.data.path + '?time=' + new Date().getTime();
this.$refs.posterPopup.open();
} else {
this.posterMsg = res.message;
this.$util.showToast({
title: this.posterMsg
})
}
uni.hideLoading();
},
fail: err => {
uni.hideLoading();
}
});
},
getNewArray(array, subGroupLength) {
if (array) {
let index = 0;
let newArray = [];
while (index < array.length) {
newArray.push(array.slice(index, (index += subGroupLength)));
}
return newArray;
}
},
toDetail(goods_id) {
this.$util.redirectTo('/pages/goods/detail', {
goods_id: goods_id
});
},
/**
* 获取分享图
*/
getShareImg() {
let posterParams = {
l_id: this.launch_id,
b_id: this.bargain_id,
bargain_id: this.bargain_id
};
this.$api.sendRequest({
url: '/bargain/api/goods/shareimg',
data: {
page: '/pages_promotion/bargain/launch',
qrcode_param: JSON.stringify(posterParams)
},
success: res => {
if (res.code == 0) this.shareImg = res.data.path;
}
});
},
openRulePopup() {
this.$refs.rulePopup.open();
},
closeRulePopup() {
this.$refs.rulePopup.close();
},
/**
* 获取商品表单
*/
getGoodsForm() {
this.$api.sendRequest({
url: "/form/api/form/goodsform",
data: {
goods_id: this.goodsDetail.goods_id
},
success: res => {
if (res.code == 0 && res.data) {
this.$set(this.goodsDetail, 'goods_form', res.data);
let goodsFormData = uni.getStorageSync('goodFormData');
// 检测是否填写过自定义表单,已经发起砍价后,禁止切换规格
if (!goodsFormData && this.launchInfo && this.goodsDetail.goods_spec_format) {
this.goodsDetail.goods_spec_format.forEach(item => {
item.value.forEach(specItem => {
for (var i = 0; i < this.goodsDetail.sku_spec_format.length; i++) {
let skuItem = this.goodsDetail.sku_spec_format[i];
if (skuItem.spec_id == specItem.spec_id && skuItem.spec_value_id != specItem.spec_value_id) {
specItem.disabled = true;
break;
}
}
});
});
}
}
}
});
}
},
filters: {
/**
* 字符掩饰输出
* @param {Object} str
*/
cover(str) {
if (typeof str == 'string' && str.length > 0) {
return str.substr(0, 1) + '******' + str.substr(-1);
} else {
return '';
}
}
},
/**
* 自定义分享内容
*/
onShareAppMessage() {
var path = '/pages_promotion/bargain/detail?l_id=' + this.launch_id + '&b_id=' + this.bargain_id;
if (this.memberInfo && this.memberInfo.member_id) path += '&source_member=' + this.memberInfo.member_id;
this.share();
return {
title: '嘿!朋友就差你这一刀了,帮一下忙呗~',
imageUrl: this.shareImg ? this.$util.img(this.shareImg) : this.$util.img(this.goodsDetail.sku_image, {
size: 'big'
}),
path: path,
success: res => {
},
fail: res => {
},
complete: res => {
}
};
}
}

View File

@@ -0,0 +1,340 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view>
<view class="combo-package" :class="isIphoneX ? 'combo-iphonex' : ''">
<view class="combo-package-content">
<view class="combo-package-name color-title">{{ combo.bl_name }}</view>
<view v-for="(item, index) in combo.bundling_goods" :key="index" class="goods-info" @click="toGoodsDetail(item)">
<view class="goods-img">
<view class="img-wrap"><image :src="$util.img(item.sku_image, { size: 'mid' })" @error="imageError(index)" mode="aspectFit" /></view>
</view>
<view class="data-info">
<view class="goods-name">{{ item.sku_name }}</view>
<view class="price-wrap">
<text class="unit price-style small">{{ $lang('common.currencySymbol') }}</text>
<text class="price price-style large">{{ parseFloat(item.price).toFixed(2).split(".")[0] }}</text>
<text class="unit price-style small">.{{ parseFloat(item.price).toFixed(2).split(".")[1] }}</text>
<text class="num">x1</text>
</view>
<view class="stock-tips color-base-text" v-if="item.stock < num">
库存不足剩余{{ item.stock }}
<block v-if="item.unit">{{ item.unit }}</block>
<block v-else></block>
</view>
</view>
</view>
</view>
<view class="footer" :class="isIphoneX ? 'padding-bottom' : ''">
<view class="price-wrap">
<text class="label">套餐价</text>
<text class="unit price-color">{{ $lang('common.currencySymbol') }}</text>
<text class="price price-color">{{ parseFloat(packagePrice).toFixed(2).split(".")[0] }}</text>
<text class="unit price-color">.{{ parseFloat(packagePrice).toFixed(2).split(".")[1] }}</text>
<!-- <text class="info-num">为您节省{{ $lang('common.currencySymbol') }} {{ saveThePrice }}</text> -->
</view>
<button class="footer-btn mini" v-if="isDisabled" type="primary" @click="comboBuy()" size="mini">立即购买</button>
<button class="footer-btn mini" v-else disabled>立即购买</button>
</view>
</view>
<!-- 悬浮按钮 -->
<hover-nav></hover-nav>
<loading-cover ref="loadingCover"></loading-cover>
<ns-login ref="login"></ns-login>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
export default {
data() {
return {
num: 1, //购买数量
blId: 0, //商品id
combo: [],
packagePrice: [], //套餐价
saveThePrice: 0, //节省价格
isDisabled: false, //按钮失效
isIphoneX: false //判断是否是iphoneX以上的设备
};
},
onLoad(e) {
this.blId = e.bl_id || 0;
this.isIphoneX = this.$util.uniappIsIPhoneX();
},
onShow() {
setTimeout( () => {
if (!this.addonIsExist.bundling) {
this.$util.showToast({
title: '商家未开启组合套餐',
mask: true,
duration: 2000
});
setTimeout(() => {
this.$util.redirectTo('/pages/index/index');
}, 2000);
}
},1000);
this.getDetail();
},
onHide() {
this.btnSwitch = true;
},
methods: {
// 获取套餐详情
getDetail() {
this.$api.sendRequest({
url: '/bundling/api/bundling/detail',
data: {
bl_id: this.blId
},
success: res => {
if (res.data) {
this.combo = res.data;
this.numberChange();
} else {
this.$util.showToast({
title: res.message
});
}
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail: res => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
toGoodsDetail(e) {
this.$util.redirectTo('/pages/goods/detail', { goods_id: e.goods_id });
},
numberChange(flag, callback) {
setTimeout(() => {
var disabledCount = 0;
// 防止空
if (flag && this.num.length == 0) {
this.num = 1;
disabledCount++;
}
// 防止输入0和负数、非法输入
if (flag && (this.num <= 0 || isNaN(this.num))) {
this.number = 1;
disabledCount++;
}
if (flag) this.num = parseInt(this.num);
var price = 0;
for (var i = 0; i < this.combo.bundling_goods.length; i++) {
price += parseFloat(this.combo.bundling_goods[i].price);
//检测库存
if (this.combo.bundling_goods[i].stock < this.num) disabledCount++;
}
this.isDisabled = !(disabledCount > 0);
this.saveThePrice = ((price - this.combo.bl_price) * this.num).toFixed(2);
this.packagePrice = (this.combo.bl_price * this.num).toFixed(2);
if (callback) callback();
}, 0);
},
// 套餐立即购买点击
async comboBuy() {
if (!this.isDisabled) return;
//纠正数量
this.numberChange(true, () => {
if (!this.storeToken) {
this.$refs.login.open('/pages_promotion/bundling/detail?bl_id=' + this.blId);
return;
}
if (this.btnSwitch == false) return;
this.btnSwitch = false;
var data = {
bl_id: this.blId,
num: this.num
};
uni.setStorage({
key: 'comboOrderCreateData',
data: data,
success: () => {
this.$util.redirectTo('/pages_promotion/bundling/payment');
this.btnSwitch = true;
}
});
});
},
imageError(index) {
this.combo.bundling_goods[index].sku_image = this.$util.getDefaultImage().goods;
this.$forceUpdate();
}
},
onShareAppMessage(res) {
var title = '购买套餐,优惠多多哦';
var path = '/pages_promotion/combo/detail?bl_id=' + this.blId;
return {
title: title,
path: path,
success: res => {},
fail: res => {}
};
}
};
</script>
<style lang="scss">
.combo-package {
border-radius: $border-radius;
margin: 20rpx 30rpx;
margin-bottom: 160rpx;
background: #ffffff;
&.combo-iphonex {
margin-bottom: 230rpx;
}
.combo-package-content {
// padding-bottom: 40rpx;
.combo-package-name {
padding: 20rpx 30rpx;
}
.goods-info {
overflow: hidden;
padding: $padding 30rpx;
border-radius: $border-radius;
.goods-img {
display: inline-block;
width: 30%;
text-align: center;
line-height: 100%;
float: left;
.img-wrap {
display: inline-block;
width: 180rpx;
height: 180rpx;
text-align: center;
border-radius: $border-radius;
image {
height: 100%;
width: 100%;
vertical-align: middle;
}
}
}
.data-info {
display: inline-block;
width: 66%;
float: left;
position: relative;
margin-left: 20rpx;
height: 180rpx;
.goods-name {
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
display: -webkit-box;
line-height: 150%;
// margin-bottom: 20rpx;
}
.stock-tips {
position: absolute;
width: 100%;
bottom: 50rpx;
height: 40rpx;
line-height: 40rpx;
font-size: $font-size-tag;
}
.price-wrap {
height: 50rpx;
line-height: 50rpx;
position: absolute;
width: 100%;
bottom: 0;
.unit {
font-weight: bold;
font-size: $font-size-tag;
margin-right: 4rpx;
}
.price {
font-weight: bold;
font-size: $font-size-toolbar;
}
.num {
float: right;
}
}
}
}
}
.footer {
width: 100%;
background: #fff;
display: flex;
justify-content: space-between;
padding: 20rpx 24rpx;
box-sizing: border-box;
position: fixed;
bottom: 0;
left: 0;
.price-wrap {
flex: 1;
text-align: right;
vertical-align: middle;
line-height: 70rpx;
margin-right: 30rpx;
.label {
font-size: $font-size-base;
}
.unit {
font-weight: bold;
font-size: $font-size-tag;
margin-right: 4rpx;
}
.price {
font-weight: bold;
font-size: $font-size-toolbar;
}
.info-num {
font-size: $font-size-activity-tag;
color: $color-tip;
line-height: 1;
margin-top: 12rpx;
}
}
.footer-btn {
display: flex;
align-items: center;
justify-content: center;
height: 70rpx;
line-height: 70rpx;
}
}
.padding-bottom {
padding-bottom: 80rpx;
}
}
</style>

View File

@@ -0,0 +1,49 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view>
<common-payment :api="api" create-data-key="comboOrderCreateData" ref="payment"></common-payment>
</view>
</template>
<script>
export default {
data() {
return {
api: {
payment: '/bundling/api/ordercreate/payment',
calculate: '/bundling/api/ordercreate/calculate',
create: '/bundling/api/ordercreate/create'
}
}
},
provide() {
return {
promotion: this.promotion.bind(this)
}
},
onShow() {
if (this.$refs.payment) this.$refs.payment.pageShow();
},
methods: {
promotion(data){
if (data.bunding_info) {
return {title: '组合套餐', content: data.bunding_info.bl_name}
}
}
}
};
</script>
<style scoped lang="scss">
/deep/ .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
background: none;
max-height: unset !important;
overflow-y: hidden !important;
}
/deep/ .uni-popup__wrapper {
border-radius: 20rpx 20rpx 0 0;
}
/deep/ .uni-popup {
z-index: 8;
}
</style>

View File

@@ -1,161 +1,159 @@
Function.prototype.asyAfter = function(afterfn) {
var _self = this;
return function() {
var ret = _self.apply(this, arguments);
if (ret === 'next') {
return afterfn.apply(this, arguments);
}
return ret;
}
}
Date.prototype.pattern = function(fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
var week = {
"0": "\u65e5",
"1": "\u4e00",
"2": "\u4e8c",
"3": "\u4e09",
"4": "\u56db",
"5": "\u4e94",
"6": "\u516d"
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
if (/(E+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") :
"") +
week[this.getDay() + ""]);
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k])
.length)));
}
}
return fmt;
}
const isType = type => (/^\[object\s(.*)\]$/.exec(Object.prototype.toString.call(type)))[1];
let Time = function() {};
let timeProto = Time.prototype;
//获取当前时间戳
timeProto.getUnix = function() {
return new Date().getTime();
}
//获取当天0点0分0秒时间戳
timeProto.getTodayUnix = function() {
let date = new Date();
let myDate = `${date.getFullYear()}/${(date.getMonth() + 1)}/${date.getDate()} 00:00:00`;
return new Date(myDate).getTime();
}
//获取今年1月1日0点0分0秒时间戳
timeProto.getYearUnix = function() {
let date = new Date();
date.setMonth(0);
date.setDate(1);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
return date.getTime();
}
//获取当前时间标准年月日
timeProto.getLastDate = function(constTime) {
if (!constTime) {
return;
}
let date = new Date(constTime);
if (date.pattern) {
return date.pattern("yyyy-MM-dd");
}
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
return date.getFullYear() + '-' + month + '-' + day;
}
const resDateStr = function(timer, constTime) {
let _just = function(timer) {
if (timer <= 0 || Math.floor(timer / 60) <= 0) {
return "刚刚"
} else return 'next';
}
let _mm = function(timer) {
if (timer < 3600) {
return Math.floor(timer / 60) + "分钟前"
} else return 'next';
}
let _hh = function(timer, constTime) {
let today = _time_.getTodayUnix();
if (timer >= 3600 && (constTime - today >= 0)) {
//可切换显示模式
// return "今天 " + new Date(constTime).pattern("HH:mm");
return Math.floor(timer / 60 / 60) + "小时前";
} else {
return 'next'
};
}
let _dd = function(timer, constTime) {
let today = _time_.getTodayUnix();
timer = (today - constTime) / 1000;
if (timer / 86400 <= 31) {
return Math.ceil(timer / 86400) + "天前"
} else return 'next';
}
let _dlast = function(timer, constTime) {
return _time_.getLastDate(constTime);
}
let dateFilter = _just.asyAfter(_mm).asyAfter(_hh).asyAfter(_dd).asyAfter(_dlast);
return dateFilter(timer, constTime);
}
//转换时间
const reg = new RegExp("-", "g");
timeProto.getFormatTime = function(constTime, max) {
if (!constTime) {
return "";
}
switch (isType(constTime)) {
case 'Date':
constTime = constTime.getTime();
break;
case 'String':
constTime = constTime.replace(reg, "/");
default:
constTime = new Date(constTime).getTime();
break;
}
let now = this.getUnix();
let year = this.getYearUnix();
let timer = (now - constTime) / 1000;
if (constTime > now && max) {
return this.getLastDate(constTime);
}
let _t = this;
return resDateStr(timer, constTime);
}
const _time_ = new Time();
export default _time_;
Function.prototype.asyAfter = function(afterfn) {
var _self = this;
return function() {
var ret = _self.apply(this, arguments);
if (ret === 'next') {
return afterfn.apply(this, arguments);
}
return ret;
}
}
Date.prototype.pattern = function(fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
var week = {
"0": "\u65e5",
"1": "\u4e00",
"2": "\u4e8c",
"3": "\u4e09",
"4": "\u56db",
"5": "\u4e94",
"6": "\u516d"
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
if (/(E+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]);
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
}
return fmt;
}
const isType = type => (/^\[object\s(.*)\]$/.exec(Object.prototype.toString.call(type)))[1];
let Time = function() {};
let timeProto = Time.prototype;
//获取当前时间戳
timeProto.getUnix = function() {
return new Date().getTime();
}
//获取当天0点0分0秒时间戳
timeProto.getTodayUnix = function() {
let date = new Date();
let myDate = `${date.getFullYear()}/${(date.getMonth() + 1)}/${date.getDate()} 00:00:00`;
return new Date(myDate).getTime();
}
//获取今年1月1日0点0分0秒时间戳
timeProto.getYearUnix = function() {
let date = new Date();
date.setMonth(0);
date.setDate(1);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
return date.getTime();
}
//获取当前时间标准年月日
timeProto.getLastDate = function(constTime) {
if (!constTime) {
return;
}
let date = new Date(constTime);
if (date.pattern) {
return date.pattern("yyyy-MM-dd");
}
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
return date.getFullYear() + '-' + month + '-' + day;
}
const resDateStr = function(timer, constTime) {
let _just = function(timer) {
if (timer <= 0 || Math.floor(timer / 60) <= 0) {
return "刚刚"
} else return 'next';
}
let _mm = function(timer) {
if (timer < 3600) {
return Math.floor(timer / 60) + "分钟前"
} else return 'next';
}
let _hh = function(timer, constTime) {
let today = _time_.getTodayUnix();
if (timer >= 3600 && (constTime - today >= 0)) {
//可切换显示模式
// return "今天 " + new Date(constTime).pattern("HH:mm");
return Math.floor(timer / 60 / 60) + "小时前";
} else {
return 'next'
}
}
let _dd = function(timer, constTime) {
let today = _time_.getTodayUnix();
timer = (today - constTime) / 1000;
if (timer / 86400 <= 31) {
return Math.ceil(timer / 86400) + "天前"
} else return 'next';
}
let _dlast = function(timer, constTime) {
return _time_.getLastDate(constTime);
}
let dateFilter = _just.asyAfter(_mm).asyAfter(_hh).asyAfter(_dd).asyAfter(_dlast);
return dateFilter(timer, constTime);
}
//转换时间
const reg = new RegExp("-", "g");
timeProto.getFormatTime = function(constTime, max) {
if (!constTime) {
return "";
}
switch (isType(constTime)) {
case 'Date':
constTime = constTime.getTime();
break;
case 'String':
constTime = constTime.replace(reg, "/");
break;
default:
constTime = new Date(constTime).getTime();
break;
}
let now = this.getUnix();
let year = this.getYearUnix();
let timer = (now - constTime) / 1000;
if (constTime > now && max) {
return this.getLastDate(constTime);
}
let _t = this;
return resDateStr(timer, constTime);
}
const _time_ = new Time();
export default _time_;

View File

@@ -1,98 +1,97 @@
//字符串拼接
export function strFormat(str) {
return str < 10 ? `0${str}` : str
}
// 获取当前时间
export function currentTime() {
const myDate = new Date();
const year = myDate.getFullYear()
const m = myDate.getMonth() + 1;
const d = myDate.getDate();
// const date = year + '-' + strFormat(m) + '-' + strFormat(d); // 隐藏年
const date = strFormat(m) + '-' + strFormat(d);
const hour = myDate.getHours()
const min = myDate.getMinutes()
const secon = myDate.getSeconds()
const time = strFormat(hour) + ':' + strFormat(min) + ':' + strFormat(secon);
return {
year,
date,
time
}
}
//时间戳转日期
export function timeStamp(time) {
const dates = new Date(time)
const year = dates.getFullYear()
const month = dates.getMonth() + 1
const date = dates.getDate()
const day = dates.getDay()
const hour = dates.getHours()
const min = dates.getMinutes()
const days = ['日', '一', '二', '三', '四', '五', '六']
return {
allDate: `${year}/${strFormat(month)}/${strFormat(date)}`,
date: `${strFormat(month)}-${strFormat(date)}`, //返回的日期 07-01${strFormat(year)}-${strFormat(month)}-${strFormat(date)}
day: `${days[day]}`, //返回的礼拜天数 星期一
hour: strFormat(hour) + ':' + strFormat(min) // + ':00' //返回的时钟 08:00
}
}
//获取最近7天的日期和礼拜天数
export function initData(appointedDay = '') {
const time = []
const date = appointedDay ? new Date(appointedDay) : new Date()
const now = date.getTime() //获取当前日期的时间戳
let timeStr = 3600 * 24 * 1000 //一天的时间戳
let obj = {
0: "今天",
1: "明天",
2: "后天"
}
for (let i = 0; i < 7; i++) {
const timeObj = {}
timeObj.date = timeStamp(now + timeStr * i).date //保存日期
timeObj.timeStamp = now + timeStr * i //保存时间戳
timeObj.week = appointedDay == '' ? (obj[i] ?? timeStamp(now + timeStr * i).day) : timeStamp(now + timeStr * i)
.day
time.push(timeObj)
}
return time
}
//时间数组
export function initTime(startTime = '09:00', endTime = '18:30', timeInterval = 1) {
const time = []
const date = timeStamp(Date.now()).allDate
const startDate = `${date} ${startTime}`
const endDate = `${date} ${endTime}`
const startTimeStamp = new Date(startDate).getTime()
const endTimeStamp = new Date(endDate).getTime()
const timeStr = 3600 * 1000 * timeInterval
for (let i = startTimeStamp; i <= endTimeStamp; i = i + timeStr) {
const timeObj = {}
timeObj.time = timeStamp(i).hour
timeObj.disable = false
time.push(timeObj)
}
return time
}
export function weekDate(){
var now = new Date(); //当前日期
var nowDayOfWeek = now.getDay(); //今天本周的第几天
var nowDay = now.getDate(); //当前
var nowMonth = now.getMonth(); //当前
var nowYear = now.getYear(); //当前年
var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek + 1);
var weekEndDate = new Date(nowYear, nowMonth, nowDay + (7 - nowDayOfWeek));
var arr = [];
arr[0] = strFormat(weekStartDate.getMonth()+1) + '-' + strFormat(weekStartDate.getDate());
arr[1] = strFormat(weekEndDate.getMonth()+1) + '-' + strFormat(weekEndDate.getDate());
return arr;
}
//字符串拼接
export function strFormat(str) {
return str < 10 ? `0${str}` : str
}
// 获取当前时间
export function currentTime() {
const myDate = new Date();
const year = myDate.getFullYear()
const m = myDate.getMonth() + 1;
const d = myDate.getDate();
// const date = year + '-' + strFormat(m) + '-' + strFormat(d); // 隐藏年
const date = strFormat(m) + '-' + strFormat(d);
const hour = myDate.getHours()
const min = myDate.getMinutes()
const secon = myDate.getSeconds()
const time = strFormat(hour) + ':' + strFormat(min) + ':' + strFormat(secon);
return {
year,
date,
time
}
}
//时间戳转日期
export function timeStamp(time) {
const dates = new Date(time)
const year = dates.getFullYear()
const month = dates.getMonth() + 1
const date = dates.getDate()
const day = dates.getDay()
const hour = dates.getHours()
const min = dates.getMinutes()
const days = ['日', '一', '二', '三', '四', '五', '六']
return {
allDate: `${year}/${strFormat(month)}/${strFormat(date)}`,
date: `${strFormat(month)}-${strFormat(date)}`, //返回的日期 07-01${strFormat(year)}-${strFormat(month)}-${strFormat(date)}
day: `${days[day]}`, //返回的礼拜天数 星期一
hour: strFormat(hour) + ':' + strFormat(min) // + ':00' //返回的时钟 08:00
}
}
//获取最近7天的日期和礼拜天数
export function initData(appointedDay = '') {
const time = []
const date = appointedDay ? new Date(appointedDay) : new Date()
const now = date.getTime() //获取当前日期的时间戳
let timeStr = 3600 * 24 * 1000 //一天的时间戳
let obj = {
0: "今天",
1: "明天",
2: "后天"
}
for (let i = 0; i < 7; i++) {
const timeObj = {}
timeObj.date = timeStamp(now + timeStr * i).date //保存日期
timeObj.timeStamp = now + timeStr * i //保存时间戳
timeObj.week = appointedDay == '' ? (obj[i] ?? timeStamp(now + timeStr * i).day) : timeStamp(now + timeStr * i).day
time.push(timeObj)
}
return time
}
//时间数组
export function initTime(startTime = '09:00', endTime = '18:30', timeInterval = 1) {
const time = []
const date = timeStamp(Date.now()).allDate
const startDate = `${date} ${startTime}`
const endDate = `${date} ${endTime}`
const startTimeStamp = new Date(startDate).getTime()
const endTimeStamp = new Date(endDate).getTime()
const timeStr = 3600 * 1000 * timeInterval
for (let i = startTimeStamp; i <= endTimeStamp; i = i + timeStr) {
const timeObj = {}
timeObj.time = timeStamp(i).hour
timeObj.disable = false
time.push(timeObj)
}
return time
}
export function weekDate(){
var now = new Date(); //当前日期
var nowDayOfWeek = now.getDay(); //今天本周的第几天
var nowDay = now.getDate(); //当前日
var nowMonth = now.getMonth(); //当前
var nowYear = now.getYear(); //当前
var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek + 1);
var weekEndDate = new Date(nowYear, nowMonth, nowDay + (7 - nowDayOfWeek));
var arr = [];
arr[0] = strFormat(weekStartDate.getMonth()+1) + '-' + strFormat(weekStartDate.getDate());
arr[1] = strFormat(weekEndDate.getMonth()+1) + '-' + strFormat(weekEndDate.getDate());
return arr;
}

View File

@@ -1,413 +1,414 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view class="content">
<mescroll-uni ref="mescroll" @getData="getGoodsList">
<block slot="list">
<view class="goods-list" :style="{ backgroundImage: 'url(' + $util.img('public/uniapp/fenxiao/promote/promote_bg.png') + ')' }">
<scroll-view class="quick-nav" scroll-x="true">
<!-- #ifdef MP -->
<view class="uni-scroll-view-content">
<!-- #endif -->
<view class="quick-nav-item" :class="{ selected: categoryId == 0 }" @click="changeCategory(0)">全部</view>
<view
class="quick-nav-item"
v-for="item in categoryList"
:class="{ selected: categoryId == item.category_id }"
@click="changeCategory(item.category_id)"
>
{{ item.category_name }}
</view>
<!-- #ifdef MP -->
</view>
<!-- #endif -->
</scroll-view>
<view v-for="(item, index) in goodsList" :key="index" class="goods-item" @click="navToDetailPage(item)">
<view class="image-wrap">
<image :src="$util.img(item.sku_image, { size: 'mid' })" @error="imageError(index)" mode="aspectFill" />
</view>
<view class="goods-content">
<view class="goods-name">
<text class="name">{{ item.sku_name }}</text>
<view class="label-list" v-if="item.label_name">
<text class="label-item">{{ item.label_name }}</text>
</view>
</view>
<view class="goods-bottom">
<view class="goods-price color-base-text">
<text class="font-size-tag"></text>
{{ item.discount_price }}
</view>
<view class="goods-share" @click.stop="shareFn('goods', index)">
<text class="icondiy icon-system-share"></text>
<text class="txt" v-if="!is_fenxiao">分享</text>
<text class="txt" v-else>{{ item.commission_money }}</text>
</view>
</view>
</view>
</view>
<view class="empty" v-if="goodsList.length == 0">
<ns-empty :isIndex="false" text="暂无分销商品" textColor="#fff"></ns-empty>
</view>
</view>
</block>
</mescroll-uni>
<view class="active-btn" v-if="goodsList.length">
<!-- #ifdef MP -->
<button class="share-btn" :plain="true" open-type="share">分享好友</button>
<text class="tag">|</text>
<!-- #endif -->
<text class="btn" @click="shareFn('fenxiao')">生成海报</text>
</view>
<loading-cover ref="loadingCover"></loading-cover>
<!-- 分享弹窗 -->
<view @touchmove.prevent.stop>
<uni-popup ref="sharePopup" type="bottom" class="share-popup">
<view>
<view class="share-title">分享</view>
<view class="share-content">
<!-- #ifdef MP -->
<view class="share-box">
<button class="share-btn" :plain="true" open-type="share">
<view class="iconfont icon-share-friend"></view>
<text>分享给好友</text>
</button>
</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="share-box" v-if="goodsCircle">
<button class="share-btn" :plain="true" @click="openBusinessView">
<view class="iconfont icon-haowuquan"></view>
<text>分享到好物圈</text>
</button>
</view>
<!-- #endif -->
<view class="share-box" @click="openPosterPopup">
<button class="share-btn" :plain="true">
<view class="iconfont icon-pengyouquan"></view>
<text>生成分享海报</text>
</button>
</view>
<!-- #ifdef H5 -->
<view class="share-box" @click="copyUrl">
<button class="share-btn" :plain="true">
<view class="iconfont icon-fuzhilianjie"></view>
<text>复制链接</text>
</button>
</view>
<!-- #endif -->
</view>
<view class="share-footer" @click="closeSharePopup"><text>取消分享</text></view>
</view>
</uni-popup>
</view>
<!-- 海报 -->
<view @touchmove.prevent.stop>
<uni-popup ref="posterPopup" type="bottom" class="poster-layer">
<template v-if="poster != '-1'">
<view>
<view class="image-wrap">
<image :src="$util.img(poster)" :show-menu-by-longpress="true" />
</view>
<!-- #ifdef MP || APP-PLUS -->
<view class="save" @click="saveGoodsPoster()">保存图片</view>
<!-- #endif -->
<!-- #ifdef H5 -->
<view class="save">长按保存图片</view>
<!-- #endif -->
</view>
<view class="close iconfont icon-close" @click="closePosterPopup()"></view>
</template>
<view v-else class="msg">{{ posterMsg }}</view>
</uni-popup>
</view>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
import list from './public/js/goods_list.js';
import fenxiaoWords from 'common/js/fenxiao-words.js';
export default {
mixins: [list, fenxiaoWords]
};
</script>
<style>
.quick-nav >>> .uni-scroll-view-content {
display: flex;
}
</style>
<style lang="scss">
/deep/ .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
max-height: unset !important;
}
.quick-nav {
margin-bottom: 20rpx;
.quick-nav-item {
display: flex;
align-items: center;
padding: 0 18rpx;
box-sizing: border-box;
flex-shrink: 0;
border-radius: 40rpx;
margin-right: 20rpx;
height: 48rpx;
font-size: 24rpx;
background: #fff;
color: $base-color;
&.selected {
background: $base-color;
color: #fff;
}
&:last-child {
margin-right: 0;
}
}
}
.content {
overflow: hidden;
padding: 0 30rpx 160rpx;
min-height: 100vh;
background-color: #ff2d46;
.goods-list {
min-height: 100vh;
padding: 420rpx 30rpx 0;
background-size: 100%;
background-repeat: no-repeat;
box-sizing: border-box;
.goods-item {
margin-bottom: 20rpx;
background: #ffffff;
padding: $padding;
display: flex;
border-radius: 10rpx;
&:last-child {
margin-bottom: 0;
}
}
.image-wrap {
display: inline-block;
width: 200rpx;
height: 200rpx;
line-height: 200rpx;
border-radius: 10rpx;
overflow: hidden;
flex-shrink: 0;
image {
width: 100%;
height: 100%;
opacity: 1;
border-radius: 20rpx;
}
}
.goods-content {
width: calc(100% - 200rpx);
min-height: 160rpx;
padding-left: $padding;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
.goods-name {
width: 100%;
line-height: 1.3;
.name {
line-height: 1.3;
word-break: break-all;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.label-list {
display: flex;
align-items: center;
margin-top: 6rpx;
.label-item {
padding: 4rpx 10rpx;
font-size: $font-size-tag;
color: $base-color;
border: 2rpx solid $base-color;
border-radius: 6rpx;
line-height: 1;
}
}
}
.goods-bottom {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.goods-price {
line-height: 1.3;
font-size: $font-size-base;
font-weight: bold;
}
.goods-share {
height: 50rpx;
display: flex;
justify-content: center;
align-items: center;
padding: 0 $padding;
border-radius: 50rpx;
border: 2rpx solid $base-color;
text {
color: $base-color;
border-radius: 40rpx;
font-size: $font-size-tag;
}
.icondiy {
margin-right: 4rpx;
font-size: $font-size-base;
}
}
}
}
}
.active-btn {
position: fixed;
bottom: 40rpx;
left: 80rpx;
right: 80rpx;
height: 80rpx;
display: flex;
justify-content: center;
align-items: center;
z-index: 2;
border-radius: 50rpx;
background-color: $base-color;
color: #fff;
.btn {
flex: 1;
text-align: center;
}
.share-btn {
margin: 0;
padding: 0;
flex: 1;
text-align: center;
border: 0;
color: #fff;
}
}
.share-popup,
.uni-popup__wrapper-box {
.share-title {
line-height: 60rpx;
font-size: $font-size-toolbar;
padding: 15rpx 0;
text-align: center;
}
.share-content {
display: flex;
display: -webkit-flex;
-webkit-flex-wrap: wrap;
-moz-flex-wrap: wrap;
-ms-flex-wrap: wrap;
-o-flex-wrap: wrap;
flex-wrap: wrap;
padding: 80rpx 15rpx;
.share-box {
flex: 1;
text-align: center;
.share-btn {
margin: 0;
padding: 0;
border: none;
line-height: 1;
height: auto;
text {
margin-top: 20rpx;
font-size: $font-size-tag;
display: block;
color: $color-title;
}
}
.iconfont {
font-size: 80rpx;
line-height: initial;
}
.icon-fuzhilianjie,
.icon-pengyouquan,
.icon-haowuquan,
.icon-share-friend {
color: #07c160;
}
}
}
.share-footer {
height: 90rpx;
line-height: 90rpx;
border-top: 2rpx solid $color-line;
text-align: center;
}
}
.poster-layer {
.generate-poster {
padding: 40rpx 0;
.iconfont {
font-size: 80rpx;
color: #07c160;
line-height: initial;
}
> view {
text-align: center;
&:last-child {
margin-top: 20rpx;
}
}
}
.image-wrap {
width: 64%;
height: 854rpx;
margin: 60rpx auto 40rpx auto;
box-shadow: 0 0 32rpx rgba(100, 100, 100, 0.3);
image {
width: 480rpx;
height: 854rpx;
}
}
.msg {
padding: 40rpx;
}
.save {
text-align: center;
height: 80rpx;
line-height: 80rpx;
}
.close {
position: absolute;
top: 0;
right: 20rpx;
width: 40rpx;
height: 80rpx;
font-size: 50rpx;
}
}
}
</style>
<template>
<page-meta :page-style="themeColor"></page-meta>
<view class="content">
<mescroll-uni ref="mescroll" @getData="getGoodsList">
<block slot="list">
<view class="goods-list" :style="{ backgroundImage: 'url(' + $util.img('public/uniapp/fenxiao/promote/promote_bg.png') + ')' }">
<scroll-view class="quick-nav" scroll-x="true">
<!-- #ifdef MP -->
<view class="uni-scroll-view-content">
<!-- #endif -->
<view class="quick-nav-item" :class="{ selected: categoryId == 0 }" @click="changeCategory(0)">全部</view>
<view
class="quick-nav-item"
v-for="item in categoryList"
:key="item.category_id"
:class="{ selected: categoryId == item.category_id }"
@click="changeCategory(item.category_id)"
>
{{ item.category_name }}
</view>
<!-- #ifdef MP -->
</view>
<!-- #endif -->
</scroll-view>
<view v-for="(item, index) in goodsList" :key="index" class="goods-item" @click="navToDetailPage(item)">
<view class="image-wrap">
<image :src="$util.img(item.sku_image, { size: 'mid' })" @error="imageError(index)" mode="aspectFill" />
</view>
<view class="goods-content">
<view class="goods-name">
<text class="name">{{ item.sku_name }}</text>
<view class="label-list" v-if="item.label_name">
<text class="label-item">{{ item.label_name }}</text>
</view>
</view>
<view class="goods-bottom">
<view class="goods-price color-base-text">
<text class="font-size-tag"></text>
{{ item.discount_price }}
</view>
<view class="goods-share" @click.stop="shareFn('goods', index)">
<text class="icondiy icon-system-share"></text>
<text class="txt" v-if="!is_fenxiao">分享</text>
<text class="txt" v-else>{{ item.commission_money }}</text>
</view>
</view>
</view>
</view>
<view class="empty" v-if="goodsList.length == 0">
<ns-empty :isIndex="false" text="暂无分销商品" textColor="#fff"></ns-empty>
</view>
</view>
</block>
</mescroll-uni>
<view class="active-btn" v-if="goodsList.length">
<!-- #ifdef MP -->
<button class="share-btn" :plain="true" open-type="share">分享好友</button>
<text class="tag">|</text>
<!-- #endif -->
<text class="btn" @click="shareFn('fenxiao')">生成海报</text>
</view>
<loading-cover ref="loadingCover"></loading-cover>
<!-- 分享弹窗 -->
<view @touchmove.prevent.stop>
<uni-popup ref="sharePopup" type="bottom" class="share-popup">
<view>
<view class="share-title">分享</view>
<view class="share-content">
<!-- #ifdef MP -->
<view class="share-box">
<button class="share-btn" :plain="true" open-type="share">
<view class="iconfont icon-share-friend"></view>
<text>分享给好友</text>
</button>
</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="share-box" v-if="goodsCircle">
<button class="share-btn" :plain="true" @click="openBusinessView">
<view class="iconfont icon-haowuquan"></view>
<text>分享到好物圈</text>
</button>
</view>
<!-- #endif -->
<view class="share-box" @click="openPosterPopup">
<button class="share-btn" :plain="true">
<view class="iconfont icon-pengyouquan"></view>
<text>生成分享海报</text>
</button>
</view>
<!-- #ifdef H5 -->
<view class="share-box" @click="copyUrl">
<button class="share-btn" :plain="true">
<view class="iconfont icon-fuzhilianjie"></view>
<text>复制链接</text>
</button>
</view>
<!-- #endif -->
</view>
<view class="share-footer" @click="closeSharePopup"><text>取消分享</text></view>
</view>
</uni-popup>
</view>
<!-- 海报 -->
<view @touchmove.prevent.stop>
<uni-popup ref="posterPopup" type="bottom" class="poster-layer">
<template v-if="poster != '-1'">
<view>
<view class="image-wrap">
<image :src="$util.img(poster)" :show-menu-by-longpress="true" />
</view>
<!-- #ifdef MP || APP-PLUS -->
<view class="save" @click="saveGoodsPoster()">保存图片</view>
<!-- #endif -->
<!-- #ifdef H5 -->
<view class="save">长按保存图片</view>
<!-- #endif -->
</view>
<view class="close iconfont icon-close" @click="closePosterPopup()"></view>
</template>
<view v-else class="msg">{{ posterMsg }}</view>
</uni-popup>
</view>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
import list from './public/js/goods_list.js';
import fenxiaoWords from 'common/js/fenxiao-words.js';
export default {
mixins: [list, fenxiaoWords]
};
</script>
<style>
.quick-nav >>> .uni-scroll-view-content {
display: flex;
}
</style>
<style lang="scss">
/deep/ .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
max-height: unset !important;
}
.quick-nav {
margin-bottom: 20rpx;
.quick-nav-item {
display: flex;
align-items: center;
padding: 0 18rpx;
box-sizing: border-box;
flex-shrink: 0;
border-radius: 40rpx;
margin-right: 20rpx;
height: 48rpx;
font-size: 24rpx;
background: #fff;
color: $base-color;
&.selected {
background: $base-color;
color: #fff;
}
&:last-child {
margin-right: 0;
}
}
}
.content {
overflow: hidden;
padding: 0 30rpx 160rpx;
min-height: 100vh;
background-color: #ff2d46;
.goods-list {
min-height: 100vh;
padding: 420rpx 30rpx 0;
background-size: 100%;
background-repeat: no-repeat;
box-sizing: border-box;
.goods-item {
margin-bottom: 20rpx;
background: #ffffff;
padding: $padding;
display: flex;
border-radius: 10rpx;
&:last-child {
margin-bottom: 0;
}
}
.image-wrap {
display: inline-block;
width: 200rpx;
height: 200rpx;
line-height: 200rpx;
border-radius: 10rpx;
overflow: hidden;
flex-shrink: 0;
image {
width: 100%;
height: 100%;
opacity: 1;
border-radius: 20rpx;
}
}
.goods-content {
width: calc(100% - 200rpx);
min-height: 160rpx;
padding-left: $padding;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
.goods-name {
width: 100%;
line-height: 1.3;
.name {
line-height: 1.3;
word-break: break-all;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.label-list {
display: flex;
align-items: center;
margin-top: 6rpx;
.label-item {
padding: 4rpx 10rpx;
font-size: $font-size-tag;
color: $base-color;
border: 2rpx solid $base-color;
border-radius: 6rpx;
line-height: 1;
}
}
}
.goods-bottom {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.goods-price {
line-height: 1.3;
font-size: $font-size-base;
font-weight: bold;
}
.goods-share {
height: 50rpx;
display: flex;
justify-content: center;
align-items: center;
padding: 0 $padding;
border-radius: 50rpx;
border: 2rpx solid $base-color;
text {
color: $base-color;
border-radius: 40rpx;
font-size: $font-size-tag;
}
.icondiy {
margin-right: 4rpx;
font-size: $font-size-base;
}
}
}
}
}
.active-btn {
position: fixed;
bottom: 40rpx;
left: 80rpx;
right: 80rpx;
height: 80rpx;
display: flex;
justify-content: center;
align-items: center;
z-index: 2;
border-radius: 50rpx;
background-color: $base-color;
color: #fff;
.btn {
flex: 1;
text-align: center;
}
.share-btn {
margin: 0;
padding: 0;
flex: 1;
text-align: center;
border: 0;
color: #fff;
}
}
.share-popup,
.uni-popup__wrapper-box {
.share-title {
line-height: 60rpx;
font-size: $font-size-toolbar;
padding: 15rpx 0;
text-align: center;
}
.share-content {
display: flex;
display: -webkit-flex;
-webkit-flex-wrap: wrap;
-moz-flex-wrap: wrap;
-ms-flex-wrap: wrap;
-o-flex-wrap: wrap;
flex-wrap: wrap;
padding: 80rpx 15rpx;
.share-box {
flex: 1;
text-align: center;
.share-btn {
margin: 0;
padding: 0;
border: none;
line-height: 1;
height: auto;
text {
margin-top: 20rpx;
font-size: $font-size-tag;
display: block;
color: $color-title;
}
}
.iconfont {
font-size: 80rpx;
line-height: initial;
}
.icon-fuzhilianjie,
.icon-pengyouquan,
.icon-haowuquan,
.icon-share-friend {
color: #07c160;
}
}
}
.share-footer {
height: 90rpx;
line-height: 90rpx;
border-top: 2rpx solid $color-line;
text-align: center;
}
}
.poster-layer {
.generate-poster {
padding: 40rpx 0;
.iconfont {
font-size: 80rpx;
color: #07c160;
line-height: initial;
}
> view {
text-align: center;
&:last-child {
margin-top: 20rpx;
}
}
}
.image-wrap {
width: 64%;
height: 854rpx;
margin: 60rpx auto 40rpx auto;
box-shadow: 0 0 32rpx rgba(100, 100, 100, 0.3);
image {
width: 480rpx;
height: 854rpx;
}
}
.msg {
padding: 40rpx;
}
.save {
text-align: center;
height: 80rpx;
line-height: 80rpx;
}
.close {
position: absolute;
top: 0;
right: 20rpx;
width: 40rpx;
height: 80rpx;
font-size: 50rpx;
}
}
}
</style>

View File

@@ -1,58 +1,58 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view>
<view class="category-page-wrap category-template-1" style="height: calc(-56px + 100vh);">
<!-- <view class="search-box" @click="$util.redirectTo('/pages_tool/goods/search')">
<view class="search-content">
<input type="text" class="uni-input" maxlength="50" placeholder="商品搜索" confirm-type="search" disabled="true" />
<text class="iconfont icon-sousuo3"></text>
</view>
</view> -->
<view class="content-box" v-if="categoryTree">
<block v-if="categoryTree.length">
<scroll-view scroll-y="true" class="tree-wrap">
<view class="category-item-wrap">
<view class="category-item" v-for="(item, index) in categoryTree" :key="index" :class="[
{ select: select == index },
]" @click="switchOneCategory(index)">
<view class="">{{ item.category_name }}</view>
</view>
</view>
</scroll-view>
<view class="right-flex-wrap">
<scroll-view scroll-y="true" class="content-wrap" ref="contentWrap" :scroll-into-view="categoryId" :scroll-with-animation="true"
@scroll="listenScroll" @touchstart="touchStart" :refresher-enabled="true"
refresher-default-style="none" :refresher-triggered="triggered" @refresherrefresh="onRefresh"
@refresherrestore="onRestore">
<view class="child-category" v-for="(item, index) in categoryTree" :id="'category-' + index" v-if="item.child_list.length > 0">
<!---->
<view class="item-wrap category">
<view class="category-title">{{ item.category_name }}</view>
<view class="category-list">
<view class="category-item" v-for="(one, oneIndex) in item.child_list" :key="oneIndex" @click="$util.redirectTo('/pages_promotion/merch/detail', { merch_id: one.merch_id })">
<view class="img-box">
<image :src="$util.img(one.merch_image)" mode="widthFix"/>
</view>
<view class="name">{{ one.merch_name }}</view>
</view>
</view>
</view>
<!-- <view class="category-empty" v-else>
<image src="/static/common-empty.png" mode="widthFix"/>
</view> -->
</view>
</scroll-view>
</view>
</block>
<!-- <view class="category-empty">
<image :src="$util.img('public/uniapp/category/empty.png')" mode="widthFix"></image>
<view class="tips">暂时没有分类哦</view>
</view> -->
</view>
<view class="category-page-wrap category-template-1" style="height: calc(-56px + 100vh);">
<!-- <view class="search-box" @click="$util.redirectTo('/pages_tool/goods/search')">
<view class="search-content">
<input type="text" class="uni-input" maxlength="50" placeholder="商品搜索" confirm-type="search" disabled="true" />
<text class="iconfont icon-sousuo3"></text>
</view>
</view> -->
<view class="content-box" v-if="categoryTree">
<block v-if="categoryTree.length">
<scroll-view scroll-y="true" class="tree-wrap">
<view class="category-item-wrap">
<view class="category-item" v-for="(item, index) in categoryTree" :key="index" :class="[
{ select: select == index },
]" @click="switchOneCategory(index)">
<view class="">{{ item.category_name }}</view>
</view>
</view>
</scroll-view>
<view class="right-flex-wrap">
<scroll-view scroll-y="true" class="content-wrap" ref="contentWrap" :scroll-into-view="categoryId" :scroll-with-animation="true"
@scroll="listenScroll" @touchstart="touchStart" :refresher-enabled="true"
refresher-default-style="none" :refresher-triggered="triggered" @refresherrefresh="onRefresh"
@refresherrestore="onRestore">
<view class="child-category" v-for="(item, index) in categoryTree" :id="'category-' + index" v-if="item.child_list.length > 0" :key="item.category_id || index">
<!---->
<view class="item-wrap category">
<view class="category-title">{{ item.category_name }}</view>
<view class="category-list">
<view class="category-item" v-for="(one, oneIndex) in item.child_list" :key="oneIndex" @click="$util.redirectTo('/pages_promotion/merch/detail', { merch_id: one.merch_id })">
<view class="img-box">
<image :src="$util.img(one.merch_image)" mode="widthFix"/>
</view>
<view class="name">{{ one.merch_name }}</view>
</view>
</view>
</view>
<!-- <view class="category-empty" v-else>
<image src="/static/common-empty.png" mode="widthFix"/>
</view> -->
</view>
</scroll-view>
</view>
</block>
<!-- <view class="category-empty">
<image :src="$util.img('public/uniapp/category/empty.png')" mode="widthFix"></image>
<view class="tips">暂时没有分类哦</view>
</view> -->
</view>
</view>
<ns-login ref="login"></ns-login>
<!-- <loading-cover ref="loadingCover"></loading-cover> -->
@@ -64,34 +64,34 @@
export default {
components: {},
data() {
return {
scrollTop: 0,
select: 0,
categoryId: 'category-0',
scrollLock: false,
triggered: true,
heightArea: [],
loadType: '',
categoryTree:[
/*{
category_id:6277,
category_name:"物业",
child_list:[
{
category_id:6572,
category_name:"鞋里革",
image:"attachment\/images\/979\/2024\/04\/y46Gg41i552o9iq9249295oz991444.jpg",
}
return {
scrollTop: 0,
select: 0,
categoryId: 'category-0',
scrollLock: false,
triggered: true,
heightArea: [],
loadType: '',
categoryTree:[
/*{
category_id:6277,
category_name:"物业",
child_list:[
{
category_id:6572,
category_name:"鞋里革",
image:"attachment\/images\/979\/2024\/04\/y46Gg41i552o9iq9249295oz991444.jpg",
}
]
},*/
],
},*/
],
user_type:uni.getStorageSync('user_type')
};
};
},
onLoad() {
uni.hideTabBar()
uni.hideTabBar()
this.getCategory()
// this.getgoodslist()
},
@@ -101,118 +101,118 @@
onUnload() {
if (!this.storeToken && this.$refs.login) this.$refs.login.cancelCompleteInfo();
},
methods: {
switchOnetype(e){
this.goods_type = e
this.select = -1;
this.categoryId = ''
this.getgoodslist()
methods: {
switchOnetype(e){
this.goods_type = e
this.select = -1;
this.categoryId = ''
this.getgoodslist()
},
/**
* 切换一级分类
* @param {Object} index
*/
switchOneCategory(index) {
if (index >= this.categoryTree.length) return;
this.select = index;
this.categoryId = 'category-' + index;
// 阻止切换分类之后滚动事件也立即执行
this.scrollLock = true;
console.log(index)
// this.goodsList = []
// this.getgoodslist()
},
touchStart() {
this.scrollLock = false;
},
/**
* 监听滚动
* @param {Object} event
*/
listenScroll(event) {
if (this.scrollLock) return;
let scrollTop = event.detail.scrollTop;
if (this.heightArea.length) {
for (let i = 0; i < this.heightArea.length; i++) {
if (scrollTop >= this.heightArea[i][0] && scrollTop <= this.heightArea[i][1]) {
this.select = i;
break;
}
}
if (this.value.template != 1 && this.value.loadType == 'all' && this.heightArea[this.select][1] -
scrollTop - contentWrapHeight < 300) {
this.$refs.categoryItem[this.select].getGoodsList();
}
}
},
sethead(item,type){
var is_select = item.is_select
this.$api.sendRequest({
url: 'app.ajax_batchheads',
data: {
goods_id:item.actId,
is_select:is_select
},
success: res => {
this.$util.showToast({
title: res.result.message
});
this.getgoodslist()
},
fail: () => {
this.$util.showToast({
title: 'request:fail'
});
}
});
},
//获取分类列表
getCategory(){
this.$api.sendRequest({
url: '/merch/api/merch/getcategory',
data: {
is_type_show:1,
},
success: res => {
console.log( res.data)
this.categoryTree = res.data
},
fail: () => {
this.$util.showToast({
title: 'request:fail'
});
}
});
},
onRefresh() {
this.triggered = false;
},
onRestore() {
this.triggered = 'restore'; // 需要重置
},
/**
* 触摸开始
* @param {Object} e
*/
// touchstart(e) {
// this.touchstartPosition = e.changedTouches[0].clientY;
// },
/**
* 触摸结束
* @param {Object} e
*/
touchend(e) {
let end = e.changedTouches[0].clientY;
if ((this.scrollType == 'top' || this.scrollType == 'none') && end - this.touchstartPosition > 100) {
// this.switchCategory('prev');
} else if ((this.scrollType == 'bottom' || this.scrollType == 'none') && this.touchstartPosition - end >
100) {
// this.switchCategory('next');
}
},
/**
* 切换一级分类
* @param {Object} index
*/
switchOneCategory(index) {
if (index >= this.categoryTree.length) return;
this.select = index;
this.categoryId = 'category-' + index;
// 阻止切换分类之后滚动事件也立即执行
this.scrollLock = true;
console.log(index)
// this.goodsList = []
// this.getgoodslist()
},
touchStart() {
this.scrollLock = false;
},
/**
* 监听滚动
* @param {Object} event
*/
listenScroll(event) {
if (this.scrollLock) return;
let scrollTop = event.detail.scrollTop;
if (this.heightArea.length) {
for (let i = 0; i < this.heightArea.length; i++) {
if (scrollTop >= this.heightArea[i][0] && scrollTop <= this.heightArea[i][1]) {
this.select = i;
break;
}
}
if (this.value.template != 1 && this.value.loadType == 'all' && this.heightArea[this.select][1] -
scrollTop - contentWrapHeight < 300) {
this.$refs.categoryItem[this.select].getGoodsList();
}
}
},
sethead(item,type){
var is_select = item.is_select
this.$api.sendRequest({
url: 'app.ajax_batchheads',
data: {
goods_id:item.actId,
is_select:is_select
},
success: res => {
this.$util.showToast({
title: res.result.message
});
this.getgoodslist()
},
fail: () => {
this.$util.showToast({
title: 'request:fail'
});
}
});
},
//获取分类列表
getCategory(){
this.$api.sendRequest({
url: '/merch/api/merch/getcategory',
data: {
is_type_show:1,
},
success: res => {
console.log( res.data)
this.categoryTree = res.data
},
fail: () => {
this.$util.showToast({
title: 'request:fail'
});
}
});
},
onRefresh() {
this.triggered = false;
},
onRestore() {
this.triggered = 'restore'; // 需要重置
},
/**
* 触摸开始
* @param {Object} e
*/
// touchstart(e) {
// this.touchstartPosition = e.changedTouches[0].clientY;
// },
/**
* 触摸结束
* @param {Object} e
*/
touchend(e) {
let end = e.changedTouches[0].clientY;
if ((this.scrollType == 'top' || this.scrollType == 'none') && end - this.touchstartPosition > 100) {
// this.switchCategory('prev');
} else if ((this.scrollType == 'bottom' || this.scrollType == 'none') && this.touchstartPosition - end >
100) {
// this.switchCategory('next');
}
},
getDiyInfo() {
getDiyInfo() {
},
toLogin() {
@@ -226,8 +226,8 @@
};
</script>
<style lang="scss">
@import './public/category.scss';
<style lang="scss">
@import './public/category.scss';
/deep/ .uni-popup__wrapper.uni-center {
background: rgba(0, 0, 0, 0.6);