otherLogin.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="container">
  3. <u-divider text="其他登录方式" textSize="3.2vw" textColor="#fff" lineColor="#fff" />
  4. <view class="grid-box">
  5. <view class="item" @click="changeLoginMethod">
  6. <text class="iconfont" :class="loginMethod == 'phone' ? 'icon-zhanghaodenglu' : 'icon-shoujidenglu'" />
  7. </view>
  8. <view class="item" style="background-color: #28C445;" v-if="port == 'wechat'" @click="wechatLogin">
  9. <u-icon name="weixin-fill" size="8vw" color="#fff"></u-icon>
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import { loginMsg } from "./dispose";
  16. export default {
  17. name: "OtherLogin",
  18. props: {
  19. "loginMethod": String,
  20. onChange: Function,
  21. isAgreement: Boolean
  22. },
  23. data() {
  24. return {
  25. port: 'wechat'
  26. }
  27. },
  28. created() {
  29. // #ifndef MP
  30. this.port = 'h5'
  31. // #endif
  32. // #ifdef MP-WEIXIN
  33. this.port = 'wechat'
  34. // #endif
  35. },
  36. methods: {
  37. /* 改变登录方式 */
  38. changeLoginMethod() {
  39. this.$emit("onChange", this.loginMethod == 'account' ? 'phone' : 'account')
  40. },
  41. /* 微信登录 */
  42. wechatLogin() {
  43. if (!this.isAgreement) return uni.showToast({
  44. title: '请阅读并勾选用户协议',
  45. icon: 'none',
  46. })
  47. let that = this;
  48. uni.login({
  49. success(res) {
  50. that.$Http.loginbywechat({
  51. wechat_code: res.code,
  52. "systemclient": "wechat"
  53. }).then(res => {
  54. console.log("微信快捷登录", res)
  55. if (that.cutoff(res.msg)) return;
  56. loginMsg(res.account_list, that)
  57. })
  58. }
  59. })
  60. },
  61. },
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .container {
  66. width: 275px !important;
  67. margin: 0 auto;
  68. .grid-box {
  69. display: flex;
  70. width: 100%;
  71. justify-content: center;
  72. flex-wrap: wrap;
  73. .item {
  74. display: flex;
  75. justify-content: center;
  76. align-items: center;
  77. width: 40px;
  78. height: 40px;
  79. border-radius: 50%;
  80. background-color: rgba($color: #fff, $alpha: .3);
  81. flex-shrink: 0;
  82. margin: 0 7px 7px;
  83. color: #fff;
  84. .iconfont {
  85. font-size: 20px;
  86. }
  87. }
  88. }
  89. }
  90. </style>