index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="sign-container">
  3. <u-loading-page
  4. :loading="loading"
  5. :bg-color="$colors.bgColor"
  6. :color="$colors.primaryColor"
  7. :loading-color="$colors.primaryColor"
  8. />
  9. <template v-if="!loading">
  10. <view
  11. class="header"
  12. :style="{
  13. backgroundImage: `url(${$setting.IMAGE_URL}/sign/bg.png)`
  14. } "
  15. >
  16. <view
  17. class="icon"
  18. :style="{
  19. backgroundImage: `url(${$setting.IMAGE_URL}/sign/icon.png)`
  20. } "
  21. />
  22. <view class="been-sign">已连续签到{{ signDays }}天</view>
  23. <view class="tips">在连续签到{{ 7 - signDays }}天立得{{ setting[7].award }}金</view>
  24. </view>
  25. <view class="content dir-left-wrap">
  26. <view
  27. v-for="(item, index) in setting"
  28. :key="index"
  29. class="item main-center cross-center"
  30. :class="{active: parseInt(index) === (parseInt(signDays) + 1)}"
  31. >
  32. <view class="left-box dir-top-wrap cross-center">
  33. <text class="title">{{ item.name }}</text>
  34. <view class="icon">
  35. <image src="@/static/image/gold.png" />
  36. </view>
  37. <view class="number">{{ item.award }}金币</view>
  38. </view>
  39. <view v-if="(index + 1) === sign.length" class="right-box">
  40. <image src="@/static/image/gold-bag.png" />
  41. </view>
  42. </view>
  43. </view>
  44. <view class="btn" :class="{todaySign: todaySign}" @click="handleSign">
  45. {{ todaySign?'已签到' : '立即签到' }}
  46. </view>
  47. </template>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. signDays: 0,
  55. loading: true,
  56. todaySign: false,
  57. setting: []
  58. }
  59. },
  60. computed: {},
  61. methods: {
  62. handleSign() {
  63. if (!this.todaySign) {
  64. this.$loading('签到中...')
  65. this.$api.sign.handle().then(res => {
  66. this.$hideLoading()
  67. if (res.code === 0) {
  68. this.$u.toast(`签到成功,获取金币 ${res.data.award}`)
  69. this.todaySign = true
  70. this.signDays += 1
  71. }
  72. })
  73. }
  74. },
  75. checkSetting() {
  76. this.$api.sign.setting().then(res => {
  77. this.loading = false
  78. const { data } = res
  79. this.signDays = data.signDays
  80. this.setting = data.setting
  81. this.todaySign = data.todaySign
  82. })
  83. }
  84. },
  85. onLoad() {
  86. this.checkSetting()
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .sign-container{
  92. padding: 20rpx;
  93. font-size: 28rpx;
  94. .header{
  95. background-repeat: no-repeat;
  96. background-size: 100% 100%;
  97. height: 300rpx;
  98. border-radius: 10rpx;
  99. position: relative;
  100. margin-top: 100rpx;
  101. padding-top: 80rpx;
  102. .icon{
  103. background-repeat: no-repeat;
  104. background-size: 100%;
  105. height: 180rpx;
  106. width: 240rpx;
  107. position: absolute;
  108. top: -50%;
  109. transform: translateY(30%) translateX(-50%);
  110. left: 50%;
  111. }
  112. .been-sign{
  113. background: linear-gradient(303deg, #FF74B9, #6EEBE8, #FFFFFF);
  114. -webkit-background-clip: text;
  115. color: transparent;
  116. text-align: center;
  117. margin-bottom: 30rpx;
  118. font-size: 46rpx;
  119. font-weight: bold;
  120. }
  121. .tips{
  122. color: $info-color;
  123. text-align: center;
  124. width: 500rpx;
  125. margin: 0 auto;
  126. border-radius: 30rpx;
  127. padding: 12rpx 0;
  128. background: #1f2336;
  129. font-size: 26rpx;
  130. }
  131. }
  132. .content{
  133. margin-top: 40rpx;
  134. .item{
  135. color: $default-color;
  136. width: calc(#{650rpx}/4);
  137. background: #1B1E32;
  138. border-radius: 10rpx;
  139. padding: 40rpx 0;
  140. margin-bottom: 20rpx;
  141. margin-right: 20rpx;
  142. &.active{
  143. background: linear-gradient(221deg, #6EEBE8, #FF74B9);
  144. }
  145. &:nth-child(4){
  146. margin-right: 0;
  147. }
  148. &:last-child{
  149. flex: 1;
  150. margin-right: 0;
  151. }
  152. .left-box{
  153. .icon{
  154. image{
  155. width: 100rpx;
  156. height: 100rpx;
  157. }
  158. }
  159. .number{
  160. color: $primary-color;
  161. }
  162. }
  163. .right-box{
  164. margin-bottom: -100rpx;
  165. margin-right: -20rpx;
  166. margin-left: 40rpx;
  167. image{
  168. width: 160rpx;
  169. height: 160rpx;
  170. }
  171. }
  172. }
  173. }
  174. .btn{
  175. width: 690rpx;
  176. margin: 80rpx auto 0;
  177. padding: 24rpx 0;
  178. color: $default-color;
  179. background: linear-gradient(270deg, #FB3651 0%, #FF8999 100%);
  180. border-radius: 45px;
  181. text-align: center;
  182. }
  183. }
  184. </style>