| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522 |
- import 'dart:convert';
- import 'package:bbyyy/beans/ad_bean_entity.dart';
- import 'package:bbyyy/beans/alipay_result_bean_entity.dart';
- import 'package:bbyyy/beans/goods_bean_entity.dart';
- import 'package:bbyyy/beans/my_shop_bean_entity.dart';
- import 'package:bbyyy/beans/pay_by_alipay_bean_entity.dart';
- import 'package:bbyyy/beans/smart_order_bean_entity.dart';
- import 'package:bbyyy/beans/user_balance_entity.dart';
- import 'package:bbyyy/https/MyDio.dart';
- import 'package:bbyyy/https/my_request.dart';
- import 'package:bbyyy/https/url.dart';
- import 'package:bbyyy/my_tools/AsperctRaioImage.dart';
- import 'package:bbyyy/my_tools/const.dart';
- import 'package:bbyyy/my_tools/dims.dart';
- import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
- import 'package:bbyyy/my_tools/event_bus.dart';
- import 'package:bbyyy/my_tools/my_colors.dart';
- import 'package:bbyyy/my_tools/my_cookie.dart';
- import 'package:bbyyy/my_tools/my_tools.dart';
- import 'package:bbyyy/my_tools/my_views.dart';
- import 'package:bbyyy/paegs/gang_page/gang_in_page/gang_in_page.dart';
- import 'package:bbyyy/paegs/mine_page/advertising_page/new_ad_page.dart';
- import 'package:bbyyy/paegs/product_details_page/product_details_page.dart';
- import 'package:bbyyy/pay/pay_tools.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:tobias/tobias.dart';
- class AdDetailsPage extends StatefulWidget {
- AdBeanDataData data;
- bool canBeModified;
- AdDetailsPage(this.data, {this.canBeModified = false});
- @override
- _AdDetailsPageState createState() => _AdDetailsPageState();
- }
- class _AdDetailsPageState extends State<AdDetailsPage> {
- @override
- Widget build(BuildContext context) {
- print(json.encode(widget.data));
- return Scaffold(
- body: Column(
- children: [
- MyViews().myAppBar('广告详情', context, [
- widget.canBeModified
- ? GestureDetector(
- onTap: () {
- MyTools().toPage(context, NewAdPage(widget.data), (then){
- if(then is bool){
- if(!then){
- Navigator.pop(context);
- }
- }
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- padding:
- EdgeInsets.symmetric(vertical: 8, horizontal: 16),
- child: Text(
- '修改',
- style: TextStyle(color: MyColors.c333333, fontSize: 16),
- ),
- ),
- )
- : Container()
- ]),
- Container(
- height: 10,
- color: MyColors.cF7F7F7,
- ),
- Expanded(
- child: SingleChildScrollView(
- child: Column(
- children: [
- MyViews().netImg(
- imgURL(widget.data.coverPath), 314, double.infinity,
- placeholder: 'images/svg/goodsDefImg.svg'),
- Container(
- color: Colors.white,
- width: double.infinity,
- padding: EdgeInsets.fromLTRB(15, 15, 15, 18),
- child: Column(
- children: [
- Container(
- margin: EdgeInsets.only(bottom: 11),
- child: Text(
- '${widget.data.title}',
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 15,
- height: 1.4),
- ),
- ),
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- Container(
- color: Colors.white,
- child: Column(
- children: [
- MyViews().myText('广告描述', MyColors.c333333, 14),
- Container(
- child: MyViews().myText('${widget.data.description}',
- MyColors.c666666, 12),
- margin: EdgeInsets.only(top: 5),
- )
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- alignment: Alignment.centerLeft,
- padding: EdgeInsets.symmetric(horizontal: 14, vertical: 12),
- margin: EdgeInsets.only(top: 5),
- ),
- Container(
- color: Colors.white,
- child: MyViews().myText('广告详情', MyColors.c333333, 14),
- alignment: Alignment.centerLeft,
- margin: EdgeInsets.only(top: 5, bottom: 2),
- padding: EdgeInsets.symmetric(horizontal: 14, vertical: 12),
- ),
- Column(
- children: images(),
- ),
- Container(
- height: 10,
- )
- ],
- ),
- ),
- ),
- Visibility(
- visible: widget.data.linkId != 0 && !widget.canBeModified,
- child: SafeArea(
- top: false,
- child: Container(
- padding: EdgeInsets.symmetric(horizontal: 37),
- color: Colors.white,
- width: double.infinity,
- height: 60,
- child: Row(
- children: [
- Expanded(
- child: GestureDetector(
- onTap: () {
- if (widget.data.linkType == 0) {
- //进入店铺
- enterAShop();
- } else {
- //进入商品
- enterTheProduct();
- }
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(20),
- color: MyColors.cFF4233),
- height: 40,
- child: MyViews().myText(
- widget.data.linkType == 0 ? '查看店铺' : '查看货品',
- Colors.white,
- 14),
- alignment: Alignment.center),
- ),
- )
- ],
- ),
- ),
- ),
- ),
- Visibility(
- visible: !widget.data.paid && widget.canBeModified,
- child: SafeArea(
- top: false,
- child: Container(
- padding: EdgeInsets.symmetric(horizontal: 37),
- color: Colors.white,
- width: double.infinity,
- height: 60,
- child: Row(
- children: [
- Expanded(
- child: GestureDetector(
- onTap: () {
- //支付广告订单
- payForInsertionOrder();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(20),
- color: MyColors.cFF4233),
- height: 40,
- child: MyViews().myText('立即支付', Colors.white, 14),
- alignment: Alignment.center),
- ),
- )
- ],
- ),
- ),
- ),
- )
- ],
- ),
- );
- }
- images() {
- List<Widget> imgs = [];
- widget.data.pictures.split(',').forEach((element) {
- imgs.add(AsperctRaioImage.network(imgURL(element),
- builder: (context, snapshot, url) {
- return MyViews().netImg(
- imgURL(element),
- (snapshot.data.height.toDouble() / 5) /
- (snapshot.data.width.toDouble() / 5) *
- MediaQuery.of(context).size.width,
- MediaQuery.of(context).size.width,
- placeholder: 'images/svg/goodsDefImg.svg');
- }));
- });
- return imgs;
- }
- void enterAShop() {
- MyDio().query({
- "key": "shop_user",
- "filters": {
- "conditions": ["id==${widget.data.linkId}"],
- },
- "dims": shopUserDims,
- "paging": [1, 1],
- "order_by": ["shop_name,DESC"]
- }, (response, hasError) {
- if (!hasError) {
- MyShopBeanEntity entity =
- MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
- MyTools()
- .toPage(context, GangInPage(entity.data.data[0], null), (then) {});
- }
- }, (error) {});
- }
- void enterTheProduct() {
- MyDio().query({
- "key": "commodity",
- "filters": {
- "conditions": ["id == ${widget.data.linkId}"]
- },
- "dims": commodityDims,
- "paging": [1, 1]
- }, (response, hasError) {
- if (!hasError) {
- GoodsBeanEntity entity =
- GoodsBeanEntity().fromJson(json.decode(response.data.toString()));
- MyTools().toPage(
- context, ProductDetailsPage(entity.data.data[0]), (then) {});
- }
- }, (error) {});
- }
- void payForInsertionOrder() {
- MyDio().query({
- 'key': 'order',
- "filters": {
- "conditions": [
- "commodity_id == ${widget.data.id}",
- "type == $orderTypeAdvertise"
- ]
- },
- "dims": orderDims,
- "paging": [1, 1]
- }, (response, hasError) {
- if (!hasError) {
- SmartOrderBeanEntity entity = SmartOrderBeanEntity()
- .fromJson(json.decode(response.data.toString()));
- showPayOrder(entity.data.data[0]);
- }
- }, (error) {});
- }
- void showPayOrder(SmartOrderBeanDataData order) {
- EasyLoading.instance
- ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
- ..alignment = Alignment.bottomCenter
- ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
- double price = order.amount;
- EasyLoading.show(
- indicator: Material(
- color: Colors.white,
- child: Column(
- children: [
- Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- Container(
- child: Image.asset(
- 'images/app_logo.png',
- height: 27,
- width: 27,
- ),
- margin: EdgeInsets.only(right: 8),
- height: 45,
- width: 45,
- decoration: BoxDecoration(
- border: Border.all(color: MyColors.cEBEBEB, width: 1)),
- alignment: Alignment.center,
- ),
- Expanded(
- child: Container(
- height: 45,
- child: Column(
- children: [
- MyViews().myText('广告费', MyColors.c333333, 13),
- Row(
- children: [
- MyViews().myText('¥${price.toStringAsFixed(2)}',
- MyColors.cFF4233, 12),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- ),
- ],
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- MyViews().myText('卖家信息:', MyColors.c333333, 13),
- Row(
- children: [
- Container(
- margin: EdgeInsets.only(right: 5),
- child: ClipRRect(
- child: Image.asset(
- 'images/app_logo.png',
- height: 23,
- width: 23,
- ),
- borderRadius: BorderRadius.circular(11.5),
- ),
- ),
- MyViews().myText('$appName', MyColors.c333333, 13),
- ],
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- MyViews().myText('买家信息:', MyColors.c333333, 13),
- Row(
- children: [
- Container(
- margin: EdgeInsets.only(right: 5),
- child: ClipRRect(
- child: MyViews().netImg(
- imgURL(MyCookie().userBean.picture), 23, 23),
- borderRadius: BorderRadius.circular(11.5),
- ),
- ),
- MyViews().myText(
- '${MyCookie().userBean.name}(${MyCookie().userBean.uid})',
- MyColors.c333333,
- 13),
- ],
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- MyViews().myText('下单时间:', MyColors.c333333, 13),
- MyViews().myText(
- '${DateTime.now().toString().substring(0, 19)}',
- MyColors.c333333,
- 13)
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 20),
- child: Row(
- children: [
- Expanded(
- child: GestureDetector(
- onTap: () {
- EasyLoading.dismiss();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(20),
- bottomLeft: Radius.circular(20),
- ),
- border: Border.all(
- color: MyColors.cFF4233, width: 1)),
- height: 40,
- child: MyViews().myText('稍后支付', MyColors.cFF4233, 14),
- alignment: Alignment.center),
- ),
- ),
- Expanded(
- child: GestureDetector(
- onTap: () {
- getUserWalletBalance((re, hE) {
- if (!hE) {
- UserBalanceEntity balance = UserBalanceEntity()
- .fromJson(json.decode(re.data.toString()));
- if (balance.data >= price) {
- payOrder(payWayWallet, order.uid, (re, hE) {
- if (!hE) {
- showToast('支付成功');
- EventBus().emit('payAnOrder');
- }
- }, (e) {}, context);
- } else {
- payOrder(payWayAliPay, order.uid, (re, hE) {
- if (!hE) {
- PayByAlipayBeanEntity entity =
- PayByAlipayBeanEntity().fromJson(
- json.decode(re.data.toString()));
- EventBus().on('alipayPaymentCallback', (arg) {
- EventBus().off('alipayPaymentCallback');
- EasyLoading.dismiss();
- showToast('支付成功');
- EventBus().emit('reNoPayOrder');
- });
- print(entity.data);
- EasyLoading.instance
- ..contentPadding = EdgeInsets.symmetric(
- horizontal: 20, vertical: 12)
- ..alignment = Alignment.center
- ..contentMargin = EdgeInsets.all(20);
- EasyLoading.show();
- aliPay(entity.data).then((value) {
- print(json.encode(value));
- AlipayResultBeanEntity e =
- AlipayResultBeanEntity().fromJson(
- json.decode(json.encode(value)));
- try {
- int r = int.parse(e.resultStatus);
- if (r == 9000) {
- showToast('支付成功');
- } else {
- showToast(aliPayResultStatus(r));
- resetOrder(order.uid);
- }
- } catch (e) {
- EasyLoading.dismiss();
- }
- });
- // EventBus().emit('payAnOrder');
- }
- }, (e) {}, context);
- // showToast('积分余额不足');
- }
- }
- }, (e) {}, context);
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(20),
- bottomRight: Radius.circular(20),
- ),
- color: MyColors.cFF4233),
- height: 40,
- child: MyViews().myText('立即支付', Colors.white, 14),
- alignment: Alignment.center),
- ),
- )
- ],
- ),
- )
- ],
- ),
- ),
- );
- }
- }
|