Bargain.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <view :class="[AppTheme]" class="box">
  3. <view class="carousel" v-show="carouselList">
  4. <view @click="add" style="padding: 10rpx;">
  5. <u-swiper :list="carouselList" keyName="ad_pic" showTitle :autoplay="false" circular @click="navtopage">
  6. </u-swiper>
  7. </view>
  8. </view>
  9. <view style="margin:20upx 30upx;">
  10. <u-search placeholder="输入商品名称搜索" height="35" inputAlign="center" bgColor="#fff" v-model="keyword"
  11. @search="search" :showAction="false"></u-search>
  12. </view>
  13. <view class="head_fixation">
  14. <u-tabs style="background-color: #fff;" :scrollable="false" ref="uTabs" :list="dataList" lineWidth="30"
  15. :lineColor="primary" :activeStyle="{
  16. color: primary,
  17. transform: 'scale(1.05)'
  18. }" :inactiveStyle="{
  19. color: '#606266',
  20. transform: 'scale(1)'
  21. }" :current="current" @click="tab">
  22. </u-tabs>
  23. </view>
  24. <view class="NewProducts">
  25. <swiper class="swiper-box" :current="current" @change="transition">
  26. <swiper-item v-for="item in dataList">
  27. <scroll-view class="scroll-box" :scroll-y='true'>
  28. <view class="content">
  29. <view class="content_box" v-for="item in list" :key="item.id">
  30. <u-image :src="item.apppic" radius="10rpx" width="344rpx" height="340rpx"
  31. :lazyLoad="true" :fade="true" duration="450">
  32. <view slot="error" style="font-size: 24rpx;">加载失败</view>
  33. </u-image>
  34. <view class="message">
  35. <p style="font-size: 12px;">{{item.name}}</p>
  36. <view class="message_bot">
  37. <view class="f_left">
  38. <view class="text">
  39. <view>低价:</view>
  40. <view class="color_org text-neutral">¥{{item.price}}</view>
  41. </view>
  42. <p class="old_price">原价:¥{{item.oprice}}</p>
  43. </view>
  44. <view class="f_right bg-linear-gradient" @click="go(item)">立即砍价</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view style="width: 100%;">
  49. <u-empty marginTop="100" style="height: 100% !important;width: 100vw;"
  50. v-if="list.length==0" text="暂无更多数据" mode="list"></u-empty>
  51. </view>
  52. </view>
  53. </scroll-view>
  54. </swiper-item>
  55. </swiper>
  56. </view>
  57. </view>
  58. </template>
  59. <!-- 商城 -->
  60. <script>
  61. import api from '@/api/mall/index.js'
  62. import {
  63. mapState
  64. } from 'vuex'
  65. import homeApi from '@/api/home/index.js';
  66. export default {
  67. data() {
  68. return {
  69. current: 0,
  70. primary: this.$theme.primary,
  71. // dataList: ['全部', '砍价中', '已购买'],
  72. dataList: [{
  73. name: '全部'
  74. },
  75. {
  76. name: '砍价中'
  77. },
  78. {
  79. name: '已购买'
  80. }
  81. ],
  82. carouselList: [],
  83. type: 1, //1 全部 2 砍价中 3 已购买
  84. p: 1,
  85. keyword: '',
  86. list: [],
  87. settingFile: getApp().globalData.siteinfo
  88. };
  89. },
  90. onLoad() {
  91. this.getlist() //默认请求全部
  92. this.advertisement() //请求广告
  93. },
  94. computed: {
  95. ...mapState(['userInfo'])
  96. },
  97. methods: {
  98. transition(e) { //swiper切换
  99. this.list = []
  100. this.current = e.detail.current
  101. let data = {
  102. type: this.current + 1,
  103. p: 1
  104. }
  105. api.barlist(data).then(ret => {
  106. this.list = this.list.concat(ret.data.cache)
  107. })
  108. },
  109. navToDetailPage(id) {
  110. uni.navigateTo({
  111. url: `/pagesD/pages/mall/Bargain_cart?id=${id}`
  112. });
  113. },
  114. navtopage(item) {
  115. homeApi.navtopage(item);
  116. },
  117. advertisement() {
  118. api.advertisement().then(res => {
  119. var list = res.data.filter(item => item.pid == 11);
  120. if (list.length) {
  121. this.carouselList = list;
  122. } else {
  123. this.carouselList = 0;
  124. }
  125. })
  126. },
  127. tab(e) {
  128. this.list = []
  129. console.log(e, "eeeee")
  130. this.type = e.index + 1
  131. this.getlist()
  132. },
  133. search() {
  134. let that = this
  135. let data = {
  136. type: that.type,
  137. p: that.p,
  138. name: encodeURI(that.keyword)
  139. }
  140. api.barlist(data).then(ret => {
  141. this.list = ret.data.cache
  142. })
  143. },
  144. getlist() {
  145. let that = this
  146. let data = {
  147. type: that.type,
  148. p: that.p
  149. }
  150. api.barlist(data).then(ret => {
  151. this.list = this.list.concat(ret.data.cache)
  152. })
  153. },
  154. go(item) {
  155. uni.navigateTo({
  156. url: "./Bargain_cart?id=" + item.id
  157. })
  158. },
  159. add() {
  160. api.barlist({
  161. type: 1,
  162. p: 1
  163. }).then(res => {
  164. this.list = this.list.concat(res.data.cache)
  165. })
  166. }
  167. },
  168. onReachBottom() {
  169. if (this.list.length == 10) {
  170. this.p++
  171. let that = this
  172. let data = {
  173. type: that.type,
  174. p: that.p
  175. }
  176. api.barlist(data).then(res => {
  177. if (res.status == 200) {
  178. this.list = this.list.concat(ret.data.cache)
  179. } else {
  180. this.p--
  181. }
  182. })
  183. }
  184. }
  185. };
  186. </script>
  187. <style lang="scss">
  188. $color-fff: #fff;
  189. @mixin lineH($index) {
  190. height: $index;
  191. line-height: $index;
  192. }
  193. page {
  194. background: #f5f5f5;
  195. }
  196. u-search view:first-child {
  197. margin-top: 2px;
  198. }
  199. .box {
  200. padding-bottom: 90upx;
  201. .NewProducts {
  202. padding-top: 10rpx;
  203. .swiper-box {
  204. height: calc(100vh - 295px);
  205. .scroll-box {
  206. height: 100%;
  207. overflow-y: scroll;
  208. .content {
  209. display: flex;
  210. flex-wrap: wrap;
  211. padding: 0 20rpx;
  212. padding-bottom: 11px;
  213. justify-content: space-between;
  214. .content_box {
  215. border-radius: 10px;
  216. margin-bottom: 20rpx;
  217. box-shadow: $box-shadow;
  218. width: 345rpx;
  219. min-height: 500rpx;
  220. display: inline-block;
  221. margin-top: 10rpx;
  222. .new-img {
  223. width: 100%;
  224. height: 355rpx;
  225. }
  226. .message {
  227. box-sizing: border-box;
  228. padding: 20rpx;
  229. p {
  230. font-size: 28rpx !important;
  231. line-height: 40rpx;
  232. overflow: hidden;
  233. text-overflow: ellipsis;
  234. white-space: nowrap;
  235. }
  236. .message_bot {
  237. height: 84rpx;
  238. margin-top: 20rpx;
  239. border-top: 0.5rpx solid #efefef;
  240. display: flex;
  241. justify-content: space-between;
  242. .f_left {
  243. margin-top: 10rpx;
  244. font-size: 24rpx;
  245. .text {
  246. display: flex;
  247. justify-content: flex-start;
  248. margin-bottom: 10rpx;
  249. align-items: center;
  250. font-size: 28rpx;
  251. height: 35upx;
  252. .color_org {
  253. margin-left: 15rpx;
  254. }
  255. }
  256. .old_price {
  257. color: #999;
  258. font-size: 28rpx;
  259. text-decoration: line-through;
  260. }
  261. }
  262. .f_right {
  263. height: 50rpx;
  264. width: 116rpx;
  265. padding: 5rpx 10rpx 5rpx 10rpx;
  266. margin-top: 36rpx;
  267. border-radius: 30rpx;
  268. color: #ffffff;
  269. line-height: 50rpx;
  270. font-size: 24rpx;
  271. text-align: center;
  272. }
  273. }
  274. }
  275. }
  276. }
  277. .content:after {
  278. content: '';
  279. width: 345rpx;
  280. border: 1px solid transparent;
  281. }
  282. }
  283. }
  284. }
  285. .no {
  286. width: 100%;
  287. display: flex;
  288. justify-content: center;
  289. margin-top: 30upx;
  290. color: #F29100;
  291. font-size: 32upx;
  292. }
  293. .subtitle {
  294. position: relative;
  295. font-size: 0.24rem;
  296. color: $color-ord;
  297. height: 45px;
  298. line-height: 45px;
  299. text-align: center;
  300. font-size: 14px;
  301. &:before {
  302. content: '';
  303. position: absolute;
  304. width: 30%;
  305. height: 1px;
  306. top: 50%;
  307. background-color: $color-ord;
  308. left: 2%;
  309. }
  310. &:after {
  311. content: '';
  312. position: absolute;
  313. width: 30%;
  314. height: 1px;
  315. top: 50%;
  316. background-color: $color-ord;
  317. right: 2%;
  318. }
  319. }
  320. .carousel {
  321. height: calc(var(--status-bar-height)+250upx);
  322. position: relative;
  323. swiper {
  324. height: 100%;
  325. }
  326. .image-wrapper {
  327. width: 100%;
  328. height: 100%;
  329. }
  330. .swiper-item {
  331. display: flex;
  332. justify-content: center;
  333. align-content: center;
  334. width: 100%;
  335. height: 250upx;
  336. overflow: hidden;
  337. image {
  338. width: 100%;
  339. height: 100%;
  340. }
  341. }
  342. }
  343. .footer {
  344. width: 100%;
  345. height: 90upx;
  346. border-top: 2px solid #f1f1f1;
  347. position: fixed;
  348. bottom: 0;
  349. background: #fff;
  350. .wrap {
  351. width: 100%;
  352. height: 100%;
  353. display: flex;
  354. align-items: center;
  355. justify-content: space-around;
  356. .inner {}
  357. }
  358. .active {
  359. // color: $tab-color-1 !important;
  360. }
  361. }
  362. }
  363. </style>