瀏覽代碼

开发设置->设置,添加用户设置
git commit -m 开发设置-

dujingxian 4 年之前
父節點
當前提交
1da5398d34
共有 5 個文件被更改,包括 152 次插入136 次删除
  1. 15 0
      src/api/index.js
  2. 1 1
      src/pages/index.vue
  3. 2 1
      src/pages/subPages/mobileCard.vue
  4. 1 1
      src/pages/subPages/oilCard.vue
  5. 133 133
      src/pages/subPages/view.vue

+ 15 - 0
src/api/index.js

@@ -276,6 +276,21 @@ export const updateKey = (params) => {
         timeout: 120000,
     })
 }
+
+// 用户设置-提交 充值管理-设置余额预警
+export const onSubUser = (params) => { 
+    return axios({
+        method: 'post',
+        url: `${Prefix}act=merchant_info&op=setcontact&client_type=ajax`,
+        withCredentials: true,
+        headers: {
+            "Content-Type": "application/x-www-form-urlencoded"
+          },
+        data: params,
+        timeout: 120000,
+    })
+}
+
 // 上传文件
 export const updateVoucher = (name) => {
     // return requestLoading(`${Prefix}act=merchant_recharge&op=voucherupload&client_type=ajax`, 'post', {voucher})

+ 1 - 1
src/pages/index.vue

@@ -69,7 +69,7 @@
                 </el-menu-item>
                 <el-menu-item index="view" route="view">
                     <i class="el-icon-s-platform"></i>
-                    <span style="font-size: 19px;" slot="title">开发者设置</span>
+                    <span style="font-size: 19px;" slot="title">设置</span>
                 </el-menu-item>
                 <el-menu-item index="interfaceDoc" route="interfaceDoc">
                     <i class="el-icon-document"></i>

+ 2 - 1
src/pages/subPages/mobileCard.vue

@@ -46,7 +46,8 @@
       </el-form>
     </el-card>
     <el-card style="margin-top:40px">
-        <p>充值结果:</p>
+        <!-- <p>充值结果:</p> -->
+        <h3 style="margin-bottom:20px">充值结果:</h3>
         <!-- 提示 -->
         <el-alert
           v-if="tableData.length"

+ 1 - 1
src/pages/subPages/oilCard.vue

@@ -37,7 +37,7 @@
       </el-form>
     </el-card>
     <el-card style="margin-top:40px">
-        <p>充值结果:</p>
+        <h3 style="margin-bottom:20px">充值结果:</h3>
         <!-- 提示 -->
         <el-alert
           v-if="tableData.length"

+ 133 - 133
src/pages/subPages/view.vue

@@ -1,91 +1,100 @@
 <template>
-<el-card>
-<el-container direction="vertical">
-    <!-- <div style="margin-bottom:10px">
-        <el-button type="primary" plain @click="add" size="small">添加ip</el-button>
-    </div>
-    <el-table :data="ipList" border style="width: 100%">
-        <el-table-column align="center" type="index" width="50" label="序号" />
-        <el-table-column align="center" prop="ip" label="IP"></el-table-column>
-        <el-table-column align="center" label="操作">
-            <template slot-scope="scope">
-                <el-button type="danger" plain @click="del(scope.$index)" size="small">删除</el-button>
-                <el-tag type="danger" @click="del(scope.$index)">删除</el-tag>
-            </template>
-        </el-table-column>
-    </el-table> -->
-    <el-form label-width="120px" :model="formKey" :rules="ruleKey" ref="keyForm">
-        <!-- <el-form-item label="商户号:">
-            {{merchantsCode}}
-        </el-form-item>
-        <el-form-item label="商户名称:">
-            {{merchantsName}}
-        </el-form-item>
-        <el-form-item label="当前余额:">
-            {{available_predeposit}}
-        </el-form-item> -->
-        <el-form-item label="余额预警:">
-            {{alarm_amount}}
-        </el-form-item>
-        <!-- show-password  -->
-        <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>
-            <el-alert
-                title="请输入32位字符串,用于接口生成签名"
-                type="info"
-                show-icon
-                style="width:880px;display:inline"
-                :closable="false">
-            </el-alert>
-        </el-form-item>
-        <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>
-            </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">
+<div>
+    <!-- 用户设置 -->
+    <el-card>
+        <el-container direction="vertical">
+            <h3 style="margin-bottom:20px">用户设置:</h3>
+            <el-form label-width="120px" :model="userForm" :rules="userRule" ref="userForm">
+                <el-form-item label="用户名:">
+                    <el-input v-model="userForm.name" style="width: 300px;"></el-input>
+                </el-form-item>
+                <el-form-item label="联系方式:" prop="phone">
+                    <el-input v-model="userForm.phone" style="width: 300px;"></el-input>
+                </el-form-item>
+                <el-form-item >
+                    <el-button type="primary" size="small" @click="onSubUser">提交</el-button>
+                    <el-button size="small" @click="resetForm">重置</el-button>
+                </el-form-item>
+            </el-form>
+        </el-container>
+    </el-card>
+    <!-- 开发者设置 -->
+    <el-card>
+        <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-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>
+                    <el-alert
+                        title="请输入32位字符串,用于接口生成签名"
+                        type="info"
+                        show-icon
+                        style="width:880px;display:inline"
+                        :closable="false">
+                    </el-alert>
+                </el-form-item>
+                <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-remove-outline" style="color:#F56C6C;margin-left:10px" @click="del(item)"></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>
+                            </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>
+                        </div>
                     </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>
-                </div>
-            </template>
-        </el-form-item>
-    </el-form>
-    <!-- 添加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-input v-model="ipFormData.name" autocomplete="off" style="width: 300px"></el-input>
-            </el-form-item>
-        </el-form>
-        <span slot="footer" class="dialog-footer">
-            <el-button @click="btnCancle">取 消</el-button>
-            <el-button type="primary" @click="onSubmit('ipFormData')">确 定</el-button>
-        </span>
-    </el-dialog>
-</el-container>
-</el-card>
+                </el-form-item>
+            </el-form>
+            <!-- 添加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-input v-model="ipFormData.name" autocomplete="off" style="width: 300px"></el-input>
+                    </el-form-item>
+                </el-form>
+                <span slot="footer" class="dialog-footer">
+                    <el-button @click="btnCancle">取 消</el-button>
+                    <el-button type="primary" @click="onSubmit('ipFormData')">确 定</el-button>
+                </span>
+            </el-dialog>
+        </el-container>
+    </el-card>
+</div>
 </template>
 
 <script>
-// getIpList获取Ip列表 delIpList-删除 addIp-添加 getUserInfo-用户信息
+// getIpList获取Ip列表 delIpList-删除 addIp-添加 getUserInfo-用户信息 onSubUser-提交用户设置
 import {
     // getIpList,
     delIpList,
     addIp,
     getUserInfo,
-    updateKey
+    updateKey,
+    onSubUser
 } from "@/api";
 export default {
     name: 'pageView',
     data() {
+        var checkPhone = (rule, value, callback) => {
+            if (!value) {
+                return callback(new Error('联系方式不能为空'));
+            } else if (!/^1[1-3]\d{9}$/.test(value)) {
+                callback(new Error('请输入合法手机号'));
+            } else {
+                callback()
+            }
+        };
         return {
             pageSize: 10,
             pageNumber: 1,
@@ -108,13 +117,13 @@ export default {
             },
             repeatIp: false,
             // 商户号
-            merchantsCode: '',
+            // merchantsCode: '',
             // 商户名称
-            merchantsName: '',
+            // merchantsName: '',
             // 余额预警
-            alarm_amount: '',
+            // alarm_amount: '',
             // 余额
-            available_predeposit: '',
+            // available_predeposit: '',
             // 密钥
             // securityKey: '',
             // 密钥校验,只能是数字和字母
@@ -133,7 +142,17 @@ export default {
                 ]
             },
             // 是否设置过密钥 1-设置过
-            useKey: ''
+            useKey: '',
+            // 用户设置
+            userForm: {
+                name: '',
+                phone: ''
+            },
+            userRule: {
+                phone: [
+                    {validator: checkPhone, trigger: 'blur'}
+                ]
+            }
         };
     },
     created() {
@@ -146,13 +165,6 @@ export default {
         }
     },
     methods: {
-        // 获取Ip列表
-        // async getIpList() {
-        //     const res = await getIpList()
-        //     console.log('获取ip列表', res);
-        //     this.ipList = res.datas
-
-        // },
         // 删除
         del(ip) {
             console.log('ip', ip);
@@ -249,12 +261,15 @@ 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.merchantsCode = res.datas.mchid
+                    // this.merchantsName = res.datas.name
                     this.ipList = res.datas.ips
-                    this.alarm_amount = res.datas.alarm_amount
+                    // this.alarm_amount = res.datas.alarm_amount
                     this.useKey = res.datas.use_key
-                    this.available_predeposit = res.datas.member.available_predeposit
+                    // 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 : ''
                 }
             } catch (error) {
                 console.log(error);
@@ -294,51 +309,36 @@ export default {
                     this.formKey.securityKey = ''
                 }
             })
