index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="content">
  3. <view class="wx">
  4. <view class="wx_1">
  5. <text class="iconfont icon-weixin"></text>
  6. </view>
  7. <view class="wx_2">
  8. <button size="mini" @tap="otherLogin('wx')">微信信任登录</button>
  9. </view>
  10. <view class="wx_3">
  11. <checkbox-group @change="changeAgree">
  12. <label>
  13. <checkbox :checked="agree" />
  14. <text @tap.stop="toAgree()">我已阅读并同意“用户协议”和“隐私政策”</text>
  15. </label>
  16. </checkbox-group>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script setup lang="ts">
  22. import moment from 'moment';
  23. import { getCurrentInstance, computed, ref } from 'vue';
  24. // 请求接口
  25. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  26. // openid
  27. const openid = computed(() => {
  28. return uni.getStorageSync('openid');
  29. })
  30. // 用户协议
  31. const agree = ref(false);
  32. // 其他登录方式
  33. const otherLogin = () => {
  34. if (agree.value) {
  35. if (openid.value) {
  36. uni.getUserProfile({
  37. desc: '用于展示',
  38. success: async function (res) {
  39. let parmas = {
  40. openid: openid.value,
  41. nickname: res.userInfo.nickName + moment().valueOf()
  42. }
  43. const arr = await $api(`matchUser`, 'POST', parmas);
  44. if (arr.code === 200) {
  45. uni.navigateBack({
  46. delta: 1
  47. })
  48. } else {
  49. uni.showToast({
  50. title: arr.msg,
  51. icon: 'error'
  52. });
  53. }
  54. },
  55. fail: function (err) {
  56. console.log(err);
  57. }
  58. })
  59. } else {
  60. uni.showToast({
  61. title: '系统更新中,请稍后再试!',
  62. icon: 'none'
  63. })
  64. }
  65. } else {
  66. uni.showToast({
  67. title: '请阅读并同意用户协议和隐私政策',
  68. icon: 'none'
  69. })
  70. }
  71. };
  72. // 查看隐私协议
  73. const toAgree = () => {
  74. uni.navigateTo({
  75. url: `/pagesHome/agree/index`
  76. })
  77. };
  78. // 同意隐私协议
  79. const changeAgree = () => {
  80. agree.value = !agree.value;
  81. };
  82. </script>
  83. <style lang="scss" scoped>
  84. .content {
  85. display: flex;
  86. flex-direction: column;
  87. .wx {
  88. text-align: center;
  89. margin: 25vw 0 0 0;
  90. .wx_1 {
  91. margin: 0 0 5vw 0;
  92. text {
  93. font-size: 50px;
  94. color: var(--f35BColor);
  95. }
  96. }
  97. .wx_2 {
  98. button {
  99. background: var(--f35BColor);
  100. color: var(--fffColor);
  101. font-size: var(--font16Size);
  102. }
  103. }
  104. .wx_3 {
  105. position: absolute;
  106. bottom: 10vw;
  107. width: 100vw;
  108. text-align: center;
  109. font-size: 12px;
  110. }
  111. }
  112. }
  113. </style>