login-code.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="container login">
  3. <view class="login-main"> <image class="logo" :src="staticUrl + 'logo@2x.png'" mode=""></image> </view>
  4. <view class="login-input">
  5. <keyInput
  6. borderValueColor="#E1E1E1"
  7. borderActiveColor="#E1E1E1"
  8. ref="vcodeInputRef"
  9. @vcodeInput="keyInput"
  10. @vcodeChange="keyInputChangeHandle"
  11. sum="6"
  12. >
  13. </keyInput>
  14. </view>
  15. <button class="login-btn" @click.stop="goLogin" :class="isDisabled ? 'disabled' : ''" :disabled="isDisabled">
  16. 邀请码登录
  17. </button>
  18. <view class="login-tips">
  19. <text class="h1">注意事项:</text>
  20. <text class="p"
  21. >邀请码是为了方便机构内成员互相邀请并快速注册【丽格集采联盟】小程序而推出的一项邀请机制。</text
  22. >
  23. <text class="p"
  24. >机构已注册了账号的成员,可在其个人中心添加其他机构成员,系统会自动为添加的每一个成员生成邀请码。其他成员使用邀请码可直接登录【丽格集采联盟】小程序。</text
  25. >
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import authorize from '@/common/config/authorize.js'
  31. import wxLogin from '@/common/config/wxLogin.js'
  32. import { mapState, mapMutations } from 'vuex'
  33. import keyInput from '@/components/uni-keyinput/uni-keyinput'
  34. export default {
  35. components: {
  36. keyInput
  37. },
  38. data() {
  39. return {
  40. staticUrl: this.global.staticUrl,
  41. params: {
  42. invitationCode: '', //获取用户登录的邀请码
  43. unionId: 0,
  44. nickName: '',
  45. avatarUrl: '',
  46. organizeId: 4
  47. }
  48. }
  49. },
  50. onLoad(option) {},
  51. computed: {
  52. ...mapState(['isWxAuthorize', 'isLoginType', 'isLoginProductId', 'isLoginOrderId']),
  53. isDisabled() {
  54. // 邀请码长度是否符合要求
  55. return this.params.invitationCode.trim().length < 6
  56. }
  57. },
  58. methods: {
  59. ...mapMutations(['login', 'wxLogin']),
  60. goLogin() {
  61. if (this.params.invitationCode == '') {
  62. this.$util.msg('请输入邀请码', 2000)
  63. return
  64. }
  65. this.params.unionId = uni.getStorageSync('unionId')
  66. this.bindingWechat(this.params)
  67. },
  68. async bindingWechat(params) {
  69. //邀请码登录并绑定微信
  70. try{
  71. const res = await this.UserService.usrInvitationLogin(params)
  72. const data = res.data
  73. uni.setStorageSync('token', data.token)
  74. this.$store.commit('updateStatus', data)
  75. this.login(data)
  76. // 登录成功处理
  77. const url = uni.getStorageSync('LOGIN_REDIRECT_URL')
  78. if (url) {
  79. if (url.indexOf('tabBar') > -1) {
  80. uni.switchTabTo(url)
  81. } else {
  82. this.$api.redirectTo(url)
  83. }
  84. } else {
  85. this.$api.switchTabTo('/pages/tabBar/user/user')
  86. }
  87. uni.removeStorageSync('LOGIN_REDIRECT_URL')
  88. }catch(error){
  89. this.$util.msg(error.msg, 2000)
  90. }
  91. },
  92. keyInput(val) {
  93. // 输入框输入介绍
  94. // this.params.invitationCode = val
  95. console.log(val)
  96. },
  97. keyInputChangeHandle(val) {
  98. // 输入框输入事件
  99. this.params.invitationCode = val
  100. // console.log(val)
  101. },
  102. setFocus() {
  103. // 控制组件获取焦点
  104. this.$refs.VcodeInput.setFocus()
  105. },
  106. setBlur() {
  107. // 控制组件失去焦点
  108. this.$refs.VcodeInput.setBlur()
  109. },
  110. clearValue() {
  111. // 清除已输入
  112. this.$refs.VcodeInput.clearValue()
  113. },
  114. InitAuthorize() {
  115. //是否已授权 0:为取消授权 1:为已授权 2:为未操作
  116. wxLogin.wxLoginQuick()
  117. }
  118. },
  119. onShow() {
  120. this.InitAuthorize()
  121. }
  122. }
  123. </script>
  124. <style lang="scss">
  125. .login {
  126. width: 100%;
  127. height: auto;
  128. .model-warp.none {
  129. display: none;
  130. }
  131. .model-warp.show {
  132. display: block;
  133. }
  134. .login-main {
  135. width: 100%;
  136. display: flex;
  137. flex-direction: column;
  138. align-items: center;
  139. height: 206rpx;
  140. padding: 60rpx 0 40rpx 0;
  141. margin: 70rpx 0;
  142. .logo {
  143. width: 358rpx;
  144. height: 206rpx;
  145. display: block;
  146. }
  147. }
  148. .login-input {
  149. width: 600rpx;
  150. height: 88rpx;
  151. padding: 24rpx 0;
  152. margin: 30rpx auto;
  153. margin-bottom: 30rpx;
  154. background: #ffffff;
  155. position: relative;
  156. }
  157. .login-row {
  158. padding: 0 75rpx;
  159. font-size: $font-size-28;
  160. line-height: 40rpx;
  161. color: #ff5b00;
  162. margin-bottom: 48rpx;
  163. text-align: right;
  164. }
  165. .login-btn {
  166. width: 600rpx;
  167. height: 88rpx;
  168. border-radius: 44rpx;
  169. font-size: $font-size-28;
  170. line-height: 88rpx;
  171. color: #ffffff;
  172. margin: 0 auto;
  173. text-align: center;
  174. background: $btn-confirm;
  175. &.disabled {
  176. background: #e1e1e1;
  177. }
  178. }
  179. .login-btn-last {
  180. width: 600rpx;
  181. height: 86rpx;
  182. border-radius: 44rpx;
  183. font-size: $font-size-28;
  184. line-height: 88rpx;
  185. color: $color-system;
  186. margin: 0 auto;
  187. text-align: center;
  188. border: 1px solid $color-system;
  189. margin-top: 20rpx;
  190. }
  191. .login-tips {
  192. width: 100%;
  193. height: auto;
  194. margin-top: 80rpx;
  195. box-sizing: border-box;
  196. padding: 0 75rpx;
  197. .h1 {
  198. line-height: 44rpx;
  199. font-size: $font-size-24;
  200. color: #666666;
  201. text-align: justify;
  202. display: inline-block;
  203. }
  204. .p {
  205. line-height: 44rpx;
  206. font-size: $font-size-24;
  207. color: #999999;
  208. text-align: justify;
  209. margin-bottom: 20rpx;
  210. display: inline-block;
  211. }
  212. }
  213. .model-authorization {
  214. width: 100%;
  215. height: 100%;
  216. position: fixed;
  217. top: 0;
  218. left: 0;
  219. z-index: 999;
  220. .authorization {
  221. width: 518rpx;
  222. height: 320rpx;
  223. position: absolute;
  224. background: rgba(255, 255, 255, 0.7);
  225. left: 0;
  226. right: 0;
  227. bottom: 0;
  228. top: 0;
  229. margin: auto;
  230. .to-btn {
  231. position: absolute;
  232. top: 0;
  233. left: 0;
  234. right: 0;
  235. bottom: 0;
  236. margin: auto;
  237. width: 70%;
  238. height: 88rpx;
  239. font-size: $font-size-28;
  240. line-height: 88rpx;
  241. color: #ffffff;
  242. text-align: center;
  243. border-radius: 44rpx;
  244. }
  245. }
  246. }
  247. }
  248. </style>