Browse Source

1.兑换积分。

shihuiyun 2 years ago
parent
commit
b20cf6d15b

+ 0 - 1
app/src/main/java/com/zswc/creativity/model/MyTibetaDetails.kt

@@ -24,7 +24,6 @@ data class MyTibetaDetails(
                          var resaleStatus:Int,var isDestruction:Int,
                          var authName:String,var memberName: String,
 
-
                          //新增
                          var examplesIllustrate:String,var royalties:String,
                          var serviceFee:String,var contractAddress:String,

+ 1 - 1
app/src/main/java/com/zswc/creativity/model/ProInfo.kt

@@ -14,6 +14,6 @@ data class ProInfo(
         var warmPrompt:String,var authImg:String,var authName:String,var hash:String,
         var contractAddress:String,var status:String,var state:String,var createAt:String,
         var updateAt:String,var companyName:String,var createTime:String,
-         var syState:Int,
+         var syState:Int,var firstTime:String,
 ) : IModel {
 }

+ 43 - 0
app/src/main/java/com/zswc/creativity/utils/PopuSuessTipsUtils.kt

@@ -64,6 +64,49 @@ object  PopuSuessTipsUtils {
 
 
 
+    fun showTo(context:Context, view: View ,choiceData: ChoiceData){
+
+        var mNormalPopup = QMUIPopups.fullScreenPopup(context)
+        val builder: QMUISkinValueBuilder = QMUISkinValueBuilder.acquire()
+        val frameLayout = QMUIFrameLayout(context)
+        //自定义布局
+        val layoutInflater = context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
+        var layout = layoutInflater.inflate(R.layout.popu_suess_tips, null)
+
+        val tvSure:TextView=layout.findViewById(R.id.tv_sure)
+        val tvTips:TextView=layout.findViewById(R.id.tv_tips)
+
+        tvTips.text="恭喜,积分兑换成功!"
+
+
+        tvSure.onClick {
+
+            if(null!=choiceData){
+                choiceData.onRestuse("")
+            }
+            mNormalPopup.dismiss()
+        }
+
+
+        builder.release();
+
+        val size= QMUIDisplayHelper.getScreenWidth(context)
+
+
+        val lp: FrameLayout.LayoutParams = FrameLayout.LayoutParams(size,
+            FrameLayout.LayoutParams.WRAP_CONTENT)
+        frameLayout.addView(layout, lp)
+
+        mNormalPopup.addView(frameLayout)
+        mNormalPopup.onDismiss() {
+        }
+
+        mNormalPopup.dismissIfOutsideTouch(false)
+        mNormalPopup.animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER)
+        mNormalPopup.show(view)
+
+
+    }
 
 
 }

+ 9 - 0
app/src/main/java/com/zswc/creativity/utils/net/ApiService.kt

