sign1.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view center>
  3. <view class="title">天天领现金</view>
  4. <view class="main after" v-if="signTrue">
  5. <image class="main-bg" src="../../static/img/money-ok.png" mode=""></image>
  6. <view class="num">
  7. {{day_integral}}
  8. </view>
  9. </view>
  10. <view class="main before" v-if="!signTrue">
  11. <image class="main-bg" src="../../static/img/money-bg.png" mode=""></image>
  12. <view class="btn" @click="integral()">立即领取</view>
  13. </view>
  14. <view class="info-box flex">
  15. <view class="info-item">
  16. <view class="info-num">{{ sum_integral }}</view>
  17. <view class="info-font">获得金额</view>
  18. </view>
  19. <view class="info-item">
  20. <view class="info-num">{{ allSign }}</view>
  21. <view class="info-font">领取天数</view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import calendar from '../../components/ss-calendar/ss-calendar.vue';
  28. import { signList, integral, signUser } from '@/api/functionalUnit.js';
  29. export default {
  30. components: {
  31. calendar
  32. },
  33. data() {
  34. return {
  35. money: '', //保存当前月份
  36. year: '', //保存当前年份
  37. day: '', //保存当前日期
  38. signList: [], //签到日子列表
  39. actionDay: 0, //连续签到天数
  40. allSign: 0, //累计签到
  41. sum_integral: 0, //累计获得积分
  42. day_integral: '', //今天签到的钱
  43. signTrue: false
  44. };
  45. },
  46. onLoad() {
  47. this.signUser();
  48. this.getData();
  49. },
  50. methods: {
  51. // 获取当前时间
  52. getData(current) {
  53. const date = current ? new Date(current) : new Date();
  54. this.year = date.getFullYear(); //保存当前年份
  55. this.month = date.getMonth() + 1; //保存当前月份
  56. this.day = date.getDate(); //保存当前日期
  57. },
  58. //获取签到用户信息
  59. signUser() {
  60. signUser({ all: 1 }).then(({ data }) => {
  61. this.actionDay = data.sign_num; //连续签到天数
  62. this.allSign = data.sum_sgin_day; //累计签到天数
  63. this.sum_integral = data.sum_integral; //累计总积分
  64. });
  65. },
  66. // 签到
  67. integral() {
  68. console.log(111);
  69. integral({})
  70. .then(e => {
  71. console.log(e);
  72. this.day_integral = e.data.integral, //今天获取的金额
  73. // 改为已签到
  74. this.signTrue = true;
  75. this.actionDay++;
  76. // 保存签到成功
  77. this.signList.push(this.day);
  78. })
  79. .catch(e => {
  80. console.log(e);
  81. });
  82. }
  83. }
  84. };
  85. </script>
  86. <style lang="scss">
  87. page,
  88. .center {
  89. height: auto;
  90. min-height: 100%;
  91. background: #ffdfd4;
  92. }
  93. .title {
  94. padding-top: 66rpx;
  95. text-align: center;
  96. font-size: 94rpx;
  97. font-family: SourceHanSansCN;
  98. font-weight: bold;
  99. color: #c85138;
  100. }
  101. .after {
  102. padding-top: 230rpx;
  103. }
  104. .before {
  105. padding-top: 590rpx;
  106. }
  107. .main {
  108. width: 750rpx;
  109. height: 926rpx;
  110. position: relative;
  111. .main-bg {
  112. position: absolute;
  113. top: 0;
  114. left: 0;
  115. right: 0;
  116. width: 750rpx;
  117. height: 926rpx;
  118. }
  119. .num {
  120. line-height: 1;
  121. text-align: center;
  122. font-size: 122rpx;
  123. font-family: PingFang SC;
  124. font-weight: bold;
  125. color: #EB2749;
  126. opacity: 0.9;
  127. }
  128. .btn {
  129. position: relative;
  130. margin: 0 auto;
  131. z-index: 10;
  132. width: 420rpx;
  133. height: 76rpx;
  134. background: linear-gradient(180deg, #fce9a8 0%, #fecd75 100%);
  135. box-shadow: 0px 16rpx 16rpx 0px rgba(159, 20, 63, 0.3), 0px 2rpx 6rpx 0px #fef5d3;
  136. border-radius: 38rpx;
  137. font-size: 26rpx;
  138. font-family: PingFang SC;
  139. font-weight: bold;
  140. color: #cb0908;
  141. line-height: 76rpx;
  142. text-align: center;
  143. }
  144. }
  145. .info-box {
  146. margin: 24rpx auto 0;
  147. padding: 22rpx 0;
  148. width: 640rpx;
  149. height: 160rpx;
  150. background: #ffffff;
  151. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  152. border-radius: 20rpx;
  153. .info-item {
  154. width: 50%;
  155. display: flex;
  156. flex-direction: column;
  157. align-items: center;
  158. border-right: 1px solid #efefef;
  159. line-height: 1;
  160. .info-num {
  161. font-size: 50rpx;
  162. font-family: PingFang SC;
  163. font-weight: bold;
  164. color: #333333;
  165. }
  166. .info-font {
  167. margin-top: 20rpx;
  168. font-size: 26rpx;
  169. font-family: PingFang SC;
  170. font-weight: 500;
  171. color: #333333;
  172. opacity: 0.6;
  173. }
  174. }
  175. }
  176. </style>