Ver código fonte

接口重新封装

dujingxian 4 anos atrás
pai
commit
1b618c03c0

+ 132 - 17
src/api/index.js

@@ -5,6 +5,7 @@ import context from '../main';
 
 // axios.defaults.timeout = 3000000;
 // let loadinginstace;
+// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
 
 axios.interceptors.request.use(
     config => {
@@ -118,7 +119,17 @@ export const testRequest = () => {
 //登录
 export const login = (params) => {
     console.log(`${Prefix}act=merchant_login&op=login`)
-    return requestLoading(`${Prefix}act=merchant_login&op=login&client_type=ajax`, 'post', params)
+    // return requestLoading(`${Prefix}act=merchant_login&op=login&client_type=ajax`, 'post', params)
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_login&op=login&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 
 //登出
@@ -133,17 +144,47 @@ export const getIpList = () => {
 
 // 删除ip列表
 export const delIpList = (params) => {
-    return requestLoading(`${Prefix}act=merchant_info&op=ipdel&client_type=ajax`, 'post', params)
+    // return requestLoading(`${Prefix}act=merchant_info&op=ipdel&client_type=ajax`, 'post', params)
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_info&op=ipdel&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 
 // 添加ip
-export const addIp = (ip) => {
-    return requestLoading(`${Prefix}act=merchant_info&op=addip&client_type=ajax&ip=${ip}`, 'post')
+export const addIp = (params) => {
+    // return requestLoading(`${Prefix}act=merchant_info&op=addip&client_type=ajax&ip=${ip}`, 'post')
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_info&op=addip&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 
 // 获取订单统计列表
-export const getOrderList = (page) => {
-    return requestLoading(`${Prefix}act=merchant_order&op=list&client_type=ajax&curpage=${page}`, 'post')
+export const getOrderList = (params) => {
+    // return requestLoading(`${Prefix}act=merchant_order&op=list&client_type=ajax&curpage=${page}`, 'post')
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_order&op=list&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+        },
+        data: params,
+        timeout: 120000,
+    })
 }
 
 /**
@@ -153,13 +194,34 @@ export const getOrderList = (page) => {
  * @param {*} end_time 结束时间
  * @param {*} card_type 充值类型
  */
-export const queryList = (page,start_time, end_time, card_type) => {
-    return requestLoading(`${Prefix}act=merchant_order&op=list&client_type=ajax&curpage=${page}&start_time=${start_time}&end_time=${end_time}&card_type=${card_type}`, 'post')
+// export const queryList = (page, start_time, end_time, card_type) => {
+export const queryList = (params) => {
+    // return requestLoading(`${Prefix}act=merchant_order&op=list&client_type=ajax&curpage=${page}&start_time=${start_time}&end_time=${end_time}&card_type=${card_type}`, 'post')
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_order&op=list&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 
 // 修改管理员密码
 export const editPwd = (params) => {
-    return requestLoading(`${Prefix}act=merchant_info&op=modifypw&client_type=ajax`, 'post', params)
+    // return requestLoading(`${Prefix}act=merchant_info&op=modifypw&client_type=ajax`, 'post', params)
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_info&op=modifypw&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 
 // 个人中心
@@ -179,13 +241,35 @@ export const getMovingAccount = (page) => {
  * @param {*} lg_type 变更类型
  * @param {*} lg_order_sn 业务单号
  */
-export const queryMovingAccount = (page, start_time, end_time, lg_type) => {
-    return requestLoading(`${Prefix}act=merchant_info&op=pdlog&client_type=ajax&curpage=${page}&start_time=${start_time}&end_time=${end_time}&lg_type=${lg_type}`, 'post')
+// export const queryMovingAccount = (page, start_time, end_time, lg_type) => {
+export const queryMovingAccount = (params) => {
+    // return requestLoading(`${Prefix}act=merchant_info&op=pdlog&client_type=ajax&curpage=${page}&start_time=${start_time}&end_time=${end_time}&lg_type=${lg_type}`, 'post')
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_info&op=pdlog&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 
 // 设置密钥
-export const updateKey = (secure_key) => {
-    return requestLoading(`${Prefix}act=merchant_info&op=setkey&client_type=ajax&secure_key=${secure_key}`, 'post')
+// export const updateKey = (secure_key) => {
+export const updateKey = (params) => {
+    // return requestLoading(`${Prefix}act=merchant_info&op=setkey&client_type=ajax&secure_key=${secure_key}`, 'post')
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_info&op=pdlog&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 // 上传文件
 export const updateVoucher = (name) => {
@@ -212,7 +296,17 @@ export const updateVoucher = (name) => {
 
 // 上传凭证
 export const updateVoucherList = (params) => {
-    return requestLoading(`${Prefix}act=refill_evidence&op=add&client_type=ajax`, 'post', params)
+    // return requestLoading(`${Prefix}act=refill_evidence&op=add&client_type=ajax`, 'post', params)
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=refill_evidence&op=add&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 
 // 获取充值列表
@@ -220,8 +314,19 @@ export const getVoucherList = () => {
     return requestLoading(`${Prefix}act=refill_evidence&op=index&client_type=ajax`, 'post')
 }
 // 查询充值列表
-export const queryVoucherList = (page, start_time, end_time) => {
-    return requestLoading(`${Prefix}act=refill_evidence&op=index&client_type=ajax&curpage=${page}&start_time=${start_time}&end_time=${end_time}`, 'get')
+// export const queryVoucherList = (page, start_time, end_time) => {
+export const queryVoucherList = (params) => {
+    // return requestLoading(`${Prefix}act=refill_evidence&op=index&client_type=ajax&curpage=${page}&start_time=${start_time}&end_time=${end_time}`, 'get')
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=refill_evidence&op=index&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 
 // 获取充值金额
@@ -230,7 +335,17 @@ export const getRechargeAmount = () => {
 }
 // 油卡充值 cardno-卡号 amount-充值金额
 export const OilCardRecharge = (params) => {
-    return requestLoading(`${Prefix}act=merchant_refill&op=add&client_type=ajax`, 'post', params)
+    // return requestLoading(`${Prefix}act=merchant_refill&op=add&client_type=ajax`, 'post', params)
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_refill&op=add&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
 }
 // 余额列表
 // export const balanceList = (params) => {

+ 2 - 0
src/main.js

@@ -4,6 +4,8 @@ import '@/css/base.css';
 import 'element-ui/lib/theme-chalk/index.css';
 import App from './App.vue'
 import router from './router'
+import axios from 'axios'
+Vue.prototype.$axios = axios
 
 
 Vue.use(ElementUI);

+ 5 - 1
src/pages/index.vue

@@ -199,7 +199,11 @@ export default {
                     //         });
                     //     }
                     // });
-                    const res = await editPwd({new_pw: this.editForm.pwd,new_pw2: this.editForm.rePwd,})
+                    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({

+ 30 - 4
src/pages/login.vue

@@ -62,10 +62,14 @@ export default {
     onLogin(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          login({
-            name: this.ruleForm.name,
-            password: this.ruleForm.pwd,
-          }).then(res => {
+          let param = new URLSearchParams()
+          param.append('name', this.ruleForm.name)
+          param.append('password', this.ruleForm.pwd)
+          // login({
+          //   name: this.ruleForm.name,
+          //   password: this.ruleForm.pwd,
+          // })
+          login(param).then(res => {
             console.log('登录', res);
             if (res && res.code === 200) {
               this.$message({
@@ -79,6 +83,28 @@ export default {
               this.$router.replace({ path: "/" });
             }
           });
+
+          // var data = new URLSearchParams();
+          // data.append('name', this.ruleForm.name);
+          // data.append('password', this.ruleForm.pwd);
+          // this.$axios({
+          //   methods: 'post',
+          //   url: 'http://192.168.1.195/mobile/index.php?act=merchant_login&op=login&client_type=ajax',
+          //   data: {
+          //     name: this.ruleForm.name,
+          //     password: this.ruleForm.pwd
+          //   },
+          //   headers: {
+          //     "Content-Type": "application/x-www-form-urlencoded"
+          //   },
+          //   // data,
+          //   withCredentials: true,
+          //   timeout: 120000,
+          // })
+          // .then((res) => {
+          //   console.log('登录', res);
+          // })
+          
         }
       });
     },

+ 24 - 8
src/pages/subPages/balance.vue

@@ -242,7 +242,12 @@ export default {
                 this.pageNumber = page;
                 this.startTime = this.dataRange[0]/1000 || ''
                 this.endTime = this.dataRange[1]/1000 || ''
-                const res = await queryVoucherList(this.pageNumber,this.startTime, this.endTime)
+                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
@@ -253,7 +258,12 @@ export default {
         async onSearch() {
             this.startTime = this.dataRange[0]/1000 || ''
             this.endTime = this.dataRange[1]/1000 || ''
-            const res = await queryVoucherList(this.pageNumber,this.startTime, this.endTime)
+            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
@@ -418,12 +428,18 @@ export default {
 
             // 上传凭证列表
             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
-                })
+                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('上传成功')

+ 14 - 2
src/pages/subPages/message.vue

@@ -112,7 +112,13 @@ export default {
                 this.pageNumber = page;
                 this.startTime = this.dataRange[0]/1000 || ''
                 this.endTime = this.dataRange[1]/1000 || ''
-                const res = await queryMovingAccount(this.pageNumber,this.startTime, this.endTime, this.changeVal)
+                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
@@ -123,7 +129,13 @@ export default {
         async queryMovingAccount() {
             this.startTime = this.dataRange[0]/1000 || ''
             this.endTime = this.dataRange[1]/1000 || ''
-            const res = await queryMovingAccount(this.pageNumber,this.startTime, this.endTime, this.changeVal)
+            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

+ 8 - 4
src/pages/subPages/mobileCard.vue

@@ -248,10 +248,14 @@ export default {
       this.loading = true
       this.splitStr = this.input.toString()
       // cardno, amount this.splitStr, this.curMoney
-      const res = await OilCardRecharge({
-        cardno: this.splitStr,
-        amount: 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

+ 8 - 4
src/pages/subPages/oilCard.vue

@@ -264,10 +264,14 @@ export default {
       this.loading = true
       this.splitStr = this.input.toString()
       // cardno, amount
-      const res = await OilCardRecharge({
-        cardno: this.splitStr,
-        amount: 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

+ 23 - 8
src/pages/subPages/order.vue

@@ -4,7 +4,8 @@
         <el-date-picker
             v-model="dataRange"
             :clearable="false"
-            value-format="yyyy-MM-dd HH:mm:ss"
+            value-format="timestamp"
+            format="yyyy-MM-dd HH:mm:ss"
             type="datetimerange"
             range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
         <el-select v-model="RechargeType" placeholder="--充值卡类型--" style="margin-left: 10px">
@@ -104,7 +105,9 @@ export default {
     methods: {
         // 获取订单列表
         async getOrderList () {
-            const res = await getOrderList(1)
+            let param = new URLSearchParams()
+            param.append('page', 10)
+            const res = await getOrderList(param)
             console.log('订单列表', res);
             if (res && res.code == 200) {
                 this.tableData = res.datas.data
@@ -128,9 +131,15 @@ export default {
         // },
         // 查询
         async queryList() {
-            const startTime = this.dataRange[0] || ''
-            const endTime = this.dataRange[1] || ''
-            const res = await queryList(this.pageNumber, startTime, endTime, this.RechargeType)
+            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
@@ -154,9 +163,15 @@ export default {
                 //     // this.getActionLogList();
                 //     this.getOrderList(this.pageNumber)
                 // }, 0);
-                const startTime = this.dataRange[0]
-                const endTime = this.dataRange[1]
-                const res = await queryList(this.pageNumber, startTime, endTime, this.RechargeType)
+                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

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

@@ -156,7 +156,10 @@ export default {
             })
             .then(async () => {
                 // 调用删除接口
-                const res = await delIpList({ip: ip})
+                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) {
                     // 提示
@@ -198,7 +201,9 @@ export default {
                         return
                     }
                     // console.log('校验通过');
-                    const res = await addIp(this.ipFormData.name)
+                    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({
@@ -228,9 +233,15 @@ export default {
         async updateKey() {
             let res 
             if (this.useKey == '1') {
-                res = await updateKey(this.formKey.ReSecurityKey)
+                let param = new URLSearchParams()
+                param.append('secure_key', this.formKey.ReSecurityKey)
+                // res = await updateKey(this.formKey.ReSecurityKey)
+                res = await updateKey(param)
             } else {
-                res = await updateKey(this.formKey.securityKey)
+                let param = new URLSearchParams()
+                param.append('secure_key', this.formKey.securityKey)
+                // res = await updateKey(this.formKey.securityKey)
+                res = await updateKey(param)
             }
             console.log('密钥', res);
             if (res && res.code == 200) {