Commit 0448737f authored by mengcuiguang2's avatar mengcuiguang2

代码优化

parent 889ed912
...@@ -40,6 +40,7 @@ import com.jobo.wxpay.WXPay ...@@ -40,6 +40,7 @@ import com.jobo.wxpay.WXPay
import com.jobo.wxpay.WXPayInfoImpl import com.jobo.wxpay.WXPayInfoImpl
import com.youth.banner.listener.OnPageChangeListener import com.youth.banner.listener.OnPageChangeListener
import kotlinx.android.synthetic.main.activity_new_vip.* import kotlinx.android.synthetic.main.activity_new_vip.*
import java.net.URLEncoder
/** /**
...@@ -226,6 +227,21 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, ...@@ -226,6 +227,21 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
return return
} }
// 自动签约付费
try {
if (paramsBean.params.isSign) {
AppConfig.enterAlipay = true
openAutoAlipay(paramsBean.params.params)
return
}
} catch (e: Exception) {
e.printStackTrace()
}
//支付宝小程序
// openAlipayApp()
// sdk支付
alipay(paramsBean) alipay(paramsBean)
} }
} }
...@@ -442,18 +458,6 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, ...@@ -442,18 +458,6 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
} }
fun alipay(wxParanBean: WxPayParamBean) { fun alipay(wxParanBean: WxPayParamBean) {
try {
// 自动签约付费
if (wxParanBean.params.isSign) {
AppConfig.enterAlipay = true
openAutoAlipay(wxParanBean.params.params)
return
}
} catch (e: Exception) {
e.printStackTrace()
}
//实例化支付宝支付策略 //实例化支付宝支付策略
val aliPay = AliPay() val aliPay = AliPay()
//构造支付宝订单实体。一般都是由服务端直接返回。 //构造支付宝订单实体。一般都是由服务端直接返回。
...@@ -764,4 +768,23 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, ...@@ -764,4 +768,23 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
}) })
timer!!.start() timer!!.start()
} }
/**
* 跳转支付宝小程序
*/
private fun openAlipayApp() {
try {
val alipayAppId = "2021004145639480"
val path = "app_uid=" + UserManager.getInstance().userID//这里是传的参数
val link = URLEncoder.encode(path, "UTF-8")//这里是encode传的参数
val url =
// "alipays://platformapi/startapp?appId=2021004129666486&page=pages/loading&query=" + link
"alipays://platformapi/startapp?appId=" + alipayAppId + "&page=pages/loading&query=" + link
val uri = Uri.parse(url) // url为你要链接的地址
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
} catch (e: Exception) {
e.printStackTrace()
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment