index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <view class="channel-coupon">
  3. <GlobalLoading />
  4. <view class="details">
  5. <swiper class="swiper" :indicator-dots="true" :autoplay="true">
  6. <swiper-item v-for="(imgItem, index) in channelCouponData.productImageList" :key="index">
  7. <image class="swiper-img" :src="imgItem"></image>
  8. </swiper-item>
  9. </swiper>
  10. <view class="info">
  11. <view class="price-box">
  12. <view class="icon">
  13. <img class="icon-img" src="../../static/images/origin/icon-coupon.png" alt="" mode="widthFix" />
  14. </view>
  15. <label class="price">¥{{ channelCouponData.price }}</label>
  16. <label class="original-price">¥{{ channelCouponData.originalPrice }}</label>
  17. <label class="buy-count">{{ channelCouponData.buyUserCount }}人付款</label>
  18. </view>
  19. <text class="name" @click="jumpProductDetail(channelCouponData)">{{ channelCouponData.productName }}</text>
  20. </view>
  21. <view class="coupon">
  22. <view class="price">
  23. <text v-if="channelCouponData.couponType === 1" class="unit">¥</text>
  24. <text class="val">{{ channelCouponData.reduceMoney }}</text>
  25. <text v-if="channelCouponData.couponType === 2" class="unit">折</text>
  26. </view>
  27. <view class="coupon-content">
  28. <view class="time">
  29. <text class="text">有效期</text>
  30. <text class="val">{{ channelCouponData.startTime.slice(0, 10) }} - {{ channelCouponData.endTime.slice(0, 10) }}</text>
  31. </view>
  32. <view v-if="channelCouponData.state === 3" class="btn" @click="receiveCoupon(channelCouponData)">立即领取</view>
  33. <view v-if="channelCouponData.state === 0" class="btn">已领取</view>
  34. <view v-if="channelCouponData.state === 1" class="btn">已使用</view>
  35. <view v-if="channelCouponData.state === 2" class="btn">已过期</view>
  36. </view>
  37. </view>
  38. </view>
  39. <div v-if="productList && productList.length > 0" class="pro-list">
  40. <div class="title">
  41. <img class="title-img" src="../../static/images/origin/img-title.png" alt="商品推荐" mode="widthFix" />
  42. </div>
  43. <div class="product-list">
  44. <div class="product-list-box">
  45. <div v-for="(item, index) in productList" :key="index" class="product-list-item-warp" @click="jumpProductDetail(item)">
  46. <div class="product-list-item">
  47. <div class="product-list-img">
  48. <img v-show="item.image" class="img" :src="item.image">
  49. </div>
  50. <div class="product-list-info">
  51. <label class="product-name">{{ item.productName }}</label>
  52. <div class="flex">
  53. <div class="shop-box" @click.stop="jumpStore(item)">
  54. <label class="shop-name">{{ item.shopName }}</label>
  55. <div class="shop-logo">
  56. <img :src="item.shopLogo">
  57. </div>
  58. </div>
  59. <label class="buy-count">{{ item.users ? item.users : 0 }}人付款</label>
  60. </div>
  61. <div class="price-warp">
  62. <img v-if="item.activityType == 1" class="iconImg" src="../../static/images/origin/groupBuyIcon.png">
  63. <img v-if="item.activityType == 2" class="iconImg" src="../../static/images/origin/spikeIcon.png">
  64. <img v-if="item.activityType == 4" class="iconImg" src="../../static/images/origin/spikeIcon.png">
  65. <img v-if="item.activityType == 3" class="iconImg" src="../../static/images/origin/discountListIcon.png">
  66. <img v-if="item.activityType == 5" class="iconImg" src="../../static/images/origin/discountListIcon.png">
  67. <img v-if="item.activityType == 8" class="iconImg" src="../../static/images/origin/memberCenterIcon.png">
  68. <div class="price">
  69. ¥ {{ item.price }}
  70. </div>
  71. <div class="original-price">
  72. ¥ {{ item.originalPrice }}
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </view>
  82. </template>
  83. <script>
  84. import { J_STORAGE_KEY } from '../../config/constant'
  85. import GlobalLoading from '../../components/diyLoading/index'
  86. const NET = require('../../utils/request')
  87. const API = require('../../config/api')
  88. export default {
  89. name: 'ChannelCoupon',
  90. components: { GlobalLoading },
  91. data() {
  92. return {
  93. channelCouponData: {},
  94. productList: [],
  95. isLogin: false,
  96. params: {
  97. productId: 0,
  98. shopCouponId: 0,
  99. shopId: 0
  100. }
  101. }
  102. },
  103. onLoad(options) {
  104. this.params.productId = options.productId
  105. this.params.shopCouponId = options.shopCouponId
  106. this.params.shopId = options.shopId
  107. const res = uni.getStorageSync(J_STORAGE_KEY); const token = res.token
  108. this.isLogin = !!token
  109. this.getChannelCoupon()
  110. this.getProductList()
  111. },
  112. methods: {
  113. // 获取渠道优惠券
  114. getChannelCoupon() {
  115. // uni.showLoading({
  116. // mask: true,
  117. // title: '加载中...'
  118. // })
  119. NET.request(API.getChannelCoupon, this.params, 'GET').then((res) => {
  120. this.channelCouponData = res.data
  121. // uni.hideLoading()
  122. })
  123. .catch((res) => {
  124. // uni.hideLoading()
  125. uni.showToast({
  126. title: '失败',
  127. icon: 'none'
  128. })
  129. })
  130. },
  131. // 获取推荐产品
  132. getProductList() {
  133. // uni.showLoading({
  134. // mask: true,
  135. // title: '加载中...'
  136. // })
  137. var params = {
  138. page: 1,
  139. pageSize: 10,
  140. timestamp: new Date().getTime()
  141. }
  142. NET.request(API.getRandomProduct, params, 'GET').then((res) => {
  143. this.productList = res.data.list
  144. // uni.hideLoading()
  145. })
  146. .catch((res) => {
  147. // uni.hideLoading()
  148. })
  149. },
  150. // 领取优惠券
  151. receiveCoupon(item) {
  152. if (this.isLogin) {
  153. var paramsData = {
  154. shopCouponId: item.shopCouponId,
  155. shopId: this.params.shopId
  156. }
  157. NET.request(API.ReceiveCoupon, paramsData, 'POST').then((res) => {
  158. uni.showToast({
  159. title: '领取成功',
  160. icon: 'success'
  161. })
  162. const data = {
  163. shopId: this.channelCouponData.shopId,
  164. productId: this.channelCouponData.productId,
  165. skuId: this.channelCouponData.skuId
  166. }
  167. setTimeout(() => {
  168. this.jumpProductDetail(data)
  169. }, 2000)
  170. })
  171. .catch((res) => {
  172. if (res.data.code !== '200') {
  173. uni.showToast({
  174. title: res.data.message,
  175. icon: 'none'
  176. })
  177. }
  178. })
  179. } else {
  180. uni.showToast({
  181. title: '请先登录',
  182. icon: 'none'
  183. })
  184. uni.navigateTo({
  185. url: '/pages_category_page2/userModule/login'
  186. })
  187. }
  188. },
  189. // 跳转到店铺主页
  190. jumpStore(item) {
  191. uni.navigateTo({
  192. url: `/pages_category_page1/store/index?storeId=${item.shopId}`
  193. })
  194. },
  195. // 跳转到商品详情
  196. jumpProductDetail(item) {
  197. uni.navigateTo({
  198. url: '/pages_category_page1/goodsModule/goodsDetails?shopId=' + item.shopId + '&productId=' + item.productId + '&skuId=' + item
  199. .skuId
  200. })
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="scss" scoped>
  206. .channel-coupon{
  207. .details{
  208. background-color: #fff;
  209. padding-bottom: 48rpx;
  210. .swiper{
  211. height: 750rpx;
  212. &-img{
  213. width: 100%;
  214. height: 100%;
  215. }
  216. }
  217. .info{
  218. padding: 0 20rpx;
  219. margin-top: 20rpx;
  220. .price-box{
  221. display: flex;
  222. align-items: center;
  223. position: relative;
  224. .icon{
  225. padding-right: 8rpx;
  226. width: 66rpx;
  227. height: 46rpx;
  228. &-img{
  229. width: 100%;
  230. height: 100%;
  231. }
  232. }
  233. .price{
  234. color: #C83732;
  235. font-weight: bold;
  236. font-size: 60rpx;
  237. margin-right: 10rpx;
  238. }
  239. .original-price{
  240. padding-top: 20rpx;
  241. font-size: 24px;
  242. color: #CCCCCC;
  243. text-decoration:line-through;
  244. }
  245. .buy-count{
  246. position: absolute;
  247. right: 0;
  248. font-size: 26rpx;
  249. color: #CCCCCC;
  250. }
  251. }
  252. .name{
  253. margin-top: 20rpx;
  254. font-size: 32rpx;
  255. line-height: 48rpx;
  256. color: #333333;
  257. }
  258. }
  259. .coupon{
  260. margin: 32rpx 20rpx;
  261. height: 140rpx;
  262. background: #333333 url("../../static/images/origin/border-coupon.png") no-repeat right center / auto 140rpx;
  263. display: flex;
  264. .price{
  265. position: relative;
  266. width: 204rpx;
  267. display: flex;
  268. justify-content: center;
  269. align-items: baseline;
  270. height: 100%;
  271. border-right: 2rpx solid #666666;
  272. line-height: 140rpx;
  273. .unit{
  274. font-size: 36rpx;
  275. color: #FFEBC4;
  276. }
  277. .val{
  278. font-size: 70rpx;
  279. color: #FFEBC4;
  280. }
  281. &:before,&:after{
  282. content: '';
  283. width: 24rpx;
  284. height: 24rpx;
  285. background: #fff;
  286. border-radius: 50%;
  287. position: absolute;
  288. right: -12rpx;
  289. }
  290. &:before{
  291. top: -12rpx;
  292. }
  293. &:after{
  294. bottom: -12rpx;
  295. }
  296. }
  297. &-content{
  298. flex: 1;
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. padding: 0 50rpx;
  303. .time{
  304. .text{
  305. font-size: 32rpx;
  306. color: #FFFFFF;
  307. line-height: 44rpx;
  308. display: block;
  309. }
  310. .val{
  311. font-size: 20rpx;
  312. color: #999999;
  313. line-height: 28rpx;
  314. }
  315. }
  316. .btn{
  317. width: 122rpx;
  318. height: 52rpx;
  319. line-height: 52rpx;
  320. border: 2rpx solid #999999;
  321. font-size: 24rpx;
  322. text-align: center;
  323. color: #FFFFFF;
  324. }
  325. }
  326. }
  327. }
  328. }
  329. .pro-list{
  330. background: #F8F8F8;
  331. padding: 42upx 13upx 20upx;
  332. .title{
  333. text-align: center;
  334. margin-bottom: 36upx;
  335. .title-img{
  336. width: 211upx;
  337. }
  338. }
  339. /**多行多列**/
  340. .product-list {
  341. position: relative;
  342. &-box {
  343. display: flex;
  344. flex-wrap: wrap;
  345. flex-direction: row;
  346. &.swiper{
  347. height: 620upx;
  348. }
  349. }
  350. &.product-swiper .product-list-box{
  351. padding-left: 0;
  352. }
  353. &-item-warp{
  354. margin: 0 0 20upx 0;
  355. }
  356. &-item {
  357. width: 348upx;
  358. padding: 0 7upx;
  359. box-sizing: content-box;
  360. }
  361. &-img {
  362. width: 348upx;
  363. height: 348upx;
  364. background-color: #f5f5f5;
  365. border-radius: 10upx 10upx 0 0;
  366. .img {
  367. width: 100%;
  368. height: 100%;
  369. object-fit: contain;
  370. }
  371. }
  372. &-info {
  373. background-color: #FFFFFF;
  374. //box-shadow: 0px 0px 15px 0px rgba(52, 52, 52, 0.15);
  375. border-radius: 0 0 10upx 10upx;
  376. padding: 20upx;
  377. label{
  378. font-weight: normal;
  379. }
  380. .product-name{
  381. font-size: 28upx;
  382. color: #333;
  383. display: block;
  384. overflow: hidden;
  385. text-overflow:ellipsis;
  386. white-space: nowrap;
  387. margin-bottom: 18upx;
  388. line-height: 40upx;
  389. }
  390. .flex{
  391. display: flex;
  392. align-items: center;
  393. }
  394. .shop-box{
  395. background-color: #333333;
  396. border-radius: 0upx 20upx 20upx 0upx;
  397. line-height: 40upx;
  398. display: flex;
  399. align-items: center;
  400. height: 40upx;
  401. margin-right: 10upx;
  402. .shop-name{
  403. font-size: 20upx;
  404. color: #FFEBC4;
  405. padding: 0 8upx 0 12upx;
  406. }
  407. .shop-logo{
  408. border: 2upx solid #707070;
  409. border-radius: 50%;
  410. overflow: hidden;
  411. float: right;
  412. img{
  413. width: 34upx;
  414. height: 34upx;
  415. display: block;
  416. }
  417. }
  418. }
  419. .buy-count{
  420. color: #C5AA7B;
  421. font-size: 20upx;
  422. border: 2upx solid #E4E5E6;
  423. line-height: 40upx;
  424. padding: 0 5upx;
  425. }
  426. .price-warp{
  427. display: flex;
  428. align-items: baseline;
  429. line-height: 56upx;
  430. .iconImg {
  431. width: 58rpx;
  432. height: 36rpx;
  433. margin-right: 10rpx;
  434. }
  435. .price{
  436. color: #C83732;
  437. font-size: 40upx;
  438. margin-right: 20upx;
  439. }
  440. .original-price{
  441. font-size: 24upx;
  442. color: #ccc;
  443. text-decoration: line-through;
  444. }
  445. }
  446. }
  447. }
  448. }
  449. .swiper-dots {
  450. display: flex;
  451. position: absolute;
  452. left: 50%;
  453. transform: translateX(-50%);
  454. bottom: 15rpx;
  455. z-index: 66;
  456. .dot {
  457. width: 10upx;
  458. height: 10upx;
  459. background: #333333;
  460. opacity: 0.3;
  461. border-radius: 5upx;
  462. margin: 0 10upx;
  463. }
  464. .dot-active {
  465. width: 20upx;
  466. opacity: 1;
  467. }
  468. }
  469. </style>