Jelajahi Sumber

设置余额预警电话

dujingxian 4 tahun lalu
induk
melakukan
b646aff88b
3 mengubah file dengan 343 tambahan dan 48 penghapusan
  1. 27 0
      src/api/index.js
  2. 157 17
      src/pages/subPages/balance.vue
  3. 159 31
      src/pages/subPages/view.vue

+ 27 - 0
src/api/index.js

@@ -361,3 +361,30 @@ export const OilCardRecharge = (params) => {
 export const getHomeData = () => {
     return requestLoading(`${Prefix}act=merchant_info&op=home&client_type=ajax`, 'post')
 }
+
+// 添加余额预警电话
+export const addwphone = (params) => {
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_info&op=addwphone&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
+}
+// 删除余额预警电话
+export const delwphone = (params) => {
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_info&op=wphonedel&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
+}

+ 157 - 17
src/pages/subPages/balance.vue

@@ -1,9 +1,9 @@
 <template>
 <div>
-<el-card>
+<el-card class="bankDeposit">
     <el-row :gutter="20">
         <el-col :span="10">
-            <el-form label-width="110px" class="bankDeposit">
+            <el-form label-width="110px">
                 <el-form-item label="银行账号:">
                     11001079900053013913
                 </el-form-item>
@@ -19,7 +19,7 @@
             </el-form>
         </el-col>
         <el-col :span="14">
-            <el-form label-width="152px" class="bankDeposit" :model="balanceForm" :rules="balanceRules">
+            <el-form label-width="152px" :model="balanceForm" :rules="balanceRules">
                 <el-form-item label="当前余额:">
                     {{available_predeposit}}
                 </el-form-item>
@@ -37,6 +37,13 @@
                     <el-button type="primary" size="small" @click="onBalance">设置</el-button>
                     <span style="color:rgb(255 1 1 / 0.7);margin-left:10px;font-size:12px;">建议设置50000及以上余额预警</span>
                 </el-form-item>
+                <el-form-item label="余额预警电话:">
+                    <template v-if="this.cWarningList">
+                        <span style="display: block;height: 30px;">{{this.cWarningList}}</span>
+                        <span style="color:rgb(255 1 1 / 0.7);font-size:12px;display:block;line-height: 17px;">当账户所剩余额到达预警额度时,将会给此预留号码发送短信提示,每隔五分钟提醒一次,最多提示五次。</span>
+                    </template>
+                    <span v-else style="color:rgb(255 1 1 / 0.7);font-size:12px;line-height:20px;display: inline-block;margin-top: 9px;">请设置余额预警电话,当账户所剩余额达到预警额度时,将会给预留电话发送短信提醒,以免给您的业务带来不便。每隔五分钟提醒一次,最多提示五次。</span>
+                </el-form-item>
                 <el-form-item label="今日已申请成功次数:">
                     {{evidence_count}}
                 </el-form-item>
@@ -104,7 +111,6 @@
                 <el-input v-model.number="formData.amount" style="width:300px"></el-input>
             </el-form-item>
             <el-form-item label="开户人姓名: " prop="bank_username">
-                <!-- <el-input v-model="formData.bank_username" style="width:300px"></el-input> -->
                 <el-autocomplete
                     class="inline-input"
                     v-model="formData.bank_username"
@@ -116,7 +122,7 @@
             </el-form-item>
             <el-form-item label="银行名称: " prop="bank_name">
                 <!-- <el-input v-model="formData.bank_name" style="width:300px"></el-input> -->
-                <el-select v-model="formData.bank_name" placeholder="请选择" style="width:300px">
+                <!-- <el-select v-model="formData.bank_name" placeholder="请选择" style="width:300px">
                     <el-option
                         v-for="item in backName"
                         :key="item.value"
@@ -141,7 +147,15 @@
                             style="border:0;width:100%"
                             @click="showMoreBank=false">收起更多</el-button>
                     </template>
-                </el-select>
+                </el-select> -->
+                <el-autocomplete
+                    class="inline-input"
+                    v-model="formData.bank_name"
+                    :fetch-suggestions="queryBankName"
+                    @select="handleBankName"
+                    style="width:300px"
+                    :debounce="0"
+                    ></el-autocomplete>
             </el-form-item>
             <el-form-item label="充值凭证: ">
                 <input type="file" @change="getFileExpr($event)" ref="updataFile">
@@ -163,12 +177,40 @@
     </el-dialog>
 </el-container>
 </el-card>
+    <!-- 预警电话弹层-->
+    <!-- <el-dialog
+        title="余额预警电话 (最少设置一个,最多可以设置5个)"
+        :visible="warningDialogVisible"
+        width="30%"
+        @close="onCloseWarningDialog">
+        <el-form  ref="formWarning" :model="formWarning" :rules="ruleWarning">
+            <el-form-item prop="phoneOne">
+                <el-input v-model="formWarning.phoneOne"></el-input>
+            </el-form-item>
+            <el-form-item prop="phoneTwo">
+                <el-input v-model="formWarning.phoneTwo"></el-input>
+            </el-form-item>
+            <el-form-item prop="phoneThree">
+                <el-input v-model="formWarning.phoneThree"></el-input>
+            </el-form-item>
+            <el-form-item prop="phoneFove">
+                <el-input v-model="formWarning.phoneFove"></el-input>
+            </el-form-item>
+            <el-form-item prop="phoneFive">
+                <el-input v-model="formWarning.phoneFive"></el-input>
+            </el-form-item>
+        </el-form>
+        <span slot="footer" class="dialog-footer">
+            <el-button @click="onCloseWarningDialog">取 消</el-button>
+            <el-button type="primary" @click="onSubmitWarning">确 定</el-button>
+        </span>
+    </el-dialog> -->
 </div>
 </template>
 <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
 <script>
 // getVoucherList-获取充值列表 updateVoucher-上传凭证 queryVoucherList-查询充值 updateVoucherList-上传凭证列表
-// getUserInfo-用户信息(余额预警) onSubUser-设置余额预警
+// getUserInfo-用户信息(余额预警) onSubUser-设置余额预警 addwphone-添加预警电话
 import {
     // balanceList,
     getVoucherList,
@@ -176,9 +218,10 @@ import {
     queryVoucherList,
     updateVoucherList,
     getUserInfo,
-    onSubUser
+    onSubUser,
+    // addwphone
 } from "@/api";
-import { balanceType, backName, MoreBank } from '@/utils/constants'
+import { balanceType } from '@/utils/constants'
 export default {
     name: 'balance',
     data() {
@@ -283,12 +326,28 @@ export default {
             },
             // 近日已申请次数
             evidence_count: '',
-            // 银行名称常量
-            backName,
-            // 更多银行
-            MoreBank,
-            // 是否显示更多银行
-            showMoreBank: false
+            // 预警电话列表
+            warningList: [],
+            // 预警电话弹层
+            // warningDialogVisible: false,
+            // 预警表单
+            // formWarning: {
+            //     phoneOne: '',
+            //     phoneTwo: '',
+            //     phoneThree: '',
+            //     phoneFove: '',
+            //     phoneFive: '',
+            // },
+            // ruleWarning: {
+            //     phoneOne: [
+            //         { required: true, message: '请输入余额预警电话', trigger: 'blur' },
+            //         { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的电话', trigger: 'blur' }
+            //     ],
+            //     phoneTwo: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的电话', trigger: 'blur' }],
+            //     phoneThree: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的电话', trigger: 'blur' }],
+            //     phoneFove: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的电话', trigger: 'blur' }],
+            //     phoneFive: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的电话', trigger: 'blur' }],
+            // }
         };
     },
     mounted() {
@@ -297,6 +356,17 @@ export default {
         this.getVoucherList()
         this.getUserInfo()
     },
+    computed: {
+        cWarningList() {
+            let listStr = ''
+            this.warningList.forEach(item => {
+                if (item) {
+                    listStr += item + ', '
+                }
+            })
+            return listStr.substr(0, listStr.length-2)
+        }
+    },
     // 监听器
     watch: {
         dataRange(newVal) {
@@ -311,6 +381,12 @@ export default {
             if (newVal) {
                 this.$refs.formData.clearValidate(['bank_username'])
             }
+        },
+        'formData.bank_name' (newVal) {
+            // console.log('newVal', newVal);
+            if (newVal) {
+                this.$refs.formData.clearValidate(['bank_name'])
+            }
         }
     },
     methods: {
@@ -537,6 +613,7 @@ export default {
                     this.balanceForm.alarm_amount = res.datas.alarm_amount != 'null' ? res.datas.alarm_amount : ''
                     this.available_predeposit = res.datas.member.available_predeposit
                     this.evidence_count = res.datas.evidence_count
+                    this.warningList = res.datas.warning_phone
                 }
             } catch (error) {
                 console.log(error);
@@ -545,6 +622,10 @@ export default {
         // 设置余额预警
         async onBalance() {
             try {
+                // if (!this.warningList.length) {
+                //     this.warningDialogVisible = true
+                //     return
+                // }
                 let param = new URLSearchParams()
                 param.append('alarm_amount', this.balanceForm.alarm_amount)
                 const res = await onSubUser(param)
@@ -561,7 +642,7 @@ export default {
         // 开户人姓名
         querySearch(queryString, cb) {
             // 调用 callback 返回建议列表的数据
-            var list = []
+            let list = []
             if (this.tableData.length) {
                 list.push(Object.assign(this.tableData[0], {value: this.tableData[0].bank_username}))
                 // console.log('list', list);
@@ -572,7 +653,60 @@ export default {
         handleSelect (item) {
             // console.log('item', item);
             this.formData.bank_username = item.value
-        }
+        },
+        // 开户银行
+        queryBankName(queryString,cb) {
+            let list = []
+            if (this.tableData.length) {
+                list.push(Object.assign(this.tableData[0], {value: this.tableData[0].bank_name}))
+                // console.log('list', list);
+            }
+            cb(list);
+        },
+        handleBankName (item) {
+            // console.log('item', item);
+            this.formData.bank_name = item.value
+        },
+        // 关闭预警电话弹层
+        // onCloseWarningDialog() {
+        //     this.warningDialogVisible = false;
+        //     this.formWarning = {
+        //         phoneOne: '',
+        //         phoneTwo: '',
+        //         phoneThree: '',
+        //         phoneFove: '',
+        //         phoneFive: '',
+        //     },
+        //     this.$refs.formWarning.resetFields();
+        // },
+        // 提交预警电话
+        // onSubmitWarning() {
+        //     this.$refs.formWarning.validate(async valid => {
+        //         if (valid) {
+        //             try {
+        //                 let phoneStr = ''
+        //                 Object.values(this.formWarning).forEach(item => {
+        //                     if (item) {
+        //                         phoneStr += item + ','
+        //                     }
+        //                 })
+        //                 let param = new URLSearchParams
+        //                 param.append('phone', phoneStr)
+        //                 const res = await addwphone(param)
+        //                 console.log(res);
+        //                 if(res && res.code == 200) {
+        //                     this.$message.success('设置余额预警电话成功')
+        //                 } else {
+        //                     this.$message.error('设置余额预警电话失败')
+        //                 }
+        //                 this.onCloseEditDialog()
+        //             } catch (error) {
+        //                 console.log(error);
+        //                 this.$message.error('设置余额预警电话失败')
+        //             }
+        //         }
+        //     })
+        // }
     },
 }
 </script>
@@ -635,6 +769,12 @@ export default {
 /deep/.el-table .cell {
     padding-right: 7px;
 }
+.bankDeposit {
+    padding-bottom: 0px;
+}
+.bankDeposit .el-form-item {
+    margin-bottom: 0px;
+}
 </style>
 <style>
 .el-main {

+ 159 - 31
src/pages/subPages/view.vue

@@ -23,10 +23,7 @@
         <el-container direction="vertical">
             <h3 style="margin-bottom:20px">开发者设置:</h3>
             <el-form label-width="120px" :model="formKey" :rules="ruleKey" ref="keyForm">
-                <!-- <el-form-item label="余额预警:">
-                    {{alarm_amount}}
-                </el-form-item> -->
-                <el-form-item label="密钥设置:" :prop="useKey == '1' ? 'ReSecurityKey' : 'securityKey'" class="keySet">
+                <el-form-item label="密钥设置:" :prop="useKey == '1' ? 'ReSecurityKey' : 'securityKey'"  class="keySet">
                     <el-input v-if="useKey == '1'" v-model="formKey.ReSecurityKey" autocomplete="off" style="width: 300px;margin-right:10px"></el-input>
                     <el-input v-else v-model="formKey.securityKey" autocomplete="off" style="width: 300px;margin-right:10px"></el-input>
                     <el-button type="primary" size="small" @click="updateKey">{{useKey == '1' ? '重设' : '设置'}}</el-button>
@@ -41,17 +38,17 @@
                 <el-form-item label="ip白名单:" >
                     <div v-if="cIpList">
                         <el-input style="width: 300px;margin-bottom: 10px;margin-right: 10px;" :value="ipFormData.name"></el-input>
-                        <i class="el-icon-circle-plus-outline" style="color:#409EFF;" @click="add"></i>
+                        <i class="el-icon-circle-plus-outline" style="color:#409EFF;font-size:22px;" @click="add"></i>
                     </div>
                     <template v-else>
                         <div v-for="(item, idx) in ipList" :key="item">
                             <el-input style="width: 300px;margin-bottom: 10px;margin-right: 10px;" :value="item"></el-input>
                             <template v-if="idx == 0">
-                                <i class="el-icon-circle-plus-outline" style="color:#409EFF;" @click="add"></i>
-                                <i class="el-icon-remove-outline" style="color:#F56C6C;margin-left:10px" @click="del(item)"></i>
+                                <i class="el-icon-circle-plus-outline" style="color:#409EFF;font-size:22px;" @click="add"></i>
+                                <i class="el-icon-remove-outline" style="color:#F56C6C;margin-left:10px;font-size:22px;" @click="del(item)"></i>
                             </template>
                             <!-- <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(item)"></i>
+                            <i v-else class="el-icon-remove-outline" style="color:#F56C6C;font-size:22px;" @click="del(item)"></i>
                         </div>
                     </template>
                 </el-form-item>
@@ -59,7 +56,7 @@
             <!-- 添加ip弹层 -->
             <el-dialog title="添加ip白名单" :visible="dialogFormVisible" @close="btnCancle">
                 <el-form :model="ipFormData" :rules="rules" ref="ipFormData" label-width="80px">
-                    <el-form-item label="ip" prop="name">
+                    <el-form-item label="ip" prop="name">
                         <el-input v-model="ipFormData.name" autocomplete="off" style="width: 300px"></el-input>
                     </el-form-item>
                 </el-form>
@@ -70,18 +67,56 @@
             </el-dialog>
         </el-container>
     </el-card>
+    <!-- 余额预警电话设置 -->
+    <el-card>
+        <el-container direction="vertical">
+            <h3 style="margin-bottom:20px">余额预警电话设置:</h3>
+            <el-form label-width="120px" ref="formWarning">
+                <el-form-item label="余额预警电话:" >
+                    <div v-if="cWarningList">
+                        <el-input style="width: 300px;margin-bottom: 10px;margin-right: 10px;" :value="addphone.phone"></el-input>
+                        <i class="el-icon-circle-plus-outline" style="color:#409EFF;font-size:22px;" @click="addwphone"></i>
+                    </div>
+                    <template v-else>
+                        <div v-for="(item, idx) in warningList" :key="item">
+                            <el-input style="width: 300px;margin-bottom: 10px;margin-right: 10px;" :value="item"></el-input>
+                            <template v-if="idx == 0">
+                                <i class="el-icon-circle-plus-outline" style="color:#409EFF;font-size:22px;" @click="addwphone"></i>
+                                <i class="el-icon-remove-outline" style="color:#F56C6C;margin-left:10px;font-size:22px;" @click="delwphone(item)"></i>
+                            </template>
+                            <i v-else class="el-icon-remove-outline" style="color:#F56C6C;font-size:22px;" @click="delwphone(item)"></i>
+                        </div>
+                    </template>
+                </el-form-item>
+            </el-form>
+            <!-- 添加预警弹层 -->
+            <el-dialog title="添加预警电话" :visible="warningDialogVisible" @close="cancleWarning">
+                <el-form :model="addphone" :rules="ruleAddphone" ref="addphone" label-width="100px">
+                    <el-form-item label="预警电话:" prop="phone">
+                        <el-input v-model="addphone.phone" autocomplete="off" style="width: 300px"></el-input>
+                    </el-form-item>
+                </el-form>
+                <span slot="footer" class="dialog-footer">
+                    <el-button @click="cancleWarning">取 消</el-button>
+                    <el-button type="primary" @click="onSubmitWarning('addphone')">确 定</el-button>
+                </span>
+            </el-dialog>
+        </el-container>
+    </el-card>
 </div>
 </template>
 
 <script>
-// getIpList获取Ip列表 delIpList-删除 addIp-添加 getUserInfo-用户信息 onSubUser-提交用户设置
+// getIpList获取Ip列表 delIpList-删除 addIp-添加 getUserInfo-用户信息 onSubUser-提交用户设置 addwphone-添加预警电话 delwphone-删除
 import {
     // getIpList,
     delIpList,
     addIp,
     getUserInfo,
     updateKey,
-    onSubUser
+    onSubUser,
+    addwphone,
+    delwphone
 } from "@/api";
 export default {
     name: 'pageView',
@@ -116,16 +151,6 @@ export default {
                 ]
             },
             repeatIp: false,
-            // 商户号
-            // merchantsCode: '',
-            // 商户名称
-            // merchantsName: '',
-            // 余额预警
-            // alarm_amount: '',
-            // 余额
-            // available_predeposit: '',
-            // 密钥
-            // securityKey: '',
             // 密钥校验,只能是数字和字母
             formKey: {
                 securityKey: '',
@@ -152,7 +177,21 @@ export default {
                 phone: [
                     {validator: checkPhone, trigger: 'blur'}
                 ]
-            }
+            },
+            // 预警电话列表
+            warningList: [],
+            // 添加预警
+            addphone: {
+                phone: ''
+            },
+            ruleAddphone: {
+                phone: [
+                    { required: true, message: '请输入预警电话', trigger: 'blur' },
+                    { pattern: /^1[3-9]\d{9}$/, message:'请输入正确的电话', trigger: 'blur' }
+                ]
+            },
+            warningDialogVisible: false,
+            repeatPhone: false
         };
     },
     created() {
@@ -162,6 +201,9 @@ export default {
     computed: {
         cIpList() {
             return this.ipList < 1
+        },
+        cWarningList() {
+            return this.warningList < 1
         }
     },
     methods: {
@@ -216,11 +258,11 @@ export default {
         onSubmit(formName) {
             this.$refs[formName].validate(async(valid) => {
                 if (valid) {
-                    console.log(valid);
+                    // console.log(valid);
                     if (this.ipList.length > 0) {
-                        this.ipList.forEach(item => {
-                            this.repeatIp = item.ip == this.ipFormData.name
-                        })
+                        // this.ipList.forEach(item => {
+                        //     this.repeatIp = item.ip == this.ipFormData.name
+                        // })
                         this.repeatIp = this.ipList.find((item => item == this.ipFormData.name))
                     }
                     if (this.repeatIp) {
@@ -261,15 +303,11 @@ export default {
                 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
-                    // this.userForm.name = res.datas.contact_name != 'null' ? res.datas.contact_name : ''
                     this.userForm.name = res.datas.contact_name != 'null' ? res.datas.contact_name : ''
                     this.userForm.phone = res.datas.contact_phone != 'null' ? res.datas.contact_phone : ''
+                    this.warningList = res.datas.warning_phone
                 }
             } catch (error) {
                 console.log(error);
@@ -338,6 +376,93 @@ export default {
         resetForm() {
             this.userForm.name = ''
             this.$refs.userForm.resetFields();
+        },
+        // 添加预警
+        addwphone() {
+            this.addphone.phone = ''
+            this.warningDialogVisible = true
+        },
+        // 关闭预警弹层
+        cancleWarning() {
+            this.warningDialogVisible = false
+            this.$refs.addphone.resetFields()
+        },
+        // 确认添加
+        onSubmitWarning(formName) {
+            this.$refs[formName].validate(async(valid) => {
+                if (valid) {
+                    console.log(valid);
+                    if (this.warningList.length > 0) {
+                        this.repeatPhone = this.warningList.find((item => item == this.addphone.phone))
+                    }
+                    if (this.repeatPhone) {
+                        this.$message.error('该预警电话已存在')
+                        return
+                    }
+                    // console.log('校验通过');
+                    try {
+                        let param = new URLSearchParams()
+                        param.append('phone', this.addphone.phone)
+                        const res = await addwphone(param)
+                        console.log('添加预警电话', res);
+                        if (res && res.code == 200) {
+                            this.$message({
+                                message: '添加预警电话成功',
+                                type: 'success'
+                            });
+                            this.getUserInfo()
+                            // this.dialogFormVisible = false
+                            // this.ipFormData.name = ''
+                        } else {
+                            this.$message.error('添加预警电话失败')
+                        } 
+                        this.warningDialogVisible = false
+                        this.addphone.phone = ''
+                    } catch (error) {
+                        console.log(error);
+                        this.warningDialogVisible = false
+                        this.addphone.phone = ''
+                        this.$message.error('添加预警电话失败')
+                    }
+                }
+            });
+        },
+        // 删除预警电话
+        delwphone(phone) {
+            console.log('phone',phone);
+            // 提示
+            this.$confirm("确认删除该预警电话?", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+            .then(async () => {
+                // 调用删除接口
+                try {
+                    let param = new URLSearchParams()
+                    param.append('phone', phone)
+                    // const res = await delIpList({ip: ip})
+                    const res = await delwphone(param)
+                    console.log('删除预警电话', 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(() => {
+                return false;
+            });
         }
     },
 };
@@ -367,6 +492,9 @@ export default {
 .keySet .el-button {
     margin-right: 10px;
 }
+.el-card {
+    padding-bottom: 0px;
+}
 </style>
 <style>
 .el-main {