logincode.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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-select')"><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 wxLogin from "@/common/config/wxLogin.js"
  23. import {mapState,mapMutations } from 'vuex';
  24. import { invitationCodeLogin } from '@/api/use.js'
  25. export default{
  26. data() {
  27. return{
  28. invitationCode:'', //获取用户登录的邀请码
  29. }
  30. },
  31. onLoad(option) {
  32. },
  33. computed: {
  34. ...mapState(['isWxAuthorize','isLoginType','isLoginProductId','isLoginOrderId'])
  35. },
  36. methods:{
  37. ...mapMutations(['login']),
  38. goLogin() {
  39. if( this.invitationCode == ''){
  40. this.$util.msg('请输入邀请码',2000)
  41. return
  42. }
  43. wx.getUserInfo({
  44. success: res => {
  45. this.isUserInfo = false
  46. this.userInfo = res.userInfo;
  47. let params ={
  48. invitationCode:this.invitationCode,
  49. nickName:res.userInfo.nickName,
  50. headimgurl:res.userInfo.avatarUrl,
  51. }
  52. invitationCodeLogin(params).then(response =>{
  53. this.login(response.data)
  54. wxLogin.wxLoginAuthorize()
  55. setTimeout(()=>{
  56. switch(this.isLoginType){
  57. case 9:
  58. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  59. break;
  60. case 8:
  61. this.$api.navigateTo(`/pages/goods/product?id=${this.isLoginProductId}`)
  62. break;
  63. case 7:
  64. this.$api.navigateTo(`/pages/user/order/order-details?type=share&orderID=${this.isLoginOrderId}`)
  65. break;
  66. default:
  67. this.$api.switchTabTo('/pages/tabBar/user/user')
  68. }
  69. },1000)
  70. }).catch(error =>{
  71. this.$util.msg(error.msg,2000)
  72. this.isUserInfo = false
  73. })
  74. }
  75. })
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss">
  81. .login{
  82. width: 100%;
  83. height: auto;
  84. .model-warp.none{
  85. display: none;
  86. }
  87. .model-warp.show{
  88. display: block;
  89. }
  90. .login-main{
  91. width: 100%;
  92. display: flex;
  93. flex-direction: column;
  94. align-items: center;
  95. height: 198rpx;
  96. padding: 170rpx 0 60rpx 0;
  97. .logo{
  98. width: 138rpx;
  99. height: 118rpx;
  100. display: block;
  101. }
  102. .logo-text{
  103. font-size: 30rpx;
  104. line-height: 44rpx;
  105. color: $color-system;
  106. font-weight: 600;
  107. margin-top: 20rpx;
  108. }
  109. }
  110. .login-input{
  111. width: 654rpx;
  112. height: 40rpx;
  113. padding: 24rpx;
  114. margin: 0 auto;
  115. margin-bottom: 24rpx;
  116. background: #F7F7F7;
  117. border-radius: 14rpx;
  118. .input{
  119. width: 100%;
  120. height: 100%;
  121. background: #F7F7F7;
  122. font-size: $font-size-28;
  123. line-height: 40rpx;
  124. color: #333333;
  125. border-radius: 14rpx;
  126. }
  127. }
  128. .login-row{
  129. padding: 0 24rpx;
  130. font-size: $font-size-28;
  131. line-height: 40rpx;
  132. color: #E15616;
  133. margin-bottom: 48rpx;
  134. }
  135. .login-btn{
  136. width: 702rpx;
  137. height: 88rpx;
  138. border-radius: 14rpx;
  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: 702rpx;
  148. height: 86rpx;
  149. border-radius: 14rpx;
  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>