achao 2 lat temu
rodzic
commit
29469af57e

+ 54 - 1
xiaochengxu/common/helper.js

@@ -25,10 +25,63 @@ const logout = () => {
 		key: 'userInfo'
 	})
 }
+const formatLocation = (str) => {
+	let area = {}
+	let index11 = 0
+	let index1 = str.indexOf("省")
+	if (index1 == -1) {
+		index11 = str.indexOf("自治区")
+		if (index11 != -1) {
+			area.Province = str.substring(0, index11 + 3)
+		} else {
+			area.Province = str.substring(0, 0)
+		}
+	} else {
+		area.Province = str.substring(0, index1 + 1)
+	}
+
+	let index2 = str.indexOf("市")
+	if (index11 == -1) {
+		area.City = str.substring(index11 + 1, index2 + 1)
+	} else {
+		if (index11 == 0) {
+			area.City = str.substring(index1 + 1, index2 + 1)
+		} else {
+			area.City = str.substring(index11 + 3, index2 + 1)
+		}
+	}
+
+	let index3 = str.indexOf("区")
+	if (index3 == -1) {
+		index3 = str.indexOf("县")
+		if (index3 == -1) {
+			index3 = str.lastIndexOf("市")
+			if (index3 == -1) {
+				index3 = str.indexOf("镇")
+				if (index3 == -1) {
+
+				} else {
+					area.Country = str.substring(index2 + 1, index3 + 1)
+
+				}
+			} else {
+				area.Country = str.substring(index2 + 1, index3 + 1)
+			}
+		} else {
+			area.Country = str.substring(index2 + 1, index3 + 1)
+		}
+
+	} else {
+		area.Country = str.substring(index2 + 1, index3 + 1)
+	}
+	area.Village = str.substring(index3 + 1, str.length)
+	return area;
+}
 
 
 
 export default {
 logout,
-contactCustomerService
+contactCustomerService,
+formatLocation
 }

+ 2 - 0
xiaochengxu/main.js

@@ -5,10 +5,12 @@ import App from './App'
 
 Vue.config.productionTip = false
 import request from '@/util/request.js'
+import helper from '@/common/helper.js'
 import WXBizDataCrypt from '@/util/WXBizDataCrypt.js'
 import uView from '@/uni_modules/uview-ui'
 Vue.use(uView)
 Vue.prototype.$request = request
+Vue.prototype.$helper = helper
 import store from './store'
 Vue.prototype.$store = store
 

+ 56 - 32
xiaochengxu/pages/mySet/myInfo.vue

@@ -3,44 +3,42 @@
 		<view class="card-list">
 			<view class="row" v-for="(item,index) in cardList" :key="index">
 				<view class="title-name">
-					名称
+					{{item.cardBusiness}}
 				</view>
 				<view class="flex card-list-item">
 					<view class="left">
 						<view class="top flex-row-center">
-							<image src="../../static/uni.png" mode="widthFix" class="img"></image>
+							<image :src="item.headSculpture" mode="widthFix" class="img"></image>
 						</view>
 						<view class="bottom flex flex-evenly">
+							<uni-icons type="home" size="20" @click="toHome(item)"></uni-icons>
 							<uni-icons type="home" size="20"></uni-icons>
-							<text>默</text>
 							<uni-icons type="redo" size="20"></uni-icons>
 						</view>
 					</view>
 					<view class="right">
 						<view class="row1 flex">
-							<text>张三</text>
+							<text>{{item.name}}</text>
 							<text class="line"></text>
-							<text>总经理</text>
+							<text>{{item.post}}</text>
 						</view>
 						<view class="row2">
-							北京xxx有限公司
+							{{item.companyName}}
 						</view>
 						<view class="row3" @click="toMap">
 							<uni-icons type="redo" size="20"></uni-icons>
-							<text>北京市朝阳区幸福大街8号</text>
+							<text>{{item.province}}{{item.city}}{{item.area}}{{item.detailedAddress}}</text>
 						</view>
 						<view class="row3">
 							<uni-icons type="redo" size="20"></uni-icons>
-							<text>13333333333</text>
-						</view>
-						<view class="row3">
-							<uni-icons type="redo" size="20"></uni-icons>
-							<text>我是备注</text>
+							<text>{{item.phone}}</text>
 						</view>
 					</view>
 				</view>
 				<view class="car-bottom flex">
