Explorar el Código

领取我的宠物后才会在个人中心中显示我的宠物入口;
添加微信支付

zengjiebin hace 7 años
padre
commit
3501919bfc
Se han modificado 24 ficheros con 412 adiciones y 430 borrados
  1. 0 0
      app/src/developSheeptest/java/com/sheep/jiuyan/samllsheep/wxapi/WXEntryActivity.java
  2. 7 0
      app/src/developSheeptest/java/com/sheep/jiuyan/samllsheep/wxapi/WXPayEntryActivity.java
  3. 4 5
      app/src/main/AndroidManifest.xml
  4. 6 0
      app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java
  5. 2 1
      app/src/main/java/com/sheep/gamegroup/module/ad_htxd/model/ArticleAd.java
  6. 70 0
      app/src/main/java/com/sheep/gamegroup/module/pay/activity/SheepWXPayEntryActivity.java
  7. 19 0
      app/src/main/java/com/sheep/gamegroup/util/ApiJSONUtil.java
  8. 18 0
      app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java
  9. 0 12
      app/src/main/java/com/sheep/gamegroup/util/Jump2View.java
  10. 1 1
      app/src/main/java/com/sheep/gamegroup/view/activity/ActSignCard.java
  11. 165 136
      app/src/main/java/com/sheep/gamegroup/view/activity/RechargeAct.java
  12. 1 1
      app/src/main/java/com/sheep/gamegroup/view/activity/SignCardAct.java
  13. 0 242
      app/src/main/java/com/sheep/gamegroup/view/activity/SignRechargeAct.java
  14. 28 0
      app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPersonalCenter.java
  15. 2 0
      app/src/main/java/com/sheep/jiuyan/samllsheep/Config.java
  16. 11 0
      app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java
  17. 24 22
      app/src/main/res/layout/fgt_personalcenter_item_center_one.xml
  18. 19 0
      app/src/main/res/layout/pay_result.xml
  19. 4 10
      app/src/main/res/layout/recharge_act_layout.xml
  20. 3 0
      app/src/main/res/values/strings.xml
  21. 7 0
      app/src/sheep/java/com/sheep/jiuyan/samllsheep/wxapi/WXEntryActivity.java
  22. 7 0
      app/src/sheep/java/com/sheep/jiuyan/samllsheep/wxapi/WXPayEntryActivity.java
  23. 7 0
      app/src/sheeptestjiguang/java/com/sheep/jiuyan/samllsheep/test/wxapi/WXEntryActivity.java
  24. 7 0
      app/src/sheeptestjiguang/java/com/sheep/jiuyan/samllsheep/test/wxapi/WXPayEntryActivity.java

app/src/main/java/com/sheep/jiuyan/samllsheep/wxapi/WXEntryActivity.java → app/src/developSheeptest/java/com/sheep/jiuyan/samllsheep/wxapi/WXEntryActivity.java


+ 7 - 0
app/src/developSheeptest/java/com/sheep/jiuyan/samllsheep/wxapi/WXPayEntryActivity.java

@@ -0,0 +1,7 @@
+package com.sheep.jiuyan.samllsheep.wxapi;
+
+
+import com.sheep.gamegroup.module.pay.activity.SheepWXPayEntryActivity;
+
+public class WXPayEntryActivity extends SheepWXPayEntryActivity {
+}

+ 4 - 5
app/src/main/AndroidManifest.xml

@@ -126,6 +126,10 @@
             android:exported="true"
             android:launchMode="singleTop" />
         <activity
+            android:name=".wxapi.WXPayEntryActivity"
+            android:exported="true"
+            android:launchMode="singleTop"/>
+        <activity
             android:name="com.sheep.gamegroup.view.activity.WebviewAct"
             android:theme="@style/AppActionTheme"
             android:screenOrientation="portrait" />
@@ -461,11 +465,6 @@
             android:theme="@style/AppActionTheme"
             android:screenOrientation="portrait" />
         <activity
-            android:name="com.sheep.gamegroup.view.activity.SignRechargeAct"
-            android:theme="@style/AppActionTheme"
-            android:exported="true"
-            android:screenOrientation="portrait" />
-        <activity
             android:name="com.sheep.gamegroup.view.activity.ActUserNoviceGuidance"
             android:theme="@style/AppActionTheme"
             android:screenOrientation="portrait" />

+ 6 - 0
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -1722,6 +1722,12 @@ public interface ApiService {
      */
     @POST("app/mission/newspring/execute")
     Observable<BaseMessage> missionExecute(@Body JSONObject jsonObject);
+    /**
+     * 执行活动任务
+     * act 任务标识
+     */
+    @GET("app/mission/newspring/getinfo")
+    Observable<BaseMessage> missionGetinfo(@Query("act") int act, @Query("state") int state);
 
 //---------------------------end 小绵羊3.4.10新增 -- app/mission 春节活动-------------------------------------
 }

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/module/ad_htxd/model/ArticleAd.java

@@ -6,6 +6,7 @@ import com.hoc.hoclib.adlib.PNative;
 import com.sheep.gamegroup.model.entity.Article;
 import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 
 import rx.functions.Action1;
