zhanghui 2 лет назад
Родитель
Сommit
ab7b439c85

+ 1 - 0
main.js

@@ -13,6 +13,7 @@ Vue.prototype.$vconsole = new vconsole()
 import api from './common/js/api'
 import env from './common/js/env.js';
 Vue.prototype.$phonePattern = '^1[3-9][0-9]\\d{8}$';
+Vue.prototype.$idCardPattern = '^([1-6][1-9]|50)\\d{4}(18|19|20)\\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$';
 //后端接口地址
 Vue.prototype.$baseUrl = env.baseUrl;
 //小程序地址

+ 1 - 0
pages/forgetPassword/forgetPassword.vue

@@ -36,6 +36,7 @@
 	export default {
 		data() {
 			return {
+				disabled1:false,
 				tips:'',
 				form:{
 					username:'',

+ 72 - 72
pages/index/attach/attach.vue

@@ -3,84 +3,37 @@
 
 		<view :style="{marginTop:'24rpx'}">
 			<scroll-view scroll-y class="scroll-Y">
-				<view class="flex-col outView select">
+				<view class="flex-col outView " :class="{select:item.select}" v-for="(item,index) in roleBindRuleList" @click="selectRule(item,index)">
 					<view class="flex-row justify-between">
-						<text class="title">规则标题</text>
-						<u-icon name="checkbox-mark" color="#666" size="24"></u-icon>
+						<text class="title">{{item.title}}</text>
+						<u-icon name="checkbox-mark" color="#666" size="24" v-if="item.select"></u-icon>
 					</view>
 					<view class="flex-row justify-between  awardView">
-						<text>注册:</text>
-						<view class="flex-row  award ">
-							<text class="awardItem">现金:12元</text>
-							<text class="awardItem">比例:10%</text>
+						<text>直推:</text>
+						<view>
+							<view class="flex-row  award ">
+								<text class="awardItem">注册现金:{{item.awardAmount}}元</text>
+							</view>
+							<view class="flex-row  award ">
+								<text class="awardItem">消费现金:{{item.consumeAmount}}元</text>
+								<text class="awardItem">消费比例:{{item.consumeRatio * 100}}%</text>
+							</view>
 						</view>
 					</view>
-				</view>
-
-				<view class="flex-col outView">
-					<view class="flex-row justify-between">
-						<text class="title">规则标题</text>
-						<u-icon name="checkbox-mark" color="#666" size="24"></u-icon>
-					</view>
 					<view class="flex-row justify-between  awardView">
-						<text>注册:</text>
+						<text>间推:</text>
 						<view class="flex-row  award ">
-							<text class="awardItem">现金:12元</text>
-						</view>
-					</view>
-				</view>
-
-				<view class="flex-col outView">
-					<view class="flex-row justify-between">
-						<text class="title">规则标题</text>
-						<u-icon name="checkbox-mark" color="#666" size="24"></u-icon>
-					</view>
-					<view class="flex-row justify-between  awardView">
-						<text>优惠券:</text>
-						<view class="flex-col  award ">
-							<text>数量:100张</text>
-							<text>有效期:2024-01-01 至 2024-01-30</text>
-						</view>
-					</view>
-				</view>
-				<view class="flex-col outView select">
-					<view class="flex-row justify-between">
-						<text class="title">规则标题</text>
-						<u-icon name="checkbox-mark" color="#666" size="24"></u-icon>
-					</view>
-					<view class="flex-row justify-between  awardView">
-						<text>优惠券:</text>
-						<view class="flex-col  award ">
-							<text>数量:100张</text>
-							<text>有效期:2024-01-01 至 2024-01-30</text>
-						</view>
-					</view>
-				</view>
-				<view class="flex-col outView">
-					<view class="flex-row justify-between">
-						<text class="title">规则标题</text>
-						<u-icon name="checkbox-mark" color="#666" size="24"></u-icon>
-					</view>
-					<view class="flex-row justify-between  awardView">
-						<text>优惠券:</text>
-						<view class="flex-col  award ">
-							<text>数量:100张</text>
-							<text>有效期:2024-01-01 至 2024-01-30</text>
-						</view>
-					</view>
-				</view>
-				<view class="flex-col outView select">
-					<view class="flex-row justify-between">
-						<text class="title">规则标题</text>
-						<u-icon name="checkbox-mark" color="#666" size="24"></u-icon>
-					</view>
-					<view class="flex-row justify-between  awardView">
-						<text>优惠券:</text>
-						<view class="flex-col  award ">
-							<text>数量:100张</text>
-							<text>有效期:2024-01-01 至 2024-01-30</text>
+							<text class="awardItem">间推现金:{{item.indirectAmount}}元</text>
+							<text class="awardItem">间推比例:{{item.indirectRatio * 100}}%</text>
 						</view>
 					</view>
+					<!--						<view class="flex-row justify-between  awardView">-->
+					<!--							<text>优惠券:</text>-->
+					<!--							<view class="flex-col  award ">-->
+					<!--								<text>满100减250的优惠券</text>-->
+					<!--								<text>有效期:2024-01-01 至 2024-01-30</text>-->
+					<!--							</view>-->
+					<!--						</view>-->
 				</view>
 			</scroll-view>
 		</view>
@@ -116,7 +69,9 @@
 		},
 		data() {
 			return {
-				qrcodeUrl:this.$xcxUrl,
+				roleBindRuleList:[],
+				userInfo:{},
+				qrcodeUrl:this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}',
 				options: {
 					// 指定二维码前景,一般可在中间放logo
 					foregroundImagePadding:2,
@@ -125,14 +80,59 @@
 				},
 			}
 		},
-		onLoad() {
-
+		created() {
+			this.userInfo = uni.getStorageSync('spreadUserInfo')
+			this.getRuleByRoleId(this.userInfo.roleId)
 		},
 		methods: {
+
+			selectRule(item,index){
+				this.roleBindRuleList.forEach(i=>{
+					i.select=false
+				})
+				item.select = true
+				this.$set(this.roleBindRuleList,index,item)
+			},
+
+			//查询角色已经绑定的规则
+			getRuleByRoleId(roleId){
+				this.$api.service.getRuleByRoleId({
+					roleId:roleId
+				}).then(res=>{
+					this.roleBindRuleList = res.data.data
+					this.roleBindRuleList[0].select = true
+				})
+			},
+
 			createQrCode(){
+				let data = {
+					expandUserId:this.userInfo.id,
+					ruleId:''
+				};
+				this.roleBindRuleList.forEach(item=>{
+					if (item.select){
+						data.ruleId= item.id
+					}
+				})
+
+				if (!data.ruleId){
+					uni.showToast({
+						icon: 'error',
+						duration: 2000,
+						title: '请选择推广规则'
+					});
+					return
+				}
+				for (let key in data) {
+					let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
+					this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
+				}
+				console.log('++++data+++++',data)
+				console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
 				this.$refs.createQrCodePopup.open()
 			},
 			closePopup(){
+				this.qrcodeUrl=this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}',
 				this.$refs.createQrCodePopup.close()
 			},
 		}

+ 5 - 3
pages/index/index.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="page">
 		<uni-nav-bar  :fixed="true" background-color="#FFE05C" :border="false" :statusBar="true"   title="首页"  />
-		<manager :height="height" v-if="userInfo.isManager == 1"></manager>
+		<manager :height="height" v-if="userInfo.isManager === 1"></manager>
 		<attach :height="height" v-else></attach>
 	</view>
 </template>
@@ -15,7 +15,6 @@
 		},
 		data() {
 			return {
-				isManager:true,
 				height:'',
 				ruleList:[],
 				roleList:[],
@@ -24,9 +23,12 @@
 			}
 		},
 		onLoad() {
-			this.userInfo = uni.getStorageSync('spreadUserInfo')
 			let sysInfo = uni.getSystemInfoSync()
 			this.height = sysInfo.windowHeight - 45 + 'px'
+
+		},
+		onShow(){
+			this.userInfo = uni.getStorageSync('spreadUserInfo')
 		},
 		methods: {
 

+ 4 - 5
pages/index/manager/manager.vue

@@ -165,11 +165,6 @@
 					foregroundImageBorderRadius:5,
 					foregroundImageSrc: '/static/logo.png'
 				},
-				range: [
-					{ value: 0, text: "篮球篮球篮球篮球篮球篮" },
-					{ value: 1, text: "足球" },
-					{ value: 2, text: "游泳" },
-				],
 			}
 		},
 		created() {
@@ -201,6 +196,10 @@
 						ruleIds.push(rule.id)
 					}
 				}