-					<button>置顶</button>
+					<u-button text="置顶" @click="topMarking(item)" throttle-time='1000'></u-button>
+					<!-- <button @click="$u.debounce(topMarking, 500)">置顶</button> -->
+					<!-- <button @click="$u.debounce(topMarking(item), 500)">置顶</button> -->
 					<button>删除</button>
 					<button>编辑</button>
 				</view>
@@ -51,35 +49,61 @@
 				<text class=''>添加新名片</text>
 			</view>
 		</view>
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
 <script>
-	import uploadImage from '@/components/ossutil/uploadFile.js';
+	var that;
 	export default {
 		data() {
 			return {
-				cardList: [{},
-					{}
-				]
+				cardList: []
 			};
 		},
-		methods:{
-			addCard(){
-				
+		onLoad() {
+			that = this
+			this.userInfo = uni.getStorageSync("userInfo")
+		},
+		onShow() {
+			this.init()
+		},
+		methods: {
+			init() {
+				this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
+					commonId: this.userInfo.id
+				}, failres => {
+					this.$refs.uToast.show({
+						type: 'error',
+						message: failres.errmsg,
+					})
+					uni.hideLoading()
+				}).then(res => {
+					this.cardList = res.data.items
+				})
+			},
+			addCard() {
+				uni.navigateTo({
+					url: "/pages/mySet/newCard"
+				})
+			},
+			topMarking(val) {
+				that.$request.baseRequest('admin.unimall.cardManagementInfo', 'top', {
+					cardManagementInfo: JSON.stringify({id:val.id})
+				}, failres => {
+					this.$refs.uToast.show({
+						type: 'error',
+						message: failres.errmsg,
+					})
+					uni.hideLoading()
+				}).then(res => {
+					this.$refs.uToast.show({
+						type: 'success',
+						message: '置顶成功!',
+					})
+						this.init()
+				})
 			}
-			// chooseImage(){
-			// 	uni.chooseImage({
-			// 		success: (res) => {
-			// 			uploadImage(res.tempFilePaths[0], 'cardImages/',
-			// 				result => {
-			// 					// this.trainImg = result
-			// 					uni.hideLoading();
-			// 				}
-			// 			)
-			// 		}
-			// 	});
-			// }
 		}
 	}
 </script>

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

@@ -2,9 +2,9 @@
 	<view class="content">
 		<view class="content1 flex-all-center relative">
 			<view class="user">
