移动端商品详情页设计

news2024/10/2 10:31:14

效果图

 

代码如下

页面设计

 <div class="container">
    <!--商品详情 start-->
    <van-image class="goods-item-image" :src="goods.goodsHeadImg"></van-image>
    <div class="goods-price">
      ¥<span>{{ goods.goodsPrice }}</span>.00起
    </div>
    <div class="goods-name">
      <el-button round size="small">{{ goods.goodsBrand.goodsBrandName }}</el-button>
      <span>{{ goods.goodsName }}</span>
      <span>{{ goods.goodsCaption }}</span>
    </div>
    <div class="goods-sp">
      <div class="goods-sp-item" v-for="(specification,specificationIndex) in goods.specifications"
           :key="specificationIndex">
        <div>
          <span>{{ specification.goodsSpecificationName }}: </span>
          <span
              v-for="(goodsSpecificationOption,goodsSpecificationOptionIndex) in specification.goodsSpecificationOptions"
              :key="goodsSpecificationOptionIndex">{{ goodsSpecificationOption.goodsSpecificationOptionName }} </span>
        </div>
      </div>
    </div>
    <div class="goods-introduction">
      <span>{{ goods.goodsIntroduction }}</span>
    </div>
    <div class="goods-images" v-for="(img,imgIndex) in goods.images" :key="imgIndex">
      <van-image class="goods-item-image" :src="img.goodsImageUrl"></van-image>
    </div>
    <!--商品详情 end-->

    <!--底部导航 start-->
    <van-action-bar style="margin-bottom: 50px ">
      <van-action-bar-icon icon="chat-o" text="客服" badge="12"/>
      <van-action-bar-icon icon="cart-o" text="购物车" dot/>
      <van-action-bar-icon icon="shop-o" text="店铺" badge="5"/>
      <van-action-bar-button type="warning" text="加入购物车" @click="onAddCartShow"/>
      <van-action-bar-button type="danger" text="立即购买"/>
    </van-action-bar>
    <!--底部导航 end-->

    <!--加入购物车弹出框 end-->
    <van-popup v-model:show="showCart" position="bottom" closeable>
      <div class="add-cart-show">
        <!--顶部 start-->
        <div class="add-header">
          <van-image class="add-goods-img" radius="10" :src="goods.goodsHeadImg"></van-image>
          <div class="add-goods-price">
            ¥<span>{{ goods.goodsPrice }}</span>
          </div>
        </div>
        <!--顶部 end-->
        <!--地址 start-->
        <AddressList class="add-address"/>
        <!--地址 end-->
        <!--规格 start-->
        <div class="add-goods-specification">
          <span>颜色分类</span>
        </div>
        <!--规格 end-->
        <!--底部 start-->
        <el-button class="button" size="large" color="#ff9003" round @click="onAddCart">加入购物车</el-button>
        <!--底部 end-->
      </div>
    </van-popup>
    <!--加入购物车弹出框 end-->

  </div>

逻辑编写

<script setup>
import {onMounted, reactive, ref} from "vue";
import axios from "@/utils/request"
import {useRoute} from "vue-router"
import {useDataStore} from "../../stores/dataStore"
import {ElMessage} from "element-plus";
import AddressList from "../../components/AddressList/Index.vue"

const dataStore = useDataStore()

const route = useRoute()
//加入购物车弹出框控制器
const showCart = ref(false)
//商品id
const goodsId = route.params.name
//商品数据
const goods = reactive({
  goodsId: "",
  goodsHeadImg: "",
  goodsName: "",
  goodsCaption: "",
  goodsPrice: "",
  goodsIntroduction: "",
  goodsUse: "",
  goodsBrand: "",
  goodsType1: "",
  goodsType2: "",
  goodsType3: "",
  images: "",
  specifications: ""
})
onMounted(() => {
  ElMessage.success("成功")
  axios.get("front/goods/findDesc", {
    params: {
      goodsId: goodsId
    }
  }).then(res => {
    if (res.data.code == 200) {
      goods.goodsId = res.data.data.goodsId
      goods.goodsHeadImg = res.data.data.goodsHeadImg
      goods.goodsName = res.data.data.goodsName
      goods.goodsCaption = res.data.data.goodsCaption
      goods.goodsPrice = res.data.data.goodsPrice
      goods.goodsIntroduction = res.data.data.goodsIntroduction
      goods.goodsUse = res.data.data.goodsUse
      goods.goodsBrand = res.data.data.goodsBrand
      goods.goodsType1 = res.data.data.goodsType1
      goods.goodsType2 = res.data.data.goodsType2
      goods.goodsType3 = res.data.data.goodsType3
      goods.images = res.data.data.images
      goods.specifications = res.data.data.specifications
    }
  })
})
/**
 * 加入购物车弹出框
 */
