Explorar o código

3.4.7基本上只剩下游戏福利了

zengjiebin %!s(int64=7) %!d(string=hai) anos
pai
achega
0b03f4de13
Modificáronse 21 ficheiros con 315 adicións e 130 borrados
  1. 2 56
      app/src/main/java/com/sheep/gamegroup/module/user/activity/ActVip.java
  2. 2 2
      app/src/main/java/com/sheep/gamegroup/module/user/model/BuyVipReq.java
  3. 12 3
      app/src/main/java/com/sheep/gamegroup/module/yf_shop/model/ReceiveCouponsCheckResq.java
  4. 4 0
      app/src/main/java/com/sheep/gamegroup/module/yf_shop/model/ReceiveCouponsResp.java
  5. 19 1
      app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java
  6. 0 7
      app/src/main/java/com/sheep/gamegroup/util/ConnectAddress.java
  7. 3 1
      app/src/main/java/com/sheep/gamegroup/util/IDConstant.java
  8. 34 34
      app/src/main/java/com/sheep/gamegroup/util/Jump2View.java
  9. 2 2
      app/src/main/java/com/sheep/gamegroup/util/TestUtil.java
  10. 74 1
      app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java
  11. 3 0
      app/src/main/java/com/sheep/gamegroup/util/js/BaseActWeb.java
  12. 62 0
      app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java
  13. 17 3
      app/src/main/java/com/sheep/gamegroup/util/string/SpannableSb.java
  14. 8 18
      app/src/main/java/com/sheep/gamegroup/view/activity/SplashAct.java
  15. 1 2
      app/src/main/java/com/sheep/jiuyan/samllsheep/Config.java
  16. BIN=BIN
      app/src/main/res/drawable-xxhdpi/bg_yf_shop_ad.png
  17. BIN=BIN
      app/src/main/res/drawable-xxhdpi/bg_yf_shop_ad_quan.webp
  18. BIN=BIN
      app/src/main/res/drawable-xxhdpi/bg_yf_shop_btn.png
  19. 69 0
      app/src/main/res/layout/dialog_yf_shop_ad.xml
  20. 1 0
      app/src/main/res/values/common.xml
  21. 2 0
      app/src/main/res/values/strings.xml

+ 2 - 56
app/src/main/java/com/sheep/gamegroup/module/user/activity/ActVip.java

@@ -4,31 +4,22 @@ import android.content.Context;
 import android.support.v4.content.ContextCompat;
 import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
 import android.view.View;
 import android.widget.TextView;
 
 import com.chad.library.adapter.base.BaseQuickAdapter;
 import com.chad.library.adapter.base.BaseViewHolder;
-import com.sheep.gamegroup.absBase.AbsObserver;
 import com.sheep.gamegroup.absBase.BaseActivity;
-import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.module.user.model.BuyVipReq;
-import com.sheep.gamegroup.module.user.model.TempUserResp;
-import com.sheep.gamegroup.util.ApiJSONUtil;
-import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.ListUtil;
-import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.util.js.KFZSJs;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
-import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Locale;
 
 import butterknife.BindView;
 
