logincode.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. }
  87. },
  88. onShow() {
  89. this.$api.getStorage().then((resolve) =>{
  90. this.params.unionId = resolve.unionId ? resolve.unionId : 0
  91. })
  92. this.InitAuthorize()
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. .login{
  98. width: 100%;
  99. height: auto;
  100. .model-warp.none{
  101. display: none;
  102. }
  103. .model-warp.show{
  104. display: block;
  105. }
  106. .login-main{
  107. width: 100%;
  108. display: flex;
  109. flex-direction: column;
  110. align-items: center;
  111. height: 189rpx;
  112. padding:60rpx 0 40rpx 0;
  113. margin-bottom: 70rpx;
  114. .logo{
  115. width:467rpx;
  116. height: 189rpx;
  117. display: block;
  118. }
  119. }
  120. .login-input{
  121. width: 600rpx;
  122. height: 88rpx;
  123. padding: 24rpx 0;
  124. margin: 0 auto;
  125. margin-bottom: 30rpx;
  126. background: #FFFFFF;
  127. position: relative;
  128. box-sizing: border-box;
  129. border-bottom: 1px solid #E1E1E1;
  130. .input{
  131. width: 100%;
  132. height: 100%;
  133. background: #FFFFFF;
  134. font-size: $font-size-28;
  135. line-height: 88rpx;
  136. color: #333333;
  137. }
  138. }
  139. .login-row{
  140. padding: 0 75rpx;
  141. font-size: $font-size-28;
  142. line-height: 40rpx;
  143. color: #E15616;
  144. margin-bottom: 48rpx;
  145. text-align: right;
  146. }
  147. .login-btn{
  148. width: 600rpx;
  149. height: 88rpx;
  150. border-radius: 44rpx;
  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. .login-btn-last{
  159. width: 600rpx;
  160. height: 86rpx;
  161. border-radius: 44rpx;
  162. font-size: $font-size-28;
  163. line-height: 88rpx;
  164. color: $color-system;
  165. margin: 0 auto;
  166. text-align: center;
  167. border: 1px solid $color-system;
  168. margin-top: 20rpx;
  169. }
  170. .model-authorization{
  171. width: 100%;
  172. height: 100%;
  173. position: fixed;
  174. top: 0;
  175. left: 0;
  176. z-index: 999;
  177. .authorization{
  178. width: 518rpx;
  179. height: 320rpx;
  180. position: absolute;
  181. background: rgba(255,255,255,.7);
  182. left: 0;
  183. right: 0;
  184. bottom: 0;
  185. top: 0;
  186. margin: auto;
  187. .to-btn{
  188. position: absolute;
  189. top: 0;
  190. left: 0;
  191. right: 0;
  192. bottom: 0;
  193. margin: auto;
  194. width: 70%;
  195. height: 88rpx;
  196. font-size: $font-size-28;
  197. line-height: 88rpx;
  198. color: #FFFFFF;
  199. text-align: center;
  200. border-radius: 44rpx;
  201. }
  202. }
  203. }
  204. }
  205. </style>