306132416@qq.com 3 years ago
parent
commit
934b3eeeae
2 changed files with 211 additions and 127 deletions
  1. 63 13
      pages/index/index.vue
  2. 148 114
      pages/index/self_info.vue

+ 63 - 13
pages/index/index.vue

@@ -8,10 +8,10 @@
 		  <p class="nickname">{{ userNickName }}</p>
 		  <p class="nickname">{{userPhone}}</p>
 		</view>
-		<view class="org-info-box">
-		  <view class="org-info">浐灞一支部</view>
-		  <view class="org-line"></view>
-		  <view class="org-info">宣传委员</view>
+		<view class="org-info-box" v-for="(item,index) in userPosList" :key="index">
+		  <view class="org-info">{{item.name || '-'}}</view>
+		  <!-- <view class="org-line"></view> -->
+		  <view class="org-info">{{item.position  || '-'}}</view>
 		</view>	  
 	  </view>
 	  
@@ -21,7 +21,8 @@
       </view>
       <!-- <image class="bg-img" :src="swiperBackground" mode="aspectFill"></image> -->
     </view>
-    <view class="options">
+    <view class="options" :style="{paddingTop:(posLength > 1 ? '160rpx':'80rpx')} ">
+	 <!-- <view class="options" :class="{ paddingTop80: userPosList.length > 1 }"> -->
       <view  v-for="(item, idx) in list" :key="idx" class="options-item" @click="goDetailFn(idx, item.url)"  v-if="item.isShow">
         <view class="img-box">
           <img :src="item.icon" alt="" class="options-item-img" />
@@ -32,7 +33,7 @@
       </view>
     </view>
 	
-		<uni-popup ref="popup" type="center" :is-mask-click="false">
+	<uni-popup ref="popup" type="center" :is-mask-click="false">
 			<view class="auth-pop">
 				<image src="/static/logo.png" mode="aspectFill"></image>
 				<text class="margin-top-3 auth-title">欢迎使用农工笔记小程序</text>
