loginDialog.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view>
  3. <van-dialog title="请登录"
  4. :show-cancel-button="ishow"
  5. :show="show"
  6. @cancel="cancelDialog" @confirm="confirmOrder"
  7. confirm-button-open-type="getUserInfo"
  8. confirm-button-color = "#323232"
  9. >
  10. </van-dialog>
  11. <!-- <button @click="wxlogion" open-type="getUserInfo">请点击授权</button> -->
  12. </view>
  13. </template>
  14. <script>
  15. import {
  16. mapMutations,mapState
  17. } from 'vuex'
  18. export default {
  19. props:{
  20. showdialog:{
  21. default: false,
  22. type: Boolean
  23. },
  24. ishow:{
  25. default: true,
  26. type: Boolean
  27. },
  28. },
  29. data() {
  30. return{
  31. show: false
  32. }
  33. },
  34. watch:{
  35. 'showdialog':function(val) {
  36. console.log("jinlaile")
  37. console.log(val)
  38. if(val) {
  39. this.show = true;
  40. }else {
  41. this.show = false;
  42. }
  43. console.log(this.show);
  44. }
  45. },
  46. methods:{
  47. ...mapMutations(['login','showDialog']),
  48. cancelDialog() {
  49. this.show = false;
  50. this.$emit('cancelDiaolog')
  51. this.showDialog(false);
  52. this.login();
  53. this.$msg('登录失败');
  54. },
  55. confirmOrder() {
  56. this.show = false;
  57. this.$emit('changeDiaolog');
  58. this.wxlogion();
  59. },
  60. wxlogion() {
  61. let that = this;
  62.     uni.getUserInfo({
  63.      success(res) {
  64. that.login(res.userInfo);
  65. that.showDialog(true); // 改变haslogion的值
  66. that.$emit('confirmDiaolog');
  67. that.$msg("登录成功")
  68.      },
  69.      fail(res) {
  70. that.$emit('keepdialog'); // 订单我的保持登录
  71. that.showDialog(false);
  72. that.$msg("登录失败")
  73.      }
  74.     })
  75. }
  76. }
  77. }
  78. </script>
  79. <style>
  80. </style>