Xiao_123 2 месяцев назад
Родитель
Сommit
2e19e0aaaf
4 измененных файлов с 171 добавлено и 15 удалено
  1. 13 0
      api/enterprise.js
  2. 6 0
      pages.json
  3. 5 15
      pages/index/my.vue
  4. 147 0
      pagesB/staffInfoEdit/index.vue

+ 13 - 0
api/enterprise.js

@@ -11,4 +11,17 @@ export const getHotEnterprise = (params) => {
       auth: false
     }
   })
+}
+
+// 更新员工信息
+export const updateStaffInfo = (data) => {
+  return request({
+    url: '/app-api/menduner/system/recruit/user/save',
+    method: 'POST',
+    data,
+    custom: {
+      showLoading: false,
+      auth: true
+    }
+  })
 }

+ 6 - 0
pages.json

@@ -100,6 +100,12 @@
 						"navigationBarTitleText": "协议中心"
 					}
 				},
+				{
+					"path": "staffInfoEdit/index",
+					"style": {
+						"navigationBarTitleText": "员工信息编辑"
+					}
+				},
 				{
 					"path": "agreement/user",
 					"style": {

+ 5 - 15
pages/index/my.vue

@@ -1,14 +1,14 @@
 <template>
   <layout-page>
 		<view class="pb-150">
-			<view class="text-center ss-p-b-30" :class="vip ? 'vipBox' : 'avatarBox'" @tap="handleTap">
+			<view class="text-center ss-p-b-30" :class="vip ? 'vipBox' : 'avatarBox'">
 				<img :src="getUserAvatar(userInfo?.avatar, userInfo?.sex)" alt="" class="img-box">
 				<image v-if="vip" src="/static/svg/vip.svg" class="vipIcon"></image>
 				<view v-if="!useUserStore.isLogin" class="font-weight-bold font-size-20">点击登录</view>
 				<view v-else>
 					<view>
 						<span class="font-weight-bold font-size-20">{{ userInfo?.name || userInfo?.phone }}</span>
-						<uni-icons @tap="handleEdit('')" class="ss-m-l-10" type="compose" :size="22"></uni-icons>
+						<uni-icons @tap="handleEdit('/pagesB/staffInfoEdit/index')" class="ss-m-l-10" type="compose" :size="22"></uni-icons>
 					</view>
 					<view style="color: #0E100F" class="ss-m-t-20">
 						<span>{{ formatName(userInfo?.enterpriseAnotherName || userInfo?.enterpriseName) }}</span>
@@ -142,23 +142,13 @@ const handleToLink = (item) => {
 }
 
 const handleEdit = (url) => {
-	// if (!useUserStore.isLogin) {
-	// 	showAuthModal()
-	// 	return
-	// }
-	// uni.navigateTo({
-	// 	url
-	// })
-}
-
-// 登录
-const handleTap = () => {
 	if (!useUserStore.isLogin) {
 		showAuthModal()
 		return
 	}
+	if (!url) return
 	uni.navigateTo({
-		url: '/pagesA/resumeOnline/index'
+		url
 	})
 }
 
@@ -170,7 +160,7 @@ const handleLogoutClose = () => {
   popup.value.close()
 }
 const handleLogoutConfirm = () => {
-	list.value = defaultList.filter(e => !e.hide) // 重置菜单
+	// list.value = defaultList.filter(e => !e.hide) // 重置菜单
   useUserStore.handleLogout()
 }
 </script>

+ 147 - 0
pagesB/staffInfoEdit/index.vue

@@ -0,0 +1,147 @@
+<template>
+	<view class="f-straight wrapper">
+		<uni-forms ref="form" :modelValue="formData" :rules="rules" validateTrigger="bind" label-width="80px" label-align="right">
+			<uni-forms-item label="头像" name="avatar" class="f-straight" required>
+        <view style="display: flex;flex-wrap: wrap;">
+          <view class="upload-img" v-if="formData?.avatar">
+            <uni-icons size="35" type="clear" color="#fe574a" style="position: absolute;right: -15px; top: -15px; z-index: 9" @click="formData.avatar = ''"></uni-icons>
+            <image :src="formData?.avatar" mode="contain" style="width: 200rpx;height: 200rpx;" @click="handlePreviewImage"></image>
+          </view>
+          <view v-else class="upload-file" @click="uploadPhotos">
+            <uni-icons type="plusempty" size="50" color="#f1f1f1"></uni-icons>
+          </view>
+        </view>
+			</uni-forms-item>
+			<uni-forms-item required label="用户名" name="name">
+        <uni-easyinput v-model="formData.name" placeholder="请输入用户名" />
+			</uni-forms-item>
+      <uni-forms-item label="联系电话" name="phone" clearable required>
+        <uni-easyinput v-model="formData.phone" placeholder="请输入电话号码" />
+			</uni-forms-item>
+      <uni-forms-item label="企业邮箱" name="email" clearable required>
+        <uni-easyinput disabled v-model="formData.email" placeholder="请输入您的企业邮箱" />
+			</uni-forms-item>
+			<uni-forms-item label="所属岗位" name="postName" clearable>
+        <uni-easyinput v-model="formData.postName" placeholder="请输入您所任职的岗位名称" />
+			</uni-forms-item>
+			<view class="f-horizon-center">
+				<button type="primary" size="default" class="send-button"  @click="submit">提 交</button>
+			</view>
+		</uni-forms>
+	</view>
+</template>
+
+<script setup>
+import { ref, unref } from 'vue'
+import { userStore } from '@/store/user'
+import { uploadFile } from '@/api/file'
+import { cloneDeep } from 'lodash-es'
+import { emailRequired } from '@/utils/validate'
+import { updateStaffInfo } from '@/api/enterprise'
+
+const form = ref()
+const useUserStore = userStore()
+
+const formData = ref({})
+const getInfo = () => {
+  formData.value = cloneDeep(useUserStore?.userInfo) || {
+    avatar: '',
+    name: '',
+    phone: '',
+    email: '',
+    postName: ''
+  }
+}
+getInfo()
+
+// 图片预览
+const handlePreviewImage = () => {
+  uni.previewImage({
+    current: 0,
+    urls: [formData.value.avatar]
+  })
+}
+
+// 选择头像
+const uploadPhotos = () => {
+  wx.chooseImage({
+    count: 1,
+    sizeType: ['original', 'compressed'],
+    sourceType: ['album', 'camera'],
+    success: function(res){
+      const size = res.tempFiles[0]?.size || 0
+      if (size >= 31457280) {
+        uni.showToast({
+          icon: 'none',
+          title: '头像上传大小不得超过 20MB !',
+          duration: 2000
+        })
+        return
+      }
+      const path = res.tempFilePaths[0]
+      uploadFile(path, 'img').then(res => {
+        formData.value.avatar = res.data
+      }).catch(error => {
+        uni.showToast({
+          icon: 'error',
+          title: '图片上传失败!',
+          duration: 2000
+        })
+      })
+    }
+  })
+}
+
+const rules = {
+	avatar:{
+		rules: [{required: true, errorMessage: '请上传头像' }]
+	},
+	name:{
+		rules: [{required: true, errorMessage: '请输入您的用户名' }]
+	},
+  email: emailRequired,
+  phone: {
+		rules: [{required: true, errorMessage: '请输入您的联系电话' }]
+	}
+}
+
+const submit = async () => {
+  const valid = await unref(form).validate()
+  if (!valid) return
+  await updateStaffInfo(formData.value)
+
+  uni.showToast({ title: '编辑成功', icon: 'success' })
+  await useUserStore.getUserInfos()
+  getInfo()
+  setTimeout(() => {
+		uni.navigateBack({
+			delta: 1
+		})
+	}, 1000)
+}
+</script>
+
+<style lang="less" scoped>
+
+.wrapper{
+	padding: 15px;
+  padding-top: 30px;
+}
+.upload-img{
+  position: relative;
+  width: 200rpx;
+  height: 200rpx;
+  border: 1px solid #f1f1f1;
+  margin: 10rpx;
+}
+.upload-file{
+  width: 200rpx;
+  height: 200rpx;
+  border: 1px solid #f1f1f1;
+  margin: 10rpx;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  border-radius: 10rpx;
+}
+</style>