const onAddCartShow = () => {
  showCart.value = true
}
/**
 * 加入购物车
 */
const onAddCart = () => {
  axios.post("front/cart/addGoodsCart", {
    userId: dataStore.userId,
    goodsId: goodsId,
    goodsHeadImg: goods.goodsHeadImg,
    goodsName: goods.goodsName,
    goodsPrice: goods.goodsPrice,
    num: 1,
  }).then(res => {
    if (res.data.code == 200) {
      showCart.value = false
    }
  })
}

</script>

css设计

<style scoped>
.container {
  background-color: #ffffff;
}

/**
商品数据样式
 */
.goods-price {
  margin-top: 10px;
  color: #ff4142;
}

.goods-price span {
  font-style: normal;
  font-family: JDZH-Regular, sans-serif;
  display: inline-block;
  font-size: 22px;
  font-weight: 500;
  line-height: normal;
  color: #f44d0b;
}

.goods-name {
  font-size: 21px;
  color: #181818;
  font-family: JDZH-Regular, sans-serif;
}

.goods-name button {
  margin: 4px;
  display: inline;
  color: #fdfdff;
  font-weight: 400;
  background-color: #fe012d;
}

.goods-sp {
  background-color: #f7f7f7;
  border-radius: 2%;
  margin-top: 10px;
  margin-bottom: 10px;
}

.goods-sp-item {
  padding: 8px;
}

.goods-sp-item span {
  font-size: 12px;
  font-weight: bold;
}

