test.blade.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. @extends('views.layouts.master')
  2. @push('css')
  3. <link rel="stylesheet" href="{{ csset('/themes/pro/nawame/resources/css/user-auth.css') }}">
  4. <script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
  5. @endpush
  6. @section('content')
  7. <div class="user-form-part">
  8. <div class="container">
  9. {{-- <div class="row justify-content-center">--}}
  10. {{-- <div class="col-md-8">--}}
  11. {{-- <p><button @click="clickBtn1">버튼1</button></p>--}}
  12. {{-- <div class="alert alert-success" role="alert">@{{ addr1 }}</div>--}}
  13. {{-- <p><button @click="clickBtn2">버튼2</button></p>--}}
  14. {{-- <div class="alert alert-success" role="alert">@{{ addr2 }}</div>--}}
  15. {{-- </div>--}}
  16. {{-- </div>--}}
  17. <div class="text-center text-danger" v-if="!items.length">카트가 비어있습니다.</div>
  18. <div v-for="item in items" class="text-danger text-center mt-3 d-flex align-items-center justify-content-center">
  19. <div class="mr-2">
  20. @{{ item['C4'] }} <span class="text-success">@{{ itemPrice(item['C6']) }} 원</span>
  21. </div>
  22. <div class="d-flex align-items-center justify-content-center mt-3">
  23. <button class="btn" v-bind:disabled="textValue" @click="deleteCart(item['Id'])">
  24. 카트 삭제
  25. </button>
  26. </div>
  27. </div>
  28. <div class="text-center mt-4">
  29. 합계: @{{ totalItem }} 원
  30. </div>
  31. </div>
  32. @include('views.address', ['ref' => 'address1', 'addressSelected' => 'addressSelected1'])
  33. @include('views.address', ['ref' => 'address2', 'addressSelected' => 'addressSelected2'])
  34. </div>
  35. @endsection
  36. @push('js')
  37. <script>
  38. var vm = new Vue({
  39. el: '#app',
  40. data: function () {
  41. return {
  42. addr1: '선택주소1',
  43. addr2: '선택주소2',
  44. listType1Book: @json($listType1Book),
  45. items: [],
  46. textValue: false
  47. };
  48. },
  49. computed: {
  50. totalItem: function() {
  51. let sum = 0;
  52. for(let i = 0; i < this.items.length; i++){
  53. sum += (parseFloat(this.items[i].C6));
  54. }
  55. return format_decimal(sum, 0);
  56. }
  57. },
  58. created: function () {
  59. this.items = this.listType1Book['Book']['0']['Page'] ?? [];
  60. },
  61. methods: {
  62. clickBtn1: function (e) {
  63. this.$refs.address1.open();
  64. },
  65. clickBtn2: function (e) {
  66. this.$refs.address2.open();
  67. },
  68. addressSelected1: function (data) {
  69. this.addr1 = data.roadAddress;
  70. },
  71. addressSelected2: function (data) {
  72. this.addr2 = data.roadAddress;
  73. },
  74. itemPrice: function (price) {
  75. return format_decimal(price, 0);
  76. },
  77. deleteCart: async function (cart_id) {
  78. // console.log(cart_id)
  79. // this.items = this.items.filter(item => item['Id'] === 50)
  80. // console.log(this.items)
  81. this.textValue = true
  82. const response = await get_api_data('cart-act', {
  83. Page : [ { Id: Number(`-${cart_id}`) } ]
  84. })
  85. const self = this
  86. show_iziToast_msg(response.data.Page, function () {
  87. self.items = self.items.filter(item => item['Id'] !== cart_id)
  88. self.textValue = false
  89. })
  90. }
  91. }
  92. });
  93. </script>
  94. @endpush