소스 검색

1.登录密码设置。

石慧云 4 년 전
부모
커밋
fe90de8069

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -88,6 +88,7 @@
         <activity android:name=".activity.SourceDetailsActivity"/>
         <activity android:name=".activity.AllCarActivity"/>
         <activity android:name=".activity.InvoiceActivity"/>
+        <activity android:name=".activity.PasswordActivity"/>
 
 
     </application >

+ 0 - 6
app/src/main/java/com/quansu/heifengwuliu/activity/InvoiceActivity.kt

@@ -36,16 +36,10 @@ class InvoiceActivity : MBRActivity<InvoiceVModel, InvoiceAdapter, ActivityInvoi
 
     override fun listeners() {
         super.listeners()
-        binding.butSure.setOnClickListener{
 
-            UiSwitch.singleRes(this, AllCarActivity::class.java,
-                    MIntentAction.REQUEST_CODE_ONE)
-        }
     }
 
 
-
-
     override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
         super.onActivityResult(requestCode, resultCode, data)
         if (MIntentAction.REQUEST_CODE_ONE == requestCode && resultCode == Activity.RESULT_OK) {

+ 42 - 0
app/src/main/java/com/quansu/heifengwuliu/activity/PasswordActivity.kt

@@ -0,0 +1,42 @@
+package com.quansu.heifengwuliu.activity
+
+import android.os.Bundle
+import com.quansu.heifengwuliu.base.MBActivity
+import com.quansu.heifengwuliu.databinding.ActivityPasswordBinding
+import com.quansu.heifengwuliu.vmodel.PasswordVModel
+
+class PasswordActivity : MBActivity<PasswordVModel, ActivityPasswordBinding>() {
+
+
+    var type=1//1:登录密码 2支付密码
+    override fun __before() {
+        super.__before()
+
+        type= intent?.extras?.getInt("type", 1)!!
+
+    }
+
+    override fun initCreate(savedInstanceState: Bundle?) {
+        super.initCreate(savedInstanceState)
+        vm.type=type
+    }
+
+
+    override fun title(): String? {
+        return if(type==1) {
+            "设置登录密码"
+        }else{
+            "设置支付密码"
+        }
+    }
+    override fun binding(): ActivityPasswordBinding {
+        return ActivityPasswordBinding.inflate(layoutInflater)
+    }
+
+    override fun vmClass(): Class<PasswordVModel> {
+        return PasswordVModel::class.java
+    }
+
+
+
+}

+ 12 - 0
app/src/main/java/com/quansu/heifengwuliu/utils/net/ApiService.kt

@@ -300,4 +300,16 @@ interface ApiService {
     ): Observable<Response<Any>>
 
 
+
+    /**
+     * 密码/支付密码
+     * @return
+     */
+    @POST("api/user/setPwd")
+    @FormUrlEncoded
+    fun setPwd(@Field("oldpwd") oldpwd: String?, @Field("newpwd") newpwd: String?,
+                @Field("type") type: String?): Observable<Response<Any>>
+
+
+
 }

+ 0 - 6
app/src/main/java/com/quansu/heifengwuliu/vmodel/MineVModel.kt

@@ -59,12 +59,6 @@ open class MineVModel : BViewModel<MineRepository>() {
     }
 
 
