1
jhzh
2025-07-28 a8b0eb32d97e7a540692a8a29f610fe76d67ef74
src/page/user/recharge.vue
@@ -1,62 +1,19 @@
<template>
  <div>
    <van-nav-bar
      :placeholder="true"
      :safe-area-inset-top="true"
      title="充值中心"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-nav-bar :placeholder="true" :safe-area-inset-top="true" :title="$t('充值中心')" left-arrow
      @click-left="onClickLeft">
      <template #right>
        <van-icon @click="$router.push('/rechargelist')" name="orders-o" size="20" />
      </template>
    </van-nav-bar>
    <main>
      <div>
        <div class="main-title">{{ $t("支持得支付渠道") }}</div>
        <van-cell
          is-link
          :title="paymentSelectData.channelAccount || $t('請選擇')"
          @click="paymentShow = true"
        />
        <!-- paymentSelectData.channelMinLimit -->
        <van-action-sheet
          v-model="paymentShow"
          :actions="paymentActions"
          :cancel-text="$t('qx')"
          close-on-click-action
          @select="paymentSelect"
        />
        <template v-if="paymentSelectData.channelAccount !== undefined">
          <div class="main-title">{{ $t("收款卡號") }}</div>
          <div class="white-input">
            <span>{{ paymentSelectData.channelAccount }}</span>
            <i
              class="iconfont icon-fuzhi fuzhi"
              @click="(e) => copyText(e, channelAccount)"
            ></i>
          </div>
          <div class="main-title">{{ $t("收款銀行") }}</div>
          <div class="white-input">
            <span>{{ paymentSelectData.channelDesc }}</span>
            <i
              class="iconfont icon-fuzhi fuzhi"
              @click="(e) => copyText(e, paymentSelectData.channelDesc)"
            ></i>
          </div>
          <div class="main-title">{{ $t("收款人名字") }}</div>
          <div class="white-input">
            <span>{{ paymentSelectData.channelImg }}</span>
            <i
              class="iconfont icon-fuzhi fuzhi"
              @click="(e) => copyText(e, channelImg)"
            ></i>
          </div>
          <div class="main-title">{{ $t("請選擇充值賬戶") }}</div>
          <van-cell is-link :title="rechargeAccountData.name || $t('請選擇')" />
        <template>
          <!-- @click="rechargeAccountShow = true" -->
          <van-action-sheet
            v-model="rechargeAccountShow"
            :actions="rechargeAccountActions"
            :cancel-text="$t('qx')"
          />
          <!-- close-on-click-action -->
          <!-- @select="rechargeAccountSelect" -->
          <div class="main-title">{{ $t("請選擇充值金額") }}</div>
