当前位置:   article > 正文

微信小程序商品详情页面开发案例_微信小程序静态商城网页

微信小程序静态商城网页

页面详细设计

详细设计步骤: 

  1. <!--pages/goods1/goods1.wxml-->
  2. <text>这是一个测试</text>
  3. <!--商品幻灯片-->
  4. <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" class="banner"
  5. duration="{{duration}}" circular="{{duration}}">
  6. <block wx:for="{{goods_img}}" wx:key="goods_info">
  7. <swiper-item>
  8. <image src="{{imghref}}{{item.img}}" class="slide-image" mode="aspectFill" data-src='{{imghref}}{{item.img}}'
  9. bindtap="previewImage" />
  10. </swiper-item>
  11. </block>
  12. </swiper>
  13. <!--商品幻灯片 end-->
  14. <view class="info-price clear">
  15. <view class='price'>¥{{goods_info.goods_price}} </view>
  16. <view class='fenxiang'>
  17. <button class='fxbtn' open-type="share">
  18. <view style='height:20px;margin-top:8px;'>
  19. <image src='/img/mryhtx.jpg' mode="aspectFill"></image>
  20. </view>
  21. <view>分享</view>
  22. </button>
  23. </view>
  24. </view>
  25. <view class="info-title">
  26. <text>{{goods_info.goods_title}}</text>
  27. </view>
  28. <view style="border-top:1px solid #F6F6F6;background: #fff; padding:5px 15px;">
  29. <view class="clearfix flex grey gridXt">
  30. <text class="sub">
  31. <block wx:if='{{goods_info.goods_yunfei==0.00}}'>运费:包邮</block>
  32. <block wx:else>运费:{{goods_info.goods_yunfei}}</block>
  33. </text>
  34. <text class="sub">库存:{{goods_info.goods_kucun}}</text>
  35. <text class="sub">销量:{{goods_info.goods_xiaoliang}}</text>
  36. </view>
  37. </view>
  38. <block wx:if="{{pjDataList!=''}}">
  39. <!--评价-->
  40. <view class='pj_box'>
  41. <view style="height:40px;line-height: 40px;border-bottom:1px solid #f5f5f5;">
  42. <view style='float:left;'>商品评价</view>
  43. <view style='float:right;margin-left:2px;margin-top:-1px;'>
  44. <image src="/img/mryhtx.jpg" class="ico_img_jt"></image>
  45. </view>
  46. <view style='float:right;font-size:12px;color:#A2A2A2;'>
  47. <navigator url="pjList?id={{goods_id}}">查看全部</navigator>
  48. </view>
  49. <view class='clear'></view>
  50. </view>
  51. <block wx:for="{{pjDataList}}" wx:for-item="item" wx:key="pj">
  52. <view class="list_item">
  53. <view class='pj_u_info clear'>
  54. <view class='header_img'>
  55. <image src="{{item.headpic}}" mode="aspectFit"></image>
  56. </view>
  57. <view class='name'>{{item.author}}</view>
  58. <view class='time'>{{item.add_time}}</view>
  59. </view>
  60. <view class='pj_cont'>
  61. {{item.content}}
  62. </view>
  63. </view>
  64. </block>
  65. </view>
  66. </block>
  67. <!--商品详情-->
  68. <view class='details_box'>
  69. <view style="height:40px;line-height: 40px;border-bottom:1px solid #f5f5f5;">
  70. <view>商品详情</view>
  71. </view>
  72. <view style='padding:10px 0px;'>
  73. <view class="wxParse">
  74. {{goods_info.content}}
  75. </view>
  76. </view>
  77. </view>
  78. <!--底部浮动 start-->
  79. <view class="foot-nav mt15">
  80. <view class="flex con gridXt tc">
  81. <view class="fast-links mr15 flex f12">
  82. <view class="sub gridYr" bindtap='shoucang'>
  83. <text class="iconfont {{is_shoucang==0?'icon-shoucang1':'icon-shoucang2'}}">收藏</text>
  84. </view>
  85. <view class="sub kefu">
  86. <button open-type="contact">
  87. <text class="iconfont icon-lianxikefu">客服</text>
  88. </button>
  89. </view>
  90. <view class="sub gridYr">
  91. <text class="iconfont icon-gouwuche">购物车</text>
  92. </view>
  93. </view>
  94. <view class="add-cart sub f16">
  95. <button class="add-cart-btn" bindtap='buy'>立即购买</button>
  96. </view>
  97. </view>
  98. </view>

 

  1. // pages/goods1/goods1.js
  2. // index/details.js
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. is_shoucang: 0,
  9. goods_info: {
  10. goods_id: 1,
  11. goods_title: "商品标题1",
  12. goods_price: '100',
  13. goods_yunfei: 0,
  14. goods_kucun: 100,
  15. goods_xiaoliang: 1,
  16. content: '商品介绍详情商品介绍详情商品介绍详情商品介绍详情商品介绍详情商品介绍详情商品介绍详情'
  17. },
  18. goods_img: [{
  19. 'img': '26&gp=0.jpg'
  20. },
  21. {
  22. 'img': 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.sooshong.com%2Fpicture%2Fuserpic2%2F2013-8-8%2F574973201388164942.jpg&refer=http%3A%2F%2Fpic.sooshong.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1620199902&t=37e1728bfdcf7cd60b653084960e1cfe'
  23. },
  24. {
  25. 'img': 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.616pic.com%2Fys_bnew_img%2F00%2F20%2F37%2FQpKhSYBpcK.jpg&refer=http%3A%2F%2Fpic.616pic.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1620199902&t=5c96e332bfee553001bcc4b7807bd90c'
  26. },
  27. {
  28. 'img': 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fci.xiaohongshu.com%2F4763a03d-ff3e-485b-a4ba-1278ad50223a%40r_750w_750h_ss1.jpg&refer=http%3A%2F%2Fci.xiaohongshu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1620199902&t=578694ae6a3194f8285c64277d5dc34c'
  29. },
  30. ],
  31. indicatorDots: true,
  32. autoplay: true,
  33. interval: 5000,
  34. duration: 1000,
  35. pjDataList: [{
  36. headpic: '/img/mryhtx.jpg',
  37. author: '张三',
  38. add_time: '2018-06-01',
  39. content: '好评好评,真实太好了!'
  40. },
  41. {
  42. headpic: '/img/mryhtx.jpg',
  43. author: '张三',
  44. add_time: '2018-06-01',
  45. content: '好评好评,真实太好了!'
  46. }
  47. ], //评价数据
  48. },
  49. previewImage: function (e) {
  50. var current = e.target.dataset.src;
  51. var href = this.data.imghref;
  52. var goodsimg = this.data.goods_img;
  53. var imglist = [];
  54. for (var i = 0; i < goodsimg.length; i++) {
  55. imglist[i] = href + goodsimg[i].img
  56. }
  57. wx.previewImage({
  58. current: current, // 当前显示图片的http链接
  59. urls: imglist // 需要预览的图片http链接列表
  60. })
  61. },
  62. /**
  63. * 生命周期函数--监听页面加载
  64. */
  65. onLoad: function (options) {
  66. },
  67. /**
  68. * 生命周期函数--监听页面初次渲染完成
  69. */
  70. onReady: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面显示
  74. */
  75. onShow: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function () {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function () {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function () {
  101. }
  102. })
  1. .clear {
  2. clear: both;
  3. overflow: hidden;
  4. }
  5. .banner {
  6. height: 300px;
  7. }
  8. .slide-image {
  9. width: 100%;
  10. height: 100%;
  11. }
  12. /*分享按钮*/
  13. .fenxiang button::after {
  14. border: none;
  15. }
  16. .fxbtn {
  17. background: none;
  18. border: 0px;
  19. margin: 0px;
  20. padding: 0px;
  21. border-radius: 0px;
  22. font-size: 12px;
  23. }
  24. .flex {
  25. display: -webkit-box;
  26. display: -webkit-flex;
  27. display: -ms-flexbox;
  28. display: flex;
  29. width: 100%;
  30. }
  31. .flex>.sub {
  32. -webkit-box-flex: 1;
  33. -webkit-flex: 1;
  34. -ms-flex: 1;
  35. flex: 1;
  36. overflow: hidden;
  37. }
  38. .info-title {
  39. background: #fff;
  40. padding: 10px 15px;
  41. font-size: 15px;
  42. }
  43. .info-price {
  44. border-bottom: 1px solid #F6F6F6;
  45. background: #fff;
  46. padding: 0px 15px;
  47. }
  48. .price {
  49. float: left;
  50. height: 50px;
  51. line-height: 50px;
  52. color: #FF6666;
  53. font-size: 25px;
  54. }
  55. .fenxiang {
  56. text-align: center;
  57. font-size: 12px;
  58. color: #999;
  59. width: 50px;
  60. line-height: 20px;
  61. overflow: hidden;
  62. float: right;
  63. }
  64. .fenxiang image {
  65. width: 20px;
  66. height: 20px;
  67. }
  68. .price em {
  69. font-size: 12px;
  70. margin-left: 20px;
  71. }
  72. .flex {
  73. position: relative;
  74. width: auto;
  75. margin: 0 -15px;
  76. padding: 3px 15px 0;
  77. }
  78. .store-info {
  79. background: #fff;
  80. }
  81. .store-info .store,
  82. .store-info .rz-item {
  83. padding: 10px 15px;
  84. }
  85. .store-info .rz-item view {
  86. margin-right: 10px;
  87. }
  88. .list_item {
  89. position: relative;
  90. padding: 15px 10px;
  91. background: #fff;
  92. border-bottom: 1px solid #f5f5f5;
  93. }
  94. .details_box {
  95. margin-top: 10px;
  96. padding: 0 15px;
  97. font-size: 13px;
  98. background: #fff;
  99. }
  100. .pj_box {
  101. margin-top: 10px;
  102. padding: 0 15px;
  103. font-size: 13px;
  104. background: #fff;
  105. }
  106. .ico_img_jt {
  107. vertical-align: middle;
  108. width: 16px;
  109. height: 16px;
  110. }
  111. .pj_u_info .header_img {
  112. float: left;
  113. }
  114. .pj_u_info .header_img image {
  115. width: 20px;
  116. height: 20px;
  117. border-radius: 50%;
  118. overflow: hidden;
  119. }
  120. .pj_u_info .name {
  121. float: left;
  122. margin-left: 10px;
  123. font-size: 15px;
  124. color: #333;
  125. }
  126. .pj_u_info .time {
  127. float: right;
  128. font-size: 12px;
  129. color: #999;
  130. }
  131. .pj_cont {
  132. font-size: 13px;
  133. }
  134. .pj_img {
  135. margin: 10px 10px 0px 10px;
  136. width: 120px;
  137. height: 100px;
  138. }
  139. .foot-nav {
  140. height: 46px;
  141. }
  142. .foot-nav .con {
  143. position: fixed;
  144. height: 46px;
  145. left: 0;
  146. bottom: 0;
  147. right: 0;
  148. background: #fff;
  149. z-index: 999;
  150. }
  151. .fast-links {
  152. width: 160px;
  153. line-height: 18px;
  154. text-align: center;
  155. }
  156. .fast-links .iconfont {
  157. padding: 5px 0;
  158. }
  159. .fast-links .iconfont::before {
  160. display: block;
  161. margin-top: 5px;
  162. font-size: 18px;
  163. }
  164. .notempty {
  165. position: relative;
  166. }
  167. .notempty::after {
  168. content: "";
  169. display: block;
  170. width: 9px;
  171. height: 9px;
  172. border: 1px solid #fff;
  173. border-radius: 50%;
  174. background: #e64340;
  175. position: absolute;
  176. top: 5px;
  177. right: 50%;
  178. margin-right: -16px;
  179. }
  180. .add-cart .add-cart-btn {
  181. background: linear-gradient(to right, #FF7A34, #EE32FF);
  182. color: #fff;
  183. border-radius: 50px;
  184. padding: 0px;
  185. width: 150px;
  186. height: 35px;
  187. line-height: 35px;
  188. margin-top: 5px;
  189. margin-right: 15px;
  190. }
  191. .kefu button {
  192. border: none;
  193. background: none;
  194. display: block;
  195. padding: 0px;
  196. margin: 0px;
  197. line-height: 1.5em;
  198. font-size: inherit;
  199. }
  200. .kefu button::after {
  201. border: none;
  202. }
  203. .kefu .button-hover {
  204. color: #333;
  205. background: none;
  206. }
  207. .kefu button .iconfont {
  208. padding: 0px;
  209. }
  210. .icon-shoucang2 {
  211. color: red;
  212. }

 

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

闽ICP备14008679号