gain.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="container">
  3. <view class="tabs">
  4. <scroll-view scroll-x class="bg-white nav">
  5. <view class="flex text-center">
  6. <view class="cu-item flex-sub" :class="index==current?'text-base cur text-xl text-bold ':'text-lg'"
  7. v-for="(item,index) in tabs" :key="index" @tap="tabChange(index)">
  8. {{item.name}}
  9. </view>
  10. </view>
  11. </scroll-view>
  12. </view>
  13. <view style="height: 100%;">
  14. <swiper style="height: 100%;" :current="current" @change="swiperChange" @animationfinish="animationfinish">
  15. <swiper-item v-for="(item,index) in tabs" :key="index">
  16. <scroll-view scroll-y style="height: 100%;">
  17. <card1 v-if="current==0"></card1>
  18. <card2 @login="showLogin" v-else></card2>
  19. </scroll-view>
  20. </swiper-item>
  21. </swiper>
  22. </view>
  23. <login ref="login" @signIn="signIn"></login>
  24. </view>
  25. </template>
  26. <script>
  27. import card1 from "./comps/card1.vue"
  28. import card2 from "./comps/card2.vue"
  29. import login from "@/components/login.vue"
  30. export default {
  31. components:{
  32. card1,card2,login
  33. },
  34. data() {
  35. return {
  36. current: 0,
  37. swiperCurrent: 0,
  38. tabs: [{
  39. name: '参与活动',
  40. value: 0
  41. },
  42. {
  43. name: '代理推广',
  44. value: 1
  45. }
  46. ],
  47. }
  48. },
  49. onLoad(options) {
  50. this.current=options.current || 0
  51. },
  52. methods: {
  53. showLogin(){
  54. this.$refs.login.show()
  55. },
  56. showPhoneModal(){
  57. this.$refs.login.showPhoneModal()
  58. },
  59. signIn(resp){
  60. this.judgeAgenterType()
  61. if (!this.vuex_phone) {
  62. this.showPhoneModal()
  63. }
  64. },
  65. judgeAgenterType(){
  66. let params={
  67. userId:this.vuex_userId,
  68. enabled:1
  69. }
  70. this.$api.agenter.list(params).then(res=>{
  71. if (!this.$isEmpty(res.data.records)) {
  72. let item=res.data.records[0]
  73. let type=this.$isEmpty(item.agenterTypeId)?1:2
  74. this.$u.vuex('vuex_agenter_type',type)
  75. }
  76. })
  77. },
  78. showModal(){
  79. if (this.current==1 && this.$isEmpty(this.vuex_userId)) {
  80. this.showLogin()
  81. return
  82. }
  83. if (this.current==1 && this.$isEmpty(this.vuex_phone)) {
  84. this.showPhoneModal()
  85. }
  86. },
  87. tabChange(index) {
  88. this.current = index
  89. this.showModal()
  90. },
  91. swiperChange(e) {
  92. uni.pageScrollTo({
  93. scrollTop: 0,
  94. duration: 0
  95. });
  96. this.current = e.detail.current
  97. this.showModal()
  98. },
  99. animationfinish({
  100. detail: {
  101. current
  102. }
  103. }) {
  104. this.swiperCurrent = current;
  105. this.current = current;
  106. },
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .text-xl {
  112. font-size: 34rpx;
  113. }
  114. .text-base{
  115. color: #EF9944;
  116. }
  117. .container {
  118. height: calc(100vh);
  119. background-color: #F6F6F6;
  120. padding: 78rpx 0rpx 0rpx;
  121. .tabs {
  122. position: fixed;
  123. top: -16rpx;
  124. left: 0;
  125. width: 100%;
  126. background-color: #FFFFFF;
  127. box-sizing: border-box;
  128. z-index: 3;
  129. }
  130. }
  131. </style>