• <abbr id="chdyf"></abbr>
    <ruby id="chdyf"><acronym id="chdyf"><meter id="chdyf"></meter></acronym></ruby>
    <bdo id="chdyf"></bdo>
    <dfn id="chdyf"><menu id="chdyf"></menu></dfn>
    1. <menuitem id="chdyf"></menuitem><strong id="chdyf"><menu id="chdyf"></menu></strong>

      <rt id="chdyf"><menu id="chdyf"></menu></rt>
      成人小说一区二区三区,伊人精品成人久久综合全集观看,久久HEZYO色综合,中文字幕精品人妻熟女,影音先锋成人网站,我要看免费一级毛片,中国女人做爰A片,中文字幕av久久爽Av

      vue項目 微信支付 和 支付寶支付

      2019-7-2    seo達人

      如果您想訂閱本博客內容,每天自動發到您的郵箱中, 請點這里

      做了一個項目,有充值功能,充值方式為 微信和支付寶,效果如下:



      代碼:

      <template>
      <el-card class="box-card">
      <ul class="msg-box">
      <li>
      <h4>我要充值</h4>
      </li>
      <li>
      <h4 style="margin-bottom: 15px;">充值金額</h4>
      <el-radio-group v-model="amountVal" @change="amountChange">
      <el-radio border :label="''+ 100">充值100</el-radio>
      <el-radio border :label="''+ 500">充值500</el-radio>
      <el-radio border :label="''+ 1000">充值1000</el-radio>
      <el-radio border :label="''+ 2000">充值2000</el-radio>
      <el-radio border :label="''+ 5000">充值5000</el-radio>
      <el-radio border :label="''">自定義</el-radio>
      </el-radio-group>
      </li>
      <li>
      <h4 style="margin-bottom: 15px;">充值方式</h4>
      <el-radio-group v-model="rechargeParams.paymentType" @change="paymentTypeChange">
      <el-radio border :label="''+ 0">微信</el-radio>
      <el-radio border :label="''+ 1">支付寶</el-radio>
      </el-radio-group>
      </li>
      <li>
      <h4 style="margin-bottom: 15px;">充值金額</h4>
      <el-input :disabled="disabled" clearable v-model="rechargeParams.totalAmt" placeholder="請輸入金額" style="width: 150px;"></el-input>
      </li>
      </ul>
      <div style="text-align: center; margin-top: 30px;">
      <el-button type="primary" @click="surePay">確認支付</el-button>
      </div>
      </el-card>
      </template>
       
      <script>
      export default {
      data() {
      return {
      amountVal: '',
      disabled: false,
      //充值參數
      rechargeParams: {
      "totalAmt": '', //金額
      "paymentType": "0", //支付方式[0:微信,1:支付寶,2:余額,3:活動]
      "transType": "0" //交易類型[0:充值,1:消費]
      }
      }
      },
      methods: {
      //充值金額
      amountChange(val) {
      this.rechargeParams.totalAmt = val;
      if (val == '') {
      this.disabled = false
      } else {
      this.disabled = true
      }
      },
      //支付方式
      paymentTypeChange(val) {
      this.rechargeParams.paymentType = val
      },
      //確認支付
      async surePay() {
      if (this.rechargeParams.totalAmt == '') {
      this.$message.warning('請輸入金額');
      return;
      }
      const res = await this.$http.post('orderInfo/createOrderInfo', this.rechargeParams)
      const {
      code,
      msg,
      result
      } = res.data
      if (code === '200') {
      //支付方式跳轉
      if (this.rechargeParams.paymentType == '0') {
      this.$message.success('微信支付');
      this.wechatPay(result);
      } else if (this.rechargeParams.paymentType == '1') {
      this.$message.success('支付寶支付')
      const payDiv = document.getElementById('payDiv');
      if (payDiv) {
      document.body.removeChild(payDiv);
      }
      const div = document.createElement('div');
      div.id = 'payDiv';
      div.innerHTML = result;
      document.body.appendChild(div);
      document.getElementById('payDiv').getElementsByTagName('form')[0].submit();
      } else if (this.rechargeParams.paymentType == '2') {
      this.$message.success('余額支付成功');
      this.$router.push({
      name: 'order'
      })
      } else {
      this.$message.success('活動支付')
      }
      } else if (code === 401) {
      this.$message.error(msg)
      this.$router.push({
      name: 'login'
      })
      } else {
      this.$message.error(msg)
      }
      },
      //微信支付
      wechatPay(result) {
      if (result) {
      const orderParams = JSON.parse(result);
      sessionStorage.qrurl = orderParams.qrurl;
      sessionStorage.amt = orderParams.amt;
      sessionStorage.returnUrl = orderParams.returnUrl;
      sessionStorage.order_id = orderParams.order_id;
      this.$router.push({
      name: 'wechatPay'
      })
      }
      }
      }
      }
      </script>
       
      <style scoped>
      /* 信息列表樣式 */
      .msg-box > li {
      list-style: none;
      border-bottom: 1px solid #c5c5c5;
      padding: 20px 10px;
      }
      </style>
      支付寶方式:后臺會返回來一個form,然后提交form自動跳轉到支付寶支付頁面。

      微信方式:需要自己根據后臺返回的url生成二維碼頁面,如圖所示:



      代碼:

      <template>
      <div class="payBox">
      <div class="img-logo">
      <img src="http://img.huoxingbeidiao.com/public/WePayLogo.png" alt="">
      </div>
      <div class="info-box">
      <div style="padding-bottom: 20px;">
      <qrcode-vue :value="qrurl" :size="200" level="H"></qrcode-vue>
      </div>
      <img src="http://img.huoxingbeidiao.com/public/WePayInfo.png" alt="">
      <p class="price">¥&nbsp;{{amt}}</p>
      </div>
      </div>
      </template>
       
      <script>
      import QrcodeVue from 'qrcode.vue'
      export default {
      data() {
      return {
      amt: 0,
      qrurl: '',
      timer: null
      }
      },
      components: {
      QrcodeVue
      },
      methods: {
      getOrderInfo() {
      if (sessionStorage.qrurl && sessionStorage.amt) {
      this.qrurl = sessionStorage.qrurl;
      this.amt = sessionStorage.amt;
      }
      },
      startLoop() {
      this.timer = setInterval(() => {
      this.isPaySuccess()
      }, 3000)
      },
      async isPaySuccess() {
      const orderId = sessionStorage.order_id;
      const res = await this.$http.get('orderInfo/queryOrder?orderId=' + orderId)
      const {
      code,
      msg,
      resultList
      } = res.data
      if (code === '200') {
      clearInterval(this.timer);
      this.timer = null;
      sessionStorage.removeItem('qrurl');
      sessionStorage.removeItem('amt');
      sessionStorage.removeItem('order_id');
      sessionStorage.removeItem('returnUrl');
      setTimeout(() => {
      this.$router.push({
      name: 'order'
      })
      }, 3000)
      } else if (code === 401) {
      clearInterval(this.timer);
      this.timer = null;
      sessionStorage.removeItem('qrurl');
      sessionStorage.removeItem('amt');
      sessionStorage.removeItem('order_id');
      sessionStorage.removeItem('returnUrl');
      this.$message.error(msg)
      this.$router.push({
      name: 'login'
      })
      } else {
       
      }
      }
      },
      created() {
      this.getOrderInfo()
      this.startLoop()
      },
      beforeDestroy() {
      clearInterval(this.timer)
      this.timer = null
      }
      }
      </script>
       
      <style scoped>
      .payBox {
      width: 1000px;
      margin: 0 auto;
      }
       
      .payBox .img-logo {
      padding: 20px 0;
      text-align: center;
      }
       
      .payBox .img-logo img {
      width: 180px;
      }
       
      .info-box {
      padding: 60px 0;
      border-top: 3px solid #F43B66;
      -webkit-box-shadow: 0 0 32px 0 rgba(0, 0, 0, .18);
      box-shadow: 0 0 32px 0 rgba(0, 0, 0, .18);
      text-align: center;
      }
       
      .info-box .price {
      color: #F43B66;
      font-size: 40px;
      padding-top: 20px;
      padding-bottom: 20px;
      border-bottom: 1px solid #f1f1f1;
      }
      </style>
      需要安裝qrcode.vue

      npm install --save qrcode.vue  或  yarn add qrcode.vue
      藍藍設計www.wtxcl.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務。

      日歷

      鏈接

      個人資料

      藍藍設計的小編 http://www.wtxcl.cn

      存檔

      主站蜘蛛池模板: 人人干干| 九九久久精品免费观看| 亚洲自拍偷拍一区二区| 伊人网视频| 国产日产精品久久一区| 久久精品国产亚洲av香蕉上下| www.xxxx中国视频| 丁香五月亭亭| 城中村快餐嫖老妇对白| 亚洲色频| 在线观看亚洲天堂| 欧美人妻少妇| 性欧美videoshd| 国产成人无码综合亚洲日韩| 26uuu亚洲| 色翁荡熄又大又硬视频| 一夲道HEYZO无码专区| 91人妻人人澡人人爽人人精品| 日本亚洲成a人片在线观看| 郴州市| 在线日本免费一区二区三区| 抚州市| 亚洲欧美日韩在线播放| 精品合集播放| 人妻系列AV无码专区| 巍山| XXXX国产| 亚洲电影欧美电影| 精品久久国产| 欧美97欧美综合色伦图| 华安县| 清涧县| 中文字幕一区二区三区久久| 久久精品熟妇丰满人妻99| 国产成人无码Av在线播放无广告| 国产V∧在线视频| 在线第99页| 亚洲AV无码久久精品色欲| 印度AV免费观看| 亚洲乱码精品乱码精品中文| 国产精品久久久影院色|