@@ -19,7 +20,7 @@ public class ArticleAd extends Article {
 
     public static final String FEED = "1D0JLRMA102V277730B60000552042FE";
     public static final int INDEX = 4;//放在position为4的位置,即第5个
-    public static final boolean showAd = true;//TestUtil.isSheep();//是否显示广告
+    public static final boolean showAd = TestUtil.isSheep();//是否显示广告
 
     private NativeADDataInfo nativeADDataInfo;
     private PNative pNative;

+ 70 - 0
app/src/main/java/com/sheep/gamegroup/module/pay/activity/SheepWXPayEntryActivity.java

@@ -0,0 +1,70 @@
+package com.sheep.gamegroup.module.pay.activity;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+
+import com.sheep.gamegroup.util.ApiJSONUtil;
+import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.jiuyan.samllsheep.Config;
+import com.sheep.jiuyan.samllsheep.R;
+import com.tencent.mm.opensdk.constants.ConstantsAPI;
+import com.tencent.mm.opensdk.modelbase.BaseReq;
+import com.tencent.mm.opensdk.modelbase.BaseResp;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
+import com.tencent.mm.opensdk.openapi.WXAPIFactory;
+
+/**
+ * Created by realicing on 2019/1/29.
+ * realicing@sina.com
+ *
+ * 微信支付回调
+ */
+public abstract class SheepWXPayEntryActivity extends Activity implements IWXAPIEventHandler {
+
+    private static final String TAG = "SheepWXPayEntryActivity";
+
+    private IWXAPI api;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.pay_result);
+
+        api = WXAPIFactory.createWXAPI(this, Config.WX_PAY_APP_ID);
+        api.handleIntent(getIntent(), this);
+    }
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        setIntent(intent);
+        api.handleIntent(intent, this);
+    }
+
+    @Override
+    public void onReq(BaseReq req) {
+    }
+
+    @Override
+    public void onResp(BaseResp resp) {
+        LogUtil.println(TAG, "onPayFinish, errCode = " + resp.errCode);
+        String result = "";
+        if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
+            switch (resp.errCode) {
+                case 0://支付成功
+                    ApiJSONUtil.missionExecute(4);
+                    break;
+                case -1://错误	可能的原因:签名错误、未注册APPID、项目设置APPID不正确、注册的APPID与设置的不匹配、其他异常等。
+                    break;
+                case -2://用户取消	无需处理。发生场景:用户不支付了,点击取消,返回APP。
+                    break;
+            }
+            result = String.valueOf(resp.errCode + 9000);//"9000" 代表支付成功
+        }
+        Jump2View.getInstance().goRechargeResultAct(this, result);
+        finish();
+    }
+}

+ 19 - 0
app/src/main/java/com/sheep/gamegroup/util/ApiJSONUtil.java

@@ -121,4 +121,23 @@ public class ApiJSONUtil {
                     }
                 });
     }
+    //记录支付成功
+    public static void missionExecute(int act) {
+        JSONObject json = new JSONObject();
+        json.put("act", act);
+        SheepApp.getInstance().getNetComponent().getApiService()
+                .missionExecute(json)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        LogUtil.logE(baseMessage.getErrorMsg() + " " + baseMessage.getMsg());
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                    }
+                });
+    }
 }

+ 18 - 0
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -77,6 +77,8 @@ import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
+import com.tencent.mm.opensdk.modelpay.PayReq;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
 import com.umeng.socialize.UMAuthListener;
 import com.umeng.socialize.UMShareAPI;
 import com.umeng.socialize.bean.SHARE_MEDIA;
@@ -1012,6 +1014,22 @@ public class CommonUtil {
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(observer);
     }