+				if (ruleIds.length === 0){
+					this.closePopup()
+					return
+				}
 				this.$api.service.roleBindRule({
 					roleId:this.roleList[this.confirmRoleIndex].id,
 					ruleIds:ruleIds

+ 11 - 4
pages/login/login.vue

@@ -125,11 +125,18 @@
 						this.$api.user.getUserInfo().then(res=>{
 							this.userInfo = res.data.data
 							uni.setStorageSync('spreadUserInfo', this.userInfo)
-							console.log(res)
-						})
-						uni.switchTab({
-							url: "/pages/index/index"
+							uni.showToast({
+								icon: 'success',
+								duration: 1000,
+								title: '登陆成功'
+							});
+							setTimeout(()=>{
+								uni.switchTab({
+									url: "/pages/index/index"
+								})
+							},1000)
 						})
+
 					})
 				})
 			}

+ 1 - 1
pages/my/index.rpx.css

@@ -11,7 +11,7 @@
 	height: 100rpx;
 	padding: 4rpx;
 	border-radius: 8rpx;
-	background: #f7f7f7;
+	background: #FFE50C;
 }
 .avatar image{
 	width: 100rpx;

+ 1 - 0
pages/register/index.rpx.css

@@ -33,6 +33,7 @@
 	height: 100rpx;
 	border-radius: 50rpx;
 	overflow: hidden;
+	background: #FFE50C;
 }
 .photoImage{
 	width: 100rpx;

+ 11 - 8
pages/register/register.vue

@@ -115,6 +115,7 @@
 						required: true,
 						min:18,
 						max: 18,
+						pattern:this.$idCardPattern,
 						message: '请输入身份证号',
 						trigger: ['blur', 'change']
 					},
