new-shop.vue 28 KB

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