+    /**
+     * 微信支付
+     * apk签名:c69316882eada62ae560c31076740400
+     * @param payInfo
+     */
+    public void wxpay(IWXAPI api, final JSONObject payInfo) {
+        PayReq request = new PayReq();
+        request.appId = payInfo.getString("appid");
+        request.partnerId = payInfo.getString("partnerid");
+        request.prepayId = payInfo.getString("prepayid");
+        request.packageValue = payInfo.getString("package");
+        request.nonceStr = payInfo.getString("noncestr");
+        request.timeStamp = payInfo.getString("timestamp");
+        request.sign = payInfo.getString("sign");
+        api.sendReq(request);
+    }
 
     /**
      * ACache.get(context).put("url_config", (JSONObject) urlConfig);

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

@@ -151,7 +151,6 @@ import com.sheep.gamegroup.view.activity.RechargeAct;
 import com.sheep.gamegroup.view.activity.RechargeQAct;
 import com.sheep.gamegroup.view.activity.RechargeResultAct;
 import com.sheep.gamegroup.view.activity.SignRankingsAct;
-import com.sheep.gamegroup.view.activity.SignRechargeAct;
 import com.sheep.gamegroup.view.activity.TaskDetailAct;
 import com.sheep.gamegroup.view.activity.TaskDetailAddQQAct;
 import com.sheep.gamegroup.view.activity.TaskDetailCreditCardAct;
@@ -1495,17 +1494,6 @@ public class Jump2View {
     }
 
     /**
-     * (一元报名充值界面)
-     *
-     * @param context
-     * @param o
-     */
-    public void goSignRechargeAct(Context context, Object o) {
-        Intent intent = new Intent(context, SignRechargeAct.class);
-        context.startActivity(intent);
-    }
-
-    /**
      * 重新登录
      */
     public void gotoLoginAgain() {

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActSignCard.java

@@ -408,7 +408,7 @@ public class ActSignCard extends BaseActivity {
                 } else {
                     ViewUtil.showMsgDialog(activity, new DialogConfig().setMsg("抱歉,你的余额不足,请先去充值或者领取奖励,然后再来参与打卡哦!").setBtnLeftText("去领奖").setBtnRightText("去充值")
                             .setBtnLeftOnClickListener(view -> Jump2View.getInstance().goTryplayView(activity, null))
-                            .setBtnRightOnClickListener(view -> Jump2View.getInstance().goSignRechargeAct(activity, null)));
+                            .setBtnRightOnClickListener(view -> Jump2View.getInstance().goRechargeAct(activity, null)));
                 }
             } else {
                 G.showToast(R.string.service_data_error);

+ 165 - 136
app/src/main/java/com/sheep/gamegroup/view/activity/RechargeAct.java

@@ -1,22 +1,31 @@
 package com.sheep.gamegroup.view.activity;
 
+import android.content.Context;
 import android.content.Intent;
+import android.support.v4.content.ContextCompat;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
 import android.view.View;
-import android.widget.AdapterView;
 import android.widget.EditText;
+import android.widget.TextView;
 
 import com.alibaba.fastjson.JSONObject;
-import com.alipay.sdk.app.PayTask;
+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.alipay.PayResult;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.RechargeEntity;
 import com.sheep.gamegroup.model.entity.RechargePriceEntity;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.module.user.activity.ActVip;
+import com.sheep.gamegroup.util.ApiJSONUtil;
+import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.MyGridview;
-import com.sheep.gamegroup.view.adapter.RechargeAdapter;
+import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.view.adapter.RechargePriceAdapter;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
@@ -25,6 +34,7 @@ import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 
 import butterknife.BindView;
 import butterknife.OnClick;
@@ -40,25 +50,23 @@ import static com.sheep.gamegroup.util.UMConfigUtils.Event.RECHARGE_PAY;
 
 public class RechargeAct extends BaseActivity {
 
-    int mPayType = -1;//选择支付方式的id
-    String mAmount = null;//支付的金额
-
-    private boolean forResult = false;
 
     @BindView(R.id.rechargeprice_greidview)
     MyGridview rechargeprice_greidview;
-    @BindView(R.id.recharge_greidview)
-    MyGridview rechargeGreidview;
-
-    RechargePriceAdapter rechargePriceAdapter;
-    List<RechargePriceEntity> mPriceEntityList = new ArrayList<>();
-    int select = -1;
-
-    RechargeAdapter rechargeAdapter;
+    @BindView(R.id.act_ral_pay_type_rv)
+    RecyclerView act_ral_pay_type_rv;
     @BindView(R.id.et_recharge_price)
     EditText etRechargePrice;
 
 
+    private RechargePriceAdapter rechargePriceAdapter;
+    private List<RechargePriceEntity> mPriceEntityList = new ArrayList<>();
+
+    private int mPayType = -1;//选择支付方式的id
+    private int payTypePosition = -1;//选择支付方式的位置
+    private String mAmount = null;//支付的金额
+    private boolean forResult = false;
+
     @Override
     protected int getLayoutId() {
         return R.layout.recharge_act_layout;
@@ -88,76 +96,59 @@ public class RechargeAct extends BaseActivity {
         rechargePriceAdapter = new RechargePriceAdapter(RechargeAct.this, mPriceEntityList);
         rechargeprice_greidview.setVerticalSpacing(20);
         rechargeprice_greidview.setAdapter(rechargePriceAdapter);
-        rechargeprice_greidview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-            @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                select = position;
-                rechargePriceAdapter.setInPut(false);
-                RechargePriceEntity rechargePriceEntity = (RechargePriceEntity) parent.getItemAtPosition(position);
-                etRechargePrice.setText("" + rechargePriceEntity.getPrice());
-                for (int i = 0; i < mPriceEntityList.size(); i++) {
-                    if (position == i) {
-                        mPriceEntityList.get(i).setSelectState(true);
-                    } else {
-                        mPriceEntityList.get(i).setSelectState(false);
-                    }
+        rechargeprice_greidview.setOnItemClickListener((parent, view, position, id) -> {
+            rechargePriceAdapter.setInPut(false);
+            RechargePriceEntity rechargePriceEntity = (RechargePriceEntity) parent.getItemAtPosition(position);
+            ViewUtil.setText(etRechargePrice, rechargePriceEntity.getPrice());
+            for (int i = 0; i < mPriceEntityList.size(); i++) {
+                if (position == i) {
+                    mPriceEntityList.get(i).setSelectState(true);
+                } else {
+                    mPriceEntityList.get(i).setSelectState(false);
                 }
-                rechargePriceAdapter.notifyDataSetChanged();
-
             }
+            rechargePriceAdapter.notifyDataSetChanged();
+
         });
 
 
         /*
           支付方式选择
          */
-        rechargeAdapter = new RechargeAdapter(RechargeAct.this);
-        rechargeGreidview.setVerticalSpacing(40);
-        rechargeGreidview.setAdapter(rechargeAdapter);
-        rechargeGreidview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+        BaseQuickAdapter<RechargeEntity, BaseViewHolder> rechargeAdapter = new BaseQuickAdapter<RechargeEntity, BaseViewHolder>(R.layout.recharge_gridview_item, rechargeEntityList){
+
             @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                RechargeEntity rechargeEntity = (RechargeEntity) parent.getItemAtPosition(position);
-                mPayType = rechargeEntity.getId();
-                rechargeAdapter.setSelect(position);
-                rechargeAdapter.notifyDataSetChanged();
-            }
-        });
+            protected void convert(BaseViewHolder helper, RechargeEntity item) {
+                int position = helper.getAdapterPosition();
 
-//        etRechargePrice.addTextChangedListener(new TextWatcher() {
-//            @Override
-//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
-//
-//            }
-//
-//            @Override
-//            public void onTextChanged(CharSequence s, int start, int before, int count) {
-//                    if(TextUtils.isEmpty(s)){
-//                        rechargePriceAdapter.setInPut(false);
-//                    }else{
-//                        boolean input = true;
-//                        for(RechargePriceEntity priceEntityList : mPriceEntityList){
-//                            int price = Integer.valueOf(s.toString());
-//                            if(price == priceEntityList.getPrice()){
-//                                input = false;
-//                                break;
-//                            }
-//                        }
-//                        rechargePriceAdapter.setInPut(input);
-//                    }
-//            }
-//
-//            @Override
-//            public void afterTextChanged(Editable s) {
-//
-//            }
-//        });
+                TextView tv_pay = helper.getView(R.id.tv_pay);
 
+                ViewUtil.setText(tv_pay, item.getName());
+                Context context = SheepApp.getInstance();
+                if (position == payTypePosition){
+                    tv_pay.setBackground(context.getResources().getDrawable(R.drawable.layer_list_check_rectgangle_small));
+                    tv_pay.setTextColor(ContextCompat.getColor(context,R.color.main_tab_activated));
+                }else{
+                    tv_pay.setBackground(context.getResources().getDrawable(R.drawable.btn_main_stroke_no_check_small));
+                    tv_pay.setTextColor(ContextCompat.getColor(context,R.color.main_tab));
+
+                }
+                //这里点击
+                tv_pay.setOnClickListener(view -> {
+                    payTypePosition = position;
+                    mPayType = item.getId();
+                    ViewUtil.notifyDataSetChanged(act_ral_pay_type_rv);
+                });
+            }
+        };
+        act_ral_pay_type_rv.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
+        rechargeAdapter.bindToRecyclerView(act_ral_pay_type_rv);
 
         showProgress();
         getRechargePayway();
     }
 
+    private List<RechargeEntity> rechargeEntityList = new ArrayList<>();
     private void getRechargePayway() {
         // 参数 1:没有绵羊币的,2:是全部
         SheepApp.getInstance().getNetComponent().getApiService().getRechargePayway("1")
@@ -168,22 +159,19 @@ public class RechargeAct extends BaseActivity {
                     public void onNext(BaseMessage baseMessage) {
                         hideProgress();
                         List<RechargeEntity> list = baseMessage.getDatas(RechargeEntity.class);
-                        if (list != null && list.size() > 0) {
-                            mPayType = list.get(0).getId();
-                            rechargeAdapter.setSelect(0);
-                        }
-                        rechargeAdapter.addAll(list);
-                        if (!list.isEmpty()) {
-                            mPayType = list.get(0).getId();
-                            rechargeAdapter.setSelect(0);
-                            rechargeAdapter.notifyDataSetChanged();
+                        if (!ListUtil.isEmpty(list)) {
+                            payTypePosition = 0;
+                            mPayType = list.get(payTypePosition).getId();
+                            rechargeEntityList.clear();
+                            rechargeEntityList.addAll(list);
+                            ViewUtil.notifyDataSetChanged(act_ral_pay_type_rv);
                         }
                     }
 
                     @Override
                     public void onError(BaseMessage baseMessage) {
                         hideProgress();
-                        G.showToast(baseMessage.getMsg() + "");
+                        G.showToast(baseMessage);
                     }
                 });
     }
@@ -199,7 +187,15 @@ public class RechargeAct extends BaseActivity {
                     @Override
                     public void onNext(BaseMessage baseMessage) {
                         hideProgress();
-                        pay(baseMessage.getData().toString());
+                        String payInfo = baseMessage.getData().toString();
+                        switch (mPayType){
+                            case 1:
+                                tryAliPay(payInfo);
+                                break;
+                            case 2:
+                                tryWxPay(baseMessage);
+                                break;
+                        }
                     }
 
                     @Override
@@ -210,6 +206,16 @@ public class RechargeAct extends BaseActivity {
                 });
     }
 
