Browse Source

增加任务审核失败 重新接任务的功能

zhaoyi 8 years ago
parent
commit
6f89c35759
25 changed files with 501 additions and 104 deletions
  1. 1 0
      app/build.gradle
  2. 4 0
      app/proguard-rules.pro
  3. 27 7
      app/src/main/AndroidManifest.xml
  4. 1 0
      app/src/main/java/com/jiuyan/sheep_children/Config.java
  5. 9 0
      app/src/main/java/com/jiuyan/sheep_children/SheepApp.java
  6. 21 2
      app/src/main/java/com/jiuyan/sheep_children/base/BaseActivity.java
  7. 3 0
      app/src/main/java/com/jiuyan/sheep_children/net/Url.java
  8. 9 1
      app/src/main/java/com/jiuyan/sheep_children/page/BindWxActivity.java
  9. 7 36
      app/src/main/java/com/jiuyan/sheep_children/page/DownloadActivity.java
  10. 7 0
      app/src/main/java/com/jiuyan/sheep_children/page/LoginActivity.java
  11. 4 13
      app/src/main/java/com/jiuyan/sheep_children/page/MainActivity.java
  12. 9 0
      app/src/main/java/com/jiuyan/sheep_children/page/ShotScreenActivity.java
  13. 114 1
      app/src/main/java/com/jiuyan/sheep_children/page/TaskRecordActivity.java
  14. 4 1
      app/src/main/java/com/jiuyan/sheep_children/page/UserCenterActivity.java
  15. 35 6
      app/src/main/java/com/jiuyan/sheep_children/page/WithdrawActivity.java
  16. 9 0
      app/src/main/java/com/jiuyan/sheep_children/page/entry/Commit.java
  17. 30 12
      app/src/main/java/com/jiuyan/sheep_children/page/entry/User.java
  18. 94 0
      app/src/main/java/com/jiuyan/sheep_children/utils/PackageUtil.java
  19. 77 0
      app/src/main/java/com/jiuyan/sheep_children/wxapi/WXEntryActivity.java
  20. 16 15
      app/src/main/res/layout/bind_wx_activity.xml
  21. 8 0
      app/src/main/res/layout/line_h_1px_black.xml
  22. 0 1
      app/src/main/res/layout/task_head.xml
  23. 7 4
      app/src/main/res/layout/task_record_item.xml
  24. 4 4
      app/src/main/res/layout/withdraw_activity.xml
  25. 1 1
      app/src/main/res/values/colors.xml

+ 1 - 0
app/build.gradle

@@ -36,6 +36,7 @@ dependencies {
     compile 'org.greenrobot:eventbus:3.1.1'
     compile 'com.zhy:base-adapter:3.0.3'
     compile 'com.liulishuo.filedownloader:library:1.6.9'
+    compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
     debugCompile 'com.readystatesoftware.chuck:library:1.1.0'
     releaseCompile 'com.readystatesoftware.chuck:library-no-op:1.1.0'
 }

+ 4 - 0
app/proguard-rules.pro

@@ -29,3 +29,7 @@
 -dontwarn javax.annotation.**
 # A resource is loaded with a relative path so the package of this class must be preserved.
 -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
+
+-keep class com.tencent.mm.opensdk.** {   *;}
+-keep class com.tencent.wxop.** {   *;}
+-keep class com.tencent.mm.sdk.** {   *;}

+ 27 - 7
app/src/main/AndroidManifest.xml

@@ -9,6 +9,11 @@
     <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.INTERNET"/>
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
+    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+
 
     <permission
         android:name="android.permission.PACKAGE_USAGE_STATS"
@@ -21,6 +26,10 @@
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
         <activity
+            android:name=".wxapi.WXEntryActivity"
+            android:exported="true"
+            android:launchMode="singleTop"/>
+        <activity
             android:name=".page.MainActivity"
             android:exported="true"
             android:launchMode="singleTask"
@@ -33,10 +42,18 @@
             android:name=".page.ShotScreenActivity"
             android:exported="true"
             android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
-        <activity android:name=".page.UserCenterActivity"/>
-        <activity android:name=".page.WithdrawActivity"/>
-        <activity android:name=".page.DownloadActivity"/>
-        <activity android:name=".page.LoginActivity">
+        <activity
+            android:name=".page.UserCenterActivity"
+            android:screenOrientation="portrait"/>
+        <activity
+            android:name=".page.WithdrawActivity"
+            android:screenOrientation="portrait"/>
+        <activity
+            android:name=".page.DownloadActivity"
+            android:screenOrientation="portrait"/>
+        <activity
+            android:name=".page.LoginActivity"
+            android:screenOrientation="portrait">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
 
@@ -62,9 +79,12 @@
                 android:resource="@xml/file_paths"/>
         </provider>
 
-        <activity android:name=".page.BindWxActivity">
-        </activity>
-        <activity android:name=".page.TaskRecordActivity"/>
+        <activity
+            android:name=".page.BindWxActivity"
+            android:screenOrientation="portrait"/>
+        <activity
+            android:name=".page.TaskRecordActivity"
+            android:screenOrientation="portrait"/>
     </application>
 
 </manifest>

+ 1 - 0
app/src/main/java/com/jiuyan/sheep_children/Config.java

@@ -16,6 +16,7 @@ public class Config {
     }
 
     public String mBaseUrl = "http://10.8.220.213:8088";
