guide.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="children-container">
  3. <!-- 标题 -->
  4. <view class="tips">
  5. <view class="title">选择您的孩子</view>
  6. <button class="detail" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" v-show="!show">点击获取您的孩子信息</button>
  7. </view>
  8. <!-- 孩子选择界面 -->
  9. <view class="children-item" v-show="show">
  10. <view class="com-box">
  11. <view class="item" v-for="(item,index) in parentdetail.childrenList" :key="index" @click="chooseChildren(item)">
  12. <view class="item-text">{{item.name}}</view>
  13. <view class="avatar-box">
  14. <u-avatar size="120" class="item-avatar" :src="item.avatar" mode="aspectFill"></u-avatar>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import {mapState,mapMutations} from 'vuex'
  23. //引入解密工具
  24. import WXBizDataCrypt from "@/utils/WXBizDataCrypt.js";
  25. export default {
  26. data() {
  27. return {
  28. show: false
  29. };
  30. },
  31. computed:{
  32. ...mapState('m_parent',['parentdetail','token'])
  33. },
  34. onLoad(){
  35. //判断用户信息
  36. this.hasParentInfo()
  37. },
  38. methods:{
  39. ...mapMutations('m_children',['updateChildrenInfo']),
  40. ...mapMutations('m_parent',['updateParentInfo']),
  41. //选择孩子并跳转首页传入id查询显示孩子信息
  42. chooseChildren(item){
  43. console.log(item.tmdid);
  44. this.updateChildrenInfo(item)
  45. uni.switchTab({
  46. url:'/pages/home/home'
  47. })
  48. },
  49. // //获取用户信息事件
  50. // async getUserInfo() {
  51. // console.log(uni.getStorageSync('parentinfo'));
  52. // if (!uni.getStorageSync('parentinfo')) {
  53. // await uni.getUserProfile({
  54. // desc: '获取您的基本信息',
  55. // success: infoRes => {
  56. // if (infoRes.errMsg === 'getUserProfile:ok') {
  57. // this.updateParentInfo(infoRes.userInfo)
  58. // this.show = true
  59. // } else {
  60. // uni.$showMsg('获取不到您的基本信息!')
  61. // }
  62. // },
  63. // fail: err => {
  64. // console.log('getUserInfo-error', JSON.stringify(err))
  65. // }
  66. // });
  67. // }
  68. // },
  69. //判断用户基本信息是否存在
  70. hasParentInfo(){
  71. if(uni.getStorageSync('parentdetail'))
  72. this.show = true
  73. else
  74. this.show = false
  75. },
  76. //获取用户手机号
  77. async getPhoneNumber(e) {
  78. if (e.detail.errMsg !== "getPhoneNumber:ok") {
  79. //用户决绝授权
  80. return uni.$showMsg('拒绝授权获取不到您的孩子信息!')
  81. } else {
  82. if (this.token) {
  83. let proof = await new WXBizDataCrypt('wx5705da8747c77cfe', this.token.session_key)
  84. let numData = await proof.decryptData(e.detail.encryptedData, e.detail.iv)
  85. console.log(numData.phoneNumber)
  86. // const parentDetailData = await uni.$http.post('',numData.phoneNumber)
  87. // this.updateParentDetail(parentDetailData)
  88. this.show = true
  89. }
  90. }
  91. },
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .children-container{
  97. display: flex;
  98. flex-direction: column;
  99. justify-content: center;
  100. align-items: center;
  101. .tips {
  102. width: 100%;
  103. padding-top: 180rpx;
  104. padding-left: 80rpx;
  105. display: flex;
  106. flex-direction: column;
  107. margin-bottom: 80rpx;
  108. .title {
  109. line-height: 70rpx;
  110. font-weight: bold;
  111. font-size: 50rpx;
  112. }
  113. .detail{
  114. line-height: 70rpx;
  115. font-weight: bold;
  116. font-size: 50rpx;
  117. margin-top: 100rpx;
  118. }
  119. }
  120. .children-item{
  121. .com-box{
  122. display: flex;
  123. flex-direction: row;
  124. justify-content: center;
  125. align-items: center;
  126. flex-wrap: wrap;//元素换行
  127. .item{
  128. margin: 10px;
  129. padding: 10px;
  130. display: flex;
  131. flex-direction: column;
  132. justify-content: center;
  133. align-items: center;
  134. background-color: #FFFFFF;
  135. border-radius: 10px;
  136. width: 140px;
  137. height: 160px;
  138. .item-text{
  139. margin: -7rpx 0 20rpx 20rpx;
  140. width: 100%;
  141. line-height: 40rpx;
  142. font-weight: bold;
  143. font-size: 30rpx;
  144. color: #696969;
  145. }
  146. .avatar-box{
  147. .item-avatar{
  148. width: 220rpx;
  149. height: 220rpx;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. </style>