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;
|
}
|
|
}
|