@@ -61,6 +62,10 @@ export default {
       userHeadImg: "",
       userNickName: "",
 	  userPhone:'',
+	  userBranch:'',
+	  userPosList:[],
+	  posLength:0,
+	  userPos:'',
 	  userscanCode:"",
 	  iv:'',
 	  encryptedData:'',
@@ -184,7 +189,13 @@ export default {
 					this.userPhone = res.data.data.substr(0, 3) + '****' + res.data.data.substr(7) ;
 					this.$refs.popup.close()
 					uni.showTabBar({})
-				}
+				}else {
+					uni.showToast({
+					  title: res.data.msg,
+					  duration: 2500,
+					  icon: "none",
+					});
+				} 
 			},
 			fail: () => {
 				console.log("连接失败");
@@ -207,7 +218,7 @@ export default {
 		  getApp().globalData.globalTimestamp +
 		  "&sign=" +
 		  md5Sign;
-		uni.request({
+		uni.request({ 
 		  url: url,
 		  method: "POST",
 		  header: {
@@ -274,7 +285,8 @@ export default {
 				  this.userHeadImg = res.data.data.headimg;
 				  this.userNickName = res.data.data.nickname;
 				  if(res.data.data.phone){
-					  this.userPhone = res.data.data.phone.substr(0, 3) + '****' + res.data.data.phone.substr(7) 
+					  this.userPhone = res.data.data.phone.substr(0, 3) + '****' + res.data.data.phone.substr(7)
+					  this.getUserInfoBranch();
 				  }else {
 					  this.open()
 				  }
@@ -302,6 +314,42 @@ export default {
 	      },
 	    });
 	  },
+	  getUserInfoBranch() {
+	      let md5Sign = md5(
+	        "method=" +
+	          "member" +
+	          "&timestamp=" +
+	          getApp().globalData.globalTimestamp +
+	          "&secret=" +
+	          getApp().globalData.secret
+	      );
+	      let url =
+	        getApp().globalData.shareUrl +
+	        "api/api.php" +
+	        "?method=member&action=my_branch&timestamp=" +
+	        getApp().globalData.globalTimestamp +
+	        "&sign=" +
+	        md5Sign;
+	      uni.request({
+	        url: url,
+	        method: "POST",
+	        header: {
+	          "content-type": "application/x-www-form-urlencoded",
+	        },
+	        data: {
+	          openid:getApp().globalData.open_id,
+	        },
+	        success: (res) => {
+	          if (res.data.code === 200) {
+				  this.userPosList = res.data.data;
+				  this.posLength = res.data.data.length;
+	          }
+	        },
+	        fail: () => {
+	          console.log("连接失败");
+	        },
+	      });
+	    },
     codeReg(strs){
 			let reg = /\[(.*?)\]/gi;
 			let str = strs;
@@ -413,7 +461,7 @@ export default {
 			});
       }
     },
-  loginOut() {
+    loginOut() {
     let md5Sign = md5(
       "method=" +
         "user" +
@@ -422,8 +470,7 @@ export default {
         "&secret=" +
         getApp().globalData.secret
     );
-    let url =
-      getApp().globalData.shareUrl +
+    let url = getApp().globalData.shareUrl +
       "api/api.php" +
       "?method=user&action=logout&timestamp=" +
       getApp().globalData.globalTimestamp +
@@ -567,7 +614,7 @@ export default {
 	background: #fff;
 	border-radius: 10rpx;
 	position: relative;
-	z-index: 99;
+	z-index: 100;
 	top: 25px;
 	width: 80%;
 	left: 10%;
@@ -678,4 +725,7 @@ export default {
    .margin-top-3{
 	   margin-top: 10%;
    }
+   .paddingTop80 {
+	   padding-top:160rpx;
+   }
 </style>

+ 148 - 114
pages/index/self_info.vue

@@ -15,7 +15,7 @@
 				<text>姓名</text>
 			</view>
 			<view class="info-value-box">
-				<input type="text" placeholder="请输入姓名" name="selfName">
+				<input type="text" placeholder="请输入姓名" name="selfName" :value="userName" >
 			</view>		
 		</view>
 		<view class="info-box">
@@ -24,7 +24,7 @@
 				<text>手机号</text>
 			</view>
 			<view class="info-value-box">
-				<input type="tel" placeholder="请输入手机号" name="selfTel">
+				<input type="tel" placeholder="请输入手机号" name="selfTel" :value="userPhone" disabled="true">
 			</view>		
 		</view>
 		<view class="info-box">
@@ -33,17 +33,14 @@
 				<text>个人照片</text>
 			</view>
 			<view class="info-value-box">
-				<view class="update_button display-flex">
+				<!-- <image :src="userHeadImg" mode="aspectFit" style="width: 120rpx;height: 120rpx;border-radius: 10rpx;" @click="showLarge(userHeadImg)"></image> -->
+			<view class="update_button display-flex">
 				  <view class="upload-box" @click="getImage('album')">
 				    <view class="img">
 				      <image src="/static/photo.png" class="photo"></image>
 				    </view>
 				  </view>
-				  <view
-				    class="display-flex upload-box-photo"
-				    v-for="(item, index) in uploadList"
-				    :key="index"
-				  >
+				  <view class="display-flex upload-box-photo" v-for="(item, index) in uploadList" :key="index">
 				    <image :src="item" mode="aspectFit"  style="width: 100%; height: 100%" @click="showLarge(item)"/>
 				    <image src="/static/del.png" class="del-icon"mode="aspectFit" 
 							  style="width: 30rpx; height: 30rpx" @click="delPhoto(index)"></image>
@@ -51,8 +48,6 @@
 				</view>
 			</view>		
 		</view>
-		
-		
 		<view class="info-box">
 			<view class="info-title-box">
 				<!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
@@ -80,7 +75,7 @@
 				<text>民族</text>
 			</view>
 			<view class="info-value-box">
-				<input type="text" placeholder="请输入民族" name="selfName">
+				<input type="text" placeholder="请输入民族" name="selfNation" :value="userNation" >
 			</view>		
 		</view>
 		
@@ -106,7 +101,7 @@
 				<uni-datetime-picker
 				    class="time-select-box"
 					type="date"
-					:value="single"
+					:value="userBorn"
 					@change="change"
 					:clear-icon="false"
 				/>
@@ -118,7 +113,7 @@
 				<text>学历</text>
 			</view>
 			<view class="info-value-box">
-				  <picker @change="bindPickerChange($event,'education')"  :range="educationArray" class="select-box" name="education">
+				  <picker @change="bindPickerChange($event,'education')"  :range="educationArray" class="select-box" >
 				        <view class="uni-input">{{educationValue}}</view>
 						<image src="/static/arrow_down.svg" mode="aspectFill"></image>
 				  </picker>
@@ -130,7 +125,7 @@
 				<text>工作单位</text>
 			</view>
 			<view class="info-value-box">
-				<input type="text" placeholder="西安芝麻开花科技有限公司" name="selfName">
+				<input type="text" placeholder="" name="selfOffice" :value="userOffice" >
 			</view>		
 		</view>
 		<view class="info-box">
@@ -139,7 +134,7 @@
 				<text>职务</text>
 			</view>
 			<view class="info-value-box">
-				<input type="text" placeholder="无" name="selfName">
+				<input type="text" placeholder="无" name="selfPosition" :value="userPosition">
 			</view>		
 		</view>
 		<view class="info-box">
@@ -148,11 +143,11 @@
 				<text>职称</text>
 			</view>
 			<view class="info-value-box">
-				<input type="text" placeholder="项目经理" name="selfName">
+				<input type="text" placeholder="" :value="userTitle" name="selfTitle">
 			</view>		
 		</view>
 		<view style="display: flex;justify-content: space-evenly;">
-			<button type="default" class="submit-bth" style="background-color: #aaaaaa;">清空</button>
+			<!-- <button type="default" class="submit-bth" style="background-color: #aaaaaa;">清空</button> -->
 			<button type="primary" class="submit-bth" style="background-color: #169bd5;" formType="submit">提交</button>
 		</view>
 	</form>	
@@ -172,12 +167,20 @@
 				dateMonth:new Date().getMonth() + 1,
 				arrayMonth:["1", "2","3", "4","5", "6","7", "8","9", "10","11", "12"],
 				title: 'Hello',
+				userName:'',
+				userPhone:getApp().globalData.user_phone,
+				userHeadImg:getApp().globalData.user_headUrl,
 				detailObj:{},
 				shareContent:'',
 				shareCode:'',
 				storeImg:'',
 				isAuthPhone:getApp().globalData.user_phone,
 				userSex:'1',
+				userNation:'',
+				userBorn:'',
+				userOffice:'',
+				userPosition:'',
+				userTitle:'',
 				txt: '请选择',
 				educationValue:'请选择',
 				educationArray: ['博士研究生','硕士研究生','本科','大专','中专'],
@@ -198,10 +201,25 @@
 				loginObj:{},
 				uploadList: [],
 				imgIdList: [],
+				headImgId:'',
+				educationObj:{
+					'1':'中专',
+					'2':'大专',
+					'3':'本科',
+					'4':'硕士研究生',
+					'5':'博士研究生'
+				},
+				educationObjEdit:{
+					'中专':'1',
+					'大专':'2',
+					'本科':'3',
+					'硕士研究生':'4',
+					'博士研究生':'5'
+				}
 			}
 		},
 		onLoad() {
-			//this.getTradeRequest();
+			this.getMemberInfo();
 		},
 		onShow() {
 		},
@@ -212,27 +230,68 @@
 		// 	    }
 		// },
 		methods: {
+			getMemberInfo() {
+			  let md5Sign = md5(
+			    "method=" +"member" + "&timestamp=" + getApp().globalData.globalTimestamp +
+			      "&secret=" + getApp().globalData.secret
+			  );
+			  let url = getApp().globalData.shareUrl +"api/api.php" +
+			    "?method=member&action=info&timestamp=" +
+			    getApp().globalData.globalTimestamp +
+			    "&sign=" +
+			    md5Sign;
+			  uni.request({
+			    url: url,
+			    method: "POST",
+			    header: {
+			      "content-type": "application/x-www-form-urlencoded",
+			    },
+			    data: {
+			      openid: getApp().globalData.open_id,
+			    },
+			    success: (res) => {
+			      if (res.data.code === 200) {
+					  let userInfoObj = res.data.data;
+					  this.userName = userInfoObj.name;
+					  this.dateYear = userInfoObj.jion_year;
+					  this.dateMonth = userInfoObj.jion_month;
+					  this.userNation = userInfoObj.nation;
+					  this.userSex = userInfoObj.sex;
+					  this.userBorn = (userInfoObj.birth_day).substr(0,4) + '-' + (userInfoObj.birth_day).substr(4,2) + '-' + (userInfoObj.birth_day).substr(6);
+					  this.educationValue = this.educationObj[userInfoObj.education_level];
+					  this.userOffice = userInfoObj.office;
+					  this.userPosition = userInfoObj.position;
+					  this.userTitle = userInfoObj.technical_title;
+					  if(userInfoObj.pic_url){
+						  userInfoObj.pic_url = getApp().globalData.shareUrl + userInfoObj.pic_url
+						  this.uploadList.push(userInfoObj.pic_url);
+					  }
+			      }
+			    },
+			    fail: () => {
+			      console.log("连接失败");
+			    },
+			  });
+			},
 			bindDateChange(e){
 						   this.dateYear = e.target.value
-						   
 			},
 			bindDateMonthChange(e){
 						   this.dateMonth = this.arrayMonth[e.target.value]
 			},
 			change(e) {
-			  this.single = e;
-			  console.log("-change事件:", e);
+			  this.userBorn = e;
 			 },
 			getImage(type) {
 			  let that = this;
-			  // if (that.uploadList.length >= 9) {
-			  //   uni.showToast({
-			  //     title: "最多上传9张图片",
-			  //     icon: "none",
-			  //     duration: 2500,
-			  //   });
-			  //   return;
-			  // }
+			  if (that.uploadList.length === 1) {
+			    uni.showToast({
+			      title: "最多上传1张图片",
+			      icon: "none",
+			      duration: 2500,
+			    });
+			    return;
+			  }
 			  uni.chooseImage({
 			    sourceType: [type],
 			    count: 1,
@@ -253,17 +312,14 @@
 			  });
 			  let that = this;
 			  let md5Sign = md5(
-			    "method=" +
-			      "upload" +
-			      "&timestamp=" +
+			    "method=" +"member_upload" +"&timestamp=" +
 			      getApp().globalData.globalTimestamp +
-			      "&secret=" +
-			      getApp().globalData.secret
+			      "&secret=" + getApp().globalData.secret
 			  );
 			  let url =
 			    getApp().globalData.shareUrl +
 			    "api/api.php" +
-			    "?method=upload&source=activity&id=1&timestamp=" +
+			    "?method=member_upload&timestamp=" +
 			    getApp().globalData.globalTimestamp +
 			    "&sign=" +
 			    md5Sign;
@@ -273,12 +329,14 @@
 			    name: "file",
 			    formData: {
 			      file: fileVal,
+				  openid:getApp().globalData.open_id,
 			    },
 			    success: (res) => {
 			      let tmpres = JSON.parse(res.data);
 			      console.log(tmpres);
 			      uni.hideLoading();
 			      that.imgIdList.push(tmpres.data.id);
+				  that.headImgId = tmpres.data.id;
 			    },
 			    fail: (res) => {
 			      console.log("上传请求失败");
@@ -302,12 +360,6 @@
 			    },
 			  });
 			},
-			getProvinceRequest(){
-				 let that = this;
-			},
-			 getTradeRequest(){
-				 let that = this;
-			 },
 			 radioCheck(e){
 			 	console.log(e.target.value)
 			 	this.userSex = e.target.value;
@@ -318,87 +370,69 @@
 				 console.log(data.data.join(''))
 			  },
 			 bindPickerChange(e,type) {
-						 let that = this;
-						  switch (type){
-						  	case 'education':
-							 that.educationValue =  that.educationArray[e.target.value]
-							 console.log(that.educationValue)
-						  		break;
-						  	case 'profession':
-						  	 that.professionValue =  that.professionArray[e.target.value]
-						  		break;
-							case 'ends':
-							 that.endsValue =  that.endsArray[e.target.value]
-								break;	
-						  }
-			             
-			          },
-				testLength(){
-					 if(this.addressDetail.length > 25){
-						 uni.showToast({
-							title: '详细地址应为0-25个字符',
-							icon: 'none'
-						 });
-					}
-				}, 	  
+					this.educationValue =  this.educationArray[e.target.value]
+					console.log(this.educationValue)
+					console.log(this.educationObjEdit[this.educationValue])
+				  },
 			  formSubmit(e) {
-				  //this.goCustomCardPage()
-			  	//将下列代码加入到对应的检查位置
-			  	//定义表单规则
-			  	var rule = [
-			  		{
-			  			name: "selfName",
-			  			checkType: "notnull",
-			  			errorMsg: "姓名不能为空"
-			  		},
-			  		// {
-			  		// 	name: "selfName",
-			  		// 	checkType: "string",
-			  		// 	checkRule: "2,15",
-			  		// 	errorMsg: "姓名不能少于2个汉字"
-			  		// },
-			  		{
-			  			name: "selfName",
-			  			checkType: "reg",
-			  			checkRule: "[\u4e00-\u9fa5]",
-			  			errorMsg: "姓名需为中文"
-			  		}
-					// {
-					// 	name: "trade",
-					// 	checkType: "notnull",
-					// 	errorMsg: "行业不能为空"
-					// }
-			  	];
 			  	//进行表单检查
 			  	var formData = e.detail.value;
 				console.log(formData)
-			  	var checkRes = graceChecker.check(formData, rule);
-			  	if (checkRes) {
-					this.txt === '请选择' ? 
+				if(!formData.selfName){
 					uni.showToast({
-						title: '请选择地区',
-						icon: "none"
-					}):
-					this.submitRequest(formData);
-			  	} else {
-			  		uni.showToast({
-			  			title: graceChecker.error,
-			  			icon: "none"
-			  		});
-			  	}
+						title:'请填写姓名',
+						duration:2500,
+						icon:'none'
+					})
+				}else {
+					this.submitRequest(formData)
+				}
 			  },
 			submitRequest(params){
-				   console.log(params)
-				 	 let that = this;
+			   console.log(this.userTitle,this.headImgId)
+				let md5Sign = md5(
+				  "method=" +"member" + "&timestamp=" + getApp().globalData.globalTimestamp +
+				    "&secret=" + getApp().globalData.secret
+				);
+				let url = getApp().globalData.shareUrl +"api/api.php" +
+				  "?method=member&action=info_update&timestamp=" +
+				  getApp().globalData.globalTimestamp +
+				  "&sign=" +
+				  md5Sign;
+				uni.request({
+				  url: url,
+				  method: "POST",
+				  header: {
+				    "content-type": "application/x-www-form-urlencoded",
+				  },
+				  data: {
+				    openid: getApp().globalData.open_id,
+					name:params.selfName,
+					jion_year :this.dateYear,
+					jion_month :this.dateMonth,
+					sex : this.userSex,
+					birth_day: this.userBorn,
+					office :params.selfOffice,
+					position:params.selfPosition,
+					nation:params.selfNation,
+					technical_title:params.selfTitle,
+					education_level:this.educationObjEdit[this.educationValue],
+					photo_attach_id:this.headImgId,
+				  },
+				  success: (res) => {
+				    if (res.data.code === 200) {
+						uni.showToast({
+							title:'修改成功',
+							duration:2500,
+							icon:'none'
+						})
+				    }
+				  },
+				  fail: () => {
+				    console.log("连接失败");
+				  },
+				}); 
 			},  
-			goCustomCardPage(){
-				uni.redirectTo({
-					url: '/pages/index/successPage/index?types='+'custom', //游客成功页面
-					success: res => {},
-					fail: () => {},
-					complete: () => {}
-				})
-			}  
 		}
 	}
 </script>