new-shop.vue 27 KB

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