+    private void tryWxPay(BaseMessage baseMessage) {
+        JSONObject jsonObject = baseMessage.getData(JSONObject.class);
+        if(jsonObject == null){
+            G.showToast(R.string.please_contact_customer_service);
+            return;
+        }
+        CommonUtil.getInstance().wxpay(SheepApp.getInstance().getWxApi(), jsonObject);
+        finish();
+    }
+
     @OnClick({R.id.tv_recharge_pay})
     public void onViewClicked(View view) {
         switch (view.getId()) {
@@ -234,64 +240,87 @@ public class RechargeAct extends BaseActivity {
         }
     }
 
-    private void pay(final String payInfo) {
-        Runnable payRunnable = new Runnable() {
-
+    private void tryAliPay(final String payInfo) {
+        CommonUtil.getInstance().alipay(this, payInfo, true, new AbsObserver<String>() {
             @Override
-            public void run() {
-                // 构造PayTask 对象
-                PayTask alipay = new PayTask(RechargeAct.this);
-                // 调用支付接口,获取支付结果
-                final String result = alipay.pay(payInfo, true);
-
-                runOnUiThread(new Runnable() {
-
-                    @Override
-                    public void run() {
-
-                        PayResult payResult = new PayResult(result);
-                        /*
-                          同步返回的结果必须放置到服务端进行验证(验证的规则请看https://doc.open.alipay.com/doc2/
-                          detail.htm?spm=0.0.0.0.xdvAU6&treeId=59&articleId=103665&
-                          docType=1) 建议商户依赖异步通知
-                         */
-//						String resultInfo = payResult.getResult();// 同步返回需要验证的信息
-
-                        String resultStatus = payResult.getResultStatus();
-                        if ("9000".equals(resultStatus)) {
-                            JSONObject json = new JSONObject();
-                            json.put("act", 4);
-                            SheepApp.getInstance().getNetComponent().getApiService()
-                                    .missionExecute(json)
-                                    .subscribeOn(Schedulers.io())
-                                    .observeOn(AndroidSchedulers.mainThread())
-                                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                                        @Override
-                                        public void onError(BaseMessage baseMessage) {
-                                            LogUtil.logE(baseMessage.getErrorMsg() + " " + baseMessage.getMsg());
-                                        }
-
-                                        @Override
-                                        public void onNext(BaseMessage baseMessage) {
-                                        }
-                                    });
-                        }
-                        if (forResult && "9000".equals(resultStatus)) {
-                            Intent intent = new Intent();
-                            intent.putExtra("amount", Integer.parseInt(mAmount));
-                            setResult(777, intent);
-                        } else {
-                            Jump2View.getInstance().goRechargeResultAct(RechargeAct.this, resultStatus);
-                        }
-                        finish();
-                    }
-                });
+            public void onNext(String result) {
+                LogUtil.println(ActVip.class.getSimpleName(), String.format(Locale.CHINA, "alipay onNext('%s')", result));
+                if ("9000".equals(result)) {
+                    ApiJSONUtil.missionExecute(4);
+                }
+                if (forResult && "9000".equals(result)) {
+                    Intent intent = new Intent();
+                    intent.putExtra("amount", Integer.parseInt(mAmount));
+                    setResult(777, intent);
+                } else {
+                    Jump2View.getInstance().goRechargeResultAct(RechargeAct.this, result);
+                }
+                finish();
             }
-        };
 
-        // 必须异步调用
-        Thread payThread = new Thread(payRunnable);
-        payThread.start();
+            @Override
+            public void onError(Throwable e) {
+                G.showToast(e);
+                LogUtil.println(ActVip.class.getSimpleName(), String.format(Locale.CHINA, "alipay onError('%s')", e.getMessage()));
+            }
+        });
+//        Runnable payRunnable = new Runnable() {
+//
+//            @Override
+//            public void run() {
+//                // 构造PayTask 对象
+//                PayTask alipay = new PayTask(RechargeAct.this);
+//                // 调用支付接口,获取支付结果
+//                final String result = alipay.tryAliPay(payInfo, true);
+//
+//                runOnUiThread(new Runnable() {
+//
+//                    @Override
+//                    public void run() {
+//
+//                        PayResult payResult = new PayResult(result);
+//                        /*
+//                          同步返回的结果必须放置到服务端进行验证(验证的规则请看https://doc.open.alipay.com/doc2/
+//                          detail.htm?spm=0.0.0.0.xdvAU6&treeId=59&articleId=103665&
+//                          docType=1) 建议商户依赖异步通知
+//                         */
+////						String resultInfo = payResult.getResult();// 同步返回需要验证的信息
+//
+//                        String resultStatus = payResult.getResultStatus();
+//                        if ("9000".equals(resultStatus)) {
+//                            JSONObject json = new JSONObject();
+//                            json.put("act", 4);
+//                            SheepApp.getInstance().getNetComponent().getApiService()
+//                                    .missionExecute(json)
+//                                    .subscribeOn(Schedulers.io())
+//                                    .observeOn(AndroidSchedulers.mainThread())
+//                                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+//                                        @Override
+//                                        public void onError(BaseMessage baseMessage) {
+//                                            LogUtil.logE(baseMessage.getErrorMsg() + " " + baseMessage.getMsg());
+//                                        }
+//
+//                                        @Override
+//                                        public void onNext(BaseMessage baseMessage) {
+//                                        }
+//                                    });
+//                        }
+//                        if (forResult && "9000".equals(resultStatus)) {
+//                            Intent intent = new Intent();
+//                            intent.putExtra("amount", Integer.parseInt(mAmount));
+//                            setResult(777, intent);
+//                        } else {
+//                            Jump2View.getInstance().goRechargeResultAct(RechargeAct.this, resultStatus);
+//                        }
+//                        finish();
+//                    }
+//                });
+//            }
+//        };
+//
+//        // 必须异步调用
+//        Thread payThread = new Thread(payRunnable);
+//        payThread.start();
     }
 
     private void addDatas() {

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/SignCardAct.java

@@ -282,7 +282,7 @@ public class SignCardAct extends BaseActivity implements SignCardContract.View {
                     .setBtnLeftOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View view) {
-                            Jump2View.getInstance().goSignRechargeAct(activity, null);
+                            Jump2View.getInstance().goRechargeAct(activity, null);
                         }
                     }));
         }

