xiaohaizhao 1 year ago
parent
commit
52afc9ddc9
6 changed files with 238 additions and 60 deletions
  1. 3 2
      App.vue
  2. 6 2
      colorui/components/cu-custom.vue
  3. 94 0
      components/my-upload.vue
  4. 49 51
      pages/index/modules/mine.vue
  5. 79 0
      static/iconfont/iconfont.css
  6. 7 5
      utils/Http.js

+ 3 - 2
App.vue

@@ -2,13 +2,14 @@
 import Vue from 'vue'
 export default {
 	onLaunch: function () {
-		Vue.prototype.cutoff = (msg, title = "", mask = false, icon = 'none', duration = 2000,) => {
+		Vue.prototype.cutoff = (msg, title = "", mask = false, exitTime = 0, icon = 'none', duration = 2000,) => {
 			if (msg != '成功' || title) wx.showToast({
 				title: msg == '成功' ? title : msg,
 				duration,
 				icon,
-				mask,
+				mask: mask || exitTime,
 			})
+			if (exitTime && msg == '成功') setTimeout(uni.navigateBack, exitTime)
 			return msg != '成功';
 		};
 

+ 6 - 2
colorui/components/cu-custom.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<view class="cu-custom" :style="[{ height: CustomBar + 'px' }]">
+		<view class="cu-custom" :style="[{ height: CustomBar + parseFloat(heighten) + 'px' }]">
 			<slot name="head"></slot>
 			<view class="cu-bar fixed" :style="style" :class="[bgImage != '' ? 'none-bg text-white bg-img' : '', bgColor]">
 				<view class="action" @tap="BackPage" v-if="isBack">
@@ -30,7 +30,7 @@ export default {
 			var StatusBar = this.StatusBar;
 			var CustomBar = this.CustomBar;
 			var bgImage = this.bgImage;
-			var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
+			var style = `height:${CustomBar + parseFloat(this.heighten)}px;padding-top:${StatusBar}px;`;
 			if (this.bgImage) {
 				style = `${style}background-image:url(${bgImage});`;
 			}
@@ -38,6 +38,10 @@ export default {
 		}
 	},
 	props: {
+		heighten: {
+			type: String,
+			default: "0"
+		},
 		bgColor: {
 			type: String,
 			default: ''

+ 94 - 0
components/my-upload.vue

@@ -0,0 +1,94 @@
+<template>
+    <u-upload @afterRead="afterRead" :maxCount="maxCount" :accept="accept" multiple>
+        <slot />
+    </u-upload>
+</template>
+<script>
+export default {
+    name: "MyUpload",
+    props: {
+        accept: { //接受的文件类型,file只支持H5(只有微信小程序才支持把accept配置为all、media)
+            type: String,
+            default: "image"
+        },
+        maxCount: {
+            type: String,
+            default: "99"
+        },
+        parentid: { //上传文件夹ID
+            type: String,
+            value: wx.getStorageSync('siteP').appfolderid
+        },
+        uploadCallback: { //上传回调
+            type: Function
+        },
+    },
+    methods: {
+        afterRead({ file }) {
+            const that = this;
+            file.forEach(v => {
+                uni.getFileSystemManager().readFile({
+                    filePath: v.url,
+                    success: (data) => {
+                        that.$Http.basic(this.requestType(v)).then(res => {
+                            if (res.msg == "成功") {
+                                that.uploadFile(res.data, data)
+                            } else {
+                                uni.showToast({
+                                    title: `${data.filename}.${data.serialfilename}`,
+                                    icon: "none"
+                                })
+                            }
+                        })
+                    },
+                    fail: console.error
+                })
+            });
+
+        },
+        /* 请求类型 */
+        requestType(file) {
+            //获取文件后缀
+            var index = file.url.lastIndexOf(".");
+            var ext = file.url.substr(index + 1);
+            //文件名称
+            return {
+                "classname": "system.attachment.huawei.OBS",
+                "method": "getFileName",
+                "content": {
+                    "filename": file.name || `${Date.now()}.${ext}`,
+                    "filetype": ext,
+                    "parentid": this.parentid
+                }
+            }
+        },
+
+        /* 上传成功反馈 */
+        uploadFile(res, data) {
+            var that = this;
+            uni.request({
+                url: res.uploadurl,
+                method: "PUT",
+                data: data,
+                header: {
+                    'content-type': 'application/octet-stream'
+                },
+                success() {
+                    that.$Http.basic({
+                        "classname": "system.attachment.huawei.OBS",
+                        "method": "uploadSuccess",
+                        "content": {
+                            "serialfilename": res.serialfilename
+                        }
+                    }).then(s => {
+                        console.log("文件上传反馈", s)
+                        if (!that.cutoff(s.msg)) that.$emit("uploadCallback", s.data.attachmentids[0]);
+                    }).catch(err => {
+                        console.error(err)
+                    })
+                }
+            })
+        },
+    },
+}
+</script>

+ 49 - 51
pages/index/modules/mine.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<cu-custom ref="Dustom"
+		<cu-custom heighten="94" ref="Dustom"
 			bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png">
 			<view slot="head" class="head" :style="{ 'height': headHeight, 'top': posTop }">
 				<view class="custom-bar" :style="{ 'height': customBar }">
@@ -19,9 +19,9 @@
 							{{ userMsg.name }}
 						</view>
 						<view class="replenish">
-							<text class="iconfont icon-daka" style="margin-right: 10rpx;" />
+							<text class="iconfont icon-daka" style="margin-right: 5px;" />
 							{{ userMsg.phonenumber || '未填写' }}
-							<text style="margin: 0 20rpx;">
+							<text style="margin: 0 10px;">
 								|
 							</text>
 							{{ userMsg.hr.position || '未知职位' }}
@@ -31,51 +31,58 @@
 			</view>
 		</cu-custom>
 
+
 		<view class="nav-box">
 			<navigator class="nav-item" url="#">
-				<text class="iconfont icon-wode-xuanzhong" style="margin-right: 20rpx;" />
+				<text class="iconfont icon-wode-xuanzhong" style="margin-right: 10px;" />
 				<view>
 					修改登录密码
 				</view>
 				<text class="iconfont icon-wode-xuanzhong" />
 			</navigator>
 			<navigator class="nav-item" url="#">
-				<text class="iconfont icon-wode-xuanzhong" style="margin-right: 20rpx;" />
+				<text class="iconfont icon-wode-xuanzhong" style="margin-right: 10px;" />
 				<view>
 					修改登录手机号
 				</view>
 				<text class="iconfont icon-wode-xuanzhong" />
 			</navigator>
 			<navigator class="nav-item" url="#">
-				<text class="iconfont icon-wode-xuanzhong" style="margin-right: 20rpx;" />
+				<text class="iconfont icon-wode-xuanzhong" style="margin-right: 10px;" />
 				<view>
 					绑定微信
 				</view>
 				<text class="iconfont icon-wode-xuanzhong" />
 			</navigator>
 		</view>
+
+		<upload>
+		</upload>
+
 		<u-button :customStyle="butStyle" @click="logOut()">退出登录</u-button>
 	</view>
 </template>
 
 <script>
+import upload from "../../../components/my-upload.vue";
 export default {
 	name: 'Mine',
+	components: { upload },
 	data() {
 		return {
-			headHeight: 0,
-			posTop: 0,
-			customBar: 0,
+			posTop: this.StatusBar + 'px',
+			headHeight: this.CustomBar - this.StatusBar + 'px',
+			customBar: this.CustomBar - this.StatusBar + 'px',
 			butStyle: {
 				position: "fixed",
-				bottom: '240rpx',
-				left: "20rpx",
-				width: "710rpx",
-				height: "90rpx",
+				bottom: '120px',
+				left: "10px",
+				width: "355px",
+				height: "45px",
 				background: "rgba(255,255,255,0.1)",
-				borderRadius: "8rpx",
-				border: "1rpx solid rgba(255,255,255,0.5)",
-				fontSize: "30rpx",
+				borderRadius: "4px",
+				border: "1px solid rgba(255,255,255,0.5)",
+				fontSize: "15px",
 				color: "#FFFFFF"
 			},
 			userMsg: {}
@@ -84,13 +91,6 @@ export default {
 	created() {
 		this.getUserMsg()
 	},
-	mounted() {
-		const Dustom = this.$refs.Dustom;
-		Dustom.CustomBar = Dustom.CustomBar + 94;
-		this.headHeight = (Dustom.CustomBar - this.StatusBar) + 'px';
-		this.customBar = (this.CustomBar - this.StatusBar) + 'px';
-		this.posTop = this.StatusBar + 'px';
-	},
 	methods: {
 		// 获取用户信息
 		getUserMsg() {
@@ -102,8 +102,6 @@ export default {
 			}).then(res => {
 				if (this.cutoff(res.msg)) return;
 				this.userMsg = res.data;
-				console.log(this.userMsg)
-
 			})
 		},
 		logOut() {
@@ -134,36 +132,36 @@ export default {
 
 		.iconfont {
 			position: absolute;
-			bottom: 28rpx;
-			font-size: 32rpx;
+			bottom: 14px;
+			font-size: 16px;
 			color: #FFFFFF;
-			margin-left: 20rpx;
+			margin-left: 10px;
 		}
 	}
 
 	.user {
 		display: flex;
-		height: 168rpx;
+		height: 84px;
 		width: 100vw;
-		padding: 20rpx;
+		padding: 10px;
 		box-sizing: border-box;
 
 		.profile-photo {
-			width: 128rpx;
-			height: 128rpx;
+			width: 64px;
+			height: 64px;
 			border-radius: 50%;
 			overflow: hidden;
 			flex-shrink: 0;
-			margin-right: 20rpx;
+			margin-right: 10px;
 
 			.substitution {
-				width: 128rpx;
-				line-height: 128rpx;
+				width: 64px;
+				line-height: 64px;
 				text-align: center;
 				background: #EFF4FA;
 
 				.iconfont {
-					font-size: 64rpx;
+					font-size: 32px;
 					color: #7C98BB;
 				}
 			}
@@ -173,21 +171,21 @@ export default {
 
 		.text {
 			flex: 1;
-			height: 128rpx;
+			height: 64px;
 			width: 0;
 
 			.name {
-				height: 48rpx;
-				line-height: 48rpx;
-				font-size: 34rpx;
+				height: 24px;
+				line-height: 24px;
+				font-size: 17px;
 				color: #FFFFFF;
-				margin-top: 10rpx;
+				margin-top: 5px;
 			}
 
 			.replenish {
-				margin-top: 20rpx;
-				line-height: 40rpx;
-				font-size: 28rpx;
+				margin-top: 10px;
+				line-height:20px;
+				font-size: 14px;
 				color: #FFFFFF;
 			}
 		}
@@ -195,21 +193,21 @@ export default {
 }
 
 .nav-box {
-	width: 710rpx;
-	margin: 20rpx auto 0;
-	border-radius: 8rpx;
+	width: 355px;
+	margin: 10px auto 0;
+	border-radius: 4px;
 	overflow: hidden;
 	background: rgba($color: #fff, $alpha: 0.1);
 
 	.nav-item {
 		display: flex;
 		align-items: center;
-		width: 710rpx;
-		height: 90rpx;
-		padding: 0 20rpx;
+		width: 355px;
+		height: 45px;
+		padding: 0 10px;
 		box-sizing: border-box;
 		color: #fff;
-		font-size: 28rpx;
+		font-size: 14px;
 
 		view {
 			flex: 1;

+ 79 - 0
static/iconfont/iconfont.css

@@ -0,0 +1,79 @@
+@font-face {
+    font-family: "iconfont"; /* Project id 4091725 */
+    src: url('//at.alicdn.com/t/c/font_4091725_vc2ip9tyt88.woff2?t=1686709095795') format('woff2'),
+         url('//at.alicdn.com/t/c/font_4091725_vc2ip9tyt88.woff?t=1686709095795') format('woff'),
+         url('//at.alicdn.com/t/c/font_4091725_vc2ip9tyt88.ttf?t=1686709095795') format('truetype');
+  }
+  
+  .iconfont {
+    font-family: "iconfont" !important;
+    font-size: 16px;
+    font-style: normal;
+    -webkit-font-smoothing: antialiased;
+    -moz-osx-font-smoothing: grayscale;
+  }
+  
+  .icon-zhanghaodenglu:before {
+    content: "\e693";
+  }
+  
+  .icon-ditu-weixuanzhong:before {
+    content: "\e68f";
+  }
+  
+  .icon-ditu-xuanzhong:before {
+    content: "\e690";
+  }
+  
+  .icon-wode-weixuanzhong:before {
+    content: "\e68c";
+  }
+  
+  .icon-shouye-weixuanzhong:before {
+    content: "\e687";
+  }
+  
+  .icon-wode-xuanzhong:before {
+    content: "\e688";
+  }
+  
+  .icon-xiaoxi-xuanzhong:before {
+    content: "\e689";
+  }
+  
+  .icon-shouye-xuanzhong:before {
+    content: "\e68a";
+  }
+  
+  .icon-xiaoxi-weixuanzhong:before {
+    content: "\e68b";
+  }
+  
+  .icon-daka:before {
+    content: "\e680";
+  }
+  
+  .icon-xiaoxi:before {
+    content: "\e681";
+  }
+  
+  .icon-gaojingzhongxin:before {
+    content: "\e682";
+  }
+  
+  .icon-didian:before {
+    content: "\e683";
+  }
+  
+  .icon-saoyisao:before {
+    content: "\e684";
+  }
+  
+  .icon-shebeiguanli:before {
+    content: "\e685";
+  }
+  
+  .icon-xunjianzhongxin:before {
+    content: "\e686";
+  }
+  

+ 7 - 5
utils/Http.js

@@ -37,17 +37,19 @@ class HTTP {
                 if (showLoading) uni.hideLoading()
                 if (res.errMsg != 'request:ok') {
                     uni.showToast({
-                        title: '网络异常,请重新进入',
+                        title: '网络异常,请稍后再试',
                         icon: "none"
                     })
                 } else if (res.data.msg == '登陆状态已过期,请重新登陆!') {
                     uni.redirectTo({
                         url: '/pages/login/login',
+                        success() {
+                            uni.showToast({
+                                title: res.msg,
+                                icon: "none"
+                            })
+                        }
                     });
-                    uni.showToast({
-                        title: res.msg,
-                        icon: "none"
-                    })
                 }
             }
         })