admin
2019-12-28 64a8f7a3be0a5584fe2164a2474b189c79cfab5c
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
package com.yeshi.fanli.util;
 
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Iterator;
 
import com.yeshi.fanli.entity.common.JumpDetailV2;
 
import net.sf.json.JSONObject;
 
public class JumpDetailUtil {
    /**
     * 过滤小程序跳转参数
     * 
     * @param detail
     * @param params
     * @return
     */
    public static JumpDetailV2 getWXMPJumDetail(JumpDetailV2 detail, JSONObject params) {
        String path = detail.getPath();
        if (params != null) {
            path += "?";
            for (Iterator<String> its = params.keys(); its.hasNext();) {
                String key = its.next();
                try {
                    path += (key + "=" + URLEncoder.encode(params.optString(key), "UTF-8") + "&");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
        }
        if (path.endsWith("&"))
            path = path.substring(0, path.length() - 1);
        JumpDetailV2 v2 = new JumpDetailV2();
        v2.setPath(path);
        v2.setType(detail.getType());
        return v2;
    }
 
}