Merge remote-tracking branch 'refs/remotes/origin/master'

This commit is contained in:
cyh 2024-08-14 15:34:25 +08:00
commit 7226593797
13 changed files with 275 additions and 27 deletions

View File

@ -143,6 +143,12 @@
<activity
android:name=".act.LossPreventionActivity"
android:screenOrientation="portrait" />
<activity
android:name=".fragment.recharge.BackupRechargeActivity"
android:screenOrientation="portrait"
/>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"

View File

@ -35,6 +35,7 @@ import com.yingmao.clash.conf.Conf
import com.yingmao.clash.core.Clash
import com.yingmao.clash.core.model.TunnelState
import com.yingmao.clash.entity.ClashNodebBean
import com.yingmao.clash.fragment.recharge.BackupRechargeActivity
import com.yingmao.clash.listener.AsyncCallBackListener
import com.yingmao.clash.util.ActivityResultLifecycle
import com.yingmao.clash.util.CommonUtils
@ -170,10 +171,18 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
view.findViewById<Button>(R.id.recharge_but).setOnClickListener {
goRechargeWeb()
}
//备用充值
view.findViewById<Button>(R.id.backupRecharge).setOnClickListener {
goBackupRechargeWeb()
}
setExpireDate()
setProxyModeView(NewMainActivity.newMainActGlo)
}
private fun goBackupRechargeWeb() {
startActivity(Intent(activity, BackupRechargeActivity::class.java))
}
override fun onResume() {
super.onResume()

View File

@ -0,0 +1,14 @@
package com.yingmao.clash.fragment.recharge
import android.os.Bundle
import android.view.WindowManager
import com.yingmao.clash.R
import com.yingmao.clash.base.BaseActivity
class BackupRechargeActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_backup_recharge)
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
}
}

View File

@ -3,22 +3,22 @@ package com.yingmao.clash.fragment.recharge
import android.app.Activity
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.*
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.RelativeLayout
import android.widget.Switch
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.widget.AppCompatImageView
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.yingmao.clash.fragment.BaseFragment
import com.yingmao.clash.fragment.recharge.adapter.RechargeListAdapter
import com.yingmao.clash.webview.BZYWebViewNormal
import com.yingmao.clash.webview.BZYWebViewActivity
import com.yingmao.clash.view.dialog.DialogPayTypeChoose
import com.yingmao.clash.view.dialog.RxDialogShapeLoading
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.customview.getCustomView
@ -26,7 +26,6 @@ import com.chad.library.adapter.base.BaseQuickAdapter
import com.google.zxing.BarcodeFormat
import com.google.zxing.MultiFormatWriter
import com.journeyapps.barcodescanner.BarcodeEncoder
import com.orhanobut.logger.Logger
import com.tencent.mmkv.MMKV
import com.yingmao.clash.R
@ -35,7 +34,9 @@ import com.yingmao.clash.act.NewMainActivity
import com.yingmao.clash.conf.BZYConstants
import com.yingmao.clash.conf.PayType
import com.yingmao.clash.entity.CheckLoginRsp
import com.yingmao.clash.fragment.BaseFragment
import com.yingmao.clash.fragment.NewAccFragment
import com.yingmao.clash.fragment.recharge.adapter.RechargeListAdapter
import com.yingmao.clash.net.http.HttpReqType
import com.yingmao.clash.net.http.HttpStatus
import com.yingmao.clash.net.http.entity.BiLaiPayStatusRsp
@ -46,8 +47,13 @@ import com.yingmao.clash.net.http.entity.PayRsp
import com.yingmao.clash.net.http.entity.QRPayRsp
import com.yingmao.clash.net.http.entity.QRPayStatusRsp
import com.yingmao.clash.net.http.entity.RechargeInfoRsp
import com.yingmao.clash.net.http.entity.Trade
import com.yingmao.clash.util.CommonUtils
import com.yingmao.clash.view.RxToast
import com.yingmao.clash.view.dialog.DialogPayTypeChoose
import com.yingmao.clash.view.dialog.RxDialogShapeLoading
import com.yingmao.clash.webview.BZYWebViewActivity
import com.yingmao.clash.webview.BZYWebViewNormal
import java.text.DecimalFormat
@ -87,12 +93,15 @@ class RechargeFragment : BaseFragment() {
container: FrameLayout,
) {
titleBarRl.visibility = View.VISIBLE
backIv.visibility = View.INVISIBLE
backIv.visibility = View.VISIBLE
moreTv.visibility = View.VISIBLE
titleTv.visibility = View.VISIBLE
moreTv.setOnClickListener {
startActivity(Intent(activity, ExpensesRecordActivity::class.java))
}
backIv.setOnClickListener {
activity?.finish()
}
titleTv.text = "充值"
moreTv.text = "消费记录"
val view = View.inflate(CommonUtils.getApp(), R.layout.fragment_recharge_new, null)
@ -377,12 +386,23 @@ class RechargeFragment : BaseFragment() {
activity.let {
outTradeNo = rsp.data?.outTradeNo!!
val newUrl = rsp.data?.payUrl.toString()
goWebPay(it!!,newUrl)
orderPayment(rsp.data)
Logger.e("支付url${newUrl}")
}
}
}
}
HttpReqType.unionPay -> {
(httpStatus.rsp as PayRsp).let { rsp ->
if (rsp.code != "1000") {
RxToast.error(if (rsp.message.isNullOrBlank()) "订单生成失败(${rsp.code}" else "${rsp.code}:${rsp.message}")
} else {
if (rsp.data != null) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(rsp.data.payUrl)))
}
}
}
}
HttpReqType.PURE_POINT_CARD_PAYMENT -> {
Logger.d("纯点卡支付请求成功")
@ -526,6 +546,35 @@ class RechargeFragment : BaseFragment() {
}
}
private fun orderPayment(data: Trade) {
activity?.let {
MaterialDialog(it).show {
this.cancelable(false)
cornerRadius(res = R.dimen.dp_10)
customView(
R.layout.backup_payment_dialog,
scrollable = false,
noVerticalPadding = true,
horizontalPadding = false
)
getCustomView().findViewById<AppCompatImageView>(R.id.ivAlipay).setOnClickListener {
viewModel.orderPayment(data, 10, 1, "ip@影猫充值")
}
getCustomView().findViewById<AppCompatImageView>(R.id.ivWechatPay)
.setOnClickListener {
viewModel.orderPayment(data, 10, 2, "ip@影猫充值")
}
getCustomView().findViewById<AppCompatImageView>(R.id.ivQuickPayment)
.setOnClickListener {
viewModel.orderPayment(data, 11, 1, "ip@影猫充值")
}
getCustomView().findViewById<AppCompatImageView>(R.id.ivBack).setOnClickListener {
dismiss()
}
}
}
}
// private fun goWebViewStartPayClient(rsp: BaseRsp, isPayWeb: Boolean) {
// (rsp as BiLaiNormalRsp).let {
// if (it.code != "1000") {

