| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <template>
- <view class="content">
- <view class="row1">
- <text class="tit">头像</text>
- <view class="background-img"><image class="background-img" v-model="avatar" :src="avatar" mode="aspectFill"></image></view>
- </view>
- <view class="row">
- <text class="tit">昵称</text>
- <input class="input" type="button" v-model="name" placeholder-class="placeholder" />
- </view>
- <!-- <view class="row">
- <text class="tit">姓名</text>
- <input class="input" type="button" v-model="real_name" placeholder-class="placeholder" />
- </view> -->
-
- <!-- <view class="row">
- <text class="tit">性别</text>
- <picker @change="bindPickerChange" :value="index" :range="array" class="input">
- <text>{{ sex }}</text>
- </picker>
- </view>
- <view class="row">
- <text class="tit">生日</text>
- <picker @change="bindDateChange" mode="date" :value="birthday" :start="startDate" :end="endDate" class="input">
- <text>{{ birthday }}</text>
- </picker>
- </view> -->
- <view class="row">
- <text class="tit">邀请码</text>
- <input class="input" disabled type="text" v-model="uid" placeholder-class="placeholder" />
- </view>
- <!-- <view class="row">
- <text class="tit1">身份证号</text>
- <input class="input" type="button" v-model="card_id" placeholder-class="placeholder" />
- </view> -->
- <button class="add-btn" @click="confirm">修改</button>
- </view>
- </template>
- <script>
- import { mapState } from 'vuex';
- import { userEdit } from '@/api/set.js';
- // import { upload } from '@/api/ask.js';
- import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
- import wPicker from '@/components/w-picker/w-picker.vue';
- export default {
- data() {
- return {
- name: '', // 昵称
- real_name:'', // 真实姓名
- sex: '',
- array: ['男', '女'],
- index: 0,
- birthday: '',
- birthdaynum: 0,
- date: '',
- uid: '',
- card_id:'',
- avatar: '',
- resultInfo: {
- result: '2019-12-20 10:00:00'
- },
- year: ''
- };
- },
- components: {
- wPicker,
- pickerAddress
- },
- computed: {
- ...mapState(['userInfo']),
- startDate() {
- console.log('start');
- },
- endDate() {
- console.log('end');
- }
- },
- onShow(option) {
- // 获取生日日期
- let date = new Date(this.userInfo.birthday * 1000);
- let month = date.getMonth() + 1; //获取月份
- let day = date.getDate();
- this.name = this.userInfo.nickname + '';
- this.uid = this.userInfo.uid || '';
- this.real_name = this.userInfo.real_name || '';
- this.avatar = this.userInfo.avatar || '';
- this.card_id = this.userInfo.card_id || '';
- this.birthday = date.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
- this.year = new Date().getFullYear();
- let sex;
- if (this.userInfo.sex == 0) {
- sex = '未知';
- } else if (this.userInfo.sex == 1) {
- sex = '男';
- } else {
- sex = '女';
- }
- this.sex = sex; //性别赋值
- },
- methods: {
- // 上传头像
- upload() {
- upload({
- filename: ''
- }).then(data => {
- this.avatar = data[0].url;
- console.log(this.avatar, 'tup')
- setTimeout(() => {
- uni.hideLoading()
- }, 500)
- });
- },
- bindDateChange: function(e) {
- this.birthday = e.detail.value;
- this.birthdaynum = new Date(e.detail.value).getTime() / 1000;
- },
- bindPickerChange: function(e) {
- this.sex = this.array[e.target.value];
- this.index = e.target.value + 1;
- },
- // 显示日期选择器
- // toggleTab(str) {
- // this.$refs[str].show();
- // },
- // 数据处理结果
- onConfirm(val) {
- //如果页面需要调用多个mode类型,可以根据mode处理结果渲染到哪里;
- // switch(this.mode){
- // case "date":
- // break;
- // }
- this.resultInfo = { ...val };
- this.birthday = this.resultInfo.result;
- },
- switchChange(e) {
- this.addressData.default = e.value;
- },
- confirm() {
- userEdit({
- nickname: this.name,
- avatar: this.avatar,
- card_id:this.card_id,
- real_name:this.real_name
- }).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;
- }
- .row1 {
- display: flex;
- align-items: center;
- justify-content: space-between;
- position: relative;
- padding: 0 30upx;
- height: 110upx;
- background: #fff;
- margin-bottom: 20upx;
- .tit {
- flex-shrink: 0;
- width: 120upx;
- font-size: $font-lg;
- color: $font-color-dark;
- }
-
- .background-img {
- width: 80rpx;
- height: 80rpx;
- border-radius: 50%;
- background: #f2f2f2;
- }
- }
- .row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- position: relative;
- padding: 0 30upx;
- height: 110upx;
- background: #fff;
- .tit {
- flex-shrink: 0;
- width: 120upx;
- font-size: $font-lg;
- color: $font-color-dark;
- }
- .tit1 {
- flex-shrink: 0;
- width: 150upx;
- font-size: $font-lg;
- color: $font-color-dark;
-
- }
- .input {
- flex: 1;
- font-size: $font-base;
- color: $color-gray;
- }
- .iconlocation {
- font-size: 36upx;
- color: $font-color-light;
- }
- }
- .add-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 560upx;
- height: 80upx;
- margin: 60upx auto;
- font-size: $font-lg;
- color: #fff;
- background: #FF0000;
- border-radius: 40upx;
- }
- </style>
|