1. <div>
    2. <!--
    3. /*
    4. 使用说明:
    5. 1.在三列商品标题设置->促销语处填写cMore
    6. 2、在页面最底端拖入次模块
    7. */
    8. -->
    9. <style>
    10. /* n+2 为露出行数,这里表示露出1行,若需要露出两行为n+3以此类推 */
    11. .cMore .flexgrid:nth-child(n+2) {
    12. display: none;
    13. }
    14. .c-moreBtn {
    15. margin-top: -2vw;
    16. }
    17. /* 展开区域背景 */
    18. .c-moreBtn .xkgd-btn {
    19. height: 1.25rem;
    20. width: auto;
    21. margin: 0;
    22. background: url(https://gfs6.gomein.net.cn/wireless/T19s_kB5Zv1RCvBVdK_576_98.png);
    23. background-size: 100%;
    24. background-repeat: no-repeat;
    25. color: #333333;
    26. }
    27. .c-moreBtn .xkgd-btn svg {
    28. width: 4vw;
    29. height: 4vw;
    30. display: inline-block;
    31. vertical-align: middle;
    32. margin-left: 2vw;
    33. }
    34. /* 商品样式框 */
    35. .cMore .list.col3.product-list .flexgrid .product {
    36. width: 2.3rem;
    37. height: 3.45rem;
    38. background-color: transparent;
    39. background: url(https://gfs5.gomein.net.cn/wireless/T17tdABXYT1RCvBVdK_333_481.png)no-repeat;
    40. background-size: 100%;
    41. left: 0.051rem;
    42. top: 0.12rem;
    43. }
    44. .cMore .list.col3.product-list .flexgrid .product:nth-child(2) {
    45. left: 0rem;
    46. }
    47. .cMore .list.col3.product-list .flexgrid .product:last-child {
    48. left: -.06rem;
    49. }
    50. /* 商品背景条 */
    51. .cMore .list.col3.product-list {
    52. margin: 0.1rem 0.2rem 0;
    53. margin-left: 0;
    54. margin-right: 0;
    55. padding: 0.3rem;
    56. padding-top: 0.13rem;
    57. margin-top: 0;
    58. border-radius: 0 0 0.16rem 0.16rem;
    59. background: url(https://gfs5.gomein.net.cn/wireless/T1iWDkBTYT1RCvBVdK_576_256.png);
    60. background-size: 100%;
    61. }
    62. .cMore .list.col3.product-list .product .container.img {
    63. margin: 0;
    64. margin-top: 0.06rem;
    65. width: 2.14rem;
    66. height: 2.06rem;
    67. margin-left: -0.05rem;
    68. }
    69. .cMore .list.col3.product-list .product .container.img img {
    70. width: 2.14rem;
    71. height: 2.06rem;
    72. border-radius: 0.1rem;
    73. }
    74. .cMore .list.col3.product-list .blocker .container.img,
    75. .list.col3.product-list .product .container.img {
    76. margin: 0.1rem 0 0.14rem;
    77. border-radius: 0.06rem;
    78. overflow: hidden;
    79. width: 2.14rem;
    80. height: 2.14rem;
    81. margin-left: -0.03rem;
    82. }
    83. .cMore .list.col3 .product .container.content .promotion {
    84. font-size: .2rem;
    85. color: #ff8d00;
    86. margin: 0.12rem 0 0;
    87. min-height: 0.3rem;
    88. line-height: .3rem;
    89. overflow: hidden;
    90. margin-bottom: 0.05rem;
    91. display: none;
    92. }
    93. .cMore .list.col3 .product .container.content .name {
    94. color: #c21500;
    95. font-size: .24rem;
    96. display: -webkit-box;
    97. -webkit-line-clamp: 2;
    98. -webkit-box-orient: vertical;
    99. text-overflow: ellipsis;
    100. overflow: hidden;
    101. height: 0.3rem;
    102. line-height: .3rem;
    103. margin-bottom: 0.07rem;
    104. margin-top: 0.13rem;
    105. width: 1.8rem;
    106. margin-left: 0.1rem;
    107. }
    108. .cMore .list.col3 .product .container.content .desc .price .zhenxuan img {
    109. width: 0.72rem;
    110. height: 0.24rem;
    111. margin-top: 0.08rem;
    112. display: none;
    113. }
    114. .cMore .list.col3 .product .container.content .desc .price .originPrice {
    115. font-size: .2rem;
    116. color: #919599;
    117. text-decoration: line-through;
    118. margin-top: -0.04rem;
    119. margin-bottom: -0.07rem;
    120. float: left;
    121. height: 0.3rem;
    122. display: none;
    123. }
    124. .cMore .list.col3 .product .container.content .desc .price strong span>span {
    125. color: #ffffff;
    126. float: left;
    127. margin-top: 0.01rem;
    128. margin-left: 0.45rem;
    129. font-size: 0.25rem;
    130. font-weight: 400;
    131. font-family: PingFangSC-Semibold;
    132. }
    133. .cMore .list.col3 .product .container.content .desc .price strong span {
    134. color: #ffffff;
    135. float: left;
    136. margin-top: 0.05rem;
    137. font-size: 0.26rem;
    138. font-family: PingFangSC-Semibold;
    139. }
    140. .cMore .list.col3 .product .container.content .desc .price strong {
    141. display: block;
    142. font-size: .32rem;
    143. font-weight: bolder;
    144. line-height: .4rem;
    145. margin-left: 0.18rem;
    146. height: 0.4rem;
    147. }
    148. .cMore.cms:not(.first) {
    149. margin-top: -0.2rem;
    150. }
    151. .list.col3 .product .container.content .desc .price .vip99-price {
    152. display: none;
    153. }
    154. </style>
    155. <script>
    156. var _len = $(".c-moreBtn").length;
    157. $(".cMore").each(function (e) {
    158. if (_len >= 1) { return; }
    159. var moreNum = $(this).attr("templetid");
    160. $(this).after(`<div class="c-moreBtn" more-num=${moreNum}><div class="xkgd-btn">
    161. </div></div>`);
    162. })
    163. setTimeout(function () {
    164. $(".c-moreBtn").each(function (e) {
    165. let targetNum = $(this).attr("more-num");
    166. let temp = 3, _len = 0;
    167. let _on = 1;
    168. $(this).click(function (event) {
    169. _len = $(`div[templetid="${targetNum}"].cMore .flexgrid`).length;
    170. if (_on) {
    171. temp += 3;
    172. $(`div[templetid="${targetNum}"].cMore .flexgrid:nth-child(-n+${temp}`).css("display", "flex !important");
    173. if (temp >= _len) {
    174. $(this).find(".xkgd-btn").html(``);
    175. _on = 0;
    176. }
    177. } else {
    178. // n+2展开后再收起显示行数,这里表示露出1行,若需要露出两行为n + 3以此类推
    179. $(`div[templetid="${targetNum}"].cMore .flexgrid:nth-child(n+2`).css("display", "none !important");
    180. $(this).find(".xkgd-btn").html(``);
    181. _top = $(this).offset().top - $(`div[templetid="${targetNum}"]`).height() / 2;
    182. window.scrollTo({ top: _top, behavior: "instant" });
    183. temp = 3;
    184. _on = 1;
    185. }
    186. });
    187. })
    188. }, 2000)
    189. </script>
    190. </div>