panyong 2 年 前
コミット
05161a96bd

+ 0 - 0
htmldev/.gitkeep


+ 1 - 1
htmldev/cps/src/api/request.js

@@ -53,7 +53,7 @@ request.interceptors.request.use(request => {
 
   // 因为微信开发者工具重复授权,本地开发时写死
   if (/^(0|192|10|localhost)/.test(domain)) {
-    request.headers.wechatToken = '653c2f9e8952b08d2c40e859a21713a1'
+    request.headers.wechatToken = '059c8aecf908987667c5d34977d36bce'
   } else {
     request.headers.wechatToken = getCookieValue('fanbutingwechatToken')
   }

+ 9 - 0
htmldev/cps/src/router/index.js

@@ -110,6 +110,15 @@ const routes = [
       isUseCache: false,
       keepAlive: true
     }
+  },
+  {
+    path: '/paymentCode', // 支付码
+    name: 'PaymentCode',
+    component: _import('views/paymentCode/index'),
+    meta: {
+      isUseCache: false,
+      keepAlive: false
+    }
   }
 ]
 

+ 26 - 0
htmldev/cps/src/views/paymentCode/api/api.js

@@ -0,0 +1,26 @@
+import request from '@/api/request'
+
+const host = window.location.host
+const domain = host.substring(0, host.indexOf('.')) || host.substring(0, host.indexOf(':'))
+const isProxy = /^(0|192|localhost|10)/.test(domain)
+
+/**
+ * 获取机构列表
+ */
+export const apiOrgList = () => request({
+  method: 'GET',
+  url: (isProxy ? '/proxycodedreamit' : '') + '/api/wechat/list'
+})
+
+/**
+ * 获取支付信息
+ */
+export const apiWechatPay = (id, orderPrice) => request({
+  method: 'GET',
+  url: (isProxy ? '/proxycodedreamit' : '') + '/api/wechat/pay',
+  params: {
+    id: id,
+    order_price: orderPrice
+  },
+  showLoading: false
+})

+ 145 - 0
htmldev/cps/src/views/paymentCode/index.vue

@@ -0,0 +1,145 @@
+<template>
+  <div class="payment-code-container">
+    <van-form
+      @submit="onSubmit">
+      <van-field
+        readonly
+        clickable
+        name="picker"
+        :value="accountName"
+        label="账号"
+        placeholder="请选择账户"
+        @click="showPicker = true"/>
+      <van-field
+        class="fbt-van-cell"
+        v-model.trim="orderPrice"
+        :border="false"
+        label="充值金额"
+        placeholder="请输入充值金额"
+        @input="orderPrice = orderPrice.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1').replace(/^0\d*/, '0').replace(/^\./, '0.')"/>
+      <div>
+        <van-button
+          block
+          type="info"
+          native-type="submit"
+          :disabled="booLock"
+          style="width: 80%;margin: 0 auto;">提交
+        </van-button>
+      </div>
+    </van-form>
+    <van-popup
+      v-model="showPicker"
+      position="bottom"
+      @click-overlay="onCancel">
+      <van-picker
+        show-toolbar
+        :columns="columns"
+        @confirm="onConfirm"
+        @cancel="onCancel"
+        ref="myPicker"
+      />
+    </van-popup>
+  </div>
+</template>
+
+<script>
+import { Form, Field, Popup, Picker, Button, Toast } from 'vant'
+import { apiOrgList, apiWechatPay } from './api/api'
+import { yuan2Fen } from '@/utils'
+
+export default {
+  name: 'index',
+  components: {
+    'van-form': Form,
+    'van-field': Field,
+    'van-popup': Popup,
+    'van-picker': Picker,
+    'van-button': Button
+  },
+  data () {
+    return {
+      accountName: '', // 账号名称
+      id: '', // 账号ID
+      orderPrice: '', // 重置金额
+      showPicker: false,
+      columns: [],
+      errorList: [],
+      booLock: false
+    }
+  },
+  created () {
+    this.fetchOrgList()
+  },
+  methods: {
+    onConfirm (val) {
+      const { text, id } = val
+      this.accountName = text
+      this.id = id
+      this.showPicker = false
+    },
+    onCancel () {
+      const index = this.columns.findIndex(item => item.id === this.id)
+      if (index > -1) {
+        this.$refs.myPicker.setIndexes([index])
+      }
+      this.showPicker = false
+    },
+    verifyData () {
+      this.errorList = []
+      if (!this.id) {
+        this.errorList.push('请选择账户')
+      }
+      if (!this.orderPrice) {
+        this.errorList.push('请输入充值金额')
+      }
+      return this.errorList.length > 0
+    },
+    async fetchOrgList () {
+      try {
+        const { status, data, msg } = await apiOrgList()
+        if (status) {
+          if (Array.isArray(data)) {
+            this.columns = data.map(item => ({
+              ...item,
+              text: item.account_name
+            }))
+          }
+        } else {
+          Toast(msg)
+        }
+      } catch (err) {}
+    },
+    async onSubmit () {
+      if (this.verifyData()) {
+        Toast(this.errorList[0])
+        return
+      }
+      try {
+        this.booLock = true
+        const { status, data, msg } = await apiWechatPay(this.id, yuan2Fen(this.orderPrice))
+        this.booLock = false
+        if (status) {
+          top.location.href = data.code_url
+        } else {
+          Toast(msg)
+        }
+      } catch (err) {}
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.payment-code-container {
+  padding-top: 100px;
+  background: #fff;
+
+  ::v-deep .van-form {
+    padding: 20px 0;
+
+    .van-cell {
+      margin-bottom: 20px;
+    }
+  }
+}
+</style>

+ 8 - 0
htmldev/cps/vue.config.js

@@ -43,6 +43,14 @@ module.exports = {
     open: true,
     clientLogLevel: 'warning',
     proxy: {
+      '/proxycodedreamit': {
+        target: 'http://test-pay.codedreamit.com',
+        ws: true,
+        changeOrigin: true,
+        pathRewrite: {
+          '^/proxycodedreamit': ''
+        }
+      },
       '/api': {
         target: 'http://test-daogou.codedreamit.com',
         ws: true,