new-shop.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  1. <template>
  2. <view class="shop-index iPhone-bottom flex-direction box-border-box">
  3. <image v-show="!navBgType" class="bg-img" src="@/static/img/order-food/shop-top.png" mode="aspectFill"
  4. :class="scrollTop > newNavHeight?'z-4':'z-3'"></image>
  5. <image v-show="navBgType" class="bg-img-type z-4" src="@/static/img/order-food/shop-top.png" mode="aspectFill"
  6. :style="{height:newNavHeight+'rpx',opacity:opacity}"></image>
  7. <newNav :leftShow="false" :textType='false' class="z-4 mb-32" @navHeight='navHeight'>
  8. <view slot="textContentSlot" class="align-items-center flex-justify-end">
  9. <view class="ss-box b-rad-50 mr-24 align-items-center flex-justify-center z-4" @click.stop="goSearch">
  10. <image class="shop-search" src="@/static/img/order-food/shop-search.png" mode=""></image>
  11. </view>
  12. <view class="dd-box align-items-center flex-justify-center b-rad-200 mr-24 z-4" @click="goToOrder">
  13. <image class="shp-list-img mr-8" src="@/static/img/order-food/shp-list.png" mode=""></image>
  14. <view class="fs-28 fc-f">
  15. 订单
  16. </view>
  17. </view>
  18. </view>
  19. </newNav>
  20. <view class="bgc-f box-border-box plr-32 mb-32 shop-info">
  21. <view class="shop-info-box bgc-f box-border-box p-24 z-3 b-rad-20">
  22. <view class="fs-40 fw-600 text-overflow-ellipsis">
  23. {{shopsInfo.shop_name}}
  24. </view>
  25. <view class="fs-24 fw-400 fc-9 text-overflow-ellipsis-one pt-15" v-if="shopsInfo.notice">
  26. 公告:{{shopsInfo.notice || '暂无公告'}}
  27. </view>
  28. </view>
  29. </view>
  30. <view class="b-b-eee bgc-f box-border-box p-0-32-12 align-items-center flex-justify-space z-3 shop-type-box">
  31. <view class="align-items-center shop-type-list">
  32. <view class="shop-item fs-36 mb-8 mr-64" @click="seletShopType(item)"
  33. :class="shopType === item.id?'fc-3 fw-600':'fc-6'" v-for="(item,i) in shopTypeList" :key="i">
  34. {{item.name}}
  35. </view>
  36. <view class="shop-item-bs bgc-FF3333" :style="{left:shopTypeBsLeft+'rpx'}"></view>
  37. </view>
  38. <view class="align-items-center">
  39. <image class="zh-icon mr-8" src="@/static/img/order-food/zh-icon.png" mode="aspectFill"></image>
  40. <view class="fw-600 fs-32 fc-3">
  41. 桌号:{{table_number}}
  42. </view>
  43. </view>
  44. </view>
  45. <!-- <view class="bgc-f sticky-nav" :style="{ height: navBgType?`calc(100vh - ${newNavHeight}rpx - ${48}rpx)`:'auto'}"> -->
  46. <view class="bgc-F7F8FA">
  47. <view class="menu-box box-border-box align-items-flex-start" v-if="shopType === 1">
  48. <view class="menu-box-left" :style="{top: newNavHeight + 'rpx'}">
  49. <view class="menu-box-left-box pb-130 box-border-box"
  50. :style="{height: menuLeftType?`calc(100vh - ${newNavHeight}rpx - ${68}rpx)`:''}">
  51. <view class="menu-type-list fs-26 box-border-box align-items-center flex-justify-center"
  52. v-for="(item,i) in categoryList" :key="i" @click="selectType(item)"
  53. :class="type === item.category_id?'bgc-f fc-3 fw-600':'fc-6 fw-400'"
  54. :id="'left-scroll'+ item.category_id">
  55. {{item.name}}
  56. <view class="menu-type-num fc-f" v-show="item.num > 0">{{item.num > 99?'99+':item.num}}
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="menu-box-only bgc-f pb-130 box-border-box">
  62. <view class="" v-for="(item,i) in goodsList" :key="i" :id="'scroll'+ item.type">
  63. <view class="fs-28 fw-600 fc-3 sticky-nav bgc-f p-20 box-border-box"
  64. :style="{top: newNavHeight + 'rpx'}">
  65. {{item.name}}
  66. </view>
  67. <view class="menu-list flex-justify-space box-border-box" v-for="(info,k) in item.list" :key="k"
  68. :id="'goods_id'+ info.goods_id">
  69. <image class="flex-shrink0 goods_img" :src="info.goods_image" mode="scaleToFill"></image>
  70. <view class="menu-list-right flex-direction flex-justify-space">
  71. <view class="mb-8">
  72. <view class="mb-4 goods-name text-overflow-ellipsis fs-32 fw-600">
  73. {{info.goods_name}}
  74. </view>
  75. <view class="text-overflow-ellipsis-one fw-400 fc-9 fs-24 mb-2 goods-name"
  76. v-if="info.spec_type == 1">
  77. {{info.goods_desc?info.goods_desc:''}}
  78. </view>
  79. </view>
  80. <view class="flex-justify-space align-items-flex-end">
  81. <view class="">
  82. <span class="fs-24 fw-400 fc-FB3D03">¥</span>
  83. <span
  84. class="fs-40 fw-b fc-FB3D03">{{info.seckill_money>0?info.seckill_money:info.price}}</span>
  85. </view>
  86. <view class="display-flex align-items-center" v-if="info.spec_type == 1">
  87. <image v-show="info.num > 0" class="wh-44" @click="addred(1,info)"
  88. src="@/static/img/order-food/reduce-img.png" mode=""></image>
  89. <view v-show="info.num > 0"
  90. class="right-only-right-2 text-align-center fs-28 fw-400">{{info.num}}
  91. </view>
  92. <image class="wh-44" src="@/static/img/order-food/add-img.png"
  93. @click="addred(2,info)" mode="">
  94. </image>
  95. </view>
  96. <view v-else class="right-only-right text-align-center b-rad-200"
  97. @click="addred(3,info)">
  98. <view class="fw-600 fs-28 fc-f">
  99. 选规格
  100. </view>
  101. <view class="selectedNum" v-if="info.num>0">
  102. {{info.num}}
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. <ShopInfo style="height: 100%;" v-else-if="shopType === 2"></ShopInfo>
  112. </view>
  113. <view v-if="shopType === 1" class="shop-buttom-money box-border-box" @click="openBuyCrad()">
  114. <view
  115. class="shop-buttom-money-1 bgc-f flex-justify-space align-items-center pl-24 box-border-box pr-8 b-rad-200">
  116. <view class="align-items-center">
  117. <image class="gwc-img mr-36" src="@/static/img/order-food/gwc-img.png" mode="scaleToFill"></image>
  118. <view class="shop-buttom-num bgc-FE6B2C fs-24 fc-f text-align-center">{{cartData.total_num}}</view>
  119. <view class="align-items-baseline">
  120. <view class="fw-600 fs-28 fc-3 mr-4">¥</view>
  121. <view class="fw-600 fs-48 fc-3">{{cartData.total_goods_money}}</view>
  122. </view>
  123. </view>
  124. <view class="shop-buttom-money-2 text-align-center fc-f fs-32 fw-600 b-rad-200"
  125. :class="cartData.total_num>0?'':'opacity-4'" @click.stop="toConfirmOrder()">去结算
  126. </view>
  127. </view>
  128. </view>
  129. <uni-popup ref="popupBuy" type="bottom" background-color="transparent" borderRadius='20px 20rpx 0 0'>
  130. <view class="buy-card flex-index-css">
  131. <view class="buy-card-top box-border-box plr-32 flex-justify-space align-items-center b-rad-20-20-0-0">
  132. <view class="">
  133. <span class="fs-32 fc-3 mr-12">已选商品</span>
  134. </view>
  135. <view class="fs-28 fw-400 fc-9 align-items-center" @click.stop="setShopIngDel">
  136. <view class="">
  137. <uni-icons type="trash" size="18" color="#999"></uni-icons>
  138. </view>
  139. <view class="fs-28 fw-400 fc-9">清空</view>
  140. </view>
  141. </view>
  142. <view class="scroll-view-css bgc-ECECEC box-border-box car-scroll-box">
  143. <view class="buy-card-item bgc-f b-rad-20 display-flex p-20 box-border-box"
  144. v-for="(goods,i) in cartData.goods_list" :key="i">
  145. <image class="goods_img" :src="goods.goods_image" mode="scaleToFill"></image>
  146. <view class="flex-1 flex-direction flex-justify-space">
  147. <view class="">
  148. <view class="w-514 text-overflow-ellipsis-one fs-34 fw-600 mb-8">
  149. {{goods.goods_name}}
  150. </view>
  151. <view class="fc-6">
  152. {{goods.goods_attr}}
  153. </view>
  154. </view>
  155. <view class="flex-justify-space">
  156. <view class="">
  157. <span class="fs-24 fc-FB3D03 fw-400">¥</span>
  158. <span class="fs-40 fc-FB3D03 fw-b">{{goods.price}}</span>
  159. </view>
  160. <view class="display-flex align-items-center">
  161. <image class="wh-44" @click.stop="setShoppingSave(goods,2)"
  162. src="@/static/img/order-food/reduce-img.png" mode="">
  163. </image>
  164. <view class="right-only-right-2 text-align-center fs-28 fw-400">
  165. {{goods.goods_number}}
  166. </view>
  167. <image class="wh-44" src="/static/img/order-food/add-img.png"
  168. @click.stop="setShoppingSave(goods,1)" mode=""></image>
  169. </view>
  170. </view>
  171. </view>
  172. </view>
  173. <en-blank navBackgroundColor='#ECECEC' v-if="cartData.goods_list.length<=0"
  174. message="快去选购商品吧!~"></en-blank>
  175. </view>
  176. <view class="pop-shop-buttom-money box-border-box" @click="openBuyCrad()">
  177. <view
  178. class="shop-buttom-money-1 bgc-f flex-justify-space align-items-center pl-24 box-border-box pr-8 b-rad-200">
  179. <view class="align-items-center">
  180. <image class="gwc-img mr-36" src="@/static/img/order-food/gwc-img.png" mode="scaleToFill">
  181. </image>
  182. <view class="shop-buttom-num bgc-FE6B2C fs-24 fc-f text-align-center">{{cartData.total_num}}
  183. </view>
  184. <view class="align-items-baseline">
  185. <view class="fw-600 fs-28 fc-3 mr-4">¥</view>
  186. <view class="fw-600 fs-48 fc-3">{{cartData.total_goods_money}}</view>
  187. </view>
  188. </view>
  189. <view class="shop-buttom-money-2 text-align-center fc-f fs-32 fw-600 b-rad-200"
  190. :class="cartData.total_num>0?'':'opacity-4'" @click.stop="toConfirmOrder()">去结算
  191. </view>
  192. </view>
  193. </view>
  194. </view>
  195. </uni-popup>
  196. </view>
  197. </template>
  198. <script>
  199. import newMenu from './shop-mod/new-menu.vue';
  200. import ShopInfo from './shop-mod/info.vue';
  201. import tools from "@/service/tools";
  202. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  203. import cartStore from '@/utils/cartStore.js';
  204. import {
  205. getGoodsCategory,
  206. getGoodsGoods
  207. } from '@/api/goods.js'
  208. import {
  209. receiveCoupon
  210. } from "@/api/coupon.js"
  211. import {
  212. shopInfo
  213. } from "@/api/shop.js"
  214. import {
  215. getDeliveryMoney
  216. } from "@/api/common";
  217. import {
  218. getShopIngList,
  219. setShopIngDel,
  220. shoppingSave
  221. } from "@/api/shopping";
  222. export default {
  223. components: {
  224. newMenu,
  225. ShopInfo,
  226. EnBlank
  227. },
  228. data() {
  229. return {
  230. domHeigjt: 0,
  231. shopTypeList: [{
  232. name: "点单",
  233. id: 1
  234. }, {
  235. name: "商家",
  236. id: 2
  237. }],
  238. table_number: '',
  239. shopType: 1, //组件类型
  240. shopTypeBsLeft: 12,
  241. shop_id: '',
  242. operate_id: '',
  243. shopsInfo: {},
  244. // cartData: {
  245. // total_price: 0,
  246. // total_num: 0,
  247. // total_goods_money: 0,
  248. // pack_price: 0,
  249. // must_category: 0,
  250. // is_place_order: 0,
  251. // err_msg: 0,
  252. // goods_list: [],
  253. // },
  254. isAjax: false,
  255. newNavHeight: '',
  256. navBgType: false,
  257. menuLeftType: false,
  258. scrollTop: 0,
  259. opacity: 0,
  260. heightOne: '',
  261. heightTwo: '',
  262. topHeight: '',
  263. idMark: '', //滚动自适应参数
  264. idMarkTwo: '', //滚动自适应参数
  265. type: '', //默认分类标识
  266. categoryList: [],
  267. goodsList: [],
  268. cartData: {
  269. total_price: 0,
  270. total_num: 0,
  271. pack_price: 0,
  272. total_goods_money: 0,
  273. goods_list: [],
  274. }
  275. }
  276. },
  277. onShow() {
  278. this.getShopIngList();
  279. },
  280. onLoad(e) {
  281. cartStore.setShopId();
  282. this.getshopInfo();
  283. },
  284. mounted() {},
  285. onReachBottom(e) {},
  286. // 监听页面滚动
  287. onPageScroll(e) {
  288. // e.scrollTop 获取滚动条距离页面顶部的距离
  289. this.scrollTop = e.scrollTop
  290. this.opacity = (Number(this.scrollTop) - 30)
  291. // 可以根据滚动位置执行相应逻辑
  292. if (e.scrollTop > 25) {
  293. this.navBgType = true
  294. } else {
  295. this.navBgType = false
  296. }
  297. if (e.scrollTop > (Number(this.newNavHeight) - 4)) {
  298. this.menuLeftType = true
  299. } else {
  300. this.menuLeftType = false
  301. }
  302. },
  303. methods: {
  304. shopInfo() {
  305. // 获取商家详情
  306. shopInfo().then((res) => {
  307. if (res.code === 1) {
  308. this.shopsInfo = res.data
  309. }
  310. })
  311. },
  312. getGoodsCategory() {
  313. //获取商家分类
  314. getGoodsCategory().then((res) => {
  315. if (res.code === 1) {
  316. this.categoryList = res.data
  317. this.type = res.data[0].category_id
  318. }
  319. })
  320. },
  321. getGoodsGoods() {
  322. //获取商家商品列表
  323. getGoodsGoods().then((res) => {
  324. if (res.code === 1) {
  325. // 初始化商品列表
  326. this.goodsList = res.data
  327. // 从购物车数据中回显每个商品的数量
  328. this.updateGoodsNumFromCart()
  329. }
  330. })
  331. },
  332. getShopIngList() {
  333. // 获取购物车列表
  334. const shopCart = cartStore.getShopCart(this.shop_id);
  335. if (shopCart) {
  336. this.cartData = {
  337. ...this.cartData,
  338. total_price: shopCart.total_price,
  339. total_num: shopCart.total_num,
  340. pack_price: shopCart.pack_price, //配送费总额
  341. total_goods_money: shopCart.total_goods_money, //商品价格总额
  342. goods_list: shopCart.goods_list
  343. };
  344. // 同步更新商品列表中的数量
  345. this.updateGoodsNumFromCart();
  346. }
  347. },
  348. getshopInfo() {
  349. this.table_number = uni.getStorageSync('table_number')
  350. this.shopInfo()
  351. this.getGoodsCategory()
  352. this.getGoodsGoods()
  353. },
  354. updateGoodsNumFromCart() {
  355. // 从购物车数据同步商品数量
  356. if (!this.goodsList) return;
  357. const shopCart = cartStore.getShopCart(this.shop_id);
  358. if (!shopCart) return;
  359. // 创建商品数量映射
  360. const goodsQuantityMap = {};
  361. const cartGoodsPackPriceMap = {}; // 存储商品配送费信息
  362. shopCart.goods_list.forEach(item => {
  363. if (!goodsQuantityMap[item.goods_id]) {
  364. goodsQuantityMap[item.goods_id] = 0;
  365. cartGoodsPackPriceMap[item.goods_id] = 0;
  366. }
  367. // 累加同一个商品不同规格的数量
  368. goodsQuantityMap[item.goods_id] += item.goods_number;
  369. // 累加同一个商品不同规格的配送费(按数量计算)
  370. cartGoodsPackPriceMap[item.goods_id] += parseFloat(item.pack_price || 0) * (item
  371. .goods_number || 0);
  372. });
  373. // 更新商品列表数量
  374. this.goodsList.forEach(category => {
  375. if (category.list && category.list.length > 0) {
  376. category.list.forEach(goods => {
  377. goods.num = goodsQuantityMap[goods.goods_id] || 0;
  378. });
  379. }
  380. });
  381. // 更新分类列表中的商品数量
  382. this.updateCategoryNum()
  383. },
  384. updateCategoryNum() {
  385. // 更新分类的商品总数
  386. if (!this.categoryList || !this.goodsList) {
  387. return
  388. }
  389. this.categoryList.forEach(categoryItem => {
  390. // 找到对应的商品分类
  391. const goodsCategory = this.goodsList.find(
  392. category => category.type === categoryItem.category_id
  393. )
  394. if (goodsCategory && goodsCategory.list) {
  395. // 计算该分类下所有商品的总数量
  396. const totalNum = goodsCategory.list.reduce((sum, goods) => {
  397. return sum + (goods.num || 0)
  398. }, 0)
  399. categoryItem.num = totalNum
  400. } else {
  401. categoryItem.num = 0
  402. }
  403. })
  404. },
  405. goToOrder() {
  406. uni.navigateTo({
  407. url: 'pages/order/index'
  408. })
  409. },
  410. goSearch() {
  411. uni.navigateTo({
  412. url: 'pages/index/search-record'
  413. })
  414. },
  415. selectType(item, itemTwo) {
  416. if (this.type != item.category_id) {
  417. this.type = item.category_id;
  418. this.idMark = 'scroll' + item.category_id
  419. // 立即更新
  420. this.$forceUpdate();
  421. // 延迟执行滚动
  422. setTimeout(() => {
  423. this.scrollToCategorySimple(item.category_id);
  424. }, 100);
  425. }
  426. },
  427. // 滚动方法
  428. scrollToCategorySimple(type) {
  429. const query = uni.createSelectorQuery();
  430. const selector = `#scroll${type}`;
  431. uni.pageScrollTo({
  432. selector: selector,
  433. duration: 300,
  434. });
  435. return
  436. let targetScrollTop = 0
  437. query.select('.shop-info').boundingClientRect(rect => {
  438. console.log('商家详情', rect);
  439. targetScrollTop += rect.height
  440. })
  441. query.select('.shop-type-box').boundingClientRect(rect => {
  442. console.log('详情切换', rect);
  443. targetScrollTop += rect.height + this.newNavHeight
  444. console.log('固定上部分位置', targetScrollTop);
  445. })
  446. query.select(selector).boundingClientRect(rect => {
  447. console.log('id找到元素,top:', rect);
  448. uni.pageScrollTo({
  449. scrollTop: targetScrollTop,
  450. duration: 300,
  451. success: () => {
  452. console.log('滚动完成');
  453. }
  454. });
  455. }).exec();
  456. },
  457. addred(type, item) {
  458. if (type === 1) {
  459. // 减
  460. --item.num;
  461. if (item.num >= 0) {
  462. this.shoppingSave(item, item.num)
  463. }
  464. } else if (type === 2) {
  465. // 加
  466. ++item.num;
  467. this.shoppingSave(item, item.num)
  468. } else if (type === 3) {
  469. // 选规格
  470. uni.navigateTo({
  471. url: `pages-takeout/new-specs-info?goods_id=${item.goods_id}&category_id=${item.category_id}&shop_id=${this.shop_id}`
  472. })
  473. }
  474. },
  475. shoppingSave(item, num) {
  476. // 前端处理购物车
  477. // const goodsData = {
  478. // goods_id: item.goods_id,
  479. // goods_name: item.goods_name,
  480. // goods_image: item.goods_image,
  481. // category_id: item.category_id,
  482. // seckill_money: item.seckill_money || 0,
  483. // price: item.price || 0,
  484. // pack_price: item.pack_price || 0, // 添加配送费
  485. // spec_type: item.spec_type || 1,
  486. // goods_desc: item.goods_desc || '',
  487. // line_price: item.line_price || '',
  488. // sales: item.sales || 0
  489. // };
  490. if (num <= 0) {
  491. // 数量为0,移除商品
  492. cartStore.removeFromCart(item.goods_id, item.goods_spec || []);
  493. } else {
  494. // 更新商品数量
  495. const success = cartStore.updateQuantity(
  496. item.goods_id,
  497. item.goods_spec || [],
  498. num
  499. );
  500. if (!success) {
  501. // 如果更新失败,尝试添加新商品
  502. cartStore.addToCart(item, item.goods_spec || [], num);
  503. }
  504. }
  505. // 更新页面数据
  506. this.getShopIngList();
  507. this.$forceUpdate();
  508. },
  509. findGoodsInList(goodsId) {
  510. // 在商品列表中查找指定商品
  511. for (let category of this.goodsList) {
  512. if (category.list) {
  513. const goods = category.list.find(item => item.goods_id === goodsId)
  514. if (goods) {
  515. return goods
  516. }
  517. }
  518. }
  519. return null
  520. },
  521. navHeight(e) {
  522. this.newNavHeight = e
  523. },
  524. setShopIngDel() {
  525. uni.showModal({
  526. title: '提示',
  527. content: '是否清除购物车商品?',
  528. success: (res) => {
  529. if (res.confirm) {
  530. cartStore.clearCurrentShopCart();
  531. this.getShopIngList();
  532. this.$refs.popupBuy.close();
  533. uni.showToast({
  534. title: '已清空购物车',
  535. icon: 'success'
  536. });
  537. }
  538. }
  539. });
  540. },
  541. setShoppingSave(item, type) {
  542. if (type === 1) {
  543. // 加
  544. item.goods_number = item.goods_number + 1
  545. } else {
  546. // 减
  547. item.goods_number = item.goods_number - 1
  548. }
  549. if (item.goods_number <= 0) {
  550. // 数量为0,移除商品
  551. cartStore.removeFromCart(item.goods_id, item.goods_spec || []);
  552. } else {
  553. // 更新商品数量
  554. cartStore.updateQuantity(
  555. item.goods_id,
  556. item.goods_spec || [],
  557. item.goods_number
  558. );
  559. }
  560. // 更新页面数据
  561. this.getShopIngList();
  562. },
  563. setCartData(cartData) {
  564. this.cartData = cartData
  565. this.getDeliveryMoney()
  566. },
  567. getDeliveryMoney() {
  568. getDeliveryMoney({
  569. 'school_id': this.operate_id,
  570. 'shop_id': this.shop_id,
  571. }).then(res => {
  572. if (res.code === 1) {
  573. this.delivery_money = res.data.delivery_money * 1
  574. }
  575. })
  576. },
  577. toBack() {
  578. tools.leftClick()
  579. },
  580. getDomH(num) {
  581. this.$nextTick(() => {
  582. let info = uni.createSelectorQuery().select('#shopInfoBox');
  583. info.boundingClientRect((data) => {
  584. if (num === 1) {
  585. this.domHeigjt = data.height + 72
  586. } else {
  587. this.domHeigjt = data.height + 72 + 48
  588. }
  589. }).exec()
  590. })
  591. },
  592. seletShopType(item) {
  593. if (this.shopType != item.id) {
  594. this.shopType = item.id;
  595. if (this.shopType == 1) {
  596. this.shopTypeBsLeft = 12
  597. } else if (this.shopType == 2) {
  598. this.shopTypeBsLeft = 150
  599. } else {
  600. this.shopTypeBsLeft = 160 * 2
  601. }
  602. }
  603. },
  604. openBuyCrad() {
  605. this.$refs.popupBuy.open()
  606. },
  607. createOrder() {
  608. this.$refs.popupBuy.close()
  609. },
  610. toConfirmOrder() {
  611. uni.navigateTo({
  612. url: '/pages-takeout/goods-order'
  613. })
  614. },
  615. shopInfo() {
  616. const operate_id = uni.getStorageSync('operate_id')
  617. shopInfo({
  618. operate_id: operate_id,
  619. shop_id: this.shop_id
  620. }).then((res) => {
  621. if (res.code == 1) {
  622. this.shopsInfo = res.data
  623. } else {
  624. tools.error(res.msg)
  625. setTimeout(() => {
  626. uni.navigateBack({
  627. delta: 1
  628. })
  629. }, 1500)
  630. }
  631. })
  632. }
  633. },
  634. }
  635. </script>
  636. <style scoped lang="scss">
  637. .car-scroll-box {
  638. padding: 12rpx 24rpx calc(env(safe-area-inset-bottom) + 48rpx);
  639. }
  640. .zh-icon {
  641. width: 32rpx;
  642. height: 32rpx;
  643. }
  644. .shp-list-img {
  645. width: 40rpx;
  646. height: 40rpx;
  647. }
  648. .dd-box {
  649. width: 144rpx;
  650. padding: 12rpx 0;
  651. background: rgba(0, 0, 0, 0.14);
  652. }
  653. .ss-box {
  654. width: 64rpx;
  655. height: 64rpx;
  656. background: rgba(0, 0, 0, 0.14);
  657. }
  658. .shop-search {
  659. width: 40rpx;
  660. height: 40rpx;
  661. }
  662. .wh-44 {
  663. width: 44rpx;
  664. height: 44rpx;
  665. }
  666. .blank-text {
  667. line-height: 32vh;
  668. }
  669. .box-title {
  670. position: relative;
  671. }
  672. .box-close {
  673. position: absolute;
  674. right: 22rpx;
  675. }
  676. .pop-coupon {
  677. width: 100%;
  678. height: 42vh;
  679. background-color: #F5F4F9;
  680. border-radius: 24rpx 24rpx 0rpx 0rpx;
  681. padding-top: 32rpx !important;
  682. display: flex;
  683. flex-direction: column;
  684. }
  685. .item-right {
  686. padding: 24rpx;
  687. box-sizing: border-box;
  688. border-radius: 20rpx 0 0 20rpx;
  689. position: relative;
  690. }
  691. .item-hr {
  692. width: 0px;
  693. height: auto;
  694. border-right: 1rpx dashed #FB7850;
  695. }
  696. .item-hr-two {
  697. width: 0px;
  698. height: auto;
  699. border-right: 1rpx dashed #999;
  700. }
  701. .item-left {
  702. width: 220rpx;
  703. height: auto;
  704. padding: 20rpx 24rpx;
  705. box-sizing: border-box;
  706. position: relative;
  707. border-radius: 0 20rpx 20rpx 0;
  708. }
  709. .but-box {
  710. width: 152rpx;
  711. height: 52rpx;
  712. line-height: 52rpx;
  713. text-align: center;
  714. background: linear-gradient(225deg, #FB3D03 0%, #FF6901 100%);
  715. border-radius: 200rpx;
  716. }
  717. .ball {
  718. width: 24rpx;
  719. height: 24rpx;
  720. border-radius: 50%;
  721. position: absolute;
  722. top: -12rpx;
  723. left: -12rpx;
  724. background: #F5F5F5;
  725. z-index: 2;
  726. }
  727. .ball-two {
  728. width: 24rpx;
  729. height: 24rpx;
  730. border-radius: 50%;
  731. position: absolute;
  732. background: #F5F5F5;
  733. z-index: 10;
  734. bottom: -12rpx;
  735. left: -12rpx;
  736. }
  737. .shop-index {
  738. width: 100%;
  739. min-height: 100vh;
  740. height: auto;
  741. position: relative;
  742. }
  743. .right-only-right-red {
  744. width: 44rpx;
  745. height: 44rpx;
  746. line-height: 40rpx;
  747. border-radius: 12rpx;
  748. border: 1rpx solid #41ABF5;
  749. color: #41ABF5;
  750. }
  751. .right-only-right-add {
  752. width: 44rpx;
  753. height: 44rpx;
  754. line-height: 40rpx;
  755. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  756. border-radius: 12rpx;
  757. }
  758. .right-only-right-2 {
  759. min-width: 50rpx;
  760. }
  761. .w-514 {
  762. width: 514rpx;
  763. }
  764. .bg-img {
  765. position: fixed;
  766. top: 0;
  767. left: 0;
  768. width: 100%;
  769. height: 300rpx;
  770. transition: linear .3s all;
  771. // height: 300rpx;
  772. }
  773. .bg-img-type {
  774. position: fixed;
  775. top: 0;
  776. left: 0;
  777. width: 100%;
  778. // opacity: 100;
  779. transition: linear .3s all;
  780. }
  781. .mb-box {
  782. position: absolute;
  783. top: 0;
  784. left: 0;
  785. width: 100%;
  786. height: 300rpx;
  787. z-index: -1;
  788. }
  789. .nav-img {
  790. width: 56rpx;
  791. height: 56rpx;
  792. }
  793. .shop-buttom-money {
  794. width: 100%;
  795. // height: 140rpx;
  796. background: rgba(255, 255, 255, 0.8);
  797. padding-left: 24rpx;
  798. padding-right: 24rpx;
  799. padding-bottom: calc(env(safe-area-inset-bottom) + 12rpx);
  800. padding-top: 22rpx;
  801. // padding: 20rpx 24rpx;
  802. position: fixed;
  803. left: 0;
  804. bottom: 0;
  805. z-index: 5;
  806. }
  807. .pop-shop-buttom-money {
  808. width: 100%;
  809. // height: 140rpx;
  810. background: #ECECEC;
  811. padding-left: 24rpx;
  812. padding-right: 24rpx;
  813. padding-bottom: calc(env(safe-area-inset-bottom) + 12rpx);
  814. padding-top: 22rpx;
  815. position: fixed;
  816. left: 0;
  817. bottom: 0;
  818. z-index: 5;
  819. }
  820. .shop-buttom-num {
  821. width: 32rpx;
  822. height: 32rpx;
  823. line-height: 32rpx;
  824. border-radius: 50%;
  825. position: absolute;
  826. top: 0rpx;
  827. left: 85rpx;
  828. border: 1rpx solid #FFFFFF;
  829. }
  830. .shop-buttom-money-2 {
  831. width: 200rpx;
  832. height: 80rpx;
  833. line-height: 80rpx;
  834. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  835. }
  836. .info-box-top {}
  837. .box-top-right {
  838. width: 100rpx;
  839. height: 100rpx;
  840. border-radius: 12rpx;
  841. }
  842. .box-top-left {}
  843. .top-left-1 {
  844. width: 480rpx;
  845. margin-bottom: 8rpx;
  846. }
  847. .img-x {
  848. width: 24rpx;
  849. height: 24rpx;
  850. }
  851. .buy-card {
  852. height: 60vh;
  853. border-radius: 24rpx 24rpx 0rpx 0rpx;
  854. }
  855. .buy-card-top {
  856. width: 100%;
  857. height: 92rpx;
  858. background: #FCF5DB;
  859. border-radius: 24rpx 24rpx 0rpx 0rpx;
  860. }
  861. .buy-card-item {
  862. width: 100%;
  863. // height: 176rpx;
  864. margin-bottom: 32rpx;
  865. }
  866. .goods_img {
  867. width: 152rpx;
  868. height: 152rpx;
  869. border-radius: 12rpx;
  870. margin-right: 20rpx;
  871. }
  872. .shop-buttom-money-1 {
  873. width: 100%;
  874. height: 96rpx;
  875. position: relative;
  876. }
  877. .gwc-img {
  878. width: 88rpx;
  879. height: 88rpx;
  880. }
  881. .head-box {
  882. width: 100%;
  883. position: relative;
  884. }
  885. .shop-info-box {
  886. box-shadow: 0rpx 8rpx 56rpx 0rpx rgba(154, 152, 152, 0.34);
  887. }
  888. .info-box-quan-list {
  889. width: 164rpx;
  890. height: 48rpx;
  891. margin: 0 8rpx 8rpx 0;
  892. position: relative;
  893. image {
  894. width: 164rpx;
  895. height: 48rpx;
  896. position: absolute;
  897. top: 0;
  898. left: 0;
  899. z-index: 1;
  900. }
  901. }
  902. .quan-list-1 {
  903. position: absolute;
  904. top: 3rpx;
  905. left: 8rpx;
  906. z-index: 2;
  907. }
  908. .quan-list-2 {
  909. position: absolute;
  910. top: 8rpx;
  911. right: 22rpx;
  912. z-index: 2;
  913. }
  914. .shop-type-list {
  915. // height: 88rpx;
  916. position: relative;
  917. }
  918. .shop-item {
  919. position: relative;
  920. }
  921. .pj-num {
  922. position: absolute;
  923. right: -80rpx;
  924. top: 0;
  925. text-align: left;
  926. width: 80rpx;
  927. }
  928. .shop-item-bs {
  929. position: absolute;
  930. bottom: 0;
  931. width: 40rpx;
  932. height: 6rpx;
  933. border-radius: 20rpx;
  934. transition: left 0.5s;
  935. }
  936. .sticky-nav {
  937. width: 100%;
  938. position: sticky;
  939. z-index: 3;
  940. }
  941. .wh-44 {
  942. width: 44rpx;
  943. height: 44rpx;
  944. }
  945. .menu-box-left-f {
  946. position: sticky;
  947. // transition: all .3s ease;
  948. // overflow: auto;
  949. }
  950. .menu-box-left {
  951. width: 160rpx;
  952. height: auto;
  953. position: sticky;
  954. overflow: auto;
  955. // transition: all .3s ease;
  956. // height: 100%;
  957. // background-color: #F7F8FA;
  958. // position: absolute;
  959. // left: 0;
  960. // top: 0;
  961. // border-radius: 0rpx 20rpx 0 0rpx;
  962. }
  963. .menu-box-left-box {
  964. overflow-y: auto;
  965. }
  966. .menu-type-list {
  967. width: 160rpx;
  968. min-height: 108rpx;
  969. padding: 18rpx 28rpx;
  970. position: relative;
  971. z-index: 10;
  972. border-radius: 0rpx 20rpx 20rpx 0rpx;
  973. .menu-type-num {
  974. position: absolute;
  975. top: 2rpx;
  976. right: 8rpx;
  977. padding: 0 6rpx;
  978. min-width: 20rpx;
  979. height: 32rpx;
  980. text-align: center;
  981. line-height: 32rpx;
  982. background: #FE6B2C;
  983. border-radius: 50%;
  984. }
  985. }
  986. .menu-type-list-f {
  987. // width: 160rpx;
  988. background-color: #007AFF;
  989. width: 100%;
  990. height: 100%;
  991. overflow-y: auto;
  992. /* 如果分类项很多,允许内部滚动 */
  993. -webkit-overflow-scrolling: touch;
  994. /* 改善移动端滚动体验 */
  995. // height: 100%;
  996. }
  997. .menu-box-only {
  998. // flex: 1;
  999. width: calc(100% - 160rpx);
  1000. }
  1001. .menu-box-right {
  1002. // flex: 1;
  1003. width: 100%;
  1004. height: 100%;
  1005. // padding: 16rpx 0;
  1006. // box-sizing: border-box;
  1007. // position: relative;
  1008. }
  1009. .menu-list {
  1010. width: 100%;
  1011. padding: 0 20rpx 40rpx;
  1012. // height: 200rpx;
  1013. // margin-bottom: 40rpx;
  1014. .goods_img {
  1015. width: 200rpx;
  1016. height: 200rpx;
  1017. border-radius: 12rpx;
  1018. margin-right: 16rpx;
  1019. }
  1020. .menu-list-right {
  1021. flex: 1;
  1022. .right-only-right {
  1023. width: 116rpx;
  1024. height: 44rpx;
  1025. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  1026. line-height: 44rpx;
  1027. position: relative;
  1028. .selectedNum {
  1029. position: absolute;
  1030. right: -10rpx;
  1031. top: -22rpx;
  1032. font-size: 24rpx;
  1033. color: #fff;
  1034. width: 32rpx;
  1035. height: 32rpx;
  1036. line-height: 32rpx;
  1037. background: #FE6B2C;
  1038. border-radius: 50%;
  1039. border: 1rpx solid #FFFFFF;
  1040. }
  1041. }
  1042. .right-only-right-red {
  1043. width: 44rpx;
  1044. height: 44rpx;
  1045. line-height: 40rpx;
  1046. border-radius: 12rpx;
  1047. border: 1rpx solid #41ABF5;
  1048. color: #41ABF5;
  1049. }
  1050. .right-only-right-add {
  1051. width: 44rpx;
  1052. height: 44rpx;
  1053. line-height: 40rpx;
  1054. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  1055. border-radius: 12rpx;
  1056. }
  1057. .right-only-right-2 {
  1058. min-width: 50rpx;
  1059. }
  1060. }
  1061. }
  1062. </style>