猎豆优选小程序

optimization1.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view>
  3. <!-- 顶部导航 -->
  4. <u-navbar class="navbar-wrap" title="优选圈" title-color="#333" :title-size="36" :title-bold="false" :is-back="false" :background="navbarBackground" >
  5. <view class="slot-wrap" style="margin-left:44rpx;"><u-icon name="search" color="#3D3D3D" size="44"></u-icon></view>
  6. </u-navbar>
  7. <!-- 优选内容 -->
  8. <swiper class="swiper" :style="'height:' + swiperHeight + 'px' " v-if="goodsList && goodsList.length" circular vertical previous-margin="0rpx" :next-margin="nextMargin">
  9. <swiper-item v-for="goodsItem in goodsList" :key="goodsItem.goods_id">
  10. <view class="goods-item-wrap">
  11. <u-lazy-load class="goods-img" :image="goodsItem.img" border-radius="10" />
  12. <!-- S 商品信息 -->
  13. <view class="info-wrap con-block">
  14. <view class="tp-wrap">
  15. <view class="lt-wrap">
  16. <text class="price-title">{{goodsItem.is_coupon == 1 && goodsItem.coupon_price > 0 ? '券后价' : '' }} ¥</text>
  17. <text class="price">{{ goodsItem.discount_price }}</text>
  18. <text class="price-old">¥{{ goodsItem.price }}</text>
  19. </view>
  20. <view class="rt-wrap">
  21. <view class="salesVolume" v-if="goodsItem.volume > 100">
  22. 月销:{{ $NumberHandle({value:goodsItem.volume,comma:true}) }}+
  23. </view>
  24. </view>
  25. </view>
  26. <view class="bm-wrap">
  27. <image class="shop-icon" v-if="goodsItem.shop_type == 0" src="https://ld.726p.com/ldyx_static/imgs/icon-tb.png" />
  28. <image class="shop-icon" v-else-if="goodsItem.shop_type == 1" src="https://ld.726p.com/ldyx_static/imgs/icon-tmall.png" />
  29. {{ goodsItem.title }}
  30. </view>
  31. <view class="btm-wrap">
  32. <view v-if="goodsItem.coupon_price > 0" class="coupon-wrap">
  33. <text class="label">券</text>
  34. <text class="value">¥{{ goodsItem.coupon_price }}</text>
  35. </view>
  36. <view v-if="user_level > 1 && goodsItem.commission_price > 0" class="coupon-wrap commission-wrap">
  37. <text class="label">返</text>
  38. <text class="value">¥{{ goodsItem.commission_price }}</text>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- E 商品信息 -->
  43. <!-- 底部按钮 -->
  44. <view class="footer-wrap" :style="{ 'padding-bottom': isIphoneX ? '66rpx' : '22rpx' }">
  45. <view class="btn-collect-wrap" v-if="goodsItem.is_favorites == 1" @click="onClickSetFavorites">
  46. <image class="btn-collect-img" src="https://ld.726p.com/ldyx_static/imgs/icon-collect-on.png" />
  47. <text class="btn-collect-text">已收藏</text>
  48. </view>
  49. <view class="btn-collect-wrap" v-else @click="onClickSetFavorites">
  50. <image class="btn-collect-img" src="https://ld.726p.com/ldyx_static/imgs/icon-collect.png" />
  51. <text class="btn-collect-text">收藏</text>
  52. </view>
  53. <!-- 已登录按钮 -->
  54. <view v-if="isLogin" class="btn-wrap">
  55. <view class="btn-item lt-btn" @click="onClickFXZQ">
  56. <!-- <image class="btn-icon" src="https://ld.726p.com/ldyx_static/imgs/icon-share.png" /> -->
  57. <text class="btn-text">{{ user_level == 1 ? '分享' : '分享赚钱' }}</text>
  58. </view>
  59. <view class="btn-item rt-btn" @click="onClickGWSQ">
  60. <!-- <image class="btn-icon" src="https://ld.726p.com/ldyx_static/imgs/icon-money.png" /> -->
  61. <text class="btn-text">购物省钱</text>
  62. </view>
  63. </view>
  64. <!-- 未登录按钮 -->
  65. <view v-else class="btn-wrap">
  66. <view class="btn-item lt-btn" @click="onClickZJGM">
  67. <!-- <image class="btn-icon" src="https://ld.726p.com/ldyx_static/imgs/icon-buy.png" /> -->
  68. <text class="btn-text">直接购买</text>
  69. </view>
  70. <view class="btn-item rt-btn" @click="onClickFYJGM">
  71. <!-- <image class="btn-icon" src="https://ld.726p.com/ldyx_static/imgs/icon-money.png" /> -->
  72. <text class="btn-text">省钱购买</text>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </swiper-item>
  78. </swiper>
  79. <!-- <u-loadmore :status="loadmoreStatus" /> -->
  80. </view>
  81. </template>
  82. <script>
  83. const app = getApp()
  84. import { loadmoreOptions } from '../../utils/tools'
  85. export default {
  86. data() {
  87. return {
  88. navbarBackground: {
  89. // background: 'linear-gradient(90deg, #F57C29 0%, #F13641 100%)'
  90. },
  91. user_level: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').user_level : '', // 当前用户等级
  92. filter: {
  93. page: 1,
  94. hasNext: true,
  95. },
  96. loadmoreStatus: loadmoreOptions.LOAD_MORE,
  97. goodsList: [], // 商品列表数据
  98. swiperHeight: '800', // swiper的高度
  99. nextMargin: '0px', // 轮播图的后边距
  100. }
  101. },
  102. watch: {
  103. user_level() { // 监听用户等级变化 => 更新页面列表数据
  104. // this.handleRefreshGoodsList()
  105. }
  106. },
  107. onLoad() {
  108. this.swiperHeight = `${uni.getSystemInfoSync().windowHeight - app.globalData.statusBarHeight - app.globalData.navigationBarHeight - 14}`;
  109. this.nextMargin = `${Number(this.swiperHeight) - uni.upx2px(1120)}px`
  110. this.handleGetGoodsList()
  111. },
  112. methods: {
  113. // 获取商品获取商品列表数据列表
  114. async handleGetGoodsList() {
  115. if (!this.filter.hasNext) return false
  116. try {
  117. uni.showLoading({
  118. title: '加载中...',
  119. mask: true
  120. })
  121. this.loadmoreStatus = loadmoreOptions.LOADING
  122. const url = this.$api.optimization_youXuanGoodsList
  123. const params = {
  124. page: this.filter.page,
  125. }
  126. const { data: res = {} } = await this.$postJSON(url, params)
  127. this.loadmoreStatus = loadmoreOptions.LOAD_MORE
  128. if (res && res.errno == 0 && Array.isArray(res.rst)) {
  129. if (!res.rst.length) { // 当前页无数据 => 更改下一页标识
  130. this.filter.hasNext = false
  131. this.loadmoreStatus = loadmoreOptions.NO_MORE
  132. }
  133. this.goodsList = [...this.goodsList, ...res.rst]
  134. } else {
  135. uni.showToast({
  136. title: res.err || '操作失败',
  137. icon: 'none'
  138. })
  139. }
  140. } catch (error) {
  141. console.log('error => ', error)
  142. } finally {
  143. uni.hideLoading()
  144. // if (this.isOnPullDownRefresh) { // 如果正在下拉刷新 => 停止
  145. // uni.stopPullDownRefresh()
  146. // this.isOnPullDownRefresh = false
  147. // }
  148. }
  149. },
  150. }
  151. }
  152. </script>
  153. <style scoped lang="scss">
  154. .swiper {
  155. width: 710rpx;
  156. height: 1180rpx;
  157. margin: auto;
  158. margin-top: 10px;
  159. }
  160. .goods-item-wrap{
  161. display: block;
  162. height: 1100rpx;
  163. border-radius: 40rpx;
  164. background-color: #fff;
  165. margin-bottom: 20rpx;
  166. overflow: hidden;
  167. .goods-img{
  168. width: 100%;
  169. height: 710rpx;
  170. }
  171. }
  172. .info-wrap {
  173. margin: 32rpx 26rpx 0;
  174. .tp-wrap {
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. .lt-wrap {
  179. display: flex;
  180. align-items: baseline;
  181. .price-title{
  182. color: #FF4040;
  183. font-size: 28rpx;
  184. line-height: 40rpx;
  185. }
  186. .price {
  187. font-size: 48rpx;
  188. color: #FF4040;
  189. font-weight: bold;
  190. line-height: 66rpx;
  191. margin-left: 12rpx;
  192. }
  193. .price-old {
  194. margin-left: 16rpx;
  195. font-size: 24rpx;
  196. line-height: 34rpx;
  197. text-decoration: line-through;
  198. color: #999999;
  199. }
  200. }
  201. .rt-wrap {
  202. display: flex;
  203. align-items: center;
  204. .btn-wrap {
  205. display: flex;
  206. align-items: center;
  207. .btn-img {
  208. width: 32rpx;
  209. height: 32rpx;
  210. }
  211. .btn-text {
  212. font-size: 25rpx;
  213. color: #999;
  214. }
  215. }
  216. }
  217. }
  218. .bm-wrap {
  219. margin-top: 20rpx;
  220. font-size: 34rpx;
  221. font-weight: bold;
  222. line-height: 48rpx;
  223. color: #333333;
  224. .shop-icon {
  225. margin-right: 6rpx;
  226. width: 32rpx;
  227. height: 32rpx;
  228. margin-top: -10rpx;
  229. border-radius: 10rpx;
  230. vertical-align: middle; // 解决图片下边框缝隙问题
  231. }
  232. }
  233. .quan-block{
  234. width: 100%;
  235. height: 132rpx;
  236. background: url('https://ld.726p.com/ldyx_static/imgs/quan-bg.png') no-repeat;
  237. background-size: 100%;
  238. margin-top: 44rpx;
  239. display: flex;
  240. align-items: center;
  241. justify-content: space-between;
  242. .quan-button{
  243. width: 214rpx;
  244. color: #FFFFFF;
  245. font-size: 36rpx;
  246. line-height: 50rpx;
  247. text-align: center;
  248. }
  249. .quan-info{
  250. flex:1;
  251. padding-left: 20rpx;
  252. .quan-info-1{
  253. color: #FFFFFF;
  254. font-size: 24rpx;
  255. line-height: 34rpx;
  256. .quan-price{
  257. color:#FFFFFF;
  258. font-size:56rpx;
  259. line-height: 70rpx;
  260. }
  261. }
  262. .quan-time{
  263. color: #FFFFFF;
  264. font-size: 22rpx;
  265. line-height: 32rpx;
  266. }
  267. }
  268. }
  269. .btm-wrap {
  270. display: flex;
  271. align-items: center;
  272. margin-top: 20rpx;
  273. .coupon-wrap {
  274. display: flex;
  275. align-items: center;
  276. width: 144rpx;
  277. height: 36rpx;
  278. background-image: url("https://ld.726p.com/ldyx_static/imgs/bg-quan-small.png");
  279. background-repeat: no-repeat;
  280. background-size: 100% 100%;
  281. color: #FF4040;
  282. font-size: 25rpx;
  283. line-height: 36rpx;
  284. .label {
  285. width: 46rpx;
  286. text-align: center;
  287. }
  288. .value {
  289. flex: 1;
  290. text-align: center;
  291. }
  292. }
  293. .commission-wrap {
  294. background-image: url("https://ld.726p.com/ldyx_static/imgs/fan.png");
  295. color: #AE4300;
  296. margin-left: 12rpx;
  297. }
  298. }
  299. }
  300. .footer-wrap {
  301. background-color: #fff;
  302. display: flex;
  303. align-items: center;
  304. justify-content: center;
  305. width: 100%;
  306. height: 150rpx;
  307. padding: 25rpx;
  308. border-top: 1rpx solid #eee;
  309. margin-top: 44rpx;
  310. position: absolute;
  311. bottom: 20rpx;
  312. left: 0;
  313. .btn-wrap {
  314. background-color: #FFBB93;
  315. display: flex;
  316. align-items: center;
  317. width: 600rpx;
  318. height: 84rpx;
  319. border-radius: 84rpx;
  320. overflow: hidden;
  321. .btn-item {
  322. height: 100%;
  323. flex: 1;
  324. display: flex;
  325. justify-content: center;
  326. align-items: center;
  327. .btn-icon {
  328. margin-right: 10rpx;
  329. }
  330. .btn-text {
  331. color: #fff;
  332. font-size: 36rpx;
  333. font-weight: bold;
  334. line-height: 84rpx;
  335. }
  336. &.lt-btn {
  337. .btn-icon {
  338. width: 42rpx;
  339. height: 38rpx;
  340. }
  341. }
  342. &.rt-btn {
  343. background: linear-gradient(90deg, #FF9048 0%, #FB3F3C 100%);
  344. border-radius: 42rpx;
  345. .btn-icon {
  346. width: 42rpx;
  347. height: 44rpx;
  348. }
  349. }
  350. }
  351. }
  352. }
  353. .btn-collect-wrap{
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. margin-right: 28rpx;
  358. .btn-collect-img{
  359. width: 42rpx;
  360. height: 42rpx;
  361. }
  362. .btn-collect-text{
  363. color: #666666;
  364. font-size: 20rpx;
  365. line-height: 28rpx;
  366. }
  367. }
  368. .swiper-list {
  369. margin-top: 40rpx;
  370. margin-bottom: 0;
  371. }
  372. .uni-common-mt {
  373. margin-top: 60rpx;
  374. position: relative;
  375. }
  376. .info {
  377. position: absolute;
  378. right: 20rpx;
  379. }
  380. .uni-padding-wrap {
  381. width: 550rpx;
  382. padding: 0 100rpx;
  383. }
  384. </style>