logincode.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 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. 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. }).catch(error =>{
  69. this.$util.msg(error.msg,2000)
  70. this.isUserInfo = false
  71. })
  72. }
  73. })
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss">
  79. .login{
  80. width: 100%;
  81. height: auto;
  82. .model-warp.none{
  83. display: none;
  84. }
  85. .model-warp.show{
  86. display: block;
  87. }
  88. .login-main{
  89. width: 100%;
  90. display: flex;
  91. flex-direction: column;
  92. align-items: center;
  93. height: 198rpx;
  94. padding: 170rpx 0 60rpx 0;
  95. .logo{
  96. width: 138rpx;
  97. height: 118rpx;
  98. display: block;
  99. }
  100. .logo-text{
  101. font-size: 30rpx;
  102. line-height: 44rpx;
  103. color: $color-system;
  104. font-weight: 600;
  105. margin-top: 20rpx;
  106. }
  107. }
  108. .login-input{
  109. width: 654rpx;
  110. height: 40rpx;
  111. padding: 24rpx;
  112. margin: 0 auto;
  113. margin-bottom: 24rpx;
  114. background: #F7F7F7;
  115. border-radius: 14rpx;
  116. .input{
  117. width: 100%;
  118. height: 100%;
  119. background: #F7F7F7;
  120. font-size: $font-size-28;
  121. line-height: 40rpx;
  122. color: #333333;
  123. border-radius: 14rpx;
  124. }
  125. }
  126. .login-row{
  127. padding: 0 24rpx;
  128. font-size: $font-size-28;
  129. line-height: 40rpx;
  130. color: #E15616;
  131. margin-bottom: 48rpx;
  132. }
  133. .login-btn{
  134. width: 702rpx;
  135. height: 88rpx;
  136. border-radius: 14rpx;
  137. font-size: $font-size-28;
  138. line-height: 88rpx;
  139. color: #FFFFFF;
  140. margin: 0 auto;
  141. text-align: center;
  142. background: $btn-confirm;
  143. }
  144. .login-btn-last{
  145. width: 702rpx;
  146. height: 86rpx;
  147. border-radius: 14rpx;
  148. font-size: $font-size-28;
  149. line-height: 88rpx;
  150. color: $color-system;
  151. margin: 0 auto;
  152. text-align: center;
  153. border: 1px solid $color-system;
  154. margin-top: 20rpx;
  155. }
  156. .model-authorization{
  157. width: 100%;
  158. height: 100%;
  159. position: fixed;
  160. top: 0;
  161. left: 0;
  162. z-index: 999;
  163. .authorization{
  164. width: 518rpx;
  165. height: 320rpx;
  166. position: absolute;
  167. background: rgba(255,255,255,.7);
  168. left: 0;
  169. right: 0;
  170. bottom: 0;
  171. top: 0;
  172. margin: auto;
  173. .to-btn{
  174. position: absolute;
  175. top: 0;
  176. left: 0;
  177. right: 0;
  178. bottom: 0;
  179. margin: auto;
  180. width: 70%;
  181. height: 88rpx;
  182. font-size: $font-size-28;
  183. line-height: 88rpx;
  184. color: #FFFFFF;
  185. text-align: center;
  186. border-radius: 44rpx;
  187. }
  188. }
  189. }
  190. }
  191. </style>