修改文件
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
<view>
|
||||
<u-cell-group :border="false">
|
||||
<u-cell-item title="退出登录" @click="logout" hover-class="none"></u-cell-item>
|
||||
<u-cell-item title="收货地址" @click="toAddress" :border-bottom="false" hover-class="none"></u-cell-item>
|
||||
<!-- <u-cell-item title="收货地址" @click="toAddress" :border-bottom="false" hover-class="none"></u-cell-item> -->
|
||||
</u-cell-group>
|
||||
|
||||
<u-modal v-model="showLogout" :content="content" :show-cancel-button="true" @confirm="confirmLogout"></u-modal>
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
<template>
|
||||
<view>
|
||||
<u-popup v-model="showPop" mode="bottom" border-radius="16" :safe-area-inset-bottom="true" :closeable="true">
|
||||
<view class="appointment-time">
|
||||
<view class="bold-700 lg u-p-t-24 u-p-b-24 u-text-center">选择预约时间</view>
|
||||
<view class="block row" style="height: 700rpx;">
|
||||
<u-popup v-model="showPop" mode="bottom" border-radius="16" :safe-area-inset-bottom="true" >
|
||||
<view class="appointment-time u-relative">
|
||||
<view class="bold-700 lg u-p-t-30 u-p-b-30 u-text-center time-text">选择预约时间</view>
|
||||
<view class="u-absolute close" @click="onClose">
|
||||
<u-icon size="40" name="close"></u-icon>
|
||||
</view>
|
||||
<view class="block row" style="height: 560rpx;">
|
||||
<view class="aside">
|
||||
<scroll-view style="height: 100%;" scroll-y="true" scroll-with-animation="true">
|
||||
<view style="padding-bottom: 200rpx;">
|
||||
@ -19,8 +22,8 @@
|
||||
|
||||
<view class="main">
|
||||
<scroll-view style="height: 100%" scroll-y="true" scroll-with-animation="true">
|
||||
<view class="main-wrap u-m-t-32">
|
||||
<view class="bg-white br16 row u-col-top u-m-b-24 nr" v-for="(item, index) in timeList" :key="index" @click="selectTime(index)">
|
||||
<view class="main-wrap">
|
||||
<view class="bg-white br16 row u-col-top nr time-block" v-for="(item, index) in timeList" :key="index" @click="selectTime(index)">
|
||||
<view>{{ item.start_time }}-{{ item.end_time }}</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -123,8 +126,17 @@
|
||||
|
||||
<style lang="scss">
|
||||
.appointment-time {
|
||||
height: 800rpx;
|
||||
max-height: 800rpx;
|
||||
height: 560rpx;
|
||||
max-height: 560rpx;
|
||||
}
|
||||
|
||||
.time-text {
|
||||
font-size: 40rpx;
|
||||
}
|
||||
|
||||
.close {
|
||||
right: 30rpx;
|
||||
top: 40rpx;
|
||||
}
|
||||
|
||||
.block {
|
||||
@ -141,6 +153,7 @@
|
||||
text-align: center;
|
||||
height: 108rpx;
|
||||
line-height: 108rpx;
|
||||
width: 200rpx;
|
||||
|
||||
&.active {
|
||||
color: $-color-theme;
|
||||
@ -159,6 +172,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
.time-block {
|
||||
height: 108rpx;
|
||||
line-height: 108rpx;
|
||||
border-bottom: 2rpx solid #F5F5F5;
|
||||
}
|
||||
|
||||
.main {
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
@ -166,6 +185,7 @@
|
||||
.main-wrap {
|
||||
position: relative;
|
||||
padding: 0 20rpx;
|
||||
padding-bottom: 108rpx;
|
||||
.goods {
|
||||
padding-bottom: 200rpx;
|
||||
.info {
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<scroll-view style="height: 100%;" scroll-y="true" scroll-with-animation="true">
|
||||
<view style="padding-bottom: 200rpx;">
|
||||
<block v-for="(item, index) in cateList" :key="index">
|
||||
<view :class="'one-item sm ' + (index == selectIndex ? 'active bg-white' : '')" @click="changeActive(index)">
|
||||
<view :class="'one-item sm ' + (index == selectIndex ? 'active bg-white' : '')"
|
||||
@click="changeActive(index)">
|
||||
<text class="name">{{ item.name }}</text>
|
||||
<view v-if="index == selectIndex" class="active-line bg-default"></view>
|
||||
</view>
|
||||
@ -15,33 +16,40 @@
|
||||
</view>
|
||||
|
||||
<view class="main">
|
||||
<scroll-view style="height: 100%" scroll-y="true" scroll-with-animation="true" @scrolltolower="getGoodsSearchFun">
|
||||
<scroll-view style="height: 100%" scroll-y="true" scroll-with-animation="true"
|
||||
@scrolltolower="getGoodsSearchFun">
|
||||
<view class="main-wrap">
|
||||
<view class="goods">
|
||||
<view class="u-p-t-32 bold-600">{{cateName}}</view>
|
||||
<view class="u-p-t-32 bold-600">{{ cateName }}</view>
|
||||
|
||||
<view class="u-p-t-32">
|
||||
<navigator :url="`/pages/shop/shop?id=${item.id}`" hover-class="none" class="bg-white br16 row u-col-top u-m-b-24" v-for="(item, index) in goodsList" :key="index" >
|
||||
<navigator :url="`/pages/shop/shop?id=${item.id}`" hover-class="none"
|
||||
class="bg-white br16 row u-col-top u-m-b-24" v-for="(item, index) in goodsList"
|
||||
:key="index">
|
||||
<view>
|
||||
<u-image :src="item.image" width="136" height="136" border-radius="16"></u-image>
|
||||
<u-image :src="item.image" width="136" height="136"
|
||||
border-radius="16"></u-image>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view>
|
||||
<view class="u-line-2 u-p-t-10">{{item.name}}</view>
|
||||
<view class="u-line-2 u-p-t-10">{{ item.name }}</view>
|
||||
<view class="u-p-t-20 row-between">
|
||||
<view class="row">
|
||||
<view class="primary">
|
||||
<price-format :price="item.price" :subscriptSize="22" :firstSize="34" :secondSize="26"></price-format>
|
||||
<price-format :price="item.price" :subscriptSize="22"
|
||||
:firstSize="34" :secondSize="26"></price-format>
|
||||
</view>
|
||||
<view class="u-m-l-8">
|
||||
<price-format :price="item.market_price" :lineThrough="true" color="#C0C0C0" :subscriptSize="22" :firstSize="22" :secondSize="22"></price-format>
|
||||
<price-format :price="item.market_price" :lineThrough="true"
|
||||
color="#C0C0C0" :subscriptSize="22" :firstSize="22"
|
||||
:secondSize="22"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="column-end">
|
||||
<view @click.stop="addCartFun(item)">
|
||||
<u-icon name="plus-circle-fill" color="#254062" size="48" ></u-icon>
|
||||
<u-icon name="plus-circle-fill" color="#254062" size="48"></u-icon>
|
||||
</view>
|
||||
<!-- <u-button @click="openSpec(item.name)" hover-class="none"
|
||||
:customStyle="{width: '116rpx', height: '46rpx', lineHeight: '46rpx', fontSize: '24rpx', backgroundColor: themeColor, color: '#fff', border: 'none', paddingTop: '8rpx'}"
|
||||
@ -75,10 +83,11 @@
|
||||
<view class="u-m-l-32">
|
||||
<view class="row-center" v-if="totalPrice">
|
||||
<text class="text-fff">
|
||||
共计
|
||||
共计
|
||||
</text>
|
||||
<view class="primary u-m-t-10 u-m-l-20">
|
||||
<price-format :price="totalPrice" :subscriptSize="26" :firstSize="34" :secondSize="26"></price-format>
|
||||
<price-format :price="totalPrice" :subscriptSize="26" :firstSize="34"
|
||||
:secondSize="26"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-fff" v-else>
|
||||
@ -93,11 +102,12 @@
|
||||
<u-popup v-model="showCart" mode="bottom" :border-radius="16">
|
||||
<view style="max-height: 800rpx;">
|
||||
<view class="px20 text-999 mt20">
|
||||
温馨提示:请适量点餐
|
||||
温馨提示:请适量点餐,(套餐与单品系列限购2套)
|
||||
</view>
|
||||
<view v-if="cartLists.length > 0">
|
||||
<scroll-view style="height: 700rpx;" scroll-y="true" scroll-with-animation="true">
|
||||
<view class="row-start u-row-between u-p-t-20 u-padding-bottom-20 px20" v-for="(item, index) in cartLists" :key="index">
|
||||
<view class="row-start u-row-between u-p-t-20 u-padding-bottom-20 px20"
|
||||
v-for="(item, index) in cartLists" :key="index">
|
||||
<view class="row-start">
|
||||
<view>
|
||||
<u-image :src="item.img" width="136" height="136" border-radius="16"></u-image>
|
||||
@ -112,7 +122,8 @@
|
||||
<text>味浓芳香</text>
|
||||
</view>
|
||||
<view class="primary">
|
||||
<price-format :price="item.price" :subscriptSize="22" :firstSize="34" :secondSize="26"></price-format>
|
||||
<price-format :price="item.price" :subscriptSize="22" :firstSize="34"
|
||||
:secondSize="26"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -121,13 +132,17 @@
|
||||
<u-icon class="u-p-t-10" name="trash" size="32"></u-icon>
|
||||
</view>
|
||||
<view class="u-p-t-30">
|
||||
<u-number-box :disabled="item.cart_status != 0" :min="1" :max="item.item_stock" :value="item.goods_num" @blur="countChange($event, item.cart_id, item)" @minus="countChange($event, item.cart_id, item)" @plus="countChange($event, item.cart_id, item)"></u-number-box>
|
||||
<u-number-box :disabled="item.cart_status != 0" :min="1" :max="item.first_category_id == 1 || item.first_category_id == 2 ? 2 : item.stock"
|
||||
:value="item.goods_num" @blur="countChange($event, item.cart_id, item)"
|
||||
@minus="countChange($event, item.cart_id, item)"
|
||||
@plus="countChange($event, item.cart_id, item)"></u-number-box>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="settle-btn">
|
||||
<u-button @tap="goSettle" shape="circle" :hair-line="false" hover-class="none" :customStyle="{backgroundColor: themeColor, color: '#fff', border: 'none', padding: '36rpx'}">去结算</u-button>
|
||||
<u-button @tap="goSettle" shape="circle" :hair-line="false" hover-class="none"
|
||||
:customStyle="{ backgroundColor: themeColor, color: '#fff', border: 'none', padding: '36rpx' }">去结算</u-button>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
@ -137,353 +152,360 @@
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<shop-spec v-model="showSpec" :name="goodsName" :spec="goods_spec" @close="showSpec = false" @confirm="confirmSpec"></shop-spec>
|
||||
<shop-spec v-model="showSpec" :name="goodsName" :spec="goods_spec" @close="showSpec = false"
|
||||
@confirm="confirmSpec"></shop-spec>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapActions,
|
||||
mapGetters
|
||||
} from 'vuex';
|
||||
import {
|
||||
loadingFun
|
||||
} from '@/utils/tools'
|
||||
import {
|
||||
getGoodsSearch,
|
||||
addCart,
|
||||
getPoster,
|
||||
getCartNum,
|
||||
getCartList,
|
||||
changeGoodsCount,
|
||||
deleteGoods
|
||||
} from '@/api/store';
|
||||
import {
|
||||
loadingType
|
||||
} from '@/utils/type';
|
||||
import {
|
||||
mapActions,
|
||||
mapGetters
|
||||
} from 'vuex';
|
||||
import {
|
||||
loadingFun
|
||||
} from '@/utils/tools'
|
||||
import {
|
||||
getGoodsSearch,
|
||||
addCart,
|
||||
getPoster,
|
||||
getCartNum,
|
||||
getCartList,
|
||||
changeGoodsCount,
|
||||
deleteGoods
|
||||
} from '@/api/store';
|
||||
import {
|
||||
loadingType
|
||||
} from '@/utils/type';
|
||||
|
||||
export default {
|
||||
name: "cate-one",
|
||||
props: {
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => ([])
|
||||
export default {
|
||||
name: "cate-one",
|
||||
props: {
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => ([])
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
page: 1,
|
||||
status: loadingType.LOADING,
|
||||
selectIndex: 0,
|
||||
categoryId: 0,
|
||||
cateList: [],
|
||||
goodsList: [],
|
||||
goods_spec: [],
|
||||
cateName: '',
|
||||
numberVal: 1,
|
||||
showCart: false,
|
||||
showSpec: false,
|
||||
goods_num: 0,
|
||||
cartLists: [],
|
||||
totalPrice: 0,
|
||||
goodsName: '',
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getCartNum();
|
||||
this.getCartListFun();
|
||||
uni.$on('refreshCartList', this.getCartListFun);
|
||||
},
|
||||
beforeDestroy() {
|
||||
uni.$off('refreshCartList', this.getCartListFun);
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['getCartNum']),
|
||||
|
||||
// 切换商品分类
|
||||
changeActive(index) {
|
||||
const {
|
||||
cateList
|
||||
} = this
|
||||
this.cateName = cateList[index].name
|
||||
this.selectIndex = index
|
||||
this.onRefresh()
|
||||
},
|
||||
|
||||
onRefresh() {
|
||||
this.page = 1
|
||||
this.goodsList = []
|
||||
this.status = loadingType.LOADING
|
||||
this.$nextTick(() => {
|
||||
this.getGoodsSearchFun();
|
||||
});
|
||||
},
|
||||
|
||||
async getGoodsSearchFun() {
|
||||
let {
|
||||
page,
|
||||
goodsList,
|
||||
priceSort,
|
||||
saleSort,
|
||||
status,
|
||||
cateList,
|
||||
selectIndex
|
||||
} = this;
|
||||
const item = cateList[selectIndex]
|
||||
if (item.type == 0) return
|
||||
if (status == loadingType.FINISHED) return;
|
||||
const params = {
|
||||
category_id: item.id,
|
||||
page_no: page,
|
||||
price: priceSort,
|
||||
sales_sum: saleSort
|
||||
}
|
||||
const data = await loadingFun(getGoodsSearch, page, goodsList, status, params)
|
||||
console.log(data);
|
||||
|
||||
if (!data) return
|
||||
this.page = data.page
|
||||
this.goodsList = data.dataList
|
||||
this.status = data.status
|
||||
},
|
||||
|
||||
// 显示购物车弹出窗
|
||||
showCartPopup() {
|
||||
if (this.cartLists.length > 0) {
|
||||
this.showCart = true
|
||||
} else {
|
||||
this.$toast({
|
||||
title: '请先添加商品'
|
||||
});
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
page:1,
|
||||
status: loadingType.LOADING,
|
||||
selectIndex: 0,
|
||||
categoryId: 0,
|
||||
cateList: [],
|
||||
goodsList: [],
|
||||
goods_spec: [],
|
||||
cateName: '',
|
||||
numberVal: 1,
|
||||
showCart: false,
|
||||
showSpec: false,
|
||||
goods_num: 0,
|
||||
cartLists: [],
|
||||
totalPrice: 0,
|
||||
goodsName: '',
|
||||
|
||||
// 添加到购物车(默认商品数量+1,可以让后端连表查询商品数量字段)
|
||||
async addCartFun(item) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/shop/shop?id=${item.id}&showPopup=true`
|
||||
})
|
||||
return
|
||||
|
||||
// 限购逻辑
|
||||
if (item.first_category_id === 1 || item.first_category_id === 2) {
|
||||
// 统计购物车中同类商品的总数量
|
||||
const totalNum = this.cartLists
|
||||
.filter(i => i.first_category_id === item.first_category_id)
|
||||
.reduce((sum, i) => sum + (i.goods_num || 0), 0);
|
||||
|
||||
if (totalNum >= 2) {
|
||||
this.$toast({ title: '该类商品每人限购2件' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
code,
|
||||
data,
|
||||
msg
|
||||
} = await addCart({
|
||||
item_id: item.id,
|
||||
goods_num: 1
|
||||
});
|
||||
if (code == 1) {
|
||||
this.getCartListFun()
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getCartNum()
|
||||
this.getCartListFun()
|
||||
|
||||
// 打开规格弹窗
|
||||
openSpec(name) {
|
||||
this.showSpec = true
|
||||
this.goodsName = name
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['getCartNum']),
|
||||
|
||||
// 切换商品分类
|
||||
changeActive(index) {
|
||||
const {
|
||||
cateList
|
||||
} = this
|
||||
this.cateName = cateList[index].name
|
||||
this.selectIndex = index
|
||||
this.onRefresh()
|
||||
},
|
||||
|
||||
onRefresh() {
|
||||
this.page = 1
|
||||
this.goodsList = []
|
||||
this.status = loadingType.LOADING
|
||||
this.$nextTick(() => {
|
||||
this.getGoodsSearchFun();
|
||||
});
|
||||
},
|
||||
|
||||
async getGoodsSearchFun() {
|
||||
let {
|
||||
page,
|
||||
goodsList,
|
||||
priceSort,
|
||||
saleSort,
|
||||
status,
|
||||
cateList,
|
||||
selectIndex
|
||||
} = this;
|
||||
const item = cateList[selectIndex]
|
||||
if(item.type == 0) return
|
||||
if (status == loadingType.FINISHED) return;
|
||||
const params = {
|
||||
category_id: item.id,
|
||||
page_no: page,
|
||||
price: priceSort,
|
||||
sales_sum: saleSort
|
||||
}
|
||||
const data = await loadingFun(getGoodsSearch, page, goodsList, status, params)
|
||||
console.log(data);
|
||||
|
||||
if (!data) return
|
||||
this.page = data.page
|
||||
this.goodsList = data.dataList
|
||||
this.status = data.status
|
||||
},
|
||||
|
||||
// 显示购物车弹出窗
|
||||
showCartPopup() {
|
||||
if (this.cartLists.length > 0) {
|
||||
this.showCart = true
|
||||
} else {
|
||||
this.$toast({
|
||||
title: '请先添加商品'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 添加到购物车(默认商品数量+1,可以让后端连表查询商品数量字段)
|
||||
async addCartFun(item) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/shop/shop?id=${item.id}&showPopup=true`
|
||||
})
|
||||
return
|
||||
|
||||
// 限购逻辑
|
||||
if (item.first_category_id === 1 || item.first_category_id === 2) {
|
||||
// 统计购物车中同类商品的总数量
|
||||
const totalNum = this.cartLists
|
||||
.filter(i => i.first_category_id === item.first_category_id)
|
||||
.reduce((sum, i) => sum + (i.goods_num || 0), 0);
|
||||
|
||||
if (totalNum >= 2) {
|
||||
this.$toast({ title: '该类商品每人限购2件' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
code,
|
||||
data,
|
||||
msg
|
||||
} = await addCart({
|
||||
item_id: item.id,
|
||||
goods_num: 1
|
||||
});
|
||||
if (code == 1) {
|
||||
// 购物车商品里面的数量
|
||||
countChange({ value }, cartId, item) {
|
||||
console.log("countChange", value, cartId, item);
|
||||
changeGoodsCount({
|
||||
cart_id: cartId,
|
||||
goods_num: value,
|
||||
}).then((res) => {
|
||||
if (res.code == 1) {
|
||||
this.getCartListFun()
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 打开规格弹窗
|
||||
openSpec(name) {
|
||||
this.showSpec = true
|
||||
this.goodsName = name
|
||||
},
|
||||
// 获取购物车列表数据
|
||||
getCartListFun() {
|
||||
// 获取商品的分类ID
|
||||
getCartList().then((res) => {
|
||||
if (res.code == 1) {
|
||||
|
||||
// 购物车商品里面的数量
|
||||
countChange({value}, cartId, item) {
|
||||
console.log("countChange", value, cartId, item);
|
||||
changeGoodsCount({
|
||||
cart_id: cartId,
|
||||
goods_num: value,
|
||||
}).then((res) => {
|
||||
if (res.code == 1) {
|
||||
this.getCartListFun()
|
||||
}
|
||||
});
|
||||
},
|
||||
let {
|
||||
lists,
|
||||
total_amount
|
||||
} = res.data;
|
||||
this.cartLists = lists;
|
||||
console.log("🚀 ~ getCartListFun ~ lists:", lists)
|
||||
// // let cartType = 0;
|
||||
|
||||
// 获取购物车列表数据
|
||||
getCartListFun() {
|
||||
// 获取商品的分类ID
|
||||
getCartList().then((res) => {
|
||||
if (res.code == 1) {
|
||||
// // if (lists.length == 0) {
|
||||
// // cartType = 2;
|
||||
// // } else {
|
||||
// // cartType = 1;
|
||||
// // }
|
||||
|
||||
let {
|
||||
lists,
|
||||
total_amount
|
||||
} = res.data;
|
||||
this.cartLists = lists;
|
||||
// // let cartType = 0;
|
||||
// this.cartLists = list;
|
||||
// console.log(">>>", this.cartLists);
|
||||
|
||||
// // if (lists.length == 0) {
|
||||
// // cartType = 2;
|
||||
// // } else {
|
||||
// // cartType = 1;
|
||||
// // }
|
||||
// // this.cartType = cartType;
|
||||
this.totalPrice = total_amount
|
||||
// // this.isShow = true;
|
||||
this.getCartNum();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// this.cartLists = list;
|
||||
// console.log(">>>", this.cartLists);
|
||||
// 购物车删除商品
|
||||
deleteGoods(cart_id) {
|
||||
deleteGoods({
|
||||
cart_id
|
||||
}).then((res) => {
|
||||
if (res.code == 1) {
|
||||
this.getCartListFun();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// // this.cartType = cartType;
|
||||
this.totalPrice = total_amount
|
||||
// // this.isShow = true;
|
||||
this.getCartNum();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 去结算
|
||||
goSettle() {
|
||||
console.log(this.cartLists)
|
||||
this.showCart = false
|
||||
const goods = this.cartLists.map(item => {
|
||||
return {
|
||||
item_id: item.item_id,
|
||||
num: item.goods_num
|
||||
}
|
||||
})
|
||||
|
||||
// 购物车删除商品
|
||||
deleteGoods(cart_id) {
|
||||
deleteGoods({
|
||||
cart_id
|
||||
}).then((res) => {
|
||||
if (res.code == 1) {
|
||||
this.getCartListFun();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 去结算
|
||||
goSettle() {
|
||||
console.log(this.cartLists)
|
||||
this.showCart = false
|
||||
const goods = this.cartLists.map(item => {
|
||||
return {
|
||||
item_id: item.item_id,
|
||||
num: item.goods_num
|
||||
}
|
||||
})
|
||||
|
||||
uni.navigateTo({
|
||||
url: "/pages/order_now/order_now?data=" +
|
||||
uni.navigateTo({
|
||||
url: "/pages/order_now/order_now?data=" +
|
||||
encodeURIComponent(
|
||||
JSON.stringify({
|
||||
goods,
|
||||
type: "cart",
|
||||
})
|
||||
),
|
||||
});
|
||||
},
|
||||
|
||||
// 跳转商品详情页
|
||||
toShop(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/shop/shop?id=${id}`
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['cartNum']),
|
||||
// 显示购物车数量
|
||||
buyNumber() {
|
||||
if (this.goods_num > 0) {
|
||||
return this.goods_num > 99 ? '99+' : this.goods_num
|
||||
}
|
||||
|
||||
return ''
|
||||
// 跳转商品详情页
|
||||
toShop(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/shop/shop?id=${id}`
|
||||
})
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['cartNum']),
|
||||
// 显示购物车数量
|
||||
buyNumber() {
|
||||
if (this.goods_num > 0) {
|
||||
return this.goods_num > 99 ? '99+' : this.goods_num
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
list: {
|
||||
handler(val) {
|
||||
if(!val.length) return
|
||||
let index = val.findIndex((item) => item.type == 1)
|
||||
|
||||
this.selectIndex = index == -1 ? 0 : index
|
||||
this.cateName = val[this.selectIndex].name
|
||||
this.cateList = val
|
||||
this.getGoodsSearchFun()
|
||||
}
|
||||
return ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
list: {
|
||||
handler(val) {
|
||||
if (!val.length) return
|
||||
let index = val.findIndex((item) => item.type == 1)
|
||||
|
||||
this.selectIndex = index == -1 ? 0 : index
|
||||
this.cateName = val[this.selectIndex].name
|
||||
this.cateList = val
|
||||
this.getGoodsSearchFun()
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
page {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
$header-height: 94rpx;
|
||||
$header-height: 94rpx;
|
||||
|
||||
.cate {
|
||||
position: relative;
|
||||
}
|
||||
.cate {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.cate-one {
|
||||
height: 100vh;
|
||||
.cate-one {
|
||||
height: 100vh;
|
||||
|
||||
.aside {
|
||||
width: 180rpx;
|
||||
flex: none;
|
||||
height: 100%;
|
||||
background-color: #F7F8FA;
|
||||
.aside {
|
||||
width: 180rpx;
|
||||
flex: none;
|
||||
height: 100%;
|
||||
background-color: #F7F8FA;
|
||||
|
||||
.one-item {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
height: 108rpx;
|
||||
line-height: 108rpx;
|
||||
.one-item {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
height: 108rpx;
|
||||
line-height: 108rpx;
|
||||
|
||||
&.active {
|
||||
color: $-color-theme;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.active-line {
|
||||
position: absolute;
|
||||
width: 6rpx;
|
||||
height: 30rpx;
|
||||
left: 4rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
&.active {
|
||||
color: $-color-theme;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
background-color: #FFFAFB;
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
|
||||
.main-wrap {
|
||||
position: relative;
|
||||
padding: 0 20rpx 160rpx;
|
||||
.goods {
|
||||
.info {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 0 16rpx;
|
||||
}
|
||||
}
|
||||
.active-line {
|
||||
position: absolute;
|
||||
width: 6rpx;
|
||||
height: 30rpx;
|
||||
left: 4rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.buy {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 10rpx);
|
||||
height: 100rpx;
|
||||
background-color: #212526;
|
||||
}
|
||||
.main {
|
||||
background-color: #FFFAFB;
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
|
||||
.number {
|
||||
background-color: #FF2C3C;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
border-radius: 100%;
|
||||
}
|
||||
.main-wrap {
|
||||
position: relative;
|
||||
padding: 0 20rpx 160rpx;
|
||||
|
||||
.settle-btn {
|
||||
padding: 20rpx;
|
||||
.goods {
|
||||
.info {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 0 16rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.buy {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 10rpx);
|
||||
height: 100rpx;
|
||||
background-color: #212526;
|
||||
}
|
||||
|
||||
.number {
|
||||
background-color: #FF2C3C;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
.settle-btn {
|
||||
padding: 20rpx;
|
||||
}
|
||||
</style>
|
||||
@ -47,7 +47,6 @@
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
props: {
|
||||
list: {
|
||||
type: Array,
|
||||
@ -58,6 +57,7 @@
|
||||
},
|
||||
couponId: [Number, String]
|
||||
},
|
||||
|
||||
watch: {
|
||||
list: {
|
||||
handler(val) {
|
||||
@ -72,6 +72,7 @@
|
||||
immediate: true,
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onSelect(id) {
|
||||
const {
|
||||
|
||||
@ -59,9 +59,6 @@
|
||||
</view>
|
||||
|
||||
<template v-if="mode === 'confirm'">
|
||||
<view class="delivery" v-if="delivery === 1 && !item.is_express"
|
||||
>该商品不支持快递配送</view
|
||||
>
|
||||
<view class="delivery" v-if="delivery === 2 && !item.is_selffetch"
|
||||
>该商品不支持门店自提</view
|
||||
>
|
||||
|
||||
@ -29,7 +29,8 @@
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="flex1 u-text-right">
|
||||
<u-number-box v-model="goodsNum" :min="1" :max="checkedGoods.stock"
|
||||
<!-- 限购逻辑:套餐和单品内的商品列表,每个都是只能购买两个 -->
|
||||
<u-number-box v-model="goodsNum" :min="1" :max="goods.first_category_id == 1 || goods.first_category_id == 2 ? 2 : checkedGoods.stock"
|
||||
:disabled="disabledNumberBox"></u-number-box>
|
||||
</view>
|
||||
</view>
|
||||
@ -157,6 +158,23 @@
|
||||
|
||||
},
|
||||
|
||||
// 商品数量变化
|
||||
handleCountChange({ value }) {
|
||||
console.log("🚀 ~ countChange ~ value:", value)
|
||||
console.log("🚀 ~ countChange ~ goods:", this.goods)
|
||||
if (this.goods.first_category_id === 1 || this.goods.first_category_id === 2) {
|
||||
// 套餐和单品系列限购2套
|
||||
if (value > 2) {
|
||||
this.disabledNumberBox = true
|
||||
return this.$toast({
|
||||
title: '套餐与单品系列限购2套',
|
||||
})
|
||||
} else {
|
||||
this.goodsNum = value
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 选择规格
|
||||
// chooseSpec(item, index1, index2, attr) {
|
||||
// if (item.name == '辣度') {
|
||||
|
||||
@ -8,14 +8,14 @@
|
||||
<u-icon name="arrow-right" size="28" class="right-icon"></u-icon>
|
||||
</navigator>
|
||||
</view>
|
||||
<view class="u-m-t-8 u-line-1">
|
||||
<!-- <view class="u-m-t-8 u-line-1">
|
||||
<navigator class="u-flex " url="/bundle/pages/address/address?type=1" hover-class="none">
|
||||
<u-icon name="map" size="32"></u-icon>
|
||||
<view class="u-line-1">
|
||||
{{userAddress || '请选择收货地址'}}
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view>
|
||||
<u-button shape="circle" :hair-line="false" hover-class="none" :customStyle="{backgroundColor: themeColor, color: '#fff', border: 'none', padding: '36rpx'}" @click="signin">签到</u-button>
|
||||
@ -53,7 +53,14 @@
|
||||
</view>
|
||||
|
||||
<!-- 下单 -->
|
||||
<view class="order u-flex u-row-center bg-white">
|
||||
<view class="order u-flex u-row-center bg-white" @click="toStore">
|
||||
<view>
|
||||
<view class="reserve">预约下单</view>
|
||||
<view class="desc">极速送达更便捷</view>
|
||||
</view>
|
||||
<view>
|
||||
<u-image :src="cloudPath + 'img/home_image1.png'" width="204" height="204"></u-image>
|
||||
</view>
|
||||
<!-- <view class="bg-white u-text-center">
|
||||
<navigator url="/pages/store/store?type=1" hover-class="none">
|
||||
<view class="text-default xxl">预约下单</view>
|
||||
@ -63,7 +70,7 @@
|
||||
</view>
|
||||
</navigator>
|
||||
</view> -->
|
||||
<view class="u-text-center">
|
||||
<!-- <view class="u-text-center">
|
||||
<navigator url="/pages/store/store?type=2" hover-class="none">
|
||||
<view class="text-default xxl">现在点单</view>
|
||||
<view class="xs text-999">预约下单更便捷</view>
|
||||
@ -71,7 +78,7 @@
|
||||
<u-image :src="cloudPath + 'img/icon_order.png'" width="132" height="133" mode="aspectFit"></u-image>
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- 活动图 -->
|
||||
@ -157,6 +164,12 @@
|
||||
uni.navigateTo({
|
||||
url: '/pages/signin/signin'
|
||||
})
|
||||
},
|
||||
|
||||
toStore() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/store/store'
|
||||
})
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -200,9 +213,31 @@
|
||||
|
||||
.order {
|
||||
margin: 30rpx 20rpx;
|
||||
height: 300rpx;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
& > view {
|
||||
border-radius: 16rpx;
|
||||
padding: 40rpx 86rpx;
|
||||
}
|
||||
|
||||
.reserve {
|
||||
font-weight: 500;
|
||||
font-size: 44rpx;
|
||||
color: #254062;
|
||||
line-height: 26rpx;
|
||||
font-weight: 500;
|
||||
margin-bottom: 34rpx;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-weight: 400;
|
||||
font-size: 22rpx;
|
||||
color: #999999;
|
||||
line-height: 26rpx;
|
||||
text-align: center;
|
||||
font-style: normal;
|
||||
text-transform: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,10 @@
|
||||
// 更新新注册的用户信息
|
||||
async handleSubmitMobile(e) {
|
||||
console.log("🚀 ~ handleSubmitMobile ~ e:", e)
|
||||
|
||||
const wxCode = await getWxCode()
|
||||
console.log("🚀 ~ handleSubmitMobile ~ wxCode:", wxCode)
|
||||
console.log("🚀 ~ handleSubmitMobile ~ client:", client)
|
||||
const res = await accountLogin({ account: e.mobile, code: wxCode, client })
|
||||
if (res.code == 1) {
|
||||
this.loginHandle(res.data)
|
||||
|
||||
@ -181,8 +181,7 @@
|
||||
|
||||
<script>
|
||||
import { orderBuy, getOrderCoupon, getDelivery } from '@/api/order'
|
||||
import { prepay, getPayway } from '@/api/app'
|
||||
import { wxpay, alipay } from '@/utils/pay'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
<view>
|
||||
<view class="shop">
|
||||
<view>
|
||||
<u-swiper :list="goods.goods_image" name="uri" height="500" border-radius="0" mode="number" indicator-pos="bottomRight"></u-swiper>
|
||||
<u-swiper :list="goods.goods_image" name="uri" height="500" border-radius="0" mode="number"
|
||||
indicator-pos="bottomRight"></u-swiper>
|
||||
</view>
|
||||
|
||||
<view class="bg-white mx24 px24 u-m-t-24 u-padding-top-20 u-padding-bottom-20 br24">
|
||||
@ -10,11 +11,13 @@
|
||||
<view class="mt10 row u-row-between">
|
||||
<view class="row">
|
||||
<view class="primary">
|
||||
<price-format :price="goods.min_price" :subscriptSize="22" :firstSize="34" :secondSize="26"></price-format>
|
||||
<price-format :price="goods.min_price" :subscriptSize="22" :firstSize="34"
|
||||
:secondSize="26"></price-format>
|
||||
</view>
|
||||
<view class="sale u-text-center primary u-m-l-12">0折</view>
|
||||
<view class="primary u-m-l-12">
|
||||
<price-format :lineThrough="true" color="#999" :subscriptSize="22" :firstSize="22" :secondSize="22" :price="goods.market_price"></price-format>
|
||||
<price-format :lineThrough="true" color="#999" :subscriptSize="22" :firstSize="22"
|
||||
:secondSize="22" :price="goods.market_price"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-999">已售66</view>
|
||||
@ -36,10 +39,9 @@
|
||||
</view>
|
||||
<view>
|
||||
<u-button @click="openSpec" hover-class="none"
|
||||
:customStyle="{width: '116rpx', height: '46rpx', lineHeight: '46rpx', fontSize: '24rpx', backgroundColor: themeColor, color: '#fff', border: 'none', paddingTop: '8rpx'}"
|
||||
:hair-line="false"
|
||||
shape="circle">
|
||||
选规格
|
||||
:customStyle="{ width: '116rpx', height: '46rpx', lineHeight: '46rpx', fontSize: '24rpx', backgroundColor: themeColor, color: '#fff', border: 'none', paddingTop: '8rpx' }"
|
||||
:hair-line="false" shape="circle">
|
||||
选规格
|
||||
</u-button>
|
||||
</view>
|
||||
</view>
|
||||
@ -73,203 +75,208 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-l-64 flex1">
|
||||
<u-button hover-class="none" @click="showSpecFun"
|
||||
:customStyle="{height: '92rpx', fontSize: '24rpx', backgroundColor: themeColor, color: '#fff', border: 'none', paddingTop: '8rpx'}"
|
||||
:hair-line="false"
|
||||
shape="circle">
|
||||
立即购买
|
||||
<u-button hover-class="none" @click="showSpecFun"
|
||||
:customStyle="{ height: '92rpx', fontSize: '24rpx', backgroundColor: themeColor, color: '#fff', border: 'none', paddingTop: '8rpx' }"
|
||||
:hair-line="false" shape="circle">
|
||||
立即购买
|
||||
</u-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<shop-spec v-model="showSpec" :name="goods.name" :goods="goods" @confirm="confirmSpec" @buynow="onBuy"></shop-spec>
|
||||
<shop-spec v-model="showSpec" :name="goods.name" :goods="goods" @confirm="confirmSpec"
|
||||
@buynow="onBuy"></shop-spec>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapActions,
|
||||
mapGetters
|
||||
} from 'vuex';
|
||||
import {
|
||||
getGoodsDetail,
|
||||
getCartList,
|
||||
addCart,
|
||||
getPoster,
|
||||
getCartNum
|
||||
} from '@/api/store'
|
||||
import {
|
||||
toLogin
|
||||
} from '@/utils/login'
|
||||
import {
|
||||
mapActions,
|
||||
mapGetters
|
||||
} from 'vuex';
|
||||
import {
|
||||
getGoodsDetail,
|
||||
getCartList,
|
||||
addCart,
|
||||
getPoster,
|
||||
getCartNum
|
||||
} from '@/api/store'
|
||||
import {
|
||||
toLogin
|
||||
} from '@/utils/login'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
id: 0,
|
||||
showSpec: false,
|
||||
goods: [],
|
||||
spec: [],
|
||||
checkedGoods: {},
|
||||
source: '',
|
||||
cartLists: [],
|
||||
totalPrice: 0,
|
||||
showPopup: false,
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
id: 0,
|
||||
showSpec: false,
|
||||
goods: [],
|
||||
spec: [],
|
||||
checkedGoods: {},
|
||||
source: '',
|
||||
cartLists: [],
|
||||
totalPrice: 0,
|
||||
showPopup: false,
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
console.log("🚀 ~ onLoad ~ options:", options)
|
||||
this.id = options.id
|
||||
this.showPopup = options.showPopup === 'true' ? true : false
|
||||
this.showSpec = this.showPopup
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
uni.$emit('refreshCartList');
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.getGoodsDetailFun();
|
||||
this.getCartNum()
|
||||
this.getCartListFun()
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapActions(['getCartNum']),
|
||||
|
||||
// 获取商品详情
|
||||
async getGoodsDetailFun() {
|
||||
const {
|
||||
data,
|
||||
code
|
||||
} = await getGoodsDetail({
|
||||
id: this.id
|
||||
});
|
||||
if (code == 1) {
|
||||
this.goods = data
|
||||
console.log(this.goods.goods_image);
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
console.log("🚀 ~ onLoad ~ options:", options)
|
||||
this.id = options.id
|
||||
this.showPopup = options.showPopup === 'true' ? true : false
|
||||
this.showSpec = this.showPopup
|
||||
},
|
||||
// 获取购物车列表数据
|
||||
getCartListFun() {
|
||||
// 获取商品的分类ID
|
||||
getCartList().then((res) => {
|
||||
if (res.code == 1) {
|
||||
let {
|
||||
lists,
|
||||
total_amount
|
||||
} = res.data;
|
||||
this.cartLists = lists;
|
||||
// // let cartType = 0;
|
||||
|
||||
onShow() {
|
||||
this.getGoodsDetailFun();
|
||||
this.getCartNum()
|
||||
this.getCartListFun()
|
||||
},
|
||||
// // if (lists.length == 0) {
|
||||
// // cartType = 2;
|
||||
// // } else {
|
||||
// // cartType = 1;
|
||||
// // }
|
||||
|
||||
methods: {
|
||||
...mapActions(['getCartNum']),
|
||||
// this.cartLists = list;
|
||||
// console.log(">>>", this.cartLists);
|
||||
|
||||
// 获取商品详情
|
||||
async getGoodsDetailFun() {
|
||||
const {
|
||||
data,
|
||||
code
|
||||
} = await getGoodsDetail({
|
||||
id: this.id
|
||||
});
|
||||
if (code == 1) {
|
||||
this.goods = data
|
||||
console.log(this.goods.goods_image);
|
||||
// // this.cartType = cartType;
|
||||
this.totalPrice = total_amount
|
||||
// // this.isShow = true;
|
||||
this.getCartNum();
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 获取购物车列表数据
|
||||
getCartListFun() {
|
||||
// 获取商品的分类ID
|
||||
getCartList().then((res) => {
|
||||
if (res.code == 1) {
|
||||
let {
|
||||
lists,
|
||||
total_amount
|
||||
} = res.data;
|
||||
this.cartLists = lists;
|
||||
// // let cartType = 0;
|
||||
// 将当前的商品添加到购物车里面
|
||||
addCartFun() {
|
||||
this.showSpec = true
|
||||
},
|
||||
|
||||
// // if (lists.length == 0) {
|
||||
// // cartType = 2;
|
||||
// // } else {
|
||||
// // cartType = 1;
|
||||
// // }
|
||||
// 打开商品规格
|
||||
openSpec() {
|
||||
this.showSpec = true
|
||||
},
|
||||
|
||||
// this.cartLists = list;
|
||||
// console.log(">>>", this.cartLists);
|
||||
// 获取选择的商品规格
|
||||
confirmSpec(data) {
|
||||
console.log("data>>>", data.spec);
|
||||
this.spec = data.spec
|
||||
this.showSpec = false
|
||||
},
|
||||
|
||||
// // this.cartType = cartType;
|
||||
this.totalPrice = total_amount
|
||||
// // this.isShow = true;
|
||||
this.getCartNum();
|
||||
onChangeGoods(e) {
|
||||
console.log(e);
|
||||
this.checkedGoods = e.detail;
|
||||
},
|
||||
|
||||
// 选择规格
|
||||
showSpecFun() {
|
||||
if (!this.isLogin) return toLogin();
|
||||
this.showSpec = true;
|
||||
},
|
||||
|
||||
// 购买商品
|
||||
onBuy(e) {
|
||||
if (e.type === 'cart') {
|
||||
let { id, goodsNum } = e.detail
|
||||
addCart({
|
||||
item_id: id,
|
||||
goods_num: goodsNum
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$toast({
|
||||
title: res.msg
|
||||
});
|
||||
return;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 将当前的商品添加到购物车里面
|
||||
addCartFun() {
|
||||
this.showSpec = true
|
||||
},
|
||||
|
||||
// 打开商品规格
|
||||
openSpec() {
|
||||
this.showSpec = true
|
||||
},
|
||||
|
||||
// 获取选择的商品规格
|
||||
confirmSpec(data) {
|
||||
console.log("data>>>", data.spec);
|
||||
this.spec = data.spec
|
||||
this.showSpec = false
|
||||
},
|
||||
|
||||
onChangeGoods(e) {
|
||||
console.log(e);
|
||||
this.checkedGoods = e.detail;
|
||||
},
|
||||
|
||||
// 选择规格
|
||||
showSpecFun() {
|
||||
if (!this.isLogin) return toLogin();
|
||||
this.showSpec = true;
|
||||
},
|
||||
|
||||
// 购买商品
|
||||
onBuy(e) {
|
||||
if (e.type === 'cart') {
|
||||
// 限购逻辑:套餐和单品内的商品列表,每个都是只能购买两个
|
||||
if (this.goods.first_category_id == 1 || this.goods.first_category_id == 2) {
|
||||
console.log("🚀 ~ onBuy ~ this.cartLists:", this.cartLists)
|
||||
|
||||
const totalNum = this.cartLists
|
||||
.filter(i => i.first_category_id === this.goods.first_category_id)
|
||||
.reduce((sum, i) => sum + (i.goods_num || 0), 0);
|
||||
|
||||
if (totalNum >= 2) {
|
||||
this.$toast({ title: '该类商品每人限购2件' });
|
||||
return;
|
||||
} else {
|
||||
let {id} = e.detail
|
||||
addCart({
|
||||
item_id: id,
|
||||
goods_num: 1
|
||||
}).then(res => {
|
||||
this.getCartListFun()
|
||||
this.getCartListFun()
|
||||
if (this.showPopup) {
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/store/store'
|
||||
});
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
} else {
|
||||
let {id, goodsNum} = e.detail
|
||||
let goods = [{item_id: id, num: goodsNum}]
|
||||
const params = {goods}
|
||||
this.showSpec = false
|
||||
uni.navigateTo({
|
||||
url: '/pages/order_now/order_now?data=' + encodeURIComponent((JSON.stringify(params)))
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let { id, goodsNum } = e.detail
|
||||
let goods = [{ item_id: id, num: goodsNum }]
|
||||
const params = { goods }
|
||||
this.showSpec = false
|
||||
uni.navigateTo({
|
||||
url: '/pages/order_now/order_now?data=' + encodeURIComponent((JSON.stringify(params)))
|
||||
})
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['cartNum']),
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['cartNum']),
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.shop {
|
||||
padding-bottom: 180rpx;
|
||||
.sale {
|
||||
background-color: #FEFBEA;
|
||||
width: 100rpx;
|
||||
height: 30rpx;
|
||||
line-height: 30rpx;
|
||||
}
|
||||
}
|
||||
.shop {
|
||||
padding-bottom: 180rpx;
|
||||
|
||||
.fixed {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
.sale {
|
||||
background-color: #FEFBEA;
|
||||
width: 100rpx;
|
||||
height: 30rpx;
|
||||
line-height: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.number {
|
||||
background-color: #FF2C3C;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
border-radius: 100%;
|
||||
}
|
||||
.fixed {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
.number {
|
||||
background-color: #FF2C3C;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
border-radius: 100%;
|
||||
}
|
||||
</style>
|
||||
@ -10,14 +10,14 @@
|
||||
MEET轻食店
|
||||
<u-icon name="arrow-right" size="28" class="right-icon u-m-l-4"></u-icon>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-8" @click="chooseAddress">
|
||||
<!-- <view class="u-flex u-m-t-8" @click="chooseAddress">
|
||||
<u-icon name="map" size="32"></u-icon>
|
||||
门店地址
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view>
|
||||
<!-- <view>
|
||||
<u-button shape="circle" :hair-line="false" hover-class="none" :customStyle="{backgroundColor: themeColor, color: '#fff', border: 'none', padding: '36rpx'}" @click="signin">自取</u-button>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="">
|
||||
<u-alert-tips type="warning" title="当前门店已休息"></u-alert-tips>
|
||||
@ -37,7 +37,6 @@
|
||||
keyword: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.getCatrgoryFun();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user