+    public final static  String WX_APPID = "wx3c0376c4fcc8b723";
     public String[] mUrlList = new String[]{"http://10.8.220.213:8088", "http://10.8.220.213:8089", "http://10.8.220.250:8088"};
 
     public void setBaseUrl(String url) {

+ 9 - 0
app/src/main/java/com/jiuyan/sheep_children/SheepApp.java

@@ -5,6 +5,8 @@ import android.content.Context;
 
 import com.liulishuo.filedownloader.FileDownloader;
 import com.liulishuo.filedownloader.connection.FileDownloadUrlConnection;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.mm.opensdk.openapi.WXAPIFactory;
 
 import java.net.Proxy;
 
@@ -15,11 +17,18 @@ import java.net.Proxy;
 public class SheepApp extends Application {
 
     public static Context mContext;
+    public static IWXAPI mWxapi;
 
     @Override
     public void onCreate() {
         super.onCreate();
         mContext = getApplicationContext();
         FileDownloader.setup(this);
+        regWx();
+    }
+
+    private void regWx() {
+        mWxapi = WXAPIFactory.createWXAPI(this, Config.WX_APPID);
+        mWxapi.registerApp(Config.WX_APPID);
     }
 }

+ 21 - 2
app/src/main/java/com/jiuyan/sheep_children/base/BaseActivity.java

@@ -1,10 +1,18 @@
 package com.jiuyan.sheep_children.base;
 
 import android.app.Activity;
+import android.content.Intent;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
+import android.view.GestureDetector;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
 import android.view.View;
 
+import com.jiuyan.sheep_children.BuildConfig;
+import com.jiuyan.sheep_children.page.MainActivity;
+import com.readystatesoftware.chuck.Chuck;
+
 import org.greenrobot.eventbus.EventBus;
 
 /**
@@ -15,13 +23,24 @@ public abstract class BaseActivity extends Activity {
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-//        EventBus.getDefault().register(this);
+        //        EventBus.getDefault().register(this);
         setContentView(getLayoutId());
         initView();
         initListener();
         initData();
     }
 
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        if (BuildConfig.DEBUG)
+            if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
+                Intent intent = Chuck.getLaunchIntent(BaseActivity.this);
+                startActivity(intent);
+                return true;
+            }
+        return super.onKeyDown(keyCode, event);
+    }
+
     protected abstract int getLayoutId();
 
     public abstract void initView();
@@ -33,6 +52,6 @@ public abstract class BaseActivity extends Activity {
     @Override
     protected void onDestroy() {
         super.onDestroy();
-//        EventBus.getDefault().unregister(this);
+        //        EventBus.getDefault().unregister(this);
     }
 }

+ 3 - 0
app/src/main/java/com/jiuyan/sheep_children/net/Url.java

@@ -10,8 +10,11 @@ public class Url {
     public static String UPLOAD_IMG = Config.instance().mBaseUrl + "/v1/up/";
     public static String PUBLISH_TASKS =Config.instance().mBaseUrl + "/v1/task_publish/getTasks/";
     public static String BIND_WX = Config.instance().mBaseUrl + "/v1/user/bindWx";
+    public static String BIND_ROBOT=Config.instance().mBaseUrl + "/v1/user/getRobot";
     public static String USER_INFO=Config.instance().mBaseUrl + "/v1/user/getUserInfo";
     public static String USER_COMMIT=Config.instance().mBaseUrl + "/v1/user/getDoneTask";
     public static String USER_CHECK_REGISTER=Config.instance().mBaseUrl + "/v1/task_publish/getRegisterTask";
     public static String USER_REGISTER_TASK=Config.instance().mBaseUrl + "/v1/task_publish/registerTask";
+    public static String USER_WITHDRAW=Config.instance().mBaseUrl + "/v1/withDraw/withDraw";
+
 }

+ 9 - 1
app/src/main/java/com/jiuyan/sheep_children/page/BindWxActivity.java

@@ -30,6 +30,7 @@ public class BindWxActivity extends BaseActivity implements View.OnClickListener
     private TextView mTitle;
     private TextInputEditText mEtWx;
     private TextView mTvWx;
+    private TextView mRobot;
 
     @Override
     protected int getLayoutId() {
@@ -42,6 +43,7 @@ public class BindWxActivity extends BaseActivity implements View.OnClickListener
         mTvWx = findViewById(R.id.tv_wx);
         mBack = findViewById(R.id.img_back);
         mTitle = findViewById(R.id.tv_title);
+        mRobot = findViewById(R.id.tv_robot);
         mTitle.setText("绑定微信");
     }
 
@@ -54,7 +56,12 @@ public class BindWxActivity extends BaseActivity implements View.OnClickListener
 
     @Override
     public void initData() {
-
+        NetManager.get(Url.BIND_ROBOT, null, getApplicationContext(), new SheepCallback<String>(this) {
+            @Override
+            public void success(String robot) {
+                mRobot.setText(String.format("添加好友->佣金发放号:%s", robot));
+            }
+        });
     }
 
 
@@ -83,6 +90,7 @@ public class BindWxActivity extends BaseActivity implements View.OnClickListener
                 @Override
                 public void success(String s) {
                     Toast.makeText(BindWxActivity.this, s, Toast.LENGTH_SHORT).show();
+                    finish();
                 }
             });
         }

+ 7 - 36
app/src/main/java/com/jiuyan/sheep_children/page/DownloadActivity.java

@@ -20,28 +20,14 @@ import com.bumptech.glide.Glide;
 import com.jiuyan.sheep_children.R;
 import com.jiuyan.sheep_children.SheepApp;
 import com.jiuyan.sheep_children.base.BaseActivity;
-import com.jiuyan.sheep_children.net.NetManager;
-import com.jiuyan.sheep_children.page.entry.TaskPublish;
+import com.jiuyan.sheep_children.page.entry.Task;
 import com.jiuyan.sheep_children.utils.FileUtil;
+import com.jiuyan.sheep_children.utils.PackageUtil;
 import com.liulishuo.filedownloader.BaseDownloadTask;
 import com.liulishuo.filedownloader.FileDownloadListener;
 import com.liulishuo.filedownloader.FileDownloader;
-import com.liulishuo.filedownloader.connection.FileDownloadConnection;
-import com.liulishuo.filedownloader.services.DownloadMgrInitialParams;
 
 import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.nio.file.Path;
-import java.util.Date;
-
-import okhttp3.Call;
-import okhttp3.Callback;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.Response;
 
 
 /**
@@ -92,15 +78,15 @@ public class DownloadActivity extends BaseActivity {
     public void initData() {
         mTvTitle.setText("任务下载");
         Intent intent = getIntent();
-        TaskPublish task = (TaskPublish) intent.getSerializableExtra("data");
+        Task task = (Task) intent.getSerializableExtra("task");
         mPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/"
                 + SheepApp.mContext.getPackageName();
         mApkPath = new File(mPath, SystemClock.currentThreadTimeMillis() + "_sheepTask.apk").getAbsolutePath();
         if (task != null) {
-            DOWNLOAD_URL = task.getTask().getDownLoadUrl();
-            mTvDesc.setText(task.getTask().getTitle());
+            DOWNLOAD_URL = task.getDownLoadUrl();
+            mTvDesc.setText(task.getTitle());
             Glide.with(this)
-                    .load(task.getTask().getIcon())
+                    .load(task.getIcon())
                     .placeholder(R.drawable.icon)
                     .dontAnimate()
                     .into(mImgIcon);
@@ -155,7 +141,7 @@ public class DownloadActivity extends BaseActivity {
 
                         @Override
                         protected void completed(BaseDownloadTask task) {
-                            installApk(mApkPath);
+                            PackageUtil.installApk(getApplicationContext(),mApkPath);
                             mTvPercent.setText("100%");
                         }
 
@@ -177,19 +163,4 @@ public class DownloadActivity extends BaseActivity {
         mDownloadTask.start();
     }
 
-
-    public void installApk(String path) {
-        File file = new File(path);
-        Intent intent = new Intent(Intent.ACTION_VIEW);
-        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        if (Build.VERSION.SDK_INT >= 24) { //判读版本是否在7.0以上
-            Uri apkUri = FileProvider.getUriForFile(this, "com.jiuyan.sheep_children", file);
-            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
-            intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
-        } else {
-            intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
-        }
-        startActivity(intent);
-    }
-
 }

+ 7 - 0
app/src/main/java/com/jiuyan/sheep_children/page/LoginActivity.java

@@ -15,8 +15,10 @@ import android.widget.TextView;
 import com.jiuyan.sheep_children.BuildConfig;
 import com.jiuyan.sheep_children.Config;
 import com.jiuyan.sheep_children.R;
+import com.jiuyan.sheep_children.SheepApp;
 import com.jiuyan.sheep_children.base.BaseActivity;
 import com.jiuyan.sheep_children.utils.SpUtils;
+import com.tencent.mm.opensdk.modelmsg.SendAuth;
 
 /**
  * Created by kemllor on 2017/12/21.
@@ -99,6 +101,11 @@ public class LoginActivity extends BaseActivity {
     }
 
     private void loginFromWx() {
+       /* SendAuth.Req req = new SendAuth.Req();
+        req.scope = "snsapi_userinfo";
+        req.state = "small_sheep_auther";
+        SheepApp.mWxapi.sendReq(req);*/
+
         SpUtils.login(this, "abcabc");
     }
 

