diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6e0266e..1c66bc5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -303,6 +303,13 @@ android:screenOrientation="portrait" /> + + + + diff --git a/app/src/main/java/com/zj365/dc/activity/DietManagementAct.kt b/app/src/main/java/com/zj365/dc/activity/DietManagementAct.kt index a38aefa..e5366a3 100644 --- a/app/src/main/java/com/zj365/dc/activity/DietManagementAct.kt +++ b/app/src/main/java/com/zj365/dc/activity/DietManagementAct.kt @@ -53,6 +53,7 @@ class DietManagementAct : BaseVmAct(){ "web_site_url", "${BuildConfig.h5url}pages/index/index?pageId=cookbook" ) + bundle.putBoolean("isShowTitle",false) RouteManager.goAct(ARouterUrl.H5_ACT, bundle) } // var url = "${BuildConfig.}" @@ -67,6 +68,7 @@ class DietManagementAct : BaseVmAct(){ "web_site_url", "${BuildConfig.h5url}pages/index/index?pageId=herbal" ) + bundle.putBoolean("isShowTitle",false) RouteManager.goAct(ARouterUrl.H5_ACT, bundle) } diff --git a/app/src/main/java/com/zj365/dc/activity/shop/CreateGoodsOrderAct.kt b/app/src/main/java/com/zj365/dc/activity/shop/CreateGoodsOrderAct.kt index 50a1d6f..85b31c0 100644 --- a/app/src/main/java/com/zj365/dc/activity/shop/CreateGoodsOrderAct.kt +++ b/app/src/main/java/com/zj365/dc/activity/shop/CreateGoodsOrderAct.kt @@ -1,5 +1,6 @@ package com.zj365.dc.activity.shop +import android.content.Intent import android.view.LayoutInflater import android.view.View import android.widget.ImageView @@ -7,19 +8,27 @@ import android.widget.LinearLayout import android.widget.TextView import com.alibaba.android.arouter.facade.annotation.Route import com.google.android.material.bottomsheet.BottomSheetDialog +import com.tamsiree.rxkit.RxActivityTool +import com.xty.base.act.BaseTenCentWebViewActivity import com.xty.base.act.BaseVmAct +import com.xty.base.model.ChooseAddressBean +import com.xty.base.model.ChooseCouponBean import com.xty.base.model.CreateOrderBean import com.xty.base.utils.PayUtils import com.xty.base.vm.BaseVm import com.xty.common.arouter.ARouterUrl import com.xty.common.arouter.RouteManager +import com.xty.common.event.ReChangeEvent import com.xty.common.setImage import com.xty.common.util.SpannableUtils import com.xty.network.model.ShopGoodsOrderBean import com.zj365.dc.BuildConfig +import com.zj365.dc.activity.DeviceChoiceAct import com.zj365.dc.databinding.ActCreateGoodsOrderBinding import com.zj365.dc.vm.ShopMallVm import com.zj365.health.R +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode @Route(path = ARouterUrl.CREATE_SHOP_ORDER_ACT) class CreateGoodsOrderAct : BaseVmAct() { @@ -32,6 +41,10 @@ class CreateGoodsOrderAct : BaseVmAct() { var bottomSheetDialog: BottomSheetDialog? = null + companion object{ + const val REQUEST_ADDRESS = 0x000011 + const val REQUEST_COUP = 0x000012 + } override fun liveObserver() { mViewModel.createOrderLiveData.observe(this){ @@ -65,7 +78,7 @@ class CreateGoodsOrderAct : BaseVmAct() { binding.tvPlatformDiscounts.text = "${(bean.ori_price * bean.skuNum) - (bean.skuPrice * bean.skuNum)}" if (bean.delivery_mode == 0){ //0,无需发货,1,需要发货 - binding.rxAddress.visibility = View.GONE + // binding.rxAddress.visibility = View.GONE }else{ binding.rxAddress.visibility = View.VISIBLE } @@ -86,7 +99,7 @@ class CreateGoodsOrderAct : BaseVmAct() { "web_site_url", "${BuildConfig.h5url}pages/index/index?pageId=address&type=order" ) - RouteManager.goAct(ARouterUrl.H5_ACT, bundle) + RouteManager.goActRequest(ARouterUrl.H5_ACT, this@CreateGoodsOrderAct,REQUEST_ADDRESS,bundle) } @@ -96,11 +109,42 @@ class CreateGoodsOrderAct : BaseVmAct() { "web_site_url", "${BuildConfig.h5url}pages/index/index?pageId=coupon&type=order" ) - RouteManager.goAct(ARouterUrl.H5_ACT, bundle) + RouteManager.goActRequest(ARouterUrl.H5_ACT, this@CreateGoodsOrderAct,REQUEST_COUP,bundle) } } override fun setLayout()=binding.root + @Subscribe(threadMode = ThreadMode.MAIN) + fun paySuccess(event: ReChangeEvent){ + RouteManager.goAct(ARouterUrl.SHOP_ORDER_LIST_ACT) + RxActivityTool.finishActivity(BaseTenCentWebViewActivity::class.java) + finish() + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + if(resultCode == RESULT_OK){ + when(requestCode){ + REQUEST_ADDRESS ->{ + var addressBean = data?.extras!!.getParcelable("address") + if (addressBean != null) { + addrId = addressBean.id + binding.tvChooseAddress.text = "${addressBean.province}${addressBean.city}${addressBean.district}${addressBean.address}" + } + + } + + REQUEST_COUP ->{ + var couponBean = data?.extras!!.getParcelable("coupon") + if (couponBean != null) { + couponsId = couponBean.id + binding.tvDiscounts.text = "可优惠${couponBean.as_amount}" + } + } + } + } + } + } \ No newline at end of file diff --git a/app/src/main/java/com/zj365/dc/activity/shop/ShopCategoryActivity.kt b/app/src/main/java/com/zj365/dc/activity/shop/ShopCategoryActivity.kt index 97aad7d..22a20f7 100644 --- a/app/src/main/java/com/zj365/dc/activity/shop/ShopCategoryActivity.kt +++ b/app/src/main/java/com/zj365/dc/activity/shop/ShopCategoryActivity.kt @@ -1,16 +1,22 @@ package com.zj365.dc.activity.shop +import android.text.TextUtils +import android.view.KeyEvent import android.view.LayoutInflater import android.view.View +import android.view.inputmethod.EditorInfo +import android.widget.TextView import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import com.alibaba.android.arouter.facade.annotation.Route +import com.tamsiree.rxkit.RxKeyboardTool import com.xty.base.act.BaseListAct import com.xty.base.act.BaseVmAct import com.xty.common.Const import com.xty.common.R import com.xty.common.arouter.ARouterUrl import com.xty.common.arouter.RouteManager +import com.xty.common.util.CommonToastUtils import com.xty.network.model.GoodsRecordsBean import com.xty.network.model.ShopCategoryBean import com.zj365.dc.BuildConfig @@ -83,6 +89,7 @@ class ShopCategoryActivity : BaseVmAct() { "web_site_url", "${BuildConfig.h5url}pages/index/index?pageId=commodityDetail&id=${bean.id}" ) + bundle.putBoolean("isShowTitle",false) RouteManager.goAct(ARouterUrl.H5_ACT, bundle) } @@ -135,6 +142,27 @@ class ShopCategoryActivity : BaseVmAct() { } mViewModel.getGoodsCategory(categoryId) + binding.etSearch.setOnEditorActionListener(object : TextView.OnEditorActionListener { + override fun onEditorAction(p0: TextView?, p1: Int, p2: KeyEvent?): Boolean { + if(p1 == EditorInfo.IME_ACTION_SEARCH){ + goodsName = binding.etSearch.text.toString().trim() + if(TextUtils.isEmpty(goodsName)){ + CommonToastUtils.showToast("请输入搜索内容") + return true + } + page = 1 + mViewModel.getGoodsList(goodsName,categoryId,0,page) + //mViewModel.getGoodsList(goodsName,0L,0,page) + + RxKeyboardTool.hideSoftInput(this@ShopCategoryActivity) + return true + + } + return false + } + + }) + } diff --git a/app/src/main/java/com/zj365/dc/fragment/MineFrag.kt b/app/src/main/java/com/zj365/dc/fragment/MineFrag.kt index d5a9143..31cd5d9 100644 --- a/app/src/main/java/com/zj365/dc/fragment/MineFrag.kt +++ b/app/src/main/java/com/zj365/dc/fragment/MineFrag.kt @@ -4,6 +4,7 @@ import android.Manifest import android.content.Intent import android.net.Uri import android.os.Build +import android.text.TextUtils import android.view.View import androidx.annotation.RequiresApi import cn.jpush.android.api.JPushInterface @@ -24,6 +25,7 @@ import com.xty.common.xqr_code.XQRCodeAct import com.xty.network.model.InviteCustodyBean import com.xty.network.model.SettingBean +import com.xty.network.model.UserOtherInfo import com.zj365.dc.BuildConfig import com.zj365.dc.activity.MainActivity import com.zj365.dc.databinding.FragMineBinding @@ -55,6 +57,8 @@ class MineFrag : BaseVmFrag() , EasyPermissions.PermissionCallbacks{ } var isDemonstrate: Boolean = false + + var otherInfo: UserOtherInfo? = null override fun setLayout(): View = binding.root private val defaultIcon by lazy { @@ -278,7 +282,22 @@ class MineFrag : BaseVmFrag() , EasyPermissions.PermissionCallbacks{ if(MMkvHelper.getLong(Const.USER_ID).toString() == "0"){ RouteManager.goAct(ARouterUrl.LOGIN_ACT) }else { - CommonToastUtils.showToast("敬请期待") + otherInfo?.let { + if (!TextUtils.isEmpty(it.start_business)){ + bundle.clear() + bundle.putString( + "web_site_url", + "${it.start_business}" + ) + RouteManager.goAct(ARouterUrl.H5_ACT, bundle) + }else{ + CommonToastUtils.showToast("敬请期待") + + } + }?:{ + CommonToastUtils.showToast("敬请期待") + + } } } @@ -286,7 +305,23 @@ class MineFrag : BaseVmFrag() , EasyPermissions.PermissionCallbacks{ if(MMkvHelper.getLong(Const.USER_ID).toString() == "0"){ RouteManager.goAct(ARouterUrl.LOGIN_ACT) }else { - CommonToastUtils.showToast("敬请期待") + otherInfo?.let { + if (!TextUtils.isEmpty(it.placard)){ + bundle.clear() + bundle.putString( + "web_site_url", + "${it.placard}" + ) + RouteManager.goAct(ARouterUrl.H5_ACT, bundle) + }else{ + CommonToastUtils.showToast("敬请期待") + + } + }?:{ + CommonToastUtils.showToast("敬请期待") + + } + } } @@ -352,11 +387,22 @@ class MineFrag : BaseVmFrag() , EasyPermissions.PermissionCallbacks{ if(MMkvHelper.getLong(Const.USER_ID).toString() == "0"){ RouteManager.goAct(ARouterUrl.LOGIN_ACT) }else { - bundle.clear() - bundle.putString("title", "操作手册") - bundle.putBoolean("isAgree", false) - bundle.putString("url", "https://mp.weixin.qq.com/s?__biz=MzkxMzI0NzU3NA==&mid=2247487161&idx=1&sn=ed2fca4f04beb00b16f1b7e6c922d40a&chksm=c101d280f6765b967665df1c3e3c5cc609f1fcf7f0434c3bb26fbc13f7806cd9a2b37048f9e8#rd") - RouteManager.goAct(ARouterUrl.AGREEMNT_READ_WEB_ACT, bundle) + otherInfo?.let { + if (!TextUtils.isEmpty(it.placard)){ + bundle.clear() + bundle.putString("title", "操作手册") + bundle.putBoolean("isAgree", false) + bundle.putString("url", "${it.operation_guide}") + RouteManager.goAct(ARouterUrl.AGREEMNT_READ_WEB_ACT, bundle) + }else{ + CommonToastUtils.showToast("敬请期待") + + } + }?:{ + CommonToastUtils.showToast("敬请期待") + + } + } } @@ -425,7 +471,7 @@ class MineFrag : BaseVmFrag() , EasyPermissions.PermissionCallbacks{ private fun refresh() { refresh.setRefresh(binding.mRefresh) { mViewModel.getMySetting() - mViewModel.getUserEquity() + mViewModel.getUserOtherInfo() mViewModel.getAllInfo(showIdInfo,false) mViewModel.searchInviteInfo() } @@ -444,7 +490,7 @@ class MineFrag : BaseVmFrag() , EasyPermissions.PermissionCallbacks{ // mViewModel.getScore(1) mViewModel.searchInviteInfo() - mViewModel.getUserEquity() + mViewModel.getUserOtherInfo() // } } @@ -452,8 +498,26 @@ class MineFrag : BaseVmFrag() , EasyPermissions.PermissionCallbacks{ /* mViewModel.familyLive.observe(this) { binding.mFamily.text = it.data.size.toString() }*/ - mViewModel.userEqualityLiveData.observe(this){ - binding.tvMemberValidity.text ="有效期至:${it.data}" + mViewModel.useOtherInfoLiveData.observe(this){ + otherInfo = it.data + binding.tvMemberValidity.text ="有效期至:${it.data.vip_end_time}" + binding.mCoupon.text = "${it.data.coupons_count}" + binding.mTvWallet.text = "${it.data.money}" + binding.tvOrder.text = "${it.data.order_count}" + + if(TextUtils.isEmpty(it.data.start_business)){ + binding.llStartBs.visibility = View.GONE + }else{ + binding.llStartBs.visibility = View.VISIBLE + } + + if(TextUtils.isEmpty(it.data.placard)){ + binding.llDailyPoster.visibility = View.GONE + }else{ + binding.llDailyPoster.visibility = View.VISIBLE + } + + } mViewModel.scoreLive.observe(this) { binding.mIntegral.text = (if (it.data.num.isNullOrEmpty()) "0" else it.data.num!!) diff --git a/app/src/main/java/com/zj365/dc/fragment/ShopFragment.kt b/app/src/main/java/com/zj365/dc/fragment/ShopFragment.kt index 57ffaad..0f8c857 100644 --- a/app/src/main/java/com/zj365/dc/fragment/ShopFragment.kt +++ b/app/src/main/java/com/zj365/dc/fragment/ShopFragment.kt @@ -78,7 +78,7 @@ class ShopFragment: BaseFragList() { CommonToastUtils.showToast("请输入搜索内容") return true } - + page = 1 mViewModel.getGoodsList(goodsName,0L,0,page) RxKeyboardTool.hideSoftInput(requireActivity()) diff --git a/app/src/main/res/layout/frag_mine.xml b/app/src/main/res/layout/frag_mine.xml index 9df8569..a9857a1 100644 --- a/app/src/main/res/layout/frag_mine.xml +++ b/app/src/main/res/layout/frag_mine.xml @@ -135,7 +135,7 @@ android:layout_height="wrap_content" android:paddingTop="@dimen/dp_25" android:orientation="horizontal" - android:weightSum="4" + android:weightSum="3" android:background="@color/white" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" @@ -636,6 +636,7 @@ - + + + + bean.linkAddress?.let { + if(bean.bannerType != 5 &&it.startsWith("http")){ + var bundle = Bundle() + bundle.putString("title", bean.title) + bundle.putString("url", it) + RouteManager.goAct(ARouterUrl.WEB_ACT, bundle) + } } + } } diff --git a/base/src/main/java/com/xty/base/h5/CloudJSBridge.kt b/base/src/main/java/com/xty/base/h5/CloudJSBridge.kt index 072a79f..7afbeff 100644 --- a/base/src/main/java/com/xty/base/h5/CloudJSBridge.kt +++ b/base/src/main/java/com/xty/base/h5/CloudJSBridge.kt @@ -1,12 +1,21 @@ package com.xty.base.h5 +import android.Manifest import android.content.Context +import android.content.Intent +import android.net.Uri import android.os.Bundle import android.webkit.JavascriptInterface +import androidx.appcompat.app.AppCompatActivity import com.blankj.utilcode.util.GsonUtils import com.google.gson.Gson +import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram +import com.tencent.mm.opensdk.openapi.WXAPIFactory import com.xty.base.act.BaseVmAct +import com.xty.base.model.ChooseAddressBean +import com.xty.base.model.ChooseCouponBean import com.xty.base.model.CreateOrderBean +import com.xty.base.model.OpenWXBean import com.xty.base.model.ScienceDetailBean import com.xty.base.model.WatchReChangeBean import com.xty.base.utils.PayUtils @@ -17,6 +26,7 @@ import com.xty.common.arouter.ARouterUrl import com.xty.common.arouter.RouteManager import com.xty.common.util.ToastUtils import org.json.JSONObject +import pub.devrel.easypermissions.EasyPermissions open class CloudJSBridge(val context: Context, val listener: IJsBridge) { private var baseActivity: BaseVmAct<*> = context as BaseVmAct<*> @@ -87,24 +97,81 @@ open class CloudJSBridge(val context: Context, val listener: IJsBridge) { @JavascriptInterface fun createOrder(str: String?){ str?.let { - var orderBean = GsonUtils.fromJson(it, CreateOrderBean::class.java) - var bundle = Bundle() - bundle.putParcelable("bean",orderBean) - RouteManager.goAct(ARouterUrl.CREATE_SHOP_ORDER_ACT,bundle) + if(MMkvHelper.getLong(Const.USER_ID).toString() == "0"){ + RouteManager.goAct(ARouterUrl.LOGIN_ACT) + }else { + var orderBean = GsonUtils.fromJson(it, CreateOrderBean::class.java) + var bundle = Bundle() + bundle.putParcelable("bean", orderBean) + RouteManager.goAct(ARouterUrl.CREATE_SHOP_ORDER_ACT, bundle) + } } } @JavascriptInterface fun selectAdd(str: String?){ str?.let { - + var addressBean = GsonUtils.fromJson(it, ChooseAddressBean::class.java) + baseActivity.bundle.clear() + baseActivity.bundle.putParcelable("address", addressBean) + baseActivity.intent.putExtras( baseActivity.bundle) + baseActivity.setResult(AppCompatActivity.RESULT_OK, baseActivity.intent) + baseActivity.finish() } } @JavascriptInterface fun selectCoupon(str: String?){ str?.let { + var couponBean = GsonUtils.fromJson(it, ChooseCouponBean::class.java) + baseActivity.bundle.clear() + baseActivity.bundle.putParcelable("coupon", couponBean) + baseActivity.intent.putExtras( baseActivity.bundle) + baseActivity.setResult(AppCompatActivity.RESULT_OK, baseActivity.intent) + baseActivity.finish() + } + } + + @JavascriptInterface + fun toHome(str: String?){ + baseActivity.finish() + } + + @JavascriptInterface + fun callTell(str: String?){ + if(EasyPermissions.hasPermissions(baseActivity, + Manifest.permission.CALL_PHONE)){ + baseActivity.startActivity(Intent(Intent.ACTION_CALL, Uri.parse("tel:4000063365"))) + }else{ + EasyPermissions.requestPermissions(baseActivity,"", + 0x00011, + Manifest.permission.CALL_PHONE) + } + } + + @JavascriptInterface + fun jumpWallet(str: String?){ + str?.let { + var wxBean = GsonUtils.fromJson(it, OpenWXBean::class.java) + + val appId = "wx032bacb749c0dcb0" // 填移动应用(App)的 AppId,非小程序的 AppID + + val api = WXAPIFactory.createWXAPI(baseActivity, appId) + + val req = WXLaunchMiniProgram.Req() + req.userName = wxBean.id // 填小程序原始id + + req.path = wxBean.path ////拉起小程序页面的可带参路径,不填默认拉起小程序首页,对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar"。 + + if(wxBean.type == 3){ + req.miniprogramType = + WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE // 可选打开 开发版,体验版和正式版 + }else{ + req.miniprogramType = + WXLaunchMiniProgram.Req.MINIPROGRAM_TYPE_PREVIEW // 可选打开 开发版,体验版和正式版 + } + api.sendReq(req) } } diff --git a/base/src/main/java/com/xty/base/model/ChooseAddressBean.kt b/base/src/main/java/com/xty/base/model/ChooseAddressBean.kt new file mode 100644 index 0000000..b0d675c --- /dev/null +++ b/base/src/main/java/com/xty/base/model/ChooseAddressBean.kt @@ -0,0 +1,16 @@ +package com.xty.base.model + +import android.os.Parcelable +import kotlinx.android.parcel.Parcelize + +@Parcelize +data class ChooseAddressBean( + var id:Long, + var username:String, + var mobile:String, + var province:String, + var city:String, + var district:String, + var address:String, + var is_default:Int +):Parcelable diff --git a/base/src/main/java/com/xty/base/model/ChooseCouponBean.kt b/base/src/main/java/com/xty/base/model/ChooseCouponBean.kt new file mode 100644 index 0000000..a38cf76 --- /dev/null +++ b/base/src/main/java/com/xty/base/model/ChooseCouponBean.kt @@ -0,0 +1,19 @@ +package com.xty.base.model + +import android.os.Parcelable +import io.reactivex.observers.DefaultObserver +import kotlinx.android.parcel.Parcelize + +@Parcelize +data class ChooseCouponBean( + var id:Long, + var card_type:Int, + var status:Int, + var is_share:Int, + var share_user_id:Long, + var share_user_name:String, + var as_amount:Double, + var discount:Double, + var card_name:String +) : Parcelable { +} \ No newline at end of file diff --git a/base/src/main/java/com/xty/base/model/OpenWXBean.kt b/base/src/main/java/com/xty/base/model/OpenWXBean.kt new file mode 100644 index 0000000..b4aa7e8 --- /dev/null +++ b/base/src/main/java/com/xty/base/model/OpenWXBean.kt @@ -0,0 +1,8 @@ +package com.xty.base.model + +data class OpenWXBean( + var path:String, + var id:String, + var type:Int +) { +} \ No newline at end of file diff --git a/base/src/main/java/com/xty/base/utils/UserInfoDefin.kt b/base/src/main/java/com/xty/base/utils/UserInfoDefin.kt index 009a7da..5f29fe9 100644 --- a/base/src/main/java/com/xty/base/utils/UserInfoDefin.kt +++ b/base/src/main/java/com/xty/base/utils/UserInfoDefin.kt @@ -173,8 +173,8 @@ object UserInfoDefin { arrayOf( R.color.col_7b8, R.color.col_7b8, - R.color.col_48d, - R.color.col_e6b, + R.color.col_9BDd, + R.color.col_96D, R.color.col_FDA481 ) } diff --git a/base/src/main/res/layout/act_base_tencent_webview.xml b/base/src/main/res/layout/act_base_tencent_webview.xml index 9baad2f..91a5b56 100644 --- a/base/src/main/res/layout/act_base_tencent_webview.xml +++ b/base/src/main/res/layout/act_base_tencent_webview.xml @@ -4,6 +4,11 @@ android:layout_height="match_parent" android:orientation="vertical"> + + #6EA8F6 #FDA481 #F7891D + #F5F6FA + \ No newline at end of file diff --git a/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt b/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt index bf25f80..f19cb29 100644 --- a/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt +++ b/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt @@ -148,6 +148,7 @@ class ARouterUrl { //心理测试 const val PSYCHOLOGICAL_TEST_LIST_ACT = "/health/com/zj365/health/act/psychological/PsychologicalTestMainAct" + const val PSYCHOLOGICAL_QUESTION_ACT = "/health/com/zj365/health/act/psychological/PsychologicalQuestionnaireAct" //设备绑定相关 @@ -228,7 +229,8 @@ class ARouterUrl { //地理围栏 const val ELECTRONIC_FENCE_SET_ACT = "/mine/com/zj365/dc/mime/act/electronicfence/ElectronicFenceSettingAct" - + const val ELECTRONIC_ADDRESS_CHOOSE_ACT = "/mine/com/zj365/dc/mime/act/electronicfence/ElectronicAddressChooseAct" + const val ELECTRONIC_ADD_MODIFY_ACT ="/mine/com/zj365/dc/mime/act/electronicfence/ElectronicAddOrModifyAct" const val CHANGE_PHONE = "/mine/com/zj365/dc/mime/act/ChangePhoneAct" diff --git a/common/src/main/java/com/xty/common/event/BtFenceSettingSuccessEvent.kt b/common/src/main/java/com/xty/common/event/BtFenceSettingSuccessEvent.kt new file mode 100644 index 0000000..24cfdd3 --- /dev/null +++ b/common/src/main/java/com/xty/common/event/BtFenceSettingSuccessEvent.kt @@ -0,0 +1,4 @@ +package com.xty.common.event + +class BtFenceSettingSuccessEvent { +} \ No newline at end of file diff --git a/common/src/main/java/com/xty/common/util/NumUtils.kt b/common/src/main/java/com/xty/common/util/NumUtils.kt new file mode 100644 index 0000000..e1bbc1b --- /dev/null +++ b/common/src/main/java/com/xty/common/util/NumUtils.kt @@ -0,0 +1,15 @@ +package com.xty.common.util + +import java.math.BigDecimal + +object NumUtils { + + fun divide(valueOne: Int, valueTwo: Int, scale: Int): Double { + if (scale < 0) { + throw IllegalArgumentException("The scale must be a positive integer or zero") + } + val b1 = BigDecimal(java.lang.Double.toString(valueOne.toDouble())) + val b2 = BigDecimal(java.lang.Double.toString(valueTwo.toDouble())) + return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).toDouble() + } +} \ No newline at end of file diff --git a/common/src/main/res/drawable/seek_bar.xml b/common/src/main/res/drawable/seek_bar.xml new file mode 100644 index 0000000..c911ba0 --- /dev/null +++ b/common/src/main/res/drawable/seek_bar.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/shape_storke_white_c53.xml b/common/src/main/res/drawable/shape_storke_white_c53.xml new file mode 100644 index 0000000..115bb34 --- /dev/null +++ b/common/src/main/res/drawable/shape_storke_white_c53.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/shape_stroke_white_d42.xml b/common/src/main/res/drawable/shape_stroke_white_d42.xml new file mode 100644 index 0000000..d6a24b2 --- /dev/null +++ b/common/src/main/res/drawable/shape_stroke_white_d42.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/health/src/main/res/mipmap-xhdpi/ic_search.png b/common/src/main/res/mipmap-xhdpi/ic_search.png similarity index 100% rename from health/src/main/res/mipmap-xhdpi/ic_search.png rename to common/src/main/res/mipmap-xhdpi/ic_search.png diff --git a/common/src/main/res/mipmap-xxhdpi/icon_address_checked.png b/common/src/main/res/mipmap-xxhdpi/icon_address_checked.png new file mode 100644 index 0000000..9e28a73 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_address_checked.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_address_location.png b/common/src/main/res/mipmap-xxhdpi/icon_address_location.png new file mode 100644 index 0000000..4a4dd27 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_address_location.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_disease.png b/common/src/main/res/mipmap-xxhdpi/icon_disease.png index f8ef79e..b67c0d8 100644 Binary files a/common/src/main/res/mipmap-xxhdpi/icon_disease.png and b/common/src/main/res/mipmap-xxhdpi/icon_disease.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_healthy.png b/common/src/main/res/mipmap-xxhdpi/icon_healthy.png index 9eca33f..c0819f9 100644 Binary files a/common/src/main/res/mipmap-xxhdpi/icon_healthy.png and b/common/src/main/res/mipmap-xxhdpi/icon_healthy.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_insufficient.png b/common/src/main/res/mipmap-xxhdpi/icon_insufficient.png index 9911cad..a08fc69 100644 Binary files a/common/src/main/res/mipmap-xxhdpi/icon_insufficient.png and b/common/src/main/res/mipmap-xxhdpi/icon_insufficient.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_sub_health.png b/common/src/main/res/mipmap-xxhdpi/icon_sub_health.png index 63caab3..e0c642d 100644 Binary files a/common/src/main/res/mipmap-xxhdpi/icon_sub_health.png and b/common/src/main/res/mipmap-xxhdpi/icon_sub_health.png differ diff --git a/common/src/main/res/values/colors.xml b/common/src/main/res/values/colors.xml index f62a39f..0ac1872 100644 --- a/common/src/main/res/values/colors.xml +++ b/common/src/main/res/values/colors.xml @@ -205,4 +205,6 @@ #E3FCF6 #F15C42 #FFD04F + #FFAC53 + #F04D42 \ No newline at end of file diff --git a/config.gradle b/config.gradle index 4cb2718..7dbdf00 100644 --- a/config.gradle +++ b/config.gradle @@ -107,6 +107,7 @@ ext { gd_location : 'com.amap.api:location:latest.integration', gd_map : 'com.amap.api:3dmap:8.0.1', + gd_search : 'com.amap.api:search:latest.integration', wixin : 'com.tencent.mm.opensdk:wechat-sdk-android:+', //核心必须依赖 diff --git a/health/src/main/AndroidManifest.xml b/health/src/main/AndroidManifest.xml index b0aecf0..668f47c 100644 --- a/health/src/main/AndroidManifest.xml +++ b/health/src/main/AndroidManifest.xml @@ -312,6 +312,10 @@ + + @@ -331,6 +335,10 @@ android:launchMode="singleTop" android:screenOrientation="portrait" /> + + \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/act/OrderListAct.kt b/health/src/main/java/com/zj365/health/act/OrderListAct.kt index 21cea33..88446b8 100644 --- a/health/src/main/java/com/zj365/health/act/OrderListAct.kt +++ b/health/src/main/java/com/zj365/health/act/OrderListAct.kt @@ -25,9 +25,15 @@ class OrderListAct : BaseListAct() { var userId: String? = null val mAdapter by lazy { OrderListAdapter() } + var type:Int = 0 //默认全部 1 是从糖医进来 + override fun initData() { super.initData() - userId = intent.getStringExtra("id") + type = intent.getIntExtra("type",0) + if(intent.hasExtra("id")){ + userId = intent.getStringExtra("id") + + } } override fun initView() { @@ -55,7 +61,13 @@ class OrderListAct : BaseListAct() { } override fun loadData() { - mViewModel.getOrderList(userId, page) + if (type == 1){ + mViewModel.getSugarMedicineOrderList( page) + + }else { + mViewModel.getOrderList(userId, page) + + } } @SuppressLint("SetTextI18n") @@ -70,5 +82,16 @@ class OrderListAct : BaseListAct() { } } } + + mViewModel.sugarMedicalListLiveData.observe(this){ + it.data?.let { listData -> + setDate(mAdapter, listData) + /*if (listData.size <= 0){ + binding.title.mTvTitle.text = "我的订单" + }else{ + binding.title.mTvTitle.text = "我的订单(${listData.size})" + }*/ + } + } } } \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/act/ShopOrderListAct.kt b/health/src/main/java/com/zj365/health/act/ShopOrderListAct.kt index 0c72df6..c6726af 100644 --- a/health/src/main/java/com/zj365/health/act/ShopOrderListAct.kt +++ b/health/src/main/java/com/zj365/health/act/ShopOrderListAct.kt @@ -6,13 +6,18 @@ import androidx.recyclerview.widget.RecyclerView import com.alibaba.android.arouter.facade.annotation.Route import com.androidkun.xtablayout.XTabLayout import com.xty.base.act.BaseListAct +import com.xty.base.utils.PayUtils import com.xty.common.arouter.ARouterUrl import com.xty.common.arouter.RouteManager +import com.xty.common.event.ReChangeEvent import com.xty.network.model.ShopOrderListBean import com.zj365.health.R import com.zj365.health.adapter.GoodsOrderAdapter import com.zj365.health.databinding.ActShopOrderListBinding import com.zj365.health.vm.ShopOrderVm +import com.zj365.health.weight.DialogTipNew +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode @Route(path = ARouterUrl.SHOP_ORDER_LIST_ACT) class ShopOrderListAct : BaseListAct() { @@ -25,6 +30,34 @@ class ShopOrderListAct : BaseListAct() { private val mTitles = mutableListOf() + var bean : ShopOrderListBean.ShopOrderBean? = null + + + val dialogCancel by lazy { + DialogTipNew(this, "取消订单","", "确认","取消",false,{ + bean?.let { + mViewModel.cancelOrder(it.id) + + } + }){ + + } + + } + + val dialogReturn by lazy { + DialogTipNew(this, "退款申请","", "确认","取消",false,{ + bean?.let { + mViewModel.applyReturn(it.id) + + } + }){ + + } + + } + + override fun initAdapter() { binding.mRecycle.adapter = mAdapter binding.mRecycle.layoutManager = LinearLayoutManager(this) @@ -50,20 +83,36 @@ class ShopOrderListAct : BaseListAct() { mAdapter.setOnItemChildClickListener { adapter, view, position -> - var bean = adapter.data[position] as ShopOrderListBean.ShopOrderBean - when(view.id){ - R.id.tv_confirm_receive_goods ->{ - mViewModel.receiveGoods(bean.id) - } - R.id.tv_logistics->{ - if (bean.status == 1){ - mViewModel.cancelOrder(bean.id) + bean = adapter.data[position] as ShopOrderListBean.ShopOrderBean + bean?.let { + when(view.id){ + R.id.tv_confirm_receive_goods ->{ + mViewModel.receiveGoods(it.id) } - } - R.id.tv_refund ->{ + R.id.tv_logistics->{ + if (it.status == 1){ + dialogCancel.setContentNew("您是否确认取消订单,取消订单后如涉及退款" + + ",请注意查收") + dialogCancel.show() + }else{ + + } + } + R.id.tv_refund ->{ + if (it.status == 3 || it.status == 2){ + dialogReturn.setContentNew("您是否确认对此订单进行退款申请,申请完成" + + "后会在1~3个工作日对订单进行审核,请及时" + + "关注订单状态") + dialogReturn.show() + }else if (it.status == 1){ + PayUtils(this).payForGoods(it.pay_price.toFloat(),it.order_no) + + } + } } } + } } @@ -149,4 +198,10 @@ class ShopOrderListAct : BaseListAct() { } override fun setLayout() = binding.root + + @Subscribe(threadMode = ThreadMode.MAIN) + fun paySuccess(event: ReChangeEvent){ + page = 1 + loadData() + } } \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/act/healthrecord/HealthRecordMainAct.kt b/health/src/main/java/com/zj365/health/act/healthrecord/HealthRecordMainAct.kt index b472f5b..72d8b6e 100644 --- a/health/src/main/java/com/zj365/health/act/healthrecord/HealthRecordMainAct.kt +++ b/health/src/main/java/com/zj365/health/act/healthrecord/HealthRecordMainAct.kt @@ -1,5 +1,6 @@ package com.zj365.health.act.healthrecord +import android.graphics.Color import android.util.Log import android.view.View import androidx.core.view.get @@ -60,6 +61,10 @@ class HealthRecordMainAct : BaseVmAct() { mViewModel.healthArchiveLiveData.observe(this){ binding.tvBmi.text = "${it.data.bmiInfo.bmi}" binding.tvBmiDesc.text = it.data.bmiInfo.levelName + if (it.data.bmiInfo.levelName.equals("理想")){ + binding.tvBmiDesc.setTextColor(Color.parseColor("#02C191")) + } + binding.tvBmr.text = "${it.data.bmr}" mAdapter.setNewInstance(it.data.healData) } diff --git a/health/src/main/java/com/zj365/health/act/psychological/PsychologicalQuestionnaireAct.kt b/health/src/main/java/com/zj365/health/act/psychological/PsychologicalQuestionnaireAct.kt index 0552f55..db1439c 100644 --- a/health/src/main/java/com/zj365/health/act/psychological/PsychologicalQuestionnaireAct.kt +++ b/health/src/main/java/com/zj365/health/act/psychological/PsychologicalQuestionnaireAct.kt @@ -1,10 +1,28 @@ package com.zj365.health.act.psychological +import android.annotation.SuppressLint +import android.graphics.Bitmap +import android.graphics.BitmapFactory +import android.os.Build import android.view.View +import android.webkit.WebChromeClient +import android.webkit.WebSettings +import android.webkit.WebView +import android.webkit.WebViewClient +import com.alibaba.android.arouter.facade.annotation.Route +import com.tamsiree.rxkit.RxNetTool +import com.tamsiree.rxkit.RxTool import com.xty.base.act.BaseVmAct import com.xty.base.vm.BaseVm +import com.xty.common.LogUtils +import com.xty.common.arouter.ARouterUrl +import com.xty.common.arouter.RouteManager +import com.xty.common.util.CommonUtils +import com.zj365.health.BuildConfig import com.zj365.health.databinding.ActPsychologicalQuestionnaireBinding +import com.zj365.health.weight.QuestionDialog +@Route(path = ARouterUrl.PSYCHOLOGICAL_QUESTION_ACT) class PsychologicalQuestionnaireAct : BaseVmAct() { val binding by lazy { ActPsychologicalQuestionnaireBinding.inflate(layoutInflater) } @@ -14,4 +32,134 @@ class PsychologicalQuestionnaireAct : BaseVmAct() { } override fun setLayout() = binding.root + + var surveyId: Long = 0 + override fun initData() { + super.initData() + surveyId = intent.getLongExtra("surveyId",0) + } + + override fun initView() { + super.initView() + statusBar(binding.title.mView) + binding.title.mTvTitle.text = "心理测试 " + binding.title.mIvBack.setOnClickListener { finish() } + initWebSettings() + var userId = CommonUtils.getMyUserId() + binding.wvContent.loadUrl(BuildConfig.url+"shareApi/H5_question/${userId}/${surveyId}/android") + + } + + @SuppressLint("SetJavaScriptEnabled") + private fun initWebSettings() { + binding.wvContent.isHorizontalScrollBarEnabled = false //水平不显示 + binding.wvContent.isVerticalScrollBarEnabled = false //垂直不显示 + var webViewClient = MyClient() + + binding.wvContent.apply { + isHorizontalScrollBarEnabled = false //水平不显示 + isVerticalScrollBarEnabled = false //垂直不显示 + + val webSetting: WebSettings = settings + webSetting.apply { + setRenderPriority(WebSettings.RenderPriority.HIGH) + cacheMode = if (RxNetTool.isConnected(RxTool.getContext())) { + WebSettings.LOAD_DEFAULT // 设置缓存模式 + } else { + WebSettings.LOAD_CACHE_ELSE_NETWORK // 设置缓存模式 + } + loadWithOverviewMode = true + domStorageEnabled = true//不添加可能加载H5的页面时候出现一片空白 + databaseEnabled = true + setAppCacheEnabled(true) + allowFileAccess = true + javaScriptEnabled = true + textZoom = 110 + useWideViewPort = false//设置此属性,可任意比例缩放 + setLayerType(View.LAYER_TYPE_HARDWARE, null) // 启用硬件加速 + layoutAlgorithm = WebSettings.LayoutAlgorithm.NORMAL + builtInZoomControls = false //设置内置的缩放控件。若为false,则该WebView不可缩放 + displayZoomControls = false //隐藏原生的缩放控件 + defaultTextEncodingName = "utf-8" //设置编码格式 + blockNetworkImage = false //解决图片不显示 + loadsImagesAutomatically = true //支持自动加载图片 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + setAllowFileAccessFromFileURLs(true) + setAllowUniversalAccessFromFileURLs(true) + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//解决视频加载不出来的问题 + mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW; + } + } + settings.domStorageEnabled = true + this.webViewClient = webViewClient + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + + settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); + + } + webChromeClient = object : WebChromeClient() { + override fun getDefaultVideoPoster(): Bitmap? { + + try { + //这个地方是加载h5的视频列表 默认图 点击前的视频图 + LogUtils.d("WebView---------加载视频默认图片"); + return BitmapFactory.decodeResource( + context.getResources(), + com.xty.common.R.mipmap.ic_chat_picture + ); + + } catch (e: Exception) { + LogUtils.e("WebView---------默认图片加载失败"); + + } + + return null + } + + } + } + } + + override fun onPause() { + super.onPause() + //暂停WebView在后台的所有活动 + binding.wvContent.onPause() + //暂停WebView在后台的JS活动 + binding.wvContent.pauseTimers() + } + + override fun onResume() { + super.onResume() + binding.wvContent.onResume(); + binding.wvContent.resumeTimers(); + } + + override fun onDestroy() { + super.onDestroy() + binding.root.removeView(binding.wvContent) + binding.wvContent.destroy() + } + val tipDialog by lazy { + QuestionDialog(this, false, "温馨提示", { + /* bundle.clear() + bundle.putString("orderNo", orderNo) + RouteManager.goAct(ARouterUrl.UPLOAD_CHECK, bundle)*/ + }) + } + inner class MyClient : WebViewClient() { + override fun shouldOverrideUrlLoading(p0: WebView?, p1: String): Boolean { + if (p1.contains("code:0")) { + showDialog() + } else { + p0?.loadUrl(p1) + } + return true + } + } + + private fun showDialog() { + tipDialog.show() + } + } \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/act/psychological/PsychologicalTestMainAct.kt b/health/src/main/java/com/zj365/health/act/psychological/PsychologicalTestMainAct.kt index 8f452c5..c0674eb 100644 --- a/health/src/main/java/com/zj365/health/act/psychological/PsychologicalTestMainAct.kt +++ b/health/src/main/java/com/zj365/health/act/psychological/PsychologicalTestMainAct.kt @@ -6,6 +6,10 @@ import com.xty.base.act.BaseListAct import com.xty.base.act.BaseVmAct import com.xty.base.vm.BaseVm import com.xty.common.arouter.ARouterUrl +import com.xty.common.arouter.RouteManager +import com.xty.common.util.CommonUtils +import com.xty.network.model.PsychologicalListBean +import com.zj365.health.BuildConfig import com.zj365.health.adapter.psychological.PsychologicalTestMainAdapter import com.zj365.health.databinding.ActPsychologicalTestMainBinding import com.zj365.health.vm.PsychologicalTestMainVm @@ -32,7 +36,13 @@ class PsychologicalTestMainAct : BaseListAct() { binding.mRecycle.layoutManager = LinearLayoutManager(this) binding.mRecycle.adapter = mAdapter - mAdapter.setOnItemChildClickListener { adapter, view, position -> + mAdapter.setOnItemClickListener { adapter, view, position -> + var bean = adapter.data[position] as PsychologicalListBean.PsychologicalBean + bundle.clear() + bundle.putString("web_site_url","${BuildConfig.url}shareApi/H5_question/${CommonUtils.getMyUserId()}/${bean.id}/android") + bundle.putBoolean("isShowTitle",true) + RouteManager.goAct(ARouterUrl.H5_ACT,bundle) + } diff --git a/health/src/main/java/com/zj365/health/act/skin/SkinMeasurementMainAct.kt b/health/src/main/java/com/zj365/health/act/skin/SkinMeasurementMainAct.kt index c4f3422..d458eb0 100644 --- a/health/src/main/java/com/zj365/health/act/skin/SkinMeasurementMainAct.kt +++ b/health/src/main/java/com/zj365/health/act/skin/SkinMeasurementMainAct.kt @@ -105,10 +105,20 @@ class SkinMeasurementMainAct : BaseVmAct() { binding.title.mTvRight.visibility = View.VISIBLE }else{ binding.title.mTvTitle.text ="AI糖医" + binding.title.mTvRight.text ="购买记录" + binding.title.mTvRight.setTextColor(resources.getColor(R.color.col_02c)) + binding.title.mTvRight.visibility = View.VISIBLE mViewModel.getAIGoods() } binding.title.mTvRight.setOnClickListener { + if(type == 0){ + + }else{ + bundle.clear() + bundle.putInt("type",1) + RouteManager.goAct(ARouterUrl.ORDER_LIST,bundle) + } } diff --git a/health/src/main/java/com/zj365/health/adapter/GoodsOrderAdapter.kt b/health/src/main/java/com/zj365/health/adapter/GoodsOrderAdapter.kt index 3927203..35a7ff4 100644 --- a/health/src/main/java/com/zj365/health/adapter/GoodsOrderAdapter.kt +++ b/health/src/main/java/com/zj365/health/adapter/GoodsOrderAdapter.kt @@ -43,12 +43,19 @@ class GoodsOrderAdapter : BaseAdapter(R.layout. holder.setGone(R.id.tv_confirm_receive_goods,true) holder.setText(R.id.tv_logistics,"取消订单") holder.setText(R.id.tv_refund,"立即支付") + + holder.setGone(R.id.tv_logistics,false) + + holder.setGone(R.id.tv_refund,false) } 3->{ status.setTextColor(context.getColor(R.color.col_9BD)) holder.setGone(R.id.tv_confirm_receive_goods,false) holder.setText(R.id.tv_logistics,"查看物流") holder.setText(R.id.tv_refund,"申请退款") + holder.setGone(R.id.tv_logistics,false) + + holder.setGone(R.id.tv_refund,false) } 4->{ diff --git a/health/src/main/java/com/zj365/health/vm/PayCancerVm.kt b/health/src/main/java/com/zj365/health/vm/PayCancerVm.kt index af37daa..74f1702 100644 --- a/health/src/main/java/com/zj365/health/vm/PayCancerVm.kt +++ b/health/src/main/java/com/zj365/health/vm/PayCancerVm.kt @@ -23,6 +23,8 @@ class PayCancerVm : BaseVm() { val isCanReservationOb by lazy { MutableLiveData>() } val orderListData by lazy { MutableLiveData>>() } + val sugarMedicalListLiveData by lazy { MutableLiveData>>() } + fun payUrl(goodsId: String?, channelName: String, exchangeCode: String) { if (goodsId.isNullOrEmpty()) { return @@ -129,6 +131,18 @@ class PayCancerVm : BaseVm() { } } + fun getSugarMedicineOrderList(pageNum:Int){ + startHttp { + var json = JSONObject() + json.put("pageNum",pageNum) + json.put("pageSize",20) + var response = + apiInterface().getSugarMedicineOrderList(retrofits.getRequestBody(json.toString())) + response.getCodeStatus(sugarMedicalListLiveData, nowData) + } + + } + fun getEstimateRecord() { startHttp { var json = JSONObject() @@ -198,4 +212,6 @@ class PayCancerVm : BaseVm() { response.getCodeStatus(isCanReservationOb, nowData) } } + + } \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/vm/ShopOrderVm.kt b/health/src/main/java/com/zj365/health/vm/ShopOrderVm.kt index b464b37..852e87a 100644 --- a/health/src/main/java/com/zj365/health/vm/ShopOrderVm.kt +++ b/health/src/main/java/com/zj365/health/vm/ShopOrderVm.kt @@ -54,4 +54,12 @@ class ShopOrderVm : BaseVm() { } } + + fun applyReturn(id:Long){ + startHttp { + val response = apiInterface().applyReturn(id) + response.getCodeStatus(cancelOrderLiveData, nowData) + + } + } } \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/weight/DialogTipNew.kt b/health/src/main/java/com/zj365/health/weight/DialogTipNew.kt index a46ea77..b95378a 100644 --- a/health/src/main/java/com/zj365/health/weight/DialogTipNew.kt +++ b/health/src/main/java/com/zj365/health/weight/DialogTipNew.kt @@ -53,4 +53,8 @@ class DialogTipNew( fun setContentNew(content:String){ binding.mTitle.text= content } + + fun setTitleNew(title:String){ + binding.tvTitle.text = title + } } \ No newline at end of file diff --git a/health/src/main/res/layout/act_psychological_questionnaire.xml b/health/src/main/res/layout/act_psychological_questionnaire.xml index dc145bb..402229d 100644 --- a/health/src/main/res/layout/act_psychological_questionnaire.xml +++ b/health/src/main/res/layout/act_psychological_questionnaire.xml @@ -12,9 +12,12 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/title" - android:layout_margin="@dimen/dp_14" + android:layout_marginStart="@dimen/dp_14" + android:layout_marginTop="@dimen/dp_14" + android:layout_marginEnd="@dimen/dp_14" + android:layout_marginBottom="@dimen/dp_14" android:background="@drawable/shape_white_8radius" - android:padding="@dimen/dp_10"/> + android:padding="@dimen/dp_10" /> () { + val binding by lazy { ActivityElectronicFenceSettingBinding.inflate(layoutInflater) } + + val mAdapter by lazy { ElectronicFenceAdapter() } + + var type: Int = 0 //0 列表页 1 设置页 2 修改已设计的电子围栏 + + private var aMap: AMap? = null + + var poiItem: PoiItem? = null + + var settingType :Int =2 // 1-禁入 2-禁出 + + var radius:Int = 500 + + var title:String = "" + + var latitude:Double = 0.00 + var longitude:Double = 0.00 + + var markerOptionsList = ArrayList() + + var bean: EtFenceListBean.EtFenceChildBean? = null + + + override fun liveObserver() { + mViewModel.addOrDeleteLiveData.observe(this){ + EventBus.getDefault().post(BtFenceSettingSuccessEvent()) + finish() + } + } + + override fun initView() { + super.initView() + statusBar(binding.title.mView) + binding.title.mTvTitle.text = "电子围栏设置" + binding.title.mIvBack.setOnClickListener { + finish() + } + aMap = binding.map.map + + initLocation() + + if (intent.hasExtra("type")){ + type = intent.getIntExtra("type",0) + + } + + if(intent.hasExtra("poiItem")){ + poiItem = intent.getParcelableExtra("poiItem") + } + + if(intent.hasExtra("bean")){ + bean = intent.getParcelableExtra("bean") + } + + if(type == 0){ + binding.llData.visibility = View.VISIBLE + binding.llSetting.visibility = View.GONE + + mViewModel.getElectronicFenceList() + binding.tvCancel.visibility = View.GONE + }else if(type == 1){ + binding.llData.visibility = View.GONE + binding.llSetting.visibility = View.VISIBLE + binding.tvCancel.visibility = View.VISIBLE + initSettingData() + }else { + binding.llData.visibility = View.GONE + binding.llSetting.visibility = View.VISIBLE + binding.tvCancel.visibility = View.VISIBLE + binding.tvCancel.text = "删除" + initModifyData() + } + + binding.recycler.adapter = mAdapter + binding.recycler.layoutManager = LinearLayoutManager(this) + + binding.tvConfirm.setOnClickListener { + if (type == 0){ + RouteManager.goAct(ARouterUrl.ELECTRONIC_ADDRESS_CHOOSE_ACT) + + }else if(type == 1){ + poiItem?.let { + mViewModel.setBtFence(title,radius,settingType,longitude,latitude,null) + } + }else if(type == 2){ + bean?.let { + mViewModel.setBtFence(title,radius,settingType,longitude,latitude,it.id) + } + } + } + + binding.tvCancel.setOnClickListener { + if(type == 2){ + bean?.let { + mViewModel.deleteBtFence(it.id) + } + }else{ + finish() + } + + } + + + + binding.clSetting.skbRadius.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{ + override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) { + radius = p1 + } + + override fun onStartTrackingTouch(p0: SeekBar?) { + } + + override fun onStopTrackingTouch(p0: SeekBar?) { + } + + }) + + binding.clSetting.rbType.setOnCheckedChangeListener { radioGroup, checkedId -> + + when(radioGroup.checkedRadioButtonId){ + R.id.rb_leave ->{ + settingType = 2 + aMap?.let { + it.clear() + var markerOptions = MarkerOptions().position(LatLng(latitude,longitude)).icon( + BitmapDescriptorFactory.fromView(View.inflate(this, + R.layout.layout_bt_fence_leave,null))) + var marker = it.addMarker(markerOptions) + + it.addCircle(CircleOptions().center(LatLng(latitude,longitude)) + .radius(radius.toDouble()).fillColor(Color.parseColor("#61FFAC53")) + .strokeColor(Color.parseColor("#FFFFFF")) + .strokeWidth(1.0f) + ) + } + + } + + R.id.rb_enter ->{ + settingType = 1 + + aMap?.let { + it.clear() + var markerOptions = MarkerOptions().position(LatLng(latitude,longitude)).icon( + BitmapDescriptorFactory.fromView(View.inflate(this, + R.layout.layout_bt_fence_enter,null))) + var marker = it.addMarker(markerOptions) + + it.addCircle(CircleOptions().center(LatLng(latitude,longitude)) + .radius(radius.toDouble()).fillColor(Color.parseColor("#66F04D42")) + .strokeColor(Color.parseColor("#FFFFFF")) + .strokeWidth(1.0f) + ) + } + + } + } + + } + } + + fun initLocation(){ + var locationStyle = MyLocationStyle() + locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATE) + aMap?.let { + it.clear() + it.myLocationStyle = locationStyle + it.uiSettings.isMyLocationButtonEnabled = false + it.isMyLocationEnabled = false + it.moveCamera(CameraUpdateFactory.zoomTo(20f)) + + var uiSettings = it.uiSettings + uiSettings.isZoomControlsEnabled = false + uiSettings.isMyLocationButtonEnabled = false + uiSettings.isScaleControlsEnabled = false + uiSettings.logoPosition = AMapOptions.LOGO_MARGIN_LEFT + } + } + + fun initModifyData(){ + bean?.let { + title = "${it.title}" + binding.clSetting.tvAddress.text = "${it.title}" + latitude = it.lat + longitude = it.log + radius = it.radius + settingType = it.type + binding.clSetting.skbRadius.progress = radius + if (settingType == 1){ + binding.clSetting.rbType.check(R.id.rb_enter) + }else{ + binding.clSetting.rbType.check(R.id.rb_leave) + + } + + } + + aMap?.let { + + + if(settingType == 1){ + var markerOptions = MarkerOptions().position(LatLng(latitude,longitude)).icon( + BitmapDescriptorFactory.fromView(View.inflate(this, + R.layout.layout_bt_fence_enter,null))) + + var marker = it.addMarker(markerOptions) + it.addCircle(CircleOptions().center(LatLng(latitude,longitude)) + .radius(radius.toDouble()).fillColor(Color.parseColor("#66F04D42")) + .strokeColor(Color.parseColor("#FFFFFF")) + .strokeWidth(1.0f) + ) + }else{ + var markerOptions = MarkerOptions().position(LatLng(latitude,longitude)).icon( + BitmapDescriptorFactory.fromView(View.inflate(this, + R.layout.layout_bt_fence_leave,null))) + + var marker = it.addMarker(markerOptions) + it.addCircle(CircleOptions().center(LatLng(latitude,longitude)) + .radius(radius.toDouble()).fillColor(Color.parseColor("#61FFAC53")) + .strokeColor(Color.parseColor("#FFFFFF")) + .strokeWidth(1.0f)) + + } + + it.moveCamera(CameraUpdateFactory.newCameraPosition(CameraPosition(LatLng(latitude,longitude),14f,0f,0f))) + } + + } + + fun initSettingData(){ + + poiItem?.let { + title = "${it.provinceName}${it.cityName}${it.adName}${it.title}" + binding.clSetting.tvAddress.text = "${it.provinceName}${it.cityName}${it.adName}${it.title}" + latitude = it.latLonPoint.latitude + longitude = it.latLonPoint.longitude + + } + + binding.clSetting.skbRadius.progress = radius + + binding.clSetting.rbType.check(R.id.rb_leave) + + aMap?.let { + var markerOptions = MarkerOptions().position(LatLng(latitude,longitude)).icon( + BitmapDescriptorFactory.fromView(View.inflate(this, + R.layout.layout_bt_fence_leave,null))) + var marker = it.addMarker(markerOptions) + it.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition(LatLng(latitude,longitude),15f,0f,0f))) + + it.addCircle(CircleOptions().center(LatLng(latitude,longitude)) + .radius(radius.toDouble()).fillColor(Color.parseColor("#61FFAC53")) + .strokeColor(Color.parseColor("#FFFFFF")) + .strokeWidth(1.0f) + ) + + } + } + + override fun setLayout() = binding.root + + override fun onDestroy() { + super.onDestroy() + binding.map.onDestroy() + } + + override fun onPause() { + super.onPause() + binding.map.onPause() + } + + + override fun onResume() { + super.onResume() + binding.map.onResume() + } + + @SuppressLint("MissingSuperCall") + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + binding.map.onSaveInstanceState(outState) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding.map.onCreate(savedInstanceState) + } +} \ No newline at end of file diff --git a/mine/src/main/java/com/zj365/mime/act/electronicfence/ElectronicAddressChooseAct.kt b/mine/src/main/java/com/zj365/mime/act/electronicfence/ElectronicAddressChooseAct.kt new file mode 100644 index 0000000..a8b53ee --- /dev/null +++ b/mine/src/main/java/com/zj365/mime/act/electronicfence/ElectronicAddressChooseAct.kt @@ -0,0 +1,341 @@ +package com.zj365.mime.act.electronicfence + +import android.animation.AnimatorSet +import android.animation.ObjectAnimator +import android.annotation.SuppressLint +import android.graphics.BitmapFactory +import android.graphics.Color +import android.os.Bundle +import android.text.TextUtils +import android.text.method.KeyListener +import android.view.KeyEvent +import android.view.View +import android.view.inputmethod.EditorInfo +import android.widget.TextView +import androidx.recyclerview.widget.LinearLayoutManager +import com.alibaba.android.arouter.facade.annotation.Route +import com.amap.api.location.AMapLocation +import com.amap.api.location.AMapLocationClient +import com.amap.api.location.AMapLocationClientOption +import com.amap.api.location.AMapLocationListener +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.amap.api.maps.CameraUpdateFactory +import com.amap.api.maps.model.BitmapDescriptorFactory +import com.amap.api.maps.model.CameraPosition +import com.amap.api.maps.model.LatLng +import com.amap.api.maps.model.MarkerOptions +import com.amap.api.maps.model.MyLocationStyle +import com.amap.api.services.core.LatLonPoint +import com.amap.api.services.core.PoiItem +import com.amap.api.services.core.PoiItemV2 +import com.amap.api.services.geocoder.GeocodeResult +import com.amap.api.services.geocoder.GeocodeSearch +import com.amap.api.services.geocoder.RegeocodeQuery +import com.amap.api.services.geocoder.RegeocodeResult +import com.amap.api.services.poisearch.PoiResult +import com.amap.api.services.poisearch.PoiResultV2 +import com.amap.api.services.poisearch.PoiSearch +import com.amap.api.services.poisearch.PoiSearchV2 +import com.tamsiree.rxkit.RxKeyboardTool +import com.xty.base.act.BaseVmAct +import com.xty.base.vm.BaseVm +import com.xty.common.LogUtils +import com.xty.common.arouter.ARouterUrl +import com.xty.common.arouter.RouteManager +import com.xty.common.event.BtFenceSettingSuccessEvent +import com.xty.common.util.CommonToastUtils +import com.zj365.mime.R +import com.zj365.mime.adapter.ElectronicAddressAdapter +import com.zj365.mime.databinding.ActElectronicAddressChooseBinding +import com.zj365.mime.model.CustomerPOItem +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode + +@Route(path = ARouterUrl.ELECTRONIC_ADDRESS_CHOOSE_ACT) +class ElectronicAddressChooseAct : BaseVmAct(),AMapLocationListener ,GeocodeSearch.OnGeocodeSearchListener + ,PoiSearch.OnPoiSearchListener{ + val binding by lazy { ActElectronicAddressChooseBinding.inflate(layoutInflater) } + + private var aMap: AMap? = null + + var mLocationClient:AMapLocationClient? = null + var mLocationOption:AMapLocationClientOption? = null + + var geocodeSearch: GeocodeSearch? = null + + val mAdapter by lazy { ElectronicAddressAdapter() } + + var searchAddress:String = "" + + var latitude:Double=0.00 + var longitude:Double = 0.00 + + var cityName :String = "" + var poiList = ArrayList() + + var choosePoiItem: PoiItem? = null + + var isHandDrag:Boolean = false + + var page:Int = 1 + + + override fun liveObserver() { + + } + + override fun initView() { + super.initView() + + binding.tvCancel.setOnClickListener { + finish() + } + + binding.tvConfirm.setOnClickListener { + choosePoiItem?.let { + bundle.clear() + bundle.putParcelable("poiItem",it) + bundle.putInt("type",1) + RouteManager.goAct(ARouterUrl.ELECTRONIC_ADD_MODIFY_ACT,bundle) + } + } + + aMap = binding.mapView.map + initLocation() + + binding.recycler.adapter = mAdapter + binding.recycler.layoutManager = LinearLayoutManager(this) + + binding.etSearch.setOnEditorActionListener(object : TextView.OnEditorActionListener { + override fun onEditorAction(p0: TextView?, p1: Int, p2: KeyEvent?): Boolean { + if(p1 == EditorInfo.IME_ACTION_SEARCH){ + searchAddress = binding.etSearch.text.toString() + page = 1 + searchPOI() + RxKeyboardTool.hideSoftInput(this@ElectronicAddressChooseAct) + return true + + } + return false + } + + }) + + mAdapter.setOnItemClickListener { adapter, view, position -> + var bean = adapter.data[position] as CustomerPOItem + (adapter.data as ArrayList).forEachIndexed { index, customerPOItem -> + customerPOItem.isChecked = false + } + + bean.isChecked = true + choosePoiItem = bean.poiItem + mAdapter.notifyDataSetChanged() + } + + binding.mRefresh.setOnRefreshListener { + page = 1 + searchPOI() + binding.mRefresh.finishRefresh(1000) + } + binding.mRefresh.setEnableLoadMore(true) + binding.mRefresh.setOnLoadMoreListener { + page++ + searchPOI() + binding.mRefresh.finishLoadMore(1000) + } + } + + fun searchPOI(){ + LogUtils.e("ElectronicAddressChooseAct","keyword${searchAddress}") + var query = PoiSearch.Query(searchAddress,"",cityName) + query.pageNum = page + query.pageSize = 20 + + var poisearch = PoiSearch(this,query) + poisearch.bound = PoiSearch.SearchBound(LatLonPoint(latitude,longitude),50000) + poisearch.setOnPoiSearchListener(this) + poisearch.searchPOIAsyn() + } + + + fun initLocation(){ + var locationStyle = MyLocationStyle() + locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATE) + aMap?.let { + it.myLocationStyle = locationStyle + it.uiSettings.isMyLocationButtonEnabled = false + it.isMyLocationEnabled = false + + it.moveCamera(CameraUpdateFactory.zoomTo(30f)) + + var uiSettings = it.uiSettings + uiSettings.isZoomControlsEnabled = false + uiSettings.isMyLocationButtonEnabled = false + uiSettings.isScaleControlsEnabled = false + uiSettings.logoPosition= AMapOptions.LOGO_MARGIN_LEFT + + goLocation() + + it.setOnCameraChangeListener(object :AMap.OnCameraChangeListener{ + override fun onCameraChange(p0: CameraPosition?) { + + } + + override fun onCameraChangeFinish(cameraPosition: CameraPosition) { + LogUtils.e("ElectronicAddressChooseAct","onCameraChangeFinish") + if(isHandDrag && TextUtils.isEmpty(searchAddress)){ + getGeocodeSearch(cameraPosition.target) + + } + isHandDrag = true + } + }) + } + } + + fun goLocation(){ + mLocationClient = AMapLocationClient(this) + mLocationOption = AMapLocationClientOption() + mLocationClient?.setLocationListener(this) + mLocationOption?.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy) + mLocationOption?.setInterval(1000) + mLocationOption?.setOnceLocation(false) + mLocationOption?.setGpsFirst(true) + mLocationOption?.setNeedAddress(true) + mLocationOption?.setOnceLocationLatest(false) + mLocationOption?.setSensorEnable(true) + + mLocationClient?.setLocationOption(mLocationOption) + mLocationClient?.startLocation() + + } + + + fun getGeocodeSearch(targe: LatLng){ + LogUtils.e("ElectronicAddressChooseAct","getGeocodeSearch ${targe.latitude},${targe.longitude},") + + if(geocodeSearch == null) { + geocodeSearch = GeocodeSearch(this) + } + searchAddress = "" + latitude = targe.latitude + longitude = targe.longitude + var query = RegeocodeQuery(LatLonPoint(targe.latitude,targe.longitude),5000f,GeocodeSearch.AMAP) + geocodeSearch?.setOnGeocodeSearchListener(this) + geocodeSearch?.getFromLocationAsyn(query) + + } + + fun setMapCenter(amapLocation:AMapLocation){ + aMap?.let { + var locationMark = it.addMarker(MarkerOptions().position(LatLng(amapLocation.latitude,amapLocation.longitude)).icon( + BitmapDescriptorFactory.fromResource(R.mipmap.icon_address_location) + )) + locationMark.setPositionByPixels(binding.mapView.width / 2,binding.mapView.height /2) + it.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition(LatLng(amapLocation.latitude,amapLocation.longitude),30f,0f,0f))) + } + } + + override fun setLayout() = binding.root + + override fun onDestroy() { + super.onDestroy() + binding.mapView.onDestroy() + } + + override fun onPause() { + super.onPause() + binding.mapView.onPause() + } + + + override fun onResume() { + super.onResume() + binding.mapView.onResume() + } + + @SuppressLint("MissingSuperCall") + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + binding.mapView.onSaveInstanceState(outState) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding.mapView.onCreate(savedInstanceState) + } + + override fun onLocationChanged(amapLocation: AMapLocation?) { + LogUtils.e("ElectronicAddressChooseAct","onLocationChanged:${amapLocation?.errorCode!!}") + amapLocation?.let { + if (it.errorCode == AMapLocation.LOCATION_SUCCESS){ + mLocationClient?.stopLocation() + mLocationClient?.onDestroy() + + setMapCenter(it) + latitude = it.latitude + longitude = it.longitude + var latLng = LatLng(latitude,longitude) + cityName =it.city + + + }else{ + + } + } + + } + + override fun onRegeocodeSearched(regeocodeResult: RegeocodeResult?, code: Int) { + LogUtils.e("ElectronicAddressChooseAct","onRegeocodeSearched:${code}") + + if(code == 1000){ + if(regeocodeResult != null && regeocodeResult?.regeocodeAddress != null && regeocodeResult?.regeocodeAddress?.formatAddress != null){ + var split = regeocodeResult!!.regeocodeAddress!!.province +regeocodeResult!!.regeocodeAddress!!.city + regeocodeResult!!.regeocodeAddress!!.district + regeocodeResult!!.regeocodeAddress!!.township + LogUtils.e("ElectronicAddressChooseAct","split:${split}") + searchPOI() + } + } + + } + + override fun onGeocodeSearched(geocodeResult: GeocodeResult?, code: Int) { + LogUtils.e("ElectronicAddressChooseAct","onGeocodeSearched:${code}") + + + } + override fun onPoiSearched(result: PoiResult?, code: Int) { + if(code == 1000){ + if(result != null && result?.query != null){ + LogUtils.e("ElectronicAddressChooseAct","query${result!!.pois.size}") + if(page == 1){ + mAdapter.data.clear() + poiList.clear() + choosePoiItem = null + if (result!!.pois.size > 0){ + aMap?.moveCamera(CameraUpdateFactory.newCameraPosition(CameraPosition(LatLng(result!!.pois[0].latLonPoint.latitude,result!!.pois[0].latLonPoint.longitude),15f,0f,30f))) + } + result!!.pois.forEach { + poiList.add(CustomerPOItem(it,false)) + } + mAdapter.setList(poiList) + }else{ + result!!.pois.forEach { + poiList.add(CustomerPOItem(it,false)) + } + mAdapter.addData(poiList) + } + + } + } + } + + override fun onPoiItemSearched(p0: PoiItem?, p1: Int) { + } + + @Subscribe(threadMode = ThreadMode.MAIN) + fun settingSuccess(event: BtFenceSettingSuccessEvent){ + this.finish() + } +} \ No newline at end of file diff --git a/mine/src/main/java/com/zj365/mime/act/electronicfence/ElectronicFenceSettingAct.kt b/mine/src/main/java/com/zj365/mime/act/electronicfence/ElectronicFenceSettingAct.kt index b34132a..c922fa7 100644 --- a/mine/src/main/java/com/zj365/mime/act/electronicfence/ElectronicFenceSettingAct.kt +++ b/mine/src/main/java/com/zj365/mime/act/electronicfence/ElectronicFenceSettingAct.kt @@ -1,15 +1,32 @@ package com.zj365.mime.act.electronicfence import android.annotation.SuppressLint +import android.graphics.Color import android.os.Bundle import android.view.View +import android.widget.SeekBar import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import com.alibaba.android.arouter.facade.annotation.Route import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.amap.api.maps.CameraUpdateFactory +import com.amap.api.maps.model.BitmapDescriptorFactory +import com.amap.api.maps.model.CameraPosition +import com.amap.api.maps.model.CircleOptions +import com.amap.api.maps.model.LatLng +import com.amap.api.maps.model.LatLngBounds +import com.amap.api.maps.model.MarkerOptions +import com.amap.api.maps.model.MyLocationStyle +import com.amap.api.services.core.PoiItem +import com.hjq.toast.ToastUtils import com.xty.base.act.BaseVmAct import com.xty.base.vm.BaseVm import com.xty.common.arouter.ARouterUrl +import com.xty.common.arouter.RouteManager +import com.xty.common.util.CommonToastUtils +import com.xty.network.model.EtFenceListBean +import com.zj365.mime.R import com.zj365.mime.adapter.ElectronicFenceAdapter import com.zj365.mime.databinding.ActivityElectronicFenceSettingBinding import com.zj365.mime.vm.ElectronicFenceSettingVm @@ -21,21 +38,72 @@ class ElectronicFenceSettingAct : BaseVmAct() { val mAdapter by lazy { ElectronicFenceAdapter() } - var type: Int = 0 //0 列表页 1 设置页 + var type: Int = 0 //0 列表页 1 设置页 2 修改已设计的电子围栏 private var aMap: AMap? = null + + var poiItem:PoiItem? = null + + var bean: EtFenceListBean.EtFenceChildBean? = null + + var total :Int = 0 + + + override fun liveObserver() { mViewModel.electronicFenceListLiveDate.observe(this){ if(it.data.count == 0){ binding.inEmpty.root.visibility = View.VISIBLE - binding.recycler.visibility = View.GONE + binding.rxData.visibility = View.GONE }else{ - binding.recycler.visibility = View.VISIBLE - binding.inEmpty.root.visibility = View.VISIBLE + binding.rxData.visibility = View.VISIBLE + binding.inEmpty.root.visibility = View.GONE mAdapter.setNewInstance(it.data.list) + total = it.data.count + binding.tvCount.text ="${it.data.count}/5" + var boundsBuilder = LatLngBounds.Builder() + + it.data.list.forEach { + var latLng = LatLng(it.lat,it.log) + var options = MarkerOptions().position(latLng) + var radius = it.radius.toDouble() + + boundsBuilder.include(latLng) + options.visible(true) + if(it.type == 1){ + aMap?.let { + var markerOptions = MarkerOptions().position(latLng) + .icon(BitmapDescriptorFactory.fromView(View.inflate(this,R.layout.layout_bt_fence_enter,null))) + var marker = it.addMarker(markerOptions) + + it.addCircle(CircleOptions().center(latLng) + .radius(radius).fillColor(Color.parseColor("#66F04D42")) + .strokeColor(Color.parseColor("#FFFFFF")) + .strokeWidth(1.0f) + ) + } + }else{ + aMap?.let { + var markerOptions = MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromView(View.inflate(this,R.layout.layout_bt_fence_leave,null))) + var marker = it.addMarker(markerOptions) + + it.addCircle(CircleOptions().center(latLng) + .radius(radius.toDouble()).fillColor(Color.parseColor("#61FFAC53")) + .strokeColor(Color.parseColor("#FFFFFF")) + .strokeWidth(1.0f) + ) + } + } + } + + aMap?.animateCamera(CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(),50)) } } + + mViewModel.addOrDeleteLiveData.observe(this){ + finish() + } } override fun initView() { @@ -46,24 +114,64 @@ class ElectronicFenceSettingAct : BaseVmAct() { finish() } aMap = binding.map.map + + binding.llData.visibility = View.VISIBLE + binding.llSetting.visibility = View.GONE + mViewModel.getElectronicFenceList() + binding.tvCancel.visibility = View.GONE + binding.recycler.adapter = mAdapter binding.recycler.layoutManager = LinearLayoutManager(this) - binding.tvCancel.visibility = View.GONE + mAdapter.setOnItemClickListener { adapter, view, position -> + var bean = adapter.data[position] as EtFenceListBean.EtFenceChildBean + bundle.clear() + bundle.putParcelable("bean",bean) + bundle.putInt("type",2) + RouteManager.goAct(ARouterUrl.ELECTRONIC_ADD_MODIFY_ACT,bundle) + } + + binding.tvConfirm.setOnClickListener { - if (type == 0){ - binding.llData.visibility = View.GONE - type = 1 - }else{ - binding.llData.visibility = View.VISIBLE - type = 0 - } + if(total < 5){ + RouteManager.goAct(ARouterUrl.ELECTRONIC_ADDRESS_CHOOSE_ACT) + + }else{ + CommonToastUtils.showToast("最多可添加5个围栏") + } + } binding.tvCancel.setOnClickListener { + if(type == 2){ + bean?.let { + mViewModel.deleteBtFence(it.id) + } + }else{ + finish() + } + } + initLocation() + } + + fun initLocation(){ + var locationStyle = MyLocationStyle() + locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATE) + locationStyle.interval(2000) + aMap?.let { + it.clear() + it.myLocationStyle = locationStyle + it.uiSettings.isMyLocationButtonEnabled = false + it.isMyLocationEnabled = false + + var uiSettings = it.uiSettings + uiSettings.isZoomControlsEnabled = false + uiSettings.isMyLocationButtonEnabled = false + uiSettings.isScaleControlsEnabled = false + uiSettings.logoPosition = AMapOptions.LOGO_MARGIN_LEFT } } @@ -83,6 +191,9 @@ class ElectronicFenceSettingAct : BaseVmAct() { override fun onResume() { super.onResume() binding.map.onResume() + if(type == 0){ + mViewModel.getElectronicFenceList() + } } @SuppressLint("MissingSuperCall") diff --git a/mine/src/main/java/com/zj365/mime/adapter/ElectronicAddressAdapter.kt b/mine/src/main/java/com/zj365/mime/adapter/ElectronicAddressAdapter.kt new file mode 100644 index 0000000..7cd7345 --- /dev/null +++ b/mine/src/main/java/com/zj365/mime/adapter/ElectronicAddressAdapter.kt @@ -0,0 +1,22 @@ +package com.zj365.mime.adapter + +import com.chad.library.adapter.base.viewholder.BaseViewHolder +import com.xty.base.adapter.BaseAdapter +import com.xty.common.util.NumUtils +import com.zj365.mime.R +import com.zj365.mime.model.CustomerPOItem + +class ElectronicAddressAdapter : BaseAdapter(R.layout.item_electronic_address_search) { + override fun convert(holder: BaseViewHolder, item: CustomerPOItem) { + + holder.setText(R.id.tv_address,"${ item.poiItem.title}") + holder.setText(R.id.tv_distance,"${item.poiItem.distance}m | ${item.poiItem.adName}${item.poiItem.snippet}附近") + if (item.isChecked){ + holder.setGone(R.id.img_checked,false) + }else{ + holder.setGone(R.id.img_checked,true) + + } + + } +} \ No newline at end of file diff --git a/mine/src/main/java/com/zj365/mime/adapter/ElectronicFenceAdapter.kt b/mine/src/main/java/com/zj365/mime/adapter/ElectronicFenceAdapter.kt index b661c4e..44cfbe2 100644 --- a/mine/src/main/java/com/zj365/mime/adapter/ElectronicFenceAdapter.kt +++ b/mine/src/main/java/com/zj365/mime/adapter/ElectronicFenceAdapter.kt @@ -1,5 +1,6 @@ package com.zj365.mime.adapter +import android.graphics.Color import android.widget.TextView import com.chad.library.adapter.base.viewholder.BaseViewHolder import com.xty.base.adapter.BaseAdapter @@ -16,14 +17,15 @@ class ElectronicFenceAdapter : BaseAdapter (R. var drawableLeft = context.getDrawable(R.mipmap.icon_forbid_enter) tvForbid.setCompoundDrawablesWithIntrinsicBounds(drawableLeft,null,null,null) tvForbid.compoundDrawablePadding = 5 - tvForbid.text = "禁入" + tvForbid.setTextColor(Color.parseColor("#F04D42")) }else{ var drawableLeft = context.getDrawable(R.mipmap.icon_forbid_leave) tvForbid.setCompoundDrawablesWithIntrinsicBounds(drawableLeft,null,null,null) tvForbid.compoundDrawablePadding = 5 tvForbid.text = "禁出" + tvForbid.setTextColor(Color.parseColor("#F09C42")) } diff --git a/mine/src/main/java/com/zj365/mime/adapter/MessageAdapter.kt b/mine/src/main/java/com/zj365/mime/adapter/MessageAdapter.kt index 9212d4d..d64aeb8 100644 --- a/mine/src/main/java/com/zj365/mime/adapter/MessageAdapter.kt +++ b/mine/src/main/java/com/zj365/mime/adapter/MessageAdapter.kt @@ -102,7 +102,7 @@ class MessageAdapter():BaseAdapter(R.layout.item_message) { fun choiceAll(){ data.forEachIndexed { pos, any -> - val item = any as MessageBean.SysMsg + val item = any as MessageTypeDataBean.MessageTypeBean if (!item.isChoice){ item.isChoice = true deletePos.add(pos) diff --git a/mine/src/main/java/com/zj365/mime/model/CustomerPOItem.kt b/mine/src/main/java/com/zj365/mime/model/CustomerPOItem.kt new file mode 100644 index 0000000..5325f83 --- /dev/null +++ b/mine/src/main/java/com/zj365/mime/model/CustomerPOItem.kt @@ -0,0 +1,8 @@ +package com.zj365.mime.model + +import android.os.Parcelable +import com.amap.api.services.core.PoiItem + + + data class CustomerPOItem (var poiItem: PoiItem,var isChecked:Boolean = false){ +} \ No newline at end of file diff --git a/mine/src/main/java/com/zj365/mime/vm/ElectronicFenceSettingVm.kt b/mine/src/main/java/com/zj365/mime/vm/ElectronicFenceSettingVm.kt index d873806..5b622bd 100644 --- a/mine/src/main/java/com/zj365/mime/vm/ElectronicFenceSettingVm.kt +++ b/mine/src/main/java/com/zj365/mime/vm/ElectronicFenceSettingVm.kt @@ -4,14 +4,46 @@ import androidx.lifecycle.MutableLiveData import com.xty.base.vm.BaseVm import com.xty.network.model.EtFenceListBean import com.xty.network.model.RespBody +import org.json.JSONObject class ElectronicFenceSettingVm : BaseVm() { val electronicFenceListLiveDate by lazy { MutableLiveData>() } + + val addOrDeleteLiveData by lazy { MutableLiveData>() } + fun getElectronicFenceList(){ startHttp { var response = apiInterface().getBtFenceList() response.getCodeStatus(electronicFenceListLiveDate, nowData) } } + + fun setBtFence(title:String,radius:Int, type:Int, log:Double,lat:Double,id:Long?){ + startHttp { + var json = JSONObject() + json.put("title",title) + json.put("radius",radius) + json.put("type",type) + json.put("log",log) + json.put("lat",lat) + id?.let { + json.put("id",id) + + } + var response = apiInterface().setBtFence(retrofits.getRequestBody(json.toString())) + response.getCodeStatus(addOrDeleteLiveData, nowData) + + } + } + + fun deleteBtFence(id:Long){ + startHttp { + var json = JSONObject() + json.put("id",id) + var response = apiInterface().deleteBtFence(retrofits.getRequestBody(json.toString())) + response.getCodeStatus(addOrDeleteLiveData, nowData) + + } + } } \ No newline at end of file diff --git a/mine/src/main/java/com/zj365/mime/vm/SettingVm.kt b/mine/src/main/java/com/zj365/mime/vm/SettingVm.kt index 2fdc02e..86426c9 100644 --- a/mine/src/main/java/com/zj365/mime/vm/SettingVm.kt +++ b/mine/src/main/java/com/zj365/mime/vm/SettingVm.kt @@ -13,6 +13,7 @@ import com.xty.network.model.SettingBean import com.xty.network.model.UnReadMessageBean import com.xty.network.model.Update import com.xty.network.model.UserEquipmentInformationizationBean +import com.xty.network.model.UserOtherInfo import org.json.JSONObject class SettingVm : BaseVm() { @@ -34,7 +35,7 @@ class SettingVm : BaseVm() { val confirmInviteLiveData by lazy { MutableLiveData>() } - val userEqualityLiveData by lazy { MutableLiveData>() } + val useOtherInfoLiveData by lazy { MutableLiveData>() } fun getNesProg(id: String) { @@ -187,10 +188,10 @@ class SettingVm : BaseVm() { } - fun getUserEquity(){ + fun getUserOtherInfo(){ startHttp { - val response = apiInterface().getUserEquity() - response.getCodeStatus(userEqualityLiveData,nowData) + val response = apiInterface().getUserOtherInfo() + response.getCodeStatus(useOtherInfoLiveData,nowData) } } } \ No newline at end of file diff --git a/mine/src/main/res/drawable/shape_radius_66f04d42.xml b/mine/src/main/res/drawable/shape_radius_66f04d42.xml new file mode 100644 index 0000000..d5cb4ef --- /dev/null +++ b/mine/src/main/res/drawable/shape_radius_66f04d42.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/mine/src/main/res/drawable/shape_raduis_61ffac53.xml b/mine/src/main/res/drawable/shape_raduis_61ffac53.xml new file mode 100644 index 0000000..dab36b5 --- /dev/null +++ b/mine/src/main/res/drawable/shape_raduis_61ffac53.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/mine/src/main/res/layout/act_electronic_address_choose.xml b/mine/src/main/res/layout/act_electronic_address_choose.xml new file mode 100644 index 0000000..15afc00 --- /dev/null +++ b/mine/src/main/res/layout/act_electronic_address_choose.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mine/src/main/res/layout/activity_electronic_fence_setting.xml b/mine/src/main/res/layout/activity_electronic_fence_setting.xml index b11abe7..ff1fd77 100644 --- a/mine/src/main/res/layout/activity_electronic_fence_setting.xml +++ b/mine/src/main/res/layout/activity_electronic_fence_setting.xml @@ -1,23 +1,24 @@ - + + android:id="@+id/ll_data" + android:layout_above="@+id/ll_btn"> + android:layout_height="match_parent" + /> - + android:layout_height="match_parent" + android:id="@+id/rx_data" + android:visibility="gone"> + + + + + + + - + + + + + - diff --git a/mine/src/main/res/layout/item_electron_setting.xml b/mine/src/main/res/layout/item_electron_setting.xml index 9c658c5..57a6e8c 100644 --- a/mine/src/main/res/layout/item_electron_setting.xml +++ b/mine/src/main/res/layout/item_electron_setting.xml @@ -1,14 +1,15 @@ diff --git a/mine/src/main/res/layout/item_electronic_address_search.xml b/mine/src/main/res/layout/item_electronic_address_search.xml new file mode 100644 index 0000000..1e3dff9 --- /dev/null +++ b/mine/src/main/res/layout/item_electronic_address_search.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mine/src/main/res/layout/layout_bt_fence_enter.xml b/mine/src/main/res/layout/layout_bt_fence_enter.xml new file mode 100644 index 0000000..54f7f6f --- /dev/null +++ b/mine/src/main/res/layout/layout_bt_fence_enter.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/mine/src/main/res/layout/layout_bt_fence_leave.xml b/mine/src/main/res/layout/layout_bt_fence_leave.xml new file mode 100644 index 0000000..9106611 --- /dev/null +++ b/mine/src/main/res/layout/layout_bt_fence_leave.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/mine/src/main/res/layout/layout_ele_fence_setting.xml b/mine/src/main/res/layout/layout_ele_fence_setting.xml index 19dfce3..b1f0f99 100644 --- a/mine/src/main/res/layout/layout_ele_fence_setting.xml +++ b/mine/src/main/res/layout/layout_ele_fence_setting.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:padding="@dimen/dp_16"> + android:max="1000" + android:progress="50" + android:progressDrawable="@drawable/seek_bar" + android:thumb="@mipmap/icon_seekbar_drawer"/> > + @POST("customer/sugarMedicine/orderList") + suspend fun getSugarMedicineOrderList(@Body rb: RequestBody):RespBody> + @POST("customer/tumor/order/orderList") suspend fun getEstimateRecord(@Body rb: RequestBody): RespBody> @@ -1825,9 +1828,24 @@ interface ApiInterface { @POST("customer/watch/realmeas") suspend fun measureWatchData(@Body rb: RequestBody):RespBody + /** + * 获取电子围栏 + */ @POST("customer/watch/getBtfenceList") suspend fun getBtFenceList():RespBody + /** + * 设置电子围栏 + */ + @POST("customer/watch/setBtfence") + suspend fun setBtFence(@Body rb: RequestBody):RespBody + + /** + * 删除电子围栏 + */ + @POST("customer/watch/delBtfence") + suspend fun deleteBtFence(@Body rb: RequestBody):RespBody + /** * 获取演示模式 @@ -1849,8 +1867,8 @@ interface ApiInterface { /** * 获取用户权益 */ - @POST("customer/user/getUserEquity") - suspend fun getUserEquity():RespBody + @POST("customer/user/getUserInfo") + suspend fun getUserOtherInfo():RespBody /** * 获取设备型号 @@ -1911,4 +1929,10 @@ interface ApiInterface { */ @GET("customer/mall/order/cancelOrder") suspend fun cancelOrder(@Query("orderId") orderId:Long): RespBody + + /** + * 申请退款 + */ + @GET("customer/mall/order/getOrderInfo") + suspend fun applyReturn(@Query("orderId") orderId:Long):RespBody } \ No newline at end of file diff --git a/network/src/main/java/com/xty/network/model/BannerBean.kt b/network/src/main/java/com/xty/network/model/BannerBean.kt index cd46131..32e07b8 100644 --- a/network/src/main/java/com/xty/network/model/BannerBean.kt +++ b/network/src/main/java/com/xty/network/model/BannerBean.kt @@ -3,11 +3,11 @@ package com.xty.network.model import java.io.Serializable data class BannerBean( - val title: String, - val content: String, + val title: String?, + val content: String?, val bannerType: Int,//1:图文展示, 5:app内部打开, 10:web外部跳转, 15:视频播放,20 小程序跳转】,imgUrl 图片地址,linkAddress,连接地址 val imgUrl: String, - val linkAddress: String, + val linkAddress: String?, val wxId:String, //小程序ID val wxType:Int //1.开发版,2.体验版 3.正式版 ):Serializable \ No newline at end of file diff --git a/network/src/main/java/com/xty/network/model/EtFenceListBean.kt b/network/src/main/java/com/xty/network/model/EtFenceListBean.kt index 5486c89..d51dbe3 100644 --- a/network/src/main/java/com/xty/network/model/EtFenceListBean.kt +++ b/network/src/main/java/com/xty/network/model/EtFenceListBean.kt @@ -1,13 +1,18 @@ package com.xty.network.model -data class EtFenceListBean(var count:Int,var list:ArrayList){ +import android.os.Parcelable +import kotlinx.android.parcel.Parcelize + +@Parcelize +data class EtFenceListBean(var count:Int,var list:ArrayList):Parcelable{ + @Parcelize data class EtFenceChildBean( var id:Long, var user_id:Long, var title:String, var radius:Int, var type:Int, - var log:String, - var lat:String - ) + var log:Double, + var lat:Double + ):Parcelable } diff --git a/network/src/main/java/com/xty/network/model/HealthArchiveBean.kt b/network/src/main/java/com/xty/network/model/HealthArchiveBean.kt index 7ae538e..831cd79 100644 --- a/network/src/main/java/com/xty/network/model/HealthArchiveBean.kt +++ b/network/src/main/java/com/xty/network/model/HealthArchiveBean.kt @@ -1,6 +1,10 @@ package com.xty.network.model -data class HealthArchiveBean(var bmiInfo:BMIInfo,var healData:ArrayList){ +data class HealthArchiveBean( + var bmiInfo:BMIInfo, + var healData:ArrayList, + var bmr:String, + var bmi:String){ data class BMIInfo(var levelName:String,var bmi:Float) } diff --git a/network/src/main/java/com/xty/network/model/UserOtherInfo.kt b/network/src/main/java/com/xty/network/model/UserOtherInfo.kt new file mode 100644 index 0000000..1e91f57 --- /dev/null +++ b/network/src/main/java/com/xty/network/model/UserOtherInfo.kt @@ -0,0 +1,10 @@ +package com.xty.network.model + +data class UserOtherInfo( + var vip_end_time:String, + var order_count:Int, + var money:Double, + var start_business:String, + var operation_guide:String, + var coupons_count:Int, + var placard:String)