diff --git a/app/build.gradle b/app/build.gradle index 2095456..439d76b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,8 +36,8 @@ android { OPPO_APPID : "OP-30804697", // OPPO平台注册的appid OPPO_APPSECRET: "OP-2ea09012e6a746dfbc503877916ba342",//OPPO平台注册的appsecret - XIAOMI_APPKEY : "MI-5232015762943",// 小米平台注册的appkey - XIAOMI_APPID : "MI-2882303761520157943", // 小米平台注册的appid + XIAOMI_APPKEY : "MI-5992028541716",// 小米平台注册的appkey + XIAOMI_APPID : "MI-2882303761520285716", // 小米平台注册的appid VIVO_APPKEY:"8e9bb7cc764a56a6862e97ef99c03a61", VIVO_APPID:"105558697", diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 60849e3..2f42e35 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -161,6 +161,10 @@ android:name=".activity.DeviceChoiceAct" android:screenOrientation="portrait" /> + + () { + val binding by lazy { ActMessageDetailNewBinding.inflate(layoutInflater) } + + + override fun liveObserver() { + } + + override fun setLayout() = binding.root + + override fun initView() { + super.initView() + statusBar(binding.title.mView) + binding.title.mTvTitle.text= "消息详情" + binding.title.mIvBack.setOnClickListener { + finish() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/zj365/dc/activity/WelcomeAct.kt b/app/src/main/java/com/zj365/dc/activity/WelcomeAct.kt index bd35456..7467c21 100644 --- a/app/src/main/java/com/zj365/dc/activity/WelcomeAct.kt +++ b/app/src/main/java/com/zj365/dc/activity/WelcomeAct.kt @@ -101,16 +101,16 @@ class WelcomeAct : BaseVmAct() { getBgImage(getImageUrl(MMkvHelper.getString(Const.WELCOME_BG))) } else if (MMkvHelper.contains(Const.WELCOME_IMG) && MMkvHelper.contains(Const.WELCOME_DESC)) {//欢迎语和logo都存在 - binding.mBg.setImageResource(R.mipmap.ic_welcome_bg) + // binding.mBg.setImageResource(R.mipmap.ic_welcome_bg) binding.mTxt.text = MMkvHelper.getString(Const.WELCOME_DESC) getLogoImage(getImageUrl(MMkvHelper.getString(Const.WELCOME_IMG))) binding.mLinInfo.visibility = View.VISIBLE } else if (MMkvHelper.contains(Const.WELCOME_DESC)) {//只有欢迎语 - binding.mBg.setImageResource(R.mipmap.ic_welcome_bg) + // binding.mBg.setImageResource(R.mipmap.ic_welcome_bg) binding.mTxt.text = MMkvHelper.getString(Const.WELCOME_DESC) binding.mLinInfo.visibility = View.VISIBLE } else if (MMkvHelper.contains(Const.WELCOME_IMG)) {//只有logo存在 - binding.mBg.setImageResource(R.mipmap.ic_welcome_bg) + // binding.mBg.setImageResource(R.mipmap.ic_welcome_bg) getLogoImage(getImageUrl(MMkvHelper.getString(Const.WELCOME_IMG))) binding.mLinInfo.visibility = View.VISIBLE } else {//上述都无信息,则展示默认欢迎界面 diff --git a/app/src/main/java/com/zj365/dc/fragment/MessageFragment.kt b/app/src/main/java/com/zj365/dc/fragment/MessageFragment.kt index 242252c..6e5c7f3 100644 --- a/app/src/main/java/com/zj365/dc/fragment/MessageFragment.kt +++ b/app/src/main/java/com/zj365/dc/fragment/MessageFragment.kt @@ -3,7 +3,10 @@ package com.zj365.dc.fragment import android.graphics.Color import android.view.View import androidx.recyclerview.widget.LinearLayoutManager +import com.alibaba.android.arouter.facade.annotation.Route import com.xty.base.fragment.BaseFragList +import com.xty.common.arouter.ARouterUrl +import com.xty.common.arouter.RouteManager import com.xty.common.event.LoginOrRegisterEvent import com.xty.common.event.LoginOutEvent import com.zj365.dc.adapter.HomeMessageAdapter @@ -20,6 +23,9 @@ class MessageFragment : BaseFragList() { override fun initAdapter() { binding.mRecycle.layoutManager= LinearLayoutManager(requireContext()) binding.mRecycle.adapter=adapter + adapter.setOnItemClickListener { adapter, view, position -> + RouteManager.goAct(ARouterUrl.MESSAGE_DETAIL_NEW) + } } override fun initView() { diff --git a/app/src/main/res/layout/act_message_detail_new.xml b/app/src/main/res/layout/act_message_detail_new.xml new file mode 100644 index 0000000..e1476c1 --- /dev/null +++ b/app/src/main/res/layout/act_message_detail_new.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/act_welcome.xml b/app/src/main/res/layout/act_welcome.xml index 89197e5..43df330 100644 --- a/app/src/main/res/layout/act_welcome.xml +++ b/app/src/main/res/layout/act_welcome.xml @@ -10,6 +10,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" + android:background="@color/white" tools:src="@mipmap/ic_welcome_main_bg" /> - + tools:background="@mipmap/icon_daily_benefit"/> + \ No newline at end of file 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 a9948a8..6d2cac8 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 @@ -1,16 +1,262 @@ package com.zj365.health.act.skin +import android.graphics.Color +import android.os.Handler +import android.os.Looper +import android.os.Message +import android.text.TextUtils +import android.view.LayoutInflater import android.view.View +import android.widget.ImageView +import android.widget.LinearLayout +import android.widget.TextView +import android.widget.Toast +import com.alibaba.android.arouter.facade.annotation.Route +import com.google.android.material.bottomsheet.BottomSheetDialog +import com.tencent.mm.opensdk.modelbase.BaseResp +import com.tencent.mm.opensdk.modelpay.PayReq +import com.tencent.mm.opensdk.openapi.WXAPIFactory import com.xty.base.act.BaseVmAct +import com.xty.common.BuildConfig +import com.xty.common.LogUtils +import com.xty.common.arouter.ARouterUrl +import com.xty.common.arouter.RouteManager +import com.xty.common.event.WxPayEvent +import com.xty.common.util.SpannableUtils +import com.xty.network.model.PayGoodsBean +import com.xty.network.model.WeixinPayBean +import com.zj365.health.R import com.zj365.health.databinding.ActAiSkinMeasurementBinding +import com.zj365.health.model.PayResult +import com.zj365.health.vm.SkinMeasurementVm import com.zj365.health.vm.TongueDiagnosisVm +import com.zj365.health.weight.CancerDialog +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode +import retrofit2.http.Path -class SkinMeasurementMainAct : BaseVmAct() { +@Route(path = ARouterUrl.AI_SKIN_MEASUREMENT_ACTIVITY) +class SkinMeasurementMainAct : BaseVmAct() { val binding by lazy { ActAiSkinMeasurementBinding.inflate(layoutInflater)} + var type = 0 //0 AI 测肤 1 AI 糖医 + + var isShowTip = false + + var bottomSheetDialog: BottomSheetDialog? = null + + lateinit var payGoodsBean: PayGoodsBean + + val tipDialog by lazy { + CancerDialog(this, false, "温馨提示", { + bottomSheetDialog?.show() + }, { + bundle.clear() + RouteManager.goAct(ARouterUrl.TONGUE_ORDER_LIST_ACTIVITY, bundle) + }) + } + override fun liveObserver() { } override fun setLayout() = binding.root + + override fun initView() { + super.initView() + statusBar(binding.title.mView) + type = intent.getIntExtra("type",0) + if(type == 0){ + 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 + }else{ + binding.title.mTvTitle.text ="AI糖医" + } + + binding.title.mTvRight.setOnClickListener { + + } + + binding.title.mIvBack.setOnClickListener { + finish() + } + + binding.tvSubmit.setOnClickListener { + if (isShowTip) { + tipDialog.setContent("您的舌诊评估记录中,有存在未完成的记录确认需要再次购买吗?") + tipDialog?.show() + } else { + bottomSheetDialog?.show() + } + } + + initBottomDialog() + mViewModel.getAIoods() + mViewModel.aiHasNoFinishOrder() + } + + fun initBottomDialog() { + if (bottomSheetDialog == null) { + bottomSheetDialog = BottomSheetDialog(this,R.style.Theme_ChartDialogManager) + bottomSheetDialog?.let { dialog -> + val view = LayoutInflater.from(this).inflate(R.layout.bottom_cancer, null) + dialog.setContentView(view) + + val tvprice = view.findViewById(R.id.tvPrice) + tvprice.text = SpannableUtils.setSpanMoney(payGoodsBean.price!!) + val ivClose = view.findViewById(R.id.close_button) + ivClose.setOnClickListener { + dialog.dismiss() + } + val tvZhifubao = view.findViewById(R.id.tv_gouxuan_zhifubao) + val tvWeixin = view.findViewById(R.id.tv_gouxuan_weixin) + tvWeixin.isSelected = true + val tvDuihuanma = view.findViewById(R.id.tv_gouxuan_duihuanma) + val llWeixin = view.findViewById(R.id.llWeixin) + val llZhifu = view.findViewById(R.id.llZhifu) + val tvZhifu = view.findViewById(R.id.tvZhifu) + llZhifu.setOnClickListener { + tvZhifubao.isSelected = true + tvDuihuanma.isSelected = false + tvWeixin.isSelected = false + tvZhifu.text = "确认支付" + } + llWeixin.setOnClickListener { + tvZhifubao.isSelected = false + tvDuihuanma.isSelected = false + tvWeixin.isSelected = true + tvZhifu.text = "确认支付" + } + val llDuihuan = view.findViewById(R.id.llDuihuan) + llDuihuan.visibility = View.GONE + llDuihuan.setOnClickListener { + tvWeixin.isSelected = false + tvZhifubao.isSelected = false + tvDuihuanma.isSelected = true + tvZhifu.text = "去兑换" + } + + tvZhifu.setOnClickListener { + //支付 + if (tvZhifubao.isSelected) { + //支付宝 + mViewModel.payTongueOrder(payGoodsBean.id.toString(), false) + } else { + //微信 + mViewModel.payTongueOrder(payGoodsBean.id.toString(), true) + } + dialog.dismiss() + } + } + } + + } + + private val SDK_PAY_FLAG = 1 + private val WEIXIN_PAY_FLAG = 2 + + /** + * 微信支付 + */ + fun startWechatPay(wxModel: WeixinPayBean) { + LogUtils.i("startWechatPay") + val appId = wxModel.appId + val partnerId = wxModel.partnerid + val prepayId = wxModel.prepayId + val packageValue = wxModel.packageName + val nonceStr = wxModel.noncestr + val timeStamp = wxModel.timestamp + val sign = wxModel.sign + + val api = WXAPIFactory.createWXAPI(this, BuildConfig.appid) + api.registerApp(appId) + + //以下这些都应该从服务器去获取 + val payRequest = PayReq() + payRequest.appId = appId//你的微信appid + payRequest.partnerId = partnerId//微信支付分配的商户号 + payRequest.prepayId = prepayId//微信返回的支付交易会话ID + payRequest.packageValue = packageValue//固定值 + payRequest.nonceStr = nonceStr//随机字符串 + payRequest.timeStamp = timeStamp//时间戳 + payRequest.sign = sign//签名 + //传入一个标识,以便区分回调 + payRequest.extData = "AICancelPay" + //在支付之前,如果应用没有注册到微信,应该先调用IWXMsg.registerApp将应用注册到微信 + //发起请求,调起微信前去支付 + api.sendReq(payRequest); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + fun getWxPayResult(event: WxPayEvent) { + val msg = mHandler.obtainMessage() + msg.what = WEIXIN_PAY_FLAG + msg.obj = event + mHandler.sendMessage(msg) + } + + private val mHandler: Handler = object : Handler(Looper.getMainLooper()) { + override fun handleMessage(msg: Message) { + when (msg.what) { + SDK_PAY_FLAG -> { + val payResult = PayResult(msg.obj as Map) + + /** + * 对于支付结果,请商户依赖服务端的异步通知结果。同步通知结果,仅作为支付结束的通知。 + */ + val resultInfo: String = payResult.getResult() // 同步返回需要验证的信息 + val resultStatus: String = payResult.getResultStatus() + // 判断resultStatus 为9000则代表支付成功 + if (TextUtils.equals(resultStatus, "9000")) { + // 该笔订单是否真实支付成功,需要依赖服务端的异步通知。 +// Toast.makeText(this@PreventCancertAct,"支付成功"+payResult,Toast.LENGTH_SHORT).show() +// com.alipay.sdk.pay.demo.PayDemoActivity.showAlert( +// this@PayDemoActivity, +// getString(R.string.pay_success) + payResult +// ) + bundle.clear() + bundle.putString("orderNo", mViewModel.payObservable.value?.data?.orderNo) + bundle.putString("orderType", payGoodsBean.goodsType.toString()) + RouteManager.goAct(ARouterUrl.PAY_SUCCESS, bundle) + } else { + Toast.makeText(this@SkinMeasurementMainAct, "支付失败,请联系客服", Toast.LENGTH_SHORT) + .show() + + // 该笔订单真实的支付结果,需要依赖服务端的异步通知。 +// com.alipay.sdk.pay.demo.PayDemoActivity.showAlert( +// this@PayDemoActivity, +// getString(R.string.pay_failed) + payResult +// ) + } + } + WEIXIN_PAY_FLAG -> { + val event = msg.obj as WxPayEvent + when (event.code) { + BaseResp.ErrCode.ERR_OK -> { + bundle.clear() + bundle.putString("orderNo", mViewModel.payObservable.value?.data?.orderNo) + bundle.putString("orderType", payGoodsBean.goodsType.toString()) + RouteManager.goAct(ARouterUrl.PAY_SUCCESS, bundle) + } + + BaseResp.ErrCode.ERR_USER_CANCEL -> { + + } + + else -> { + Toast.makeText( + this@SkinMeasurementMainAct, + "支付失败,请联系客服", + Toast.LENGTH_SHORT + ).show() + } + } + } + } + } + } + + } \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/vm/SkinMeasurementVm.kt b/health/src/main/java/com/zj365/health/vm/SkinMeasurementVm.kt new file mode 100644 index 0000000..c87331b --- /dev/null +++ b/health/src/main/java/com/zj365/health/vm/SkinMeasurementVm.kt @@ -0,0 +1,46 @@ +package com.zj365.health.vm + +import androidx.lifecycle.MutableLiveData +import com.xty.base.vm.BaseVm +import com.xty.network.model.PayBean +import com.xty.network.model.PayGoodsBean +import com.xty.network.model.RespBody +import org.json.JSONObject + +class SkinMeasurementVm: BaseVm() { + val payGoodsObservable by lazy { MutableLiveData>() } + + val payObservable by lazy { MutableLiveData>() } + + val haveOrder by lazy { MutableLiveData>() } + + + fun getAIoods(){ + startHttp { + apiInterface().getTongueGoods() + var response = apiInterface().getTongueGoods() + response.getCodeStatus(payGoodsObservable, nowData) + } + } + + //获取有无未完成订单 + fun aiHasNoFinishOrder() { + startHttp { + var json = JSONObject() + var response = + apiInterface().tongueHasNoFinishOrder(retrofits.getRequestBody(json.toString())) + response.getCodeStatus(haveOrder, nowData) + } + } + + //获取支付信息 + fun payTongueOrder(goodsId:String,isWeChatPay:Boolean){ + startHttp { + var json = JSONObject() + json.put("goodsId",goodsId) + json.put("channelName", if (isWeChatPay) "WEIXIN_APP" else "ALIPAY_APP") + var response = apiInterface().payTongueOrder(retrofits.getRequestBody(json.toString())) + response.getCodeStatus(payObservable, nowData) + } + } +} \ No newline at end of file diff --git a/health/src/main/res/layout/act_psychological_test_main.xml b/health/src/main/res/layout/act_psychological_test_main.xml new file mode 100644 index 0000000..d829e29 --- /dev/null +++ b/health/src/main/res/layout/act_psychological_test_main.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file