Explorar o código

game appointment

billyyoyo %!s(int64=6) %!d(string=hai) anos
pai
achega
a0937fda21

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

@@ -1961,6 +1961,9 @@ public interface ApiService {
     @POST("app/user/clear_pay_pwd")
     Observable<BaseMessage> clearPayPwd();
 
+    @POST("app/user/send_mobile_sms_captcha")
+    Observable<BaseMessage> sendCommonCaptcha(@Body JSONObject jsonObject);
+
     @POST("app/user/send_sms_captcha")
     Observable<BaseMessage> sendSmsCaptcha();
 
@@ -1994,4 +1997,7 @@ public interface ApiService {
     @POST("app/advertising_v2/create/statistics")
     Observable<BaseMessage> statAdAction(@Body JSONObject json);
 
+    @POST("app/find/mobile_appointment")
+    Observable<BaseMessage> appointGame(@Body JSONObject json);
+
 }

+ 9 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/Applications.java

@@ -99,7 +99,16 @@ public class Applications implements IDownload, IGameGroup, Serializable {
     private int welfare_num = 0;
     //赏金数量
     private double reward_sum = 0;
+    //1下载  2预约
+    private int mobile_appointment=0;
 
+    public int getMobile_appointment() {
+        return mobile_appointment;
+    }
+
+    public void setMobile_appointment(int mobile_appointment) {
+        this.mobile_appointment = mobile_appointment;
+    }
     public int getGame_discount_id() {
         return game_discount_id;
     }

+ 8 - 2
app/src/main/java/com/sheep/gamegroup/module/game/activity/ActGameGroupOrGameDetail.java

@@ -42,6 +42,7 @@ import com.sheep.gamegroup.module.game.fragment.FgtGameDetail;
 import com.sheep.gamegroup.module.game.fragment.FgtGameGift;
 import com.sheep.gamegroup.module.game.fragment.FgtGameWelfare;
 import com.sheep.gamegroup.module.game.model.GameGroup;
+import com.sheep.gamegroup.module.game.util.GameAppointHelper;
 import com.sheep.gamegroup.util.ApiUtil;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
@@ -319,13 +320,18 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
                 recyclerView.getAdapter().notifyDataSetChanged();
         }
         //下载按钮
-        CommonUtil.getInstance().palyGameDetailBtnValue(false, gameEntity, gc_game_app_detail_bt2, 0);
+        if(gameEntity.getApp().getMobile_appointment()==1) {
+            CommonUtil.getInstance().palyGameDetailBtnValue(false, gameEntity, gc_game_app_detail_bt2, 0);
+        }else{
+            ViewUtil.setText(gc_game_app_detail_bt2, "立即预约");
+            ViewUtil.setOnClickListener(gc_game_app_detail_bt2, v->new GameAppointHelper(this, gameEntity).showAppointDialog());
+        }
         fgtGameDetail.loadData(gameEntity);
         ViewUtil.setVisibility(gc_game_app_detail_bt3, gameEntity.getApp().hasGameDiscountId());
         ViewUtil.setVisibility(gc_game_app_hot_iv, gameEntity.getApp().getIsHot() == 1);
         ViewUtil.setVisibility(gc_game_app_discount_desc_btn, gameEntity.getApp().hasGameDiscountId());
 
-        if (isAutoDownload) {//可以进行自动下载
+        if (isAutoDownload && gameEntity.getApp().getMobile_appointment()==1) {//可以进行自动下载
             if (!PackageUtil.isAppInstalled(SheepApp.getInstance(), gameEntity.getApp().getPackage_name())) {//未安装的情况才进行下载
                 gc_game_app_detail_bt2.performLongClick();
             }

+ 144 - 0
app/src/main/java/com/sheep/gamegroup/module/game/util/GameAppointHelper.java

@@ -0,0 +1,144 @@
+package com.sheep.gamegroup.module.game.util;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.GameEntity;
+import com.sheep.gamegroup.model.entity.UserEntity;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.util.DataUtil;
+import com.sheep.gamegroup.util.RxjavaCountDownTimer;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.groups.creditcard.RegexUtils;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.G;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+
+public class GameAppointHelper {
+
+    private GameEntity game;
+
+    private Context context;
+
+    @BindView(R.id.mobile_view)
+    TextView mobile_view;
+    @BindView(R.id.code_view)
+    TextView code_view;
+    @BindView(R.id.get_code_btn)
+    TextView get_code_btn;
+
+    boolean hasMobile = false;
+
+    public GameAppointHelper(Context context, GameEntity game) {
+        this.context = context;
+        this.game = game;
+        hasMobile = DataUtil.getInstance().getUserEntity().isBindMobile();
+    }
+
+    public void showAppointDialog() {
+        View content = bindView();
+        ViewUtil.showConfirmDialog(context, "请输入手机号", content, "取消", "提交预约", false, (dialog) -> {
+            if (!RegexUtils.isMobileSimple(mobile_view.getText().toString())) {
+                G.showToast("请输入正确的手机号");
+                return;
+            }
+            if (!hasMobile) {
+                if (TextUtils.isEmpty(code_view.getText().toString())) {
+                    G.showToast("请输入验证码");
+                    return;
+                }
+            }
+            appoint(dialog);
+        }).show();
+    }
+
+    private void appoint(Dialog dialog) {
+        JSONObject json = new JSONObject();
+        json.put("app_id", game.getApp().getId());
+        json.put("mobile", mobile_view.getText().toString());
+        if (!hasMobile) {
+            json.put("captcha", code_view.getText().toString());
+        }
+        SheepApp.getInstance()
+                .getNetComponent()
+                .getApiService()
+                .appointGame(json)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(context) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        G.showToast(baseMessage);
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        G.showToast("预约成功");
+                        dialog.dismiss();
+                    }
+                });
+    }
+
+    private View bindView() {
+        View view = LayoutInflater.from(context).inflate(R.layout.dialog_game_appoint, null, false);
+        ButterKnife.bind(this, view);
+        if (hasMobile) {
+            ViewUtil.setVisibility(code_view, !hasMobile);
+            ViewUtil.setVisibility(get_code_btn, !hasMobile);
+        }
+        return view;
+    }
+
+    @OnClick(R.id.get_code_btn)
+    void getCode() {
+        if (!RegexUtils.isMobileSimple(mobile_view.getText().toString())) {
+            G.showToast("请输入正确的手机号");
+            return;
+        }
+        JSONObject json = new JSONObject();
+        json.put("mobile", mobile_view.getText().toString());
+        SheepApp.getInstance().getNetComponent().getApiService().sendCommonCaptcha(json)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        ViewUtil.setEnabled(get_code_btn, false);
+                        G.shortToast("验证码已发送");
+                        RxjavaCountDownTimer.getInstance(60)
+                                .setOnTickListener(new RxjavaCountDownTimer.OnTickListener() {
+                                    @Override
+                                    public void onFinish() {
+                                        ViewUtil.setEnabled(get_code_btn, true);
+                                        ViewUtil.setText(get_code_btn, "获取验证码");
+                                    }
+
+                                    @Override
+                                    public void onTicker(long time) {
+                                        ViewUtil.setText(get_code_btn, (time / 1000) + "秒");
+                                    }
+                                }).start();
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        G.showToast(baseMessage);
+                    }
+                });
+    }
+
+}

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

