Browse Source

文章html富文本点击跳转,

使用正则表达式:ubb 转 html ,
ff_new
w-R 3 years ago
parent
commit
aed7869897
  1. 2
      lib/community/headlines/headlines_collection.dart
  2. 8
      lib/retrofit/min_api.dart
  3. 2
      lib/retrofit/min_api.g.dart
  4. 8
      lib/retrofit/retrofit_api.dart
  5. 2
      lib/retrofit/retrofit_api.g.dart
  6. 4
      lib/union/union_page.dart
  7. 27
      lib/web/web_view/web_content.dart

2
lib/community/headlines/headlines_collection.dart

@ -107,7 +107,7 @@ class _HeadlinesCollection extends State<HeadlinesCollection> {
Container(
margin: EdgeInsets.only(right:4),
padding:EdgeInsets.only(left:2,right:2),
height: 16.h,
height:22.h,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:

8
lib/retrofit/min_api.dart

@ -21,8 +21,8 @@ import 'data/shoppingCart.dart';
part 'min_api.g.dart';
const base_url = "https://pos.api.lotus-wallet.com/app/"; ///
const baseUrl = "https://pos.api.lotus-wallet.com/app/"; ///
// const base_url = "https://pos.api.lotus-wallet.com/app/"; ///
// const baseUrl = "https://pos.api.lotus-wallet.com/app/"; ///
// const base_url = "http://user.prod.kunqi.lotus-wallet.com/app/"; ///222
@ -32,6 +32,10 @@ const baseUrl = "https://pos.api.lotus-wallet.com/app/"; ///正式
// const baseUrl = "http://192.168.10.236:8765/app/";///
const base_url = "http://192.168.10.142:8765/app/";///
const baseUrl = "http://192.168.10.142:8765/app/";///
// const base_url = "http://192.168.10.37:8766/app/";
// const baseUrl = "http://192.168.10.37:8766/app/";

2
lib/retrofit/min_api.g.dart

@ -9,7 +9,7 @@ part of 'min_api.dart';
class _MinApiService implements MinApiService {
_MinApiService(this._dio, {this.baseUrl}) {
ArgumentError.checkNotNull(_dio, '_dio');
baseUrl ??= 'https://pos.api.lotus-wallet.com/app/';
baseUrl ??= 'http://192.168.10.142:8765/app/';
}
final Dio _dio;

8
lib/retrofit/retrofit_api.dart

@ -53,8 +53,8 @@ import 'data/wx_pay.dart';
part 'retrofit_api.g.dart';
const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///
const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///
// const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///
// const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///
// const base_url = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
// const baseUrl = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
@ -66,8 +66,8 @@ const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式
// const baseUrl = "http://192.168.10.37:8766/app/";
// const base_url = "http://192.168.10.142:8766/app/";///
// const baseUrl = "http://192.168.10.142:8766/app/";///
const base_url = "http://192.168.10.142:8766/app/";///
const baseUrl = "http://192.168.10.142:8766/app/";///
@RestApi(baseUrl: baseUrl)
abstract class ApiService {

2
lib/retrofit/retrofit_api.g.dart

@ -9,7 +9,7 @@ part of 'retrofit_api.dart';
class _ApiService implements ApiService {
_ApiService(this._dio, {this.baseUrl}) {
ArgumentError.checkNotNull(_dio, '_dio');
baseUrl ??= 'https://pos.platform.lotus-wallet.com/app/';
baseUrl ??= 'http://192.168.10.142:8766/app/';
}
final Dio _dio;

4
lib/union/union_page.dart

@ -454,7 +454,7 @@ class _UnionPage extends State<UnionPage>
Expanded(
flex: 1,
child: Container(
height: 100.h,
// height: 100.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.end,
@ -610,7 +610,7 @@ class _UnionPage extends State<UnionPage>
return AlertDialog(
content: Container(
width: MediaQuery.of(context).size.width - 84,
height: 110.h,
height: 130.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,

27
lib/web/web_view/web_content.dart

@ -29,11 +29,34 @@ class WebContent extends StatefulWidget {
class _WebContent extends State<WebContent> {
@override
Widget build(BuildContext context) {
var htmlCnt = widget.activity?.content??widget.article?.content??"";
var regex = RegExp("\\[jump.*?\\].*?\\[/jump\\]");
var match = regex.allMatches(htmlCnt);
if(match.length > 0){
match.forEach((element) {
var viewType = RegExp("viewType=\"(.+?)\"").firstMatch(element.group(0)).group(1);
if(viewType == "text"){
var cnt = RegExp("\\](.*?)\\[").firstMatch(element.group(0)).group(1);
var storeId = RegExp("storeId=\"(.+?)\"").firstMatch(element.group(0)).group(1);
var storeName = RegExp("storeName=\"(.+?)\"").firstMatch(element.group(0)).group(1);
var tenantCode = RegExp("tenantCode=\"(.+?)\"").firstMatch(element.group(0)).group(1);
var textCnt = "<a storeName=\"${storeName}\" storeId=\"${storeId}\" tenantCode=\"${tenantCode}\" href=\"/\">${cnt}</a>";
htmlCnt = htmlCnt.replaceAll(element.group(0), textCnt);
}else if(viewType == "img"){
var cnt = RegExp("\\](.*?)\\[").firstMatch(element.group(0)).group(1);
var storeId = RegExp("storeId=\"(.+?)\"").firstMatch(element.group(0)).group(1);
var storeName = RegExp("storeName=\"(.+?)\"").firstMatch(element.group(0)).group(1);
var tenantCode = RegExp("tenantCode=\"(.+?)\"").firstMatch(element.group(0)).group(1);
var textCnt = "<img src=\"${cnt}\" storeName=\"${storeName}\" storeId=\"${storeId}\" tenantCode=\"${tenantCode}\" />";
htmlCnt = htmlCnt.replaceAll(element.group(0), textCnt);
}
});
}
return Html(
data: (widget.activity?.content??widget.article?.content??"")+"<a storeName=\"前进麦味烘焙*海峡姐妹茶(哈乐城店)\" storeId=\"1432164681279078400\" tenantCode=\"1175\" href=\"/\">立即购买</a><img storeName=\"前进麦味烘焙*海峡姐妹茶(哈乐城店)\" storeId=\"1432164681279078400\" tenantCode=\"1175\" src=\"https://pos.upload.gznl.top/MDAwMA==/2021/12/6edfe416-aaf9-4f0e-b2a4-4dc85db03489.jpg\" />",
data: htmlCnt,
// + "<a storeName=\"前进麦味烘焙*海峡姐妹茶(哈乐城店)\" storeId=\"1432164681279078400\" tenantCode=\"1175\" href=\"/\">立即购买</a><img storeName=\"前进麦味烘焙*海峡姐妹茶(哈乐城店)\" storeId=\"1432164681279078400\" tenantCode=\"1175\" src=\"https://pos.upload.gznl.top/MDAwMA==/2021/12/6edfe416-aaf9-4f0e-b2a4-4dc85db03489.jpg\" />",
style: {
"html": Style(
backgroundColor: Colors.white

Loading…
Cancel
Save