@@ -66,55 +23,27 @@
          </div>
          <div class="bottom-text">
            <!---->
            <!-- <div class="balance">
              <div>需要支付</div>
              <div class="balance-text" style="margin-bottom: 0px">
                0.0000 {{ rechargeAccountData.symbolCode }}
              </div>
            </div> -->
            <div class="balance" style="margin-top: 10px">
              <div>{{ $t("最小充值金額") }}</div>
              <div class="balance-text" style="margin-bottom: 0px">
                {{ paymentSelectData.channelMinLimit }}
                {{ rechargeAccountData.symbolCode }}
                <!-- {{ paymentSelectData.channelMinLimit }}
                {{ rechargeAccountData.symbolCode }} -->
                1000
              </div>
            </div>
            <div class="division"></div>
            <div class="upload-text">
              <div style="margin-bottom: 0.37333rem">
                {{ $t("上傳憑證:") }}
              </div>
              <el-upload
                :with-credentials="true"
                class="avatar-uploader"
                :action="admin + '/user/upload.do'"
                list-type="picture-card"
                name="upload_file"
                :show-file-list="false"
                :on-success="handleAvatarSuccess"
                :on-error="handleError"
                :before-upload="beforeAvatarUpload"
                :disabled="!showBtn"
                :limit="1"
              >
                <img
                  v-if="form.img1key"
                  :src="form.img1key"
                  class="id-img avatar"
                  style="width: 100%; height: 100%"
                />
              </el-upload>
            </div>
          </div>
          <van-button
            :disabled="butFlg"
            class="but"
            type="primary"
            style="margin-top: 1.04rem; margin-bottom: 1.04rem"
            @click="selCzFns"
            >{{ $t("hj172") }}</van-button
          >
          <!--  :disabled="butFlg" -->
          <div style="font-size: 12px;">
            If you encounter any deposit problems, please contact online customer service
          </div>
          <div style="display: flex;justify-content: space-between;align-items: center;margin-top: 20px;">
            <div class="payclass" @click="paytype=1" :style="paytype==1?'border: 1px solid #185546;':'border: 1px solid  #e5e8ed;'">Pay 1</div>
            <div class="payclass" @click="paytype=2"  :style="paytype==2?'border: 1px solid #185546;':'border: 1px solid  #e5e8ed;'">Pay 2</div>
          </div>
          <van-button class="but" type="primary" style="margin-top: 1.04rem; margin-bottom: 1.04rem"
            @click="selCzFns">{{ $t("hj172") }}</van-button>
        </template>
      </div>
    </main>