-				<image src="../../static/logo.png" mode="widthFix" class="img"></image>
+				<image :src="userInfo.head" 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){

+ 70 - 56
xiaochengxu/pages/mySet/newCard.vue

@@ -6,10 +6,10 @@
 			</view>
 			<view class="right">
 				<view class="row1">
-					姓名|职务
+					{{cardInfo.name}}|{{cardInfo.post}}
 				</view>
 				<view class="">
-					公司名称
+					{{cardInfo.companyName}}
 				</view>
 				<view class="">
 					地址
@@ -31,7 +31,7 @@
 			</view>
 			<u--form labelPosition="left" :model="cardInfo" ref="uForm">
 				<u-form-item label="名片标识" prop="userInfo.cardBusiness" borderBottom>
-					<text>名片-{{cardInfo.cardBusiness}}</text>
+					<u--input v-model="cardInfo.cardBusiness" border="none" placeholder="输入名片标识"></u--input>
 				</u-form-item>
 				<u-form-item label="姓名" prop="userInfo.name" borderBottom>
 					<u--input v-model="cardInfo.name" border="none" placeholder="输入姓名"></u--input>
@@ -42,14 +42,19 @@
 				<u-form-item label="公司/机构名称" prop="userInfo.companyName" borderBottom>
 					<u--input v-model="cardInfo.companyName" border="none" placholder="输入公司/机构名称"></u--input>
 				</u-form-item>
-				<u-form-item label="定位" prop="userInfo.name" borderBottom  @click="placeSelect();hideKeyboard()">
-					<text>选择定位> </text>
+				</u-form-item>
+				<!-- 		<u-form-item label="地址" prop="userInfo.name" borderBottom>
+					<view @click="showPicker">选择地址</view>
+					<view>{{ province }}{{ city }}{{ area }}</view>
+				</u-form-item> -->
+				<u-form-item label="定位" prop="userInfo.name" borderBottom @click="placeSelect();hideKeyboard()">
+					<text>选择地址> </text>
 				</u-form-item>
 				<u-form-item label="详细地址" prop="userInfo.name" borderBottom>
-					<u--input v-model="cardInfo.name" border="none" placeholder="输入地址,不超过15个字"></u--input>
+					<u--input v-model="cardInfo.detailedAddress" border="none" placeholder="输入地址,不超过15个字"></u--input>
 				</u-form-item>
 				<u-form-item label="联系电话" prop="userInfo.name" borderBottom>
-					<u--input v-model="cardInfo.name" border="none" placeholder="输入联系电话"></u--input>
+					<u--input v-model="cardInfo.phone" border="none" placeholder="输入联系电话"></u--input>
 				</u-form-item>
 			</u--form>
 		</view>
@@ -63,30 +68,41 @@
 			</view>
 		</view>
 		<view class="bottom">
-			<button>提交</button>
+			<button @click="submit">提交</button>
 		</view>
+		<city-picker ref="picker" mode="multiSelector" :list="areaData" :level="3" @confirm="finishSelectAddress">
+		</city-picker>
+		<u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
+			@cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
 <script>
+	var that;
 	import uploadImage from '@/components/ossutil/uploadFile.js';
 	export default {
+		onLoad() {
+			that = this
+			this.userInfo = uni.getStorageSync("userInfo")
+			this.cardInfo.commonId = this.userInfo.id
+		},
 		data() {
 			return {
+				isSubmit: false,
+				content: '确定提交名片信息?',
+				userInfo: {},
 				fileList1: [],
 				cardInfo: {
-					commonId:'',
-					cardBusiness:'',
-					name:'',
-					post:'',
-					companyName:'',
-					location:'',
-					detailedAddress:'',
-					phone:'',
-					headSculpture:''
-					
-					
-					
+					commonId: '',
+					cardBusiness: '名片标识-1',
+					name: '',
+					post: '',
+					companyName: '',
+					location: '',
+					detailedAddress: '',
+					phone: '',
+					headSculpture: ''
 				}
 			};
 		},
@@ -95,22 +111,12 @@
 				uni.chooseLocation({
 					success: function(res) {
 						console.log(res);
-						111
-						// console.log('位置名称:' + res.name);
-						// console.log('详细地址:' + res.address);
-						// console.log('纬度:' + res.latitude);
-						// console.log('经度:' + res.longitude);
-						this.cardInfo.location = res.latitude+','+res.longitude
-						this.
-						console.log('----------------------------')
-						// that.addressInfo.latitude = res.latitude
-						// that.addressInfo.longitude = res.longitude
-						// that.addressInfo.detailedAddress = _address.Village
-						// that.addressInfo.province = _address.Province
-						// that.addressInfo.city = _address.City
-						// that.addressInfo.area = _address.Country
-						// that.addressInfo.commonId = that.userInfo.id
-						// that.$forceUpdate()
+						that.cardInfo.location = res.latitude + ',' + res.longitude
+						let _address = that.$helper.formatLocation(res.address)
+						that.cardInfo.province = _address.Province
+						that.cardInfo.city = _address.City
+						that.cardInfo.area = _address.Country
+						that.cardInfo.detailedAddress = _address.Village
 					}
 				});
 			},
@@ -144,29 +150,37 @@
 					fileListLen++
 				}
 			},
-			uploadFilePromise(url) {
+			uploadFilePromise(res) {
 				return new Promise((resolve, reject) => {
-					// 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,
-					// 	name: 'file',
-					// 	formData: {
-					// 		user: 'test'
-					// 	},
-					// 	success: (res) => {
-					// 		setTimeout(() => {
-					// 			resolve(res.data.data)
-					// 		}, 1000)
-					// 	}
-					// });
+					uploadImage(res, 'cardImages/',
+						result => {
+							that.cardInfo.headSculpture = result
+							resolve(res)
+						}
+					)
 				})
 			},
+			confirmSubmit() {
+				this.$request.baseRequest('admin.unimall.cardManagementInfo', 'add', {
+					cardManagementInfo: JSON.stringify(this.cardInfo)
+				}, failres => {
+					this.$refs.uToast.show({
+						type: 'error',
+						message: failres.errmsg,
+					})
+					uni.hideLoading()
+				}).then(res => {
+					this.isSubmit = false
+					this.$refs.uToast.show({
+						type: 'success',
+						message: '提交成功!',
+					})
+				})
+			},
+			submit() {
+				this.isSubmit = true
+
+			}
 		}
 	}
 </script>