first commit

This commit is contained in:
wangxiaowei
2025-10-22 22:56:36 +08:00
commit 90c54df48b
302 changed files with 54312 additions and 0 deletions

350
pages/product/category.vue Normal file
View File

@ -0,0 +1,350 @@
<template>
<view class="category-wrap" :data-theme='theme()' :class="theme() || ''">
<!-- #ifdef APP-PLUS -->
<header-bar></header-bar>
<!-- #endif -->
<!-- 搜索框 -->
<view class="index-search-box-cate d-b-c" id="searchBox"
:style="topBarHeight() == 0 ? '': 'height:'+topBarHeight()+'px;padding-top:'+topBarTop()+'px'">
<view class="index-search-cate flex-1 t-c" @click="gotoSearch">
<span class="icon iconfont icon-sousuo"></span>
<text class="ml10">{{ searchName }}</text>
</view>
<!-- #ifdef MP-WEIXIN -->
<view class="wx-top-right"></view>
<!-- #endif -->
</view>
<!--类别列表-->
<view class="category-content">
<!--一级分类 大图-->
<view class="cotegory-type cotegory-type-1" v-if="show_type==10">
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:'+scrollviewHigh+'px;'">
<view class="list">
<view class="item" v-for="(item,index) in listData" :key="index"
@click="gotoList(item.category_id)">
<view class="pic">
<image :src="hasImages(item)" mode="widthFix"></image>
</view>
<view class="p-20-0 fb tc f34">
{{item.name}}
</view>
</view>
</view>
</scroll-view>
</view>
<!--一级分类 小图-->
<view class="cotegory-type cotegory-type-2" v-if="show_type==20">
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:'+scrollviewHigh+'px;'">
<view class="list">
<view class="item" v-for="(item,index) in listData" :key="index"
@click="gotoList(item.category_id)">
<image :src="hasImages(item)" mode="aspectFit"></image>
<text>{{item.name}}</text>
</view>
</view>
</scroll-view>
</view>
<!--二级分类-->
<view class="cotegory-type cotegory-type-3" v-if="show_type==30">
<view class="category-tab">
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:'+scrollviewHigh+'px;'">
<view :class="index==select_index?'item active':'item'" v-for="(item,index) in listData"
:key="index" @click="selectCategory(index)">
<text>{{item.name}}</text>
</view>
</scroll-view>
</view>
<view class="category-content pr">
<scroll-view scroll-y="true" class="scroll-Y scroll-3" :style="'height:'+scrollviewHigh+'px;'">
<view class="f26 catename">{{catename}}</view>
<view class="list">
<view class="item" v-for="(item,index) in childlist" :key="index"
@click="gotoList(item.category_id)">
<image :src="hasImages(item)" mode="aspectFit"></image>
<text class="type-name">{{item.name}}</text>
</view>
</view>
</scroll-view>
</view>
</view>
</view>
<tabBar></tabBar>
</view>
</template>
<script>
import utils from '@/common/utils.js';
export default {
components: {},
data() {
return {
isloadding: true,
searchName: '搜索商品',
/*展示方式*/
show_type: 3,
/*手机高度*/
phoneHeight: 0,
/*可滚动视图区域高度*/
scrollviewHigh: 0,
/*数据*/
listData: [],
/*子类数据*/
childlist: [],
/*当前选中的分类*/
select_index: 0,
catename:''
};
},
onLoad() {
},
onShow() {
this.getTabBarLinks();
},
mounted() {
this.init();
this.getData();
},
methods: {
/*初始化*/
init() {
let _this = this;
uni.getSystemInfo({
success(res) {
_this.phoneHeight = res.windowHeight;
// 计算组件的高度
let view = uni.createSelectorQuery().select('#searchBox');
view.boundingClientRect(data => {
let h = _this.phoneHeight - data.height;
_this.scrollviewHigh = h;
}).exec();
}
});
},
/*判断是否有图片*/
hasImages(e) {
if (e.images != null && e.images.file_path != null) {
return e.images.file_path;
} else {
return '';
}
},
/*获取数据*/
getData() {
let _this = this;
_this.isloadding = true;
_this._get('product.category/index', {}, function(res) {
_this.listData = res.data.list;
_this.catename = _this.listData[0].name;
_this.show_type = res.data.template.category_style;
console.log(_this.show_type);
if (_this.listData[0].child) {
_this.childlist = _this.listData[0].child;
}
_this.background = res.data.background;
_this.isloadding = false;
});
},
/*选择分类*/
selectCategory(e) {
if (this.listData[e].child) {
this.childlist = this.listData[e].child;
this.select_index = e;
this.catename = this.listData[this.select_index].name;
}
},
/*跳转产品列表*/
gotoList(e) {
let category_id = e;
let sortType = 'all';
let search = '';
let sortPrice = 0;
this.gotoPage('/pages/product/list/list?category_id=' + category_id + '&sortType=' + sortType +
'&search=' + search +
'&sortPrice=' + sortPrice);
},
wxGetUserInfo: function(res) {
if (!res.detail.iv) {
uni.showToast({
title: "您取消了授权,登录失败",
icon: "none"
});
return false;
}
},
/*跳转搜索页面*/
gotoSearch() {
this.gotoPage('/pages/product/search/search');
},
/**
* 设置分享内容
*/
onShareAppMessage() {
let self = this;
return {
title: self.templet.share_title,
path: '/pages/product/category?' + self.getShareUrlParams()
};
},
}
};
</script>
<style lang="scss">
@import '@/common/mixin.scss';
.foot_ {
height: 98rpx;
width: 100%;
}
.cotegory-type {
line-height: 40rpx;
background: #ffffff;
}
.cotegory-type image {
width: 100%;
}
.cotegory-type-1 .list {
padding: 20rpx;
}
.cotegory-type-1 .list .item {
margin-top: 30rpx;
}
.cotegory-type-1 .list .item .pic {
border: 1px solid #e3e3e3;
width: 710rpx;
height: auto;
overflow: hidden;
border-radius: 8px;
}
.cotegory-type-1 .list .item image {
width: 100%;
height: 100%;
}
.cotegory-type-2 .list,
.cotegory-type-3 .list {
padding: 0 20rpx;
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
}
.cotegory-type-2 .list .item,
.cotegory-type-3 .list .item {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.cotegory-type-2 .list .item {
padding: 0 16rpx;
width: 200rpx;
height: 300rpx;
font-size: 28rpx;
}
.cotegory-type-2 .list .item image {
width: 180rpx;
height: 180rpx;
margin-bottom: 20rpx;
}
.cotegory-type-3 {
display: flex;
}
.cotegory-type-3 .category-tab {
width: 200rpx;
background: #FFFFFF;
@include background_color('opacify_background_0');
// border-right: 1px solid #e3e3e3;
}
.cotegory-type-3 .category-tab .item {
padding: 40rpx 0;
font-size: 26rpx;
text-align: center;
color: #666666;
font-weight: bold;
}
.cotegory-type-3 .category-tab .item.active {
position: relative;
background: #ffffff;
color: #333333;
}
.cotegory-type-3 .category-tab .item.active::after {
position: absolute;
content: '';
top: 40rpx;
bottom: 40rpx;
left: 0;
width: 6rpx;
height: 22rpx;
margin: auto;
@include background_linear('titleft1', 'titleft2', 180deg, 0%, 100%);
}
.cotegory-type-3 .category-content {
flex: 1;
margin: 0 20rpx;
}
.cotegory-type-3 .list .item {
width: 140rpx;
height: 200rpx;
margin-top: 40rpx;
margin-right: 20rpx;
font-size: 24rpx;
}
.cotegory-type-3 .list .item:nth-child(3n) {
margin-right: 0;
}
.cotegory-type-3 .list .item image {
width: 140rpx;
height: 140rpx;
}
.cotegory-type-3 .list .item .type-name {
display: block;
margin-top: 20rpx;
height: 80rpx;
line-height: 60rpx;
text-overflow: ellipsis;
width: 100%;
color: #818181;
font-size: 26rpx;
white-space: nowrap;
overflow: hidden;
text-align: center;
}
.scroll-3 {
position: absolute;
background: #ffffff;
border-radius: 12px;
}
.catename{
padding-top: 10rpx;
line-height: 60rpx;
border-bottom: 1rpx solid #D9D9D9;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,270 @@
<template>
<view class="look-evaluate">
<view class="top-tabbar">
<view :class="state_active == -1 ? 'tab-item active' : 'tab-item'" @click="stateFunc(-1)">
全部({{ Total.all }})</view>
<view :class="state_active == 10 ? 'tab-item active' : 'tab-item'" @click="stateFunc(10)">
<view class="d-c-c mr20">
<text class="icon iconfont icon-pingjiahaoping"></text>
<text class="ml10 gray9">好评({{ Total.praise }})</text>
</view>
</view>
<view :class="state_active == 20 ? 'tab-item active' : 'tab-item'" @click="stateFunc(20)">
<view class="d-c-c mr20">
<text class="icon iconfont icon-pingjiazhongping"></text>
<text class="ml10 gray9">中评({{ Total.review }})</text>
</view>
</view>
<view :class="state_active == 30 ? 'tab-item active' : 'tab-item'" @click="stateFunc(30)">
<view class="d-c-c mr20">
<text class="icon iconfont icon-pingjiachaping"></text>
<text class="ml10 gray9">差评({{ Total.negative }})</text>
</view>
</view>
</view>
<!--评论列表-->
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50"
@scrolltolower="scrolltolowerFunc">
<view class="comment-list">
<view class="item" v-for="(item, index) in tableData" :key="index">
<view class="cmt-user">
<view class="left">
<image class="photo" :src="item.users.avatarUrl" mode="aspectFill"></image>
<text class="name">{{ item.users.nickName }}</text>
</view>
</view>
<view class="d-b-c p20">
<view class="d-s-c">
<view v-if="item.score == 10" class="d-c-c mr20">
<text class="icon iconfont icon-pingjiahaoping"></text>
<text class="ml10 gray9">好评</text>
</view>
<view v-if="item.score == 20" class="d-c-c mr20">
<text class="icon iconfont icon-pingjiazhongping"></text>
<text class="ml10 gray9">中评</text>
</view>
<view v-if="item.score == 30" class="d-c-c mr20">
<text class="icon iconfont icon-pingjiachaping"></text>
<text class="ml10 gray9">差评</text>
</view>
</view>
<text class="datetime gray9">{{ item.create_time }}</text>
</view>
<view class="p-0-20 f24 gray3">{{ item.content }}</view>
<view class="imgs d-s-c p-0-20">
<view class="box" v-for="(imgs, img_num) in item.image" :key="img_num">
<image @click="previewImage(imgs.file_path)" :src="imgs.file_path" mode="aspectFill"
width="">
</image>
</view>
</view>
</view>
<!-- 没有记录 -->
<view class="d-c-c p30" v-if="tableData.length==0 && !loading">
<view class="none-data-box">
<image src="/static/none.png" mode="widthFix"></image>
<text>亲,暂无相关记录哦</text>
</view>
</view>
<uni-load-more v-else :loadingType="loadingType"></uni-load-more>
</view>
</scroll-view>
</view>
</template>
<script>
import uniLoadMore from "@/components/uni-load-more.vue";
export default {
components: {
uniLoadMore
},
data() {
return {
/*手机高度*/
phoneHeight: 0,
/*可滚动视图区域高度*/
scrollviewHigh: 0,
/*选中状态*/
state_active: -1,
/*商品id*/
product_id: 0,
/*评论列表*/
tableData: [],
/*统计*/
Total: {
/*总数*/
all: 0,
/*score = 30*/
negative: 0,
/*score = 10*/
praise: 0,
/*score = 20*/
negative: 0,
review: 0
},
/*页码*/
page: 1,
list_rows: 15,
no_more: false,
loading: true,
/*最后一页码数*/
last_page: 0
};
},
computed: {
/*加载中状态*/
loadingType() {
if (this.loading) {
return 1;
} else {
if (this.tableData.length != 0 && this.no_more) {
return 2;
} else {
return 0;
}
}
}
},
onLoad(e) {
this.product_id = e.product_id;
},
mounted() {
this.init();
/*获取数据*/
this.getData();
},
methods: {
previewImage(img) {
console.log(img)
uni.previewImage({
urls: [img],
current:img,
fail(err) {
console.log(err)
this.showError(err)
}
});
},
/*初始化*/
init() {
let self = this;
uni.getSystemInfo({
success(res) {
self.phoneHeight = res.windowHeight;
// 计算组件的高度
let view = uni.createSelectorQuery().select('.top-tabbar');
view.boundingClientRect(data => {
let h = self.phoneHeight - data.height;
self.scrollviewHigh = h;
}).exec();
}
});
},
/*获取数据*/
getData() {
let _this = this;
let product_id = _this.product_id;
_this._get(
'product.comment/lists', {
product_id: product_id,
scoreType: _this.state_active,
page: _this.page,
list_rows: _this.list_rows
},
function(res) {
_this.loading = false;
_this.Total = res.data.total;
_this.tableData = _this.tableData.concat(res.data.list.data);
_this.last_page = res.data.list.last_page;
if (res.data.list.last_page <= 1) {
_this.no_more = true;
}
}
);
},
/*可滚动视图区域到底触发*/
scrolltolowerFunc() {
let self = this;
self.bottomRefresh = true;
self.page++;
self.loading = true;
if (self.page > self.last_page) {
self.loading = false;
self.no_more = true;
return;
}
self.getData();
},
/*类别切换*/
stateFunc(e) {
let self = this;
if (self.state_active != e) {
self.tableData = [];
self.no_more = false;
self.loading = true;
self.state_active = e;
self.page = 1;
self.getData();
}
}
}
};
</script>
<style scoped lang="scss">
.look-evaluate .comment-list {
background: #ffffff;
}
.look-evaluate .comment-list .item {
padding-top: 30rpx;
padding-bottom: 30rpx;
border-top: none;
border-bottom: 1px solid #dddddd;
}
.tab-item.active {
font-size: 30rpx;
}
.look-evaluate .iconfont {
border-radius: 50%;
font-size: 40rpx;
text-align: center;
}
.look-evaluate .icon-pingjiahaoping {
color: #f42222;
}
.look-evaluate .icon-pingjiazhongping {
color: #f2b509;
}
.look-evaluate .icon-pingjiachaping {
color: #999999;
}
.look-evaluate .imgs {
flex-wrap: wrap;
}
.look-evaluate .imgs .box {
margin-top: 10rpx;
margin-right: 10rpx;
}
.look-evaluate .imgs .box:nth-child(3n) {
margin-right: 0;
}
.look-evaluate .imgs .box,
.look-evaluate .imgs .box image {
width: 210rpx;
height: 210rpx;
}
</style>

View File

@ -0,0 +1,310 @@
<template>
<view :class="Visible ? 'usable-coupon open' : 'usable-coupon close'">
<view class="popup-bg" @click="closePopup"></view>
<view class="main" v-on:click.stop>
<view class="pop-title">
<view>优惠</view>
<view class="pop-close" @click.stop="closePopup"><text class=" icon iconfont icon-guanbi"></text></view>
</view>
<view class="p-0-20">
<view class="" v-if="discount.product_reduce.length > 0">
<view class="f22 gray3 line-h-50 p-20-0">
<text class="text-box ">满减</text>
<text v-for="(item,index) in discount.product_reduce" :key="index" :label="item" :value="index">
<text class="ml20" v-if="item.full_type == 1">满{{item.full_value}}元</text>
<text class="ml20" v-if="item.full_type == 2">满{{item.full_value}}件</text>
<text v-if="item.reduce_type == 1">减{{item.reduce_value}}元</text>
<text v-if="item.reduce_type == 2">{{(100 - item.reduce_value)/10}}折</text>
</text>
</view>
</view>
<view class="p-20-0 line-h-50 f22 gray3 " v-if="discount.give_points>0">
<text class="text-box">返{{points_name()}}</text>商城购物返{{points_name()}},订单完成后最高返{{discount.give_points}}{{points_name()}}
</view>
</view>
<scroll-view scroll-y="true" class="scroll-Y scroll-coupon" :style="'height:' + scrollviewHigh + 'px;'">
<view>
<view class=" scroll-coupon-tit">可领取优惠券</view>
<view v-for="(item, index) in datalist" :key="index" class="mb20">
<view
:class="item.is_get?'coupon-item coupon-item-gray':'coupon-item coupon-item-'+item.color.text">
<!--装饰用的小圆-->
<view class="circles"><text v-for="(circle, num) in 6" :key="num"></text></view>
<view class="info w100">
<view class="d-c-c d-c">
<text class="f40 fb w-s-n">{{ item.coupon_type.text }}</text>
</view>
</view>
<view class="operation d-b-c w-b">
<view class="flex-1 o-h">
<template v-if=" item.coupon_type.value == 10 ">
<view class="f34">
<text class="f34 fb">{{ item.reduce_price*1 }}</text>
</view>
</template>
<template v-if="item.coupon_type.value == 20 ">
<text class="f34 fb">{{ item.discount }}</text><text>折券</text>
</template>
<view class="f24">{{item.min_price>0?'满'+item.min_price*1+'元可用':'无门槛'}}</view>
<block v-if="item.expire_type == 10">
<view class="mt30 f24">领取{{ item.expire_day }}天内有效</view>
</block>
<block v-if="item.expire_type == 20">
<view class="mt30 f24 white">{{ item.start_time.text }}~{{ item.end_time.text }}
</view>
</block>
</view>
<view class="f30 mr20 b-radio" v-if="!item.is_receive"
@click="selectCoupon(item,index)">
立即领取
</view>
<view v-else class="f30 mr20 b-radio">
<text>已领取</text>
</view>
</view>
</view>
<view class="range_item d-b-c" v-if="item.apply_range == 20"
@click.stop="gotoPage('/pages/coupon/detail?coupon_id='+ item.coupon_id)">
<view>限购店铺部分商品</view>
<view><text class="icon iconfont icon-jiantou"
style="color: #999999; font-size: 24rpx;"></text></view>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
/*手机高度*/
phoneHeight: 0,
/*可滚动视图区域高度*/
scrollviewHigh: 0,
/*是否可见*/
Visible: false,
/*优惠券列表*/
datalist: {},
/*尺寸比例*/
ratio: 1
};
},
props: ['isCoupon', 'couponList', 'discount'],
onLoad() {},
mounted() {
this.init();
},
watch: {
isCoupon: function(n, o) {
if (n != o) {
this.Visible = n;
this.datalist = this.couponList;
this.getHeight();
}
}
},
methods: {
/*初始化*/
init() {
let self = this;
uni.getSystemInfo({
success(res) {
self.phoneHeight = res.windowHeight;
self.ratio = res.windowWidth / 750;
self.getHeight();
}
});
},
/*获取高度*/
getHeight() {
let count = Object.keys(this.couponList).length;
if (count > 2) {
this.scrollviewHigh = this.phoneHeight * 0.5;
} else {
if (count == 1) {
this.scrollviewHigh = 250 * this.ratio + 60;
} else if (count == 2) {
this.scrollviewHigh = 460 * this.ratio + 60;
}
}
},
/*选择优惠券*/
selectCoupon(e, i) {
let self = this;
uni.showLoading({
title: '领取中'
});
self._post('user.coupon/receive', {
coupon_id: e.coupon_id,
}, function(res) {
uni.hideLoading();
uni.showToast({
title: '领取成功',
duration: 2000,
icon: 'success'
});
self.datalist[i].is_receive = true;
});
// self.getData();
},
/*关闭弹窗*/
closePopup() {
this.$emit('close');
}
}
};
</script>
<style lang="scss" scoped>
.usable-coupon .popup-bg {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 99;
}
.usable-coupon .main {
position: fixed;
width: 100%;
bottom: 0;
min-height: 200rpx;
background-color: #fff;
transform: translate3d(0, 1980rpx, 0);
transition: transform 0.2s cubic-bezier(0, 0, 0.25, 1);
padding-bottom: env(safe-area-inset-bottom);
border-radius: 15rpx 15rpx 0 0;
z-index: 99;
}
.usable-coupon .main {
position: fixed;
width: 100%;
bottom: 0;
min-height: 200rpx;
background-color: #fff;
transform: translate3d(0, 1980rpx, 0);
transition: transform 0.2s cubic-bezier(0, 0, 0.25, 1);
bottom: env(safe-area-inset-bottom);
z-index: 99;
}
.usable-coupon.open .main {
transform: translate3d(0, 0, 0);
}
.usable-coupon.close .popup-bg {
display: none;
}
.coupon-item-red .operation {
/* background: #fdf1df; */
}
.coupon-btns .btn-cancel {
height: 88rpx;
line-height: 88rpx;
font-size: 30rpx;
background: #999999;
color: #ffffff;
border-radius: 0;
}
.coupon-item .w100 {
padding: 0 75rpx;
}
.b-radio {
border: 1rpx solid #FFFFFF;
border-radius: 30rpx;
padding: 10rpx 30rpx;
}
.range_item {
border: 1rpx solid #D9D9D9;
border-top: none;
padding: 8rpx;
border-bottom-left-radius: 10rpx;
border-bottom-right-radius: 10rpx;
color: #666666;
box-shadow: 0 0 8rpx rgba(0, 0, 0, 0.1);
}
.text-sheng {
display: inline-block;
width: 26rpx;
height: 28rpx;
background: linear-gradient(180deg, #FF5649 0%, #FF5649 100%);
border-radius: 3rpx;
font-size: 18rpx;
font-family: PingFangSC;
font-weight: 500;
color: #FFFFFF;
text-align: center;
line-height: 28rpx;
}
.text-box {
padding: 2rpx 6rpx;
background-color: #fbe9e7;
color: #fd5342;
margin-right: 10rpx;
border-radius: 4rpx;
font-size: 20rpx;
}
.line-h-50 {
line-height: 50rpx;
}
.pop-title {
padding-top: 53rpx;
font-size: 28rpx;
font-family: PingFangSC;
font-weight: 500;
color: #333333;
position: relative;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 50rpx;
}
.pop-close {
position: absolute;
right: 20rpx;
top: 20rpx;
width: 60rpx;
height: 60rpx;
color: #999999;
display: flex;
justify-content: center;
align-items: center;
.icon-guanbi{
font-size: 26rpx;
}
}
.scroll-coupon {
margin: 0 20rpx;
border-top: 1rpx solid #EEEEEE;
width: 710rpx;
box-sizing: border-box;
}
.scroll-coupon-tit {
height: 74rpx;
display: flex;
justify-content: flex-start;
align-items: center;
font-size: 24rpx;
color: #999999;
}
</style>

View File

@ -0,0 +1,177 @@
<template>
<view class="bottom-panel" :class="Visible?'bottom-panel open':'bottom-panel close'" @click="closePopup">
<view class="popup-bg">
<view class="wechat-box" v-if="wechat_share">
<image src="/static/share.png" mode="widthFix"></image>
</view>
</view>
<view class="content" v-on:click.stop>
<view class="module-box module-share">
<view class="hd d-c-c">
分享
</view>
<view class="p30 box-s-b">
<view class="d-c-c">
<view class="item flex-1 d-c-c d-c">
<button open-type="share" @click="share">
<view class="icon-box d-c-c share-friend">
<text class="iconfont icon-fenxiang"></text>
</view>
<text class="pt20">分享好友</text>
</button>
</view>
<view class="item flex-1 d-c-c d-c">
<button @click="genePoster">
<view class="icon-box d-c-c">
<text class="iconfont icon-edit"></text>
</view>
<text class="pt20">生成海报</text>
</button>
</view>
</view>
</view>
<view class="btns">
<button type="default" @click="closePopup(1)">取消</button>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
/*是否可见*/
Visible: false,
poster_img: '',
/*公众号分享是否显示*/
wechat_share:false
}
},
props: ['isbottmpanel', 'product_id'],
watch: {
'isbottmpanel': function(n, o) {
if (n != o) {
this.wechat_share=false;
this.Visible = n;
}
}
},
methods: {
/*关闭弹窗*/
closePopup(type) {
this.$emit('close', {
type: type,
poster_img:this.poster_img
})
},
//发送给朋友
share: function() {
//#ifdef H5
this.wechat_share=true;
//#endif
},
//生成海报
genePoster: function() {
let self = this;
uni.showLoading({
title: '加载中',
});
let source = 'wx';
//#ifdef H5
source = 'mp';
//#endif
self._get('product.product/poster', {
product_id: self.product_id,
source: source
}, (result) => {
self.poster_img = result.data.qrcode;
self.closePopup(2);
}, null, () => {
uni.hideLoading();
});
},
}
}
</script>
<style>
.bottom-panel .popup-bg {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, .6);
z-index: 98;
}
.bottom-panel .popup-bg .wechat-box{ padding-top: var(--window-top);}
.bottom-panel .popup-bg .wechat-box image{ width: 100%;}
.bottom-panel .content {
position: fixed;
width: 100%;
bottom: 0;
min-height: 200rpx;
max-height: 900rpx;
background-color: #fff;
transform: translate3d(0, 980rpx, 0);
transition: transform .2s cubic-bezier(0, 0, .25, 1);
bottom: env(safe-area-inset-bottom);
z-index: 99;
}
.bottom-panel.open .content {
transform: translate3d(0, 0, 0);
}
.bottom-panel.close .popup-bg {
display: none;
}
.module-share .hd {
height: 90rpx;
line-height: 90rpx;
font-size: 36rpx;
}
.module-share .item button,.module-share .item button::after{ background: none; border: none;}
.module-share .icon-box {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
background: #f6bd1d;
}
.module-share .icon-box .iconfont {
font-size: 60rpx;
color: #FFFFFF;
}
.module-share .btns {
margin-top: 30rpx;
}
.module-share .btns button {
height: 90rpx;
line-height: 90rpx;
border-radius: 0;
border-top: 1px solid #EEEEEE;
}
.module-share .btns button::after {
border-radius: 0;
}
.module-share .share-friend {
background: #04BE01;
}
</style>

