Commit 44a350d4 authored by mengcuiguang2's avatar mengcuiguang2

Merge branch 'dev_ad' into branche_zsf

parents deaf0bd6 942b75aa
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
tools:replace="android:screenOrientation" /> <!-- WX_APPID必填项 --> tools:replace="android:screenOrientation" /> <!-- WX_APPID必填项 -->
<meta-data <meta-data
android:name="WX_APPID" android:name="WX_APPID"
android:value="wx8f26539eabfb04f2" /> android:value="wx62d0739d771e6633" />
<activity <activity
android:name=".wxapi.WXPayEntryActivity" android:name=".wxapi.WXPayEntryActivity"
......
...@@ -13,6 +13,7 @@ class UserBean : Serializable { ...@@ -13,6 +13,7 @@ class UserBean : Serializable {
inner class ConsumerBean : Serializable { inner class ConsumerBean : Serializable {
val openid: String = "" val openid: String = ""
val head: String = ""
val nickname: String = "" val nickname: String = ""
val mobile: String = "" val mobile: String = ""
val idcode: String = "" val idcode: String = ""
......
...@@ -3,9 +3,9 @@ package com.mints.street.bean ...@@ -3,9 +3,9 @@ package com.mints.street.bean
import java.io.Serializable import java.io.Serializable
class VipBean : Serializable { class VipBean : Serializable {
var list: List<ConsumerBean>? = null var list: List<ListBean>? = null
inner class ConsumerBean : Serializable { inner class ListBean : Serializable {
var id: Int = 0 // 1 var id: Int = 0 // 1
var price: Int = 0// 78 var price: Int = 0// 78
var days: Int = 0 // 365 var days: Int = 0 // 365
......
package com.mints.street.bean;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class WxPayParamBean implements Serializable {
/**
* params : {"package":"Sign=WXPay","appid":"wx8f26539eabfb04f2","sign":"5012752C519C5EF177181F64514AF66C","partnerid":"1546641181","prepayid":"wx13145659084039f3fb9f073b1270898700","noncestr":"RAJD28WMYMT61N17FYOYGT73PNFC","timestamp":"1592031419"}
* tid : 2016514565805500001
*/
private ParamsBean params;
private long tid;
public ParamsBean getParams() {
return params;
}
public void setParams(ParamsBean params) {
this.params = params;
}
public long getTid() {
return tid;
}
public void setTid(long tid) {
this.tid = tid;
}
public class ParamsBean implements Serializable {
/**
* package : Sign=WXPay
* appid : wx8f26539eabfb04f2
* sign : 5012752C519C5EF177181F64514AF66C
* partnerid : 1546641181
* prepayid : wx13145659084039f3fb9f073b1270898700
* noncestr : RAJD28WMYMT61N17FYOYGT73PNFC
* timestamp : 1592031419
*/
@SerializedName("package")
private String packageX;
private String appid;
private String sign;
private String partnerid;
private String prepayid;
private String noncestr;
private String timestamp;
private String params;
public String getPackageX() {
return packageX;
}
public void setPackageX(String packageX) {
this.packageX = packageX;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getPartnerid() {
return partnerid;
}
public void setPartnerid(String partnerid) {
this.partnerid = partnerid;
}
public String getPrepayid() {
return prepayid;
}
public void setPrepayid(String prepayid) {
this.prepayid = prepayid;
}
public String getNoncestr() {
return noncestr;
}
public void setNoncestr(String noncestr) {
this.noncestr = noncestr;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
}
}
...@@ -2,17 +2,21 @@ package com.mints.street.main.my ...@@ -2,17 +2,21 @@ package com.mints.street.main.my
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.view.View import android.view.View
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import com.alibaba.android.vlayout.DelegateAdapter import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager import com.alibaba.android.vlayout.VirtualLayoutManager
import com.cuieney.sdk.rxpay.RxPay
import com.fry.base.base.BaseActivity import com.fry.base.base.BaseActivity
import com.mints.street.BR import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.adapter.GridPaymentAdapter import com.mints.street.adapter.GridPaymentAdapter
import com.mints.street.bean.PaymentBean import com.mints.street.bean.PaymentBean
import com.mints.street.bean.VipBean import com.mints.street.bean.VipBean
import com.mints.street.bean.WxPayParamBean
import com.mints.street.databinding.ActivityOpenvipBinding import com.mints.street.databinding.ActivityOpenvipBinding
import com.mints.street.manager.UserManager
import kotlinx.android.synthetic.main.activity_openvip.* import kotlinx.android.synthetic.main.activity_openvip.*
import kotlinx.android.synthetic.main.include_header.* import kotlinx.android.synthetic.main.include_header.*
import me.goldze.mvvmhabit.utils.ToastUtils import me.goldze.mvvmhabit.utils.ToastUtils
...@@ -23,6 +27,8 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -23,6 +27,8 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
private var vLayout: VirtualLayoutManager? = null private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null private var mAdapter: DelegateAdapter? = null
private var vipList: MutableList<VipBean.ListBean>? = null
override fun initVariableId() = BR.viewModel override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_openvip override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_openvip
override fun initData() { override fun initData() {
...@@ -77,6 +83,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -77,6 +83,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
override fun initViewObservable() { override fun initViewObservable() {
super.initViewObservable() super.initViewObservable()
viewModel.Vipdata.observe(this, Observer<VipBean> { viewModel.Vipdata.observe(this, Observer<VipBean> {
vipList= it.list as MutableList<VipBean.ListBean>?
mAdapter?.addAdapter(GridPaymentAdapter(this, it.list!!)) mAdapter?.addAdapter(GridPaymentAdapter(this, it.list!!))
}) })
viewModel.Paymentdata.observe(this, Observer<PaymentBean> { viewModel.Paymentdata.observe(this, Observer<PaymentBean> {
...@@ -109,7 +116,13 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -109,7 +116,13 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
setOnChecked(2) setOnChecked(2)
} }
R.id.bt_try -> { R.id.bt_try -> {
if (vipList != null && vipList!!.size > 0) {
// if (TextUtils.equals("weixin", payDialog?.payChannel)) {
// vipPresenter?.getVipPayParams("WEIXIN", vipList!![vipAdapter?.getPosition()].pid)
// } else {
// vipPresenter?.getVipPayParams("ALIPAY", vipList!![vipAdapter?.getPosition()].pid)
// }
}
} }
} }
} }
...@@ -128,5 +141,39 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -128,5 +141,39 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
} }
fun wxPay(wxParanBean: WxPayParamBean) {
val data = wxParanBean.params
var str = "{\"prepayId\":\"${data.prepayid}\"," +
"\"nonceStr\":\"${data.noncestr}\"," +
"\"packageValue\":\"${data.packageX}\"," +
"\"partnerId\":\"${data.partnerid}\"," +
"\"sign\":\"${data.sign}\"," +
"\"timeStamp\":\"${data.timestamp}\"}"
RxPay(this).requestWXpay(str)
.subscribe({ isPay ->
if (isPay) {
//支付成功
UserManager.INSTANCE.setVipFlag(true)
}
// vipPresenter?.queryVipOrder(wxParanBean.tid.toString(), isPay)
}) { throwable ->
ToastUtils.showShort("支付异常,请联系管理员")
}
}
fun alipay(wxParanBean: WxPayParamBean) {
RxPay(this).requestAlipay(wxParanBean.params.params)
.subscribe({ isPay ->
if (isPay) {
//支付成功
UserManager.INSTANCE.setVipFlag(true)
}
// vipPresenter?.queryVipOrder(wxParanBean.tid.toString(), isPay)
}) { throwable ->
ToastUtils.showShort("支付异常,请联系管理员")
}
}
} }
...@@ -58,6 +58,11 @@ class UserManager { ...@@ -58,6 +58,11 @@ class UserManager {
*/ */
private const val EXPIRETIME = "expiretime" private const val EXPIRETIME = "expiretime"
/**
* vip支付是否有效
*/
private const val VIP_FLAG = "vipFlag"
val INSTANCE: UserManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { val INSTANCE: UserManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
UserManager() UserManager()
} }
...@@ -90,11 +95,19 @@ class UserManager { ...@@ -90,11 +95,19 @@ class UserManager {
if (!TextUtils.isEmpty(user.nickname)) { if (!TextUtils.isEmpty(user.nickname)) {
MMKV.mmkvWithID(WX_NAME).encode(WX_NAME, user.nickname) MMKV.mmkvWithID(WX_NAME).encode(WX_NAME, user.nickname)
} }
if (!TextUtils.isEmpty(user.head)) {
MMKV.mmkvWithID(WX_HEADER).encode(WX_HEADER, user.head)
}
MMKV.mmkvWithID(IS_FOREVER).encode(IS_FOREVER, user.isForever) MMKV.mmkvWithID(IS_FOREVER).encode(IS_FOREVER, user.isForever)
MMKV.mmkvWithID(EXPIRETIME).encode(EXPIRETIME, user.expireTime) MMKV.mmkvWithID(EXPIRETIME).encode(EXPIRETIME, user.expireTime)
if (!TextUtils.isEmpty(openid)) { if (!TextUtils.isEmpty(openid)) {
MMKV.mmkvWithID(WX_OPENID).encode(WX_OPENID, openid) MMKV.mmkvWithID(WX_OPENID).encode(WX_OPENID, openid)
} }
if (user.expireTime > 0) {
MMKV.mmkvWithID(VIP_FLAG).encode(VIP_FLAG, true)
} else {
MMKV.mmkvWithID(VIP_FLAG).encode(VIP_FLAG, false)
}
} }
} }
...@@ -117,31 +130,21 @@ class UserManager { ...@@ -117,31 +130,21 @@ class UserManager {
return !TextUtils.isEmpty(wxId)||!TextUtils.isEmpty(mobile) return !TextUtils.isEmpty(wxId)||!TextUtils.isEmpty(mobile)
} }
/**
* 单独获取用户id
*/
fun getUserID(): String { fun getUserID(): String {
val kv = MMKV.mmkvWithID(USER_ID) val kv = MMKV.mmkvWithID(USER_ID)
return kv.decodeString(USER_ID, "") return kv.decodeString(USER_ID, "")
} }
/**
* 获取用户登陆状态
*/
fun getTokenID(): String { fun getTokenID(): String {
val kv = MMKV.mmkvWithID(TOKEN_ID) val kv = MMKV.mmkvWithID(TOKEN_ID)
return kv.decodeString(TOKEN_ID, "") return kv.decodeString(TOKEN_ID, "")
} }
/**
* 获取用户邀请码
*/
fun getCodeID(): String { fun getCodeID(): String {
val kv = MMKV.mmkvWithID(CODE_ID) val kv = MMKV.mmkvWithID(CODE_ID)
return kv.decodeString(CODE_ID, "") return kv.decodeString(CODE_ID, "")
} }
fun getWxName(): String { fun getWxName(): String {
val kv = MMKV.mmkvWithID(WX_NAME) val kv = MMKV.mmkvWithID(WX_NAME)
return kv.decodeString(WX_NAME, "") return kv.decodeString(WX_NAME, "")
...@@ -167,6 +170,14 @@ class UserManager { ...@@ -167,6 +170,14 @@ class UserManager {
return kv.decodeLong(EXPIRETIME, 0) return kv.decodeLong(EXPIRETIME, 0)
} }
fun getVipFlag(): Boolean {
val kv = MMKV.mmkvWithID(EXPIRETIME)
return kv.decodeBool(EXPIRETIME, false)
}
fun setVipFlag(vipFlag:Boolean){
MMKV.mmkvWithID(VIP_FLAG).encode(VIP_FLAG, vipFlag)
}
fun userLogout() { fun userLogout() {
MMKV.mmkvWithID(USER_ID).remove(USER_ID) MMKV.mmkvWithID(USER_ID).remove(USER_ID)
...@@ -178,6 +189,7 @@ class UserManager { ...@@ -178,6 +189,7 @@ class UserManager {
MMKV.mmkvWithID(WX_HEADER).remove(WX_HEADER) MMKV.mmkvWithID(WX_HEADER).remove(WX_HEADER)
MMKV.mmkvWithID(IS_FOREVER).remove(IS_FOREVER) MMKV.mmkvWithID(IS_FOREVER).remove(IS_FOREVER)
MMKV.mmkvWithID(EXPIRETIME).remove(EXPIRETIME) MMKV.mmkvWithID(EXPIRETIME).remove(EXPIRETIME)
MMKV.mmkvWithID(VIP_FLAG).encode(VIP_FLAG, false)
} }
} }
\ No newline at end of file
...@@ -77,15 +77,15 @@ ...@@ -77,15 +77,15 @@
但是只能分享图片和文字,username和path是分享小程序用的的,userName是小程序的原始ID,path是小程序内的页面路径; 但是只能分享图片和文字,username和path是分享小程序用的的,userName是小程序的原始ID,path是小程序内的页面路径;
而且必须保证微信开放平台与微信公众/小程序绑定才可以分享;不需要的不用管 而且必须保证微信开放平台与微信公众/小程序绑定才可以分享;不需要的不用管
--> -->
<Wechat AppId="wxa824ad2a65960e60" AppSecret="a01fbb557b214f7c11564b47bc7f3c91" BypassApproval="false" <Wechat AppId="wx62d0739d771e6633" AppSecret="d837b62b054912b68befa1e33b4c3e13" BypassApproval="false"
Enable="true" Id="4" Enable="true" Id="4"
MiniprogramType="0" Path="pages/index/index.html?id=1" SortId="4" MiniprogramType="0" Path="pages/index/index.html?id=1" SortId="4"
UserName="gh_afb25ac019c9" WithShareTicket="true" /> UserName="gh_afb25ac019c9" WithShareTicket="true" />
<WechatMoments AppId="wxa824ad2a65960e60" AppSecret="a01fbb557b214f7c11564b47bc7f3c91" BypassApproval="false" <WechatMoments AppId="wx62d0739d771e6633" AppSecret="d837b62b054912b68befa1e33b4c3e13" BypassApproval="false"
Enable="true" Id="5" SortId="5" /> Enable="true" Id="5" SortId="5" />
<WechatFavorite AppId="wxa824ad2a65960e60" AppSecret="a01fbb557b214f7c11564b47bc7f3c91" Enable="true" <WechatFavorite AppId="wx62d0739d771e6633" AppSecret="d837b62b054912b68befa1e33b4c3e13" Enable="true"
Id="6" SortId="6" /> Id="6" SortId="6" />
<!-- ShareByAppClient标识是否使用微博客户端分享,默认是false --> <!-- ShareByAppClient标识是否使用微博客户端分享,默认是false -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment