login.vue 4.2 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-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. let data = JSON.parse(option.data);
  36. this.getOption = data
  37. this.loginType = option.type;
  38. this.id = option.id
  39. if(option.listType) {
  40. this.listType = option.listType;
  41. this.listVal = option.listVal;
  42. }
  43. },
  44. methods:{
  45. ...mapMutations(['login']),
  46. goLogin() {
  47. if( this.invitationCode == ''){
  48. this.$util.msg('请输入邀请码',2000)
  49. return
  50. }
  51. wx.getUserInfo({
  52. success: res => {
  53. this.isUserInfo = false
  54. this.userInfo = res.userInfo;
  55. let params ={
  56. invitationCode:this.invitationCode,
  57. nickName:res.userInfo.nickName,
  58. headimgurl:res.userInfo.avatarUrl,
  59. }
  60. invitationCodeLogin(params).then(response =>{
  61. if(response.code == 0){
  62. this.login(response.data)
  63. this.$api.switchTabTo('/pages/tabBar/home/home')
  64. }else if(response.code == 4){
  65. this.login(response.data)
  66. this.$api.navigateTo(`/pages/login/bindemail?pathType=1`)
  67. }else{
  68. this.$util.msg(response.msg,2000)
  69. this.isUserInfo = false
  70. }
  71. })
  72. }
  73. })
  74. },
  75. goUserLogininit(){
  76. let url;
  77. if(this.loginType) {
  78. if(this.loginType=='detilType'){
  79. this.$api.redirectTo(`/pages/goods/product?id=${this.id}&page=2`);
  80. }else if(this.loginType=='search'){
  81. this.$api.redirectTo('/pages/search/search');
  82. }else if(this.loginType == 1){
  83. url ='/pages/tabBar/cart/cart'
  84. }else if(this.loginType == 4){
  85. url ='/pages/tabBar/user/user'
  86. }else {
  87. url ='/pages/tabBar/home/home'
  88. }
  89. uni.switchTab({
  90. url
  91. })
  92. } else if(this.listType) {
  93. this.$api.navToListPage({type:this.listType,value:this.listVal,lType:'4'});
  94. }
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss">
  100. .login{
  101. width: 100%;
  102. height: auto;
  103. .model-warp.none{
  104. display: none;
  105. }
  106. .model-warp.show{
  107. display: block;
  108. }
  109. .login-main{
  110. width: 100%;
  111. display: flex;
  112. flex-direction: column;
  113. align-items: center;
  114. height: 198rpx;
  115. padding: 170rpx 0 60rpx 0;
  116. .logo{
  117. width: 138rpx;
  118. height: 118rpx;
  119. display: block;
  120. }
  121. .logo-text{
  122. font-size: 30rpx;
  123. line-height: 44rpx;
  124. color: $color-system;
  125. font-weight: 600;
  126. margin-top: 20rpx;
  127. }
  128. }
  129. .login-input{
  130. width: 654rpx;
  131. height: 40rpx;
  132. padding: 24rpx;
  133. margin: 0 auto;
  134. margin-bottom: 60rpx;
  135. background: #F7F7F7;
  136. border-radius: 14rpx;
  137. .input{
  138. width: 100%;
  139. height: 100%;
  140. background: #F7F7F7;
  141. font-size: $font-size-28;
  142. line-height: 40rpx;
  143. color: #333333;
  144. border-radius: 14rpx;
  145. }
  146. }
  147. .login-btn{
  148. width: 702rpx;
  149. height: 88rpx;
  150. border-radius: 14rpx;
  151. font-size: $font-size-28;
  152. line-height: 88rpx;
  153. color: #FFFFFF;
  154. margin: 0 auto;
  155. text-align: center;
  156. background: $btn-confirm;
  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>