import 'dart:convert'; import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/data/user_entity.dart'; import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/min.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/receive_success.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:huixiang/view_widget/separator.dart'; import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:url_launcher/url_launcher.dart'; class UnionDetailsPage extends StatefulWidget { final Map arguments; UnionDetailsPage({this.arguments}); @override State createState() { return _UnionDetailsPage(); } } class _UnionDetailsPage extends State { ApiService apiService; @override void dispose() { super.dispose(); refreshController.dispose(); } @override void initState() { super.initState(); SharedPreferences.getInstance().then((value) => { apiService = ApiService(Dio(), context: context, token: value.getString('token')), queryStoreInfo(), }); } StoreInfo storeInfo; List activitys; queryStoreInfo() async { BaseData baseData = await apiService .queryStoreInfo(widget.arguments["id"]) .catchError((error) { refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { refreshController.refreshCompleted(); storeInfo = StoreInfo.fromJson(baseData.data); activitys = storeInfo.informationVOPageVO.list .map((e) => Activity.fromJson(e)) .toList(); if (mounted) setState(() {}); } else { refreshController.refreshFailed(); } } RefreshController refreshController = RefreshController(); @override Widget build(BuildContext context) { return Scaffold( appBar: MyAppBar( background: Color(0xFFF7F7F7), title: storeInfo == null ? "" : storeInfo.storeName, titleColor: Colors.black87, titleSize: 18.sp, leadingColor: Colors.black, ), body: Column( children: [ Expanded( child: SmartRefresher( controller: refreshController, enablePullDown: true, enablePullUp: false, header: MyHeader(), physics: BouncingScrollPhysics(), onRefresh: queryStoreInfo, child: SingleChildScrollView( physics: NeverScrollableScrollPhysics(), child: Column( children: [ AspectRatio( aspectRatio: 1, child: GestureDetector( onTap: () {}, child: Container( margin: EdgeInsets.fromLTRB(16, 20, 16, 8), padding: EdgeInsets.fromLTRB(10, 20, 10, 14), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(8)), boxShadow: [ BoxShadow( color: Colors.black.withAlpha(25), offset: Offset(0, 1), blurRadius: 12, spreadRadius: 0, ) ], ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ AspectRatio( aspectRatio: 1.8, child: buildSwiper(), ), Expanded( child: Container( margin: EdgeInsets.only( left: 10.w, right: 10.w, top: 16.h, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text( storeInfo != null ? storeInfo.storeName : "", style: TextStyle( fontSize: 16.sp, color: Colors.black, fontWeight: FontWeight.bold, ), ), Expanded( child: Container( alignment: Alignment.centerRight, child: Text( S.of(context).ren( storeInfo != null ? storeInfo .perCapitaConsumption : "", ), style: TextStyle( fontSize: 14.sp, color: Color(0xFF353535), ), ), ), ) ], ), Text( storeInfo != null ? storeInfo.address : "", maxLines: 2, textAlign: TextAlign.justify, style: TextStyle( color: Color(0xFF353535), fontSize: 12.sp, ), ), Row( children: itemServer( storeInfo != null ? storeInfo.businessService : "", ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.end, children: [ Expanded( child: Text( S.of(context).yingyeshijian(storeInfo == null ? "" : (storeInfo.openStartTime == null && storeInfo.openEndTime == null) ? S.of(context).quantian : "${storeInfo.openStartTime.substring(0, storeInfo.openStartTime.lastIndexOf(":"))} - ${storeInfo.openEndTime.substring(0, storeInfo.openEndTime.lastIndexOf(":"))}"), style: TextStyle( color: Color(0xFF353535), fontSize: 12.sp, ), )), SizedBox( width: 16.w, ), InkWell( onTap: () { if (storeInfo == null || storeInfo.latitude == null || storeInfo.longitude == null || storeInfo.latitude == "" || storeInfo.longitude == "") return; Navigator.of(context).pushNamed( '/router/location_map', arguments: { "lat": storeInfo.latitude, "lng": storeInfo.longitude, "storeName": storeInfo.storeName, }); }, child: Image.asset( "assets/image/icon_union_location.png", width: 24.w, height: 24.h, ), ), SizedBox( width: 16.w, ), InkWell( onTap: () { showCallMobile(); }, child: Image.asset( "assets/image/icon_union_call.png", width: 24.w, height: 24.h, ), ) ], ), ], ), ), flex: 1, ) ], ), ), ), ), buildVip(), Container( margin: EdgeInsets.only(top: 10.h, bottom: 10.h), child: ItemTitle( text: S.of(context).youhuiquan, imgPath: "assets/image/icon_union_coupons.png", ), ), (storeInfo != null && storeInfo.couponVOList != null) ? buildCoupon() : Container( width: double.infinity, height: 50.h, alignment: Alignment.center, child: Text( S.of(context).zanwuyouhuiquankelingqu, style: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.bold, color: Color(0xFFA0A0A0), ), ), ), Container( margin: EdgeInsets.only(top: 20.h, bottom: 20.h), child: ItemTitle( text: S.of(context).xindianhuodong, imgPath: "assets/image/icon_union_start_store.png", ), ), (activitys != null && activitys.length > 0) ? Container( margin: EdgeInsets.only(bottom: 30.h), child: AspectRatio( aspectRatio: 1.55, child: buildSwiper2Bottom(), ), ) : Container( width: double.infinity, height: 30.h, margin: EdgeInsets.only(bottom: 30.h), alignment: Alignment.center, child: Text( S.of(context).muqianzanwuxingdianhuodong, style: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.bold, color: Color(0xFFA0A0A0), ), ), ), ], ), ), ), flex: 1, ), InkWell( onTap: _loginMin, child: Container( padding: EdgeInsets.only(top: 16.h, bottom: 16.h), decoration: BoxDecoration( color: isEnable() ? Color(0xFF32A060) : Color(0xFFD8D8D8), borderRadius: BorderRadius.only( topLeft: Radius.circular(4), topRight: Radius.circular(4), ), ), alignment: Alignment.center, child: Text( isEnable() ? S.of(context).jinrushangdian : S.of(context).zanwuxianshangjindian, style: TextStyle( fontSize: 16.sp, color: isEnable() ? Colors.white : Color(0xFFA0A0A0), fontWeight: FontWeight.bold, ), ), ), ), ], ), ); } bool isEnable() { if (storeInfo == null) return false; if (storeInfo.mini == null) return false; String miniAppId = storeInfo.mini.miniAppId; if (miniAppId == null || miniAppId == "" || storeInfo.mini.miniVersion == null || storeInfo.mini.miniVersion == "" || storeInfo.mini.miniDownloadUrl == null || storeInfo.mini.miniDownloadUrl == "") { return false; } else { return true; } } Widget buildVip() { return Container( margin: EdgeInsets.symmetric( vertical: (storeInfo != null && storeInfo.isVip) ? 12.h : 20.h, horizontal: 16.w), padding: EdgeInsets.all(16), decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage("assets/image/icon_vip_bg.png"), ), ), child: (storeInfo != null && storeInfo.isVip) ? Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [ Text( S.of(context).huiyuanyue, style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.bold, color: Colors.white, ), ), SizedBox( width: 8.w, ), Text( "¥${(storeInfo != null && storeInfo.memberSource != null) ? storeInfo.memberSource.balance : ""}", style: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.bold, color: Colors.white, ), ), ], ), Container( color: Colors.white, width: 1.w, height: 20.h, ), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [ Text( S.of(context).huiyuanjifen, style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.bold, color: Colors.white, ), ), SizedBox( width: 8.w, ), Text( (storeInfo != null && storeInfo.memberSource != null) ? "${storeInfo.memberSource.integral}" : "", style: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.bold, color: Colors.white, ), ), ], ), ], ), SizedBox( height: 10.h, ), Text( S.of(context).gongxinichengweibendianhuiyuan, style: TextStyle( fontSize: 10.sp, fontWeight: FontWeight.bold, color: Color(0xFFEDC98E), ), ) ], ) : Row( children: [ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.asset( "assets/image/icon_vip.png", width: 36.w, height: 20.h, ), SizedBox( height: 2.h, ), Text( S.of(context).chengweidianpuzhuanshuhuiyuan, style: TextStyle( fontSize: 10.sp, color: Color(0xCFFFFFFF), fontWeight: FontWeight.bold, ), ), ], ), flex: 1, ), InkWell( onTap: () { receiveVip(); }, child: RoundButton( text: isReceive ? S.of(context).dianwolingqu : S.of(context).yilingqu, textColor: isReceive ? Colors.white : Color(0xFF484D66), backgroup: isReceive ? Color(0xFF242B45) : Colors.white, padding: EdgeInsets.symmetric(vertical: 5.h, horizontal: 16.w), radius: 14, ), ), ], ), ); } bool isReceive = true; Widget buildCoupon() { return Container( height: 109.h, child: ListView.builder( itemCount: (storeInfo != null && storeInfo.couponVOList != null) ? storeInfo.couponVOList.length : 0, physics: BouncingScrollPhysics(parent: PageScrollPhysics()), scrollDirection: Axis.horizontal, itemBuilder: (context, position) { return Container( width: MediaQuery.of(context).size.width * 0.784, margin: EdgeInsets.only(left: 6.w), child: AspectRatio( aspectRatio: 2.86, child: Stack( children: [ Image.asset( "assets/image/icon_union_coupons_bg.png", fit: BoxFit.fill, width: double.infinity, height: double.infinity, ), Container( padding: EdgeInsets.only( left: 24.w, right: 24.w, bottom: 17.h, top: 11.h, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( margin: EdgeInsets.only(left: 5), child: Text.rich(TextSpan(children: [ TextSpan( text: (storeInfo != null && storeInfo.couponVOList != null && storeInfo .couponVOList[position].bizType == 1) ? "¥" : "", style: TextStyle( fontSize: 22.sp, color: Color(0xFFFF7A1A), fontWeight: FontWeight.bold, ), ), TextSpan( text: (storeInfo != null && storeInfo.couponVOList != null && storeInfo .couponVOList[position].bizType == 1) ? "${double.tryParse(storeInfo.couponVOList[position].discountAmount).toInt()}" : (storeInfo != null && storeInfo.couponVOList != null && storeInfo.couponVOList[position] .bizType == 5) ? S.of(context).duihuanquan : "${storeInfo.couponVOList[position].discountPercent / 10}折", style: TextStyle( fontSize: 36.sp, color: Color(0xFFFF7A1A), fontWeight: FontWeight.bold, ), ), ])), alignment: Alignment.center, ), Container( margin: EdgeInsets.only( top: 12.h, bottom: 12.h, left: 15.w, right: 24.w, ), child: MySeparator( width: 1.w, height: 5.h, color: Color(0xFF979797), ), ), Expanded( child: Container( margin: EdgeInsets.only( bottom: 12.h, top: 12.h, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( (storeInfo != null && storeInfo.couponVOList != null) ? storeInfo .couponVOList[position].couponName : "", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 10.sp, fontWeight: FontWeight.bold, color: Color(0xFF727272), ), ), Text( (storeInfo != null && storeInfo.couponVOList != null) ? (storeInfo.couponVOList[position] .bizType == 1 ? S.of(context).manlijiandaijinquan( double.tryParse(storeInfo .couponVOList[position] .fullAmount) .toInt(), double.tryParse(storeInfo .couponVOList[position] .discountAmount) .toInt()) : S.of(context).quanchangzhe(storeInfo .couponVOList[position] .discountPercent)) : "", // (storeInfo != null && storeInfo.couponVOList != null) ? storeInfo.couponVOList[position].couponImg : "", // S.of(context).manlijiandaijinquan(30, 5), overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 12.sp, fontWeight: FontWeight.bold, color: Color(0xFFFF7A1A), ), ), Text( S.of(context).youxiaoqizhi( (storeInfo != null && storeInfo.couponVOList != null && storeInfo.couponVOList[position] .useStartTime != null && storeInfo.couponVOList[position] .useEndTime != null) ? "${storeInfo.couponVOList[position].useStartTime.replaceAll("-", ".").split(" ")[0]}-${storeInfo.couponVOList[position].useEndTime.replaceAll("-", ".").split(" ")[0]}" : "", ), overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle( fontSize: 8.sp, color: Color(0xFFA29E9E), ), ), ], ), ), ), InkWell( onTap: () { if (storeInfo != null && storeInfo.couponVOList != null && storeInfo.couponVOList[position].status == 0) { receiveCoupon( storeInfo.couponVOList[position].id); } }, child: Container( height: 25.h, child: RoundButton( text: (storeInfo != null && storeInfo.couponVOList != null && storeInfo.couponVOList[position].status > 0) ? S.of(context).yilingqu : S.of(context).lingqu, textColor: Colors.white, backgroup: (storeInfo != null && storeInfo.couponVOList != null && storeInfo.couponVOList[position].status > 0) ? Colors.grey : Color(0xFF32A060), padding: EdgeInsets.fromLTRB(8, 4, 8, 4), fontSize: 12.sp, ), ), ), ], ), ) ], ), ), ); }, ), ); } ///领取优惠券 receiveCoupon(couponId) async { BaseData baseData = await apiService.receiveCoupon(couponId); if (baseData != null && baseData.isSuccess) { queryStoreInfo(); showAlertDialog(); } } /// 领取成功弹窗 showAlertDialog() { //显示对话框 showDialog( context: context, builder: (BuildContext context) { return ReceiveSuccess(); }, ); } ///领取VIP receiveVip() async { BaseData baseData = await apiService.minLogin(storeInfo.id); if (baseData != null && baseData.isSuccess) { SmartDialog.showToast(S.of(context).lingquchenggong, alignment: Alignment.center); setState(() { isReceive = false; }); } } Widget buildSwiper2Bottom() { return Container( child: Swiper( viewportFraction: 0.95, loop: false, itemBuilder: (context, position) { return InkWell( onTap: () { if (widget.arguments["source"] != null && widget.arguments["source"] == activitys[position].id) { Navigator.of(context).pop(); } else { Navigator.of(context).pushNamed('/router/store_detail_page', arguments: { "activityId": activitys[position].id, "source": widget.arguments["id"] }); } }, child: Container( margin: EdgeInsets.symmetric(horizontal: 5.w), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), boxShadow: [ BoxShadow( color: Color(0x0D000000), offset: Offset(0, 3), blurRadius: 14, spreadRadius: 0, ) ], ), child: Stack( children: [ Container( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ MImage( (activitys != null && activitys.length > position) ? activitys[position].coverImg : "", aspectRatio: 2.2, radius: BorderRadius.only( topRight: Radius.circular(8), topLeft: Radius.circular(8), ), fit: BoxFit.cover, errorSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png", ), Container( padding: EdgeInsets.all(8), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( (activitys != null && activitys.length > position) ? activitys[position].storeName : "", style: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.bold, color: Color(0xFF000000), ), ), SizedBox( height: 4.h, ), Text( (activitys != null && activitys.length > position) ? activitys[position].mainTitle : "", style: TextStyle( fontSize: 12.sp, fontWeight: FontWeight.bold, color: Color(0xFF727272), ), ), ], ), ), ], ), ), Positioned( top: 0, right: 0, child: Container( padding: EdgeInsets.symmetric( vertical: 4.h, horizontal: 8.w, ), decoration: BoxDecoration( color: Colors.black.withAlpha(76), borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8), topRight: Radius.circular(8), ), ), child: Text( (activitys != null && activitys.length > position) ? activitys[position].startTime.split(" ")[0] : "", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 12.sp, color: Color(0xD9FFFFFF), ), ), ), ), ], ), ), ); }, itemCount: (activitys != null && activitys.length > 0) ? activitys.length : 0, ), ); } Widget buildSwiper() { return Container( child: Swiper( pagination: SwiperPagination( alignment: Alignment.bottomCenter, builder: DotSwiperPaginationBuilder( size: 8.w, activeSize: 8.w, space: 5.w, activeColor: Colors.white, color: Colors.white.withAlpha(76), ), ), itemBuilder: (context, position) { return Container( margin: EdgeInsets.only(left: 10.w, right: 10.w), child: MImage( (storeInfo != null && storeInfo.bannerList != null && position < storeInfo.bannerList.length) ? storeInfo.bannerList[position].imgUrl : "", fit: BoxFit.cover, radius: BorderRadius.circular(4), errorSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png", ), ); }, itemCount: (storeInfo != null && storeInfo.bannerList != null) ? storeInfo.bannerList.length : 1), ); } //{"uid":"1412687522458238976", // "userInfo":{"headimg":"https:\/\/pos.upload.gznl.top\/admin\/2021\/07\/4ed055e5-5341-4080-a6f0-fe97c62d078f.jpg", // "balance":null, // "money":"0.00", // "phone":"13800138000", // "isBind":true, // "nickname":"你这橘子洋气呀" // }, // "baseURL":"https:\/\/pos-test.api.lotus-wallet.com\/app\/", // "shopId":"1344490596986781696", // "tenantCode":"1177", // "position":"30.554638,114.34394500000002", // "token":"Bearer eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX3R5cGUiOiJNSU5JIiwibmFtZSI6IiIsInRva2VuX3R5cGUiOiJ0b2tlbiIsInVzZXJpZCI6IjE0MTI2ODc1MjI0NTgyMzg5NzYiLCJhY2NvdW50IjoiIiwiZXhwIjoxNjI2Nzk1Nzc0LCJuYmYiOjE2MjY3NjY5NzR9.cggcx_vqTozKS-z9uygjV4uA2yHQ4eWssMAngd2c-i0"} printMin() async { String miniAppId = storeInfo.mini.miniAppId; print("print isExistsApp: ${await Min.isExistsApp(miniAppId)}"); print("print getAppBasePath: ${await Min.getAppBasePath(miniAppId)}"); print("print currentPageUrl: ${await Min.currentPageUrl()}"); print("print runingAppid: ${await Min.runingAppid()}"); // print("print getAppVersionInfo: ${await Min.getAppVersionInfo(miniAppId)}"); } _loginMin() async { if (storeInfo == null) return; if (!isEnable()) { SmartDialog.showToast(S.of(context).zanbuzhichixianshangdiancan, alignment: Alignment.center); return; } BaseData baseData = await apiService.minLogin(storeInfo.id); if (baseData != null && baseData.isSuccess) { UserEntity userEntity = UserEntity.fromJson(baseData.data); startMin(userEntity.token, userEntity.userId); } } startMin(token, userId) async { if (storeInfo == null) return; if (storeInfo.mini == null) return; if (!(await Min.isInitialize())) { await Min.initialize(); } printMin(); String miniAppId = storeInfo.mini.miniAppId; String filePath = ""; if (Platform.isAndroid) { filePath = (await getExternalStorageDirectory()).path; } else { filePath = (await getApplicationDocumentsDirectory()).path; } filePath = "$filePath/$miniAppId.wgt"; if (!(await Min.isExistsApp(miniAppId))) { await downloadWgt(miniAppId, filePath); await Min.reloadWgt(miniAppId, filePath); } else { String version = await Min.getAppVersionInfo(storeInfo.mini.miniAppId); if (version != storeInfo.mini.miniVersion) { await downloadWgt(miniAppId, filePath); await Min.reloadWgt(miniAppId, filePath); } } //baseURL : 'http://192.168.10.130:8765/app/', // 本地 //baseURL : 'http://192.168.10.236:8766/app/', // 本地 // baseURL : 'https://pos-test.api.lotus-wallet.com/app/', //测试 // baseURL : 'https://pos.api.lotus-wallet.com/app/', //线上 // socketUrl: 'ws://192.168.10.130:9999/cart', // 本地 // socketUrl : 'wss://pos-test.api.lotus-wallet.com:10005/cart', //测试 // socketUrl : 'wss://pos.api.lotus-wallet.com:10015/cart', //线上 SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); String nickname = sharedPreferences.getString("nick"); String mobile = sharedPreferences.getString("mobile"); String user = sharedPreferences.getString('user'); String latitude = sharedPreferences.getString("latitude"); String longitude = sharedPreferences.getString("longitude"); print(user); UserInfo userInfo = UserInfo.fromJson(jsonDecode(user)); Min.startMin(miniAppId, { "token": "Bearer $token", "shopId": widget.arguments["id"], "tenantCode": storeInfo.tenantCode, if (latitude != null && longitude != null) "position": "$latitude,$longitude", "baseURL": "https://pos.api.lotus-wallet.com/app/", "uid": userId, "userInfo": { "nickname": nickname, "headimg": userInfo.headimg, "balance": userInfo.balance, "money": userInfo.money, "phone": mobile, "isBind": userInfo.isBind, }, }); } Function state; double progressValue = 0; String downText = "正在下载中..."; downloadWgt(appid, savePath) async { downText = S.of(context).zhengzaixiazaizhong; showCupertinoDialog( context: context, barrierDismissible: true, builder: (context) { return Material( type: MaterialType.transparency, child: StatefulBuilder(builder: (context, status) { state = status; return Center( child: Container( width: 130.w, height: 130.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Colors.white, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 40.h, width: 40.w, child: CircularProgressIndicator( value: progressValue, backgroundColor: Colors.yellow, color: Colors.blue, valueColor: AlwaysStoppedAnimation(Colors.red), ), ), Text( downText, style: TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold, ), ), ], ), ), ); }), ); }); Response response = await Dio() .download(storeInfo.mini.miniDownloadUrl, savePath, onReceiveProgress: (progress, max) { progressValue = progress.toDouble() / max.toDouble(); // print("print progressValue: $progressValue"); state(() {}); }); if (response.statusCode == 200) { downText = "下载完成"; SharedPreferences.getInstance().then((value) { value.setStringList( "miniAppid", (value.getStringList("miniAppid") != null ? value.getStringList("miniAppid") : []) ..add(appid)); }); state(() {}); Future.delayed(Duration(seconds: 1), () { if (Navigator.canPop(context)) { Navigator.of(context).pop(); } }); } else { print("print 下载失败"); } } List itemServer(String businessService) { if (businessService == null || businessService == "") return []; var list = businessService.split(","); return list .map((e) => Container( margin: EdgeInsets.only(right: 8.w), child: RoundButton( height: 14.h, text: "$e", backgroup: Color(0xFFFF7A1A), padding: EdgeInsets.only( left: 2.w, right: 2.w, ), fontSize: 10.sp, textColor: Colors.white, ), )) .toList(); } showCallMobile() { showCupertinoModalPopup( context: context, builder: (contetx) { return CupertinoActionSheet( title: Text(S.of(context).bodadianhua), actions: [ if (storeInfo != null && storeInfo.headMobile != null && storeInfo.headMobile != "") CupertinoActionSheetAction( child: Text(storeInfo.headMobile), onPressed: () { callMobile(storeInfo.headMobile); Navigator.of(context).pop(); }, isDefaultAction: true, isDestructiveAction: false, ), ], cancelButton: CupertinoActionSheetAction( onPressed: () { Navigator.of(context).pop(); }, child: Text(S.of(context).quxiao), isDestructiveAction: true, ), ); }); } callMobile(mobile) async { String url = "tel:$mobile"; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } }