当前位置:   article > 正文

微信小程序—仿写京东购物商城带源码_微信小程序仿京东

微信小程序仿京东

商品分类界面 

搜索界面 

代码:

  1. 首页wxml:
  2. <!--顶部搜素框-->
  3. <view class="search">
  4. <view class="searchlong">
  5. <image class="searchico" src="/images/index/16.png"></image>
  6. <input class="searchkuang" type="text" placeholder="窗帘遮光"/>
  7. <image class="photoico" src="/images/index/17.png"></image>
  8. <button class="searchbutton">搜索</button>
  9. </view>
  10. <image class="doudou" src="/images/index/15.jpg"></image>
  11. <view class="daohanglan">
  12. <block wx:for="{{daohang}}">
  13. <text class="daohangstyle">{{item}}</text>
  14. </block>
  15. <image class="xiala" src="/images/index/18.png"></image>
  16. </view>
  17. </view>
  18. <!--顶部轮播图-->
  19. <view class="luobotu">
  20. <swiper autoplay="{{autoplay}}" interval="{{interval}}">
  21. <block wx:for="{{imgUrls}}">
  22. <swiper-item>
  23. <image class = "lunboimg" src="{{item}}"></image>
  24. </swiper-item>
  25. </block>
  26. </swiper>
  27. </view>
  28. <!--10个京东图标-->
  29. <view class="content">
  30. <block wx:for="{{elements}}">
  31. <view class="content-item">
  32. <view>
  33. <image src="{{item.image}}" style="width:86rpx;height:78rpx;"></image>
  34. </view>
  35. <view>
  36. {{item.name}}
  37. </view>
  38. </view>
  39. </block>
  40. </view>
  41. <view class="shenquan">
  42. <image class="shenquanimg" src="/images/index/11.jpg"></image>
  43. </view>
  44. <!--商品展示-->
  45. <view class="hr"></view>
  46. <view class="footer">
  47. <text class="jd">京东秒杀</text>
  48. <image class="footerimg" src="/images/index/12.png"></image>
  49. <text class="wenzi">9.9元抢翻天</text>
  50. <text class="jiantou"></text>
  51. <view class="content1">
  52. <block wx:for="{{elements2}}">
  53. <view class="botton">
  54. <view>
  55. <image src="{{item.image}}" style="width:170rpx;height:200rpx;"></image>
  56. <text class="money">
  57. {{item.name}}
  58. </text>
  59. </view>
  60. </view>
  61. </block>
  62. </view>
  63. </view>
  1. 首页wxss:
  2. /*顶部图片大小*/
  3. swiper image {
  4. width: 100%;
  5. height: 300rpx;
  6. }
  7. .search{
  8. position: absolute;
  9. width: 750rpx;
  10. height: 300rpx;
  11. background-color: #FF0000;
  12. }
  13. .kongge{
  14. width: 20px;
  15. height: 20px;
  16. }
  17. .searchbutton{
  18. background-color: rgb(201,52,35);
  19. width: 50px;
  20. height: 55rpx;
  21. margin-top: 2rpx;
  22. border-radius: 10px 10px 10px 10px;
  23. font-size: 9px;
  24. color: #f4f5f6;
  25. }
  26. .doudou{
  27. width: 60rpx;
  28. height:60rpx;
  29. position: absolute;
  30. right: 20rpx;
  31. top: 5rpx;
  32. }
  33. .searchico{
  34. margin-top: 5px;
  35. margin-left: 10px;
  36. margin-right: 7px;
  37. width: 20px;
  38. height: 20px;
  39. border-radius: 10px 10px 10px 10px;
  40. }
  41. .daohanglan{
  42. position: relative;
  43. top: 5px;
  44. }
  45. .luobotu{
  46. position: relative;
  47. top: 70px;
  48. }
  49. .shenquan{
  50. margin-top: 23px;
  51. width: auto;
  52. height: 130rpx;
  53. }
  54. .shenquanimg{
  55. margin-left: 20rpx;
  56. margin-right: 20rpx;
  57. height: 130rpx;
  58. width: 700rpx;
  59. }
  60. .lunboimg{
  61. height: 100px;
  62. width: 700rpx;
  63. margin-left: 25rpx;
  64. margin-right: 25rpx;
  65. border-radius: 10px 10px 10px 10px;
  66. }
  67. .xiala{
  68. position: relative;
  69. top: 5px;
  70. right: 0px;
  71. width: 20px;
  72. height: 20px;
  73. }
  74. .daohangstyle{
  75. font-size: 13px;
  76. color: #f4f5f6;
  77. margin: 17rpx;
  78. }
  79. .photoico{
  80. margin-top: 5px;
  81. margin-left: 10px;
  82. margin-right: 2px;
  83. width: 20px;
  84. height: 20px;
  85. border-radius: 10px 10px 10px 10px;
  86. }
  87. .searchkuang{
  88. font-size: 12px;
  89. width: 335rpx;
  90. height: 30px;
  91. }
  92. .searchlong{
  93. position: relative;
  94. display: flex;
  95. flex-direction: row;
  96. flex-wrap: wrap;
  97. width: 640rpx;
  98. height: 25px;
  99. border-radius: 20px 20px 20px 20px;
  100. font-weight: 100;
  101. background-color: #f4f5f6;
  102. left: 20rpx;
  103. }
  104. /*10个京东图标外部容器布局*/
  105. .content {
  106. display: flex;
  107. flex-direction: row;
  108. flex-wrap: wrap;
  109. position: relative;
  110. top: 20px;
  111. }
  112. /*10个京东图标内部容器样式*/
  113. .content-item {
  114. width: 20%;
  115. text-align: center;
  116. font-size: 24rpx;
  117. margin: 8rpx 0;
  118. }
  119. /*分割线样式*/
  120. .hr {
  121. width: 100%;
  122. height: 30rpx;
  123. background-color: #f4f5f6;
  124. }
  125. .content1{
  126. display: flex;
  127. flex-direction: row;
  128. flex-wrap: wrap;
  129. height: 400rpx;
  130. }
  131. /*页面底部外部容器布局
  132. .footer {
  133. display: flex;
  134. flex-direction: row;
  135. justify-content: space-between;
  136. padding: 20rpx 40rpx;
  137. }*/
  138. /*"京东拼购"字体样式*/
  139. .jd {
  140. margin: 20rpx;
  141. }
  142. .footerimg{
  143. margin-top: 20rpx;
  144. width: 200rpx;
  145. height: 50rpx;
  146. }
  147. .wenzi {
  148. margin-left: 130rpx;
  149. font-size: 12px;
  150. color: darkgrey;
  151. }
  152. .jiantou{
  153. font-size: 20px;
  154. margin-top: 20rpx;
  155. position: absolute;
  156. right: 0rpx;
  157. font-weight: bolder;
  158. }
  159. .botton{
  160. margin-top: 10rpx;
  161. width: 150rpx;
  162. margin-left: 10rpx;
  163. margin-right: 10rpx;
  164. height: 230rpx;
  165. }
  166. .money{
  167. color: #FF0000;
  168. font-size: 14px;
  169. font-weight: bolder;
  170. }
  1. 首页js:
  2. Page({
  3. data: {
  4. autoplay: true,
  5. interval: 5000,
  6. imgUrls: [
  7. "/images/haibao/haibao-1.png",
  8. "/images/haibao/haibao-3.jpg",
  9. "/images/haibao/haibao-2.png"
  10. ],
  11. daohang: [
  12. "首页",
  13. "补贴爆品",
  14. "女鞋",
  15. "宠物",
  16. "爱车",
  17. "箱包皮具"
  18. ],
  19. elements: [{
  20. image: "/images/index/1.png",
  21. name: "京东超市",
  22. }, {
  23. image: "/images/index/2.png",
  24. name: "京东家电",
  25. },
  26. {
  27. image: "/images/index/3.png",
  28. name: " 京东服饰",
  29. },
  30. {
  31. image: "/images/index/4.png",
  32. name: "京东手机",
  33. },
  34. {
  35. image: "/images/index/5.png",
  36. name: "京喜",
  37. },
  38. {
  39. image: "/images/index/6.jpg",
  40. name: "一元疯抢",
  41. }, {
  42. image: "/images/index/7.jpg",
  43. name: "领京豆",
  44. }, {
  45. image: "/images/index/8.jpg",
  46. name: " 领优惠券",
  47. }, {
  48. image: "/images/index/9.jpg",
  49. name: "免费水果",
  50. }, {
  51. image: "/images/index/10.jpg",
  52. name: "充值中心",
  53. },
  54. ],
  55. elements2: [{
  56. image: "/images/index/19.jpg",
  57. name: "京东超市",
  58. }, {
  59. image: "/images/index/20.jpg",
  60. name: "京东家电",
  61. },
  62. {
  63. image: "/images/index/21.jpg",
  64. name: " 京东服饰",
  65. },
  66. {
  67. image: "/images/index/22.jpg",
  68. name: " 京东服饰",
  69. },
  70. ],
  71. }
  72. })
  1. 搜索wxml:
  2. <view class="total">
  3. <view class="search">
  4. <image class="searchicon" src="/images/index/45.png"></image>
  5. <view class="searchtext">手机x</view>
  6. </view>
  7. <view class="tiaojian">
  8. <view class="zonghe">综合<image class="xiala" src="/images/index/46.png"></image></view>
  9. <view class="xiaoliang">销量</view>
  10. <view class="price">价格<image class="priceimg" src="/images/index/47.png" ></image></view>
  11. <view class="hour"><image class="houtimg" src="/images/index/48.png" ></image>小时达</view>
  12. </view>
  13. <view class="biaoji">
  14. <view class="bggray">京东物流</view>
  15. <view class="bggray">新品</view>
  16. <view class="bggray">品牌<image class="pinpai" src="/images/index/46.png"></image></view>
  17. <view class="bggray">拍拍二手</view>
  18. <view class="choose">筛选<image class="shalou" src="/images/index/49.png"></image></view>
  19. </view>
  20. <block wx:for="{{elements}}">
  21. <view class="goodsbox1">
  22. <image class="iponeimg" src="{{item.image}}"></image>
  23. <view class="goodstext">
  24. <view class="goodstitle">{{item.goodstitle}}</view>
  25. <view class="canshu">
  26. <view class="goodscanshu1"> {{item.chicun}}英寸</view>
  27. <view class="goodscanshu1">{{item.neicun}}GB内存</view>
  28. </view>
  29. <view class="goodsprice">¥{{item.price}}</view>
  30. <view class="goodsbox">
  31. <view class="pingjia">{{item.pingjia}}条评价</view>
  32. <view class="pingjia">{{item.haoping}}好评</view>
  33. </view>
  34. <view class="goodsbox">
  35. <view class="pingjia">{{item.dianpu}}</view>
  36. <view class="jindian">进店<image style="width: 16rpx;height: 16rpx;" src="/images/index/50.png"></image></view>
  37. </view>
  38. </view>
  39. </view>
  40. </block>
  41. </view>
  1. 搜索wxss:
  2. /* page/jd-goods/jd-goods.wxss */
  3. .search{
  4. display: flex;
  5. flex-direction: row;
  6. flex-wrap: wrap;
  7. margin: 20rpx;
  8. width: 720rpx;
  9. height: 80rpx;
  10. background-color: lightgray;
  11. border-radius: 40rpx 40rpx 40rpx 40rpx;
  12. }
  13. .searchtext{
  14. text-align: center;
  15. background-color: gray;
  16. font-size: 12px;
  17. height: 30rpx;
  18. border-radius: 30rpx 30rpx 30rpx 30rpx;
  19. padding: 20rpx 20rpx;
  20. padding-top: 10rpx;
  21. margin-top: 10rpx;
  22. color: aliceblue;
  23. }
  24. .searchicon{
  25. width: 50rpx;
  26. height: 50rpx;
  27. margin-top: 15rpx;
  28. margin-left: 20rpx;
  29. }
  30. .tiaojian{
  31. display: flex;
  32. flex-direction: row;
  33. flex-wrap: wrap;
  34. }
  35. .zonghe{
  36. height: 80rpx;
  37. font-size: 14px;
  38. margin-left: 50rpx;
  39. margin-right: 50rpx;
  40. margin-top: 10rpx;
  41. }
  42. .xiala{
  43. position: relative;
  44. top: 15rpx;
  45. width: 50rpx;
  46. height: 50rpx;
  47. }
  48. .xiaoliang{
  49. font-weight: bolder;
  50. height: 80rpx;
  51. font-size: 14px;
  52. margin-left: 50rpx;
  53. margin-right: 50rpx;
  54. margin-top: 25rpx;
  55. }
  56. .price{
  57. font-weight: bolder;
  58. height: 80rpx;
  59. font-size: 14px;
  60. margin-left: 50rpx;
  61. margin-right: 50rpx;
  62. margin-top: 25rpx;
  63. color: darkgrey;
  64. }
  65. .priceimg{
  66. width: 20rpx;
  67. height: 20rpx;
  68. }
  69. .hour{
  70. font-weight: bolder;
  71. height: 80rpx;
  72. font-size: 14px;
  73. font-style: oblique;
  74. margin-left: 30rpx;
  75. margin-top: 25rpx;
  76. }
  77. .houtimg{
  78. position: relative;
  79. top: 10rpx;
  80. width: 40rpx;
  81. height: 40rpx;
  82. }
  83. .biaoji{
  84. display: flex;
  85. flex-direction: row;
  86. flex-wrap: wrap;
  87. }
  88. .bggray{
  89. text-align: center;
  90. background-color: lightgray;
  91. font-size: 12px;
  92. height: 30rpx;
  93. border-radius: 30rpx 30rpx 30rpx 30rpx;
  94. padding: 20rpx 20rpx;
  95. padding-top: 10rpx;
  96. margin-left: 30rpx;
  97. }
  98. .pinpai{
  99. width: 30rpx;
  100. height: 30rpx;
  101. }
  102. .shalou{
  103. width: 30rpx;
  104. height: 30rpx;
  105. }
  106. .choose{
  107. position: relative;
  108. top: 6rpx;
  109. text-align: center;
  110. height: 60rpx;
  111. font-size: 14px;
  112. box-shadow:-0.5px 0px 0px 0px gray ;
  113. padding-left: 10rpx;
  114. }
  115. .iponeimg{
  116. height: 300rpx;
  117. width: 300rpx;
  118. border-radius: 20rpx 20rpx 20rpx 20rpx;
  119. }
  120. .goodsbox1{
  121. display: flex;
  122. flex-direction: row;
  123. flex-wrap: wrap;
  124. margin-top: 20rpx;
  125. }
  126. .goodsbox{
  127. display: flex;
  128. flex-direction: row;
  129. flex-wrap: wrap;
  130. }
  131. .goodstext{
  132. margin-left: 10rpx;
  133. width: 430rpx;
  134. height: 300rpx;
  135. display: flex;
  136. flex-direction: row;
  137. flex-wrap: wrap;
  138. }
  139. .goodstitle{
  140. font-weight: bolder;
  141. font-size: 12px;
  142. }
  143. .goodsprice{
  144. color: red;
  145. font-weight: 600;
  146. font-size: 14px;
  147. width: 400rpx;
  148. }
  149. .canshu{
  150. display: flex;
  151. flex-direction: row;
  152. flex-wrap: wrap;
  153. width: 400rpx;
  154. }
  155. .goodscanshu1{
  156. font-weight: bolder;
  157. text-align: center;
  158. height: 25rpx;
  159. border-radius: 15rpx 15rpx 15rpx 15rpx;
  160. font-size: 8px;
  161. color: gray;
  162. background-color: lightgrey;
  163. padding: 5rpx;
  164. margin-top: 20rpx;
  165. margin-bottom: 20rpx;
  166. margin-left: 0rpx;
  167. margin-right: 10rpx;
  168. }
  169. .pingjia{
  170. font-size: 8px;
  171. color: gray;
  172. margin-right: 20rpx;
  173. }
  174. .jindian{
  175. font-size: 8px;
  176. font-weight: bolder;
  177. }
  1. 搜索js:
  2. Page({
  3. data: {
  4. elements: [{
  5. image:"/images/index/51.jpg",
  6. goodstitle:"华为HMS超薄便宜智能手机学生价游戏长续航大屏百元机",
  7. neicun:"8",
  8. chicun:"6.6",
  9. price:"599.00",
  10. pingjia:"5000+",
  11. haoping:"97%",
  12. dianpu:"百事乐手机官方旗舰店",
  13. }, {
  14. image:"/images/index/52.jpg",
  15. goodstitle:"荣耀Play5T Pro 6400万双摄6.6英寸全视屏22.5W超级快充4000mAh大电池",
  16. neicun:"8",
  17. chicun:"6.6",
  18. price:"1099.00",
  19. pingjia:"20万+",
  20. haoping:"96%",
  21. dianpu:"荣耀京东自营旗舰店",
  22. },
  23. {
  24. image:"/images/index/53.jpg",
  25. goodstitle:"荣耀Play5 活力版 66W超级快充 120Hz全速屏 6400万超清摄像 全网通版8GB+128GB",
  26. neicun:"8",
  27. chicun:"6.67",
  28. price:"599.00",
  29. pingjia:"5万+",
  30. haoping:"97%",
  31. dianpu:"百事乐手机官方旗舰店",
  32. },
  33. ],
  34. }
  35. })
  1. 商品分类wxml
  2. <!--分割线-->
  3. <view class="hr"></view>
  4. <!--输入框-->
  5. <input placeholder="请输入商品名称"></input>
  6. <view class="hr"></view>
  7. <view class="content">
  8. <view class="left">
  9. <!--左侧部分-->
  10. <scroll-view scroll-y="true">
  11. <block wx:for="{{list}}">
  12. <view class="cedaohang">{{item}}</view>
  13. </block>
  14. </scroll-view>
  15. </view>
  16. <view class="right">
  17. <!--右侧部分-->
  18. <view class="order">
  19. <!--分类部分-->
  20. <view>热门搜索</view>
  21. </view>
  22. <view class="content1">
  23. <block wx:for="{{elements}}">
  24. <view class="botton">
  25. <view>
  26. <image class="img" bindtap="clickchoose" src="{{item.image}}"></image>
  27. <view class="texts">
  28. <text class="money">
  29. {{item.name}}
  30. </text>
  31. </view>
  32. </view>
  33. </view>
  34. </block>
  35. </view>
  36. </view>
  37. </view>
  1. 商品分类wxss:
  2. /*分割线样式*/
  3. .hr {
  4. border: 1px solid #EEE9E9;
  5. width: 100%;
  6. opacity: 0.6;
  7. }
  8. /*输入框样式*/
  9. input {
  10. margin: 15rpx 30rpx;
  11. border: 1px solid #ccc;
  12. border-radius: 50rpx;
  13. text-align: center;
  14. font-size: 32rpx;
  15. }
  16. /*布局样式*/
  17. .content {
  18. display: flex;
  19. flex-direction: row;
  20. }
  21. /*左边样式*/
  22. .left {
  23. width: 25%;
  24. font-size: 30rpx;
  25. }
  26. scroll-view {
  27. height: 90%;
  28. }
  29. /*左边元素样式*/
  30. .left view {
  31. text-align: center;
  32. height: 100rpx;
  33. line-height: 100rpx;
  34. }
  35. /*右边样式*/
  36. .right {
  37. width: 75%;
  38. }
  39. /*分类样式*/
  40. .order {
  41. display: flex;
  42. flex-direction: row;
  43. text-align: center;
  44. padding: 20 rpx;
  45. }
  46. .order view {
  47. width: 33%;
  48. font-size: 32rpx;
  49. }
  50. .content1{
  51. display: flex;
  52. flex-direction: row;
  53. flex-wrap: wrap;
  54. height: 400rpx;
  55. }
  56. .cedaohang{
  57. color: gray
  58. }
  59. .botton{
  60. text-align: center;
  61. margin-left: 10px;
  62. width: 150rpx;
  63. }
  64. .texts{
  65. width: 150rpx;
  66. text-align: center;
  67. }
  68. .img{
  69. height: 140rpx;
  70. width: 100rpx;
  71. }
  72. .money{
  73. width: 150rpx;
  74. text-align: center;
  75. font-size: 12px;
  76. margin-left: 40px;
  77. }
  1. 商品分类js:
  2. Page({
  3. data: {
  4. list: ["热搜推荐", "食品酒水", "生鲜果蔬", "美妆护肤", "个护清洁", "精品男装", "精品女装", "内衣配饰", "鞋靴箱包", "手机数码", "家用电器", "电脑办公", "运动户外"],
  5. elements: [{
  6. image: "/images/index/31.png",
  7. name: "手机",
  8. }, {
  9. image: "/images/index/32.png",
  10. name: "冰箱",
  11. },
  12. {
  13. image: "/images/index/33.png",
  14. name: " 华为",
  15. },
  16. {
  17. image: "/images/index/34.jpg",
  18. name: "白酒",
  19. },
  20. {
  21. image: "/images/index/35.jpg",
  22. name: "电饭煲",
  23. },
  24. {
  25. image: "/images/index/36.jpg",
  26. name: "电风扇",
  27. }, {
  28. image: "/images/index/37.jpg",
  29. name: "方便面",
  30. }, {
  31. image: "/images/index/38.png",
  32. name: " 空调",
  33. }, {
  34. image: "/images/index/39.png",
  35. name: "口红",
  36. }, {
  37. image: "/images/index/40.jpg",
  38. name: "蓝牙耳机",
  39. },{
  40. image: "/images/index/41.png",
  41. name: " 跑步鞋",
  42. }, {
  43. image: "/images/index/42.jpg",
  44. name: "平板电视",
  45. }, {
  46. image: "/images/index/43.jpg",
  47. name: "洗衣机",
  48. },{
  49. image: "/images/index/44.jpg",
  50. name: "香水",
  51. },
  52. ],
  53. },
  54. clickchoose:function(){
  55. wx.navigateTo({
  56. url: '../jd-goods/jd-goods',
  57. })
  58. }
  59. })
  60. App.json
  61. {
  62. "pages": [
  63. "pages/jd-index/jd-index",
  64. "page/jd-fenlei/jd-fenlei",
  65. "page/jd-goods/jd-goods"
  66. ],
  67. "window": {
  68. "backgroundTextStyle": "light",
  69. "navigationBarBackgroundColor": "#FF0000",
  70. "navigationBarTitleText": "京东购物",
  71. "navigationBarTextStyle": "white"
  72. },
  73. "tabBar": {
  74. "color": "#4D4D4D",
  75. "selectedColor": "#FF0000",
  76. "borderStyle": "black",
  77. "list": [
  78. {
  79. "selectedIconPath": "icon/index0.png",
  80. "iconPath": "icon/index.png",
  81. "pagePath": "pages/jd-index/jd-index",
  82. "text": "首页"
  83. },
  84. {
  85. "selectedIconPath": "icon/sort0.png",
  86. "iconPath": "icon/sort.png",
  87. "pagePath": "page/jd-fenlei/jd-fenlei",
  88. "text": "分类"
  89. },
  90. {
  91. "selectedIconPath": "icon/shop0.png",
  92. "iconPath": "icon/shop.png",
  93. "pagePath": "pages/jd-index/jd-index",
  94. "text": "购物圈"
  95. },
  96. {
  97. "selectedIconPath": "icon/cart0.png",
  98. "iconPath": "icon/cart.png",
  99. "pagePath": "pages/jd-index/jd-index",
  100. "text": "购物车"
  101. },
  102. {
  103. "selectedIconPath": "icon/me0.png",
  104. "iconPath": "icon/me.png",
  105. "pagePath": "pages/jd-index/jd-index",
  106. "text": "我的"
  107. }
  108. ]
  109. },
  110. "sitemapLocation": "sitemap.json"
  111. }

结尾:

    源码成品获取:v18634371151

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

闽ICP备14008679号