高敬炎 2 éve
szülő
commit
c48b7f201e

+ 179 - 65
xiaochengxu/pages/mySet/myHome.vue

@@ -1,15 +1,19 @@
 <template>
 	<view>
-		<view class="swiper-wrap">
-			<u-swiper :list="list1" indicator indicatorMode="dot"
+		<view v-if='!editstatus&&fileList.length>0' class="swiper-wrap">
+			<u-swiper :list="fileList" indicator indicatorMode="dot"
 			autoplay
+			imgMode='aspectFit'
+			height='300'
 		    @change="change" @click="click">
 			</u-swiper>	
 		</view>
-		<view>
+		<view v-if='editstatus'>
+			<view>企业风采</view>
+			<!-- <image v-for='item in fileList' :src="item.url" mode=""></image> -->
 			<u-upload
-					:fileList="fileList1"
 					@afterRead="afterRead"
+					:fileList="fileList1"
 					@delete="deletePic"
 					name="1"
 					multiple
@@ -22,81 +26,184 @@
 				loading
 		></u-skeleton> -->
 		<view class="company-title">
-		 	<u--input v-model="companyData.companyName" placeholder="请选择性别" border="none" ></u--input>
+			<view>公司名称</view>
+		 	<u--input v-if='editstatus' v-model="companyData.companyName"  placeholder="请输入公司名称" border="none" ></u--input>
+			<view v-else>{{companyData.companyName}}</view>
 		</view>
 		<view class="intro">
-			<u--input v-model="companyData.companyIntroduction" placeholder="请选择性别" border="none" ></u--input>
+			<view>公司简介</view>
+			<u--input v-if='editstatus' v-model="companyData.companyIntroduction" placeholder="请输入公司简介" border="none" ></u--input>
+			<view v-else>{{companyData.companyIntroduction}}</view>
 		</view>
 		<view class="scope">
-			<u--input v-model="companyData.scopeOfBusiness" placeholder="请选择性别" border="none" ></u--input>
+			<view>业务范围</view>
+			<u--input v-if='editstatus' v-model="companyData.scopeOfBusiness" placeholder="请输入业务范围" border="none" ></u--input>
+			<view v-else>{{companyData.scopeOfBusiness}}</view>
 		</view>
 		<u-list>
 			<u-list-item>
-				<u--input v-model="companyData.companyAddress" placeholder="请选择性别" border="none" ></u--input>
+				<view>公司地址</view>
+				<u--input v-if='editstatus' v-model="companyData.companyAddress" placeholder="请输入公司地址" border="none" ></u--input>
+				<view v-else>{{companyData.companyAddress}}</view>
 			</u-list-item>
 			<u-list-item>
-				<u--input v-model="companyData.phone" placeholder="请选择性别" border="none" ></u--input>
+				<view>公司电话</view>
+				<u--input v-if='editstatus' v-model="companyData.phone" placeholder="请输入公司电话" border="none" ></u--input>
+				<view v-else>{{companyData.phone}}</view>
 			</u-list-item>
 			<u-list-item>
-				<u--input v-model="companyData.portraiture" placeholder="请选择性别" border="none" ></u--input>
+				<view>公司传真</view>
+				<u--input v-if='editstatus' v-model="companyData.portraiture" placeholder="请输入公司传真" border="none" ></u--input>
+				<view v-else>{{companyData.portraiture}}</view>
 			</u-list-item>
 			<u-list-item>
-				<u--input v-model="companyData.postbox" placeholder="请选择性别" border="none" ></u--input>
+				<view>公司邮箱</view>
+				<u--input v-if='editstatus' v-model="companyData.postbox" placeholder="请输入公司邮箱" border="none" ></u--input>
+				<view v-else>{{companyData.postbox}}</view>
 			</u-list-item>
 		</u-list>
 		<view class="footer">
-			<view @click='edit' class='button'>编辑</view>
+			<view v-if='!editstatus' @click='edit' class='button'>编辑</view>
+			<view v-else @click='$u.debounce(buttonsubmit, 500)' class='button'>提交</view>
 		</view>
 	</view>
 </template>
 
 <script>
