飞道的博客

衣服、商品、商城网站模板首页,仿U袋网,vue+elementui简洁实现(二)

521人阅读  评论(0)

一.前言

接上一遍博客:《衣服、商品、商城网站模板首页,仿U袋网,vue+elementui简洁实现

在此基础上增加了和完善一些页面:

  • 商品分类筛选页面
  • 登录、注册、找回密码共用页面
  • U袋学堂(视频专区,视频播放)
  • 企业账号(企业简述页面,简单例子)
  • 诚信合约(简单例子)
  • 实时下架(简单例子)

当前最新demo源码并没有提供下载,需要源码或需要增加其他页面的,私聊即可(会及时回复)。

二.主页面,分离了菜单(达到共用)

 分离在top(顶部共用):


  
  1. <template>
  2. <div style="font-size: 14px;">
  3. <div style="display: flex;height: 40px;padding: 0 400px;background-color: #f5f5f5;">
  4. <div class="top-title" style="padding-right: 20px;line-height: 40px;color: #666;">嗨,欢迎来到 <span style="color: #b31e22;">XXX </span> </div>
  5. <div class="top-title" style="padding-right: 20px;line-height: 40px;color: #666;margin-left: 20px;">网店代销 </div>
  6. <div class="top-title" style="padding-right: 20px;line-height: 40px;color: #666;margin-left: 20px;">帮助中心 </div>
  7. <div style="flex: 1;display: flex;">
  8. <div style="flex: 1;"> </div>
  9. <div style="width: 300px;display: flex;">
  10. <el-button type="text" style="color: #666;" class="top-title" @click="toLogin">登录 </el-button>
  11. <el-button type="text" style="color: #666;margin-right: 10px;" class="top-title" @click="toLogin">注册 </el-button>
  12. <el-button type="text" style="color: #666;margin-right: 10px;" class="top-title">我的U袋 </el-button>
  13. <el-button type="text" style="color: #666;margin-right: 10px;" class="top-title">我的订单 </el-button>
  14. <el-button type="text" style="color: #666;margin-right: 10px;" class="top-title">积分平台 </el-button>
  15. </div>
  16. </div>
  17. </div>
  18. <div style="margin: 0 400px;height: 100px;line-height: 100px;">
  19. <div style="display: flex;">
  20. <div style="width: 200px;height: 100px;">
  21. <img src="../../../public/img/logo.jpg" style="cursor: pointer;width: 200px;height: 100px;">
  22. </div>
  23. <div style="flex: 1;text-align: center;padding: 0 50px;">
  24. <el-input placeholder="Ta们都在搜XXX" v-model="input" style="width: 100%;margin-top: 30px;">
  25. <el-button slot="append" icon="el-icon-search"> </el-button>
  26. </el-input>
  27. </div>
  28. <div style="width: 200px;text-align: center;">
  29. <el-button type="warning" icon="el-icon-shopping-cart-2">购物车 0 件 </el-button>
  30. </div>
  31. </div>
  32. </div>
  33. <div style="height: 40px;line-height: 40px;background-color: #333;display: flex;">
  34. <div :class="'menu-index '+(menuIndex===1?'menu-active':'')" @click="selMenu(1)" style="margin-left: 400px;color: #FFFFFF;">
  35. <div> <i class="el-icon-menu" style="margin-right: 10px;"> </i>全部分类 </div>
  36. </div>
  37. <div :class="'menu-index '+(menuIndex===2?'menu-active':'')" @click="selMenu(2)">
  38. 首页
  39. </div>
  40. <div :class="'menu-index '+(menuIndex===3?'menu-active':'')" @click="selMenu(3)">
  41. 企业简介
  42. </div>
  43. <div :class="'menu-index '+(menuIndex===4?'menu-active':'')" @click="selMenu(4)">
  44. 新手上路
  45. </div>
  46. <div :class="'menu-index '+(menuIndex===5?'menu-active':'')" @click="selMenu(5)">
  47. U袋学堂
  48. </div>
  49. <div :class="'menu-index '+(menuIndex===6?'menu-active':'')" @click="selMenu(6)">
  50. 企业账号
  51. </div>
  52. <div :class="'menu-index '+(menuIndex===7?'menu-active':'')" @click="selMenu(7)">
  53. 诚信合约
  54. </div>
  55. <div :class="'menu-index '+(menuIndex===8?'menu-active':'')" @click="selMenu(8)">
  56. 实时下架
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. export default {
  63. data( ) {
  64. return {
  65. input: '',
  66. menuIndex: 1
  67. };
  68. },
  69. mounted( ) {
  70. },
  71. methods: {
  72. selMenu( index){
  73. if( this. menuIndex === index){
  74. return;
  75. }
  76. this. menuIndex = index;
  77. if(index === 2){
  78. this. $router. push({ path: '/home/index'});
  79. } else if(index === 5){
  80. this. $router. push({ path: '/video/index'});
  81. } else if(index === 6){
  82. this. $router. push({ path: '/enterprise/index'});
  83. } else if(index === 7){
  84. this. $router. push({ path: '/contract/index'});
  85. } else if(index === 8){
  86. this. $router. push({ path: '/shelf/index'});
  87. }
  88. },
  89. toLogin( ){
  90. this. $router. push({ path: '/login'});
  91. }
  92. }
  93. };
  94. </script>
  95. <style>
  96. .top-title :hover{
  97. cursor: pointer;
  98. color: #b31e22 !important;
  99. }
  100. .el-input-group__append, .el-input-group__prepend{
  101. background-color: #b31e22 !important;
  102. color: #ffffff !important;
  103. }
  104. .menu-index{
  105. text-align: center;
  106. width: 100px;
  107. color: #FFFFFF;
  108. cursor: pointer;
  109. }
  110. .menu-index :hover{
  111. background-color: #666;
  112. }
  113. .menu-active{
  114. background-color: #b31e22 !important;
  115. }
  116. </style>

