Explorar el Código

5.24 1.0.93 -- 2

huxiaoqiang hace 4 años
padre
commit
b6e2aa8025

+ 0 - 1
lib/beans/send_message_bean_entity.dart

@@ -1,5 +1,4 @@
 import 'package:bbyyy/generated/json/base/json_convert_content.dart';
-import 'package:bbyyy/generated/json/base/json_field.dart';
 
 import 'message_bean_entity.dart';
 

+ 0 - 1
lib/generated/json/my_shop_bean_entity_helper.dart

@@ -1,5 +1,4 @@
 import 'package:bbyyy/beans/my_shop_bean_entity.dart';
-import 'package:azlistview/azlistview.dart';
 
 myShopBeanEntityFromJson(MyShopBeanEntity data, Map<String, dynamic> json) {
 	if (json['data'] != null) {

+ 14 - 2
lib/my_tools/dims.dart

@@ -42,7 +42,13 @@ var shopDims = [
   'mobile', //联系电话
   'introduction', //店铺介绍
   'hide_members',
-  'notice'
+  'notice',
+  'longitude',
+  'latitude',
+  'auto_address',
+  'province',
+  'city',
+  'county'
 ];
 
 var userDims = [
@@ -107,7 +113,13 @@ var commodityDims = [
   'create_time',
   'pictures',
   'category',
-  'public'
+  'public',
+  'longitude',
+  'latitude',
+  'auto_address',
+  'province',
+  'city',
+  'county'
 ];
 
 var flowDims = [

+ 1 - 0
lib/my_tools/event_bus.dart

@@ -27,6 +27,7 @@ class EventBus {
     if (eventName == null || list == null) return;
     if (f == null) {
       _emap[eventName] = null;
+
     } else {
       list.remove(f);
     }

+ 2 - 0
lib/my_tools/my_cookie.dart

@@ -1,5 +1,6 @@
 import 'dart:convert';
 
+import 'package:amap_location/amap_location.dart';
 import 'package:bbyyy/beans/login_information_bean_entity.dart';
 import 'package:bbyyy/beans/user_bean_entity.dart';
 import 'package:disable_screenshots/disable_screenshots.dart';
@@ -27,6 +28,7 @@ class MyCookie {
   PackageInfo packageInfo;
   UserBeanDataData userBean;
   DisableScreenshots plugin;
+  AMapLocation location;
 
   getUT() {
     return 'user=${loginInformation.data.user}&token=${loginInformation.data.token}';

+ 1 - 1
lib/my_tools/order.dart

@@ -362,6 +362,6 @@ String computeOrderHash(Map<String, String> order) {
   sortedKeys.forEach((key) {
     values.add(order[key]);
   });
-  print('${values.toString()}');
+  values.sort();
   return '${values.toString().hashCode}';
 }

+ 9 - 10
lib/paegs/gang_page/create_a_gang_page/create_a_gang_page.dart

@@ -54,7 +54,6 @@ class _CreateAGangPageState extends State<CreateAGangPage> {
   int commissionCommissionType = 0; //店主收取佣金方式  直接收取固定金额 = 0 按照比例收取 = 1
   String feePricing;
   int feeType;
-  AMapLocation location;
 
   @override
   void initState() {
@@ -944,7 +943,7 @@ class _CreateAGangPageState extends State<CreateAGangPage> {
                               EasyLoading.show();
                               await AMapLocationClient.getLocation(true)
                                   .then((value) {
-                                location = value;
+                                MyCookie().location = value;
                                 upload(_image, (r, hE) {
                                   if (!hE) {
                                     UploadImageBeanEntity data =
@@ -962,7 +961,7 @@ class _CreateAGangPageState extends State<CreateAGangPage> {
                           EasyLoading.show();
                           await AMapLocationClient.getLocation(true)
                               .then((value) {
-                            location = value;
+                            MyCookie().location = value;
                             upload(_image, (r, hE) {
                               if (!hE) {
                                 UploadImageBeanEntity data =
@@ -1021,13 +1020,13 @@ class _CreateAGangPageState extends State<CreateAGangPage> {
           : double.parse(_amountCharged.text.toString());
       object['shop_commission_percent'] = commissionCommissionType == 1;
     }
-    if (!private && location != null) {
-      object['longitude'] = location.longitude;
-      object['latitude'] = location.latitude;
-      object['auto_address'] = location.formattedAddress;
-      object['province'] = location.province;
-      object['city'] = location.city;
-      object['county'] = location.district;
+    if (!private && MyCookie().location != null) {
+      object['longitude'] = MyCookie().location.longitude;
+      object['latitude'] = MyCookie().location.latitude;
+      object['auto_address'] = MyCookie().location.formattedAddress;
+      object['province'] = MyCookie().location.province;
+      object['city'] = MyCookie().location.city;
+      object['county'] = MyCookie().location.district;
     }
     MyDio().save({'key': 'shop', 'object': object}, (response, hasError) {
       if (!hasError) {

+ 0 - 1
lib/paegs/gang_page/gang_in_page/pay_to_the_helper_page/pay_to_the_helper_page.dart

@@ -12,7 +12,6 @@ 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/order_information_page.dart';
-import 'package:bbyyy/paegs/pay_page/pay_page.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 

+ 306 - 84
lib/paegs/home_page/home_page.dart

@@ -1,6 +1,9 @@
 import 'dart:async';
 import 'dart:convert';
 
+import 'package:address_picker/address_picker.dart';
+import 'package:amap_location/amap_location.dart';
+import 'package:amap_location/amap_location_option.dart';
 import 'package:bbyyy/beans/ad_bean_entity.dart';
 import 'package:bbyyy/beans/commodity_category_bean_entity.dart';
 import 'package:bbyyy/beans/goods_bean_entity.dart';
@@ -22,6 +25,7 @@ import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_svg/flutter_svg.dart';
 import 'package:flutter_swiper/flutter_swiper.dart';
+import 'package:permission_handler/permission_handler.dart';
 import 'package:pull_to_refresh/pull_to_refresh.dart';
 
 class HomePage extends StatefulWidget {
@@ -54,6 +58,9 @@ class _HomePageState extends State<HomePage>
   int page = 1;
   int pageIndex = 0;
   bool showS = false;
+  String province;
+  String city;
+  Address _address;
 
   @override
   void initState() {
@@ -79,6 +86,10 @@ class _HomePageState extends State<HomePage>
     EventBus().on('商品变动', (arg) {
       _reController.requestRefresh();
     });
+    EventBus().on('getLocation', (arg) {
+      _reController.requestRefresh();
+      setState(() {});
+    });
     _controller.addListener(() {
       setState(() {
         if (_controller.offset == 0) {
@@ -125,6 +136,7 @@ class _HomePageState extends State<HomePage>
     EventBus().off('toTop');
     EventBus().off('homeCarousel');
     EventBus().off('商品变动');
+    EventBus().off('getLocation');
   }
 
   @override
@@ -170,96 +182,290 @@ class _HomePageState extends State<HomePage>
                   bottom: false,
                   child: Stack(
                     children: [
-                      AnimatedOpacity(
-                        duration: Duration(milliseconds: 200),
-                        opacity: showS ? 0.0 : 1.0,
+                      // AnimatedOpacity(
+                      //   duration: Duration(milliseconds: 200),
+                      //   opacity: showS ? 0.0 : 1.0,
+                      //   child: Container(
+                      //     margin: EdgeInsets.only(top: 18),
+                      //     width: double.infinity,
+                      //     child: Row(
+                      //       children: [
+                      //         GestureDetector(
+                      //           onTap: () {
+                      //             setState(() {
+                      //               pageIndex = 0;
+                      //               _reController.requestRefresh();
+                      //             });
+                      //           },
+                      //           behavior: HitTestBehavior.translucent,
+                      //           child: Container(
+                      //             height: 28,
+                      //             width: 60,
+                      //             alignment: Alignment.center,
+                      //             child: Column(
+                      //               children: [
+                      //                 Text(
+                      //                   '货帮',
+                      //                   style: TextStyle(
+                      //                       color: pageIndex == 0
+                      //                           ? MyColors.cFF4233
+                      //                           : MyColors.c333333,
+                      //                       fontSize: 16,
+                      //                       fontWeight: FontWeight.bold),
+                      //                 ),
+                      //                 Visibility(
+                      //                   child: Container(
+                      //                     width: 32,
+                      //                     height: 2,
+                      //                     decoration: BoxDecoration(
+                      //                         color: MyColors.cFF4233,
+                      //                         borderRadius:
+                      //                             BorderRadius.circular(1)),
+                      //                   ),
+                      //                   visible: pageIndex == 0,
+                      //                 ),
+                      //               ],
+                      //             ),
+                      //           ),
+                      //         ),
+                      //         Container(
+                      //           width: 40,
+                      //         ),
+                      //         GestureDetector(
+                      //           onTap: () {
+                      //             setState(() {
+                      //               pageIndex = 1;
+                      //               _reController.requestRefresh();
+                      //             });
+                      //           },
+                      //           behavior: HitTestBehavior.translucent,
+                      //           child: Container(
+                      //             height: 28,
+                      //             width: 60,
+                      //             alignment: Alignment.center,
+                      //             child: Column(
+                      //               children: [
+                      //                 Text(
+                      //                   '商品',
+                      //                   style: TextStyle(
+                      //                       color: pageIndex == 1
+                      //                           ? MyColors.cFF4233
+                      //                           : MyColors.c333333,
+                      //                       fontSize: 16,
+                      //                       fontWeight: FontWeight.bold),
+                      //                 ),
+                      //                 Visibility(
+                      //                   child: Container(
+                      //                     width: 32,
+                      //                     height: 2,
+                      //                     decoration: BoxDecoration(
+                      //                         color: MyColors.cFF4233,
+                      //                         borderRadius:
+                      //                             BorderRadius.circular(1)),
+                      //                   ),
+                      //                   visible: pageIndex == 1,
+                      //                 ),
+                      //               ],
+                      //             ),
+                      //           ),
+                      //         ),
+                      //       ],
+                      //       mainAxisAlignment: MainAxisAlignment.center,
+                      //     ),
+                      //   ),
+                      // ),
+                      Positioned(
+                        left: 0,
                         child: Container(
-                          margin: EdgeInsets.only(top: 18),
-                          width: double.infinity,
-                          child: Row(
-                            children: [
-                              GestureDetector(
-                                onTap: () {
-                                  setState(() {
-                                    pageIndex = 0;
-                                    _reController.requestRefresh();
-                                  });
-                                },
-                                behavior: HitTestBehavior.translucent,
-                                child: Container(
-                                  height: 28,
-                                  width: 60,
-                                  alignment: Alignment.center,
-                                  child: Column(
-                                    children: [
-                                      Text(
-                                        '货帮',
-                                        style: TextStyle(
-                                            color: pageIndex == 0
-                                                ? MyColors.cFF4233
-                                                : MyColors.c333333,
-                                            fontSize: 16,
-                                            fontWeight: FontWeight.bold),
-                                      ),
-                                      Visibility(
-                                        child: Container(
-                                          width: 32,
-                                          height: 2,
-                                          decoration: BoxDecoration(
-                                              color: MyColors.cFF4233,
-                                              borderRadius:
-                                                  BorderRadius.circular(1)),
+                          padding:
+                              EdgeInsets.only(left: 10, right: 10, top: 12),
+                          child: GestureDetector(
+                            onTap: () {
+                              showModalBottomSheet(
+                                context: context,
+                                builder: (context) => BottomSheet(
+                                  onClosing: () {},
+                                  builder: (context) => Container(
+                                    height: 290,
+                                    child: Column(
+                                      children: [
+                                        Container(
+                                          height: 40,
+                                          padding: EdgeInsets.symmetric(
+                                              horizontal: 15),
+                                          child: Row(
+                                            children: [
+                                              Row(
+                                                children: [
+                                                  Text(
+                                                    '定位: ',
+                                                    style: TextStyle(
+                                                        color: MyColors.cFF4233,
+                                                        fontSize: 14),
+                                                  ),
+                                                  GestureDetector(
+                                                    onTap: () async {
+                                                      if (MyCookie().location !=
+                                                          null) {
+                                                        province = MyCookie()
+                                                            .location
+                                                            .province;
+                                                        city = MyCookie()
+                                                            .location
+                                                            .city;
+                                                        setState(() {});
+                                                        _reController
+                                                            .requestRefresh();
+                                                        Navigator.pop(context);
+                                                      } else {
+                                                        var locationStatus =
+                                                            await Permission
+                                                                .location
+                                                                .status;
+                                                        if (locationStatus
+                                                            .isDenied) {
+                                                          await Permission
+                                                              .location
+                                                              .request()
+                                                              .then(
+                                                                  (value) async {
+                                                            print(
+                                                                'Permission.location.request()-----$value');
+                                                            if (value ==
+                                                                PermissionStatus
+                                                                    .granted) {
+                                                              await AMapLocationClient.startup(
+                                                                  new AMapLocationOption(
+                                                                      desiredAccuracy:
+                                                                          CLLocationAccuracy
+                                                                              .kCLLocationAccuracyHundredMeters));
+                                                              await AMapLocationClient
+                                                                      .getLocation(
+                                                                          true)
+                                                                  .then(
+                                                                      (value) {
+                                                                MyCookie()
+                                                                        .location =
+                                                                    value;
+                                                                EventBus().emit(
+                                                                    'getLocation');
+                                                                _reController
+                                                                    .requestRefresh();
+                                                                Navigator.pop(
+                                                                    context);
+                                                              });
+                                                            }
+                                                          });
+                                                        }
+                                                      }
+                                                    },
+                                                    behavior: HitTestBehavior
+                                                        .translucent,
+                                                    child: Text(
+                                                      MyCookie().location !=
+                                                              null
+                                                          ? '${MyCookie().location.province} ${MyCookie().location.city}'
+                                                          : '获取定位',
+                                                      style: TextStyle(
+                                                          color:
+                                                              MyColors.cFF4233,
+                                                          fontSize: 14),
+                                                    ),
+                                                  ),
+                                                ],
+                                              ),
+                                              GestureDetector(
+                                                child: Text(
+                                                  '确定',
+                                                  style: TextStyle(
+                                                      color: MyColors.cFF4233,
+                                                      fontSize: 16),
+                                                ),
+                                                onTap: () {
+                                                  if (_address == null) {
+                                                    province = '北京市';
+                                                    city = '北京市';
+                                                    setState(() {});
+                                                    _reController
+                                                        .requestRefresh();
+                                                    Navigator.pop(context);
+                                                  } else {
+                                                    province = _address
+                                                        .currentProvince
+                                                        .province;
+                                                    city = _address
+                                                        .currentCity.city;
+                                                    setState(() {});
+                                                    _reController
+                                                        .requestRefresh();
+                                                    Navigator.pop(context);
+                                                  }
+                                                },
+                                                behavior:
+                                                    HitTestBehavior.translucent,
+                                              ),
+                                            ],
+                                            mainAxisAlignment:
+                                                MainAxisAlignment.spaceBetween,
+                                          ),
                                         ),
-                                        visible: pageIndex == 0,
-                                      ),
-                                    ],
-                                  ),
-                                ),
-                              ),
-                              Container(
-                                width: 40,
-                              ),
-                              GestureDetector(
-                                onTap: () {
-                                  setState(() {
-                                    pageIndex = 1;
-                                    _reController.requestRefresh();
-                                  });
-                                },
-                                behavior: HitTestBehavior.translucent,
-                                child: Container(
-                                  height: 28,
-                                  width: 60,
-                                  alignment: Alignment.center,
-                                  child: Column(
-                                    children: [
-                                      Text(
-                                        '商品',
-                                        style: TextStyle(
-                                            color: pageIndex == 1
-                                                ? MyColors.cFF4233
-                                                : MyColors.c333333,
-                                            fontSize: 16,
-                                            fontWeight: FontWeight.bold),
-                                      ),
-                                      Visibility(
-                                        child: Container(
-                                          width: 32,
-                                          height: 2,
-                                          decoration: BoxDecoration(
-                                              color: MyColors.cFF4233,
-                                              borderRadius:
-                                                  BorderRadius.circular(1)),
+                                        Container(
+                                          height: 250.0,
+                                          child: AddressPicker(
+                                            style: TextStyle(
+                                                color: Colors.black,
+                                                fontSize: 17),
+                                            mode: AddressPickerMode
+                                                .provinceAndCity,
+                                            onSelectedAddressChanged:
+                                                (address) {
+                                              _address = address;
+                                            },
+                                          ),
                                         ),
-                                        visible: pageIndex == 1,
-                                      ),
-                                    ],
+                                      ],
+                                    ),
                                   ),
                                 ),
+                              );
+                            },
+                            behavior: HitTestBehavior.translucent,
+                            child: Container(
+                              padding: EdgeInsets.only(left: 11, right: 14),
+                              decoration: BoxDecoration(
+                                  boxShadow: [
+                                    BoxShadow(
+                                      color: MyColors.c7FE1E1E1,
+                                      blurRadius: 5.0,
+                                    ),
+                                  ],
+                                  color: Colors.white,
+                                  borderRadius: BorderRadius.circular(20)),
+                              child: Row(
+                                children: [
+                                  Icon(
+                                    Icons.location_on_rounded,
+                                    color: MyColors.c333333,
+                                    size: 20,
+                                  ),
+                                  Text(
+                                    province == null
+                                        ? MyCookie().location != null
+                                            ? MyCookie().location.city
+                                            : '成都市'
+                                        : city,
+                                    style: TextStyle(
+                                        color: MyColors.c333333,
+                                        fontSize: 12,
+                                        fontWeight: FontWeight.bold),
+                                  ),
+                                ],
                               ),
-                            ],
-                            mainAxisAlignment: MainAxisAlignment.center,
+                              height: 40,
+                              alignment: Alignment.center,
+                            ),
                           ),
+                          alignment: Alignment.center,
                         ),
                       ),
                       Container(
@@ -594,6 +800,10 @@ class _HomePageState extends State<HomePage>
   }
 
   queryAd() {
+    int count = 2;
+    if (container.length == 0) {
+      count = 20;
+    }
     MyDio().query({
       "key": "ad",
       "filters": {
@@ -601,7 +811,7 @@ class _HomePageState extends State<HomePage>
       },
       "dims": adDims,
       "order_by": ["id,desc", "no,desc"],
-      "paging": [page, 2]
+      "paging": [page, count]
     }, (response, hasError) {
       if (!hasError) {
         AdBeanEntity entity =
@@ -638,6 +848,18 @@ class _HomePageState extends State<HomePage>
     if (_description.text.isNotEmpty) {
       conditions.add('name LIKE ${_description.text.toString()}');
     }
+    if (MyCookie().location == null && province == null) {
+      conditions.add('province == 四川省');
+      conditions.add('city == 成都市');
+    } else {
+      if (province != null) {
+        conditions.add('province == $province');
+        conditions.add('city == $city');
+      } else if (MyCookie().location != null) {
+        conditions.add('province == ${MyCookie().location.province}');
+        conditions.add('city == ${MyCookie().location.city}');
+      }
+    }
     MyDio().query({
       "key": "shop",
       "filters": {"conditions": conditions},

+ 0 - 1
lib/paegs/pay_page/pay_page.dart

@@ -15,7 +15,6 @@ 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/global.dart';
 import 'package:bbyyy/my_tools/my_colors.dart';
 import 'package:bbyyy/my_tools/my_tools.dart';
 import 'package:bbyyy/my_tools/my_views.dart';

+ 18 - 4
lib/paegs/root_page/root_page.dart

@@ -131,8 +131,25 @@ class _RootPageState extends State<RootPage> {
     print('Permission.location.status--------------$locationStatus');
     print('Permission.camera.status--------------$cameraStatus');
     if (locationStatus.isDenied) {
-      await Permission.location.request().then((value) {
+      await Permission.location.request().then((value) async {
         print('Permission.location.request()-----$value');
+        if(value==PermissionStatus.granted){
+          await AMapLocationClient.startup(new AMapLocationOption(
+              desiredAccuracy: CLLocationAccuracy.kCLLocationAccuracyHundredMeters));
+          await AMapLocationClient.getLocation(true)
+              .then((value) {
+            MyCookie().location = value;
+            EventBus().emit('getLocation');
+          });
+        }
+      });
+    }else if(locationStatus.isGranted){
+      await AMapLocationClient.startup(new AMapLocationOption(
+          desiredAccuracy: CLLocationAccuracy.kCLLocationAccuracyHundredMeters));
+      await AMapLocationClient.getLocation(true)
+          .then((value) {
+        MyCookie().location = value;
+        EventBus().emit('getLocation');
       });
     }
     if (cameraStatus.isDenied) {
@@ -140,9 +157,6 @@ class _RootPageState extends State<RootPage> {
         print('Permission.camera.request()-----$value');
       });
     }
-    await AMapLocationClient.startup(new AMapLocationOption(
-        desiredAccuracy: CLLocationAccuracy.kCLLocationAccuracyHundredMeters));
-    AMapLocationClient.onLocationUpate.listen((AMapLocation loc) {});
   }
 
   //查询优惠券活动

+ 7 - 0
pubspec.lock

@@ -1,6 +1,13 @@
 # Generated by pub
 # See https://dart.dev/tools/pub/glossary#lockfile
 packages:
+  address_picker:
+    dependency: "direct main"
+    description:
+      name: address_picker
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "0.0.1"
   amap_location:
     dependency: "direct main"
     description:

+ 2 - 1
pubspec.yaml

@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
 # Read more about iOS versioning at
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 1.0.92+1
+version: 1.0.93+1
 
 environment:
   sdk: ">=2.7.0 <3.0.0"
@@ -66,6 +66,7 @@ dependencies:
   catcher: ^0.6.5
   qr_flutter: ^4.0.0
   scan: ^1.4.3
+  address_picker: ^0.0.1
 
 dev_dependencies:
   flutter_test: