index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }"
  3. :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  4. <tm-menubars title="消息列表" :shadow="0" :showback="true"></tm-menubars>
  5. <view class="zhuti shangpin">
  6. <tm-sheet :padding="[0, 0]" class="jiaoxi xiao">
  7. <view v-for="item in test">
  8. <tm-checkbox @change="choose" style="float: left;padding:2px !important;margin-top:9%;" v-model="item.checked" label=""></tm-checkbox>
  9. <tm-cartCellListFood @change="shuliangjia(item)" class="shuliang" :typeclick="typeclick" :mdata="item" :cart-num.sync="item.buy"></tm-cartCellListFood>
  10. </view>
  11. </tm-sheet>
  12. </view>
  13. <view class="dibu">
  14. <tm-listitem class="liebiao" value="免费" :round="24" :shadow="12" title="邮费" :show-right-icon="false"></tm-listitem>
  15. <tm-listitem class="liebiao jiageList" :value="'¥'+zongjia" :round="24" :shadow="12" title="价格" :show-right-icon="false"></tm-listitem>
  16. <view class="text-align-center">
  17. <tm-button theme="red" @click="shanchu" :round="24" class="mt-50 logincla">删除</tm-button>
  18. <tm-button theme="primary" :round="24" class="mt-50 logincla">立即付款</tm-button>
  19. </view>
  20. </view>
  21. <!-- 弹出层消息 -->
  22. <tm-message ref="toast"></tm-message>
  23. </view>
  24. </template>
  25. <script>
  26. import{myRequest} from '@/api/request.js'
  27. export default {
  28. data() {
  29. return {
  30. zongjia:0,
  31. test: [],
  32. typeclick:2,//1加入购物车,2购物车
  33. };
  34. },
  35. onLoad() {
  36. },
  37. created() {
  38. this.sys = uni.getSystemInfoSync();
  39. this.getList()
  40. },
  41. methods: {
  42. shanchu(){
  43. var that=this,data=this.test,ids=[];
  44. for(let i=0;i<data.length;i++){
  45. if(data[i].checked){
  46. ids.push(data[i].id)
  47. }
  48. }
  49. if(ids.length==0){
  50. that.$refs.toast.show({model:'success',label:'请选择商品'})
  51. return
  52. }
  53. myRequest({
  54. url: "/api/ShopCart/deleteOneGoods",
  55. method:'post',
  56. data:{id:ids}
  57. }).then(res => {
  58. if (res.data.code == 200) {
  59. this.getList()
  60. that.$refs.toast.show({model:'success',label:res.data.msg})
  61. }else{
  62. that.$refs.toast.show({model:'error',label:res.data.msg})
  63. }
  64. })
  65. },
  66. shuliangjia(num){
  67. this.jiage();
  68. },
  69. choose(){
  70. this.jiage()
  71. },
  72. jiage(){
  73. var data=this.test,jiage=0;
  74. for(let i=0;i<data.length;i++){
  75. if(data[i].checked){
  76. var danjia=JSON.parse(data[i].price);
  77. var shuliang=data[i].buy;
  78. jiage=jiage+(danjia*shuliang);
  79. }
  80. }
  81. this.zongjia=jiage;
  82. },
  83. getList(){
  84. var that=this;
  85. myRequest({
  86. url: "/api/ShopCart/shopCartList",
  87. method:'post',
  88. data:{}
  89. }).then(res => {
  90. if (res.data.code == 200) {
  91. if(res.data.data.length != 0){
  92. that.test=[];
  93. for(let i=0;i<res.data.data.length;i++){
  94. var obj={
  95. img: res.data.data[i].goods_image,
  96. title: res.data.data[i].goods_name,
  97. // label: '黑色 - 6518/320',
  98. // size:'S',
  99. price: res.data.data[i].goods_price,
  100. id: res.data.data[i].id,
  101. buy: res.data.data[i].goods_num,
  102. itemId: res.data.data[i].id,
  103. checked:false,
  104. };
  105. that.test.push(obj)
  106. }
  107. that.jiage()
  108. }
  109. }else{
  110. that.test=[];
  111. }
  112. })
  113. },
  114. },
  115. }
  116. </script>
  117. <style lang="scss">
  118. /deep/ .tm-menubars .body{
  119. background-color: #1b1b1b !important;
  120. }
  121. /deep/ .jiaoxi{margin:0 !important;padding: 8px !important;margin-bottom: 200px !important;}
  122. /deep/ .shangpin .white.bk{background-color:#1b1b1b!important;}
  123. /deep/ .shangpin .tm-cartCellListFood{ padding: 0px 0px 15px 0px !important;
  124. margin-top: 5px !important;margin-bottom: 20px !important;
  125. border-bottom: 1px solid #303030;}
  126. /deep/ .shangpin .border-t-1.bk{border-top:1px solid #1b1b1b!important;}
  127. /deep/ .shangpin .title{color: white !important;}
  128. /deep/ .shangpin .text-red{color: white !important;}
  129. /deep/ .shangpin .round-3{width:90px !important;height:90px !important;}
  130. /deep/ .shangpin .tm-cartCellListFood-img{width:90px !important;height:90px !important;}
  131. /deep/ .shuliang .text-size-n{color: white !important;}
  132. .dibu{background: #0D0D0D;position: fixed;bottom:0px;width: 100%;}
  133. /deep/ .liebiao .grey-darken-4.bk{background: #0D0D0D !important;padding: 0px;margin: 0px;
  134. width: 100%;border-radius: 0px !important;}
  135. .logincla{width: 40%;margin:0 auto;margin-top:20px;margin-bottom:30px;}
  136. /deep/ .jiageList .d-inline-block{font-size: 18px !important;color: white !important;}
  137. </style>