微信小程序云开发项目实战之商城开发日记 04

news/2024/7/20 2:58:58 标签: html, css, 小程序, 前端

今天是愉快开发商城项目的第四天了,相信如果大家跟着我能把前两天的前端内容敲完,相信你是有比较大的收货的。

今天的内容是完成购物车前端代码。

购物车的设计还是比较常规的UI,展示商品的信息提供选中按钮提供加减按钮提供结算按钮提供一键清空按钮并在界面底部实时展示目前的购物车已选中的商品的总价

首先是商品的信息卡片,依然是以flex为核心的布局方式。

html"><view class="body">

 <view class="product">

  <checkbox-group bindchange="checked" class="left">

   <checkbox ></checkbox>

  </checkbox-group>

  <image src="../../images/apple.png"></image>

  <view class="middle">

   <text>苹果</text>

   <text>进口红富士,又大又甜</text>

   <text>¥6</text>

  </view>

  <view class="right">

   <text>-</text>

   <text>1</text>

   <text>+</text>

  </view>

 </view>

</view>
css">page {

 background-color: #f3f3f3;

 height: 100%;

}

.product {

 display: flex;

 flex-direction: row;

 width: 100%;

 align-items: center;

 position: relative;

 margin-bottom: 25rpx;

 background-color: #fff;

 padding-bottom: 20rpx;

}

.middle {

 display: flex;

 flex-direction: column;

 margin-left: 40rpx;

 margin-top: 20rpx;

 font-size: 28rpx;

}

.middle :nth-child(1){

 font-weight: bold;

 margin-bottom: 10rpx;

}

.middle :nth-last-child(2){

 color: gray;

 width: 220rpx;

 font-size: 24rpx;

 margin-bottom: 10rpx;

}

.middle :nth-child(3){

 color: red;

}

.product > .left {

 margin-left: 50rpx;

}

.product > image {

 width: 100rpx;

 height: 100rpx;

 padding-left: 40rpx;

}

.product > .right {

 display: flex;

 flex-direction: row;

 border:1rpx solid black;

 font-weight: bold;

 width: 180rpx;

 height:60rpx; 

 line-height: 60rpx;

 text-align: center;

 position: absolute;

 bottom: 20rpx;

 right: 10rpx;

}

.product > .right :nth-child(1){

 height: 60rpx ;

 width: 60rpx;

 border-right:1rpx solid black

}

.product > .right :nth-last-child(2){

 height: 60rpx;

 width: 60rpx;

 border-right: 1rpx solid black;

}

.product > .right :nth-child(3) {

 height: 60rpx;

 width: 60rpx;

}

效果:
在这里插入图片描述
基本是这样的样式,我们现在只是写前端内容,所以这个选中和数量加减没效果的。

而且我只写了一组数据,如果大家想多加几组的话,参照前两天的写法,利用wx:for渲染。

接下来写全部删除按钮底部的内容

html"><view class="button">清空购物车</view>

<view class="bottom">

 <view class="bottom_left">

  <text>¥999</text>

 </view>

 <view class="bottom_right">去结算</view>

</view>
css">.button {

 width: 100rpx;

 padding: 10rpx;

 font-size: 20rpx;

 margin: 0 auto;

 border: 1rpx solid gray;

 margin-top: 30rpx;

}

.bottom {

 display: flex;

 flex-direction: row;

 width: 100%;

 position: fixed;

 bottom: 0;

 height: 100rpx;

 background-color: white;

}

.bottom_left {

 width: 70%;

 line-height: 100rpx;

}

.bottom_left > text {

 text-align: center;

 margin-left: 50rpx;

 color: red;

 font-size: 40rpx;

}

.bottom_right {

 width: 30%;

 text-align: center;

 line-height: 100rpx;

 color: white;

 background-color: green;

}

