wangguoyu 2 months ago
parent
commit
3a1f22a188

+ 12 - 0
api/jiazheng.js

@@ -11,3 +11,15 @@ export function getJiazhengList(data = {}) {
     timeout: 20000
   })
 }
+// 阿里云 上传
+export function getAliyunPolicy(data = {}) {
+  return request({
+    url: '/app/file/policy',
+    headers: {
+      isToken: false
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}

+ 3 - 3
pages/Login/components/loginBox.vue

@@ -32,7 +32,7 @@
 	import passwordLli from "@/components/password-lli/password-lli.vue";
 	import {ref} from "vue"
 	import {toast} from "@/utils/common";
-	const userName = ref('18604088413') // 用户名
+	const userName = ref('18640920672') // 用户名
 	const password = ref('') // 密码
 	const lliPassword = ref('') // 加密后的密码
 	const passLLiRef = ref(null)
@@ -116,14 +116,14 @@
 		// 客户端
 		// #ifdef H5
 		uni.navigateTo({
-			url: `/pages/client/ShouYe/shouye`
+			url: `/pages/admin/Jiazheng/index`
 		})
 		// #endif
 		
 		// 管理端
 		// #ifdef APP-PLUS
 		uni.navigateTo({
-			url: `/pages/admin/ShouYe/shouye`
+			url: `/pages/admin/Jiazheng/index`
 		})
 		// #endif
 

+ 142 - 0
pages/admin/Jiazheng/common/jiazhengUpload.vue

@@ -0,0 +1,142 @@
+<template>
+	<view class="upload-btn" @click="showActionSheet">
+		<text>+</text>
+
+	</view>
+	<viwe v-if="bottomText" class="bottom-text">
+		{{bottomText}}
+	</viwe>
+</template>
+
+<script>
+	import {
+		getAliyunPolicy
+	} from "@/api/jiazheng.js"
+	export default {
+		props: {
+			bottomText: { // 试题序号
+				type: String
+			}
+		},
+		methods: {
+			showActionSheet() {
+				uni.showActionSheet({
+					itemList: ['拍照', '从相册选择'],
+					success: (res) => {
+						if (res.tapIndex === 0) {
+							this.chooseImage('camera');
+						} else if (res.tapIndex === 1) {
+							this.chooseImage('album');
+						}
+					}
+				});
+			},
+			chooseImage(sourceType) {
+				uni.chooseImage({
+					count: 1, // 只能选择一张图片
+					sourceType: [sourceType], // 'camera' 或 'album'
+					success: (res) => {
+						const filePath = res.tempFilePaths[0];
+						this.uploadFileToAliyun(filePath);
+					}
+				});
+			},
+			uploadFileToAliyun(filePath) {
+				console.log('filePath', filePath);
+				const loading = uni.showLoading({
+					title: '上传中...',
+					mask: true
+				});
+
+				try {
+					const suffix = filePath.split('.').pop();
+					let req = {
+						prefix: 'resource/',
+						suffix: suffix
+					}
+
+					getAliyunPolicy(req).then(res => {
+						if (res.code == 0) {
+							const policyData = res.data;
+							console.log('policyData', policyData);
+							const formData = {
+								key: policyData.key,
+								policy: policyData.policy,
+								OSSAccessKeyId: policyData.accessid,
+								signature: policyData.signature,
+								success_action_status: '200',
+								file: {
+									name: policyData.key,
+									uri: filePath
+								}
+							};
+							uni.uploadFile({
+								url: policyData.uploadUrl,
+								filePath: filePath,
+								name: 'file',
+								formData: formData,
+								header: {
+									'Content-Type': 'multipart/form-data'
+								},
+								success(uploadRes) {
+									console.log('uploadRes', uploadRes);
+									if (uploadRes.statusCode === 200) {
+										const imageUrl = `${policyData.downloadUrl}/${policyData.key}`;
+										uni.showToast({
+											title: '上传成功',
+											icon: 'success'
+										});
+										console.log('imageUrl', imageUrl);
+										//this.$emit('getFileUrl', imageUrl);
+									} else {
+										uni.showToast({
+											title: '上传失败',
+										});
+										return false
+									}
+								},
+								fail(err) {
+									console.log('err', err);
+								}
+							});
+
+						} else {
+							uni.showToast({
+								title: '获取凭证失败',
+							});
+							return false
+						}
+					})
+				} catch (error) {
+					uni.showToast({
+						title: '上传失败',
+						icon: 'none'
+					});
+					console.error('上传失败:', error);
+				} finally {
+					uni.hideLoading();
+				}
+			},
+		}
+	};
+</script>
+<style scoped>
+	.upload-btn {
+		width: 100px;
+		height: 100px;
+		border: 1px dashed #ccc;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+		font-size: 24px;
+		color: #ccc;
+		margin: 5px;
+		border-radius: 5px;
+	}
+
+	.bottom-text {
+		font-size: 12px;
+		color: #bdbdbd;
+		
+	}
+</style>

+ 1 - 1
pages/admin/Jiazheng/jiazhengUserManager.vue

@@ -27,7 +27,7 @@
 	export default {
 		data() {
 			return {
-				current: 0,
+				current: 2,
 				tabs: ['个人资料', '求职信息', '照片资料', '办证信息']
 			}
 		},

+ 36 - 140
pages/admin/Jiazheng/zhaopianZiliao.vue

@@ -1,144 +1,40 @@
 <template>
-  <view class="image-upload">
-    <!-- 显示已选择的图片 -->
-    <view class="image-list">
-      <view v-for="(image, index) in imageList" :key="index" class="image-item">
-        <image :src="image" mode="aspectFill" class="image"></image>
-        <view class="delete-btn" @click="deleteImage(index)">×</view>
-      </view>
-    </view>
-
-    <!-- 选择图片按钮 -->
-    <view class="upload-btn" @click="chooseImage">
-      <text>+</text>
-    </view>
-  </view>
+	<view>
+		<view>
+			<jiazhengUpload bottomText="上传头像和生活照"></jiazhengUpload>
+		</view>
+		<view>
+			<view>
+				身份证照片
+			</view>
+			<switch @change="switchChange" />
+		</view>
+	</view>
 </template>
 
 <script>
-export default {
-  data() {
-    return {
-      imageList: [], // 存储已选择的图片路径
-    };
-  },
-  methods: {
-    // 打开相册选择图片
-    chooseImage() {
-      uni.chooseImage({
-        count: 9, // 最多可以选择 9 张图片
-        sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图
-        sourceType: ['album'], // 仅从相册选择
-        success: (res) => {
-          // 将选择的图片路径添加到 imageList 中
-          this.imageList = this.imageList.concat(res.tempFilePaths);
-        },
-        fail: (err) => {
-          console.error('选择图片失败', err);
-          uni.showToast({
-            title: '选择图片失败',
-            icon: 'none',
-          });
-        },
-      });
-    },
-
-    // 删除图片
-    deleteImage(index) {
-      this.imageList.splice(index, 1);
-    },
-
-    // 上传图片
-    uploadImages() {
-      if (this.imageList.length === 0) {
-        uni.showToast({
-          title: '请先选择图片',
-          icon: 'none',
-        });
-        return;
-      }
-
-      // 遍历 imageList 上传每张图片
-      this.imageList.forEach((imagePath) => {
-        uni.uploadFile({
-          url: 'https://your-upload-url.com/upload', // 替换为你的上传接口地址
-          filePath: imagePath,
-          name: 'file', // 文件对应的 key
-          formData: {
-            // 可以添加额外的表单数据
-            userId: '123',
-          },
-          success: (uploadRes) => {
-            console.log('上传成功', uploadRes);
-            uni.showToast({
-              title: '上传成功',
-              icon: 'success',
-            });
-          },
-          fail: (err) => {
-            console.error('上传失败', err);
-            uni.showToast({
-              title: '上传失败',
-              icon: 'none',
-            });
-          },
-        });
-      });
-    },
-  },
-};
-</script>
-
-<style scoped>
-.image-upload {
-  display: flex;
-  flex-wrap: wrap;
-}
-
-.image-list {
-  display: flex;
-  flex-wrap: wrap;
-}
-
-.image-item {
-  position: relative;
-  width: 100px;
-  height: 100px;
-  margin: 5px;
-}
-
-.image {
-  width: 100%;
-  height: 100%;
-  border-radius: 5px;
-}
-
-.delete-btn {
-  position: absolute;
-  top: 0;
-  right: 0;
-  width: 20px;
-  height: 20px;
-  background-color: rgba(0, 0, 0, 0.5);
-  color: white;
-  border-radius: 50%;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  font-size: 16px;
-  cursor: pointer;
-}
-
-.upload-btn {
-  width: 100px;
-  height: 100px;
-  border: 1px dashed #ccc;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  font-size: 24px;
-  color: #ccc;
-  margin: 5px;
-  border-radius: 5px;
-}
-</style>
+	import {
+		getAliyunPolicy
+	} from "@/api/jiazheng.js"
+	import jiazhengUpload from "./common/jiazhengUpload.vue"
+
+	export default {
+		data() {
+
+			return {
+				bottomText: 'bottomTextbottomTextbottomTextbottomText'
+			}
+		},
+		components: {
+			jiazhengUpload
+		},
+		methods: {
+			switchChange(data) {
+				console.log('data',data);
+			}
+		},
+		created() {
+
+		},
+	};
+</script>