more.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. <!-- 盲盒商城 -->
  2. <template>
  3. <view class="more">
  4. <view class="banner"><image src="https://www.chaomangdao.com/image/home/banner@2x.png" mode=""></image></view>
  5. <view class="small">
  6. <view class="small-item">
  7. <view class="small-image"><image src="https://www.chaomangdao.com/image/home/small1.png" mode=""></image></view>
  8. <view class="small-font">新手帮助</view>
  9. </view>
  10. <view class="small-item" @click="navTo('/pages/me/recharge')">
  11. <view class="small-image"><image src="https://www.chaomangdao.com/image/home/small2.png" mode=""></image></view>
  12. <view class="small-font">优惠充值</view>
  13. </view>
  14. <view class="small-item" @click="navTo('/pages/me/balance')">
  15. <view class="small-image"><image src="https://www.chaomangdao.com/image/home/small3.png" mode=""></image></view>
  16. <view class="small-font">我的余额</view>
  17. </view>
  18. <view class="small-item" @click="navTo('/pages/tabbar/box')">
  19. <view class="small-image"><image src="https://www.chaomangdao.com/image/home/small4.png" mode=""></image></view>
  20. <view class="small-font">我的盒柜</view>
  21. </view>
  22. </view>
  23. <view class="more_head flex">
  24. <view class="more_head_li flexs" :class="{ active: index == i }" v-for="(item, index) in list" :key="index" @click="changeHead(index)">
  25. <text>{{ item.name }}</text>
  26. </view>
  27. </view>
  28. <view class="home_recommend_ul flex">
  29. <view class="home_recommend_li" v-for="(item, index) in boxList" :key="index" @click="goMessage(item, 0)">
  30. <view class="home_recommend_li_img">
  31. <view class="home_recommend_li_img_top flex">
  32. <view class="home_recommend_li_img_box"><image :src="item.image" mode="aspectFill"></image></view>
  33. </view>
  34. </view>
  35. <view class="home_recommend_li_main">
  36. <view class="home_recommend_li_name">{{ item.box_name }}</view>
  37. <view class="home_recommend_li_glod flex">
  38. <image src="https://www.chaomangdao.com/image/home/gold.png" mode=""></image>
  39. <view class="home_recommend_li_glod_font">{{ item.coin_price }}金币</view>
  40. </view>
  41. <view class="home_recommend_li_price">
  42. <view class="home_recommend_li_price_icon">
  43. <view class="home_recommend_li_price_icon_bg"><image src="https://www.chaomangdao.com/image/home/bdbz.png" mode=""></image></view>
  44. <view class="home_recommend_li_price_icon_font">保底必中</view>
  45. </view>
  46. <view class="home_recommend_li_price_font">{{ item.price_min }}元~{{ item.price_max }}元</view>
  47. </view>
  48. <view class="home_recommend_shop">
  49. <view class="home_recommend_li_img_right" v-if="item.right.length != 0">
  50. <view class="home_recommend_li_img_bot"><image :src="items" mode="aspectFill" v-for="(items, index) in item.bot" :key="index"></image></view>
  51. <image :src="items" mode="aspectFill" v-for="(items, index) in item.right" :key="index"></image>
  52. </view>
  53. <text>共{{ item.goods_num }}款商品</text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="screen" :style="{ width: isShow ? '600rpx' : 0 }">
  59. <view class="screen_box">
  60. <view class="screen_name">价格区间</view>
  61. <view class="screen_head flexs">
  62. <view class="screen_ipt center"><input type="number" v-model="minPrice" placeholder="最低价" placeholder-style="color:#999999" /></view>
  63. <view class="screen_head_line"></view>
  64. <view class="screen_ipt center"><input type="number" v-model="maxPrice" placeholder="最高价" placeholder-style="color:#999999" /></view>
  65. </view>
  66. <view class="screen_ul flexs">
  67. <view class="screen_li center" :class="{ active: index == selectPrice }" v-for="(item, index) in priceList" :key="index" @click="selectprice(index)">
  68. {{ item }}
  69. </view>
  70. </view>
  71. </view>
  72. <view class="screen_footer flex">
  73. <view class="screen_footer_li center" v-for="(item, index) in 2" :key="index" @click="reset(index)">{{ index == 0 ? '重置' : '确定' }}</view>
  74. </view>
  75. </view>
  76. <view class="marking" v-if="isShow"></view>
  77. <!-- <uni-popup ref="popup" :mask-click="false" type="right">
  78. </uni-popup> -->
  79. <!-- <uni-drawer ref="popup" mode="right" :mask-click="false">
  80. <scroll-view style="height: 100%;" scroll-y="true">
  81. <button @click="closeDrawer" type="primary">关闭Drawer</button>
  82. <view v-for="item in 60" :key="item">可滚动内容 {{ item }}</view>
  83. </scroll-view>
  84. </uni-drawer> -->
  85. </view>
  86. </template>
  87. <script>
  88. export default {
  89. data() {
  90. return {
  91. i: 0,
  92. page: 1,
  93. pages: 0,
  94. price: '', //加个排序
  95. sort: '', //排序
  96. list: [{ name: '新品', type: 0 }, { name: '综合', type: 0 }, { name: '价格', type: 0 }, { name: '筛选', type: 0 }],
  97. boxList: [], //
  98. isShow: false,
  99. selectPrice: -1, //选择哪个价钱
  100. minPrice: '', //最低价
  101. maxPrice: '', //最高价
  102. priceList: [] //价格区间
  103. };
  104. },
  105. methods: {
  106. //去详情
  107. goMessage(item, type) {
  108. uni.navigateTo({ url: '/pages/index/details?id=' + item.box_id + '&type=' + type });
  109. },
  110. //重置
  111. reset(index) {
  112. if (index == 0) {
  113. this.minPrice = '';
  114. this.maxPrice = '';
  115. this.selectPrice = -1;
  116. } else {
  117. this.price = (this.minPrice == 0 || this.minPrice) && this.maxPrice ? this.minPrice + '-' + this.maxPrice : '';
  118. this.isShow = false;
  119. this.list[3].type = 0;
  120. this.getBoxListByCategory();
  121. }
  122. },
  123. //选择价钱
  124. selectprice(index) {
  125. this.selectPrice = index == this.selectPrice ? -1 : index;
  126. if (this.selectPrice != -1) {
  127. this.minPrice = this.priceList[index].split('-')[0];
  128. this.maxPrice = this.priceList[index].split('-')[1];
  129. }
  130. },
  131. changeHead(index) {
  132. this.page = 1;
  133. this.i = index;
  134. // this.list[index].type = this.list[index].type == 0 ? 1 : 0;
  135. // if (index == 0) {
  136. // this.sort = 'new';
  137. // } else if (index == 1) {
  138. // this.sort = this.list[index].type == 0 ? 'combine_desc' : 'combine_asc';
  139. // } else if (index == 2) {
  140. // this.sort = this.list[index].type == 0 ? 'price_desc' : 'price_asc';
  141. // } else {
  142. // this.list[index].type == 1 ? (this.isShow = true) : (this.isShow = false);
  143. // return;
  144. // }
  145. this.getBoxListByCategory(this.list[index].category_id);
  146. },
  147. returnTop() {
  148. uni.navigateBack();
  149. },
  150. getBoxListByCategory(id) {
  151. this.$api.search({ page: this.page, msg: '数据加载中', sort: this.sort, price: this.price, category_id: id }).then(res => {
  152. if (res.code === 1) {
  153. res.data.data.forEach(item => {
  154. item.image = item.goods_images[0];
  155. item.right = [];
  156. item.bot = [];
  157. item.goods_images.forEach((em, index) => {
  158. if (index > 0 && index < 3) {
  159. item.right.push(em);
  160. }
  161. if (index > 2) {
  162. item.bot.push(em);
  163. }
  164. });
  165. });
  166. (this.boxList = this.page == 1 ? res.data.data : [...rhis.boxList, ...res.data.data]), (this.pages = res.data.last_page);
  167. }
  168. });
  169. },
  170. //获取价格区间
  171. getPriceList() {
  172. this.$api.priceRange().then(res => {
  173. if (res.code === 1) {
  174. this.priceList = res.data.range;
  175. }
  176. });
  177. },
  178. navTo(url) {
  179. uni.navigateTo({
  180. url,
  181. fail() {
  182. uni.switchTab({
  183. url
  184. });
  185. }
  186. });
  187. },
  188. classify() {
  189. this.$api.categoryList({ page: 1, limit: 1000 }).then(({ data }) => {
  190. data.unshift({ category_id: 0, name: '全部' });
  191. this.list = data;
  192. this.getBoxListByCategory(this.list[0].category_id);
  193. });
  194. }
  195. },
  196. onLoad() {
  197. this.classify();
  198. this.getPriceList();
  199. },
  200. onPullDownRefresh() {
  201. this.page = 1;
  202. this.getBoxListByCategory();
  203. },
  204. onReachBottom() {
  205. if (this.page < this.pages) {
  206. this.page++;
  207. this.getBoxListByCategory();
  208. }
  209. }
  210. };
  211. </script>
  212. <style lang="scss">
  213. .more,
  214. page {
  215. min-height: 100%;
  216. height: auto;
  217. background: #fff6f7;
  218. }
  219. .screen {
  220. position: fixed;
  221. bottom: 0;
  222. right: 0;
  223. width: 0;
  224. overflow: hidden;
  225. height: calc(100vh - 88px);
  226. background: #ffffff;
  227. z-index: 2021;
  228. transition: all 0.2s ease;
  229. .screen_box {
  230. padding: 30rpx 20rpx 0 30rpx;
  231. .screen_name {
  232. font-size: 28rpx;
  233. margin-bottom: 24rpx;
  234. }
  235. .screen_head {
  236. .screen_ipt {
  237. width: 168rpx;
  238. height: 64rpx;
  239. padding: 0 30rpx;
  240. background: #f5f5f5;
  241. border-radius: 32rpx;
  242. input {
  243. font-size: 26rpx;
  244. text-align: center;
  245. }
  246. }
  247. .screen_head_line {
  248. width: 27rpx;
  249. height: 3rpx;
  250. margin: 0 20rpx;
  251. background: #999999;
  252. }
  253. }
  254. .screen_ul {
  255. flex-wrap: wrap;
  256. .screen_li {
  257. width: 166rpx;
  258. height: 64rpx;
  259. margin: 24rpx 24rpx 0 0;
  260. font-size: 26rpx;
  261. background: #f5f5f5;
  262. border-radius: 32rpx;
  263. &:nth-child(3n) {
  264. margin-right: 0;
  265. }
  266. }
  267. .active {
  268. color: #ffffff;
  269. background: #f6af32;
  270. }
  271. }
  272. }
  273. .screen_footer {
  274. width: 100%;
  275. bottom: 0;
  276. position: absolute;
  277. .screen_footer_li {
  278. width: 260rpx;
  279. height: 68rpx;
  280. color: #666666;
  281. font-size: 32rpx;
  282. background: #f5f5f5;
  283. &:last-child {
  284. color: #ffffff;
  285. background: #f6af32;
  286. }
  287. }
  288. }
  289. }
  290. .marking {
  291. position: fixed;
  292. bottom: 0;
  293. right: 0;
  294. width: 100%;
  295. height: calc(100vh - 88px);
  296. background: rgba(0, 0, 0, 0.5);
  297. }
  298. .banner {
  299. width: 715rpx;
  300. height: 317rpx;
  301. margin: 0 auto;
  302. image {
  303. width: 100%;
  304. height: 100%;
  305. }
  306. }
  307. .small {
  308. margin-top: 24rpx;
  309. width: 100%;
  310. display: flex;
  311. justify-content: space-around;
  312. align-items: center;
  313. .small-item {
  314. width: 25%;
  315. display: flex;
  316. flex-direction: column;
  317. justify-content: center;
  318. align-items: center;
  319. line-height: 1;
  320. .small-image {
  321. width: 64rpx;
  322. height: 64rpx;
  323. image {
  324. width: 100%;
  325. height: 100%;
  326. }
  327. }
  328. .small-font {
  329. margin-top: 16rpx;
  330. font-size: 22rpx;
  331. font-family: PingFang SC;
  332. font-weight: bold;
  333. color: #333333;
  334. }
  335. }
  336. }
  337. .more_head {
  338. width: 100%;
  339. height: 88rpx;
  340. z-index: 20;
  341. margin-bottom: 30rpx;
  342. justify-content: start;
  343. margin-top: 20rpx;
  344. .more_head_li {
  345. margin: 0 30rpx;
  346. padding-bottom: 10rpx;
  347. text {
  348. font-size: 30rpx;
  349. }
  350. image {
  351. width: 22rpx;
  352. height: 22rpx;
  353. transition: all 0.2s ease;
  354. margin-left: 10rpx;
  355. }
  356. .handstand {
  357. transform: rotate(180deg);
  358. }
  359. &.active {
  360. text {
  361. color: #6087f6;
  362. }
  363. border-bottom: 2px solid #6087f6;
  364. }
  365. }
  366. }
  367. .home_recommend_ul {
  368. flex-wrap: wrap;
  369. padding: 0 28rpx;
  370. .home_recommend_li {
  371. width: 700rpx;
  372. background: #ffffff;
  373. border-radius: 15rpx;
  374. padding: 20rpx;
  375. margin-bottom: 30rpx;
  376. background: #ffffff;
  377. box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(153, 153, 153, 0.1);
  378. border-radius: 10rpx;
  379. display: flex;
  380. align-items: center;
  381. .home_recommend_li_img {
  382. width: 190rpx;
  383. height: 190rpx;
  384. .home_recommend_li_img_box {
  385. image {
  386. width: 190rpx;
  387. height: 190rpx;
  388. border-radius: 6rpx;
  389. }
  390. }
  391. }
  392. .home_recommend_li_main {
  393. padding-left: 10rpx;
  394. }
  395. .home_recommend_li_price {
  396. padding: 0 8rpx 0 0;
  397. margin: 10rpx 0 0;
  398. background: #fff1eb;
  399. display: flex;
  400. align-items: center;
  401. border-top-right-radius: 14rpx;
  402. border-bottom-right-radius: 14rpx;
  403. .home_recommend_li_price_icon {
  404. position: relative;
  405. width: 124rpx;
  406. height: 32rpx;
  407. padding-left: 36rpx;
  408. .home_recommend_li_price_icon_bg {
  409. position: absolute;
  410. top: 0;
  411. left: 0;
  412. right: 0;
  413. width: 124rpx;
  414. height: 32rpx;
  415. imgae {
  416. width: 100%;
  417. height: 100%;
  418. }
  419. }
  420. .home_recommend_li_price_icon_font {
  421. position: relative;
  422. z-index: 2;
  423. font-size: 18rpx;
  424. font-family: PingFang SC;
  425. font-weight: bold;
  426. color: #ffffff;
  427. line-height: 32rpx;
  428. }
  429. }
  430. .home_recommend_li_price_font {
  431. font-size: 24rpx;
  432. font-family: PingFang SC;
  433. font-weight: bold;
  434. color: #ff2829;
  435. line-height: 32rpx;
  436. }
  437. }
  438. .home_recommend_li_name {
  439. font-family: PingFang SC;
  440. font-weight: bold;
  441. color: #333333;
  442. font-size: 28rpx;
  443. display: -webkit-box;
  444. -webkit-box-orient: vertical;
  445. -webkit-line-clamp: 2;
  446. overflow: hidden;
  447. }
  448. .home_recommend_li_glod {
  449. justify-content: flex-start;
  450. align-items: center;
  451. margin-top: 22rpx;
  452. image {
  453. width: 32rpx;
  454. height: 32rpx;
  455. }
  456. .home_recommend_li_glod_font {
  457. font-size: 24rpx;
  458. font-family: PingFang SC;
  459. font-weight: bold;
  460. color: #ff281e;
  461. margin-left: 10rpx;
  462. }
  463. }
  464. }
  465. }
  466. .home_recommend_shop {
  467. margin-top: 10rpx;
  468. display: flex;
  469. align-items: flex-end;
  470. text {
  471. font-size: 16rpx;
  472. font-family: PingFang SC;
  473. font-weight: bold;
  474. color: #999999;
  475. }
  476. }
  477. .home_recommend_li_img_right {
  478. display: flex;
  479. align-items: center;
  480. image {
  481. width: 50rpx;
  482. height: 50rpx;
  483. background: #ffffff;
  484. border: 1px solid #e2e2e2;
  485. border-radius: 5rpx;
  486. margin-right: 10rpx;
  487. &:last-child {
  488. margin-right: 0;
  489. }
  490. }
  491. .home_recommend_li_img_bot {
  492. display: flex;
  493. align-items: center;
  494. image {
  495. width: 50rpx;
  496. height: 50rpx;
  497. background: #ffffff;
  498. border: 1px solid #e2e2e2;
  499. border-radius: 5rpx;
  500. margin-right: 10rpx;
  501. }
  502. }
  503. }
  504. </style>