|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_html/flutter_html.dart';
|
|
|
|
import 'package:flutter_html/image_render.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/activity.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/article.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart';
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:huixiang/view_widget/share_dialog.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_defines.dart';
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_interface.dart';
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_map.dart';
|
|
|
|
|
|
|
|
class StoreDetailsPage extends StatefulWidget {
|
|
|
|
final Map<String, dynamic> arguments;
|
|
|
|
|
|
|
|
StoreDetailsPage({this.arguments});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _StoreDetailsPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
ApiService apiService;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
SharedPreferences.getInstance().then((value) {
|
|
|
|
apiService =
|
|
|
|
ApiService(Dio(), context: context, token: value.getString("token"));
|
|
|
|
queryHtml();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Activity activity;
|
|
|
|
Article article;
|
|
|
|
|
|
|
|
queryHtml() async {
|
|
|
|
BaseData baseData = await apiService.informationInfo(
|
|
|
|
widget.arguments["activityId"] ?? widget.arguments["articleId"]);
|
|
|
|
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
if (widget.arguments.containsKey("activityId")) {
|
|
|
|
activity = Activity.fromJson(baseData.data);
|
|
|
|
} else if (widget.arguments.containsKey("articleId")) {
|
|
|
|
article = Article.fromJson(baseData.data);
|
|
|
|
}
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
share() async {
|
|
|
|
// await registerWxApi(appId: "wx3b269e795ed23e5f", doOnAndroid: true, universalLink: "https://hx.lotus-wallet.com/app/");
|
|
|
|
// shareToWeChat(WeChatShareWebPageModel(
|
|
|
|
// "http://hx.lotus-wallet.com/index.html?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}",
|
|
|
|
// scene: WeChatScene.SESSION));
|
|
|
|
// SharesdkPlugin.showMenu();
|
|
|
|
SSDKMap params = SSDKMap()
|
|
|
|
..setGeneral(
|
|
|
|
activity != null
|
|
|
|
? activity.mainTitle
|
|
|
|
: article != null
|
|
|
|
? article.mainTitle
|
|
|
|
: "",
|
|
|
|
activity != null
|
|
|
|
? activity.viceTitle
|
|
|
|
: article != null
|
|
|
|
? article.viceTitle
|
|
|
|
: "",
|
|
|
|
[],
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"http://hx.lotus-wallet.com/index.html?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SSDKContentTypes.webpage);
|
|
|
|
|
|
|
|
SharesdkPlugin.uploadPrivacyPermissionStatus(1, (success) => {
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
builder: (context) {
|
|
|
|
return ShareDialog((platform){
|
|
|
|
if (platform == ShareSDKPlatforms.line) {
|
|
|
|
params.map["text"] = "${activity != null
|
|
|
|
? activity.viceTitle
|
|
|
|
: article != null
|
|
|
|
? article.viceTitle
|
|
|
|
: ""} http://hx.lotus-wallet.com/index.html?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}";
|
|
|
|
}
|
|
|
|
// shareFacebookCustom(context);
|
|
|
|
SharesdkPlugin.share(platform, params, (state, userData, contentEntity, error) {
|
|
|
|
print("分享成功!$state");
|
|
|
|
print("分享成功!$platform");
|
|
|
|
print("分享成功!$userData");
|
|
|
|
print("分享成功!$contentEntity");
|
|
|
|
print("分享成功!$error");
|
|
|
|
print("分享成功!");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void shareFacebookCustom(BuildContext context) {
|
|
|
|
SSDKMap params = SSDKMap()
|
|
|
|
..setFacebook(
|
|
|
|
"Share SDK Link Desc",
|
|
|
|
"http://ww4.sinaimg.cn/bmiddle/005Q8xv4gw1evlkov50xuj30go0a6mz3.jpg",
|
|
|
|
"http://www.mob.com",
|
|
|
|
"Share SDK",
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
"#MobData",
|
|
|
|
"Mob官网 - 全球领先的移动开发者服务平台",
|
|
|
|
SSDKFacebookShareTypes.native,
|
|
|
|
SSDKContentTypes.webpage);
|
|
|
|
params
|
|
|
|
..setFacebookAssetLocalIdentifier("73EC5698-20CF-4030-8FB2-CC0C80EF8156/L0/001,B2A42CA3-FA0F-45EC-92B2-F0F94A8A5A2B/L0/001,AA97F2F3-D2E4-43BB-8C2A-06D77480D7CA/L0/001,B220D191-2D5F-43E1-BF97-E3D7E61E86DB/L0/001,F064C692-79A1-4768-9530-1EFEA8360843/L0/001", "asdf");
|
|
|
|
SharesdkPlugin.share(ShareSDKPlatforms.facebook, params,
|
|
|
|
(SSDKResponseState state, userdata, contentEntity,
|
|
|
|
SSDKError error) {
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: MyAppBar(
|
|
|
|
action: Container(
|
|
|
|
margin: EdgeInsets.only(right: 10),
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
share();
|
|
|
|
},
|
|
|
|
child: Icon(
|
|
|
|
Icons.share,
|
|
|
|
size: 24,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
background: Color(0xFFF7F7F7),
|
|
|
|
leadingColor: Colors.black,
|
|
|
|
title: activity != null
|
|
|
|
? activity.mainTitle
|
|
|
|
: article != null
|
|
|
|
? article.mainTitle
|
|
|
|
: "",
|
|
|
|
titleSize: 18.sp,
|
|
|
|
titleColor: Colors.black,
|
|
|
|
),
|
|
|
|
body: Container(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
activity != null
|
|
|
|
? activity.mainTitle
|
|
|
|
: article != null
|
|
|
|
? article.mainTitle
|
|
|
|
: "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
InkWell(
|
|
|
|
child: Text(
|
|
|
|
"${activity != null ? activity.storeName : (article != null && article.author != null) ? article.author.name : ""}",
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
fontSize: 14.sp,
|
|
|
|
color: Colors.blue,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
if (activity != null) {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
'/router/union_detail_page',
|
|
|
|
arguments: {"id": activity.storeId});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 10,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
activity != null
|
|
|
|
? activity.createTime
|
|
|
|
: article != null
|
|
|
|
? article.createTime
|
|
|
|
: "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: Colors.grey,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Html(
|
|
|
|
data: activity != null
|
|
|
|
? activity.content
|
|
|
|
: article != null
|
|
|
|
? article.content
|
|
|
|
: "",
|
|
|
|
customImageRenders: {
|
|
|
|
base64DataUriMatcher(): base64ImageRender(),
|
|
|
|
assetUriMatcher(): assetImageRender(),
|
|
|
|
networkSourceMatcher(extension: "svg"):
|
|
|
|
svgNetworkImageRender(),
|
|
|
|
networkSourceMatcher(): networkImageRender(loadingWidget: () {
|
|
|
|
// return Image.asset("assets/image/default_1.png",);
|
|
|
|
return Container();
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|