소스 검색

修改登录

achao 2 년 전
부모
커밋
6160fcf20d

+ 89 - 176
xiaochengxu/pages/cardHolder/cardHolder.vue

@@ -292,21 +292,12 @@
 		<poster :data="canvasData" background-color="#FFF" :width='750' :height='420' @on-success="posterSuccess"
 			ref="poster" @on-error="posterError"></poster>
 		<!-- #ifdef MP-WEIXIN -->
-		<!-- <u-popup :show="isPhone" mode="center" :round="10">
-			<view class='sq-view'>
-				<view class="text">
-					手机登录后才能查看名片哦~
-				</view>
-				<button class="confirm" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">授权手机号</button>
-			</view>
-		</u-popup> -->
 		<u-modal :show="showAuthorizePhone" :showConfirmButton="false">
 			<view class="slot-content">
 				<view class="auth-card">
 					<view class="img">
 						<img class="avatar-img" src="@/static/imgs/logo.png" mode="widthFix">
 					</view>
-					<!-- <div class="title">手机登录后才能查看名片哦~</div> -->
 					<view class="content">手机登录后才能查看名片哦~</view>
 				</view>
 				<view class="auth-btncard">
@@ -323,12 +314,12 @@
 		</u-modal>
 		<u-modal :show="showAuthorizeUser" :showConfirmButton="false">
 			<view class="slot-content">
-				<div class="auth-card">
-					<div class="img">
+				<view class="auth-card">
+					<view class="img">
 						<img class="avatar-img" src="/static/imgs/logo.png" mode="widthFix">
-					</div>
-					<div class="content">邀请您补全个人信息<br></br>(昵称、头像)</div>
-					<div style="margin-left: 100rpx;margin-right: 100rpx">
+					</view>
+					<view class="content">邀请您补全个人信息<br></br>(昵称、头像)</view>
+					<view style="margin-left: 100rpx;margin-right: 100rpx">
 						<u-form :model="userInfo" ref="uForm">
 							<u-form-item label="头像">
 								<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"
@@ -344,13 +335,16 @@
 								<!-- <input type="nickname" :value="userInfo.nickname" class="weui-input" @blur="userNameInput" placeholder="请输入昵称"/> -->
 							</u-form-item>
 						</u-form>
-					</div>
-				</div>
-				<div class="auth-btncard">
-					<div class="btn-unok"><u-button :customStyle="customStyleUnOk" @click="showAuthorizeUser=false">
-							拒绝</u-button></div>
-					<div class="btn-ok"><u-button :customStyle="customStyleOk" @click="authUser"> 允许</u-button></div>
-				</div>
+					</view>
+				</view>
+				<view class="auth-btncard">
+					<view class="btn-unok"><u-button :customStyle="customStyleUnOk" @click="authUser(0)">
+							拒绝</u-button>
+					</view>
+					<view class="btn-ok">
+						<u-button :customStyle="customStyleOk" @click="authUser(1)"> 允许</u-button>
+					</view>
+				</view>
 			</view>
 		</u-modal>
 
@@ -376,7 +370,8 @@
 			return {
 				userInfo: {
 					head: '',
-					nickname: ''
+					nickname: '',
+					phone: '',
 				},
 				downOption: {
 					auto: false,
@@ -467,28 +462,23 @@
 					}
 					console.log(that.unread)
 				})
+			} else {
+				this.showAuthorizePhone = true
 			}
 
 		},
 		onLoad: function(options) {
 			that = this
-			console.log(uni.getLaunchOptionsSync().scene, 1011)
 			if (uni.getStorageSync("userInfo").phone) {
 				this.userInfo = uni.getStorageSync("userInfo")
 				this.$nextTick(function() {
 					that.mescroll.resetUpScroll()
-
 					wx.showShareMenu({
 						withShareTicket: true,
 						menus: ["shareAppMessage", "shareTimeline"]
 					})
 				});
 
-			} else {
-				if (uni.getLaunchOptionsSync().scene != 1154) {
-					this.login()
-
-				}
 			}
 			this.status = uni.getLaunchOptionsSync().scene
 			if (uni.getLaunchOptionsSync().scene == 1154) {
@@ -539,21 +529,24 @@
 					})
 				})
 			},
-			authUser() {
-				if (this.userInfo.nickname == '') {
-					uni.showToast({
-						icon: "none",
-						title: '请输入您的昵称',
-						duration: 2000
-					});
-					return;
+			async authUser(type) {
+				//同步信息,没有头像和昵称自动生成
+				this.userInfo = await this.$request.syncInfo(this.userInfo)
+				if (this.userInfo.openId) {
+					uni.setStorageSync("userInfo", that.userInfo)
+					that.showAuthorizeUser = false
+					that.mescroll.resetUpScroll()
 				}
-				this.getTokenAsync1()
-
 			},
 
 			downCallback() {
-				this.mescroll.resetUpScroll()
+				if (uni.getStorageSync("userInfo").phone) {
+					this.mescroll.resetUpScroll()
+				} else {
+					that.mescroll.endBySize(0, 0)
+					this.showAuthorizePhone = true
+				}
+
 			},
 			freeTell(item) {
 				uni.makePhoneCall({
@@ -566,66 +559,13 @@
 					}
 				})
 			},
-			getPhoneNumber(e) {
-				console.log(e)
-				if (e.mp.detail.errMsg === "getPhoneNumber:ok") {
-					this.isPhone = false
-					this.params.iv = e.mp.detail.iv
-					this.params.encryptedData = e.mp.detail.encryptedData
-					this.params.session_key = this.accessToken
-					console.log(this.params)
-					let appId = 'wx5d8906c2208c899f'
-					let sessionKey = this.userInfo.sessionKey
-					let encryptedData = this.params.encryptedData
-					let iv = this.params.iv
-
-					let pc = this.$WXBizDataCrypt(appId, sessionKey)
-
-					let data = this.$WXBizDataCrypt.prototype.decryptData(encryptedData, iv, appId, sessionKey)
-
-					console.log('解密后 data: ', data)
-					this.showAuthorizePhone = false
-					this.getTokenAsync(data)
-				}
+			async getPhoneNumber(e) {
+				that.userInfo = await this.$request.wxlogin()
+				that.userInfo.phone = await this.$request.getPhone(e, that.userInfo)
+				this.showAuthorizePhone = false
+				this.showAuthorizeUser = true
 
 			},
-			async getTokenAsync(val) {
-				let that = this
-				that.userInfo.phone = val.phoneNumber
-				that.$request.baseRequest('commonUserApp', 'edit', {
-					commonUserInfo: JSON.stringify(that.userInfo)
-				}, failres => {
-					uni.showToast({
-						icon: "none",
-						title: failres.errmsg,
-						duration: 3000
-					});
-					uni.hideLoading()
-				}).then(res1 => {
-					that.userInfo = res1.data
-					uni.setStorageSync("userInfo", that.userInfo)
-					that.showAuthorizeUser = true
-					that.mescroll.resetUpScroll()
-				})
-			},
-			async getTokenAsync1() {
-				let that = this
-				that.$request.baseRequest('commonUserApp', 'edit', {
-					commonUserInfo: JSON.stringify(that.userInfo)
-				}, failres => {
-					uni.showToast({
-						icon: "none",
-						title: failres.errmsg,
-						duration: 3000
-					});
-					uni.hideLoading()
-				}).then(res1 => {
-					that.userInfo = res1.data
-					uni.setStorageSync("userInfo", that.userInfo)
-					that.showAuthorizeUser = false
-					that.mescroll.resetUpScroll()
-				})
-			},
 			delVal() {
 				this.searchVal = ""
 				this.mescroll.resetUpScroll()
@@ -1029,13 +969,6 @@
 						this.checked = false
 					}
 				}
-
-				// for(var i=0;i<this.cardList.length;i++){
-				// 	console.log(this.cardList[i].checked)
-				// 	// if(this.cardList[i].checkedList.length>0){
-				// 	// 	this.checkedList.push(i)
-				// 	// }
-				// }
 				console.log(this.checkedList)
 			},
 			remarkConfirm() {
@@ -1173,48 +1106,24 @@
 
 				}
 			},
