zxl
2025-05-23 5d5b0f7ab0f34019e11901ddcd59cd8b51ea9ff9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<template>
 
  <div class="layout">
 
    <div class="row" v-if="client ==item.client" v-for="(item,index) in  formValidate" :key="index">
      <div class="col">
        <Card :padding="0">
          <!-- app -->
          <div class="icon-item" v-if="item.clientType== 'APP'">
            <img class="icon" src="../../../../assets/setting/app.svg" alt="" srcset="">
          </div>
          <div class="icon-item" v-if="item.clientType== 'PC'">
            <!-- pc -->
            <img class="icon" src="../../../../assets/setting/pc.svg" alt="" srcset="">
          </div>
          <div class="icon-item" v-if="item.clientType== 'WECHAT_MP'">
            <!-- 小程序 -->
            <img class="icon" src="../../../../assets/setting/wechat_mp.svg" alt="" srcset="">
          </div>
          <div class="icon-item" v-if=" item.clientType== 'H5'">
            <!-- h5 -->
            <img class="icon" src="../../../../assets/setting/h5.svg" alt="" srcset="">
          </div>
          <div class='pay-title'> {{way[item.clientType]}}</div>
          <div>
 
            <Divider orientation="left">登录设置</Divider>
            <div class="pay-list">
              <Form style="width:100%;" ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="100">
                <FormItem label="appId" prop="appId">
                  <Input @on-enter="setupSetting" class="label-appkey" v-model="item.appId" />
                </FormItem>
                <FormItem label="appSecret" prop="appSecret">
                  <Input @on-enter="setupSetting" v-model="item.appSecret" />
                </FormItem>
              </Form>
                 <Button @click="setupSetting">保存设置</Button>
            </div>
          </div>
 
        </Card>
      </div>
 
    </div>
 
  </div>
 
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "../setting/validate";
 
export default {
  data() {
    return {
      ruleValidate: {}, // 验证规则
      way: { // 类型
        APP: "移动应用端",
        H5: "移动端",
        WECHAT_MP: "小程序端",
        PC: "PC端",
      },
      formValidate: {} // 表单数据
    };
  },
  props: ["res", "type"],
  created() {
    this.init();
  },
  methods: {
    submit(name) {
      let that = this;
      if (handleSubmit(that, name)) {
        this.setupSetting();
      }
    },
    // 保存设置
    setupSetting() {
      this.$Spin.show();
      setTimeout(() => {
             this.$Spin.hide();
        setSetting(this.type, {
          wechatConnectSettingItems: this.formValidate,
        }).then((res) => {
          if (res.success) {
            this.$Message.success("保存成功!");
            this.$Modal.remove();
          } else {
            this.$Message.error("保存失败!");
            this.$Modal.remove();
          }
        });
      }, 3000);
    },
    // 实例化数据
    async init() {
      this.formValidate = JSON.parse(this.res).wechatConnectSettingItems;
      Object.keys(this.formValidate).forEach((item) => {
        this.ruleValidate[item] = [
          {
            required: true,
            message: "请填写必填项",
            trigger: "blur",
          },
        ];
      });
    },
  },
};
</script>
 
<style lang="scss" scoped>
@import "../setting/style.scss";
.pay-title {
  text-align: center;
  margin: 10px 0;
}
 
.col {
  width: 100%;
}
.layout {
  padding: 20px;
 
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-start;
}
.row {
  width: 350px;
  margin-right: 20px;
  display: flex;
  margin-bottom: 20px;
  /deep/ .ivu-card-body {
    padding: 0 16px !important;
  }
}
 
.label-item {
  display: flex;
}
.label-item {
  display: flex;
  align-items: center;
}
.pay-list {
  display: flex;
  justify-content: center;
  padding-bottom: 10px;
  flex-direction: column;
  align-items: center;
  /deep/ .ivu-btn {
    width: 100px;
  }
}
.icon-item {
  width: 100%;
  padding: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.ivu-form-item {
  display: flex;
 
  align-items: center;
}
.ivu-row {
  width: 100%;
}
.icon {
  width: 100px;
  height: 100px;
}
</style>