app-check-in.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="app-check-in dir-left-nowrap" :class="'main-' + textPosition" :style="{backgroundImage: `url(`+backgroundPicUrl+`)`}">
  3. <app-hotspot :hotspot="hotspot">
  4. <view @click='checkIn' style="width:100%;height:100%;"></view>
  5. </app-hotspot>
  6. <view class="dir-top-nowrap main-center" v-if="userInfo.check_in && showText" :style="{color:textColor,textAlign: textPosition}">
  7. <view class="box-grow-0 first">今天签到可获得{{userInfo.check_in.todayAward}}</view>
  8. <view class="box-grow-0 second">已连续签到{{userInfo.check_in.continue}}天</view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import {mapGetters} from 'vuex';
  14. import appHotspot from '../../basic-component/app-hotspot/app-hotspot.vue';
  15. import checkInAward from './check-in-award.js';
  16. export default {
  17. name: "app-check-in",
  18. components: {
  19. 'app-hotspot': appHotspot
  20. },
  21. props: {
  22. backgroundPicUrl: {
  23. type: String,
  24. default() {
  25. return '';
  26. }
  27. },
  28. hotspot: {
  29. type: Object,
  30. default() {
  31. return {};
  32. }
  33. },
  34. showText: {
  35. type: Boolean,
  36. default() {
  37. return false;
  38. }
  39. },
  40. textColor: String,
  41. textPosition: String,
  42. },
  43. computed: {
  44. ...mapGetters({
  45. userInfo: 'user/info',
  46. })
  47. },
  48. methods: {
  49. checkIn() {
  50. uni.showLoading({
  51. title: '签到中'
  52. });
  53. checkInAward.getAward(1, 1).then(result => {
  54. uni.hideLoading();
  55. uni.showToast({
  56. title: '签到成功',
  57. icon: 'success',
  58. mask: false
  59. });
  60. this.$store.dispatch('user/info');
  61. }).catch(e => {
  62. uni.hideLoading();
  63. uni.showToast({
  64. title: e,
  65. mask: false,
  66. icon: 'none'
  67. })
  68. });
  69. }
  70. }
  71. }
  72. </script>
  73. <style scoped lang="scss">
  74. .app-check-in {
  75. width: 100%;
  76. height: #{200rpx};
  77. padding: 0 #{50rpx};
  78. position: relative;
  79. background-position: center;
  80. background-size: cover;
  81. background-repeat: no-repeat;
  82. }
  83. </style>