首页 > 其他分享 >vue2+uni-app的实现的动态数据显示

vue2+uni-app的实现的动态数据显示

时间:2024-05-27 18:00:28浏览次数:18  
标签:roles true res app length vue2 uni data FF8787

 1:所用技术:Vue2.X,Uview2.0,

确保项目上已经安装了Vue2.X 版本和组件Uview(注:其余组件:如ElementUI组件也适用,主要是样式的区别)

2:template层

<template>
	<view class="NavPage">
		<view class="LoginCard">
			<uni-card is-shadow:true class="CardLogin" style="margin: 0rpx;">
				<view>
					<p style="text-align: center;color:#FF8787;font-weight: bold;font-size: 45rpx;margin-top: 30rpx;">
						请选择登录角色</p>
					<p class="RolesChange" style="margin-top: 40rpx;">
						<button @click="Toconsume()" v-bind:style="{backgroundColor:isnoHave7}" v-show="IsBind7"
							value="consumer">用户</button>
						<button @click="Tomerchant()" v-bind:style="{backgroundColor:isnoHave1}" v-show="IsBind1"
							value="merchant">商家</button>
						<button @click="ToSalesMan()" v-bind:style="{backgroundColor:isnoHave2}" v-show="IsBind2"
							value="salesMan">业务员</button>
						<button @click="TocityAgency()" v-bind:style="{backgroundColor:isnoHave3}" v-show="IsBind3"
							value="agent">市代理</button>
						<button @click="ToareaAgency()" v-bind:style="{backgroundColor:isnoHave33}" v-show="IsBind4"
							value="agent">区县代理</button>
						<button @click="ToInvestMent()" v-bind:style="{backgroundColor:isnoHave4}" v-show="IsBind5"
							value="investment">招商</button>
						<button @click="ToStockHolder()" v-bind:style="{backgroundColor:isnoHave5}" v-show="IsBind6"
							value="shareholder">股东</button>
					</p>
				
				</view>

			</uni-card>
		</view>

	</view>
</template>

3:Style层

