购物车逻辑完善
个人信息存储优化 团购下单
This commit is contained in:
@@ -2,20 +2,21 @@
|
||||
<view class='content'>
|
||||
<view class='c-flex-row'>
|
||||
<text>收货人</text>
|
||||
<input placeholder='请输入收货人姓名' />
|
||||
<input placeholder='请输入收货人姓名' @input='bindConsignee' />
|
||||
</view>
|
||||
|
||||
<view class='divider' />
|
||||
<view class='c-flex-row'>
|
||||
<text>手机号</text>
|
||||
<input placeholder='请输入收货人手机号' maxlength='11' />
|
||||
<input placeholder='请输入收货人手机号' @input='bindMobile' :maxlength='11' />
|
||||
</view>
|
||||
|
||||
<view class='divider' />
|
||||
<view class='c-flex-row detail-row'>
|
||||
<text>详细地址</text>
|
||||
<view class='c-flex-column'>
|
||||
<textarea placeholder='详细地址:如街道、门牌\n号、楼栋号、单元室等' />
|
||||
<textarea placeholder='详细地址:如街道、门牌\n号、楼栋号、单元室等'
|
||||
@input='bindAddress' />
|
||||
<view class='tips-view c-flex-row'>
|
||||
<image :src='assetsUrl("ic_tips.png")' />
|
||||
<text>记得完善门牌号</text>
|
||||
@@ -27,7 +28,8 @@
|
||||
<view class='c-flex-column'>
|
||||
<text style='width: auto'>设为默认地址</text>
|
||||
<text style='width: auto'>提醒:每次下单会默认推荐使用该地址</text>
|
||||
<switch color='#F32B2B' />
|
||||
<!-- @change='ev=>{params.defaultstatus = ev.detail.value}'-->
|
||||
<switch color='#F32B2B' @change='bindStatus' />
|
||||
</view>
|
||||
|
||||
<view class='bottom-button-view'>
|
||||
@@ -41,16 +43,40 @@
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import { addressCreate } from '@/api/user';
|
||||
|
||||
const params = ref<{
|
||||
name: string,
|
||||
mobile: string,
|
||||
zonecode: string,
|
||||
addr: string,
|
||||
defaultstatus: number
|
||||
}>({
|
||||
name: '',
|
||||
mobile: '',
|
||||
zonecode: '',
|
||||
addr: '',
|
||||
defaultstatus: 0
|
||||
});
|
||||
|
||||
const bindConsignee = (e: any) => {
|
||||
params.value.name = e.detail.value;
|
||||
};
|
||||
|
||||
const bindMobile = (e: any) => {
|
||||
params.value.mobile = e.detail.value;
|
||||
};
|
||||
|
||||
const bindAddress = (e: any) => {
|
||||
params.value.addr = e.detail.value;
|
||||
};
|
||||
|
||||
const bindStatus = (e: any) => {
|
||||
params.value.defaultstatus = e.detail.value == true ? 1 : 0;
|
||||
};
|
||||
|
||||
const save = () => {
|
||||
addressCreate(
|
||||
{
|
||||
bean: {
|
||||
'name': '高昂',
|
||||
'mobile': '15475655487',
|
||||
'zonecode': '420101001001',
|
||||
'addr': '肯德基挂',
|
||||
'defaultstatus': 1
|
||||
}
|
||||
bean: params.value
|
||||
}
|
||||
).then(() => {
|
||||
uni.showToast({
|
||||
|
@@ -24,6 +24,10 @@ const addressList = ref<{
|
||||
}[]>([]);
|
||||
|
||||
onLoad((e) => {
|
||||
// fetchAddressList();
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
fetchAddressList();
|
||||
});
|
||||
|
||||
|
@@ -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