index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view class="content">
  3. <view>
  4. <view>ddddddd{{showModal}}</view>
  5. <!-- <button open-type="getUserInfo">用户登录</button> -->
  6. <button v-if="showModal" open-type="getUserInfo" @click="wxlogion">请点击授权</button>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. import {
  12. mapMutations,mapState
  13. } from 'vuex';
  14. export default {
  15. data() {
  16. return {
  17. title: 'Hello',
  18. }
  19. },
  20. computed:{
  21. ...mapState([
  22. 'showModal'
  23. ]),
  24. },
  25. onLoad() {
  26. },
  27. methods: {
  28. ...mapMutations(['login','showDialog']),
  29. wxlogion() {
  30. let that = this;
  31.     uni.getUserInfo({
  32.      success(res) {
  33. that.login(res.userInfo);
  34. that.showDialog(false);
  35.      },
  36.      fail(res) {
  37.      uni.showModal({
  38. title: 'shouquanshibai',
  39. })
  40.      }
  41.     })
  42. }
  43. },
  44. }
  45. </script>
  46. <style>
  47. .content {
  48. display: flex;
  49. flex-direction: column;
  50. align-items: center;
  51. justify-content: center;
  52. }
  53. .logo {
  54. height: 200upx;
  55. width: 200upx;
  56. margin-top: 200upx;
  57. margin-left: auto;
  58. margin-right: auto;
  59. margin-bottom: 50upx;
  60. }
  61. .text-area {
  62. display: flex;
  63. justify-content: center;
  64. }
  65. .title {
  66. font-size: 36upx;
  67. color: #8f8f94;
  68. }
  69. </style>