login.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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-btn" @click="goLogin">登录</view>
  16. </view>
  17. </template>
  18. <script>
  19. import {mapState,mapMutations } from 'vuex';
  20. import authorize from '@/common/config/authorize.js'
  21. import { invitationCodeLogin } from '@/api/use.js'
  22. export default{
  23. data() {
  24. return{
  25. invitationCode:'', //获取用户登录的邀请码
  26. loginType:'', //跳转类型
  27. alertText:'',
  28. listType: '',
  29. listVal: '',
  30. detilType:'',
  31. id:''//商品ID
  32. }
  33. },
  34. onLoad(option) {
  35. console.log(option)
  36. let data = JSON.parse(option.data);
  37. this.getOption = data
  38. this.loginType = option.type;
  39. this.id = option.id
  40. if(option.listType) {
  41. this.listType = option.listType;
  42. this.listVal = option.listVal;
  43. }
  44. },
  45. methods:{
  46. ...mapMutations(['login']),
  47. goLogin() {
  48. if( this.invitationCode == ''){
  49. this.$util.msg('请输入邀请码',2000)
  50. return
  51. }
  52. wx.getUserInfo({
  53. success: res => {
  54. console.log('useInfo:',res.userInfo)
  55. this.isUserInfo = false
  56. this.userInfo = res.userInfo;
  57. let params ={
  58. invitationCode:this.invitationCode,
  59. nickName:res.userInfo.nickName,
  60. headimgurl:res.userInfo.avatarUrl,
  61. }
  62. invitationCodeLogin(params).then(response =>{
  63. if(response.code == 0){
  64. this.login(response.data)
  65. uni.switchTab({
  66. url:'/pages/tabBar/home/home'
  67. })
  68. }else if(response.code == 4){
  69. this.login(response.data)
  70. this.$api.navigateTo(`/pages/user-module/bindemail?data=${JSON.stringify(this.getOption)}&pathType=1`)
  71. }else{
  72. this.$util.msg(response.msg,2000)
  73. this.isUserInfo = false
  74. }
  75. })
  76. }
  77. })
  78. },
  79. goUserLogininit(){
  80. let url;
  81. if(this.loginType) {
  82. if(this.loginType=='detilType'){
  83. this.$api.redirectTo(`/pages/goods/product?id=${this.id}&page=2`);
  84. }else if(this.loginType=='search'){
  85. this.$api.redirectTo('/pages/search/search');
  86. }else if(this.loginType == 1){
  87. url ='/pages/tabBar/cart/cart'
  88. }else if(this.loginType == 4){
  89. url ='/pages/tabBar/user/user'
  90. }else {
  91. url ='/pages/tabBar/home/home'
  92. }
  93. uni.switchTab({
  94. url
  95. })
  96. } else if(this.listType) {
  97. this.$api.navToListPage({type:this.listType,value:this.listVal,lType:'4'});
  98. }
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .login{
  105. width: 100%;
  106. height: auto;
  107. .model-warp.none{
  108. display: none;
  109. }
  110. .model-warp.show{
  111. display: block;
  112. }
  113. .login-main{
  114. width: 100%;
  115. display: flex;
  116. flex-direction: column;
  117. align-items: center;
  118. height: 198rpx;
  119. padding: 170rpx 0 60rpx 0;
  120. .logo{
  121. width: 138rpx;
  122. height: 118rpx;
  123. display: block;
  124. }
  125. .logo-text{
  126. font-size: 30rpx;
  127. line-height: 44rpx;
  128. color: $color-system;
  129. font-weight: 600;
  130. margin-top: 20rpx;
  131. }
  132. }
  133. .login-input{
  134. width: 654rpx;
  135. height: 40rpx;
  136. padding: 24rpx;
  137. margin: 0 auto;
  138. margin-bottom: 60rpx;
  139. background: #F7F7F7;
  140. border-radius: 14rpx;
  141. .input{
  142. width: 100%;
  143. height: 100%;
  144. background: #F7F7F7;
  145. font-size: $font-size-28;
  146. line-height: 40rpx;
  147. color: #333333;
  148. border-radius: 14rpx;
  149. }
  150. }
  151. .login-btn{
  152. width: 702rpx;
  153. height: 88rpx;
  154. border-radius: 14rpx;
  155. font-size: $font-size-28;
  156. line-height: 88rpx;
  157. color: #FFFFFF;
  158. margin: 0 auto;
  159. text-align: center;
  160. background: $btn-confirm;
  161. }
  162. .model-authorization{
  163. width: 100%;
  164. height: 100%;
  165. position: fixed;
  166. top: 0;
  167. left: 0;
  168. z-index: 999;
  169. .authorization{
  170. width: 518rpx;
  171. height: 320rpx;
  172. position: absolute;
  173. background: rgba(255,255,255,.7);
  174. left: 0;
  175. right: 0;
  176. bottom: 0;
  177. top: 0;
  178. margin: auto;
  179. .to-btn{
  180. position: absolute;
  181. top: 0;
  182. left: 0;
  183. right: 0;
  184. bottom: 0;
  185. margin: auto;
  186. width: 70%;
  187. height: 88rpx;
  188. font-size: $font-size-28;
  189. line-height: 88rpx;
  190. color: #FFFFFF;
  191. text-align: center;
  192. border-radius: 44rpx;
  193. }
  194. }
  195. }
  196. }
  197. </style>