logincode.vue 6.2 KB

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