dujingxian 4 سال پیش
والد
کامیت
e87adbdb2a
3فایلهای تغییر یافته به همراه75 افزوده شده و 38 حذف شده
  1. 15 10
      src/api/index.js
  2. 56 27
      src/pages/subPages/balance.vue
  3. 4 1
      src/pages/subPages/view.vue

+ 15 - 10
src/api/index.js

@@ -185,25 +185,30 @@ export const updateKey = (secure_key) => {
     return requestLoading(`${Prefix}act=merchant_info&op=setkey&client_type=ajax&secure_key=${secure_key}`, 'post')
 }
 // 上传文件
+export const updateVoucher = (name) => {
+    // return requestLoading(`${Prefix}act=merchant_recharge&op=voucherupload&client_type=ajax`, 'post', {voucher})
+    return axios({
+        method: 'post',
+        url: `http://192.168.1.195/upfile.php`,
+        // withCredentials: true,
+        data: name,
+        timeout: 120000,
+    })
+}
 // export const updateVoucher = (voucher) => {
 //     // return requestLoading(`${Prefix}act=merchant_recharge&op=voucherupload&client_type=ajax`, 'post', {voucher})
 //     return axios({
 //         method: 'post',
-//         url: `${Prefix}act=merchant_recharge&op=voucherupload&client_type=ajax&voucher=${voucher}`,
+//         url: `http://192.168.1.195:8080/index.php&client_type=ajax`,
 //         withCredentials: true,
 //         data: voucher,
 //         timeout: 120000,
 //     })
 // }