+	import uploadImage from '@/components/ossutil/uploadFile.js'; 
 	export default {
 		data() {
 			return {
-				list1: [],
-				companyData:{},
+				companyData:{
+					commonId:''
+				},
+				userInfo:{},
+				fileList:[],
+				fileList1:[],
+				editstatus:false,
 			}
 		},
+		onLoad() {
+			uni.showLoading({
+					title: '数据加载中'
+				})
+				this.getList()
+		},
+		onShow() {
+				this.userInfo = uni.getStorageSync("userInfo")
+				this.companyData.commonId=uni.getStorageSync("userInfo").id
+				console.log(1111111111)
+				
+			
+			// this.getList()
+			
+		},
 		methods: {
+			getList(){
+				this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'list',{
+					page:1,
+					limit:10,
+					commonId:uni.getStorageSync("userInfo").id
+				}, failres => {
+					console.log('res+++++', failres.errmsg)
+					this.$refs.uToast.show({
+						type: 'error',
+						message: failres.errmsg,
+					})
+					uni.hideLoading()
+				}).then(res => {
+					console.log(res)
+					if(res.data.items.length>0){
+						this.companyData=res.data.items[0]
+						if(res.data.items[0].addressUrl){
+							var arr=res.data.items[0].addressUrl.split(',')
+							this.fileList1=[]
+							for(var i=0;i<arr.length;i++){
+								if(arr[i]){
+									this.fileList1.push({url:arr[i]})
+								}
+							}
+							this.fileList=arr
+						}
+						console.log(this.fileList1)
+						this.editstatus=false
+					}else{
+						this.editstatus=true
+					}
+					// if (res.errno == 200) {
+					uni.hideLoading()
+					
+					// }
+				})
+			},
 			edit(){
+				this.editstatus=true
+			},
+			change(){
+				
+			},
+			click(index){
+				console.log(index)
+				uni.previewImage({
+						current: index,     // 当前显示图片的索引值
+						urls: this.fileList,    // 需要预览的图片列表,photoList要求必须是数组
+						loop:true,          // 是否可循环预览
+					})
+			},
+			buttonsubmit(){
+				uni.showLoading({
+					title: '数据加载中',
+					mask:true
+				})
+				if(this.companyData.id){
+					this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'update',{
+						personalHomepageInfo:JSON.stringify(this.companyData)
+					}, failres => {
+						console.log('res+++++', failres.errmsg)
+						this.$refs.uToast.show({
+							type: 'error',
+							message: failres.errmsg,
+						})
+						uni.hideLoading()
+					}).then(res => {
+						// if (res.errno == 200) {
+						uni.hideLoading()
+						uni.showToast({
+						    title: '编辑成功',
+						    icon: 'none',
+						    duration: 2000
+						})
+						this.getList()
+						// }
+					})
+				}else{
+					this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'add',{
+						personalHomepageInfo:JSON.stringify(this.companyData)
+					}, failres => {
+						console.log('res+++++', failres.errmsg)
+						this.$refs.uToast.show({
+							type: 'error',
+							message: failres.errmsg,
+						})
+						uni.hideLoading()
+					}).then(res => {
+						// if (res.errno == 200) {
+						uni.hideLoading()
+						uni.showToast({
+						    title: '提交成功',
+						    icon: 'none',
+						    duration: 2000
+						})
+						this.getList()
+						
+						// }
+					})
+				}
 				