@@ -92,52 +83,7 @@ public class ActVip extends BaseActivity {
     public void onClickPay(View view) {
         BuyVipReq item = ListUtil.getItem(list, curPosition);
         if(item != null){
-            ApiJSONUtil.postBuyVip(1, item.getPay_type())
-                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                        @Override
-                        public void onError(BaseMessage baseMessage) {
-                            G.showToast(baseMessage);
-                        }
-
-                        @Override
-                        public void onNext(BaseMessage baseMessage) {
-                            TempUserResp result = baseMessage.getData(TempUserResp.class);
-                            if(result != null && !TextUtils.isEmpty(result.getPay_url())) {
-                                switch (item.getPay_type()){
-                                    case BuyVipReq.PAY_TYPE_ALIPAY:
-                                        CommonUtil.getInstance().alipay(ActVip.this, result.getPay_url(), true, new AbsObserver<String>() {
-                                            @Override
-                                            public void onNext(String result) {
-                                                switch (result){
-                                                    case "9000":
-                                                        G.showToast(R.string.pay_success);
-                                                        break;
-                                                    case "6001":
-                                                        G.showToast(R.string.you_had_cancel_pay);
-                                                        break;
-                                                    default:
-                                                        G.showToast(R.string.pay_fail);
-                                                        break;
-                                                }
-                                                LogUtil.println(ActVip.class.getSimpleName(), String.format(Locale.CHINA, "alipay onNext('%s')", result));
-                                            }
-
-                                            @Override
-                                            public void onError(Throwable e) {
-                                                G.showToast(e);
-                                                LogUtil.println(ActVip.class.getSimpleName(), String.format(Locale.CHINA, "alipay onError('%s')", e.getMessage()));
-                                            }
-                                        });
-                                        break;
-                                    case BuyVipReq.PAY_TYPE_WX:
-                                        G.showToast(R.string.coming_soon);
-                                        break;
-                                }
-                            } else {
-                                G.showToast(R.string.please_contact_customer_service);
-                            }
-                        }
-                    });
+            KFZSJs.buyVip(this, item);
         }
 
     }

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/module/user/model/BuyVipReq.java

