logincode.vue 4.4 KB

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