+ 4 - 13
app/src/main/java/com/jiuyan/sheep_children/page/MainActivity.java

@@ -90,16 +90,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
     public void initListener() {
         mTvWithdraw.setOnClickListener(this);
         mDown.setOnClickListener(this);
-        if (BuildConfig.DEBUG)
-            mTvWithdraw.setOnLongClickListener(new View.OnLongClickListener() {
 
-                @Override
-                public boolean onLongClick(View v) {
-                    Intent intent = Chuck.getLaunchIntent(MainActivity.this);
-                    startActivity(intent);
-                    return true;
-                }
-            });
     }
 
 
@@ -117,8 +108,8 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
         NetManager.get(Url.USER_INFO, map, getApplicationContext(), new SheepCallback<User>(this) {
             @Override
             public void success(User user) {
-                mMoney.setText(user.getMoney().getBalance());
-                mToday.setText(String.format("今日收入:%s", user.getMoney().getToday()));
+                mMoney.setText(user.getBalance());
+                mToday.setText(String.format("今日收入:%s", user.getToday()));
             }
         });
     }
@@ -201,13 +192,13 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
     private void registerTask() {
         HashMap<String, String> map = new HashMap<>();
         map.put("wx_open_id", SpUtils.getOpenId(this));
-        map.put("task_id", mClickItem.getTask().getId() + "");
+        map.put("task_id", mClickItem.getId() + "");
         NetManager.get(Url.USER_REGISTER_TASK, map, getApplicationContext(), new SheepCallback<String>(this) {
             @Override
             public void success(String o) {
                 initData();
                 Intent intent = new Intent(MainActivity.this, DownloadActivity.class);
-                intent.putExtra("data", mClickItem);
+                intent.putExtra("task", mClickItem.getTask());
                 startActivity(intent);
             }
         });

+ 9 - 0
app/src/main/java/com/jiuyan/sheep_children/page/ShotScreenActivity.java

@@ -15,6 +15,7 @@ import com.jiuyan.sheep_children.net.NetManager;
 import com.jiuyan.sheep_children.net.SheepCallback;
 import com.jiuyan.sheep_children.net.Url;
 import com.jiuyan.sheep_children.utils.PackageUtil;
+import com.jiuyan.sheep_children.utils.SpUtils;
 import com.shark.screencapture.ScreenCapture;
 
 import java.io.File;
@@ -81,9 +82,17 @@ public class ShotScreenActivity extends Activity {
         }
         HashMap<String, String> parma = new HashMap<>();
         parma.put("task_pkg", topApp);
+        parma.put("wx_open_id", SpUtils.getOpenId(this));
         NetManager.upload(Url.UPLOAD_IMG, parma, new File(path), getApplicationContext(), new SheepCallback<String>(this) {
             @Override
             public void success(String s) {
+                Toast.makeText(ShotScreenActivity.this, s, Toast.LENGTH_SHORT).show();
+                finish();
+            }
+
+            @Override
+            public void otherCode(int code, String string) {
+                super.otherCode(code, string);
                 finish();
             }
 

+ 114 - 1
app/src/main/java/com/jiuyan/sheep_children/page/TaskRecordActivity.java

@@ -1,12 +1,17 @@
 package com.jiuyan.sheep_children.page;
 
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.AdapterView;
 import android.widget.BaseAdapter;
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import com.bumptech.glide.Glide;
 import com.jiuyan.sheep_children.R;
@@ -16,6 +21,7 @@ import com.jiuyan.sheep_children.net.SheepCallback;
 import com.jiuyan.sheep_children.net.Url;
 import com.jiuyan.sheep_children.page.entry.Commit;
 import com.jiuyan.sheep_children.page.entry.TaskPublish;
+import com.jiuyan.sheep_children.utils.PackageUtil;
 import com.jiuyan.sheep_children.utils.SpUtils;
 import com.zhy.adapter.abslistview.CommonAdapter;
 import com.zhy.adapter.abslistview.ViewHolder;
@@ -36,6 +42,9 @@ public class TaskRecordActivity extends BaseActivity {
     private TextView mTvTitle;
     private View mBack;
     private CommonAdapter mAdapter;
+    private List<Commit> mCommits;
+    private AlertDialog mDialog;
+    private AlertDialog mReDialog;
 
     @Override
     protected int getLayoutId() {
@@ -45,6 +54,7 @@ public class TaskRecordActivity extends BaseActivity {
     @Override
     public void initView() {
         mLvTask = findViewById(R.id.lv_task);
+        mLvTask.setDividerHeight(0);
         mTvTitle = findViewById(R.id.tv_title);
         mBack = findViewById(R.id.img_back);
 
@@ -58,6 +68,108 @@ public class TaskRecordActivity extends BaseActivity {
                 finish();
             }
         });
+        mLvTask.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            @Override
+            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+                final Commit commit = mCommits.get(position);
+                if (mDialog == null) {
+                    mDialog = new AlertDialog.Builder(TaskRecordActivity.this)
+                            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+                                @Override
+                                public void onClick(DialogInterface dialog, int which) {
+                                    dispatch(commit);
+                                    mDialog.dismiss();
+                                }
+                            }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
+                                @Override
+                                public void onClick(DialogInterface dialog, int which) {
+                                    mDialog.dismiss();
+                                }
+                            }).create();
+                }
+                mDialog.setMessage(getTip(commit.getStatus()));
+                mDialog.show();
+            }
+        });
+
+    }
+
+    private void dispatch(final Commit commit) {
+        if (commit.getStatus() == 3) {
+            HashMap<String, String> map = new HashMap<>();
+            map.put("wx_open_id", SpUtils.getOpenId(this));
+            NetManager.get(Url.USER_CHECK_REGISTER, map, getApplicationContext(), new SheepCallback<String>(this) {
+                @Override
+                public void success(String ok) {
+                    if (TextUtils.equals(ok, "ok")) {
+                        startRecommitTask(commit);
+                    } else {
+                        showRecommitDialog("你有任务正在进行,是否取消,接受新任务?", commit);
+                    }
+                }
+            });
+        }
+    }
+
+    private void showRecommitDialog(String s, final Commit commit) {
+        if (mReDialog == null) {
+            mReDialog = new AlertDialog.Builder(TaskRecordActivity.this)
+                    .setMessage(s)
+                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            startRecommitTask(commit);
+                            mReDialog.dismiss();
+                        }
+                    }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            mReDialog.dismiss();
+                        }
+                    }).create();
+        }
+        mReDialog.show();
+    }
+
+    private void startRecommitTask(final Commit commit) {
+        HashMap<String, String> map = new HashMap<>();
+        map.put("wx_open_id", SpUtils.getOpenId(this));
+        map.put("task_id", commit.getTaskPublishId() + "");
+        NetManager.get(Url.USER_REGISTER_TASK, map, getApplicationContext(), new SheepCallback<String>(this) {
+            @Override
+            public void success(String o) {
+                String pkg = commit.getTask().getPkg();
+                if (!TextUtils.isEmpty(pkg)) {
+                    boolean installed = PackageUtil.isAppInstalled(getApplicationContext(), pkg);
+                    if (installed) {
+                        PackageUtil.startApp(getApplicationContext(), pkg);
+                    } else {
+                        Intent intent = new Intent(TaskRecordActivity.this, DownloadActivity.class);
+                        intent.putExtra("task", commit.getTask());
+                        startActivity(intent);
+                    }
+                } else {
+                    Toast.makeText(TaskRecordActivity.this, "任务已经重新激活,快去完成吧", Toast.LENGTH_SHORT).show();
+                }
+            }
+        });
+
+    }
+
+    private String getTip(int status) {
+        String str = null;
+        switch (status) {
+            case 1:
+                str = "您提交的任务正在排队审核,请耐心等待,很快就好";
+                break;
+            case 2:
+                str = "您提交的任务已经通过审核,羊毛已经入库~~";
+                break;
+            case 3:
+                str = "您提交的任务审核未通过,是否重新提交";
+                break;
+        }
+        return str;
     }
 
     @Override
