logincode.vue 6.6 KB

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