part of user_order_evaluate;


/// 订单评价
class UserOrderEvaluateController extends GetxController {
  OrderInfoModel orderInfoModel;
  String  orderNum;
  UserOrderEvaluateController(this.orderNum,this.orderInfoModel); // 已完成订单

  // 按钮是否可用
  bool  _enable = false;
  bool get enable => _enable;


  @override
  void onReady() {
    getOrderInfo();
    super.onReady();
  }

  /// 获取订单信息
  Future<void> getOrderInfo() async {
    orderInfoModel = await MineAPI.getOrderInfo(orderNum: orderNum);
    update();
  }

  /// 上传评价
  void UpOrderEvaluate(String evaluate) async {
    final result = await MineAPI.UpOrderEvaluate(evaluate: evaluate);
    if (result) {
      Toast.show('评价成功');
      update();
    }
  }

  void setCanClick(num double){
    if (double > 0){
      _enable = true;
    }
    else{
      _enable = false;
    }
    update();
  }
}
