gain.vue 2.8 KB

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