金诚优选前端代码
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.

275 lines
6.1 KiB

  1. <template>
  2. <view>
  3. <lf-nav :showIcon="true" :spreadOut="false" bgColor="transparent"></lf-nav>
  4. <view class="head">
  5. <image class="img" mode="aspectFill" src="https://picsum.photos/seed/picsum/200/300"></image>
  6. <view class="suspension" hover-class="lf-opacity" @click="$url('/pages/coupon/index/index')">我的优惠券</view>
  7. </view>
  8. <view class="coupon-wrap">
  9. <view class="coupon-box" v-for="(item,index) of coupon_list" :key="index">
  10. <view class="coupon-card lf-m-b-30">
  11. <view class="coupon-circle-top">
  12. <view class="coupon-circle1"></view>
  13. </view>
  14. <view class="coupon-circle-bottom">
  15. <view class="coupon-circle1"></view>
  16. </view>
  17. <view class="coupon-radius">
  18. <view class="coupon-left">
  19. <view class="lf-color-white" v-if="item.action_type.type == 'cash'">
  20. <text class="lf-font-24"></text>
  21. <text class="lf-font-70 lf-color-white lf-font-bold">{{item.action_type.value}}</text>
  22. </view>
  23. </view>
  24. <view class="coupon-right">
  25. <view class="lf-font-32 lf-font-bold lf-color-white">{{item.title}}</view>
  26. <view class="lf-font-24 lf-color-white">有效期{{item.starts_at}}-{{item.ends_at}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="coupon-receive" @click="receive(item.code)">立即领取</view>
  31. <block v-if="item.ifpast">
  32. <view class="coupon-opacity"></view>
  33. <view class="coupon-end">
  34. <view>抢光了</view>
  35. </view>
  36. </block>
  37. </view>
  38. </view>
  39. <u-back-top :scrollTop="pageScrollTop"></u-back-top>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data(){
  45. return {
  46. coupon_list: []
  47. }
  48. },
  49. onLoad(){
  50. this.getCouponsList();
  51. },
  52. onPullDownRefresh() {
  53. this.getCouponsList();
  54. },
  55. methods: {
  56. receive(code){
  57. this.$http.post({
  58. api: 'api/coupon/convert',
  59. data: {
  60. coupon_code: code
  61. },
  62. header: {
  63. Authorization: this.$cookieStorage.get('user_token')
  64. }
  65. }).then(res => {
  66. if(res.data.code == 200) {
  67. this.$msg('领取成功');
  68. this.getCouponsList();
  69. }else {
  70. this.$msg(JSON.stringify(res.data.message));
  71. }
  72. }).catch(err => {
  73. console.log("====", err);
  74. })
  75. },
  76. compareDate(val) {
  77. var nowTime = new Date(new Date().toLocaleDateString()).getTime();
  78. let oldTime = new Date(new Date(val).toLocaleDateString()).getTime();
  79. if(nowTime>oldTime) {
  80. return true;
  81. }else {
  82. return false;
  83. }
  84. },
  85. //获取优惠券列表
  86. getCouponsList() {
  87. this.$http.get({
  88. api: 'api/coupons/list',
  89. header: {
  90. Authorization: this.$cookieStorage.get('user_token')
  91. }
  92. }).then(res => {
  93. this.coupon_list = res.data.data;
  94. this.coupon_list.forEach((item,index) => {
  95. if(this.compareDate(item.ends_at)) {
  96. this.$set(item,'ifpast',true);
  97. }else {
  98. this.$set(item,'ifpast',false);
  99. }
  100. })
  101. uni.stopPullDownRefresh();
  102. }).catch(err => {
  103. console.log("====", err);
  104. })
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped="scoped">
  110. .head{
  111. height: 376rpx;
  112. width: 750rpx;
  113. position: relative;
  114. .img{
  115. width: 100%;
  116. height: 100%;
  117. }
  118. .suspension{
  119. position: absolute;
  120. bottom: 30rpx;
  121. right: 0;
  122. width: 165rpx;
  123. height: 54rpx;
  124. background: #15716E;
  125. border-radius: 100rpx 0rpx 0rpx 100rpx;
  126. border: 2rpx solid #FFFFFF;
  127. font-size: 24rpx;
  128. color: #FFFFFF;
  129. display: flex;
  130. justify-content: center;
  131. align-items: center;
  132. }
  133. }
  134. .coupon-wrap {
  135. display: flex;
  136. justify-content: center;
  137. margin-top: 30rpx;
  138. flex-direction: column;
  139. align-content: center;
  140. align-items: center;
  141. }
  142. .coupon-box{
  143. display: flex;
  144. align-items: center;
  145. position: relative;
  146. }
  147. .coupon-card {
  148. overflow: hidden;
  149. position: relative;
  150. display: flex;
  151. align-items: center;
  152. justify-content: center;
  153. width: 637rpx;
  154. // display: flex;
  155. height: 171rpx;
  156. // opacity: 0.59;
  157. // border: 1rpx solid #FFFFFF;
  158. background: #15716E;
  159. border-radius: 20rpx;
  160. z-index: 3;
  161. }
  162. .coupon-radius {
  163. width: 627rpx;
  164. display: flex;
  165. height: 161rpx;
  166. border: 1rpx dashed #ccc;
  167. // background: #15716E;
  168. border-radius: 20rpx;
  169. }
  170. .coupon-circle1 {
  171. width: 40rpx;
  172. height: 40rpx;
  173. background-color: white;
  174. border-radius: 50%;
  175. }
  176. .coupon-circle-top {
  177. width: 50rpx;
  178. height: 50rpx;
  179. border-radius: 50%;
  180. // background-color: red;
  181. position: absolute;
  182. border: 1px dashed #ccc;
  183. left: 190rpx;
  184. top: -20rpx;
  185. display: flex;
  186. align-items: center;
  187. text-align: center;
  188. justify-content: center;
  189. }
  190. .coupon-circle-bottom {
  191. width: 50rpx;
  192. height: 50rpx;
  193. border-radius: 50%;
  194. // background-color: red;
  195. position: absolute;
  196. border: 1px dashed #ccc;
  197. left: 190rpx;
  198. bottom: -20rpx;
  199. display: flex;
  200. align-items: center;
  201. text-align: center;
  202. justify-content: center;
  203. }
  204. .coupon-right {
  205. text-align: left;
  206. justify-content: center;
  207. align-items: flex-start;
  208. display: flex;
  209. flex-direction: column;
  210. margin-left: 84rpx;
  211. }
  212. .coupon-left {
  213. margin-left: 40rpx;
  214. display: flex;
  215. flex-direction: column;
  216. justify-content: center;
  217. align-items: center;
  218. }
  219. .coupon-receive{
  220. width: 45rpx;
  221. height: 126rpx;
  222. font-size: 24rpx;
  223. background: #22A19F;
  224. border-radius: 6rpx;
  225. line-height: 1.2;
  226. color: #FFFFFF;
  227. text-align: center;
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. transform: translate(-16rpx, -9rpx) rotate(10deg);
  232. transform-origin: bottom;
  233. position: relative;
  234. z-index: 1;
  235. }
  236. .coupon-opacity{
  237. width: 102%;
  238. height: 100%;
  239. position: absolute;
  240. left: 0;
  241. right: 0;
  242. top: 0;
  243. bottom: 0;
  244. background-color: rgba(255,255,255,0.5);
  245. z-index: 5;
  246. }
  247. .coupon-end{
  248. position: absolute;
  249. z-index: 7;
  250. width: 136rpx;
  251. height: 136rpx;
  252. background-color: #15716E;
  253. border-radius: 50%;
  254. top: calc(50% - 81rpx);
  255. left: calc(50% - 68rpx);
  256. display: flex;
  257. justify-content: center;
  258. align-items: center;
  259. &>view{
  260. width: 126rpx;
  261. height: 126rpx;
  262. border: 2rpx dashed #FFFFFF;
  263. border-radius: 50%;
  264. font-size: 32rpx;
  265. color: #FFFFFF;
  266. display: flex;
  267. justify-content: center;
  268. align-items: center;
  269. transform: rotate(-38deg);
  270. }
  271. }
  272. </style>