logincode.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view class="container login">
  3. <view class="login-main">
  4. <image class="logo" src="https://admin-b.caimei365.com/userfiles/1/images/photo/2020/11/logo.png" mode=""></image>
  5. </view>
  6. <view class="login-input">
  7. <input type="number"
  8. v-model="invitationCode"
  9. maxlength="6"
  10. class="input"
  11. placeholder="请输入邀请码"
  12. />
  13. </view>
  14. <view class="login-row" @click.stop="this.$api.navigateTo('/pages/login/register-select')"><text>免费注册</text></view>
  15. <view class="login-btn" @click.stop="goLogin">登录</view>
  16. <view class="login-btn-last" @click.stop="this.$api.navigateTo('/pages/login/login')">账号登录</view>
  17. </view>
  18. </template>
  19. <script>
  20. import authorize from '@/common/config/authorize.js'
  21. import wxLogin from "@/common/config/wxLogin.js"
  22. import {mapState,mapMutations } from 'vuex';
  23. export default{
  24. data() {
  25. return{
  26. invitationCode:'', //获取用户登录的邀请码
  27. unionId:'',
  28. }
  29. },
  30. onLoad(option) {
  31. },
  32. computed: {
  33. ...mapState(['isWxAuthorize','isLoginType','isLoginProductId','isLoginOrderId'])
  34. },
  35. methods:{
  36. ...mapMutations(['login']),
  37. goLogin() {
  38. const userInfo = uni.getStorageSync('wechatUserInfo')
  39. if( this.invitationCode == ''){
  40. this.$util.msg('请输入邀请码',2000)
  41. return
  42. }
  43. this.isUserInfo = false
  44. this.UserService.InvitationCodeLogin({
  45. invitationCode:this.invitationCode,
  46. nickName:userInfo.nickName,
  47. avatarUrl:userInfo.avatarUrl,
  48. unionId:uni.getStorageSync('unionId')
  49. })
  50. .then(response =>{
  51. wxLogin.wxLoginAuthorize()
  52. if(response.data.userIdentity === 3){
  53. setTimeout(()=>{
  54. this.$api.navigateTo('/supplier/pages/index/index')
  55. },1500)
  56. }else{
  57. setTimeout(()=>{
  58. switch(this.isLoginType){
  59. case 9:
  60. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  61. break;
  62. case 8:
  63. this.$api.navigateTo(`/pages/goods/product?id=${this.isLoginProductId}`)
  64. break;
  65. case 7:
  66. this.$api.navigateTo(`/pages/user/order/order-details?type=share&orderID=${this.isLoginOrderId}`)
  67. break;
  68. default:
  69. this.$api.switchTabTo('/pages/tabBar/user/user')
  70. }
  71. },1500)
  72. }
  73. })
  74. .catch(error =>{
  75. this.$util.msg(error.msg,2000)
  76. this.isUserInfo = false
  77. })
  78. },
  79. InitAuthorize(){ //是否已授权 0:为取消授权 1:为已授权 2:为未操作
  80. if(uni.getStorageSync('_WX_State')){
  81. wxLogin.wxLoginQuick()
  82. }
  83. }
  84. },
  85. onShow() {
  86. this.$api.getStorage().then((resolve) =>{
  87. this.params.unionId = resolve.unionId ? resolve.unionId : 0
  88. })
  89. this.InitAuthorize()
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. .login{
  95. width: 100%;
  96. height: auto;
  97. .model-warp.none{
  98. display: none;
  99. }
  100. .model-warp.show{
  101. display: block;
  102. }
  103. .login-main{
  104. width: 100%;
  105. display: flex;
  106. flex-direction: column;
  107. align-items: center;
  108. height: 189rpx;
  109. padding:60rpx 0 40rpx 0;
  110. margin-bottom: 70rpx;
  111. .logo{
  112. width:467rpx;
  113. height: 189rpx;
  114. display: block;
  115. }
  116. }
  117. .login-input{
  118. width: 600rpx;
  119. height: 88rpx;
  120. padding: 24rpx 0;
  121. margin: 0 auto;
  122. margin-bottom: 30rpx;
  123. background: #FFFFFF;
  124. position: relative;
  125. box-sizing: border-box;
  126. border-bottom: 1px solid #E1E1E1;
  127. .input{
  128. width: 100%;
  129. height: 100%;
  130. background: #FFFFFF;
  131. font-size: $font-size-28;
  132. line-height: 88rpx;
  133. color: #333333;
  134. }
  135. }
  136. .login-row{
  137. padding: 0 75rpx;
  138. font-size: $font-size-28;
  139. line-height: 40rpx;
  140. color: #E15616;
  141. margin-bottom: 48rpx;
  142. text-align: right;
  143. }
  144. .login-btn{
  145. width: 600rpx;
  146. height: 88rpx;
  147. border-radius: 44rpx;
  148. font-size: $font-size-28;
  149. line-height: 88rpx;
  150. color: #FFFFFF;
  151. margin: 0 auto;
  152. text-align: center;
  153. background: $btn-confirm;
  154. }
  155. .login-btn-last{
  156. width: 600rpx;
  157. height: 86rpx;
  158. border-radius: 44rpx;
  159. font-size: $font-size-28;
  160. line-height: 88rpx;
  161. color: $color-system;
  162. margin: 0 auto;
  163. text-align: center;
  164. border: 1px solid $color-system;
  165. margin-top: 20rpx;
  166. }
  167. .model-authorization{
  168. width: 100%;
  169. height: 100%;
  170. position: fixed;
  171. top: 0;
  172. left: 0;
  173. z-index: 999;
  174. .authorization{
  175. width: 518rpx;
  176. height: 320rpx;
  177. position: absolute;
  178. background: rgba(255,255,255,.7);
  179. left: 0;
  180. right: 0;
  181. bottom: 0;
  182. top: 0;
  183. margin: auto;
  184. .to-btn{
  185. position: absolute;
  186. top: 0;
  187. left: 0;
  188. right: 0;
  189. bottom: 0;
  190. margin: auto;
  191. width: 70%;
  192. height: 88rpx;
  193. font-size: $font-size-28;
  194. line-height: 88rpx;
  195. color: #FFFFFF;
  196. text-align: center;
  197. border-radius: 44rpx;
  198. }
  199. }
  200. }
  201. }
  202. </style>