Register.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false"><view class="div container">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="注册" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div main-content">
  13. <view class="div topList">
  14. <view class="div list">
  15. <view
  16. class="div item"
  17. v-for="(item, index) in items"
  18. :key="index"
  19. v-on:click="onClickItem(item.id)"
  20. >
  21. <label
  22. class="title"
  23. v-bind:class="{
  24. active: item.id === currentIndex,
  25. normal: item.id !== currentIndex
  26. }"
  27. >{{ getTitle(item) }}</label
  28. >
  29. </view>
  30. </view>
  31. </view>
  32. <flex-line v-if="inviter" :show-border="true"><text class="span line-name">推荐人</text><text class="span" slot="right">{{inviter.member_name}}</text></flex-line>
  33. <view class="div" v-if="items.length">
  34. <register-by-email v-if="currentIndex === 1" />
  35. <register-by-mobile v-else-if="currentIndex === 2" />
  36. </view>
  37. </view>
  38. </view></home-base>
  39. </template>
  40. <script>
  41. import {getFontSize} from '@/util/common'
  42. import TitleHeader from '../../TitleHeader'
  43. import HomeBase from '../HomeBase'
  44. import RegisterByMobile from './RegisterByMobile'
  45. import RegisterByEmail from './RegisterByEmail'
  46. import { mapState, mapMutations, mapActions } from 'vuex'
  47. import { getInviterInfo } from '../../../api/memberRegister'
  48. import flexLine from '../../flexLine'
  49. export default {
  50. name: 'Register',
  51. components:{
  52. TitleHeader,
  53. HomeBase,
  54. flexLine,
  55. RegisterByMobile,
  56. RegisterByEmail
  57. },
  58. mounted(){
  59. // #ifdef MP-WEIXIN
  60. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  61. // #endif
  62. },
  63. data(){
  64. return {
  65. navHeight: 0,
  66. inviter:false,
  67. currentIndex: 0,
  68. items: []
  69. }
  70. },
  71. created: function () {
  72. this.fetchConfig({}).then(
  73. res => {
  74. var config=res.result.config_list
  75. if(config.member_normal_register==1){
  76. this.items.push({id:1,title:'普通注册'})
  77. if(!this.currentIndex){
  78. this.currentIndex=1
  79. }
  80. }
  81. if(config.sms_register==1){
  82. this.items.push({id:2,title:'手机注册'})
  83. if(!this.currentIndex){
  84. this.currentIndex=2
  85. }
  86. }
  87. },
  88. error => {
  89. uni.showToast({icon:'none',title: error.message})
  90. }
  91. )
  92. if (this.inviter_id) {
  93. getInviterInfo(this.inviter_id).then(res => {
  94. this.inviter = res.result.member
  95. })
  96. }
  97. },
  98. computed:{
  99. fontSize(){
  100. return getFontSize()
  101. },
  102. ...mapState({
  103. inviter_id: state => state.member.inviterId,
  104. config: state => state.config.config
  105. }),
  106. isFirstTab () {
  107. if (this.currentIndex === 0) {
  108. return true
  109. } else {
  110. return false
  111. }
  112. }
  113. },
  114. methods: {
  115. ...mapActions({
  116. fetchConfig: 'fetchConfig'
  117. }),
  118. goBack () {
  119. uni.navigateBack({delta:1})
  120. },
  121. getTitle (item) {
  122. return item ? item.title : ''
  123. },
  124. isShowLine (index) {
  125. return index === this.currentIndex
  126. },
  127. onClickItem (index) {
  128. if (this.currentIndex !== index) {
  129. this.currentIndex = index
  130. }
  131. }
  132. }
  133. }
  134. </script>
  135. <style scoped lang="scss">
  136. .container {
  137. display: flex;
  138. flex-direction: column;
  139. justify-content: flex-start;
  140. align-items: stretch;
  141. //background-color: $primaryColor;
  142. .main-content{background: #fff;padding:1rem 0;}
  143. }
  144. .topList {
  145. height:2rem;
  146. padding:1rem $pageSpace;
  147. .list {
  148. height: 100%;
  149. display: flex;
  150. flex-direction: row;
  151. justify-content: flex-start;
  152. align-content: center;
  153. align-items: stretch;
  154. background-color: #fff;
  155. }
  156. .item {
  157. padding:0 .5rem;
  158. position: relative;
  159. display: flex;
  160. flex-direction: column;
  161. justify-content: center;
  162. align-items: center;
  163. }
  164. .title {
  165. text-align: center;
  166. font-size:$h2;
  167. color: $formInputColor;
  168. }
  169. .active {
  170. color: $primaryColor;
  171. font-size:1.1rem;
  172. }
  173. .normal {
  174. color: #404245;
  175. }
  176. }
  177. </style>