index.vue 12 KB

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