@@ -156,9 +157,11 @@
 		},
 		onLoad(e){
 			if (e.roleId){
+				this.form.roleId = e.roleId
 				console.log('获取到的id',e.roleId)
 			}
 			if (e.parentId){
+				this.form.parentId = e.parentId
 				console.log('获取到的name',e.parentId)
 			}
 		},
@@ -182,7 +185,7 @@
 							filePath:tempUrl,
 							name: 'file',
 							header: {
-								// "Content-Type": "multipart/form-data",
+								"Content-Type": "multipart/form-data",
 								// 'X-Access-Token': uni.getStorageSync('token'),
 								'Authorization': 'Bearer ' + uni.getStorageSync('accessToken'),
 							},
@@ -217,13 +220,13 @@
 				console.log(this.form)
 				this.$refs.uForm.validate().then(res => {
 					this.$api.login.expandRegister(this.form).then(res=>{
-
+						uni.showToast({
+							icon: 'success',
+							duration: 2000,
+							title: '注册成功,即将跳转登录页'
+						});
 						setTimeout(()=>{
-							uni.showToast({
-								icon: 'success',
-								duration: 2000,
-								title: '注册成功,即将跳转登录页'
-							});
+							this.gologin()
 						},2000)
 
 					})
@@ -257,7 +260,7 @@
 					uni.showLoading({
 						title: '正在获取验证码'
 					})
-					this.$api.service.getSmsCode({phonenumber: this.form.username}).then(res=>{
+					this.$api.service.getSmsCode({phonenumber: this.form.phone}).then(res=>{
 						uni.hideLoading();
 						// 这里此提示会被this.start()方法中的提示覆盖
 						uni.$u.toast('验证码已发送');

+ 1 - 0
pages/userInfo/index.rpx.css

@@ -16,6 +16,7 @@
     padding: 0;
     margin: 30rpx 0;
     overflow: hidden;
+    background: #FFE50C;
 }
 
 

+ 2 - 3
pages/userInfo/userInfo.vue

@@ -169,11 +169,10 @@
 				})
 			},
 			logout(){
-
 				this.$api.login.logout().then(res=>{
 					uni.removeStorageSync('accessToken');
-					uni.removeStorageSync('userInfo');
-					uni.navigateTo({
+					uni.removeStorageSync('spreadUserInfo');
+					uni.reLaunch({
 						url:'/pages/login/login'
 					})
 				})