inline_shop.vue 11 KB

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