Explorar o código

用户实名认证,登录用户服务协议、用户隐私政策

gcz %!s(int64=2) %!d(string=hai) anos
pai
achega
f7c504e299
Modificáronse 8 ficheiros con 347 adicións e 13 borrados
  1. 137 0
      center/factorauth.vue
  2. 13 0
      center/memberinfo.vue
  3. 10 0
      common/apiurl.js
  4. 6 6
      common/config.js
  5. 14 0
      pages.json
  6. 47 4
      pages/login/login.vue
  7. 58 0
      pages/login/regulation.vue
  8. 62 3
      shopping/productdetails.vue

+ 137 - 0
center/factorauth.vue

@@ -0,0 +1,137 @@
+<template>
+	<view class="pages">
+		<u-navbar
+			title="实名认证"
+			:placeholder="true"
+			:autoBack="true"
+			@leftClick="leftClick"
+			 :safeAreaInsetTop="true"
+		>
+		</u-navbar>
+		<view class="page-wrap">
+			<view class="login-box">
+				<u--form labelPosition="left" labelWidth="200rpx" :model="form" :rules="rules" ref="uForm" >
+					<u-form-item label="真实姓名" prop="name" borderBottom ref="name" >
+						<u--input
+							v-model="form.name"
+							placeholder="真实姓名"
+							border="none"
+							:customStyle="inputCustomStyle"
+						></u--input>
+					</u-form-item>
+					<u-form-item label="身份证号码" prop="idcard" ref="idcard" >
+						<u--input
+							v-model="form.idcard"
+							border="none"
+							placeholder="身份证号码"
+							:customStyle="inputCustomStyle"
+						></u--input>
+					</u-form-item>
+				</u--form>
+				<u-button 
+					@click="submit"
+					text="提交认证" 
+					type="warning" 
+					shape="circle" 
+					:customStyle="{'margin-top':'60rpx',height:'98rpx','box-sizing':'border-box'}">
+				</u-button>
+			</view>
+		</view>
+		<u-toast ref="uToast"></u-toast>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				backUrl:'',
+				form:{
+					name:'',
+					idcard:''
+				},
+				rules: {
+					name: {
+						type: 'string',
+						required: true,
+						message: '请填写真实姓名',
+						trigger: ['blur', 'change']
+					},
+					idcard:[
+						{
+							type: 'string',
+							required: true,
+							message: '请填身份证号码',
+							trigger: ['blur', 'change']
+						},
+						{
+							validator: (rule, value, callback) => {
+								// 上面有说,返回true表示校验通过,返回false表示不通过
+								// uni.$u.test.mobile()就是返回true或者false的
+								return uni.$u.test.idCard(value);
+							},
+							message: '身份证号码不正确',
+							// 触发器可以同时用blur和change
+							trigger: ['change','blur'],
+						}
+					]
+				},
+				inputCustomStyle:{}
+			}
+		},
+		onShow() {
+		},
+		onReady() {
+			//onReady 为uni-app支持的生命周期之一
+			this.$refs.uForm.setRules(this.rules)
+		},
+		onLoad(page) {
+			console.log('page',page);
+			this.backUrl =  decodeURIComponent(page.backUrl)||'/center/center'
+		},
+		methods: {
+			leftClick(){
+				
+			},
+			submit(){
+				// console.log('form',this.form);
+				this.$refs.uForm.validate().then(res => {
+					// uni.$u.toast('校验通过')
+					this.$u.api.factorAuth(this.form).then(res=>{
+						this.getMemberInfo()
+						// console.log('res',res.data);
+					}).catch(err=>{
+						// this.$refs.uToast.show({
+						// 	type: 'error',
+						// 	icon: false,
+						// 	title: '认证失败',
+						// 	message: err.msg,
+						// })
+						console.log('login',err);
+					})
+				}).catch(errors => {
+					uni.$u.toast('请正确填写表单')
+				})
+			},
+			getMemberInfo(){
+				this.$u.api.memberInfo({id:this.vuex_user_info.userid}).then(res=>{
+					this.$u.vuex('vuex_member_info', res.data);
+					uni.showToast({
+						title:'认证成功',
+						icon:'success'
+					})
+					setTimeout(()=>{
+						uni.reLaunch({url: this.backUrl});
+					},2000)
+					// console.log('memberInfo',this.memberInfo);
+					}).catch(err=>{
+					// console.log('memberInfo',err.data);
+				})
+			},
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+
+</style>

+ 13 - 0
center/memberinfo.vue

@@ -32,6 +32,7 @@
 				<u-cell title="性别" @click="showSex=true" :value="memberInfo.sex|filterSex"></u-cell>
 				<u-cell title="生日" :value="memberInfo.birthdayTime||'未设置'" @click="timeShow = true" :isLink="true"></u-cell>
 				<u-cell title="会员等级" :value="memberInfo.levelName"></u-cell>
+				<u-cell title="实名制认证" @click="factorAuth" :value="memberInfo.isAuth==1?'已认证':'去认证'"></u-cell>
 			</u-cell-group>
 			<!-- <u-button text="取消登录" type="warning" @click="clearStorage" style="margin-top: 30rpx;"></u-button> -->
 			<u-datetime-picker
@@ -183,6 +184,18 @@
 				this.sex = e.val;
 				this.updateMemberInfo('sex')
 				console.log('sexSelect',e);
+			},
+			factorAuth(){
+				if(this.memberInfo.isAuth==1){
+					uni.showToast({
+						title:'已认证',
+						icon:'none'
+					})
+					return
+				}
+				uni.$u.route('/center/factorauth', {
+					backUrl: '/center/center'
+				});
 			}
 		}
 	}

