Init project
This commit is contained in:
@@ -0,0 +1,476 @@
|
||||
<template>
|
||||
<view class="productSort">
|
||||
<view class="header acea-row row-center-wrapper">
|
||||
<view class="search-box flex ai-center">
|
||||
<input type="text" v-model="keyword" placeholder="搜索商品" placeholder-style="color:#949494"
|
||||
@confirm="asideTap(navActive)">
|
||||
<image class="icon" :src="webUrl+'/20220903142935869059.png'" mode="scaleToFill" @click="asideTap(navActive)"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="aside">
|
||||
<view class="item acea-row row-center-wrapper" :class="categoryDivindex === navActive ? 'on' : ''"
|
||||
v-for="(item, categoryDivindex) in category" :key="categoryDivindex" @click="asideTap(categoryDivindex)">
|
||||
<text>{{ item.cateName }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="conter">
|
||||
<mescroll-body ref="mescrollRef" top="16rpx" bottom="0" class='cotent-scroll' :up="upOption" :down="downOption"
|
||||
@up="upCallback" @down="downCallback" @init="mescrollInit" @emptyclick="emptyClick">
|
||||
|
||||
<view class="text acea-row row-center row-middle">
|
||||
<view class="h-line"></view>
|
||||
<view class="cate-name">
|
||||
{{ curCategoryName }}
|
||||
</view>
|
||||
<view class="h-line"></view>
|
||||
</view>
|
||||
|
||||
<view class="acea-row">
|
||||
<view @click="goodsDetail(item)" class="item acea-row cate-goods-item" v-for="(item, index) in goodsList"
|
||||
:key="index" :style="{width:goodsColumnWidth}">
|
||||
|
||||
<view class="img-box">
|
||||
<image :style="{width:goodsColumnWidth,height:goodsColumnWidth}" :src="item.image"/>
|
||||
</view>
|
||||
<view class="pro-info line2">
|
||||
<text>{{ item.storeName }}</text>
|
||||
</view>
|
||||
<view class="info-line flex jc-between ai-center">
|
||||
<text>产地:{{ item.origin || "" }}</text>
|
||||
<!-- <text>单位:{{ item.unitName || "" }}</text>-->
|
||||
</view>
|
||||
<view class="info-line" style="margin-top: 4rpx">规格:{{ item.storeInfo || "" }}</view>
|
||||
<view class="price-line">¥{{ item.price }}</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</mescroll-body>
|
||||
</view>
|
||||
<view style="height:100rpx;"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {fetchWenwan, getCategory} from "@/api/store";
|
||||
import MescrollMixins from "@/mixins/mescroll-mixins.js";
|
||||
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue";
|
||||
import NP from "number-precision";
|
||||
import {mapGetters} from 'vuex';
|
||||
|
||||
var that;
|
||||
export default {
|
||||
name: "WenwanGoodsClass",
|
||||
components: {
|
||||
MescrollBody
|
||||
},
|
||||
props: {},
|
||||
computed: mapGetters(["userInfo"]),
|
||||
mixins: [
|
||||
MescrollMixins({
|
||||
getPageData(mescroll) {
|
||||
// 此时mescroll会携带page的参数:
|
||||
let pageNum = mescroll.num; // 页码, 默认从1开始
|
||||
let pageSize = mescroll.size; // 页长, 默认每页10条
|
||||
|
||||
var params = {
|
||||
page: pageNum,
|
||||
// limit: pageSize,
|
||||
keyword: that.keyword,
|
||||
sid: that.sid,
|
||||
// news: 0,
|
||||
// priceOrder: "",
|
||||
// salesOrder: ""
|
||||
}
|
||||
var _this = this;
|
||||
|
||||
fetchWenwan(params)
|
||||
.then(res => {
|
||||
//mescroll.endByPage(res.data.length, res.data.total_pages);
|
||||
|
||||
if (mescroll.num == 1) {
|
||||
_this.goodsList = []; //如果是第一页需手动制空列表
|
||||
//_this.adjustPage();
|
||||
}
|
||||
|
||||
_this.goodsList = _this.goodsList.concat(res.data.map((goods) => {
|
||||
goods.price = _this.$force2Decimal(goods.price);
|
||||
// goods.vipPrice = _this.$force2Decimal(goods.vipPrice);
|
||||
if (that.$store.getters.token && that.userInfo) {
|
||||
var p = NP.times(goods.price, NP.divide(parseFloat(that.userInfo.discount), 100))
|
||||
goods.vipPrice = that.$force2Decimal(p);
|
||||
}
|
||||
return goods;
|
||||
})); //追加新数据
|
||||
mescroll.endSuccess(res.data.length);
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
mescroll.endErr();
|
||||
//uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: err + '',
|
||||
icon: 'none',
|
||||
mask: false,
|
||||
duration: 1500
|
||||
});
|
||||
})
|
||||
}
|
||||
})
|
||||
],
|
||||
data: function () {
|
||||
return {
|
||||
keyword: '',
|
||||
sid: 35, //二给分类id
|
||||
curCategoryName: '全部商品',
|
||||
category: [],
|
||||
navActive: 0,
|
||||
tabName: "", // 跳转初始分类名
|
||||
lock: false,
|
||||
upOption: {
|
||||
noMoreSize: 10, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
|
||||
auto: false,
|
||||
empty: {
|
||||
tip: '暂无商品' // 提示
|
||||
// btnText:'点击刷新'
|
||||
}
|
||||
},
|
||||
downOption: {
|
||||
auto: true
|
||||
},
|
||||
goodsList: [],
|
||||
goodsColumnWidth: '246rpx',
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
cityId: null
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
"$yroute.query.id": function (n) {
|
||||
if (n) {
|
||||
this.activeCateId(n);
|
||||
}
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
let name = uni.getStorageSync("name");
|
||||
if (name) {
|
||||
this.tabName = name;
|
||||
uni.removeStorageSync("name");
|
||||
}
|
||||
this.loadCategoryData();
|
||||
},
|
||||
onLoad: function (option) {
|
||||
that = this;
|
||||
that.cityId = option.cityId;
|
||||
uni.getSystemInfo({
|
||||
success: (e) => {
|
||||
//两列商品宽度
|
||||
that.goodsColumnWidth = (e.screenWidth - uni.upx2px(180 + 3 * 30)) / 2 + 'px';
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
goodsDetail: function (item) {
|
||||
this.$yrouter.push({
|
||||
path: '/pages/shop/GoodsCon/index',
|
||||
query: {
|
||||
id: item.id
|
||||
}
|
||||
})
|
||||
},
|
||||
emptyClick: function () {
|
||||
//触发加载请求
|
||||
this.mescroll && this.mescroll.triggerDownScroll()
|
||||
},
|
||||
goGoodsList(child) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/GoodsList/index",
|
||||
query: {
|
||||
id: child.id,
|
||||
title: child.cateName
|
||||
}
|
||||
});
|
||||
},
|
||||
activeCateId(n) {
|
||||
let index = 0;
|
||||
n = parseInt(n);
|
||||
if (!n) return;
|
||||
this.category.forEach((cate, i) => {
|
||||
if (cate.id === n) index = i;
|
||||
});
|
||||
|
||||
if (index !== this.navActive) {
|
||||
this.asideTap(index);
|
||||
}
|
||||
},
|
||||
loadCategoryData() {
|
||||
let that = this;
|
||||
// 第三参数, that.cityId
|
||||
getCategory(35, null).then(res => {
|
||||
that.category = [];
|
||||
|
||||
res.data.forEach(function (fcat, idx) {
|
||||
if (fcat.children) {
|
||||
fcat.children.forEach(function (sub, sidex) {
|
||||
that.category.push(sub);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
that.category.unshift({
|
||||
"id": 35,
|
||||
"pid": 0,
|
||||
"cateName": "全部商品"
|
||||
});
|
||||
that.$nextTick(() => {
|
||||
if (that.$yroute.query.id) {
|
||||
that.activeCateId(that.$yroute.query.id);
|
||||
}
|
||||
for (let i = 0; i < that.category.length; i++) {
|
||||
if (that.tabName == that.category[i].cateName) that.asideTap(i);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
asideTap(index) {
|
||||
this.navActive = index;
|
||||
|
||||
this.curCategoryName = this.category[index].cateName;
|
||||
this.sid = this.category[index].id;
|
||||
//触发加载请求
|
||||
this.mescroll.scrollTo(0, 0);
|
||||
this.mescroll && this.mescroll.resetUpScroll(false);
|
||||
}
|
||||
},
|
||||
beforeDestroy: function () {
|
||||
// document.removeEventListener("scroll", this.onScroll, false);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
/*产品分类*/
|
||||
.productSort {
|
||||
height: 100%;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.header {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 0 32rpx;
|
||||
border-bottom: 2rpx solid #DADCE0;
|
||||
background: #F9F9F9;
|
||||
z-index: 9;
|
||||
|
||||
.search-box {
|
||||
width: 686rpx;
|
||||
height: 60rpx;
|
||||
padding: 0 25rpx;
|
||||
border-radius: 50rpx;
|
||||
background: #FFFFFF;
|
||||
|
||||
input {
|
||||
width: 600rpx;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.productSort .aside {
|
||||
position: fixed;
|
||||
width: 176rpx;
|
||||
left: 0;
|
||||
top: 0.96*100rpx;
|
||||
bottom: 0 !important;
|
||||
box-sizing: border-box;
|
||||
border-right: 2rpx solid #DADCE0;
|
||||
background-color: #fff;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.productSort .aside::-webkit-scrollbar {
|
||||
width: 0 !important
|
||||
}
|
||||
|
||||
.productSort .aside .item {
|
||||
width: 100%;
|
||||
height: 104rpx;
|
||||
|
||||
|
||||
text {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
height: 28rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.productSort .aside .item.on {
|
||||
text {
|
||||
border-left: 6rpx solid #FF564A;
|
||||
color: #FF564A;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.productSort .conter {
|
||||
margin-left: 176rpx;
|
||||
// padding: 0 0.14*100rpx;
|
||||
// margin-top: 0.96*100rpx;
|
||||
margin-top: 96rpx;
|
||||
}
|
||||
|
||||
.productSort .conter .listw {
|
||||
padding-top: 0.2*100rpx;
|
||||
}
|
||||
|
||||
.productSort .conter .listw .title {
|
||||
height: 0.9*100rpx;
|
||||
}
|
||||
|
||||
.productSort .conter .listw .title .line {
|
||||
width: 1*100rpx;
|
||||
height: 0.02*100rpx;
|
||||
background-color: #999;
|
||||
}
|
||||
|
||||
.productSort .conter .listw .title .name {
|
||||
font-size: 0.28*100rpx;
|
||||
color: #333;
|
||||
margin: 0 0.3*100rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.productSort .conter .list {
|
||||
flex-wrap: wrap;
|
||||
-ms-flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.productSort .conter .list .item {
|
||||
width: 1.77*100rpx;
|
||||
margin-top: 0.26*100rpx;
|
||||
}
|
||||
|
||||
.productSort .conter .list .item .picture {
|
||||
width: 1.2*100rpx;
|
||||
height: 1.2*100rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.productSort .conter .list .item .picture image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.productSort .conter .list .item .name {
|
||||
font-size: 0.24*100rpx;
|
||||
color: #333;
|
||||
height: 0.56*100rpx;
|
||||
line-height: 0.56*100rpx;
|
||||
width: 1.2*100rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.conter .text {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.pink-dot {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
background: rgba(255, 86, 74, 0.4);
|
||||
border-radius: 50%;
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
bottom: 0;
|
||||
right: -12rpx;
|
||||
}
|
||||
|
||||
.main-title {
|
||||
font-size: 36rpx;
|
||||
line-height: 36rpx;
|
||||
color: #080F1A;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.h-line {
|
||||
width: 56rpx;
|
||||
height: 0px;
|
||||
border: 1px solid #999999;
|
||||
}
|
||||
|
||||
.cate-name {
|
||||
font-size: 30rpx;
|
||||
color: #999999; //rgba(255,45,105,1);
|
||||
margin-left: 5*2rpx;
|
||||
margin-right: 5*2rpx;
|
||||
}
|
||||
|
||||
.shoppingCart {
|
||||
width: 28*2rpx;
|
||||
height: 28*2rpx;
|
||||
background: rgba(255, 45, 105, 1);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.cart-icon {
|
||||
width: 18*2rpx;
|
||||
height: 18*2rpx;
|
||||
}
|
||||
|
||||
.img-box {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pro-info {
|
||||
margin-bottom: 8rpx;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.info-line {
|
||||
width: 100%;
|
||||
font-size: 22rpx;
|
||||
line-height: 36rpx;
|
||||
color: #707070;
|
||||
}
|
||||
|
||||
.price-line {
|
||||
margin-top: 10rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 36rpx;
|
||||
color: #DA0000;
|
||||
}
|
||||
|
||||
.market-price {
|
||||
font-size: 12*2rpx;
|
||||
color: #C2C5CC;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.cate-goods-item {
|
||||
margin-left: 34rpx;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.money {
|
||||
font-size: 24rpx;
|
||||
color: #FF564A;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user