category - 副本.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. <!-- 商品分类列表 -->
  2. <template>
  3. <s-layout title="分类" :bgStyle="{ color: '#fff' }">
  4. <view class="s-category">
  5. <view class="three-level-wrap ss-flex ss-col-top" :style="[{ height: pageHeight + 'px' }]">
  6. <!-- 商品分类(左) -->
  7. <scroll-view class="side-menu-wrap" scroll-y :style="[{ height: pageHeight + 'px' }]">
  8. <view class="menu-item ss-flex" v-for="(item, index) in state.categoryList" :key="item.id"
  9. :class="[{ 'menu-item-active': index === state.activeMenu }]" @tap="onMenu(index)">
  10. <view class="menu-title ss-line-1">
  11. {{ item.name }}
  12. </view>
  13. </view>
  14. </scroll-view>
  15. <!-- 商品分类(右) -->
  16. <scroll-view scroll-with-animation :scroll-y="goodsBoxScroll" class="right" @scroll="asideScroll"
  17. :scroll-top="tabScrollTop">
  18. <view class="goodsListBox">
  19. <view class="category" v-for="item in state.categoryList" :key="item.id" :id="'goodsBox'+item.id">
  20. <view class="s-item">{{item.name}}</view>
  21. <view class="list">
  22. <view class="box" v-for="(rowData,i) in item.children" :key="rowData.id" >
  23. <!-- -->
  24. <!-- 商品列表 -->
  25. <!-- <m-store-pro @touchOnGoods="touchOnGoods" :rowData="box"></m-store-pro>
  26. -->
  27. <!-- 商品列表 -->
  28. <view class="m-store-item" v-if="item.id == rowData.parentId">
  29. <view class="m-img" @click="hrefGoodsInfo(rowData.id)">
  30. <image style="width: 100%;height: 100%;" :src="rowData.image"
  31. alt="Product Image"></image>
  32. </view>
  33. <view class="m-text">
  34. <view class="m-title" @click="hrefGoodsInfo(rowData.id)">
  35. {{rowData.name}}
  36. </view>
  37. <view class="m-descripe">
  38. {{rowData.descripe}}
  39. </view>
  40. <template v-if="rowData.form">
  41. <view class="m-price-box">
  42. <view class="symbol">¥</view>
  43. <view class="m-price">{{rowData.form_child[0].price}}</view>
  44. <view class="m-old-price" v-if="rowData.form_child[0].oldprice">
  45. <span>¥{{rowData.form_child[0].oldprice}}</span>
  46. </view>
  47. </view>
  48. </template>
  49. <template v-else>
  50. <view class="m-price-box">
  51. <view class="symbol">¥</view>
  52. <view class="m-price">{{rowData.price}}</view>
  53. <view class="m-old-price" v-if="rowData.oldprice">
  54. <span>¥{{rowData.oldprice}}</span>
  55. </view>
  56. </view>
  57. </template>
  58. <view class="m-distance">
  59. <template v-if="rowData.form">
  60. <view class="miniBtn" @click="showForm(rowData)">
  61. <span>选规格</span>
  62. <!-- #ifdef APP-PLUS || H5 -->
  63. <view class="num" v-if="getCartGoodsNum(rowData)">
  64. {{getCartGoodsNum(rowData)}}
  65. </view>
  66. <!-- #endif -->
  67. </view>
  68. </template>
  69. <template v-else>
  70. <view :class="'addEle_' + i" class="jumpPosition"></view>
  71. <hx-number-box @change="addGoodsChange" :value="rowData.number"
  72. :rowData="rowData" :clickTime="animaTime"
  73. @addChange="touchOnAddGoods('.addEle_' + i,rowData)"></hx-number-box>
  74. </template>
  75. <!-- <image @click="touchOnAddGoods('.addEle_' + i,rowData)" style="width:20px;height: 20px;" src="../../static/img/icon/shop_icon_buy.png" mode="aspectFit"></image>
  76. -->
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- </scroll-view> -->
  85. <!-- <image v-if="state.categoryList[state.activeMenu].picUrl" class="banner-img"
  86. :src="sheep.$url.cdn(state.categoryList[state.activeMenu].picUrl)" mode="widthFix" />
  87. <first-one v-if="state.style === 'first_one'" :pagination="state.pagination" />
  88. <first-two v-if="state.style === 'first_two'" :pagination="state.pagination" />
  89. <second-one v-if="state.style === 'second_one'" :data="state.categoryList"
  90. :activeMenu="state.activeMenu" /> -->
  91. <uni-load-more v-if="
  92. (state.style === 'first_one' || state.style === 'first_two') &&
  93. state.pagination.total > 0
  94. " :status="state.loadStatus" :content-text="{
  95. contentdown: '点击查看更多',
  96. }" @tap="loadMore" />
  97. </scroll-view>
  98. </view>
  99. </view>
  100. <!-- 下方购物车 -->
  101. <view class="foot" @touchmove.stop.prevent="mpClear" :style="{height: 50}" v-if="state.showFoot">
  102. <view class="zz" @click="hideShoppingCar"></view>
  103. <view class="btn-box">
  104. <view class="btn-box-left" @click="contact">
  105. <view class="imgBox">
  106. <image src="../../static/store/contact.png" mode=""></image>
  107. </view>
  108. <text>联系商家</text>
  109. </view>
  110. <view class="btn-box-line"></view>
  111. <view class="btn-box-center" @click="showShoppingCar">
  112. <view class="cart" :animation="cartAnimationData">
  113. <view class="tag cartNum" v-if="goodsTotalNumber>0">{{goodsTotalNumber}}</view>
  114. <image :src="goodsTotalNumber ? '/static/store/cart.png' : '/static/store/cart2.png'" mode=""></image>
  115. </view>
  116. <view class="priceBox">
  117. <view class="hx-txt-18 hx-color-white" v-if="goodsTotalPrice>0">
  118. ¥{{goodsTotalPrice}}
  119. </view>
  120. <view class="hx-txt-10 hx-color-gray">
  121. 另需配送费¥{{shippingDees}}
  122. </view>
  123. </view>
  124. </view>
  125. <view class="btn-box-right">
  126. <view class="jiesuan" v-if="goodsTotalPrice>0 && goodsTotalPrice >= startingPrice" @click="jiesuan">
  127. 去结算
  128. </view>
  129. <view class="pscj hx-txt-10 hx-color-gray" v-else>
  130. <text v-if="startingPrice>0">差¥{{-(goodsTotalPrice-startingPrice)}}起送</text>
  131. </view>
  132. </view>
  133. </view>
  134. <view class="cart-box" :style="{display: showCar ? 'flex' : 'none'}">
  135. <view class="box-container rebate-box" v-if="showDiscount">
  136. <text>已享100减25</text>
  137. </view>
  138. <view class="box-container operating-box">
  139. <view class="operating-box_right">
  140. </view>
  141. <view class="operating-box_left clear" @click="clearShoppingCart">
  142. <i class="hxicon-delete"></i>
  143. <text>清空购物车</text>
  144. </view>
  145. </view>
  146. <view class=" goods-box">
  147. <view class="" style="flex: 1;">
  148. <scroll-view scroll-y="true" class="goods-list-scroll" :scroll-top="carGoodsScrollTop">
  149. <view class="goods-list">
  150. <view class="box" v-for="(rowData,i) in shoppCart" :key="rowData.id" >
  151. <!-- v-if="rowData.number>0" -->
  152. <view class="m-store-item">
  153. <view class="m-img">
  154. <image style="width: 100%;height: 100%;" :src="rowData.img" mode="aspectFit"></image>
  155. </view>
  156. <view class="m-text">
  157. <view class="m-title">
  158. {{rowData.name}}
  159. </view>
  160. <view class="m-descripe">
  161. {{rowData.current_form ? rowData.form.name + ":" + rowData.current_form.name : rowData.descripe}}
  162. </view>
  163. <view class="m-price-box" >
  164. <view class="symbol">¥</view>
  165. <view class="m-price">{{rowData.price}}</view>
  166. <view class="m-old-price" v-if="rowData.oldprice">
  167. <text>¥{{rowData.oldprice}}</text>
  168. </view>
  169. </view>
  170. <view class="m-distance" >
  171. <view :class="'addEle2_' + rowData.id" class="jumpPosition">
  172. </view>
  173. <hx-number-box @change="addGoodsChange" :value="rowData.number" :rowData="rowData" :clickTime="animaTime" @addChange="touchOnAddGoods('.addEle2_' + rowData.id,rowData)"></hx-number-box>
  174. </view>
  175. </view>
  176. </view>
  177. </view>
  178. </view>
  179. </scroll-view>
  180. </view>
  181. </view>
  182. </view>
  183. </view>
  184. </s-layout>
  185. </template>
  186. <script setup>
  187. import secondOne from './components/second-one.vue';
  188. import firstOne from './components/first-one.vue';
  189. import firstTwo from './components/first-two.vue';
  190. import hxNumberBox from './components/uni-number-box.vue';
  191. import sheep from '@/sheep';
  192. import CategoryApi from '@/sheep/api/product/category';
  193. import SpuApi from '@/sheep/api/product/spu';
  194. import {
  195. onLoad,
  196. onLaunch,
  197. onReachBottom
  198. } from '@dcloudio/uni-app';
  199. import {
  200. computed,
  201. reactive,
  202. onMounted
  203. } from 'vue';
  204. import _ from 'lodash';
  205. import {
  206. handleTree
  207. } from '@/sheep/util';
  208. const state = reactive({
  209. style: 'second_one', // first_one(一级 - 样式一), first_two(二级 - 样式二), second_one(二级)
  210. categoryList: [], // 商品分类树
  211. goodsList:[],//分类下的商品
  212. activeMenu: 0, // 选中的一级菜单,在 categoryList 的下标
  213. pagination: {
  214. // 商品分页
  215. list: [], // 商品列表
  216. total: [], // 商品总数
  217. pageNo: 1,
  218. pageSize: 6,
  219. },
  220. loadStatus: '',
  221. //显示购物车
  222. showFoot:true,
  223. });
  224. // const showTabbar = ref(true);
  225. const {
  226. safeArea
  227. } = sheep.$platform.device;
  228. const pageHeight = computed(() => safeArea.height - 44 - 50);
  229. onMounted(() => {
  230. // 当组件挂载完成后隐藏底部TabBar
  231. uni.hideTabBar({
  232. animation: false, // 是否需要动画效果,默认为 false
  233. success: function () {
  234. console.log('TabBar已隐藏');
  235. },
  236. fail: function (err) {
  237. console.error('隐藏TabBar失败:', err);
  238. }
  239. });
  240. });
  241. // 加载商品分类
  242. async function getList() {
  243. const {
  244. code,
  245. data
  246. } = await CategoryApi.getCategoryList();
  247. if (code !== 0) {
  248. return;
  249. }
  250. state.categoryList = handleTree(data);
  251. console.log(state.categoryList,'state.categoryListstate.categoryList')
  252. // state.categoryList = [
  253. // {id: 1,name: '烧烤'},
  254. // {id: 2,name: '生鲜'},
  255. // {id: 3,name: '绿蔬'},
  256. // {id: 4,name: '肉类'},
  257. // {id: 5,name: '川味'},
  258. // {id: 6,name: '粤菜'},
  259. // {id: 7,name: '湘菜'},
  260. // {id: 8,name: '西餐'},
  261. // {id: 9,name: '饮料'},
  262. // {id: 10,name: '糕点'},
  263. // {id: 11,name: '凉菜'},
  264. // {id: 12,name: '火锅'},
  265. // {id: 13,name: '干锅'}
  266. // ];
  267. // state.goodsList = [{
  268. // id: 1,
  269. // type_id:1,
  270. // name:'白果王水果沙拉',
  271. // descripe:"脆糯营养,口感好,健康绿色",
  272. // img:'//imgs.1op.cn/i/hxshop/goods/14.jpg',
  273. // price:"",
  274. // oldprice:"",
  275. // //规格
  276. // form: {id:1,name:"尺寸"},
  277. // form_child:[
  278. // {id:81,pid:1,name:"8寸500g", price:"46", oldprice:"100", select:true},
  279. // {id:82,pid:1,name:"10寸600g", price:"97", oldprice:"100",select:false},
  280. // {id:83,pid:1,name:"12寸800g", price:"135", oldprice:"100",select:false},
  281. // {id:84,pid:1,name:"四川麻辣", price:"12", oldprice:"100",select:false},
  282. // {id:85,pid:1,name:"香辣", price:"20", oldprice:"100",select:false},
  283. // {id:86,pid:1,name:"卤香", price:"90", oldprice:"100",select:false},
  284. // {id:87,pid:1,name:"鲜甜广味", price:"80", oldprice:"100",select:false},
  285. // {id:88,pid:1,name:"镇店茴香味", price:"100", oldprice:"100",select:false}
  286. // ]
  287. // },
  288. // {
  289. // id: 2,
  290. // type_id:2,
  291. // name:'精品烤山药',
  292. // descripe:"脆糯营养,口感好,健康绿色",
  293. // img: '//imgs.1op.cn/i/hxshop/goods/12.jpg',
  294. // price:"",
  295. // oldprice:"",
  296. // //规格
  297. // form: {id:1,name:"尺寸"},
  298. // form_child:[
  299. // {id:81,pid:1,name:"8寸500g", price:"78", oldprice:"100", select:true},
  300. // {id:82,pid:1,name:"10寸600g", price:"97", oldprice:"100",select:false},
  301. // {id:83,pid:1,name:"12寸800g", price:"135", oldprice:"100",select:false},
  302. // {id:84,pid:1,name:"四川麻辣", price:"12", oldprice:"100",select:false},
  303. // {id:85,pid:1,name:"香辣", price:"20", oldprice:"100",select:false},
  304. // {id:86,pid:1,name:"卤香", price:"90", oldprice:"100",select:false},
  305. // {id:87,pid:1,name:"鲜甜广味", price:"80", oldprice:"100",select:false},
  306. // {id:88,pid:1,name:"镇店茴香味", price:"100", oldprice:"100",select:false}
  307. // ]
  308. // },
  309. // {
  310. // id: 3,
  311. // type_id:2,
  312. // name:'川味毛血旺',
  313. // descripe:"脆糯营养,口感好,健康绿色",
  314. // img: '//imgs.1op.cn/i/hxshop/goods/11.jpg',
  315. // price:"4",
  316. // oldprice:"",
  317. // },
  318. // {
  319. // id: 4,
  320. // type_id:3,
  321. // name:'吐鲁番烤全羊',
  322. // descripe:"脆糯营养,口感好,健康绿色",
  323. // img: '//imgs.1op.cn/i/hxshop/goods/10.jpg',
  324. // price:"4",
  325. // oldprice:""
  326. // },
  327. // {
  328. // id: 5,
  329. // type_id:3,
  330. // name:'红烧肉',
  331. // descripe:"脆糯营养,口感好,健康绿色",
  332. // img: '//imgs.1op.cn/i/hxshop/goods/9.jpg',
  333. // price:"4",
  334. // oldprice:""
  335. // },
  336. // {
  337. // id: 6,
  338. // type_id:4,
  339. // name:'新疆特色辣子鸡',
  340. // descripe:"脆糯营养,口感好,健康绿色",
  341. // img: '//imgs.1op.cn/i/hxshop/goods/8.jpg',
  342. // price:"4",
  343. // oldprice:""
  344. // },
  345. // {
  346. // id: 106,
  347. // type_id:4,
  348. // name:'新疆特色羊排',
  349. // descripe:"脆糯营养,口感好,健康绿色",
  350. // img: '//imgs.1op.cn/i/hxshop/goods/9.jpg',
  351. // price:"4",
  352. // oldprice:""
  353. // },
  354. // {
  355. // id: 7,
  356. // type_id:5,
  357. // name:'绝味海鲜拼盘',
  358. // descripe:"脆糯营养,口感好,健康绿色",
  359. // img: '//imgs.1op.cn/i/hxshop/goods/7.jpg',
  360. // price:"4",
  361. // oldprice:""
  362. // },
  363. // {
  364. // id: 8,
  365. // type_id:5,
  366. // name:'金色香糯大粽子',
  367. // descripe:"脆糯营养,口感好,健康绿色",
  368. // img: '//imgs.1op.cn/i/hxshop/goods/6.jpg',
  369. // price:"4",
  370. // oldprice:""
  371. // },
  372. // {
  373. // id: 9,
  374. // type_id:5,
  375. // name:'马梓林香香鸡',
  376. // descripe:"脆糯营养,口感好,健康绿色",
  377. // img: '//imgs.1op.cn/i/hxshop/goods/5.jpg',
  378. // price:"4",
  379. // oldprice:""
  380. // },
  381. // {
  382. // id: 10,
  383. // type_id:6,
  384. // name:'草莓味莫普氏蛋糕',
  385. // descripe:"脆糯营养,口感好,健康绿色",
  386. // img: '//imgs.1op.cn/i/hxshop/goods/4.jpg',
  387. // price:"4",
  388. // oldprice:""
  389. // },
  390. // {
  391. // id: 23,
  392. // type_id:6,
  393. // name:'川味毛血旺',
  394. // descripe:"脆糯营养,口感好,健康绿色",
  395. // img: '//imgs.1op.cn/i/hxshop/goods/11.jpg',
  396. // price:"4",
  397. // oldprice:"",
  398. // },
  399. // {
  400. // id: 24,
  401. // type_id:6,
  402. // name:'吐鲁番烤全羊',
  403. // descripe:"脆糯营养,口感好,健康绿色",
  404. // img: '//imgs.1op.cn/i/hxshop/goods/10.jpg',
  405. // price:"4",
  406. // oldprice:""
  407. // },
  408. // {
  409. // id: 25,
  410. // type_id:7,
  411. // name:'红烧肉',
  412. // descripe:"脆糯营养,口感好,健康绿色",
  413. // img: '//imgs.1op.cn/i/hxshop/goods/9.jpg',
  414. // price:"4",
  415. // oldprice:""
  416. // },
  417. // {
  418. // id: 26,
  419. // type_id:7,
  420. // name:'新疆特色辣子鸡',
  421. // descripe:"脆糯营养,口感好,健康绿色",
  422. // img: '//imgs.1op.cn/i/hxshop/goods/8.jpg',
  423. // price:"4",
  424. // oldprice:""
  425. // },
  426. // {
  427. // id: 27,
  428. // type_id:7,
  429. // name:'绝味海鲜拼盘',
  430. // descripe:"脆糯营养,口感好,健康绿色",
  431. // img: '//imgs.1op.cn/i/hxshop/goods/7.jpg',
  432. // price:"4",
  433. // oldprice:""
  434. // },
  435. // {id: 28,type_id:8,name:'金色香糯大粽子',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/6.jpg',price:"4",oldprice:""},
  436. // {id: 29,type_id:8,name:'马梓林香香鸡',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/5.jpg',price:"4",oldprice:""},
  437. // {id: 30,type_id:8,name:'草莓味莫普氏蛋糕',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/4.jpg',price:"4",oldprice:""},
  438. // {id: 31,type_id:9,name:'金色香糯大粽子',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/16.jpg',price:"4",oldprice:""},
  439. // {id: 32,type_id:9,name:'马梓林香香鸡',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/17.jpg',price:"4",oldprice:""},
  440. // {id: 33,type_id:9,name:'草莓味莫普氏蛋糕',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/15.jpg',price:"4",oldprice:""},
  441. // {id: 46,type_id:8,name:'金色香糯大粽子',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/6.jpg',price:"4",oldprice:""},
  442. // {id: 34,type_id:10,name:'马梓林香香鸡',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/14.jpg',price:"4",oldprice:""},
  443. // {id: 35,type_id:10,name:'草莓味莫普氏蛋糕',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/13.jpg',price:"4",oldprice:""},
  444. // {id: 45,type_id:8,name:'金色香糯大粽子',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/6.jpg',price:"4",oldprice:""},
  445. // {id: 36,type_id:10,name:'马梓林香香鸡',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/12.jpg',price:"4",oldprice:""},
  446. // {id: 37,type_id:10,name:'草莓味莫普氏蛋糕',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/11.jpg',price:"4",oldprice:""},
  447. // {id: 38,type_id:11,name:'草莓味莫普氏蛋糕',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/10.jpg',price:"4",oldprice:""},
  448. // {id: 44,type_id:8,name:'金色香糯大粽子',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/6.jpg',price:"4",oldprice:""},
  449. // {id: 39,type_id:12,name:'马梓林香香鸡',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/9.jpg',price:"4",oldprice:""},
  450. // {id: 40,type_id:12,name:'草莓味莫普氏蛋糕',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/8.jpg',price:"4",oldprice:""},
  451. // {id: 13,type_id:13,name:'金色香糯大粽子',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/6.jpg',price:"4",oldprice:""},
  452. // {id: 41,type_id:12,name:'马梓林香香鸡',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/7.jpg',price:"4",oldprice:""},
  453. // {id: 42,type_id:13,name:'草莓味莫普氏蛋糕',descripe:"脆糯营养,口感好,健康绿色",img: '//imgs.1op.cn/i/hxshop/goods/1.jpg',price:"4",oldprice:""}
  454. // ];
  455. }
  456. // 选中菜单
  457. const onMenu = (val) => {
  458. state.activeMenu = val;
  459. if (state.style === 'first_one' || state.style === 'first_two') {
  460. state.pagination.pageNo = 1;
  461. state.pagination.list = [];
  462. state.pagination.total = 0;
  463. getGoodsList();
  464. }
  465. };
  466. // 加载商品列表
  467. async function getGoodsList() {
  468. // 加载列表
  469. state.loadStatus = 'loading';
  470. const res = await SpuApi.getSpuPage({
  471. categoryId: state.categoryList[state.activeMenu].id,
  472. pageNo: state.pagination.pageNo,
  473. pageSize: state.pagination.pageSize,
  474. });
  475. if (res.code !== 0) {
  476. return;
  477. }
  478. // 合并列表
  479. state.pagination.list = _.concat(state.pagination.list, res.data.list);
  480. state.pagination.total = res.data.total;
  481. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  482. }
  483. // 加载更多商品
  484. function loadMore() {
  485. if (state.loadStatus === 'noMore') {
  486. return;
  487. }
  488. state.pagination.pageNo++;
  489. getGoodsList();
  490. }
  491. onLoad(async () => {
  492. await getList();
  493. // 如果是 first 风格,需要加载商品分页
  494. if (state.style === 'first_one' || state.style === 'first_two') {
  495. onMenu(0);
  496. }
  497. });
  498. onLaunch(() => {
  499. console.log('Component is shown');
  500. // 隐藏原生tabBar
  501. uni.hideTabBar();
  502. });
  503. onReachBottom(() => {
  504. loadMore();
  505. });
  506. </script>
  507. <style lang="scss" scoped>
  508. //主题颜色
  509. $hx-theme-color: #FFC107;
  510. $hx-theme-color-light: #FFEB3B;
  511. .s-category {
  512. :deep() {
  513. .side-menu-wrap {
  514. width: 200rpx;
  515. height: 100%;
  516. padding-left: 12rpx;
  517. background-color: #f6f6f6;
  518. .menu-item {
  519. width: 100%;
  520. height: 88rpx;
  521. position: relative;
  522. transition: all linear 0.2s;
  523. .menu-title {
  524. line-height: 32rpx;
  525. font-size: 30rpx;
  526. font-weight: 400;
  527. color: #333;
  528. margin-left: 28rpx;
  529. position: relative;
  530. z-index: 0;
  531. &::before {
  532. content: '';
  533. width: 64rpx;
  534. height: 12rpx;
  535. background: linear-gradient(90deg,
  536. var(--ui-BG-Main-gradient),
  537. var(--ui-BG-Main-light)) !important;
  538. position: absolute;
  539. left: -64rpx;
  540. bottom: 0;
  541. z-index: -1;
  542. transition: all linear 0.2s;
  543. }
  544. }
  545. &.menu-item-active {
  546. background-color: #fff;
  547. border-radius: 20rpx 0 0 20rpx;
  548. &::before {
  549. content: '';
  550. position: absolute;
  551. right: 0;
  552. bottom: -20rpx;
  553. width: 20rpx;
  554. height: 20rpx;
  555. background: radial-gradient(circle at 0 100%, transparent 20rpx, #fff 0);
  556. }
  557. &::after {
  558. content: '';
  559. position: absolute;
  560. top: -20rpx;
  561. right: 0;
  562. width: 20rpx;
  563. height: 20rpx;
  564. background: radial-gradient(circle at 0% 0%, transparent 20rpx, #fff 0);
  565. }
  566. .menu-title {
  567. font-weight: 600;
  568. &::before {
  569. left: 0;
  570. }
  571. }
  572. }
  573. }
  574. }
  575. .right {
  576. width: 76%;
  577. left: 24%;
  578. .goodsListBox {
  579. padding-bottom: 100px;
  580. .category {
  581. // width: 94%;
  582. padding: 0 15px 10px 15px;
  583. .s-item {
  584. height: 45px;
  585. line-height: 45px;
  586. font-size: 16px;
  587. background: #ffffff;
  588. color: #555555;
  589. position: sticky;
  590. top: 0;
  591. z-index: 18;
  592. }
  593. .list:last-child {
  594. margin-bottom: 0;
  595. }
  596. .list {
  597. margin-bottom: 20px;
  598. width: 100%;
  599. display: flex;
  600. flex-wrap: wrap;
  601. .box:first-child {
  602. .m-store-item {
  603. margin-top: 0;
  604. }
  605. }
  606. .box {
  607. width: 100%;
  608. .m-store-item {
  609. display: flex;
  610. flex-direction: row;
  611. width: 100%;
  612. justify-content: space-between;
  613. align-items: flex-end;
  614. margin-top: 15px;
  615. margin-bottom: 15px;
  616. .m-img {
  617. flex: 0 0 85px;
  618. height: 85px;
  619. background: #eee;
  620. border-radius: 4px;
  621. }
  622. .m-text {
  623. flex: 1;
  624. position: relative;
  625. height: 85px;
  626. padding: 0 6px;
  627. display: flex;
  628. align-content: space-between;
  629. flex-direction: column;
  630. .m-title {
  631. font-size: 16px;
  632. color: #555555;
  633. height: 21px;
  634. font-weight: bold;
  635. }
  636. .m-descripe {
  637. font-size: 12px;
  638. color: #999999;
  639. margin-top: 5px;
  640. height: 35px;
  641. }
  642. .m-price-box {
  643. height: 24px;
  644. font-weight: bold;
  645. display: flex;
  646. flex-direction: row;
  647. align-items: flex-end;
  648. .symbol {
  649. color: #ff582b;
  650. font-size: 12px;
  651. }
  652. .m-price {
  653. position: relative;
  654. top: 2px;
  655. font-size: 18px;
  656. color: #ff582b;
  657. }
  658. .m-old-price {
  659. margin-left: 3px;
  660. display: flex;
  661. flex-direction: row;
  662. font-size: 10px;
  663. color: #999999;
  664. margin-top: 5upx;
  665. text-decoration: line-through;
  666. font-weight: normal;
  667. }
  668. }
  669. .m-distance {
  670. position: absolute;
  671. right: 0;
  672. bottom: -4px;
  673. z-index: 16;
  674. color: #b2b2b2;
  675. font-size: 20upx;
  676. text-align: right;
  677. .jumpPosition {
  678. position: absolute;
  679. bottom: 23px;
  680. right: 0;
  681. z-index: 2;
  682. width: 28px;
  683. height: 28px;
  684. }
  685. }
  686. }
  687. }
  688. }
  689. }
  690. }
  691. }
  692. }
  693. .goods-list-box {
  694. background-color: #fff;
  695. width: calc(100vw - 100px);
  696. padding: 10px;
  697. }
  698. .banner-img {
  699. width: calc(100vw - 130px);
  700. border-radius: 5px;
  701. margin-bottom: 20rpx;
  702. }
  703. }
  704. }
  705. .foot{
  706. position: fixed;
  707. display: flex;
  708. z-index: 999;
  709. justify-content:center;
  710. align-items : center;
  711. bottom: 0;
  712. height: 100%;
  713. width: 100%;
  714. /*width: calc(100% - 32px);*/
  715. .btn-box{
  716. position:absolute;
  717. display: flex;
  718. bottom: 15px;
  719. justify-content:center;
  720. align-items : center;
  721. margin:0;
  722. height: 50px;
  723. width: calc(100% - 32px);
  724. z-index: 9;
  725. &-left{
  726. background: #222222;
  727. border-top-left-radius:50px;
  728. border-top-right-radius:9px;
  729. border-bottom-left-radius:50px;
  730. border-bottom-right-radius:9px;
  731. padding-left: 6upx;
  732. display: flex;
  733. flex-direction:column;
  734. justify-content:center;
  735. align-self: center;
  736. width: 70px;
  737. height: 100%;
  738. color: #f6d200;
  739. text-align: center;
  740. .imgBox{
  741. display: flex;
  742. text-align: center;
  743. justify-content:center;
  744. image{
  745. width: 20px;
  746. height: 20px;
  747. }
  748. }
  749. text{
  750. font-size: 20upx;
  751. }
  752. }
  753. &-line{
  754. background: #ffffff;
  755. width: 2px;
  756. height: 100%;
  757. }
  758. &-center{
  759. height: 100%;
  760. flex: auto;
  761. display: flex;
  762. justify-content:flex-start;
  763. align-self: center;
  764. align-items: center;
  765. background: #222222;
  766. border-top-left-radius:8upx;
  767. border-bottom-left-radius:8upx;
  768. padding-left: 10upx;
  769. .cart{
  770. position: relative;
  771. width: 36px;
  772. height: 36px;
  773. image{
  774. width: 100%;
  775. height: 100%;
  776. }
  777. .tag{
  778. position: absolute;
  779. right: 12upx;
  780. top: 16upx;
  781. height: 18px;
  782. width: 18px;
  783. background-color: #ff4000;
  784. color: #ffffff;
  785. border-radius: 50%;
  786. z-index: 1;
  787. font-size: 10px;
  788. text-align: center;
  789. line-height: 18px;
  790. }
  791. }
  792. .priceBox{
  793. flex: auto;
  794. }
  795. }
  796. &-right{
  797. width: 70px;
  798. height: 100%;
  799. position: relative;
  800. display: flex;
  801. justify-content:flex-start;
  802. align-self: center;
  803. align-items: center;
  804. .pscj{
  805. width: 100%;
  806. height: 100%;
  807. border-top-right-radius:100upx;
  808. border-bottom-right-radius:100upx;
  809. background: #222222;
  810. text-align: center;
  811. display: flex;
  812. justify-content:center;
  813. align-self: center;
  814. align-items: center;
  815. }
  816. .jiesuan{
  817. width: 100%;
  818. height: 100%;
  819. font-size: 28upx;
  820. border-top-right-radius:100upx;
  821. border-bottom-right-radius:100upx;
  822. text-align: center;
  823. display: flex;
  824. justify-content:center;
  825. align-self: center;
  826. align-items: center;
  827. background: linear-gradient(45deg, $hx-theme-color-light, $hx-theme-color);
  828. font-weight: bold;
  829. color: #222222;
  830. }
  831. }
  832. }
  833. .zz{
  834. position: absolute;
  835. top: 0;
  836. left: 0;
  837. right: 0;
  838. bottom: 0;
  839. // background-color: rgba(0,0,0,.7);
  840. z-index: 1;
  841. }
  842. .cart-box{
  843. display: flex;
  844. justify-content: flex-start;
  845. flex-flow: column;
  846. background: #ffffff;
  847. position: absolute;
  848. bottom: 0;
  849. z-index: 2;
  850. max-height: 66%;
  851. padding-bottom: 62px;
  852. border-top-left-radius: 16px;
  853. border-top-right-radius: 16px;
  854. overflow: hidden;
  855. width: 100%;
  856. .rebate-box{
  857. height: 30px;
  858. background: #FFC107;
  859. color: #FF9900;
  860. text-align: center;
  861. line-height: 30px;
  862. font-size: 14px;
  863. }
  864. .box-container{
  865. box-sizing: border-box;
  866. padding:0 16px;
  867. }
  868. .operating-box{
  869. font-size: 12px;
  870. line-height: 40px;
  871. height: 40px;
  872. border-bottom: 1px solid #f6f6f6;
  873. color: #666666;
  874. display: flex;
  875. flex-direction: row;
  876. &_right{
  877. flex: 1;
  878. }
  879. &_left{
  880. display: flex;
  881. flex-direction: row;
  882. }
  883. }
  884. .goods-box{
  885. height: 100%;
  886. overflow: hidden;
  887. flex: 1;
  888. display: flex;
  889. .goods-list-scroll{
  890. height: 100%;
  891. .goods-list{
  892. width: 100%;
  893. display: flex;
  894. flex-wrap: wrap;
  895. .box{
  896. width: 100%;
  897. border-bottom: 1px solid #f6f6f6;
  898. box-sizing: border-box;
  899. padding: 0 16px;
  900. .m-store-item{
  901. display: flex;
  902. flex-direction: row;
  903. width: 100%;
  904. justify-content: space-between;
  905. align-items: flex-end;
  906. padding-top: 15px;
  907. padding-bottom: 15px;
  908. .m-img{
  909. flex: 0 0 85px;
  910. height: 85px;
  911. background: #eee;
  912. border-radius: 4px;
  913. }
  914. .m-text{
  915. flex: 1;
  916. position: relative;
  917. height: 85px;
  918. padding: 0 6px;
  919. display: flex;
  920. align-content: space-between;
  921. flex-direction: column;
  922. .m-title{
  923. font-size: 16px;
  924. color:#555555;
  925. height: 21px;
  926. font-weight: bold;
  927. }
  928. .m-descripe{
  929. font-size: 12px;
  930. color:#999999;
  931. margin-top: 5px;
  932. height: 35px;
  933. }
  934. .m-price-box{
  935. height: 24px;
  936. font-weight: bold;
  937. display: flex;
  938. flex-direction: row;
  939. align-items: flex-end;
  940. .symbol{
  941. color:#ff582b;
  942. font-size: 12px;
  943. }
  944. .m-price{
  945. position: relative;
  946. top: 2px;
  947. font-size: 18px;
  948. color:#ff582b;
  949. }
  950. .m-old-price{
  951. margin-left: 3px;
  952. display: flex;
  953. flex-direction: row;
  954. font-size: 10px;
  955. color:#999999;
  956. margin-top: 5upx;
  957. text-decoration: line-through;
  958. font-weight: normal;
  959. }
  960. }
  961. .m-distance{
  962. position: absolute;
  963. right: 0;
  964. bottom: -4px;
  965. z-index: 16;
  966. color:#b2b2b2;
  967. font-size: 20upx;
  968. text-align: right;
  969. .jumpPosition{
  970. position: absolute;
  971. bottom: 23px;
  972. right: 0;
  973. z-index: 2;
  974. width: 28px;
  975. height: 28px;
  976. }
  977. }
  978. }
  979. }
  980. }
  981. }
  982. }
  983. }
  984. }
  985. }
  986. </style>