View File

@ -0,0 +1,602 @@
<template>
<view :class="Visible ? 'product-popup open' : 'product-popup close'" @touchmove.stop.prevent="" @click="closePopup">
<view class="popup-bg"></view>
<view class="main" v-on:click.stop>
<view class="header">
<image :src="form.show_sku.sku_image" mode="aspectFit" class="avt"></image>
<view class="price">
¥
<text class="num">{{ form.show_sku.product_price }}</text>
<text class="old-price" v-if="form.show_sku.line_price">¥{{ form.show_sku.line_price }}</text>
</view>
<view class="stock">库存:{{ form.show_sku.stock_num }}</view>
<view class="select_spec">{{ selectSpec }}</view>
<view class="close-btn" @click="closePopup"><text class="icon iconfont icon-guanbi"></text></view>
</view>
<view class="body">
<!--规格-->
<view>
<scroll-view scroll-y="true" class="specs mt20" style="max-height: 600rpx;" v-if="form.specData != null">
<view class="specs mt20" v-for="(item_attr, attr_index) in form.specData.spec_attr" :key="attr_index">
<view class="specs-hd p-20-0">
<text class="f26 gray3">{{ item_attr.group_name }}</text>
<!-- <text class="ml10 red" v-if="form.productSpecArr[attr_index]==null">
请选择{{item_attr.group_name}}
</text> -->
</view>
<view class="specs-list">
<button
:class="item.checked ? 'btn-checked' : 'btn-checke'"
v-for="(item, item_index) in item_attr.spec_items"
:key="item_index"
@click="selectAttr(attr_index, item_index)"
>
{{ item.spec_value }}
</button>
</view>
</view>
</scroll-view>
</view>
<!--选择数量-->
<view class="level-box count_choose">
<text class="key">数量</text>
<view class="d-s-c">
<view class="icon-box minus d-c-c" @click="sub()" :class="{ 'num-wrap': !issub }">
<text class="icon iconfont icon-jian" style="font-size: 20rpx;color: #333333;"></text>
</view>
<view class="text-wrap"><input type="text" v-model="form.show_sku.sum" value="" /></view>
<view class="icon-box plus d-c-c" :class="{ 'num-wrap': !isadd }" @click="add()">
<text class="icon iconfont icon-jia" style="font-size: 20rpx;color: #333333;"></text>
</view>
</view>
</view>
</view>
<view class="btns">
<button class="confirm-btn" v-if="!clock" @click="confirmFunc(form)">确认</button>
<button class="confirm-btn" v-else>暂无库存</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
/*是否可见*/
Visible: false,
/*表单对象*/
form: {
detail: {},
show_sku: {
sku_image: ''
}
},
/*当前商品总库存*/
stock: 0,
/*选择提示*/
selectSpec: '',
/*是否打开过多规格选择框*/
isOpenSpec: false,
type: '',
clock: false
};
},
props: ['isPopup', 'productModel'],
onLoad() {},
mounted() {},
computed: {
/*判断增加数量*/
isadd: function() {
return this.form.show_sku.sum >= this.stock || this.form.show_sku.sum >= this.form.detail.limit_num;
},
/*判断减少数量*/
issub: function() {
return this.form.show_sku.sum <= 1;
}
},
watch: {
isPopup: function(n, o) {
if (n != o) {
this.Visible = n;
if (!this.isOpenSpec) {
this.form = this.productModel;
this.isOpenSpec = true;
this.initShowSku();
}
this.form.type = this.productModel.type;
}
},
'form.specData': {
handler(n, o) {
let str = '',
select = '';
this.isAll = true;
if (n) {
for (let i = 0; i < n.spec_attr.length; i++) {
if (this.form.productSpecArr[i] == null) {
this.isAll = false;
str += n.spec_attr[i].group_name + ' ';
} else {
n.spec_attr[i].spec_items.forEach(item => {
if (this.form.productSpecArr[i] == item.item_id) {
select += '"' + item.spec_value + '" ';
}
});
}
}
if (!this.isAll) {
str = '请选择: ' + str;
} else {
select = '已选: ' + select;
}
}
this.selectSpec = this.isAll ? select : str;
},
deep: true,
immediate: true
}
},
methods: {
/*初始化*/
initShowSku() {
this.form.show_sku.sku_image = this.form.detail.image[0].file_path;
this.form.show_sku.product_price = this.form.detail.product_price;
if (this.form.detail.spec_type == 20) {
if (this.form.detail.product_price != this.form.detail.product_max_price) {
this.form.show_sku.product_price = this.form.detail.product_price + '-' + this.form.detail.product_max_price;
}
}
this.form.show_sku.spec_sku_id = 0;
this.form.show_sku.line_price = this.form.detail.line_price;
this.form.show_sku.stock_num = this.form.detail.product_stock;
this.form.show_sku.sum = 1;
this.stock = this.form.detail.product_stock;
if (this.form.plus_name == 'advance') {
this.form.show_sku.product_price = this.form.plus_sku[0].product_price;
this.form.show_sku.line_price = '';
this.form.show_sku.sku_image = this.form.plus_sku[0].productSku.image ? this.form.plus_sku[0].productSku.image.file_path : this.form.detail.image[0].file_path;
this.form.show_sku.stock_num = this.form.plus_sku[0].advance_stock;
this.stock = this.form.plus_sku[0].advance_stock;
}
if (this.form.plus_name == 'seckill') {
this.form.show_sku.product_price = this.form.plus_sku[0].seckill_price;
this.form.show_sku.line_price = this.form.plus_sku[0].product_price;
this.form.show_sku.sku_image = this.form.plus_sku[0].productSku.image ? this.form.plus_sku[0].productSku.image.file_path : this.form.detail.image[0].file_path;
this.form.show_sku.stock_num = this.form.plus_sku[0].seckill_stock;
this.stock = this.form.plus_sku[0].seckill_stock;
}
},
/*选择属性*/
selectAttr(attr_index, item_index) {
let self = this;
let items = self.form.specData.spec_attr[attr_index].spec_items;
let curItem = items[item_index];
if (curItem.checked) {
curItem.checked = false;
self.form.productSpecArr[attr_index] = null;
} else {
for (let i = 0; i < items.length; i++) {
items[i].checked = false;
}
curItem.checked = true;
self.form.productSpecArr[attr_index] = curItem.item_id;
}
for (let i = 0; i < self.form.productSpecArr.length; i++) {
if (self.form.productSpecArr[i] == null) {
self.initShowSku();
return;
}
}
// 更新商品规格信息
self.updateSpecProduct();
},
/*更新商品规格信息*/
updateSpecProduct() {
let self = this;
let specSkuId = self.form.productSpecArr.join('_');
// 查找skuItem
let spec_list = self.form.specData.spec_list;
if (self.form.plus_sku != null) {
spec_list = self.form.plus_sku;
}
let skuItem = spec_list.find(val => {
if (self.form.plus_name) {
return val.productSku.spec_sku_id == specSkuId;
} else {
return val.spec_sku_id == specSkuId;
}
});
if (!skuItem) {
self.clock = true;
self.initShowSku();
return;
} else {
self.clock = false;
}
if (self.form.plus_name && !skuItem.spec_form) {
skuItem.spec_form = skuItem.productSku;
}
// 记录spec_sku_id
// 更新商品价格、划线价、库存
if (typeof skuItem === 'object') {
/*保存当前规格*/
if (self.form.plus_name) {
self.stock = skuItem[self.form.plus_name + '_stock'];
if (self.form.show_sku.sum > self.stock) {
self.form.show_sku.sum = self.stock > 0 ? self.stock : 1;
}
} else {
self.stock = skuItem.spec_form.stock_num;
if (self.form.show_sku.sum > self.stock) {
self.form.show_sku.sum = self.stock > 0 ? self.stock : 1;
}
}
self.form.show_sku.spec_sku_id = specSkuId;
self.form.show_sku.product_price = skuItem.spec_form.product_price;
self.form.show_sku.line_price = skuItem.spec_form.line_price;
if (skuItem.spec_form.image_id > 0) {
self.form.show_sku.sku_image = skuItem.spec_form.image_path;
} else {
self.form.show_sku.sku_image = self.form.detail.image[0].file_path;
}
self.form.show_sku.stock_num = skuItem.spec_form.stock_num;
if (self.form.plus_name) {
self.form.show_sku.product_price = skuItem.product_price;
if (self.form.plus_name == 'seckill') {
self.form.show_sku.product_price = skuItem.seckill_price;
}
self.form.show_sku.stock_num = skuItem[self.form.plus_name + '_stock'];
self.form.show_sku.line_price = '';
self.form.show_sku.sku_image = skuItem.spec_form.image?skuItem.spec_form.image.file_path : self.form.detail.image[0].file_path;
self.form.show_sku.advance_product_id = skuItem.spec_form.image?skuItem.spec_form.image.file_path : self.form.detail.image[0].file_path
}
}
},
/*关闭弹窗*/
closePopup() {
this.$emit('close', this.form.specData, null);
},
/*确认提交*/
confirmFunc() {
if (this.form.specData != null) {
for (let i = 0; i < this.form.productSpecArr.length; i++) {
if (this.form.productSpecArr[i] == null) {
uni.showToast({
title: '请选择规格',
icon: 'none',
duration: 2000
});
return;
}
}
}
if (this.form.type == 'card') {
this.addCart();
} else if (this.form.type == 'order') {
this.createdOrder();
} else if (this.form.type == 'deposit') {
this.createdOrder();
}
},
/*加入购物车*/
addCart() {
let self = this;
let product_id = self.form.detail.product_id;
let total_num = self.form.show_sku.sum;
let spec_sku_id = self.form.show_sku.spec_sku_id;
if (self.form.detail.spec_type == 20 && spec_sku_id == 0) {
uni.showToast({
title: '请选择属性',
icon: 'none',
duration: 2000
});
return false;
}
self._post(
'order.cart/add',
{
product_id: product_id,
total_num: total_num,
spec_sku_id: spec_sku_id
},
function(res) {
uni.showToast({
title: res.msg,
duration: 2000
});
self.$emit('close', null, res.data.cart_total_num);
}
);
},
/*创建订单*/
createdOrder() {
let product_id = this.form.detail.product_id;
let product_num = this.form.show_sku.sum;
let spec_sku_id = this.form.show_sku.spec_sku_id;
let room_id = '';
if ((this.room_id != 0) & (this.room_id != '')) {
room_id = '&room_id=' + this.form.room_id;
}
let url = '/pages/order/confirm-order?product_id=' + product_id + '&product_num=' + product_num + '&product_sku_id=' + spec_sku_id + '&order_type=buy' + room_id;
if (this.form.type == 'deposit') {
if (this.form.plus_name == 'advance') {
let skuItem = this.form.detail.advance.sku.find(val => {
return val.productSku.spec_sku_id == spec_sku_id;
});
url =
'/pages/order/confirm-order?product_id=' +
product_id +
'&product_num=' +
product_num +
'&product_sku_id=' +
spec_sku_id +
'&advance_product_sku_id=' +
skuItem.advance_product_sku_id +
'&advance_product_id=' +
skuItem.advance_product_id +
'&order_type=deposit';
}
if (this.form.plus_name == 'seckill') {
let skuItem = this.form.detail.secKill.seckillSku.find(val => {
return val.productSku.spec_sku_id == spec_sku_id;
});
url =
'/pages/order/confirm-order?seckill_product_id=' +
skuItem.seckill_product_id +
'&product_num=' +
product_num +
'&product_sku_id=' +
skuItem.productSku.spec_sku_id +
'&seckill_product_sku_id=' +
skuItem.seckill_product_sku_id +
'&order_type=seckill';
}
}
this.gotoPage(url);
},
/*商品增加*/
add() {
if (this.stock <= 0) {
return;
}
if (this.form.show_sku.sum >= this.stock) {
uni.showToast({
title: '数量超过了库存',
icon: 'none',
duration: 2000
});
return false;
}
if (this.form.detail.limit_num > 0 && this.form.show_sku.sum >= this.form.detail.limit_num) {
uni.showToast({
title: '数量超过了限购数量',
icon: 'none',
duration: 2000
});
return false;
}
this.form.show_sku.sum++;
},
/*商品减少*/
sub() {
if (this.stock <= 0) {
return;
}
if (this.form.show_sku.sum < 2) {
uni.showToast({
title: '商品数量至少为1',
icon: 'none',
duration: 2000
});
return false;
}
this.form.show_sku.sum--;
}
}
};
</script>
<style lang="scss">
.product-popup {
}
.product-popup .popup-bg {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 99;
}
.product-popup .main {
position: fixed;
width: 100%;
bottom: 0;
min-height: 200rpx;
// max-height: 1050rpx;
background-color: #fff;
transform: translate3d(0, 980rpx, 0);
transition: transform 0.2s cubic-bezier(0, 0, 0.25, 1);
// bottom: env(safe-area-inset-bottom);
z-index: 99;
border-radius: 12rpx;
}
.product-popup.open .main {
transform: translate3d(0, 0, 0);
z-index: 99;
}
.product-popup.close .popup-bg {
display: none;
}
.product-popup.close .main {
display: none;
z-index: -1;
}
.product-popup .header {
height: 200rpx;
padding: 40rpx 0 10rpx 250rpx;
position: relative;
border-bottom: 1px solid #eeeeee;
}
.product-popup .header .avt {
position: absolute;
top: 40rpx;
left: 30rpx;
width: 180rpx;
height: 180rpx;
border: 2px solid #ffffff;
background: #ffffff;
border-radius: 12rpx;
}
.product-popup .header .stock {
font-size: 26rpx;
color: #999999;
}
.product-popup .close-btn {
position: absolute;
width: 40rpx;
height: 40rpx;
top: 40rpx;
right: 30rpx;
}
.product-popup .price {
@include font_color('price_color');
font-size: 24rpx;
}
.product-popup .price .num {
padding: 0 4rpx;
font-size: 40rpx;
}
.product-popup .old-price {
margin-left: 10rpx;
font-size: 26rpx;
color: #999999;
text-decoration: line-through;
}
.product-popup .body {
padding: 20rpx 30rpx 39rpx 30rpx;
// max-height: 600rpx;
overflow-y: auto;
}
.product-popup .level-box {
display: flex;
justify-content: space-between;
align-items: center;
}
.product-popup .level-box .key {
font-size: 24rpx;
color: #999999;
}
.product-popup .level-box .icon-box {
width: 48rpx;
height: 40rpx;
background: #e0e0e0;
}
.product-popup .num-wrap .iconfont {
color: #666;
}
.product-popup .num-wrap.no-stock .iconfont {
color: #cccccc;
}
.product-popup .level-box .text-wrap {
margin: 0 4rpx;
height: 60rpx;
border: none;
background: #ffffff;
}
.product-popup .level-box .text-wrap input {
padding: 0 10rpx;
height: 60rpx;
line-height: 60rpx;
width: 80rpx;
font-size: 32rpx;
text-align: center;
}
.specs .specs-list {
display: flex;
justify-content: flex-start;
align-items: center;
flex-wrap: wrap;
}
.specs .specs-list button {
margin-right: 10rpx;
margin-bottom: 10rpx;
font-size: 24rpx;
}
.specs .specs-list button:after,
.product-popup .btns button,
.product-popup .btns button:after {
height: 88rpx;
line-height: 88rpx;
border: 0;
border-radius: 0;
margin-bottom: 55rpx;
}
.product-popup .btns .confirm-btn {
width: 710rpx;
height: 80rpx;
@include background_linearmore('cart_right1', 'cart_right2', 'right_deg', 0%, 100%);
border-radius: 40rpx;
margin: 0 auto;
margin-bottom: 55rpx;
color: #ffffff;
line-height: 80rpx;
font-size: 32rpx;
}
.btn-checked {
border: 1rpx solid #f6220c;
@include border_color('background_color');
border-radius: 6px;
@include font_color('font_color');
font-size: 26rpx;
background-color: #ffffff;
}
.btn-checke {
border: 1rpx solid #d9d9d9;
border-radius: 6rpx;
font-size: 26rpx;
color: #333333;
background-color: #ffffff;
}
</style>

