logincode.vue 4.1 KB

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