dataSet.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <view>
  3. <ujp-navbar title="个人资料"></ujp-navbar>
  4. <!-- 个人信息 -->
  5. <view class="userCell">
  6. <view class="title oldTextjp2" oldstyle="font-size: 20px;">
  7. 个人信息
  8. </view>
  9. <!-- 头像 -->
  10. <view class="userCell-item">
  11. <view class="userCell-title">
  12. <text class="user"><img style="visibility: middle;;" src="../../assets/img/account-circle-fill.svg"
  13. alt=""></text>
  14. <p class="oldTextjp" oldstyle="font-size: 18px;">头像</p>
  15. </view>
  16. <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="uploadPhoto">
  17. <view class="value">
  18. <view class="box">
  19. <u-avatar v-if="form.headImg != null" class="avatar" :src="form.headImg+'?x-oss-process=image/resize,m_fill,w_256,h_256'" size="80">
  20. <img src="" alt="">
  21. </u-avatar>
  22. <img v-else class="camera" src="../../assets/img/camera-fill.svg" alt="">
  23. </view>
  24. </view>
  25. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
  26. </view>
  27. </view>
  28. <!-- 昵称 -->
  29. <view class="userCell-item">
  30. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  31. <text class="user"><img style="visibility: middle;;" src="../../assets/img/edit-box-fill.svg"
  32. alt=""></text>
  33. <p class="oldTextjp" oldstyle="font-size: 18px;">昵称</p>
  34. </view>
  35. <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="maskShow1">
  36. <view class="value black">
  37. {{form.nickName}}
  38. </view>
  39. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
  40. </view>
  41. </view>
  42. <!-- 真实姓名 -->
  43. <view class="userCell-item">
  44. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  45. <text class="user"><img style="visibility: middle;;" src="../../assets/img/edit-box-fill.svg"
  46. alt=""></text>
  47. <p class="oldTextjp" oldstyle="font-size: 18px;">姓名</p>
  48. </view>
  49. <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="maskShow2">
  50. <view class="value black" v-if="form.realName != null">
  51. {{form.realName}}
  52. </view>
  53. <view class="value" v-else>
  54. 请填写真实姓名
  55. </view>
  56. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
  57. </view>
  58. </view>
  59. <!-- 生日 -->
  60. <view class="userCell-item">
  61. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  62. <text class="user"><img style="visibility: middle;;" src="../../assets/img/cake-2-fill.svg"
  63. alt=""></text>
  64. <p class="oldTextjp" oldstyle="font-size: 18px;">生日</p>
  65. </view>
  66. <u-picker mode="time" v-model="timeShow" :params="params" @confirm="confirmTime" @cancel="cancelTime"></u-picker>
  67. <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="timeShowClick">
  68. <view class="value black" v-if="birthday != null">
  69. {{birthday}}
  70. </view>
  71. <view class="value" v-else>
  72. 请选择
  73. </view>
  74. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
  75. </view>
  76. </view>
  77. </view>
  78. <u-line color="#F2F2F2 100%" length="87.2%" margin="8px auto 0" />
  79. <!-- 账户与安全 -->
  80. <view class="userCell">
  81. <view class="title oldTextjp2" oldstyle="font-size: 20px;">
  82. 账户与安全
  83. </view>
  84. <!-- 更换手机号 -->
  85. <view class="userCell-item">
  86. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  87. <text class="user"><img style="visibility: middle;;" src="../../assets/img/smartphone-fill.svg"
  88. alt=""></text>
  89. <p class="oldTextjp" oldstyle="font-size: 18px;">更换手机号</p>
  90. </view>
  91. <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="gotoUrl('pages/user/phone')">
  92. <view class="value black">
  93. {{userPhone}}
  94. </view>
  95. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
  96. </view>
  97. </view>
  98. <!-- 实名认证 -->
  99. <!-- <view class="userCell-item">
  100. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  101. <text class="user"><img style="visibility: middle;;" src="../../assets/img/shield-user-fill.svg"
  102. alt=""></text>
  103. <p class="oldTextjp" oldstyle="font-size: 18px;">实名认证</p>
  104. </view>
  105. <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;">
  106. <view class="value">
  107. 未实名
  108. </view>
  109. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
  110. </view>
  111. </view> -->
  112. </view>
  113. <u-line color="#F2F2F2 100%" length="87.2%" margin="8px auto 0" />
  114. <!-- 更多操作 -->
  115. <view class="userCell">
  116. <view class="title oldTextjp2" oldstyle="font-size: 20px;">
  117. 更多操作
  118. </view>
  119. <!-- 车辆信息 -->
  120. <view class="userCell-item">
  121. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  122. <text class="user"><img style="visibility: middle;;" src="../../assets/img/car-fill (1).svg"
  123. alt=""></text>
  124. <p class="oldTextjp" oldstyle="font-size: 18px;">车辆信息</p>
  125. </view>
  126. <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="carClick">
  127. <view class="value black" v-if="carList.carNum != null">
  128. {{carList.carNum}}
  129. </view>
  130. <view class="value" v-else>
  131. 未绑定
  132. </view>
  133. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
  134. </view>
  135. </view>
  136. <!-- 长辈模式 -->
  137. <view class="userCell-item">
  138. <view class="userCell-title">
  139. <text class="user"><img style="visibility: middle;;" src="../../assets/img/zoom-in-fill.svg"
  140. alt=""></text>
  141. <p class="oldTextjp" oldstyle="font-size: 18px;">长辈模式</p>
  142. </view>
  143. <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;">
  144. <view class="value">
  145. <view class="text black">
  146. 字体更大 看得清
  147. </view>
  148. <u-switch v-model="checked" active-color="#00E266" @change="checkedChange"></u-switch>
  149. </view>
  150. <!-- <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon> -->
  151. </view>
  152. </view>
  153. <!-- 注销账号 -->
  154. <view class="userCell-item" @click="gotoUrl('pages/user/logout')">
  155. <view class="userCell-title">
  156. <text class="user"><img style="visibility: middle;;" src="../../assets/img/spam-3-fill.svg"
  157. alt=""></text>
  158. <p class="oldTextjp" oldstyle="font-size: 18px;">注销账号</p>
  159. </view>
  160. <view class="userCell-content">
  161. <view class="value black" :style="elderStatus ? 'font-size: 16px;' : 'font-size: 14px;'">
  162. 注销后无法恢复,请谨慎操作
  163. </view>
  164. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
  165. </view>
  166. </view>
  167. </view>
  168. <view class="exit oldTextjp2" oldstyle="font-size: 18px;" @click="signOut">
  169. 退出账号
  170. </view>
  171. <view>
  172. <u-modal v-model="exitShow" @confirm="confirm" confirm-color="#FF3D00" :show-cancel-button="true" ref="uModal" :asyncClose="true" :title="title"
  173. :content="content" :content-style="{color: '#333333'}"></u-modal>
  174. </view>
  175. <!-- 昵称遮罩层 -->
  176. <u-mask :show="show1" @click="show1 = false" :zoom='false'>
  177. <view class="warp">
  178. <view class="rect" @tap.stop>
  179. <p>修改昵称</p>
  180. <textarea name="" id="" cols="30" rows="10" v-model="name1"></textarea>
  181. <img class="canc" src="../../assets/img/md-cancel Copy@3x.png" alt="" @click="nickNameReset">
  182. <u-button type="success" @click="nickNameSubmit">保存</u-button>
  183. </view>
  184. </view>
  185. </u-mask>
  186. <!-- 真实姓名遮罩层 -->
  187. <u-mask :show="show2" @click="show2 = false" :zoom='false'>
  188. <view class="warp">
  189. <view class="rect" @tap.stop>
  190. <p>请填写真实姓名</p>
  191. <textarea name="" id="" cols="30" rows="10" v-model="name2"></textarea>
  192. <img class="canc" src="../../assets/img/md-cancel Copy@3x.png" alt="" @click="realNameReset">
  193. <u-button type="success" @click="realNameSubmit">保存</u-button>
  194. </view>
  195. </view>
  196. </u-mask>
  197. </view>
  198. </template>
  199. <script>
  200. import * as API from '@/apis/index.js'
  201. import * as userApi from '@/apis/user.js'
  202. import * as loginApi from '@/apis/login.js'
  203. export default {
  204. data() {
  205. return {
  206. params: {
  207. year: true,
  208. month: true,
  209. day: true,
  210. hour: false,
  211. minute: false,
  212. second: false,
  213. timestamp: true,
  214. },
  215. timeShow: false,
  216. exitShow: false,
  217. title: '退出账号',
  218. content: '是否退出当前账号?',
  219. checked: false,
  220. src: '',
  221. show1: false,
  222. show2: false,
  223. fontMode: '',
  224. userId: '',
  225. userPhone: '',
  226. name1: '',
  227. name2: '',
  228. form: {
  229. nickName: '',
  230. headImg: '',
  231. realName: '',
  232. },
  233. birthday: '',
  234. carList: {
  235. carNum: null,
  236. },
  237. elderStatus: false,
  238. }
  239. },
  240. onShow() {
  241. if (this.carhelp.get("getElderModeClass") == "长辈模式") {
  242. this.checked = true;
  243. this.elderStatus = true;
  244. } else {
  245. this.checked = false;
  246. this.elderStatus = false;
  247. }
  248. this.getUserInfo();
  249. this.getCarList();
  250. },
  251. methods: {
  252. carClick() {
  253. if(this.carList.carNum != null) {
  254. uni.navigateTo({
  255. url: '/pages/user/car/carAdd?id=' + this.carList.id
  256. })
  257. } else {
  258. uni.navigateTo({
  259. url: '/pages/user/car/carDet'
  260. })
  261. }
  262. },
  263. getCarList() {
  264. this.carList.carNum = null;
  265. uni.showLoading({
  266. title: "加载中",
  267. mask: true,
  268. })
  269. userApi.regUserCarList().then((res) => {
  270. uni.hideLoading();
  271. if(res.data.length != 0) {
  272. this.carList = res.data[0];
  273. }
  274. }).catch(error => {
  275. uni.showToast({
  276. title: error,
  277. icon: "none"
  278. })
  279. })
  280. },
  281. timeShowClick() {
  282. if(this.birthday == null) {
  283. this.timeShow = true;
  284. }
  285. },
  286. confirmTime(params) {
  287. this.birthday = params.year + '-' + params.month + '-' + params.day;
  288. console.log(this.birthday)
  289. uni.showLoading({
  290. title: "加载中",
  291. mask: true,
  292. })
  293. userApi.changeBirthday({birthday: this.birthday}).then((res) => {
  294. uni.hideLoading();
  295. this.timeShow = false;
  296. }).catch(error => {
  297. uni.showToast({
  298. title: error,
  299. icon: "none"
  300. })
  301. })
  302. },
  303. cancelTime() {
  304. this.timeShow = false;
  305. },
  306. signOut() {
  307. this.exitShow = true;
  308. },
  309. confirm() {
  310. uni.showLoading({
  311. title: "加载中",
  312. mask: true,
  313. })
  314. userApi.logout().then((res) => {
  315. uni.hideLoading();
  316. this.exitShow = false;
  317. this.carhelp.logoff()
  318. uni.redirectTo({
  319. url: '/pages/login/login'
  320. })
  321. }).catch(error => {
  322. uni.showToast({
  323. title: error,
  324. icon: "none"
  325. })
  326. })
  327. },
  328. submit() {
  329. uni.showLoading({
  330. title: "加载中",
  331. mask: true,
  332. })
  333. userApi.updatePersonInformation(this.form).then((res) => {
  334. uni.hideLoading();
  335. }).catch(error => {
  336. uni.showToast({
  337. title: error,
  338. icon: "none"
  339. })
  340. })
  341. },
  342. nickNameSubmit() {
  343. this.form.nickName = this.name1;
  344. this.submit();
  345. this.show1 = false;
  346. },
  347. maskShow1() {
  348. this.show1 = true;
  349. this.name1 = this.form.nickName;
  350. },
  351. nickNameReset() {
  352. this.name1 = '';
  353. },
  354. realNameSubmit() {
  355. this.form.realName = this.name2;
  356. this.submit();
  357. this.show2 = false;
  358. },
  359. maskShow2() {
  360. this.show2 = true;
  361. this.name2 = this.form.realName;
  362. },
  363. realNameReset() {
  364. this.name2 = '';
  365. },
  366. checkedChange() {
  367. if (this.checked) {
  368. this.carhelp.set("getElderModeClass", "长辈模式");
  369. this.fontMode = '1';
  370. this.elderStatus = true;
  371. } else {
  372. this.carhelp.set("getElderModeClass", "标准模式");
  373. this.fontMode = '0';
  374. this.elderStatus = false;
  375. }
  376. API.changeFont({
  377. fontMode: this.fontMode
  378. }).then((res) => {
  379. }).catch(error => {
  380. uni.showToast({
  381. title: error,
  382. icon: "none"
  383. })
  384. })
  385. },
  386. getUserInfo() {
  387. uni.showLoading({
  388. title: "加载中",
  389. mask: true,
  390. })
  391. loginApi.findByOpenId({
  392. openId: this.carhelp.getOpenId()
  393. }).then((res) => {
  394. uni.hideLoading();
  395. this.form.nickName = res.data.regUser.nickName;
  396. this.form.headImg = res.data.regUser.headImg;
  397. this.form.realName = res.data.regUser.realName;
  398. this.birthday = res.data.regUser.birthday;
  399. var phone = res.data.regUser.phone;
  400. var phone1 = phone.slice(0,3);
  401. var phone2 = phone.slice(-4);
  402. this.userPhone = phone1 + '****' + phone2;
  403. }).catch(error => {
  404. uni.showToast({
  405. title: error,
  406. icon: "none"
  407. })
  408. })
  409. },
  410. uploadPhoto() {
  411. let _self = this;
  412. const crop = {
  413. quality: 100,
  414. width: 600,
  415. height: 600,
  416. resize: true
  417. };
  418. // 上传图片
  419. uni.chooseImage({
  420. count: 1,
  421. crop,
  422. success: async (res) => {
  423. //(res);
  424. let tempFile = res.tempFiles[0],
  425. avatar_file = {
  426. // #ifdef H5
  427. extname: tempFile.name.split('.')[tempFile.name.split('.').length - 1],
  428. // #endif
  429. // #ifndef H5
  430. extname: tempFile.path.split('.')[tempFile.path.split('.').length - 1]
  431. // #endif
  432. },
  433. filePath = res.tempFilePaths[0]
  434. // #ifndef APP-PLUS
  435. //(`filePath=${filePath}`)
  436. //非app端用前端组件剪裁头像,app端用内置的原生裁剪
  437. let fileData = await new Promise((callback) => {
  438. uni.navigateTo({
  439. url: '/pages/user/cropImage?path=' + filePath +
  440. `&options=${JSON.stringify(crop)}`,
  441. animationType: "fade-in",
  442. events: {
  443. success: url => {
  444. callback(url)
  445. }
  446. }
  447. });
  448. })
  449. // #endif
  450. //返回 base64 图片
  451. //(fileData);
  452. var token = _self.carhelp.getToken()
  453. uni.showLoading({
  454. title: '上传中'
  455. });
  456. uni.request({
  457. url: process.car.BASE_URL + "uploadBase64",
  458. method: 'POST',
  459. data: {
  460. photoBase64Data: fileData
  461. },
  462. header: {
  463. 'Authorization': token,
  464. 'content-type': 'application/x-www-form-urlencoded'
  465. },
  466. success: (res) => {
  467. let jsonData = res.data;
  468. _self.form.headImg = jsonData.data;
  469. _self.submit();
  470. uni.hideLoading();
  471. }
  472. });
  473. }
  474. });
  475. },
  476. }
  477. }
  478. </script>
  479. <style lang="scss" scoped>
  480. page {
  481. background-color: #fff;
  482. padding-bottom: 20px;
  483. }
  484. .userCell {
  485. .user {
  486. img {
  487. vertical-align: middle;
  488. }
  489. }
  490. .title {
  491. padding: 24px 20px 8px 20px;
  492. font-size: 18px;
  493. color: rgba(16, 16, 16, 100);
  494. }
  495. .userCell-item {
  496. display: flex;
  497. justify-content: space-between;
  498. align-items: center;
  499. padding: 11px 20px;
  500. .userCell-title {
  501. font-size: 16px;
  502. display: flex;
  503. p {
  504. margin-left: 8px;
  505. font-size: 16px;
  506. line-height: 28px;
  507. color: #333333;
  508. }
  509. }
  510. .userCell-content {
  511. display: flex;
  512. color: rgba(153, 153, 153, 100);
  513. font-size: 16px;
  514. line-height: 20px;
  515. }
  516. .value {
  517. display: flex;
  518. .text {
  519. line-height: 28px;
  520. }
  521. .circle {
  522. width: 40px;
  523. height: 40px;
  524. }
  525. .u-avatar {
  526. position: absolute;
  527. }
  528. .camera {
  529. width: 20px;
  530. height: 20px;
  531. position: absolute;
  532. left: 50%;
  533. top: 50%;
  534. transform: translate(-50%, -50%);
  535. z-index: 9999;
  536. }
  537. .box {
  538. border-radius: 999px;
  539. height: 40px;
  540. width: 40px;
  541. position: relative;
  542. background: url(@/assets/img/circle.png);
  543. background-repeat: no-repeat;
  544. background-position: 30% 10%;
  545. background-size: cover;
  546. }
  547. }
  548. .u-switch {
  549. width: 48px;
  550. height: 24px;
  551. vertical-align: middle;
  552. margin-left: 8px;
  553. }
  554. /deep/.u-switch__node {
  555. width: 24px !important;
  556. height: 24px !important;
  557. }
  558. span {
  559. color: #999;
  560. }
  561. .add {
  562. color: #999;
  563. }
  564. .black {
  565. color: #666666;
  566. }
  567. }
  568. }
  569. .exit {
  570. color: rgba(238, 49, 56, 100);
  571. font-size: 16px;
  572. text-align: center;
  573. margin-top: 10px;
  574. }
  575. .warp {
  576. position: fixed;
  577. left: 0;
  578. bottom: 0;
  579. width: 100%;
  580. }
  581. .rect {
  582. width: 100%;
  583. height: 100%;
  584. background-color: #fff;
  585. padding: 24px 0;
  586. p {
  587. color: rgba(16, 16, 16, 100);
  588. font-size: 16px;
  589. line-height: 24px;
  590. padding: 0 24px;
  591. }
  592. textarea {
  593. width: 87.2%;
  594. border-radius: 8px;
  595. background-color: rgba(229, 231, 234, 100);
  596. margin: 12px auto 0;
  597. height: 44px;
  598. line-height: 44px !important;
  599. padding: 0 8px;
  600. position: relative;
  601. }
  602. .canc {
  603. width: 20px;
  604. height: 20px;
  605. position: absolute;
  606. top: 70px;
  607. right: 7vw;
  608. }
  609. .u-btn {
  610. width: 89.2%;
  611. color: rgba(255, 255, 255, 100);
  612. font-size: 18px;
  613. border-radius: 8px;
  614. margin-top: 24px;
  615. z-index: 99999;
  616. }
  617. }
  618. </style>