.goods-introduction {
  background-color: #f7f7f7;
  font-size: 12px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.goods-introduction span {
  padding: 10px;
}

.goods-name span {
  margin-left: 5px;
  font-size: 16px;
  font-weight: bold;
}

/*加入购物车弹出框样式*/
.add-cart-show {
  height: 500px;
}

.add-cart-show button {
  position: fixed;
  bottom: 10px;
  left: 10px;
  width: 350px;
  color: #faf7e7;
  font-weight: 700;
}

.add-header {
  display: flex;
  position: fixed;
  left: 10px;
  top: 70px;
  z-index: 100;
  background-color: #ffffff;

}

.add-goods-img {
  margin: 10px;
  width: 80px;
}

.add-goods-price {
  margin-left: 20px;
  margin-top: 35px;
  color: #ff4142;
  font-size: 15px;
}

.add-goods-price span {
  font-style: normal;
  font-family: JDZH-Regular, sans-serif;
  display: inline-block;
  font-size: 32px;
  font-weight: 500;
  line-height: normal;
  color: #f44d0b;
}

.add-address {
  margin-top: 110px;
}

.add-goods-specification {
  margin-top: 20px;
}
</style>

全部代码

<template>
  <div class="container">
    <!--商品详情 start-->
    <van-image class="goods-item-image" :src="goods.goodsHeadImg"></van-image>
    <div class="goods-price">
      ¥<span>{{ goods.goodsPrice }}</span>.00起
    </div>
    <div class="goods-name">
      <el-button round size="small">{{ goods.goodsBrand.goodsBrandName }}</el-button>
      <span>{{ goods.goodsName }}</span>
      <span>{{ goods.goodsCaption }}</span>
    </div>
    <div class="goods-sp">
      <div class="goods-sp-item" v-for="(specification,specificationIndex) in goods.specifications"
           :key="specificationIndex">
        <div>
          <span>{{ specification.goodsSpecificationName }}: </span>
          <span
              v-for="(goodsSpecificationOption,goodsSpecificationOptionIndex) in specification.goodsSpecificationOptions"
              :key="goodsSpecificationOptionIndex">{{ goodsSpecificationOption.goodsSpecificationOptionName }} </span>
        </div>
      </div>
    </div>
    <div class="goods-introduction">
      <span>{{ goods.goodsIntroduction }}</span>
    </div>
    <div class="goods-images" v-for="(img,imgIndex) in goods.images" :key="imgIndex">
      <van-image class="goods-item-image" :src="img.goodsImageUrl"></van-image>
    </div>
    <!--商品详情 end-->
    
    <!--底部导航 start-->
    <van-action-bar style="margin-bottom: 50px ">
      <van-action-bar-icon icon="chat-o" text="客服" badge="12"/>
      <van-action-bar-icon icon="cart-o" text="购物车" dot/>
      <van-action-bar-icon icon="shop-o" text="店铺" badge="5"/>
      <van-action-bar-button type="warning" text="加入购物车" @click="onAddCartShow"/>
      <van-action-bar-button type="danger" text="立即购买"/>
    </van-action-bar>
    <!--底部导航 end-->

    <!--加入购物车弹出框 end-->
    <van-popup v-model:show="showCart" position="bottom" closeable>
      <div class="add-cart-show">
        <!--顶部 start-->
        <div class="add-header">
          <van-image class="add-goods-img" radius="10" :src="goods.goodsHeadImg"></van-image>
          <div class="add-goods-price">
            ¥<span>{{ goods.goodsPrice }}</span>
          </div>
        </div>
        <!--顶部 end-->
        <!--地址 start-->
        <AddressList class="add-address"/>
        <!--地址 end-->
        <!--规格 start-->
        <div class="add-goods-specification">
          <span>颜色分类</span>
        </div>
        <!--规格 end-->
        <!--底部 start-->
        <el-button class="button" size="large" color="#ff9003" round @click="onAddCart">加入购物车</el-button>
        <!--底部 end-->
      </div>
    </van-popup>
    <!--加入购物车弹出框 end-->

  </div>
</template>

<script setup>
import {onMounted, reactive, ref} from "vue";
import axios from "@/utils/request"
import {useRoute} from "vue-router"
import {useDataStore} from "../../stores/dataStore"
import {ElMessage} from "element-plus";
import AddressList from "../../components/AddressList/Index.vue"

const dataStore = useDataStore()

const route = useRoute()
//加入购物车弹出框控制器
const showCart = ref(false)
//商品id
const goodsId = route.params.name
//商品数据
const goods = reactive({
  goodsId: "",
  goodsHeadImg: "",
  goodsName: "",
  goodsCaption: "",
  goodsPrice: "",
  goodsIntroduction: "",
  goodsUse: "",
  goodsBrand: "",
  goodsType1: "",
  goodsType2: "",
  goodsType3: "",
  images: "",
  specifications: ""
})
onMounted(() => {
  ElMessage.success("成功")
  axios.get("front/goods/findDesc", {
    params: {
      goodsId: goodsId
    }
  }).then(res => {
    if (res.data.code == 200) {
      goods.goodsId = res.data.data.goodsId
      goods.goodsHeadImg = res.data.data.goodsHeadImg
      goods.goodsName = res.data.data.goodsName
      goods.goodsCaption = res.data.data.goodsCaption
      goods.goodsPrice = res.data.data.goodsPrice
      goods.goodsIntroduction = res.data.data.goodsIntroduction
      goods.goodsUse = res.data.data.goodsUse
      goods.goodsBrand = res.data.data.goodsBrand
      goods.goodsType1 = res.data.data.goodsType1
      goods.goodsType2 = res.data.data.goodsType2
      goods.goodsType3 = res.data.data.goodsType3
      goods.images = res.data.data.images
      goods.specifications = res.data.data.specifications
    }
  })
})
/**
 * 加入购物车弹出框
 */
const onAddCartShow = () => {
  showCart.value = true
}
/**
 * 加入购物车
 */
const onAddCart = () => {
  axios.post("front/cart/addGoodsCart", {
    userId: dataStore.userId,
    goodsId: goodsId,
    goodsHeadImg: goods.goodsHeadImg,
    goodsName: goods.goodsName,
    goodsPrice: goods.goodsPrice,
    num: 1,
  }).then(res => {
    if (res.data.code == 200) {
      showCart.value = false
    }
  })
}

</script>

<style scoped>
.container {
  background-color: #ffffff;
}

/**
商品数据样式
 */
.goods-price {
  margin-top: 10px;
  color: #ff4142;
}

.goods-price span {
  font-style: normal;
  font-family: JDZH-Regular, sans-serif;
  display: inline-block;
  font-size: 22px;
  font-weight: 500;
  line-height: normal;
  color: #f44d0b;
}

.goods-name {
  font-size: 21px;
  color: #181818;
  font-family: JDZH-Regular, sans-serif;
}

.goods-name button {
  margin: 4px;
  display: inline;
  color: #fdfdff;
  font-weight: 400;
  background-color: #fe012d;
}

.goods-sp {
  background-color: #f7f7f7;
  border-radius: 2%;
  margin-top: 10px;
  margin-bottom: 10px;
}

.goods-sp-item {
  padding: 8px;
}

.goods-sp-item span {
  font-size: 12px;
  font-weight: bold;
}

.goods-introduction {
  background-color: #f7f7f7;
  font-size: 12px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.goods-introduction span {
  padding: 10px;
}

.goods-name span {
  margin-left: 5px;
  font-size: 16px;
  font-weight: bold;
}

/*加入购物车弹出框样式*/
.add-cart-show {
  height: 500px;
}

.add-cart-show button {
  position: fixed;
  bottom: 10px;
  left: 10px;
  width: 350px;
  color: #faf7e7;
  font-weight: 700;
}

.add-header {
  display: flex;
  position: fixed;
  left: 10px;
  top: 70px;
  z-index: 100;
  background-color: #ffffff;

}

.add-goods-img {
  margin: 10px;
  width: 80px;
}

.add-goods-price {
  margin-left: 20px;
  margin-top: 35px;
  color: #ff4142;
  font-size: 15px;
}

.add-goods-price span {
  font-style: normal;
  font-family: JDZH-Regular, sans-serif;
  display: inline-block;
  font-size: 32px;
  font-weight: 500;
  line-height: normal;
  color: #f44d0b;
}

.add-address {
  margin-top: 110px;
}

.add-goods-specification {
  margin-top: 20px;
}
</style>

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/788110.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

MySQL函数讲解(谓词、CASE)

目录 MySQL常见函数 字符串函数 进行字符串操作的函数 算术函数 进行数值计算的函数 日期函数 进行日期操作的函数 转换函数 进行数据类型和值转换的函数 流程函数 进行条件删选 聚合函数 进行数据聚合的函数 谓词 一般用于条件判断 什么是函数 函数指一段可以直接被…

web前端tips:js继承——原型链继承

原型链继承 原型链继承是 JavaScript 中实现继承的一种方式&#xff0c;它通过使用原型来实现对象之间的继承关系。 在 JavaScript 中&#xff0c;每个对象都有一个原型&#xff08;prototype&#xff09;&#xff0c;它是一个指向另一个对象的引用。当我们访问一个对象的属性…

Quartz线程调度源码分析

Quartz作为任务调度的组件&#xff0c;其中涉及到多种线程&#xff0c;主要分为主线程、调度线程和工作线程。 主线程&#xff1a;创建Quartz的调度工厂(SchedulerFactory)、调度器(Scheduler)、触发器(Trigger)、任务&#xff08;Job&#xff09;并启动调度器的线程。这里的主…

Pytest结合数据驱动-yaml

Pytest 结合数据驱动 YAML 数据驱动 什么是数据驱动&#xff1f; 数据驱动就是数据的改变从而驱动自动化测试的执行&#xff0c;最终引起测试结果的改变。简单来说&#xff0c;就是参数化的应用。数据量小的测试用例可以使用代码的参数化来实现数据驱动&#xff0c;数据量大的…

Ceph社区上游正式合入openEuler原生支持,并通过CI持续验证

作为覆盖全场景应用、支持多样性算力的面向数字基础设施的开源操作系统&#xff0c;openEuler始终遵循“上游优先”的策略&#xff0c;帮助上游开源软件原生支持openEuler&#xff0c;让openEuler系操作系统的用户可以在开发、集成、使用这些开源软件或基于这些开源软件的产品和…

比较版本号(力扣)思维 JAVA

给你两个版本号 version1 和 version2 &#xff0c;请你比较它们。 版本号由一个或多个修订号组成&#xff0c;各修订号由一个 ‘.’ 连接。每个修订号由 多位数字 组成&#xff0c;可能包含 前导零。每个版本号至少包含一个字符。修订号从左到右编号&#xff0c;下标从 0 开始…

vue3+ts+elementui-plus二次封装树形表格

复制粘贴即可&#xff1a; 一、定义table组件 <template><div classmain><div><el-table ref"multipleTableRef" :height"height" :default-expand-all"isExpend" :data"treeTableData"style"width: 100%…

IL汇编字符串连接

在此实现了一个基本的IL汇编程序&#xff1b; 了解MSIL汇编和IL汇编评估堆栈_bcbobo21cn的博客-CSDN博客 它用了下面两句来在屏幕输出字符串&#xff0c; ldstr "I am from the IL Assembly Language..." call void [mscorlib]System.Console::WriteLine (string) …

Ros终端出现找不到bash: /home/***/devel/setup.bash: 没有那个文件或目录

现象&#xff1a;Ros终端出现找不到bash: /home/***/devel/setup.bash: 没有那个文件或目录 问题&#xff1a;配置时路径写错 解决方法&#xff1a;改正路径 1.打开文件 gedit ~/.bashrc2.修改正确路径

Day 42算法记录| 动态规划 08

这里写目录标题 139. 单词拆分多重背包问题背包问题总结 139. 单词拆分 单词就是物品&#xff0c;字符串s就是背包 1.dp[0]背包啥也不要用装&#xff0c;true。 2. for循环&#xff0c;顺序很重要&#xff0c;所以先背包再物品 如果求组合数就是外层for循环遍历物品&#xff0…

UG\NX二次开发 遍历部件中所有表达式

文章作者:里海 来源网站:https://blog.csdn.net/WangPaiFeiXingYuan 简介: 遍历部件中所有表达式 效果: 代码: #include "me.hpp" #include <uf_defs.h> #include <NXOpen/NXException.hxx> #include <NXOpen/Session.hxx> #include <NXO…

java根据模板导出word

java根据模板导出word 日常开发中&#xff0c;常常会遇到各种各样的表格进行导出&#xff0c;比较好的办法就是提前弄好word模版&#xff0c;再通过遍历的方式进行导出文档 1、制作word模版 模版编写 内容替换 目标下面模版进行多页展示 将word转换成xml 将xml格式化 再将x…

FTP文件传输工具:简单、高效、实用的数据传输方式

在当今的信息化社会&#xff0c;数据已经成为各行各业的重要资产&#xff0c;而数据的传输和交换则是数据价值的体现。在很多场景中&#xff0c;企业需要传输或接收大文件&#xff0c;比如设计图纸、视频素材、软件开发包、数据库备份等。这些文件的大小通常在几百兆字节到几十…

版本控制泄露代码

在文章的开头我们首先得了解什么是版本控制 在实际的开发过程中&#xff0c;我们会用到两个工具来进行版本控制和代码托管&#xff0c;它们分别是git和svn。 而在CTF中我们主要面对的就是git或svn的版本控制泄露。 &#xff08;1&#xff09;在使用 SVN 管理本地代码过程中&am…

在拦截器中使用redis报错空指针

问题 当在拦截器中使用 redis 时&#xff0c;获取不到 RedisTemplate 对象 原因 拦截器在SpringContext初始化之前就执行了&#xff0c;即Bean初始化之前它就执行了&#xff0c;所以肯定是无法获取SpringIOC容器中的内容的 解决 提前实例化拦截器 在配置类里面先实例化拦截…

vue2项目迁移到vue3中的改动——vuex部分——基础积累2

pinia中文文档里面有关于vuex的部分&#xff1a; Pinia 最初是在 2019 年 11 月左右重新设计使用 Composition API 。从那时起&#xff0c;最初的原则仍然相同&#xff0c;但 Pinia 对 Vue 2 和 Vue 3 都有效&#xff0c;并且不需要您使用组合 API。 除了安装和 SSR 之外&…

【使用时空RBF-NN进行非线性系统识别】实现了 RBF、分数 RBF 和时空 RBF 神经网络,用于非线性系统识别研究(Matlab代码实现)

目录 &#x1f4a5;1 概述 &#x1f4da;2 运行结果 2.1 算例1 2.2 算例2 &#x1f389;3 参考文献 &#x1f308;4 Matlab代码实现 &#x1f4a5;1 概述 本文用于非线性系统识别任务的径向基函数神经网络&#xff08;RBF-NN&#xff09;的三种变体。特别是&#xff0c;我实现…

Cesium态势标绘专题-正多边形(标绘+编辑)

标绘专题介绍:态势标绘专题介绍_总要学点什么的博客-CSDN博客 入口文件:Cesium态势标绘专题-入口_总要学点什么的博客-CSDN博客 辅助文件:Cesium态势标绘专题-辅助文件_总要学点什么的博客-CSDN博客 本专题没有废话,只有代码,代码中涉及到的引入文件方法,从上面三个链…

Android OpenGL 教程——窗口初始化绘制矩形

上节介绍了 Native 工程初始化&#xff0c;但是我们的窗口什么都没有&#xff0c;这节我们将 NativeActivity 创建的 window 绑定到 OpenGL 创建的 display 的 surface 上&#xff0c;并且绘制背景颜色和三角形&#xff0c;通过三角形绘制出一个矩形 显示系统创建 void Rende…

app专项性能测试测试指标和测试方法

工作中没有做过app这块的性能测试&#xff0c;但是你有面试问到过&#xff0c;现在做个总结如下 1、首次加载&#xff08;冷启动&#xff09; A.使用logcat监控activitymanager B.adb shell am start -w C.人工秒表计数 2、非第一启动&#xff08;热启动&#xff09; 应…