当前位置:   article > 正文

小鱼商城首页_小鱼商城网页案例

小鱼商城网页案例

项目介绍:本项目是购物平台,页面展示商品,点击商品能进入详情页面,能做购 买、加入购物车等操作,购买和加入购物车都需要登录

工具:PyCharm 2021.3, Microsoft Edge, Navicat Premium 16

技术点:链接数据库,Django框架,轮播图,html+css,Cookie记住密码

主要职责:

  1. 完成项目框架设计
  2. 根据项目框架编写html,css,以及js代码编写轮播图效果
  3. 使用orm映射进行商品展示,完成首页类容

效果展示:

代码展示:

  1. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  4. <title>小鱼商城-首页</title>
  5. <link rel="stylesheet" type="text/css" href="/static/css/reset.css">
  6. <link rel="stylesheet" type="text/css" href="/static/css/main.css">
  7. <style>
  8. {#不显示滑动条#}
  9. ::-webkit-scrollbar {
  10. display: none;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <div id="app">
  16. <div class="header_con">
  17. <div class="header">
  18. <div class="welcome fl">欢迎来到小鱼商城!</div>
  19. <div class="fr">
  20. <div class="login_btn fl">
  21. 欢迎您:<em>某某某</em>
  22. <span>|</span>
  23. <a href="#">退出</a>
  24. </div>
  25. <div v-else class="login_btn fl">
  26. <a href="#">登录</a>
  27. <span>|</span>
  28. <a href="#">注册</a>
  29. </div>
  30. <div class="user_link fl">
  31. <span>|</span>
  32. <a href="#">用户中心</a>
  33. <span>|</span>
  34. <a href="#">我的购物车</a>
  35. <span>|</span>
  36. <a href="#">我的订单</a>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="search_bar clearfix">
  42. <a href="#" class="logo fl"><img src="/static/images/logo.png"></a>
  43. <div class="search_wrap fl">
  44. <form action="#" class="search_con">
  45. <input type="text" class="input_text fl" name="q" placeholder="搜索商品">
  46. <input type="submit" class="input_btn fr" name="" value="搜索">
  47. </form>
  48. <ul class="search_suggest fl">
  49. <li><a href="#">索尼微单</a></li>
  50. <li><a href="#">优惠15元</a></li>
  51. <li><a href="#">美妆个护</a></li>
  52. <li><a href="#">买2免1</a></li>
  53. </ul>
  54. </div>
  55. <div class="guest_cart fr">
  56. <a href="#" class="cart_name fl">我的购物车</a>
  57. <div class="goods_count fl" id="show_count">点击结算</div>
  58. <ul class="cart_goods_show">
  59. <li>
  60. <img src="#" alt="商品图片">
  61. <h4></h4>
  62. <div></div>
  63. </li>
  64. </ul>
  65. </div>
  66. </div>
  67. <div class="navbar_con">
  68. <div class="navbar">
  69. <div class="sub_menu_con fl">
  70. <h1 class="fl">商品分类</h1>
  71. <ul class="sub_menu">
  72. {% for k,v in cates.items %}
  73. <li>
  74. <div class="level1">
  75. {% for item in v.cate1 %}
  76. <a href="#">{{ item.name }}</a>
  77. {% endfor %}
  78. </div>
  79. <div class="level2">
  80. <div class="list_group">
  81. {% for item2 in v.cate2 %}
  82. <div class="group_name fl">{{ item2.name }} &gt;</div>
  83. <div class="group_detail fl">
  84. {% for item3 in item2.cate3_new %}
  85. <a href="/list/{{ cat3.id }}/1/">{{ item3.name }}</a>
  86. {% endfor %}
  87. </div>
  88. {% endfor %}
  89. </div>
  90. </div>
  91. </li>
  92. {% endfor %}
  93. </ul>
  94. </div>
  95. <ul class="navlist fl">
  96. <li><a href="">首页</a></li>
  97. <li class="interval">|</li>
  98. <li><a href="">真划算</a></li>
  99. <li class="interval">|</li>
  100. <li><a href="">抽奖</a></li>
  101. </ul>
  102. </div>
  103. </div>
  104. <div class="pos_center_con clearfix">
  105. <ul class="slide" style="position: absolute">
  106. {% for content in contents.index_lbt %}
  107. <li><a href="#"><img style="opacity: 0;position: absolute;transition-duration: 1s " src="/static/images/{{ content.image }}.jpg" alt="幻灯片01"></a>
  108. </li>
  109. {% endfor %}
  110. </ul>
  111. <div class="prev"></div>
  112. <div class="next"></div>
  113. <ul class="points">
  114. <li></li>
  115. <li></li>
  116. <li></li>
  117. <li></li>
  118. </ul>
  119. <div class="news">
  120. <div class="news_title">
  121. <h3>快讯</h3>
  122. <a href="#">更多 &gt;</a>
  123. </div>
  124. <ul class="news_list">
  125. {% for content in contents.index_kx %}
  126. <li><a href="{{ content.url }}">{{ content.title }}</a></li>
  127. {% endfor %}
  128. </ul>
  129. {% for content in contents.index_ytgg %}
  130. <a href="{{ content.url }}" class="advs"><img src="/static/images/{{ content.image }}.jpg"></a>
  131. {% endfor %}
  132. </div>
  133. </div>
  134. <div class="floor_adv">
  135. <div class="list_model">
  136. <div class="list_title clearfix">
  137. <h3 class="fl" id="model01">1F 手机通讯</h3>
  138. <div id="f1" class="subtitle fr">
  139. <a>时尚新品</a>
  140. <a>畅想低价</a>
  141. <a>手机配件</a>
  142. </div>
  143. </div>
  144. <div class="goods_con clearfix">
  145. <div class="goods_banner fl">
  146. <!--{# <img src="/static/data_images/{{ contents.index_1f_logo.0.image.url}}.jpg">#}-->
  147. {# <img src="/static/images/indexes/{{ contents.index_1f_logo.0.image.url}}.jpg">#}
  148. <img src="/static/images/{{ contents.index_1f_logo.0.image}}.jpg">
  149. <div class="channel">
  150. {% for content in contents.index_1f_pd %}
  151. <a href="{{ content.url }}">{{ content.title }}</a>
  152. {% endfor %}
  153. </div>
  154. <div class="key_words">
  155. {% for content in contents.index_1f_bq %}
  156. <a href="{{ content.url }}">{{ content.title }}</a>
  157. {% endfor %}
  158. </div>
  159. </div>
  160. <div id="goods_list_con" class="goods_list_con" style="overflow: auto" >
  161. <ul class="goods_list fl ">
  162. {% for content in contents.index_1f_ssxp %}
  163. <li>
  164. <!--{# <a href="{{ content.url }}" class="goods_pic"><img src="/static/data_images/{{ content.image.url }}.jpg"></a>#}-->
  165. {# <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/indexes/{{ content.image.url }}.jpg"></a>#}
  166. <a href="/product/detail/{{ content.id }}" class="goods_pic"><img src="/static/images/{{ content.image }}.jpg"></a>
  167. <h4><a href="{{ content.url }}" title="{{ content.title }}">{{ content.title }}</a></h4>
  168. <div class="price">{{ content.text }}</div>
  169. </li>
  170. {% endfor %}
  171. </ul>
  172. <ul class="goods_list fl" style="display: none">
  173. {% for content in contents.index_1f_cxdj %}
  174. <li>
  175. <!--{# <a href="{{ content.url }}" class="goods_pic"><img src="/static/data_images/{{ content.image.url }}.jpg"></a>#}-->
  176. {# <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/indexes/{{ content.image.url }}.jpg"></a>#}
  177. <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/{{ content.image}}.jpg"></a>
  178. <h4><a href="{{ content.url }}" title="{{ content.title }}">{{ content.title }}</a></h4>
  179. <div class="price">{{ content.text }}</div>
  180. </li>
  181. {% endfor %}
  182. </ul>
  183. <ul class="goods_list fl" style="display: none">
  184. {% for content in contents.index_1f_sjpj %}
  185. <li>
  186. <!--{# <a href="{{ content.url }}" class="goods_pic"><img src="/static/data_images/{{ content.image.url }}.jpg"></a>#}-->
  187. {# <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/indexes/{{ content.image.url }}.jpg"></a>#}
  188. <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/{{ content.image }}.jpg"></a>
  189. <h4><a href="{{ content.url }}" title="{{ content.title }}">{{ content.title }}</a></h4>
  190. <div class="price">{{ content.text }}</div>
  191. </li>
  192. {% endfor %}
  193. </ul>
  194. </div>
  195. </div>
  196. </div>
  197. <div class="list_model model02">
  198. <div class="list_title clearfix">
  199. <h3 class="fl" id="model01">2F 电脑数码</h3>
  200. <div id="f2" class="subtitle fr">
  201. <a >加价换购</a>
  202. <a >畅享低价</a>
  203. </div>
  204. </div>
  205. <div class="goods_con clearfix">
  206. <div class="goods_banner fl">
  207. <!--{# <img src="/static/data_images/{{ contents.index_2f_logo.0.image.url}}.jpg">#}-->
  208. {# <img src="/static/images/indexes/{{ contents.index_2f_logo.0.image.url}}.jpg">#}
  209. <img src="/static/images/{{ contents.index_2f_logo.0.image}}.jpg">
  210. <div class="channel">
  211. {% for content in contents.index_2f_pd %}
  212. <a href="{{ content.url }}">{{ content.title }}</a>
  213. {% endfor %}
  214. </div>
  215. <div class="key_words">
  216. {% for content in contents.index_2f_bq %}
  217. <a href="{{ content.url }}">{{ content.title }}</a>
  218. {% endfor %}
  219. </div>
  220. </div>
  221. <div id="goods_list_con2" class="goods_list_con" style="overflow: auto">
  222. <ul class="goods_list f2">
  223. {% for content in contents.index_2f_cxdj %}
  224. <li>
  225. <!--{# <a href="{{ content.url }}" class="goods_pic"><img src="/static/data_images/{{ content.image.url }}.jpg"></a>#}-->
  226. {# <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/indexes/{{ content.image.url }}.jpg"></a>#}
  227. <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/{{ content.image }}.jpg"></a>
  228. <h4><a href="{{ content.url }}" title="{{ content.title }}">{{ content.title }}</a></h4>
  229. <div class="price">{{ content.text }}</div>
  230. </li>
  231. {% endfor %}
  232. </ul>
  233. <ul class="goods_list f2" style="display: none">
  234. {% for content in contents.index_2f_jjhg %}
  235. <li>
  236. <!--{# <a href="{{ content.url }}" class="goods_pic"><img src="/static/data_images/{{ content.image.url }}.jpg"></a>#}-->
  237. {# <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/indexes/{{ content.image.url }}.jpg"></a>#}
  238. <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/{{ content.image }}.jpg"></a>
  239. <h4><a href="{{ content.url }}" title="{{ content.title }}">{{ content.title }}</a></h4>
  240. <div class="price">{{ content.text }}</div>
  241. </li>
  242. {% endfor %}
  243. </ul>
  244. </div>
  245. </div>
  246. </div>
  247. <div class="list_model model03">
  248. <div class="list_title clearfix">
  249. <h3 class="fl" id="model01">3F 家居家装</h3>
  250. <div id="f3" class="subtitle fr">
  251. <a>生活用品</a>
  252. <a>厨房用品</a>
  253. </div>
  254. </div>
  255. <div class="goods_con clearfix">
  256. <div class="goods_banner fl">
  257. <img src="/static/images/{{ contents.index_3f_logo.0.image }}.jpg">
  258. <div class="channel">
  259. {% for content in contents.index_3f_pd %}
  260. <a href="{{ content.url }}">{{ content.title }}</a>
  261. {% endfor %}
  262. </div>
  263. <div class="key_words">
  264. {% for content in contents.index_3f_bq %}
  265. <a href="{{ content.url }}">{{ content.title }}</a>
  266. {% endfor %}
  267. </div>
  268. </div>
  269. <div id="goods_list_con3" class="goods_list_con" style="overflow: auto">
  270. <ul class="goods_list fl">
  271. {% for content in contents.index_3f_shyp %}
  272. <li>
  273. <!--{# <a href="{{ content.url }}" class="goods_pic"><img src="/static/data_images/{{ content.image.url }}.jpg"></a>#}-->
  274. {# <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/indexes/{{ content.image.url }}.jpg"></a>#}
  275. <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/{{ content.image }}.jpg"></a>
  276. <h4><a href="{{ content.url }}" title="{{ content.title }}">{{ content.title }}</a></h4>
  277. <div class="price">{{ content.text }}</div>
  278. </li>
  279. {% endfor %}
  280. </ul>
  281. <ul class="goods_list fl" style="display: none">
  282. {% for content in contents.index_3f_cfyp %}
  283. <li>
  284. <!--{# <a href="{{ content.url }}" class="goods_pic"><img src="/static/data_images/{{ content.image.url }}.jpg"></a>#}-->
  285. {# <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/indexes/{{ content.image.url }}.jpg"></a>#}
  286. <a href="{{ content.url }}" class="goods_pic"><img src="/static/images/{{ content.image }}.jpg"></a>
  287. <h4><a href="{{ content.url }}" title="{{ content.title }}">{{ content.title }}</a></h4>
  288. <div class="price">{{ content.text }}</div>
  289. </li>
  290. {% endfor %}
  291. </ul>
  292. </div>
  293. </div>
  294. </div>
  295. </div>
  296. <div class="footer">
  297. <div class="foot_link">
  298. <a href="#">关于我们</a>
  299. <span>|</span>
  300. <a href="#">联系我们</a>
  301. <span>|</span>
  302. <a href="#">招聘人才</a>
  303. <span>|</span>
  304. <a href="#">友情链接</a>
  305. </div>
  306. <p>CopyRight © 2016 北京小鱼商业股份有限公司 All Rights Reserved</p>
  307. <p>电话:010-****888 京ICP备*******8号</p>
  308. </div>
  309. </div>
  310. </body>
  311. <script src="/static/js/gaoliang.js"></script>
  312. <script src="/static/js/Carousel.js"></script>
  313. </html>

 

  1. from django.shortcuts import render
  2. from Product.models import TbContent,TbGoodsChannel,TbContentCategory,TbSku,TbChannelGroup,TbGoodsCategory,TbSpu
  3. from django.db.models import Avg,Sum,Count
  4. # from redis import Redis
  5. # Create your views here.
  6. def index(request):
  7. tbc=TbContentCategory.objects.all()
  8. contents={}
  9. for item in tbc:
  10. contents[item.key]=TbContent.objects.filter(category_id=item.id)
  11. cates={}
  12. tgc=TbGoodsChannel.objects.all()
  13. for item in tgc:
  14. if item.group_id not in cates.keys():
  15. cates[item.group_id]={"cate1":[],'cate2':[]}
  16. cate1=item.category
  17. cates[item.group_id]['cate1'].append(cate1)
  18. cate2=TbGoodsCategory.objects.filter(parent_id=cate1.id)
  19. for item2 in cate2:
  20. item2.cate3_new=[]
  21. cate3=TbGoodsCategory.objects.filter(parent_id=item2.id)
  22. for item3 in cate3:
  23. item2.cate3_new.append(item3)
  24. cates[item.group_id]['cate2'].append(item2)
  25. return render(request,'index12.html',locals())
  26. def list(request):
  27. lists=TbSku.objects.all()
  28. hot_shop = TbSku.objects.order_by('comments')
  29. print(hot_shop)
  30. return render(request,'list.html',locals())
  31. def detail(request,id):
  32. # rc=Redis(host='192.168.121.78')
  33. # rc.hset('111','111','111')
  34. # info=rc.hgetall('111')
  35. # print(info)
  36. details = TbSku.objects.get(id=id)
  37. return render(request,'detail.html',locals())

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/178219
推荐阅读
相关标签
  

闽ICP备14008679号