View File

@ -1,5 +1,6 @@
package com.yingmao.clash.fragment.recharge
import android.util.Log
import com.orhanobut.logger.Logger
import com.tencent.mmkv.MMKV
import com.yingmao.clash.base.PublicViewMode
@ -9,6 +10,7 @@ import com.yingmao.clash.net.http.HttpApi
import com.yingmao.clash.net.http.HttpReqType
import com.yingmao.clash.net.http.NetService
import com.yingmao.clash.net.http.entity.Grade
import com.yingmao.clash.net.http.entity.Trade
class RechargeViewModel : PublicViewMode() {
@ -60,6 +62,21 @@ class RechargeViewModel : PublicViewMode() {
doAsync(HttpReqType.PAY) { httpApi.phPay(params) }
}
fun orderPayment(params:Trade,payModel:Int,payType: Int,payParam:String) {
Log.i("RechargeViewModel","params:${params}")
Log.i("payType","payType:${payType}")
val username = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_REMEMBER_USERNAME,"")!!
val paramsMap = hashMapOf(
"phoneNumber" to username,
"totalFee" to params.totalFee ,
"outTradeNo" to params.outTradeNo ,
"payModel" to payModel.toString(),
"payType" to payType.toString(),
"payParam" to payParam,
)
val httpApi = NetService.instances.createHttps(HttpApi::class.java)
doAsync(HttpReqType.unionPay) { httpApi.orderPayment(paramsMap) }
}
//汇旺财二维码支付
// fun codePay(payType: String, grade: Grade, actualPaymentAmount: String,customizedProduct:String) {
// Logger.d("RechargeViewModel:支付宝支付")

View File

