index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view>
  3. <!-- 分类购物车下拉列表 -->
  4. <view :style="[parent.isFooter?listH:'']" class="cartList" :class="{on:cartData.iScart,ons:!isFooter}" @touchmove.stop.prevent="moveHandle">
  5. <view class="title acea-row row-between-wrapper">
  6. <view class="name">购物车 <text class="fs-24 text--w111-999 pl-8">(共{{cartNums||cartNum}}件商品)</text></view>
  7. <view class="del acea-row row-middle" @click="subDel"><view class="iconfont icon-ic_delete"></view>清空</view>
  8. </view>
  9. <view class="list">
  10. <!-- <scroll-view scroll-y="true" style="max-height: 800rpx;margin-bottom: 146rpx;"> -->
  11. <scroll-view scroll-y="true" :style="{
  12. 'max-height': '800rpx',
  13. 'margin-bottom': 146+marginBottom+'rpx'
  14. }">
  15. <view class="item flex" v-for="(item,index) in cartData.cartList" :key="index">
  16. <view class="pictrue">
  17. <image v-if="item.productInfo.attrInfo" :src='item.productInfo.attrInfo.image'></image>
  18. <image v-else :src='item.productInfo.image'></image>
  19. <view class="mantle" v-if="!item.status || !item.attrStatus"></view>
  20. </view>
  21. <view class="flex-1 flex-col justify-between ml-20">
  22. <view class="w-full">
  23. <view class="lh-40rpx fs-28 text--w111-333 line2"
  24. :class="(item.attrStatus && item.status)?'':'on'">{{item.productInfo.store_name}}</view>
  25. <view class="inline-block max-w-460 h-38 lh-38rpx mt-12 bg--w111-f5f5f5 text--w111-999 rd-20rpx px-12 text-center fs-22"
  26. v-if="item.productInfo.spec_type && item.attrStatus">
  27. <view class="flex">
  28. <text class="line1">属性: {{item.productInfo.attrInfo.suk}}</text>
  29. <text class="iconfont icon-ic_downarrow fs-24 ml-12"></text>
  30. </view>
  31. </view>
  32. <view class="inline-block max-w-460 h-38 lh-38rpx mt-12 bg--w111-f5f5f5 text--w111-999 rd-20rpx px-12 text-center fs-22"
  33. v-else>
  34. <view class="flex">
  35. <text class="line1">属性: {{item.productInfo.attrInfo.suk}}</text>
  36. <text class="iconfont icon-ic_downarrow fs-24 ml-12"></text>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="flex-between-center mt-20">
  41. <baseMoney :money="item.truePrice" symbolSize="24" integerSize="40" decimalSize="24" weight></baseMoney>
  42. <view class="flex-y-center" v-if="item.attrStatus && item.status">
  43. <view class="flex-center w-48 h-48 rd-30rpx bg--w111-f5f5f5 text--w111-333" @click="leaveCart(index)">
  44. <text class="iconfont icon-ic_Reduce fs-32"></text>
  45. </view>
  46. <view class="fs-30 text--w111-333 px-20">{{item.cart_num}}</view>
  47. <view class="flex-center w-48 h-48 rd-30rpx bg-color text--w111-fff" @click="joinCart(index)">
  48. <text class="iconfont icon-ic_increase fs-32"></text>
  49. </view>
  50. </view>
  51. <view class="noBnt" v-else-if="!item.attrStatus">已售罄</view>
  52. <view class="noBnt" v-else-if="!item.status">已下架</view>
  53. </view>
  54. </view>
  55. </view>
  56. </scroll-view>
  57. </view>
  58. </view>
  59. <view class="mask" v-if="cartData.iScart" @click="closeList" @touchmove.stop.prevent="moveHandle"></view>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. mapState
  65. } from 'vuex';
  66. export default {
  67. props:{
  68. cartData: {
  69. type: Object,
  70. default: () => {}
  71. },
  72. isFooter: {
  73. type: Boolean,
  74. default: false
  75. },
  76. marginBottom: {
  77. type: Number,
  78. default: 0
  79. },
  80. cartNums: {
  81. type: Number,
  82. default: 0
  83. },
  84. },
  85. inject: ['parent'],
  86. computed:{
  87. listH(){
  88. let H = `calc(${this.parent.pdHeight*2+100}rpx + env(safe-area-inset-bottom))`
  89. return{
  90. paddingBottom: H
  91. }
  92. },
  93. ...mapState({
  94. cartNum: state => state.indexData.cartNum
  95. })
  96. },
  97. data() {
  98. return {};
  99. },
  100. mounted(){
  101. },
  102. methods: {
  103. moveHandle(){
  104. return false
  105. },
  106. closeList(){
  107. this.$emit('closeList', false);
  108. },
  109. leaveCart(index){
  110. this.$emit('ChangeCartNumDan', false,index);
  111. },
  112. joinCart(index){
  113. this.$emit('ChangeCartNumDan', true,index);
  114. },
  115. subDel(){
  116. this.$emit('ChangeSubDel');
  117. },
  118. oneDel(id,index){
  119. this.$emit('ChangeOneDel',id,index);
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss">
  125. .mask{
  126. z-index: 99;
  127. }
  128. .cartList{
  129. position: fixed;
  130. left:0;
  131. bottom: 0;
  132. width: 100%;
  133. background-color: #fff;
  134. z-index:100;
  135. padding: 40rpx 32rpx 0;
  136. padding-bottom: calc(100rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  137. padding-bottom: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  138. box-sizing: border-box;
  139. border-radius:40rpx 40rpx 0 0;
  140. transform: translate3d(0, 100%, 0);
  141. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  142. &.on{
  143. transform: translate3d(0, 0, 0);
  144. }
  145. &.ons{
  146. // #ifndef H5
  147. padding-bottom: 0;
  148. padding-bottom: calc(0 + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  149. padding-bottom: calc(0 + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  150. // #endif
  151. }
  152. .title{
  153. margin-bottom: 32rpx;
  154. .name{
  155. font-size:32rpx;
  156. color: #333;
  157. font-weight:500;
  158. }
  159. .del{
  160. font-size: 24rpx;
  161. color: #666;
  162. .iconfont{
  163. margin-right: 8rpx;
  164. font-size: 28rpx;
  165. }
  166. }
  167. }
  168. .list{
  169. max-height: 1000rpx;
  170. .item{
  171. margin-bottom: 32rpx;
  172. .pictrue{
  173. width: 200rpx;
  174. height: 200rpx;
  175. border-radius: 16rpx;
  176. position: relative;
  177. image{
  178. width: 100%;
  179. height: 100%;
  180. border-radius: 16rpx;
  181. }
  182. .mantle{
  183. position: absolute;
  184. top:0;
  185. left:0;
  186. width: 100%;
  187. height: 100%;
  188. background:rgba(255,255,255,0.65);
  189. border-radius:16rpx;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. .noBnt{
  196. width:126rpx;
  197. height:44rpx;
  198. background:#f5f5f5;
  199. border-radius:22rpx;
  200. text-align: center;
  201. line-height: 44rpx;
  202. font-size: 24rpx;
  203. color: #333;
  204. }
  205. .max-w-460{
  206. max-width: 460rpx;;
  207. }
  208. </style>