dataSet.vue 17 KB

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