轻源码

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
一起源码网 门户 微信小程序 查看主题

ECSHOP 小程序底部滑出效果,淡入效果,底部菜单导航,加入购物车 ... ...

发布者: perfectbeer | 发布时间: 2018-5-29 12:37| 查看数: 5855| 评论数: 1|帖子模式

作者:lch198548,来自原文地址

ECSHOP 小程序底部滑出效果,淡入效果,底部菜单导航,加入购物车 演示扫描二维码 
收藏一个商品之后 -> 个人中心 -> 我的收藏 查看演示效果。

上先效果图。 
JS(这里的JS我是直接用别人的,CSDN有下,自己处理了下样式)

  1. let animationShowHeight = 300;
  2. Page({
  3. data: {
  4. showModalStatus: false,
  5. imageHeight: 0,
  6. imageWidth: 0
  7. },
  8. showModal: function () {
  9. // 显示遮罩层
  10. var animation = wx.createAnimation({
  11. duration: 200,
  12. timingFunction: "linear",
  13. delay: 0
  14. })
  15. this.animation = animation
  16. animation.translateY(animationShowHeight).step()
  17. this.setData({
  18. animationData: animation.export(),
  19. showModalStatus: true
  20. })
  21. setTimeout(function () {
  22. animation.translateY(0).step()
  23. this.setData({
  24. animationData: animation.export()
  25. })
  26. }.bind(this), 0)
  27. },
  28. hideModal: function () {
  29. // 隐藏遮罩层
  30. var animation = wx.createAnimation({
  31. duration: 200,
  32. timingFunction: "linear",
  33. delay: 0
  34. })
  35. this.animation = animation;
  36. animation.translateY(animationShowHeight).step()
  37. this.setData({
  38. animationData: animation.export(),
  39. })
  40. setTimeout(function () {
  41. animation.translateY(0).step()
  42. this.setData({
  43. animationData: animation.export(),
  44. showModalStatus: false
  45. })
  46. }.bind(this), 200)
  47. },
  48. onShow: function () {
  49. let that = this;
  50. wx.getSystemInfo({
  51. success: function (res) {
  52. animationShowHeight = res.windowHeight;
  53. }
  54. })
  55. },
  56. })