+ 0 - 242
app/src/main/java/com/sheep/gamegroup/view/activity/SignRechargeAct.java

@@ -1,242 +0,0 @@
-package com.sheep.gamegroup.view.activity;
-
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.EditText;
-
-import com.alibaba.fastjson.JSONObject;
-import com.alipay.sdk.app.PayTask;
-import com.sheep.gamegroup.absBase.BaseActivity;
-import com.sheep.gamegroup.alipay.PayResult;
-import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.model.entity.RechargeEntity;
-import com.sheep.gamegroup.model.entity.RechargePriceEntity;
-import com.sheep.gamegroup.model.util.SheepSubscriber;
-import com.sheep.gamegroup.util.Jump2View;
-import com.sheep.gamegroup.util.MyGridview;
-import com.sheep.gamegroup.view.adapter.RechargeAdapter;
-import com.sheep.gamegroup.view.adapter.RechargePriceAdapter;
-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 butterknife.BindView;
-import butterknife.OnClick;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.schedulers.Schedulers;
-
-/**
- * Created by Administrator on 2018/3/19.
- * 充值界面
- */
-
-public class SignRechargeAct extends BaseActivity {
-
-    int mPayType = -1;//选择支付方式的id
-    String mAmount = null;//支付的金额
-
-    @BindView(R.id.rechargeprice_greidview)
-    MyGridview rechargeprice_greidview;
-    @BindView(R.id.recharge_greidview)
-    MyGridview rechargeGreidview;
-
-    RechargeAdapter rechargeAdapter;
-    @BindView(R.id.et_recharge_price)
-    EditText etRechargePrice;
-
-    RechargePriceAdapter rechargePriceAdapter;
-    List<RechargePriceEntity> mPriceEntityList = new ArrayList<>();
-    int select = -1;
-
-    @Override
-    protected int getLayoutId() {
-        return R.layout.recharge_act_layout;
-    }
-
-    @Override
-    public void initView() {
-        TitleBarUtils.getInstance()
-                .setTitle(this, "充值")
-                .setShowOrHide(this, true)
-                .setTitleFinish(this);
-    }
-
-    @Override
-    public void initListener() {
-    }
-
-    @Override
-    public void initData() {
-
-        addDatas();
-        /*
-          支付金额选择
-         */
-        rechargePriceAdapter = new RechargePriceAdapter(SignRechargeAct.this, mPriceEntityList);
-        rechargeprice_greidview.setVerticalSpacing(20);
-        rechargeprice_greidview.setAdapter(rechargePriceAdapter);
-        rechargeprice_greidview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-            @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                select = position;
-                rechargePriceAdapter.setInPut(false);
-                RechargePriceEntity rechargePriceEntity = (RechargePriceEntity) parent.getItemAtPosition(position);
-                etRechargePrice.setText("" + rechargePriceEntity.getPrice());
-                for (int i = 0; i < mPriceEntityList.size(); i++) {
-                    if (position == i) {
-                        mPriceEntityList.get(i).setSelectState(true);
-                    } else {
-                        mPriceEntityList.get(i).setSelectState(false);
-                    }
-                }
-                rechargePriceAdapter.notifyDataSetChanged();
-
-            }
-        });
-
-        /*
-          支付方式选择
-         */
-        rechargeAdapter = new RechargeAdapter(SignRechargeAct.this);
-        rechargeGreidview.setVerticalSpacing(40);
-        rechargeGreidview.setAdapter(rechargeAdapter);
-        rechargeGreidview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-            @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                RechargeEntity rechargeEntity = (RechargeEntity) parent.getItemAtPosition(position);
-                mPayType = rechargeEntity.getId();
-                rechargeAdapter.setSelect(position);
-                rechargeAdapter.notifyDataSetChanged();
-            }
-        });
-
-
-        showProgress();
-        getRechargePayway();
-    }
-
-    private void getRechargePayway() {
-        // 参数 1:没有绵羊币的,2:是全部
-        SheepApp.getInstance().getNetComponent().getApiService().getRechargePayway("1")
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new SheepSubscriber<BaseMessage>(SignRechargeAct.this) {
-                    @Override
-                    public void onNext(BaseMessage baseMessage) {
-                        hideProgress();
-                        List<RechargeEntity> list = baseMessage.getDatas(RechargeEntity.class);
-                        if(list != null && list.size() > 0){
-                            mPayType = list.get(0).getId();
-                            rechargeAdapter.setSelect(0);
-                        }
-                        rechargeAdapter.addAll(list);
-                        if(!list.isEmpty()) {
-                            mPayType = list.get(0).getId();
-                            rechargeAdapter.setSelect(0);
-                            rechargeAdapter.notifyDataSetChanged();
-                        }
-                    }
-
-                    @Override
-                    public void onError(BaseMessage baseMessage) {
-                        hideProgress();
-                        G.showToast(baseMessage.getMsg() + "");
-                    }
-                });
-    }
-
-    private void getRechargeBalance() {
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("Amount", Float.valueOf(mAmount));
-        jsonObject.put("PayType", mPayType);
-        SheepApp.getInstance().getNetComponent().getApiService().getRechargeBalance(jsonObject)
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new SheepSubscriber<BaseMessage>(SignRechargeAct.this) {
-                    @Override
-                    public void onNext(BaseMessage baseMessage) {
-                        hideProgress();
-                        pay(baseMessage.getData().toString());
-                    }
-
-                    @Override
-                    public void onError(BaseMessage baseMessage) {
-                        hideProgress();
-                        G.showToast(baseMessage.getMsg() + "");
-                    }
-                });
-    }
-
-    @OnClick({R.id.tv_recharge_pay})
-    public void onViewClicked(View view) {
-        switch (view.getId()) {
-
-            case R.id.tv_recharge_pay:
-                if (mPayType == -1) {
-                    G.showToast("请选择支付方式");
-                    return;
-                }
-
-                mAmount = etRechargePrice.getText().toString().trim();
-                if(android.text.TextUtils.isEmpty(mAmount)){
-                    G.showToast("请输入充值金额");
-                    return;
-                }
-
-
-                showProgress();
-                getRechargeBalance();
-                break;
-        }
-    }
-
-    private void pay(final String payInfo) {
-        Runnable payRunnable = new Runnable() {
-
-            @Override
-            public void run() {
-                // 构造PayTask 对象
-                PayTask alipay = new PayTask(SignRechargeAct.this);
-                // 调用支付接口,获取支付结果
-                final String result = alipay.pay(payInfo, true);
-
-                runOnUiThread(new Runnable() {
-
-                    @Override
-                    public void run() {
-
-                        PayResult payResult = new PayResult(result);
-                        /*
-                          同步返回的结果必须放置到服务端进行验证(验证的规则请看https://doc.open.alipay.com/doc2/
-                          detail.htm?spm=0.0.0.0.xdvAU6&treeId=59&articleId=103665&
-                          docType=1) 建议商户依赖异步通知
-                         */
-//						String resultInfo = payResult.getResult();// 同步返回需要验证的信息
-
-                        String resultStatus = payResult.getResultStatus();
-                        Jump2View.getInstance().goRechargeResultAct(SignRechargeAct.this, resultStatus);
-                        finish();
-                    }
-                });
-            }
-        };
-
-        // 必须异步调用
-        Thread payThread = new Thread(payRunnable);
-        payThread.start();
-    }
-
-
-    private void addDatas() {
-        mPriceEntityList.add(new RechargePriceEntity(false,"10元", 10));
-        mPriceEntityList.add(new RechargePriceEntity(false,"20元", 20));
-        mPriceEntityList.add(new RechargePriceEntity(false,"50元", 50));
-        mPriceEntityList.add(new RechargePriceEntity(false,"100元", 100));
-        mPriceEntityList.add(new RechargePriceEntity(false,"200元", 200));
-        mPriceEntityList.add(new RechargePriceEntity(false,"500元", 500));
-    }
-}

