mine.vue 12 KB

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