多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

466 lines
13 KiB

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