mine.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <view>
  3. <view class="head" @click="toEditProfile">
  4. <view class="photo">
  5. <u-avatar class="avatar"
  6. :src="form.headImg != null ? form.headImg : '../../assets/img/head.png'" size="112">
  7. </u-avatar>
  8. </view>
  9. <view class="infos">
  10. <view class="name">
  11. {{form.nickName}}
  12. </view>
  13. <view class="modification">
  14. 点击修改个人信息
  15. </view>
  16. </view>
  17. </view>
  18. <view class="my-children">
  19. <view class="top">
  20. <view class="text">
  21. 我的子女
  22. </view>
  23. <view class="add" @click="toAddChildInformation()">
  24. 添加
  25. </view>
  26. </view>
  27. <view class="children" v-if="studentList.length != 0">
  28. <view class="check-box" v-for="(item,index) in studentList" :key="item.studentId">
  29. <view class="photo" @click="toAddChildInformation(item)">
  30. <u-avatar class="avatar"
  31. :src="item.headPhoto != null ? item.headPhoto : '../../assets/img/head.png'" size="80">
  32. </u-avatar>
  33. </view>
  34. <view class="infos" @click="toAddChildInformation(item)">
  35. <view class="name">
  36. {{item.studentName}}
  37. </view>
  38. <view class="age">
  39. {{item.age}}岁
  40. </view>
  41. </view>
  42. <view class="radio">
  43. <u-radio-group v-model="studentId" size="40rpx">
  44. <u-radio @change="radioChange" :key="item.studentId" :name="item.studentId"></u-radio>
  45. </u-radio-group>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="class-times">
  51. <!-- <view class="box">
  52. <view class="times">
  53. 36节
  54. </view>
  55. <view class="text">
  56. 购买课次
  57. </view>
  58. </view>
  59. <u-line direction="col" color="rgba(232, 232, 232, 1)" length="80rpx" margin="auto 0"></u-line>
  60. <view class="box">
  61. <view class="times">
  62. 4节
  63. </view>
  64. <view class="text">
  65. 赠送课次
  66. </view>
  67. </view> -->
  68. </view>
  69. <view class="option-group">
  70. <!-- <view class="item">
  71. <view class="title">
  72. <view class="icon">
  73. <img src="../../../assets/img/riLine-user-smile-line@1x.png" alt="">
  74. </view>
  75. <view class="text">
  76. 人脸信息采集
  77. </view>
  78. </view>
  79. <view class="value">
  80. <view class="text">
  81. </view>
  82. <view class="icon">
  83. <u-icon name="arrow-right" color="#cccccc"></u-icon>
  84. </view>
  85. </view>
  86. </view> -->
  87. <view class="item" @click="gotoUrl('pages/parents/mine/changePhoneNumber/changePhoneNumber')">
  88. <view class="title">
  89. <view class="icon">
  90. <img src="../../../assets/img/riLine-smartphone-line@1x(1).png" alt="">
  91. </view>
  92. <view class="text">
  93. 绑定手机
  94. </view>
  95. </view>
  96. <view class="value">
  97. <view class="text">
  98. {{form.phone.slice(0,3) + '****' + form.phone.slice(-4)}}
  99. </view>
  100. <view class="icon">
  101. <u-icon name="arrow-right" color="#cccccc"></u-icon>
  102. </view>
  103. </view>
  104. </view>
  105. <view class="item" @click="gotoUrl('pages/parents/mine/optionsList')">
  106. <view class="title">
  107. <view class="icon">
  108. <img src="../../../assets/img/riLine-file-edit-line@1x.png" alt="">
  109. </view>
  110. <view class="text">
  111. 意见反馈
  112. </view>
  113. </view>
  114. <view class="value">
  115. <view class="icon">
  116. <u-icon name="arrow-right" color="#cccccc"></u-icon>
  117. </view>
  118. </view>
  119. </view>
  120. <!-- <view class="item">
  121. <view class="title">
  122. <view class="icon">
  123. <img src="../../../assets/img/riLine-customer-service-2-line@1x.png" alt="">
  124. </view>
  125. <view class="text">
  126. 联系我们
  127. </view>
  128. </view>
  129. <view class="value">
  130. <view class="text">
  131. 0716-8888888
  132. </view>
  133. <view class="icon">
  134. <u-icon name="arrow-right" color="#cccccc"></u-icon>
  135. </view>
  136. </view>
  137. </view> -->
  138. <view class="item" @click="gotoUrl('pages/parents/mine/logout')">
  139. <view class="title">
  140. <view class="icon">
  141. <img src="../../../assets/img/riLine-spam-3-line@1x.png" alt="">
  142. </view>
  143. <view class="text">
  144. 注销账号
  145. </view>
  146. </view>
  147. <view class="value">
  148. <view class="text">
  149. 注销后无法恢复,请谨慎操作
  150. </view>
  151. <view class="icon">
  152. <u-icon name="arrow-right" color="#cccccc"></u-icon>
  153. </view>
  154. </view>
  155. </view>
  156. <view class="item" @click="signOut">
  157. <view class="title">
  158. <view class="icon">
  159. <img src="../../../assets/img/riLine-logout-box-r-line@1x(1).png" alt="">
  160. </view>
  161. <view class="text">
  162. 退出账号
  163. </view>
  164. </view>
  165. <view class="value">
  166. <view class="text">
  167. </view>
  168. <view class="icon">
  169. <u-icon name="arrow-right" color="#cccccc"></u-icon>
  170. </view>
  171. </view>
  172. </view>
  173. <u-modal v-model="show" @confirm="confirm" confirm-color="#FF3D00" :show-cancel-button="true"
  174. ref="uModal" :asyncClose="true" :title="title" :content="content"
  175. :content-style="{color: '#333333'}"></u-modal>
  176. </view>
  177. <ParentsTabbar :current="3" ref="tabbarMain"></ParentsTabbar>
  178. </view>
  179. </template>
  180. <script>
  181. import * as mineApi from '@/apis/parents/mine.js'
  182. import * as loginApi from '@/apis/login.js'
  183. import * as API from '@/apis/index.js'
  184. import ParentsTabbar from '@/components/ParentsTabbar.vue'
  185. export default {
  186. components: {
  187. ParentsTabbar
  188. },
  189. data() {
  190. return {
  191. form: {
  192. id: '',
  193. headImg: '',
  194. nickName: '',
  195. phone: ''
  196. },
  197. show: false,
  198. title: '退出账号',
  199. content: '是否退出当前账号?',
  200. studentList: [],
  201. studentId: '',
  202. }
  203. },
  204. onShow() {
  205. this.getParentsInfo();
  206. this.getStudentList();
  207. },
  208. onReady() {
  209. if(this.carhelp.getStudentId()) {
  210. this.studentId = this.carhelp.getStudentId().studentId;
  211. }
  212. },
  213. methods: {
  214. radioChange(e) {
  215. this.carhelp.setStudentId({studentId: e});
  216. this.studentId = e;
  217. },
  218. toAddChildInformation(item) {
  219. if(this.form.id) {
  220. if(item) {
  221. uni.navigateTo({
  222. url: '/pages/parents/mine/addChildInformation?id=' + item.studentId
  223. })
  224. } else {
  225. uni.navigateTo({
  226. url: '/pages/parents/mine/addChildInformation'
  227. })
  228. }
  229. }else {
  230. uni.navigateTo({
  231. url: '/pages/parents/login/login'
  232. })
  233. }
  234. },
  235. getAge(str) {
  236. var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
  237. if (r == null) return false;
  238. var d = new Date(r[1], r[3] - 1, r[4]);
  239. if (d.getFullYear() == r[1] && (d.getMonth() + 1) == r[3] && d.getDate() == r[4]) {
  240. var date = new Date();
  241. var Y = date.getFullYear() - r[1];
  242. var M = date.getMonth() + 1 - r[3];
  243. var D = date.getDate();
  244. if (parseInt(D) - parseInt(r[4]) < 0) {
  245. M--;
  246. if (M < 0) {
  247. Y--;
  248. M = 11;
  249. }
  250. }
  251. if (M < 0) {
  252. Y--;
  253. M = 11;
  254. }
  255. if(Y != 0 && M != 0) {
  256. return (Y + "岁" + M + "个月");
  257. }else if(Y != 0 && M == 0) {
  258. return (Y + "岁");
  259. }else {
  260. return (M + "个月");
  261. }
  262. }
  263. return ("输入的日期格式错误!");
  264. },
  265. getParentsInfo() {
  266. uni.showLoading({
  267. title: "加载中",
  268. mask: true,
  269. })
  270. loginApi.findByOpenId({
  271. openId: this.carhelp.getOpenId()
  272. }).then((response) => {
  273. uni.hideLoading();
  274. this.form = response.data.regUser;
  275. }).catch(error => {
  276. uni.showToast({
  277. title: error,
  278. icon: "none"
  279. })
  280. })
  281. },
  282. getStudentList() {
  283. uni.showLoading({
  284. title: "加载中",
  285. mask: true,
  286. })
  287. mineApi.studentList().then((res) => {
  288. uni.hideLoading();
  289. this.studentList = res.data.studentList;
  290. if(this.studentList.length == 1) {
  291. this.carhelp.setStudentId({studentId: this.studentList[0].studentId});
  292. }
  293. }).catch(error => {
  294. uni.showToast({
  295. title: error,
  296. icon: "none"
  297. })
  298. })
  299. },
  300. signOut() {
  301. this.show = true;
  302. },
  303. confirm() {
  304. uni.showLoading({
  305. title: "加载中",
  306. mask: true,
  307. })
  308. API.logout().then((res) => {
  309. uni.hideLoading();
  310. this.show = false;
  311. this.carhelp.logoff()
  312. uni.reLaunch({
  313. url: '/pages/parents/login/login'
  314. })
  315. }).catch(error => {
  316. uni.showToast({
  317. title: error,
  318. icon: "none"
  319. })
  320. })
  321. },
  322. toEditProfile() {
  323. if (this.form.id) {
  324. uni.navigateTo({
  325. url: '/pages/parents/mine/editProfile'
  326. })
  327. } else{
  328. uni.navigateTo({
  329. url: '/pages/parents/login/login'
  330. })
  331. }
  332. },
  333. }
  334. }
  335. </script>
  336. <style lang="scss" scoped>
  337. .head {
  338. padding: 48rpx 40rpx;
  339. display: flex;
  340. align-items: center;
  341. .photo {
  342. width: 120rpx;
  343. height: 120rpx;
  344. border-radius: 100rpx;
  345. border: 4rpx solid rgba(255, 255, 255, 1);
  346. overflow: hidden;
  347. img {
  348. width: 100%;
  349. height: 100%;
  350. }
  351. }
  352. .infos {
  353. margin-left: 32rpx;
  354. .name {
  355. color: rgba(51, 51, 51, 1);
  356. font-size: 20px;
  357. line-height: 20px;
  358. font-weight: bold;
  359. }
  360. .modification {
  361. color: rgba(119, 119, 119, 1);
  362. font-size: 24rpx;
  363. line-height: 24rpx;
  364. margin-top: 16rpx;
  365. }
  366. }
  367. }
  368. .my-children {
  369. margin: 0 32rpx;
  370. padding: 32rpx 24rpx;
  371. border-radius: 12px;
  372. background: linear-gradient(90deg, rgba(13, 186, 199, 1) 0%, rgba(37, 209, 146, 1) 100%);
  373. .top {
  374. display: flex;
  375. justify-content: space-between;
  376. .text {
  377. color: rgba(255, 255, 255, 1);
  378. font-size: 18px;
  379. }
  380. .add {
  381. width: 120rpx;
  382. line-height: 28px;
  383. border-radius: 50px;
  384. background-color: rgba(255, 174, 0, 1);
  385. color: rgba(255, 255, 255, 1);
  386. font-size: 28rpx;
  387. text-align: center;
  388. }
  389. }
  390. .children {
  391. margin-top: 12px;
  392. border-radius: 16rpx;
  393. background-color: rgba(255, 255, 255, 1);
  394. padding: 24rpx 24rpx 8rpx 24rpx;
  395. display: -webkit-box;
  396. overflow-x: auto;
  397. position: relative;
  398. .check-box {
  399. width: 48%;
  400. padding: 16rpx 40rpx 16rpx 16rpx;
  401. border-radius: 100rpx;
  402. background-color: rgba(13, 186, 199, 0.1);
  403. border: 1px solid rgba(13, 186, 199, 0.5);
  404. display: flex;
  405. position: relative;
  406. margin-right: 24rpx;
  407. margin-bottom: 16rpx;
  408. .photo {
  409. width: 80rpx;
  410. height: 80rpx;
  411. border-radius: 100rpx;
  412. overflow: hidden;
  413. img {
  414. width: 100%;
  415. height: 100%;
  416. }
  417. }
  418. @media screen and(max-width:320px) {
  419. .photo {
  420. width: 70rpx;
  421. height: 70rpx;
  422. border-radius: 999rpx;
  423. overflow: hidden;
  424. img {
  425. width: 100%;
  426. height: 100%;
  427. vertical-align: middle;
  428. }
  429. }
  430. }
  431. .infos {
  432. margin-left: 16rpx;
  433. .name {
  434. width: 96rpx;
  435. overflow: hidden;
  436. white-space: nowrap;
  437. text-overflow: ellipsis;
  438. color: rgba(51, 51, 51, 1);
  439. font-size: 32rpx;
  440. line-height: 48rpx;
  441. }
  442. .age {
  443. color: rgba(119, 119, 119, 1);
  444. font-size: 24rpx;
  445. line-height: 28rpx;
  446. }
  447. }
  448. .radio {
  449. position: absolute;
  450. bottom: -2rpx;
  451. right: -40rpx;
  452. ::v-deep.uni-radio-input {
  453. width: 40rpx;
  454. height: 40rpx;
  455. background-color: rgba(221, 241, 242, 1);
  456. }
  457. ::v-deep.uni-radio-input-checked {
  458. background-color: #43C9D3 !important;
  459. border-color: #43C9D3 !important;
  460. }
  461. }
  462. ::v-deep.u-radio__icon-wrap {
  463. background-color: rgba(221, 241, 242, 1);
  464. }
  465. }
  466. @media screen and(max-width:320px) {
  467. .check-box {
  468. margin-right: 16rpx;
  469. }
  470. }
  471. }
  472. .children::-webkit-scrollbar {
  473. display: none;
  474. }
  475. }
  476. .class-times {
  477. // border-radius: 12px;
  478. // background-color: rgba(255, 255, 255, 1);
  479. // display: flex;
  480. // padding: 20px 0;
  481. margin: 12px 16px;
  482. .box {
  483. width: 50%;
  484. text-align: center;
  485. .times {
  486. color: rgba(51, 51, 51, 1);
  487. font-size: 20px;
  488. font-weight: bold;
  489. }
  490. .text {
  491. color: rgba(119, 119, 119, 1);
  492. font-size: 14px;
  493. margin-top: 8px;
  494. }
  495. }
  496. }
  497. .option-group {
  498. margin: 0 32rpx;
  499. background-color: #fff;
  500. border-radius: 12px;
  501. .item {
  502. display: flex;
  503. justify-content: space-between;
  504. align-items: center;
  505. padding: 24rpx;
  506. border-bottom: 1px solid rgba(244, 244, 244, 1);
  507. .title {
  508. display: flex;
  509. align-items: center;
  510. img {
  511. vertical-align: middle;
  512. }
  513. .text {
  514. margin-left: 16rpx;
  515. color: rgba(119, 119, 119, 1);
  516. font-size: 28rpx
  517. }
  518. }
  519. .value {
  520. display: flex;
  521. align-items: center;
  522. .icon {
  523. margin-left: 16rpx;
  524. }
  525. .text {
  526. color: rgba(119, 119, 119, 1);
  527. font-size: 24rpx;
  528. }
  529. }
  530. }
  531. }
  532. </style>