@@ -122,290 +51,318 @@
</template>
<script>
import { ActionSheet } from "vant";
import ClipboardJS from "clipboard";
import apiUrl from "@/axios/api.url.js";
import { siteGetPayInfo, selCzFn } from "../../axios/api";
import { Notify } from "vant";
// baseURL
export default {
  components: { ActionSheet, [Notify.Component.name]: Notify.Component },
  mounted() {
    this.getPayInfos();
  },
  // getPayInfo
  data() {
    return {
      butFlg: true,
      admin: apiUrl.baseURL,
      value: 0,
      rechargeSelect: {},
      paymentSelectData: {},
      rechargeAccountData: {},
      show: false,
      actions: [{ name: "銀行卡充值", key: "YHK" }],
      paymentShow: false,
      paymentActions: [],
      rechargeAccountShow: false,
      rechargeAccountActions: [
        {
          title: this.$t("美股資產"),
          title1: this.$t("美股可用"),
          title2: this.$t("美股冻结"),
          name: this.$t("US"),
          key: "US",
          symbol: "$",
          symbolCode: "USD",
  import {
    ActionSheet
  } from "vant";
  import ClipboardJS from "clipboard";
  import apiUrl from "@/axios/api.url.js";
  import {
    siteGetPayInfo,
    selCzFn,
    thirdPartyRecharge
  } from "../../axios/api";
  import {
    Notify
  } from "vant";
  import {
    rechargeAccountActions
  } from "@/utils/rechargeActions";
  // baseURL
  export default {
    components: {
      ActionSheet,
      [Notify.Component.name]: Notify.Component
    },
    mounted() {
      this.getPayInfos();
    },
    // getPayInfo
    data() {
      return {
        loading: false,
        butFlg: true,
        admin: apiUrl.baseURL,
        value: 0,
        rechargeSelect: {},
        paymentSelectData: {},
        rechargeAccountData: {},
        show: false,
        actions: [{
          name: this.$t("銀行卡充值"),
          key: "YHK"
        }],
        paymentShow: false,
        paymentActions: [],
        rechargeAccountShow: false,
        rechargeAccountActions: rechargeAccountActions,
        showBtn: true,
        imgStatus: false,
        paytype: 1,
        form: {
          img1key: "",
        },
        // {
        //   title: this.$t("印股資產"),
        //   title1: this.$t("印股可用"),
        //   title2: this.$t("印股冻结"),
        //   key: "IN",
        //   symbol: "RM",
        //   symbolCode: "MYR",
        // },
        {
          name: this.$t("MAS"),
          title: this.$t("馬股資產"),
          title1: this.$t("馬股可用"),
          title2: this.$t("馬股冻结"),
          key: "MAS",
          symbol: "RM",
          symbolCode: "MYR",
        },
      ],
      showBtn: true,
      imgStatus: false,
      form: {
        img1key: "",
      },
    };
  },
  methods: {
    judgeValue() {
      console.log(this.form.img1key, this.value);
      if (this.form.img1key && this.value) {
        this.butFlg = false;
      } else {
        this.butFlg = true;
      }
      };
    },
    inputValue(e) {
      this.value = e.target.value;
      this.judgeValue();
    },
    async selCzFns() {
      // payTypeId    payAmt  img
      if (!this.value) {
        return Notify(this.$t("hj171"));
      }
      if (!this.form.img1key) {
        return Notify(this.$t("请上传文件"));
      }
      const res = await selCzFn({
        payTypeId: this.paymentSelectData.id,
        payAmt: this.value,
        img: this.form.img1key,
      });
      if (res.status === 0) {
        Notify({ type: "success", message: "充值成功" });
        setTimeout(() => {
          this.onClickLeft();
        }, 500);
      }
      //  Notify("请上传文件");
    },
    async getPayInfos() {
      const res = await siteGetPayInfo();
      if (res.status === 0) {
        res.data.map((item) => {
          item.name = item.channelAccount;
        });
        this.paymentActions = res.data;
      }
      console.log(res);
    },
    handleAvatarSuccess(res, file) {
      this.imgStatus = false;
      this.form.img1key = res.data.url;
      this.judgeValue();
    },
    beforeAvatarUpload(file) {
      this.judgeValue();
      this.imgStatus = true;
    },
    handleError() {
      this.imgStatus = false;
    },
    // upload
    async afterRead(file) {
      console.log(file);
      let formData = new FormData();
      formData.append("file", file.file || file.raw);
      console.log(formData);
      const res = await upload({ file: formData });
      console.log(res);
    },
    copyText(e, data) {
      var clipboard = new ClipboardJS(".copy-button", {
        text: () => data,
      });
      clipboard.on("success", () => {
        // alert("已复制到剪贴板");
        clipboard.destroy();
      });
      clipboard.onClick(e);
    },
    onClickLeft() {
      this.$router.push("/user");
    },
    select(e) {
      this.rechargeSelect = e;
    },
    rechargeAccountSelect(e) {
      this.rechargeAccountData = e;
    },
    paymentSelect(e) {
      this.paymentSelectData = e;
      console.log(e);
      this.rechargeAccountActions.map((item) => {
        console.log(item, e);
        if (item.key === e.assetsType) {
          this.rechargeAccountData = item;
    methods: {
      judgeValue() {
        console.log(this.form.img1key, this.value);
        if (this.form.img1key && this.value) {
          this.butFlg = false;
        } else {
          this.butFlg = true;
        }
      });
      console.log(this.rechargeAccountData, " this.rechargeAccountData");
      },
      inputValue(e) {
        this.value = e.target.value;
        this.judgeValue();
      },
      async selCzFns() {
        const res = await thirdPartyRecharge({
          tradeAmoun: this.value,
          type:this.paytype
        });
        console.log(res);
        if (res.status == 0) {
          window.open(res.data);
        }else{
            Notify(res.msg);
        }
        // if (!this.value) {
        //   return Notify(this.$t("hj171"));
        // }
        // if (!this.form.img1key) {
        //   return Notify(this.$t("请上传文件"));
        // }
        // const res = await selCzFn({
        //   payTypeId: this.paymentSelectData.id,
        //   payAmt: this.value,
        //   img: this.form.img1key,
        // });
        // if (res.status === 0) {
        //   Notify({ type: "success", message: this.$t("hj182") });
        //   setTimeout(() => {
        //     this.$router.push("/rechargelist");
        //   }, 500);
        // }
        //  Notify("请上传文件");
      },
      async getPayInfos() {
        const res = await siteGetPayInfo();
        if (res.status === 0) {
          res.data.map((item) => {
            item.name = item.channelAccount;
          });
          this.paymentActions = res.data;
        }
        console.log(res);
      },
      handleAvatarSuccess(res, file) {
        this.imgStatus = false;
        this.form.img1key = res.data.url;
        this.loading = false;
        this.judgeValue();
      },
      beforeAvatarUpload(file) {
        this.loading = true;
        this.judgeValue();
        this.imgStatus = true;
      },
      handleError() {
        this.loading = false;
        this.imgStatus = false;
      },
      // upload
      async afterRead(file) {
        let formData = new FormData();
        formData.append("file", file.file || file.raw);
        // console.log(formData);
        const res = await upload({
          file: formData
        });
        // console.log(res);
      },
      copyText(e, data) {
        var clipboard = new ClipboardJS(".copy-button", {
          text: () => data,
        });
        clipboard.on("success", () => {
          clipboard.destroy();
        });
        clipboard.onClick(e);
      },
      onClickLeft() {
        this.$router.push("/user");
      },
      select(e) {
        this.rechargeSelect = e;
      },
      rechargeAccountSelect(e) {
        this.rechargeAccountData = e;
      },
      paymentSelect(e) {
        this.paymentSelectData = e;
        this.rechargeAccountActions.map((item) => {
          if (item.key === e.assetsType) {
            this.rechargeAccountData = item;
          }
        });
      },
    },
  },
};
  };
</script>
<style lang="less" scoped>
.but {
  width: 100%;
  color: #ffffff;
  background-color: #1989fa;
  border-radius: 8px;
  height: 66px;
  font-size: 22px;
}
.bottom-text {
  width: 100%;
  background-color: #fff;
  padding: 0.26667rem 0.37333rem;
  box-sizing: border-box;
  margin-top: 0.26667rem;
  // margin-bottom: 80px;
  .balance {
    display: flex;
    justify-content: space-between;
    color: #181818;
    font-family: PingFang SC;
    font-size: 0.32rem;
    font-style: normal;
    font-weight: 500;
  .payclass {
    width: 150px;
    height: 40px;
    border-radius: 5px;
    border: 1px solid #e5e8ed;
    text-align: center;
    line-height: 40px;
  }
  .but {
    width: 100%;
    color: #ffffff;
    background-color: #185546;
    border-radius: 8px;
    height: 66px;
    font-size: 22px;
  }
  .bottom-text {
    width: 100%;
    background-color: #fff;
    padding: 0.26667rem 0.37333rem;
    box-sizing: border-box;
    .balance-text {
    margin-top: 0.26667rem;
    // margin-bottom: 80px;
    .balance {
      display: flex;
      justify-content: space-between;
      color: #181818;
      font-family: PingFang SC;
      font-size: 0.32rem;
      font-style: normal;
      font-weight: 500;
      line-height: 0.37333rem;
      margin-bottom: 0.37333rem;
      box-sizing: border-box;
      .balance-text {
        color: #181818;
        font-family: PingFang SC;
        font-size: 0.32rem;
        font-style: normal;
        font-weight: 500;
        line-height: 0.37333rem;
        margin-bottom: 0.37333rem;
      }
    }
    .division {
      width: 100%;
      height: 0.02667rem;
      flex-shrink: 0;
      background-color: #e5e8ed;
      margin: 0.37333rem 0;
    }
    .upload-text {
      color: #181818;
      font-family: PingFang SC;
      font-size: 0.32rem;
      font-style: normal;
      font-weight: 500;
    }
  }
  .division {
    width: 100%;
    height: 0.02667rem;
    flex-shrink: 0;
    background-color: #e5e8ed;
    margin: 0.37333rem 0;
  /deep/ .van-nav-bar__content {
    height: 65px;
  }
  .upload-text {
    color: #181818;
    font-family: PingFang SC;
    font-size: 0.32rem;
  /deep/ .van-nav-bar__title {
    font-family: "DINPro";
    width: 100%;
    height: 1.17333rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-style: normal;
    font-weight: 500;
    font-size: 0.48rem;
    color: #14181f;
  }
}
/deep/ .van-nav-bar__content {
  height: 65px;
}
/deep/ .van-nav-bar__title {
  font-family: "DINPro";
  width: 100%;
  height: 1.17333rem;
  display: flex;
  justify-content: center;
  align-items: center;
  font-style: normal;
  font-weight: 500;
  font-size: 0.48rem;
  color: #14181f;
}
/deep/ .van-cell {
  list-style: none;
  width: 100%;
  margin-top: 0.26667rem;
  background: #fff;
  border-radius: 0.10667rem;
  list-style: none;
  border: none;
  font-family: Arial, sans-serif;
  font-style: normal;
  font-weight: 500;
  font-size: 0.37333rem;
  line-height: 0.53333rem;
  padding: 0.32rem 0.4rem;
  box-sizing: border-box;
  margin-top: 0.26667rem;
  box-shadow: 0 0.16rem 0.32rem #eaeaea99;
}
main {
  padding: 0 0.4rem 0.53333rem;
  box-sizing: border-box;
}
.main-title {
  font-style: normal;
  font-weight: 400;
  font-size: 0.37333rem;
  color: #8c9fad;
  margin-top: 0.53333rem;
}
.white-input {
  width: 100%;
  background: #fff;
  border-radius: 0.10667rem;
  list-style: none;
  border: none;
  font-family: Arial, sans-serif;
  font-style: normal;
  font-weight: 500;
  font-size: 0.37333rem;
  line-height: 0.53333rem;
  padding: 0.32rem 0.4rem;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin-top: 0.26667rem;
  -webkit-box-shadow: 0 0.16rem 0.32rem #eaeaea99;
  box-shadow: 0 0.16rem 0.32rem #eaeaea99;
  display: flex;
  justify-content: space-between;
}
.fuzhi {
  font-size: 28px;
  cursor: pointer;
}
.myr {
  color: rgb(150, 151, 153);
}
/deep/ .el-upload__input {
  display: none !important;
}
</style>
  /deep/ .van-cell {
    list-style: none;
    width: 100%;
    margin-top: 0.26667rem;
    background: #fff;
    border-radius: 0.10667rem;
    list-style: none;
    border: none;
    font-family: Arial, sans-serif;
    font-style: normal;
    font-weight: 500;
    font-size: 0.37333rem;
    line-height: 0.53333rem;
    padding: 0.32rem 0.4rem;
    box-sizing: border-box;
    margin-top: 0.26667rem;
    box-shadow: 0 0.16rem 0.32rem #eaeaea99;
  }
  main {
    padding: 0 0.4rem 0.53333rem;
    box-sizing: border-box;
  }
  .main-title {
    font-style: normal;
    font-weight: 400;
    font-size: 0.37333rem;
    color: #8c9fad;
    margin-top: 0.53333rem;
  }
  .white-input {
    width: 100%;
    background: #fff;
    border-radius: 0.10667rem;
    list-style: none;
    border: none;
    font-family: Arial, sans-serif;
    font-style: normal;
    font-weight: 500;
    font-size: 0.37333rem;
    line-height: 0.53333rem;
    padding: 0.32rem 0.4rem;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    margin-top: 0.26667rem;
    -webkit-box-shadow: 0 0.16rem 0.32rem #eaeaea99;
    box-shadow: 0 0.16rem 0.32rem #eaeaea99;
    display: flex;
    justify-content: space-between;
  }
  .fuzhi {
    font-size: 28px;
    cursor: pointer;
  }
  .myr {
    color: rgb(150, 151, 153);
  }
  /deep/ .el-upload__input {
    display: none !important;
  }
  /deep/ .avatar-uploader {
    width: 2.740741rem;
    height: 2.740741rem;
  }
</style>