主布局:


  
  1. <template>
  2. <div id="body" style="width: 100%;height: 100%;overflow: auto;">
  3. <top> </top>
  4. <router-view> </router-view>
  5. <foot> </foot>
  6. </div>
  7. </template>
  8. <script>
  9. import top from "../top/index.vue";
  10. import foot from "../foot/index";
  11. export default {
  12. components: {
  13. top,
  14. foot
  15. },
  16. name: "index",
  17. data( ) {
  18. return {
  19. };
  20. },
  21. mounted( ) {
  22. },
  23. methods: {
  24. }
  25. };
  26. </script>
  27. <style>
  28. #body{
  29. background-size: 100% 100%;
  30. background-repeat: no-repeat;
  31. }
  32. </style>

三.商品分类筛选页面

模拟动态数据:

 


  
  1. export default {
  2. name: "index",
  3. data( ) {
  4. return {
  5. tags: [
  6. { name: '颜色:灰色', type: 'info' },
  7. { name: '尺寸:XXXL', type: 'info' }
  8. ],
  9. types1: [ '全部', '上装', '下装', '裙装', '内衣'],
  10. typeIndex1: 0,
  11. types2: [ '全部', '红色', '粉红', '蓝色', '白色'],
  12. typeIndex2: 0,
  13. types3: [ '全部', 'L', 'M', 'S', 'X', 'XL', 'XXL', 'XXXL'],
  14. typeIndex3: 0,
  15. types4: [ '全部', '0-20', '20-40', '40-80', '80-100', '100-150', '150以上'],
  16. typeIndex4: 0,
  17. types5: [ '销量↑', '评价↓', '价格'],
  18. typeIndex5: 0,
  19. startPrice: '',
  20. endPrice: '',
  21. products: [
  22. { productName: '锦瑟 原创传统日常汉服男绣花交领衣裳cp情侣装春夏款', price: 18.0, saleNum: 666, hot: 888, commentNum: 1666, img: 'http://shop.jlkjgf.cn/images/temp/M-001.jpg'},
  23. { productName: '锦瑟 原创传统日常汉服男绣花交领衣裳cp情侣装春夏款', price: 18.0, saleNum: 666, hot: 888, commentNum: 1666, img: 'http://shop.jlkjgf.cn/images/temp/M-001.jpg'},
  24. { productName: '锦瑟 原创传统日常汉服男绣花交领衣裳cp情侣装春夏款', price: 18.0, saleNum: 666, hot: 888, commentNum: 1666, img: 'http://shop.jlkjgf.cn/images/temp/M-001.jpg'},
  25. { productName: '锦瑟 原创传统日常汉服男绣花交领衣裳cp情侣装春夏款', price: 18.0, saleNum: 666, hot: 888, commentNum: 1666, img: 'http://shop.jlkjgf.cn/images/temp/M-001.jpg'},
  26. { productName: '锦瑟 原创传统日常汉服男绣花交领衣裳cp情侣装春夏款', price: 18.0, saleNum: 666, hot: 888, commentNum: 1666, img: 'http://shop.jlkjgf.cn/images/temp/M-001.jpg'},
  27. { productName: '锦瑟 原创传统日常汉服男绣花交领衣裳cp情侣装春夏款', price: 18.0, saleNum: 666, hot: 888, commentNum: 1666, img: 'http://shop.jlkjgf.cn/images/temp/M-001.jpg'},
  28. { productName: '锦瑟 原创传统日常汉服男绣花交领衣裳cp情侣装春夏款', price: 18.0, saleNum: 666, hot: 888, commentNum: 1666, img: 'http://shop.jlkjgf.cn/images/temp/M-001.jpg'},
  29. { productName: '锦瑟 原创传统日常汉服男绣花交领衣裳cp情侣装春夏款', price: 18.0, saleNum: 666, hot: 888, commentNum: 1666, img: 'http://shop.jlkjgf.cn/images/temp/M-001.jpg'},
  30. { productName: '锦瑟 原创传统日常汉服男绣花交领衣裳cp情侣装春夏款', price: 18.0, saleNum: 666, hot: 888, commentNum: 1666, img: 'http://shop.jlkjgf.cn/images/temp/M-001.jpg'},
  31. ]
  32. };
  33. },
  34. mounted( ) {
  35. },
  36. methods: {
  37. handleClose( tag) {
  38. this. tags. splice( this. tags. indexOf(tag), 1);
  39. },
  40. selType1( index){
  41. this. typeIndex1 = index;
  42. },
  43. selType2( index){
  44. this. typeIndex2 = index;
  45. },
  46. selType3( index){
  47. this. typeIndex3 = index;
  48. },
  49. selType4( index){
  50. this. typeIndex4 = index;
  51. },
  52. selType5( index){
  53. this. typeIndex5 = index;
  54. }
  55. }
  56. }

