| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544 |
- import 'dart:convert';
- import 'dart:io';
- import 'package:bbyyy/beans/my_shop_bean_entity.dart';
- import 'package:bbyyy/https/url.dart';
- import 'package:bbyyy/my_tools/my_colors.dart';
- import 'package:bbyyy/my_tools/my_views.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_svg/svg.dart';
- import 'package:pull_to_refresh/pull_to_refresh.dart';
- import '../../../beans/complain_bean_entity.dart';
- import '../../../beans/upload_image_bean_entity.dart';
- import '../../../https/MyDio.dart';
- import '../../../https/my_request.dart';
- import '../../../my_tools/dims.dart';
- import '../../../my_tools/easy_loading/easy_loading.dart';
- import '../../../my_tools/my_cookie.dart';
- import '../../../my_tools/my_tools.dart';
- import 'choose_a_store_page.dart';
- class PunishPage extends StatefulWidget {
- @override
- _PunishPageState createState() => _PunishPageState();
- }
- class _PunishPageState extends State<PunishPage> {
- int selectedIndex = 0;
- TextEditingController _phoneNum = TextEditingController();
- TextEditingController _content = TextEditingController();
- List<ComplainBeanDataData> data = [];
- MyShopBeanDataData shop;
- @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: 40,
- color: Colors.white,
- child: Row(
- children: [
- GestureDetector(
- onTap: () {
- setState(() {
- selectedIndex = 0;
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Padding(
- padding: EdgeInsets.only(left: 10, right: 10),
- child: Column(
- children: [
- Text(
- '投诉',
- style: TextStyle(
- color: selectedIndex == 0
- ? MyColors.cFF4233
- : MyColors.c666666,
- fontSize: 15),
- ),
- Container(
- height: 10,
- child: Visibility(
- child: SvgPicture.asset('images/svg/tab.svg'),
- visible: selectedIndex == 0,
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.end,
- ),
- ),
- ),
- GestureDetector(
- onTap: () {
- setState(() {
- selectedIndex = 1;
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Padding(
- padding: EdgeInsets.only(left: 10, right: 10),
- child: Column(
- children: [
- Text(
- '被投诉',
- style: TextStyle(
- color: selectedIndex == 1
- ? MyColors.cFF4233
- : MyColors.c666666,
- fontSize: 15),
- ),
- Container(
- height: 10,
- child: Visibility(
- child: SvgPicture.asset('images/svg/tab.svg'),
- visible: selectedIndex == 1,
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.end,
- ),
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- ),
- ),
- Expanded(
- child: selectedIndex == 0 ? complaintPage() : punishPage(),
- )
- ],
- ),
- ),
- );
- }
- complaintPage() {
- return SingleChildScrollView(
- child: Column(
- children: [
- Container(
- color: Colors.white,
- margin: EdgeInsets.only(top: 10),
- child: Column(
- children: [
- Container(
- padding: EdgeInsets.fromLTRB(16, 17, 14, 17),
- child: Row(
- children: [
- MyViews().myText('投诉货帮', MyColors.c333333, 15),
- GestureDetector(child:
- shop == null
- ? MyViews().myText('请选择货帮', MyColors.c333333, 15)
- : Row(
- children: [
- ClipRRect(
- borderRadius: BorderRadius.circular(10),
- child: MyViews()
- .netImg(imgURL(shop?.shopPic), 20, 20),
- ),
- Container(child: MyViews().myText(shop?.shopName, MyColors.c333333, 15),margin: EdgeInsets.only(left: 10),)
- ],
- ),onTap: (){
- MyTools().toPage(context, ChooseAStorePage(), (then){
- if(then is MyShopBeanDataData){
- shop = then;
- setState(() {
- });
- }
- });
- },
- behavior: HitTestBehavior.translucent,),
- ],mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- Container(
- color: MyColors.cF7F7F7,
- height: 0.5,
- margin: EdgeInsets.only(left: 16, right: 14),
- ),
- Container(
- padding: EdgeInsets.fromLTRB(16, 17, 14, 17),
- child: Row(
- children: [
- MyViews().myText('个人电话', MyColors.c333333, 15),
- Expanded(
- child: TextField(
- inputFormatters: [
- LengthLimitingTextInputFormatter(11)
- ],
- controller: _phoneNum,
- cursorColor: MyColors.cFF4233,
- cursorWidth: 1.0,
- textAlign: TextAlign.end,
- 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, 0, 4.5),
- ),
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 14,
- height: 1.3,
- letterSpacing: 0.2),
- keyboardType: TextInputType.number,
- onChanged: (t) {},
- ),
- )
- ],
- ),
- ),
- ],
- ),
- ),
- Container(
- margin: EdgeInsets.only(top: 10),
- color: Colors.white,
- child: Column(
- children: [
- Container(
- width: double.infinity,
- margin: EdgeInsets.only(left: 16, top: 17),
- child: Text(
- '投诉内容',
- style: TextStyle(color: MyColors.c333333, fontSize: 15),
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 15, right: 15, top: 17),
- constraints: BoxConstraints(minHeight: 86),
- decoration: BoxDecoration(
- border: Border.all(color: MyColors.cE7E7E7, width: 1),
- borderRadius: BorderRadius.all(
- Radius.circular(4),
- ),
- ),
- child: TextField(
- controller: _content,
- cursorColor: MyColors.cFF4233,
- cursorWidth: 1.0,
- maxLines: null,
- 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(
- width: double.infinity,
- margin: EdgeInsets.only(left: 16, top: 17),
- child: Text(
- '证据图片',
- style: TextStyle(color: MyColors.c333333, fontSize: 15),
- ),
- ),
- Container(
- margin:
- EdgeInsets.only(left: 15, right: 15, bottom: 17, top: 18),
- child: Row(
- children: [
- GestureDetector(
- onTap: () async {
- pictures[0] = await selectImage(isCover: false);
- setState(() {});
- },
- behavior: HitTestBehavior.translucent,
- child: pictures[0] == null
- ? 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,
- ),
- )
- : ClipRRect(
- child: Image.file(
- pictures[0],
- height: 102,
- width: 102,
- fit: BoxFit.cover,
- ),
- borderRadius: BorderRadius.circular(4),
- ),
- ),
- GestureDetector(
- onTap: () async {
- pictures[1] = await selectImage(isCover: false);
- setState(() {});
- },
- behavior: HitTestBehavior.translucent,
- child: pictures[1] == null
- ? 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,
- ),
- )
- : ClipRRect(
- child: Image.file(
- pictures[1],
- height: 102,
- width: 102,
- fit: BoxFit.cover,
- ),
- borderRadius: BorderRadius.circular(4),
- ),
- ),
- GestureDetector(
- onTap: () async {
- pictures[2] = await selectImage(isCover: false);
- setState(() {});
- },
- behavior: HitTestBehavior.translucent,
- child: pictures[2] == null
- ? 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,
- ),
- )
- : ClipRRect(
- child: Image.file(
- pictures[2],
- height: 102,
- width: 102,
- fit: BoxFit.cover,
- ),
- borderRadius: BorderRadius.circular(4),
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- ],
- ),
- ),
- GestureDetector(
- onTap: () {
- uploadPictureOne();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- color: Colors.white,
- margin: EdgeInsets.only(top: 10),
- height: 50,
- child: MyViews().myText('确 定', MyColors.cFF4233, 16),
- alignment: Alignment.center,
- ),
- )
- ],
- ),
- );
- }
- RefreshController controller = RefreshController(initialRefresh: true);
- punishPage() {
- return SmartRefresher(
- controller: controller,
- onRefresh: onRefresh,
- onLoading: onLoading,
- enablePullDown: true,
- enablePullUp: true,
- child: ListView.builder(
- itemBuilder: (c, index) {
- return MyViews().getPunishItem(context, data[index]);
- },
- itemCount: data.length,
- padding: EdgeInsets.only(top: 10),
- ),
- );
- }
- List<File> pictures = [null, null, null];
- String picturesPath = '';
- void uploadPictureOne() {
- print('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 {
- 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 {
- 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;
- }
- submitAComplaint();
- } else {
- EasyLoading.dismiss();
- }
- }, (e) {
- EasyLoading.dismiss();
- });
- } else {
- submitAComplaint();
- }
- }
- void submitAComplaint() {
- MyDio().save({
- 'key': 'complain',
- 'object': {
- 'shop_uid': shop?.shopUid,
- 'user_uid': MyCookie().getUID(),
- 'content': _content.text.toString(),
- 'snapshots': picturesPath
- }
- }, (response, hasError) {
- if (!hasError) {
- showToast('提交成功');
- _content.clear();
- _phoneNum.clear();
- shop = null;
- pictures.forEach((element) {
- element = null;
- });
- picturesPath = '';
- setState(() {});
- }
- }, (error) {});
- }
- int page = 1;
- inquiryAndComplaint() {
- MyDio().query({
- "key": "complain",
- "filters": {
- "conditions": ["owner_uid==${MyCookie().getUID()}"]
- },
- "dims": complainDims,
- "paging": [page, 20]
- }, (response, hasError) {
- if (!hasError) {
- ComplainBeanEntity entity = ComplainBeanEntity()
- .fromJson(json.decode(response.data.toString()));
- if (page == 1) {
- data.clear();
- }
- data.addAll(entity.data.data);
- setState(() {});
- }
- endRe(controller);
- }, (error) {
- endRe(controller);
- });
- }
- void onRefresh() {
- page = 1;
- inquiryAndComplaint();
- }
- void onLoading() {
- page++;
- inquiryAndComplaint();
- }
- }
|