guide.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view class="children-container">
  3. <!-- 标题 -->
  4. <view class="tips">
  5. <view class="title" v-show="!show">欢迎您的使用</view>
  6. <view style="font-weight: bold;font-size: 36rpx;color: #b0b0b1;margin-left: 40rpx;margin-top: 20rpx;"
  7. v-show="!show">醍摩豆家长助您孩子成长</view>
  8. <view class="title" v-show="show">选择您的孩子</view>
  9. <view class="detail-image" v-show="!show"></view>
  10. <button class="detail-button" plain="true" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
  11. v-show="!show">获取您的孩子信息</button>
  12. </view>
  13. <!-- 孩子选择界面 -->
  14. <view class="children-item" v-show="show">
  15. <view class="com-box">
  16. <view class="item" v-for="(item,index) in parentdetail.childrenList" :key="index"
  17. @click="chooseChildren(item)">
  18. <view class="item-text">{{item.name}}</view>
  19. <view class="avatar-box">
  20. <u-avatar size="120" class="item-avatar" :src="item.avatar" mode="aspectFill"></u-avatar>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 动画 -->
  26. <view class="ocean"></view>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. mapState,
  32. mapMutations
  33. } from 'vuex'
  34. //引入解密工具
  35. import WXBizDataCrypt from "@/utils/WXBizDataCrypt.js";
  36. export default {
  37. data() {
  38. return {
  39. show: false,
  40. };
  41. },
  42. computed: {
  43. ...mapState('m_parent', ['parentdetail', 'token']),
  44. ...mapState('m_children', ['semesterList'])
  45. },
  46. onLoad() {
  47. //判断用户信息
  48. this.hasParentDetail()
  49. },
  50. methods: {
  51. ...mapMutations('m_children', ['updateChildrenInfo', 'updateChildrenSemester']),
  52. ...mapMutations('m_parent', ['updateParentInfo', 'updateParentDetail']),
  53. //选择孩子并跳转首页传入id查询显示孩子信息
  54. chooseChildren(item) {
  55. console.log(item.tmdid);
  56. this.updateChildrenInfo(item)
  57. //默认学期
  58. this.updateChildrenSemester(this.semesterList[0][0])
  59. uni.switchTab({
  60. url: '/pages/home/home'
  61. })
  62. },
  63. //判断用户基本信息是否存在
  64. hasParentDetail() {
  65. if (uni.getStorageSync('parentdetail'))
  66. this.show = true
  67. else
  68. this.show = false
  69. },
  70. //获取用户手机号
  71. async getPhoneNumber(e) {
  72. if (e.detail.errMsg !== "getPhoneNumber:ok") {
  73. //用户决绝授权
  74. return uni.$showMsg('拒绝授权获取不到您的孩子信息!')
  75. } else {
  76. if (this.token) {
  77. let proof = await new WXBizDataCrypt('wx5705da8747c77cfe', this.token.session_key)
  78. let numData = await proof.decryptData(e.detail.encryptedData, e.detail.iv)
  79. console.log(numData.phoneNumber)
  80. // const parentDetailData = await uni.$http.post('',numData.phoneNumber)
  81. this.updateParentDetail({
  82. phoneNumber: '17882237075',
  83. name: '家长姓名',
  84. childrenList: [{
  85. avatar: '/static/default-icons/boy.png',
  86. name: '张三',
  87. classid: '0301',
  88. class: '三年级一班',
  89. tmdid: 'tmdid01',
  90. schoolname: '研发学校'
  91. }, {
  92. avatar: '/static/default-icons/girl.png',
  93. name: '张梅',
  94. classid: '0504',
  95. class: '五年级四班',
  96. tmdid: 'tmdid03',
  97. schoolname: '研发学校'
  98. }, ]
  99. })
  100. this.show = true
  101. }
  102. }
  103. },
  104. }
  105. }
  106. </script>
  107. <style lang="scss">
  108. @import '@/subpkg/common/ocean.scss';
  109. .children-container {
  110. display: flex;
  111. flex-direction: column;
  112. justify-content: center;
  113. align-items: center;
  114. .tips {
  115. width: 100%;
  116. display: flex;
  117. flex-direction: column;
  118. z-index: 99;
  119. .title {
  120. padding-top: 200rpx;
  121. padding-left: 40rpx;
  122. line-height: 70rpx;
  123. font-weight: bold;
  124. font-size: 50rpx;
  125. color: #4169E1;
  126. // background-clip: text; //裁剪成文字的前景色
  127. // color: transparent; //文字颜色变成透明
  128. }
  129. .detail-image {
  130. margin-top: 80rpx;
  131. margin-bottom: 20rpx;
  132. width: 100%;
  133. height: 500rpx;
  134. background: $guide-back-base64;
  135. background-size: cover; //背景图片自适应
  136. }
  137. .detail-button {
  138. line-height: 80rpx;
  139. height: 80rpx;
  140. width: 80%;
  141. font-weight: bold;
  142. font-size: 36rpx;
  143. border-radius: 80rpx;
  144. position: relative;
  145. margin: 100rpx auto; //relative相对定位居中
  146. border: none;
  147. color: #FFFFFF;
  148. background: linear-gradient(to right, #506AE7, #87CEFA);
  149. }
  150. }
  151. .children-item {
  152. .com-box {
  153. display: flex;
  154. flex-direction: row;
  155. justify-content: center;
  156. align-items: center;
  157. flex-wrap: wrap; //元素换行
  158. margin-top: 60rpx;
  159. .item {
  160. margin: 10rpx 20rpx 10rpx 20rpx;
  161. padding: 20rpx;
  162. display: flex;
  163. flex-direction: column;
  164. justify-content: center;
  165. align-items: center;
  166. box-shadow: $box-shadow-stereo-white;
  167. background-color: #FFFFFF;
  168. border-radius: 20rpx;
  169. width: 280rpx;
  170. height: 300rpx;
  171. z-index: 99;
  172. .item-text {
  173. margin: -7rpx 0 20rpx 20rpx;
  174. width: 100%;
  175. line-height: 40rpx;
  176. font-weight: bold;
  177. font-size: 35rpx;
  178. color: #696969;
  179. }
  180. .avatar-box {
  181. .item-avatar {
  182. width: 220rpx;
  183. height: 220rpx;
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. </style>