logincode.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. authorize.getSetting().then(res =>{
  81. console.log('用户是否授权过',res)
  82. if(res == 1){
  83. wxLogin.wxLoginQuick()
  84. }
  85. })
  86. // if(uni.getStorageSync('_WX_State')){
  87. // wxLogin.wxLoginQuick()
  88. // }
  89. }
  90. },
  91. onShow() {
  92. this.$api.getStorage().then((resolve) =>{
  93. this.params.unionId = resolve.unionId ? resolve.unionId : 0
  94. })
  95. this.InitAuthorize()
  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: 189rpx;
  115. padding:60rpx 0 40rpx 0;
  116. margin-bottom: 70rpx;
  117. .logo{
  118. width:467rpx;
  119. height: 189rpx;
  120. display: block;
  121. }
  122. }
  123. .login-input{
  124. width: 600rpx;
  125. height: 88rpx;
  126. padding: 24rpx 0;
  127. margin: 0 auto;
  128. margin-bottom: 30rpx;
  129. background: #FFFFFF;
  130. position: relative;
  131. box-sizing: border-box;
  132. border-bottom: 1px solid #E1E1E1;
  133. .input{
  134. width: 100%;
  135. height: 100%;
  136. background: #FFFFFF;
  137. font-size: $font-size-28;
  138. line-height: 88rpx;
  139. color: #333333;
  140. }
  141. }
  142. .login-row{
  143. padding: 0 75rpx;
  144. font-size: $font-size-28;
  145. line-height: 40rpx;
  146. color: #E15616;
  147. margin-bottom: 48rpx;
  148. text-align: right;
  149. }
  150. .login-btn{
  151. width: 600rpx;
  152. height: 88rpx;
  153. border-radius: 44rpx;
  154. font-size: $font-size-28;
  155. line-height: 88rpx;
  156. color: #FFFFFF;
  157. margin: 0 auto;
  158. text-align: center;
  159. background: $btn-confirm;
  160. }
  161. .login-btn-last{
  162. width: 600rpx;
  163. height: 86rpx;
  164. border-radius: 44rpx;
  165. font-size: $font-size-28;
  166. line-height: 88rpx;
  167. color: $color-system;
  168. margin: 0 auto;
  169. text-align: center;
  170. border: 1px solid $color-system;
  171. margin-top: 20rpx;
  172. }
  173. .model-authorization{
  174. width: 100%;
  175. height: 100%;
  176. position: fixed;
  177. top: 0;
  178. left: 0;
  179. z-index: 999;
  180. .authorization{
  181. width: 518rpx;
  182. height: 320rpx;
  183. position: absolute;
  184. background: rgba(255,255,255,.7);
  185. left: 0;
  186. right: 0;
  187. bottom: 0;
  188. top: 0;
  189. margin: auto;
  190. .to-btn{
  191. position: absolute;
  192. top: 0;
  193. left: 0;
  194. right: 0;
  195. bottom: 0;
  196. margin: auto;
  197. width: 70%;
  198. height: 88rpx;
  199. font-size: $font-size-28;
  200. line-height: 88rpx;
  201. color: #FFFFFF;
  202. text-align: center;
  203. border-radius: 44rpx;
  204. }
  205. }
  206. }
  207. }
  208. </style>