logion.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view>
  3. <view style="text-align: center;margin: 100upx;font-size: 36upx;">欢迎回来</view>
  4. <view style="width: 50%;margin: 0 auto;">
  5. <button @click="wxlogion" open-type='getUserInfo'>
  6. 授权登录
  7. </button>
  8. </view>
  9. <!-- <van-dialog title="请登录"
  10. :show-cancel-button="ishow"
  11. :show="show"
  12. @cancel="cancelDialog" @confirm="confirmOrder"
  13. confirm-button-open-type="getUserInfo"
  14. confirm-button-color = "#323232"
  15. >
  16. </van-dialog> -->
  17. <!-- <button @click="wxlogion" open-type="getUserInfo">请点击授权</button> -->
  18. </view>
  19. </template>
  20. <script>
  21. import {
  22. mapMutations,mapState
  23. } from 'vuex'
  24. export default {
  25. props:{
  26. showdialog:{
  27. default: false,
  28. type: Boolean
  29. },
  30. ishow:{
  31. default: true,
  32. type: Boolean
  33. },
  34. },
  35. data() {
  36. return{
  37. show: false
  38. }
  39. },
  40. methods:{
  41. ...mapMutations(['login','showDialog']),
  42. wxlogion() {
  43. let that = this;
  44.     uni.getUserInfo({
  45.      success(res) {
  46. that.login(res.userInfo);
  47. that.showDialog(true); // 改变haslogion的值
  48. // that.$emit('confirmDiaolog');
  49. that.$msg("登录成功")
  50. uni.navigateBack()
  51.      },
  52.      fail(res) {
  53. //that.$emit('keepdialog'); // 订单我的保持登录
  54. that.showDialog(false);
  55. that.$msg("登录失败")
  56.      }
  57.     })
  58. }
  59. }
  60. }
  61. </script>
  62. <style>
  63. </style>