dcc
2024-06-13 3616db170333df7d668c97323344335b52c4153c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<template>
  <div class="bg-white">
    <div
      class="relative z-10 w-174 h-46 rounded-md bg-f5 cursor-pointer"
      @click.stop="handleMouseOver"
      @mouseleave.stop="handleMouseOut"
    >
      <div class="flex items-center h-full w-full">
        <img
          class="Subtract"
          src="@/assets/images/c2c/want-buy/Subtract.png"
          alt=""
        />
        <div class="ml-11 font-14" v-if="!active">
          {{ $t("message.c2c.suoyoushoukuanfangshi") }}
        </div>
        <div
          v-if="active.title"
          class="flex items-center h-full pl-11 box-border"
        >
          <!-- <img class="w-14 h-14 mr-6" src="active.img" alt="" /> -->
          <span>{{ active.title }}</span>
        </div>
      </div>
      <transition name="el-fade-in-linear">
        <otc-select
          class="absolute z-10 top-46 left-0 pt-10 pb-10"
          v-show="show"
          :list="options"
          v-model="active"
          @itemSelect="itemData"
          :isIcon="true"
          @mouseleave="handleMouseOut"
        >
          <template #other>
            <otc-input @input="handleInputCb" :inputValue="inputValue">
              <template #left>
                <img
                  class="w-18 h-18 cursor-pointer"
                  src="@/assets/images/c2c/want-buy/Union.png"
                  alt=""
                />
              </template>
              <template #right>
                <img
                  class="w-15 h-15 cursor-pointer"
                  @click="clearData"
                  src="@/assets/images/c2c/want-buy/Group1384.png"
                  alt=""
                />
              </template>
            </otc-input>
          </template>
        </otc-select>
      </transition>
    </div>
  </div>
</template>
 
<script>
import OtcInput from "@/views/c2c/components/OtcInput.vue";
import OtcSelect from "./OtcSelect.vue";
 
export default {
  name: "PaymentMethod",
  data() {
    return {
      inputValue: "", //输入框的值
      show: false,
      active: "", //选中的支付方式
      options: [], //支付方式
    };
  },
  props: ["payList"],
  created() {
    this.allList = this.options = this.payList;
  },
  methods: {
    handleMouseOver() {
      this.show = true;
    },
    handleMouseOut() {
      this.show = false;
    },
    itemData(val) {
      this.active = val;
      this.clearData();
      this.handleMouseOut();
      this.$emit("selectPayItem", val);
    },
    // 输入银行卡
    handleInputCb(val) {
      this.inputValue = val;
      if (val) {
        this.options = this.allList.filter((item) => {
          if (item.title.includes(val)) {
            return true;
          }
        });
      } else {
        this.options = this.allList;
      }
    },
    clearData() {
      console.log("清除数据");
      this.inputValue = "";
      this.options = this.allList;
    },
  },
  watch: {
    active: {
      immediate: true,
      handler() {
        this.show = false;
      },
    },
    payList(val) {
      this.allList = val;
      this.options = val;
    },
  },
  components: {
    OtcInput,
    OtcSelect,
  },
};
</script>
 
<style lang="scss" scoped>
@import "@/assets/css/c2c/init.scss";
:deep {
  .otc-select-wrapper {
    padding-bottom: 6px;
 
    .item {
      height: 36px;
    }
  }
 
  .otc-input {
    width: 152px;
    height: 42px;
    margin: 0 auto 11px;
    padding-top: 15px;
 
    input {
      padding-left: 35px;
    }
  }
}
 
.Subtract {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 10px;
  height: 5px;
}
</style>