Commit c29a8e87 authored by fengruiyu's avatar fengruiyu

修改JS(z3map)

地图样式
parent 4d37bd73
......@@ -114,6 +114,16 @@ function needPay() {
}
}
function needPayPopup() {
try {
doAppFun("needPayPopup");
} catch (e) {
// console.log("tips", msg)
//alert("app未弹框==>" + msg + e)
}
}
function tips(msg) {
try {
doAppFun("tips", msg);
......
......@@ -52,7 +52,7 @@ var vm = new Vue({
vrs: function () {
var th = this;
if(this.isVip==false){
this.needPay();
this.needPay('p');
return;
}
if (th.canclick) {
......@@ -129,7 +129,7 @@ var vm = new Vue({
})
marker.addListener("click", (ss) => {
if(this.isVip==false){
this.needPay();
this.needPay('p');
return;
}
params = vm.getSeLabel(marker.getTitle());
......@@ -163,7 +163,7 @@ var vm = new Vue({
inMsg.lat = 39.90960456049752;
inMsg.lng = 116.3972282409668;
}
th.isVip = inMsg.vip == 1;
th.isVip = inMsg.vip == 1;
var point = {
lat: parseFloat(inMsg.lat),
lng: parseFloat(inMsg.lng)
......@@ -232,9 +232,14 @@ var vm = new Vue({
return;
}
},
needPay:function(){
needPay:function(d){
console.log("<<请开启会员")
needPay();
if(d!=undefined&&d!=null&&d=='p'){
needPay();
return;
}
needPayPopup();
},
G_initMap: function (point, zoomLevel) {
if (zoomLevel == undefined || zoomLevel == null)
......@@ -284,24 +289,14 @@ var vm = new Vue({
});
G_MAP.addListener("dragend", () => {
centerChanged();
});
// G_MAP.addListener("dragend", () => {
// centerChanged();
// });
document.addEventListener("touchstart", function (e) {
centerChanged();
// document.addEventListener("touchstart", function (e) {
// console.log(e.touches);
// if (e.touches.length > 1) {
// vm.gdcenter =
// {
// lat: G_MAP.getCenter().lat(),
// lng: G_MAP.getCenter().lng()
// };
// console.log("两指")
// } else {
// vm.gdcenter = null;
// console.log("一指")
// }
// }, false);
}, false);
}
......@@ -317,7 +312,7 @@ var vm = new Vue({
window.onload = function () {
allIsOk();
// init();
//init();
}
function init() {
......
package com.mints.street.adapter
import android.content.Context
import android.content.Intent
import android.view.View
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.utils.ImageLoader
import com.mints.street.R
import com.mints.street.bean.MapStyleList
import com.mints.street.databinding.DialogMapContentItemBinding
import com.mints.street.databinding.DialogMapContentItemBindingImpl
import com.mints.street.databinding.ItemGridMapAdapterBinding
import com.mints.street.main.my.OpenvipActivity
import com.mints.street.manager.UserManager
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.RxUtils
/**
* Created by 冯瑞雨 on 2021/8/9.
*/
class DialogMapContentAdapter(val context: Context, var list: List<MapStyleList>?,
val onItemMapStyleChange:OnItemMapStyleChange?=null) :
class DialogMapContentAdapter(
val context: Context, var list: List<MapStyleList>?,
private val onItemMapStyleChange: OnItemMapStyleChange? = null
) :
AbstractVLayoutBaseAdapter<DialogMapContentItemBinding, List<MapStyleList>>(context, list, 2) {
override fun onBindViewHolder(
holder: BindingViewHolder<DialogMapContentItemBinding>,
position: Int) {
when(list?.get(position)?.img?:0){
1->holder.binding.image.setImageResource(R.mipmap.img_mapstyle_1)
2->holder.binding.image.setImageResource(R.mipmap.img_mapstyle_2)
3->holder.binding.image.setImageResource(R.mipmap.img_mapstyle_3)
4->holder.binding.image.setImageResource(R.mipmap.img_mapstyle_4)
}
if(list?.get(position)?.isSelected == true){
position: Int
) {
ImageLoader.ImageBuilder.with(context)
.setTargetView(holder.binding.image)
.setUrl(list?.get(position)?.img).start()
holder.binding.tvName.text = list?.get(position)?.name
if (list?.get(position)?.isSelected == true) {
holder.binding.ivSelected.visibility = View.VISIBLE
}else{
} else {
holder.binding.ivSelected.visibility = View.GONE
}
RxUtils.onMultiClick(holder.binding.image){
if(list?.get(position)?.isSelected==true)return@onMultiClick
RxUtils.onMultiClick(holder.binding.image) {
if (list?.get(position)?.isSelected == true) return@onMultiClick
if (list?.get(position)?.type == "1" && !UserManager.INSTANCE.getVipFlag()) {
AppManager.getAppManager().currentActivity?.apply {
this.startActivity(
Intent(
this, OpenvipActivity::class.java
)
)
}
return@onMultiClick
}
list?.forEach {
it.isSelected = false
}
list?.get(position)?.isSelected =true
onItemMapStyleChange?.onItemChange(list?.get(position)?.img?:0)
list?.get(position)?.isSelected = true
onItemMapStyleChange?.onItemChange(list?.get(position)?.key ?: "hybrid")
notifyDataSetChanged()
}
}
override fun getItemCount() = list?.size?:0
override fun getItemCount() = list?.size ?: 0
override fun onCreateLayoutHelper(): LayoutHelper {
val helper = GridLayoutHelper(2)
......@@ -57,7 +70,7 @@ class DialogMapContentAdapter(val context: Context, var list: List<MapStyleList>
override fun getLayoutId(viewType: Int) = R.layout.dialog_map_content_item
interface OnItemMapStyleChange{
fun onItemChange(type:Int)
interface OnItemMapStyleChange {
fun onItemChange(type: String)
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.mints.street.netwrok.common.HttpManager
import io.reactivex.Observable
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
/**
......@@ -145,4 +146,9 @@ interface MainApi {
@POST("na/getAttractionsList")
fun getHotView(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<HotViewBean>>>
/**
* 地图是否收费
*/
@POST("na/getMapChargeConfig")
fun getMapChargeConfig():Observable<Response<BaseResponse<MapStyleSort>>>
}
\ No newline at end of file
package com.mints.street.bean
/**
* Created by 冯瑞雨 on 2021/8/16.
*/
class InitMapBean {
var lat: Double = 0.0
var lng: Double = 0.0
var vip: Int? = 0//0 非vip 1 vip
var inner: Int? = 0// 0国内 ,1国外
}
\ No newline at end of file
......@@ -10,11 +10,12 @@ class MapStyleSortBean {
}
class MapStyleSort{
var name:String?=null
var mapStyleList:List<MapStyleList>?=null
var list:List<MapStyleList>?=null
}
class MapStyleList{
var name:String?=null
var img:Int=0
var key:String?=null
var type:String?=null//是否收费
var img:String?=null
var isSelected:Boolean?=false
}
\ No newline at end of file
}
......@@ -4,7 +4,6 @@ import android.Manifest
import android.os.Build
import android.os.Bundle
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
......@@ -17,7 +16,6 @@ import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityMainBinding
import com.mints.street.main.googlemap.GoogleMapFragment
import com.mints.street.main.home.HomeFragment
import com.mints.street.main.my.MyFragment
import com.mints.street.main.vr.VRFragment
import com.mints.street.manager.UserManager
......@@ -25,6 +23,7 @@ import com.mints.street.manager.oaid.OaidManager
import com.permissionx.guolindev.PermissionX
import com.permissionx.guolindev.callback.RequestCallback
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.ToastUtils
......@@ -37,29 +36,20 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
override fun getStatusBarHeightView(): View? {
return null
}
private val homeFragment = HomeFragment()
override fun initData() {
super.initData()
OaidManager.init()
//初始化viewpager2
binding.mainViewpager.initMain(this,homeFragment)
binding.mainViewpager.initMain(this)
//初始化 bottomBarF
binding.mainBottom.init {
when (it) {
R.id.menu_home -> {
if (UserManager.INSTANCE.userIsLogin() && UserManager.INSTANCE.getVipFlag()) {
binding.mainViewpager.setCurrentItem(3, false)
} else {
binding.mainViewpager.setCurrentItem(0, false)
}
}
R.id.menu_home -> binding.mainViewpager.setCurrentItem(0, false)
R.id.menu_square -> binding.mainViewpager.setCurrentItem(1, false)
R.id.menu_my -> {
binding.mainViewpager.setCurrentItem(2, false)
// stopAnim()
}
R.id.menu_my -> { binding.mainViewpager.setCurrentItem(2, false) }
}
}
//加载本地GIF动图
......@@ -81,15 +71,7 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
viewModel.checkUpgrade()
}
override fun onResume() {
super.onResume()
if (binding.mainViewpager.currentItem == 0){
if (UserManager.INSTANCE.userIsLogin() && UserManager.INSTANCE.getVipFlag()) {
binding.mainViewpager.setCurrentItem(3, false)
}
}
}
var oldTime: Long = 0
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
when (keyCode) {
......@@ -108,19 +90,18 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
}
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_MOVE){
//触点的个数,就是有几个手指同时接触屏幕
if (ev.pointerCount==1){
homeFragment.updateGesture(true)
}else{
homeFragment.updateGesture(false)
}
}
return super.dispatchTouchEvent(ev)
}
// override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
// if (ev.action == MotionEvent.ACTION_MOVE) {
// //触点的个数,就是有几个手指同时接触屏幕
// if (ev.pointerCount == 1) {
// homeFragment.updateGesture(true)
// } else {
// homeFragment.updateGesture(false)
// }
// }
//
// return super.dispatchTouchEvent(ev)
// }
}
......@@ -137,11 +118,11 @@ private fun BottomNavigationViewEx.init(navigationItemSelectedAction: (Int) -> U
return this
}
private fun ViewPager2.initMain(activity: MainActivity,homeFragment:HomeFragment): ViewPager2 {
private fun ViewPager2.initMain(activity: MainActivity): ViewPager2 {
//是否可滑动
this.isUserInputEnabled = false
//预加载
this.offscreenPageLimit = 4
// this.offscreenPageLimit = 2
//设置适配器
adapter = object : FragmentStateAdapter(activity) {
......@@ -149,7 +130,7 @@ private fun ViewPager2.initMain(activity: MainActivity,homeFragment:HomeFragment
return when (position) {
0 -> {
//首页
homeFragment
GoogleMapFragment()
}
1 -> {
//广场
......@@ -159,16 +140,13 @@ private fun ViewPager2.initMain(activity: MainActivity,homeFragment:HomeFragment
//个人中心
MyFragment()
}
3 -> {
GoogleMapFragment()
}
else -> {
//首页
HomeFragment()
GoogleMapFragment()
}
}
}
override fun getItemCount() = 4
......
......@@ -130,7 +130,9 @@ class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), Senso
}
//地图样式
RxUtils.onMultiClick(binding.imageMapChangeIcon) {
if (!com.mints.street.manager.UserManager.INSTANCE.userIsLogin()&&!com.mints.street.manager.UserManager.INSTANCE.getVipFlag()){
if (!com.mints.street.manager.UserManager.
INSTANCE.userIsLogin()&&!com.mints.street.
manager.UserManager.INSTANCE.getVipFlag()){
startActivity(OpenvipActivity::class.java)
}
......
......@@ -16,11 +16,13 @@ import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.utils.DeviceUuidFactory
import com.mints.street.webview.MintsWebViewActivity
import io.reactivex.Observable
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.SPUtils
import me.tatarka.bindingcollectionadapter2.ItemBinding
import retrofit2.Response
import java.io.BufferedReader
import java.io.InputStreamReader
......@@ -33,14 +35,22 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
var addressList = ObservableArrayList<HomeButtonItemVM?>()
var addressItemBinding =
ItemBinding.of<HomeButtonItemVM>(BR.viewModel, R.layout.item_home_button)
var isLoginAndVipEqualTrue:Boolean?=null
//搜索页面回调 谷歌GPS
var pt = MutableLiveData<GPS>()
val authorizedBean = MutableLiveData<AuthorizedBean>()
fun authorized() {
ApiModel.authorized().safeSubscribe(object
var authorized : Observable< Response<BaseResponse<AuthorizedBean>>>?=null
if (isLoginAndVipEqualTrue == true){
//vip
authorized = ApiModel.authorized()
}else{
//非vip
authorized = ApiModel.authorizedA()
}
authorized.safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
null, false
) {
......@@ -50,7 +60,6 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
}
authorizedBean.value = response.result
}
})
}
......@@ -241,26 +250,21 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
/**
* 获取地图展示样式
*/
val mapStyleSortBean = MutableLiveData<MapStyleSortBean>(getMapStyle())
fun getMapStyle():MapStyleSortBean?{
val assets = AppManager.getAppManager().currentActivity.assets
val stringBuilder = StringBuilder()
var mapBean: MapStyleSortBean? = null
try {
//通过管理器打开文件并读取
val bf = BufferedReader(
InputStreamReader(
assets.open("mapStyle.json")
)
)
var line: String?
while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line)
val mapStyleSortBean = MutableLiveData<MapStyleSortBean>()
fun getMapStyle(){
ApiModel.getMapChargeConfig(lifecycleProvider).safeSubscribe(object
:HttpSubscribeImpl<BaseResponse<MapStyleSort>>(this@HomeViewModel){
override fun onBusinessSuccess(response: BaseResponse<MapStyleSort>) {
response.result.name = "常用"
val bean = MapStyleSortBean()
bean.isStreetViewMap = true
bean.isRecommendedPlaces = false
if (response.result.list!=null && response.result.list?.size?:0>0){
response.result.list?.get(0)?.isSelected = true
}
bean.mapStyleSort = listOf(response.result)
mapStyleSortBean.value = bean
}
mapBean = Gson().fromJson(stringBuilder.toString(), MapStyleSortBean::class.java)
} catch (e: Exception) {
KLog.e("读取assets文件下的json出问题")
}
return mapBean
})
}
}
\ No newline at end of file
......@@ -149,8 +149,18 @@ object ApiModel {
/**
* 请求热门景点数据
*/
fun getHotView(lifecycleProvider: LifecycleProvider<Any>?, map: HashMap<String, Any>):Observable<Response<BaseResponse<HotViewBean>>>{
return HttpManager.getInstance().execute(lifecycleProvider,MainApi.newInstance().getHotView(map))
fun getHotView(lifecycleProvider: LifecycleProvider<Any>?,
map: HashMap<String, Any>):Observable<Response<BaseResponse<HotViewBean>>>{
return HttpManager.getInstance().execute(lifecycleProvider,
MainApi.newInstance().getHotView(map))
}
/**
* 地图是否收费
*/
fun getMapChargeConfig(lifecycleProvider: LifecycleProvider<Any>?)
:Observable<Response<BaseResponse<MapStyleSort>>>{
return HttpManager.getInstance().execute(lifecycleProvider,
MainApi.newInstance().getMapChargeConfig())
}
}
\ No newline at end of file
package com.mints.street.widget.dialog
import androidx.fragment.app.FragmentActivity
import com.mints.street.login.OnLoginListener
class BenfitDialog(context: FragmentActivity){
}
\ No newline at end of file
......@@ -66,9 +66,9 @@ class DialogMapStyle(
mapStyleBean?.mapStyleSort?.forEach {
mAdapter?.addAdapter(DialogMapHeadAdapter(mContext, it.name))
mAdapter?.addAdapter(
DialogMapContentAdapter(mContext, it.mapStyleList,
DialogMapContentAdapter(mContext, it.list,
object : DialogMapContentAdapter.OnItemMapStyleChange {
override fun onItemChange(type: Int) {
override fun onItemChange(type: String) {
onMapStyleDataChange?.onMapStyleItemChange(type)
}
})
......@@ -92,7 +92,7 @@ class DialogMapStyle(
)
}
interface OnMapStyleDataChange{
fun onMapStyleItemChange(type:Int)
fun onMapStyleItemChange(type:String)
fun onRecommendedPlacesChange(isSelected: Boolean)
fun onStreetViewMapChange(isSelected: Boolean)
}
......
......@@ -22,7 +22,7 @@ object DialogUtils {
dialogListener.setDialog(bonusDialog)
}
fun showupgradevipDialog(ctx: Context){
fun showupgradevipDialog(ctx: Context?){
val weakReference = WeakReference<Context>(ctx)
val bonusDialog = UpgradeVipDialog(weakReference.get()!!)
bonusDialog.show()
......
......@@ -30,6 +30,7 @@
android:src="@mipmap/map_select_icon"
/>
<TextView
android:id="@+id/tv_name"
android:paddingTop="10dp"
app:layout_constraintTop_toBottomOf="@+id/image"
app:layout_constraintStart_toStartOf="parent"
......
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