|
|
|
@ -18,14 +18,14 @@ |
|
|
|
|
</view> |
|
|
|
|
<view class="flex ai-c jc-sb p15 bb1"> |
|
|
|
|
<view class="fs14">性别</view> |
|
|
|
|
<view class="flex" @tap="showPicker"> |
|
|
|
|
<text class="cor-666">{{ form.sex || '请选择性别' }}</text> |
|
|
|
|
<view class="flex" @tap="showSexPicker"> |
|
|
|
|
<text class="cor-666">{{ ['男', '女'][form.sex] || '请选择性别' }}</text> |
|
|
|
|
<u-icon name="arrow-right" size="16" class="ml10"></u-icon> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="flex ai-c jc-sb p15 bb1"> |
|
|
|
|
<view class="fs14">生日</view> |
|
|
|
|
<view class="flex" @tap="showPicker"> |
|
|
|
|
<view class="flex" @tap="showDate = true"> |
|
|
|
|
<text class="cor-666">{{ form.birthday || '请选择出生日期' }}</text> |
|
|
|
|
<u-icon name="arrow-right" size="16" class="ml10"></u-icon> |
|
|
|
|
</view> |
|
|
|
@ -39,18 +39,21 @@ |
|
|
|
|
<view class="p15 mt20"> |
|
|
|
|
<u-button type="primary" @tap="submit">保存</u-button> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<u-datetime-picker :show="showDate" mode="date" closeOnClickOverlay v-model="form.birthday" :minDate="Number(new Date('1900-01-01'))" @confirm="confirmDate" @cancel="showDate=false"></u-datetime-picker> |
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
// import { updateUserInfo } from '@/jtools/api/user' |
|
|
|
|
import { updateUserInfo } from '@/jtools/api/user' |
|
|
|
|
import useUserStore from '@/jtools/store/user' //引入store |
|
|
|
|
export default { |
|
|
|
|
name: 'UserInfo', |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
form: {...useUserStore().userInfo}, |
|
|
|
|
form: {...useUserStore().userInfo, sex: useUserStore().userInfo.sex || 0}, |
|
|
|
|
saving: false, |
|
|
|
|
showDate: false |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
@ -77,22 +80,35 @@ import useUserStore from '@/jtools/store/user' //引入store |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
uploadAvatar(url) { |
|
|
|
|
const _this = this |
|
|
|
|
uni.uploadFile({ |
|
|
|
|
url: import.meta.env.VITE_UPLOAD_URL + 'wrj-api/system/file/upload', // 仅为示例,非真实的接口地址 |
|
|
|
|
url: import.meta.env.VITE_UPLOAD_URL + 'sinology-api/system/file/upload', // 仅为示例,非真实的接口地址 |
|
|
|
|
filePath: url, |
|
|
|
|
name: 'file', |
|
|
|
|
success: (res) => { |
|
|
|
|
// setTimeout(() => { |
|
|
|
|
// resolve(JSON.parse(res.data).data); |
|
|
|
|
// }, 100); |
|
|
|
|
console.log(JSON.parse(res.data).data); |
|
|
|
|
|
|
|
|
|
_this.form.avatar = JSON.parse(res.data).data |
|
|
|
|
this.saving = false; |
|
|
|
|
}, |
|
|
|
|
fail: () => { |
|
|
|
|
resolve(null); |
|
|
|
|
uni.showToast({ title: '上传失败', icon: 'none' }); |
|
|
|
|
this.saving = false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
showSexPicker() { |
|
|
|
|
uni.showActionSheet({ |
|
|
|
|
itemList: ['男', '女'], |
|
|
|
|
success: (res) => { |
|
|
|
|
this.form.sex = res.tapIndex |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
confirmDate(e) { |
|
|
|
|
this.showDate = false; |
|
|
|
|
this.form.birthday = uni.$u.timeFormat(e.value, 'yyyy-mm-dd'); |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|