购物车逻辑完善
个人信息存储优化 团购下单
This commit is contained in:
@@ -3,22 +3,22 @@
|
||||
<view class='top-card-view'>
|
||||
<image class='bg-image' :src='assetsUrl("test_bg.png")' />
|
||||
<image class='avatar-image' :src='userInfo.image' />
|
||||
<text>{{ userInfo.nickName }}</text>
|
||||
<text>会员卡</text>
|
||||
<text>{{ userInfo.name }}</text>
|
||||
<text>{{ userInfo.levelName }}</text>
|
||||
</view>
|
||||
|
||||
<view class='basic-info-view c-flex-column'>
|
||||
<view class='c-flex-row'>
|
||||
<text>头像</text>
|
||||
<view class='avatar-view'>
|
||||
<image class='avatar-image' :src='userInfo.image' />
|
||||
<image class='avatar-image' :src='params.avatarUrl' />
|
||||
<button class='avatar-btn' open-type='chooseAvatar' @chooseavatar='chooseAvatar' />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='c-flex-row'>
|
||||
<text class='nickname'>姓名</text>
|
||||
<input placeholder='请输入姓名' type='nickname' v-model='userInfo.nickName' @input='bindNickname' />
|
||||
<input placeholder='请输入姓名' type='nickname' v-model='userInfo.nickName' @change='bindNickname' />
|
||||
</view>
|
||||
|
||||
<view class='divider' />
|
||||
@@ -32,12 +32,12 @@
|
||||
<text>性别</text>
|
||||
<view class='c-flex-row' @click.stop='changeGender(0)'>
|
||||
<image class='gender-image'
|
||||
:src='assetsUrl(currentGender==0?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
|
||||
:src='assetsUrl(params?.gender==0?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
|
||||
<text class='gender-text'>男</text>
|
||||
</view>
|
||||
<view class='c-flex-row' @click.stop='changeGender(1)'>
|
||||
<image class='gender-image'
|
||||
:src='assetsUrl(currentGender==1?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
|
||||
:src='assetsUrl(params?.gender==1?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
|
||||
<text class='gender-text'>女</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -46,7 +46,7 @@
|
||||
<view class='c-flex-row'>
|
||||
<text>生日</text>
|
||||
<picker mode='date' @change='changeDate'>
|
||||
<text>{{ userInfo.birthday || '请选择生日' }}</text>
|
||||
<text>{{ params?.birthday || '请选择生日' }}</text>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
@@ -63,7 +63,21 @@ import { showToast } from '@/utils';
|
||||
const store = useUserStore();
|
||||
const { userInfo } = storeToRefs(store);
|
||||
|
||||
const currentGender = ref<number>(0);
|
||||
const params = ref<{
|
||||
avatarUrl: string;
|
||||
image: string;
|
||||
nickName: string;
|
||||
telephone: string;
|
||||
gender: number;
|
||||
birthday: string;
|
||||
}>({
|
||||
avatarUrl: userInfo.value.image,
|
||||
image: userInfo.value.image,
|
||||
nickName: userInfo.value.nickName,
|
||||
telephone: userInfo.value.telephone,
|
||||
gender: userInfo.value.gender,
|
||||
birthday: userInfo.value.birthday
|
||||
});
|
||||
|
||||
onLoad(() => {
|
||||
store.getProfile();
|
||||
@@ -79,7 +93,8 @@ const chooseAvatar = (e: any) => {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
success: (res: any) => {
|
||||
userInfo.value.image = JSON.parse(res.data).data;
|
||||
params.value!.avatarUrl = JSON.parse(res.data).data;
|
||||
params.value!.image = JSON.parse(res.data).data;
|
||||
},
|
||||
error: (err: any) => {
|
||||
showToast('上传失败');
|
||||
@@ -91,40 +106,30 @@ const chooseAvatar = (e: any) => {
|
||||
};
|
||||
|
||||
const bindNickname = (e: any) => {
|
||||
userInfo.value.nickName = e.detail.value;
|
||||
console.log('---------->>>>', e.detail.value);
|
||||
params.value!.nickName = e.detail.value;
|
||||
};
|
||||
|
||||
const bindTelephone = (e: any) => {
|
||||
userInfo.value.telephone = e.detail.value;
|
||||
params.value!.telephone = e.detail.value;
|
||||
};
|
||||
|
||||
const changeGender = (index: number) => {
|
||||
currentGender.value = index;
|
||||
userInfo.value.gender = index;
|
||||
params.value!.gender = index;
|
||||
};
|
||||
|
||||
const changeDate = (e: any) => {
|
||||
userInfo.value.birthday = e.detail.value;
|
||||
params.value!.birthday = e.detail.value;
|
||||
};
|
||||
|
||||
const save = async () => {
|
||||
// const registerForm = {
|
||||
// unionId: userInfo.value.unionId,
|
||||
// openId: userInfo.value.openId,
|
||||
// maOpenId: userInfo.value.maOpenId,
|
||||
// image: userInfo.value.image,
|
||||
// nickName: userInfo.value.nickName,
|
||||
// telephone: userInfo.value.telephone,
|
||||
// birthday: userInfo.value.birthday,
|
||||
// gender: userInfo.value.gender,
|
||||
// companyId: userInfo.value.companyId,
|
||||
// creatorId: userInfo.value.creatorId
|
||||
// };
|
||||
// console.log('--------_>>>userInfo.value ', userInfo.value);
|
||||
// const result = await store.userRegister(registerForm);
|
||||
// console.log('--------->>>', result);
|
||||
|
||||
store.setUserInfo(userInfo.value)
|
||||
console.log('---------->>>>', params.value);
|
||||
const newUserInfo = {
|
||||
...userInfo.value,
|
||||
...params.value
|
||||
};
|
||||
console.log('---------->>>>', newUserInfo);
|
||||
store.setUserInfo(newUserInfo);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user