-				// uni.showLoading({
-				// 	title: '数据加载中'
-				// })
-				// this.$request.baseRequest('personalHomepageInfo', 'list', {
-				// 	remark2: this.route,
-				// 	carpoolingType: this.type,
-				// 	companyId: 1,
-				// 	pageNum: page.num,
-				// 	pageSize: page.size,
-				// }, failres => {
-				// 	console.log('res+++++', failres.errmsg)
-				// 	this.$refs.uToast.show({
-				// 		type: 'error',
-				// 		message: failres.errmsg,
-				// 	})
-				// 	uni.hideLoading()
-				// }).then(res => {
-				// 	// if (res.errno == 200) {
-				// 	uni.hideLoading()
-				// 	console.log(11)
-				// 	let curPageData = res.data.items;
-				// 	let totalPage = res.data.total;
-				// 	let curPageLen = curPageData.length;
-				// 	this.mescroll.endByPage(curPageLen, totalPage);
-				// 	console.log(res.data)
-				// 	// this.makeData(res.data)
-				// 	if (page.num == 1) this.infoList = []; //如果是第一页需手动置空列表
-				// 	this.infoList = this.infoList.concat(curPageData); //追加新数据
-				// 	// }
-				// })
-				// uni.navigateTo({
-				// 	url:_url
-				// })
 			},
 			deletePic(event) {
 				this[`fileList${event.name}`].splice(event.index, 1)
+				this.companyData.addressUrl =this[`fileList${event.name}`].toString()
 			},
 			// 新增图片
 			async afterRead(event) {
@@ -104,31 +211,38 @@
 				let lists = [].concat(event.file)
 				let fileListLen = this[`fileList${event.name}`].length
 				lists.map((item) => {
-					this[`fileList${event.name}`].push({
-						...item,
-						status: 'uploading',
-						message: '上传中'
-					})
-				})
+				     this[`fileList${event.name}`].push({
+				      ...item,
+				      status: 'uploading',
+				      message: '上传中'
+				     })
+				    })
+				// console.log(event,111111,fileListLen)
 				for (let i = 0; i < lists.length; i++) {
 					const result = await this.uploadFilePromise(lists[i].url)
+					this.companyData.addressUrl = this.companyData.addressUrl?this.companyData.addressUrl+','+result:result
+					this[`fileList${event.name}`][fileListLen]={}
 					let item = this[`fileList${event.name}`][fileListLen]
-					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
-						status: 'success',
-						message: '',
-						url: result
-					}))
-					fileListLen++
+					console.log(item)
+					 this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
+					  status: 'success',
+					  message: '',
+					  url: result
+					 }))
+					 fileListLen++
 				}
+				console.log(this[`fileList${event.name}`])
 			},
 			uploadFilePromise(url) {
+				console.log(url)
 				return new Promise((resolve, reject) => {
-					// uploadImage(res.tempFilePaths[0], 'cardImages/',
-					// 				result => {
-					// 					// this.trainImg = result
-					// 					uni.hideLoading();
-					// 				}
-					// 			)
+					uploadImage(url, 'cardImages/',
+						result => {
+							console.log(result,22222)
+							
+							resolve(result)
+						}
+					)
 					// let a = uni.uploadFile({
 					// 	url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
 					// 	filePath: url,

+ 3 - 2
xiaochengxu/pages/mySet/mySet.vue

@@ -4,7 +4,7 @@
 			<view class="user">
 				<image src="../../static/logo.png" mode="widthFix" class="img"></image>
 				<view class="name">
-					{{userInfo.nickName}}
+					{{userInfo.nickname}}
 				</view>
 			</view>
 			<view class="position">
@@ -63,7 +63,8 @@
 			};
 		},
 		onShow() {
-			this.userInfo = uni.getStorageInfoSync("userInfo")
+			this.userInfo = uni.getStorageSync("userInfo")
+			console.log(this.userInfo)
 		},
 		methods:{
 			menuClick(typeName){

+ 6 - 6
xiaochengxu/pages/mySet/newCard.vue

@@ -146,12 +146,12 @@
 			},
 			uploadFilePromise(url) {
 				return new Promise((resolve, reject) => {
-					// uploadImage(res.tempFilePaths[0], 'cardImages/',
-					// 				result => {
-					// 					// this.trainImg = result
-					// 					uni.hideLoading();
-					// 				}
-					// 			)
+					uploadImage(res.tempFilePaths[0], 'cardImages/',
+									result => {
+										this.trainImg = result
+										uni.hideLoading();
+									}
+								)
 					// let a = uni.uploadFile({
 					// 	url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
 					// 	filePath: url,