new-shop.vue 30 KB

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