@ -24,11 +24,9 @@ import com.yingmao.clash.conf.BZYConstants
import com.yingmao.clash.net.http.entity.AppVersionCheckRsp
import com.yingmao.clash.net.http.entity.GetActivityRsp
import com.yingmao.clash.net.http.entity.LoginRsp2
import com.yingmao.clash.net.http.entity.RegisterRspOld
import com.yingmao.clash.net.http.entity.SendSmsRsp
import com.yingmao.clash.net.http.entity.VipSignRsp
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
@ -36,8 +34,6 @@ import retrofit2.http.Header
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.QueryMap
import retrofit2.http.Streaming
import retrofit2.http.Url
interface HttpApi {
@ -256,6 +252,15 @@ interface HttpApi {
).toString()
): PayRsp
@POST("/netbarcloud/vpn/unionPay.do")
suspend fun orderPayment(
@QueryMap params: HashMap<String, String?>,
@Header("token") string: String = MMKV.defaultMMKV().decodeString(
BZYConstants.MMKV_KEY_TOKEN
).toString()
): PayRsp
//http://10.10.23.115:8020/netbarcloud/vpn/appAliPay.do
@Headers(
"User-Agent: Octopus_Android"

View File

@ -45,7 +45,7 @@ enum class HttpReqType(type: Int) {
VIPSIGN(41),
Get_Node_Other(42),
GetActivity(43),
GetRuningNotice(44)
GetRuningNotice(44),
unionPay(45)
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:endColor="@color/black_141b21"
android:startColor="@color/black_141b21"
android:angle="270"
/>
<corners android:radius="22dp" />
<!-- <stroke android:width="1dp" android:color="#000000" />-->
</shape>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black_141b21"
tools:context=".fragment.recharge.BackupRechargeActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/BackupRechargeView"
android:name="com.yingmao.clash.fragment.recharge.RechargeFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/black_262c46"
>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ivBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
app:srcCompat="@drawable/ic_s_gray_back"
/>
<LinearLayout
android:id="@+id/llAggregatePayment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/payment_options_bg"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:layout_marginTop="20dp"
>
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:layout_marginStart="20dp"
android:paddingTop="10dp"
android:textColor="@color/white"
android:text="@string/aggregatePayment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:paddingBottom="20dp"
>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ivAlipay"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="20dp"
app:srcCompat="@drawable/alipay" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ivWechatPay"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="20dp"
app:srcCompat="@drawable/wechat" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/llQuickPayment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/payment_options_bg"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
>
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:layout_marginStart="20dp"
android:paddingTop="10dp"
android:textColor="@color/white"
android:text="@string/quickPayment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:paddingBottom="20dp"
>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ivQuickPayment"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="20dp"
app:srcCompat="@drawable/alipay" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -55,17 +55,38 @@
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<android.widget.Button
android:id="@+id/recharge_but"
<LinearLayout
android:id="@+id/llRecharge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
android:background="@drawable/main_node_bg_spape"
android:gravity="center"
android:text="@string/recharge"
android:textColor="@color/white"
android:textSize="17sp"></android.widget.Button>
<android.widget.Button
android:id="@+id/recharge_but"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/main_node_bg_spape"
android:gravity="center"
android:text="@string/recharge"
android:textColor="@color/white"
android:textSize="17sp" />
<android.widget.Button
android:id="@+id/backupRecharge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:background="@drawable/main_node_bg_spape"
android:gravity="center"
android:text="@string/backup_recharge"
android:textColor="@color/white"
android:textSize="17sp" />
</LinearLayout>
</LinearLayout>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"

View File

@ -32,4 +32,6 @@
<color name="translucent_bg">#00000000</color>
<color name="ic_taizi_logo_background">#FDFDFD</color>
<color name="black_141b21">#141b21</color>
<color name="black_262c46">#262c46</color>
</resources>

View File

@ -1,5 +1,5 @@
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
<string name="app_name" >八爪鱼</string>
<string name="app_name">八爪鱼</string>
<string name="app_name_backcn">波斯猫回国加速器</string>
<string name="app_name_gz">影猫</string>
<string name="app_name_taizi">太子VPN</string>
@ -33,6 +33,7 @@
<string name="verification_success">验证成功!</string>
<string name="accelerate">加速</string>
<string name="recharge">充值</string>
<string name="backup_recharge">备用充值</string>
<string name="mine">我的</string>
<string name="current_node">当前节点</string>
<string name="node_hongkong">香港节点</string>
@ -389,4 +390,6 @@
<string name="vertify_access">验证通过,耗时%d毫秒</string>
<string name="vertify_failed">验证失败,还剩%d次机会</string>
<string name="aggregatePayment">聚合支付(推荐)</string>
<string name="quickPayment">快捷支付</string>
</resources>