123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716 |
- <template>
- <view>
- <ujp-navbar title="个人资料"></ujp-navbar>
- <!-- 个人信息 -->
- <view class="userCell">
- <view class="title oldTextjp2" oldstyle="font-size: 20px;">
- 个人信息
- </view>
- <!-- 头像 -->
- <view class="userCell-item">
- <view class="userCell-title">
- <text class="user"><img style="visibility: middle;;" src="../../assets/img/account-circle-fill.svg"
- alt=""></text>
- <p class="oldTextjp" oldstyle="font-size: 18px;">头像</p>
- </view>
- <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="uploadPhoto">
- <view class="value">
- <view class="box">
- <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">
- <img src="" alt="">
- </u-avatar>
- <img v-else class="camera" src="../../assets/img/camera-fill.svg" alt="">
- </view>
-
- </view>
- <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
- </view>
- </view>
- <!-- 昵称 -->
- <view class="userCell-item">
- <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
- <text class="user"><img style="visibility: middle;;" src="../../assets/img/edit-box-fill.svg"
- alt=""></text>
- <p class="oldTextjp" oldstyle="font-size: 18px;">昵称</p>
- </view>
- <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="maskShow1">
- <view class="value black">
- {{form.nickName}}
- </view>
- <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
- </view>
- </view>
- <!-- 真实姓名 -->
- <view class="userCell-item">
- <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
- <text class="user">
- <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"/>
- </svg>
- </text>
- <p class="oldTextjp" oldstyle="font-size: 18px;">姓名</p>
- </view>
- <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="maskShow2">
- <view class="value black" v-if="form.realName != null && form.realName != ''">
- {{form.realName}}
- </view>
- <view class="value" v-else>
- 请填写真实姓名
- </view>
- <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
- </view>
- </view>
- <!-- 生日 -->
- <view class="userCell-item">
- <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
- <text class="user"><img style="visibility: middle;;" src="../../assets/img/cake-2-fill.svg"
- alt=""></text>
- <p class="oldTextjp" oldstyle="font-size: 18px;">生日</p>
- </view>
- <u-picker mode="time" v-model="timeShow" :params="params" @confirm="confirmTime" @cancel="cancelTime"></u-picker>
- <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="timeShowClick">
- <view class="value black" v-if="birthday != null">
- {{birthday}}
- </view>
- <view class="value" v-else>
- 请选择
- </view>
- <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
- </view>
-
- </view>
- <p style="
- text-align: end;
- padding: 0 20px;
- color: #999999;">生日填写后不可修改,仅作为活动营销使用</p>
- </view>
- <u-line color="#F2F2F2 100%" length="87.2%" margin="8px auto 0" />
- <!-- 账户与安全 -->
- <view class="userCell">
- <view class="title oldTextjp2" oldstyle="font-size: 20px;">
- 账户与安全
- </view>
- <!-- 更换手机号 -->
- <view class="userCell-item">
- <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
- <text class="user"><img style="visibility: middle;;" src="../../assets/img/smartphone-fill.svg"
- alt=""></text>
- <p class="oldTextjp" oldstyle="font-size: 18px;">更换手机号</p>
- </view>
- <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="gotoUrl('pages/user/phone')">
- <view class="value black">
- {{userPhone}}
- </view>
- <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
- </view>
- </view>
- <!-- 实名认证 -->
- <!-- <view class="userCell-item">
- <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
- <text class="user"><img style="visibility: middle;;" src="../../assets/img/shield-user-fill.svg"
- alt=""></text>
- <p class="oldTextjp" oldstyle="font-size: 18px;">实名认证</p>
- </view>
- <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;">
- <view class="value">
- 未实名
- </view>
- <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
- </view>
- </view> -->
- </view>
- <u-line color="#F2F2F2 100%" length="87.2%" margin="8px auto 0" />
- <!-- 更多操作 -->
- <view class="userCell">
- <view class="title oldTextjp2" oldstyle="font-size: 20px;">
- 更多操作
- </view>
- <!-- 车辆信息 -->
- <view class="userCell-item">
- <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
- <text class="user"><img style="visibility: middle;;" src="../../assets/img/car-fill.svg"
- alt=""></text>
- <p class="oldTextjp" oldstyle="font-size: 18px;">车辆信息</p>
- </view>
-
- <view class="userCell-content oldTextjp2" oldstyle="font-size: 18px;" @click="carClick">
-
- <view class="value black" v-if="carList.carNum != null">
- {{carList.carNum}}
- </view>
- <view class="value" v-else>
- 未绑定
- </view>
- <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="48"></u-icon>
- </view>
- </view>
- <view class="position" v-show="!userInfo.carLicense">
- <view id="talkbubble">首次认证送5元代金卷</view>
- </view>
-
- </view>
- <!-- <view class="exit oldTextjp2" oldstyle="font-size: 18px;" @click="signOut">
- 退出账号
- </view> -->
- <view>
- <u-modal v-model="exitShow" @confirm="confirm" confirm-color="#FF3D00" :show-cancel-button="true" ref="uModal" :asyncClose="true" :title="title"
- :content="content" :content-style="{color: '#333333'}"></u-modal>
- </view>
- <!-- 昵称遮罩层 -->
- <u-mask :show="show1" @click="show1 = false" :zoom='false'>
- <view class="warp">
- <view class="rect" @tap.stop>
- <p>修改昵称</p>
- <textarea name="" id="" cols="30" rows="10" v-model="name1"></textarea>
- <img class="canc" src="../../assets/img/md-cancel@3x.png" alt="" @click="nickNameReset">
- <u-button type="success" @click="nickNameSubmit">保存</u-button>
- </view>
- </view>
- </u-mask>
-
- <!-- 真实姓名遮罩层 -->
- <u-mask :show="show2" @click="show2 = false" :zoom='false'>
- <view class="warp">
- <view class="rect" @tap.stop>
- <p>请填写真实姓名</p>
-
- <textarea name="" id="" cols="30" rows="10" v-model="name2"></textarea>
- <img class="canc" src="../../assets/img/md-cancel@3x.png" alt="" @click="realNameReset">
- <u-button type="success" @click="realNameSubmit">保存</u-button>
- </view>
- </view>
- </u-mask>
-
- </view>
- </template>
- <script>
- import * as API from '@/apis/index.js'
- import * as userApi from '@/apis/user.js'
- import * as loginApi from '@/apis/login.js'
- import {
- newDate
- } from '@/utils'
- export default {
- data() {
- return {
- params: {
- year: true,
- month: true,
- day: true,
- hour: false,
- minute: false,
- second: false,
- timestamp: true,
- },
- timeShow: false,
- exitShow: false,
- title: '退出账号',
- content: '是否退出当前账号?',
- checked: false,
- src: '',
- show1: false,
- show2: false,
- fontMode: '',
- userId: '',
- userPhone: '',
- name1: '',
- name2: '',
- form: {
- nickName: '',
- headImg: '',
- realName: '',
- },
- birthday: '',
- carList: {
- carNum: null,
- },
- elderStatus: false,
- userInfo:{},
- }
- },
- onShow() {
- if (this.carhelp.get("getElderModeClass") == "长辈模式") {
- this.checked = true;
- this.elderStatus = true;
- } else {
- this.checked = false;
- this.elderStatus = false;
- }
- this.getUserInfo();
- this.getCarList();
- },
- computed:{
- userCardBool(){
- if(this.userCard){
- var date=new Date().getTime()
- var reg=new RegExp('-','gi')
- var str=this.userCard.endTime;
- //console.log(str.replace(reg,'/'))
- var date2=newDate(str).getTime();
- if(date<date2){
- return true;
- }
- }
- return false
- }
- },
- methods: {
-
- carClick() {
- var url='/pages/user/car/carDet'
-
- uni.navigateTo({
- url: url
- })
-
- },
- getCarList() {
- this.carList.carNum = null;
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- userApi.regUserCarList().then((res) => {
- uni.hideLoading();
- if(res.data.length != 0) {
- this.carList = res.data[0];
- }
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- timeShowClick() {
- if(this.birthday == null) {
- this.timeShow = true;
- }
- },
- confirmTime(params) {
- this.birthday = params.year + '-' + params.month + '-' + params.day;
- console.log(this.birthday)
-
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- userApi.changeBirthday({birthday: this.birthday}).then((res) => {
- uni.hideLoading();
- this.timeShow = false;
-
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- cancelTime() {
- this.timeShow = false;
- },
- signOut() {
- this.exitShow = true;
- },
- confirm() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- userApi.logout().then((res) => {
- uni.hideLoading();
- this.exitShow = false;
- this.carhelp.logoff()
- uni.redirectTo({
- url: '/pages/login/login'
- })
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- submit() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- userApi.updatePersonInformation(this.form).then((res) => {
- uni.hideLoading();
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- nickNameSubmit() {
- this.form.nickName = this.name1;
- this.submit();
- this.show1 = false;
- },
- maskShow1() {
- this.show1 = true;
- this.name1 = this.form.nickName;
- },
- nickNameReset() {
- this.name1 = '';
- },
- realNameSubmit() {
- this.form.realName = this.name2;
- this.submit();
- this.show2 = false;
- },
- maskShow2() {
- this.show2 = true;
- this.name2 = this.form.realName;
- },
- realNameReset() {
- this.name2 = '';
- },
- checkedChange() {
- if (this.checked) {
- this.carhelp.set("getElderModeClass", "长辈模式");
- this.fontMode = '1';
- this.elderStatus = true;
- } else {
- this.carhelp.set("getElderModeClass", "标准模式");
- this.fontMode = '0';
- this.elderStatus = false;
- }
- API.changeFont({
- fontMode: this.fontMode
- }).then((res) => {
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- getUserInfo() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- loginApi.findByOpenId({
- openId: this.carhelp.getOpenId()
- }).then((res) => {
- uni.hideLoading();
- this.form.nickName = res.data.regUser.nickName;
- this.form.headImg = res.data.regUser.headImg;
- this.form.realName = res.data.regUser.realName;
- this.birthday = res.data.regUser.birthday;
- this.userInfo=res.data.regUser;
- this.userCard=res.data.userCard;
-
- var phone = res.data.regUser.phone;
- var phone1 = phone.slice(0,3);
- var phone2 = phone.slice(-4);
- this.userPhone = phone1 + '****' + phone2;
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- uploadPhoto() {
- let _self = this;
-
- const crop = {
- quality: 100,
- width: 600,
- height: 600,
- resize: true
- };
-
- // 上传图片
- uni.chooseImage({
- count: 1,
- crop,
- success: async (res) => {
- //(res);
- let tempFile = res.tempFiles[0],
- avatar_file = {
- // #ifdef H5
- extname: tempFile.name.split('.')[tempFile.name.split('.').length - 1],
- // #endif
- // #ifndef H5
- extname: tempFile.path.split('.')[tempFile.path.split('.').length - 1]
- // #endif
- },
- filePath = res.tempFilePaths[0]
-
- // #ifndef APP-PLUS
- //(`filePath=${filePath}`)
-
- //非app端用前端组件剪裁头像,app端用内置的原生裁剪
- let fileData = await new Promise((callback) => {
- uni.navigateTo({
- url: '/pages/user/cropImage?path=' + filePath +
- `&options=${JSON.stringify(crop)}`,
- animationType: "fade-in",
- events: {
- success: url => {
- callback(url)
- }
- }
- });
- })
- // #endif
-
- //返回 base64 图片
- //(fileData);
-
- var token = _self.carhelp.getToken()
-
- uni.showLoading({
- title: '上传中'
- });
-
- uni.request({
- url: process.car.BASE_URL + "uploadBase64",
- method: 'POST',
- data: {
- photoBase64Data: fileData
- },
- header: {
- 'Authorization': token,
- 'content-type': 'application/x-www-form-urlencoded'
- },
- success: (res) => {
- let jsonData = res.data;
- _self.form.headImg = jsonData.data;
- _self.submit();
- uni.hideLoading();
- }
- });
- }
- });
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background-color: #fff;
- padding-bottom: 20px;
- }
- .userCell {
- .user {
- img {
- vertical-align: middle;
- }
- }
- .title {
- padding: 24px 20px 8px 20px;
- font-size: 18px;
- color: rgba(16, 16, 16, 100);
- }
- .userCell-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 11px 20px;
- .userCell-title {
- width: 125px;
- font-size: 16px;
- display: flex;
- p {
- margin-left: 8px;
- font-size: 16px;
- line-height: 28px;
- color: #333333;
- }
- }
- .userCell-content {
- display: flex;
- color: rgba(153, 153, 153, 100);
- font-size: 16px;
- line-height: 20px;
-
- }
-
- .value {
- display: flex;
- .text {
- line-height: 28px;
- }
- .circle {
- width: 40px;
- height: 40px;
- }
- .u-avatar {
- position: absolute;
- }
- .camera {
- width: 20px;
- height: 20px;
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- z-index: 9999;
- }
- .box {
- border-radius: 999px;
- height: 40px;
- width: 40px;
- position: relative;
-
- background-repeat: no-repeat;
- background-position: 30% 10%;
- background-size: cover;
- }
- }
- .u-switch {
- width: 48px;
- height: 24px;
- vertical-align: middle;
- margin-left: 8px;
- }
- ::v-deep.u-switch__node {
- width: 24px !important;
- height: 24px !important;
- }
- span {
- color: #999;
- }
- .add {
- color: #999;
- }
- .black {
- color: #666666;
- }
- }
- }
- .exit {
- color: rgba(238, 49, 56, 100);
- font-size: 16px;
- text-align: center;
- margin-top: 10px;
- }
- .warp {
- position: fixed;
- left: 0;
- bottom: 0;
- width: 100%;
- }
- .rect {
- width: 100%;
- height: 100%;
- background-color: #fff;
- padding: 24px 0;
- p {
- color: rgba(16, 16, 16, 100);
- font-size: 16px;
- line-height: 24px;
- padding: 0 24px;
- }
- textarea {
- width: 87.2%;
- border-radius: 8px;
- background-color: rgba(229, 231, 234, 100);
- margin: 12px auto 0;
- height: 44px;
- line-height: 44px !important;
- padding: 0 8px;
- position: relative;
- }
- .canc {
- width: 20px;
- height: 20px;
- position: absolute;
- top: 70px;
- right: 7vw;
- }
- .u-btn {
- width: 89.2%;
- color: rgba(255, 255, 255, 100);
- font-size: 18px;
- border-radius: 8px;
- margin-top: 24px;
- z-index: 99999;
- }
- }
- ::v-deep.u-line{
- transform: scaleY(0.1) !important;
- }
-
-
- .position {
- position: relative;
- top: -66px;
- left: 54%;
- z-index: 999;
- width: 138px;
- }
-
- #talkbubble {
-
- top: 0;
- left: 0;
- padding: 0 5px;
- line-height: 20px;
- font-size: 12px;
- color: #fff;
- background: red;
- position: relative;
- border-radius: 4px;
- text-align: center;
- }
-
- #talkbubble:before {
- content: "";
- position: absolute;
- top: 100%;
- right: 25%;
- border-top: 5px solid red;
- border-right: 5px solid transparent;
- border-left: 5px solid transparent;
- }
- </style>
|