login.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <ax-body blank="0" hideIndicatorArea>
  3. <image src="@/static/img/page-bg01.png" class="page-background"></image>
  4. <view class="body">
  5. <view class="title">
  6. <view>
  7. <view class="h1">您好!</view>
  8. <view class="h2">欢迎使用中数电动</view>
  9. </view>
  10. <image src="@/static/img/logo.svg" class="logo" mode="widthFix"></image>
  11. </view>
  12. <view class="logo-wrap">
  13. <image src="@/static/img/login-bg.svg" class="bg" mode="widthFix"></image>
  14. </view>
  15. <view class="footer" style="padding-left: 0;padding-right: 0;">
  16. <button @getphonenumber="onGetPhoneNumber" open-type="getPhoneNumber" class="submit"
  17. :disabled="!agreement" style="margin-left: 35px;width: calc(100% - 70px);">
  18. <text class="ax ax-iconblock i-weixin"></text>
  19. <text>微信用户一键登录</text>
  20. </button>
  21. <view class="cancel" @click="cancelLogin">取消登录</view>
  22. <view @click="agreement = !agreement" class="agreement" style="font-size: 17px;">
  23. <view class="mask" :class="{ active: agreement }"><text class="ax ax-iconline i-select"></text>
  24. </view>
  25. <text>我已阅读并理解和同意</text>
  26. <text @click.stop="checkPrivacy()" class="em">《隐私政策协议》</text>
  27. </view>
  28. </view>
  29. </view>
  30. </ax-body>
  31. </template>
  32. <script>
  33. import $config from '@/static/js/config.js';
  34. export default {
  35. onLoad() {
  36. uni.getPrivacySetting({
  37. success: res => {
  38. this.privacy.name = res.privacyContractName;
  39. this.privacy.need = res.needAuthorization;
  40. }
  41. });
  42. },
  43. data() {
  44. return {
  45. agreement: false,
  46. privacy: {
  47. need: true,
  48. name: ''
  49. },
  50. }
  51. },
  52. methods: {
  53. // 查看隐私
  54. checkPrivacy() {
  55. uni.openPrivacyContract();
  56. },
  57. onGetPhoneNumber(e) {
  58. console.log(e);
  59. // let channelUrl='http://192.168.110.241:9120/zs/channel/admin/'
  60. let channelUrl = 'https://channel-api.zonelife.cn/zs/channel/admin/';
  61. uni.login({
  62. provider: 'weixin',
  63. success: (res) => {
  64. if (res.code) {
  65. if (e.detail.code) {
  66. this.$api.base("post", '/api/v1/auth/wx/miniapp/phone-code-login', {
  67. code: res.code,
  68. phoneCode: e.detail.code
  69. }).then(async res => {
  70. uni.setStorageSync($config.keyname.accessToken, res?.data?.accessToken);
  71. uni.setStorageSync($config.keyname.refreshToken, res?.data?.refreshToken);
  72. // 识别用户是否通过分销码进入小程序
  73. if (uni.getStorageSync('ADMIN_USERID')) {
  74. uni.request({
  75. url: channelUrl + 'ums/umsAdminUser/distributionBindUser',
  76. method: 'POST',
  77. header: {
  78. 'content-type': 'application/json'
  79. },
  80. data: {
  81. userId: res.userInfo.id,
  82. adminUserId: uni.getStorageSync('ADMIN_USERID'),
  83. },
  84. success: (res) => {
  85. console.info(res.data, '----扫码接口调用');
  86. setTimeout(() => {
  87. this.$app.storage.remove('ADMIN_USERID')
  88. }, 500)
  89. },
  90. fail(err) {
  91. console.log(err, '----错误信息');
  92. }
  93. });
  94. }
  95. if (this.$app.storage.get('FRIM_ID')) {
  96. this.$api.base("post", "/userApi/add-firm-user?firmId=" + parseInt(this.$app.storage.get('FRIM_ID')), {}, { error: false }).then(res => {
  97. this.$app.popup.alert(res.msg);
  98. setTimeout(() => {
  99. this.$app.storage.remove('FRIM_ID')
  100. }, 500)
  101. console.log(res, '----企业用户通过扫码进入');
  102. }).catch(err => {
  103. setTimeout(() => {
  104. this.$app.storage.remove('FRIM_ID')
  105. }, 500)
  106. })
  107. }
  108. this.$app.url.back()
  109. });
  110. }
  111. }
  112. },
  113. })
  114. },
  115. cancelLogin() {
  116. this.$app.url.back()
  117. }
  118. }
  119. }
  120. </script>
  121. <style scoped>
  122. @import url("login.css");
  123. </style>