@@ -69,11 +181,12 @@ public class TaskRecordActivity extends BaseActivity {
         NetManager.get(Url.USER_COMMIT, map, getApplicationContext(), new SheepCallback<List<Commit>>(this) {
             @Override
             public void success(List<Commit> commits) {
+                mCommits = commits;
                 if (mAdapter == null)
                     mLvTask.setAdapter(mAdapter = new CommonAdapter<Commit>(TaskRecordActivity.this, R.layout.task_record_item, commits) {
                         @Override
                         protected void convert(ViewHolder viewHolder, Commit item, int position) {
-                            String[] tmp1 = item.getCheckTime().split("-");
+                            String[] tmp1 = item.getCreateTime().split("-");
                             String[] tmp2 = tmp1[2].split(" ")[1].split(":");
                             String time = tmp1[1] + "/" + tmp1[2].split(" ")[0] + "\n" + tmp2[0] + ":" + tmp2[1];
                             viewHolder.setText(R.id.tv_time, time);

+ 4 - 1
app/src/main/java/com/jiuyan/sheep_children/page/UserCenterActivity.java

@@ -34,6 +34,7 @@ public class UserCenterActivity extends BaseActivity implements View.OnClickList
     private TextView mTvWithdraw;
     private TextView mTvTask;
     private TextView mTvWithdrawHostroy;
+    private User mUser;
 
 
     @Override
@@ -62,9 +63,10 @@ public class UserCenterActivity extends BaseActivity implements View.OnClickList
         NetManager.get(Url.USER_INFO, map, getApplicationContext(), new SheepCallback<User>(this) {
             @Override
             public void success(User user) {
+                mUser =user;
                 mTvNick.setText(user.getNickName());
                 mTvLevel.setText(user.getWxId());
-                mTvMoney.setText(String.format("账户余额:%s", user.getMoney().getBalance()));
+                mTvMoney.setText(String.format("账户余额:%s", user.getBalance()));
                 Glide.with(getApplicationContext()).load(user.getIcon()).placeholder(R.drawable.icon).dontAnimate().into(mImgIcon);
             }
         });
@@ -90,6 +92,7 @@ public class UserCenterActivity extends BaseActivity implements View.OnClickList
             case R.id.tv_withdraw:
                 if (checkLogin()) {
                     intent = new Intent(UserCenterActivity.this, WithdrawActivity.class);
+                    intent.putExtra("money",mUser.getBalance());
                     startActivity(intent);
                 } else {
                     toLogin();

+ 35 - 6
app/src/main/java/com/jiuyan/sheep_children/page/WithdrawActivity.java

@@ -5,6 +5,7 @@ import android.content.Intent;
 import android.os.Bundle;
 import android.os.PersistableBundle;
 import android.support.annotation.Nullable;
+import android.text.TextUtils;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewParent;
@@ -16,13 +17,17 @@ import android.widget.RadioButton;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.bumptech.glide.Glide;
 import com.jiuyan.sheep_children.R;
 import com.jiuyan.sheep_children.base.BaseActivity;
 import com.jiuyan.sheep_children.net.NetManager;
 import com.jiuyan.sheep_children.net.SheepCallback;
 import com.jiuyan.sheep_children.net.Url;
+import com.jiuyan.sheep_children.page.entry.User;
 import com.jiuyan.sheep_children.utils.SpUtils;
 
+import java.util.HashMap;
+
 /**
  * Created by kemllor on 2017/12/13.
  */
@@ -34,6 +39,7 @@ public class WithdrawActivity extends BaseActivity implements View.OnClickListen
     private GridView mGvMoney;
     int[] mMoneys = new int[]{5, 10, 20, 50, 100, 500};
     private TextView mTvWx;
+    private GvAdapter mAdapter;
 
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
@@ -53,7 +59,20 @@ public class WithdrawActivity extends BaseActivity implements View.OnClickListen
 
     @Override
     public void initData() {
-
+        Intent intent = getIntent();
+        String money = intent.getStringExtra("money");
+        if (!TextUtils.isEmpty(money)) {
+            mMoney.setText(String.format("账户余额:%s", money));
+        } else {
+            HashMap<String, String> map = new HashMap<>();
+            map.put("wx_open_id", SpUtils.getOpenId(this));
+            NetManager.get(Url.USER_INFO, map, getApplicationContext(), new SheepCallback<User>(this) {
+                @Override
+                public void success(User user) {
+                    mMoney.setText(String.format("账户余额:%s", user.getBalance()));
+                }
+            });
+        }
     }
 
     @Override
@@ -64,8 +83,8 @@ public class WithdrawActivity extends BaseActivity implements View.OnClickListen
         mTvWx = (TextView) findViewById(R.id.tv_wx);
         mGvMoney = (GridView) findViewById(R.id.gv_money);
         mTitle.setText("提  现");
-        GvAdapter adapter = new GvAdapter();
-        mGvMoney.setAdapter(adapter);
+        mAdapter = new GvAdapter();
+        mGvMoney.setAdapter(mAdapter);
     }
 
     @Override
@@ -85,7 +104,14 @@ public class WithdrawActivity extends BaseActivity implements View.OnClickListen
         if (!SpUtils.isLogin(getApplicationContext())) {
             startActivity(new Intent(this, LoginActivity.class));
         } else {
-            NetManager.get(Url.BIND_WX, null, getApplicationContext(), new SheepCallback<String>(this) {
+            if (mAdapter.checked == -1) {
+                Toast.makeText(this, "请选择提现金额", Toast.LENGTH_SHORT).show();
+                return;
+            }
+            HashMap<String, String> map = new HashMap<>();
+            map.put("money", mMoneys[mAdapter.checked] + "");
+            map.put("wx_open_id", SpUtils.getOpenId(this));
+            NetManager.get(Url.USER_WITHDRAW, map, getApplicationContext(), new SheepCallback<String>(this) {
                 @Override
                 public void success(String o) {
                     Toast.makeText(WithdrawActivity.this, o, Toast.LENGTH_SHORT).show();
@@ -93,8 +119,11 @@ public class WithdrawActivity extends BaseActivity implements View.OnClickListen
 
                 @Override
                 public void otherCode(int code, String string) {
-                    if (code == 406)
+                    if (code == 406) {
                         startActivity(new Intent(WithdrawActivity.this, BindWxActivity.class));
+                        return;
+                    }
+                    super.otherCode(code, string);
                 }
             });
         }
@@ -102,7 +131,7 @@ public class WithdrawActivity extends BaseActivity implements View.OnClickListen
 
 
     private class GvAdapter extends BaseAdapter {
-        int checked = 0;
+        int checked = -1;
 
 
         @Override

+ 9 - 0
app/src/main/java/com/jiuyan/sheep_children/page/entry/Commit.java

@@ -22,12 +22,21 @@ public class Commit implements Serializable {
     private int Id;
     private Task Task;
     private String TaskImg;
+    private int TaskPublishId;
     private String TaskPkg;
     private int Status;
     private String CreateTime;
     private String CheckTime;
     private String FailDesc;
 
+    public int getTaskPublishId() {
+        return TaskPublishId;
+    }
+
+    public void setTaskPublishId(int taskPublishId) {
+        TaskPublishId = taskPublishId;
+    }
+
     public int getId() {
         return Id;
     }

+ 30 - 12
app/src/main/java/com/jiuyan/sheep_children/page/entry/User.java

@@ -12,27 +12,31 @@ public class User implements Serializable {
     /**
      * OpenId : abcabc
      * UnionId :
-     * Icon :
-     * NickName :
+     * Icon : https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1514376596134&di=e4ee38b45dd338e3e45329e0e3b4195a&imgtype=0&src=http%3A%2F%2Fwww.51ppt.com.cn%2FArticle%2FUploadphotos_0708%2F200604%2F200641315713933.png
+     * NickName : 又熄火了
      * Token :
-     * WxId : aadwasd
-     * Money : {"Hostroy":"30","Today":"5","Balance":"35"}
+     * WxId :
+     * Hostroy :
+     * Today : 5
+     * Balance : 25
      */
 
-    private String OpenId;
+    private String WxOpenId;
     private String UnionId;
     private String Icon;
     private String NickName;
     private String Token;
     private String WxId;
-    private Money Money;
+    private String Hostroy;
+    private String Today;
+    private String Balance;
 
     public String getOpenId() {
-        return OpenId;
+        return WxOpenId;
     }
 
     public void setOpenId(String OpenId) {
-        this.OpenId = OpenId;
+        this.WxOpenId = OpenId;
     }
 
     public String getUnionId() {
@@ -75,13 +79,27 @@ public class User implements Serializable {
         this.WxId = WxId;
     }
 
-    public Money getMoney() {
-        return Money;
+    public String getHostroy() {
+        return Hostroy;
     }
 
-    public void setMoney(Money Money) {
-        this.Money = Money;
+    public void setHostroy(String Hostroy) {
+        this.Hostroy = Hostroy;
     }
 
+    public String getToday() {
+        return Today;
+    }
+
+    public void setToday(String Today) {
+        this.Today = Today;
+    }
 
+    public String getBalance() {
+        return Balance;
+    }
+
+    public void setBalance(String Balance) {
+        this.Balance = Balance;
+    }
 }

+ 94 - 0
app/src/main/java/com/jiuyan/sheep_children/utils/PackageUtil.java

@@ -3,9 +3,17 @@ package com.jiuyan.sheep_children.utils;
 import android.app.ActivityManager;
 import android.app.usage.UsageEvents;
 import android.app.usage.UsageStatsManager;
+import android.content.ComponentName;
 import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
 import android.os.Build;
+import android.support.v4.content.FileProvider;
 
+import java.io.File;
 import java.util.List;
 
 /**
@@ -41,4 +49,90 @@ public class PackageUtil {
         }
         return "";
     }
+
+
+    /*
+    * 判断是否安装
+    * check the app is installed
+    */
+    public static boolean isAppInstalled(Context context, String packagename) {
+        PackageInfo packageInfo;
+        try {
+            packageInfo = context.getPackageManager().getPackageInfo(packagename, 0);
+        } catch (PackageManager.NameNotFoundException e) {
+            packageInfo = null;
+            e.printStackTrace();
+        }
+        if (packageInfo == null) {
+            //System.out.println("没有安装");
+            return false;
+        } else {
+            //System.out.println("已经安装");
+            return true;
+        }
+    }
+
+
+    /*
+    * 安装
+    * install app
+    */
+    public static void installApk(Context context, String path) {
+        File file = new File(path);
+        Intent intent = new Intent(Intent.ACTION_VIEW);
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        if (Build.VERSION.SDK_INT >= 24) { //判读版本是否在7.0以上
+            Uri apkUri = FileProvider.getUriForFile(context, "com.jiuyan.sheep_children", file);
+            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+            intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
+        } else {
+            intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
+        }
+        context.startActivity(intent);
+    }
+
+    /*
+     * 启动
+     * install app
+     */
+    public static void startApp(Context context, String packagename) {
+
+        // 通过包名获取此APP详细信息,包括Activities、services、versioncode、name等等
+        PackageInfo packageinfo = null;
+        try {
+            packageinfo = context.getPackageManager().getPackageInfo(packagename, 0);
+        } catch (PackageManager.NameNotFoundException e) {
+            e.printStackTrace();
+        }
+        if (packageinfo == null) {
+            return;
+        }
+
+        // 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
+        Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
+        resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
+        resolveIntent.setPackage(packageinfo.packageName);
+
+        // 通过getPackageManager()的queryIntentActivities方法遍历
+        List<ResolveInfo> resolveinfoList = context.getPackageManager()
+                .queryIntentActivities(resolveIntent, 0);
+
+        ResolveInfo resolveinfo = resolveinfoList.iterator().next();
+        if (resolveinfo != null) {
+            // packagename = 参数packname
+            String packageName = resolveinfo.activityInfo.packageName;
+            // 这个就是我们要找的该APP的LAUNCHER的Activity[组织形式:packagename.mainActivityname]
+            String className = resolveinfo.activityInfo.name;
+            // LAUNCHER Intent
+            Intent intent = new Intent(Intent.ACTION_MAIN);
+            intent.addCategory(Intent.CATEGORY_LAUNCHER);
+
+            // 设置ComponentName参数1:packagename参数2:MainActivity路径
+            ComponentName cn = new ComponentName(packageName, className);
+
+            intent.setComponent(cn);
+            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            context.startActivity(intent);
+        }
+    }
 }

+ 77 - 0
app/src/main/java/com/jiuyan/sheep_children/wxapi/WXEntryActivity.java

@@ -0,0 +1,77 @@
+package com.jiuyan.sheep_children.wxapi;
+
+import com.jiuyan.sheep_children.SheepApp;
+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.IWXAPIEventHandler;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.Toast;
+
+
+public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
+
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        //注意:
+        //第三方开发者如果使用透明界面来实现WXEntryActivity,需要判断handleIntent的返回值,如果返回值为false,则说明入参不合法未被SDK处理,应finish当前透明界面,避免外部通过传递非法参数的Intent导致停留在透明界面,引起用户的疑惑
+        try {
+            boolean ok = SheepApp.mWxapi.handleIntent(getIntent(), this);
+            if (!ok) {
+                finish();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+
+        setIntent(intent);
+        SheepApp.mWxapi.handleIntent(intent, this);
+    }
+
+    // 微信发送请求到第三方应用时,会回调到该方法
+    @Override
+    public void onReq(BaseReq req) {
+        switch (req.getType()) {
+            case ConstantsAPI.COMMAND_GETMESSAGE_FROM_WX:
+                break;
+            case ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX:
+                break;
+            default:
+                break;
+        }
+    }
+
+    // 第三方应用发送到微信的请求处理后的响应结果,会回调到该方法
+    @Override
+    public void onResp(BaseResp resp) {
+        int result = 0;
+
+        Toast.makeText(this, "baseresp.getType = " + resp.getType(), Toast.LENGTH_SHORT).show();
+
+        switch (resp.errCode) {
+            case BaseResp.ErrCode.ERR_OK:
+                break;
+            case BaseResp.ErrCode.ERR_USER_CANCEL:
+                break;
+            case BaseResp.ErrCode.ERR_AUTH_DENIED:
+                break;
+            case BaseResp.ErrCode.ERR_UNSUPPORT:
+                break;
+            default:
+                break;
+        }
+
+        Toast.makeText(this, result, Toast.LENGTH_LONG).show();
+    }
+}

+ 16 - 15
app/src/main/res/layout/bind_wx_activity.xml

@@ -8,43 +8,44 @@
         layout="@layout/title"/>
 
     <TextView
-        android:layout_marginTop="10dp"
-        android:textColor="@color/black_dark"
-        android:layout_marginLeft="15dp"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="步骤1"/>
+        android:layout_marginLeft="15dp"
+        android:layout_marginTop="10dp"
+        android:text="步骤1"
+        android:textColor="@color/black_dark"/>
 
     <TextView
-        android:textColor="@color/theme"
-        android:layout_marginTop="15dp"
-        android:layout_marginLeft="20dp"
+        android:id="@+id/tv_robot"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="添加好友->佣金发放号:45245124"/>
+        android:layout_marginLeft="20dp"
+        android:layout_marginTop="15dp"
+        android:text="添加好友->佣金发放号:"
+        android:textColor="@color/theme"/>
 
     <TextView
-        android:layout_marginTop="15dp"
-        android:textColor="@color/black_dark"
-        android:layout_marginLeft="15dp"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="步骤2"/>
+        android:layout_marginLeft="15dp"
+        android:layout_marginTop="15dp"
+        android:text="步骤2"
+        android:textColor="@color/black_dark"/>
 
     <android.support.design.widget.TextInputEditText
         android:id="@+id/et_wx"
-        android:layout_margin="15dp"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:textColorHint="@color/theme"
+        android:layout_margin="15dp"
         android:hint="请输入登录使用的微信号"
         android:textColor="@color/black_dark"
+        android:textColorHint="@color/theme"
         android:textSize="14sp"/>
 
     <TextView
-        android:layout_marginLeft="15dp"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:layout_marginLeft="15dp"
         android:text="注:填入的微信帐号为佣金接收号,必须和登录帐号一致。\n        帐号一经绑定不能修改"
         android:textColor="@color/red"
         android:textSize="12sp"/>

+ 8 - 0
app/src/main/res/layout/line_h_1px_black.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<View
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="1px"
+    android:layout_alignParentBottom="true"
+    android:background="@color/black_dark"/>
+

+ 0 - 1
app/src/main/res/layout/task_head.xml

@@ -49,7 +49,6 @@
             android:layout_below="@id/title"
             android:layout_centerHorizontal="true"
             android:layout_marginTop="10dp"
-            android:text="250.0"
             android:textColor="@color/white_red"
             android:textSize="30dp"
             />

+ 7 - 4
app/src/main/res/layout/task_record_item.xml

@@ -7,9 +7,7 @@
 
     <RelativeLayout
         android:layout_width="match_parent"
-        android:layout_height="50dp"
-        android:layout_marginLeft="5dp"
-        android:layout_marginRight="5dp"
+        android:layout_height="70dp"
         android:layout_marginTop="10dp"
         android:background="@color/backgroud"
         >
@@ -19,7 +17,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_centerVertical="true"
-            android:layout_marginLeft="3dp"
+            android:layout_marginLeft="5dp"
             android:gravity="center"
             android:textColor="@color/black_dark"
             android:textSize="14sp"/>
@@ -62,6 +60,7 @@
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:layout_alignParentRight="true"
+            android:layout_marginRight="5dp"
             android:gravity="center"
             android:orientation="vertical"
             android:paddingRight="3dp">
@@ -82,11 +81,15 @@
                 android:layout_alignParentRight="true"
                 android:layout_marginTop="5dp"
                 android:textColor="@color/black_dark"
+                android:textSize="12dp"
                 android:visibility="gone"/>
 
         </LinearLayout>
 
+        <include
+            layout="@layout/line_h_1px_black"/>
 
     </RelativeLayout>
 
+
 </LinearLayout>

+ 4 - 4
app/src/main/res/layout/withdraw_activity.xml

@@ -9,20 +9,20 @@
         layout="@layout/title"/>
 
     <TextView
-        android:paddingLeft="15dp"
         android:id="@+id/tv_money"
-        android:layout_marginTop="10dp"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:layout_marginTop="10dp"
+        android:paddingLeft="15dp"
         android:text="余 额:25.5"
         android:textColor="@color/black_dark"
         android:textSize="14sp"/>
 
     <GridView
-        android:layout_marginTop="10dp"
         android:id="@+id/gv_money"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
+        android:layout_marginTop="10dp"
         android:numColumns="3">
 
     </GridView>
@@ -31,13 +31,13 @@
         layout="@layout/line_h_1px"/>
 
     <TextView
-        android:gravity="center"
         android:id="@+id/tv_wx"
         android:layout_width="200dp"
         android:layout_height="40dp"
         android:layout_marginLeft="5dp"
         android:layout_marginTop="15dp"
         android:background="@drawable/text_backgroud"
+        android:gravity="center"
         android:text="提现到微信"
         android:textColor="@drawable/text_color"
         android:textSize="16sp"/>

+ 1 - 1
app/src/main/res/values/colors.xml

@@ -8,7 +8,7 @@
     <color name="white">#ffffff</color>
     <color name="white_red">#fffbf9</color>
     <color name="black_dark">#363636</color>
-    <color name="backgroud">#f7f0ee</color>
+    <color name="backgroud">#f9f5f4</color>
     <color name="green">#358400</color>
     <color name="red">#f00</color>
 </resources>