diff --git a/api/user.js b/api/user.js index 235ccbb..85a8199 100644 --- a/api/user.js +++ b/api/user.js @@ -23,12 +23,11 @@ export function login(data) { } -export function userDetail(data) { +export function userDetail() { return request({ url: `${host}/user/detail`, method: "post", - data }); } export function userExtends(data) { @@ -56,4 +55,16 @@ export function appletLogin(code){ code:code } }) +} + +/** + * 更新用户详情 + * @param data + */ +export function updateUserDetail(data){ + return request({ + url:"user/updateInfo", + method:'post', + data:data + }) } \ No newline at end of file diff --git a/pages/Card/index.vue b/pages/Card/index.vue index 1b4f7cf..8dd87cc 100644 --- a/pages/Card/index.vue +++ b/pages/Card/index.vue @@ -36,7 +36,7 @@ { + chatList(this.page, this.$store.state.userInfo.store_id > 0).then(res => { this.chatList.push.apply(this.chatList,res.data); if(res.data.length === 0){ this.status = 'nomore'; diff --git a/pages/Index/components/OrderPage/index.vue b/pages/Index/components/OrderPage/index.vue index 9557de3..3c1c03b 100644 --- a/pages/Index/components/OrderPage/index.vue +++ b/pages/Index/components/OrderPage/index.vue @@ -39,7 +39,7 @@ - + @@ -162,7 +162,6 @@ }, methods: { - selectScreen(item){ this.screenCheck = item.value; this.page = 1; diff --git a/pages/UserDetail/index.vue b/pages/UserDetail/index.vue index 6b3ed2d..dba2a39 100644 --- a/pages/UserDetail/index.vue +++ b/pages/UserDetail/index.vue @@ -15,26 +15,38 @@ 昵称 - {{user.nickname}} + + - + 生日 - {{user.birthday}} + + + 手机 - {{user.phone}} + + - + 性别 - {{user.sex}} + + + @@ -45,6 +57,9 @@ + + 修改信息 + 退出登录 @@ -63,19 +78,28 @@ } from '@/config/host.js' import api from '@/utils/functions.js'; import HeaderNav from '@/components/HeaderNav/Index.vue'; + import log from "@/utils/log"; + import {updateUserDetail, userDetail} from "@/api/user"; + import functions from "@/utils/functions.js"; export default { components:{ HeaderNav }, data: { + sexChecked:0, + sexTitle:'', + birthday:'', + show:false, + sexShow:false, + sexs:[[{title: '男', value: 1}, {title:'女', value:2}]], staticImage:{ wallpaperBgImage:imghost+'/static/image/background.png', }, user:{ avatar:imghost+'/static/image/banner.png', - nickname:'清晨的风', + name:'清晨的风', background:imghost+'/static/image/banner.png', - sex:'女', + sex:1, phone:'15012345678', coupons:221, id:88685, @@ -83,10 +107,43 @@ }, }, onLoad() { - + this.setSexTitle(); + this.getUserDetail(); }, methods: { - + getUserDetail(){ + userDetail().then(({ data }) => { + this.user = data; + this.birthday = this.user.birthday ? this.user.birthday : '2000-01-01' + this.user.birthday = this.birthday + this.user.sex = this.user.sex === 1 ? 1 : 2; + this.setSexTitle(this.user.sex); + }) + }, + sexConfirm(v){ + log(v); + this.user.sex = v.value[0].value; + this.setSexTitle(v.value[0].value); + }, + birthdayConfirm(v){ + this.birthday = uni.$u.timeFormat(v.value, 'yyyy-mm-dd'); + }, + submit(){ + if(this.user.birthday ){ + this.user.birthday = uni.$u.timeFormat(this.user.birthday, 'yyyy-mm-dd') + } + updateUserDetail(this.user).then((data) =>{ + uni.setStorageSync('user', data.data); + functions.success("修改成功").then(() =>{ + uni.navigateBack(); + }) + }); + }, + setSexTitle(v){ + log(v); + this.sexTitle = [0, '男', '女'][v ? v : this.user.sex]; + log(this.sexTitle); + } }, onPageScroll(res) {