package com.tejia.lijin.app.ui.recommend;
|
|
import android.annotation.SuppressLint;
|
import android.content.DialogInterface;
|
import android.content.Intent;
|
import android.content.SharedPreferences;
|
import android.graphics.PixelFormat;
|
import android.os.Bundle;
|
import android.util.Log;
|
import android.view.KeyEvent;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.view.View.OnClickListener;
|
import android.view.ViewGroup;
|
import android.view.animation.Animation;
|
import android.view.animation.LinearInterpolator;
|
import android.view.animation.RotateAnimation;
|
import android.webkit.WebChromeClient;
|
import android.webkit.WebResourceRequest;
|
import android.webkit.WebResourceResponse;
|
import android.webkit.WebSettings;
|
import android.webkit.WebView;
|
import android.webkit.WebViewClient;
|
import android.widget.AdapterView;
|
import android.widget.FrameLayout;
|
import android.widget.ImageView;
|
import android.widget.LinearLayout;
|
import android.widget.ListView;
|
import android.widget.PopupWindow;
|
import android.widget.ProgressBar;
|
import android.widget.TextView;
|
import android.widget.Toast;
|
|
import com.ali.auth.third.ui.context.CallbackContext;
|
import com.alibaba.baichuan.android.trade.AlibcTrade;
|
import com.alibaba.baichuan.android.trade.model.AlibcShowParams;
|
import com.alibaba.baichuan.android.trade.page.AlibcBasePage;
|
import com.alibaba.baichuan.android.trade.page.AlibcDetailPage;
|
import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType;
|
import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams;
|
import com.alibaba.baichuan.trade.biz.login.AlibcLogin;
|
import com.alibaba.baichuan.trade.biz.login.AlibcLoginCallback;
|
import com.tejia.lijin.app.util.JumpActivityUtil;
|
import com.google.gson.Gson;
|
import com.google.gson.GsonBuilder;
|
import com.google.gson.reflect.TypeToken;
|
import com.umeng.analytics.MobclickAgent;
|
import com.wpc.library.dialog.BottomDialog;
|
import com.wpc.library.util.SystemCommon;
|
import com.wpc.library.util.common.StringUtils;
|
import com.tejia.lijin.app.BasicTextHttpResponseHandler;
|
import com.tejia.lijin.app.BuXinConstant;
|
import com.tejia.lijin.app.R;
|
import com.tejia.lijin.app.ShoppingApi;
|
import com.tejia.lijin.app.callBack.MiDuoTradeCallback;
|
import com.tejia.lijin.app.entity.CouponInfo;
|
import com.tejia.lijin.app.entity.GoodsDetail;
|
import com.tejia.lijin.app.entity.ImgText;
|
import com.tejia.lijin.app.entity.QuanInfo;
|
import com.tejia.lijin.app.entity.TbPidInfo;
|
import com.tejia.lijin.app.entity.share.SingleGoodsShareInfo;
|
import com.tejia.lijin.app.ui.BaseActivity;
|
import com.tejia.lijin.app.ui.dialog.BindDialog;
|
import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog;
|
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
|
import com.tejia.lijin.app.ui.mine.CollectionBrowserActivity;
|
import com.tejia.lijin.app.ui.mine.WebTopRightAdapter;
|
import com.tejia.lijin.app.util.InitAlibcSdk;
|
import com.tejia.lijin.app.util.KeFuUtil;
|
import com.tejia.lijin.app.util.TopStatusSettings;
|
import com.tejia.lijin.app.util.baichuan.AlibcTradeUtil;
|
import com.tejia.lijin.app.util.user.UserUtil;
|
|
import org.apache.http.Header;
|
import org.json.JSONException;
|
import org.json.JSONObject;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.List;
|
|
/**
|
* 商品网页版详情页
|
*/
|
public class GoodsDetailBrowerActivity extends BaseActivity implements OnClickListener {
|
|
private TextView tv_top_bar_left;
|
private TextView tv_top_bar_left2;
|
private TextView tv_top_bar_middle;
|
private TextView tv_share_make_money;
|
private TextView tv_money, tv_rebate_num;
|
private TextView tv_coupon_state, tv_like_state;
|
ImageView iv_top_bar_right2;
|
private WebView webview;
|
private FrameLayout fl_webview;
|
private LinearLayout ll_already_login, ll_no_login;
|
View v_cover;
|
private ProgressBar progressBar;
|
private MWebviewClient mWebviewClient;
|
private MiDuoTradeCallback tradeCallback;
|
AlibcShowParams alibcShowParams;
|
AlibcTaokeParams alibcTaokeParams;
|
AlibcDetailPage alibcBasePage;
|
boolean isTrolley;
|
boolean isWeex;
|
|
@Override
|
protected void onCreate(Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState);
|
setContentView(R.layout.activity_goods_brower);
|
getWindow().setFormat(PixelFormat.TRANSLUCENT);
|
tv_share_make_money = findViewById(R.id.tv_share_make_money);
|
TopStatusSettings.setStatusViewAndDeepColor(this);
|
id = getIntent().getStringExtra("id");
|
|
tv_top_bar_left = findViewById(R.id.tv_top_bar_left);
|
tv_top_bar_left2 = findViewById(R.id.tv_top_bar_left2);
|
tv_top_bar_left2.setVisibility(View.VISIBLE);
|
tv_top_bar_middle = findViewById(R.id.tv_top_bar_middle);
|
fl_webview = findViewById(R.id.fl_webview);
|
tv_money = findViewById(R.id.tv_red_packet_money);
|
tv_rebate_num = findViewById(R.id.tv_rebate_num);
|
tv_like_state = findViewById(R.id.tv_like_state);
|
tv_coupon_state = findViewById(R.id.tv_coupon_state);
|
ll_no_login = findViewById(R.id.ll_no_login);
|
ll_already_login = findViewById(R.id.ll_already_login);
|
v_cover = findViewById(R.id.v_cover_goods_detail);
|
// tv_top_bar_left2.setText("关闭");
|
tv_top_bar_left.setOnClickListener(this);
|
tv_top_bar_left2.setOnClickListener(this);
|
findViewById(R.id.iv_doubt).setOnClickListener(this);
|
findViewById(R.id.tv_login).setOnClickListener(this);
|
tv_coupon_state.setOnClickListener(this);
|
tv_like_state.setOnClickListener(this);
|
|
webview = new WebView(GoodsDetailBrowerActivity.this);
|
mWebviewClient = new MWebviewClient();
|
fl_webview.addView(webview, new FrameLayout.LayoutParams(
|
FrameLayout.LayoutParams.MATCH_PARENT,
|
FrameLayout.LayoutParams.MATCH_PARENT));
|
WebSettings webSettings = webview.getSettings();
|
webSettings.setJavaScriptEnabled(true);
|
webSettings.setDomStorageEnabled(true);
|
webSettings.setAppCacheEnabled(true);
|
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
webSettings.setDatabaseEnabled(true);
|
webSettings.setTextZoom(100);
|
|
webview.setDrawingCacheEnabled(true);
|
webview.setWebViewClient(mWebviewClient);
|
progressBar = findViewById(R.id.myProgressBar);
|
progressBar.setMax(100);
|
progressBar.setProgressDrawable(this.getResources()
|
.getDrawable(R.drawable.color_progressbar));
|
webview.setWebChromeClient(new WebChromeClient() {
|
|
@Override
|
public void onReceivedTitle(WebView view, String title) {
|
// Toast.makeText(GoodsDetailBrowerActivity.this, "我的标题是" + title, Toast.LENGTH_LONG).show();
|
tv_top_bar_middle.setText(title);
|
}
|
|
@Override
|
public void onProgressChanged(WebView webView, int i) {
|
if (i == 100) {
|
progressBar.setVisibility(View.GONE);
|
} else {
|
if (View.INVISIBLE == progressBar.getVisibility()) {
|
progressBar.setVisibility(View.VISIBLE);
|
}
|
progressBar.setProgress(i);
|
}
|
super.onProgressChanged(webView, i);
|
}
|
|
});
|
tv_top_bar_middle.setText("商品详情");
|
|
alibcShowParams = new AlibcShowParams();
|
alibcTaokeParams = new AlibcTaokeParams("", "", "");
|
alibcTaokeParams.setPid(BuXinConstant.BAICHUAN_PID);
|
alibcTaokeParams.setAdzoneid(BuXinConstant.BAICHUAN_ADZONE_ID);
|
alibcTaokeParams.pid = BuXinConstant.BAICHUAN_PID;
|
alibcTaokeParams.adzoneid = BuXinConstant.BAICHUAN_ADZONE_ID;
|
alibcTaokeParams.extraParams = new HashMap<>();
|
alibcTaokeParams.extraParams.put("taokeAppkey", BuXinConstant.TAO_BAO_KE_KEY);
|
tradeCallback = new MiDuoTradeCallback("");
|
//购物车传过来的参数
|
isTrolley = getIntent().getBooleanExtra("isTrolley", false);
|
isWeex = getIntent().getBooleanExtra("isWeex", false);
|
if (!isWeex && !isTrolley && getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").equalsIgnoreCase("0")) {
|
findViewById(R.id.tv_prombt).setVisibility(View.GONE);
|
findViewById(R.id.ll_bottom).setVisibility(View.GONE);
|
findViewById(R.id.tv_share_make_money).setVisibility(View.GONE);
|
findViewById(R.id.iv_top_bar_right3).setVisibility(View.INVISIBLE);
|
findViewById(R.id.iv_top_bar_right1).setVisibility(View.INVISIBLE);
|
TbPidInfo info = (TbPidInfo) getIntent().getSerializableExtra("tInfo");
|
QuanInfo couponInfo = (QuanInfo) getIntent().getSerializableExtra("cInfo");
|
int type;
|
try {
|
type = Integer.parseInt(getIntent().getStringExtra("type"));
|
} catch (NumberFormatException e) {
|
e.printStackTrace();
|
type = 0;
|
}
|
|
if (info != null) {
|
alibcTaokeParams.setPid(info.getPid());
|
alibcTaokeParams.setAdzoneid(info.getAdZoneId());
|
alibcTaokeParams.pid = info.getPid();
|
alibcTaokeParams.adzoneid = info.getAdZoneId();
|
alibcTaokeParams.extraParams = new HashMap<>();
|
alibcTaokeParams.extraParams.put("taokeAppkey", info.getAppKey());
|
} else {
|
alibcTaokeParams = null;
|
}
|
if (type == 1) {
|
if (couponInfo != null && !StringUtils.isEmpty(couponInfo.getCouponUrl())) {
|
// AlibcBasePage alibcPage = new AlibcPage(couponInfo.getCouponUrl());
|
// AlibcTrade.show(GoodsDetailBrowerActivity.this, webview, mWebviewClient, new MyWebChromeClient(), alibcPage,
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
jumpWeb(couponInfo.getCouponUrl());
|
} else {
|
String clickUrl = getIntent().getStringExtra("clickUrl");
|
// AlibcPage alibcPage = new AlibcPage(clickUrl);
|
// AlibcTrade.show(GoodsDetailBrowerActivity.this, webview, mWebviewClient, new MyWebChromeClient(), alibcPage,
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
jumpWeb(clickUrl);
|
}
|
} else {
|
// Toast.makeText(GoodsDetailBrowerActivity.this, "商品ID为::" + id + "--pid" + info.getPid() +
|
// "--AppKey" + info.getAppKey(), Toast.LENGTH_LONG).show();
|
if (couponInfo != null && !StringUtils.isEmpty(couponInfo.getCouponUrl())) {
|
// AlibcBasePage alibcPage = new AlibcPage(couponInfo.getCouponUrl());
|
// AlibcTrade.show(GoodsDetailBrowerActivity.this, webview, mWebviewClient, new MyWebChromeClient(), alibcPage,
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
jumpWeb(couponInfo.getCouponUrl());
|
} else {
|
String clickUrl = getIntent().getStringExtra("clickUrl");
|
// AlibcPage alibcPage = new AlibcPage(clickUrl);
|
// AlibcTrade.show(GoodsDetailBrowerActivity.this, webview, mWebviewClient, new MyWebChromeClient(), alibcPage,
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
jumpWeb(clickUrl);
|
}
|
}
|
|
} else {
|
tv_coupon_state.setVisibility(View.GONE);
|
//购物车传过来为true 隐藏右上角 按钮
|
if (isTrolley) {
|
tv_share_make_money.setVisibility(View.GONE);
|
iv_top_bar_right2 = findViewById(R.id.iv_top_bar_right2);
|
iv_top_bar_right2.setVisibility(View.VISIBLE);
|
iv_top_bar_right2.setImageResource(R.drawable.ic_des_top_right);
|
findViewById(R.id.iv_top_bar_right3).setVisibility(View.INVISIBLE);
|
initTopRightPopupWindow();
|
}
|
getGoodsdetail();
|
}
|
// alibcPage = new AlibcPage("https://s.click.taobao.com/YInT4Tw");
|
findViewById(R.id.iv_top_bar_right1).setOnClickListener(this);
|
findViewById(R.id.iv_top_bar_right2).setOnClickListener(this);
|
v_cover.setOnClickListener(this);
|
}
|
|
/**
|
* 初始化右上角提示
|
*/
|
PopupWindow mTopRightPopupWindow;
|
private List<ImgText> mulList = new ArrayList<>();
|
WebTopRightAdapter shareFromAdapter;
|
|
private void initTopRightPopupWindow() {
|
View view = getLayoutInflater().inflate(R.layout.item_share_from_filter,
|
null, false);
|
// 创建PopupWindow实例,200,150分别是宽度和高度
|
mTopRightPopupWindow = new PopupWindow(view, (int) (SystemCommon.getScreenWidth(tv_coupon_state.getContext()) / 2), ViewGroup.LayoutParams.WRAP_CONTENT, true);
|
// 设置动画效果 [R.style.AnimationFade 是自己事先定义好的]
|
// pw_filter.setAnimationStyle(R.style.pop_multiple);
|
mTopRightPopupWindow.setTouchable(true);
|
mTopRightPopupWindow.setOutsideTouchable(false);
|
mTopRightPopupWindow.setFocusable(false);
|
ListView lv = view.findViewById(R.id.lv_filter_pw);
|
|
ImgText info0 = new ImgText();
|
info0.setIcon1(R.drawable.ic_goods_detail_help_center);
|
info0.setName("帮助");
|
ImgText info1 = new ImgText();
|
info1.setName("刷新");
|
ImgText info2 = new ImgText();
|
info2.setName("人工客服");
|
mulList.add(info0);
|
mulList.add(info1);
|
mulList.add(info2);
|
shareFromAdapter = new WebTopRightAdapter(tv_coupon_state.getContext(), mulList);
|
lv.setAdapter(shareFromAdapter);
|
|
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
@Override
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
mTopRightPopupWindow.dismiss();
|
v_cover.setVisibility(View.GONE);
|
|
if (position == mulList.size() - 1) {
|
KeFuUtil.jumpKeFu(tv_coupon_state.getContext(), "购物车");
|
} else if (position == mulList.size() - 2) {
|
webview.reload();
|
} else {
|
SharedPreferences sp = tv_coupon_state.getContext().getSharedPreferences("user", MODE_PRIVATE);
|
Intent intent = new Intent(tv_coupon_state.getContext(), ShareBrowserActivity.class);
|
intent.putExtra("title", "帮助中心");
|
intent.putExtra("url", sp.getString("help", ""));
|
startActivity(intent);
|
}
|
// mTopRightPopupWindow.dismiss();
|
}
|
});
|
mTopRightPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
@Override
|
public void onDismiss() {
|
v_cover.setVisibility(View.GONE);
|
}
|
});
|
}
|
|
class MWebviewClient extends WebViewClient {
|
@Override
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
// String reStr = GetPostUrl.get("http://192.168.1.122:8080/cjw/test/url?url=" + url);
|
// Toast.makeText(GoodsDetailBrowerActivity.this, url, Toast.LENGTH_LONG).show();
|
if (view.getUrl().startsWith("https://h5.m.taobao.com/awp/base/cart.htm?")) {
|
Intent intent = new Intent(webview.getContext(), CollectionBrowserActivity.class);
|
intent.putExtra("type", "showCart");
|
startActivity(intent);
|
webview.postDelayed(new Runnable() {
|
@Override
|
public void run() {
|
if (webview != null)
|
webview.goBack();
|
}
|
}, 100);
|
return false;
|
} else if (url.contains("/tbopen/") || url.startsWith("tbopen://")) {
|
return true;
|
}
|
if (getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").equalsIgnoreCase("1"))
|
if (url.startsWith("https://h5.m.taobao.com/awp/core/detail.htm") || url.startsWith("https://detail.m.tmall.com")) {
|
tv_share_make_money.setVisibility(View.VISIBLE);
|
} else {
|
tv_share_make_money.setVisibility(View.GONE);
|
}
|
if (url.startsWith("http:") || url.startsWith("https:")) {
|
view.loadUrl(url);
|
return false;
|
} else if (url != null && url.startsWith("yestv://")) {
|
String murl = url.split("yestv://")[1];
|
String[] params = murl.split("#");
|
if (params[0].equalsIgnoreCase("getgoodsdetail")) {
|
|
}else if (params[0].equalsIgnoreCase("jumppage")) {
|
Intent intent = null;
|
try {
|
Class<String> forName = (Class<String>) Class.forName(JumpActivityUtil.filterActivityName(params[1]));
|
intent = new Intent(GoodsDetailBrowerActivity.this, forName);
|
} catch (ClassNotFoundException e) {
|
e.printStackTrace();
|
}
|
if (params.length > 2) {
|
String str = params[2];
|
JSONObject obj = null;
|
try {
|
obj = new JSONObject(str);
|
} catch (JSONException e) {
|
}
|
Iterator<String> its = obj.keys();
|
while (its.hasNext()) {
|
String key = its.next();
|
String value = obj.optString(key);
|
intent.putExtra(key, value);
|
}
|
}
|
startActivity(intent);
|
} else {
|
return super.shouldOverrideUrlLoading(view, url);
|
}
|
}
|
return super.shouldOverrideUrlLoading(view, url);
|
}
|
|
@SuppressLint("NewApi")
|
@Override
|
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest
|
request) {
|
String url = request.getUrl().toString();
|
WebResourceResponse response = super.shouldInterceptRequest(view, url);
|
return response;
|
}
|
|
@Override
|
public void onPageFinished(WebView view, String url) {
|
super.onPageFinished(view, url);
|
if (getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").equalsIgnoreCase("1"))
|
if (url.contains(id)) {
|
tv_share_make_money.setVisibility(View.VISIBLE);
|
} else {
|
tv_share_make_money.setVisibility(View.GONE);
|
}
|
}
|
|
@Override
|
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
WebResourceResponse response = super.shouldInterceptRequest(view, url);
|
if (url.startsWith("https://h5acs.m.taobao.com/h5/mtop.trade.createorder.h5") || url.startsWith("https://h5acs.m.tmall.com/h5/mtop.trade.createorder.h5"))//订单提交
|
{
|
final WebView fwebView = view;
|
webview.post(new Runnable() {
|
@Override
|
public void run() {
|
fwebView.loadUrl("javascript:var ss = document.getElementsByClassName('order-service');var yunfeiXian = 0;for(var i = 0; i < ss.length; i++) {if(ss[i].getElementsByClassName('title')[0].innerHTML == '运费险') {var yunfeiStr = ss[i].getElementsByClassName('option')[0].innerHTML;if(yunfeiStr != undefined && yunfeiStr.indexOf('元') > -1 && yunfeiStr.indexOf('赔付') > -1) {if(yunfeiStr.split(' ').length > 1) {yunfeiXian = yunfeiStr.split(' ')[1].replace('元', '');}}break;}}; var ss = document.getElementsByClassName('order-order')[0].getElementsByClassName('select-face');var kuaidiMoney=0;for(var i = 0; i < ss.length; i++) {if(ss[i].innerHTML.indexOf(('快递¥'))>-1||ss[i].innerHTML.indexOf(('EMS¥'))>-1) {kuaidiMoney=ss[i].innerHTML.replace('快递¥').replace('EMS¥');break;}} window.local_obj.getOrderPrice(kuaidiMoney,yunfeiXian,document.getElementsByClassName('order-orderPay')[0].getElementsByClassName('price')[0].innerHTML)");
|
}
|
});
|
}
|
// if (url != null && (url.startsWith("tbopen://") || url.contains("intent"))) {
|
// url = "";
|
// Toast.makeText(GoodsDetailBrowerActivity.this, "请求路劲----" + url, Toast.LENGTH_LONG).show();
|
// }
|
return response;
|
}
|
|
}
|
|
class MyWebChromeClient extends WebChromeClient {
|
@Override
|
public void onReceivedTitle(WebView view, String title) {
|
tv_top_bar_middle.setText(title);
|
}
|
|
@Override
|
public void onProgressChanged(WebView webView, int i) {
|
if (i == 100) {
|
progressBar.setVisibility(View.GONE);
|
} else {
|
if (View.INVISIBLE == progressBar.getVisibility()) {
|
progressBar.setVisibility(View.VISIBLE);
|
}
|
progressBar.setProgress(i);
|
}
|
super.onProgressChanged(webView, i);
|
}
|
}
|
|
private boolean isFirstLogin = true;
|
|
private void login() {
|
final AlibcLogin alibcLogin = AlibcLogin.getInstance();
|
if (!alibcLogin.isLogin()) {
|
alibcLogin.showLogin(new AlibcLoginCallback() {
|
|
@Override
|
public void onSuccess(int i, String s, String s1) {
|
SharedPreferences.Editor editor = getSharedPreferences("user",
|
MODE_PRIVATE).edit();
|
editor.putString("TrolleyTransformationLink", "");
|
editor.commit();
|
Toast.makeText(GoodsDetailBrowerActivity.this, "恭喜你,登录成功",
|
Toast.LENGTH_LONG).show();
|
}
|
|
@Override
|
public void onFailure(int code, String msg) {
|
if (isFirstLogin) {
|
InitAlibcSdk.init();
|
isFirstLogin = false;
|
}
|
Toast.makeText(GoodsDetailBrowerActivity.this, "登录失败,请稍候再试",
|
Toast.LENGTH_LONG).show();
|
MobclickAgent.reportError(GoodsDetailBrowerActivity.this, "GoodsDetailBrowerActivity---login---code:" + code + "---msg:" + msg);
|
}
|
});
|
// BindDialog.Builder builder = new BindDialog.Builder(GoodsDetailBrowerActivity.this);
|
// builder.setMessage("淘宝授权登录失效,是否重新授权登录!").setPositiveButtonColor(2).setNegativeButtonColor(2).setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
// @Override
|
// public void onClick(DialogInterface dialogInterface, int i) {
|
// dialogInterface.dismiss();
|
// }
|
// }).setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
// @Override
|
// public void onClick(DialogInterface dialogInterface, int i) {
|
// alibcLogin.showLogin(new AlibcLoginCallback() {
|
// @Override
|
// public void onSuccess(int i) {
|
// Toast.makeText(GoodsDetailBrowerActivity.this, "登录成功",
|
// Toast.LENGTH_LONG).show();
|
// }
|
//
|
// @Override
|
// public void onFailure(int code, String msg) {
|
// Toast.makeText(GoodsDetailBrowerActivity.this, "登录失败",
|
// Toast.LENGTH_LONG).show();
|
// }
|
// });
|
// dialogInterface.dismiss();
|
// }
|
// }).create().show();
|
}
|
}
|
|
private CouponInfo qInfo;
|
private GoodsDetail mInfo;
|
private String id;
|
|
private void getGoodsdetail() {
|
SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
String uid = sp.getString("uid", "");
|
ShoppingApi.getGoodsInfoTB(this, id, uid, isTrolley ? "购物车" : isWeex ? "weex" : "其它", new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
Log.e("mResult", "getGoodsdetail()---onSuccessPerfect()---");
|
if (jsonObject.optInt("code") == 0) {
|
Log.e("mResult", "Gson---" + jsonObject);
|
Gson gson = new GsonBuilder().serializeNulls().create();
|
mInfo = gson.fromJson(jsonObject.optJSONObject("data").toString(), GoodsDetail.class);
|
Log.e("mResult", "isCollection---");
|
isCollection = mInfo.getExtra().isCollected();
|
if (isCollection) {
|
tv_like_state.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_like_goods_detail_light, 0, 0);
|
tv_like_state.setText("已收藏");
|
} else {
|
tv_like_state.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_like_goods_detail, 0, 0);
|
tv_like_state.setText("收藏");
|
}
|
|
TbPidInfo tInfo = mInfo.getExtra().getTbPidInfo();
|
alibcTaokeParams.setPid(tInfo.getPid());
|
alibcTaokeParams.setAdzoneid(tInfo.getAdZoneId());
|
alibcTaokeParams.pid = tInfo.getPid();
|
alibcTaokeParams.adzoneid = tInfo.getAdZoneId();
|
alibcTaokeParams.extraParams = new HashMap<>();
|
alibcTaokeParams.extraParams.put("taokeAppkey", tInfo.getAppKey());
|
|
String is_goods_web_detail = getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0");
|
|
if (is_goods_web_detail.equalsIgnoreCase("0")) {
|
Log.e("mResult", "isCollection---0---" + mInfo.getGoods().isHasCoupon());
|
if (mInfo.getGoods().isHasCoupon()) {
|
Log.e("mResult", "isCollection---" + isCollection);
|
qInfo = mInfo.getGoods().getCouponInfo();
|
tv_coupon_state.setVisibility(View.VISIBLE);
|
webview.loadUrl(mInfo.getGoods().getCouponInfo().getLink());
|
} else {
|
tv_coupon_state.setVisibility(View.GONE);
|
openGoods();
|
}
|
|
} else if (is_goods_web_detail.equalsIgnoreCase("1") && getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
|
openGoods();
|
Log.e("mResult", "isCollection---1---" + mInfo.getGoods().isHasCoupon());
|
if (mInfo.getGoods().isHasCoupon()) {
|
qInfo = mInfo.getGoods().getCouponInfo();
|
tv_coupon_state.setVisibility(View.VISIBLE);
|
couponHint();
|
} else {
|
tv_coupon_state.setVisibility(View.GONE);
|
}
|
} else {
|
openGoods();
|
tv_coupon_state.setVisibility(View.GONE);
|
}
|
tv_share_make_money.setText("返利 ¥ " + mInfo.getGoods().getMoneyInfo().getFanliMoney());
|
tv_money.setText("返利:¥" + mInfo.getGoods().getMoneyInfo().getFanliMoney());
|
tv_rebate_num.setText("立即下单 返利:¥" + mInfo.getGoods().getMoneyInfo().getFanliMoney());
|
} else {
|
alibcBasePage = new AlibcDetailPage(id);
|
// AlibcTrade.show(GoodsDetailBrowerActivity.this, webview, mWebviewClient, new MyWebChromeClient(), alibcBasePage,
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
jumpNoLink(alibcBasePage);
|
}
|
}
|
|
@Override
|
public void onFailure(int statusCode, Header[] headers, String
|
responseString, Throwable
|
throwable) {
|
super.onFailure(statusCode, headers, responseString, throwable);
|
Log.e("mResult", "getGoodsdetail()---onFailure()");
|
alibcBasePage = new AlibcDetailPage(id);
|
// AlibcTrade.show(GoodsDetailBrowerActivity.this, webview, mWebviewClient, new MyWebChromeClient(), alibcBasePage,
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
jumpNoLink(alibcBasePage);
|
}
|
|
@Override
|
public void onFinish() {
|
super.onFinish();
|
Log.e("mResult", "getGoodsdetail()---onFinish()");
|
}
|
});
|
}
|
|
private void openGoods() {
|
Log.e("mResult", "openGoods()");
|
alibcBasePage = new AlibcDetailPage(id);
|
// AlibcTrade.show(GoodsDetailBrowerActivity.this, webview, mWebviewClient, new MyWebChromeClient(), alibcBasePage,
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
jumpNoLink(alibcBasePage);
|
}
|
|
private void couponHint() {
|
final BottomDialog dialog = new BottomDialog(this);
|
View view = LayoutInflater.from(this).inflate(R.layout.item_coupon2_hint, null);
|
ImageView iv_close = view.findViewById(R.id.iv_close);
|
FrameLayout fl_webView_coupon = view.findViewById(R.id.fl_webView_coupon);
|
final WebView webView_coupon = new WebView(this);
|
fl_webView_coupon.addView(webView_coupon, new FrameLayout.LayoutParams(
|
FrameLayout.LayoutParams.MATCH_PARENT,
|
FrameLayout.LayoutParams.MATCH_PARENT));
|
WebSettings webSettings = webView_coupon.getSettings();
|
webSettings.setJavaScriptEnabled(true);
|
webSettings.setDomStorageEnabled(true);
|
|
webView_coupon.setDrawingCacheEnabled(true);
|
webView_coupon.setWebViewClient(new WebViewClient() {
|
@Override
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
if (url.contains("/tbopen/") || url.startsWith("tbopen://")) {
|
return true;
|
}
|
return super.shouldOverrideUrlLoading(view, url);
|
}
|
});
|
webView_coupon.loadUrl(qInfo.getLink());
|
LinearLayout ll_refresh = view.findViewById(R.id.fl_refresh);
|
final ImageView iv_refresh = view.findViewById(R.id.iv_refresh);
|
iv_close.setOnClickListener(new OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
dialog.dismiss();
|
}
|
});
|
webView_coupon.setOnClickListener(new OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
Intent intent = new Intent(GoodsDetailBrowerActivity.this, ShareBrowserActivity.class);
|
intent.putExtra("url", qInfo.getLink());
|
startActivity(intent);
|
}
|
});
|
ll_refresh.setOnClickListener(new OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
RotateAnimation an = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
|
an.setInterpolator(new LinearInterpolator());//不停顿
|
an.setRepeatCount(1000);//重复次数
|
an.setFillAfter(true);//停在最后
|
an.setDuration(1000);
|
iv_refresh.setAnimation(an);
|
iv_refresh.startAnimation(an);
|
refresh(iv_refresh);
|
}
|
});
|
dialog.setContentView(view);
|
dialog.show();
|
if (!AlibcLogin.getInstance().isLogin()) {
|
tbLogin();
|
}
|
}
|
|
private boolean isCollection = false;
|
|
private void refresh(final ImageView iv) {
|
SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
String uid = sp.getString("uid", "");
|
ShoppingApi.getGoodsInfoTB(this, id, uid, isTrolley ? "购物车" : isWeex ? "weex" : "其它", new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optString("code").equalsIgnoreCase("0")) {
|
Log.i("mResult", "onSuccessPerfect");
|
|
Gson gson = new GsonBuilder().serializeNulls().create();
|
GoodsDetail info = gson.fromJson(jsonObject.optJSONObject("data").toString(), new TypeToken<GoodsDetail>() {
|
}.getType());
|
mInfo = info;
|
isCollection = info.getExtra().isCollected();
|
if (isCollection) {
|
tv_like_state.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_like_goods_detail_light, 0, 0);
|
tv_like_state.setText("已收藏");
|
} else {
|
tv_like_state.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_like_goods_detail, 0, 0);
|
tv_like_state.setText("收藏");
|
}
|
|
TbPidInfo tInfo = info.getExtra().getTbPidInfo();
|
alibcTaokeParams.setPid(tInfo.getPid());
|
alibcTaokeParams.setAdzoneid(tInfo.getAdZoneId());
|
alibcTaokeParams.pid = tInfo.getPid();
|
alibcTaokeParams.adzoneid = tInfo.getAdZoneId();
|
alibcTaokeParams.extraParams = new HashMap<>();
|
alibcTaokeParams.extraParams.put("taokeAppkey", tInfo.getAppKey());
|
|
if (getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").equalsIgnoreCase("0")) {
|
if (info.getGoods().isHasCoupon()) {
|
qInfo = info.getGoods().getCouponInfo();
|
tv_coupon_state.setVisibility(View.VISIBLE);
|
webview.loadUrl(info.getGoods().getCouponInfo().getLink());
|
} else {
|
tv_coupon_state.setVisibility(View.GONE);
|
openGoods();
|
}
|
|
} else if (getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").equalsIgnoreCase("1") && getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
|
openGoods();
|
if (info.getGoods().isHasCoupon()) {
|
qInfo = info.getGoods().getCouponInfo();
|
tv_coupon_state.setVisibility(View.VISIBLE);
|
couponHint();
|
} else {
|
tv_coupon_state.setVisibility(View.GONE);
|
}
|
} else {
|
openGoods();
|
tv_coupon_state.setVisibility(View.GONE);
|
}
|
tv_share_make_money.setText("返利 ¥ " + info.getGoods().getMoneyInfo().getFanliMoney());
|
tv_money.setText("返利:¥" + info.getGoods().getMoneyInfo().getFanliMoney());
|
tv_rebate_num.setText("立即下单 返利:¥" + info.getGoods().getMoneyInfo().getFanliMoney());
|
} else {
|
alibcBasePage = new AlibcDetailPage(id);
|
// AlibcTrade.show(GoodsDetailBrowerActivity.this, webview, mWebviewClient, new MyWebChromeClient(), alibcBasePage,
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
jumpNoLink(alibcBasePage);
|
}
|
}
|
|
@Override
|
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
|
super.onFailure(statusCode, headers, responseString, throwable);
|
alibcBasePage = new AlibcDetailPage(id);
|
// AlibcTrade.show(GoodsDetailBrowerActivity.this, webview, mWebviewClient, new MyWebChromeClient(), alibcBasePage,
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
jumpNoLink(alibcBasePage);
|
}
|
|
@Override
|
public void onFinish() {
|
super.onFinish();
|
iv.clearAnimation();
|
}
|
});
|
}
|
|
@Override
|
public void onResume() {
|
super.onResume();
|
MobclickAgent.onPageStart("网页");
|
if (!getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
|
if (getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").contains("0")) {
|
findViewById(R.id.tv_prombt).setVisibility(View.GONE);
|
} else {
|
findViewById(R.id.tv_prombt).setVisibility(View.VISIBLE);
|
}
|
ll_no_login.setVisibility(View.VISIBLE);
|
ll_already_login.setVisibility(View.GONE);
|
} else {
|
findViewById(R.id.tv_prombt).setVisibility(View.GONE);
|
ll_no_login.setVisibility(View.GONE);
|
ll_already_login.setVisibility(View.VISIBLE);
|
if (isFirstLogin) {
|
login();
|
}
|
}
|
}
|
|
@Override
|
public void onPause() {
|
super.onPause();
|
MobclickAgent.onPageEnd("网页");
|
}
|
|
@Override
|
protected void onDestroy() {
|
super.onDestroy();
|
|
}
|
|
|
@Override
|
protected void onStop() {
|
super.onStop();
|
}
|
|
@Override
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
CallbackContext.onActivityResult(requestCode, resultCode, data);
|
}
|
|
@Override
|
public void onClick(View v) {
|
switch (v.getId()) {
|
case R.id.tv_top_bar_left: {
|
if (!webview.canGoBack()) {
|
finish();
|
} else {
|
webview.goBack();
|
}
|
}
|
break;
|
case R.id.tv_top_bar_left2: {
|
finish();
|
}
|
break;
|
case R.id.tv_coupon_state: {
|
if (mInfo == null) {
|
// SingleToast.showToast(GoodsDetailBrowerActivity.this, "没有获取到优惠券信息,请稍等!");
|
Toast.makeText(GoodsDetailBrowerActivity.this, "没有获取到优惠券信息", Toast.LENGTH_SHORT).show();
|
return;
|
}
|
if (mInfo.getGoods().isHasCoupon()) {
|
couponHint();
|
} else {
|
// SingleToast.showToast(GoodsDetailBrowerActivity.this, "此商品没有优惠券!");
|
Toast.makeText(GoodsDetailBrowerActivity.this, "此商品没有优惠券", Toast.LENGTH_SHORT).show();
|
}
|
}
|
break;
|
case R.id.tv_like_state: {
|
if (mInfo == null) {
|
// SingleToast.showToast(GoodsDetailBrowerActivity.this, "没有获取到商品收藏状态,请稍等!");
|
Toast.makeText(GoodsDetailBrowerActivity.this, "没有获取到商品收藏状态", Toast.LENGTH_SHORT).show();
|
return;
|
}
|
collection();
|
}
|
break;
|
case R.id.iv_doubt: {
|
Intent intent = new Intent(this, ShareBrowserActivity.class);
|
intent.putExtra("title", "帮助中心");
|
intent.putExtra("url", getSharedPreferences("user", MODE_PRIVATE).getString("help", ""));
|
startActivity(intent);
|
}
|
break;
|
case R.id.tv_login: {
|
UserUtil.jumpLogin(GoodsDetailBrowerActivity.this);
|
}
|
break;
|
case R.id.iv_top_bar_right1: {
|
tradeCallback = new MiDuoTradeCallback("");
|
getGoodsdetail();
|
}
|
break;
|
case R.id.v_cover_goods_detail: {
|
mTopRightPopupWindow.dismiss();
|
}
|
break;
|
case R.id.iv_top_bar_right2: {
|
boolean isTrolley = getIntent().getBooleanExtra("isTrolley", false);
|
if (isTrolley) {
|
v_cover.setVisibility(View.VISIBLE);
|
mTopRightPopupWindow.showAsDropDown(iv_top_bar_right2);
|
} else {
|
if (mInfo != null) {
|
if (mInfo != null) {
|
getTaobaoShareLink();
|
} else {
|
Toast.makeText(GoodsDetailBrowerActivity.this, "暂未获取到分享返利,请稍等", Toast.LENGTH_LONG).show();
|
}
|
} else {
|
Toast.makeText(GoodsDetailBrowerActivity.this, "暂未获取到分享返利,请稍等", Toast.LENGTH_LONG).show();
|
}
|
}
|
}
|
break;
|
default:
|
break;
|
}
|
}
|
|
private void getTaobaoShareLink() {
|
final ShapeLoadingDialog pb = new ShapeLoadingDialog.Builder(this).build();
|
pb.show();
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0");
|
ShoppingApi.createShareLink(this, uid, mInfo.getGoods().getGoodsId(), mInfo.getGoods().getGoodsType() + "", "", null,null, new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optString("code").equalsIgnoreCase("0")) {
|
JSONObject data = jsonObject.optJSONObject("data");
|
SingleGoodsShareInfo shareInfo = new Gson().fromJson(data.toString(), SingleGoodsShareInfo.class);
|
shareInfo.setGoodsInfo(mInfo.getGoods());
|
Intent intent = new Intent(GoodsDetailBrowerActivity.this, ShareGoodsImageActivity31.class);
|
intent.putExtra("shareInfo", shareInfo);
|
startActivity(intent);
|
}
|
}
|
|
@Override
|
public void onFinish() {
|
super.onFinish();
|
pb.dismiss();
|
}
|
});
|
}
|
|
private void collection() {
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0");
|
ShoppingApi.collectionGoods(GoodsDetailBrowerActivity.this, id, uid, isCollection ? "2" : "1", mInfo.getGoods().getGoodsType() + "", new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optString("code").equalsIgnoreCase("0")) {
|
isCollection = !isCollection;
|
if (isCollection) {
|
tv_like_state.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_like_goods_detail_light, 0, 0);
|
tv_like_state.setText("已收藏");
|
} else {
|
tv_like_state.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_like_goods_detail, 0, 0);
|
tv_like_state.setText("收藏");
|
}
|
// SingleToast.showToast(GoodsDetailBrowerActivity.this, jsonObject.optString("data"));
|
Toast.makeText(GoodsDetailBrowerActivity.this, jsonObject.optString("data"), Toast.LENGTH_SHORT).show();
|
} else {
|
// SingleToast.showToast(GoodsDetailBrowerActivity.this, jsonObject.optString("msg"));
|
Toast.makeText(GoodsDetailBrowerActivity.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show();
|
}
|
}
|
|
});
|
}
|
|
@Override
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
|
finish();
|
return true;
|
}
|
return super.onKeyDown(keyCode, event);
|
}
|
|
|
private void tbLogin() {
|
final AlibcLogin alibcLogin = AlibcLogin.getInstance();
|
if (!alibcLogin.isLogin()) {
|
BindDialog.Builder builder = new BindDialog.Builder(GoodsDetailBrowerActivity.this);
|
builder.setMessage("为确保订单有返利,请授权登录淘宝账号。").setPositiveButtonColor(2).setNegativeButtonColor(2).setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialogInterface, int i) {
|
dialogInterface.dismiss();
|
}
|
}).setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialogInterface, int i) {
|
alibcLogin.showLogin(new AlibcLoginCallback() {
|
|
@Override
|
public void onSuccess(int i, String s, String s1) {
|
SharedPreferences.Editor editor = getSharedPreferences("user",
|
MODE_PRIVATE).edit();
|
editor.putString("TrolleyTransformationLink", "");
|
editor.commit();
|
Toast.makeText(GoodsDetailBrowerActivity.this, "恭喜你,登录成功",
|
Toast.LENGTH_LONG).show();
|
}
|
|
@Override
|
public void onFailure(int code, String msg) {
|
if (isFirstLogin) {
|
InitAlibcSdk.init();
|
isFirstLogin = false;
|
}
|
Toast.makeText(GoodsDetailBrowerActivity.this, "登录失败,请稍候再试",
|
Toast.LENGTH_LONG).show();
|
MobclickAgent.reportError(GoodsDetailBrowerActivity.this, "GoodsDetailBrowerActivity---tbLogin---code:" + code + "---msg:" + msg);
|
}
|
});
|
dialogInterface.dismiss();
|
}
|
}).create().show();
|
}
|
}
|
|
/**
|
* 百川详情页跳转网页
|
*/
|
private void jumpWeb(String url) {
|
alibcShowParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeJumpH5);
|
// AlibcTrade.openByUrl(GoodsDetailBrowerActivity.this, "webDetail",
|
// url, webview, mWebviewClient, new WebChromeClient(),
|
// alibcShowParams, alibcTaokeParams, null, tradeCallback);
|
|
AlibcTradeUtil.openByUrl(GoodsDetailBrowerActivity.this,
|
url, webview, mWebviewClient, new WebChromeClient(),
|
alibcShowParams, alibcTaokeParams, null);
|
}
|
|
/**
|
* 百川非link跳转
|
*/
|
private void jumpNoLink(AlibcBasePage basePage) {
|
AlibcTrade.openByBizCode(GoodsDetailBrowerActivity.this, basePage, webview,
|
mWebviewClient, new WebChromeClient(), "nativeDetail", alibcShowParams,
|
alibcTaokeParams, null, tradeCallback);
|
}
|
}
|