logincode.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="container login">
  3. <view class="login-main">
  4. <image class="logo" src="../../static/login-logo@3x.png" mode=""></image>
  5. <text class="logo-text">生美/医美采购服务平台</text>
  6. </view>
  7. <view class="login-input">
  8. <input type="number"
  9. v-model="invitationCode"
  10. maxlength="6"
  11. class="input"
  12. placeholder="请输入邀请码"
  13. />
  14. </view>
  15. <view class="login-row" @click.stop="this.$api.navigateTo('/pages/login/register')"><text>免费注册</text></view>
  16. <view class="login-btn" @click.stop="goLogin">登录</view>
  17. <view class="login-btn-last" @click.stop="this.$api.navigateTo('/pages/login/login')">账号登录</view>
  18. </view>
  19. </template>
  20. <script>
  21. import authorize from '@/common/config/authorize.js'
  22. import {mapState,mapMutations } from 'vuex';
  23. import { invitationCodeLogin } from '@/api/use.js'
  24. export default{
  25. data() {
  26. return{
  27. invitationCode:'', //获取用户登录的邀请码
  28. }
  29. },
  30. onLoad(option) {
  31. },
  32. methods:{
  33. ...mapMutations(['login']),
  34. goLogin() {
  35. if( this.invitationCode == ''){
  36. this.$util.msg('请输入邀请码',2000)
  37. return
  38. }
  39. wx.getUserInfo({
  40. success: res => {
  41. this.isUserInfo = false
  42. this.userInfo = res.userInfo;
  43. let params ={
  44. invitationCode:this.invitationCode,
  45. nickName:res.userInfo.nickName,
  46. headimgurl:res.userInfo.avatarUrl,
  47. }
  48. invitationCodeLogin(params).then(response =>{
  49. this.login(response.data)
  50. switch(this.isLoginType){
  51. case 9:
  52. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  53. break;
  54. case 8:
  55. this.$api.navigateTo(`/pages/goods/product?id=${this.isLoginProductId}`)
  56. break;
  57. default:
  58. this.$api.switchTabTo('/pages/tabBar/user/user')
  59. }
  60. }).catch(error =>{
  61. this.$util.msg(error.msg,2000)
  62. this.isUserInfo = false
  63. })
  64. }
  65. })
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss">
  71. .login{
  72. width: 100%;
  73. height: auto;
  74. .model-warp.none{
  75. display: none;
  76. }
  77. .model-warp.show{
  78. display: block;
  79. }
  80. .login-main{
  81. width: 100%;
  82. display: flex;
  83. flex-direction: column;
  84. align-items: center;
  85. height: 198rpx;
  86. padding: 170rpx 0 60rpx 0;
  87. .logo{
  88. width: 138rpx;
  89. height: 118rpx;
  90. display: block;
  91. }
  92. .logo-text{
  93. font-size: 30rpx;
  94. line-height: 44rpx;
  95. color: $color-system;
  96. font-weight: 600;
  97. margin-top: 20rpx;
  98. }
  99. }
  100. .login-input{
  101. width: 654rpx;
  102. height: 40rpx;
  103. padding: 24rpx;
  104. margin: 0 auto;
  105. margin-bottom: 24rpx;
  106. background: #F7F7F7;
  107. border-radius: 14rpx;
  108. .input{
  109. width: 100%;
  110. height: 100%;
  111. background: #F7F7F7;
  112. font-size: $font-size-28;
  113. line-height: 40rpx;
  114. color: #333333;
  115. border-radius: 14rpx;
  116. }
  117. }
  118. .login-row{
  119. padding: 0 24rpx;
  120. font-size: $font-size-28;
  121. line-height: 40rpx;
  122. color: #E15616;
  123. margin-bottom: 48rpx;
  124. }
  125. .login-btn{
  126. width: 702rpx;
  127. height: 88rpx;
  128. border-radius: 14rpx;
  129. font-size: $font-size-28;
  130. line-height: 88rpx;
  131. color: #FFFFFF;
  132. margin: 0 auto;
  133. text-align: center;
  134. background: $btn-confirm;
  135. }
  136. .login-btn-last{
  137. width: 702rpx;
  138. height: 86rpx;
  139. border-radius: 14rpx;
  140. font-size: $font-size-28;
  141. line-height: 88rpx;
  142. color: $color-system;
  143. margin: 0 auto;
  144. text-align: center;
  145. border: 1px solid $color-system;
  146. margin-top: 20rpx;
  147. }
  148. .model-authorization{
  149. width: 100%;
  150. height: 100%;
  151. position: fixed;
  152. top: 0;
  153. left: 0;
  154. z-index: 999;
  155. .authorization{
  156. width: 518rpx;
  157. height: 320rpx;
  158. position: absolute;
  159. background: rgba(255,255,255,.7);
  160. left: 0;
  161. right: 0;
  162. bottom: 0;
  163. top: 0;
  164. margin: auto;
  165. .to-btn{
  166. position: absolute;
  167. top: 0;
  168. left: 0;
  169. right: 0;
  170. bottom: 0;
  171. margin: auto;
  172. width: 70%;
  173. height: 88rpx;
  174. font-size: $font-size-28;
  175. line-height: 88rpx;
  176. color: #FFFFFF;
  177. text-align: center;
  178. border-radius: 44rpx;
  179. }
  180. }
  181. }
  182. }
  183. </style>