CSS

  1. .add {
  2. background: #f60;
  3. color: #fff;
  4. float: right;
  5. padding: 14rpx 35rpx;
  6. margin-right: 20rpx;
  7. }
  8. .can {
  9. background: #eee;
  10. float: right;
  11. padding: 14rpx 35rpx;
  12. margin-right: 0rpx;
  13. }
  14. .container-column {
  15. display: flex;
  16. flex-direction: column;
  17. width: 100%;
  18. background-color: white;
  19. }
  20. .buydes-container {
  21. display: flex;
  22. height: 100%;
  23. justify-content: space-between;
  24. }
  25. .buydes-dialog-container {
  26. width: 100%;
  27. height: 100%;
  28. justify-content: space-between;
  29. background-color: rgba(15, 15, 26, 0.7);
  30. position: fixed;
  31. z-index: 999;
  32. }
  33. .buydes-dialog-container-top {
  34. flex-grow: 1;
  35. }
  36. .buydes-dialog-container-bottom {
  37. display: flex;
  38. flex-grow: 0;
  39. }
  40. .buydes-dialog-container-bottom-item {
  41. padding: 24rpx;
  42. display: flex;
  43. justify-content: center;
  44. border-bottom: 1rpx solid #eee;
  45. }
  46. .close {
  47. width: 22px;
  48. height: 22px;
  49. background: #555;
  50. border: 1px solid #555;
  51. border-radius: 50% 50%;
  52. line-height: 22px;
  53. text-align: center;
  54. color: #fff;
  55. font-family: 'Lucida Sans',
  56. 'Lucida Sans Regular',
  57. 'Lucida Grande',
  58. 'Lucida Sans Unicode',
  59. Geneva,
  60. Verdana,
  61. sans-serif;
  62. font-size: 16px;
  63. position: absolute;
  64. right: 10rpx;
  65. margin-top: 10rpx;
  66. }
  67. .addimg {
  68. float: left;
  69. }
  70. .addimg image {
  71. width: 220rpx;
  72. height: 220rpx;
  73. padding: 10rpx 10rpx 10rpx 0;
  74. }
  75. .goodsaddinfo {
  76. border-bottom: 1px solid #eee;
  77. width: 100%;
  78. }
  79. .addname {
  80. width: 420rpx;
  81. float: left;
  82. font-size: 32rpx;
  83. margin: 30rpx 0 0 0;
  84. }
  85. .addnamet {
  86. height: 70rpx;
  87. overflow: hidden;
  88. }
  89. .addprice {
  90. font-size: 42rpx;
  91. color: #f60;
  92. padding: 15rpx 0;
  93. }
  94. .stepper {
  95. border: 1px solid #ccc;
  96. border-radius: 3px;
  97. width: 80px;
  98. height: 28px;
  99. float: left;
  100. margin-bottom: 10px;
  101. display: block;
  102. margin-left: 6px;
  103. }
  104. /*加号与减号*/
  105. .stepper text {
  106. width: 19px;
  107. line-height: 26px;
  108. text-align: center;
  109. float: left;
  110. }
  111. /*数值*/
  112. .stepper input {
  113. color: black;
  114. float: left;
  115. margin: 0 auto;
  116. width: 40px;
  117. height: 28px;
  118. text-align: center;
  119. font-size: 12px;
  120. border-left: 1px solid #ccc;
  121. border-right: 1px solid #ccc;
  122. }
  123. /*普通样式*/
  124. .stepper .normal {
  125. color: black;
  126. }
  127. /*禁用样式*/
  128. .stepper .disabled {
  129. color: #ccc;
  130. }
  131. /*复选框样式*/
  132. .carts-list icon {
  133. margin-top: 60rpx;
  134. margin-right: 20rpx;
  135. }
  136. .attr li {
  137. width: 100%;
  138. float: right;
  139. border-bottom: 1px solid #f2f2f2;
  140. line-height: 28px;
  141. padding: 10px 0 0 0;
  142. }
  143. .attr li view {
  144. width: 620rpx;
  145. float: right;
  146. }
  147. .attr label {
  148. font-size: 12px;
  149. float: left;
  150. width: 90rpx;
  151. margin-left: 4%;
  152. }
  153. .attr span {
  154. font-size: 14px;
  155. border-radius: 3px;
  156. text-align: center;
  157. color: #ff4200;
  158. padding: 0px 15px;
  159. margin-right: 10px;
  160. border: 1px solid #eee;
  161. float: left;
  162. display: block;
  163. margin-bottom: 10px;
  164. box-sizing: border-box;
  165. }
  166. .attr .hover {
  167. background: #ff4200;
  168. border: 1px solid #ff4200;
  169. color: #fff;
  170. }
  171. .num label {
  172. font-size: 12px;
  173. float: left;
  174. width: 90rpx;
  175. margin-left: 4%;
  176. }
  177. .num {
  178. width: 96%;
  179. float: right;
  180. border-bottom: 1px solid #f2f2f2;
  181. line-height: 28px;
  182. padding: 10px 0 0 0;
  183. display: block;
  184. overflow: auto;
  185. }
  186. .up, .down {
  187. font-family: "iconfont";
  188. font-size: 12px;
  189. color: #556665;
  190. position: absolute;
  191. display: inline-block;
  192. right: 4%;
  193. }
  194. .up:before {
  195. content: "\e616";
  196. }
  197. .down:before {
  198. content: "\e615";
  199. }
  200. .addcart {
  201. width: 100%;
  202. background: #ff4200;
  203. text-align: center;
  204. color: #fff;
  205. float: right;
  206. height: 50px;
  207. line-height: 50px;
  208. font-size: 16px;
  209. }

页面文件:

  1. <view class="add" bindtap="showModal">加入购物车</view>
  2. <view animation="{{animationData}}" class="container-column buydes-dialog-container" wx:if="{{showModalStatus}}">
  3. <view class="buydes-dialog-container-top" bindtap="hideModal"></view>
  4. <view class="container-column buydes-dialog-container-bottom">
  5. <view class="close" bindtap="hideModal">x</view>
  6. <view class="goodsaddinfo">
  7. <view class="addimg">
  8. <image src=""></image>
  9. </view>
  10. <view class="addname">
  11. <view class="addnamet">商品名称比较一下商品名称比较一下商品名称比较一下商品名称比较一下商品名称比较一下</view>
  12. <view class="addprice">¥199元</view>
  13. </view>
  14. </view>
  15. <view class="attr">
  16. <ul>
  17. <li>
  18. <label>尺码</label>
  19. <view>
  20. <span class="hover">S</span>
  21. <span>M</span>
  22. <span>L</span>
  23. <span>XL</span>
  24. </view>
  25. </li>
  26. <li>
  27. <label>颜色</label>
  28. <view>
  29. <span class="hover">红色</span>
  30. <span>绿</span>
  31. <span>紫色</span>
  32. <span>紫色</span>
  33. <span>紫色</span>
  34. </view>
  35. </li>
  36. </ul>
  37. </view>
  38. <view class="num">
  39. <label>数量</label>
  40. <view class="stepper">
  41. <!-- 减号 -->
  42. <text class="{{goods_number == 1 ? 'disabled' : 'normal'}}" bindtap="bindMinus">-</text>
  43. <!-- 数值 -->
  44. <input type="number" bindchange="bindManual" value="1" />
  45. <!-- 加号 -->
  46. <text class="normal" bindtap="bindPlus">+</text>
  47. </view>
  48. </view>
  49. <view class="addcart" bindtap="addToCart">加入购物车</view>
  50. </view>
  51. </view>

最新评论

240205294 发表于 2022-6-20 14:07
编程常用代码大全

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表