View File

@ -0,0 +1,137 @@
<template>
<view >
<!--限时秒杀-->
<view class="limited-spike m-0-20 d-b-s">
<view class="active-name mr20">
<view></view>
<view></view>
</view>
<view class="flex-1 pt16">
<view class="white">
<text class="f28 fb"></text>
<text class="f42 fb">{{ subPrice(detail.product_price, '1') }}.</text>
<text class="f24 fb">{{ subPrice(detail.product_price, '2') }}</text>
</view>
<view class="old-price">{{ detail.product_sku.line_price }}</view>
</view>
<view class="right-time">
<Countdown
activeName="previewProduct"
ref="countdown"
:config="{ startstamp: detail.preview.start_time, endstamp: detail.preview.end_time, type: 'preview' }"
:start_name="'距开始仅剩'"
:end_name="'距开始仅剩'"
@returnVal="returnValFunc"
></Countdown>
</view>
</view>
<!--基本信息-->
<view class="bg-white m-0-20 mb20 p20 mt-down-box">
<view class="f30 gray3">{{ detail.product_name }}</view>
<view class="product-describe" v-if="detail.selling_point">{{ detail.selling_point }}</view>
<view class="border-t d-b-c mt20">
<button class="flex-1 active-btn d-c-c" @click="sendFunc('showShare')">
<text class="icon iconfont icon-fenxiang3 shoucang-icon"></text>
<text class="f28 gray9">分享</text>
</button>
<button class="flex-1 active-btn d-c-c" @click="sendFunc('favorite')">
<text :class="is_fav ? 'icon-shoucang2 dominant' : 'icon-shoucang1'" class="icon iconfont shoucang-icon" src="/static/icon/sc.png" mode=""></text>
<text class="f28" :class="is_fav ? 'dominant' : 'gray9'">收藏</text>
</button>
</view>
</view>
</view>
</template>
<script>
import Countdown from '@/components/countdown/countdown-act.vue';
export default {
components: {
Countdown
},
data() {
return {};
},
props: ['detail',"is_fav"],
methods: {
sendFunc(e){
this.$emit('send',e)
},
returnValFunc(e) {}
}
};
</script>
<style lang="scss">
/* 预售 */
.limited-spike {
position: relative;
z-index: 2;
margin-top: -112rpx;
color: #ffffff;
background: linear-gradient(140deg, #f11e0b 0%, #f77737 100%);
border-radius: 15rpx;
height: 246rpx;
padding: 14rpx 18rpx 14rpx 20rpx;
box-sizing: border-box;
}
.mt-down-box {
margin-top: -102rpx;
z-index: 3;
position: relative;
border-radius: 15rpx;
padding-bottom: 0;
}
.limited-spike .right-time {
padding-top: 45rpx;
}
.limited-spike .right-time::v-deep text {
font-size: 22rpx;
}
.limited-spike .right-time::v-deep .box {
padding: 0;
font-size: 22rpx;
background: #ffffff;
color: #ff4c01;
width: 36rpx;
height: 36rpx;
display: inline-block;
line-height: 36rpx;
text-align: center;
border-radius: 8rpx;
}
.limited-spike .right-time::v-deep .daybox {
padding: 0;
font-size: 22rpx;
background: none;
}
.limited-spike .right-time::v-deep .countdown {
border: none;
padding: 0;
font-size: 22rpx;
white-space: nowrap;
}
.limited-spike .old-price {
font-size: 24rpx;
color: #ffffff;
text-decoration: line-through;
}
.active-name {
background-color: rgba(#000000, 0.2);
font-size: 28rpx;
padding: 20rpx 22rpx;
box-sizing: border-box;
color: #ffffff;
border-radius: 8rpx;
}
.active-btn{
height: 100rpx;
background:none;
}
.shoucang-icon{
font-size: 28rpx;
color: #999999;
margin-right: 10rpx;
}
</style>

588
pages/product/list/list.vue Normal file
View File

@ -0,0 +1,588 @@
<template>
<view :data-theme='theme()' :class="theme() || ''">
<view class="top-box">
<view class="index-search-box index-search-box_re d-b-c" id="searchBox">
<view class="index-search index-search_re t-c flex-1">
<span class="icon iconfont icon-sousuo"></span>
<input type="text" v-model="search" class="flex-1 ml10 f26 gray3" value=""
placeholder-class="f26 gray9" placeholder="搜索商品" confirm-type="search"
@confirm="searchFunc()" />
</view>
</view>
<view class="inner-tab">
<view :class="type_active==0?'item active':'item'" @click="tabTypeFunc(0)">
<view class="box">综合</view>
</view>
<view :class="type_active==1?'item active':'item'" @click="tabTypeFunc(1)">
<view class="box">销量</view>
</view>
<view :class="type_active==2?'item active':'item'" @click="tabTypeFunc(2)">
<view class="box">
<text>价格</text>
<view class="arrows">
<view :class="price_top&&type_active==2?'arrow active':'arrow'">
<span class="icon iconfont icon-sanjiao2"></span>
</view>
<view :class="!price_top&&type_active==2?'arrow active':'arrow'">
<span class="icon iconfont icon-sanjiao1"></span>
</view>
</view>
</view>
</view>
<view class="item">
<view class="box" style="height: 100%;">
<image style="width: 36rpx;height: 36rpx;" @click="select_type()"
:src="isLieBiao == true?'/static/liebiao.png':'/static/tubiao.png'"></image>
</view>
</view>
</view>
</view>
<view class="prodcut-list-wrap">
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'"
lower-threshold="50" @scrolltolower="scrolltolowerFunc">
<view :class="topRefresh?'top-refresh open':'top-refresh'">
<view class="circle" v-for="(circle,n) in 3" :key="n"></view>
</view>
<view class="shop_body" v-if="isLieBiao ==true">
<view class="shop_body_l_item" :class="index==listData.length-1?'noborder':''"
v-for="(item,index) in listData" :key="index" @click="gotoList(item.product_id)">
<view>
<image :src="item.product_image" mode=""></image>
</view>
<view class="shop_body_l_item_info">
<view class="shop_body_l_item_info_title gray3 f32">{{item.product_name}}</view>
<view class="d-b-c pb10">
<view class="shop_body_l_item_info_price">
<view class="f24 shop_red">¥<text class="f32 fb">{{item.product_price}}</text>
</view>
</view>
<view class="shop_body_l_item_info_others f22">
<view class="shop_body_l_item_info_others_sales">累计成交:{{item.product_sales}}笔</view>
</view>
</view>
</view>
</view>
</view>
<view class="shop_body2" v-if="isLieBiao ==false">
<view class="shop_body_t_item" :class="index % 2 == 0?'ml20 mr20':' mr20'"
v-for="(item,index) in listData" :key="index" @click="gotoList(item.product_id)">
<image :src="item.product_image" mode=""></image>
<view class="shop_body_t_item_info">
<view class="shop_body_t_item_info_title f26">{{item.product_name}}</view>
<view class="shop_body_t_item_info_others f24 gray9 mt">
<view class="shop_body_t_item_info_others_sales">累计成交:{{item.product_sales}}笔</view>
</view>
<view class="shop_body_t_item_info_price">
<view class="f20 redF6">¥<text class="f32">{{item.product_price}}</text></view>
</view>
</view>
</view>
</view>
<!-- 没有记录 -->
<view class="d-c-c p30" v-if="listData.length==0 && !loading">
<text class="iconfont icon-wushuju"></text>
<text class="cont">亲,暂无相关记录哦</text>
</view>
<uni-load-more v-else :loadingType="loadingType"></uni-load-more>
</scroll-view>
</view>
</view>
</template>
<script>
import uniLoadMore from "@/components/uni-load-more.vue";
export default {
components: {
uniLoadMore
},
data() {
return {
isLieBiao: true,
/*手机高度*/
phoneHeight: 0,
/*可滚动视图区域高度*/
scrollviewHigh: 0,
/*顶部刷新*/
topRefresh: false,
/*底部加载*/
loading: true,
/*没有更多*/
no_more: false,
/*类别选中*/
type_active: 0,
/*价格选中*/
price_top: false,
/*商品列表*/
listData: [],
/*当前页面*/
page: 1,
category_id: 0,
search: '',
sortType: '',
sortPrice: 0,
list_rows: 10,
last_page: 0,
};
},
computed: {
/*加载中状态*/
loadingType() {
if (this.loading) {
return 1;
} else {
if (this.listData.length != 0 && this.no_more) {
return 2;
} else {
return 0;
}
}
}
},
onLoad(e) {
/*分类id*/
this.category_id = e.category_id;
if (e.search) {
this.search = e.search;
}
if (e.sortType) {
this.sortType = e.sortType;
}
if (e.sortPrice) {
this.sortPrice = e.sortPrice;
}
},
mounted() {
this.init();
/*获取产品列表*/
this.getData();
},
onPullDownRefresh() {
/*下拉到顶,页面值还原初始化*/
this.restoreData();
this.getData();
},
methods: {
searchFunc() {
this.listData = [];
this.page = 1;
/*获取产品列表*/
this.getData();
},
/*初始化*/
init() {
let _this = this;
uni.getSystemInfo({
success(res) {
_this.phoneHeight = res.windowHeight;
// 计算组件的高度
let view = uni.createSelectorQuery().select('.top-box');
view.boundingClientRect(data => {
let h = _this.phoneHeight - data.height;
_this.scrollviewHigh = h;
}).exec();
}
});
},
/*还原初始化*/
restoreData() {
this.listData = [];
this.category_id = 0;
this.search = '';
this.sortType = '';
this.sortPrice = 0;
},
/*类别切换*/
tabTypeFunc(e) {
let self = this;
self.listData = [];
self.page = 1;
self.no_more = false;
self.loading = true;
if (e == 2) {
self.price_top = !this.price_top;
if (self.price_top == true) {
self.sortPrice = 0;
} else {
self.sortPrice = 1;
}
self.sortType = 'price';
} else if (e == 1) {
self.price_top = !this.price_top;
self.sortType = 'sales';
}
self.type_active = e;
console.log(self.type_active)
self.getData();
},
/*获取数据*/
getData() {
let self = this;
let page = self.page;
let list_rows = self.list_rows;
let category_id = self.category_id;
let search = self.search;
let sortType = self.sortType;
let sortPrice = self.sortPrice;
self.loading = true;
self._get('product.product/lists', {
page: page || 1,
category_id: category_id,
search: search,
sortType: sortType,
sortPrice: sortPrice,
list_rows: list_rows,
}, function(res) {
self.loading = false;
self.listData = self.listData.concat(res.data.list.data);
self.last_page = res.data.list.last_page;
if (res.data.list.last_page <= 1) {
self.no_more = true;
}
});
},
/*跳转产品列表*/
gotoList(e) {
let url = 'pages/product/detail/detail?product_id=' + e
this.gotoPage(url);
},
/*跳转搜索页面*/
gotoSearch() {
this.gotoPage('/pages/product/search/search');
},
/*可滚动视图区域到底触发*/
scrolltolowerFunc() {
let self = this;
self.bottomRefresh = true;
self.page++;
self.loading = true;
if (self.page > self.last_page) {
self.loading = false;
self.no_more = true;
return;
}
self.getData();
},
//选择图标模式或者列表模式 true 为列表模式 false 为图表模式
select_type() {
let self = this;
self.isLieBiao = !self.isLieBiao
},
/** 设置分享内容*/
onShareAppMessage() {
// 构建分享参数
return {
title: "全部分类",
path: "/pages/product/category?" + this.getShareUrlParams()
};
},
}
};
</script>
<style lang="scss">
.inner-tab {
position: relative;
height: 100rpx;
display: flex;
justify-content: space-around;
align-items: center;
// border-bottom: 16rpx solid #F2F2F2;
background: #ffffff;
z-index: 9;
}
.inner-tab .item {
flex: 1;
height: 100%;
line-height: 90rpx;
position: relative;
color: #999;
font-size: 32rpx;
}
.inner-tab .item.active,
.inner-tab .item .arrow.active .iconfont {
color: #333333;
font-weight: bold;
}
.item.active::after {
content: '';
width: 72rpx;
height: 4rpx;
@include background_color('background_color');
border-radius: 2rpx;
position: absolute;
bottom: 14rpx;
left: 0;
right: 0;
margin: auto;
}
.inner-tab .item .box {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
}
.inner-tab .item .arrows {
margin-left: 10rpx;
line-height: 0;
}
.inner-tab .item .iconfont {
line-height: 24rpx;
font-size: 24rpx;
}
.inner-tab .item .arrow,
.inner-tab .item .svg-icon {
width: 20rpx;
height: 20rpx;
}
.prodcut-list-wrap {
padding-top: 20rpx;
}
.prodcut-list-wrap .list {
background: #FFFFFF;
}
.prodcut-list-wrap .list .item {
padding: 20rpx;
display: flex;
border-bottom: 1rpx solid #f6f6f6;
}
.prodcut-list-wrap .product-cover,
.prodcut-list-wrap .product-cover image {
width: 150rpx;
height: 150rpx;
}
.prodcut-list-wrap .product-info {
flex: 1;
margin-left: 30rpx;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.prodcut-list-wrap .product-title {
display: -webkit-box;
line-height: 36rpx;
overflow: hidden;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 26rpx;
}
.prodcut-list-wrap .already-sale {
// margin-top: 20rpx;
color: #999;
font-size: 22rpx;
}
.prodcut-list-wrap .already-sale>text {
padding: 6rpx 10rpx;
// background-color: #f2f2f7;
}
.prodcut-list-wrap .price {
@include font_color('price_color');
font-size: 24rpx;
}
.prodcut-list-wrap .price .num {
margin-left: 6rpx;
padding: 0 4rpx;
font-size: 32rpx;
font-weight: bold;
}
.inner-tab .item .box {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
}
.shop_body {
width: 100%;
background-color: #ffffff;
padding: 0rpx 20rpx;
box-sizing: border-box;
}
.shop_body_l_item {
// width: 90%;
// height: 250rpx;
margin: 0 auto;
background-color: white;
// border-radius: 15rpx;
// margin-top: 20rpx;
display: flex;
padding: 40rpx 0;
box-sizing: border-box;
border-bottom: 1rpx solid #D9D9D9;
}
.shop_body_l_item image {
width: 150rpx;
height: 150rpx;
border-radius: 12rpx;
background-color: rgba(0, 0, 0, 0.1);
}
.shop_body_l_item_info {
// width: 70%;
// height: 100%;
flex: 1;
display: flex;
justify-content: space-between;
flex-direction: column;
padding-left: 20rpx;
box-sizing: border-box;
}
.shop_body_l_item_info_title {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
word-wrap: break-word;
word-break: break-all;
overflow: hidden;
}
.shop_body_l_item_info_price {
display: flex;
align-items: flex-end;
}
.shop_body_l_item_info_price view {
margin-right: 15rpx;
}
.shop_body_l_item_info_others {
// width: 100%;
height: 30rpx;
display: flex;
justify-content: space-between;
}
.shop_body_l_item_info_others_activity {
width: 150rpx;
height: 30rpx;
line-height: 30rpx;
border: 1rpx #E22319 solid;
border-radius: 30rpx;
/* font-size: 16rpx; */
color: #E22319;
text-align: center;
box-sizing: border-box;
}
.shop_body_l_item_info_others_sales {
color: #333333;
}
.shop_body2 {
width: 100%;
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
background-color: #f2f2f2;
}
.shop_body_t_item {
width: 345rpx;
// margin: 0 2.5%;
margin-bottom: 20rpx;
height: 520rpx;
overflow: hidden;
background-color: white;
border-radius: 12rpx;
}
.collect text {
color: #FFFFFF;
}
.shop_body_t_item image {
width: 100%;
height: 337.5rpx;
background-color: rgba(0, 0, 0, 0.1);
}
.shop_body_t_item_info {
// height: 182.5rpx;
display: flex;
flex-direction: column;
justify-content: flex-start;
padding: 20rpx;
box-sizing: border-box;
}
.shop_body_t_item_info_title {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
word-wrap: break-word;
word-break: break-all;
overflow: hidden;
margin-bottom: 30rpx;
}
.shop_body_t_item_info_price {
display: flex;
align-items: flex-end;
}
.shop_body_t_item_info_others {
display: flex;
justify-content: space-between;
margin-bottom: 8rpx;
}
.shop_body_t_item_info_others_activity {}
.shop_body_t_item_info_others_sales {
color: #999999;
}
.huaxianjia {
text-decoration: line-through;
color: #999;
margin-left: 5rpx;
}
.shop_red {
color: #F6220C;
}
.inner-tab .item .icon-sanjiao2 {
font-size: 13rpx;
}
.inner-tab .item .icon-sanjiao1 {
font-size: 13rpx;
}
.noborder {
border: none;
}
</style>

View File

@ -0,0 +1,135 @@
<template>
<view class="search-wrap">
<!-- 搜索框 -->
<view class="index-search-box d-b-c" id="searchBox">
<view class="index-search t-c flex-1">
<span class="icon iconfont icon-sousuo"></span>
<input type="text" v-model="form.keyWord" class="flex-1 ml10 f30 gray3" value="" placeholder-class="f24 gray6"
placeholder="输入你要的商品" confirm-type="search" @confirm="search()"/>
</view>
<!--<button class="btn ml10" @click="search()" type="default">搜索</button>-->
</view>
<view class="p-0-20 bg-white">
<view class="group-hd">
<view class="left"><text class="min-name">最近搜索</text></view>
<view class="right">
<span class="icon iconfont icon-lajitong" @click='clearStorage'></span>
</view>
</view>
<view class="before-search">
<text class="item" v-for="(item,index) in arr" :key="index" @click="search(arr[index])">{{arr[index]}}</text>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
form: {
},
arr:[],
}
},
mounted() {
/*获取缓存数据*/
this.getData();
},
methods: {
/*获取缓存里的搜索历史*/
getData(){
let self=this;
/*获取搜索记录*/
uni.getStorage({
key: 'search_list',
success: function (res) {
if(res!=null&&res.data!=null){
self.arr = res.data;
}
}
});
},
/*搜索*/
search(str) {
let self = this;
let search=null;
if(str!=null){
search=str;
}else{
search= this.form.keyWord;
let arrs=this.arr;
if(typeof search != "undefined" && search!=null && search!=''){
arrs.push(search);
}else{
uni.showToast({
title: '请输入搜索的关键字',
icon: 'none',
duration: 2000
});
return false;
}
/*设置搜索记录*/
uni.setStorage({
key: 'search_list',
data: arrs,
success: function () {
console.log('success');
}
});
}
let category_id = 0;
let sortType = 'all';
self.gotoPage('/pages/product/list/list?search=' + search + '&category_id=' + category_id + '&sortType=' + sortType);
},
/*清楚缓存*/
clearStorage(){
let self=this;
uni.removeStorage({
key: 'search_list',
success: function (res) {
self.arr=[];
}
});
}
}
}
</script>
<style>
.search-wrap .index-search-box .search-box {
padding: 0 20rpx;
height: 64rpx;
line-height: 64rpx;
background: #f7f7f7;
border-radius: 50rpx;
overflow: hidden;
font-size: 28rpx;
color: #999;
box-sizing: border-box;
}
.search-wrap .index-search-box button{ height: 78rpx; line-height: 78rpx; border:solid 1rpx #CCCCCC; color:#333333; background: #FFFFFF;}
.before-search {
display: flex;
justify-content: flex-start;
align-items: center;
flex-flow: wrap;
}
.before-search .item {
padding: 16rpx;
margin-right: 16rpx;
margin-bottom: 16rpx;
border-radius: 8rpx;
color: #686868;
background: #f0f2f5;
font-size: 24rpx;
}
</style>