浏览代码

给所有接口调用添加try

dujingxian 4 年之前
父节点
当前提交
d9750cc1af

+ 4 - 4
src/api/index.js

@@ -47,7 +47,7 @@ axios.interceptors.response.use(
         }
     },
     err => {
-        console.log('err', err);
+        // console.log('err', err);
         // loading.close();
         // if (err.message.includes('timeout')) {
         //     err.message = '请求超时';
@@ -127,7 +127,7 @@ export const login = (params) => {
         withCredentials: true,
         headers: {
             "Content-Type": "application/x-www-form-urlencoded"
-          },
+        },
         data: params,
         timeout: 120000,
     })
@@ -277,8 +277,8 @@ 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`,
-        url: `https://www.xyzshops.cn/upfile.php`,
+        url: `http://192.168.1.195/upfile.php`,
+        // url: `https://www.xyzshops.cn/upfile.php`,
         // withCredentials: true,
         data: name,
         timeout: 120000,

+ 21 - 16
src/pages/index.vue

@@ -197,22 +197,27 @@ export default {
                     //         });
                     //     }
                     // });
-                    let param = new URLSearchParams()
-                    param.append('new_pw', this.editForm.pwd)
-                    param.append('new_pw2', this.editForm.rePwd)
-                    // const res = await editPwd({new_pw: this.editForm.pwd,new_pw2: this.editForm.rePwd,})
-                    const res = await editPwd(param)
-                    console.log('修改密码', res);
-                    if (res && res.message == "成功") {
-                        this.$message({
-                            message: "修改成功",
-                            type: "success",
-                            center: true,
-                            duration: 1000,
-                            onClose: () => {
-                                this.onCloseEditDialog();
-                            },
-                        });
+                    try {
+                        let param = new URLSearchParams()
+                        param.append('new_pw', this.editForm.pwd)
+                        param.append('new_pw2', this.editForm.rePwd)
+                        // const res = await editPwd({new_pw: this.editForm.pwd,new_pw2: this.editForm.rePwd,})
+                        const res = await editPwd(param)
+                        console.log('修改密码', res);
+                        if (res && res.message == "成功") {
+                            this.$message({
+                                message: "修改成功",
+                                type: "success",
+                                center: true,
+                                duration: 1000,
+                                onClose: () => {
+                                    this.onCloseEditDialog();
+                                },
+                            });
+                        }
+                    } catch (error) {
+                        console.log(error);
+                        this.$message.error('修改失败')
                     }
                 } else {
                     console.log("error submit!!");

+ 78 - 62
src/pages/subPages/balance.vue

@@ -61,8 +61,9 @@
 
     <!-- 查看弹层 -->
     <el-dialog title="充值凭证" :visible.sync="seeDialogVisible" width="20%" class="seeDialog">
+        <!-- display: flex;align-items: center;margin: auto; -->
         <el-image 
-            style="width: 200px; height: 200px"
+            style="width: 200px;height:200px;"
             :src="url" 
             :preview-src-list="srcList">
         </el-image>
@@ -236,11 +237,15 @@ export default {
         },
         // 获取充值列表
         async getVoucherList() {
-            const res = await getVoucherList()
-            console.log('充值', res);
-            if (res && res.code == 200) {
-                this.tableData = res.datas.data
-                this.total = res.datas.total * this.pageSize
+            try {
+                const res = await getVoucherList()
+                console.log('充值', res);
+                if (res && res.code == 200) {
+                    this.tableData = res.datas.data
+                    this.total = res.datas.total * this.pageSize
+                }
+            } catch (error) {
+                console.log(error);
             }
         },
         // 分页
@@ -248,11 +253,32 @@ export default {
             if (page == this.pageNumber) {
                 return;
             } else {
-                this.pageNumber = page;
+                try {
+                    this.pageNumber = page;
+                    this.startTime = this.dataRange[0]/1000 || ''
+                    this.endTime = this.dataRange[1]/1000 || ''
+                    let param = new URLSearchParams()
+                    param.append('curpage', this.pageNumber)
+                    param.append('start_time', this.startTime)
+                    param.append('end_time', this.endTime)
+                    // const res = await queryVoucherList(this.pageNumber,this.startTime, this.endTime)
+                    const res = await queryVoucherList(param)
+                    console.log('查询动账', res);
+                    if (res && res.code == 200) {
+                        this.tableData = res.datas.data
+                    }
+                } catch (error) {
+                    console.log(error);
+                }
+            }
+        },
+        // 搜索
+        async onSearch() {
+            try {
                 this.startTime = this.dataRange[0]/1000 || ''
                 this.endTime = this.dataRange[1]/1000 || ''
                 let param = new URLSearchParams()
-                param.append('curpage', this.pageNumber)
+                param.append('curpage', 1)
                 param.append('start_time', this.startTime)
                 param.append('end_time', this.endTime)
                 // const res = await queryVoucherList(this.pageNumber,this.startTime, this.endTime)
@@ -260,23 +286,10 @@ export default {
                 console.log('查询动账', res);
                 if (res && res.code == 200) {
                     this.tableData = res.datas.data
+                    this.total = res.datas.total * this.pageSize
                 }
-            }
-        },
-        // 搜索
-        async onSearch() {
-            this.startTime = this.dataRange[0]/1000 || ''
-            this.endTime = this.dataRange[1]/1000 || ''
-            let param = new URLSearchParams()
-            param.append('curpage', 1)
-            param.append('start_time', this.startTime)
-            param.append('end_time', this.endTime)
-            // const res = await queryVoucherList(this.pageNumber,this.startTime, this.endTime)
-            const res = await queryVoucherList(param)
-            console.log('查询动账', res);
-            if (res && res.code == 200) {
-                this.tableData = res.datas.data
-                this.total = res.datas.total * this.pageSize
+            } catch (error) {
+                console.log(error);
             }
         },
         // 重置
@@ -327,46 +340,40 @@ export default {
         },
         // 上传按钮
         async onSubmit() {
+            try {
+                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);
+                if (res && res.code == 200) {
+                    this.file_path = res.datas.file_path
+                }
 
-            //关于formdata使用方式请自行搜索
-            let uploadForm = document.getElementById("uploadForm");
-            console.log('uploadForm',uploadForm);
-            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);
-            if (res && res.code == 200) {
-                this.file_path = res.datas.file_path
+                // 上传凭证列表
+                this.$nextTick(async () => {
+                    let param = new URLSearchParams()
+                    param.append('amount', this.formData.amount)
+                    param.append('bank_username', this.formData.bank_username)
+                    param.append('bank_name', this.formData.bank_name)
+                    param.append('voucher', this.file_path)
+                    // const result = await updateVoucherList({
+                    //     amount: this.formData.amount,
+                    //     bank_username: this.formData.bank_username,
+                    //     bank_name: this.formData.bank_name,
+                    //     voucher: this.file_path
+                    // })
+                    const result = await updateVoucherList(param)
+                    console.log('result', result);
+                    if (result && result.code == 200) {
+                        this.$message.success('上传成功')
+                        this.uploadDialogVisible = false
+                        this.getVoucherList()
+                    }
+                })
+            } catch (error) {
+                console.log(error);
             }
-
-            // const res = await this.$axios.post('http://192.168.1.195/upfile.php', {
-            //     name: fd
-            // })
-            // console.log('res', res);
-
-            // 上传凭证列表
-            this.$nextTick(async () => {
-                let param = new URLSearchParams()
-                param.append('amount', this.formData.amount)
-                param.append('bank_username', this.formData.bank_username)
-                param.append('bank_name', this.formData.bank_name)
-                param.append('voucher', this.file_path)
-                // const result = await updateVoucherList({
-                //     amount: this.formData.amount,
-                //     bank_username: this.formData.bank_username,
-                //     bank_name: this.formData.bank_name,
-                //     voucher: this.file_path
-                // })
-                const result = await updateVoucherList(param)
-                console.log('result', result);
-                if (result && result.code == 200) {
-                    this.$message.success('上传成功')
-                    this.uploadDialogVisible = false
-                    this.getVoucherList()
-
-                }
-            })
         }
     },
 }
@@ -409,6 +416,15 @@ export default {
 .updata /deep/ .el-dialog__footer {
     text-align: center;
 }
+/* 查看弹层 图片居中 */
+.seeDialog .el-image {
+    display: flex;
+    align-items: center;
+    margin: auto;
+}
+.seeDialog /deep/.el-image__inner {
+    height: auto;
+}
 </style>
 <style>
 .el-main {

+ 28 - 20
src/pages/subPages/home.vue

@@ -181,30 +181,38 @@ export default {
       }
       console.log('dateArr', dateArr);
       option.xAxis[0].data = dateArr
-      const res = await getHomeData()
-      console.log('首页', res);
-      if (res && res.code == 200) {
-        let weekOrderCount = res.datas.weeksStatistics
-        weekOrderCount.forEach(item => this.weekOrderCount.push(item.count))
-        option.series[0].data = this.weekOrderCount
-        myChart.setOption(option)
-        setTimeout(function (){
-          window.onresize = function () {
-            myChart.resize();
-          }
-        },50)
+      try {
+        const res = await getHomeData()
+        console.log('首页', res);
+        if (res && res.code == 200) {
+          let weekOrderCount = res.datas.weeksStatistics
+          weekOrderCount.forEach(item => this.weekOrderCount.push(item.count))
+          option.series[0].data = this.weekOrderCount
+          myChart.setOption(option)
+          setTimeout(function (){
+            window.onresize = function () {
+              myChart.resize();
+            }
+          },50)
+        }
+      } catch (error) {
+        console.log(error);
       }
     },
     // 获取数据
     async getHomeData() {
-      const res = await getHomeData()
-      console.log('首页', res);
-      if (res && res.code == 200) {
-        this.merchantData = res.datas.merchant_info
-        this.todayOrder = res.datas.todayStatistics
-        let weekOrderCount = res.datas.weeksStatistics
-        weekOrderCount.forEach(item => this.weekOrderCount.push(item.count))
-        console.log('weekOrderCount', weekOrderCount);
+      try {
+        const res = await getHomeData()
+        console.log('首页', res);
+        if (res && res.code == 200) {
+          this.merchantData = res.datas.merchant_info
+          this.todayOrder = res.datas.todayStatistics
+          let weekOrderCount = res.datas.weeksStatistics
+          weekOrderCount.forEach(item => this.weekOrderCount.push(item.count))
+          console.log('weekOrderCount', weekOrderCount);
+        }
+      } catch (error) {
+        console.log(error);
       }
     }
   }

+ 47 - 41
src/pages/subPages/message.vue

@@ -15,24 +15,7 @@
         <el-button type="primary" style="margin-left:10px;" @click="queryMovingAccount">查询</el-button>
         <el-button style="margin-left:10px;" type="danger" @click="onReset">重置</el-button>
     </div>
-    <!-- <div style="margin:10px 0;">
-        <el-form :inline="true">
-            <el-form-item label="选择柜子">
-                <el-select v-model="cabinetValue" placeholder="请选择" @change="onChangeCabinet">
-                    <el-option v-for="item in cabinetOptions" :key="item.id" :label="item.alias" :value="item.id"></el-option>
-                </el-select>
-            </el-form-item>
-            <el-form-item label="选择箱子">
-                <el-select v-model="boxValue" placeholder="请选择">
-                    <el-option v-for="item in boxOptions" :key="item.box_number" :label="item.box_number" :value="item.box_number"></el-option>
-                </el-select>
-            </el-form-item>
-            <el-form-item>
-                <el-button style="margin-left:10px;" type="primary" @click="onSearch">查询</el-button>
-            </el-form-item>
-        </el-form>
-    </div> -->
-    <el-table :data="tableData" border style="width:100%">
+    <el-table :data="tableData" border style="width:100%" v-loading="isLoading">
         <!-- <el-table-column align="center" type="index" width="50" label="序号" /> -->
         <!-- <el-table-column align="center" prop="lg_order_sn" label="业务订单号"></el-table-column> -->
         <el-table-column align="left" prop="lg_type_text" label="资金变动类型" width="200"></el-table-column>
@@ -84,7 +67,9 @@ export default {
             // 1-减款 2-加款
             changeVal: '',
             startTime: '',
-            endTime: ''
+            endTime: '',
+            // 是否正在加载
+            isLoading: false
         };
     },
     created() {
@@ -99,11 +84,18 @@ export default {
     methods: {
         // 获取实时动账
         async getMovingAccount() {
-            const res = await getMovingAccount(1)
-            console.log('动账', res);
-            if (res && res.code == 200) {
-                this.tableData = res.datas.data
-                this.total = res.datas.total * this.pageSize
+            this.isLoading = true
+            try {
+                const res = await getMovingAccount(1)
+                console.log('动账', res);
+                if (res && res.code == 200) {
+                    this.tableData = res.datas.data
+                    this.total = res.datas.total * this.pageSize
+                }
+                this.isLoading = false
+            } catch (error) {
+                console.log(error);
+                this.isLoading = false
             }
         },
         // 页码
@@ -111,9 +103,35 @@ export default {
             if (page == this.pageNumber) {
                 return;
             } else {
+                this.isLoading = true
                 this.pageNumber = page;
                 this.startTime = this.dataRange[0]/1000 || ''
                 this.endTime = this.dataRange[1]/1000 || ''
+                try {
+                    let param = new URLSearchParams()
+                    param.append('curpage', this.pageNumber)
+                    param.append('start_time', this.startTime)
+                    param.append('end_time', this.endTime)
+                    param.append('lg_type', this.changeVal)
+                    // const res = await queryMovingAccount(this.pageNumber,this.startTime, this.endTime, this.changeVal)
+                    const res = await queryMovingAccount(param)
+                    console.log('查询动账', res);
+                    if (res && res.code == 200) {
+                        this.tableData = res.datas.data
+                    }
+                    this.isLoading = false
+                } catch (error) {
+                    console.log(error);
+                    this.isLoading = false
+                }
+            }
+        },
+        // 查询
+        async queryMovingAccount() {
+            this.isLoading = true
+            this.startTime = this.dataRange[0]/1000 || ''
+            this.endTime = this.dataRange[1]/1000 || ''
+            try {
                 let param = new URLSearchParams()
                 param.append('curpage', this.pageNumber)
                 param.append('start_time', this.startTime)
@@ -124,24 +142,12 @@ export default {
                 console.log('查询动账', res);
                 if (res && res.code == 200) {
                     this.tableData = res.datas.data
+                    this.total = res.datas.total * this.pageSize
                 }
-            }
-        },
-        // 查询
-        async queryMovingAccount() {
-            this.startTime = this.dataRange[0]/1000 || ''
-            this.endTime = this.dataRange[1]/1000 || ''
-            let param = new URLSearchParams()
-            param.append('curpage', this.pageNumber)
-            param.append('start_time', this.startTime)
-            param.append('end_time', this.endTime)
-            param.append('lg_type', this.changeVal)
-            // const res = await queryMovingAccount(this.pageNumber,this.startTime, this.endTime, this.changeVal)
-            const res = await queryMovingAccount(param)
-            console.log('查询动账', res);
-            if (res && res.code == 200) {
-                this.tableData = res.datas.data
-                this.total = res.datas.total * this.pageSize
+                this.isLoading = false
+            } catch (error) {
+                console.log(error);
+                this.isLoading = false
             }
         },
         // 重置

+ 47 - 32
src/pages/subPages/mobileCard.vue

@@ -167,18 +167,24 @@ export default {
       // 判断是否有,或者;
       // console.log('newVal.substr(0,1)',newVal.substr(0,1) == ',');
       if (newVal.substr(0,1) == "," || newVal.substr(0,1) == "," || newVal.substr(0,1) == ";" || newVal.substr(0,1) == ";") {
-        this.codeStr = this.codeStr.replace(/[,,;;]/, "")
+        this.codeStr = this.codeStr.replace(/[,,;;]/g, "")
         console.log('替换', this.codeStr);
       }
       if (this.codeStr.length > 0) {
         // 手机卡11位
         if (this.codeStr.length < 11) {
-            this.$message.error('请输入合法手机号')
-            this.dialogVisible = false
-            return
-          }
-          this.splitStr = this.splitStr == '' ? this.splitStr.concat(this.codeStr.substring(0,11)) : this.splitStr.concat(',' + this.codeStr.substring(0,11))
-          this.codeStr = this.codeStr.substr(11)
+          this.$message.error('请输入合法手机号')
+          this.dialogVisible = false
+          return
+        }
+        console.log('手机号', /^1[3-9]\d{9}$/.test(Number(this.codeStr.substr(0,11))));
+        if (!/^1[3-9]\d{9}$/.test(Number(this.codeStr.substr(0,11)))) {
+          this.$message.error('请输入合法手机号')
+          this.dialogVisible = false
+          return
+        }
+        this.splitStr = this.splitStr == '' ? this.splitStr.concat(this.codeStr.substring(0,11)) : this.splitStr.concat(',' + this.codeStr.substring(0,11))
+        this.codeStr = this.codeStr.substr(11)
       }
       if (!newVal) {
         this.input = this.splitStr.split(',')
@@ -203,10 +209,14 @@ export default {
   methods: {
     // 获取充值金额
     async getRechargeAmount() {
-      const res = await getRechargeAmount()
-      console.log('充值金额', res);
-      if (res && res.code == 200) {
-        this.phone_amount = res.datas.phone_amount
+      try {
+        const res = await getRechargeAmount()
+        console.log('充值金额', res);
+        if (res && res.code == 200) {
+          this.phone_amount = res.datas.phone_amount
+        }
+      } catch (error) {
+        console.log(error);
       }
     },
     // 点击充值金额
@@ -291,28 +301,33 @@ export default {
     async onSubmit() {
       this.dialogVisibleCard = false
       this.loading = true
-      this.splitStr = this.input.toString()
-      // cardno, amount this.splitStr, this.curMoney
-      let param = new URLSearchParams()
-      param.append('cardno', this.splitStr)
-      param.append('amount', this.curMoney)
-      // const res = await OilCardRecharge({
-      //   cardno: this.splitStr,
-      //   amount: this.curMoney
-      // })
-      const res = await OilCardRecharge(param)
-      console.log('手机卡充值', res);
-      if (res && res.code == 200) {
-        this.tableData = res.datas.data
-        this.all_no = res.datas.all_no
-        this.success_no = res.datas.success_no
-        this.error_no = res.datas.error_no
-        this.splitStr = ''
-        this.curMoney = ''
-        this.curBtn = ''
-        this.formData.code = ''
+      try {
+        this.splitStr = this.input.toString()
+        // cardno, amount this.splitStr, this.curMoney
+        let param = new URLSearchParams()
+        param.append('cardno', this.splitStr)
+        param.append('amount', this.curMoney)
+        // const res = await OilCardRecharge({
+        //   cardno: this.splitStr,
+        //   amount: this.curMoney
+        // })
+        const res = await OilCardRecharge(param)
+        console.log('手机卡充值', res);
+        if (res && res.code == 200) {
+          this.tableData = res.datas.data
+          this.all_no = res.datas.all_no
+          this.success_no = res.datas.success_no
+          this.error_no = res.datas.error_no
+          this.splitStr = ''
+          this.curMoney = ''
+          this.curBtn = ''
+          this.formData.code = ''
+        }
+        this.loading = false
+      } catch (error) {
+        console.log(error);
+        this.loading = false
       }
-      this.loading = false
     },
   }
 }

+ 34 - 25
src/pages/subPages/oilCard.vue

@@ -213,10 +213,14 @@ export default {
   methods: {
     // 获取充值金额
     async getRechargeAmount() {
-      const res = await getRechargeAmount()
-      console.log('充值金额', res);
-      if (res && res.code == 200) {
-        this.oil_amount = res.datas.oil_amount
+      try {
+        const res = await getRechargeAmount()
+        console.log('充值金额', res);
+        if (res && res.code == 200) {
+          this.oil_amount = res.datas.oil_amount
+        }
+      } catch (error) {
+        console.log(error);
       }
     },
     // 点击充值金额
@@ -300,28 +304,33 @@ export default {
     async onSubmit() {
       this.dialogVisibleCard = false
       this.loading = true
-      this.splitStr = this.input.toString()
-      // cardno, amount
-      let param = new URLSearchParams()
-      param.append('cardno', this.splitStr)
-      param.append('amount', this.curMoney)
-      // const res = await OilCardRecharge({
-      //   cardno: this.splitStr,
-      //   amount: this.curMoney
-      // })
-      const res = await OilCardRecharge(param)
-      console.log('油卡充值', res);
-      if (res && res.code == 200) {
-        this.tableData = res.datas.data
-        this.all_no = res.datas.all_no
-        this.success_no = res.datas.success_no
-        this.error_no = res.datas.error_no
-        this.splitStr = ''
-        this.curMoney = ''
-        this.curBtn = ''
-        this.formData.code = ''
+      try {
+        this.splitStr = this.input.toString()
+        // cardno, amount
+        let param = new URLSearchParams()
+        param.append('cardno', this.splitStr)
+        param.append('amount', this.curMoney)
+        // const res = await OilCardRecharge({
+        //   cardno: this.splitStr,
+        //   amount: this.curMoney
+        // })
+        const res = await OilCardRecharge(param)
+        console.log('油卡充值', res);
+        if (res && res.code == 200) {
+          this.tableData = res.datas.data
+          this.all_no = res.datas.all_no
+          this.success_no = res.datas.success_no
+          this.error_no = res.datas.error_no
+          this.splitStr = ''
+          this.curMoney = ''
+          this.curBtn = ''
+          this.formData.code = ''
+        }
+        this.loading = false
+      } catch (error) {
+        console.log(error);
+        this.loading = false
       }
-      this.loading = false
     },
     // 分页
     async onPageChange(page) {

+ 53 - 44
src/pages/subPages/order.vue

@@ -21,7 +21,7 @@
         <el-button style="margin-left:10px;" type="danger" @click="onReset">重置</el-button>
     </el-header>
    
-    <el-table :data="tableData" border style="width: 1561px; margin-top:20px">
+    <el-table :data="tableData" border style="width: 1561px; margin-top:20px" v-loading="isLoading">
         <el-table-column align="left" type="index" width="50" label="序号" />
         <el-table-column align="left" prop="mch_order" width="200" label="客户单号"></el-table-column>
         <el-table-column align="left" prop="card_no" width="180" label="卡号"></el-table-column>
@@ -116,8 +116,9 @@ export default {
             // 充值类型 常量
             moneyType,
             // 充值
-            RechargeType: ''
-
+            RechargeType: '',
+            // 是否正在加载
+            isLoading: false
         };
     },
     created () {
@@ -127,45 +128,46 @@ export default {
     methods: {
         // 获取订单列表
         async getOrderList () {
-            let param = new URLSearchParams()
-            param.append('page', 50)
-            const res = await getOrderList(param)
-            console.log('订单列表', res);
-            if (res && res.code == 200) {
-                this.tableData = res.datas.data
-                this.total = res.datas.total * this.pageSize
+            this.isLoading = true
+            try {
+                let param = new URLSearchParams()
+                param.append('page', 50)
+                const res = await getOrderList(param)
+                console.log('订单列表', res);
+                if (res && res.code == 200) {
+                    this.tableData = res.datas.data
+                    this.total = res.datas.total * this.pageSize
+                }
+                this.isLoading = false
+            } catch (error) {
+                console.log(error);
+                this.isLoading = false
             }
             // const res = await getIp()
             // console.log('res', res);
         },
-        // getActionLogList() {
-        //     const _self = this;
-        //     actionLogList({
-        //         pageSize: _self.pageSize,
-        //         pageNumber: _self.pageNumber,
-        //     }).then((res) => {
-        //         console.log(res);
-        //         if (res && res.msg == "ok") {
-        //             _self.total = res.data.total;
-        //             _self.tableData = [...res.data.rows];
-        //         }
-        //     });
-        // },
         // 查询
         async queryList() {
+            this.isLoading = true
             const startTime = this.dataRange[0]/1000 || ''
             const endTime = this.dataRange[1]/1000 || ''
-            let param = new URLSearchParams()
-            param.append('curpage', this.pageNumber)
-            param.append('start_time', startTime)
-            param.append('end_time', endTime)
-            param.append('card_type', this.RechargeType)
-            // const res = await queryList(this.pageNumber, startTime, endTime, this.RechargeType)
-            const res = await queryList(param)
-            console.log('查询订单', res);
-            if (res && res.code == 200) {
-                this.tableData = res.datas.data
-                this.total = res.datas.total * this.pageSize
+            try {
+                let param = new URLSearchParams()
+                param.append('curpage', this.pageNumber)
+                param.append('start_time', startTime)
+                param.append('end_time', endTime)
+                param.append('card_type', this.RechargeType)
+                // const res = await queryList(this.pageNumber, startTime, endTime, this.RechargeType)
+                const res = await queryList(param)
+                console.log('查询订单', res);
+                if (res && res.code == 200) {
+                    this.tableData = res.datas.data
+                    this.total = res.datas.total * this.pageSize
+                }
+                this.isLoading = false
+            } catch (error) {
+                console.log(error);
+                this.isLoading = false
             }
         },
         // 重置
@@ -180,6 +182,7 @@ export default {
             if (page == this.pageNumber) {
                 return;
             } else {
+                this.isLoading = true
                 this.pageNumber = page;
                 // setTimeout(() => {
                 //     // this.getActionLogList();
@@ -187,16 +190,22 @@ export default {
                 // }, 0);
                 const startTime = this.dataRange[0]/1000 || ''
                 const endTime = this.dataRange[1]/1000 || ''
-                let param = new URLSearchParams()
-                param.append('curpage', this.pageNumber)
-                param.append('start_time', startTime)
-                param.append('end_time', endTime)
-                param.append('card_type', this.RechargeType)
-                // const res = await queryList(this.pageNumber, startTime, endTime, this.RechargeType)
-                const res = await queryList(param)
-                console.log('查询订单', res);
-                if (res && res.code == 200) {
-                    this.tableData = res.datas.data
+                try {
+                    let param = new URLSearchParams()
+                    param.append('curpage', this.pageNumber)
+                    param.append('start_time', startTime)
+                    param.append('end_time', endTime)
+                    param.append('card_type', this.RechargeType)
+                    // const res = await queryList(this.pageNumber, startTime, endTime, this.RechargeType)
+                    const res = await queryList(param)
+                    console.log('查询订单', res);
+                    if (res && res.code == 200) {
+                        this.tableData = res.datas.data
+                    }
+                    this.isLoading = false
+                } catch (error) {
+                    console.log(error);
+                    this.isLoading = false
                 }
             }
         },

+ 72 - 40
src/pages/subPages/view.vue

@@ -164,19 +164,26 @@ export default {
             })
             .then(async () => {
                 // 调用删除接口
-                let param = new URLSearchParams()
-                param.append('ip', ip)
-                // const res = await delIpList({ip: ip})
-                const res = await delIpList(param)
-                console.log('删除ip', res);
-                if (res && res.code == 200) {
-                    // 提示
-                    this.$message({
-                        message: '删除成功',
-                        type: 'success'
-                    });
-                    // 获取列表
-                    this.getUserInfo()
+                try {
+                    let param = new URLSearchParams()
+                    param.append('ip', ip)
+                    // const res = await delIpList({ip: ip})
+                    const res = await delIpList(param)
+                    console.log('删除ip', res);
+                    if (res && res.code == 200) {
+                        // 提示
+                        this.$message({
+                            message: '删除成功',
+                            type: 'success'
+                        });
+                        // 获取列表
+                        this.getUserInfo()
+                    } else {
+                        this.$message.error('删除失败')
+                    }
+                } catch (error) {
+                    console.log(error);
+                    this.$message.error('删除失败')
                 }
             })
             .catch(() => {
@@ -209,33 +216,48 @@ export default {
                         return
                     }
                     // console.log('校验通过');
-                    let param = new URLSearchParams()
-                    param.append('ip', this.ipFormData.name)
-                    const res = await addIp(param)
-                    console.log('添加ip', res);
-                    if (res && res.code == 200) {
-                        this.$message({
-                            message: '添加成功',
-                            type: 'success'
-                        });
-                        this.getUserInfo()
+                    try {
+                        let param = new URLSearchParams()
+                        param.append('ip', this.ipFormData.name)
+                        const res = await addIp(param)
+                        console.log('添加ip', res);
+                        if (res && res.code == 200) {
+                            this.$message({
+                                message: '添加ip成功',
+                                type: 'success'
+                            });
+                            this.getUserInfo()
+                            // this.dialogFormVisible = false
+                            // this.ipFormData.name = ''
+                        } else {
+                            this.$message.error('添加ip失败')
+                        } 
+                        this.dialogFormVisible = false
+                        this.ipFormData.name = ''
+                    } catch (error) {
+                        console.log(error);
                         this.dialogFormVisible = false
                         this.ipFormData.name = ''
+                        this.$message.error('添加ip失败')
                     }
                 }
             });
         },
         // 获取商户号
         async getUserInfo() {
-            const res = await getUserInfo()
-            console.log('个人中心', res);
-            if (res && res.code == 200) {
-                this.merchantsCode = res.datas.mchid
-                this.merchantsName = res.datas.name
-                this.ipList = res.datas.ips
-                this.alarm_amount = res.datas.alarm_amount
-                this.useKey = res.datas.use_key
-                this.available_predeposit = res.datas.member.available_predeposit
+            try {
+                const res = await getUserInfo()
+                console.log('个人中心', res);
+                if (res && res.code == 200) {
+                    this.merchantsCode = res.datas.mchid
+                    this.merchantsName = res.datas.name
+                    this.ipList = res.datas.ips
+                    this.alarm_amount = res.datas.alarm_amount
+                    this.useKey = res.datas.use_key
+                    this.available_predeposit = res.datas.member.available_predeposit
+                }
+            } catch (error) {
+                console.log(error);
             }
         },
         // 设置密钥
@@ -244,19 +266,29 @@ export default {
             this.$refs.keyForm.validate(async(valid) => {
                 if (valid) {
                     if (this.useKey == '1') {
-                        let param = new URLSearchParams()
-                        param.append('secure_key', this.formKey.ReSecurityKey)
-                        // res = await updateKey(this.formKey.ReSecurityKey)
-                        res = await updateKey(param)
+                        try {
+                            let param = new URLSearchParams()
+                            param.append('secure_key', this.formKey.ReSecurityKey)
+                            // res = await updateKey(this.formKey.ReSecurityKey)
+                            res = await updateKey(param)
+                        } catch (error) {
+                            console.log(error);
+                        }
                     } else {
-                        let param = new URLSearchParams()
-                        param.append('secure_key', this.formKey.securityKey)
-                        // res = await updateKey(this.formKey.securityKey)
-                        res = await updateKey(param)
+                        try {
+                            let param = new URLSearchParams()
+                            param.append('secure_key', this.formKey.securityKey)
+                            // res = await updateKey(this.formKey.securityKey)
+                            res = await updateKey(param)
+                        } catch (error) {
+                            console.log(error);
+                        }
                     }
                     console.log('密钥', res);
                     if (res && res.code == 200) {
                         this.$message.success('设置密钥成功')
+                    } else {
+                        this.$message.error('设置密钥失败')
                     }
                     this.formKey.ReSecurityKey = ''
                     this.formKey.securityKey = ''