|
@@ -7,17 +7,23 @@ import android.widget.EditText
|
|
|
import androidx.fragment.app.viewModels
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
|
|
import com.google.gson.Gson
|
|
|
+import com.hboxs.serialport.sbc.SBCHeartbeat
|
|
|
import com.module.backstage.R
|
|
|
import com.module.backstage.adapter.PriceAdapter
|
|
|
import com.module.backstage.databinding.BackstageFragmentPriceBinding
|
|
|
import com.module.backstage.vm.PriceFragmentVM
|
|
|
import com.quyunshuo.sbm10.base.utils.SpUtils
|
|
|
+import com.quyunshuo.sbm10.common.constant.Heartbeat
|
|
|
import com.quyunshuo.sbm10.common.constant.MMKVName
|
|
|
+import com.quyunshuo.sbm10.common.constant.event.ApiMessageEvent
|
|
|
import com.quyunshuo.sbm10.common.listener.AdapterClickListener
|
|
|
import com.quyunshuo.sbm10.common.ui.BaseFragment
|
|
|
import com.quyunshuo.sbm10.common.util.ToastUtil
|
|
|
import com.quyunshuo.sbm10.common.util.UiUtil
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
+import org.json.JSONArray
|
|
|
+import org.json.JSONObject
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -64,8 +70,34 @@ class PriceFragment : BaseFragment<BackstageFragmentPriceBinding, PriceFragmentV
|
|
|
}
|
|
|
}
|
|
|
val toJson = Gson().toJson(priceAdapter?.productList)
|
|
|
- Log.d(TAG, "toJson : "+toJson)
|
|
|
SpUtils.putString(MMKVName.PRODUCT_DATA, toJson)
|
|
|
+ Log.d(TAG, "toJson : "+toJson)
|
|
|
+ val jsonArray = JSONArray(toJson)
|
|
|
+ for (i in 0 until jsonArray.length()) {
|
|
|
+ val jsonObject = jsonArray.getJSONObject(i)
|
|
|
+ val price = jsonObject.getDouble("price") // 获取 price 值
|
|
|
+ val productNo = jsonObject.getString("productNo") // 获取 price 值
|
|
|
+ val sellStatus = jsonObject.getBoolean("isSelected") // 获取 price 值
|
|
|
+ var productName = jsonObject.getString("customName") // 获取 price 值
|
|
|
+ if (productName==""){
|
|
|
+ productName = UiUtil.getStringRes(R.string.base_pro_02)
|
|
|
+ }
|
|
|
+ val name = jsonObject.getString("nameChinese") // 获取 price 值
|
|
|
+// val newArray = JSONArray()
|
|
|
+ val newPrice = JSONObject()
|
|
|
+ newPrice.put("codePrice", price) // 价格
|
|
|
+ newPrice.put("productName", productName)// 自定义名字
|
|
|
+ newPrice.put("name", name) // 默认名字
|
|
|
+ newPrice.put("rmbPrice",price) // 价格
|
|
|
+ newPrice.put("sellStatus", sellStatus) // 商品显示
|
|
|
+ newPrice.put("no", productNo) // 商品编号
|
|
|
+ // 将新对象添加到新数组中
|
|
|
+// newArray.put(newPrice)
|
|
|
+// Log.d(TAG, "initViewnewArray: "+newArray)
|
|
|
+// Log.d(TAG, "newArrayinitView:1 "+newArray)
|
|
|
+ Log.d(TAG, "newArrayinitView:2 "+newPrice)
|
|
|
+ EventBus.getDefault().post(ApiMessageEvent(MMKVName.PRICE, newPrice))
|
|
|
+ }
|
|
|
ToastUtil.switchToastStyleToSuccess(UiUtil.getStringRes(R.string.backstage_update_success))
|
|
|
priceAdapter?.notifyDataSetChanged()
|
|
|
}
|