| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254 |
- import 'dart:convert';
- import 'dart:io';
- import 'package:bbyyy/beans/ad_bean_entity.dart';
- import 'package:bbyyy/beans/ad_pricing_bean_entity.dart';
- import 'package:bbyyy/beans/annual_fee_order_bean_entity.dart';
- import 'package:bbyyy/beans/goods_bean_entity.dart';
- import 'package:bbyyy/beans/my_shop_bean_entity.dart';
- import 'package:bbyyy/beans/upload_image_bean_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/dims.dart';
- import 'package:bbyyy/my_tools/easy_loading/easy_loading.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/pay_page/pay_page.dart';
- import 'package:flustars/flustars.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_svg/svg.dart';
- import 'associated_store_page.dart';
- import 'related_products_page.dart';
- class NewAdPage extends StatefulWidget {
- AdBeanDataData data;
- NewAdPage(this.data);
- @override
- _NewAdPageState createState() => _NewAdPageState();
- }
- class _NewAdPageState extends State<NewAdPage> {
- TextEditingController _title = TextEditingController();
- TextEditingController _description = TextEditingController();
- TextEditingController _days = TextEditingController();
- List<DropdownMenuItem<String>> sortItems = [];
- List<AdPricingBeanData> pricing = [];
- String typeValue = '';
- int typeIndex = 0;
- File cover;
- String coverPath = '';
- String picturesPath = '';
- List<File> pictures = [null, null, null];
- int associationType = -1;
- String startTime = '请选择时间';
- DateTime startDate;
- MyShopBeanDataData shop;
- GoodsBeanDataData product;
- int status;
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- if (widget.data != null) {
- if (widget.data.paid == false) {
- status = 1;
- } else {
- var sT = DateTime.parse(widget.data.startDate);
- var eT = sT.add(Duration(days: widget.data.days));
- if (sT.isBefore(DateTime.now()) && eT.isAfter(DateTime.now())) {
- status = 0;
- } else if (sT.isAfter(DateTime.now())) {
- status = 3;
- } else if (eT.isBefore(DateTime.now())) {
- status = 2;
- }
- }
- }
- Future.delayed(Duration.zero, () {
- advertisingPricing((re, hE) {
- if (!hE) {
- AdPricingBeanEntity entity =
- AdPricingBeanEntity().fromJson(json.decode(re.data.toString()));
- if (entity.data.isEmpty) {
- return;
- }
- pricing = entity.data;
- typeValue = entity.data[0].type == 0 ? '货帮/商品部分广告' : '首页banner';
- typeIndex = entity.data[0].type;
- entity.data.forEach((element) {
- sortItems.add(DropdownMenuItem(
- child: Container(
- child: Text(
- element.type == 0 ? '货帮/商品部分广告' : '首页banner',
- style: TextStyle(color: MyColors.c333333, fontSize: 15),
- textAlign: TextAlign.end,
- ),
- alignment: Alignment.centerRight,
- width: 150,
- ),
- value: element.type == 0 ? '货帮/商品部分广告' : '首页banner',
- ));
- });
- if (widget.data != null) {
- initAd();
- }
- setState(() {});
- }
- });
- });
- }
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: () {
- MyTools().hideKeyboard(context);
- },
- behavior: HitTestBehavior.translucent,
- child: Scaffold(
- backgroundColor: MyColors.cF7F7F7,
- body: Column(
- children: [
- MyViews().myAppBar('发布广告', context, []),
- Container(
- height: 10,
- color: MyColors.cF7F7F7,
- ),
- Expanded(
- child: SingleChildScrollView(
- child: Column(
- children: [
- Container(
- color: Colors.white,
- child: Column(
- children: [
- //广告标题
- Container(
- padding: EdgeInsets.all(16),
- child: aboutRow([
- MyViews().myText('广告标题', MyColors.c333333, 15),
- Expanded(
- child: Container(
- alignment: Alignment.centerRight,
- child: TextField(
- textAlign: TextAlign.end,
- controller: _title,
- cursorColor: MyColors.cFF4233,
- cursorWidth: 1.0,
- onTap: () {},
- decoration: InputDecoration(
- border: InputBorder.none,
- disabledBorder: InputBorder.none,
- enabledBorder: InputBorder.none,
- focusedBorder: InputBorder.none,
- isDense: true,
- hintText: '请输入',
- hintStyle: TextStyle(
- color: MyColors.c999999,
- fontSize: 15),
- contentPadding: const EdgeInsets.fromLTRB(
- 14, 4.5, 8, 4.5),
- ),
- maxLines: 1,
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 15,
- height: 1.3,
- letterSpacing: 0.2),
- keyboardType: TextInputType.text,
- onChanged: (t) {},
- ),
- ),
- ),
- ]),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 16),
- ),
- //首页图片
- Container(
- padding: EdgeInsets.all(16),
- child: aboutRow([
- MyViews().myText('首页图片', MyColors.c333333, 15),
- GestureDetector(
- onTap: () async {
- cover = await selectImage();
- setState(() {});
- },
- behavior: HitTestBehavior.translucent,
- child: getCover(),
- )
- ]),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 16),
- ),
- //广告类型
- Container(
- padding: EdgeInsets.symmetric(
- horizontal: 16,
- vertical:
- widget.data == null || !widget.data.paid
- ? 4
- : 16),
- child: aboutRow([
- MyViews().myText('广告类型', MyColors.c333333, 15),
- widget.data == null || !widget.data.paid
- ? DropdownButtonHideUnderline(
- child: DropdownButton(
- items: sortItems,
- onChanged: (value) {
- setState(() {
- typeValue = value;
- });
- },
- value: typeValue,
- ),
- )
- : MyViews()
- .myText(typeValue, MyColors.c333333, 15),
- ]),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 16),
- ),
- //开始投放时间
- Container(
- padding: EdgeInsets.all(16),
- child: aboutRow([
- MyViews().myText('开始投放时间', MyColors.c333333, 15),
- GestureDetector(
- onTap: () async {
- if (widget.data == null ||
- !widget.data.paid) {
- var result = await showDatePicker(
- context: context,
- initialDate: DateTime.now(),
- firstDate: DateTime.now(),
- lastDate: DateTime.now()
- .add(Duration(days: 500)),
- );
- setState(() {
- startTime =
- result.toString().substring(0, 10);
- startDate = result;
- });
- }
- },
- behavior: HitTestBehavior.translucent,
- child: MyViews()
- .myText(startTime, MyColors.c333333, 15),
- ),
- ]),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 16),
- ),
- //停止投放时间
- Container(
- padding: EdgeInsets.all(16),
- child: aboutRow([
- MyViews().myText('投放天数', MyColors.c333333, 15),
- Expanded(
- child: Container(
- alignment: Alignment.centerRight,
- child: TextField(
- enabled: widget.data == null ||
- !widget.data.paid,
- inputFormatters: [
- FilteringTextInputFormatter.allow(
- RegExp("[0-9]")),
- ],
- textAlign: TextAlign.end,
- controller: _days,
- cursorColor: MyColors.cFF4233,
- cursorWidth: 1.0,
- onTap: () {},
- decoration: InputDecoration(
- border: InputBorder.none,
- disabledBorder: InputBorder.none,
- enabledBorder: InputBorder.none,
- focusedBorder: InputBorder.none,
- isDense: true,
- hintText: '请输入天数',
- hintStyle: TextStyle(
- color: MyColors.c999999,
- fontSize: 15),
- contentPadding: const EdgeInsets.fromLTRB(
- 14, 4.5, 8, 4.5),
- ),
- maxLines: 1,
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 15,
- height: 1.3,
- letterSpacing: 0.2),
- keyboardType: TextInputType.number,
- onChanged: (t) {},
- ),
- ),
- ),
- ]),
- ),
- Container(
- height: 10,
- color: MyColors.cF7F7F7,
- ),
- //详情描述
- Container(
- padding: EdgeInsets.all(16),
- child: aboutRow([
- MyViews().myText('详情描述', MyColors.c333333, 15),
- ]),
- ),
- Container(
- margin: EdgeInsets.only(
- left: 15, right: 15, bottom: 15),
- constraints: BoxConstraints(minHeight: 86),
- decoration: BoxDecoration(
- border:
- Border.all(color: MyColors.cE7E7E7, width: 1),
- borderRadius: BorderRadius.all(
- Radius.circular(4),
- ),
- ),
- child: TextField(
- controller: _description,
- cursorColor: MyColors.cFF4233,
- maxLines: null,
- cursorWidth: 1.0,
- onTap: () {},
- decoration: InputDecoration(
- border: InputBorder.none,
- disabledBorder: InputBorder.none,
- enabledBorder: InputBorder.none,
- focusedBorder: InputBorder.none,
- isDense: true,
- hintText: '请输入',
- hintStyle: TextStyle(
- color: MyColors.c999999, fontSize: 14),
- contentPadding:
- const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5),
- ),
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 14,
- height: 1.3,
- letterSpacing: 0.2),
- keyboardType: TextInputType.text,
- onChanged: (t) {},
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 16),
- ),
- //详情图片
- Container(
- padding: EdgeInsets.all(16),
- child: aboutRow([
- MyViews().myText('详情图片', MyColors.c333333, 15),
- ]),
- ),
- Container(
- margin: EdgeInsets.only(
- left: 15, right: 15, bottom: 17),
- child: Row(
- children: [
- GestureDetector(
- onTap: () async {
- pictures[0] =
- await selectImage(isCover: false);
- setState(() {});
- },
- behavior: HitTestBehavior.translucent,
- child: getP1(),
- ),
- GestureDetector(
- onTap: () async {
- pictures[1] =
- await selectImage(isCover: false);
- setState(() {});
- },
- behavior: HitTestBehavior.translucent,
- child: getP2(),
- ),
- GestureDetector(
- onTap: () async {
- pictures[2] =
- await selectImage(isCover: false);
- setState(() {});
- },
- behavior: HitTestBehavior.translucent,
- child: getP3(),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- Container(
- height: 10,
- color: MyColors.cF7F7F7,
- ),
- //广告关联类型
- Container(
- padding: EdgeInsets.symmetric(
- horizontal: 16, vertical: 4),
- child: aboutRow([
- MyViews().myText('广告关联类型', MyColors.c333333, 15),
- Row(
- children: [
- Checkbox(
- activeColor: MyColors.cFF4233,
- value: associationType == 0,
- onChanged: (v) {
- shop = null;
- product = null;
- setState(() {
- if (v) {
- associationType = 0;
- } else {
- associationType = -1;
- }
- });
- }),
- MyViews().myText('货帮', MyColors.c333333, 15),
- Checkbox(
- activeColor: MyColors.cFF4233,
- value: associationType == 1,
- onChanged: (v) {
- setState(() {
- if (v) {
- associationType = 1;
- } else {
- associationType = -1;
- }
- });
- }),
- MyViews().myText('商品', MyColors.c333333, 15),
- ],
- ),
- ]),
- ),
- //关联
- Visibility(
- visible: associationType != -1,
- child: Column(
- children: [
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 16),
- ),
- Container(
- padding: EdgeInsets.all(16),
- child: aboutRow([
- MyViews().myText(
- associationType == 0 ? '关联货帮' : '关联商品',
- MyColors.c333333,
- 15),
- GestureDetector(
- onTap: () {
- MyTools().hideKeyboard(context);
- MyTools().toPage(
- context,
- associationType == 0
- ? AssociatedStorePage()
- : RelatedProductsPage(),
- (then) {
- if (then is MyShopBeanDataData) {
- shop = then;
- setState(() {});
- }
- if (then is GoodsBeanDataData) {
- product = then;
- setState(() {});
- }
- });
- },
- behavior: HitTestBehavior.translucent,
- child: associatedView()),
- ]),
- ),
- ],
- ),
- ),
- Container(
- height: 10,
- color: MyColors.cF7F7F7,
- ),
- GestureDetector(
- onTap: () {
- uploadCover();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 50,
- child: MyViews().myText(
- widget.data == null ? '发 布' : '保 存',
- MyColors.cFF4233,
- 16),
- alignment: Alignment.center,
- ),
- ),
- Container(
- height: 10,
- color: MyColors.cF7F7F7,
- ),
- Visibility(
- visible: status == 1 || status == 2,
- child: GestureDetector(
- onTap: () {
- showSimpleDialog('确认删除此广告?', context, () {
- Navigator.pop(context);
- deleteAD(widget.data);
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 50,
- child: MyViews()
- .myText('删 除', MyColors.cFF4233, 16),
- alignment: Alignment.center,
- ),
- ),
- ),
- Container(
- height: 50,
- color: MyColors.cF7F7F7,
- ),
- ],
- ),
- )
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- );
- }
- Widget aboutRow(List<Widget> ws) {
- return Row(
- children: ws,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- );
- }
- associatedView() {
- if (associationType == 0) {
- if (shop == null) {
- return MyViews().myText('选择关联货帮', MyColors.c333333, 15);
- } else {
- return Row(
- children: [
- ClipRRect(
- child: MyViews().netImg(imgURL(shop.shopPic), 24, 24),
- borderRadius: BorderRadius.circular(12),
- ),
- Container(
- child: MyViews().myText(shop.shopName, MyColors.c333333, 15),
- margin: EdgeInsets.only(left: 8),
- )
- ],
- );
- }
- } else {
- if (product == null) {
- return MyViews().myText('选择关联商品', MyColors.c333333, 15);
- } else {
- return Row(
- children: [
- ClipRRect(
- child: MyViews().netImg(imgURL(product.coverPath), 24, 24),
- borderRadius: BorderRadius.circular(12),
- ),
- Container(
- child: MyViews().myText(product.title, MyColors.c333333, 15),
- margin: EdgeInsets.only(left: 8),
- )
- ],
- );
- }
- }
- }
- void uploadCover() {
- if (_title.text.isEmpty) {
- showToast('请填写标题');
- return;
- }
- if (cover == null && coverPath == '') {
- showToast('请选择首页图片');
- return;
- }
- if (startTime == '请选择时间') {
- showToast('请选择时间');
- return;
- }
- if (_days.text.isEmpty) {
- showToast('请填写投放天数');
- return;
- }
- if (_description.text.isEmpty) {
- showToast('请填写描述');
- return;
- }
- EasyLoading.instance
- ..contentPadding = EdgeInsets.symmetric(horizontal: 20, vertical: 12)
- ..alignment = Alignment.center
- ..loadingStyle = EasyLoadingStyle.light
- ..contentMargin = EdgeInsets.all(20);
- EasyLoading.show();
- print('uploadCover');
- if (cover == null) {
- uploadPictureOne();
- } else {
- upload(cover, (r, hE) {
- if (!hE) {
- UploadImageBeanEntity data =
- UploadImageBeanEntity().fromJson(json.decode(r.data.toString()));
- coverPath = data.data[0].path;
- uploadPictureOne();
- } else {
- EasyLoading.dismiss();
- }
- }, (e) {
- EasyLoading.dismiss();
- });
- }
- }
- void uploadPictureOne() {
- if (pictures[0] != null) {
- upload(pictures[0], (r, hE) {
- if (!hE) {
- UploadImageBeanEntity data =
- UploadImageBeanEntity().fromJson(json.decode(r.data.toString()));
- if (picturesPath == '') {
- picturesPath = data.data[0].path;
- } else {
- picturesPath = picturesPath + ',' + data.data[0].path;
- }
- uploadPictureTwo();
- } else {
- EasyLoading.dismiss();
- }
- }, (e) {
- EasyLoading.dismiss();
- });
- } else {
- if (p1 != '') {
- if (picturesPath == '') {
- picturesPath = p1;
- } else {
- picturesPath = picturesPath + ',' + p1;
- }
- }
- uploadPictureTwo();
- }
- }
- void uploadPictureTwo() {
- print('uploadPictureTwo');
- if (pictures[1] != null) {
- upload(pictures[1], (r, hE) {
- if (!hE) {
- UploadImageBeanEntity data =
- UploadImageBeanEntity().fromJson(json.decode(r.data.toString()));
- if (picturesPath == '') {
- picturesPath = data.data[0].path;
- } else {
- picturesPath = picturesPath + ',' + data.data[0].path;
- }
- uploadPictureThree();
- } else {
- EasyLoading.dismiss();
- }
- }, (e) {
- EasyLoading.dismiss();
- });
- } else {
- if (p2 != '') {
- if (picturesPath == '') {
- picturesPath = p2;
- } else {
- picturesPath = picturesPath + ',' + p2;
- }
- }
- uploadPictureThree();
- }
- }
- void uploadPictureThree() {
- print('uploadPictureThree');
- if (pictures[2] != null) {
- upload(pictures[2], (r, hE) {
- if (!hE) {
- UploadImageBeanEntity data =
- UploadImageBeanEntity().fromJson(json.decode(r.data.toString()));
- if (picturesPath == '') {
- picturesPath = data.data[0].path;
- } else {
- picturesPath = picturesPath + ',' + data.data[0].path;
- }
- if (widget.data != null) {
- updateAd();
- } else {
- saveAd();
- }
- } else {
- EasyLoading.dismiss();
- }
- }, (e) {
- EasyLoading.dismiss();
- });
- } else {
- if (p3 != '') {
- if (picturesPath == '') {
- picturesPath = p3;
- } else {
- picturesPath = picturesPath + ',' + p3;
- }
- }
- if (widget.data != null) {
- updateAd();
- } else {
- saveAd();
- }
- }
- }
- void showPayOrder(AnnualFeeOrderBeanEntity order) {
- EasyLoading.instance
- ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
- ..alignment = Alignment.bottomCenter
- ..loadingStyle = EasyLoadingStyle.light
- ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
- double price = NumUtil.multiply(
- int.parse(_days.text.toString()),
- pricing[pricing.indexWhere((element) => element.type == typeIndex)]
- .pricing);
- 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();
- Navigator.pop(context, widget.data == null);
- },
- 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: () {
- MyTools().toPage(
- context,
- PayPage(order.data.orderUid, false, price),
- (then) {});
- // getUserWalletBalance((re, hE) {
- // if (!hE) {
- // UserBalanceEntity balance = UserBalanceEntity()
- // .fromJson(json.decode(re.data.toString()));
- // if (balance.data >= price) {
- // payOrder(payWayWallet, order.data.orderUid,
- // (re, hE) {
- // if (!hE) {
- // showToast('支付成功');
- // EventBus().emit('payAnOrder');
- // Navigator.pop(context, widget.data == null);
- // }
- // }, (e) {}, context);
- // } else {
- // payOrder(payWayAliPay, order.data.orderUid,
- // (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');
- // Navigator.pop(context, widget.data == null);
- // });
- // print(entity.data);
- // EasyLoading.instance
- // ..contentPadding = EdgeInsets.symmetric(
- // horizontal: 20, vertical: 12)
- // ..alignment = Alignment.center
- // ..loadingStyle = EasyLoadingStyle.light
- // ..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('支付成功');
- // Navigator.pop(
- // context, widget.data == null);
- // } else {
- // showToast(aliPayResultStatus(r));
- // resetOrder(order.data.orderUid);
- // }
- // } 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),
- ),
- )
- ],
- ),
- )
- ],
- ),
- ),
- );
- }
- String p1 = '';
- String p2 = '';
- String p3 = '';
- void initAd() {
- _title.text = widget.data.title;
- coverPath = widget.data.coverPath;
- typeIndex = widget.data.type;
- typeValue = typeIndex == 0 ? '货帮/商品部分广告' : '首页banner';
- startTime = widget.data.startDate;
- _days.text = widget.data.days.toString();
- _description.text = widget.data.description;
- widget.data.pictures.split(',').forEach((element) {
- if (p1 == '') {
- p1 = element;
- } else if (p2 == '') {
- p2 = element;
- } else if (p3 == '') {
- p3 = element;
- }
- });
- if (widget.data.linkId == 0) {
- associationType = -1;
- } else {
- associationType = widget.data.linkType;
- }
- setState(() {});
- if (associationType != -1) {
- if (associationType == 0) {
- 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()));
- if (entity.data.data.length != 0) {
- shop = entity.data.data[0];
- setState(() {});
- }
- }
- }, (error) {});
- } else if (associationType == 1) {
- 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()));
- if (entity.data.data.length != 0) {
- product = entity.data.data[0];
- setState(() {});
- }
- }
- }, (error) {});
- }
- }
- }
- getCover() {
- if (cover == null && coverPath == '') {
- return SvgPicture.asset(
- 'images/svg/更换头像.svg',
- height: 40,
- width: 40,
- );
- } else if (cover != null) {
- return ClipRRect(
- child: Image.file(
- cover,
- height: 40,
- width: 40,
- ),
- borderRadius: BorderRadius.circular(4),
- );
- } else if (coverPath != '') {
- return ClipRRect(
- child: MyViews().netImg(imgURL(coverPath), 40, 40),
- borderRadius: BorderRadius.circular(4),
- );
- }
- }
- getP1() {
- if (pictures[0] == null && p1 == '') {
- return Container(
- height: 102,
- width: 102,
- decoration: BoxDecoration(
- color: MyColors.cF0F0F0,
- borderRadius: BorderRadius.all(Radius.circular(4))),
- child: Icon(
- Icons.add,
- color: MyColors.cB6B6B6,
- size: 44,
- ),
- );
- } else if (pictures[0] != null) {
- return ClipRRect(
- child: Image.file(
- pictures[0],
- height: 102,
- width: 102,
- fit: BoxFit.cover,
- ),
- borderRadius: BorderRadius.circular(4),
- );
- } else if (p1 != '') {
- return ClipRRect(
- child: MyViews().netImg(imgURL(p1), 102, 102),
- borderRadius: BorderRadius.circular(4),
- );
- }
- }
- getP2() {
- if (pictures[1] == null && p2 == '') {
- return Container(
- height: 102,
- width: 102,
- decoration: BoxDecoration(
- color: MyColors.cF0F0F0,
- borderRadius: BorderRadius.all(Radius.circular(4))),
- child: Icon(
- Icons.add,
- color: MyColors.cB6B6B6,
- size: 44,
- ),
- );
- } else if (pictures[1] != null) {
- return ClipRRect(
- child: Image.file(
- pictures[1],
- height: 102,
- width: 102,
- fit: BoxFit.cover,
- ),
- borderRadius: BorderRadius.circular(4),
- );
- } else if (p2 != '') {
- return ClipRRect(
- child: MyViews().netImg(imgURL(p2), 102, 102),
- borderRadius: BorderRadius.circular(4),
- );
- }
- }
- getP3() {
- if (pictures[2] == null && p3 == '') {
- return Container(
- height: 102,
- width: 102,
- decoration: BoxDecoration(
- color: MyColors.cF0F0F0,
- borderRadius: BorderRadius.all(Radius.circular(4))),
- child: Icon(
- Icons.add,
- color: MyColors.cB6B6B6,
- size: 44,
- ),
- );
- } else if (pictures[2] != null) {
- return ClipRRect(
- child: Image.file(
- pictures[2],
- height: 102,
- width: 102,
- fit: BoxFit.cover,
- ),
- borderRadius: BorderRadius.circular(4),
- );
- } else if (p3 != '') {
- return ClipRRect(
- child: MyViews().netImg(imgURL(p3), 102, 102),
- borderRadius: BorderRadius.circular(4),
- );
- }
- }
- void updateAd() {
- var values = {
- "id": widget.data.id,
- "title": _title.text.toString(),
- "description": _description.text.toString(),
- "cover_path": coverPath,
- "pictures": picturesPath
- };
- if (associationType == 0 && shop != null) {
- values['link_type'] = associationType;
- values['link_id'] = shop.id;
- }
- if (associationType == 1 && product != null) {
- values['link_type'] = associationType;
- values['link_id'] = product.id;
- }
- MyDio().update({'key': 'ad', 'values': values}, (response, hasError) {
- if (!hasError) {
- widget.data.title = _title.text.toString();
- widget.data.description = _description.text.toString();
- widget.data.coverPath = coverPath;
- widget.data.pictures = picturesPath;
- AnnualFeeOrderBeanEntity entity = AnnualFeeOrderBeanEntity()
- .fromJson(json.decode(response.data.toString()));
- if (!widget.data.paid) {
- showPayOrder(entity);
- } else {
- EasyLoading.dismiss();
- Navigator.pop(context, widget.data == null);
- }
- }
- }, (error) {});
- }
- void saveAd() {
- var object = {
- "type": typeValue == '货帮/商品部分广告' ? 0 : 1,
- "start_date": startTime,
- "days": int.parse(_days.text.toString()),
- "user_uid": MyCookie().getUID(),
- "user_name": MyCookie().getName(),
- "user_pic": MyCookie().userBean.picture,
- "title": _title.text.toString(),
- "description": _description.text.toString(),
- "cover_path": coverPath,
- "pictures": picturesPath
- };
- if (associationType == 0 && shop != null) {
- object['link_type'] = associationType;
- object['link_id'] = shop.id;
- }
- if (associationType == 1 && product != null) {
- object['link_type'] = associationType;
- object['link_id'] = product.id;
- }
- MyDio().save({'key': 'ad', 'object': object}, (response, hasError) {
- AnnualFeeOrderBeanEntity entity = AnnualFeeOrderBeanEntity()
- .fromJson(json.decode(response.data.toString()));
- showPayOrder(entity);
- }, (error) {});
- }
- void deleteAD(AdBeanDataData ad) {
- MyDio().del({
- 'key': 'ad',
- 'ids': [ad.id]
- }, (response, hasError) {
- Navigator.pop(context, widget.data == null);
- }, (error) {});
- }
- }
|