new-shop.vue 29 KB

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