login-code.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view class="container login">
  3. <view class="login-main">
  4. <image class="logo" src="https://static.caimei365.com/app/img/icon/logo@2x.png" mode=""></image>
  5. </view>
  6. <view class="login-input">
  7. <keyInput
  8. borderValueColor="#E1E1E1"
  9. borderActiveColor="#E1E1E1"
  10. ref="vcodeInputRef"
  11. @vcodeInput="keyInput"
  12. @vcodeChange="keyInputChangeHandle"
  13. sum="6"
  14. >
  15. </keyInput>
  16. </view>
  17. <button class="login-btn" @click.stop="goLogin" :class="isDisabled ? 'disabled' : ''" :disabled="isDisabled">邀请码登录</button>
  18. <view class="login-tips">
  19. 邀请码是为了方便机构内成员互相邀请并快速注册【丽格集采联盟】小程序而推出的一项邀请机制。
  20. 机构已注册了账号的成员,可在其个人中心添加其他机构成员,系统会自动为添加的每一个成员生成邀请码。其他成员使用邀请码可直接登录【丽格集采联盟】小程序。
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import authorize from '@/common/config/authorize.js'
  26. import wxLogin from "@/common/config/wxLogin.js"
  27. import {mapState,mapMutations } from 'vuex';
  28. import keyInput from '@/components/uni-keyinput/uni-keyinput'
  29. export default{
  30. components: {
  31. keyInput
  32. },
  33. data() {
  34. return{
  35. params:{
  36. invitationCode:'',//获取用户登录的邀请码
  37. unionId:0,
  38. nickName:'',
  39. avatarUrl:'',
  40. },
  41. }
  42. },
  43. onLoad(option) {
  44. },
  45. computed: {
  46. ...mapState(['isWxAuthorize','isLoginType','isLoginProductId','isLoginOrderId']),
  47. isDisabled() {// 邀请码长度是否符合要求
  48. return this.params.invitationCode.trim().length < 6
  49. },
  50. },
  51. methods:{
  52. ...mapMutations(['login','wxLogin']),
  53. goLogin(){
  54. if( this.params.invitationCode == ''){
  55. this.$util.msg('请输入邀请码',2000)
  56. return
  57. }
  58. this.isUserInfo = false
  59. this.params.unionId = uni.getStorageSync('unionId')
  60. // 友盟埋点邀请码确认登录点击事件
  61. if(process.env.NODE_ENV != 'development'){
  62. this.$uma.trackEvent('Um_Event_InvitationCode', {
  63. Um_Key_PageName: '邀请码登录',
  64. Um_Key_SourcePage: '邀请码页面',
  65. })
  66. }
  67. this.GetUserProfile()
  68. },
  69. navigatorRegirst(url){
  70. // 友盟埋点注册入口点击事件
  71. if(process.env.NODE_ENV != 'development'){
  72. this.$uma.trackEvent('Um_Event_zhuce', {
  73. Um_Key_PageName: '立即注册',
  74. Um_Key_SourcePage: '个人中心',
  75. })
  76. }
  77. this.$api.navigateTo(url)
  78. },
  79. GetUserProfile(){//获取用户微信个人信息
  80. const self = this
  81. wx.getUserProfile({
  82. desc: '采美采购商城小程序获取您的信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  83. success(res) {
  84. console.log('微信获取用户信息新API',res)
  85. self.wxLogin(res.userInfo)
  86. self.params.nickName = res.userInfo.nickName
  87. self.params.avatarUrl = res.userInfo.avatarUrl
  88. self.BindingWechat(self.params)
  89. },
  90. fail() {
  91. self.$util.msg('授权失败', 2000)
  92. }
  93. })
  94. },
  95. BindingWechat(params){//邀请码登录并绑定微信
  96. this.UserService.InvitationCodeLogin(params)
  97. .then(response =>{
  98. wxLogin.wxLoginAuthorize()
  99. if(response.data.userIdentity === 3){
  100. setTimeout(()=>{
  101. this.$api.navigateTo('/pages/supplier/index/index')
  102. },1500)
  103. }else{
  104. setTimeout(()=>{
  105. switch(this.isLoginType){
  106. case 9:
  107. this.$api.navigateTo(`/pages/h5/activity/activity_mid`)
  108. break;
  109. case 8:
  110. this.$api.navigateTo(`/pages/goods/product?id=${this.isLoginProductId}`)
  111. break;
  112. case 7:
  113. this.$api.navigateTo(`/pages/user/order/order-details?type=share&orderID=${this.isLoginOrderId}`)
  114. break;
  115. default:
  116. this.$api.switchTabTo('/pages/tabBar/user/user')
  117. }
  118. },1500)
  119. }
  120. })
  121. .catch(error =>{
  122. this.$util.msg(error.msg,2000)
  123. this.isUserInfo = false
  124. })
  125. },
  126. keyInput(val) {// 输入框输入介绍
  127. // this.params.invitationCode = val
  128. console.log(val)
  129. },
  130. keyInputChangeHandle(val) {// 输入框输入事件
  131. this.params.invitationCode = val
  132. // console.log(val)
  133. },
  134. setFocus() {// 控制组件获取焦点
  135. this.$refs.VcodeInput.setFocus()
  136. },
  137. setBlur() {// 控制组件失去焦点
  138. this.$refs.VcodeInput.setBlur()
  139. },
  140. clearValue() {// 清除已输入
  141. this.$refs.VcodeInput.clearValue()
  142. },
  143. InitAuthorize(){ //是否已授权 0:为取消授权 1:为已授权 2:为未操作
  144. wxLogin.wxLoginQuick()
  145. }
  146. },
  147. onShow() {
  148. this.$api.getStorage().then((resolve) =>{
  149. this.params.unionId = resolve.unionId ? resolve.unionId : 0
  150. })
  151. this.InitAuthorize()
  152. }
  153. }
  154. </script>
  155. <style lang="scss">
  156. .login{
  157. width: 100%;
  158. height: auto;
  159. .model-warp.none{
  160. display: none;
  161. }
  162. .model-warp.show{
  163. display: block;
  164. }
  165. .login-main{
  166. width: 100%;
  167. display: flex;
  168. flex-direction: column;
  169. align-items: center;
  170. height: 284rpx;
  171. padding:60rpx 0 40rpx 0;
  172. margin-bottom: 70rpx;
  173. .logo{
  174. width:611rpx;
  175. height: 284rpx;
  176. display: block;
  177. }
  178. }
  179. .login-input{
  180. width: 600rpx;
  181. height: 88rpx;
  182. padding: 24rpx 0;
  183. margin: 30rpx auto;
  184. margin-bottom: 30rpx;
  185. background: #FFFFFF;
  186. position: relative;
  187. }
  188. .login-row{
  189. padding: 0 75rpx;
  190. font-size: $font-size-28;
  191. line-height: 40rpx;
  192. color: #FF5B00;
  193. margin-bottom: 48rpx;
  194. text-align: right;
  195. }
  196. .login-btn{
  197. width: 600rpx;
  198. height: 88rpx;
  199. border-radius: 44rpx;
  200. font-size: $font-size-28;
  201. line-height: 88rpx;
  202. color: #FFFFFF;
  203. margin: 0 auto;
  204. text-align: center;
  205. background:$btn-confirm;
  206. &.disabled{
  207. background: #E1E1E1;
  208. }
  209. }
  210. .login-btn-last{
  211. width: 600rpx;
  212. height: 86rpx;
  213. border-radius: 44rpx;
  214. font-size: $font-size-28;
  215. line-height: 88rpx;
  216. color: $color-system;
  217. margin: 0 auto;
  218. text-align: center;
  219. border: 1px solid $color-system;
  220. margin-top: 20rpx;
  221. }
  222. .login-tips{
  223. width: 100%;
  224. height: auto;
  225. margin-top: 80rpx;
  226. box-sizing: border-box;
  227. padding: 0 75rpx;
  228. line-height: 44rpx;
  229. font-size: $font-size-20;
  230. color: #fea785;
  231. text-align: justify;
  232. text-indent: 40rpx;
  233. }
  234. .model-authorization{
  235. width: 100%;
  236. height: 100%;
  237. position: fixed;
  238. top: 0;
  239. left: 0;
  240. z-index: 999;
  241. .authorization{
  242. width: 518rpx;
  243. height: 320rpx;
  244. position: absolute;
  245. background: rgba(255,255,255,.7);
  246. left: 0;
  247. right: 0;
  248. bottom: 0;
  249. top: 0;
  250. margin: auto;
  251. .to-btn{
  252. position: absolute;
  253. top: 0;
  254. left: 0;
  255. right: 0;
  256. bottom: 0;
  257. margin: auto;
  258. width: 70%;
  259. height: 88rpx;
  260. font-size: $font-size-28;
  261. line-height: 88rpx;
  262. color: #FFFFFF;
  263. text-align: center;
  264. border-radius: 44rpx;
  265. }
  266. }
  267. }
  268. }
  269. </style>