+ 10 - 0
common/apiurl.js

@@ -294,6 +294,16 @@ const apiurl = {
 		url: '/memberInfo/selectBalanceLogList',
 		type: 'get'
 	},
+	// 实名认证
+	factorAuth: {
+		url: '/memberInfo/factorAuth',
+		type: 'post'
+	},
+	// 注册协议
+	getRegistinfoByName: {
+		url: '/memberCreditDesc/getRegistinfoByName',
+		type: 'get'
+	},
 }
 
 

+ 6 - 6
common/config.js

@@ -12,14 +12,14 @@
 // }
 
 //64
-// let baseUrl='https://xusfoodapi.hw.hongweisoft.com/appapi/app';
-// let upFileUrl='http://fileupload.hw.hongweisoft.com/upload/single/minio';
-// let staticUrl='http://res.hw.hongweisoft.com/xushuo/';
+let baseUrl='https://xusfoodapi.hw.hongweisoft.com/appapi/app';
+let upFileUrl='http://fileupload.hw.hongweisoft.com/upload/single/minio';
+let staticUrl='http://res.hw.hongweisoft.com/xushuo/';
 
 //正式
-let baseUrl='https://xusapi.gzxsjt.cn/appapi/app';
-let upFileUrl='https://xusapi.gzxsjt.cn/thirdapi/upload/single/minio';
-let staticUrl='http://res.gzxsjt.cn/xushuo/';
+// let baseUrl='https://xusapi.gzxsjt.cn/appapi/app';
+// let upFileUrl='https://xusapi.gzxsjt.cn/thirdapi/upload/single/minio';
+// let staticUrl='http://res.gzxsjt.cn/xushuo/';
 
 const commonConfig = {
 	wxAppid: '', // 测试wxAppid

+ 14 - 0
pages.json

@@ -13,6 +13,13 @@
 				"navigationBarTitleText": "登录",
 				"navigationStyle": "custom"
 			}
+		},
+		{
+			"path": "pages/login/regulation",
+			"style": {
+				"navigationBarTitleText": "使用条款",
+				"navigationStyle": "custom"
+			}
 		}
 	],
 	"subPackages": [
@@ -26,6 +33,13 @@
 						"navigationStyle": "custom"
 					}
 				},
