|
|
@@ -10,30 +10,31 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
-
|
|
|
<scroll-view :scroll-y="true" :scroll-with-animation='true' :scroll-into-view="idMark" @scroll="menuScroll">
|
|
|
<view class="menu-box-right">
|
|
|
<view class="menu-box-only" v-for="(item,i) in categoryData" :key="i" :id="'scroll'+ item.type">
|
|
|
<view class="mb-32 fs-30">{{item.name}}</view>
|
|
|
<view class="menu-list flex-justify-space" v-for="(info,k) in item.list" :key="k">
|
|
|
- <image class="flex-shrink0" :src="info.goods_image" mode="scaleToFill"></image>
|
|
|
+ <image class="flex-shrink0 goods_img" :src="info.goods_image" mode="scaleToFill"></image>
|
|
|
<view class="menu-list-right">
|
|
|
<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="">
|
|
|
<span class="fs-24 fw-400 fc-FB3D03">¥</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>
|
|
|
+ <span
|
|
|
+ class="fs-40 fw-b fc-FB3D03">{{info.seckill_money>0?info.seckill_money:info.price}}</span>
|
|
|
+ <view class="">
|
|
|
+ <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_type == 1">
|
|
|
- <view v-show="info.num > 0"
|
|
|
- class="right-only-right-red fw-500 text-align-center fs-36 fc-f"
|
|
|
- @click="addred(1,i,k,info)">-</view>
|
|
|
+ <image v-show="info.num > 0" class="wh-44" @click="addred(1,i,k,info)"
|
|
|
+ src="@/static/img/takeout/j.png" mode=""></image>
|
|
|
<view v-show="info.num > 0"
|
|
|
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"
|
|
|
- @click="addred(2,i,k,info)">+</view>
|
|
|
+ <image class="wh-44" src="@/static/img/takeout/add.png" @click="addred(2,i,k,info)"
|
|
|
+ mode=""></image>
|
|
|
</view>
|
|
|
<view v-else class="right-only-right text-align-center fw-600 fs-28 fc-f"
|
|
|
@click="addred(3,i,k,info)">选规格</view>
|
|
|
@@ -43,9 +44,6 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
<uni-popup ref="popupGG" type="bottom">
|
|
|
<view class="gg-box flex-index-css">
|
|
|
<view class="flex-justify-space box-border-box p-32">
|
|
|
@@ -55,27 +53,27 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="goods-info flex-justify-space mb-32 box-border-box plr-32">
|
|
|
- <image v-if="popData.goodsItem.goods_image" :src="popData.goodsItem.goods_image" mode="scaleToFill"></image>
|
|
|
+ <image v-if="popData.goodsItem.goods_image" :src="popData.goodsItem.goods_image" mode="scaleToFill">
|
|
|
+ </image>
|
|
|
<view class="flex-1">
|
|
|
- <view style="width: 446rpx;" class="fw-600 fs-34 text-overflow-ellipsis-one">{{popData.goodsItem.goods_name}}
|
|
|
+ <view style="width: 446rpx;" class="fw-600 fs-34 text-overflow-ellipsis-one">
|
|
|
+ {{popData.goodsItem.goods_name}}
|
|
|
</view>
|
|
|
<view class="fw-400 fc-9 fs-24">月销{{popData.goodsItem.sales}}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
-
|
|
|
<view class="scroll-view-css box-border-box plr-32">
|
|
|
<view class="" v-for="(item,i) in popData.spec_attr" :key="i">
|
|
|
<view class="fs-32 fw-500 fc-0 mb-32">{{item.group_name}}</view>
|
|
|
<view class="flex-wrap-wrap">
|
|
|
- <view class="spec-item text-align-center fs-28" :class="popData.spec_ids.indexOf(info.item_id)>=0?'s-item':'n-item'"
|
|
|
+ <view class="spec-item text-align-center fs-28"
|
|
|
+ :class="popData.spec_ids.indexOf(info.item_id)>=0?'s-item':'n-item'"
|
|
|
v-for="(info,k) in item.spec_items" :key="k" @click="selectSpec(info,i)">
|
|
|
{{info.spec_value}}
|
|
|
</view>
|
|
|
</view>
|
|
|
-
|
|
|
</view>
|
|
|
</view>
|
|
|
-
|
|
|
<view class="pop-buttom box-border-box plr-32">
|
|
|
<view class="flex-justify-space mb-28">
|
|
|
<view class="pop-buttom-left">
|
|
|
@@ -89,9 +87,11 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="display-flex align-items-center">
|
|
|
- <view class="right-only-right-red fw-500 text-align-center fs-36 fc-f" @click.stop="setSpecNum(1)">-</view>
|
|
|
+ <image class="wh-44" @click.stop="setSpecNum(1)" src="@/static/img/takeout/j.png" mode="">
|
|
|
+ </image>
|
|
|
<view class="right-only-right-2 text-align-center fs-28 fw-400">{{popData.num}}</view>
|
|
|
- <view class="right-only-right-add fw-500 text-align-center fs-36 fc-f" @click.stop="setSpecNum(2)">+</view>
|
|
|
+ <image class="wh-44" src="@/static/img/takeout/add.png" @click.stop="setSpecNum(2)" mode="">
|
|
|
+ </image>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="pop-buttom-2 text-align-center fs-32 fw-600 fc-f" @click="addred(4)">选好了</view>
|
|
|
@@ -103,199 +103,209 @@
|
|
|
|
|
|
<script>
|
|
|
import tools from "@/service/tools";
|
|
|
- import {shopCategory, shopGoods, shopGoodsSpec} from "@/api/shop";
|
|
|
- import {getShopIngList, setShopIngAdd, setShopIngDel, setShopIngNumber} from "@/api/shopping";
|
|
|
+ import {
|
|
|
+ shopCategory,
|
|
|
+ shopGoods,
|
|
|
+ shopGoodsSpec
|
|
|
+ } from "@/api/shop";
|
|
|
+ import {
|
|
|
+ getShopIngList,
|
|
|
+ setShopIngAdd,
|
|
|
+ setShopIngDel,
|
|
|
+ setShopIngNumber
|
|
|
+ } from "@/api/shopping";
|
|
|
export default {
|
|
|
name: 'menu-box',
|
|
|
- props:{
|
|
|
- 'shop_id':{
|
|
|
- default:0
|
|
|
- }
|
|
|
- },
|
|
|
+ props: {
|
|
|
+ 'shop_id': {
|
|
|
+ default: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
idMark: '', //滚动自适应参数
|
|
|
-
|
|
|
type: 1, //分类标识
|
|
|
typeList: [],
|
|
|
- categoryData: [],
|
|
|
-
|
|
|
+ categoryData: [],
|
|
|
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:[],
|
|
|
- },
|
|
|
- isAjax:false,
|
|
|
- operate_id: '',
|
|
|
-
|
|
|
+ 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: [],
|
|
|
+ },
|
|
|
+ isAjax: false,
|
|
|
+ operate_id: '',
|
|
|
popData: {
|
|
|
goodsItem: {},
|
|
|
- price: '0.00',
|
|
|
- line_price: '',
|
|
|
- num: 0,
|
|
|
+ price: '0.00',
|
|
|
+ line_price: '',
|
|
|
+ num: 0,
|
|
|
goods_id: '',
|
|
|
- spec_key: '',
|
|
|
- goods_spec_id: '',
|
|
|
+ spec_key: '',
|
|
|
+ goods_spec_id: '',
|
|
|
spec_name: [],
|
|
|
spec_ids: [],
|
|
|
- spec_list: [],
|
|
|
- spec_attr: [],
|
|
|
-
|
|
|
+ spec_list: [],
|
|
|
+ spec_attr: [],
|
|
|
},
|
|
|
}
|
|
|
},
|
|
|
- watch:{
|
|
|
- 'shop_id':function () {
|
|
|
- this.getShopGoods();
|
|
|
- }
|
|
|
- },
|
|
|
+ watch: {
|
|
|
+ 'shop_id': function() {
|
|
|
+ this.getShopGoods();
|
|
|
+ }
|
|
|
+ },
|
|
|
mounted() {
|
|
|
- this.operate_id = uni.getStorageSync('operate_id')
|
|
|
+ this.operate_id = uni.getStorageSync('operate_id')
|
|
|
this.getShopGoods();
|
|
|
this.getShopIngList(true);
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
- setSpecNum(type){
|
|
|
- console.log(this.popData.goods_spec_id)
|
|
|
- if(!this.popData.goods_spec_id){
|
|
|
- tools.error('请选择规格')
|
|
|
- return;
|
|
|
- }
|
|
|
- if(this.isAjax){
|
|
|
- return
|
|
|
- }
|
|
|
- this.isAjax=true
|
|
|
- if (type === 1) {
|
|
|
- // 减
|
|
|
- if(this.popData.num>0){
|
|
|
- --this.popData.num;
|
|
|
- }else {
|
|
|
- this.isAjax=false
|
|
|
- return
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 加
|
|
|
- ++this.popData.num;
|
|
|
- }
|
|
|
- let cartKey=this.cartData.goods_list.findIndex(row=>this.popData.goods_spec_id===row.goods_spec_id)
|
|
|
- console.log(cartKey)
|
|
|
- console.log(type===2 && cartKey<0)
|
|
|
- if(type===2 && cartKey<0){
|
|
|
- this.setShopIngAdd(this.popData.goods_id,this.popData.goodsItem.category_id,this.popData.goods_spec_id)
|
|
|
- }else {
|
|
|
- this.setShopIngNumber(this.popData.goods_id,this.popData.goodsItem.category_id,type,this.popData.goods_spec_id)
|
|
|
- }
|
|
|
- },
|
|
|
- getShopGoodsSpec(item){
|
|
|
- shopGoodsSpec({
|
|
|
- 'goods_id':item.goods_id
|
|
|
- }).then(res=>{
|
|
|
- this.popData.goodsItem=item
|
|
|
- if(this.popData.goods_id!==item.goods_id){
|
|
|
- this.popData.goods_id=item.goods_id
|
|
|
- this.popData.spec_name=[]
|
|
|
- this.popData.price='0.00'
|
|
|
- this.popData.line_price=''
|
|
|
- this.popData.spec_key=''
|
|
|
- this.popData.num=0
|
|
|
- this.popData.spec_ids=[]
|
|
|
- }
|
|
|
- this.popData.spec_list=res.data.spec_list
|
|
|
- this.popData.spec_attr=res.data.spec_attr
|
|
|
- this.$refs.popupGG.open();
|
|
|
- this.setGoodsSpecPrice()
|
|
|
- this.isAjax=false
|
|
|
- }).catch(()=>{
|
|
|
- tools.error('规格信息异常')
|
|
|
- this.isAjax=false
|
|
|
- })
|
|
|
- },
|
|
|
- setGoodsSpecPrice(){
|
|
|
- if(this.popData.spec_ids.length>0){
|
|
|
- let spec_ids=JSON.parse(JSON.stringify(this.popData.spec_ids))
|
|
|
- spec_ids.sort((a, b) => a - b);
|
|
|
- let spec_key=spec_ids.join('_')
|
|
|
- this.popData.spec_key=spec_key
|
|
|
- console.log(this.popData.spec_list[spec_key])
|
|
|
- if(this.popData.spec_list[spec_key]!==undefined){
|
|
|
- this.popData.price=this.popData.spec_list[spec_key].seckill_money>0?this.popData.spec_list[spec_key].seckill_money:this.popData.spec_list[spec_key].price
|
|
|
- this.popData.line_price=this.popData.spec_list[spec_key].line_price
|
|
|
- this.popData.goods_spec_id=this.popData.spec_list[spec_key].goods_spec_id+''
|
|
|
- let cartKey=this.cartData.goods_list.findIndex(row=>this.popData.goods_spec_id===row.goods_spec_id)
|
|
|
- if(cartKey>=0){
|
|
|
- this.popData.num=this.cartData.goods_list[cartKey].goods_number
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- setShopIngList(cartData){
|
|
|
- this.cartData=cartData
|
|
|
- this.setGoodsNum()
|
|
|
- },
|
|
|
- getShopIngList(isStart){
|
|
|
- getShopIngList({
|
|
|
- 'shop_id':this.shop_id,
|
|
|
- }).then(res=>{
|
|
|
- if(res.code===1){
|
|
|
- this.cartData=res.data
|
|
|
- this.$emit('setCartData',this.cartData)
|
|
|
- if(isStart) this.setGoodsNum()
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- setGoodsNum(){
|
|
|
- if(this.cartData.goods_list.length>0){
|
|
|
- this.cartData.goods_list.forEach(item=>{
|
|
|
- this.categoryData.forEach(categoryItem=>{
|
|
|
- if(categoryItem.type===item.category_id){
|
|
|
- categoryItem.list.forEach(goodsItem=>{
|
|
|
- console.log(item.goods_id,goodsItem.goods_id)
|
|
|
- if(item.goods_id===goodsItem.goods_id){
|
|
|
- goodsItem.num=item.goods_number*1
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
- })
|
|
|
- }else {
|
|
|
- //购物车数据清除
|
|
|
- this.categoryData.forEach(categoryItem=>{
|
|
|
- categoryItem.list.forEach(goodsItem=>{
|
|
|
- goodsItem.num=0
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- 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)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
+ setSpecNum(type) {
|
|
|
+ console.log(this.popData.goods_spec_id)
|
|
|
+ if (!this.popData.goods_spec_id) {
|
|
|
+ tools.error('请选择规格')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.isAjax) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.isAjax = true
|
|
|
+ if (type === 1) {
|
|
|
+ // 减
|
|
|
+ if (this.popData.num > 0) {
|
|
|
+ --this.popData.num;
|
|
|
+ } else {
|
|
|
+ this.isAjax = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 加
|
|
|
+ ++this.popData.num;
|
|
|
+ }
|
|
|
+ let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id === row.goods_spec_id)
|
|
|
+ console.log(cartKey)
|
|
|
+ console.log(type === 2 && cartKey < 0)
|
|
|
+ if (type === 2 && cartKey < 0) {
|
|
|
+ this.setShopIngAdd(this.popData.goods_id, this.popData.goodsItem.category_id, this.popData
|
|
|
+ .goods_spec_id)
|
|
|
+ } else {
|
|
|
+ this.setShopIngNumber(this.popData.goods_id, this.popData.goodsItem.category_id, type, this.popData
|
|
|
+ .goods_spec_id)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getShopGoodsSpec(item) {
|
|
|
+ shopGoodsSpec({
|
|
|
+ 'goods_id': item.goods_id
|
|
|
+ }).then(res => {
|
|
|
+ this.popData.goodsItem = item
|
|
|
+ if (this.popData.goods_id !== item.goods_id) {
|
|
|
+ this.popData.goods_id = item.goods_id
|
|
|
+ this.popData.spec_name = []
|
|
|
+ this.popData.price = '0.00'
|
|
|
+ this.popData.line_price = ''
|
|
|
+ this.popData.spec_key = ''
|
|
|
+ this.popData.num = 0
|
|
|
+ this.popData.spec_ids = []
|
|
|
+ }
|
|
|
+ this.popData.spec_list = res.data.spec_list
|
|
|
+ this.popData.spec_attr = res.data.spec_attr
|
|
|
+ this.$refs.popupGG.open();
|
|
|
+ this.setGoodsSpecPrice()
|
|
|
+ this.isAjax = false
|
|
|
+ }).catch(() => {
|
|
|
+ tools.error('规格信息异常')
|
|
|
+ this.isAjax = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setGoodsSpecPrice() {
|
|
|
+ if (this.popData.spec_ids.length > 0) {
|
|
|
+ let spec_ids = JSON.parse(JSON.stringify(this.popData.spec_ids))
|
|
|
+ spec_ids.sort((a, b) => a - b);
|
|
|
+ let spec_key = spec_ids.join('_')
|
|
|
+ this.popData.spec_key = spec_key
|
|
|
+ console.log(this.popData.spec_list[spec_key])
|
|
|
+ if (this.popData.spec_list[spec_key] !== undefined) {
|
|
|
+ this.popData.price = this.popData.spec_list[spec_key].seckill_money > 0 ? this.popData.spec_list[
|
|
|
+ spec_key].seckill_money : this.popData.spec_list[spec_key].price
|
|
|
+ this.popData.line_price = this.popData.spec_list[spec_key].line_price
|
|
|
+ this.popData.goods_spec_id = this.popData.spec_list[spec_key].goods_spec_id + ''
|
|
|
+ let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id === row
|
|
|
+ .goods_spec_id)
|
|
|
+ if (cartKey >= 0) {
|
|
|
+ this.popData.num = this.cartData.goods_list[cartKey].goods_number
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setShopIngList(cartData) {
|
|
|
+ this.cartData = cartData
|
|
|
+ this.setGoodsNum()
|
|
|
+ },
|
|
|
+ getShopIngList(isStart) {
|
|
|
+ getShopIngList({
|
|
|
+ 'shop_id': this.shop_id,
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === 1) {
|
|
|
+ this.cartData = res.data
|
|
|
+ this.$emit('setCartData', this.cartData)
|
|
|
+ if (isStart) this.setGoodsNum()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setGoodsNum() {
|
|
|
+ if (this.cartData.goods_list.length > 0) {
|
|
|
+ this.cartData.goods_list.forEach(item => {
|
|
|
+ this.categoryData.forEach(categoryItem => {
|
|
|
+ if (categoryItem.type === item.category_id) {
|
|
|
+ categoryItem.list.forEach(goodsItem => {
|
|
|
+ console.log(item.goods_id, goodsItem.goods_id)
|
|
|
+ if (item.goods_id === goodsItem.goods_id) {
|
|
|
+ goodsItem.num = item.goods_number * 1
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ //购物车数据清除
|
|
|
+ this.categoryData.forEach(categoryItem => {
|
|
|
+ categoryItem.list.forEach(goodsItem => {
|
|
|
+ goodsItem.num = 0
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 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) {
|
|
|
if (this.type != item.type) {
|
|
|
this.type = item.type;
|
|
|
@@ -316,112 +326,108 @@
|
|
|
}).exec();
|
|
|
},
|
|
|
addred(type, i, k, item) {
|
|
|
- if(this.isAjax){
|
|
|
- return
|
|
|
- }
|
|
|
- this.isAjax=true
|
|
|
+ if (this.isAjax) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.isAjax = true
|
|
|
if (type === 1) {
|
|
|
// 减
|
|
|
- if(item.num>0){
|
|
|
- --item.num;
|
|
|
- this.setSub(item,type);
|
|
|
- }else {
|
|
|
- this.isAjax=false
|
|
|
- }
|
|
|
-
|
|
|
+ if (item.num > 0) {
|
|
|
+ --item.num;
|
|
|
+ this.setSub(item, type);
|
|
|
+ } else {
|
|
|
+ this.isAjax = false
|
|
|
+ }
|
|
|
} else if (type === 2) {
|
|
|
// 加
|
|
|
- if(item.is_infinite===1 || item.stock>item.num){
|
|
|
- ++item.num;
|
|
|
- this.setSub(item,type);
|
|
|
- }else {
|
|
|
- this.isAjax=false
|
|
|
- }
|
|
|
+ if (item.is_infinite === 1 || item.stock > item.num) {
|
|
|
+ ++item.num;
|
|
|
+ this.setSub(item, type);
|
|
|
+ } else {
|
|
|
+ this.isAjax = false
|
|
|
+ }
|
|
|
// this.menuList[i].list[k].num += 1;
|
|
|
// this.setSub(item);
|
|
|
} else if (type === 3) {
|
|
|
// 选规格
|
|
|
- this.getShopGoodsSpec(item)
|
|
|
+ this.getShopGoodsSpec(item)
|
|
|
} else {
|
|
|
this.$refs.popupGG.close();
|
|
|
- this.isAjax=false
|
|
|
+ this.isAjax = false
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
- setSub(item,type) {
|
|
|
- let cartKey=this.cartData.goods_list.findIndex(row=>row.goods_id===item.goods_id)
|
|
|
- if(type===2 && cartKey<0){
|
|
|
- this.setShopIngAdd(item.goods_id,item.category_id,'')
|
|
|
- }else {
|
|
|
- this.setShopIngNumber(item.goods_id,item.category_id,type,'')
|
|
|
- }
|
|
|
-
|
|
|
+ setSub(item, type) {
|
|
|
+ let cartKey = this.cartData.goods_list.findIndex(row => row.goods_id === item.goods_id)
|
|
|
+ if (type === 2 && cartKey < 0) {
|
|
|
+ this.setShopIngAdd(item.goods_id, item.category_id, '')
|
|
|
+ } else {
|
|
|
+ this.setShopIngNumber(item.goods_id, item.category_id, type, '')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setShopIngAdd(goodsId, categoryId, goodsSpecId) {
|
|
|
+ setShopIngAdd({
|
|
|
+ 'type': 1,
|
|
|
+ 'goods_id': goodsId,
|
|
|
+ 'shop_id': this.shop_id,
|
|
|
+ 'category_id': categoryId,
|
|
|
+ 'goods_spec_id': goodsSpecId,
|
|
|
+ }).then(res => {
|
|
|
+ this.isAjax = false
|
|
|
+ this.getShopIngList()
|
|
|
+ }).catch(() => {
|
|
|
+ this.isAjax = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setShopIngNumber(goodsId, categoryId, operation, goodsSpecId) {
|
|
|
+ setShopIngNumber({
|
|
|
+ 'type': 1,
|
|
|
+ 'goods_id': goodsId,
|
|
|
+ 'shop_id': this.shop_id,
|
|
|
+ 'category_id': categoryId,
|
|
|
+ 'goods_spec_id': goodsSpecId,
|
|
|
+ 'operation': operation === 2 ? 1 : 2,
|
|
|
+ }).then(res => {
|
|
|
+ this.isAjax = false
|
|
|
+ this.getShopIngList()
|
|
|
+ }).catch(() => {
|
|
|
+ this.isAjax = false
|
|
|
+ })
|
|
|
},
|
|
|
- setShopIngAdd(goodsId,categoryId,goodsSpecId){
|
|
|
- setShopIngAdd({
|
|
|
- 'type':1,
|
|
|
- 'goods_id':goodsId,
|
|
|
- 'shop_id':this.shop_id,
|
|
|
- 'category_id':categoryId,
|
|
|
- 'goods_spec_id':goodsSpecId,
|
|
|
- }).then(res=>{
|
|
|
- this.isAjax=false
|
|
|
- this.getShopIngList()
|
|
|
- }).catch(()=>{
|
|
|
- this.isAjax=false
|
|
|
- })
|
|
|
- },
|
|
|
- setShopIngNumber(goodsId,categoryId,operation,goodsSpecId){
|
|
|
- setShopIngNumber({
|
|
|
- 'type':1,
|
|
|
- 'goods_id':goodsId,
|
|
|
- 'shop_id':this.shop_id,
|
|
|
- 'category_id':categoryId,
|
|
|
- 'goods_spec_id':goodsSpecId,
|
|
|
- 'operation':operation===2?1:2,
|
|
|
- }).then(res=>{
|
|
|
- this.isAjax=false
|
|
|
- this.getShopIngList()
|
|
|
- }).catch(()=>{
|
|
|
- this.isAjax=false
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
- setShopIngDel(){
|
|
|
-
|
|
|
- },
|
|
|
|
|
|
+ setShopIngDel() {},
|
|
|
// -------弹窗选择规格-----------
|
|
|
- selectSpec( info,groupKey) {
|
|
|
- let specKey=this.popData.spec_ids.indexOf(info.item_id)
|
|
|
- if(specKey>=0){
|
|
|
- this.popData.spec_ids.splice(specKey,1)
|
|
|
- this.popData.spec_name.splice(specKey,1)
|
|
|
- }else {
|
|
|
- this.popData.spec_ids.push(info.item_id)
|
|
|
- this.popData.spec_name.push(info.spec_value)
|
|
|
- for (const attrKey in this.popData.spec_attr[groupKey].spec_items) {
|
|
|
- if(this.popData.spec_attr[groupKey].spec_items[attrKey].item_id!==info.item_id){
|
|
|
- let oldKey=this.popData.spec_ids.indexOf(this.popData.spec_attr[groupKey].spec_items[attrKey].item_id)
|
|
|
- if(oldKey>=0){
|
|
|
- this.popData.spec_ids.splice(oldKey,1)
|
|
|
- this.popData.spec_name.splice(oldKey,1)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ selectSpec(info, groupKey) {
|
|
|
+ let specKey = this.popData.spec_ids.indexOf(info.item_id)
|
|
|
+ if (specKey >= 0) {
|
|
|
+ this.popData.spec_ids.splice(specKey, 1)
|
|
|
+ this.popData.spec_name.splice(specKey, 1)
|
|
|
+ } else {
|
|
|
+ this.popData.spec_ids.push(info.item_id)
|
|
|
+ this.popData.spec_name.push(info.spec_value)
|
|
|
+ for (const attrKey in this.popData.spec_attr[groupKey].spec_items) {
|
|
|
+ if (this.popData.spec_attr[groupKey].spec_items[attrKey].item_id !== info.item_id) {
|
|
|
+ let oldKey = this.popData.spec_ids.indexOf(this.popData.spec_attr[groupKey].spec_items[attrKey]
|
|
|
+ .item_id)
|
|
|
+ if (oldKey >= 0) {
|
|
|
+ this.popData.spec_ids.splice(oldKey, 1)
|
|
|
+ this.popData.spec_name.splice(oldKey, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// this.spec_ids = this.popData.spec_list.join('_')
|
|
|
- this.setGoodsSpecPrice()
|
|
|
-
|
|
|
+ this.setGoodsSpecPrice()
|
|
|
},
|
|
|
},
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
+ .wh-44 {
|
|
|
+ width: 44rpx;
|
|
|
+ height: 44rpx;
|
|
|
+ }
|
|
|
+
|
|
|
.menu-box {
|
|
|
height: 100%;
|
|
|
|
|
|
@@ -461,7 +467,7 @@
|
|
|
// flex: 1;
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
- padding: 16rpx;
|
|
|
+ padding: 16rpx 12rpx 16rpx 16rpx;
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
.menu-list {
|
|
|
@@ -469,7 +475,7 @@
|
|
|
// height: 200rpx;
|
|
|
margin-bottom: 40rpx;
|
|
|
|
|
|
- image {
|
|
|
+ .goods_img {
|
|
|
width: 200rpx;
|
|
|
height: 200rpx;
|
|
|
border-radius: 12rpx;
|
|
|
@@ -593,7 +599,8 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- .goods-name{
|
|
|
+
|
|
|
+ .goods-name {
|
|
|
max-width: 310rpx;
|
|
|
}
|
|
|
</style>
|