logincode.vue 5.9 KB

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