logincode.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 '@/services/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. if(response.data.userIdentity === 3){
  55. setTimeout(()=>{
  56. this.$api.navigateTo('/supplier/pages/index/index')
  57. },1000)
  58. }else{
  59. setTimeout(()=>{
  60. switch(this.isLoginType){
  61. case 9:
  62. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  63. break;
  64. case 8:
  65. this.$api.navigateTo(`/pages/goods/product?id=${this.isLoginProductId}`)
  66. break;
  67. case 7:
  68. this.$api.navigateTo(`/pages/user/order/order-details?type=share&orderID=${this.isLoginOrderId}`)
  69. break;
  70. default:
  71. this.$api.switchTabTo('/pages/tabBar/user/user')
  72. }
  73. },1000)
  74. }
  75. }).catch(error =>{
  76. this.$util.msg(error.msg,2000)
  77. this.isUserInfo = false
  78. })
  79. }
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. .login{
  87. width: 100%;
  88. height: auto;
  89. .model-warp.none{
  90. display: none;
  91. }
  92. .model-warp.show{
  93. display: block;
  94. }
  95. .login-main{
  96. width: 100%;
  97. display: flex;
  98. flex-direction: column;
  99. align-items: center;
  100. height: 189rpx;
  101. padding:60rpx 0 40rpx 0;
  102. margin-bottom: 70rpx;
  103. .logo{
  104. width:467rpx;
  105. height: 189rpx;
  106. display: block;
  107. }
  108. }
  109. .login-input{
  110. width: 600rpx;
  111. height: 88rpx;
  112. padding: 24rpx 0;
  113. margin: 0 auto;
  114. margin-bottom: 30rpx;
  115. background: #FFFFFF;
  116. position: relative;
  117. box-sizing: border-box;
  118. border-bottom: 1px solid #E1E1E1;
  119. .input{
  120. width: 100%;
  121. height: 100%;
  122. background: #FFFFFF;
  123. font-size: $font-size-28;
  124. line-height: 88rpx;
  125. color: #333333;
  126. }
  127. }
  128. .login-row{
  129. padding: 0 75rpx;
  130. font-size: $font-size-28;
  131. line-height: 40rpx;
  132. color: #E15616;
  133. margin-bottom: 48rpx;
  134. text-align: right;
  135. }
  136. .login-btn{
  137. width: 600rpx;
  138. height: 88rpx;
  139. border-radius: 44rpx;
  140. font-size: $font-size-28;
  141. line-height: 88rpx;
  142. color: #FFFFFF;
  143. margin: 0 auto;
  144. text-align: center;
  145. background: $btn-confirm;
  146. }
  147. .login-btn-last{
  148. width: 600rpx;
  149. height: 86rpx;
  150. border-radius: 44rpx;
  151. font-size: $font-size-28;
  152. line-height: 88rpx;
  153. color: $color-system;
  154. margin: 0 auto;
  155. text-align: center;
  156. border: 1px solid $color-system;
  157. margin-top: 20rpx;
  158. }
  159. .model-authorization{
  160. width: 100%;
  161. height: 100%;
  162. position: fixed;
  163. top: 0;
  164. left: 0;
  165. z-index: 999;
  166. .authorization{
  167. width: 518rpx;
  168. height: 320rpx;
  169. position: absolute;
  170. background: rgba(255,255,255,.7);
  171. left: 0;
  172. right: 0;
  173. bottom: 0;
  174. top: 0;
  175. margin: auto;
  176. .to-btn{
  177. position: absolute;
  178. top: 0;
  179. left: 0;
  180. right: 0;
  181. bottom: 0;
  182. margin: auto;
  183. width: 70%;
  184. height: 88rpx;
  185. font-size: $font-size-28;
  186. line-height: 88rpx;
  187. color: #FFFFFF;
  188. text-align: center;
  189. border-radius: 44rpx;
  190. }
  191. }
  192. }
  193. }
  194. </style>