<style scoped>
	/deep/ uni-button::after {
		border: none !important;
	}

	.RolesChange button {
		width: 95%;
		border-radius: 30rpx;
		border: none;
		margin-top: 30rpx;
		color: white;
	}

	.CardLogin {
		background-image: linear-gradient(#FFC3C3, #FFC3C3, white);
		border: none;
		border-radius: 40rpx;
		position: fixed;
		top: 14.7rem;
		width: 85%;
		left: 5%;
		margin: auto;
	}

	page {
		height: 100vh;
		background-image: linear-gradient(#FF7576, #FF8787, white);  //渐变色背景

		/* 背景图片覆盖整个容器,保持宽高比 */
		background-repeat: no-repeat;

	}

	.NavPage {

		/* 背景图片不重复 */
		position: fixed;
		/* 定位为固定位置 */
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(123, 123, 123, 0.32);
	
	}


</style>

4:Script层

<script>
	import {
		getChangeInfo
	} from "@/api/login.js"
	import {
		IfPay
	} from "@/api/login.js"
	export default {
		data() {
			return {
				IsBind1: false,
				IsBind2: false,
				IsBind3: false,
				IsBind4: false,
				IsBind5: false,
				IsBind6: false,
				IsBind7: false,

				isnoHave1: "#e0dedd",
				isnoHave2: "#e0dedd",
				isnoHave3: "#e0dedd",
				isnoHave33: "#e0dedd",
				isnoHave4: "#e0dedd",
				isnoHave5: "#e0dedd",
				isnoHave7: "#e0dedd",

				consumer: "consumer",
				merchant: "merchant",
				salesMan: "salesMan", //业务员
				countryagent: "countryagent", //区县代
				cityagent: "cityagent", //市代
				investment: "investment",
				shareholder: "shareholder",
				// 身份识别
				identify: ''

			}
		},
		onLoad() {
//后台数据——在页面加载时候进行获取
			this.ToSell()
		},


		methods: {
			FirstGetRoles() {

			},
//获取后台数据——并且进行循环判断(前端自己定义的数在后台数组中进行查询遍历)
			ToSell() {
				getChangeInfo().then(res => {
					console.log('res', res)
                   //后台传来的动态数组 res.data.roles

					console.log(res.data.roles.length)  //数组的长度,判断外层循环次数
					// 循环判断————高亮
					for (let i = 0; i < res.data.roles.length; i++) {
						if (this.merchant === res.data.roles[i]) {
							this.isnoHave1 = '#FF8787';  
                            //动态颜色的控制,可以同时展示不同的高亮颜色
							this.IsBind1 = true  //如果有则控制v-show为true,让其显示
						};
					}
					// 消费者
					for (let i = 0; i < res.data.roles.length; i++) {

						if (this.consumer === res.data.roles[i]) {
							this.isnoHave7 = '#FF8787';
							this.IsBind7 = true
						};
					}
					//业务员
					for (let j = 0; j < res.data.roles.length; j++) {

						if (this.salesMan === res.data.roles[j]) {
							this.isnoHave2 = '#FF8787';
							this.IsBind2 = true
						};
					}
					//市代理
					for (let j = 0; j < res.data.roles.length; j++) {

						if (this.cityagent === res.data.roles[j]) {
							this.isnoHave3 = '#FF8787';
							this.IsBind3 = true
						};
					}
					//区县代理
					for (let j = 0; j < res.data.roles.length; j++) {
						if (this.countryagent === res.data.roles[j]) {
							this.isnoHave33 = '#FF8787';
							this.IsBind4 = true
						};
					}

					for (let j = 0; j < res.data.roles.length; j++) {
						if (this.investment === res.data.roles[j]) {
							this.isnoHave4 = '#FF8787';
							this.IsBind5 = true
						};
					}
					for (let j = 0; j < res.data.roles.length; j++) {
						if (this.shareholder === res.data.roles[j]) {
							this.isnoHave5 = '#FF8787';
							this.IsBind6 = true
						};
					}


				}, err => {

				})
			},
			//点击事件——每个进行不同的事件(点击跳转不同页面)
			ToSalesMan() {
			},
			Toconsume() {
//采用uni-app的原生跳转方式——(注意navigation和switchTab的区别,后者仅用于tabbar页面的跳转)
				// uni.navigateTo({
				//	url: ('/pages/RoleConsumerPages/ConsumeMine/index')
			//	})

			},
			Tomerchant() {
			},
			//市代理
			TocityAgency() {
				
			},
			//区县代理
			ToareaAgency() {
				
			},
			ToInvestMent() {

			},
			ToStockHolder() {

			}
		}
	}
</script>

标签:roles,true,res,app,length,vue2,uni,data,FF8787
From: https://blog.csdn.net/qq_63141820/article/details/139243924

相关文章

  • Unity性能优化——其他合集
     本节将详细介绍在收集性能分析数据之前不应使用的优化。可能的原因是这些优化在实现时非常耗费精力,在提高性能的同时可能会损害代码整洁性或可维护性,或者解决的可能仅仅是特定的范围内才存在的问题。多维数组与交错数组如该 StackOverflow文章所述,遍历交错数组通常比遍历多......
  • Unity 2022无法安装Entities 1.2.0 Package的解决方法
    会出现如下的错误提示:本质原因是国内版的Unity2022使用了自己的Package加速CDN:packages.unity.cn,而不是官方的packages.unity.com。而这个CDN更新了Entities的几个包到1.2.0,却没有将依赖的com.unity.collections更新到2.4.0。诡异的是CDN里却有2.4.1。所以解决方法就来了:直......
  • 基于SpringBoot的酒店订房系统-82159(免费领源码+数据库)可做计算机毕业设计JAVA、PHP、
    springboot酒店订房系统摘 要随着科学技术的飞速发展,社会的方方面面、各行各业都在努力与现代的先进技术接轨,通过科技手段来提高自身的优势,酒店订房系统当然也不能排除在外。酒店订房系统是以实际运用为开发背景,运用软件工程开发方法,采用springboot技术构建的一个管理系统......
  • uniapp APP端全局组件-水印
    一、水印核心代码<template><viewclass="watermark-box":style="{backgroundImage:`url(${waterMarkImgSrc})`,backgroundSize:`auto${height}px`}"><canvasid="watermark"class="watermark&......
  • 一例APP绕过root检测解密
    一例APP绕过root检测解密前言最近在分析一款app时遇见了root检测,数据包加密,花了时间简单研究了一下,记录下学习的过程。 抛出问题打开app发现提示检测到设备为root设备,闪退。能看到提示,推测应该是java层的检测。拖进jadx发现是加固的。通过frida绕过检测java层常见......
  • app上架国内应用商城合规检测、隐私合规检测
    1.工具准备camile代码(python)gitclonehttps://github.com/zhengjim/camille.git模拟器(夜神模拟器/Mumu模拟器)mumu模擬器:127.0.0.1:7555夜神模擬器:127.0.0.1:62001FridaFirda是一款易用的跨平Hook工具,Java层到Native层的Hook无所不能,是一种动态的插桩工......
  • 使用.Net Core开发WPF App系列教程( 八、WPF中的常用控件(下))
    使用.NetCore开发WPFApp系列教程一、.NetCore和WPF介绍二、在VisualStudio2019中创建.NetCoreWPF工程三、与.NetFramework的区别四、WPF中的XAML五、WPF中的布局六、WPF中的常用控件(上)七、WPF中的常用控件(中)八、WPF中的常用控件(下)其它、实现多语言切换的几种方......
  • appKey&appSecret 加密验签算法
    加密方式请求参数依次从a-z排列然后拼接后加入加密app_secret然后MD5加密即可得到签名字符串PHP示例privatestaticfunctiongenerateSign($params,$appSecret){ksort($params);$str='';foreach($paramsas$key=>$value){......
  • mybatis- [04] mapper文件详解
      Mybatis的Mapper文件(通常是以.xml为扩展名的文件)主要用于定义SQL语句和它们与Java接口方法之间的映射关系。以下是Mapper文件中一些常用的配置元素和属性。 一、mapper文件配置详解(1)namespace:定义Mapper接口对应的唯一命名空间,用于区分不同的Mapper。(常以UserMapper类的......
  • 探索Solana链上DApp开发:高性能区块链生态的新机遇
    Solana是一个新兴的区块链平台,致力于为DApp(去中心化应用程序)开发者提供高性能、低成本的解决方案。Solana的独特之处在于其创新性的共识机制和高吞吐量的网络,使得开发者可以构建高度可扩展的DApp,并为用户提供无与伦比的体验。以下是一份简要介绍,让您可以快速了解Solana链......