+ 28 - 0
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPersonalCenter.java

@@ -19,6 +19,7 @@ import com.kfzs.duanduan.utils.ApkUtils;
 import com.kfzs.duanduan.utils.NumberFormatUtils;
 import com.sheep.gamegroup.model.entity.AgentEntity;
 import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.Mission;
 import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.model.entity.UserTaskExistsNew;
 import com.sheep.gamegroup.model.entity.WebParams;
@@ -29,6 +30,7 @@ import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.GlideImageLoader;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ListUtil;
+import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.ViewUtil;
@@ -122,6 +124,10 @@ public class FgtPersonalCenter extends BaseFragment {
     TextView vip_flag_view_tv;
     @BindView(R.id.voucher_red_dot)
     View voucher_red_dot;
+    @BindView(R.id.fgt_pc_item_my_pet_v)
+    View fgt_pc_item_my_pet_v;
+    @BindView(R.id.my_pet_layout)
+    View my_pet_layout;
 
     public UserEntity userEntity;
     private String faqUrl;
@@ -223,6 +229,28 @@ public class FgtPersonalCenter extends BaseFragment {
                 });
         initUserModuleItemByACache();
         initUserModuleItem();
+        initMyPetState();
+    }
+
+    private void initMyPetState() {
+        SheepApp.getInstance().getNetComponent().getApiService().missionGetinfo(5, 3)
+                        .subscribeOn(Schedulers.io())
+                        .observeOn(AndroidSchedulers.mainThread())
+                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                            @Override
+                            public void onNext(BaseMessage baseMessage) {
+                                Mission result = baseMessage.getData(Mission.class);
+                                boolean hasPet = result != null && result.getId() > 0;
+                                ViewUtil.setVisibility(my_pet_layout, hasPet);
+                                ViewUtil.setVisibility(fgt_pc_item_my_pet_v, hasPet);
+                            }
+
+                            @Override
+                            public void onError(BaseMessage baseMessage) {
+                                ViewUtil.setVisibility(my_pet_layout, false);
+                                ViewUtil.setVisibility(fgt_pc_item_my_pet_v, false);
+                            }
+                        });
     }
 
 

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

