草庐IT

uni-app商品分类

黑白两客 2023-04-08 原文
<template>
	<view class="classify">
		<!-- 分类部分 -->
		<view class="cate-left">
			<view :class="['cate-item',activeIndex==index?'active':'']" v-for="(item,index) in cateList" :key="index"
				@click="changeActive(index)">{{item.classifyName}}</view>
		</view>

		<view class="cate-right">
			<view class="cate-content" v-for="(it,id) in 30" :key="id"  @click="getto(it)">
				<image src="../../static/images/userinfo.jpg" mode=""></image>
				<view class="cate-text">好东西</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scrollTop: 0,
				// 初始化的分类列表
				cateList: [{
					classifyName: '女装',
					id: 1
				}, {
					classifyName: '洗护',
					id: 2
				}, {
					classifyName: '内衣',
					id: 3
				}, {
					classifyName: '百货',
					id: 4
				}, {
					classifyName: '饰品',
					id: 5
				}, {
					classifyName: '母婴',
					id: 6
				}, {
					classifyName: '数码',
					id: 7
				}, {
					classifyName: '食品',
					id: 8
				}, {
					classifyName: '电器',
					id: 9
				}, {
					classifyName: '进口',
					id: 10
				}, {
					classifyName: '手机',
					id: 11
				}, {
					classifyName: '家装',
					id: 12
				}, {
					classifyName: '美妆',
					id: 13
				}],
				// 当前点击项的索引号
				activeIndex: 0,
				// 分类下的商品信息
				goodList: []
			};
		},
		methods: {
			async getcateList() {
				const res = await uni.$http.get('/classify')
				console.log(res)
				const {
					data: {
						classify,
						code
					}
				} = res
				if (code != 200) {
					return uni.showToast({
						title: '加载数据失败',
						duration: 1000,
						icon: 'none'
					})
				} else {
					this.cateList = classify
					// 获取第一个分类下的商品
					this.goodList = classify[0].children
				}
			},
			//更改点击项的索引号
			changeActive(i) {
				this.activeIndex = i
				// 已经获取到索引号
				this.goodList = this.cateList[i].children
			},
			//点击搜索框跳转到搜索页面
			getto(it) {
				console.log(it,123)
				uni.navigateTo({
					url: '/pages-zzfw/productDisplay-detail/productDisplay-detail'
				})
			},
		},
		onLoad() {
			// this.getcateList()
		}
	}
</script>

<style lang="scss" scoped>
	.classify {
		background-color: #fff;
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: space-between;
		.cate-left {
			width: 200rpx;
			height: 100vh;
			overflow: auto;
			background-color: #F6F6F6;

			.cate-item {
				width: 100%;
				height: 100rpx;
				line-height: 100rpx;
				padding-left: 40rpx;
				box-sizing: border-box;
			}

			.active {
				background-color: #FFFFFF;
				position: relative;
				padding-left: 40rpx;
				box-sizing: border-box;

				&::before {
					content: '';
					display: block;
					width: 5rpx;
					border-radius: 6rpx;
					height: 50rpx;
					background-color: #FC4353;
					position: absolute;
					left: 5rpx;
					top: 30rpx;
				}
			}
		}

		.cate-right {
			width: 80%;
			height: 100vh;
			overflow: auto;
			.cate-content {
				float: left;
				width: 28%;
				height: 185rpx;
				text-align: center;
				margin: 20rpx 0 0 15rpx;
				padding: 5rpx;
				background: #f1f1f1;
				border-radius: 20rpx;
				image {
					width: 100rpx;
					height: 100rpx;
				}
				.cate-text {
					font-size: 34rpx;
				}
			}
		}
	}
</style>