-			login() {
-				let that = this
-				uni.login({
-					"provider": "weixin",
-					success: function(wxres) {
-						that.$request.baseRequest('commonUserApp', 'commonUserLogin', {
-							loginType: 1,
-							raw: JSON.stringify(wxres)
-						}, failres => {
-							uni.showToast({
-								icon: "none",
-								title: failres.errmsg,
-								duration: 3000
-							});
-							uni.hideLoading()
-						}).then(res => {
-							console.log(res.data)
-							that.isPhone = true
-							that.showAuthorizePhone = true
-							that.userInfo = res.data
-						})
-					},
-					fail: function(err) {
-						uni.showToast({
-							icon: "none",
-							title: err.code,
-							duration: 3000
-						});
-						// 登录授权失败  
-						// err.code是错误码
-					}
-				})
-			},
 			toNotice() {
-				uni.navigateTo({
-					url: "/pages/cardHolder/notice"
-				})
+				if (this.userInfo.phone) {
+					uni.navigateTo({
+						url: "/pages/cardHolder/notice"
+					})
+				} else {
+					this.showAuthorizePhone = true
+				}
 			},
 			micOpen: function() {
-				uni.navigateTo({
-					url: "/pages/cardHolder/search?mic=1"
-				})
+				if (this.userInfo.phone) {
+					uni.navigateTo({
+						url: "/pages/cardHolder/search?mic=1"
+					})
+				} else {
+					this.showAuthorizePhone = true
+				}
+
 			},
 			uploadFile: function(tempFilePath) {
 				return new Promise((resolve, reject) => {
@@ -1233,9 +1142,13 @@
 				});
 			},
 			search() {
-				uni.navigateTo({
-					url: "/pages/cardHolder/search"
-				})
+				if (this.userInfo.phone) {
+					uni.navigateTo({
+						url: "/pages/cardHolder/search"
+					})
+				} else {
+					this.showAuthorizePhone = true
+				}
 			},
 			input(res) {
 				console.log('----input:', res)
@@ -1269,36 +1182,36 @@
 				this.type = 1
 			},
 			scan() {
-				var that = this
-				// console.log(1)
-				// uni.navigateTo({
-				// 	url: "/pages/cardHolder/scancode"
-				// })
-				uni.scanCode({
-					success: function(res) {
-						console.log('条码类型:' + res.scanType);
-						console.log('条码内容:' + res.result);
-						// console.log(res.result.split("=")[1],res.result.split("=")[1].indexOf(','),res.result.split("=")[1].split(",")[0])
-						var cardId = res.result.split("=")[1].split(",")[0]
-						that.$request.baseRequest('admin.unimall.cardHolderInfo', 'getAdded', {
-							commonId: uni.getStorageSync("userInfo").id,
-							cardId: cardId
-						}, failres => {
-							console.log('res+++++', failres.errmsg)
-							uni.showToast({
-								icon: "none",
-								title: failres.errmsg,
-								duration: 3000
-							});
-						}).then(res1 => {
-							uni.navigateTo({
-								url: "/pages/cardHolder/scanCodeAddCard?id=" + res.result
-									.split("=")[1]
+				if (this.userInfo.phone) {
+					
+					uni.scanCode({
+						success: function(res) {
+							console.log('条码类型:' + res.scanType);
+							console.log('条码内容:' + res.result);
+							// console.log(res.result.split("=")[1],res.result.split("=")[1].indexOf(','),res.result.split("=")[1].split(",")[0])
+							var cardId = res.result.split("=")[1].split(",")[0]
+							that.$request.baseRequest('admin.unimall.cardHolderInfo', 'getAdded', {
+								commonId: uni.getStorageSync("userInfo").id,
+								cardId: cardId
+							}, failres => {
+								console.log('res+++++', failres.errmsg)
+								uni.showToast({
+									icon: "none",
+									title: failres.errmsg,
+									duration: 3000
+								});
+							}).then(res1 => {
+								uni.navigateTo({
+									url: "/pages/cardHolder/scanCodeAddCard?id=" + res.result
+										.split("=")[1]
+								})
 							})
-						})
-
-					}
-				});
+					
+						}
+					});
+				} else {
+					this.showAuthorizePhone = true
+				}
 			},
 			toMap(item) {
 				uni.navigateTo({

+ 190 - 6
xiaochengxu/pages/cardHolder/scanCodeAddCard.vue

@@ -211,12 +211,69 @@
 			<u-button @click='$u.debounce(save, 500)' text="保存" type="primary" color="#18254C"
 				:customStyle="btnStyle"></u-button>
 		</view>
-
+	<u-modal :show="showAuthorizePhone" :showConfirmButton="false">
+			<view class="slot-content">
+				<view class="auth-card">
+					<view class="img">
+						<img class="avatar-img" src="@/static/imgs/logo.png" mode="widthFix">
+					</view>
+					<!-- <div class="title">手机登录后才能查看名片哦~</div> -->
+					<view class="content">手机登录后才能查看名片哦~</view>
+				</view>
+				<view class="auth-btncard">
+					<view class="btn-unok">
+						<u-button :customStyle="customStyleUnOk" @click="showAuthorizePhone=false" :plain="true">
+							拒绝</u-button>
+					</view>
+					<view class="btn-ok">
+						<u-button :customStyle="customStyleOk" open-type="getPhoneNumber"
+							@getphonenumber="getPhoneNumber"> 立即登录</u-button>
+					</view>
+				</view>
+			</view>
+		</u-modal>
+		<u-modal :show="showAuthorizeUser" :showConfirmButton="false">
+			<view class="slot-content">
+				<view class="auth-card">
+					<view class="img">
+						<img class="avatar-img" src="/static/imgs/logo.png" mode="widthFix">
+					</view>
+					<view class="content">邀请您补全个人信息<br></br>(昵称、头像)</view>
+					<view style="margin-left: 100rpx;margin-right: 100rpx">
+						<u-form :model="userInfo" ref="uForm">
+							<u-form-item label="头像">
+								<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"
+									slot="right">
+									<image class="avatar"
+										:src="userInfo.head?userInfo.head:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'">
+									</image>
+								</button>
+							</u-form-item>
+							<u-form-item label="昵称">
+								<u-input inputAlign='right' v-model="userInfo.nickname" class="weui-input"
+									@blur="userNameInput" placeholder="请输入昵称" border="false" />
+								<!-- <input type="nickname" :value="userInfo.nickname" class="weui-input" @blur="userNameInput" placeholder="请输入昵称"/> -->
+							</u-form-item>
+						</u-form>
+					</view>
+				</view>
+				<view class="auth-btncard">
+					<view class="btn-unok"><u-button :customStyle="customStyleUnOk" @click="showAuthorizeUser=false">
+							拒绝</u-button></view>
+					<view class="btn-ok"><u-button :customStyle="customStyleOk" @click="authUser"> 允许</u-button></view>
+				</view>
+			</view>
+		</u-modal>
 		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
 <script>
+	var that;
+	import {
+		pathToBase64,
+		base64ToPath
+	} from 'image-tools'
 	import Card from '../../components/Card/Card.vue'
 	export default {
 		components: {
@@ -224,6 +281,23 @@
 		},
 		data() {
 			return {
+				showAuthorizeUser: false,
+				showAuthorizePhone: false,
+				customStyleUnOk: {
+					marginTop: '20rpx',
+					color: '#18254C',
+					border: '2px solid #18254C',
+					"border-radius": "10px",
+					fontSize: "32rpx"
+				},
+				customStyleOk: {
+					marginTop: '20rpx',
+					color: '#fff',
+					border: '2px solid #18254C',
+					"border-radius": "10px",
+					fontSize: "32rpx",
+					background: "#18254C"
+				},
 				value: '',
 				btnStyle: {
 					width:'calc(50% - 80rpx)'
@@ -239,6 +313,7 @@
 				show1: false,
 				columns: [],
 				cardList: [],
+				userInfo:{},
 				rules: {
 					'userInfo.name': {
 						type: 'string',
@@ -257,16 +332,64 @@
 			}
 		},
 		onLoad(options) {
-			console.log(123)
-			this.id = options.id.indexOf(",") ? options.id.split(",")[0] : options.id
-			this.commonId = options.id.indexOf(",") ? options.id.split(",")[1] : ''
-			this.getList()
+			that = this
+			console.log(options)
+			if (uni.getStorageSync("userInfo").phone) {
+				this.userInfo = uni.getStorageSync("userInfo")
+				this.id = options.id.indexOf(",") ? options.id.split(",")[0] : options.id
+				this.commonId = options.id.indexOf(",") ? options.id.split(",")[1] : ''
+				this.getList()
+				
+			} else {
+				this.showAuthorizePhone = true
+			}
 		},
 		onShow() {
-
+			
 		},
 		methods: {
+			//获取昵称输入内容
+			userNameInput(e) {
+				this.userInfo.nickname = e.detail.value
+			},
+			async onChooseAvatar(e) {
+				this.$set(this.userInfo, "head", await this.toBase64(e.detail.avatarUrl))
+			},
+			toBase64(url) {
+				return new Promise(resolve => {
+					pathToBase64(url).then(path => {
+						resolve(path);
+					}).catch(error => {
+						console.log(error)
+					})
+				})
+			},
+			async authUser(type) {
+				//同步信息,没有头像和昵称自动生成
+				this.userInfo =  await this.$request.syncInfo(this.userInfo)
+				if(this.userInfo.openId) {
+					uni.setStorageSync("userInfo", that.userInfo)
+					that.showAuthorizeUser = false
+					that.mescroll.resetUpScroll()
+				}
+			},
+			async getPhoneNumber(e) {
+				that.userInfo = await this.$request.wxlogin()
+				that.userInfo.phone = await this.$request.getPhone(e, that.userInfo)
+				this.showAuthorizePhone = false
+				this.showAuthorizeUser = true
+				this.getList()
+			
+			},
 			save() {
+				if(this.cardInfo.length==0){
+					uni.showToast({
+						icon: "none",
+						title: "您还未创建名片,请前往我的先创建名片!",
+						duration: 3000
+					});
+					return
+				}
 				uni.showLoading({
 					title: '数据加载中',
 					mask: true
@@ -332,6 +455,13 @@
 				}).then(res => {
 					console.log(res, "this.cardInfo")
 					this.cardInfo = res.data
+					if(this.cardInfo.length==0){
+						uni.showToast({
+							icon: "none",
+							title: "您还未创建名片,请前往我的先创建名片!",
+							duration: 3000
+						});
+					}
 					// this.cardInfo.cardBusiness = ''
 					// this.cardInfo.cardCommonId = res.data.commonId
 					console.log(res)
@@ -610,4 +740,58 @@
 	.icon-text{
 		margin-left: 20rpx;
 	}
+	.slot-content {
+		width: 100%;
+	}
+	
+	.auth-btncard {
+		display: flex !important;
+		justify-content: space-between !important;
+	
+		.btn-unok {
+			width: 40%;
+		}
+	
+		.btn-ok {
+			width: 40%;
+		}
+	}
+	
+	.auth-card {
+		text-align: center;
+	
+		.avatar-img {
+			width: 250rpx;
+		}
+	
+		.title {
+			font-size: 20rpx;
+		}
+	
+		.content {
+			font-size: 32rpx;
+			font-weight: bold;
+			color: #1A1A1A;
+			margin-bottom: 30rpx;
+		}
+	}
+	
+	.avatar-wrapper {
+		color: #333 !important;
+		border: none !important;
+		border-radius: 0 !important;
+		background-color: transparent !important;
+		padding: 0;
+	}
+	
+	.avatar-wrapper::after {
+		border: none !important;
+	}
+	
+	.avatar {
+		width: 100rpx;
+		height: 100rpx;
+		overflow: hidden;
+		border-radius: 100%;
+	}
 </style>

+ 315 - 69
xiaochengxu/pages/circle/circle.vue

@@ -5,7 +5,9 @@
 				<view class="left flex" @click="search">
 					<image src="../../static/imgs/cirlce/search.png" mode="widthFix" class="search-img"></image>
 					<text class="search-val"> {{searchVal?searchVal:'搜索圈子'}}</text>
-					<image class='search-del' style='width:32rpx;height:32rpx;' v-if="searchVal" @click.native.stop="delSearchVal" src="../../static/imgs/card/searchdel.png" mode="widthFix" ></image>
+					<image class='search-del' style='width:32rpx;height:32rpx;' v-if="searchVal"
+						@click.native.stop="delSearchVal" src="../../static/imgs/card/searchdel.png" mode="widthFix">
+					</image>
 				</view>
 			</view>
 			<view class="right relative">
@@ -14,7 +16,8 @@
 				<u-badge v-if='cardList.length>0' :isDot="true" type="error" class="point position"></u-badge>
 			</view>
 		</view>
-		<mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" @down="downCallback">
+		<mescroll-uni ref="mescrollRef" :top="120" :up="upOption" :down="downOption" @init="mescrollInit" @up="upCallback"
+			@down="downCallback">
 			<view class="content2 flex flex-between">
 
 				<view class="left flex title">
@@ -37,7 +40,8 @@
 					</view>
 					<view class="row-tiem flex" v-if="!item.name" @click="toDetail(item.id)">
 						<view class="left">
-							<image :src="item.circleHead?item.circleHead:'../../static/imgs/mySet/ewm.png'" mode="aspectFill" class="img"></image>
+							<image :src="item.circleHead?item.circleHead:'../../static/imgs/mySet/ewm.png'"
+								mode="aspectFill" class="img"></image>
 						</view>
 						<view class="right">
 							<view class="top">{{item.circleName}}({{item.cardNum}}人)</view>
@@ -51,7 +55,7 @@
 				</view>
 			</view>
 			<view class="content2 flex flex-between">
-			
+
 				<view class="left flex title">
 					<view class="line"></view>
 					<view class="text-title">
@@ -72,7 +76,8 @@
 					</view>
 					<view class="row-tiem flex" v-if="!item.name" @click="toDetail(item.id)">
 						<view class="left">
-							<image :src="item.circleHead?item.circleHead:'../../static/imgs/mySet/ewm.png'" mode="aspectFill" class="img"></image>
+							<image :src="item.circleHead?item.circleHead:'../../static/imgs/mySet/ewm.png'"
+								mode="aspectFill" class="img"></image>
 						</view>
 						<view class="right">
 							<view class="top">{{item.circleName}}({{item.cardNum}}人)</view>
@@ -85,13 +90,76 @@
 					</view>
 				</view>
 			</view>
-		</mescroll-body>
+		</mescroll-uni>
 		<image src="../../static/imgs/cirlce/add.png" mode="widthFix" class="add" @click="toCreateCircle"></image>
 		<u-toast ref="uToast"></u-toast>
+		<!-- #ifdef MP-WEIXIN -->
+		<u-modal :show="showAuthorizePhone" :showConfirmButton="false">
+			<view class="slot-content">
+				<view class="auth-card">
+					<view class="img">
+						<img class="avatar-img" src="@/static/imgs/logo.png" mode="widthFix">
+					</view>
+					<view class="content">手机登录后才能查看名片哦~</view>
+				</view>
+				<view class="auth-btncard">
+					<view class="btn-unok">
+						<u-button :customStyle="customStyleUnOk" @click="showAuthorizePhone=false" :plain="true">
+							拒绝</u-button>
+					</view>
+					<view class="btn-ok">
+						<u-button :customStyle="customStyleOk" open-type="getPhoneNumber"
+							@getphonenumber="getPhoneNumber"> 立即登录</u-button>
+					</view>
+				</view>
+			</view>
+		</u-modal>
+		<u-modal :show="showAuthorizeUser" :showConfirmButton="false">
+			<view class="slot-content">
+				<view class="auth-card">
+					<view class="img">
+						<img class="avatar-img" src="/static/imgs/logo.png" mode="widthFix">
+					</view>
+					<view class="content">邀请您补全个人信息<br></br>(昵称、头像)</view>
+					<view style="margin-left: 100rpx;margin-right: 100rpx">
+						<u-form :model="userInfo" ref="uForm">
+							<u-form-item label="头像">
+								<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"
+									slot="right">
+									<image class="avatar"
+										:src="userInfo.head?userInfo.head:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'">
+									</image>
+								</button>
+							</u-form-item>
+							<u-form-item label="昵称">
+								<u-input inputAlign='right' v-model="userInfo.nickname" class="weui-input"
+									@blur="userNameInput" placeholder="请输入昵称" border="false" />
+								<!-- <input type="nickname" :value="userInfo.nickname" class="weui-input" @blur="userNameInput" placeholder="请输入昵称"/> -->
+							</u-form-item>
+						</u-form>
+					</view>
+				</view>
+				<view class="auth-btncard">
+					<view class="btn-unok"><u-button :customStyle="customStyleUnOk" @click="authUser(0)">
+							拒绝</u-button>
+					</view>
+					<view class="btn-ok">
+						<u-button :customStyle="customStyleOk" @click="authUser(1)"> 允许</u-button>
+					</view>
+				</view>
+			</view>
+		</u-modal>
+
+		<!-- #endif -->
 	</view>
 </template>
 
 <script>
+	var that;
+	import {
+		pathToBase64,
+		base64ToPath
+	} from 'image-tools'
 	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
 	import {
 		mapState,
@@ -104,67 +172,175 @@
 		},
 		data() {
 			return {
+				showAuthorizeUser: false,
+				showAuthorizePhone: false,
+				customStyleUnOk: {
+					marginTop: '20rpx',
+					color: '#18254C',
+					border: '2px solid #18254C',
+					"border-radius": "10px",
+					fontSize: "32rpx"
+				},
+				customStyleOk: {
+					marginTop: '20rpx',
+					color: '#fff',
+					border: '2px solid #18254C',
+					"border-radius": "10px",
+					fontSize: "32rpx",
+					background: "#18254C"
+				},
 				searchVal: '',
 				circleList: [],
 				userInfo: {},
 				canReset: false,
-				cardList:[],
-				circleList1:[]
+				cardList: [],
+				circleList1: [],
+				downOption: {
+					auto: false,
+					textColor: '#bbb'
+				},
+				upOption: {
+					page: {
+						size: 10 // 每页数据的数量,默认10
+					},
+					auto: false,
+					noMoreSize: 1,
+					textNoMore: '没有更多了~',
+					textColor: '#bbb'
+				}
 			};
 		},
 		onLoad() {
-			// this.searchVal = uni.getStorageSync("cirlce_search_val") ? uni.getStorageSync("cirlce_search_val") : ''
-			this.userInfo = uni.getStorageSync("userInfo")
-			this.$nextTick(function() {
-				this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页  
-				this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题  
-				this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
-			});
-			
-			
+			that = this
+			if (uni.getStorageSync("userInfo").phone) {
+				this.userInfo = uni.getStorageSync("userInfo")
+				this.$nextTick(function() {
+					that.mescroll.resetUpScroll()
+				});
+				this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'list', {
+					receiveId: this.userInfo.id,
+					status: 1
+				}, failres => {
+					console.log('res+++++', failres.errmsg)
+					uni.showToast({
+						icon: "none",
+						title: failres.errmsg,
+						duration: 3000
+					});
+
+				}).then(res => {
+					this.cardList = res.data.items.filter((item) => {
+						return item.status == 0
+					})
+					console.log(this.cardList)
+				})
+
+			}
 		},
 		onShow() {
-			this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'list', {
-				receiveId:this.userInfo.id,
-				status:1
-			}, failres => {
-				console.log('res+++++', failres.errmsg)
-				uni.showToast({
-				  icon:"none",
-				  title: failres.errmsg,
-				  duration: 3000
-				});
-				
-			}).then(res => {
-				this.cardList = res.data.items.filter((item)=>{return item.status==0})
-				console.log(this.cardList)
-			})
-		this.searchVal = uni.getStorageSync("cirlce_search_val") ? uni.getStorageSync("cirlce_search_val") : ''
-		if(this.searchVal) this.mescroll.resetUpScroll();
+			if (uni.getStorageSync("userInfo").phone) {
+				this.userInfo = uni.getStorageSync("userInfo")
+				this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'list', {
+					receiveId: this.userInfo.id,
+					status: 1
+				}, failres => {
+					console.log('res+++++', failres.errmsg)
+					uni.showToast({
+						icon: "none",
+						title: failres.errmsg,
+						duration: 3000
+					});
+
+				}).then(res => {
+					this.searchVal = uni.getStorageSync("cirlce_search_val") ? uni.getStorageSync(
+						"cirlce_search_val") : ''
+					if (this.searchVal) this.mescroll.resetUpScroll();
+				})
+			
+			} else {
+				this.showAuthorizePhone = true
+			}
+
 		},
 		methods: {
+			//获取昵称输入内容
+			userNameInput(e) {
+				this.userInfo.nickname = e.detail.value
+			},
+			async onChooseAvatar(e) {
+				this.$set(this.userInfo, "head", await this.toBase64(e.detail.avatarUrl))
+			},
+			toBase64(url) {
+				return new Promise(resolve => {
+					pathToBase64(url).then(path => {
+						resolve(path);
+					}).catch(error => {
+						console.log(error)
+					})
+				})
+			},
+			async authUser(type) {
+				//同步信息,没有头像和昵称自动生成
+				this.userInfo =  await this.$request.syncInfo(this.userInfo)
+				if(this.userInfo.openId) {
+					uni.setStorageSync("userInfo", that.userInfo)
+					that.showAuthorizeUser = false
+					that.mescroll.resetUpScroll()
+				}
+			},
+			
+			downCallback() {
+				if (uni.getStorageSync("userInfo").phone) {
+					this.mescroll.resetUpScroll()
+				} else {
+					this.mescroll.endBySize(0, 0)
+					this.showAuthorizePhone = true
+				}
+			
+			},
+			async getPhoneNumber(e) {
+				that.userInfo = await this.$request.wxlogin()
+				that.userInfo.phone = await this.$request.getPhone(e, that.userInfo)
+				this.showAuthorizePhone = false
+				this.showAuthorizeUser = true
+
+			},
 			delSearchVal() {
 				this.searchVal = ""
 				uni.removeStorageSync('cirlce_search_val')
 				this.mescroll.resetUpScroll()
 			},
 			toChangeCard() {
-				uni.navigateTo({
-					url: "/pages/circle/changeCard"
-				})
+				if (this.userInfo.phone) {
+					uni.navigateTo({
+						url: "/pages/circle/changeCard"
+					})
+				} else {
+					this.showAuthorizePhone = true
+				}
+				
 			},
 			toCreateCircle() {
-				uni.navigateTo({
-					url: "/pages/circle/createCirclce"
-				})
+				if (this.userInfo.phone) {
+					uni.navigateTo({
+						url: "/pages/circle/createCirclce"
+					})
+				} else {
+					this.showAuthorizePhone = true
+				}
 			},
 			micOpen: function() {
 				this.$refs.asr.show();
 			},
 			search() {
-				uni.navigateTo({
-					url: "/pages/circle/search"
-				})
+				if (this.userInfo.phone) {
+					uni.navigateTo({
+						url: "/pages/circle/search"
+					})
+				} else {
+					this.showAuthorizePhone = true
+				}
+				
 			},
 			toDetail(val) {
 				uni.navigateTo({
@@ -179,7 +355,7 @@
 					commonId: this.userInfo.id,
 					page: page.num,
 					limit: page.size,
-					status:1
+					status: 1
 				}
 				if (this.searchVal) {
 					_data.circleName = this.searchVal
@@ -187,9 +363,9 @@
 				this.$request.baseRequest('admin.unimall.circleManagementInfo', 'list', _data, failres => {
 					console.log('res+++++', failres.errmsg)
 					uni.showToast({
-					  icon:"none",
-					  title: failres.errmsg,
-					  duration: 3000
+						icon: "none",
+						title: failres.errmsg,
+						duration: 3000
 					});
 					uni.hideLoading()
 				}).then(res => {
@@ -203,23 +379,30 @@
 					// this.makeData(res.data)
 					//追加新数据
 					for (let i = 0; i < this.circleList.length; i++) {
-						if(this.circleList[i].circleLabel){
-							if(this.circleList[i].circleLabel.split(',').length>=3){
-								var arr=this.circleList[i].circleLabel.split(',')
+						if (this.circleList[i].circleLabel) {
+							if (this.circleList[i].circleLabel.split(',').length >= 3) {
+								var arr = this.circleList[i].circleLabel.split(',')
 								console.log(arr)
-								this.circleList[i].circleLabelArray=arr.filter((item,index)=>{return index<=2})
-							}else{
-								this.circleList[i].circleLabelArray=this.circleList[i].circleLabel.split(',')
+								this.circleList[i].circleLabelArray = arr.filter((item, index) => {
+									return index <= 2
+								})
+							} else {
+								this.circleList[i].circleLabelArray = this.circleList[i].circleLabel.split(',')
 							}
 						}
 					}
-					
-					if (page.num == 1) this.circleList1 = []; this.circleList = []; //如果是第一页需手动置空列表
-					var tjarr=curPageData.filter((item)=>{return item.addedFlag==0})
-					var wdarr=curPageData.filter((item)=>{return item.addedFlag==1})
-					this.circleList1 = this.circleList1.concat(wdarr); 
-					this.circleList = this.circleList.concat(tjarr); 
-					
+
+					if (page.num == 1) this.circleList1 = [];
+					this.circleList = []; //如果是第一页需手动置空列表
+					var tjarr = curPageData.filter((item) => {
+						return item.addedFlag == 0
+					})
+					var wdarr = curPageData.filter((item) => {
+						return item.addedFlag == 1
+					})
+					this.circleList1 = this.circleList1.concat(wdarr);
+					this.circleList = this.circleList.concat(tjarr);
+
 				})
 			},
 			input(res) {
@@ -265,15 +448,16 @@
 				border-radius: 38rpx;
 				padding: 18rpx;
 				width: 100%;
-				position:relative;
+				position: relative;
 			}
 
 			.search-val {
 				color: #B3B3B3;
 			}
-			.search-del{
-				position:absolute;
-				right:10px;
+
+			.search-del {
+				position: absolute;
+				right: 10px;
 			}
 		}
 
@@ -344,6 +528,7 @@
 
 			.bottom {
 				margin-top: 10rpx;
+
 				.text {
 					background: #FAFAFA;
 					border-radius: 10rpx;
@@ -351,24 +536,85 @@
 					font-weight: 700;
 					color: #666666;
 					padding: 10rpx 20rpx;
-					margin:0px 10rpx 10rpx 0;
+					margin: 0px 10rpx 10rpx 0;
 				}
 			}
 		}
 	}
 
-	.add{
-		width:84rpx;
+	.add {
+		width: 84rpx;
 		height: auto;
 		position: fixed;
 		bottom: 26rpx;
 		right: 26rpx;
 		height: auto;
+		z-index: 999;
 	}
-	.wd-list,.tj-list{
+
+	.wd-list,
+	.tj-list {
 		border-radius: 20rpx;
-		background:#fff;
+		background: #fff;
 		margin: 0 34rpx;
 	}
 
+	.slot-content {
+		width: 100%;
+	}
+
+	.auth-btncard {
+		display: flex !important;
+		justify-content: space-between !important;
+
+		.btn-unok {
+			width: 40%;
+		}
+
+		.btn-ok {
+			width: 40%;
+		}
+	}
+
+	.auth-card {
+		text-align: center;
+
+		.avatar-img {
+			width: 250rpx;
+		}
+
+		.title {
+			font-size: 20rpx;
+		}
+
+		.content {
+			font-size: 32rpx;
+			font-weight: bold;
+			color: #1A1A1A;
+			margin-bottom: 30rpx;
+		}
+	}
+
+	.avatar-wrapper {
+		color: #333 !important;
+		border: none !important;
+		border-radius: 0 !important;
+		background-color: transparent !important;
+		padding: 0;
+	}
+
+	.avatar-wrapper::after {
+		border: none !important;
+	}
+
+	.avatar {
+		width: 100rpx;
+		height: 100rpx;
+		overflow: hidden;
+		border-radius: 100%;
+	}
+
+	/deep/.u-popup__content {
+		border-radius: 20rpx !important;
+	}
 </style>

+ 25 - 6
xiaochengxu/pages/mySet/myInfo.vue

@@ -225,13 +225,13 @@
 					<view class="block" @click="toUrl()">
 						<button class="moment">
 							<view class="iconfont icon-pengyouquan"></view>
-							<view>分享朋友圈</view>
+							<view style="font-size: 26rpx;">分享朋友圈</view>
 						</button>
 					</view>
 					<view class="block">
 						<button class="shareBtn" type="default" data-name="shareBtn" open-type="share">
 							<view class="iconfont icon-weixin"></view>
-							<view>分享微信好友</view>
+							<view  style="font-size: 26rpx;">分享微信好友</view>
 						</button>
 					</view>
 				</view>
@@ -271,13 +271,31 @@
 		},
 		onLoad() {
 			that = this
-			this.userInfo = uni.getStorageSync("userInfo")
+
 		},
 		onShow() {
-			this.init()
+			console.log(123123)
+			if (uni.getLaunchOptionsSync().scene == 1154) {
+				uni.showToast({
+					title: '请前往小程序查看名片~',
+					icon: 'none',
+					duration: 10000
+				});
+			} 
+			this.userInfo = uni.getStorageSync("userInfo")
+			if (uni.getStorageSync("userInfo").phone) {
+				this.init()
+			} else {
+				uni.switchTab({
+					url:'/pages/cardHolder/cardHolder'
+				})
+			
+				
+			}
+
 		},
 		onShareAppMessage(res) {
-
+			debugger
 			console.log(res, this.popupshow)
 			let that = this;
 			//生成名片图片
@@ -285,6 +303,7 @@
 			console.log("imageUrl", imageUrl)
 			if (res.from === 'button') {
 				let path = `/pages/cardHolder/scanCodeAddCard?id=${that.currectData.id}`
+				console.log("分享地址",path)
 				return {
 					title: this.popupshow ? `${that.currectData.name}分享的名片~` : '电子名片',
 					path: path,
@@ -703,7 +722,7 @@
 			},
 			addCard() {
 				uni.navigateTo({
-					url: "/pages/mySet/newCard?cardIndex="+(this.cardList.length+1)
+					url: "/pages/mySet/newCard?cardIndex=" + (this.cardList.length + 1)
 				})
 			},
 			topMarking(val) {

+ 286 - 109
xiaochengxu/pages/mySet/mySet.vue

@@ -5,7 +5,7 @@
 				<image :src="userInfo.head?userInfo.head:'../../static/imgs/mySet/head.png'" mode="widthFix" class="img"
 					@click="editHead"></image>
 				<view @click="editNickName" class="name">
-					{{userInfo.nickname}}
+					{{userInfo.nickname?userInfo.nickname:''}}
 				</view>
 			</view>
 			<view class="position">
@@ -20,8 +20,8 @@
 				@click="menuClick(item.type)">
 				<view class="flex" style="width: 100%;">
 					<image :src="item.src" mode="widthFix" class="nav-img"></image>
-					<button class="left-btn" v-if='item.type=="contactCustomer"'
-						open-type='contact' style="width: 90%;">{{item.name}}</button>
+					<button class="left-btn" v-if='item.type=="contactCustomer"' open-type='contact'
+						style="width: 90%;">{{item.name}}</button>
 					<span class="left" v-else>{{item.name}}</span>
 				</view>
 
@@ -33,12 +33,70 @@
 		<u-popup :show="isShowCode" @close="isShowCode=false" mode="center" :round='10'>
 			<image :src="selectCode" mode="widthFix" style="height: auto;"></image>
 		</u-popup>
-		<u-picker :immediateChange ="true" keyName="cardBusiness" :confirmType='"share"' :confirmText='"分享"' title="选择名片" @cancel="show=false"
-			closeOnClickOverlay @change="cardChange" :show="show" :columns="cardList"></u-picker>
-		<u-picker :immediateChange ="true" keyName="cardBusiness" confirmText='确定' title="选择名片" @cancel="show1=false" closeOnClickOverlay
-			@confirm="cardConfirm" :show="show1" :columns="cardList" ></u-picker>
+		<u-picker :immediateChange="true" keyName="cardBusiness" :confirmType='"share"' :confirmText='"分享"' title="选择名片"
+			@cancel="show=false" closeOnClickOverlay @change="cardChange" :show="show" :columns="cardList"></u-picker>
+		<u-picker :immediateChange="true" keyName="cardBusiness" confirmText='确定' title="选择名片" @cancel="show1=false"
+			closeOnClickOverlay @confirm="cardConfirm" :show="show1" :columns="cardList"></u-picker>
 		<poster :data="canvasData" background-color="#FFF" :width='750' :height='420' @on-success="posterSuccess"
 			ref="poster" @on-error="posterError"></poster>
+		<!-- #ifdef MP-WEIXIN -->
+		<u-modal :show="showAuthorizePhone" :showConfirmButton="false">
+			<view class="slot-content">
+				<view class="auth-card">
+					<view class="img">
+						<img class="avatar-img" src="@/static/imgs/logo.png" mode="widthFix">
+					</view>
+					<view class="content">手机登录后才能查看名片哦~</view>
+				</view>
+				<view class="auth-btncard">
+					<view class="btn-unok">
+						<u-button :customStyle="customStyleUnOk" @click="showAuthorizePhone=false" :plain="true">
+							拒绝</u-button>
+					</view>
+					<view class="btn-ok">
+						<u-button :customStyle="customStyleOk" open-type="getPhoneNumber"
+							@getphonenumber="getPhoneNumber"> 立即登录</u-button>
+					</view>
+				</view>
+			</view>
+		</u-modal>
+		<u-modal :show="showAuthorizeUser" :showConfirmButton="false">
+			<view class="slot-content">
+				<view class="auth-card">
+					<view class="img">
+						<img class="avatar-img" src="/static/imgs/logo.png" mode="widthFix">
+					</view>
+					<view class="content">邀请您补全个人信息<br></br>(昵称、头像)</view>
+					<view style="margin-left: 100rpx;margin-right: 100rpx">
+						<u-form :model="userInfo" ref="uForm">
+							<u-form-item label="头像">
+								<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"
+									slot="right">
+									<image class="avatar"
+										:src="userInfo.head?userInfo.head:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'">
+									</image>
+								</button>
+							</u-form-item>
+							<u-form-item label="昵称">
+								<u-input inputAlign='right' v-model="userInfo.nickname" class="weui-input"
+									@blur="userNameInput" placeholder="请输入昵称" border="false" />
+								<!-- <input type="nickname" :value="userInfo.nickname" class="weui-input" @blur="userNameInput" placeholder="请输入昵称"/> -->
+							</u-form-item>
+						</u-form>
+					</view>
+				</view>
+				<view class="auth-btncard">
+					<view class="btn-unok"><u-button :customStyle="customStyleUnOk" @click="authUser(0)">
+							拒绝</u-button>
+					</view>
+					<view class="btn-ok">
+						<u-button :customStyle="customStyleOk" @click="authUser(1)"> 允许</u-button>
+					</view>
+				</view>
+			</view>
+		</u-modal>
+
+		<!-- #endif -->
 		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
@@ -46,6 +104,10 @@
 <script>
 	var that;
 	import uploadImage from '@/components/ossutil/uploadFile.js';
+	import {
+		pathToBase64,
+		base64ToPath
+	} from 'image-tools'
 	import Poster from '../../components/zhangyuhao-poster/Poster.vue'
 	export default {
 		components: {
@@ -53,6 +115,24 @@
 		},
 		data() {
 			return {
+				// 是否弹出登录注册授权弹窗
+				showAuthorizeUser: false,
+				showAuthorizePhone: false,
+				customStyleUnOk: {
+					marginTop: '20rpx',
+					color: '#18254C',
+					border: '2px solid #18254C',
+					"border-radius": "10px",
+					fontSize: "32rpx"
+				},
+				customStyleOk: {
+					marginTop: '20rpx',
+					color: '#fff',
+					border: '2px solid #18254C',
+					"border-radius": "10px",
+					fontSize: "32rpx",
+					background: "#18254C"
+				},
 				userInfo: {},
 				cardList: [],
 				canvasData: {},
@@ -108,51 +188,15 @@
 		},
 		onShow() {
 			this.userInfo = uni.getStorageSync("userInfo")
-		},
-		onLoad() {
-			that = this
-			this.userInfo = uni.getStorageSync("userInfo")
-			if (!this.userInfo.nickname) {
-				let code = ""
-				for (var i = 0; i < 6; i++) {
-					code += parseInt(Math.random() * 10);
-				}
-				this.userInfo.nickname = 'user' + code
-				this.$request.baseRequest('commonUserApp', 'edit', {
-					commonUserInfo: JSON.stringify(this.userInfo)
-				}, failres => {
-					uni.hideLoading()
-					uni.showToast({
-						icon: "none",
-						title: failres.errmsg,
-						duration: 3000
-					});
-				}).then(res => {
-					this.userInfo = res.data
-					uni.setStorageSync("userInfo", this.userInfo)
-				})
-			}
 			if (this.userInfo.phone) {
-				this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
-					commonId: this.userInfo.id
-				}, failres => {
-					uni.hideLoading()
-					uni.showToast({
-						icon: "none",
-						title: failres.errmsg,
-						duration: 3000
-					});
+				this.getData()
 
-				}).then(res => {
-					this.list = res.data.items
-					this.cardList = [res.data.items]
-				})
 			} else {
-				uni.switchTab({
-					url: "/pages/cardHolder/cardHolder"
-				})
+				this.showAuthorizePhone = true
 			}
-
+		},
+		onLoad() {
+			that = this
 		},
 		onShareAppMessage(res) {
 			this.popupshow = false
@@ -178,75 +222,143 @@
 			}
 		},
 		methods: {
-			editNickName(){
-				let _url = '/pages/mySet/editNickName'
-				uni.navigateTo({
-					url: _url
+			getData() {
+				this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
+					commonId: this.userInfo.id
+				}, failres => {
+					uni.hideLoading()
+					uni.showToast({
+						icon: "none",
+						title: failres.errmsg,
+						duration: 3000
+					});
+
+				}).then(res => {
+					this.list = res.data.items
+					this.cardList = [res.data.items]
+				})
+			},
+			//获取昵称输入内容
+			userNameInput(e) {
+				this.userInfo.nickname = e.detail.value
+			},
+			async onChooseAvatar(e) {
+				this.$set(this.userInfo, "head", await this.toBase64(e.detail.avatarUrl))
+			},
+			toBase64(url) {
+				return new Promise(resolve => {
+					pathToBase64(url).then(path => {
+						resolve(path);
+					}).catch(error => {
+						console.log(error)
+					})
 				})
 			},
+			async authUser(type) {
+				//同步信息,没有头像和昵称自动生成
+				this.userInfo = await this.$request.syncInfo(this.userInfo)
+				if (this.userInfo.openId) {
+					uni.setStorageSync("userInfo", that.userInfo)
+					that.showAuthorizeUser = false
+					this.getData()
+				}
+			},
+			async getPhoneNumber(e) {
+				that.userInfo = await this.$request.wxlogin()
+				that.userInfo.phone = await this.$request.getPhone(e, that.userInfo)
+				this.showAuthorizePhone = false
+				this.showAuthorizeUser = true
+
+			},
+			editNickName() {
+				if (this.userInfo.phone) {
+					let _url = '/pages/mySet/editNickName'
+					uni.navigateTo({
+						url: _url
+					})
+				} else {
+					this.showAuthorizePhone = true
+				}
+			},
 			editHead() {
-				uni.chooseImage({
-					count: 1,
-					sizeType: ['original', 'compressed'],
-					success: function(res) {
-						uploadImage(res.tempFilePaths[0], 'cardImages/',
-							result => {
-								that.userInfo.head = result
-								that.$request.baseRequest('commonUserApp', 'edit', {
-									commonUserInfo: JSON.stringify(that.userInfo)
-								}, failres => {
-									uni.hideLoading()
-									uni.showToast({
-									  icon:"none",
-									  title: failres.errmsg,
-									  duration: 3000
-									});
-								}).then(res => {
-									uni.setStorageSync("userInfo", that.userInfo)
-									uni.showToast({
-									  icon:"success",
-									  title: '修改成功!',
-									  duration: 2000,
-									  complete:function(){
-										  uni.switchTab({
-										  	url: "/pages/mySet/mySet"
-										  })
-									  }
+				if (this.userInfo.phone) {
+					uni.chooseImage({
+						count: 1,
+						sizeType: ['original', 'compressed'],
+						success: function(res) {
+							uploadImage(res.tempFilePaths[0], 'cardImages/',
+								result => {
+									that.userInfo.head = result
+									that.$request.baseRequest('commonUserApp', 'edit', {
+										commonUserInfo: JSON.stringify(that.userInfo)
+									}, failres => {
+										uni.hideLoading()
+										uni.showToast({
+											icon: "none",
+											title: failres.errmsg,
+											duration: 3000
+										});
+									}).then(res => {
+										uni.setStorageSync("userInfo", that.userInfo)
+										uni.showToast({
+											icon: "success",
+											title: '修改成功!',
+											duration: 2000,
+											complete: function() {
+												uni.switchTab({
+													url: "/pages/mySet/mySet"
+												})
+											}
+										})
 									})
-								})
-							}
-						)
-					}
-				});
+								}
+							)
+						}
+					});
+				} else {
+					this.showAuthorizePhone = true
+				}
 			},
 			handleHiddenShare() {
 				this.popupshow = false
 			},
 			selectCard() {
-
-				if (this.cardList[0].length > 0) {
-					this.index = 0
-					this.cardChange({
-						value: this.cardList[[0]]
-					})
-				} else if (this.cardList[0].length == 0) {
-					uni.showToast({
-					  icon:"none",
-					  title: '您还未创建名片',
-					  duration: 3000
-					})
+				if (this.userInfo.phone) {
+					if (this.cardList[0].length > 0) {
+						this.index = 0
+						this.cardChange({
+							value: this.cardList[[0]]
+						})
+					} else if (this.cardList[0].length == 0) {
+						uni.showToast({
+							icon: "none",
+							title: '您还未创建名片',
+							duration: 3000
+						})
+					}
+				} else {
+					this.showAuthorizePhone = true
 				}
 			},
 			selectCard1() {
-				console.log(this.cardList[0])
-				if (this.cardList[0].length > 1) {
-					this.show1 = true
-				} else if (this.cardList[0].length > 0) {
-					this.cardConfirm({
-						value: this.cardList[[0]]
-					})
+				if (this.userInfo.phone) {
+					console.log(this.cardList[0])
+					if (this.cardList[0].length > 1) {
+						this.show1 = true
+					} else if (this.cardList[0].length > 0) {
+						this.cardConfirm({
+							value: this.cardList[[0]]
+						})
+					} else if (this.cardList[0].length == 0) {
+						uni.showToast({
+							icon: "none",
+							title: '您还未创建名片',
+							duration: 3000
+						})
+					}
+				} else {
+					this.showAuthorizePhone = true
 				}
-
 			},
 			cardConfirm(e) {
 				console.log(e)
@@ -537,11 +649,17 @@
 				uni.hideLoading()
 			},
 			menuClick(typeName) {
-				if (typeName == "contactCustomer") return
-				let _url = '/pages/mySet/' + typeName
-				uni.navigateTo({
-					url: _url
-				})
+				if (this.userInfo.phone) {
+					if (typeName == "contactCustomer") return
+					let _url = '/pages/mySet/' + typeName
+					uni.navigateTo({
+						url: _url
+					})
+				} else {
+					this.showAuthorizePhone = true
+				}
+
+
 			}
 
 		}
@@ -634,4 +752,63 @@
 		border: none;
 
 	}
+
+	.slot-content {
+		width: 100%;
+	}
+
+	.auth-btncard {
+		display: flex !important;
+		justify-content: space-between !important;
+
+		.btn-unok {
+			width: 40%;
+		}
+
+		.btn-ok {
+			width: 40%;
+		}
+	}
+
+	.auth-card {
+		text-align: center;
+
+		.avatar-img {
+			width: 250rpx;
+		}
+
+		.title {
+			font-size: 20rpx;
+		}
+
+		.content {
+			font-size: 32rpx;
+			font-weight: bold;
+			color: #1A1A1A;
+			margin-bottom: 30rpx;
+		}
+	}
+
+	.avatar-wrapper {
+		color: #333 !important;
+		border: none !important;
+		border-radius: 0 !important;
+		background-color: transparent !important;
+		padding: 0;
+	}
+
+	.avatar-wrapper::after {
+		border: none !important;
+	}
+
+	.avatar {
+		width: 100rpx;
+		height: 100rpx;
+		overflow: hidden;
+		border-radius: 100%;
+	}
+
+	/deep/.u-popup__content {
+		border-radius: 20rpx !important;
+	}
 </style>

+ 89 - 2
xiaochengxu/util/request.js

@@ -1,4 +1,5 @@
 import * as config from '@/config'
+import WXBizDataCrypt from './WXBizDataCrypt.js'
 let baseUrl = config.def().baseUrlNew
 // 定义基础请求路径(后端服务器地址)
 const baseRequest = (_gp, _mt, data = {}, failCallback) => {
@@ -92,8 +93,94 @@ const TokenRequest = (method, url, data, header) => {
 	})
 	return promise
 }
+
+//微信登录
+const wxlogin = () => {
+	let promise = new Promise(function(resolve, reject) {
+		uni.login({
+			"provider": "weixin",
+			success: function(wxres) {
+				baseRequest('commonUserApp', 'commonUserLogin', {
+					loginType: 1,
+					raw: JSON.stringify(wxres)
+				}, failres => {
+					uni.showToast({
+						icon: "none",
+						title: failres.errmsg,
+						duration: 3000
+					});
+					uni.hideLoading()
+				}).then(res => {
+					console.log(res.data)
+					resolve(res.data)
+				})
+			},
+			fail: function(err) {
+				reject(err.code)
+			}
+		})
+	})
+	return promise
+}
+
+//获取手机号
+const getPhone = (e, userInfo) => {
+	let promise = new Promise(function(resolve, reject) {
+		if (e.mp.detail.errMsg === "getPhoneNumber:ok") {
+			let appId = 'wx5d8906c2208c899f'
+			let sessionKey = userInfo.sessionKey
+			let encryptedData = e.mp.detail.encryptedData
+			let iv = e.mp.detail.iv
+			let data =''
+			try {
+				data= WXBizDataCrypt.prototype.decryptData(encryptedData, iv, appId, sessionKey)
+				console.log('解密后 data: ', data)
+				resolve(data.phoneNumber)
+			} catch (e) {
+				uni.showToast({
+					icon: "none",
+					title: e,
+					duration: 3000
+				});
+			}
+		}
+	})
+	return promise
+}
+
+//同步信息
+const syncInfo = (userInfo) => {
+	let promise = new Promise(function(resolve, reject) {
+		debugger
+		if (!userInfo.head) userInfo.head =
+			'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/card_head.png'
+		if (!userInfo.nickname) {
+			let code = ""
+			for (var i = 0; i < 6; i++) {
+				code += parseInt(Math.random() * 10);
+			}
+			userInfo.nickname = 'user' + code
+		}
+		baseRequest('commonUserApp', 'edit', {
+			commonUserInfo: JSON.stringify(userInfo)
+		}, failres => {
+			uni.showToast({
+				icon: "none",
+				title: failres.errmsg,
+				duration: 3000
+			});
+			reject(err.code)
+		}).then(res => {
+			resolve(res.data)
+		})
+	})
+	return promise
+}
 export default {
 	baseUrl,
 	baseRequest,
-	TokenRequest
-}
+	TokenRequest,
+	wxlogin,
+	getPhone,
+	syncInfo
+}