+				{
+					"path": "factorauth",
+					"style": {
+						"navigationBarTitleText": "实名认证",
+						"navigationStyle": "custom"
+					}
+				},
 				{
 					"path": "memberinfo",
 					"style": {

+ 47 - 4
pages/login/login.vue

@@ -10,7 +10,31 @@
 				@click="getUserProfile"></u-button> -->
 			<!-- <u-button v-if="loginBtn" text="微信一键登录" type="success" :hairline="false" throttleTime="2000" shape="circle" 
 				@click="openAuth"></u-button> -->
-			<u-button v-if="loginBtn" :hair-line='false' type="success" throttleTime="2000" shape="circle" open-type="getPhoneNumber" @getphonenumber="authPhone">登录</u-button>
+			<view class="btn-wrap" style="margin:24rpx">
+				<u-button
+					v-if="loginBtn&&checked.length>0" 
+					:hair-line='false' 
+					type="success" 
+					throttleTime="2000" 
+					shape="circle" 
+					open-type="getPhoneNumber" 
+					@getphonenumber="authPhone">微信一键登录
+				</u-button>
+				<u-button
+					v-else
+					:hair-line='false' 
+					type="success" 
+					@click="disabledClick"
+					shape="circle">微信一键登录
+				</u-button>
+			</view>
+			<view class="rule-wrap u-flex u-flex-wrap u-row-center">
+				<u-checkbox-group v-model="checked" @change="checkboxChange" placement="row">
+					<u-checkbox activeColor="#00A447" name="同意" labelSize="26rpx" shape="circle" label="登录代表您已同意"></u-checkbox>
+				</u-checkbox-group>
+				<text class="link" @click="$u.route('/pages/login/regulation',{regulationName:'用户服务协议'})">《用户服务协议》</text>
+				和<text class="link" @click="$u.route('/pages/login/regulation',{regulationName:'用户隐私政策'})">《用户隐私政策》</text>
+			</view>
 		</view>
 		
 		<!-- 微信获取手机号弹窗 -->
@@ -70,6 +94,8 @@
 	export default {
 		data() {
 			return {
+				checked:false,
+				checkboxVal:null,
 				loginBtn:true,
 				bname:'旭烁集团',
 				//屏幕高度
@@ -313,6 +339,15 @@
 			},
 			nickNameInput(e){
 				this.user.name = e.detail.value
+			},
+			checkboxChange(e){
+				this.checkboxVal = e[0];
+			},
+			disabledClick(){
+				uni.showToast({
+					title:'请先同意使用条款!',
+					icon:'none'
+				})
 			}
 		}
 	}
@@ -322,8 +357,9 @@
 .body {
 	// width: 100%;
 	background-color: #f3f3f3;
-	padding: 24px;
+	// padding: 24px;
 	box-sizing: border-box;
+	text-align: center;
 	.logo {
 		padding-top: 200rpx;
 		margin: auto;
@@ -334,7 +370,6 @@
 	.title {
 		width: 90%;
 		margin: 0 auto 30rpx;
-		text-align: center;
 		font-size: 18px;
 		color: #111;
 	}
@@ -400,6 +435,14 @@
 	border-radius: 100%;
 }
 
-
+.rule-wrap{
+	margin: 40rpx auto;
+	font-size: 26rpx;
+	line-height: 1.5;
+	.link{
+		white-space: nowrap;
+		color: #00A447;
+	}
+}
 </style>
 

+ 58 - 0
pages/login/regulation.vue

@@ -0,0 +1,58 @@
+<template>
+	<view class="">
+		<u-navbar
+			:title="title"
+			:placeholder="true"
+			:autoBack="true"
+			 :safeAreaInsetTop="true"
+		>
+		</u-navbar>
+		<!-- <view class="title">积分规则</view> -->
+		<view class="page-wrap">
+			<u-parse :content="content"></u-parse>
+		</view>
+		
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				title:'',
+				regulationName:'',
+				content:'',
+			}
+		},
+		onShow() {	
+			
+		},
+		onLoad(page) {
+			this.title = page.regulationName;;
+			this.regulationName = page.regulationName;
+			// console.log('page',page);
+			this.getPageData();
+		},
+		methods: {
+			getPageData(){
+				this.$u.api.getRegistinfoByName({type:1,name:this.regulationName}).then(res=>{
+					this.content = res.data.content
+					console.log('res',res.data);
+				}).catch(err=>{
+					console.log('memberCreditDesc',err);
+				})
+			}
+
+		}
+	}
+</script>
+<style>
+page{
+	background-color: #f5f5f5;
+}
+</style>
+<style lang="scss" scoped>
+.title{
+	text-align: center;
+}
+</style>

