Commit 1d9a3575 by 霍志良

feat:底部webview

parent 84364bb0
......@@ -66,11 +66,11 @@ class ExpertConsultServiceListDialog(val mContext: Context, val mList: List<Serv
}
override fun onItemClick(serviceBean: ServiceItemBean.ProductsBean) {
if (mConsultServiceDetailView != null) {
mConsultServiceDetailView?.updateData(serviceBean)
dialog_bottom_scroll_view.currentItem = 1
}
// if (mConsultServiceDetailView != null) {
// mConsultServiceDetailView?.updateData(serviceBean)
// dialog_bottom_scroll_view.currentItem = 1
// }
dialog_bottom_scroll_view.currentItem = 1
}
override fun addTime() { // 提醒添加时间回调
......@@ -106,7 +106,9 @@ class ExpertConsultServiceListDialog(val mContext: Context, val mList: List<Serv
}
},mIsBusy,toUid)
mViewList.add(mConsultServiceDetailView as View)
// mViewList.add(mConsultServiceDetailView as View)
mWebviewView=ExpertConsultWebview(mContext)
mViewList.add(mWebviewView as View)
dialog_bottom_scroll_view.adapter = ConsultServicePagerAdapter()
dialog_bottom_scroll_view.currentItem = 0
......
......@@ -2,7 +2,9 @@ package com.yidianling.uikit.custom.widget.expertConsultService.view
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.view.View
import android.widget.RelativeLayout
import com.tencent.smtt.export.external.interfaces.JsResult
......@@ -11,7 +13,9 @@ import com.ydl.utils.WebUrlParamsUtils
import com.ydl.webview.ProgressWebView
import com.ydl.webview.TellData
import com.ydl.webview.WebModularServiceUtils
import com.ydl.ydlcommon.base.config.HttpConfig
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.R
import com.yidianling.uikit.custom.widget.expertConsultService.callback.ConsultServiceViewCallback
......@@ -22,11 +26,7 @@ class ExpertConsultWebview : RelativeLayout {
mContext = context
initView()
}
private var mListener: ConsultServiceViewCallback? = null
private var mContext: Context? = null
private fun initView() {
val mWidth: Int = RxDeviceTool.getScreenWidth(mContext)
......@@ -39,9 +39,66 @@ class ExpertConsultWebview : RelativeLayout {
params.height = mHeight
layoutParams = params
View.inflate(mContext, R.layout.im_expert_consult_webview_view, this)
var view=View.inflate(mContext, R.layout.im_expert_consult_webview_view, this)
webViewInit(view.findViewById<ProgressWebView>(R.id.wv_content))
}
private fun shouldOverridePayUrl(view: WebView, url: String): Boolean {
if (url.startsWith("weixin://")) {
return try {
mContext?.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
true
} catch (e: java.lang.Exception) {
// 防止手机没有安装处理某个 scheme 开头的 url 的 APP 导致 crash
ToastUtil.toastShort("该手机没有安装微信")
true
}
} else if (url.startsWith("alipays://") || url.startsWith("alipay")) {
return try {
mContext?.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
true
} catch (e: java.lang.Exception) {
// 防止手机没有安装处理某个 scheme 开头的 url 的 APP 导致 crash
// 启动支付宝 App 失败,会自行跳转支付宝网页支付
true
}
}
// 处理普通 http 请求跳转
// if (!(url.startsWith("http") || url.startsWith("https"))) {
// return true;
// }
// 处理微信 H5 支付跳转时验证请求头 referer 失效
// 验证不通过会出现“商家参数格式有误,请联系商家解决”
if (url.contains("wx.tenpay.com")) {
// 申请微信 H5 支付时填写的域名
// 比如经常用来测试网络连通性的 http://www.baidu.com
val parse = Uri.parse(url)
//从url 中获取 域名信息
val redirectUrlStr = parse.getQueryParameter("redirect_url")
val redirectUrl = Uri.parse(redirectUrlStr)
// 申请微信 H5 支付时填写的域名
val referer = redirectUrl.scheme + "://" + redirectUrl.host
// 兼容 Android 4.4.3 和 4.4.4 两个系统版本设置 referer 无效的问题
return if ("4.4.3" == Build.VERSION.RELEASE
|| "4.4.4" == Build.VERSION.RELEASE
) {
// 返回 false 由系统 WebView 自己处理该 url
false
} else {
// HashMap 指定容量初始化,避免不必要的内存消耗
val map = HashMap<String, String>(1)
map["Referer"] = referer
view.loadUrl(url, map)
true
}
} else if (url.contains("alipay")) {
return false
}
return false
}
fun webViewInit(wv_content: ProgressWebView) {
val setting: WebSettings = wv_content?.settings!!
......@@ -64,7 +121,7 @@ class ExpertConsultWebview : RelativeLayout {
.getJavascripHandler(mContext as Activity, tellData = TellData())
wv_content!!.addJavascriptInterface(jtoJHandle, "javascriptHandler")
var jumpurl = "http://192.168.210.152/jy/listenMask?listenerId=257&isFromApp=1"
var jumpurl = HttpConfig.MH5_URL+"wb/product/chat/template?doctorId=${111}{&cateId=634&productId=${111}"
val url = WebUrlParamsUtils.getSuffix(jumpurl, jtoJHandle.getUriAppendSuffix())
wv_content.loadUrl(url)
......
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