|
@@ -1,13 +1,79 @@
|
|
|
<template>
|
|
|
- <view class="info-container">
|
|
|
- <!--头像 + 背景-->
|
|
|
- <view class="user-section" :class="'bg-' + proxy.$settingStore.themeColor.name" :style="{ paddingTop: proxy.$settingStore.barHightTop }">
|
|
|
+ <view :data-theme="'theme-' + proxy.$settingStore.themeColor.name" class="info-container">
|
|
|
+ <u-sticky bgColor="#fff" style="box-shadow: 1px 1px 4px rgb(26 26 26 / 10%)">
|
|
|
+ <u-tabs
|
|
|
+ :list="tabsList"
|
|
|
+ :current="tabsCurrent"
|
|
|
+ @click="tabsClick"
|
|
|
+ lineColor="#333"
|
|
|
+ :activeStyle="{ color: '#333' }"
|
|
|
+ :inactiveStyle="{ color: '#909399' }"
|
|
|
+ :scrollable="false"
|
|
|
+ style="border-bottom: 1px solid #eaeef1"
|
|
|
+ ></u-tabs>
|
|
|
+ </u-sticky>
|
|
|
+
|
|
|
+ <view class="content-section" v-show="tabsCurrent == 0">
|
|
|
+ <view class="menu-list margin-top-0 margin-lr-0">
|
|
|
+ <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToAvatar(2)">
|
|
|
+ <view class="menu-item-box">
|
|
|
+ <view class="title">头像</view>
|
|
|
+ <image style="margin: 0 15px 0 auto" v-if="avatar" :src="avatar" class="cu-avatar radius"> </image>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="list-cell list-cell-arrow" @click="handleUserModal('修改昵称')">
|
|
|
+ <view class="menu-item-box">
|
|
|
+ <view class="title">昵称</view>
|
|
|
+ <view class="content" style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.nickName }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="list-cell list-cell-arrow" @click="handleUserModal('修改手机号')">
|
|
|
+ <view class="menu-item-box">
|
|
|
+ <view class="title">手机号码</view>
|
|
|
+ <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.phonenumber }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="list-cell list-cell-arrow" @click="handleUserModal('修改邮箱')">
|
|
|
+ <view class="menu-item-box">
|
|
|
+ <view class="title">邮箱</view>
|
|
|
+ <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.email }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleAbout()">
|
|
|
+ <view class="menu-item-box">
|
|
|
+ <view class="title">性别</view>
|
|
|
+ <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.sex == "0" ? "男" : "女" }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
|
|
|
+ <view class="menu-item-box">
|
|
|
+ <view class="title">我的名片</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="menu-list margin-top-0 margin-lr-0">
|
|
|
+ <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
|
|
|
+ <view class="menu-item-box">
|
|
|
+ <view>个人实名认证</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
|
|
|
+ <view class="menu-item-box">
|
|
|
+ <view>更多</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- <view class="user-section" :class="'bg-' + proxy.$settingStore.themeColor.name" :style="{ paddingTop: proxy.$settingStore.barHightTop }">
|
|
|
<image class="bg" src="@/static/images/mine/user-bg.png"></image>
|
|
|
<view class="portrait-box">
|
|
|
- <image v-if="!avatar" @click="handleToAvatar(1)" class="portrait" src="@/static/images/mine/missing-face.png"></image>
|
|
|
- <image v-if="avatar" @click="handleToAvatar(2)" :src="avatar" class="portrait cu-avatar xl round"> </image>
|
|
|
+ <image v-if="!avatar" @click="proxy.$settingStore.handleToAvatar(1)" class="portrait" src="@/static/images/mine/missing-face.png"></image>
|
|
|
+ <image v-if="avatar" @click="proxy.$settingStore.handleToAvatar(2)" :src="avatar" class="portrait cu-avatar xl round"> </image>
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
+
|
|
|
<!-- <uni-list>
|
|
|
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'person-filled' }" title="昵称" :rightText="user.nickName" />
|
|
|
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'phone-filled' }" title="手机号码" :rightText="user.phonenumber" />
|
|
@@ -17,7 +83,7 @@
|
|
|
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'calendar-filled' }" title="创建日期" :rightText="user.createTime" />
|
|
|
</uni-list> -->
|
|
|
|
|
|
- <view class="example">
|
|
|
+ <!-- <view class="example">
|
|
|
<uni-forms ref="form" :model="user" labelWidth="80px">
|
|
|
<uni-forms-item label="用户昵称" name="nickName">
|
|
|
<uni-easyinput v-model="user.nickName" placeholder="请输入昵称" />
|
|
@@ -33,17 +99,37 @@
|
|
|
</uni-forms-item>
|
|
|
</uni-forms>
|
|
|
<button type="primary" class="round text-dfl" @click="submit">修改资料</button>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
</view>
|
|
|
+
|
|
|
+ <u-modal :show="modalShow" :showConfirmButton="true" :showCancelButton="true" @cancel="modalShow = false" @confirm="handleConfirm">
|
|
|
+ <view class="slot-content" style="width: 100%">
|
|
|
+ <view class="margin-bottom-15" style="color: #909399">{{ modalTitle }}</view>
|
|
|
+
|
|
|
+ <view v-if="modalTitle === '修改昵称'">
|
|
|
+ <u--input v-model="userArr.nickName" :maxlength="5" :placeholder="modalTitle" border="bottom" clearable></u--input>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view v-if="modalTitle === '修改手机号'">
|
|
|
+ <u--input type="number" v-model="userArr.phonenumber" :maxlength="11" :placeholder="modalTitle" border="bottom" clearable></u--input>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view v-if="modalTitle === '修改邮箱'">
|
|
|
+ <u--input v-model="userArr.email" :placeholder="modalTitle" border="bottom" clearable></u--input>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </u-modal>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onLoad, onShow, onHide, onReady, onLaunch, onNavigationBarButtonTap } from "@dcloudio/uni-app";
|
|
|
-import { ref, shallowRef, reactive, computed, getCurrentInstance, toRefs, onMounted, inject } from "vue";
|
|
|
+import config from "@/config";
|
|
|
+import storage from "@/utils/storage";
|
|
|
+import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
|
|
|
+import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
|
|
|
+import { publicStores, useStores } from "@/store/modules/index";
|
|
|
|
|
|
-import { getUserProfile, uploadAvatar, updateUserProfile } from "@/api/system/user";
|
|
|
+import { updateUserProfile, getUserProfile } from "@/api/system/user";
|
|
|
|
|
|
-import useStores from "@/store/modules/user.js";
|
|
|
const useStore = useStores();
|
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
@@ -52,16 +138,36 @@ const avatar = computed(() => {
|
|
|
return useStore.$state.avatar;
|
|
|
});
|
|
|
|
|
|
+const user = computed(() => {
|
|
|
+ return useStore.$state.user;
|
|
|
+});
|
|
|
+
|
|
|
+const userArr = computed(() => {
|
|
|
+ return useStore.$state.userArr;
|
|
|
+});
|
|
|
+
|
|
|
+const postGroup = computed(() => {
|
|
|
+ return useStore.$state.postGroup;
|
|
|
+});
|
|
|
+
|
|
|
+const roleGroup = computed(() => {
|
|
|
+ return useStore.$state.roleGroup;
|
|
|
+});
|
|
|
+
|
|
|
const data = reactive({
|
|
|
- name: useStore.$state.name,
|
|
|
- version: getApp().globalData.config.appInfo.version,
|
|
|
-
|
|
|
- user: {
|
|
|
- nickName: "",
|
|
|
- phonenumber: "",
|
|
|
- email: "",
|
|
|
- sex: "",
|
|
|
- },
|
|
|
+ tabsList: [
|
|
|
+ {
|
|
|
+ name: "个人信息",
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // name: "其它信息",
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ name: "企业/团队",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ tabsCurrent: 0,
|
|
|
+
|
|
|
sexs: [
|
|
|
{
|
|
|
text: "男",
|
|
@@ -72,116 +178,91 @@ const data = reactive({
|
|
|
value: "1",
|
|
|
},
|
|
|
],
|
|
|
- rules: {
|
|
|
- nickName: {
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- errorMessage: "用户昵称不能为空",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- phonenumber: {
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- errorMessage: "手机号码不能为空",
|
|
|
- },
|
|
|
- {
|
|
|
- pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
|
|
- errorMessage: "请输入正确的手机号码",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- email: {
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- errorMessage: "邮箱地址不能为空",
|
|
|
- },
|
|
|
- {
|
|
|
- format: "email",
|
|
|
- errorMessage: "请输入正确的邮箱地址",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- },
|
|
|
+
|
|
|
+ modalShow: false,
|
|
|
+ modalTitle: "",
|
|
|
});
|
|
|
|
|
|
-const { user, sexs, rules } = toRefs(data);
|
|
|
+// .test(value)
|
|
|
+
|
|
|
+const { name, phone, tabsList, tabsCurrent, sexs, modalShow, modalTitle } = toRefs(data);
|
|
|
|
|
|
-const roleGroup = ref("");
|
|
|
-const postGroup = ref("");
|
|
|
const form = ref(null);
|
|
|
|
|
|
-/**
|
|
|
- * @点击头像
|
|
|
- */
|
|
|
-function handleToAvatar(type) {
|
|
|
- if (type == 1) {
|
|
|
- uni.chooseImage({
|
|
|
- count: 1, //默认9
|
|
|
- sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
|
|
|
- sourceType: ["album", "camera"], //从相册选择、摄像头
|
|
|
- success: function (res) {
|
|
|
- uploadApi(res);
|
|
|
- },
|
|
|
- });
|
|
|
- } else if (type == 2) {
|
|
|
- proxy.$tab.navigateTo("/pages/mine/avatar/index");
|
|
|
- }
|
|
|
+function handleUserModal(title) {
|
|
|
+ modalShow.value = true;
|
|
|
+ modalTitle.value = title;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * @upload上传头像
|
|
|
- * @api接口请求
|
|
|
- */
|
|
|
-function uploadApi(res) {
|
|
|
- let data = { name: "file", filePath: res.tempFilePaths[0] };
|
|
|
- uploadAvatar(data).then((response) => {
|
|
|
- useStore.$state.avatar = response.data.url;
|
|
|
- updateUserProfile({
|
|
|
- avatar: response.data.url,
|
|
|
- }).then(() => {});
|
|
|
- });
|
|
|
-}
|
|
|
+function handleConfirm() {
|
|
|
+ if (modalTitle.value == "修改昵称") {
|
|
|
+ if (!userArr.value.nickName) {
|
|
|
+ proxy.$modal.showToast("昵称不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (modalTitle.value == "修改手机号") {
|
|
|
+ if (!userArr.value.phonenumber) {
|
|
|
+ proxy.$modal.showToast("手机号码不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(userArr.value.phonenumber)) {
|
|
|
+ proxy.$modal.showToast("请输入正确的手机号码");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (modalTitle.value == "修改邮箱") {
|
|
|
+ if (!userArr.value.email) {
|
|
|
+ proxy.$modal.showToast("邮箱不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
-function getUser() {
|
|
|
- getUserProfile().then((response) => {
|
|
|
- user.value = response.data.user;
|
|
|
- roleGroup.value = response.roleGroup;
|
|
|
- postGroup.value = response.postGroup;
|
|
|
+ if (/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(userArr.value.email)) {
|
|
|
+ proxy.$modal.showToast("请输入正确的邮箱地址");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ updateUserProfile(userArr.value).then((response) => {
|
|
|
+ proxy.$tab.reLaunch("/pages/mine/index");
|
|
|
+ useStore.getUser();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function submit(ref) {
|
|
|
- form.value.validate().then((res) => {
|
|
|
- updateUserProfile(user.value).then((response) => {
|
|
|
- proxy.$modal.msgSuccess("修改成功,重新登录后生效!");
|
|
|
- proxy.$tab.reLaunch("pages/mine/index");
|
|
|
- });
|
|
|
- });
|
|
|
+function submit(ref) {}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @tabs点击事件
|
|
|
+ */
|
|
|
+function tabsClick(e) {
|
|
|
+ tabsCurrent.value = e.index;
|
|
|
}
|
|
|
|
|
|
onLoad((options) => {
|
|
|
- getUser();
|
|
|
+ useStore.getUser();
|
|
|
});
|
|
|
|
|
|
onReady(() => {
|
|
|
- form.value.setRules(rules.value);
|
|
|
+ // form.value.setRules(rules.value);
|
|
|
});
|
|
|
|
|
|
onShow(() => {
|
|
|
//调用系统主题颜色
|
|
|
proxy.$settingStore.systemThemeColor([1]);
|
|
|
});
|
|
|
+
|
|
|
+// 自定义导航事件
|
|
|
+onNavigationBarButtonTap((e) => {
|
|
|
+ if (e.float == "right") {
|
|
|
+ proxy.$tab.navigateTo("/pages/mine/setting/index");
|
|
|
+ }
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss">
|
|
|
-page {
|
|
|
- background-color: #ffffff;
|
|
|
-}
|
|
|
-</style>
|
|
|
+<style lang="scss" scoped></style>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
:deep(.uni-page-head__title) {
|