mine.vue 13 KB

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