logincode.vue 4.3 KB

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