my.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="my-container">
  3. <!-- 家长信息头部 -->
  4. <view class="userinfo-topinfo">
  5. <image class="parent-avatar" :src="parentinfo.avatarUrl" @click="getUserInfo"></image>
  6. <view class="parent-name" @click="getUserInfo">
  7. <text class="name">{{parentinfo.nickName}}</text>
  8. <text class="detail">{{childreninfo.name + '家长'}}</text>
  9. </view>
  10. </view>
  11. <!-- 功能组件 -->
  12. <mini-userinfo v-if="parentdetail"></mini-userinfo>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. mapState,
  18. mapMutations
  19. } from 'vuex'
  20. export default {
  21. computed: {
  22. ...mapState('m_parent', ['token', 'parentdetail', 'parentinfo']),
  23. ...mapState('m_children', ['childreninfo'])
  24. },
  25. data() {
  26. return {
  27. };
  28. },
  29. onLoad() {},
  30. methods: {
  31. ...mapMutations('m_parent', ['updateParentInfo']),
  32. getUserInfo(e) {
  33. if (!uni.getStorageSync('parentinfo')) {
  34. uni.getUserProfile({
  35. desc: '获取您的昵称,头像,地区信息',
  36. success: infoRes => {
  37. if (infoRes.errMsg === 'getUserProfile:ok') {
  38. this.updateParentInfo(infoRes.userInfo)
  39. } else {
  40. uni.$showMsg('获取不到您的基本信息!')
  41. }
  42. },
  43. fail: err => {
  44. console.log('getUserInfo-error', JSON.stringify(err))
  45. }
  46. });
  47. }
  48. },
  49. }
  50. }
  51. </script>
  52. <style lang="scss">
  53. page,
  54. .my-container {
  55. height: 100%;
  56. .userinfo-topinfo {
  57. height: 400rpx;
  58. background: linear-gradient(#ff5959, #f1f3f5);
  59. display: flex;
  60. justify-content: flex-start;
  61. align-items: center;
  62. .parent-avatar {
  63. margin-top: 11px;
  64. margin-left: 20px;
  65. width: 60px;
  66. height: 60px;
  67. border-radius: 35px;
  68. border: 3px solid #FFFFFF;
  69. box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
  70. }
  71. .parent-name {
  72. margin-top: 10px;
  73. margin-left: 10px;
  74. display: flex;
  75. flex-direction: column;
  76. font-weight: bold;
  77. .name {
  78. color: #6b778d;
  79. font-size: 14px;
  80. margin: 2px 0px 0px 5px;
  81. }
  82. .detail {
  83. color: #3B4144;
  84. font-weight: bold;
  85. margin: 5px 0px 0px 5px;
  86. }
  87. }
  88. .parent-avatar {
  89. margin-top: 11px;
  90. margin-left: 20px;
  91. width: 60px;
  92. height: 60px;
  93. border-radius: 35px;
  94. border: 3px solid #FFFFFF;
  95. box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
  96. }
  97. .parent-name {
  98. margin-top: 10px;
  99. margin-left: 10px;
  100. display: flex;
  101. flex-direction: column;
  102. font-weight: bold;
  103. .name {
  104. color: #6b778d;
  105. font-size: 14px;
  106. margin: 2px 0px 0px 5px;
  107. }
  108. .detail {
  109. color: #3B4144;
  110. font-weight: bold;
  111. margin: 5px 0px 0px 5px;
  112. }
  113. }
  114. }
  115. }
  116. </style>