-export const updateVoucher = (voucher) => {
-    // return requestLoading(`${Prefix}act=merchant_recharge&op=voucherupload&client_type=ajax`, 'post', {voucher})
-    return axios({
-        method: 'post',
-        url: `http://192.168.1.195:8080/index.php&client_type=ajax&voucher=${voucher}`,
-        withCredentials: true,
-        data: voucher,
-        timeout: 120000,
-    })
+
+// 上传凭证
+export const updateVoucherList = (params) => {
+    return requestLoading(`${Prefix}act=merchant_recharge&op=add&client_type=ajax`, 'post', params)
 }
 
 // 获取充值列表

+ 56 - 27
src/pages/subPages/balance.vue

@@ -30,7 +30,9 @@
         <!-- <el-table-column align="center" prop="payment_type" label="支付方式"></el-table-column> -->
         <el-table-column align="center" prop="add_time" label="充值时间"></el-table-column>
         <el-table-column align="center" label="充值凭证">
-            <el-button type="success" size="small" @click="seeDialogVisible = true">查看</el-button>
+            <template slot-scope="scope">
+                <el-button type="success" size="small" @click="seeBtn(scope.row.voucher_path)">查看</el-button>
+            </template>
             <!-- <el-button size="small" type="primary" @click="uploadDialogVisible = true">上传</el-button> -->
             <!-- <el-upload
                 class="upload-demo"
@@ -60,7 +62,7 @@
     </el-dialog>
 
     <!-- 上传弹层 -->
-    <el-dialog title="上传凭证" :visible="uploadDialogVisible" class="updata" @closed="onCloseEditDialog">
+    <el-dialog title="上传凭证" :visible="uploadDialogVisible" class="updata" @close="onCloseEditDialog">
         <!-- <el-form :model="formData" label-width="120px">
             <el-form-item label="充值金额: ">
                 <el-input v-model="formData.amount" style="width:300px"></el-input>
@@ -139,12 +141,13 @@
 </template>
 <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
 <script>
-// getVoucherList-获取充值列表 updateVoucher-上传凭证 queryVoucherList-查询充值
+// getVoucherList-获取充值列表 updateVoucher-上传凭证 queryVoucherList-查询充值 updateVoucherList-上传凭证列表
 import {
     // balanceList,
     getVoucherList,
     updateVoucher,
-    queryVoucherList
+    queryVoucherList,
+    updateVoucherList
 } from "@/api";
 import { balanceType } from '@/utils/constants'
 export default {
@@ -194,36 +197,28 @@ export default {
                 amount: [{ required: true, message: '请输入充值金额', trigger: 'blur' }],
                 bank_username: [{ required: true, message: '请输入开户人姓名', trigger: 'blur' }],
                 bank_name: [{ required: true, message: '请输入银行名称', trigger: 'blur' }],
-                voucher: [{ required: true, message: '请上传充值凭证', trigger: 'change' }],
+                voucher: [{ required: true, message: '请上传充值凭证', trigger: 'blur' }],
             },
             files: '',
             selectFileobj: '',
             imgCode: '',
-            fileImg: ''
+            fileImg: '',
+            // 上传图片返回地址
+            file_path: ''
         };
     },
     mounted() {
-        // this.getOrderList();
     },
     created () {
         this.getVoucherList()
     },
     methods: {
-        // getOrderList() {
-        //     const _self = this;
-        //     balanceList({
-        //         pageSize: _self.pageSize,
-        //         pageNumber: _self.pageNumber,
-        //         order_sn: _self.searchValue,
-        //         start_time: _self.dataRange && _self.dataRange.length == 2 ? _self.dataRange[0] : '',
-        //         end_time: _self.dataRange && _self.dataRange.length == 2 ? _self.dataRange[1] : ''
-        //     }).then((res) => {
-        //         if (res && res.msg == "ok") {
-        //             _self.total = res.data.total;
-        //             _self.tableData = [...res.data.rows];
-        //         }
-        //     });
-        // },
+        // 查看
+        seeBtn(path) {
+            this.seeDialogVisible = true
+            this.url = path
+            this.srcList = [path]
+        },
         // 关闭弹层
         onCloseEditDialog() {
             this.formData = {};
@@ -359,6 +354,18 @@ export default {
                 // this.fileName = event.target.files[0].name;
                 this.fileImg = event.target.files[0];
                 console.log('file', event.target.files[0]);
+
+                // var reader = new FileReader()
+                // reader.readAsDataURL(this.fileImg)
+                // reader.onload = async function (e) {
+                //     let fd = new FormData(document.getElementById("uploadForm")); 
+                //     fd.append('file', this.fileImg);
+                //     console.log('fd', fd);
+                //     const res = await updateVoucher(fd)     // 调用接口实现文件上传
+                //     console.log('res', res);
+                //     this.file_path = res.datas.file_path
+
+                // }
             }
         },
         // 上传按钮
@@ -386,12 +393,34 @@ export default {
             // }
 
             //关于formdata使用方式请自行搜索
-            // let uploadForm = document.getElementById("uploadForm");
-            // console.log('uploadForm',uploadForm);
+            let uploadForm = document.getElementById("uploadForm");
+            console.log('uploadForm',uploadForm);
             let fd = new FormData(document.getElementById("uploadForm")); 
-            fd.append('voucher', this.fileImg);
+            fd.append('file', this.fileImg);
+            console.log('fd', fd);
             const res = await updateVoucher(fd)     // 调用接口实现文件上传
             console.log('res', res);
+            this.file_path = res.datas.file_path
+
+            // const res = await this.$axios.post('http://192.168.1.195/upfile.php', {
+            //     name: fd
+            // })
+            // console.log('res', res);
+
+            // 上传凭证列表
+            this.$nextTick(async () => {
+                const result = await updateVoucherList({
+                    amount: this.formData.amount,
+                    bank_username: this.formData.bank_username,
+                    bank_name: this.formData.bank_name,
+                    voucher: this.file_path
+                })
+                console.log('result', result);
+                if (result && result.code == 200) {
+                    this.$message.success('上传成功')
+                    this.uploadDialogVisible = false
+                }
+            })
         }
     },
 }
@@ -402,9 +431,9 @@ export default {
     display: inline-block;
     margin-left: 10px;
 }
-/* .seeDialog /deep/.el-dialog__body {
+.seeDialog /deep/.el-dialog__body {
     text-align: center;
-} */
+}
 /* .avatar-uploader {
     text-align: center;
 } */

+ 4 - 1
src/pages/subPages/view.vue

@@ -120,7 +120,7 @@ export default {
                 // 调用删除接口
                 const res = await delIpList({ip: ip})
                 console.log('删除ip', res);
-                if (res.code == 200) {
+                if (res && res.code == 200) {
                     // 提示
                     this.$message({
                         message: '删除成功',
@@ -187,6 +187,9 @@ export default {
         async updateKey() {
             const res = await updateKey(this.securityKey)
             console.log('密钥', res);
+            if (res && res.code == 200) {
+                this.$message.success('设置密钥成功')
+            }
         }
         // 新增
         // addIp() {}