new-shop.vue 28 KB

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