四.U袋学堂-视频专区

 视频数据,视频播放方法:


  
  1. export default {
  2. name: "index",
  3. data( ) {
  4. return {
  5. videos: [
  6. { title: 'U袋学堂第一课', des: '免费学习', img: 'http://shop.jlkjgf.cn/images/temp/S-001-1_s.jpg', videoPath: 'http://shop.jlkjgf.cn/images/temp/videos/video_1.mp4'},
  7. { title: 'U袋学堂第一课', des: '免费学习', img: 'http://shop.jlkjgf.cn/images/temp/S-001-1_s.jpg', videoPath: 'http://shop.jlkjgf.cn/images/temp/videos/video_1.mp4'},
  8. { title: 'U袋学堂第一课', des: '免费学习', img: 'http://shop.jlkjgf.cn/images/temp/S-001-1_s.jpg', videoPath: 'http://shop.jlkjgf.cn/images/temp/videos/video_1.mp4'},
  9. { title: 'U袋学堂第一课', des: '免费学习', img: 'http://shop.jlkjgf.cn/images/temp/S-001-1_s.jpg', videoPath: 'http://shop.jlkjgf.cn/images/temp/videos/video_1.mp4'},
  10. { title: 'U袋学堂第一课', des: '免费学习', img: 'http://shop.jlkjgf.cn/images/temp/S-001-1_s.jpg', videoPath: 'http://shop.jlkjgf.cn/images/temp/videos/video_1.mp4'},
  11. { title: 'U袋学堂第一课', des: '免费学习', img: 'http://shop.jlkjgf.cn/images/temp/S-001-1_s.jpg', videoPath: 'http://shop.jlkjgf.cn/images/temp/videos/video_1.mp4'},
  12. { title: 'U袋学堂第一课', des: '免费学习', img: 'http://shop.jlkjgf.cn/images/temp/S-001-1_s.jpg', videoPath: 'http://shop.jlkjgf.cn/images/temp/videos/video_1.mp4'},
  13. { title: 'U袋学堂第一课', des: '免费学习', img: 'http://shop.jlkjgf.cn/images/temp/S-001-1_s.jpg', videoPath: 'http://shop.jlkjgf.cn/images/temp/videos/video_1.mp4'},
  14. ],
  15. playBox: false,
  16. video: null,
  17. isPlay: 0, //默认0未自动播放 1播放 2暂停
  18. eleVideo: null,
  19. autoPlay: false, //自动播放
  20. };
  21. },
  22. mounted( ) {
  23. },
  24. methods: {
  25. autoPlayFun( ){
  26. this. autoPlay = ! this. autoPlay;
  27. },
  28. playModal( item){
  29. this. video = item;
  30. this. playBox = true;
  31. if(! this. eleVideo){
  32. let that = this;
  33. setTimeout( function( ){
  34. that. eleVideo = that. $refs. player;
  35. that. eleVideo. addEventListener( 'waiting', function ( ) { //加载
  36. console. log( "加载中");
  37. });
  38. that. eleVideo. addEventListener( 'play', function ( ) { //播放开始执行的函数
  39. console. log( "开始播放");
  40. that. isPlay = 1;
  41. console. log(that. isPlay);
  42. });
  43. that. eleVideo. addEventListener( 'playing', function ( ) { //播放中
  44. console. log( "播放中");
  45. that. isPlay = 1;
  46. console. log(that. isPlay);
  47. });
  48. that. eleVideo. addEventListener( 'pause', function ( ) { //暂停开始执行的函数
  49. console. log( "暂停播放");
  50. that. isPlay = 2;
  51. console. log(that. isPlay);
  52. });
  53. if(that. autoPlay){
  54. that. playFun(); //加载马上自动播放,有些浏览器已经不支持自动播放,可以先设置浏览器允许自动播放
  55. }
  56. }, 300);
  57. } else if( this. autoPlay){
  58. this. playFun(); //加载马上自动播放,有些浏览器已经不支持自动播放,可以先设置浏览器允许自动播放
  59. }
  60. },
  61. playFun( ) {
  62. if (! this. $refs. player) {
  63. alert( '播放资源不存在!');
  64. return;
  65. }
  66. if ( this. isPlay === 1) { //暂停
  67. this. isPlay = 2;
  68. this. $refs. player. pause();
  69. } else if ( this. isPlay === 0 || this. isPlay === 2) { //播放
  70. this. $refs. player. play();
  71. }
  72. },
  73. beforeClose( ){
  74. this. isPlay = 2;
  75. this. $refs. player. pause();
  76. this. playBox = false;
  77. }
  78. }
  79. }

