Commit c1a220af160f37a90f1024cbe93460b454f34276

Authored by zhiyangdu
1 parent 033ad82f

测试环境接口签名

Showing 1 changed file with 29 additions and 10 deletions
src/main.js
... ... @@ -157,22 +157,41 @@ Vue.prototype.SIGN = {
157 157  
158 158 /* 根据模式,获取相关请求参数 开始 */
159 159 Vue.prototype.getParams = function(mode) {
160   -
  160 + // 随机生成字符串
  161 + function randomString(e) {
  162 + e = e || 8;
  163 + let t = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";
  164 + let a = t.length;
  165 + let n = "";
  166 + for (let i = 0; i < e; i++) {
  167 + n += t.charAt(Math.floor(Math.random() * a));
  168 + }
  169 + return n
  170 + }
161 171 // 返回参数
162 172 let params = {};
163 173  
164 174 switch (mode.toLowerCase()) {
165 175 case "test":
  176 + // 请求头
  177 + let app_key_test= "769_jnjxdh3w53";
  178 + let timestamp_test = new Date().getTime().toString().substr(0, 10);
  179 + let nonce_test = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCpeLgK0vk5POU5PQ";
  180 + let nonce_str_test = randomString(8);
166 181 params.shop = {
167   - apiAddress: "https://wjjshop.cnlive.com",
168   - headers: {
169   - "content-type": "application/x-www-form-urlencoded",
170   - "Phone-Model": "Wap",
171   - "Version":"1.0.1"
172   - },
173   - sellerCategory: {
174   - url: "http://wjjh5test.cnlive.com/hqyw.html"
175   - }
  182 + apiAddress: "https://wjjshop.cnlive.com",
  183 + headers: {
  184 + "App-Key": app_key_test,
  185 + "Timestamp": timestamp_test,
  186 + "Signature": sha1(app_key_test + nonce_test + nonce_str_test + timestamp_test),
  187 + "Nonce-Str": nonce_str_test,
  188 + "Content-Type": "application/x-www-form-urlencoded",
  189 + "Phone-Model": "Wap",
  190 + "Version": "1.0.1"
  191 + },
  192 + sellerCategory: {
  193 + url: "http://wjjh5test.cnlive.com/hqyw.html"
  194 + }
176 195 }
177 196 params.cnlive = {
178 197 apiAddress: "https://api.cnlive.com",
... ...