...
This commit is contained in:
@@ -10,6 +10,7 @@ enum URL {
|
||||
login = '/wc/wechat/LoginByMa',
|
||||
loginByCode = '/wc/wechat/LoginByMaCode',
|
||||
register = '/wc/wechat/register',
|
||||
uploadAvatar = '/wc/wechat/uploadImage',
|
||||
logout = '/user/logout',
|
||||
profile = '/user/profile',
|
||||
addressList = '/ext/addr/list',
|
||||
|
@@ -7,10 +7,10 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class='goods-list' :scroll-y='true' type='custom'>
|
||||
<grid-view type='masonry' :cross-axis-count='2'>
|
||||
<scroll-view class='goods-list'>
|
||||
<grid-view :cross-axis-count='2'>
|
||||
<view v-for='(item, index) in goodsList' :key='index' class='goods-item'
|
||||
@click.stop='goPath(`/pages/mall/subs/goods/goods-detail?goodsId=${item.goodsId}`)'>
|
||||
@click.stop='goPath(`/pages/mall/subs/goods/detail?goodsId=${item.goodsId}`)'>
|
||||
<image class='goods-image' :src='item.images' />
|
||||
<text class='goods-name'>{{ item.goodsName }}</text>
|
||||
<text class='goods-price'>¥{{ item.price }}</text>
|
||||
@@ -72,6 +72,7 @@ const goodsList = ref<GoodsBean[]>([1, 2, 3, 4, 1, 2, 2, 2]);
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
padding: 10rpx 10rpx;
|
||||
background: #333333;
|
||||
flex: 1;
|
||||
|
||||
.goods-image {
|
||||
|
@@ -21,15 +21,7 @@ const addressList = ref<{
|
||||
mobile: string,
|
||||
address: string,
|
||||
status: number
|
||||
}[]>([{
|
||||
name: '黄先生',
|
||||
mobile: '13xxxxxx8900',
|
||||
status: 1
|
||||
}, {
|
||||
name: '李先生',
|
||||
mobile: '13xxxxxx8900',
|
||||
status: 0
|
||||
}]);
|
||||
}[]>([]);
|
||||
|
||||
onLoad((e) => {
|
||||
fetchAddressList();
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<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>{{ userInfo.nickName }}</text>
|
||||
<text>会员卡</text>
|
||||
</view>
|
||||
|
||||
@@ -12,19 +12,19 @@
|
||||
<text>头像</text>
|
||||
<view class='avatar-view'>
|
||||
<image class='avatar-image' :src='userInfo.image' />
|
||||
<button class='avatar-btn' open-type='chooseAvatar' />
|
||||
<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 placeholder='请输入姓名' type='nickname' v-model='userInfo.nickName' @input='bindNickname' />
|
||||
</view>
|
||||
|
||||
<view class='divider' />
|
||||
<view class='c-flex-row'>
|
||||
<text>手机号</text>
|
||||
<input placeholder='15523653265' v-model='userInfo.telephone'/>
|
||||
<input placeholder='请输入手机号' v-model='userInfo.telephone' @input='bindTelephone' />
|
||||
</view>
|
||||
|
||||
<view class='divider' />
|
||||
@@ -51,25 +51,75 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class='primary-button'>保存</button>
|
||||
<button class='primary-button' @click.stop='save'>保存</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import { useUserStore } from '@/store';
|
||||
import { showToast } from '@/utils';
|
||||
|
||||
const store= useUserStore()
|
||||
const {userInfo} = storeToRefs(store)
|
||||
const store = useUserStore();
|
||||
const { userInfo } = storeToRefs(store);
|
||||
|
||||
const currentGender = ref<number>(0);
|
||||
|
||||
const changeGender = (index: number) => {
|
||||
currentGender.value = index;
|
||||
const chooseAvatar = (e: any) => {
|
||||
uni.showLoading();
|
||||
uni.uploadFile({
|
||||
url: import.meta.env.VITE_APP_BASE_API + '/wc/wechat/uploadImage',
|
||||
filePath: e.detail.avatarUrl,
|
||||
name: 'fileName',
|
||||
header: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
success: (res: any) => {
|
||||
userInfo.value.image = JSON.parse(res.data).data;
|
||||
},
|
||||
error: (err: any) => {
|
||||
showToast('上传失败');
|
||||
},
|
||||
complete() {
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const bindNickname = (e: any) => {
|
||||
userInfo.value.nickName = e.detail.value;
|
||||
};
|
||||
|
||||
const bindTelephone = (e: any) => {
|
||||
userInfo.value.telephone = e.detail.value;
|
||||
};
|
||||
|
||||
const changeGender = (index: number) => {
|
||||
currentGender.value = index;
|
||||
userInfo.value.gender = index;
|
||||
};
|
||||
|
||||
|
||||
const changeDate = (e: any) => {
|
||||
console.log(e);
|
||||
userInfo.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);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
@@ -8,13 +8,17 @@ const useUserStore = defineStore('user', {
|
||||
state: (): UserState => <UserState>({
|
||||
id: '',
|
||||
unionId: '',
|
||||
openId: '',
|
||||
maOpenId: '',
|
||||
name: '未登录',
|
||||
nickName: '未登录',
|
||||
image: '',
|
||||
telephone: '',
|
||||
gender: 0,
|
||||
balance: 0,
|
||||
integration: 0,
|
||||
birthday: '',
|
||||
creatorId: '',
|
||||
companyId: ''
|
||||
}),
|
||||
|
||||
|
@@ -27,7 +27,7 @@ export function mpUpdate() {
|
||||
});
|
||||
}
|
||||
|
||||
export function showToast(title: string, icon: 'none' | 'success' | 'loading' | 'error' | 'fail' | 'exception' | undefined, duration: number = 2000) {
|
||||
export function showToast(title: string, icon: 'none' | 'success' | 'loading' | 'error' | 'fail' | 'exception' | undefined = 'none', duration: number = 2000) {
|
||||
uni.showToast({
|
||||
title,
|
||||
icon,
|
||||
|
Reference in New Issue
Block a user