有关uni-app商品分类的更多相关文章

  1. ruby - RuntimeError(自动加载常量 Apps 多线程时检测到循环依赖 - 2

    我收到这个错误:RuntimeError(自动加载常量Apps时检测到循环依赖当我使用多线程时。下面是我的代码。为什么会这样?我尝试多线程的原因是因为我正在编写一个HTML抓取应用程序。对Nokogiri::HTML(open())的调用是一个同步阻塞调用,需要1秒才能返回,我有100,000多个页面要访问,所以我试图运行多个线程来解决这个问题。有更好的方法吗?classToolsController0)app.website=array.join(',')putsapp.websiteelseapp.website="NONE"endapp.saveapps=Apps.order("

  2. ruby-on-rails - 每次我尝试部署时,我都会得到 - (gcloud.preview.app.deploy) 错误响应 : [4] DEADLINE_EXCEEDED - 2

    我是Google云的新手,我正在尝试对其进行首次部署。我的第一个部署是RubyonRails项目。我基本上是在关注thisguideinthegoogleclouddocumentation.唯一的区别是我使用的是我自己的项目,而不是他们提供的“helloworld”项目。这是我的app.yaml文件runtime:customvm:trueentrypoint:bundleexecrackup-p8080-Eproductionconfig.ruresources:cpu:0.5memory_gb:1.3disk_size_gb:10当我转到我的项目目录并运行gcloudprevie

  3. ruby-on-rails - 如何重命名或移动 Rails 的 README_FOR_APP - 2

    当我在我的Rails应用程序根目录中运行rakedoc:app时,API文档是使用/doc/README_FOR_APP作为主页生成的。我想向该文件添加.rdoc扩展名,以便它在GitHub上正确呈现。更好的是,我想将它移动到应用程序根目录(/README.rdoc)。有没有办法通过修改包含的rake/rdoctask任务在我的Rakefile中执行此操作?是否有某个地方可以查找可以修改的主页文件的名称?还是我必须编写一个新的Rake任务?额外的问题:Rails应用程序的两个单独文件/README和/doc/README_FOR_APP背后的逻辑是什么?为什么不只有一个?

  4. ruby - 使用 postgres.app 在 rvm 下要求 pg 时出错 - 2

    我正在使用Postgres.app在OSX(10.8.3)上。我已经修改了我的PATH,以便应用程序的bin文件夹位于所有其他文件夹之前。Rammy:~phrogz$whichpg_config/Applications/Postgres.app/Contents/MacOS/bin/pg_config我已经安装了rvm并且可以毫无错误地安装pggem,但是当我需要它时我得到一个错误:Rammy:~phrogz$gem-v1.8.25Rammy:~phrogz$geminstallpgFetching:pg-0.15.1.gem(100%)Buildingnativeextension

  5. ruby - 为 capybara 设置 app_host 的内容 - 2

    我的测试尝试访问网页并验证页面上是否存在某些元素。例如,它访问http://foo.com/homepage.html并检查Logo图像,然后访问http://bar.com/store/blah.html并检查页面上是否出现了某些文本。我的目标是访问经过Kerberos身份验证的网页。我发现Kerberos代码如下:主文件uri=URI.parse(Capybara.app_host)kerberos=Kerberos.new(uri.host)@kerberos_token=kerberos.encoded_tokenkerberos.rb文件classKerberosdefini

  6. ruby - 导轨 3 : Creating app with internal plugin system - 2

    我想在Rails中使用插件系统创建一个应用程序。潜在用户应该能够上传(或更好地从存储库安装)一个插件并安装它,使我的应用程序能够做更多的事情。这应该在没有FTP/SSH/对服务器的任何低级别访问的情况下完成。关于如何在Rails3中完成它,是否有任何好的gems或教程? 最佳答案 你看过http://edgeguides.rubyonrails.org/plugins.html了吗??它似乎不是100%兼容Rails3,但它可以帮助您入门。我看过的大多数插件文章都涉及Rails2。 关于

  7. ruby - 使用 Foreman 启动位于不同目录的 Rack App - 2

    我有一个成功运行多个进程的Procfile设置:#/Procfileredis:bundleexecredis-serversidekiq:bundleexecsidekiq-v-C./config.ymlforward:forward4567mock-api我需要再添加一个进程-一个位于我机器上不同目录中的Sinatra应用程序。如果我cd到该目录,我可以从终端启动它:$rackup-p4567我可以使用终端从不同的目录启动它:$sh-c'cd/Path/to/project/&&execrackup-p4567'但是我应该如何使用工头来做到这一点。我尝试添加以下内容,但它无声地失败

  8. ruby-on-rails - Rake 文档 :app fails after upgrading to Ruby 2. 1.1 和 Rails 4.1 - 2

    我使用命令rakedoc:app为我的Rails应用程序生成一些基本文档。它在过去一直运行良好。昨天我通过应用程序从Ruby1.9.3升级到2.1.1,从Rails3.2升级到4.1。该应用程序一切正常,所以几周后我第一次重新生成文档,但失败了。我运行上面的命令并收到以下错误消息:rakeaborted!Don'tknowhowtobuildtask'README.rdoc'/home/vagrant/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in`eval'/home/vagrant/.rvm/gems/ruby-2.1.1/

  9. ruby-on-rails - rails : Omniauth - "The parameter app_id is required" - 2

    我正在按照这个railscast教程在我的rails项目上为facebook身份验证设置omniauth:http://railscasts.com/episodes/360-facebook-authentication?autoplay=true.我只用了4分钟,到目前为止我所做的就是捆绑gemomniauth-facebook并添加,omniauth.rbOmniAuth.config.logger=Rails.loggerRails.application.config.middleware.useOmniAuth::Builderdoprovider:facebook,ENV

  10. ruby-on-rails - 将 Rails/ClearDB App 推送到 Heroku 错误 'Can' t 连接到 '127.0.0.1' 上的 MySQL 服务器 - 2

    每次我跑:gitpushherokumaster我收到以下错误:Running:rakeassets:precompilerakeaborted!Can'tconnecttoMySQLserveron'127.0.0.1'我在运行rails-vRails3.2.11和ruby-vruby1.9.3p194(2012-04-20revision35410)[x86_64-darwin12.2.0]我已经通过HerokuCLI安装了ClearDB,它似乎工作正常,但我无法找出这个错误。这是我用于生产的yml:production:adapter:mysql2encoding:utf8hos

随机推荐