|
@@ -3,7 +3,7 @@
|
|
|
<scroll-view scroll-y="true" class="menu-box-left" :scroll-into-view="idMark" :scroll-with-animation='true'>
|
|
<scroll-view scroll-y="true" class="menu-box-left" :scroll-into-view="idMark" :scroll-with-animation='true'>
|
|
|
<view class="menu-type-list-f">
|
|
<view class="menu-type-list-f">
|
|
|
<view class="menu-type-list fs-26 box-border-box align-items-center flex-justify-center"
|
|
<view class="menu-type-list fs-26 box-border-box align-items-center flex-justify-center"
|
|
|
- v-for="(item,i) in typeList" :key="i" @click="selectType(item)"
|
|
|
|
|
|
|
+ v-for="(item,i) in categoryData" :key="i" @click="selectType(item)"
|
|
|
:class="type === item.type?'bgc-f fc-3 fw-600':'fc-6 fw-400'" :id="'scroll'+ item.type">
|
|
:class="type === item.type?'bgc-f fc-3 fw-600':'fc-6 fw-400'" :id="'scroll'+ item.type">
|
|
|
{{item.name}}
|
|
{{item.name}}
|
|
|
<view class="menu-type-num fc-f" v-show="item.num > 0">{{item.num > 99?'99+':item.num}}</view>
|
|
<view class="menu-type-num fc-f" v-show="item.num > 0">{{item.num > 99?'99+':item.num}}</view>
|
|
@@ -13,31 +13,30 @@
|
|
|
|
|
|
|
|
<scroll-view :scroll-y="true" :scroll-with-animation='true' :scroll-into-view="idMark" @scroll="menuScroll">
|
|
<scroll-view :scroll-y="true" :scroll-with-animation='true' :scroll-into-view="idMark" @scroll="menuScroll">
|
|
|
<view class="menu-box-right">
|
|
<view class="menu-box-right">
|
|
|
- <view class="menu-box-only" v-for="(item,i) in menuList" :key="i" :id="'scroll'+ item.type">
|
|
|
|
|
|
|
+ <view class="menu-box-only" v-for="(item,i) in categoryData" :key="i" :id="'scroll'+ item.type">
|
|
|
<view class="mb-32 fs-32">{{item.name}}</view>
|
|
<view class="mb-32 fs-32">{{item.name}}</view>
|
|
|
<view class="menu-list flex-justify-space" v-for="(info,k) in item.list" :key="k">
|
|
<view class="menu-list flex-justify-space" v-for="(info,k) in item.list" :key="k">
|
|
|
- <image class="flex-shrink0" src="@/static/img/my/bg.png" mode="scaleToFill"></image>
|
|
|
|
|
|
|
+ <image class="flex-shrink0" :src="info.goods_image" mode="scaleToFill"></image>
|
|
|
<view class="menu-list-right">
|
|
<view class="menu-list-right">
|
|
|
- <view class="mb-4 goods-name text-overflow-ellipsis fs-34 fw-600">[畅销款]奥尔1良烤肉 牛油拌饭[畅销款]奥尔1良烤肉
|
|
|
|
|
- 牛油拌饭[畅销款]奥尔1良烤肉 牛油拌饭[畅销款]奥尔1良烤肉 牛油拌饭</view>
|
|
|
|
|
- <view class="mb-20 fw-400 fc-9 fs-24">月销196</view>
|
|
|
|
|
|
|
+ <view class="mb-4 goods-name text-overflow-ellipsis fs-34 fw-600">{{info.goods_name}}</view>
|
|
|
|
|
+ <view class="mb-20 fw-400 fc-9 fs-24">月销{{info.sales}}</view>
|
|
|
<view class="flex-justify-space align-items-flex-end">
|
|
<view class="flex-justify-space align-items-flex-end">
|
|
|
<view class="">
|
|
<view class="">
|
|
|
<span class="fs-24 fw-400 fc-FB3D03">¥</span>
|
|
<span class="fs-24 fw-400 fc-FB3D03">¥</span>
|
|
|
- <span class="fs-40 fw-b fc-FB3D03">3.9</span>
|
|
|
|
|
- <span class="fs-24 fc-9 fw-400 text-line-through">¥12</span>
|
|
|
|
|
|
|
+ <span class="fs-40 fw-b fc-FB3D03">{{info.seckill_money>0?info.seckill_money:info.price}}</span>
|
|
|
|
|
+ <span class="fs-24 fc-9 fw-400 text-line-through">¥{{info.line_price}}</span>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="display-flex align-items-center" v-if="info.spec != 1">
|
|
|
|
|
|
|
+ <view class="display-flex align-items-center" v-if="info.spec_type == 1">
|
|
|
<view v-show="info.num > 0"
|
|
<view v-show="info.num > 0"
|
|
|
class="right-only-right-red fw-500 text-align-center fs-36 fc-f"
|
|
class="right-only-right-red fw-500 text-align-center fs-36 fc-f"
|
|
|
- @click="addred(1,i,k,item)">-</view>
|
|
|
|
|
|
|
+ @click="addred(1,i,k,info)">-</view>
|
|
|
<view v-show="info.num > 0"
|
|
<view v-show="info.num > 0"
|
|
|
class="right-only-right-2 text-align-center fs-28 fw-400">{{info.num}}</view>
|
|
class="right-only-right-2 text-align-center fs-28 fw-400">{{info.num}}</view>
|
|
|
<view class="right-only-right-add fw-500 text-align-center fs-36 fc-f"
|
|
<view class="right-only-right-add fw-500 text-align-center fs-36 fc-f"
|
|
|
- @click="addred(2,i,k,item)">+</view>
|
|
|
|
|
|
|
+ @click="addred(2,i,k,info)">+</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view v-else class="right-only-right text-align-center fw-600 fs-28 fc-f"
|
|
<view v-else class="right-only-right text-align-center fw-600 fs-28 fc-f"
|
|
|
- @click="addred(3,i,k,item)">选规格</view>
|
|
|
|
|
|
|
+ @click="addred(3,i,k,info)">选规格</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -104,16 +103,35 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import tools from "@/service/tools";
|
|
import tools from "@/service/tools";
|
|
|
|
|
+ import {shopCategory, shopGoods} from "@/api/shop";
|
|
|
|
|
+ import {getShopIngList} from "@/api/shopping";
|
|
|
export default {
|
|
export default {
|
|
|
name: 'menu-box',
|
|
name: 'menu-box',
|
|
|
|
|
+ props:{
|
|
|
|
|
+ 'shop_id':{
|
|
|
|
|
+ default:0
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
idMark: '', //滚动自适应参数
|
|
idMark: '', //滚动自适应参数
|
|
|
|
|
|
|
|
type: 1, //分类标识
|
|
type: 1, //分类标识
|
|
|
typeList: [],
|
|
typeList: [],
|
|
|
|
|
+ categoryData: [],
|
|
|
|
|
|
|
|
menuList: [],
|
|
menuList: [],
|
|
|
|
|
+ cartData: {
|
|
|
|
|
+ total_price:0,
|
|
|
|
|
+ total_num:0,
|
|
|
|
|
+ total_goods_money:0,
|
|
|
|
|
+ pack_price:0,
|
|
|
|
|
+ must_category:0,
|
|
|
|
|
+ is_place_order:0,
|
|
|
|
|
+ err_msg:0,
|
|
|
|
|
+ goods_list:0,
|
|
|
|
|
+ },
|
|
|
|
|
+ operate_id: '',
|
|
|
|
|
|
|
|
popData: {
|
|
popData: {
|
|
|
spec_name: '',
|
|
spec_name: '',
|
|
@@ -186,66 +204,63 @@
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ watch:{
|
|
|
|
|
+ 'shop_id':function () {
|
|
|
|
|
+ this.getShopGoods();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
mounted() {
|
|
mounted() {
|
|
|
- this.getTypeList();
|
|
|
|
|
|
|
+ this.operate_id = uni.getStorageSync('operate_id')
|
|
|
|
|
+ this.getShopGoods();
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- getTypeList() {
|
|
|
|
|
- this.typeList = [{
|
|
|
|
|
- "category_id": 1,
|
|
|
|
|
- "name": "爆品推荐",
|
|
|
|
|
- "type": 1,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- "category_id": 2,
|
|
|
|
|
- "name": "必点口味",
|
|
|
|
|
- "type": 2
|
|
|
|
|
- },
|
|
|
|
|
- ]
|
|
|
|
|
- this.type = this.typeList[0].type;
|
|
|
|
|
- this.idMark = 'scroll' + this.type;
|
|
|
|
|
- this.typeList.forEach((v) => {
|
|
|
|
|
- v.num = 0
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- this.menuList = [{
|
|
|
|
|
- name: '分类1',
|
|
|
|
|
- type: 1,
|
|
|
|
|
- list: [{
|
|
|
|
|
- name: 1,
|
|
|
|
|
- num: 0,
|
|
|
|
|
- spec: 1
|
|
|
|
|
- }, {
|
|
|
|
|
- name: 2,
|
|
|
|
|
- num: 0
|
|
|
|
|
- }, {
|
|
|
|
|
- name: 3,
|
|
|
|
|
- num: 0
|
|
|
|
|
- }, {
|
|
|
|
|
- name: 4,
|
|
|
|
|
- num: 0
|
|
|
|
|
- }, ]
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: '分类2',
|
|
|
|
|
- type: 2,
|
|
|
|
|
- list: [{
|
|
|
|
|
- name: 1,
|
|
|
|
|
- num: 0
|
|
|
|
|
- }, {
|
|
|
|
|
- name: 2,
|
|
|
|
|
- num: 0,
|
|
|
|
|
- spec: 1
|
|
|
|
|
- }, {
|
|
|
|
|
- name: 3,
|
|
|
|
|
- num: 0
|
|
|
|
|
- }, {
|
|
|
|
|
- name: 4,
|
|
|
|
|
- num: 0
|
|
|
|
|
- }, ]
|
|
|
|
|
- },
|
|
|
|
|
- ]
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ getShopIngList(){
|
|
|
|
|
+ getShopIngList().then(res=>{
|
|
|
|
|
+ if(res.code===1){
|
|
|
|
|
+ this.cartData=res.data
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ // getShopCategory(){
|
|
|
|
|
+ // if(this.shop_id<0 || !this.operate_id){
|
|
|
|
|
+ // return;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // shopCategory({'shop_id':this.shop_id, operate_id: this.operate_id,}).then(res=>{
|
|
|
|
|
+ // if(res.code===1){
|
|
|
|
|
+ // for (const cKey in res.data) {
|
|
|
|
|
+ // let item =res.data[cKey]
|
|
|
|
|
+ // item.goodsList=[]
|
|
|
|
|
+ // this.categoryData.push(item)
|
|
|
|
|
+ // if(cKey===0){
|
|
|
|
|
+ // this.selectType(item)
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.getShopGoods()
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+ // },
|
|
|
|
|
+ getShopGoods(){
|
|
|
|
|
+ if(this.shop_id<0 || !this.operate_id){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ shopGoods({'shop_id':this.shop_id, operate_id: this.operate_id,}).then(res=>{
|
|
|
|
|
+ if(res.code===1){
|
|
|
|
|
+ this.categoryData=res.data
|
|
|
|
|
+ if(this.categoryData.length>0){
|
|
|
|
|
+ this.selectType(this.categoryData[0])
|
|
|
|
|
+ }
|
|
|
|
|
+ this.categoryData.forEach(categoryItem=>{
|
|
|
|
|
+ categoryItem.list.forEach(goodsItem=>{
|
|
|
|
|
+ goodsItem.payNum=0
|
|
|
|
|
+ goodsItem.spec=[]
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ // console.log(res)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
|
|
|
selectType(item) {
|
|
selectType(item) {
|
|
|
if (this.type != item.type) {
|
|
if (this.type != item.type) {
|
|
@@ -267,14 +282,25 @@
|
|
|
}).exec();
|
|
}).exec();
|
|
|
},
|
|
},
|
|
|
addred(type, i, k, item) {
|
|
addred(type, i, k, item) {
|
|
|
|
|
+ console.log(item,type)
|
|
|
if (type === 1) {
|
|
if (type === 1) {
|
|
|
// 减
|
|
// 减
|
|
|
- this.menuList[i].list[k].num -= 1;
|
|
|
|
|
- this.setSub(item);
|
|
|
|
|
|
|
+ if(item.num>0){
|
|
|
|
|
+ --item.num;
|
|
|
|
|
+ // this.menuList[i].list[k].num -= 1;
|
|
|
|
|
+ this.setSub(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
} else if (type === 2) {
|
|
} else if (type === 2) {
|
|
|
// 加
|
|
// 加
|
|
|
- this.menuList[i].list[k].num += 1;
|
|
|
|
|
- this.setSub(item);
|
|
|
|
|
|
|
+ console.log(item.is_infinite===1 || item.stock>item.num)
|
|
|
|
|
+ if(item.is_infinite===1 || item.stock>item.num){
|
|
|
|
|
+ ++item.num;
|
|
|
|
|
+ this.setSub(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log(item.num)
|
|
|
|
|
+ // this.menuList[i].list[k].num += 1;
|
|
|
|
|
+ // this.setSub(item);
|
|
|
} else if (type === 3) {
|
|
} else if (type === 3) {
|
|
|
// 选规格
|
|
// 选规格
|
|
|
this.$refs.popupGG.open();
|
|
this.$refs.popupGG.open();
|
|
@@ -283,15 +309,15 @@
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
setSub(item) {
|
|
setSub(item) {
|
|
|
- let num = 0;
|
|
|
|
|
- item.list.forEach((n) => {
|
|
|
|
|
- num += n.num
|
|
|
|
|
- })
|
|
|
|
|
- this.typeList.forEach((v) => {
|
|
|
|
|
- if (v.type == item.type) {
|
|
|
|
|
- v.num = num
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // let num = 0;
|
|
|
|
|
+ // item.list.forEach((n) => {
|
|
|
|
|
+ // num += n.num
|
|
|
|
|
+ // })
|
|
|
|
|
+ // this.typeList.forEach((v) => {
|
|
|
|
|
+ // if (v.type == item.type) {
|
|
|
|
|
+ // v.num = num
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// -------弹窗选择规格-----------
|
|
// -------弹窗选择规格-----------
|