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>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,216 @@
|
||||
<template>
|
||||
<view class="wenwan-store-list">
|
||||
<view class="search-box flex jc-between ai-center">
|
||||
<input type="text" v-model="name" placeholder="搜索店铺" placeholder-style="color:#999" @confirm="search">
|
||||
<image class="icon" :src="webUrl+'/20220903142935869059.png'" mode="scaleToFill" @click="search"></image>
|
||||
</view>
|
||||
|
||||
<view class="nav-box flex jc-between ai-center">
|
||||
<view class="location-box flex ai-center">
|
||||
<image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill" @click="goCity"></image>
|
||||
<text class="city-name" @click="goCity">{{ cityName }}</text>
|
||||
<text>当前定位</text>
|
||||
</view>
|
||||
<view class="more-box flex ai-center">
|
||||
<text @click="goClass">全部商品列表</text>
|
||||
<image :src="webUrl+'/20220903145836941399.png'" mode="scaleToFill"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list flex flex-wrap" v-if="list.length">
|
||||
<view class="item" v-for="item in list" :key="item.id" @click="goStore(item)">
|
||||
<image class="image" :src="item.cover" mode="scaleToFill"></image>
|
||||
|
||||
<view class="title more-t">{{ item.content }}</view>
|
||||
|
||||
<view class="footer flex ai-center">
|
||||
<image class="icon" :src="item.logo" mode="scaleToFill" v-if="item.logo"></image>
|
||||
<image class="icon" :src="webUrl+'/20230609145651814148.png'" v-else/>
|
||||
<view class="name one-t">{{ item.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="v4-nodata" v-else>
|
||||
<image src="@/static/images/img_nodata.png" mode="scaleToFill"/>
|
||||
<view class="text">暂无数据</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {fetchStore} from "@/api/wenwan";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
page: 1,
|
||||
cityId: null,
|
||||
cityName: "丽江市",
|
||||
list: [],
|
||||
name: ""
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.cityId = option.cityId;
|
||||
},
|
||||
onShow() {
|
||||
let memCityName = uni.getStorageSync("cityName")
|
||||
if (memCityName.length) {
|
||||
this.cityName = memCityName;
|
||||
this.page = 1;
|
||||
this.list = [];
|
||||
this.fetchList(this.cityName);
|
||||
uni.removeStorageSync("cityName")
|
||||
}
|
||||
},
|
||||
onReachBottom() {
|
||||
this.page++;
|
||||
this.fetchList(this.cityName);
|
||||
},
|
||||
methods: {
|
||||
goClass() {
|
||||
uni.navigateTo({
|
||||
url: "/wenwan/views/goodsClass?cityId=" + this.cityId
|
||||
})
|
||||
},
|
||||
goCity() {
|
||||
uni.redirectTo({
|
||||
url: `/components/chose-city/chose-city?type=1&city=${this.cityName}`
|
||||
})
|
||||
},
|
||||
goStore: function (item) {
|
||||
//跳转到客栈详情
|
||||
uni.navigateTo({
|
||||
url: `/wenwan/views/store?id=${item.id}`,
|
||||
})
|
||||
},
|
||||
search() {
|
||||
this.page = 1;
|
||||
this.list = [];
|
||||
this.fetchList(this.cityName);
|
||||
},
|
||||
fetchList(cityName) {
|
||||
fetchStore(this.page, cityName, this.name).then(res => {
|
||||
if (res.data.length > 0) {
|
||||
res.data.forEach(item => {
|
||||
this.list.push(item);
|
||||
})
|
||||
}
|
||||
// else if (this.list.length === 0 && this.name.length === 0 && this.page === 1) {
|
||||
// this.fetchList("");
|
||||
// }
|
||||
// this.page++;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wenwan-store-list {
|
||||
min-height: 100vh;
|
||||
background: #F9F9F9;
|
||||
color: #333;
|
||||
font-size: 24rpx;
|
||||
|
||||
|
||||
view {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
width: 686rpx;
|
||||
height: 64rpx;
|
||||
margin: 40rpx auto;
|
||||
padding: 0 24rpx 0 32rpx;
|
||||
background: #fff;
|
||||
border-radius: 32rpx;
|
||||
|
||||
input {
|
||||
width: 560rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-box {
|
||||
padding: 0 32rpx;
|
||||
|
||||
.location-box {
|
||||
color: #999;
|
||||
|
||||
.city-name {
|
||||
margin: 0 20rpx 0 6rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.more-box {
|
||||
image {
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
margin-left: 4rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
margin: 24rpx 32rpx 0;
|
||||
|
||||
.item {
|
||||
position: relative;
|
||||
width: 328rpx;
|
||||
height: 480rpx;
|
||||
margin-bottom: 24rpx;
|
||||
margin-right: 30rpx;
|
||||
background: #fff;
|
||||
border-radius: 8rpx;
|
||||
|
||||
.image {
|
||||
width: 328rpx;
|
||||
height: 328rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 8rpx 8rpx 0;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
left: 8rpx;
|
||||
|
||||
.icon {
|
||||
width: 38rpx;
|
||||
height: 38rpx;
|
||||
margin-right: 6rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.name {
|
||||
width: 268rpx;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.item:nth-child(2n) {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user