logincode.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. // 友盟埋点邀请码确认登录点击事件
  60. if(process.env.NODE_ENV != 'development'){
  61. this.$uma.trackEvent('Um_Event_InvitationCode', {
  62. Um_Key_PageName: '邀请码登录',
  63. Um_Key_SourcePage: '邀请码页面',
  64. })
  65. }
  66. this.GetUserProfile()
  67. },
  68. navigatorRegirst(url){
  69. // 友盟埋点注册入口点击事件
  70. if(process.env.NODE_ENV != 'development'){
  71. this.$uma.trackEvent('Um_Event_zhuce', {
  72. Um_Key_PageName: '立即注册',
  73. Um_Key_SourcePage: '个人中心',
  74. })
  75. }
  76. this.$api.navigateTo(url)
  77. },
  78. GetUserProfile(){//获取用户微信个人信息
  79. const self = this
  80. wx.getUserProfile({
  81. desc: '采美采购商城小程序获取您的信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  82. success(res) {
  83. console.log('微信获取用户信息新API',res)
  84. self.wxLogin(res.userInfo)
  85. self.params.nickName = res.userInfo.nickName
  86. self.params.avatarUrl = res.userInfo.avatarUrl
  87. self.BindingWechat(self.params)
  88. },
  89. fail() {
  90. self.$util.msg('授权失败', 2000)
  91. }
  92. })
  93. },
  94. BindingWechat(params){//邀请码登录并绑定微信
  95. this.UserService.InvitationCodeLogin(params)
  96. .then(response =>{
  97. wxLogin.wxLoginAuthorize()
  98. if(response.data.userIdentity === 3){
  99. setTimeout(()=>{
  100. this.$api.navigateTo('/pages/supplier/index/index')
  101. },1500)
  102. }else{
  103. setTimeout(()=>{
  104. switch(this.isLoginType){
  105. case 9:
  106. this.$api.navigateTo(`/pages/h5/activity/activity_mid`)
  107. break;
  108. case 8:
  109. this.$api.navigateTo(`/pages/goods/product?id=${this.isLoginProductId}`)
  110. break;
  111. case 7:
  112. this.$api.navigateTo(`/pages/user/order/order-details?type=share&orderID=${this.isLoginOrderId}`)
  113. break;
  114. default:
  115. this.$api.switchTabTo('/pages/tabBar/user/user')
  116. }
  117. },1500)
  118. }
  119. })
  120. .catch(error =>{
  121. this.$util.msg(error.msg,2000)
  122. this.isUserInfo = false
  123. })
  124. },
  125. keyInput(val) {// 输入框输入介绍
  126. // this.params.invitationCode = val
  127. console.log(val)
  128. },
  129. keyInputChangeHandle(val) {// 输入框输入事件
  130. this.params.invitationCode = val
  131. // console.log(val)
  132. },
  133. setFocus() {// 控制组件获取焦点
  134. this.$refs.VcodeInput.setFocus()
  135. },
  136. setBlur() {// 控制组件失去焦点
  137. this.$refs.VcodeInput.setBlur()
  138. },
  139. clearValue() {// 清除已输入
  140. this.$refs.VcodeInput.clearValue()
  141. },
  142. InitAuthorize(){ //是否已授权 0:为取消授权 1:为已授权 2:为未操作
  143. wxLogin.wxLoginQuick()
  144. }
  145. },
  146. onShow() {
  147. this.$api.getStorage().then((resolve) =>{
  148. this.params.unionId = resolve.unionId ? resolve.unionId : 0
  149. })
  150. this.InitAuthorize()
  151. }
  152. }
  153. </script>
  154. <style lang="scss">
  155. .login{
  156. width: 100%;
  157. height: auto;
  158. .model-warp.none{
  159. display: none;
  160. }
  161. .model-warp.show{
  162. display: block;
  163. }
  164. .login-main{
  165. width: 100%;
  166. display: flex;
  167. flex-direction: column;
  168. align-items: center;
  169. height: 189rpx;
  170. padding:60rpx 0 40rpx 0;
  171. margin-bottom: 70rpx;
  172. .logo{
  173. width:467rpx;
  174. height: 189rpx;
  175. display: block;
  176. }
  177. }
  178. .login-input{
  179. width: 600rpx;
  180. height: 88rpx;
  181. padding: 24rpx 0;
  182. margin: 30rpx auto;
  183. margin-bottom: 30rpx;
  184. background: #FFFFFF;
  185. position: relative;
  186. }
  187. .login-row{
  188. padding: 0 75rpx;
  189. font-size: $font-size-28;
  190. line-height: 40rpx;
  191. color: #E15616;
  192. margin-bottom: 48rpx;
  193. text-align: right;
  194. }
  195. .login-btn{
  196. width: 600rpx;
  197. height: 88rpx;
  198. border-radius: 44rpx;
  199. font-size: $font-size-28;
  200. line-height: 88rpx;
  201. color: #FFFFFF;
  202. margin: 0 auto;
  203. text-align: center;
  204. background:$btn-confirm;
  205. &.disabled{
  206. background: #E1E1E1;
  207. }
  208. }
  209. .login-btn-last{
  210. width: 600rpx;
  211. height: 86rpx;
  212. border-radius: 44rpx;
  213. font-size: $font-size-28;
  214. line-height: 88rpx;
  215. color: $color-system;
  216. margin: 0 auto;
  217. text-align: center;
  218. border: 1px solid $color-system;
  219. margin-top: 20rpx;
  220. }
  221. .login-tips{
  222. width: 100%;
  223. height: auto;
  224. margin-top: 80rpx;
  225. box-sizing: border-box;
  226. padding: 0 75rpx;
  227. line-height: 44rpx;
  228. font-size: $font-size-20;
  229. color: #fea785;
  230. text-align: justify;
  231. text-indent: 40rpx;
  232. }
  233. .model-authorization{
  234. width: 100%;
  235. height: 100%;
  236. position: fixed;
  237. top: 0;
  238. left: 0;
  239. z-index: 999;
  240. .authorization{
  241. width: 518rpx;
  242. height: 320rpx;
  243. position: absolute;
  244. background: rgba(255,255,255,.7);
  245. left: 0;
  246. right: 0;
  247. bottom: 0;
  248. top: 0;
  249. margin: auto;
  250. .to-btn{
  251. position: absolute;
  252. top: 0;
  253. left: 0;
  254. right: 0;
  255. bottom: 0;
  256. margin: auto;
  257. width: 70%;
  258. height: 88rpx;
  259. font-size: $font-size-28;
  260. line-height: 88rpx;
  261. color: #FFFFFF;
  262. text-align: center;
  263. border-radius: 44rpx;
  264. }
  265. }
  266. }
  267. }
  268. </style>