@@ -16,8 +16,8 @@ import java.lang.annotation.RetentionPolicy;
  * 支付方式 1:支付宝 2:微信
  */
 public class BuyVipReq {
-    private int level;
-    private int pay_type;
+    private int level = 1;
+    private int pay_type = PAY_TYPE_ALIPAY;
     private String pay_name;
 
     public int getLevel() {

+ 12 - 3
app/src/main/java/com/sheep/gamegroup/module/yf_shop/model/ReceiveCouponsCheckResq.java

@@ -1,5 +1,7 @@
 package com.sheep.gamegroup.module.yf_shop.model;
 
+import com.kfzs.duanduan.utils.NumberFormatUtils;
+
 /**
  * Created by realicing on 2018/12/24.
  * realicing@sina.com
@@ -29,7 +31,14 @@ public class ReceiveCouponsCheckResq {
     public void setStatus(int status) {
         this.status = status;
     }
-//    代金券类型 1:新手任务完成领取 2:h5任务领取 默认1
-    public static final int TYPE_NEW_TASK = 1;//新手任务完成领取
-    public static final int TYPE_H5_TASK = 2;//h5任务领取
+
+    //未领取优惠券
+    public boolean notReceive() {
+        return status == 2;
+    }
+
+    //返回金额的字符串形式
+    public String getAmountText() {
+        return NumberFormatUtils.retainMost2(amount);
+    }
 }

+ 4 - 0
app/src/main/java/com/sheep/gamegroup/module/yf_shop/model/ReceiveCouponsResp.java

@@ -38,4 +38,8 @@ public class ReceiveCouponsResp {
     public void setType(int type) {
         this.type = type;
     }
+
+    //    代金券类型 1:新手任务完成领取 2:h5任务领取 默认1
+    public static final int TYPE_NEW_TASK = 1;//新手任务完成领取
+    public static final int TYPE_H5_TASK = 2;//h5任务领取
 }

+ 19 - 1
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -549,6 +549,15 @@ public class CommonUtil {
             case IDConstant.JUMP_COIN_CENTER://金币中心
                 Jump2View.getInstance().goActCoinCenter();
                 break;
+            case IDConstant.JUMP_VIP://vip
+                Jump2View.getInstance().gotoVip(activity);
+                break;
+            case IDConstant.JUMP_LONG_MAO://龙猫
+                Jump2View.getInstance().gotoLongMao(activity);
+                break;
+            case IDConstant.JUMP_YF_SHOP://商城
+                Jump2View.getInstance().gotoYfShop(activity);
+                break;
             default:
                 String url = jump.getUrl();
                 if (TextUtils.isEmpty(url))
@@ -1015,7 +1024,7 @@ public class CommonUtil {
      */
     public void initUrlConfigByNet(final String name, final Action1<String> action1) {
         JSONObject url_config = DataUtil.getInstance().getCacheResult(ApiKey.url, JSONObject.class);
-        if (name == null || url_config == null) {
+        if (name == null || url_config == null || !url_config.containsKey(name)) {
             SheepApp.getInstance()
                     .getNetComponent()
                     .getApiService()
@@ -2255,6 +2264,15 @@ public class CommonUtil {
                 }
                 Jump2View.getInstance().goWatchFocus(activity, ext.getId());
                 break;
+            case IDConstant.JUMP_VIP://vip
+                Jump2View.getInstance().gotoVip(activity);
+                break;
+            case IDConstant.JUMP_LONG_MAO://龙猫
+                Jump2View.getInstance().gotoLongMao(activity);
+                break;
+            case IDConstant.JUMP_YF_SHOP://商城
+                Jump2View.getInstance().gotoYfShop(activity);
+                break;
             default:
                 G.showToast(R.string.coming_soon);
                 break;

+ 0 - 7
app/src/main/java/com/sheep/gamegroup/util/ConnectAddress.java

@@ -104,9 +104,6 @@ public enum ConnectAddress {
         public String getYfShotHomeSheep(){
             return Config.YF_SHOP_HOME_SHEEP;
         }
-        public String getVipUrl(){
-            return Config.URL_VIP;
-        }
 
     };
     public abstract String getAppUrl();
@@ -134,10 +131,6 @@ public enum ConnectAddress {
     public String getYfShotHomeSheep(){
         return Config.YF_SHOP_HOME_SHEEP_TEST;
     }
-    //VIP h5地址
-    public String getVipUrl(){
-        return Config.URL_VIP_TEST;
-    }
 
     public int getVersionType() {
         switch (this){

+ 3 - 1
app/src/main/java/com/sheep/gamegroup/util/IDConstant.java

@@ -50,8 +50,10 @@ public class IDConstant {
     public static final int JUMP_EVERY_DAY_SHARE = 307;//每日分享
     public static final int JUMP_ENTERTAINMENT_LUCK_DRAW = 308;//娱乐抽奖
     public static final int JUMP_COIN_CENTER = 309;//金币中心
+    public static final int JUMP_VIP = 310;//跳转vip
+    public static final int JUMP_LONG_MAO = 311;//跳转龙猫
+    public static final int JUMP_YF_SHOP = 312;//跳转优惠购物
 
     //TODO 这里移动积分兑换的id需要替换
     public static final int JUMP_EXCHANGE_CMCC = 1000025;//移动积分兑换
-    public static final int JUMP_EXCHANGE_COUPON = 1000026;//绵羊币兑换商城优惠券
 }

+ 34 - 34
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -55,6 +55,7 @@ import com.sheep.gamegroup.module.plugin.model.Plugin;
 import com.sheep.gamegroup.module.plugin.util.SheepPluginUtil;
 import com.sheep.gamegroup.module.user.activity.ActVip;
 import com.sheep.gamegroup.module.yf_shop.model.ReceiveCouponsCheckResq;
+import com.sheep.gamegroup.module.yf_shop.model.ReceiveCouponsResp;
 import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.activity.ActApprenticeRedPacket;
 import com.sheep.gamegroup.view.activity.ActArticleComment;
@@ -1494,56 +1495,54 @@ public class Jump2View {
             return;
         }
         CommonUtil.getInstance().callActionWithUserInfo(userEntity ->
-                Observable.create((ObservableOnSubscribe<Boolean>) emitter -> {
+                Observable.create((ObservableOnSubscribe<Object>) emitter -> {
                     if (userEntity.alreadyFinishAllNewTask()) {//已经完成所有新手任务
                         //没有兑换过优惠券时,显示商城优惠券
-                        SheepApp.getInstance().getNetComponent().getApiService().getYfShopReceiveCouponsCheck(ReceiveCouponsCheckResq.TYPE_NEW_TASK)
+                        SheepApp.getInstance().getNetComponent().getApiService().getYfShopReceiveCouponsCheck(ReceiveCouponsResp.TYPE_NEW_TASK)
                                 .subscribeOn(Schedulers.io())
                                 .observeOn(AndroidSchedulers.mainThread())
                                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                                     @Override
                                     public void onNext(BaseMessage baseMessage) {
-                                        emitter.onNext(false);
+                                        emitter.onNext(baseMessage);
                                     }
 
                                     @Override
                                     public void onError(BaseMessage baseMessage) {
-                                        emitter.onNext(true);
+                                        emitter.onNext(1);
                                     }
                                 });
                     } else {
-                        emitter.onNext(true);
+                        emitter.onNext(1);
                     }
                 }).subscribeOn(Schedulers.io())
                         .observeOn(AndroidSchedulers.mainThread())
-                        .subscribe(new AbsObserver<Boolean>() {
+                        .subscribe(new AbsObserver<Object>() {
                             @Override
-                            public void onNext(Boolean showAd) {
-                                if (showAd) {//显示开屏广告
-                                    SheepApp.getInstance().getNetComponent().getApiService().getAdvertising(2)
-                                            .subscribeOn(Schedulers.io())
-                                            .observeOn(AndroidSchedulers.mainThread())
-                                            .subscribe(new SheepSubscriber<BaseMessage>(activity) {
-                                                @Override
-                                                public void onNext(BaseMessage baseMessage) {
-                                                    Advertising advertising = baseMessage.getData(Advertising.class);
-                                                    ViewUtil.showHalfScreenAd(activity, advertising, container);
-                                                }
-
-                                                @Override
-                                                public void onError(BaseMessage baseMessage) {
-                                                    tryShowReservation(activity);
-                                                }
-                                            });
-                                } else {//显示商城
-                                    Advertising advertising = new Advertising();
-                                    advertising.setName("兑换商城优惠券,优惠多多");
-//                    advertising.setDesc("点击兑换商城优惠券,优惠多多");
-                                    advertising.setDisplay_type(Advertising.TYPE_IMG);
-                                    advertising.setDisplay_src(ViewUtil.getNetImgByName("homepage_xinshourw"));
-                                    advertising.setLinkType(IDConstant.JUMP_EXCHANGE_COUPON);
-                                    ViewUtil.showHalfScreenAd(activity, advertising, container);
+                            public void onNext(Object result) {
+                                if (result instanceof BaseMessage) {
+                                    ReceiveCouponsCheckResq data = ((BaseMessage) result).getData(ReceiveCouponsCheckResq.class);
+                                    if(data.notReceive()) {//未领取显示领取优惠券
+                                        ViewUtil.showYfShopAd(activity, data, container);
+                                        return;
+                                    }
                                 }
+                                //显示商城
+                                SheepApp.getInstance().getNetComponent().getApiService().getAdvertising(2)
+                                        .subscribeOn(Schedulers.io())
+                                        .observeOn(AndroidSchedulers.mainThread())
+                                        .subscribe(new SheepSubscriber<BaseMessage>(activity) {
+                                            @Override
+                                            public void onNext(BaseMessage baseMessage) {
+                                                Advertising advertising = baseMessage.getData(Advertising.class);
+                                                ViewUtil.showHalfScreenAd(activity, advertising, container);
+                                            }
+
+                                            @Override
+                                            public void onError(BaseMessage baseMessage) {
+                                                tryShowReservation(activity);
+                                            }
+                                        });
                             }
                         }));
     }
@@ -2482,9 +2481,10 @@ public class Jump2View {
      * @param activity
      */
     public void gotoVip(Activity activity) {
-        String url = SheepApp.getInstance().getConnectAddress().getVipUrl();
-        WebParams webParams = new WebParams(url).setShowTitle(false);
-        goWeb(activity, webParams);
+        CommonUtil.getInstance().initUrlConfigByNet(Config.KEY_BUY_VIP_URL, url -> {
+            WebParams webParams = new WebParams(url).setShowTitle(false);
+            goWeb(activity, webParams);
+        });
     }
     /**
      * 小绵羊3.4.7新增 -- 跳转VIP介绍界面

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/util/TestUtil.java

@@ -868,7 +868,7 @@ public class TestUtil {
 
     //开启后可 测试充值与绑定微信和身份信息逻辑 等
     public static boolean isDev() {
-        return BuildConfig.DEBUG;
-//        return false;
+//        return BuildConfig.DEBUG;
+        return false;
     }
 }

+ 74 - 1
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -12,6 +12,7 @@ import android.content.Intent;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
 import android.graphics.Color;
+import android.graphics.Typeface;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.media.MediaPlayer;
@@ -67,6 +68,7 @@ import com.sheep.gamegroup.absBase.ITag;
 import com.sheep.gamegroup.dateview.DatePickerDialog;
 import com.sheep.gamegroup.dateview.DateUtil;
 import com.sheep.gamegroup.model.entity.Advertising;
+import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.Container;
 import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.model.entity.GameAccountEntity;
@@ -75,8 +77,12 @@ import com.sheep.gamegroup.model.entity.Lp;
 import com.sheep.gamegroup.model.entity.PayEntity;
 import com.sheep.gamegroup.model.entity.RobTask;
 import com.sheep.gamegroup.model.entity.TaskEty;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.module.yf_shop.model.ReceiveCouponsCheckResq;
+import com.sheep.gamegroup.module.yf_shop.model.ReceiveCouponsResp;
 import com.sheep.gamegroup.util.glide.RoundedCornersTransformation;
 import com.sheep.gamegroup.util.share.ShareLinkConfig;
+import com.sheep.gamegroup.util.string.SpannableSb;
 import com.sheep.gamegroup.util.viewHelper.LayoutParamsUtil;
 import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.activity.PersonalInfoAct;
@@ -1362,6 +1368,7 @@ public class ViewUtil {
     }
 
 
+    //展示弹窗广告
     public static void showHalfScreenAd(final Activity activity, final Advertising advertising, Container<Action1<Integer>> container) {
         if (activity != null) {
             View dialog_parent = View.inflate(activity, R.layout.dialog_parent, null);
@@ -1484,7 +1491,11 @@ public class ViewUtil {
                 }
             });
             if (TextUtils.isEmpty(advertising.getDesc())) {
-                ad_msg.setVisibility(View.GONE);
+                ViewUtil.setVisibility(ad_msg, false);
+                //3.4.7添加 -- 不显示标题栏,不显示背景 start
+                ViewUtil.setVisibility(dialog_title, false);
+                dialog_center_ll.setBackgroundColor(Color.TRANSPARENT);
+                //3.4.7添加 -- 不显示标题栏,不显示背景 end
             } else {
                 ad_msg.setText(advertising.getDesc());
             }
@@ -1496,6 +1507,68 @@ public class ViewUtil {
         }
     }
 
+    //3.4.7添加 -- 展示商城优惠券领取对话框
+    public static void showYfShopAd(final Activity activity, ReceiveCouponsCheckResq data, Container<Action1<Integer>> container) {
+        if (activity != null) {
+            View dialog_parent = View.inflate(activity, R.layout.dialog_parent, null);
+            final AlertDialog dialog = new AlertDialog.Builder(activity, R.style.MyDialogActivityTheme)
+                    .setView(dialog_parent)
+                    .create();
+            TextView dialog_title = dialog_parent.findViewById(R.id.dialog_title);
+            final View dialog_close = dialog_parent.findViewById(R.id.dialog_close);
+            final LinearLayout dialog_center_ll = dialog_parent.findViewById(R.id.dialog_center_ll);
+            View view = LayoutInflater.from(activity).inflate(R.layout.dialog_yf_shop_ad, dialog_center_ll, true);
+            ViewUtil.setVisibility(dialog_title, false);
+            dialog_center_ll.setBackgroundColor(Color.TRANSPARENT);
+
+            TextView dialog_yf_shop_ad_yuan_tv = view.findViewById(R.id.dialog_yf_shop_ad_yuan_tv);
+            TextView dialog_yf_shop_ad_tip_tv = view.findViewById(R.id.dialog_yf_shop_ad_tip_tv);
+            TextView dialog_yf_shop_ad_btn_tv = view.findViewById(R.id.dialog_yf_shop_ad_btn_tv);
+
+            ViewUtil.setText(dialog_yf_shop_ad_yuan_tv, new SpannableSb().append("¥", R.dimen.text_size_2).append(data.getAmountText(), R.dimen.text_size_28).setTextStyle(Typeface.BOLD).getSsb());
+            ViewUtil.setText(dialog_yf_shop_ad_tip_tv, R.string.yf_shop_quan_tip, data.getAmountText());
+            dialog_close.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    dialog.dismiss();
+                }
+            });
+            dialog_yf_shop_ad_btn_tv.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    //调用接口兑换商城优惠券, 然后跳转到对应的商城h5界面
+                    ApiJSONUtil.postYfShopReceiveCoupons(ReceiveCouponsResp.TYPE_NEW_TASK, 6f)
+                            .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                                @Override
+                                public void onError(BaseMessage baseMessage) {
+                                    G.showToast(baseMessage);
+                                }
+
+                                @Override
+                                public void onNext(BaseMessage baseMessage) {
+                                    G.showToast(baseMessage);
+                                    ReceiveCouponsResp data = baseMessage.getData(ReceiveCouponsResp.class);
+                                    if(data != null){
+                                        Jump2View.getInstance().goWeb(activity, data.getBuy_url(), Config.YF_SHOP_NAME);
+                                    }
+                                }
+                            });
+                }
+            });
+            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
+                @Override
+                public void onDismiss(DialogInterface dialogInterface) {
+                    Jump2View.getInstance().tryShowReservation(activity);
+                }
+            });
+            try {
+                dialog.show();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
     //显示定向货币详情
     public static void showOrienteeringDetails(Activity activity) {
         new DialogOrienteeringDetails(activity).showOrienteeringDetails();

+ 3 - 0
app/src/main/java/com/sheep/gamegroup/util/js/BaseActWeb.java

@@ -45,6 +45,9 @@ public abstract class BaseActWeb extends BaseUMActivity {
     }
 
     public static String addUrlQuery(String url, String key, String value) {
+        if(url.contains("?"+key+"=") || url.contains("#"+key+"=") || url.contains("&"+key+"=")){
+            return url;
+        }
         return url + ((url.contains("?") || url.contains("#") && url.contains("=")) ? "&" : "?") + key + "=" + value;
     }
     public void setH5Type(String h5Type) {

+ 62 - 0
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -1,17 +1,26 @@
 package com.sheep.gamegroup.util.js;
 
+import android.app.Activity;
 import android.text.TextUtils;
 import android.webkit.JavascriptInterface;
 
 import com.sheep.gamegroup.absBase.AbsObserver;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.module.user.activity.ActVip;
+import com.sheep.gamegroup.module.user.model.BuyVipReq;
+import com.sheep.gamegroup.module.user.model.TempUserResp;
+import com.sheep.gamegroup.util.ApiJSONUtil;
 import com.sheep.gamegroup.util.ApiUtil;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.DeviceUtil;
 import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.QQUtil;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.share.ShareLinkConfig;
+import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
@@ -210,4 +219,57 @@ public class KFZSJs {
             }
         });
     }
+    @JavascriptInterface
+    public void buyVip(int level, int pay_type){
+        buyVip(activity, new BuyVipReq());
+    }
+    //购买vip
+    public static void buyVip(Activity activity, BuyVipReq item){
+        ApiJSONUtil.postBuyVip(item.getLevel(), item.getPay_type())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        G.showToast(baseMessage);
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        TempUserResp result = baseMessage.getData(TempUserResp.class);
+                        if(result != null && !TextUtils.isEmpty(result.getPay_url())) {
+                            switch (item.getPay_type()){
+                                case BuyVipReq.PAY_TYPE_ALIPAY:
+                                    CommonUtil.getInstance().alipay(activity, result.getPay_url(), true, new AbsObserver<String>() {
+                                        @Override
+                                        public void onNext(String result) {
+                                            switch (result){
+                                                case "9000":
+                                                    G.showToast(R.string.pay_success);
+                                                    break;
+                                                case "6001":
+                                                    G.showToast(R.string.you_had_cancel_pay);
+                                                    break;
+                                                default:
+                                                    G.showToast(R.string.pay_fail);
+                                                    break;
+                                            }
+                                            LogUtil.println(ActVip.class.getSimpleName(), String.format(Locale.CHINA, "alipay onNext('%s')", result));
+                                        }
+
+                                        @Override
+                                        public void onError(Throwable e) {
+                                            G.showToast(e);
+                                            LogUtil.println(ActVip.class.getSimpleName(), String.format(Locale.CHINA, "alipay onError('%s')", e.getMessage()));
+                                        }
+                                    });
+                                    break;
+                                case BuyVipReq.PAY_TYPE_WX:
+                                    G.showToast(R.string.coming_soon);
+                                    break;
+                            }
+                        } else {
+                            G.showToast(R.string.please_contact_customer_service);
+                        }
+                    }
+                });
+    }
 }

+ 17 - 3
app/src/main/java/com/sheep/gamegroup/util/string/SpannableSb.java

@@ -2,12 +2,15 @@ package com.sheep.gamegroup.util.string;
 
 import android.graphics.Color;
 import android.support.annotation.DimenRes;
+import android.text.ParcelableSpan;
 import android.text.Spannable;
 import android.text.SpannableStringBuilder;
+import android.text.Spanned;
 import android.text.TextUtils;
 import android.text.style.AbsoluteSizeSpan;
 import android.text.style.ForegroundColorSpan;
 import android.text.style.ImageSpan;
+import android.text.style.StyleSpan;
 
 import com.sheep.gamegroup.util.ResourceUtils;
 import com.sheep.jiuyan.samllsheep.SheepApp;
@@ -47,13 +50,24 @@ public class SpannableSb {
     public SpannableSb setTextSize(@DimenRes int textSize) {
         //AbsoluteSizeSpan 参数 dip: size单位为px,true;size单位为dip(默认为false)。
         AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(ResourceUtils.getXmlDef(textSize), true);
-        ssb.setSpan(absoluteSizeSpan, start, end, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
+        ssb.setSpan(absoluteSizeSpan, start, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
         return this;
     }
 
     public SpannableSb setTextColor(String textColor) {
         ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor(textColor));
-        ssb.setSpan(colorSpan, start, end, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
+        ssb.setSpan(colorSpan, start, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
+        return this;
+    }
+    //设置字体样式: NORMAL正常,BOLD粗体,ITALIC斜体,BOLD_ITALIC粗斜体  如: android.graphics.Typeface.BOLD
+    public SpannableSb setTextStyle(int textStyle) {
+        StyleSpan colorSpan = new StyleSpan(textStyle);
+        ssb.setSpan(colorSpan, start, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
+        return this;
+    }
+    //设置样式
+    public SpannableSb setTextSpan(ParcelableSpan span) {
+        ssb.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
         return this;
     }
     public SpannableSb append(String text, @DimenRes int textSize) {
@@ -79,7 +93,7 @@ public class SpannableSb {
 //
 //        Spannable.SPAN_INCLUSIVE_EXCLUSIVE  //前包括后不包括
 //
-//        Spannable.SPAN_EXCLUSIVE_INCLUSIVE  //前不包括后包括
+//        Spanned.SPAN_EXCLUSIVE_INCLUSIVE  //前不包括后包括
 //
 //        Spannable.SPAN_INCLUSIVE_INCLUSIVE  //前后都包括
         return this;

+ 8 - 18
app/src/main/java/com/sheep/gamegroup/view/activity/SplashAct.java

@@ -438,24 +438,14 @@ public class SplashAct extends BaseActivity implements EasyPermissions.Permissio
                 case JUMP_WATCH_FOCUS://看点
                     Jump2View.getInstance().goWatchFocus(activity, advertising.getLink_id());
                     break;
-                case IDConstant.JUMP_EXCHANGE_COUPON://绵羊币兑换商城优惠券
-                    //调用接口兑换商城优惠券, 然后跳转到对应的商城h5界面
-                    ApiJSONUtil.postYfShopReceiveCoupons(ReceiveCouponsCheckResq.TYPE_NEW_TASK, 6f)
-                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                            @Override
-                            public void onError(BaseMessage baseMessage) {
-                                G.showToast(baseMessage);
-                            }
-
-                            @Override
-                            public void onNext(BaseMessage baseMessage) {
-                                G.showToast(baseMessage);
-                                ReceiveCouponsResp data = baseMessage.getData(ReceiveCouponsResp.class);
-                                if(data != null){
-                                    Jump2View.getInstance().goWeb(activity, data.getBuy_url(), advertising.getName());
-                                }
-                            }
-                        });
+                case IDConstant.JUMP_VIP://vip
+                    Jump2View.getInstance().gotoVip(activity);
+                    break;
+                case IDConstant.JUMP_LONG_MAO://龙猫
+                    Jump2View.getInstance().gotoLongMao(activity);
+                    break;
+                case IDConstant.JUMP_YF_SHOP://商城
+                    Jump2View.getInstance().gotoYfShop(activity);
                     break;
             }
         }

+ 1 - 2
app/src/main/java/com/sheep/jiuyan/samllsheep/Config.java

@@ -27,7 +27,6 @@ public class Config {
     public static final String LONG_MAO_APP_URI = "guess://longmao";
 
     //vip h5配置
-    public static final String URL_VIP = "http://10.8.220.229:8088/#/vip-desc";
-    public static final String URL_VIP_TEST = "http://10.8.220.229:8088/#/vip-desc";
+    public static final String KEY_BUY_VIP_URL = "buy_vip_url";
 
 }

BIN=BIN
app/src/main/res/drawable-xxhdpi/bg_yf_shop_ad.png


BIN=BIN
app/src/main/res/drawable-xxhdpi/bg_yf_shop_ad_quan.webp


BIN=BIN
app/src/main/res/drawable-xxhdpi/bg_yf_shop_btn.png


+ 69 - 0
app/src/main/res/layout/dialog_yf_shop_ad.xml

@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@drawable/bg_yf_shop_ad"
+    android:orientation="vertical">
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="22dp"
+        android:gravity="center"
+        android:text="@string/yf_shop_quan_title"
+        android:textColor="#fff8532f"
+        android:textSize="16sp" />
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_horizontal"
+        android:layout_marginTop="33dp"
+        android:background="@drawable/bg_yf_shop_ad_quan"
+        android:gravity="center_vertical"
+        android:orientation="horizontal">
+
+        <TextView
+            android:id="@+id/dialog_yf_shop_ad_yuan_tv"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="21"
+            android:gravity="center"
+            android:text="¥50"
+            android:textColor="#ffffffff"
+            android:textSize="28sp" />
+
+        <TextView
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="39"
+            android:gravity="center"
+            android:text="商城抵扣券"
+            android:textColor="#fffb4e12"
+            android:textSize="15sp" />
+    </LinearLayout>
+
+    <TextView
+        android:id="@+id/dialog_yf_shop_ad_tip_tv"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="66dp"
+        android:layout_marginTop="22dp"
+        android:layout_marginEnd="66dp"
+        android:text="@string/yf_shop_quan_tip"
+        android:textColor="#ff2b2813"
+        android:textSize="13sp" />
+
+    <TextView
+        android:id="@+id/dialog_yf_shop_ad_btn_tv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_horizontal"
+        android:layout_marginTop="70dp"
+        android:textStyle="bold"
+        android:gravity="center"
+        android:background="@drawable/bg_yf_shop_btn"
+        android:text="进入商城"
+        android:textColor="#fff64c2f"
+        android:textSize="13sp" />
+</LinearLayout>

+ 1 - 0
app/src/main/res/values/common.xml

@@ -27,6 +27,7 @@
     <dimen name="text_size_17">17sp</dimen>
     <dimen name="text_size_20">20sp</dimen>
     <dimen name="text_size_25">25sp</dimen>
+    <dimen name="text_size_28">28sp</dimen>
     <dimen name="text_size_32">32sp</dimen>
 
     <!--一般layout的高度-->

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -208,5 +208,7 @@
     <string name="you_had_cancel_pay">您取消了支付</string>
     <string name="task_detail_vip_tip">做任务可提高收益哦,任务优先审核</string>
     <string name="get_money_x_yuan">账户入账通知 尊敬的羊羊用户,恭喜元宝账户收入XXX元。</string>
+    <string name="yf_shop_quan_tip">恭喜你获得%s元商品劵,你可前往商城,直接选择心仪的商品哦~</string>
+    <string name="yf_shop_quan_title">—— 商城优惠券  ——</string>
 
 </resources>