-    fun goLogOut(){
-        //退出登录
-        MMKVManager.instance().clearAll()
-        UiSwitch.single_new_task_with_clear_task(repository().context, OneLoginActivity::class.java)
-
-    }
 
     override fun firstReq() {
         super.firstReq()

+ 86 - 0
app/src/main/java/com/quansu/heifengwuliu/vmodel/PasswordVModel.kt

@@ -0,0 +1,86 @@
+package com.quansu.heifengwuliu.vmodel
+
+import android.app.Activity
+import android.text.TextUtils
+import androidx.databinding.Bindable
+import androidx.lifecycle.MutableLiveData
+import com.quansu.heifengwuliu.BR
+import com.quansu.heifengwuliu.model.User
+import com.quansu.heifengwuliu.utils.net.NetEngine
+import com.ysnows.base.base.BRepository
+import com.ysnows.base.base.BViewModel
+
+open class PasswordVModel : BViewModel<BRepository>() {
+
+
+    var isShow: MutableLiveData<Boolean> = MutableLiveData( User.get()!!.isPwd)
+
+    var type=1
+
+
+    @Bindable
+    open var oldpassWord: String? = null
+        set(value) {
+            field = value
+            notifyPropertyChanged(BR.oldpassWord)
+        }
+
+
+    @Bindable
+    open var passWord: String? = null
+        set(value) {
+            field = value
+            notifyPropertyChanged(BR.passWord)
+        }
+
+    @Bindable
+    open var passWordTo: String? = null
+        set(value) {
+            field = value
+            notifyPropertyChanged(BR.passWordTo)
+        }
+
+
+    fun toSubmit(){
+        if(type==1){//设置登录密码
+
+            var oldpwd=""
+            if(isShow.value!!) {
+                if (TextUtils.isEmpty(oldpassWord)) {
+                    toast("请输入旧密码")
+                    return
+                }
+                oldpwd= oldpassWord.toString()
+            }
+            if(TextUtils.isEmpty(passWord)){
+                toast("请输入新密码")
+                return
+            }
+
+            if(TextUtils.isEmpty(passWordTo)){
+                toast("请再次输入新密码")
+                return
+            }
+            if(passWord!=passWordTo){
+                toast("两次新密码不一致!")
+                return
+            }
+
+            repository().lreq(NetEngine.service.setPwd(oldpwd, passWord,"0"))
+                    .doOnNext {
+                        if (it.ok(true)) {
+                            toast(it.msg())
+                            (repository().context as Activity).finish()
+                        }
+                    }
+                    .subscribe()
+
+            return
+        }
+
+
+    }
+
+
+
+}

+ 11 - 0
app/src/main/java/com/quansu/heifengwuliu/vmodel/SettingsVModel.kt

@@ -1,9 +1,12 @@
 package com.quansu.heifengwuliu.vmodel
 
+import android.os.Bundle
 import androidx.lifecycle.MutableLiveData
+import com.quansu.heifengwuliu.activity.PasswordActivity
 import com.quansu.heifengwuliu.model.User
 import com.quansu.heifengwuliu.repository.UserInfoRepository
 import com.ysnows.base.base.BViewModel
+import com.ysnows.base.utils.UiSwitch
 
 class SettingsVModel : BViewModel<UserInfoRepository>() {
     val user: MutableLiveData<User?> = MutableLiveData(User.get())
@@ -22,4 +25,12 @@ class SettingsVModel : BViewModel<UserInfoRepository>() {
     fun buyVip() {
     }
 
+
+    //设置登录密码和支付密码 1:登录密码 2支付密码
+    fun goPassword(type:Int){
+        UiSwitch.bundle(repository().context, PasswordActivity::class.java, Bundle().apply {
+            putInt("type",type)
+        })
+    }
+
 }

+ 16 - 31
app/src/main/res/layout/activity_invoice.xml

@@ -1,51 +1,36 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tools="http://schemas.android.com/tools" >
+    xmlns:tools="http://schemas.android.com/tools">
+
+    <data>
 
-    <data >
         <variable
             name="vm"
             type="com.quansu.heifengwuliu.vmodel.InvoiceVModel" />
-    </data >
+    </data>
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical" >
+        android:orientation="vertical">
 
 
-        <FrameLayout
+        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+            android:id="@+id/refresh_layout"
             android:layout_width="match_parent"
-            android:layout_height="match_parent" >
+            android:layout_height="match_parent">
 
-            <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
-                android:id="@+id/refresh_layout"
+            <androidx.recyclerview.widget.RecyclerView
+                android:id="@+id/recycler_view"
                 android:layout_width="match_parent"
-                android:layout_height="match_parent" >
-
-                <androidx.recyclerview.widget.RecyclerView
-                    android:id="@+id/recycler_view"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:paddingBottom="70dp"
-                    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
-                    tools:listitem="@layout/item_invoice" />
+                android:layout_height="match_parent"
+                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
+                tools:listitem="@layout/item_invoice" />
 
-            </androidx.swiperefreshlayout.widget.SwipeRefreshLayout >
-
-            <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
-                android:id="@+id/but_sure"
-                android:layout_width="match_parent"
-                android:layout_height="@dimen/dp_40"
-                android:layout_gravity="bottom"
-                android:layout_marginStart="@dimen/dp_30"
-                android:layout_marginEnd="@dimen/dp_30"
-                android:layout_marginBottom="@dimen/dp_30"
-                android:text="@string/add_vehicle" />
+        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
-        </FrameLayout >
 
-    </LinearLayout >
+    </LinearLayout>
 
-</layout >
+</layout>

+ 168 - 0
app/src/main/res/layout/activity_password.xml

@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools" >
+
+    <data >
+        <import type="android.view.View" />
+        <import type="com.quansu.heifengwuliu.utils.MUiSwitch" />
+
+        <variable
+            name="vm"
+            type="com.quansu.heifengwuliu.vmodel.PasswordVModel" />
+
+    </data >
+
+    <LinearLayout
+        android:name="com.ysnows.login.activity.LoginActivity"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@color/white"
+        android:fitsSystemWindows="true"
+        android:orientation="vertical"
+        tools:context="com.quansu.heifengwuliu.activity.LoginActivity" >
+
+
+
+        <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="48dp"
+            android:layout_marginLeft="35dp"
+            android:visibility="@{vm.isShow?View.VISIBLE :View.GONE}"
+            android:layout_marginTop="25dp"
+            android:layout_marginRight="35dp"
+            android:gravity="center_vertical"
+            android:paddingStart="@dimen/dp_8"
+            android:paddingEnd="@dimen/dp_14"
+            app:rv_radius="25dp"
+            app:qmui_borderWidth="@dimen/dp_1"
+            app:qmui_borderColor="#F4F3F9"
+            app:qmui_backgroundColor="#F4F3F9"
+
+            >
+
+            <ImageView
+                android:layout_width="35dp"
+                android:layout_height="35dp"
+                android:padding="5dp"
+                android:src="@drawable/ic_login_pwd" />
+
+            <com.ysnows.base.widget.DelEditText
+                android:id="@+id/edt_old_pwd"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@null"
+                android:hint="@string/please_input_old_pwd"
+                android:inputType="textPassword"
+                android:text="@={vm.oldpassWord}"
+                android:textSize="@dimen/sp_15" />
+
+        </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout >
+
+        <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="48dp"
+            android:layout_marginLeft="35dp"
+            android:layout_marginTop="25dp"
+            android:layout_marginRight="35dp"
+            android:gravity="center_vertical"
+            android:paddingStart="@dimen/dp_8"
+            android:paddingEnd="@dimen/dp_14"
+            app:rv_radius="25dp"
+            app:qmui_borderWidth="@dimen/dp_1"
+            app:qmui_borderColor="#F4F3F9"
+            app:qmui_backgroundColor="#F4F3F9"
+
+            >
+
+            <ImageView
+                android:layout_width="35dp"
+                android:layout_height="35dp"
+                android:padding="5dp"
+                android:src="@drawable/ic_login_pwd" />
+
+            <com.ysnows.base.widget.DelEditText
+                android:id="@+id/edt_new_pwd"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@null"
+                android:hint="@string/please_input_new_pwd"
+                android:inputType="textPassword"
+                android:text="@={vm.passWord}"
+                android:textSize="@dimen/sp_15" />
+
+        </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout >
+
+
+        <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="48dp"
+            android:layout_marginLeft="35dp"
+            android:layout_marginTop="25dp"
+            android:layout_marginRight="35dp"
+            android:gravity="center_vertical"
+            android:paddingStart="@dimen/dp_8"
+            android:paddingEnd="@dimen/dp_14"
+            app:rv_radius="25dp"
+            app:qmui_borderWidth="@dimen/dp_1"
+            app:qmui_borderColor="#F4F3F9"
+            app:qmui_backgroundColor="#F4F3F9"
+
+            >
+
+            <ImageView
+                android:layout_width="35dp"
+                android:layout_height="35dp"
+                android:padding="5dp"
+                android:src="@drawable/ic_login_pwd" />
+
+            <com.ysnows.base.widget.DelEditText
+                android:id="@+id/edt_new_pwd_to"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@null"
+                android:hint="@string/please_input_new_pwd_twice"
+                android:inputType="textPassword"
+                android:text="@={vm.passWordTo}"
+                android:textSize="@dimen/sp_15" />
+
+        </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout >
+
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_weight="1"
+            android:layout_height="0dp">
+
+        </View>
+
+        <androidx.cardview.widget.CardView
+            android:layout_width="match_parent"
+            android:layout_height="45dp"
+            android:layout_marginLeft="35dp"
+            android:layout_marginTop="10dp"
+            android:layout_marginBottom="@dimen/dp_40"
+            android:layout_marginRight="35dp"
+            android:background="@color/colorPrimary"
+            app:cardBackgroundColor="@color/colorPrimary"
+            app:cardCornerRadius="22.5dp"
+            app:cardElevation="2dp"
+            app:cardPreventCornerOverlap="true" >
+
+            <Button
+                android:id="@+id/btn_submit"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="#E17E30"
+                android:onClick="@{v->vm.toSubmit()}"
+                android:text="@string/submit"
+                android:textColor="@color/white"
+                android:textSize="@dimen/sp_16" />
+
+        </androidx.cardview.widget.CardView >
+
+
+
+
+    </LinearLayout >
+</layout >

+ 103 - 1
app/src/main/res/layout/activity_settings.xml

@@ -37,6 +37,109 @@
                         android:paddingTop="@dimen/dp_10"
                         android:paddingBottom="@dimen/dp_10" >
 
+
+                        <RelativeLayout
+                            android:id="@+id/lay_login_password"
+                            android:layout_width="match_parent"
+                            android:layout_height="48dp"
+                            android:onClick="@{v->vm.goPassword(1)}"
+                            android:layout_marginStart="@dimen/dp_14" >
+
+                            <ImageView
+                                android:id="@+id/img_icon1"
+                                android:layout_width="30dp"
+                                android:layout_height="30dp"
+                                android:layout_centerVertical="true"
+                                android:padding="@dimen/dp_4"
+                                android:src="@drawable/ic_login_pwd" />
+
+                            <TextView
+                                android:id="@+id/tv_title1"
+                                android:layout_width="wrap_content"
+                                android:layout_height="wrap_content"
+                                android:layout_centerVertical="true"
+                                android:layout_marginLeft="@dimen/dp_10"
+                                android:layout_toRightOf="@id/img_icon1"
+                                android:gravity="center_vertical"
+                                android:text="登录密码"
+                                android:textColor="@color/primary_text"
+                                android:textSize="@dimen/sp_15" />
+
+                             <ImageView
+                                style="@style/mine_arrow_right"
+                                 android:layout_centerVertical="true"
+                                 android:layout_alignParentRight="true"
+                                 android:layout_marginEnd="@dimen/dp_12"
+                                 android:src="@drawable/mine_right" />
+
+                            <View
+                                android:layout_width="match_parent"
+                                android:layout_height="1dp"
+                                android:layout_alignLeft="@id/tv_title1"
+                                android:layout_alignParentBottom="true"
+                                android:background="@color/color_page_bg" />
+
+                        </RelativeLayout >
+
+                        <View
+                            android:layout_width="match_parent"
+                            android:layout_height="1dp"
+                            android:layout_marginLeft="@dimen/dp_14"
+                            android:background="@color/color_page_bg" />
+
+
+                        <RelativeLayout
+                            android:id="@+id/lay_pay_password"
+                            android:layout_width="match_parent"
+                            android:layout_height="48dp"
+                            android:onClick="@{v->vm.goPassword(2)}"
+                            android:layout_marginStart="@dimen/dp_14" >
+
+                            <ImageView
+                                android:id="@+id/img_icon2"
+                                android:layout_width="30dp"
+                                android:layout_height="30dp"
+                                android:layout_centerVertical="true"
+                                android:padding="@dimen/dp_4"
+                                android:src="@drawable/ic_login_pwd" />
+
+                            <TextView
+                                android:id="@+id/tv_title2"
+                                android:layout_width="wrap_content"
+                                android:layout_height="wrap_content"
+                                android:layout_centerVertical="true"
+                                android:layout_marginLeft="@dimen/dp_10"
+                                android:layout_toRightOf="@id/img_icon2"
+                                android:gravity="center_vertical"
+                                android:text="支付密码"
+                                android:textColor="@color/primary_text"
+                                android:textSize="@dimen/sp_15" />
+
+                            <ImageView
+                                style="@style/mine_arrow_right"
+                                android:layout_centerVertical="true"
+                                android:layout_alignParentRight="true"
+                                android:layout_marginEnd="@dimen/dp_12"
+                                android:src="@drawable/mine_right" />
+
+                            <View
+                                android:layout_width="match_parent"
+                                android:layout_height="1dp"
+                                android:layout_alignLeft="@id/tv_title2"
+                                android:layout_alignParentBottom="true"
+                                android:background="@color/color_page_bg" />
+
+                        </RelativeLayout >
+
+                        <View
+                            android:layout_width="match_parent"
+                            android:layout_height="1dp"
+                            android:layout_marginLeft="@dimen/dp_14"
+                            android:background="@color/color_page_bg" />
+
+
+
+
                         <TextView
                             android:layout_width="wrap_content"
                             android:layout_height="28dp"
@@ -50,7 +153,6 @@
                             android:layout_width="match_parent"
                             android:layout_height="1dp"
                             android:layout_marginLeft="@dimen/dp_14"
-
                             android:background="@color/color_page_bg" />
 
                         <RelativeLayout

+ 0 - 20
app/src/main/res/layout/fragment_mine.xml

@@ -279,26 +279,6 @@
                     </LinearLayout >
 
 
-                    <View style="@style/line_mine" />
-
-                    <LinearLayout
-                        android:id="@+id/lay_sign_out"
-                        style="@style/mine_list"
-                        android:onClick="@{v->vm.goLogOut()}" >
-
-                        <ImageView
-                            style="@style/mine_img"
-                            android:src="@drawable/ic_private_settings" />
-
-                        <TextView
-                            style="@style/mine_text"
-                            android:text="退出登录" />
-
-                        <ImageView
-                            style="@style/mine_arrow_right"
-                            android:src="@drawable/mine_right" />
-
-                    </LinearLayout >
 
                     <View style="@style/line_mine" />
 

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

@@ -373,6 +373,12 @@ Api 已达到使用限制
     <string name="please_input_user_name" >请输入真实姓名</string >
 
     <string name="login" >登录</string >
+    <string name="please_input_old_pwd" >请输入旧密码</string >
+    <string name="please_input_new_pwd" >请输入新密码</string >
+    <string name="please_input_new_pwd_twice" >请再次输入新密码</string >
+
+
+
     <string name="please_input_pwd" >请输入密码</string >
 
     <string name="logout" >退出登录</string >