五.登录、注册、找回密码

 

 登录、注册、找回密码通过参数控制切换页面效果:


  
  1. <div style="display: flex;width: 100%;height: 100%;overflow: hidden;">
  2. <div class="name"> <span @click="homePage" style="cursor: pointer;">欢迎使用U袋网平台 </span> </div>
  3. <div class="login-modal">
  4. <div class="title">{{modalType === 'login'?'登录':(modalType==='forget'?'找回密码':'注册')}} </div>
  5. <el-form class="login-form"
  6. :rules= "loginRules"
  7. ref= "loginForm"
  8. :model= "loginForm"
  9. label-width= "0">
  10. <el-form-item prop="phone">
  11. <el-input
  12. placeholder= "请输入手机号"
  13. prefix-icon= "el-icon-mobile-phone"
  14. v-model= "loginForm.phone">
  15. </el-input>
  16. </el-form-item>
  17. <el-form-item v-show="modalType !== 'login'" prop="validCode">
  18. <el-input placeholder="请输入验证码" v-model="loginForm.validCode">
  19. <el-button slot="append" @click="handleLogin">发送短信验证码 </el-button>
  20. </el-input>
  21. </el-form-item>
  22. <el-form-item prop="password">
  23. <el-input
  24. :type= "passwordType"
  25. placeholder= "请输入密码"
  26. prefix-icon= "el-icon-lock"
  27. v-model= "loginForm.password">
  28. </el-input>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-row>
  32. <el-col :span="12">
  33. <el-checkbox v-model="loginForm.rememberPwd">30天内免登录 </el-checkbox>
  34. </el-col>
  35. <el-col :span="12" v-if="modalType !== 'forget'">
  36. <div style="color: #df1f20;float: right;cursor: pointer;" @click="changeModalType('forget')">忘记密码? </div>
  37. </el-col>
  38. </el-row>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="primary"
  42. style= "width: 100%;"
  43. @ click.native.prevent= "handleLogin"
  44. class= "login-submit">
  45. {{modalType === 'login'?'登录':(modalType==='forget'?'重置密码':'注册')}}
  46. </el-button>
  47. </el-form-item>
  48. <div v-if="modalType === 'login'" style="text-align: center;font-size: 14px;">
  49. 没有账号? <span style="cursor: pointer;color: #df1f20;" @click="changeModalType('register')">免费注册 </span>
  50. </div>
  51. <div v-if="modalType !== 'login'" style="text-align: center;font-size: 14px;">
  52. 已有账号? <span style="cursor: pointer;color: #df1f20;" @click="changeModalType('login')">返回登录 </span>
  53. </div>
  54. </el-form>
  55. </div>
  56. </div>

 

六.其他简单页面

 

 

 


转载:https://blog.csdn.net/lucky_fang/article/details/128444977
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场