@@ -348,6 +348,15 @@ interface ApiService {
 
 
     /**
+     * 兑换积分
+     * @return
+     */
+
+    @POST("User_center/conversion")
+    suspend fun openIntegral(@Body body: JSONObject?): Resp<Any>
+
+
+    /**
      *首页banner
      * @return
      */

+ 39 - 0
app/src/main/java/com/zswc/creativity/vmodel/CollectDetailsVModel.kt

@@ -135,6 +135,45 @@ class CollectDetailsVModel(application: Application) : BViewModel<BRepository>(a
     }
 
 
+    fun toComIntegral(){//换积分
+        var inter=data.value?.proInfoObj?.firstTime
+        if(null==data.value?.proInfoObj?.firstTime){
+            inter="0"
+        }
+        if(inter.equals("0")){
+            toast("该藏品不支持兑换积分!")
+            return
+        }
+
+        PopuTipsUtils.show(repository().context!!,"可兑换"+inter+"积分,确认兑换么?",ll!!,object :ChoiceData{
+            override fun onRestuse(type: String?) {
+                var param=JSONObject()
+                param["id"]=id.value
+
+                viewModelScope.launch {
+                    var it=repository().lreq { NetEngine.service.openIntegral(param) }
+                    if(it.ok()){
+
+
+                        PopuSuessTipsUtils.showTo(repository().context!!,ll!!,object : ChoiceData {
+                            override fun onRestuse(id: String?) {
+                                //发消息刷新列表
+                                RxBus.get().post(ConfigRx.REFRESH_ZENG,"")
+
+                                ( ( repository().context) as Activity).finish()
+                            }
+
+                        })
+
+
+                    }
+                }
+
+            }
+        })
+    }
+
+
     fun toOpen(){
 
         PopuTipsUtils.show(repository().context!!,"确定打开盲盒?",ll!!,object : ChoiceData {

+ 4 - 1
app/src/main/java/com/zswc/creativity/vmodel/ConsignOrderListFragmentVModel.kt

@@ -110,7 +110,10 @@ class ConsignOrderListFragmentVModel(application: Application) : BRViewModel<BRR
         param["page"]=repository().page
 
         return {
-            NetEngine.service.getSecondaryOrderListOne(param)
+            NetEngine.service.getSecondaryOrderListOne(JSONObject()
+                .fluentPut("status", state)
+                .fluentPut("page_num", 10)
+                .fluentPut("page", repository().page))
         }
     }
 

+ 9 - 9
app/src/main/java/com/zswc/creativity/vmodel/HomeSaleVModel.kt

@@ -95,15 +95,15 @@ class HomeSaleVModel(application: Application) : BRViewModel<BRRepository>(appli
     override fun apiFunc(): suspend () -> IResp<*> {
 
 
-        var param = JSONObject()
-        param["keyword"] = keyword
-        param["label"] = label
-        param["price_order"] = price_order
-        param["time_order"] = time_order
-        param["type"] = type
-        param["page_num"] = 10
-        param["page"] = repository().page
-        return { NetEngine.service.sellList(param) }
+
+        return { NetEngine.service.sellList(JSONObject()
+            .fluentPut("keyword", keyword)
+            .fluentPut("label", label)
+            .fluentPut("price_order", price_order)
+            .fluentPut("time_order", time_order)
+            .fluentPut("type", type)
+            .fluentPut("page_num", 10)
+            .fluentPut("page", repository().page)) }
 
     }
 

+ 5 - 5
app/src/main/java/com/zswc/creativity/vmodel/MallListVModel.kt

@@ -114,12 +114,12 @@ class MallListVModel(application: Application) : BRViewModel<BRRepository>(appli
 
 
     override fun apiFunc(): suspend () -> IResp<*> {
-        var param= JSONObject()
-        param["type"]=state
-        param["page_num"]=10
-        param["page"]=repository().page
+
         return {
-            NetEngine.service.placeOrderList(param)
+            NetEngine.service.placeOrderList(JSONObject()
+                .fluentPut("type", state)
+                .fluentPut("page_num", 10)
+                .fluentPut("page", repository().page))
         }
     }
 

+ 5 - 4
app/src/main/java/com/zswc/creativity/vmodel/MsgVModel.kt

@@ -10,6 +10,7 @@ import com.zswc.creativity.utils.net.NetEngine
 import com.ysnows.base.base.BRRepository
 import com.ysnows.base.base.BRViewModel
 import com.ysnows.base.net.IResp
+import com.ysnows.base.net.PageResp
 import kotlinx.coroutines.launch
 
 /**
@@ -40,12 +41,12 @@ class MsgVModel(application: Application) : BRViewModel<BRRepository>(applicatio
 
 
     override fun apiFunc(): suspend () -> IResp<*> {
-        var param= JSONObject()
-        param["page_num"]=10
-        param["page"]=repository().page
 
 
-        return { NetEngine.service.msgListPage(param) }
+
+        return { NetEngine.service.msgListPage(JSONObject()
+            .fluentPut("page_num", 10)
+            .fluentPut("page", repository().page)) }
     }
 
 

+ 24 - 15
app/src/main/java/com/zswc/creativity/vmodel/OrderListFragmentVModel.kt

@@ -7,15 +7,12 @@ import android.widget.LinearLayout
 import androidx.lifecycle.MutableLiveData
 import androidx.lifecycle.viewModelScope
 import com.alibaba.fastjson.JSONObject
-import com.hwangjr.rxbus.RxBus
 import com.ysnows.base.base.BRRepository
 import com.ysnows.base.base.BRViewModel
 import com.ysnows.base.net.IResp
 import com.ysnows.base.utils.B
 import com.ysnows.base.utils.UiSwitch
 import com.zswc.creativity.activity.WebViewActivity
-import com.zswc.creativity.config.ConfigRx
-import com.zswc.creativity.fragment.OrderListFragment
 import com.zswc.creativity.inte.ChoiceData
 import com.zswc.creativity.utils.PopuTipsUtils
 import com.zswc.creativity.utils.net.NetEngine
@@ -98,7 +95,7 @@ class OrderListFragmentVModel(application: Application) : BRViewModel<BRReposito
         PopuTipsUtils.show(repository().context!!, "确定删除该订单么?", ll!!, object : ChoiceData {
             override fun onRestuse(id: String?) {
 
-                var param=JSONObject()
+                var param= JSONObject()
                 param["order_no"]=order_no
 
                 viewModelScope.launch {
@@ -148,21 +145,33 @@ class OrderListFragmentVModel(application: Application) : BRViewModel<BRReposito
 
         if(state.equals("-1")){//已转赠
 
-            var param=JSONObject()
-            param["page_num"]=10
-            param["page"]=repository().page
             return {
-                NetEngine.service.getMySendList(param)
+                NetEngine.service.getMySendList(JSONObject()
+                    .fluentPut("page_num", 10)
+                    .fluentPut("page", repository().page))
             }
-        }
+        }else {
+
+
+//            var param = JSONObject()
+//            param["status"] = state
+//            param["page_num"] = 10
+//            param["page"] = repository().page
+
+//            val params = JSONObject()
+//                .fluentPut("status", state)
+//                .fluentPut("page_num", 10)
+//                .fluentPut("page", repository().autoPage())
 
 
-        var param=JSONObject()
-        param["status"]=state
-        param["page_num"]=10
-        param["page"]=repository().page
-        return {
-            NetEngine.service.getMyOrderList(param)
+
+
+            return {
+                NetEngine.service.getMyOrderList(JSONObject()
+                    .fluentPut("status", state)
+                    .fluentPut("page_num", 10)
+                    .fluentPut("page", repository().page))
+            }
         }
     }
 

+ 8 - 8
app/src/main/java/com/zswc/creativity/vmodel/PointsVModel.kt

@@ -152,14 +152,14 @@ class PointsVModel(application: Application) : BRViewModel<BRRepository>(applica
     override fun apiFunc(): suspend () -> IResp<*> {
 
 
-        var param = JSONObject()
-        param["keyword"] = keyword
-        param["label_id"] = label_id
-        param["price_order"] = price_order
-        param["time_order"] = time_order
-        param["page_num"] = 10
-        param["page"] = repository().page
-        return { NetEngine.service.shoppingList(param) }
+
+        return { NetEngine.service.shoppingList(JSONObject()
+            .fluentPut("keyword", keyword)
+            .fluentPut("label_id", label_id)
+            .fluentPut("price_order", price_order)
+            .fluentPut("time_order", time_order)
+            .fluentPut("page_num", 10)
+            .fluentPut("page", repository().page)) }
 
     }
 

+ 3 - 4
app/src/main/java/com/zswc/creativity/vmodel/RecorRankVModel.kt

@@ -22,12 +22,11 @@ class RecorRankVModel(application: Application) : BRViewModel<BRRepository>(appl
 
     override fun apiFunc(): suspend () -> IResp<*> {
 
-        var  param= JSONObject()
-        param["page_num"]=10
-        param["page"]=repository().page
 
         return {
-            NetEngine.service.invitedList(param)
+            NetEngine.service.invitedList(JSONObject()
+                .fluentPut("page_num", 10)
+                .fluentPut("page", repository().page))
         }
     }
 

+ 3 - 4
app/src/main/java/com/zswc/creativity/vmodel/RecordListFragmentVModel.kt

@@ -21,12 +21,11 @@ class RecordListFragmentVModel(application: Application) : BRViewModel<BRReposit
 
     override fun apiFunc(): suspend () -> IResp<*> {
 
-        var  param=JSONObject()
-        param["page_num"]=10
-        param["page"]=repository().page
 
         return {
-            NetEngine.service.invitedRecord(param)
+            NetEngine.service.invitedRecord(JSONObject()
+                .fluentPut("page_num", 10)
+                .fluentPut("page", repository().page))
         }
     }
 

+ 5 - 5
app/src/main/java/com/zswc/creativity/vmodel/SaleListFragmentVModel.kt

@@ -71,12 +71,12 @@ class SaleListFragmentVModel(application: Application) : BRViewModel<BRRepositor
 
     override fun apiFunc(): suspend () -> IResp<*> {
 
-        var param= JSONObject()
-        param["status"]=state
-        param["page_num"]=10
-        param["page"]=repository().page
+
         return {
-            NetEngine.service.getMyOrderList(param)
+            NetEngine.service.getMyOrderList(JSONObject()
+                .fluentPut("status", state)
+                .fluentPut("page_num", 10)
+                .fluentPut("page", repository().page))
         }
     }
 

+ 5 - 5
app/src/main/java/com/zswc/creativity/vmodel/SellOrderListVModel.kt

@@ -87,12 +87,12 @@ class SellOrderListVModel(application: Application) : BRViewModel<BRRepository>(
 
 
     override fun apiFunc(): suspend () -> IResp<*> {
-        var param=JSONObject()
-        param["status"]=state
-        param["page_num"]=10
-        param["page"]=repository().page
+
         return {
-            NetEngine.service.getSecondaryOrderLisTwo(param)
+            NetEngine.service.getSecondaryOrderLisTwo(JSONObject()
+                .fluentPut("status", state)
+                .fluentPut("page_num", 10)
+                .fluentPut("page", repository().page))
         }
     }
 

BIN
app/src/main/res/drawable-xxhdpi/ct_bottom_intel.png


+ 56 - 3
app/src/main/res/layout/activity_collect_details.xml

@@ -597,11 +597,14 @@
                 </LinearLayout>
 
 
+
+
+
                 <LinearLayout
                     android:id="@+id/ll_given"
                     android:layout_width="wrap_content"
                     android:layout_height="match_parent"
-                    android:layout_marginStart="63dp"
+                    android:layout_marginStart="30dp"
                     android:gravity="center"
                     android:onClick="@{v->vm.toGiven()}"
                     android:orientation="vertical">
@@ -621,6 +624,30 @@
 
                 </LinearLayout>
 
+                <LinearLayout
+
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_marginStart="30dp"
+                    android:gravity="center"
+                    android:onClick="@{v->vm.toComIntegral()}"
+                    android:orientation="vertical">
+
+                    <ImageView
+                        android:layout_width="22dp"
+                        android:layout_height="22dp"
+                        android:src="@drawable/ct_bottom_intel" />
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginTop="2dp"
+                        android:text="兑换积分"
+                        android:textColor="@color/text_title"
+                        android:textSize="10sp" />
+
+                </LinearLayout>
+
 
                 <View
                     android:layout_width="0dp"
@@ -628,7 +655,7 @@
                     android:layout_weight="1" />
 
                 <TextView
-                    android:layout_width="180dp"
+                    android:layout_width="120dp"
                     android:layout_height="36dp"
                     android:layout_marginEnd="25dp"
                     android:background="@drawable/bg_six_but"
@@ -751,6 +778,8 @@
 
                     </LinearLayout>
 
+
+
                     <LinearLayout
 
                         android:layout_width="wrap_content"
@@ -800,6 +829,30 @@
 
                     </LinearLayout>
 
+                    <LinearLayout
+
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_marginStart="30dp"
+                        android:gravity="center"
+                        android:onClick="@{v->vm.toComIntegral()}"
+                        android:orientation="vertical">
+
+                        <ImageView
+                            android:layout_width="22dp"
+                            android:layout_height="22dp"
+                            android:src="@drawable/ct_bottom_intel" />
+
+                        <TextView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:layout_marginTop="2dp"
+                            android:text="兑换积分"
+                            android:textColor="@color/text_title"
+                            android:textSize="10sp" />
+
+                    </LinearLayout>
+
 
                     <View
                         android:layout_width="0dp"
@@ -807,7 +860,7 @@
                         android:layout_weight="1" />
 
                     <TextView
-                        android:layout_width="180dp"
+                        android:layout_width="120dp"
                         android:layout_height="36dp"
                         android:layout_marginEnd="25dp"
                         android:background="@drawable/bg_six_but"

+ 1 - 0
app/src/main/res/layout/popu_suess_tips.xml

@@ -25,6 +25,7 @@
             android:src="@drawable/ct_pay_suess" />
 
         <TextView
+            android:id="@+id/tv_tips"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="center_horizontal"

+ 55 - 46
base/src/main/java/com/ysnows/base/base/BRRepository.kt

@@ -38,8 +38,8 @@ open class BRRepository : BRepository() {
      * */
 
     private suspend fun <T : IResp<*>> reqList(
-            pageLoading: Boolean = true,
-            func: suspend () -> T
+        pageLoading: Boolean = true,
+        func: suspend () -> T
     ): T {
 
         try {
@@ -58,21 +58,26 @@ open class BRRepository : BRepository() {
                         view().refreshing(false)
                     }
                 }
-                bView.toLogin()
-                // bView.processCodeOffline()
+                if(resp.isLogin()==-1) {
+                    bView.toLogin()
+                }
+                //  bView.processCodeOffline()
             } else {
 
                 if (page <= 1) {
-                    if (resp.empty()) {
+                    if (resp.empty()) { //如果没有数据
 
                         view().loadService?.showCallback(EmptyCallback::class.java)
 
-                    } else {
-                        if (resp is PageResp<*>) {
+//                        if (pageLoading) {//列表还未有数据
+//
+//                            view().loadService?.showCallback(EmptyCallback::class.java)
+//                        }
 
 
+                    } else {
+                        if (resp is PageResp<*>) {
                             view().adapter().setList(resp.data()?.records as Collection<Nothing>)
-
                         } else {
                             view().adapter().setList(resp.data() as Collection<Nothing>)
                         }
@@ -110,7 +115,7 @@ open class BRRepository : BRepository() {
         } catch (e: Exception) {
             e.printStackTrace()
 
-            Log.e("shy", "e=: " + e)
+            Log.e("shy", "e=: "+e )
             when {
                 pageLoading -> {
                     bView.loadService?.showCallback(TimeoutCallback::class.java)
@@ -131,8 +136,8 @@ open class BRRepository : BRepository() {
 
 
             return Resp<Any>(
-                    NetCode.CODE_EXCEPTION,
-                    message = ExceptionUtils.getExceptionName(e)
+                NetCode.CODE_EXCEPTION,
+                message  = ExceptionUtils.getExceptionName(e)
             ) as T
         }
     }
@@ -150,8 +155,8 @@ open class BRRepository : BRepository() {
 
 
     fun rxReqFirstPage(
-            api: Observable<IResp<Collection<Any>>>,
-            pagable: Boolean
+        api: Observable<IResp<Collection<Any>>>,
+        pagable: Boolean
     ): Observable<IResp<Collection<Any>>> {
         this.api = api;
         page = 1
@@ -170,50 +175,50 @@ open class BRRepository : BRepository() {
 
     @SuppressLint("CheckResult")
     fun rxReqList(
-            observable: Observable<IResp<Collection<Any>>>,
-            pageLoading: Boolean
+        observable: Observable<IResp<Collection<Any>>>,
+        pageLoading: Boolean
     ): Observable<IResp<Collection<Any>>> {
         return Observable.create { emitter: ObservableEmitter<IResp<Collection<Any>>> ->
             rxReq(observable, pageLoading, false)
-                    .doOnError { throwable: Throwable ->
-                        throwable.printStackTrace()
-                        if (page >= 1) {
-                            view().adapter().loadMoreModule.loadMoreFail()
-                            page -= 1
-                        }
-                        emitter.onError(throwable)
+                .doOnError { throwable: Throwable ->
+                    throwable.printStackTrace()
+                    if (page >= 1) {
+                        view().adapter().loadMoreModule.loadMoreFail()
+                        page -= 1
                     }
-                    .subscribe({ res: IResp<Collection<Any>> ->
-                        view().onListReceive(res)
-                        if (page <= 1) {
-                            if (res.empty()) { //如果没有数据
-                                view().refreshing(false)
-                                view().loadService!!.showCallback(EmptyCallback::class.java)
-                            } else {
-                                view().refreshing(false)
-                                //Object data = res.data();
+                    emitter.onError(throwable)
+                }
+                .subscribe({ res: IResp<Collection<Any>> ->
+                    view().onListReceive(res)
+                    if (page <= 1) {
+                        if (res.empty()) { //如果没有数据
+                            view().refreshing(false)
+                            view().loadService!!.showCallback(EmptyCallback::class.java)
+                        } else {
+                            view().refreshing(false)
+                            //Object data = res.data();
 //                                if (data instanceof IResultList) {
 //                                    adapter.setList(((IResultList) data).list());
 //                                }
-                                view().adapter().setList(res.data() as Collection<Nothing>)
-                                view().loadService!!.showSuccess()
-                            }
-                            view().getTotal(res.total())
-                        } else {
+                            view().adapter().setList(res.data() as Collection<Nothing>)
+                            view().loadService!!.showSuccess()
+                        }
+                        view().getTotal(res.total())
+                    } else {
 //                            Object data = res.data();
 //                            if (data instanceof IResultList) {
 //                                view().getAdapter().addData((((IResultList) data).list()));
 //                            }
-                            view().adapter().addData(res.data() as Collection<Nothing>)
-                        }
-                        if (res.more(page)) {
-                            view().adapter().loadMoreModule.loadMoreComplete()
-                        } else {
-                            //数据全部加载完毕
-                            view().adapter().loadMoreModule.loadMoreEnd()
-                        }
-                        emitter.onNext(res)
-                    }, { throwable: Throwable? -> }) { emitter.onComplete() }
+                        view().adapter().addData(res.data() as Collection<Nothing>)
+                    }
+                    if (res.more(page)) {
+                        view().adapter().loadMoreModule.loadMoreComplete()
+                    } else {
+                        //数据全部加载完毕
+                        view().adapter().loadMoreModule.loadMoreEnd()
+                    }
+                    emitter.onNext(res)
+                }, { throwable: Throwable? -> }) { emitter.onComplete() }
         }
     }
 
@@ -221,4 +226,8 @@ open class BRRepository : BRepository() {
         page += 1
         return page
     }
+
+
+
+
 }

+ 1 - 0
common-build.gradle

@@ -84,6 +84,7 @@ dependencies {
 
 
 
+
     //普通版本
 //    implementation 'cn.yc:WebViewLib:1.2.4'