TibetanDetailsVModel.kt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package com.zswc.creativity.vmodel
  2. import android.app.Application
  3. import android.text.TextUtils
  4. import android.view.View
  5. import android.widget.LinearLayout
  6. import androidx.lifecycle.MutableLiveData
  7. import androidx.lifecycle.viewModelScope
  8. import com.ysnows.base.base.BRepository
  9. import com.ysnows.base.base.BViewModel
  10. import com.zswc.creativity.model.TibetaDetails
  11. import com.zswc.creativity.utils.PopuBuyUtils
  12. import com.zswc.creativity.utils.PopuShareWxUtils
  13. import com.zswc.creativity.utils.net.NetEngine
  14. import kotlinx.coroutines.launch
  15. class TibetanDetailsVModel(application: Application) : BViewModel<BRepository>(application) {
  16. var ll: LinearLayout? = null
  17. var data= MutableLiveData<TibetaDetails>()
  18. //倒计时
  19. var isUp = true
  20. var time = MutableLiveData<String>()
  21. fun getInfo(id:String){
  22. viewModelScope.launch {
  23. var it=repository().lreq { NetEngine.service.CollectionDetail(id) }
  24. if(it.ok()){
  25. data.value=it.data
  26. }
  27. }
  28. }
  29. fun toBuy(view :View){//支付弹框
  30. PopuBuyUtils.show(repository().context!!, view)
  31. }
  32. fun getUrl() {
  33. // viewModelScope.launch {
  34. // var it = repository().lreq { NetEngine.service.getAppCode(k_id, "1") }
  35. // if (it.ok()) {
  36. //
  37. // toShareCode(it.datas?.appcode)
  38. //
  39. // }
  40. // }
  41. //测试
  42. toShareCode("https://img.chuangchi.vip/nft/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20220704134149.jpg20220704014839.jpg?time=1658644985996")
  43. }
  44. fun toShareCode(shareUrl: String?) {
  45. if (TextUtils.isEmpty(shareUrl)) {
  46. return
  47. }
  48. PopuShareWxUtils.show(repository().context!!, shareUrl!!, ll!!,repository().context!!.contentResolver)
  49. }
  50. }