+        },
+        // 提交用户设置
+        onSubUser() {
+            this.$refs.userForm.validate(async(valid) => {
+                // console.log('valid', valid);
+                if (valid) {
+                    try {
+                        let param = new URLSearchParams()
+                        param.append('contact_name', this.userForm.name)
+                        param.append('contact_phone', this.userForm.phone)
+                        const res = await onSubUser(param)
+                        if (res && res.code && res.code == 200) {
+                            this.$message.success('提交用户设置成功')
+                            this.getUserInfo()
+                        }
+                        // this.userForm.name = ''
+                        // this.userForm.phone = ''
+                        console.log('用户设置提交', res);
+                    } catch (error) {
+                        console.log(error);
+                        this.$message.error('提交用户设置失败')
+                    }
+                }
+            })
+        },
+        // 重置
+        resetForm() {
+            this.userForm.name = ''
+            this.$refs.userForm.resetFields();
         }
-        // 新增
-        // addIp() {}
-        // 分页
-        // onPageChange(page) {
-        //     if (page == this.pageNumber) {
-        //         return;
-        //     } else {
-        //         this.pageNumber = page;
-        //         setTimeout(() => {
-        //             // this.getIpList();
-        //         }, 0);
-        //     }
-        // },
-        // 搜索
-        // onSearch() {
-        //     this.pageNumber = 1;
-        //     setTimeout(() => {
-        //         this.getIpList();
-        //     }, 0);
-        // },
-        // getBoxList() {
-        //     boxList({
-        //         cabinet_number: this.cabinetValue
-        //     }).then((res) => {
-        //         if (res && res.msg == "ok") {
-        //             this.boxOptions = res.data.rows;
-        //         }
-        //     });
-        // },
-        // getBoxActionList() {
-        //     let box = this.boxValue ? this.boxValue : 0;
-        //     boxActionList({
-        //         cabinet_number: this.cabinetValue,
-        //         box_number: box,
-        //         pageSize: this.pageSize,
-        //         pageNumber: this.pageNumber,
-        //     }).then((res) => {
-        //         console.log(res);
-        //         if (res && res.msg == "ok") {
-        //             this.total = res.data.total;
-        //             this.ipList = res.data.rows;
-        //         }
-        //     });
-        // }
     },
 };
 </script>