@@ -1441,12 +1441,6 @@ public class Jump2View {
                 .setShowCamera(false)
                 .setShowGif(false)
                 .setPreviewEnabled(true)
-                .setPicker(ListUtil.asList(new ListUtil.CallBack<File, String>() {
-                    @Override
-                    public String call(File file) {
-                        return file.getAbsolutePath();
-                    }
-                }, files))
                 .start(activity, PhotoPicker.REQUEST_CODE);
     }
 

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

@@ -1417,6 +1417,37 @@ public class ViewUtil {
         return dialog;
     }
 
+    public static AlertDialog showConfirmDialog(Context mContext
+            , String title
+            , View content
+            , String cancelText
+            , String confirmString
+            , boolean isDismiss
+            , OnConfirDialogListener confirmListener) {
+        View container = View.inflate(mContext, R.layout.dialog_confirm, null);
+        final AlertDialog dialog = new AlertDialog.Builder(mContext, mContext instanceof Activity ? R.style.MyDialogActivityTheme : R.style.AppTheme_Dialog_Alert)
+                .setView(container)
+                .create();
+        TextView titleView = container.findViewById(R.id.dialog_title);
+        titleView.setText(title);
+        LinearLayout contentContainer = container.findViewById(R.id.dialog_center_ll);
+        contentContainer.addView(content, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+        TextView cancelBtn = container.findViewById(R.id.cancel_btn);
+        cancelBtn.setText(cancelText);
+        cancelBtn.setOnClickListener((v) -> {
+            dialog.dismiss();
+        });
+        TextView confirmBtn = container.findViewById(R.id.confirm_btn);
+        confirmBtn.setText(confirmString);
+        confirmBtn.setOnClickListener((v) -> {
+            if(isDismiss) {
+                dialog.dismiss();
+            }
+            confirmListener.onActin(dialog);
+        });
+        return dialog;
+    }
+
     public interface OnConfirDialogListener {
         void onActin(Dialog d);
     }
@@ -2041,7 +2072,7 @@ public class ViewUtil {
         }
     }
 