最终效果:
在这里插入图片描述
基本的框架是这样的,大家可以自己多做几组数据,然后按照自己的设计完成布局,每个人都有自己的布局方式,我只是给大家提供一个完成代码的思路
然后再强调一下,目前我们都是在完成页面的前端内容不涉及任何后端数据交互,所以我们写的都是死数据,并且尽量不写JS的内容,只写样式。

点赞、关注、收藏都是对作者莫大的鼓励,谢谢!

有任何问题可以联系QQ:505417246

零基础入门微信小程序云开发QQ群:1073011570

关注下面微信公众号,可以领取微信小程序、Vue、TypeScript、前端、uni-app、全栈、Nodejs等实战学习资料
在这里插入图片描述


http://www.niftyadmin.cn/n/1576627.html

相关文章

springCloud集成redis快速搭建

redis集成可以将其直接进行导入RedisTemplate&#xff0c;或者通过封装之后直接调用&#xff0c;具体怎么操作根据个人喜好去开发&#xff0c;一下介绍一下后者方法&#xff0c;在开发过程中可以直接调用&#xff0c;开发方便 1、下载redis或者docker上进行部署 docker部署直…

微信小程序云开发项目实战之商城开发日记 05

hello童鞋们&#xff0c;我又来了&#xff0c;今天写tabbar的最后一个页面&#xff0c;个人中心页。 个人中心页的布局也是比较常规的。其实当你看过了很多成品之后你会发现&#xff0c;代码千篇一律&#xff0c;重要的还是UI的设计。 顶部是一个头像和昵称的展示&#xff0c…

前端之HTML学习

HTML学习 请带着以下几个问题进行学习&#xff1a; 什么是HTML、HTML文档类型起到什么作用、HTML5和HTML4有哪些区别、pc端和移动端页面有什么区别、什么是块级元素什么是内联元素、块级元素和内联元素的区别、什么是HTML标签语义化基础知识学习和实例演练教程html教程html5教程…

将SpringBoot项目打包成war,并且Tomcat读取外置的文件

这里写自定义目录标题SpringBoot项目打包成war&#xff0c;并且Tomcat可以读取外置的文件部署tomcat修改SpringBoot项目SpringBoot项目打包成war&#xff0c;并且Tomcat可以读取外置的文件 Springboot项目内置Tomcat一般情况下不需要在进行tomcat的配置&#xff0c;在一些特殊…

JavaScript的基础清单(超级全面!!!)

1.js类型 首先&#xff0c;现在js的类型有以下几种: 基本类型 : String , Number , null , undefined , Boolean , Symbol , Bigint引用类型 : object , function &#xff08;1&#xff09;基本类型和应用类型的区别 基本数据类型是按值访问的&#xff0c;因为可以直接操作保…

微信小程序解决诡异的异步问题

先说一下什么是异步&#xff0c;我举一个通俗易懂的例子。 你现在有两个任务&#xff1a; 向Java老师要一份复习资料买一瓶矿泉水 如果你是同步执行&#xff0c;那么你的执行过程就是&#xff0c;先去向老师要一份复习资料&#xff0c;等老师把复习资料给到了你的手里&#x…

一次Jenkins的trableshooting经历

背景&#xff1a;公司采用bitbucket管理代码&#xff0c;Jenkins、git作为集成工具&#xff0c;Jenkins部署在公司内网。公司网络为长城宽带对等光纤&#xff0c;网络调整后路由器为VOLANS VE989GW。近期因为工作需要&#xff0c;调整了公司的网络&#xff0c;更换了入口路由器…

好玩的CSS---实现打字效果

代码自用自取&#xff0c;复制粘贴直接使用&#xff0c;喜欢的话可以查看博主其它文章&#xff0c;贡献一丢丢的浏览量&#xff0c;感激不尽。 CSS是前端非常重要的技术也是对于前端熟练度的考察。很多的后端程序员表示在学习前端知识的时候&#xff0c;JS其实不是强有力的拦路…