Commit ab18a99d authored by 王雪伟's avatar 王雪伟

[提交人]:王雪伟

[提交简述] :小象省钱
[实现方案] :调整订单
parent 75262c44
package com.zxbw.modulemain.activity
import android.content.Intent
import android.net.Uri
import android.net.http.SslError
import android.os.Handler
import android.util.Log
import android.view.View
import android.webkit.*
import androidx.recyclerview.widget.LinearLayoutManager
import com.zxbw.modulemain.R
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.NetConfig
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
......
......@@ -25,7 +25,7 @@ class ItemVipOrderAdapter :
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
var bean = mList[position]
holder.id_img_rights_icon?.setLoadImageUrl(bean.icon,0, 4)
holder.id_img_rights_icon?.setLoadImageUrl(bean.icon,false)
holder.id_tv_vip_goods_name?.text = "${bean.brand} ${bean.category} ${bean.goodsName}"
holder.id_tv_vip_goods_price?.text = "¥${bean.salePrice}"
// holder.id_tv_vip_goods_num?.text = "${bean.salePrice}"
......
......@@ -41,7 +41,12 @@ class JgqQyAdapter : BaseRecyclerAdapter<JgqQyEntity, JgqQyAdapter.ViewHolder> {
.apply(RequestOptions.bitmapTransform(CircleCrop()))
.into(holder?.id_icon!!)
holder.id_name?.text = bean.brand
holder.id_tv_discount_value?.text = "${bean.maxDiscount}折"
if(bean.maxDiscount.isNullOrEmpty()||bean.maxDiscount.equals("0")){
holder.id_tv_discount_value?.visibility = View.INVISIBLE
}else{
holder.id_tv_discount_value?.visibility = View.VISIBLE
holder.id_tv_discount_value?.text = "${bean.maxDiscount}折"
}
holder.id_rl_qy_item_view?.setOnClickListener {
listener.onItemClick(it, position, bean)
}
......
......@@ -51,7 +51,6 @@ class MyOrderAdapter : BaseRecyclerAdapter<ShopOrderEntity, RecyclerView.ViewHol
copy(holder.id_tv_order_no?.text.toString())
}
holder.id_tv_total_price?.text = "¥${bean.cash}"
// var mPrice = bean.cash?.toDouble()?.plus(bean.discount?.toDouble())
holder.id_tv_pricedesc?.text =
"总价:¥${bean.totalPrice}|优惠:¥${bean.discount}|运费:¥${bean.freight}|"
holder.id_tv_order_no?.text = bean.orderNo
......@@ -63,7 +62,6 @@ class MyOrderAdapter : BaseRecyclerAdapter<ShopOrderEntity, RecyclerView.ViewHol
holder.id_rl_order_item?.adapter = mAdapter
mAdapter?.clear()
mAdapter?.appendToList(bean.goodsList)
mAdapter?.notifyDataSetChanged()
}
} else if (holder is VipRightsOrderViewHolder) {
holder.img_vip_order_no_copy?.setOnClickListener {
......@@ -102,9 +100,9 @@ class MyOrderAdapter : BaseRecyclerAdapter<ShopOrderEntity, RecyclerView.ViewHol
.inflate(R.layout.items_layout_card_rights_order, parent, false)
)
} else if (viewType == VIEW_TYPE_GOODS_VIEW) {
return CardRightsOrderViewHolder(
return GoodsOrderViewHolder(
LayoutInflater.from(AppContext.get())
.inflate(R.layout.items_layout_card_rights_order, parent, false)
.inflate(R.layout.items_layout_box_order, parent, false)
)
} else {
return CardRightsOrderViewHolder(
......
......@@ -102,7 +102,7 @@ class NewBoxGoodsDetailActivity : BaseActivity(), GoodsDetailContract.View,
id_detail_rule?.setOnClickListener {
JumpUtils.webJump(
"规则",
"https://newspool.zhangxinhulian.com/sspapiNovel/su/custom/xingyunmohe/ios/use_introduce.html"
"https://newspool.zhangxinhulian.com/sspapiNovel/su/custom/xiaoxiangSaveMoney/privacy_app1.html"
)
}
//试玩
......
......@@ -10,6 +10,7 @@ import android.view.View
import android.webkit.*
import androidx.recyclerview.widget.LinearLayoutManager
import com.zxbw.modulemain.R
import com.zxbw.modulemain.activity.OpenMemberOrderActivity
import com.zxbw.modulemain.box.adapter.OrderAdapter
import com.zxbw.modulemain.box.contract.OrderDetailContract
import com.zxbw.modulemain.box.presenter.OrderDetailPresenter
......@@ -22,17 +23,18 @@ import com.zxhl.cms.net.model.box.AddressEntity
import com.zxhl.cms.net.model.box.AppInEntity
import com.zxhl.cms.net.model.box.OrderEntity
import com.zxhl.cms.net.model.video.MemberEntity
import com.zxhl.cms.pay.PayActivity
import com.zxhl.cms.pay.PayContract
import com.zxhl.cms.pay.PayPresenter
import com.zxhl.cms.utils.*
import com.zxhl.cms.widget.LoadingDialog
import com.zxhl.cms.net.model.uc.PayResultEntity
import com.zxhl.cms.pay.PaymentFunAdapter
import com.zxhl.cms.pay.*
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import kotlinx.android.synthetic.main.activity_layout_member_order.*
import kotlinx.android.synthetic.main.activity_layout_order_detail.*
import kotlinx.android.synthetic.main.activity_layout_order_detail.id_img_back
import kotlinx.android.synthetic.main.activity_layout_order_detail.id_img_close_pay_web
import kotlinx.android.synthetic.main.activity_layout_order_detail.id_rl_h5_pay_view
class OrderDetailActivity : BaseActivity(), OrderDetailContract.View, PayContract.View {
private var mPresenter: OrderDetailPresenter? = null
......@@ -56,7 +58,7 @@ class OrderDetailActivity : BaseActivity(), OrderDetailContract.View, PayContrac
const val H5_PAY = 21 //h5支付
}
private var pay_type = 0
private var pay_type: Int? = H5_PAY
override fun onClick(v: View?) {
}
......@@ -116,6 +118,9 @@ class OrderDetailActivity : BaseActivity(), OrderDetailContract.View, PayContrac
// id_img_ali?.setImageResource(com.zxhl.cms.R.drawable.icon_xuanzhong)
// }
id_img_close_pay_web?.setOnClickListener {
id_rl_h5_pay_view?.visibility = View.GONE
}
id_tv_to_pay?.setOnClickListener {
EventUtils.onEvent("pick_up_btn_click")
......@@ -293,6 +298,7 @@ class OrderDetailActivity : BaseActivity(), OrderDetailContract.View, PayContrac
pay_type.toString()
)
} else {
Log.d("wxw","goodsID"+payGoodsId)
mPayresenter?.requestMiniProgrom(
payGoodsId ?: "",
pay_type.toString(),
......@@ -380,7 +386,32 @@ class OrderDetailActivity : BaseActivity(), OrderDetailContract.View, PayContrac
EventUtils.onEvent("h5_pay_error")
showResultLoading(false)
} else {
loadH5Pay(form)
mHandler.sendEmptyMessageDelayed(1, 8000)
H5PayUtil().loadH5PayWeb(
this,
id_pay_web_view,
form,
object : H5PayUtil.H5PayCallBack {
override fun jumpZfbAppSuc() {
id_rl_h5_pay_view?.visibility = View.GONE
EventUtils.onEvent("h5_open_zfb_suc")
mHandler.removeMessages(1)
}
override fun jumpZfbAppException(e: Exception) {
EventUtils.onEvent("h5_open_zfb_error", e.toString())
mHandler.removeMessages(1)
mHandler.sendEmptyMessage(2)
}
override fun loadH5Error1(errorStr: String) {
EventUtils.onEvent("h5_pay_error1", errorStr)
}
override fun loadH5Error2(errorStr: String) {
EventUtils.onEvent("h5_pay_error2", errorStr)
}
})
}
}
......@@ -418,34 +449,6 @@ class OrderDetailActivity : BaseActivity(), OrderDetailContract.View, PayContrac
}
}
}
// if (result != null) {
//
// if (result.pay_ali.equals("1") && result.pay_wx.equals("0")) {
// pay_type = PayActivity.ALI_PAY
// id_rl_wechat_pay.visibility = View.GONE
// id_rl_zfb_pay.visibility = View.VISIBLE
// id_img_ali?.setImageResource(com.zxhl.cms.R.drawable.icon_xuanzhong)
// } else {
// if (result?.pay_ali.equals("0")) {
// id_rl_zfb_pay.visibility = View.GONE
// } else {
// id_rl_zfb_pay.visibility = View.VISIBLE
//// pay_type = PayActivity.ALI_PAY
//// id_img_wechat?.setImageResource(com.zxhl.cms.R.drawable.icon_xuanzhong_default)
//// id_img_ali?.setImageResource(com.zxhl.cms.R.drawable.icon_xuanzhong)
// }
// if (result?.pay_wx.equals("0")) {
// id_rl_wechat_pay.visibility = View.GONE
// } else {
// id_rl_wechat_pay.visibility = View.VISIBLE
// pay_type = PayActivity.MINI_PROGRAM
// id_img_wechat?.setImageResource(com.zxhl.cms.R.drawable.icon_xuanzhong)
// id_img_ali?.setImageResource(com.zxhl.cms.R.drawable.icon_xuanzhong_default)
// }
// }
// }
}
private var isPause = false
......@@ -477,112 +480,20 @@ class OrderDetailActivity : BaseActivity(), OrderDetailContract.View, PayContrac
mLoading?.setResult(false, "取消支付", 1000)
}
}
}
false
}
private fun loadH5Pay(form: String) {
val webSettings = id_pay_web_view.settings
//如果访问的页面中要与Javascript交互,则webview必须设置支持Javascript
webSettings.javaScriptEnabled = true
//设置自适应屏幕,两者合用
webSettings.useWideViewPort = true //将图片调整到适合webview的大小
webSettings.loadWithOverviewMode = true // 缩放至屏幕的大小
//其他细节操作
webSettings.cacheMode = WebSettings.LOAD_NO_CACHE //关闭webview中缓存
webSettings.allowFileAccess = true //设置可以访问文件
webSettings.javaScriptCanOpenWindowsAutomatically = true //支持通过JS打开新窗口
webSettings.loadsImagesAutomatically = true //支持自动加载图片
webSettings.defaultTextEncodingName = "utf-8" //设置编码格式
webSettings.domStorageEnabled = true
webSettings.allowFileAccessFromFileURLs = true;
webSettings.allowUniversalAccessFromFileURLs = true;
id_pay_web_view?.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
Log.e("WXW", "dURL" + url.toString())
if (url == null) return false
try {
if (url.startsWith("alipays://") //支付宝
) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
EventUtils.onEvent("h5_open_zfb_suc")
return true
}
} catch (e: Exception) { //防止crash (如果手机上没有安装处理某个scheme开头的url的APP, 会导致crash)
EventUtils.onEvent("h5_open_zfb_error", e.toString())
showResultLoading(false)
return true //没有安装该app时,返回true,表示拦截自定义链接,但不跳转,避免弹出上面的错误页面
}
return false
}
override fun onPageFinished(view: WebView?, url: String?) {
Log.e("WXW", "cURL" + url.toString())
Log.d("wxw", "EndTime" + System.currentTimeMillis())
super.onPageFinished(view, url)
if (url?.contains(NetConfig.H5.WEB_URL_H5_PAY) == true) {
id_pay_web_view?.loadUrl("javascript:loadPayHtml('$form')");
}
}
override fun onReceivedSslError(
view: WebView?,
handler: SslErrorHandler?,
error: SslError?
) {
// 接受所有网站的证书,忽略SSL错误,执行访问网页
handler?.proceed();
}
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
error: WebResourceError?
) {
super.onReceivedError(view, request, error)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
Log.d("wxw", "1error${error?.errorCode}")
Log.d("wxw", "2error${error?.description}")
Log.d("wxw", "3error${error?.toString()}")
EventUtils.onEvent(
"h5_pay_error1",
"code: ${error?.errorCode} desc: ${error?.description}"
)
} else {
EventUtils.onEvent("h5_pay_error1", error.toString())
1 -> {
if (mLoading != null) {
mLoading?.setResult(false, "支付异常", 0)
}
showResultLoading(false)
id_rl_h5_pay_view.visibility = View.VISIBLE
EventUtils.onEvent("h5_pay_end")
}
override fun onReceivedHttpError(
view: WebView?,
request: WebResourceRequest?,
errorResponse: WebResourceResponse?
) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
if (request?.url?.path?.endsWith("/favicon.ico") == true) {
} else {
Log.d("wxw", "1errorResponse?.statusCode${request?.url}")
Log.d("wxw", "2errorResponse?.statusCode${errorResponse?.statusCode}")
EventUtils.onEvent(
"h5_pay_error2",
errorResponse?.statusCode.toString() + " url:${request?.url}"
)
showResultLoading(false)
}
} else {
EventUtils.onEvent("h5_pay_error2", errorResponse.toString())
showResultLoading(false)
2 -> {
if (mLoading != null) {
mLoading?.setResult(false, "支付异常", 0)
}
super.onReceivedHttpError(view, request, errorResponse)
id_rl_h5_pay_view.visibility = View.VISIBLE
}
}
id_pay_web_view.loadUrl(NetConfig.H5.WEB_URL_H5_PAY)
false
}
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ import android.text.TextUtils
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.zxbw.modulemain.R
import com.zxbw.modulemain.adapter.MyOrderAdapter
import com.zxbw.modulemain.contract.BoxOrderContract
......@@ -13,66 +15,57 @@ import com.zxhl.cms.net.model.box.NoticeEntity
import com.zxhl.cms.net.model.box.ShopOrderEntity
import com.zxhl.cms.utils.Utils
import kotlinx.android.synthetic.main.fragment_layout_magic_box_order.*
import kotlinx.android.synthetic.main.fragment_layout_magic_box_order.id_refresh_view
import kotlinx.android.synthetic.main.fragment_layout_recommend.*
class MagicBoxOrderFragment:BaseFragment(), BoxOrderContract.View {
class MagicBoxOrderFragment : BaseFragment(), BoxOrderContract.View {
private var mPresenter: BoxOrderPresenter? = null
private var mAdapter: MyOrderAdapter?=null
private var mAdapter: MyOrderAdapter? = null
override fun layoutID(): Int {
return R.layout.fragment_layout_magic_box_order
}
override fun init(view: View?) {
mPresenter = BoxOrderPresenter(this)
mAdapter= MyOrderAdapter(mActivity)
box_order_recyclerView.layoutManager= LinearLayoutManager(mActivity)
box_order_recyclerView.adapter=mAdapter
mAdapter = MyOrderAdapter(mActivity)
box_order_recyclerView.layoutManager = LinearLayoutManager(mActivity)
box_order_recyclerView.adapter = mAdapter
mPresenter?.getOrderList(true)
mPresenter?.getNotice()
refreshLayout.setColorSchemeColors(resources.getColor(R.color.color_3A95FD))
refreshLayout?.setOnRefreshListener {
mPresenter?.getOrderList(true)
}
box_order_recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
}
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
if (Utils.isSlideToBottom(recyclerView)) {
if ((mAdapter?.list?.size ?: 0) > 0) {
mPresenter?.getOrderList(false)
}
}
}
})
id_refresh_view.setRefreshHeader(ClassicsHeader(activity))
id_refresh_view.setRefreshFooter(ClassicsFooter(activity))
id_refresh_view.setOnRefreshListener {
mPresenter?.getOrderList(true)
}
id_refresh_view.setOnLoadMoreListener {
mPresenter?.getOrderList(false)
}
}
companion object {
fun newInstance() = MagicBoxOrderFragment()
}
override fun setOrderListData(isRefresh: Boolean, reslut: List<ShopOrderEntity>?) {
if (isRefresh) {
id_refresh_view.finishRefresh(!reslut.isNullOrEmpty());//传入false表示加载失败
} else {
id_refresh_view.finishLoadMore(!reslut.isNullOrEmpty());//传入false表示加载失败
}
if (isRefresh && !reslut.isNullOrEmpty()) {
mAdapter?.clear()
}
setEmptyView(false)
val start = mAdapter?.getItemCount() ?: 0
mAdapter?.appendToList(reslut)
if (isRefresh) {
mAdapter?.notifyDataSetChanged()
} else {
val end = mAdapter?.getItemCount() ?: 0
mAdapter?.notifyItemRangeChanged(start, end)
if (!reslut.isNullOrEmpty()) {
mAdapter?.appendToList(reslut)
}
setEmptyView(mAdapter?.list?.size ?: 0 == 0)
}
override fun setEmptyView(isEmpty: Boolean) {
refreshLayout?.isRefreshing = false
if (isEmpty) {
id_order_empty.visibility = View.VISIBLE
} else {
......@@ -81,11 +74,11 @@ class MagicBoxOrderFragment:BaseFragment(), BoxOrderContract.View {
}
override fun setNotice(reslut: NoticeEntity?) {
if(!TextUtils.isEmpty(reslut?.orderNotice)){
id_ll_notice?.visibility=View.VISIBLE
id_tv_order_notice?.text=reslut?.orderNotice
}else{
id_ll_notice?.visibility=View.GONE
if (!TextUtils.isEmpty(reslut?.orderNotice)) {
id_ll_notice?.visibility = View.VISIBLE
id_tv_order_notice?.text = reslut?.orderNotice
} else {
id_ll_notice?.visibility = View.GONE
}
}
......
......@@ -18,43 +18,25 @@ class BoxOrderPresenter : BoxOrderContract.Presenter {
private var page: Int = 1
private val size: Int = 10
private var isMore = false
override fun getOrderList(ifRefresh: Boolean) {
if (ifRefresh) {
page = 1
isMore = false
} else if (isMore) {
return
}
isMore = true
ApiClient.homeApi.getOrder(page, size)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<List<ShopOrderEntity>>() {
override fun onSuccess(result: List<ShopOrderEntity>?) {
if (result != null) {
if (!result.isNullOrEmpty()) {
if (result.size <= size) {
page++
isMore = false
} else {
isMore = true
}
mView.setOrderListData(ifRefresh, result)
} else {
if (page == 1) {
mView.setEmptyView(true)
}
}
page++;
mView.setOrderListData(ifRefresh, result)
} else {
mView.setEmptyView(true)
mView.setOrderListData(ifRefresh, null)
}
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
Log.d("wxw", "goodsListError " + code + " errorMsg " + errorMsg)
// mView.setEmptyView(true)
mView.setEmptyView(true)
mView.setOrderListData(ifRefresh, null)
}
})
......
......@@ -409,7 +409,7 @@
android:id="@+id/id_img_close_pay_web"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/id_member_pay_web_view"
android:layout_alignRight="@id/id_rights_pay_web_view"
android:padding="10dp"
android:src="@drawable/icon_guanbi" />
......
......@@ -342,7 +342,7 @@
android:id="@+id/id_img_close_pay_web"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/id_member_pay_web_view"
android:layout_alignRight="@id/id_member_pay_web_view"
android:padding="10dp"
android:src="@drawable/icon_guanbi" />
......
......@@ -450,9 +450,25 @@
<!-- android:textSize="15sp" />-->
<!-- </RelativeLayout>-->
<WebView
android:id="@+id/id_pay_web_view"
<RelativeLayout
android:id="@+id/id_rl_h5_pay_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
android:layout_height="match_parent"
android:layout_below="@id/id_rl_order_title"
android:visibility="gone">
<WebView
android:id="@+id/id_pay_web_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/id_img_close_pay_web"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@id/id_pay_web_view"
android:padding="10dp"
android:src="@drawable/icon_guanbi" />
</RelativeLayout>
</RelativeLayout>
......@@ -322,7 +322,7 @@
android:id="@+id/id_img_close_pay_web"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/id_member_pay_web_view"
android:layout_alignRight="@id/id_rights_pay_web_view"
android:padding="10dp"
android:src="@drawable/icon_guanbi" />
......
......@@ -343,7 +343,7 @@
android:id="@+id/id_img_close_pay_web"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/id_member_pay_web_view"
android:layout_alignRight="@id/id_rights_pay_web_view"
android:padding="10dp"
android:src="@drawable/icon_guanbi" />
......
......@@ -344,7 +344,7 @@
android:id="@+id/id_img_close_pay_web"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/id_member_pay_web_view"
android:layout_alignRight="@id/id_rights_pay_web_view"
android:padding="10dp"
android:src="@drawable/icon_guanbi" />
......
......@@ -31,18 +31,19 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refreshLayout"
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/id_refresh_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/box_order_recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
<LinearLayout
android:id="@+id/id_order_empty"
......
......@@ -9,11 +9,18 @@
android:layout_height="52dp"
android:orientation="horizontal">
<com.zxhl.cms.widget.RecycleImageView
android:id="@+id/id_img_rights_icon"
<RelativeLayout
android:layout_width="70dp"
android:layout_height="52dp"
android:layout_marginRight="10dp" />
android:layout_marginRight="10dp"
android:background="@drawable/img_vip_rights_bg">
<com.zxhl.cms.widget.RecycleImageView
android:id="@+id/id_img_rights_icon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_margin="5dp" />
</RelativeLayout>
<TextView
android:id="@+id/id_tv_vip_goods_name"
......
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