new-shop.vue 31 KB

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