coupon.vue 7.8 KB

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