coupon.vue 7.8 KB

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