coupon.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <view ref="container">
  3. <view class="top-fixed">
  4. <view class="cate-list">
  5. <!-- 关键字列表 -->
  6. <scroll-view scroll-x="true" >
  7. <view class="inner">
  8. <view v-for="(item,index) in cates" :key="index" :class="cateId == item.dictValue?'item active':'item'" @click="choseCate(item)">
  9. {{ item.dictLabel }}
  10. </view>
  11. </view>
  12. </scroll-view>
  13. </view>
  14. </view>
  15. <view class="tui-coupon-list">
  16. <view class="tui-coupon-item tui-top20" v-for="(item, index) in couponsList" :key="index">
  17. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/bg_coupon_3x.png" class="tui-coupon-bg" mode="widthFix"></image>
  18. <view class="tui-coupon-item-left">
  19. <view class="tui-coupon-price-box" :class="{ 'tui-color-grey': item.receiveCount>0 }">
  20. <view class="tui-coupon-price-sign">¥</view>
  21. <view class="tui-coupon-price" :class="{ 'tui-price-small': false }">{{ item.couponPrice }}</view>
  22. </view>
  23. <view class="tui-coupon-intro">满{{ item.useMinPrice }}元可用</view>
  24. </view>
  25. <view class="tui-coupon-item-right">
  26. <view class="tui-coupon-content">
  27. <view class="tui-coupon-title-box">
  28. <view class="tui-coupon-title">{{ item.couponName }}</view>
  29. </view>
  30. <view class="tui-coupon-rule">
  31. <view class="tui-rule-box tui-padding-btm">
  32. <view class="tui-coupon-circle"></view>
  33. <view class="tui-coupon-text">不可叠加使用</view>
  34. </view>
  35. <view class="tui-rule-box">
  36. <view class="tui-coupon-circle"></view>
  37. <view class="tui-coupon-text">{{ item.limitTime }} 到期</view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="tui-btn-box">
  43. <view class="btn receive" @click="show(item)">查看</view>
  44. </view>
  45. </view>
  46. </view>
  47. <Loading :loaded="loadend" :loading="loading"></Loading>
  48. <!--暂无优惠券-->
  49. <view v-if="couponsList.length == 0 && page > 1" class="no-data-box" >
  50. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/no_data.png" mode="aspectFit"></image>
  51. <view class="empty-title">暂无数据</view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import { getCompanyCouponIssueList, receive } from '@/api/coupon'
  57. import Loading from '@/components/Loading'
  58. export default {
  59. name: 'getCoupon',
  60. components: {
  61. Loading,
  62. },
  63. props: {},
  64. data: function() {
  65. return {
  66. cateId:0,
  67. cates:[],
  68. page: 1,
  69. limit: 10,
  70. couponsList: [],
  71. loading: false,
  72. loadend: false,
  73. }
  74. },
  75. onLoad(options) {
  76. var cate={dictLabel:"全部",dictValue:0};
  77. this.cates.push(cate);
  78. this.cates=this.cates.concat(this.utils.getDict("storeProductPackageCate"));
  79. },
  80. mounted: function() {
  81. },
  82. onShow() {
  83. this.getCompanyCouponIssueList()
  84. },
  85. onReachBottom() {
  86. !this.loading && this.getCompanyCouponIssueList()
  87. },
  88. methods: {
  89. choseCate(item){
  90. this.cateId = item.dictValue;
  91. this.couponsList=[];
  92. this.loading=false;
  93. this.loadend=false;
  94. this.page=1;
  95. this.getCompanyCouponIssueList();
  96. },
  97. show(item){
  98. uni.navigateTo({
  99. url: './couponDetails?id=' +item.id
  100. })
  101. },
  102. getCompanyCouponIssueList() {
  103. if (this.loading) return //阻止下次请求(false可以进行请求);
  104. if (this.loadend) return //阻止结束当前请求(false可以进行请求);
  105. this.loading = true
  106. let q = { couponType:1,page: this.page, pageSize: this.limit,cateId:this.cateId }
  107. getCompanyCouponIssueList(q).then(res => {
  108. this.loading = false
  109. this.couponsList.push.apply(this.couponsList, res.data.list)
  110. this.loadend = res.data.list.length < this.limit //判断所有数据是否加载完成;
  111. this.page = this.page + 1
  112. })
  113. },
  114. },
  115. }
  116. </script>
  117. <style lang="less" scoped>
  118. page {
  119. background-color: #f5f5f5;
  120. }
  121. .container {
  122. padding-bottom: env(safe-area-inset-bottom);
  123. }
  124. .top-fixed{
  125. width: 100%;
  126. position: fixed;
  127. top: 0;
  128. left: 0;
  129. z-index: 99999;
  130. .cate-list{
  131. box-sizing: border-box;
  132. background: #fff;
  133. padding: 10upx 27upx;
  134. height: 100upx;
  135. .inner{
  136. display: flex;
  137. }
  138. .item{
  139. flex-shrink: 0;
  140. padding: 0 24upx;
  141. height: 64upx;
  142. line-height: 64upx;
  143. font-size: 28upx;
  144. font-family: PingFang SC;
  145. font-weight: 500;
  146. color: #2BC7B9;
  147. background: #F5FFFE;
  148. border: 1px solid #8AD5CE;
  149. border-radius: 32upx;
  150. margin: 0 20upx 20upx 0;
  151. &.active{
  152. color: #FFFFFF;
  153. background: #2BC7B9;
  154. border: 1px solid #2BC7B9;
  155. }
  156. }
  157. }
  158. }
  159. .tui-coupon-list {
  160. margin-top: 120upx;
  161. width: 100%;
  162. padding: 0 25rpx;
  163. box-sizing: border-box;
  164. }
  165. .tui-coupon-banner {
  166. width: 100%;
  167. }
  168. .tui-coupon-item {
  169. width: 100%;
  170. height: 210rpx;
  171. position: relative;
  172. display: flex;
  173. align-items: center;
  174. padding-right: 30rpx;
  175. box-sizing: border-box;
  176. overflow: hidden;
  177. }
  178. .tui-coupon-bg {
  179. width: 100%;
  180. height: 210rpx;
  181. position: absolute;
  182. left: 0;
  183. top: 0;
  184. z-index: 1;
  185. }
  186. .tui-coupon-sign {
  187. height: 110rpx;
  188. width: 110rpx;
  189. position: absolute;
  190. z-index: 9;
  191. top: -30rpx;
  192. right: 40rpx;
  193. }
  194. .tui-coupon-item-left {
  195. width: 218rpx;
  196. height: 210rpx;
  197. position: relative;
  198. z-index: 2;
  199. display: flex;
  200. align-items: center;
  201. justify-content: center;
  202. flex-direction: column;
  203. flex-shrink: 0;
  204. }
  205. .tui-coupon-price-box {
  206. display: flex;
  207. color: #e41f19;
  208. align-items: flex-end;
  209. }
  210. .tui-coupon-price-sign {
  211. font-size: 30rpx;
  212. }
  213. .tui-coupon-price {
  214. font-size: 70rpx;
  215. line-height: 68rpx;
  216. font-weight: bold;
  217. }
  218. .tui-price-small {
  219. font-size: 58rpx !important;
  220. line-height: 56rpx !important;
  221. }
  222. .tui-coupon-intro {
  223. background: #f7f7f7;
  224. padding: 8rpx 10rpx;
  225. font-size: 26rpx;
  226. line-height: 26rpx;
  227. font-weight: 400;
  228. color: #666;
  229. margin-top: 18rpx;
  230. }
  231. .tui-coupon-item-right {
  232. flex: 1;
  233. height: 210rpx;
  234. position: relative;
  235. z-index: 2;
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. padding-left: 24rpx;
  240. box-sizing: border-box;
  241. overflow: hidden;
  242. }
  243. .tui-coupon-content {
  244. width: 82%;
  245. display: flex;
  246. flex-direction: column;
  247. justify-content: center;
  248. }
  249. .tui-coupon-title-box {
  250. display: flex;
  251. align-items: center;
  252. }
  253. .tui-coupon-btn {
  254. padding: 6rpx;
  255. background: #ffebeb;
  256. color: #e41f19;
  257. font-size: 25rpx;
  258. line-height: 25rpx;
  259. display: flex;
  260. align-items: center;
  261. justify-content: center;
  262. transform: scale(0.9);
  263. transform-origin: 0 center;
  264. border-radius: 4rpx;
  265. flex-shrink: 0;
  266. }
  267. .tui-color-grey {
  268. color: #888 !important;
  269. }
  270. .tui-bg-grey {
  271. background: #f0f0f0 !important;
  272. color: #888 !important;
  273. }
  274. .tui-coupon-title {
  275. width: 100%;
  276. font-size: 26rpx;
  277. color: #333;
  278. white-space: nowrap;
  279. overflow: hidden;
  280. text-overflow: ellipsis;
  281. }
  282. .tui-coupon-rule {
  283. padding-top: 52rpx;
  284. }
  285. .tui-rule-box {
  286. display: flex;
  287. align-items: center;
  288. transform: scale(0.8);
  289. transform-origin: 0 100%;
  290. }
  291. .tui-padding-btm {
  292. padding-bottom: 6rpx;
  293. }
  294. .tui-coupon-circle {
  295. width: 8rpx;
  296. height: 8rpx;
  297. background: rgb(160, 160, 160);
  298. border-radius: 50%;
  299. }
  300. .tui-coupon-text {
  301. font-size: 28rpx;
  302. line-height: 28rpx;
  303. font-weight: 400;
  304. color: #666;
  305. padding-left: 8rpx;
  306. white-space: nowrap;
  307. }
  308. .tui-top20 {
  309. margin-top: 20rpx;
  310. }
  311. .tui-coupon-title {
  312. font-size: 28rpx;
  313. line-height: 28rpx;
  314. }
  315. .tui-coupon-radio {
  316. transform: scale(0.7);
  317. transform-origin: 100% center;
  318. }
  319. .tui-btn-box {
  320. position: absolute;
  321. right: 20rpx;
  322. bottom: 40rpx;
  323. z-index: 10;
  324. .btn{
  325. width: 155upx;
  326. height: 64upx;
  327. line-height: 64upx;
  328. font-size: 26upx;
  329. font-family: PingFang SC;
  330. font-weight: 500;
  331. text-align: center;
  332. border-radius: 32upx;
  333. margin-left: 15upx;
  334. &.cancel{
  335. border: 1px solid red;
  336. color: red;
  337. }
  338. &.receive{
  339. background: red;
  340. color: #FFFFFF;
  341. }
  342. }
  343. }
  344. </style>