new-shop.vue 29 KB

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