Przeglądaj źródła

6.9 添加登录version

huxiaoqiang 4 lat temu
rodzic
commit
d363aae93b

+ 21 - 16
lib/my_tools/my_tools.dart

@@ -2,8 +2,8 @@ import 'dart:convert' as convert;
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:bbyyy/beans/new_msg_bean_entity.dart';
 import 'package:bbyyy/beans/address_bean_entity.dart';
+import 'package:bbyyy/beans/new_msg_bean_entity.dart';
 import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
 import 'package:bbyyy/my_tools/my_cookie.dart';
 import 'package:convert/convert.dart';
@@ -73,11 +73,11 @@ selectImage({bool isCover = true}) async {
   final pickedFile = await picker.getImage(source: ImageSource.gallery);
   if (pickedFile != null) {
     File cropperImg;
-    if(isCover){
+    if (isCover) {
       cropperImg = await ImageCropper.cropImage(
           sourcePath: pickedFile.path,
           cropStyle: CropStyle.rectangle,
-          aspectRatio: CropAspectRatio(ratioX: 1,ratioY: 1),
+          aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1),
           aspectRatioPresets: [
             isCover
                 ? CropAspectRatioPreset.square
@@ -94,7 +94,7 @@ selectImage({bool isCover = true}) async {
           iosUiSettings: IOSUiSettings(
             minimumAspectRatio: 1.0,
           ));
-    }else{
+    } else {
       cropperImg = await ImageCropper.cropImage(
           sourcePath: pickedFile.path,
           aspectRatioPresets: [
@@ -116,7 +116,7 @@ selectImage({bool isCover = true}) async {
     }
 
     if (cropperImg != null) {
-      cropperImg = await compression(cropperImg,1000000);
+      cropperImg = await compression(cropperImg, 1000000);
       return cropperImg;
     } else {
       return null;
@@ -126,7 +126,7 @@ selectImage({bool isCover = true}) async {
 
 int quality = 90;
 
-Future<File> compression(File cropperImg,int maxSize) async {
+Future<File> compression(File cropperImg, int maxSize) async {
   int l = await cropperImg.length();
   print('$l');
   if (l > maxSize) {
@@ -140,7 +140,7 @@ Future<File> compression(File cropperImg,int maxSize) async {
     print('$l1');
     if (l > maxSize) {
       quality -= 10;
-      return await compression(f,maxSize);
+      return await compression(f, maxSize);
     } else {
       quality = 90;
       return f;
@@ -152,7 +152,7 @@ Future<File> compression(File cropperImg,int maxSize) async {
 
 selectPicturesIndividually() async {
   final pickedFile = await picker.getImage(source: ImageSource.gallery);
-  return await compression(File(pickedFile.path),1000000);
+  return await compression(File(pickedFile.path), 1000000);
 }
 
 endRe(RefreshController reController) {
@@ -269,16 +269,18 @@ numberComplement(String s) {
   }
 }
 
-String hideUID(String uid){
+String hideUID(String uid) {
   return uid.replaceRange(0, 4, '****');
 }
 
-
-
-getAddressByLatitudeAndLongitude(double latitude, double longitude){
+getAddressByLatitudeAndLongitude(double latitude, double longitude) {
   print('getAddressByLatitudeAndLongitude');
-  Dio().get('https://restapi.amap.com/v3/geocode/regeo?output=json&location=$longitude,$latitude&key=5dcd9f0ed7d51aefb5b2f73dba1069cb&radius=10&extensions=all').then((value) {
-    AddressBeanEntity addressBeanEntity = AddressBeanEntity().fromJson(json.decode(value.toString()));
+  Dio()
+      .get(
+          'https://restapi.amap.com/v3/geocode/regeo?output=json&location=$longitude,$latitude&key=5dcd9f0ed7d51aefb5b2f73dba1069cb&radius=10&extensions=all')
+      .then((value) {
+    AddressBeanEntity addressBeanEntity =
+        AddressBeanEntity().fromJson(json.decode(value.toString()));
     MyCookie().location = MyLocation(
         province: addressBeanEntity.regeocode.addressComponent.province,
         city: addressBeanEntity.regeocode.addressComponent.city,
@@ -286,6 +288,9 @@ getAddressByLatitudeAndLongitude(double latitude, double longitude){
         district: addressBeanEntity.regeocode.addressComponent.district,
         latitude: latitude,
         longitude: longitude);
-    EventBus().emit('getLocation');
+    if (addressBeanEntity.regeocode.addressComponent.province != '四川省' ||
+        addressBeanEntity.regeocode.addressComponent.city != '成都市') {
+      EventBus().emit('getLocation');
+    }
   });
-}
+}

+ 119 - 113
lib/my_tools/my_views.dart

@@ -2123,62 +2123,66 @@ class MyViews {
         },
         behavior: HitTestBehavior.translucent,
         child: Container(
-          margin: EdgeInsets.only(bottom: 5),
-          child: Card(
-            elevation: 2,
-            shadowColor: MyColors.c21333333,
-            child: Padding(
-              padding: const EdgeInsets.all(10),
-              child: Row(
-                children: [
-                  ClipRRect(
-                    child: MyViews().netImg(imgURL(data.picture), 70, 70,
-                        placeholder: 'images/svg/goodsDefImg.svg'),
-                    borderRadius: BorderRadius.circular(4),
-                  ),
-                  Expanded(
-                    child: Container(
-                      height: 70,
-                      margin: EdgeInsets.only(left: 10),
-                      child: Column(
-                        children: [
-                          myText('${data.name}(${data.uid})', MyColors.c333333,
-                              14),
-                          Text(
-                            '货帮介绍:${data.introduction}',
-                            style: TextStyle(
-                                color: MyColors.c666666, fontSize: 11),
-                            maxLines: 1,
-                            overflow: TextOverflow.ellipsis,
-                            softWrap: true,
-                          ),
-                          Row(
-                            children: [
-                              Icon(
-                                Icons.location_on_outlined,
-                                size: 15,
-                                color: MyColors.c666666,
-                              ),
-                              Expanded(
-                                child: Text(
-                                  '${data.address}',
-                                  style: TextStyle(
-                                      color: MyColors.c666666, fontSize: 10),
-                                  maxLines: 1,
-                                  overflow: TextOverflow.ellipsis,
-                                  softWrap: true,
-                                ),
+          decoration: BoxDecoration(
+            boxShadow: [BoxShadow(
+              color: MyColors.c7FE1E1E1,
+              blurRadius: 5.0,
+            ),],
+            color: Colors.white,
+            borderRadius: BorderRadius.circular(4),
+          ),
+          margin: EdgeInsets.only(bottom: 6.5,left: 16,right: 16,top: 6.5),
+          child: Padding(
+            padding: const EdgeInsets.all(10),
+            child: Row(
+              children: [
+                ClipRRect(
+                  child: MyViews().netImg(imgURL(data.picture), 70, 70,
+                      placeholder: 'images/svg/goodsDefImg.svg'),
+                  borderRadius: BorderRadius.circular(4),
+                ),
+                Expanded(
+                  child: Container(
+                    height: 70,
+                    margin: EdgeInsets.only(left: 10),
+                    child: Column(
+                      children: [
+                        myText('${data.name}(${data.uid})', MyColors.c333333,
+                            14),
+                        Text(
+                          '货帮介绍:${data.introduction}',
+                          style: TextStyle(
+                              color: MyColors.c666666, fontSize: 11),
+                          maxLines: 1,
+                          overflow: TextOverflow.ellipsis,
+                          softWrap: true,
+                        ),
+                        Row(
+                          children: [
+                            Icon(
+                              Icons.location_on_outlined,
+                              size: 15,
+                              color: MyColors.c666666,
+                            ),
+                            Expanded(
+                              child: Text(
+                                '${data.address}',
+                                style: TextStyle(
+                                    color: MyColors.c666666, fontSize: 10),
+                                maxLines: 1,
+                                overflow: TextOverflow.ellipsis,
+                                softWrap: true,
                               ),
-                            ],
-                          ),
-                        ],
-                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
-                        crossAxisAlignment: CrossAxisAlignment.start,
-                      ),
+                            ),
+                          ],
+                        ),
+                      ],
+                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                      crossAxisAlignment: CrossAxisAlignment.start,
                     ),
-                  )
-                ],
-              ),
+                  ),
+                )
+              ],
             ),
           ),
         ),
@@ -2190,63 +2194,54 @@ class MyViews {
         },
         behavior: HitTestBehavior.translucent,
         child: Container(
-          margin: EdgeInsets.only(bottom: 5),
-          child: Card(
-            elevation: 2,
-            shadowColor: MyColors.c21333333,
-            child: Padding(
-              padding: const EdgeInsets.only(top: 10, bottom: 10, left: 10),
-              child: Row(
-                children: [
-                  ClipRRect(
-                    child: MyViews().netImg(imgURL(data.coverPath), 70, 70,
-                        placeholder: 'images/svg/goodsDefImg.svg'),
-                    borderRadius: BorderRadius.circular(4),
-                  ),
-                  Expanded(
-                    child: Container(
-                      height: 70,
-                      margin: EdgeInsets.only(left: 10),
-                      child: Column(
-                        children: [
-                          Row(
-                            children: [
-                              Expanded(
-                                  child: myText(
-                                      '${data.title}', MyColors.c333333, 14)),
-                              Container(
-                                decoration: BoxDecoration(
-                                  color: MyColors.cADD358,
-                                  borderRadius: BorderRadius.only(
-                                    topLeft: Radius.circular(8),
-                                    bottomLeft: Radius.circular(8),
-                                  ),
+          margin: EdgeInsets.only(bottom: 6.5,left: 16,right: 16,top: 6.5),
+          decoration: BoxDecoration(boxShadow: [BoxShadow(
+            color: MyColors.c7FE1E1E1,
+            blurRadius: 5.0,
+          ),],
+            color: Colors.white,
+            borderRadius: BorderRadius.circular(4),),
+          child: Padding(
+            padding: const EdgeInsets.only(top: 10, bottom: 10, left: 10),
+            child: Row(
+              children: [
+                ClipRRect(
+                  child: MyViews().netImg(imgURL(data.coverPath), 70, 70,
+                      placeholder: 'images/svg/goodsDefImg.svg'),
+                  borderRadius: BorderRadius.circular(4),
+                ),
+                Expanded(
+                  child: Container(
+                    height: 70,
+                    margin: EdgeInsets.only(left: 10),
+                    child: Column(
+                      children: [
+                        Row(
+                          children: [
+                            Expanded(
+                                child: myText(
+                                    '${data.title}', MyColors.c333333, 14)),
+                            Container(
+                              decoration: BoxDecoration(
+                                color: MyColors.cADD358,
+                                borderRadius: BorderRadius.only(
+                                  topLeft: Radius.circular(8),
+                                  bottomLeft: Radius.circular(8),
                                 ),
-                                height: 16,
-                                width: 32,
-                                child: myText('推广', Colors.white, 9),
-                                alignment: Alignment.center,
-                              ),
-                            ],
-                          ),
-                          Visibility(
-                            visible: data.mobile.isNotEmpty,
-                            child: Container(
-                              margin: EdgeInsets.only(right: 10),
-                              child: Text(
-                                '联系电话:${data.mobile}',
-                                style: TextStyle(
-                                    color: MyColors.c666666, fontSize: 11),
-                                maxLines: 2,
-                                overflow: TextOverflow.ellipsis,
-                                softWrap: true,
                               ),
+                              height: 16,
+                              width: 32,
+                              child: myText('推广', Colors.white, 9),
+                              alignment: Alignment.center,
                             ),
-                          ),
-                          Container(
+                          ],
+                        ),
+                        Visibility(
+                          visible: data.mobile.isNotEmpty,
+                          child: Container(
                             margin: EdgeInsets.only(right: 10),
                             child: Text(
-                              '${data.description}',
+                              '联系电话:${data.mobile}',
                               style: TextStyle(
                                   color: MyColors.c666666, fontSize: 11),
                               maxLines: 2,
@@ -2254,14 +2249,25 @@ class MyViews {
                               softWrap: true,
                             ),
                           ),
-                        ],
-                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
-                        crossAxisAlignment: CrossAxisAlignment.start,
-                      ),
+                        ),
+                        Container(
+                          margin: EdgeInsets.only(right: 10),
+                          child: Text(
+                            '${data.description}',
+                            style: TextStyle(
+                                color: MyColors.c666666, fontSize: 11),
+                            maxLines: 2,
+                            overflow: TextOverflow.ellipsis,
+                            softWrap: true,
+                          ),
+                        ),
+                      ],
+                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                      crossAxisAlignment: CrossAxisAlignment.start,
                     ),
-                  )
-                ],
-              ),
+                  ),
+                )
+              ],
             ),
           ),
         ),

+ 309 - 283
lib/paegs/home_page/home_page.dart

@@ -1,5 +1,6 @@
 import 'dart:async';
 import 'dart:convert';
+import 'dart:math';
 
 import 'package:address_picker/address_picker.dart';
 import 'package:bbyyy/beans/ad_bean_entity.dart';
@@ -18,6 +19,7 @@ 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/home_page/recommended_today_page.dart';
 import 'package:bbyyy/paegs/root_page/root_page_view.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
@@ -150,176 +152,286 @@ class _HomePageState extends State<HomePage>
       behavior: HitTestBehavior.translucent,
       child: Scaffold(
         resizeToAvoidBottomInset: false,
-        body: Column(
-          children: [
-            Stack(
+        body: SmartRefresher(
+          controller: _reController,
+          onRefresh: onRefresh,
+          onLoading: onLoading,
+          enablePullDown: true,
+          enablePullUp: true,
+          child: CustomScrollView(
+            slivers: [
+              carouselAndSearch(context),
+              recommendedToday(),
+              storeCategory(),
+              shopList()
+            ],
+          ),
+        ),
+      ),
+    );
+  }
+
+  Widget shopList() {
+    return SliverList(
+        delegate: SliverChildBuilderDelegate(
+      (c, index) {
+        return MyViews().pubShopItem(puShop[index], context);
+      },
+      childCount: puShop.length,
+    ));
+  }
+
+  Widget storeCategory() {
+    return SliverPersistentHeader(
+        pinned: true, //是否固定在顶部
+        floating: false,
+        delegate: _SliverAppBarDelegate(
+            minHeight: 54,
+            maxHeight: 54,
+            child: Column(
               children: [
-                AnimatedContainer(
-                  height: H,
-                  duration: Duration(milliseconds: 200),
-                  child: Swiper(
-                    itemBuilder: (BuildContext context, int index) {
-                      return netImgs.length == 0
-                          ? Image.asset(
-                              "${imgs[index]}",
-                              fit: BoxFit.cover,
-                            )
-                          : MyViews().netImg(
-                              imgURL(netImgs[index]), H, double.infinity,
-                              placeholder: 'images/svg/goodsDefImg.svg');
+                Container(
+                  color: Colors.white,
+                  height: 53,
+                  child: ListView.builder(
+                    padding: EdgeInsets.only(left: 12, right: 12),
+                    itemBuilder: (c, index) {
+                      return GestureDetector(
+                        onTap: () {
+                          setState(() {
+                            selectedIndex = index;
+                            _reController.requestRefresh();
+                          });
+                        },
+                        behavior: HitTestBehavior.translucent,
+                        child: Container(
+                          padding:
+                              EdgeInsets.only(right: 15, left: 15, bottom: 9),
+                          child: Column(
+                            children: [
+                              Text(
+                                tabs[index],
+                                style: TextStyle(
+                                    color: index == selectedIndex
+                                        ? MyColors.cFF4233
+                                        : MyColors.c666666,
+                                    fontSize: 14),
+                              ),
+                              Container(
+                                height: 10,
+                                child: Visibility(
+                                  child: SvgPicture.asset('images/svg/tab.svg'),
+                                  visible: index == selectedIndex,
+                                ),
+                              )
+                            ],
+                            mainAxisAlignment: MainAxisAlignment.end,
+                          ),
+                          height: 53,
+                        ),
+                      );
                     },
-                    itemCount:
-                        netImgs.length == 0 ? imgs.length : netImgs.length,
-                    viewportFraction: 1,
-                    scale: 1,
-                    autoplay: true,
+                    itemCount: tabs.length,
+                    scrollDirection: Axis.horizontal,
                   ),
                 ),
-                SafeArea(
-                  bottom: false,
-                  child: Stack(
+                Container(
+                  height: 1,
+                  color: MyColors.cf2f2f2,
+                ),
+              ],
+            )));
+  }
+
+  Widget recommendedToday() {
+    return SliverToBoxAdapter(
+      child: Column(
+        children: [
+          Container(
+            padding: EdgeInsets.only(left: 16, right: 10),
+            height: 54,
+            child: Row(
+              children: [
+                Text(
+                  '梆梆今日折扣',
+                  style: TextStyle(color: MyColors.c333333, fontSize: 14),
+                ),
+                GestureDetector(
+                  onTap: (){
+                    MyTools().toPage(context, RecommendedTodayPage(), (then){});
+                  },
+                  behavior:HitTestBehavior.translucent,
+                  child: Row(
                     children: [
-                      // 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(
-                          padding:
-                              EdgeInsets.only(left: 10, right: 10, top: 12),
-                          child: GestureDetector(
-                            onTap: () {
-                              addressSelection();
-                            },
-                            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),
+                      Text(
+                        '查看更多',
+                        style: TextStyle(color: MyColors.c666666, fontSize: 12),
+                      ),
+                      Icon(
+                        Icons.chevron_right,
+                        color: MyColors.c666666,
+                      )
+                    ],
+                  ),
+                )
+              ],
+              mainAxisAlignment: MainAxisAlignment.spaceBetween,
+            ),
+          ),
+          Container(
+            height: 1,
+            color: MyColors.cf2f2f2,
+          ),
+          Container(
+            height: 168,
+            child: ListView.builder(
+              padding: EdgeInsets.symmetric(horizontal: 16, vertical: 15),
+              itemBuilder: (c, index) {
+                return Container(
+                  margin: EdgeInsets.only(right: 10),
+                  height: 138,
+                  width: 100,
+                  padding: EdgeInsets.all(5),
+                  decoration: BoxDecoration(
+                    boxShadow: [
+                      BoxShadow(
+                        color: MyColors.c7FE1E1E1,
+                        blurRadius: 5.0,
+                      ),
+                    ],
+                    color: Colors.white,
+                    borderRadius: BorderRadius.circular(4),
+                  ),
+                  child: Column(
+                    children: [
+                      MyViews().netImg('', 90, 90,
+                          placeholder: 'images/svg/goodsDefImg.svg'),
+                      Text(
+                        '8.9元充10元话费',
+                        style: TextStyle(color: MyColors.c333333, fontSize: 11),
+                        maxLines: 1,
+                        overflow: TextOverflow.ellipsis,
+                        softWrap: true,
+                      ),
+                      Row(
+                        children: [
+                          Text(
+                            '¥8.90',
+                            style: TextStyle(
+                                color: MyColors.cFF4233,
+                                fontSize: 13,
+                                fontWeight: FontWeight.bold),
+                            maxLines: 1,
+                            overflow: TextOverflow.ellipsis,
+                            softWrap: true,
+                          ),
+                          Container(
+                            decoration: BoxDecoration(
+                              border:
+                                  Border.all(color: MyColors.cFF4233, width: 1),
+                              borderRadius: BorderRadius.circular(7),
+                            ),
+                            height: 14,
+                            width: 30,
+                            child: Text('详情',style: TextStyle(color: MyColors.cFF4233,fontSize: 9),),
+                            alignment: Alignment.center,
+                          )
+                        ],mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                      )
+                    ],mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                    crossAxisAlignment: CrossAxisAlignment.start,
+                  ),
+                );
+              },
+              itemCount: 10,
+              scrollDirection: Axis.horizontal,
+            ),
+          ),
+        ],
+      ),
+    );
+  }
+
+  Widget carouselAndSearch(BuildContext context) {
+    return SliverPersistentHeader(
+      pinned: true,
+      floating: false,
+      delegate: _SliverAppBarDelegate(
+          minHeight: minH,
+          maxHeight: maxH,
+          child: Stack(
+            children: [
+              Swiper(
+                itemBuilder: (BuildContext context, int index) {
+                  return netImgs.length == 0
+                      ? Image.asset(
+                          "${imgs[index]}",
+                          fit: BoxFit.cover,
+                        )
+                      : MyViews().netImg(
+                          imgURL(netImgs[index]), H, double.infinity,
+                          placeholder: 'images/svg/goodsDefImg.svg');
+                },
+                itemCount: netImgs.length == 0 ? imgs.length : netImgs.length,
+                viewportFraction: 1,
+                scale: 1,
+                autoplay: true,
+              ),
+              SafeArea(
+                bottom: false,
+                child: Stack(
+                  children: [
+                    Positioned(
+                      left: 0,
+                      child: Container(
+                        padding: EdgeInsets.only(left: 10, right: 10, top: 12),
+                        child: GestureDetector(
+                          onTap: () {
+                            addressSelection();
+                          },
+                          behavior: HitTestBehavior.translucent,
+                          child: Container(
+                            padding: EdgeInsets.only(left: 11, right: 14),
+                            decoration: BoxDecoration(
+                                boxShadow: [
+                                  BoxShadow(
+                                    color: MyColors.c7FE1E1E1,
+                                    blurRadius: 5.0,
                                   ),
                                 ],
-                              ),
-                              height: 40,
-                              alignment: Alignment.center,
+                                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),
+                                ),
+                              ],
                             ),
+                            height: 40,
+                            alignment: Alignment.center,
                           ),
-                          alignment: Alignment.center,
                         ),
+                        alignment: Alignment.center,
                       ),
-                      Container(
+                    ),
+                    Positioned(
+                      top: 0,
+                      right: 0,
+                      child: Container(
                         padding: EdgeInsets.only(left: 10, right: 10, top: 12),
                         child: GestureDetector(
                           onTap: () {
@@ -332,8 +444,9 @@ class _HomePageState extends State<HomePage>
                           behavior: HitTestBehavior.translucent,
                           child: AnimatedContainer(
                             height: 40,
-                            width:
-                                !showS ? 40 : MediaQuery.of(context).size.width,
+                            width: !showS
+                                ? 40
+                                : MediaQuery.of(context).size.width - 20,
                             child: Row(
                               children: [
                                 SvgPicture.asset(
@@ -423,88 +536,12 @@ class _HomePageState extends State<HomePage>
                         ),
                         alignment: Alignment.centerRight,
                       ),
-                    ],
-                  ),
-                ),
-              ],
-            ),
-            Container(
-              height: 168,
-              child: ListView.builder(
-                padding: EdgeInsets.only(left: 12, right: 12),
-                itemBuilder: (c, index) {
-                  return Container(margin:EdgeInsets.only(right: 10),height: 138,width: 100,color: Colors.amber,);
-                },
-                itemCount: 10,
-                scrollDirection: Axis.horizontal,
-              ),
-            ),
-            Column(
-              children: [
-                Container(
-                  height: 53,
-                  child: ListView.builder(
-                    padding: EdgeInsets.only(left: 12, right: 12),
-                    itemBuilder: (c, index) {
-                      return GestureDetector(
-                        onTap: () {
-                          setState(() {
-                            selectedIndex = index;
-                            _reController.requestRefresh();
-                          });
-                        },
-                        behavior: HitTestBehavior.translucent,
-                        child: Container(
-                          padding:
-                          EdgeInsets.only(right: 15, left: 15, bottom: 9),
-                          child: Column(
-                            children: [
-                              Text(
-                                tabs[index],
-                                style: TextStyle(
-                                    color: index == selectedIndex
-                                        ? MyColors.cFF4233
-                                        : MyColors.c666666,
-                                    fontSize: 14),
-                              ),
-                              Container(
-                                height: 10,
-                                child: Visibility(
-                                  child: SvgPicture.asset('images/svg/tab.svg'),
-                                  visible: index == selectedIndex,
-                                ),
-                              )
-                            ],
-                            mainAxisAlignment: MainAxisAlignment.end,
-                          ),
-                          height: 53,
-                        ),
-                      );
-                    },
-                    itemCount: tabs.length,
-                    scrollDirection: Axis.horizontal,
-                  ),
-                ),
-                Container(
-                  height: 1,
-                  color: MyColors.cf2f2f2,
+                    ),
+                  ],
                 ),
-              ],
-            ),
-            Expanded(
-              flex: 1,
-              child: SmartRefresher(
-                controller: _reController,
-                onRefresh: onRefresh,
-                onLoading: onLoading,
-                enablePullDown: true,
-                enablePullUp: true,
-                child: body(),
               ),
-            )
-          ],
-        ),
-      ),
+            ],
+          )),
     );
   }
 
@@ -771,48 +808,6 @@ class _HomePageState extends State<HomePage>
     }, (error) {});
   }
 
-  body() {
-    if (pageIndex == 1) {
-      return body1();
-    } else if (pageIndex == 0) {
-      return body2();
-    }
-  }
-
-  body1() {
-    if (data.length == 0) {
-      return SingleChildScrollView(child: noData());
-    } else {
-      return GridView.builder(
-          controller: _controller,
-          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
-              crossAxisCount: 2,
-              childAspectRatio: 164 / 261,
-              mainAxisSpacing: 8,
-              crossAxisSpacing: 8),
-          itemCount: data.length,
-          padding: EdgeInsets.only(left: 14, right: 14, top: 14, bottom: 65),
-          itemBuilder: (context, index) {
-            return MyViews().getGoodsItem(data[index], context);
-          });
-    }
-  }
-
-  body2() {
-    if (puShop.length == 0) {
-      return SingleChildScrollView(child: noData());
-    } else {
-      return ListView.builder(
-        controller: _controller,
-        itemBuilder: (BuildContext context, int index) {
-          return MyViews().pubShopItem(puShop[index], context);
-        },
-        itemCount: puShop.length,
-        padding: EdgeInsets.all(10),
-      );
-    }
-  }
-
   void addressSelection() {
     StateSetter ss;
     showModalBottomSheet(
@@ -934,3 +929,34 @@ class _HomePageState extends State<HomePage>
     );
   }
 }
+
+class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
+  _SliverAppBarDelegate({
+    @required this.minHeight,
+    @required this.maxHeight,
+    @required this.child,
+  });
+
+  final double minHeight;
+  final double maxHeight;
+  final Widget child;
+
+  @override
+  double get minExtent => minHeight;
+
+  @override
+  double get maxExtent => max(maxHeight, minHeight);
+
+  @override
+  Widget build(
+      BuildContext context, double shrinkOffset, bool overlapsContent) {
+    return new SizedBox.expand(child: child);
+  }
+
+  @override
+  bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
+    return maxHeight != oldDelegate.maxHeight ||
+        minHeight != oldDelegate.minHeight ||
+        child != oldDelegate.child;
+  }
+}

+ 116 - 0
lib/paegs/home_page/recommended_today_page.dart

@@ -0,0 +1,116 @@
+import 'package:bbyyy/my_tools/my_colors.dart';
+import 'package:bbyyy/my_tools/my_views.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+
+class RecommendedTodayPage extends StatefulWidget {
+  @override
+  _RecommendedTodayPageState createState() => _RecommendedTodayPageState();
+}
+
+class _RecommendedTodayPageState extends State<RecommendedTodayPage> {
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      body: Column(
+        children: [
+          MyViews().myAppBar('梆梆今日折扣', context, []),
+          Expanded(
+            child: GridView.builder(
+              padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
+              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+                  crossAxisCount: 2,
+                  childAspectRatio:
+                      164/261,
+                  crossAxisSpacing: 16,
+                  mainAxisSpacing: 16),
+              itemBuilder: (c, index) {
+                return Container(
+                  decoration: BoxDecoration(
+                    boxShadow: [
+                      BoxShadow(
+                        color: MyColors.c7FE1E1E1,
+                        blurRadius: 5.0,
+                      ),
+                    ],
+                    color: Colors.white,
+                    borderRadius: BorderRadius.circular(4),
+                  ),
+                  child: Column(
+                    children: [
+                      Padding(
+                        padding: const EdgeInsets.all(6.0),
+                        child: Row(
+                          children: [
+                            ClipRRect(
+                              child: MyViews().netImg('path', 20, 20),
+                              borderRadius: BorderRadius.circular(10),
+                            ),
+                            Container(
+                              child: Text(
+                                'name',
+                                style: TextStyle(
+                                    color: MyColors.c999999, fontSize: 10),
+                              ),
+                              margin: EdgeInsets.only(left: 5),
+                            ),
+                          ],
+                        ),
+                      ),
+                      Container(
+                        height: 1,
+                        color: MyColors.cF0F0F0,
+                      ),
+                      MyViews().netImg(
+                          'path',
+                          (MediaQuery.of(context).size.width - 48) / 2,
+                          (MediaQuery.of(context).size.width - 48) / 2,
+                          placeholder: 'images/svg/goodsDefImg.svg'),
+                      Container(
+                        height: 1,
+                        color: MyColors.cF0F0F0,
+                      ),
+                      Padding(
+                        padding: const EdgeInsets.only(top: 6.0,left: 6,right: 6),
+                        child: Text(
+                          '8.9元充10元话费',
+                          style: TextStyle(color: MyColors.c333333, fontSize: 12),
+                        ),
+                      ),
+                      Padding(
+                        padding: const EdgeInsets.only(bottom: 6.0,left: 6,right: 6),
+                        child: Row(
+                          children: [
+                            Text(
+                              '¥8.90',
+                              style: TextStyle(
+                                  color: MyColors.cFF4233,
+                                  fontSize: 15,
+                                  fontWeight: FontWeight.bold),
+                            ),
+                            Container(
+                              decoration: BoxDecoration(
+                                border:
+                                    Border.all(color: MyColors.cFF4233, width: 1),
+                                borderRadius: BorderRadius.circular(10),
+                              ),
+                              height: 20,width: 50,
+                              child: Text('详情',style: TextStyle(color: MyColors.cFF4233,fontSize: 12),),
+                              alignment: Alignment.center,
+                            )
+                          ],mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                        ),
+                      )
+                    ],
+                    crossAxisAlignment: CrossAxisAlignment.start,
+                  ),
+                );
+              },
+              itemCount: 20,
+            ),
+          ),
+        ],
+      ),
+    );
+  }
+}