123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- <template>
- <view class="children-container">
- <!-- 标题 -->
- <view class="tips">
- <view class="title">选择您的孩子</view>
- <button class="detail" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" v-show="!show">点击获取您的孩子信息</button>
- </view>
-
- <!-- 孩子选择界面 -->
- <view class="children-item" v-show="show">
- <view class="com-box">
- <view class="item" v-for="(item,index) in parentdetail.childrenList" :key="index" @click="chooseChildren(item)">
- <view class="item-text">{{item.name}}</view>
- <view class="avatar-box">
- <u-avatar size="120" class="item-avatar" :src="item.avatar" mode="aspectFill"></u-avatar>
- </view>
- </view>
- </view>
- </view>
-
- </view>
- </template>
- <script>
- import {mapState,mapMutations} from 'vuex'
- //引入解密工具
- import WXBizDataCrypt from "@/utils/WXBizDataCrypt.js";
-
- export default {
- data() {
- return {
- show: false
- };
- },
- computed:{
- ...mapState('m_parent',['parentdetail','token'])
- },
- onLoad(){
- //判断用户信息
- this.hasParentInfo()
- },
- methods:{
- ...mapMutations('m_children',['updateChildrenInfo']),
- ...mapMutations('m_parent',['updateParentInfo']),
-
- //选择孩子并跳转首页传入id查询显示孩子信息
- chooseChildren(item){
- console.log(item.tmdid);
- this.updateChildrenInfo(item)
- uni.switchTab({
- url:'/pages/home/home'
- })
- },
-
- // //获取用户信息事件
- // async getUserInfo() {
- // console.log(uni.getStorageSync('parentinfo'));
- // if (!uni.getStorageSync('parentinfo')) {
- // await uni.getUserProfile({
- // desc: '获取您的基本信息',
- // success: infoRes => {
- // if (infoRes.errMsg === 'getUserProfile:ok') {
- // this.updateParentInfo(infoRes.userInfo)
- // this.show = true
- // } else {
- // uni.$showMsg('获取不到您的基本信息!')
- // }
- // },
- // fail: err => {
- // console.log('getUserInfo-error', JSON.stringify(err))
- // }
- // });
- // }
- // },
-
- //判断用户基本信息是否存在
- hasParentInfo(){
- if(uni.getStorageSync('parentdetail'))
- this.show = true
- else
- this.show = false
- },
-
- //获取用户手机号
- async getPhoneNumber(e) {
- if (e.detail.errMsg !== "getPhoneNumber:ok") {
- //用户决绝授权
- return uni.$showMsg('拒绝授权获取不到您的孩子信息!')
- } else {
- if (this.token) {
- let proof = await new WXBizDataCrypt('wx5705da8747c77cfe', this.token.session_key)
- let numData = await proof.decryptData(e.detail.encryptedData, e.detail.iv)
- console.log(numData.phoneNumber)
- // const parentDetailData = await uni.$http.post('',numData.phoneNumber)
- // this.updateParentDetail(parentDetailData)
- this.show = true
- }
- }
- },
-
-
- }
- }
- </script>
- <style lang="scss">
- .children-container{
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
-
- .tips {
- width: 100%;
- padding-top: 180rpx;
- padding-left: 80rpx;
- display: flex;
- flex-direction: column;
- margin-bottom: 80rpx;
-
- .title {
- line-height: 70rpx;
- font-weight: bold;
- font-size: 50rpx;
- }
- .detail{
- line-height: 70rpx;
- font-weight: bold;
- font-size: 50rpx;
- margin-top: 100rpx;
- }
- }
- .children-item{
- .com-box{
- display: flex;
- flex-direction: row;
- justify-content: center;
- align-items: center;
- flex-wrap: wrap;//元素换行
-
- .item{
- margin: 10px;
- padding: 10px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- background-color: #FFFFFF;
- border-radius: 10px;
- width: 140px;
- height: 160px;
-
- .item-text{
- margin: -7rpx 0 20rpx 20rpx;
- width: 100%;
- line-height: 40rpx;
- font-weight: bold;
- font-size: 30rpx;
- color: #696969;
- }
- .avatar-box{
- .item-avatar{
- width: 220rpx;
- height: 220rpx;
- }
- }
- }
- }
- }
- }
- </style>
|