浏览代码

增加银行卡提现模式

xinfeng 6 年之前
父节点
当前提交
63dd140811
共有 3 个文件被更改,包括 323 次插入21 次删除
  1. 234 0
      components/wo/successToast.vue
  2. 6 1
      nuxt.config.js
  3. 83 20
      pages/wo/cash.vue

+ 234 - 0
components/wo/successToast.vue

@@ -0,0 +1,234 @@
+<template>
+  <div :class="{connectUs: !mobile, connectUsMobile: mobile}">
+    <div class="toastBox" v-if="isShowToast">
+      <div class="toastArea">
+        <div class="title">提现成功</div>
+        <div class="tips">提现成功,项目款将在3-5个工作日内到账 可通过了解开发者会员服务,更快获取更多收益</div>
+        <div class="btnList">
+          <div class="btnItem cancleBtn" @click="close">
+            <p>下次再说</p>
+          </div>
+          <div class="btnItem submitBtn" @click="handleSubmit">
+            <p>立即了解</p>
+          </div>
+        </div>
+        <div class="closeIcon" @click="close"/>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  props: ["isShowToast"],
+  components: {},
+  data() {
+    return {
+      name: "",
+      phone: "",
+      mobile: this.$deviceType.isMobile()
+    };
+  },
+  computed: {},
+  mounted() {
+
+  },
+  methods: {
+    close() {
+      this.$emit('close')
+    },
+    handleSubmit() {
+      location.href = "/type/vip/developer"
+    }
+  }
+};
+</script>
+
+<style lang="scss">
+  @import "~@/assets/css/scssCommon.scss";
+.connectUs {
+  .toastBox {
+    position: fixed;
+    width: 100vw;
+    height: 100vh;
+    background-color: rgba(0, 0, 0, 0.8);
+    z-index: 888;
+    left: 0;
+    top: 0;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+
+    .toastArea {
+      position: relative;
+      width: 446px;
+      height: 267px;
+      background: rgba(255, 255, 255, 1);
+      border-radius: 3px;
+      padding: 34px 34px;
+
+      .title {
+        font-size: 19px;
+        font-weight: 500;
+        color: rgba(34, 34, 34, 1);
+        line-height: 26px;
+        text-align: center;
+      }
+
+      .tips {
+        margin-top: 35px;
+        font-size:14px;
+        font-weight:400;
+        color:rgba(51,51,51,1);
+        line-height:20px;
+      }
+
+      .btnList {
+        margin-top: 40px;
+        display: flex;
+        width: 100%;
+        justify-content: space-around;
+
+        .btnItem {
+          width: 170px;
+          height: 44px;
+          background: rgba(48, 142, 255, 1);
+          box-shadow: 0 2px 6px 0 rgba(48, 142, 255, 0.3);
+          border-radius: 2px;
+          display: flex;
+          justify-content: center;
+          align-items: center;
+          cursor: pointer;
+          p {
+            font-size: 14px;
+            font-weight: 500;
+            color: rgba(255, 255, 255, 1);
+            line-height: 20px;
+          }
+        }
+
+        .submitBtn {
+
+        }
+        .cancleBtn {
+          background:rgba(236,236,236,1);
+          border-radius:2px;
+          box-shadow: none;
+          p {
+            color:rgba(102,102,102,1);
+          }
+        }
+
+      }
+
+      .closeIcon {
+        position: absolute;
+        right: 20px;
+        top: 34px;
+        width: 16px;
+        height: 16px;
+        background: url('~@/assets/img/credit/closeIcon.png') no-repeat;
+        background-size: cover;
+        cursor: pointer;
+      }
+    }
+
+  }
+
+}
+.connectUsMobile {
+  .toastBox {
+    position: fixed;
+    width: 100vw;
+    height: 100vh;
+    background-color: rgba(0, 0, 0, 0.8);
+    z-index: 888;
+    left: 0;
+    top: 0;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+
+    .toastArea {
+      position: relative;
+      width: pxtovw(355);
+      height: pxtovw(403);
+      background: rgba(255, 255, 255, 1);
+      border-radius: pxtovw(3);
+      padding: pxtovw(30) pxtovw(30);
+
+      .title {
+        font-size: pxtovw(19);
+        font-weight: 500;
+        color: rgba(34, 34, 34, 1);
+        line-height: pxtovw(26);
+        text-align: center;
+      }
+
+      .tips {
+        margin-top: pxtovw(8);
+        margin-bottom: pxtovw(14);
+        font-size: pxtovw(12);
+        font-weight: 400;
+        color: rgba(153, 153, 153, 1);
+        line-height: pxtovw(17);
+        text-align: center;
+      }
+
+      .nameCell, .phoneCell {
+        margin-top: pxtovw(25);
+
+        .label {
+          font-size: pxtovw(14);
+          font-weight: 500;
+          color: rgba(25, 34, 46, 1);
+          line-height: pxtovw(20);
+        }
+        input {
+          margin-top: pxtovw(5);
+          padding: pxtovw(10);
+          width: pxtovw(295);
+          height: pxtovw(48);
+          background: rgba(255, 255, 255, 1);
+          border-radius: pxtovw(3);
+          border: pxtovw(1) solid rgba(221, 225, 230, 1);
+        }
+      }
+      .nameCell {
+        margin-top: pxtovw(39);
+      }
+
+      .submitBtn {
+        margin-top: pxtovw(18);
+        width: pxtovw(295);
+        height: pxtovw(48);
+        background: rgba(48, 142, 255, 1);
+        box-shadow: 0 pxtovw(2) pxtovw(6) 0 rgba(48, 142, 255, 0.3);
+        border-radius: pxtovw(2);
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        cursor: pointer;
+        p {
+          font-size: pxtovw(14);
+          font-weight: 500;
+          color: rgba(255, 255, 255, 1);
+          line-height: pxtovw(20);
+        }
+      }
+
+      .closeIcon {
+        position: absolute;
+        right: pxtovw(20);
+        top: pxtovw(34);
+        width: pxtovw(16);
+        height: pxtovw(16);
+        background: url('~@/assets/img/credit/closeIcon.png') no-repeat;
+        background-size: cover;
+        cursor: pointer;
+      }
+    }
+
+  }
+}
+</style>