@@ -48,4 +48,6 @@ public class Config {
     //我的宠物地址 key
     public static final String KEY_MY_PET_URL = "my_pet_url";
 
+    //微信支付app_id
+    public static final String WX_PAY_APP_ID = "wx427e8e74e8dd27a6";
 }

+ 11 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java

@@ -54,6 +54,8 @@ import com.squareup.leakcanary.LeakCanary;
 import com.squareup.leakcanary.RefWatcher;
 import com.tencent.bugly.Bugly;
 import com.tencent.bugly.beta.Beta;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.mm.opensdk.openapi.WXAPIFactory;
 import com.tencent.smtt.sdk.QbSdk;
 import com.umeng.commonsdk.UMConfigure;
 import com.umeng.socialize.PlatformConfig;
@@ -289,6 +291,15 @@ public class SheepApp extends MultiDexApplication {
         }
         //初始化换肤框架
         SkinUtil.init();
+        //注册微信支付
+        wxApi = WXAPIFactory.createWXAPI(this, null);
+        // 将该app注册到微信
+        wxApi.registerApp(Config.WX_PAY_APP_ID);
+    }
+    private IWXAPI wxApi;
+
+    public IWXAPI getWxApi() {
+        return wxApi;
     }
 
     private void initBdLocationOption() {

+ 24 - 22
app/src/main/res/layout/fgt_personalcenter_item_center_one.xml

@@ -22,6 +22,7 @@
     </LinearLayout>
 
     <View
+        android:id="@+id/fgt_pc_item_my_pet_v"
         style="@style/style_item_line_new"
         android:visibility="gone" />
     <LinearLayout
@@ -85,27 +86,6 @@
 
     <View style="@style/style_item_line_new" />
 
-    <LinearLayout
-        android:id="@+id/order_layout"
-        style="@style/style_item_container"
-        android:visibility="visible">
-
-        <ImageView
-            style="@style/style_item_img"
-            android:src="@mipmap/order_manager" />
-
-        <TextView
-            style="@style/style_item_label"
-            android:text="订单管理" />
-
-        <TextView
-            style="@style/style_item_end_next"
-            android:visibility="visible" />
-
-    </LinearLayout>
-
-    <View style="@style/style_item_line_new" />
-
     <RelativeLayout
         android:id="@+id/voucher_layout"
         android:layout_width="match_parent"
@@ -151,9 +131,31 @@
 
     </RelativeLayout>
 
+
+    <View style="@style/style_item_line_new" />
+
+    <LinearLayout
+        android:id="@+id/order_layout"
+        style="@style/style_item_container"
+        android:visibility="visible">
+
+        <ImageView
+            style="@style/style_item_img"
+            android:src="@mipmap/order_manager" />
+
+        <TextView
+            style="@style/style_item_label"
+            android:text="订单管理" />
+
+        <TextView
+            style="@style/style_item_end_next"
+            android:visibility="visible" />
+
+    </LinearLayout>
     <View
         android:id="@+id/fgt_person_center_my_focus_line"
-        style="@style/style_item_line_new" />
+        style="@style/style_item_line_new"
+        android:visibility="gone" />
 
     <LinearLayout
         android:id="@+id/fgt_person_center_my_focus"

+ 19 - 0
app/src/main/res/layout/pay_result.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+
+	android:layout_width="fill_parent"
+	android:layout_height="fill_parent"
+	android:orientation="vertical"
+	android:gravity="center_horizontal"
+	android:background="@color/white">
+    
+	<TextView
+	    android:layout_width="fill_parent"
+	 	android:layout_height="fill_parent"
+		android:gravity="center"
+	 	android:textColor="#ff000000"
+	 	android:textSize="20dp"
+	 	android:text="@string/pay_result_tip"/>
+	
+</LinearLayout>

+ 4 - 10
app/src/main/res/layout/recharge_act_layout.xml

@@ -79,19 +79,13 @@
                         android:layout_height="wrap_content"
                         android:text="支付方式" />
 
-                    <com.sheep.gamegroup.util.MyGridview
-                        android:id="@+id/recharge_greidview"
-                        android:layout_width="wrap_content"
+                    <android.support.v7.widget.RecyclerView
+                        android:id="@+id/act_ral_pay_type_rv"
+                        android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_marginLeft="@dimen/content_padding_65"
                         android:layout_marginRight="@dimen/content_padding_65"
-                        android:layout_marginTop="@dimen/content_padding_20"
-                        android:background="@color/white"
-                        android:gravity="center_horizontal"
-                        android:listSelector="@color/transparent"
-                        android:numColumns="1"
-                        android:scrollbars="none"
-                        android:visibility="visible" />
+                        android:layout_marginTop="@dimen/content_padding_20"/>
                 </LinearLayout>
             </LinearLayout>
 

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

@@ -214,4 +214,7 @@
     <string name="yf_shop_ask_tip">恭喜%s用户,元旦邀新活动,你已获得礼品,请前往填写收件信息,羊羊乐园的工作人员将尽快的为你安排发货,请耐心等待!</string>
     <string name="yf_shop_ask_tip_2">恭喜%s用户,元旦邀新活动,你已获得礼品。请耐心等待,羊羊乐园的工作人员将尽快的为你安排发货,!</string>
 
+    <!-- WXPayEntryActivity -->
+    <string name="pay_result_tip">这个界面用于显示第三方app通过微信支付的结果</string>
+    <string name="pay_result_callback_msg" formatted="false">微信支付结果:%s</string>
 </resources>

+ 7 - 0
app/src/sheep/java/com/sheep/jiuyan/samllsheep/wxapi/WXEntryActivity.java

@@ -0,0 +1,7 @@
+package com.sheep.jiuyan.samllsheep.wxapi;
+import com.umeng.socialize.weixin.view.WXCallbackActivity;
+
+public class WXEntryActivity extends WXCallbackActivity {
+
+
+}

+ 7 - 0
app/src/sheep/java/com/sheep/jiuyan/samllsheep/wxapi/WXPayEntryActivity.java

@@ -0,0 +1,7 @@
+package com.sheep.jiuyan.samllsheep.wxapi;
+
+
+import com.sheep.gamegroup.module.pay.activity.SheepWXPayEntryActivity;
+
+public class WXPayEntryActivity extends SheepWXPayEntryActivity {
+}

+ 7 - 0
app/src/sheeptestjiguang/java/com/sheep/jiuyan/samllsheep/test/wxapi/WXEntryActivity.java

@@ -0,0 +1,7 @@
+package com.sheep.jiuyan.samllsheep.wxapi;
+import com.umeng.socialize.weixin.view.WXCallbackActivity;
+
+public class WXEntryActivity extends WXCallbackActivity {
+
+
+}

+ 7 - 0
app/src/sheeptestjiguang/java/com/sheep/jiuyan/samllsheep/test/wxapi/WXPayEntryActivity.java

@@ -0,0 +1,7 @@
+package com.sheep.jiuyan.samllsheep.test.wxapi;
+
+
+import com.sheep.gamegroup.module.pay.activity.SheepWXPayEntryActivity;
+
+public class WXPayEntryActivity extends SheepWXPayEntryActivity {
+}