inline_shop.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="page">
  3. <!-- 购物车 -->
  4. <u-navbar :background="background" title-color="#ffffff" back-icon-color="#ffffff" is-fixed>
  5. <u-search placeholder="请输入轮胎规格" :show-action="false" v-model="keyword"></u-search>
  6. <u-icon @click="handleGo('msg')" name="chat-fill" label="消息" size="36" label-pos="bottom" :margin-right="16"
  7. label-color="#ffffff" :custom-style="iconCustomStyle"></u-icon>
  8. </u-navbar>
  9. <u-sticky >
  10. <view class="filter-wrap wrap-flex">
  11. <u-button :custom-style="buttonCustomStyle" :hair-line="false" hover-class="none" @click="handleGo('mallMenu1')">全部</u-button>
  12. <u-dropdown style="position: static;">
  13. <u-dropdown-item v-model="brandValue" title="品牌" :options="brandOptions"></u-dropdown-item>
  14. <u-dropdown-item v-model="patternValue" title="花纹" :options="patternOptions"></u-dropdown-item>
  15. </u-dropdown>
  16. <u-button :custom-style="buttonCustomStyle" :hair-line="false" hover-class="none" @click="showFilterPopup=true">筛选
  17. <u-icon name="grid"></u-icon>
  18. </u-button>
  19. </view>
  20. </u-sticky>
  21. <scroll-view scroll-y="true" @scrolltolower="scrollBottom" class="scroll-view-container">
  22. <view class="page-box">
  23. <u-waterfall v-model="goodsList" ref="uWaterfall">
  24. <template v-slot:left="{leftList}">
  25. <view class="demo-warter" v-for="(item, index) in leftList" :key="index" @click="handleGoDetails">
  26. <!-- 警告:微信小程序中需要hx2.8.11版本才支持在template中结合其他组件,比如下方的lazy-load组件 -->
  27. <u-lazy-load threshold="-450" border-radius="10" :image="item.image" :index="index"></u-lazy-load>
  28. <view class="demo-title">
  29. {{item.title}}
  30. </view>
  31. <!-- <view class="demo-price">
  32. {{item.price}}元
  33. </view> -->
  34. <!-- <view class="demo-tag">
  35. <view class="demo-tag-owner">
  36. 自营
  37. </view>
  38. <view class="demo-tag-text">
  39. 放心购
  40. </view>
  41. </view> -->
  42. <view class="demo-shop">
  43. 库存:{{item.count}}
  44. </view>
  45. <view class="shopping-car"><u-icon :custom-style="iconCustomStyleCar" color="#ffffff" name="car"></u-icon></view>
  46. </view>
  47. </template>
  48. <template v-slot:right="{rightList}">
  49. <view class="demo-warter" v-for="(item, index) in rightList" :key="index" @click="handleGoDetails">
  50. <u-lazy-load threshold="-450" border-radius="10" :image="item.image" :index="index"></u-lazy-load>
  51. <view class="demo-title">
  52. {{item.title}}
  53. </view>
  54. <!-- <view class="demo-price">
  55. {{item.price}}元
  56. </view> -->
  57. <!-- <view class="demo-tag">
  58. <view class="demo-tag-owner">
  59. 自营
  60. </view>
  61. <view class="demo-tag-text">
  62. 放心购
  63. </view>
  64. </view> -->
  65. <view class="demo-shop">
  66. 库存:{{item.count}}
  67. </view>
  68. <view class="shopping-car"><u-icon :custom-style="iconCustomStyleCar" name="car" color="#ffffff"></u-icon></view>
  69. </view>
  70. </template>
  71. </u-waterfall>
  72. <u-loadmore :status="loadStatus" bgColor="#f2f2f2"></u-loadmore>
  73. </view>
  74. </scroll-view>
  75. <view id="shopping-car" @click="handleGoCar"><u-icon :custom-style="iconCustomStyleCarFixed" size="48" name="car" color="#9999999"></u-icon><u-badge :offset="[-8,-8]" :count="goodsCounts" type="error"></u-badge></view>
  76. <u-popup v-model="showFilterPopup" mode="right" width="60%">
  77. <view class="filter-title">筛选</view>
  78. <block v-for="(item,index) in tabbar" :key="index">
  79. <scroll-view scroll-y class="right-box">
  80. <view class="page-view">
  81. <view class="class-item">
  82. <view class="item-title">
  83. <text>{{item.name}}</text>
  84. </view>
  85. <view class="item-container">
  86. <view class="thumb-box" v-for="(item1, index1) in item.foods" :key="index1">
  87. <view class="item-menu-name">{{item1.value}}</view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </scroll-view>
  93. </block>
  94. </u-popup>
  95. </view>
  96. </template>
  97. <script>
  98. export default {
  99. data() {
  100. return {
  101. background: {
  102. backgroundColor: "#0291FD",
  103. color: "#ffffff"
  104. },
  105. iconCustomStyle: {
  106. padding: "24rpx 14rpx 14rpx 14rpx"
  107. },
  108. iconCustomStyleCar: {
  109. background: "#0291FD",
  110. padding: "16rpx",
  111. borderRadius: "50%"
  112. },
  113. iconCustomStyleCarFixed: {
  114. background: "#ffffff",
  115. padding: "16rpx",
  116. borderRadius: "50%",
  117. boxShadow: "0px 1px 12px 0px rgba(116, 116, 116, 0.6)"
  118. },
  119. buttonCustomStyle: {
  120. border: "none"
  121. },
  122. keyword: "",
  123. allValue: "",
  124. brandValue: "",
  125. brandOptions: [{
  126. label: "赛轮",
  127. value: "SAILUN"
  128. }, {
  129. label: "金宇",
  130. value: "jinyu"
  131. }],
  132. patternValue: "",
  133. patternOptions: [{
  134. label: "SH08",
  135. value: "SH08"
  136. }, {
  137. label: "RH07",
  138. value: "RH07"
  139. }],
  140. showFilterPopup: false,
  141. tabbar: [{
  142. "name": "品牌",
  143. "foods": [{
  144. "value": "赛轮",
  145. "label": "SAILUN",
  146. },
  147. {
  148. "value": "金宇",
  149. "label": "jinyu",
  150. },
  151. ]
  152. }],
  153. loadStatus: 'loadmore',
  154. goodsCounts: 99,//购物车商品数
  155. goodsList: [],
  156. list: [{
  157. price: 35,
  158. title: '175/70R14 88T XL SH08 BGSL',
  159. count: '100',
  160. image: 'https://img12.360buyimg.com/n7/jfs/t16642/126/2693663818/450163/6879e8ce/5b06d93bN6305bd94.png',
  161. },
  162. {
  163. price: 75,
  164. title: '175/70R14 88T XL SH08 BGSL',
  165. count: '100',
  166. image: 'https://img12.360buyimg.com/n7/jfs/t1/47645/22/6120/140457/5d3d17deEec9f8e8d/3687ff03ca89b48c.jpg',
  167. },
  168. {
  169. price: 385,
  170. title: '175/70R14 88T XL SH08 BGSL',
  171. count: '100',
  172. image: 'https://img11.360buyimg.com/n7/jfs/t1/88990/24/4208/105799/5de4c6e9E24bc09d0/f810effb14c9c13a.jpg',
  173. },
  174. {
  175. price: 784,
  176. title: '175/70R14 88T XL SH08 BGSL',
  177. count: '100',
  178. image: 'https://img12.360buyimg.com/n7/jfs/t1/93698/23/4500/114562/5de713dfEfc997085/e8deaa979909851d.jpg',
  179. },
  180. {
  181. price: 7891,
  182. title: '175/70R14 88T XL SH08 BGSL',
  183. count: '100',
  184. image: 'https://img11.360buyimg.com/n7/jfs/t16642/126/2693663818/450163/6879e8ce/5b06d93bN6305bd94.png',
  185. },
  186. {
  187. price: 2341,
  188. count: '100',
  189. title: '175/70R14 88T XL SH08 BGSL',
  190. image: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  191. },
  192. {
  193. price: 661,
  194. count: '100',
  195. title: '175/70R14 88T XL SH08 BGSL',
  196. image: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  197. },
  198. {
  199. price: 1654,
  200. title: '175/70R14 88T XL SH08 BGSL',
  201. count: '100',
  202. image: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  203. },
  204. {
  205. price: 1678,
  206. title: '175/70R14 88T XL SH08 BGSL',
  207. count: '100',
  208. image: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  209. },
  210. {
  211. price: 924,
  212. title: '175/70R14 88T XL SH08 BGSL',
  213. count: '100',
  214. image: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  215. },
  216. {
  217. price: 8243,
  218. title: '175/70R14 88T XL SH08 BGSL',
  219. count: '100',
  220. image: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  221. },
  222. ]
  223. }
  224. },
  225. onLoad() {
  226. this.addRandomData();
  227. },
  228. methods: {
  229. scrollBottom: function(){
  230. console.log("到底了")
  231. this.loadStatus = 'loading';
  232. // 模拟数据加载
  233. setTimeout(() => {
  234. this.addRandomData();
  235. this.loadStatus = 'loadmore';
  236. }, 1000)
  237. },
  238. handleGo: function(value) {
  239. var urlStr = ""
  240. switch (value) {
  241. case "msg":
  242. urlStr: "../../msg/index";
  243. break;
  244. case "mallMenu1":
  245. urlStr: "../../mallMenu/index1";
  246. break;
  247. case "mallMenu2":
  248. urlStr: "../../mallMenu2/index2";
  249. break;
  250. };
  251. uni.switchTab({
  252. url: urlStr
  253. });
  254. },
  255. handleGoDetails: function(){
  256. uni.navigateTo({
  257. url: "/pages/home/inline-shop/inline_shop_details"
  258. })
  259. },
  260. handleGoCar: function(){
  261. console.log("进入购物车")
  262. uni.navigateTo({
  263. url: "/pages/home/inline-shop/inline_shop_car"
  264. })
  265. },
  266. addRandomData() {
  267. for (let i = 0; i < 10; i++) {
  268. let index = this.$u.random(0, this.list.length - 1);
  269. // 先转成字符串再转成对象,避免数组对象引用导致数据混乱
  270. let item = JSON.parse(JSON.stringify(this.list[index]))
  271. item.id = this.$u.guid();
  272. this.goodsList.push(item);
  273. };
  274. },
  275. }
  276. }
  277. </script>
  278. <style lang="scss" scoped>
  279. .wrap-flex {
  280. display: flex;
  281. }
  282. .filter-wrap {
  283. background: #ffffff;
  284. }
  285. .filter-title {
  286. background: #F6F6F6;
  287. padding: 16rpx;
  288. }
  289. .class-item {
  290. margin-bottom: 30rpx;
  291. background-color: #fff;
  292. padding: 16rpx;
  293. border-radius: 8rpx;
  294. }
  295. .class-item:last-child {
  296. min-height: 100vh;
  297. }
  298. .item-title {
  299. font-size: 26rpx;
  300. color: $u-main-color;
  301. font-weight: bold;
  302. }
  303. .item-menu-name {
  304. font-weight: normal;
  305. font-size: 24rpx;
  306. color: $u-main-color;
  307. }
  308. .item-container {
  309. display: flex;
  310. flex-wrap: wrap;
  311. }
  312. .thumb-box {
  313. width: 33.333333%;
  314. display: flex;
  315. align-items: center;
  316. justify-content: center;
  317. flex-direction: column;
  318. margin: 20px 16rpx 0;
  319. background: #f6f6f6;
  320. padding: 8rpx;
  321. }
  322. .scroll-view-container{
  323. width: 100%;
  324. height: calc(100vh - 176rpx);
  325. }
  326. .demo-warter {
  327. border-radius: 8px;
  328. margin: 5px;
  329. background-color: #ffffff;
  330. padding: 8px;
  331. position: relative;
  332. }
  333. .u-close {
  334. position: absolute;
  335. top: 32rpx;
  336. right: 32rpx;
  337. }
  338. .demo-image {
  339. width: 100%;
  340. border-radius: 4px;
  341. }
  342. .demo-title {
  343. font-size: 30rpx;
  344. margin-top: 5px;
  345. color: $u-main-color;
  346. }
  347. .demo-tag {
  348. display: flex;
  349. margin-top: 5px;
  350. }
  351. .demo-tag-owner {
  352. background-color: $u-type-error;
  353. color: #FFFFFF;
  354. display: flex;
  355. align-items: center;
  356. padding: 4rpx 14rpx;
  357. border-radius: 50rpx;
  358. font-size: 20rpx;
  359. line-height: 1;
  360. }
  361. .demo-tag-text {
  362. border: 1px solid $u-type-primary;
  363. color: $u-type-primary;
  364. margin-left: 10px;
  365. border-radius: 50rpx;
  366. line-height: 1;
  367. padding: 4rpx 14rpx;
  368. display: flex;
  369. align-items: center;
  370. border-radius: 50rpx;
  371. font-size: 20rpx;
  372. }
  373. .demo-price {
  374. font-size: 30rpx;
  375. color: $u-type-error;
  376. margin-top: 5px;
  377. }
  378. .demo-shop {
  379. font-size: 22rpx;
  380. color: $u-tips-color;
  381. margin-top: 5px;
  382. }
  383. .shopping-car{
  384. position: absolute;
  385. bottom: 4rpx;
  386. right: 16rpx;
  387. }
  388. #shopping-car{
  389. position: fixed;
  390. z-index: 9999;
  391. right: 26rpx;
  392. bottom: 300rpx;
  393. }
  394. </style>