+ 6 - 1
nuxt.config.js

@@ -3,7 +3,12 @@ const pkg = require("./package");
 
 module.exports = {
   mode: "universal",
-
+  vue: {
+    config: {
+      productionTip: process.env.NODE_ENV !== "development",
+      devtools: process.env.NODE_ENV === "development"
+    }
+  },
   env: {
     baseUrl:
       process.env.NODE_ENV == "development"

+ 83 - 20
pages/wo/cash.vue

@@ -2,15 +2,19 @@
   <div class="cash">
     <inner-header title="资金提现"></inner-header>
     <section class="content">
-      <h2>提现到支付宝({{userInfo.alipay}})</h2>
+      <h2 v-if="isIdCard">提现到银行卡(
+        <span v-if="userInfo.bankAccount">{{userInfo.bankAccount}}</span>
+        <span v-else><a href="/wo/account_manage">去绑定银行卡</a></span>
+        )</h2>
+      <h2 v-else>提现到支付宝({{userInfo.alipay}})</h2>
       <div class="input-box">
-        <el-input class="cash-input" placeholder="最少提现1元,每日上限3万元" v-model="coins"></el-input>
+        <el-input class="cash-input" placeholder="最少提现10元,每日上限3万元" v-model="coins"></el-input>
         <span class="input-icon">¥</span>
         <el-button type="text" class="get-all" @click="doGetAll">全部提现</el-button>
       </div>
       <div class="balance">
         可用余额
-        <span>¥{{(+coinInfo.balance) || 0}}</span>元
+        <span>¥{{(+userCanWithdrawAmount) || 0}}</span>元
       </div>
       <el-button @click="doGet" class="get-btn" type="primary">提现</el-button>
       <p class="remind-time">预计1~3个工作日到账</p>
@@ -36,17 +40,22 @@
         <el-button type="primary" @click="doDialogConfirm">确 定</el-button>
       </div>
     </el-dialog>
+    <SuccessToast :isShowToast="isShowToastSuccess" @close="isShowToastSuccess=false"/>
   </div>
 </template>
 
 <script>
 import InputVer from "@/components/input/ver";
 import InnerHeader from "@/components/inner_header";
+import SuccessToast from "@/components/wo/successToast";
+const Max_Money = 30000
+const Min_Money = 10
 
 export default {
   components: {
     InputVer,
-    InnerHeader
+    InnerHeader,
+    SuccessToast
   },
   data() {
     return {
@@ -57,17 +66,29 @@ export default {
       // 验证码
       ver: "",
       // 费率
-      rate: ""
+      rate: "",
+      isIdCard: false, //是否是提现到银行卡
+      isShowToastSuccess: false, //是否展示成功后的提示
     };
   },
   computed: {
     coinInfo() {
-      return this.alipayInfo.coinInfo || {};
+      return this.alipayInfo && this.alipayInfo.coinInfo || {};
+    },
+    userCanWithdrawAmount() {
+      const {balance=0, incomeTaxBalance=0} = this.alipayInfo && this.alipayInfo.coinInfo || {}
+      return this.isIdCard ? incomeTaxBalance : balance
     },
     userInfo() {
-      return this.alipayInfo.userInfo || {};
+      return this.alipayInfo && this.alipayInfo.userInfo || {};
     }
   },
+  created() {
+    console.log('this.$route.query', this.$route.query)
+    //type 1-支付宝 2-银行卡 默认是1
+    const {type=1} = this.$route.query || {}
+    this.isIdCard = Number(type) === 2
+  },
   mounted() {
     this.getAlipayInfo();
     this.getRate();
@@ -77,7 +98,11 @@ export default {
      * 全部提现
      */
     doGetAll() {
-      this.coins = this.coinInfo.balance;
+      this.coins = this.userCanWithdrawAmount;
+      if (this.userCanWithdrawAmount > Max_Money) {
+        this.$message.info("每日最多可提现3万元")
+        this.coins = Max_Money
+      }
     },
     /**
      * 获取支付宝信息
@@ -87,6 +112,11 @@ export default {
       console.log(res);
       if (res) {
         this.alipayInfo = res.data;
+        const {alipay, bankAccount} = res.data.alipayInfo || {}
+        //银行卡提现,但没绑定时 提示
+        if (!bankAccount && this.isIdCard === 2) {
+          this.$message.info("请前往程序员客栈APP绑定银行卡!")
+        }
       }
     },
     /**
@@ -107,6 +137,18 @@ export default {
         this.$message("请输入提现金额");
         return;
       }
+      //最少
+      if (Min_Money > this.userCanWithdrawAmount) {
+        this.$message(`单次最少提现${Min_Money}元`);
+        return;
+      }
+      //最多允许提现2位小数
+      let docRight = (this.coins + "").split(".")[1]
+      console.log("docRight", docRight)
+      if (docRight && docRight.length > 2) {
+        this.$message(`最多允许输入2位小数`);
+        return;
+      }
       // 错误处理
       let coinsNum = +(this.coins + "").replace(/[^\d\.]/g, "");
       if (
@@ -117,7 +159,8 @@ export default {
         this.$message("请输入正确的提现金额");
         return;
       }
-      if (coinsNum > this.coinInfo.balance) {
+      //余额不足
+      if (coinsNum > this.userCanWithdrawAmount) {
         this.$message("可提现余额不足");
         return;
       }
@@ -140,22 +183,42 @@ export default {
         cancelButtonText: "取消",
         type: "warning"
       }).then(async () => {
-        let res = await this.$axios.$post("/api/account/take_coins_to_alipay", {
+        this.withdrawFn()
+      });
+    },
+
+    /** 提现到支付宝 **/
+    async withdrawFn() {
+      let res = null
+      if (this.isIdCard) {
+        res = await this.$axios.$post("/api/account/takeSalary", {
+          coins: +this.coins,
+          auth_code: this.ver
+        });
+      } else {
+        res = await this.$axios.$post("/api/account/take_coins_to_alipay", {
           coins: +this.coins,
           payee_real_name: this.userinfo.realname,
           alipay_account: this.userInfo.alipay,
           auth_code: this.ver
         });
-        if (res) {
-          this.$message({
-            type: "success",
-            message: "提现成功"
-          });
-          setTimeout(() => {
-            location.reload();
-          }, 1000);
-        }
-      });
+      }
+      if (res && Number(res.status) === 1) {
+        this.$message({
+          type: "success",
+          message: res.info || "提现成功"
+        });
+        this.dialogShow = false
+        setTimeout(() => {
+          if (this.isIdCard) {
+            this.isShowToastSuccess = true
+            this.getAlipayInfo()
+            this.coins = 0
+          } else {
+            window.reload()
+          }
+        }, 1000);
+      }
     }
   }
 };