+ 62 - 3
shopping/productdetails.vue

@@ -183,7 +183,19 @@
 					console.log('goodsAddView',err.data);
 				})
 			},
-			addCart(id,buyNow){
+			async addCart(id,buyNow){
+				try {
+					let authResult = await this.checkAuth();
+					console.log('实名认证结果:', authResult);
+					// 在此处可以继续执行需要进行实名认证的业务逻辑
+					// 例如下单购买商品等操作
+				} catch (err) {
+					console.log('实名认证未通过:', err);
+					return
+					// 在此处可以处理用户未通过实名认证的情况
+					// 例如返回上一页或者跳转到实名认证页等操作
+				}
+				this.checkAuth();
 				this.$u.api.addCart({goodsId:id}).then(res=>{
 					this.$refs.uToast.show({
 						type:"success",
@@ -201,7 +213,18 @@
 					console.log('addCart',err);
 				})
 			},
-			buyNow(id){
+			async buyNow(id){
+				try {
+					let authResult = await this.checkAuth();
+					console.log('实名认证结果:', authResult);
+					// 在此处可以继续执行需要进行实名认证的业务逻辑
+					// 例如下单购买商品等操作
+				} catch (err) {
+					console.log('实名认证未通过:', err);
+					return
+					// 在此处可以处理用户未通过实名认证的情况
+					// 例如返回上一页或者跳转到实名认证页等操作
+				}
 				// this.addCart(id,'buyNow')//跳购物车
 				let that = this;
 				if(!this.hasAddr){
@@ -223,7 +246,18 @@
 				this.$u.vuex('buyNowGoods',[{goodsId:this.id,quantity:1}]);
 				uni.$u.route('/shopping/submitorder', {fromPage: 'productdetails'});
 			},
-			addCreditOrder(id){
+			async addCreditOrder(id){
+				try {
+					let authResult = await this.checkAuth();
+					console.log('实名认证结果:', authResult);
+					// 在此处可以继续执行需要进行实名认证的业务逻辑
+					// 例如下单购买商品等操作
+				} catch (err) {
+					console.log('实名认证未通过:', err);
+					return
+					// 在此处可以处理用户未通过实名认证的情况
+					// 例如返回上一页或者跳转到实名认证页等操作
+				}
 				let that = this;
 				let creditGoods = [];
 				creditGoods.push({id:that.details.id,quantity:1})
@@ -279,6 +313,31 @@
 					console.log('getAddrList',err.data);
 				})
 			},
+			checkAuth() {
+				// console.log('details-----',this.details);
+				let that = this;
+			    return new Promise((resolve, reject) => {
+			        console.log('vuex_member_info', this.vuex_member_info.isAuth);
+			        if (that.details.isBuy!=1) {
+			            uni.showModal({
+			                title: '温馨提示',
+			                content: '购买该商品需要实名认证,请先实名认证!',
+			                success: res => {
+			                    if (res.confirm) {
+			                        let url = encodeURIComponent(`/shopping/productdetails?id=${that.id}`);
+			                        uni.$u.route('/center/factorauth', {
+			                            from: 'productdetails',
+			                            backUrl: url
+			                        });
+			                        reject('needAuth'); // 实名认证未通过,使用 reject 方法返回结果
+			                    }
+			                }
+			            });
+			        } else {
+			            resolve('noNeedAuth'); // 实名认证已通过,使用 resolve 方法返回结果
+			        }
+			    });
+			}
 		}
 	}
 </script>