123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <template>
- <view class="content">
- <view class="row b-b">
- <text class="tit">昵称</text>
- <input class="input" type="text" v-model="name" placeholder="修改昵称" placeholder-class="placeholder" />
- </view>
- <view class="row b-b">
- <text class="tit">生日</text>
- <picker mode="date" @change="bindDateChange">
- <input class="input" type="text" v-model="date" placeholder="请选择日期" placeholder-class="placeholder" />
- </picker>
- </view>
- <view class="row b-b">
- <text class="tit">手机</text>
- <input class="input" type="text" v-model="phone" placeholder="请填写手机号" placeholder-class="placeholder" />
- </view>
- <button class="add-btn" @click="confirm">提交</button>
- </view>
- </template>
- <script>
- import { mapState } from 'vuex';
- import { userEdit } from '@/api/set.js';
- export default {
- data() {
- const currentDate = this.getDate({
- format: true
- })
- return {
- name: '',
- phone: '',
- date: currentDate,
- };
- },
- computed: {
- ...mapState(['userInfo']),
- },
- onShow() {
- this.name = this.userInfo.nickname + '';
- this.phone = this.userInfo.phone||'';
- },
- methods: {
- bindDateChange: function(e) {
- this.date = e.target.value
- },
- getDate(type) {
- const date = new Date();
- let year = date.getFullYear();
- let month = date.getMonth() + 1;
- let day = date.getDate();
- if (type === 'start') {
- year = year - 60;
- } else if (type === 'end') {
- year = year + 2;
- }
- month = month > 9 ? month : '0' + month;;
- day = day > 9 ? day : '0' + day;
- return `${year}-${month}-${day}`;
- },
- // 数据处理结果
- onConfirm(val) {
- this.resultInfo = { ...val };
- this.birthday = this.resultInfo.result;
- },
- confirm() {
- userEdit({ nickname: this.name, avatar: this.userInfo.avatar, birthday: this.date, phone: this.phone })
- .then(e => {
- this.$api.msg('修改成功');
- setTimeout(() => {
- uni.switchTab({
- url: '/pages/user/user'
- });
- }, 1000);
- console.log(e);
- })
- .catch(e => {
- console.log(e);
- });
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background: $page-color-base;
- padding-top: 16upx;
- }
- .uni-picker{
-
- }
- .row {
- display: flex;
- align-items: center;
- position: relative;
- padding: 0 30upx;
- height: 110upx;
- background: #fff;
- .tit {
- flex-shrink: 0;
- width: 120upx;
- font-size: 30upx;
- color: $font-color-dark;
- }
- .input {
- flex: 1;
- font-size: 30upx;
- color: $font-color-dark;
- }
- .iconlocation {
- font-size: 36upx;
- color: $font-color-light;
- }
- }
- .add-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 690upx;
- height: 80upx;
- margin: 60upx auto;
- font-size: $font-lg;
- color: #fff;
- background-color: $base-color;
- border-radius: 10upx;
- }
- </style>
|