index.vue 5.2 KB

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