part of book_pay;

class BookPayController extends GetxController {
  final List<CourseModel> buy;
  BookPayController(this.buy);

  // 支付方式
  List<PayModel> pays =  Platform.isIOS ?[
    PayModel(type: 3, name: '紫荆币', icon: 'assets/images/pay_coin.png', selected: true),
  ]:[
    PayModel(type: 1, name: '微信', icon: 'assets/images/pay_wechat.png', selected: true),
    PayModel(type: 2, name: '支付宝', icon: 'assets/images/pay_ali.png', selected: false),
    PayModel(type: 3, name: '紫荆币', icon: 'assets/images/pay_coin.png', selected: false),
  ];


  // 支付方式
  late PayModel _payModel = pays.first;
  PayModel get payModel => _payModel;

  void setPayModel(PayModel payModel){
    for (PayModel model in pays) {
      if (model.type == payModel.type){
        model.selected = true;
        _payModel = model;
      }
      else{
        model.selected = false;
      }
    }
    update();
  }


  // /// 获取总价
  // ///总价格
  // double get allPrice{
  //   Decimal price = Decimal.zero;
  //   for (CourseModel model in buy) {
  //     if (model.status == 1){
  //       if (model.selected == true){
  //         price = price + Decimal.parse(model.vipPrice??'0.00');
  //       }
  //     }
  //   }
  //   return price.toDouble();
  // }

}