orderingfood.vue 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294
  1. <template>
  2. <view class="content">
  3. <block v-if="loading">
  4. <view class="loadingBox">
  5. <img class="loading" lazy-load src="http://teaclub.oss-cn-chengdu.aliyuncs.com/CloudShop/head_pic/3a96ff52efce6661adb41c54c29a87241b6e72f5gif" />
  6. </view>
  7. </block>
  8. <block v-else>
  9. <view class="header flex_r flex_jb">
  10. <view class="left flex_c flex_jc">
  11. <view class="title ellipsis">{{MerchantInfo.restaurant_name}}</view>
  12. <view v-if="distance" class="address">距离您 {{$h.Div(distance, 1000).toFixed(2)}}km</view>
  13. <view v-else class="address">{{MerchantInfo.restaurant_address}}</view>
  14. </view>
  15. <view class="right flex_c flex_jc">
  16. <span @click="openm" class="iconfont">&#xe634;</span>
  17. </view>
  18. </view>
  19. <view style="height: 130rpx;"></view>
  20. <view class="goodsBox" v-if="goodsAllList.length">
  21. <view class="left">
  22. <scroll-view scroll-y scroll-with-animation class="menuList">
  23. <view class="menu" :class="menuCurrent==index?'active':''" :style="menuCurrent==index?'color:'+template.color.color2+';border-color:'+template.color.color1:'color:'+template.color.color3" @click="selectMenuTap(index)" v-for="(item, index) in goodsAllList" :key="index">{{item.title}}</view>
  24. <view style="height: 200rpx;"></view>
  25. </scroll-view>
  26. </view>
  27. <view class="right">
  28. <scroll-view scroll-y scroll-with-animation :scroll-into-view="goodsInto" class="goodList">
  29. <!-- <view v-if="swiperList.length>0" class="swiperBpx">
  30. <swiper class="swiper" circular autoplay interval="6000" duration="500" @change="swiperChange">
  31. <swiper-item v-for="(item, index) in swiperList" :key="index" @click="getBannerTap(item.target_data)">
  32. <image lazy-load="true" mode="aspectFill" :src="item.pic" />
  33. </swiper-item>
  34. </swiper>
  35. <view class="swiperDots">
  36. <block v-for="(item, index) in swiperList" :key="index">
  37. <view class="dot" :class="swiperCurrent==index?'active':''"></view>
  38. </block>
  39. </view>
  40. </view> -->
  41. <view id="goodsQuery" v-for="(item, index) in goodsAllList" :key="index">
  42. <view class="goodsList" :id="'gory-'+index">
  43. <view class="gheader" :style="'color:'+template.color.color2">{{item.title}}</view>
  44. <view class="goods lineBottom" v-for="(itm, idx) in item.goods" :key="idx" @click="getDteailsTap(index, idx)">
  45. <view class="left">
  46. <view class="image">
  47. <img :src="itm.product_img" class="product_img" alt="">
  48. <icon v-if="itm.recom_status" class="icon" type="hot" size="30" color="#d3aa79"></icon>
  49. <view v-if="itm.stock_number==0" class="none" :style="'color:'+template.color.color5">已售罄</view>
  50. </view>
  51. </view>
  52. <view class="right">
  53. <view class="title" :style="'color:'+template.color.color2">{{itm.product_name}}</view>
  54. <view class="intro" :style="'color:'+template.color.color3">{{itm.product_description || ""}}</view>
  55. <view class="box">
  56. <view class="price" :style="'color:'+template.color.color1">¥{{itm.product_price}}</view>
  57. <view class="button">
  58. <view v-if="itm.product_choose" class="text" :style="'background-color:'+template.color.color1">选规格</view>
  59. <icon v-else type="jia" size="23" :color="template.color.color1"></icon>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view style="height: 180rpx;"></view>
  67. </scroll-view>
  68. </view>
  69. </view>
  70. <div class="hahaha">
  71. <img src="http://teaclub.oss-cn-chengdu.aliyuncs.com/CloudShop/head_pic/769023cde4b820d36e75baf7b3faef6ea3095cb3png" alt="">
  72. </div>
  73. <!-- 购物袋 - 底部栏 -->
  74. <view v-if="openStoreStatus && cartList.length>0" class="footer" :class="ios>=0?'footerX':''">
  75. <view class="left">
  76. <view class="cart" @click="cartShow=!cartShow" :style="'color:'+template.color.color2">
  77. <icon type="liwu" size="18" color="#343434"></icon>购物袋<text :style="'background-color:'+template.color.color1">{{cartNumber}}</text>
  78. </view>
  79. <view class="price" :style="'color:'+template.color.color2">¥{{cartTotal}}</view>
  80. </view>
  81. <view class="right">
  82. <view v-if="cartNumber>0" class="button" @click="toPaypalTap()" :style="'background-color:'+template.color.color1">去结算</view>
  83. <view v-else class="button none" :style="'background-color:'+template.color.color5">去结算</view>
  84. </view>
  85. </view>
  86. <!-- 购物袋 - 弹窗列表 -->
  87. <view v-if="cartShow && cartList.length>0" class="showPopBox" style="z-index: 898;">
  88. <view class="bg" @click="cartShow=false"></view>
  89. <view class="showContent" :style="ios>=0?'bottom:96rpx;':''">
  90. <view class="sheade">
  91. <view class="left">
  92. <view class="text">共{{cartNumber}}件商品</view>
  93. </view>
  94. <view class="right">
  95. <view class="text" @click="delNoneCartTap()">
  96. <icon type="shanchu" size="14" />清空购物袋</view>
  97. </view>
  98. </view>
  99. <view class="sconten">
  100. <view class="goods" v-for="(item, index) in cartList" :key="index" :style="cartList.length==(index+1)?'border-bottom: none;':''">
  101. <view class="left">
  102. <view class="title">{{item.product_name}}</view>
  103. <view class="label" v-if="item.spec">
  104. <text v-for="(value, name) in item.spec.selectSpecification" :key="name" class="good_spec">{{value}}</text>
  105. </view>
  106. </view>
  107. <view class="right">
  108. <view class="price">¥{{$h.Add(item.product_price, item.spec_price)}}</view>
  109. <view class="buy">
  110. <icon type="jian" @click="editGoods(item, 'jian')" size="23" :color="item.number==1?'#ccc':'#d3aa79'"></icon>
  111. <input type="number" :value="item.number" disabled />
  112. <icon type="jia" @click="editGoods(item, 'jia')" size="23" color="#d3aa79"></icon>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. <view v-if="!openStoreStatus" class="footer" :class="ios>=0?'footerX':''" style="overflow: hidden;">
  120. <view class="label" :style="'background-color:'+template.color.color2">本店已休息,<block v-if="MerchantInfo.open_time">营业时间{{MerchantInfo.open_time}}</block>
  121. </view>
  122. </view>
  123. <!-- 选规格-看详情 -->
  124. <view v-if="goodShow" class="showPopBox" style="display: flex;align-items: center;justify-content: center;">
  125. <view class="bg" @click="goodShow=false"></view>
  126. <view class="goodsConten">
  127. <view class="image">
  128. <image :src="goodsOneData.product_img" class="img" mode="aspectFill" />
  129. <icon @click="goodShow=false" type="close" size="25" :color="template.color.color5" style="top: 10rpx; right: 10rpx;"></icon>
  130. </view>
  131. <view class="title" :style="'color:'+template.color.color2">{{goodsOneData.product_name}}</view>
  132. <scroll-view scroll-y class="moreBox" style="max-height: 500rpx;">
  133. <!-- 奈雪规格 -->
  134. <template v-if="mda.brand_id == 2">
  135. <view class="label" v-for="(item, index) in goodsOneData.details.spu_specs" :key="index">
  136. <view class="stitle"><text>{{item.name}}</text></view>
  137. <view class="specBox">
  138. <view class="spec" :class="{active:itm.checked}" @click="naixues(index, idx)" v-for="(itm, idx) in item.values" :key="idx">{{itm.name + (itm.price ? ` +${itm.price}` : "")}}</view>
  139. </view>
  140. </view>
  141. <view class="label">
  142. <view class="stitle"><text>加料</text></view>
  143. <view class="specBox">
  144. <view class="spec" :class="{active:itm.checked}" @click="naixue(idx,itm.checked)" v-for="(itm, idx) in goodsOneData.details.accessories" :key="idx">{{itm.name + (itm.price ? ` +${itm.price}` : "")}}</view>
  145. </view>
  146. </view>
  147. </template>
  148. <!-- 瑞辛规格 -->
  149. <template v-else-if="mda.brand_id == 13">
  150. <view class="label" v-for="(item, index) in goodsOneData.details.specifications" :key="index">
  151. <view class="stitle"><text>{{item.name}}</text></view>
  152. <view class="specBox">
  153. <view class="spec" :class="{active:itm.checked}" @click="ruixins(index, idx)" v-for="(itm, idx) in item.ingredients" :key="idx">{{itm.name + (itm.price ? ` +${itm.price}` : "")}}</view>
  154. </view>
  155. </view>
  156. </template>
  157. <!-- 喜茶规格 -->
  158. <template v-else-if="mda.brand_id == 19">
  159. <view class="label" v-for="(item, index) in goodsOneData.details.specifications" :key="index">
  160. <view class="stitle"><text>{{item.name}}</text></view>
  161. <view class="specBox">
  162. <view class="spec" :class="{active:itm.checked}" @click="xichas(index, idx)" v-for="(itm, idx) in item.values" :key="idx">{{itm.name + (itm.price ? ` +${itm.price}` : "")}}</view>
  163. </view>
  164. </view>
  165. </template>
  166. <!-- 其他规格 -->
  167. <template v-else>
  168. <view class="label" v-for="(item, index) in goodsOneData.details.optional" :key="index">
  169. <view class="stitle"><text>{{item.name}}</text></view>
  170. <view class="specBox">
  171. <view class="spec" :class="{active:itm.checked}" @click="selectSpecsTap(index, idx)" v-for="(itm, idx) in item.sku_infos" :key="idx">{{itm.name + (itm.price ? ` +${itm.price}` : "")}}</view>
  172. </view>
  173. </view>
  174. </template>
  175. <view class="more" v-if="goodsOneData.product_description">
  176. <view class="labtit" :style="'color:'+template.color.color3">产品介绍</view>
  177. <view class="intro" :style="'color:'+template.color.color3">{{goodsOneData.product_description}}</view>
  178. </view>
  179. </scroll-view>
  180. <view class="gfooter">
  181. <view class="price">
  182. <view class="left">
  183. <view v-if="childProductData.spec_price" class="text" :style="'color:'+template.color.color1">¥{{childProductData.spec_price + goodsOneData.product_price}}</view>
  184. <view v-else class="text" :style="'color:'+template.color.color1">¥{{goodsOneData.product_price}}</view>
  185. <view class="label" v-if="childProductData.selectSpecification" :style="'color:'+template.color.color3">
  186. <text v-for="(value, name) in childProductData.selectSpecification" :key="name" class="good_spec">{{value}} </text>
  187. </view>
  188. </view>
  189. <view class="right">
  190. <view class="buy">
  191. <icon type="jian" @click="editGoodsOne('jian')" size="23" :color="template.color.color1"></icon>
  192. <input type="number" :value="buyNumber" disabled :style="'color:'+template.color.color2" />
  193. <icon type="jia" @click="editGoodsOne('jia')" size="23" :color="template.color.color1"></icon>
  194. </view>
  195. </view>
  196. </view>
  197. <view class="button" @click="addShopCar()" :style="'background-color:'+template.color.color1">加入购物袋</view>
  198. </view>
  199. </view>
  200. </view>
  201. </block>
  202. </view>
  203. </template>
  204. <script>
  205. import Icon from "@/pagesB/components/icon/icon.vue";
  206. import { post } from "@/request/api.js";
  207. export default {
  208. components: { Icon },
  209. props: {
  210. goods: {
  211. type: Number,
  212. default: 0,
  213. },
  214. },
  215. data() {
  216. return {
  217. loading: true,
  218. ios: 1,
  219. template: {
  220. color: {
  221. color1: "#d3aa79",
  222. color2: "#323232",
  223. color3: "#999",
  224. color5: "#bbb"
  225. }
  226. },
  227. menuCurrent: 0,
  228. menuList: [],
  229. swiperCurrent: 0,
  230. swiperList: [],
  231. cartTotal: 0,
  232. cartNumber: 0,
  233. cartList: [],
  234. goodsOneData: '',
  235. buyNumber: 1,
  236. canSubmit: false,
  237. childProductData: {},
  238. // buyActive: false,
  239. cartShow: false,
  240. infoShow: false,
  241. goodShow: false,
  242. goodsInto: '',
  243. goodsAllList: [],
  244. distance: 0,
  245. openStoreStatus: true,
  246. openStoreTime: '',
  247. MerchantInfo: uni.getStorageSync("MerchantItem"),
  248. mda: {},
  249. }
  250. },
  251. onReady() {
  252. this.distance = this.MerchantInfo.distance;
  253. uni.setNavigationBarTitle({ title: this.MerchantInfo.restaurant_name });
  254. this.getCartList();
  255. let that = this;
  256. uni.getSystemInfo({
  257. success: function(e) {
  258. that.ios = e.model.search("iPhone");
  259. }
  260. })
  261. },
  262. onLoad(da) {
  263. this.getGoodsAllList(da)
  264. this.mda = da
  265. },
  266. methods: {
  267. // 获取当下店铺所有商品
  268. getGoodsAllList(da) {
  269. post("local/getMerchantMenu", da).then(res => {
  270. this.loading = false;
  271. if (res.code == 0) {
  272. if (res.data.error_code == 200) {
  273. let da = res.data.data.products;
  274. let arr = [],
  275. obj = [];
  276. for (const it of da) {
  277. // if ([2, 13, 19].includes(res.data.data.brand_id)) it.product_choose = false
  278. if (!arr.includes(it.category_name)) arr.push(it.category_name)
  279. }
  280. for (const i of arr) {
  281. obj.push({ title: i, goods: [] })
  282. }
  283. for (const it of da) {
  284. obj[arr.indexOf(it.category_name)].goods.push(it)
  285. }
  286. this.goodsAllList = obj
  287. }
  288. } else if (res.code == -1) {
  289. this.openStoreStatus = false
  290. }
  291. })
  292. },
  293. // 商品类别导航跳转
  294. selectMenuTap(index) {
  295. this.menuCurrent = index;
  296. this.goodsInto = 'gory-' + index;
  297. },
  298. // 获取商品详情 - 展开规格选择
  299. getDteailsTap(index, idx) {
  300. this.childProductData = {};
  301. let data = this.goodsAllList[index].goods[idx];
  302. // if (![2,13,19].includes(data.brand_id) && data.product_choose) {
  303. if (data.product_choose) {
  304. post("local/getProduct", { ...this.mda, product_id: data.product_id }).then(res => {
  305. if (res.code === 0) {
  306. let da = res.data.data
  307. this.goodsOneData = da;
  308. this.goodShow = true;
  309. if(this.mda.brand_id == 2) this.naixueSpec()
  310. else if(this.mda.brand_id == 13) this.ruixinSpec()
  311. else if(this.mda.brand_id == 19) this.xichasSpec()
  312. else this.selectSpec()
  313. }
  314. })
  315. } else {
  316. this.goodsOneData = data;
  317. this.goodShow = true;
  318. }
  319. },
  320. // 选择规格标签 奈雪
  321. naixues(index, key) {
  322. let da = this.goodsOneData.details.spu_specs;
  323. da[index].values.forEach(value => this.$set(value, 'checked', 0))
  324. da[index].values[key].checked = 1
  325. this.naixueSpec();
  326. },
  327. naixueSpec(){
  328. this.childProductData.product_details = []
  329. let da = this.goodsOneData.details.spu_specs;
  330. let arr = [], obj = this.childProductData.selectSpecification || {};
  331. let arrs = [];
  332. for (let it of da) {
  333. for (let i of it.values) {
  334. if(i.checked) {
  335. arr.push(i);
  336. obj[it.name] = i.name
  337. let arrb = []
  338. if(arr.length == 1) arrs = this.goodsOneData.details.sku_infos
  339. for (const a of arrs) {
  340. for (const b of a.specs) {
  341. if(i.code == b.spec_code) arrb.push(a)
  342. }
  343. }
  344. arrs = arrb
  345. }
  346. }
  347. }
  348. this.childProductData.selectSpecArr = arr
  349. this.childProductData.selectSpecification = obj
  350. this.childProductData.product_details[0].sku_code = arrs[0].code
  351. },
  352. naixue(key,r) {
  353. let selectSpecification = this.childProductData.selectSpecification || {};
  354. let da = this.goodsOneData.details.accessories;
  355. da.forEach(value => this.$set(value, 'checked', 0))
  356. da[key].checked = r ? 0 : 1;
  357. this.childProductData.spec_price = !r ? da[key].price : 0
  358. if(!r) selectSpecification['加料'] = da[key].name
  359. else delete selectSpecification['加料']
  360. this.childProductData.selectSpecification = selectSpecification
  361. this.childProductData.product_details[0].accessories_code = da[key].code
  362. },
  363. // 选择规格标签 瑞辛
  364. ruixins(index, key) {
  365. let da = this.goodsOneData.details.specifications;
  366. da[index].ingredients.forEach(value => this.$set(value, 'checked', false))
  367. da[index].ingredients[key].checked = true
  368. this.ruixinSpec();
  369. },
  370. ruixinSpec(){
  371. let da = this.goodsOneData.details.specifications;
  372. let arr = [], obj = this.childProductData.selectSpecification || {};
  373. let arrs = [];
  374. for (let it of da) {
  375. for (let i of it.ingredients) {
  376. if(i.checked) {
  377. arr.push(i);
  378. obj[it.name] = i.name
  379. let arrb = []
  380. if(arr.length == 1) arrs = this.goodsOneData.details.sku_infos
  381. for (const a of arrs) {
  382. for (const b of a.values) {
  383. if(i.name == b.spec_name) arrb.push(a)
  384. }
  385. }
  386. arrs = arrb
  387. }
  388. }
  389. }
  390. let sku = {
  391. sku_code : arrs[0].code
  392. }
  393. this.childProductData = {
  394. selectSpecArr: arr,
  395. selectSpecification: obj,
  396. product_details: [sku]
  397. }
  398. },
  399. xichas(index, key){
  400. let da = this.goodsOneData.details.specifications;
  401. da[index].values.forEach(value => this.$set(value, 'checked', 0))
  402. da[index].values[key].checked = 1
  403. this.xichasSpec();
  404. },
  405. xichasSpec(){
  406. let spec_price = 0;
  407. let da = this.goodsOneData.details.specifications;
  408. let arr = [], obj = this.childProductData.selectSpecification || {};
  409. let accessories_id = [], sku_id = [];
  410. for (let it of da) {
  411. for (let i of it.values) {
  412. if(i.checked) {
  413. arr.push(i);
  414. obj[it.name] = i.name
  415. spec_price = this.$h.Add(spec_price,i.price)
  416. if(it.mandatory) sku_id.push(i.id)
  417. else accessories_id.push(i.id)
  418. }
  419. }
  420. }
  421. let product_details = [{
  422. accessories_id: accessories_id.join(),
  423. sku_id: sku_id.join()
  424. }]
  425. this.childProductData = {
  426. selectSpecArr: arr,
  427. selectSpecification: obj,
  428. spec_price,
  429. product_details
  430. }
  431. },
  432. // 选择规格标签
  433. selectSpecsTap(index, key) {
  434. let da = this.goodsOneData.details.optional;
  435. da[index].sku_infos.forEach(value => this.$set(value, 'checked', false))
  436. da[index].sku_infos[key].checked = true
  437. this.selectSpec();
  438. },
  439. selectSpec(){
  440. let spec_price = 0, product_details = [];
  441. let da = this.goodsOneData.details.optional;
  442. let arr = [], obj = this.childProductData.selectSpecification || {};
  443. for (let it of da) {
  444. for (let i of it.sku_infos) {
  445. if(i.checked) {
  446. arr.push(i);
  447. obj[it.name] = i.name
  448. spec_price = this.$h.Add(spec_price,i.price)
  449. product_details.push({
  450. specification_id: it.id,
  451. sku_id: i.id
  452. })
  453. }
  454. }
  455. }
  456. this.childProductData = {
  457. selectSpecArr: arr,
  458. selectSpecification: obj,
  459. spec_price,
  460. product_details
  461. }
  462. },
  463. // 添加购物袋前 修改购买数量
  464. editGoodsOne(type) {
  465. let self = this;
  466. if (type == 'jian') {
  467. if (self.buyNumber > 1) {
  468. self.buyNumber--
  469. }
  470. } else if (type == 'jia') {
  471. self.buyNumber++
  472. }
  473. },
  474. // 添加进购物袋
  475. addShopCar() {
  476. let data = this.goodsOneData;
  477. this.addCartGoods(data, this.buyNumber, this.childProductData);
  478. },
  479. // 添加购物袋
  480. addCartGoods(da, num, spec = []) {
  481. let json = {
  482. ...this.mda,
  483. product_id: da.product_id,
  484. product_img: da.product_img,
  485. product_name: da.product_name,
  486. product_price: da.product_price,
  487. spec_price: spec.spec_price,
  488. number: num,
  489. spec: JSON.stringify(spec)
  490. }
  491. post("local/addMyCart", json).then(res => {
  492. if (res.code == 0) {
  493. this.goodShow = false;
  494. setTimeout(() => {
  495. this.getCartList();
  496. }, 100)
  497. }
  498. })
  499. },
  500. // 编辑购物袋中商品数量
  501. editGoods(data, type) {
  502. let self = this;
  503. if (type == 'jian') {
  504. data.number--
  505. } else if (type == 'jia') {
  506. data.number++
  507. }
  508. let url = "local/editMyCart",
  509. da = {};
  510. if (data.number < 1) {
  511. data.number = 1;
  512. url = "local/delMyCart";
  513. da = { cart_id: data.id }
  514. } else {
  515. url = "local/editMyCart";
  516. da = { cart_id: data.id, number: data.number }
  517. }
  518. post(url, da).then(res => {
  519. if (res.code == 0) {
  520. setTimeout(() => {
  521. this.getCartList();
  522. }, 100)
  523. }
  524. })
  525. },
  526. // 购物袋列表 获取当前店铺
  527. getCartList() {
  528. post("local/myCart", {
  529. restaurant_id: this.mda.restaurant_id,
  530. }).then(res => {
  531. if (res.code == 0) {
  532. let data = res.data;
  533. let totals = 0;
  534. let number = 0;
  535. data.forEach(itm => {
  536. number += itm.number;
  537. totals = this.$h.Add(totals, this.$h.Mul(this.$h.Add(itm.product_price, itm.spec_price), itm.number));
  538. itm.spec = JSON.parse(itm.spec)
  539. })
  540. this.cartList = data;
  541. this.cartTotal = totals;
  542. this.cartNumber = number;
  543. }
  544. })
  545. },
  546. // 清空购物袋
  547. delNoneCartTap() {
  548. let self = this;
  549. if (self.cartList.length > 0) {
  550. uni.showModal({
  551. title: '清空购物袋',
  552. content: '是否清空已经加入购物袋的商品?',
  553. success(res) {
  554. if (res.confirm) {
  555. post("local/cleanCart", {
  556. restaurant_id: self.mda.restaurant_id,
  557. }).then(res => {
  558. if (res.code == 0) {
  559. self.cartShow = false;
  560. self.cartList = [];
  561. }
  562. })
  563. }
  564. }
  565. })
  566. }
  567. },
  568. // 去结算页
  569. toPaypalTap() {
  570. this.goto("/pagesB/orderingfood/payTheBill", {
  571. restaurant_id: this.mda.restaurant_id,
  572. brand_id: this.mda.brand_id,
  573. })
  574. },
  575. openm() {
  576. let latitude = parseFloat(this.MerchantInfo.latitude);
  577. let longitude = parseFloat(this.MerchantInfo.longitude);
  578. let name = this.MerchantInfo.brand_name;
  579. let address = this.MerchantInfo.restaurant_address;
  580. uni.openLocation({
  581. latitude, longitude, scale: 18, name, address,
  582. success: function() {
  583. console.log('success');
  584. }
  585. });
  586. },
  587. }
  588. }
  589. </script>
  590. <style lang="scss">
  591. page {
  592. background-color: #f5f5f5;
  593. overflow: hidden;
  594. }
  595. .header {
  596. width: 100%;
  597. height: 130rpx;
  598. position: fixed;
  599. top: 0;
  600. z-index: 900;
  601. background-color: #fff;
  602. box-shadow: 0 0 10rpx rgba(0, 0, 0, .05);
  603. padding: 0 32rpx;
  604. .left {
  605. width: calc(100% - 60rpx);
  606. .title {
  607. width: 90%;
  608. color: #343434;
  609. font-size: 30rpx;
  610. font-weight: bold;
  611. }
  612. .address {
  613. width: 90%;
  614. color: #999;
  615. font-size: 26rpx;
  616. padding-top: 6rpx;
  617. text-overflow: ellipsis;
  618. white-space: nowrap;
  619. overflow: hidden;
  620. }
  621. }
  622. .right {
  623. width: 60rpx;
  624. text-align: right;
  625. .iconfont {
  626. font-size: 50rpx;
  627. color: #666;
  628. }
  629. }
  630. }
  631. .goodsBox {
  632. width: 100%;
  633. display: flex;
  634. height: calc(100vh - 130rpx);
  635. .left {
  636. flex: 0 0 28%;
  637. .menuList {
  638. overflow-y: scroll;
  639. height: calc(100vh - 130rpx);
  640. .menu {
  641. color: #999999;
  642. font-size: 26rpx;
  643. padding: 30rpx 10rpx;
  644. text-align: center;
  645. background-color: transparent;
  646. border-left: 16rpx solid transparent;
  647. transition: all 0.6s;
  648. }
  649. .active {
  650. font-weight: bold;
  651. background-color: #FFFFFF;
  652. }
  653. }
  654. }
  655. .right {
  656. flex: 0 0 72%;
  657. background-color: #FFFFFF;
  658. .swiperBpx {
  659. width: 95%;
  660. margin: 0 auto;
  661. padding-top: 14rpx;
  662. position: relative;
  663. swiper {
  664. height: 220rpx;
  665. .swiper-item {
  666. width: 100%;
  667. height: 100%;
  668. display: flex;
  669. align-items: center;
  670. justify-content: center;
  671. color: #FFFFFF;
  672. font-size: 56rpx;
  673. }
  674. }
  675. .swiperDots {
  676. position: absolute;
  677. left: 0;
  678. right: 0;
  679. bottom: 12rpx;
  680. display: flex;
  681. justify-content: center;
  682. height: 10rpx;
  683. .dot {
  684. margin: 0 5rpx;
  685. width: 25rpx;
  686. height: 4rpx;
  687. background: #fff;
  688. border-radius: 20rpx;
  689. transition: all 0.6s;
  690. opacity: 0.5;
  691. }
  692. .active {
  693. opacity: 1;
  694. }
  695. }
  696. }
  697. .goodList {
  698. height: calc(100vh - 130rpx);
  699. }
  700. .goodsList {
  701. width: 95%;
  702. margin: 0 auto;
  703. .gheader {
  704. font-weight: bold;
  705. font-size: 26rpx;
  706. display: flex;
  707. height: 100rpx;
  708. align-items: center;
  709. }
  710. .goods {
  711. display: flex;
  712. position: relative;
  713. padding-bottom: 20rpx;
  714. margin-bottom: 20rpx;
  715. .left {
  716. flex: 0 0 30%;
  717. display: flex;
  718. .image {
  719. width: 140rpx;
  720. height: 140rpx;
  721. background-color: #f5f5f5;
  722. border-radius: 6rpx;
  723. overflow: hidden;
  724. position: relative;
  725. .icon {
  726. position: absolute;
  727. top: 0;
  728. left: 0;
  729. }
  730. .none {
  731. position: absolute;
  732. top: 0;
  733. left: 0;
  734. width: 100%;
  735. height: 100%;
  736. background-color: rgba(255, 255, 255, .6);
  737. display: flex;
  738. align-items: center;
  739. justify-content: center;
  740. font-size: 26rpx;
  741. color: #999;
  742. }
  743. }
  744. }
  745. .right {
  746. flex: 0 0 70%;
  747. .title {
  748. color: #343434;
  749. font-size: 26rpx;
  750. font-weight: bold;
  751. }
  752. .intro {
  753. color: #999;
  754. font-size: 24rpx;
  755. overflow: hidden;
  756. text-overflow: ellipsis;
  757. display: -webkit-box;
  758. -webkit-line-clamp: 2;
  759. -webkit-box-orient: vertical;
  760. padding-top: 4rpx;
  761. }
  762. .box {
  763. display: flex;
  764. align-items: center;
  765. padding-top: 10rpx;
  766. position: relative;
  767. .price {
  768. color: #343434;
  769. font-size: 28rpx;
  770. font-weight: bold;
  771. flex: 0 0 50%
  772. }
  773. .button {
  774. flex: 0 0 50%;
  775. display: flex;
  776. justify-content: flex-end;
  777. .text {
  778. background-color: #d3aa79;
  779. color: #fff;
  780. font-size: 24rpx;
  781. padding: 4rpx 16rpx;
  782. border-radius: 100rpx;
  783. }
  784. }
  785. }
  786. }
  787. }
  788. }
  789. }
  790. }
  791. .hahaha {
  792. text-align: center;
  793. margin-top: calc(30vh - 150rpx);
  794. }
  795. .footer {
  796. position: fixed;
  797. bottom: 80rpx;
  798. width: 92%;
  799. left: 0;
  800. right: 0;
  801. height: 100rpx;
  802. margin: 0 auto;
  803. border-radius: 100rpx;
  804. background-color: #fff;
  805. display: flex;
  806. align-items: center;
  807. z-index: 899;
  808. box-shadow: 0 0 20rpx rgba(0, 0, 0, .05);
  809. .label {
  810. color: #fff;
  811. width: 100%;
  812. height: 100%;
  813. display: flex;
  814. align-items: center;
  815. justify-content: center;
  816. }
  817. .left {
  818. flex: 0 0 70%;
  819. display: flex;
  820. align-items: center;
  821. justify-content: flex-end;
  822. height: 100%;
  823. .cart {
  824. position: absolute;
  825. width: 180rpx;
  826. height: 100%;
  827. left: 0;
  828. color: #343434;
  829. font-size: 26rpx;
  830. display: flex;
  831. align-items: center;
  832. justify-content: center;
  833. icon {
  834. padding-right: 8rpx;
  835. }
  836. text {
  837. position: absolute;
  838. top: -8rpx;
  839. right: -12rpx;
  840. background-color: #d3aa79;
  841. border-radius: 100%;
  842. width: 36rpx;
  843. height: 36rpx;
  844. display: flex;
  845. align-items: center;
  846. justify-content: center;
  847. color: #fff;
  848. font-size: 24rpx;
  849. }
  850. }
  851. .price {
  852. color: #343434;
  853. font-size: 30rpx;
  854. padding-right: 30rpx;
  855. font-weight: bold;
  856. }
  857. }
  858. .right {
  859. flex: 0 0 30%;
  860. height: 100%;
  861. border-top-right-radius: 100rpx;
  862. border-bottom-right-radius: 100rpx;
  863. overflow: hidden;
  864. .button {
  865. width: 100%;
  866. height: 100%;
  867. color: #FFFFFF;
  868. display: flex;
  869. align-items: center;
  870. justify-content: center;
  871. background-color: #d3aa79;
  872. }
  873. .none {
  874. background-color: #bbbbbb;
  875. }
  876. }
  877. }
  878. .footerX {
  879. bottom: 106rpx;
  880. }
  881. .showPopBox {
  882. position: fixed;
  883. top: 0;
  884. left: 0;
  885. width: 100%;
  886. height: 100%;
  887. background-color: rgba(0, 0, 0, .5);
  888. z-index: 970;
  889. transition: all 0.3s;
  890. .bg {
  891. position: absolute;
  892. top: 0;
  893. left: 0;
  894. width: 100%;
  895. height: 100%;
  896. z-index: 971;
  897. }
  898. .showContent {
  899. position: absolute;
  900. bottom: 70rpx;
  901. left: 0;
  902. z-index: 972;
  903. width: 100%;
  904. max-height: 600rpx;
  905. background-color: #fff;
  906. border-radius: 26rpx 26rpx 0 0;
  907. .sheade {
  908. width: 100%;
  909. background-color: #f2f2f2;
  910. font-size: 24rpx;
  911. height: 68rpx;
  912. display: flex;
  913. align-items: center;
  914. border-radius: 26rpx 26rpx 0 0;
  915. .left {
  916. flex: 0 0 50%;
  917. .text {
  918. color: #999;
  919. padding-left: 20rpx;
  920. }
  921. }
  922. .right {
  923. flex: 0 0 50%;
  924. .text {
  925. color: #999;
  926. display: flex;
  927. align-items: center;
  928. justify-content: flex-end;
  929. padding-right: 20rpx;
  930. icon {
  931. padding-right: 6rpx;
  932. }
  933. }
  934. }
  935. }
  936. .sconten {
  937. padding: 20rpx 0 120rpx;
  938. max-height: 544rpx;
  939. overflow-y: scroll;
  940. .goods {
  941. width: 95%;
  942. margin: 0 auto;
  943. display: flex;
  944. align-items: center;
  945. border-bottom: 1px dashed #f5f5f5;
  946. padding: 15rpx 0;
  947. .left {
  948. flex: 0 0 60%;
  949. .title {
  950. color: #343434;
  951. }
  952. }
  953. .right {
  954. flex: 0 0 40%;
  955. display: flex;
  956. align-items: center;
  957. justify-content: flex-end;
  958. .price {
  959. flex: 0 0 40%;
  960. color: #343434;
  961. }
  962. .buy {
  963. display: flex;
  964. align-items: center;
  965. justify-content: center;
  966. flex: 0 0 60%;
  967. input {
  968. text-align: center;
  969. color: #343434;
  970. }
  971. text {
  972. color: #999;
  973. font-size: 24rpx;
  974. }
  975. }
  976. }
  977. }
  978. }
  979. }
  980. .infoContent {
  981. position: absolute;
  982. z-index: 972;
  983. width: 100%;
  984. max-height: 55vh;
  985. top: 130rpx;
  986. background-color: #fff;
  987. left: 0;
  988. overflow-y: scroll;
  989. padding-bottom: 20rpx;
  990. padding-top: 10rpx;
  991. .label {
  992. width: 95%;
  993. margin: 0 auto;
  994. padding: 12rpx 0;
  995. .title {
  996. color: #343434;
  997. font-size: 26rpx;
  998. }
  999. .text {
  1000. color: #999;
  1001. font-size: 24rpx;
  1002. padding-top: 4rpx;
  1003. }
  1004. }
  1005. .images {
  1006. display: flex;
  1007. align-items: center;
  1008. flex-wrap: wrap;
  1009. padding-top: 6rpx;
  1010. .image {
  1011. width: 200rpx;
  1012. height: 200rpx;
  1013. border: 2rpx solid #f5f5f5;
  1014. background-color: #f5f5f5;
  1015. margin-right: 20rpx;
  1016. position: relative;
  1017. .text {
  1018. position: absolute;
  1019. bottom: 0;
  1020. left: 0;
  1021. width: 100%;
  1022. background-color: rgba(255, 255, 255, .6);
  1023. height: 50rpx;
  1024. display: flex;
  1025. align-items: center;
  1026. justify-content: center;
  1027. color: #666;
  1028. font-size: 26rpx;
  1029. }
  1030. }
  1031. }
  1032. }
  1033. .goodsConten {
  1034. position: absolute;
  1035. z-index: 972;
  1036. width: 80%;
  1037. background-color: #fff;
  1038. border-radius: 10rpx;
  1039. padding-bottom: 20rpx;
  1040. margin-top: -5vh;
  1041. box-shadow: 0 10rpx 20rpx rgba(0, 0, 0, .06);
  1042. .image {
  1043. display: flex;
  1044. align-items: center;
  1045. justify-content: center;
  1046. position: relative;
  1047. .img {
  1048. width: 100%;
  1049. height: 320rpx;
  1050. border-radius: 10rpx 10rpx 0 0;
  1051. }
  1052. icon {
  1053. position: absolute;
  1054. }
  1055. }
  1056. .title {
  1057. width: 90%;
  1058. margin: 0 auto;
  1059. padding-top: 10rpx;
  1060. padding-bottom: 10rpx;
  1061. color: #343434;
  1062. font-weight: bold;
  1063. }
  1064. .moreBox {
  1065. width: 90%;
  1066. margin: 0 auto;
  1067. .label {
  1068. padding-bottom: 10rpx;
  1069. .stitle {
  1070. padding-bottom: 10rpx;
  1071. text {
  1072. color: #999;
  1073. font-size: 26rpx;
  1074. }
  1075. }
  1076. .specBox {
  1077. display: flex;
  1078. flex-wrap: wrap;
  1079. .spec {
  1080. border: 1px solid #eee;
  1081. padding: 8rpx 20rpx;
  1082. margin-right: 12rpx;
  1083. font-size: 24rpx;
  1084. color: #999999;
  1085. }
  1086. .active {
  1087. color: #FFFFFF;
  1088. background-color: #d3aa79;
  1089. border-color: #d3aa79;
  1090. }
  1091. }
  1092. }
  1093. .more {
  1094. padding-bottom: 20rpx;
  1095. .labtit {
  1096. color: #999;
  1097. font-size: 26rpx;
  1098. padding-top: 10rpx;
  1099. }
  1100. .intro {
  1101. color: #999;
  1102. font-size: 24rpx;
  1103. }
  1104. }
  1105. }
  1106. .gfooter {
  1107. border-top: 1px solid #f5f5f5;
  1108. padding-top: 20rpx;
  1109. .price {
  1110. width: 90%;
  1111. margin: 0 auto;
  1112. display: flex;
  1113. padding: 10rpx 0;
  1114. align-items: center;
  1115. justify-content: center;
  1116. .left {
  1117. flex: 0 0 65%;
  1118. .text {
  1119. color: #d3aa79;
  1120. font-size: 32rpx;
  1121. font-weight: bold;
  1122. display: flex;
  1123. align-items: center;
  1124. text {
  1125. text-decoration: line-through;
  1126. color: #999;
  1127. font-size: 26rpx;
  1128. margin-left: 10rpx;
  1129. font-weight: normal;
  1130. }
  1131. }
  1132. .label {
  1133. color: #999;
  1134. font-size: 24rpx;
  1135. }
  1136. }
  1137. .right {
  1138. flex: 0 0 35%;
  1139. display: flex;
  1140. justify-content: flex-end;
  1141. .buy {
  1142. display: flex;
  1143. align-items: center;
  1144. input {
  1145. text-align: center;
  1146. color: #343434;
  1147. }
  1148. }
  1149. }
  1150. }
  1151. .button {
  1152. width: 90%;
  1153. margin: 0 auto;
  1154. margin-top: 20rpx;
  1155. background-color: #d3aa79;
  1156. color: #fff;
  1157. height: 66rpx;
  1158. display: flex;
  1159. align-items: center;
  1160. justify-content: center;
  1161. border-radius: 100rpx;
  1162. font-size: 26rpx;
  1163. }
  1164. .none {
  1165. background-color: #cccccc;
  1166. }
  1167. }
  1168. }
  1169. }
  1170. .product_img {
  1171. width: 100%;
  1172. height: 100%;
  1173. }
  1174. .good_spec {
  1175. color: #999;
  1176. font-size: 22rpx;
  1177. margin-right: 12rpx;
  1178. &:last-child {
  1179. margin-right: 0;
  1180. }
  1181. }
  1182. .loadingBox {
  1183. .loading {
  1184. width: 100%;
  1185. height: 100vw;
  1186. }
  1187. }
  1188. </style>