-    public static void setGif(ImageView imageView, int resId){
+    public static void setGif(ImageView imageView, int resId) {
         GlideApp.with(imageView)
                 .asGif()
                 .load(resId)

+ 3 - 3
app/src/main/res/layout/dialog_confirm.xml

@@ -38,13 +38,13 @@
             android:layout_width="match_parent"
             android:layout_height="1dp"
             android:layout_below="@id/dialog_title"
-            android:background="#cccccc" />
+            android:background="#eeeeee" />
 
         <View
             android:layout_width="match_parent"
             android:layout_height="1dp"
             android:layout_below="@id/dialog_center_ll"
-            android:background="#cccccc" />
+            android:background="#eeeeee" />
 
         <LinearLayout
             android:layout_width="match_parent"
@@ -66,7 +66,7 @@
                 android:layout_width="1dp"
                 android:layout_height="match_parent"
                 android:layout_below="@id/dialog_center_ll"
-                android:background="#cccccc" />
+                android:background="#eeeeee" />
 
             <TextView
                 android:id="@+id/confirm_btn"

+ 50 - 0
app/src/main/res/layout/dialog_game_appoint.xml

@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingBottom="12dp">
+
+    <EditText
+        android:id="@+id/mobile_view"
+        android:hint="请输入手机号"
+        android:textSize="13sp"
+        android:inputType="phone"
+        android:textColor="#333333"
+        android:paddingLeft="8dp"
+        android:paddingRight="8dp"
+        android:layout_marginTop="12dp"
+        android:layout_marginLeft="12dp"
+        android:layout_marginRight="12dp"
+        android:background="@drawable/shape_blue_stroke_rectangle_3_radius"
+        android:layout_width="match_parent"
+        android:layout_height="40dp" />
+
+    <EditText
+        android:id="@+id/code_view"
+        android:hint="请输入验证码"
+        android:textColor="#333333"
+        android:textSize="13sp"
+        android:paddingLeft="8dp"
+        android:paddingRight="8dp"
+        android:layout_below="@+id/mobile_view"
+        android:layout_marginTop="12dp"
+        android:layout_marginLeft="12dp"
+        android:layout_marginRight="12dp"
+        android:background="@drawable/shape_blue_stroke_rectangle_3_radius"
+        android:layout_toLeftOf="@+id/get_code_btn"
+        android:layout_width="match_parent"
+        android:layout_height="40dp" />
+
+    <Button
+        android:id="@+id/get_code_btn"
+        android:text="获取验证码"
+        android:textColor="@color/white"
+        android:textSize="13sp"
+        android:layout_below="@+id/mobile_view"
+        android:layout_marginTop="12dp"
+        android:layout_alignParentRight="true"
+        android:background="@drawable/shape_btn_blue"
+        android:layout_marginRight="12dp"
+        android:layout_width="120dp"
+        android:layout_height="40dp" />
+</RelativeLayout>