333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
<template>
  <div :ref="'settings'" class="settings-sub-container">
    <el-form ref="form" :model="formData" label-width="150px" class="margin-top-20">
      <el-form-item label="货主编号">
        <el-input v-model="formData.consignorCode" class="w-500 app-secret"></el-input>
      </el-form-item>
      <el-form-item label="token">
        <el-input v-model="formData.token" class="w-500 app-secret"></el-input>
      </el-form-item>
      <el-form-item label="时间戳timestamp">
        <el-input v-model="formData.timestamp" class="w-300 app-secret"></el-input>
        <el-button type="text" icon="el-icon-yrt-shuaxin" @click="refreshTimestamp">刷新</el-button>
      </el-form-item>
      <el-form-item label="随机数nonce">
        <el-input v-model="formData.nonce" class="w-300 app-secret"></el-input>
        <el-button type="text" icon="el-icon-yrt-shuaxin" @click="refreshNonce">刷新</el-button>
      </el-form-item>
      <el-form-item label="签名signature">
        <el-input v-model="formData.signature" class="w-500 app-secret"></el-input>
      </el-form-item>
      <el-form-item label="推送内容">
        <el-input v-model="formData.json" :rows="3" type="textarea" class="w-500 app-secret"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-yrt-shuaxin1" @click="createSignature()">生成签名</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
 
<script>
export default {
  name: "settings-pda",
 
  components: {},
  data() {
    return {
      Type_Id: 585, // 通用参数类别ID,不可修改
      // 编辑数据对象
      formData: {
        consignorCode: null,
        token: null,
        timestamp: null,
        nonce: null,
        signature: null
      },
      // 接口数据
      valueList: []
    };
  },
  mounted() {
    this.refreshTimestamp();
    this.refreshNonce();
  },
  methods: {
    handleClose(tag) {},
    // 刷新timestamp
    refreshTimestamp() {
      this.formData.timestamp = new Date().valueOf();
      this.formData.signature = null;
    },
    // 刷新timestamp
    refreshNonce() {
      this.formData.nonce = Math.random()
        .toString(36)
        .substr(2);
      this.formData.signature = null;
    },
    // 生成签名
    createSignature() {
      const signature = this.common.getSignature2(
        this.formData.consignorCode,
        this.formData.token,
        this.formData.timestamp,
        this.formData.nonce,
        this.formData.json
      );
      this.$set(this.formData, "signature", signature);
      if (signature) {
        this.$message.success("生成成功");
      }
    }
  }
};
</script>
 
<style lang="scss" scoped>
.settings-sub-container {
  /deep/ .sub-title {
    font-size: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ebeef5;
    padding-top: 20px;
    margin-bottom: 10px;
  }
  /deep/ .el-form-item__label {
    font-weight: normal;
  }
  .remark {
    color: #888;
  }
  /deep/ .el-form-item {
    margin-bottom: 20px;
  }
  .form-footer {
    margin-top: 30px;
  }
}
</style>