Quellcode durchsuchen

开发者设置调整

dujingxian vor 4 Jahren
Ursprung
Commit
9d4af14d3a
2 geänderte Dateien mit 52 neuen und 33 gelöschten Zeilen
  1. 26 15
      src/api/index.js
  2. 26 18
      src/pages/subPages/view.vue

+ 26 - 15
src/api/index.js

@@ -8,10 +8,11 @@ import context from '../main';
 
 axios.interceptors.request.use(
     config => {
-        // config.headers = {
-        //     // "Content-Type": "application/json"
-        //     "Content-Type": "text/html"
-        // }
+        config.headers = {
+            // "Content-Type": "application/json"
+            // "Content-Type": "text/html"
+            // "Content-Type":"multipart/form-data"
+        }
         return config;
     }, error => {
         console.log('error', error);
@@ -32,16 +33,15 @@ axios.interceptors.response.use(
         if (res.data.code == 200) {
             return res.data;
         }
-        // else {
-            // context.$alert(res.data.message,'提示',{
-            //     confirmButtonText: '确定'
-            // }).then(()=>{
-            //     if(res.data.code == '1005') {
-            //         context.$router.replace({path:'/login'});
-            //     }
-            //     // context.$router.replace({path:'/login'});
-            // });
-        // }
+        else {
+            context.$alert(res.data.message,'提示',{
+                confirmButtonText: '确定'
+            }).then(()=>{
+                if(res.data.code == '1004') {
+                    context.$router.replace({path:'/login'});
+                }
+            });
+        }
     },
     err => {
         console.dir('err', err);
@@ -91,7 +91,7 @@ let requestLoading = (url, method, params) => {
         params,
         withCredentials: true,
         data: params,
-        timeout: 120000
+        timeout: 120000,
     })
 };
 
@@ -184,6 +184,17 @@ export const queryMovingAccount = (page, start_time, end_time, lg_type) => {
 export const updateKey = (secure_key) => {
     return requestLoading(`${Prefix}act=merchant_info&op=setkey&client_type=ajax&secure_key=${secure_key}`, 'post')
 }
+// 上传文件
+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}`,
+        withCredentials: true,
+        data: voucher,
+        timeout: 120000,
+    })
+}
 // 余额列表
 // export const balanceList = (params) => {
 //     return requestLoading(`${Prefix}/balanceList`, 'get', params)

+ 26 - 18
src/pages/subPages/view.vue

@@ -17,15 +17,18 @@
         <el-form-item label="商户号:">
             {{merchantsCode}}
         </el-form-item>
+        <el-form-item label="商户名称:">
+            {{merchantsName}}
+        </el-form-item>
         <el-form-item label="密钥设置:">
             <el-input v-model="securityKey" autocomplete="off" style="width: 300px;margin-right:10px"></el-input>
             <el-button type="primary" size="small" @click="updateKey">确定</el-button>
         </el-form-item>
         <el-form-item label="ip白名单:" >
-            <div v-for="(item, idx) in ipList" :key="idx">
-                <el-input style="width: 300px;margin-bottom: 10px;margin-right: 10px;" v-model="item.ip"></el-input>
-                <i v-if="idx === 0" class="el-icon-circle-plus-outline" style="color:#409EFF;" @click="add"></i>
-                <i v-else class="el-icon-remove-outline" style="color:#F56C6C;" @click="del(idx)"></i>
+            <div v-for="item in ipList" :key="item">
+                <el-input style="width: 300px;margin-bottom: 10px;margin-right: 10px;" :value="item"></el-input>
+                <i v-if="item === '172.22.0.1'" class="el-icon-circle-plus-outline" style="color:#409EFF;" @click="add"></i>
+                <i v-else class="el-icon-remove-outline" style="color:#F56C6C;" @click="del(item)"></i>
             </div>
         </el-form-item>
     </el-form>
@@ -45,9 +48,9 @@
 </template>
 
 <script>
-// getIpList获取Ip列表 delIpList-删除 addIp-添加
+// getIpList获取Ip列表 delIpList-删除 addIp-添加 getUserInfo-用户信息
 import {
-    getIpList,
+    // getIpList,
     delIpList,
     addIp,
     getUserInfo,
@@ -83,27 +86,29 @@ export default {
             repeatIp: false,
             // 商户号
             merchantsCode: '',
+            // 商户名称
+            merchantsName: '',
             // 密钥
             securityKey: ''
         };
     },
     created() {
-        this.getIpList();
+        // this.getIpList();
         this.getUserInfo()
     },
     computed: {
     },
     methods: {
         // 获取Ip列表
-        async getIpList() {
-            const res = await getIpList()
-            console.log('获取ip列表', res);
-            this.ipList = res.datas
+        // async getIpList() {
+        //     const res = await getIpList()
+        //     console.log('获取ip列表', res);
+        //     this.ipList = res.datas
 
-        },
+        // },
         // 删除
-        del(idx) {
-            console.log('idx', idx);
+        del(ip) {
+            console.log('ip', ip);
             // 提示
             this.$confirm("确认删除该ip?", {
                 confirmButtonText: "确定",
@@ -112,7 +117,7 @@ export default {
             })
             .then(async () => {
                 // 调用删除接口
-                const res = await delIpList({ip_key: idx})
+                const res = await delIpList({ip: ip})
                 console.log('删除ip', res);
                 if (res.code == 200) {
                     // 提示
@@ -121,7 +126,7 @@ export default {
                         type: 'success'
                     });
                     // 获取列表
-                    this.getIpList()
+                    this.getUserInfo()
                 }
             })
             .catch(() => {
@@ -147,6 +152,7 @@ export default {
                         this.ipList.forEach(item => {
                             this.repeatIp = item.ip == this.ipFormData.name
                         })
+                        this.repeatIp = this.ipList.find((item => item == this.ipFormData.name))
                     }
                     if (this.repeatIp) {
                         this.$message.error('该ip已存在')
@@ -160,7 +166,7 @@ export default {
                             message: '添加成功',
                             type: 'success'
                         });
-                        this.getIpList()
+                        this.getUserInfo()
                         this.dialogFormVisible = false
                         this.ipFormData.name = ''
                     }
@@ -171,7 +177,9 @@ export default {
         async getUserInfo() {
             const res = await getUserInfo()
             console.log('个人中心', res);
-            this.merchantsCode = res.datas.admin_id
+            this.merchantsCode = res.datas.mchid
+            this.merchantsName = res.datas.name
+            this.ipList = res.datas.ips
         },
         // 设置密钥
         async updateKey() {