new-shop.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  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. mustBut() {
  525. // 未点必选品
  526. const item = {
  527. type: this.cartData.must_category
  528. }
  529. this.$refs.goodsMenu.selectType(item)
  530. },
  531. setShopIngDel() {
  532. uni.showModal({
  533. title: '提示',
  534. content: '是否清除购物车商品?',
  535. success: (res) => {
  536. if (res.confirm) {
  537. cartStore.clearCurrentShopCart();
  538. this.getShopIngList();
  539. this.$refs.popupBuy.close();
  540. uni.showToast({
  541. title: '已清空购物车',
  542. icon: 'success'
  543. });
  544. }
  545. }
  546. });
  547. },
  548. setShoppingSave(item, type) {
  549. if (type === 1) {
  550. // 加
  551. item.goods_number = item.goods_number + 1
  552. } else {
  553. // 减
  554. item.goods_number = item.goods_number - 1
  555. }
  556. if (item.goods_number <= 0) {
  557. // 数量为0,移除商品
  558. cartStore.removeFromCart(item.goods_id, item.goods_spec || []);
  559. } else {
  560. // 更新商品数量
  561. cartStore.updateQuantity(
  562. item.goods_id,
  563. item.goods_spec || [],
  564. item.goods_number
  565. );
  566. }
  567. // 更新页面数据
  568. this.getShopIngList();
  569. },
  570. setCartData(cartData) {
  571. this.cartData = cartData
  572. this.getDeliveryMoney()
  573. },
  574. getDeliveryMoney() {
  575. getDeliveryMoney({
  576. 'school_id': this.operate_id,
  577. 'shop_id': this.shop_id,
  578. }).then(res => {
  579. if (res.code === 1) {
  580. this.delivery_money = res.data.delivery_money * 1
  581. }
  582. })
  583. },
  584. toBack() {
  585. tools.leftClick()
  586. },
  587. getDomH(num) {
  588. this.$nextTick(() => {
  589. let info = uni.createSelectorQuery().select('#shopInfoBox');
  590. info.boundingClientRect((data) => {
  591. if (num === 1) {
  592. this.domHeigjt = data.height + 72
  593. } else {
  594. this.domHeigjt = data.height + 72 + 48
  595. }
  596. }).exec()
  597. })
  598. // setTimeout(() => {
  599. // }, 500)
  600. },
  601. seletShopType(item) {
  602. if (this.shopType != item.id) {
  603. this.shopType = item.id;
  604. if (this.shopType == 1) {
  605. this.shopTypeBsLeft = 12
  606. } else if (this.shopType == 2) {
  607. this.shopTypeBsLeft = 150
  608. } else {
  609. this.shopTypeBsLeft = 160 * 2
  610. }
  611. }
  612. },
  613. openBuyCrad() {
  614. this.$refs.popupBuy.open()
  615. },
  616. createOrder() {
  617. this.$refs.popupBuy.close()
  618. },
  619. openCoupon() {
  620. this.$refs.popupCoupon.open()
  621. },
  622. closeCoupon() {
  623. this.$refs.popupCoupon.close()
  624. },
  625. toConfirmOrder() {
  626. // console.log(this.cartData, '11111111111');
  627. // return
  628. uni.navigateTo({
  629. url: '/pages-takeout/goods-order'
  630. })
  631. },
  632. shopInfo() {
  633. const operate_id = uni.getStorageSync('operate_id')
  634. shopInfo({
  635. operate_id: operate_id,
  636. shop_id: this.shop_id
  637. }).then((res) => {
  638. if (res.code == 1) {
  639. this.shopsInfo = res.data
  640. } else {
  641. tools.error(res.msg)
  642. setTimeout(() => {
  643. uni.navigateBack({
  644. delta: 1
  645. })
  646. }, 1500)
  647. }
  648. })
  649. }
  650. },
  651. }
  652. </script>
  653. <style scoped lang="scss">
  654. .car-scroll-box {
  655. padding: 12rpx 24rpx calc(env(safe-area-inset-bottom) + 48rpx);
  656. }
  657. .zh-icon {
  658. width: 32rpx;
  659. height: 32rpx;
  660. }
  661. .shp-list-img {
  662. width: 40rpx;
  663. height: 40rpx;
  664. }
  665. .dd-box {
  666. width: 144rpx;
  667. padding: 12rpx 0;
  668. background: rgba(0, 0, 0, 0.14);
  669. }
  670. .ss-box {
  671. width: 64rpx;
  672. height: 64rpx;
  673. background: rgba(0, 0, 0, 0.14);
  674. }
  675. .shop-search {
  676. width: 40rpx;
  677. height: 40rpx;
  678. }
  679. .wh-44 {
  680. width: 44rpx;
  681. height: 44rpx;
  682. }
  683. .blank-text {
  684. line-height: 32vh;
  685. }
  686. .box-title {
  687. position: relative;
  688. }
  689. .box-close {
  690. position: absolute;
  691. right: 22rpx;
  692. }
  693. .pop-coupon {
  694. width: 100%;
  695. height: 42vh;
  696. background-color: #F5F4F9;
  697. border-radius: 24rpx 24rpx 0rpx 0rpx;
  698. padding-top: 32rpx !important;
  699. display: flex;
  700. flex-direction: column;
  701. }
  702. .item-right {
  703. padding: 24rpx;
  704. box-sizing: border-box;
  705. border-radius: 20rpx 0 0 20rpx;
  706. position: relative;
  707. }
  708. .item-hr {
  709. width: 0px;
  710. height: auto;
  711. border-right: 1rpx dashed #FB7850;
  712. }
  713. .item-hr-two {
  714. width: 0px;
  715. height: auto;
  716. border-right: 1rpx dashed #999;
  717. }
  718. .item-left {
  719. width: 220rpx;
  720. height: auto;
  721. padding: 20rpx 24rpx;
  722. box-sizing: border-box;
  723. position: relative;
  724. border-radius: 0 20rpx 20rpx 0;
  725. }
  726. .but-box {
  727. width: 152rpx;
  728. height: 52rpx;
  729. line-height: 52rpx;
  730. text-align: center;
  731. background: linear-gradient(225deg, #FB3D03 0%, #FF6901 100%);
  732. border-radius: 200rpx;
  733. }
  734. .ball {
  735. width: 24rpx;
  736. height: 24rpx;
  737. border-radius: 50%;
  738. position: absolute;
  739. top: -12rpx;
  740. left: -12rpx;
  741. background: #F5F5F5;
  742. z-index: 2;
  743. }
  744. .ball-two {
  745. width: 24rpx;
  746. height: 24rpx;
  747. border-radius: 50%;
  748. position: absolute;
  749. background: #F5F5F5;
  750. z-index: 10;
  751. bottom: -12rpx;
  752. left: -12rpx;
  753. }
  754. .shop-index {
  755. width: 100%;
  756. min-height: 100vh;
  757. height: auto;
  758. position: relative;
  759. }
  760. .right-only-right-red {
  761. width: 44rpx;
  762. height: 44rpx;
  763. line-height: 40rpx;
  764. border-radius: 12rpx;
  765. border: 1rpx solid #41ABF5;
  766. color: #41ABF5;
  767. }
  768. .right-only-right-add {
  769. width: 44rpx;
  770. height: 44rpx;
  771. line-height: 40rpx;
  772. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  773. border-radius: 12rpx;
  774. }
  775. .right-only-right-2 {
  776. min-width: 50rpx;
  777. }
  778. .w-514 {
  779. width: 514rpx;
  780. }
  781. .bg-img {
  782. position: fixed;
  783. top: 0;
  784. left: 0;
  785. width: 100%;
  786. height: 300rpx;
  787. transition: linear .3s all;
  788. // height: 300rpx;
  789. }
  790. .bg-img-type {
  791. position: fixed;
  792. top: 0;
  793. left: 0;
  794. width: 100%;
  795. // opacity: 100;
  796. transition: linear .3s all;
  797. }
  798. .mb-box {
  799. position: absolute;
  800. top: 0;
  801. left: 0;
  802. width: 100%;
  803. height: 300rpx;
  804. z-index: -1;
  805. }
  806. .nav-img {
  807. width: 56rpx;
  808. height: 56rpx;
  809. }
  810. .shop-buttom-money {
  811. width: 100%;
  812. // height: 140rpx;
  813. background: rgba(255, 255, 255, 0.8);
  814. padding-left: 24rpx;
  815. padding-right: 24rpx;
  816. padding-bottom: calc(env(safe-area-inset-bottom) + 12rpx);
  817. padding-top: 22rpx;
  818. // padding: 20rpx 24rpx;
  819. position: fixed;
  820. left: 0;
  821. bottom: 0;
  822. z-index: 5;
  823. }
  824. .pop-shop-buttom-money {
  825. width: 100%;
  826. // height: 140rpx;
  827. background: #ECECEC;
  828. padding-left: 24rpx;
  829. padding-right: 24rpx;
  830. padding-bottom: calc(env(safe-area-inset-bottom) + 12rpx);
  831. padding-top: 22rpx;
  832. position: fixed;
  833. left: 0;
  834. bottom: 0;
  835. z-index: 5;
  836. }
  837. .shop-buttom-num {
  838. width: 32rpx;
  839. height: 32rpx;
  840. line-height: 32rpx;
  841. border-radius: 50%;
  842. position: absolute;
  843. top: 0rpx;
  844. left: 85rpx;
  845. border: 1rpx solid #FFFFFF;
  846. }
  847. .shop-buttom-money-2 {
  848. width: 200rpx;
  849. height: 80rpx;
  850. line-height: 80rpx;
  851. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  852. }
  853. .info-box-top {}
  854. .box-top-right {
  855. width: 100rpx;
  856. height: 100rpx;
  857. border-radius: 12rpx;
  858. }
  859. .box-top-left {}
  860. .top-left-1 {
  861. width: 480rpx;
  862. margin-bottom: 8rpx;
  863. }
  864. .img-x {
  865. width: 24rpx;
  866. height: 24rpx;
  867. }
  868. .buy-card {
  869. height: 60vh;
  870. border-radius: 24rpx 24rpx 0rpx 0rpx;
  871. }
  872. .buy-card-top {
  873. width: 100%;
  874. height: 92rpx;
  875. background: #FCF5DB;
  876. border-radius: 24rpx 24rpx 0rpx 0rpx;
  877. }
  878. .buy-card-item {
  879. width: 100%;
  880. // height: 176rpx;
  881. margin-bottom: 32rpx;
  882. }
  883. .goods_img {
  884. width: 152rpx;
  885. height: 152rpx;
  886. border-radius: 12rpx;
  887. margin-right: 20rpx;
  888. }
  889. .shop-buttom-money-1 {
  890. width: 100%;
  891. height: 96rpx;
  892. position: relative;
  893. }
  894. .gwc-img {
  895. width: 88rpx;
  896. height: 88rpx;
  897. }
  898. .head-box {
  899. width: 100%;
  900. position: relative;
  901. }
  902. .shop-info-box {
  903. box-shadow: 0rpx 8rpx 56rpx 0rpx rgba(154, 152, 152, 0.34);
  904. }
  905. .info-box-quan-list {
  906. width: 164rpx;
  907. height: 48rpx;
  908. margin: 0 8rpx 8rpx 0;
  909. position: relative;
  910. image {
  911. width: 164rpx;
  912. height: 48rpx;
  913. position: absolute;
  914. top: 0;
  915. left: 0;
  916. z-index: 1;
  917. }
  918. }
  919. .quan-list-1 {
  920. position: absolute;
  921. top: 3rpx;
  922. left: 8rpx;
  923. z-index: 2;
  924. }
  925. .quan-list-2 {
  926. position: absolute;
  927. top: 8rpx;
  928. right: 22rpx;
  929. z-index: 2;
  930. }
  931. .shop-type-list {
  932. // height: 88rpx;
  933. position: relative;
  934. }
  935. .shop-item {
  936. position: relative;
  937. }
  938. .pj-num {
  939. position: absolute;
  940. right: -80rpx;
  941. top: 0;
  942. text-align: left;
  943. width: 80rpx;
  944. }
  945. .shop-item-bs {
  946. position: absolute;
  947. bottom: 0;
  948. width: 40rpx;
  949. height: 6rpx;
  950. border-radius: 20rpx;
  951. transition: left 0.5s;
  952. }
  953. .sticky-nav {
  954. width: 100%;
  955. position: sticky;
  956. z-index: 3;
  957. }
  958. .wh-44 {
  959. width: 44rpx;
  960. height: 44rpx;
  961. }
  962. .menu-box-left-f {
  963. position: sticky;
  964. // transition: all .3s ease;
  965. // overflow: auto;
  966. }
  967. .menu-box-left {
  968. width: 160rpx;
  969. height: auto;
  970. position: sticky;
  971. overflow: auto;
  972. // transition: all .3s ease;
  973. // height: 100%;
  974. // background-color: #F7F8FA;
  975. // position: absolute;
  976. // left: 0;
  977. // top: 0;
  978. // border-radius: 0rpx 20rpx 0 0rpx;
  979. }
  980. .menu-box-left-box {
  981. overflow-y: auto;
  982. }
  983. .menu-type-list {
  984. width: 160rpx;
  985. min-height: 108rpx;
  986. padding: 18rpx 28rpx;
  987. position: relative;
  988. z-index: 10;
  989. border-radius: 0rpx 20rpx 20rpx 0rpx;
  990. .menu-type-num {
  991. position: absolute;
  992. top: 2rpx;
  993. right: 8rpx;
  994. padding: 0 6rpx;
  995. min-width: 20rpx;
  996. height: 32rpx;
  997. text-align: center;
  998. line-height: 32rpx;
  999. background: #FE6B2C;
  1000. border-radius: 50%;
  1001. }
  1002. }
  1003. .menu-type-list-f {
  1004. // width: 160rpx;
  1005. background-color: #007AFF;
  1006. width: 100%;
  1007. height: 100%;
  1008. overflow-y: auto;
  1009. /* 如果分类项很多,允许内部滚动 */
  1010. -webkit-overflow-scrolling: touch;
  1011. /* 改善移动端滚动体验 */
  1012. // height: 100%;
  1013. }
  1014. .menu-box-only {
  1015. // flex: 1;
  1016. width: calc(100% - 160rpx);
  1017. }
  1018. .menu-box-right {
  1019. // flex: 1;
  1020. width: 100%;
  1021. height: 100%;
  1022. // padding: 16rpx 0;
  1023. // box-sizing: border-box;
  1024. // position: relative;
  1025. }
  1026. .menu-list {
  1027. width: 100%;
  1028. padding: 0 20rpx 40rpx;
  1029. // height: 200rpx;
  1030. // margin-bottom: 40rpx;
  1031. .goods_img {
  1032. width: 200rpx;
  1033. height: 200rpx;
  1034. border-radius: 12rpx;
  1035. margin-right: 16rpx;
  1036. }
  1037. .menu-list-right {
  1038. flex: 1;
  1039. .right-only-right {
  1040. width: 116rpx;
  1041. height: 44rpx;
  1042. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  1043. line-height: 44rpx;
  1044. position: relative;
  1045. .selectedNum {
  1046. position: absolute;
  1047. right: -10rpx;
  1048. top: -22rpx;
  1049. font-size: 24rpx;
  1050. color: #fff;
  1051. width: 32rpx;
  1052. height: 32rpx;
  1053. line-height: 32rpx;
  1054. background: #FE6B2C;
  1055. border-radius: 50%;
  1056. border: 1rpx solid #FFFFFF;
  1057. }
  1058. }
  1059. .right-only-right-red {
  1060. width: 44rpx;
  1061. height: 44rpx;
  1062. line-height: 40rpx;
  1063. border-radius: 12rpx;
  1064. border: 1rpx solid #41ABF5;
  1065. color: #41ABF5;
  1066. }
  1067. .right-only-right-add {
  1068. width: 44rpx;
  1069. height: 44rpx;
  1070. line-height: 40rpx;
  1071. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  1072. border-radius: 12rpx;
  1073. }
  1074. .right-only-right-2 {
  1075. min-width: 50rpx;
  1076. }
  1077. }
  1078. }
  1079. </style>