index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. this.$api.user.info().then(res => {
  78. this.$store.dispatch('user/info', res.data)
  79. })
  80. }
  81. })
  82. }
  83. },
  84. checkSetting() {
  85. this.$api.sign.setting().then(res => {
  86. this.loading = false
  87. const { data } = res
  88. this.signDays = data.signDays
  89. this.setting = data.setting
  90. this.todaySign = data.todaySign
  91. })
  92. }
  93. },
  94. onLoad() {
  95. this.checkSetting()
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .sign-container{
  101. padding: 20rpx;
  102. font-size: 28rpx;
  103. .header{
  104. background-repeat: no-repeat;
  105. background-size: 100% 100%;
  106. height: 300rpx;
  107. border-radius: 10rpx;
  108. position: relative;
  109. margin-top: 100rpx;
  110. padding-top: 80rpx;
  111. .icon{
  112. background-repeat: no-repeat;
  113. background-size: 100%;
  114. height: 180rpx;
  115. width: 240rpx;
  116. position: absolute;
  117. top: -50%;
  118. transform: translateY(30%) translateX(-50%);
  119. left: 50%;
  120. }
  121. .been-sign{
  122. background: linear-gradient(303deg, #FF74B9, #6EEBE8, #FFFFFF);
  123. -webkit-background-clip: text;
  124. color: transparent;
  125. text-align: center;
  126. margin-bottom: 30rpx;
  127. font-size: 46rpx;
  128. font-weight: bold;
  129. }
  130. .tips{
  131. color: $info-color;
  132. text-align: center;
  133. width: 500rpx;
  134. margin: 0 auto;
  135. border-radius: 30rpx;
  136. padding: 12rpx 0;
  137. background: #1f2336;
  138. font-size: 26rpx;
  139. }
  140. }
  141. .content{
  142. margin-top: 40rpx;
  143. .item{
  144. color: $default-color;
  145. width: calc(#{650rpx}/4);
  146. background: #1B1E32;
  147. border-radius: 10rpx;
  148. padding: 28rpx 0;
  149. margin-bottom: 20rpx;
  150. margin-right: 20rpx;
  151. &.active{
  152. background: linear-gradient(221deg, #6EEBE8, #FF74B9);
  153. }
  154. &:nth-child(4){
  155. margin-right: 0;
  156. }
  157. &:last-child{
  158. flex: 1;
  159. margin-right: 0;
  160. }
  161. .left-box{
  162. &.last{
  163. height: 100%;
  164. .title{
  165. margin-bottom: 10rpx;
  166. }
  167. }
  168. .title{
  169. font-size: 32rpx;
  170. }
  171. .icon{
  172. margin-top: 14rpx;
  173. image{
  174. width: 100rpx;
  175. height: 100rpx;
  176. }
  177. }
  178. .number{
  179. color: $primary-color;
  180. }
  181. }
  182. .right-box{
  183. margin-bottom: -100rpx;
  184. margin-right: -20rpx;
  185. margin-left: 40rpx;
  186. image{
  187. width: 160rpx;
  188. height: 160rpx;
  189. }
  190. }
  191. }
  192. }
  193. .btn{
  194. width: 690rpx;
  195. margin: 80rpx auto 0;
  196. padding: 24rpx 0;
  197. color: $default-color;
  198. background: linear-gradient(270deg, #FB3651 0%, #FF8999 100%);
  199. border-radius: 45px;
  200. text-align: center;
  201. }
  202. }
  203. </style>