11
jhzh
2024-08-01 4ebbadfe4c8c7aa6404dcd9b126cc8265bf03c0d
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
<template>
  <div
    style="overflow: hidden"
    class="c2cTabBackground absolute left-0 right-0 bottom-0 top-122 box-ra flex flex-col"
    :class="fullBottom"
  >
    <div class="flex justify-between mt-46 mb-40 items-center">
      <div class="flex ml-32 text-grey">
        <div
          class="font-400 font-36 mr-89"
          @click="switchDirection('buy')"
          :class="{ textColor: buyTab === 'buy' }"
        >
          {{ $t("我要买") }}
        </div>
        <div
          class="font-400 font-36"
          @click="switchDirection('sell')"
          :class="{ textColor: buyTab === 'sell' }"
        >
          {{ $t("我要卖") }}
        </div>
      </div>
      <span @click="$router.push({ path: '/wantBuy/c2cOrderList' })">
        <img
          class="w-22 h-30 mr-55"
          src="@/assets/image/otc/buy/subtract.png"
          alt=""
        />
      </span>
    </div>
    <!-- <div class="flex"> -->
    <!-- <div class="flex flex-col mr-80 ml-32" @click="tab = 0" :class="{'text-blue': tab === 0}" v-for="(item, index) in symbol" :key="index">
      <div class="font-400 font-26 mb-18">{{item}}</div>
      <div class="h-4 w-48 text-white" :class="{'text-blue': tab === 0}">一</div>
    </div> -->
    <!-- <div class="flex flex-col " @click="tab = 1" :class="{'text-blue': tab === 1}">
      <div class="font-400 font-26 mb-18 mr-80">BTC</div>
      <div class="h-4 w-48 text-white" :class="{'text-blue': tab === 1}">一</div>
    </div>
    <div class="flex flex-col " @click="tab = 2" :class="{'text-blue': tab === 2}">
      <div class="font-400 font-26 mb-18">ETH</div>
      <div class="h-4 w-48 text-white" :class="{'text-blue': tab === 2}">一</div>
    </div> -->
    <!-- </div> -->
    <!--    <van-tabs v-model="tab" @change="onchange">-->
    <!--      <van-tab :title="item" v-for="(item, index) in symbol" :key="index"></van-tab>-->
    <!--    </van-tabs>-->
    <div
      class="tabs flex px-32 items-center"
      style="overflow-x: auto; touch-action: auto"
    >
      <div
        :class="{ active: tab === index }"
        @click="onchange(index)"
        style="flex-shrink: inherit; touch-action: auto"
        v-for="(item, index) in symbol"
        :key="index"
        class="mr-80 item flex flex-col items-center textColor1"
      >
        <span class="font-26">{{ item }}</span>
        <div
          v-if="tab === index"
          class="w-48 h-4 mt-20"
          style="background: var(--theme-color)"
        ></div>
        <div v-else class="w-48 h-4 mt-20"></div>
      </div>
    </div>
    <div class="mt-26 flex justify-between">
      <div class="flex ml-16">
        <div class="mr-80">
          <van-dropdown-menu active-color="#1989fa">
            <van-dropdown-item :title="$t('金额')" ref="amountItem">
              <van-field v-model="value1" :placeholder="$t('请输入总额')">
                <template #extra>
                  {{ exchangeCurrency }}
                </template>
              </van-field>
              <div
                class="flex flex-wrap justify-between px-20 box-border mb-62 mt-12"
              >
                <div
                  class="font-400 font-28 w-248 h-72 mb-12 rounded-md tabBackground c2cColor text-center lh-72 mr-12"
                  :class="{ active_trade: index === numListActive }"
                  v-for="(item, index) in numList"
                  :key="'num' + index"
                  @click="onQuickAmount(item, index)"
                >
                  {{ item.num }}
                </div>
              </div>
              <div class="flex mb-36 justify-center">
                <button
                  class="w-370 h-82 tabBackground c2cColor rounded-lg font-400 font-30 border-none mr-21"
                  :class="[
                    { 'bg-blue': tabindex === 0 },
                    { 'text-white': tabindex === 0 },
                  ]"
                  @click="onResetMoney"
                >
                  {{ $t("重置") }}
                </button>
                <button
                  class="w-370 h-82 btnMain c2cColor rounded-lg font-400 font-30 border-none"
                  :class="[
                    { 'bg-blue': tabindex === 1 },
                    { 'text-white': tabindex === 1 },
                  ]"
                  @click="onConfirmMoney"
                >
                  {{ $t("确认") }}
                </button>
              </div>
            </van-dropdown-item>
          </van-dropdown-menu>
        </div>
        <div class="  ">
          <van-dropdown-menu active-color="#1989fa">
            <van-dropdown-item :title="$t('交易方式')" ref="payTypeItem">
              <div class="flex mb-72 justify-center mt-44 flex-wrap">
                <button
                  v-show="showTab !== 0"
                  class="w-232 h-82 tabBackground c2cColor rounded-lg font-400 font-28 border-none mr-32"
                  @click="onAllType"
                >
                  {{ $t("全部") }}
                </button>
                <div
                  class="relative"
                  v-show="showTab === 0"
                  @click="showTab = 2"
                >
                  <button
                    class="w-232 h-82 tabBackground c2cColor rounded-lg font-400 font-28 border-none mr-32"
                  >
                    {{ $t("全部") }}
                  </button>
                  <img
                    class="absolute top-0 right-0 w-232 h-82 mr-32"
                    src="../../../../assets/image/otc/wantBuyHead/trade_bg.png"
                    alt=""
                  />
                </div>
                <button
                  class="w-232 minh-82 tabBackground c2cColor rounded-lg font-400 font-24 border-none mr-32 mb-20"
                  :class="{ active_trade: showTab == index + 1 }"
                  @click="onShowTab(index)"
                  v-for="(item, index) in payMethods"
                  :key="index"
                >
                  {{ item }}
                </button>
                <!-- <button class="w-232 h-82 bg-grey rounded-lg font-400 font-28 border-none "
                        :class="{'active_trade' : showTab === 2} " @click="showTab = 2">币收款
                </button> -->
              </div>
              <div class="font-22 text-center mb-30 text-grey">
                {{ $t("仅展示可用的交易方式") }}
              </div>
            </van-dropdown-item>
          </van-dropdown-menu>
        </div>
      </div>
      <div class="flex mr-32 items-center" @click="selectClick">
        <div class="mr-10 font-24 font-400 textColor">{{ $t("筛选") }}</div>
        <img class="w-18 h-21" src="@/assets/image/otc/buy/Vector.png" alt="" />
      </div>
    </div>
    <div class="flex justify-center mb-52">
      <div class="w-full h-2 diviLine mt-28 box-border mx-32"></div>
    </div>
    <!-- loading / empty -->
    <!--      <div class="flex justify-center" :class="{'pt-100': !buyList.length}">-->
    <!--        <van-loading color="#1989fa" v-if="loading"/>-->
    <!--        <van-empty description="没有广告" v-if="!loading && !buyList.length"/>-->
    <!--      </div>-->
    <div class="flex-1 roll-section" style="overflow-y: auto">
      <slot></slot>
    </div>
 
    <van-popup class="w-600 rounded-xl" v-model="showRemoved">
      <div class="flex flex-col items-center pt-46 pb-40 px-34 bg-white">
        <img class="w-76 h-76" src="~@/assets/image/c2c/Group41-3.png" alt="" />
        <div>
          <p class="mt-36 mb-50 font-28">
            {{ $t("该广告已下架。请选择其他广告。") }}
          </p>
          <van-button
            @click.native="showRemoved = false"
            class="w-full h-80 rounded-lg bg-blue"
            type="info"
          >
            {{ $t("确认") }}
          </van-button>
        </div>
      </div>
    </van-popup>
 
    <!--筛选-->
    <van-popup
      class="w-full popHeight"
      round
      v-model="showSelect"
      position="bottom"
    >
      <ad-screening @back="handlerBack" @confirm="confirm" />
    </van-popup>
  </div>
