coupon.vue 7.5 KB

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