<template>
|
<view class="bargain-container" :data-theme='theme()' :class="theme() || ''">
|
<!--内容-->
|
<view class="bargain-list" v-if="!loading">
|
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50">
|
<view class="goods-list">
|
<view class="goods-item" v-for="(item, index) in listData" :key="index">
|
<view class="goods-content">
|
<!-- 商品图片 -->
|
<view class="goods-image-wrapper">
|
<image class="goods-image" :src="item.product_image" mode="aspectFill"></image>
|
</view>
|
|
<!-- 右侧内容 -->
|
<view class="goods-info">
|
<!-- 商品标题 -->
|
<view class="goods-title">{{ item.product_name }}</view>
|
|
<!-- 价格行 -->
|
<view class="price-row">
|
<text class="theme-price f28 fb mr10">¥{{ item.product_sku.product_price }}</text>
|
<text class="original-price">¥{{ item.product_sku.line_price }}</text>
|
</view>
|
|
<!-- 购物车操作 -->
|
<view class="action-row">
|
<view class="cart-btn" @click="openPopup(item,'cart')">加购物车</view>
|
<view class="buy-btn" @click="openPopup(item,'buy')">立即购买</view>
|
</view>
|
</view>
|
</view>
|
|
|
</view>
|
</view>
|
|
<!-- 没有记录 -->
|
<view class="none-data-box" v-if="listData.length == 0 && !loading">
|
<image src="/static/none.png" mode="widthFix"></image>
|
<text>暂无数据</text>
|
</view>
|
</scroll-view>
|
</view>
|
<!--购物确定-->
|
|
<spec :isPopup="isPopup" :activity_id="activity_id" :longitude="longitude" :latitude="latitude" :productModel="productModel" @handelPreviewing="handelPreviewing" @close="closePopup"></spec>
|
|
<view class="float-button" @click="handleFloatButtonClick">
|
<image class="button-icon" src="/static/cart_active.png" mode="aspectFit"></image>
|
<view class="cart-badge" v-if="cart_total_num > 0">{{cart_total_num}}</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import utils from '@/common/utils.js';
|
import spec from './popup/spec.vue';
|
export default {
|
components: {
|
spec
|
},
|
data() {
|
return {
|
/*手机高度*/
|
phoneHeight: 0,
|
/*可滚动视图区域高度*/
|
scrollviewHigh: 0,
|
/*商品列表*/
|
listData: [],
|
/*是否正在加载*/
|
loading: true,
|
activity_id: '',
|
//多规格弹窗
|
detail: null,
|
/*商品属性*/
|
specData: null,
|
/*子级页面传参*/
|
productModel: {},
|
isPopup: false,
|
cart_total_num:0,
|
longitude:'',
|
latitude:'',
|
is_previewing:false,
|
activityDetail: [],
|
};
|
},
|
computed: {},
|
onLoad(e) {
|
let scene = utils.getSceneData(e);
|
if (typeof e.activity_id != 'undefined') {
|
this.activity_id = e.activity_id;
|
} else {
|
this.activity_id = scene.activity_id;
|
}
|
},
|
onShow() {
|
if(!this.is_previewing){
|
/*获取列表*/
|
this.getlist();
|
}
|
},
|
mounted() {
|
this.init();
|
},
|
onReachBottom() {},
|
methods: {
|
handleFloatButtonClick(){
|
this.gotoPage('/pages/branch/activity/product/cart?activity_id=' + this.activity_id);
|
},
|
/*初始化*/
|
init() {
|
let _this = this;
|
uni.getSystemInfo({
|
success(res) {
|
_this.scrollviewHigh = res.windowHeight;
|
}
|
});
|
},
|
|
/*获取活动列表*/
|
getlist() {
|
let self = this;
|
uni.showLoading({
|
title: '加载中'
|
});
|
self.loading = true;
|
self._get(
|
'branch.activityProduct/lists',
|
{
|
activity_id: self.activity_id,
|
},
|
function (res) {
|
self.listData = res.data.list;
|
self.cart_total_num = res.data.cart_total_num;
|
self.activityDetail = res.data.activityDetail;
|
uni.hideLoading();
|
self.loading = false;
|
}
|
);
|
},
|
|
/*选规格*/
|
openPopup(e,type) {
|
const self = this;
|
const detail = e;
|
let specData = e.specData;
|
if (e.spec_type == 20) {
|
for (let i in specData.spec_attr) {
|
for (let j in specData.spec_attr[i].spec_items) {
|
specData.spec_attr[i].spec_items[j].checked = false;
|
}
|
}
|
}
|
let obj = {
|
specData: specData,
|
detail: detail,
|
productSpecArr: specData != null ? new Array(specData.spec_attr.length) : [],
|
show_sku: {
|
sku_image: '',
|
price: 0,
|
product_sku_id: 0,
|
line_price: 0,
|
stock: 0,
|
product_sku_id: 0,
|
sum: 1,
|
},
|
plus_sku: null,
|
type: type,
|
plus_name: ''
|
};
|
self.productModel = obj;
|
self.isPopup = true;
|
|
},
|
|
/*关闭弹窗*/
|
closePopup(e, cart_total_num) {
|
const self = this;
|
self.isPopup = false;
|
if(cart_total_num!=null){
|
self.cart_total_num = cart_total_num;
|
}
|
|
console.log('触发返回',self.cart_total_num);
|
},
|
/*处理关闭预览*/
|
handelPreviewing(option){
|
this.is_previewing = option;
|
},
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
page {
|
background: #f2f2f2;
|
}
|
.bargain-list{
|
padding-bottom: 100rpx;
|
}
|
|
/* 商品列表 */
|
.goods-list {
|
display: flex;
|
flex-direction: column;
|
}
|
|
/* 商品项 */
|
.goods-item {
|
margin: 20rpx 20rpx 0rpx 20rpx;
|
background-color: #fff;
|
border-radius: 24rpx;
|
overflow: hidden;
|
}
|
|
/* 商品内容 */
|
.goods-content {
|
display: flex;
|
padding: 20rpx;
|
}
|
|
/* 商品图片 */
|
.goods-image-wrapper {
|
width: 180rpx;
|
height: 180rpx;
|
flex-shrink: 0;
|
border-radius: 16rpx;
|
overflow: hidden;
|
}
|
|
.goods-image {
|
width: 100%;
|
height: 100%;
|
}
|
|
/* 商品信息 */
|
.goods-info {
|
flex: 1;
|
margin-left: 20rpx;
|
display: flex;
|
flex-direction: column;
|
justify-content: space-between;
|
}
|
|
/* 商品标题 */
|
.goods-title {
|
font-size: 28rpx;
|
color: #333;
|
line-height: 1.4;
|
display: -webkit-box;
|
-webkit-box-orient: vertical;
|
-webkit-line-clamp: 2;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
}
|
|
/* 价格行 */
|
.price-row {
|
display: flex;
|
align-items: center;
|
margin-top: 10rpx;
|
}
|
|
.current-price {
|
font-size: 32rpx;
|
color: #f44;
|
font-weight: bold;
|
margin-right: 10rpx;
|
}
|
|
.original-price {
|
font-size: 24rpx;
|
color: #999;
|
text-decoration: line-through;
|
}
|
|
/* 操作行 */
|
.action-row {
|
display: flex;
|
align-items: center;
|
margin-top: 15rpx;
|
}
|
|
.cart-btn {
|
padding: 8rpx 20rpx;
|
border-radius: 30rpx;
|
font-size: 24rpx;
|
margin-right: 30rpx;
|
@include font_color('text_color2');
|
@include background_linearmore('cart_left1', 'cart_left2', 'left_deg', 0%, 100%);
|
}
|
.buy-btn{
|
padding: 8rpx 20rpx;
|
border-radius: 30rpx;
|
font-size: 24rpx;
|
@include font_color('text_color1');
|
@include background_linearmore('cart_right1', 'cart_right2', 'right_deg', 0%, 100%);
|
}
|
|
.selected-count {
|
font-size: 24rpx;
|
color: #666;
|
margin-left: 15rpx;
|
}
|
|
.float-button {
|
position: fixed;
|
right: 30rpx;
|
bottom: 140rpx;
|
width: 100rpx;
|
height: 100rpx;
|
border-radius: 50%;
|
background-color: #ffffff;
|
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
z-index: 10;
|
transition: transform 0.1s ease;
|
}
|
|
.float-button:active {
|
transform: scale(0.95);
|
}
|
|
.button-icon {
|
width: 60rpx;
|
height: 60rpx;
|
}
|
|
/* 购物车数量徽标 */
|
.cart-badge {
|
position: absolute;
|
top: -20rpx;
|
right: 10rpx;
|
min-width: 36rpx;
|
height: 36rpx;
|
line-height: 36rpx;
|
text-align: center;
|
border-radius: 18rpx;
|
background-color: #ffffff;
|
color: #ff5a5f;
|
font-size: 36rpx;
|
font-weight: bold;
|
padding: 0 6rpx;
|
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
|
}
|
|
|
|
/* 适配iPhone X系列 */
|
@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3),
|
only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3),
|
only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) {
|
.container {
|
padding-bottom: 68rpx; /* 增加底部安全区域 */
|
}
|
}
|
</style>
|