</template>
<script>
import {
  Cell,
  Icon,
  Popup,
  DropdownMenu,
  DropdownItem,
  Field,
  Button,
  Tabs,
  Tab,
} from "vant";
import adScreening from "@/page/placeAnOrder/page/adScreening";
import { mapGetters } from "vuex";
 
export default {
  name: "BuyPage",
  components: {
    [Icon.name]: Icon,
    [Field.name]: Field,
    [Popup.name]: Popup,
    [Cell.name]: Cell,
    [DropdownMenu.name]: DropdownMenu,
    [DropdownItem.name]: DropdownItem,
    [Button.name]: Button,
    [Tabs.name]: Tabs,
    [Tab.name]: Tab,
    adScreening,
  },
  props: {
    buyList: {
      // 承兑商列表
      type: Array,
      default() {
        return [];
      },
    },
    symbol: {
      type: Array,
      default() {
        return [];
      },
    },
    loading: {
      type: Boolean,
      default: false,
    },
    finished: {
      type: Boolean,
      default: false,
    },
    isLoading: {
      type: Boolean,
      default: false,
    },
  },
  created() {
    // 设置选中tab
    const index = this.symbol.findIndex(
      (item) => item === this.$store.state.c2c.symbol
    );
    // this.tab = index
    this.tab = 0;
    // direction
    this.buyTab = this.$store.state.c2c.direction;
  },
  data() {
    return {
      showSelect: false, // 显示筛选
      showRemoved: false, // 显示已下架弹窗
      tabindex: 1,
      tab: 0,
      showTab: 0,
      buyTab: 0,
      // buyList1: [
      //   {
      //     name: 'BitcomTxm',
      //     unit_price: '0.960',
      //     quantity: '498.6 USDT',
      //     limit: '$200.50 - $483.64',
      //     volume: '158',
      //     Transaction_rate: '78%',
      //     bgm: require('@/assets/image/otc/buy/B.png'),
      //     bgm2: require('@/assets/image/otc/buy/star.png'),
      //     uid: 'dsadas',
      //   },
      //   {
      //     name: 'ETHCoin',
      //     unit_price: '0.960',
      //     quantity: '498.6 USDT',
      //     limit: '$200.50 - $483.64',
      //     volume: '158',
      //     Transaction_rate: '78%',
      //     bgm: require('@/assets/image/otc/buy/E.png'),
      //     bgm2: require('@/assets/image/otc/buy/star.png'),
      //     uid: 'sss',
      //     isRemoved: true, // 已下架
      //   },
      //   {
      //     name: 'BitcomTxm',
      //     unit_price: '0.960',
      //     quantity: '498.6 USDT',
      //     limit: '$200.50 - $483.64',
      //     volume: '158',
      //     Transaction_rate: '78%',
      //     bgm: require('@/assets/image/otc/buy/B.png'),
      //     bgm2: require('@/assets/image/otc/buy/star.png'),
      //     uid: '333',
      //   },
      //   {
      //     name: 'BitcomTxm',
      //     unit_price: '0.960',
      //     quantity: '498.6 USDT',
      //     limit: '$200.50 - $483.64',
      //     volume: '158',
      //     Transaction_rate: '78%',
      //     bgm: require('@/assets/image/otc/buy/B.png'),
      //     bgm2: require('@/assets/image/otc/buy/star.png'),
      //     uid: '5444',
      //   },
      // ],
      value: 0,
      value1: "",
      switch1: false,
      switch2: false,
      numListActive: -1,
      numList: [
        {
          num: "100",
          value: "100",
        },
        {
          num: "1000",
          value: "1000",
        },
        {
          num: "5000",
          value: "5000",
        },
        {
          num:
            this.$i18n.locale === "CN" || this.$i18n.locale === "zh-CN"
              ? "1万"
              : "10k",
          value: "10000",
        },
        {
          num:
            this.$i18n.locale === "CN" || this.$i18n.locale === "zh-CN"
              ? "10万"
              : "100k",
          value: "100000",
        },
        {
          num:
            this.$i18n.locale === "CN" || this.$i18n.locale === "zh-CN"
              ? "20万"
              : "200k",
          value: "200000",
        },
      ],
    };
  },
  methods: {
    onAllType() {
      //全部
      this.showTab = 0;
      this.$emit("change", { method_type: "" });
      this.$refs.payTypeItem.toggle();
    },
    onShowTab(index) {
      // 选择交易方式
      this.showTab = index + 1;
      this.$emit("change", { method_type: index });
      this.$refs.payTypeItem.toggle();
    },
    onResetMoney() {
      // 重置金额
      this.value1 = "";
      this.numListActive = -1;
    },
    onConfirmMoney() {
      // 确定金额
      this.$emit("change", { amount: this.value1 });
      this.$refs.amountItem.toggle();
    },
    onQuickAmount(item, index) {
      // 快捷金额
      this.numListActive = index;
      this.value1 = item.value;
      // console.log(item)
    },
    // 筛选
    selectClick() {
      this.showSelect = true;
    },
    // 隐藏筛选
    handlerBack() {
      this.showSelect = false;
    },
    // 筛选确定
    confirm(params) {
      console.log(params);
      this.$emit("confirm", params);
    },
 
    switchDirection(direction) {
      // 我要买/卖
      this.buyTab = direction;
      this.$store.commit("c2c/SET_DIRECTION", direction);
      this.$emit("change", { direction });
    },
    onchange(index) {
      // tab改变
      this.tab = index;
      this.$store.commit("c2c/SET_SYMBOL", this.symbolList[index]);
      this.$emit("change", { symbol: this.symbolList[index] });
    },
  },
  computed: {
    ...mapGetters("c2c", ["symbolList", "payMethods", "exchangeCurrency"]),
    fullBottom() {
      return this.$route.path === "/wantBuy" ? "bottom-0" : "bottom-160";
    },
  },
};
</script>
 
<style lang="scss" scoped>
::-webkit-scrollbar {
  width: 0;
  height: 0;
  color: transparent;
}
 
.tabs {
  .item:last-child {
    margin-right: 0;
  }
}
 
.popHeight {
  height: calc(100% - 122px);
}
 
.box-ra {
  border-radius: 80px 80px 0 0;
}
 
.col {
  color: #e7bb41;
}
 
.cl {
  color: var(--theme-color);
}
 
.active {
  color: var(--theme-color);
}
 
.active_all {
  background: url("~@/assets/image/otc/wantBuyHead/trade_bg.png");
  border: 2px solid #2c78f8;
}
 
.active_trade {
  color: #ffffff;
 
  @include themify() {
    background-color: themed("color_main");
  }
}
 
::v-deep {
  .van-dropdown-menu__bar {
    background: none;
    box-shadow: none;
  }
}
 
.minh-82 {
  min-height: 82px;
}
 
.mb-52 {
  margin-bottom: 52px;
}
 
.c2cTabBackground {
  .van-cell {
    @include themify() {
      background: themed("input_background");
      color: themed("text_color");
    }
  }
 
  ::v-deep .van-field__control {
    @include themify() {
      color: themed("c2c_color");
    }
  }
}
</style>