|
|
|
@ -1,11 +1,15 @@
|
|
|
|
|
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:fluttertoast/fluttertoast.dart'; |
|
|
|
|
import 'package:huixiang/generated/l10n.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'; |
|
|
|
@ -15,6 +19,7 @@ import 'package:huixiang/view_widget/item_title.dart';
|
|
|
|
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/separator.dart'; |
|
|
|
|
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.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'; |
|
|
|
@ -300,7 +305,7 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
|
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
InkWell( |
|
|
|
|
onTap: _startMin, |
|
|
|
|
onTap: _loginMin, |
|
|
|
|
child: Container( |
|
|
|
|
padding: EdgeInsets.only(top: 16.h, bottom: 16.h), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
@ -497,7 +502,14 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
|
|
|
|
|
Text( |
|
|
|
|
S.of(context).youxiaoqizhi( |
|
|
|
|
(storeInfo != null && |
|
|
|
|
storeInfo.couponVOList != null && storeInfo.couponVOList[position].useStartTime != null && storeInfo.couponVOList[position].useEndTime != 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]}" |
|
|
|
|
: "", |
|
|
|
|
), |
|
|
|
@ -626,7 +638,8 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
|
|
|
|
|
), |
|
|
|
|
child: Text( |
|
|
|
|
(storeInfo != null && storeInfo.promotionList != null) |
|
|
|
|
? storeInfo.promotionList[position].activityStartTime.split(" ")[0] |
|
|
|
|
? storeInfo.promotionList[position].activityStartTime |
|
|
|
|
.split(" ")[0] |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
@ -682,19 +695,46 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_startMin() async { |
|
|
|
|
printMin() async { |
|
|
|
|
print("print isExistsApp: ${await Min.isExistsApp("__UNI__ACD00DA")}"); |
|
|
|
|
print("print getAppBasePath: ${await Min.getAppBasePath()}"); |
|
|
|
|
print("print currentPageUrl: ${await Min.currentPageUrl()}"); |
|
|
|
|
print("print runingAppid: ${await Min.runingAppid()}"); |
|
|
|
|
print("print getAppVersionInfo: ${await Min.getAppVersionInfo("__UNI__ACD00DA")}"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_loginMin() async { |
|
|
|
|
if (storeInfo == null) return; |
|
|
|
|
BaseData baseData = await apiService.minLogin(storeInfo.id); |
|
|
|
|
if(baseData != null && baseData.isSuccess) { |
|
|
|
|
UserEntity userEntity = UserEntity.fromJson(baseData.data); |
|
|
|
|
startMin(userEntity.token, userEntity.userId); |
|
|
|
|
} else { |
|
|
|
|
Fluttertoast.showToast(msg: baseData.msg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
startMin(token, userId) async { |
|
|
|
|
if (storeInfo == null) return; |
|
|
|
|
if (!(await Min.isInitialize())) { |
|
|
|
|
await Min.initialize(); |
|
|
|
|
} |
|
|
|
|
printMin(); |
|
|
|
|
Min.clickListener(); |
|
|
|
|
if (!(await Min.isExistsApp("__UNI__ACD00DA"))) { |
|
|
|
|
await Min.reloadWgt("__UNI__ACD00DA", |
|
|
|
|
"/storage/emulated/0/Android/data/com.zsw.huixiang/files/__UNI__ACD00DA.wgt"); |
|
|
|
|
String filePath = ""; |
|
|
|
|
if(Platform.isAndroid) { |
|
|
|
|
filePath = (await getExternalStorageDirectory()).path; |
|
|
|
|
} else { |
|
|
|
|
filePath = (await getApplicationDocumentsDirectory()).path; |
|
|
|
|
} |
|
|
|
|
filePath = "$filePath/__UNI__ACD00DA.wgt"; |
|
|
|
|
|
|
|
|
|
await downloadWgt("__UNI__ACD00DA", filePath); |
|
|
|
|
await Min.reloadWgt("__UNI__ACD00DA",filePath); |
|
|
|
|
} |
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|
String token = sharedPreferences.getString("token"); |
|
|
|
|
String userId = sharedPreferences.getString("userId"); |
|
|
|
|
String nickname = sharedPreferences.getString("nick"); |
|
|
|
|
String mobile = sharedPreferences.getString("mobile"); |
|
|
|
|
String user = sharedPreferences.getString('user'); |
|
|
|
@ -714,4 +754,76 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
|
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Function state; |
|
|
|
|
double progressValue = 0; |
|
|
|
|
String downText = "正在下载中..."; |
|
|
|
|
|
|
|
|
|
downloadWgt(appid, savePath) async { |
|
|
|
|
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, |
|
|
|
|
height: 130, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
|
color: Colors.white, |
|
|
|
|
), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
SizedBox( |
|
|
|
|
//限制进度条的高度 |
|
|
|
|
height: 40.0, |
|
|
|
|
//限制进度条的宽度 |
|
|
|
|
width: 40, |
|
|
|
|
child: CircularProgressIndicator( |
|
|
|
|
value: progressValue, |
|
|
|
|
backgroundColor: Colors.yellow, |
|
|
|
|
color: Colors.blue, |
|
|
|
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.red), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
downText, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.black, |
|
|
|
|
fontSize: 16, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}), |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
Response response = await Dio().download( |
|
|
|
|
"https://qiniu.upload.gznl.top/__UNI__ACD00DA.wgt", |
|
|
|
|
savePath, |
|
|
|
|
onReceiveProgress: (progress, max) { |
|
|
|
|
progressValue = progress.toDouble() / max.toDouble(); |
|
|
|
|
print("print progressValue: $progressValue"); |
|
|
|
|
state(() {}); |
|
|
|
|
}); |
|
|
|
|
if (response.statusCode == 200) { |
|
|
|
|
downText = "下载完成"; |
|
|
|
|
state(() {}); |
|
|
|
|
Future.delayed(Duration(seconds: 1), () { |
|
|
|
|
if (Navigator.canPop(context)) { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|