| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- <template>
- <view class="menu-box display-flex">
- <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 fs-26 box-border-box align-items-center flex-justify-center"
- 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">
- {{item.name}}
- <view class="menu-type-num fc-f" v-show="item.num > 0">{{item.num > 99?'99+':item.num}}</view>
- </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-32">{{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>
- <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>
- </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>
- <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>
- </view>
- <view v-else class="right-only-right text-align-center fw-600 fs-28 fc-f"
- @click="addred(3,i,k,info)">选规格</view>
- </view>
- </view>
- </view>
- </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">
- <view class="fs-32 fw-500 fc-0">商品详情规格</view>
- <view class="" @click="addred(4)">
- <uni-icons type="closeempty" size="20"></uni-icons>
- </view>
- </view>
- <view class="goods-info flex-justify-space mb-32 box-border-box plr-32">
- <image src="@/static/img/my/bg.png" mode="scaleToFill"></image>
- <view class="flex-1">
- <view style="width: 446rpx;" class="fw-600 fs-34 text-overflow-ellipsis-one">[畅销款]奥尔1良烤肉牛油拌饭
- </view>
- <view class="fw-400 fc-9 fs-24">月销196</view>
- </view>
- </view>
- <view class="scroll-view-css box-border-box plr-32">
- <view class="" v-for="(item,i) in popData.specList" :key="i">
- <view class="fs-32 fw-500 fc-0 mb-32">{{item.specName}}</view>
- <view class="flex-wrap-wrap">
- <view class="spec-item text-align-center fs-28" :class="info.isSelect?'s-item':'n-item'"
- v-for="(info,k) in item.list" :key="k" @click="select(i,k,item,info)">
- {{info.name}}
- </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">
- <view class="">
- <span class="fw-600 fs-32 fc-ED301D">¥</span>
- <span class="fw-600 fs-48 fc-ED301D">19.26</span>
- </view>
- <view class="">
- <span class="fw-400 fs-24 fc-9">已选规格:</span>
- <span class="fw-400 fs-24">不辣</span>
- </view>
- </view>
- <view class="display-flex align-items-center">
- <view class="right-only-right-red fw-500 text-align-center fs-36 fc-f">-</view>
- <view class="right-only-right-2 text-align-center fs-28 fw-400">1</view>
- <view class="right-only-right-add fw-500 text-align-center fs-36 fc-f">+</view>
- </view>
- </view>
- <view class="pop-buttom-2 text-align-center fs-32 fw-600 fc-f">选好了</view>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import tools from "@/service/tools";
- import {shopCategory, shopGoods} from "@/api/shop";
- import {getShopIngList} from "@/api/shopping";
- export default {
- name: 'menu-box',
- props:{
- 'shop_id':{
- default:0
- }
- },
- data() {
- return {
- idMark: '', //滚动自适应参数
- type: 1, //分类标识
- typeList: [],
- 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:0,
- },
- operate_id: '',
- popData: {
- spec_name: '',
- spec_ids: '',
- spec_list: [],
- specList: [{
- specName: '口味',
- specType: 1,
- list: [{
- name: '辣1',
- id: 1,
- isSelect: false
- }, {
- name: '辣2',
- id: 2,
- isSelect: false
- }, {
- name: '辣3',
- id: 3,
- isSelect: false
- }, {
- name: '辣4',
- id: 4,
- isSelect: false
- }, ]
- },
- {
- specName: '大小',
- specType: 2,
- list: [{
- name: '大1',
- id: 5,
- isSelect: false
- }, {
- name: '大2',
- id: 6,
- isSelect: false
- }, {
- name: '大3',
- id: 7,
- isSelect: false
- }, {
- name: '大4',
- id: 8,
- isSelect: false
- }, ]
- },
- {
- specName: '加料',
- specType: 3,
- list: [{
- name: '加1',
- id: 9,
- isSelect: false
- }, {
- name: '加2',
- id: 10,
- isSelect: false
- }, {
- name: '加3',
- id: 11,
- isSelect: false
- }, {
- name: '加4',
- id: 12,
- isSelect: false
- }, ]
- },
- ]
- },
- }
- },
- watch:{
- 'shop_id':function () {
- this.getShopGoods();
- }
- },
- mounted() {
- this.operate_id = uni.getStorageSync('operate_id')
- this.getShopGoods();
- },
- methods: {
- 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) {
- if (this.type != item.type) {
- this.type = item.type;
- this.idMark = 'scroll' + item.type
- }
- },
- menuScroll() {
- let _this = this;
- let query = uni.createSelectorQuery().in(this);
- query.selectAll(".menu-box-only").boundingClientRect(data => {
- data.forEach((v) => {
- if (v.top < 329 && v.top > 0) {
- _this.idMark = v.id;
- let arr = v.id.split('scroll');
- _this.type = Number(arr[1]);
- }
- })
- }).exec();
- },
- addred(type, i, k, item) {
- console.log(item,type)
- if (type === 1) {
- // 减
- if(item.num>0){
- --item.num;
- // this.menuList[i].list[k].num -= 1;
- this.setSub(item);
- }
- } else if (type === 2) {
- // 加
- 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) {
- // 选规格
- this.$refs.popupGG.open();
- } else {
- this.$refs.popupGG.close();
- }
- },
- setSub(item) {
- // let num = 0;
- // item.list.forEach((n) => {
- // num += n.num
- // })
- // this.typeList.forEach((v) => {
- // if (v.type == item.type) {
- // v.num = num
- // }
- // })
- },
- // -------弹窗选择规格-----------
- select(i, k, item, info) {
- if (!info.isSelect) {
- item.list.forEach((v) => {
- v.isSelect = false;
- })
- info.isSelect = true;
- item.list.forEach(v => {
- this.popData.spec_list.forEach((n, i) => {
- if (v.id == n) {
- this.popData.spec_list.splice(i, 1)
- }
- })
- })
- this.popData.spec_list.push(info.id);
- } else {
- info.isSelect = false;
- let index = this.popData.spec_list.indexOf(info.id)
- this.popData.spec_list.splice(index, 1)
- }
- this.spec_ids = this.popData.spec_list.join('_')
- },
- },
- }
- </script>
- <style scoped lang="scss">
- .menu-box {
- height: 100%;
- .menu-box-left {
- width: 160rpx;
- height: 100%;
- background-color: #F7F8FA;
- // border-radius: 0rpx 20rpx 0 0rpx;
- .menu-type-list-f {
- width: 160rpx;
- height: 100%;
- .menu-type-list {
- width: 160rpx;
- min-height: 108rpx;
- padding: 18rpx 28rpx;
- position: relative;
- .menu-type-num {
- position: absolute;
- top: 2rpx;
- right: 8rpx;
- padding: 0 6rpx;
- min-width: 20rpx;
- height: 32rpx;
- text-align: center;
- line-height: 32rpx;
- background: #FB3D03;
- border-radius: 50%;
- }
- }
- }
- }
- .menu-box-right {
- // flex: 1;
- width: 100%;
- height: 100%;
- padding: 16rpx;
- box-sizing: border-box;
- .menu-list {
- width: 100%;
- // height: 200rpx;
- margin-bottom: 40rpx;
- image {
- width: 200rpx;
- height: 200rpx;
- border-radius: 12rpx;
- margin-right: 16rpx;
- }
- .menu-list-right {
- flex: 1;
- .right-only-right {
- width: 100rpx;
- height: 44rpx;
- background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
- border-radius: 12rpx;
- line-height: 44rpx;
- }
- .right-only-right-red {
- width: 44rpx;
- height: 44rpx;
- line-height: 40rpx;
- border-radius: 12rpx;
- border: 1rpx solid #41ABF5;
- color: #41ABF5;
- }
- .right-only-right-add {
- width: 44rpx;
- height: 44rpx;
- line-height: 40rpx;
- background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
- border-radius: 12rpx;
- }
- .right-only-right-2 {
- min-width: 50rpx;
- }
- }
- }
- }
- .gg-box {
- width: 750rpx;
- height: 1208rpx;
- background: #FFFFFF;
- border-radius: 24rpx 24rpx 0rpx 0rpx;
- .goods-info {
- border-bottom: 1rpx solid #EEEEEE;
- image {
- width: 170rpx;
- height: 160rpx;
- border-radius: 8rpx;
- margin-right: 22rpx;
- margin-bottom: 32rpx;
- }
- }
- .pop-buttom {
- width: 100%;
- height: 250rpx;
- box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(51, 51, 51, 0.1);
- .pop-buttom-left {
- padding-top: 12rpx;
- }
- .pop-buttom-2 {
- width: 100%;
- height: 96rpx;
- line-height: 96rpx;
- background: #41ABF5;
- border-radius: 200rpx
- }
- .right-only-right-red {
- width: 44rpx;
- height: 44rpx;
- line-height: 40rpx;
- border-radius: 12rpx;
- border: 1rpx solid #41ABF5;
- color: #41ABF5;
- }
- .right-only-right-add {
- width: 44rpx;
- height: 44rpx;
- line-height: 40rpx;
- background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
- border-radius: 12rpx;
- }
- .right-only-right-2 {
- min-width: 50rpx;
- }
- }
- .spec-item {
- width: 210rpx;
- height: 66rpx;
- line-height: 66rpx;
- box-sizing: border-box;
- border-radius: 12rpx;
- margin: 0 26rpx 26rpx 0;
- }
- .spec-item:nth-child(3) {
- margin-right: 0rpx !important;
- }
- .s-item {
- background-color: #ECF7FE;
- border: 2rpx solid #41ABF5;
- color: #41ABF5;
- }
- .n-item {
- border: 2rpx solid #EEEEEE;
- color: #000;
- }
- }
- }
- .goods-name{
- max-width: 310rpx;
- }
- </style>
|