我的设置样式 以及我的智能设备样式修改
This commit is contained in:
52
lib/pages/mh_page/component/jd.dart
Normal file
52
lib/pages/mh_page/component/jd.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'dart:convert';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class JDLauncher {
|
||||
/// 跳转京东店铺(App 优先)
|
||||
static Future<void> openShop(String shopUrlOrShortLink) async {
|
||||
final isShortLink = shopUrlOrShortLink.contains("3.cn");
|
||||
|
||||
if (isShortLink) {
|
||||
// 如果是短链接,比如 https://3.cn/xxxxx,直接尝试打开即可
|
||||
await _launchJD(shopUrlOrShortLink);
|
||||
} else {
|
||||
// 如果是普通店铺链接,比如 https://mall.jd.com/index-xxxxxxx.html
|
||||
final jdAppUrl = _buildJDAppUrl("m", {"url": shopUrlOrShortLink});
|
||||
await _launchJD(jdAppUrl, fallbackUrl: shopUrlOrShortLink);
|
||||
}
|
||||
}
|
||||
|
||||
/// 跳转京东商品详情页(传入 SKU)
|
||||
static Future<void> openProduct(String skuId) async {
|
||||
final webUrl = "https://item.jd.com/$skuId.html";
|
||||
final jdAppUrl = _buildJDAppUrl("productDetail", {"skuId": skuId});
|
||||
await _launchJD(jdAppUrl, fallbackUrl: webUrl);
|
||||
}
|
||||
|
||||
/// 构建京东 App 的 scheme 跳转 URL
|
||||
static String _buildJDAppUrl(String des, Map<String, dynamic> extraParams) {
|
||||
final params = {
|
||||
"category": "jump",
|
||||
"des": des,
|
||||
...extraParams,
|
||||
};
|
||||
final encoded = Uri.encodeComponent(jsonEncode(params));
|
||||
return "openapp.jdmobile://virtual?params=$encoded";
|
||||
}
|
||||
|
||||
/// 通用跳转逻辑(优先跳 App,失败跳网页)
|
||||
static Future<void> _launchJD(String url, {String? fallbackUrl}) async {
|
||||
try {
|
||||
final uri = Uri.parse(url);
|
||||
if (await canLaunchUrl(uri)) {
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} else if (fallbackUrl != null) {
|
||||
await launchUrl(Uri.parse(fallbackUrl), mode: LaunchMode.externalApplication);
|
||||
}
|
||||
} catch (_) {
|
||||
if (fallbackUrl != null) {
|
||||
await launchUrl(Uri.parse(fallbackUrl), mode: LaunchMode.externalApplication);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ class _EditBedPageState extends State<EditBedPage> {
|
||||
fontFamily: 'Readex Pro',
|
||||
letterSpacing: 0,
|
||||
color: Colors.white,
|
||||
fontSize: 26.rpx,
|
||||
fontSize: 36.rpx,
|
||||
),
|
||||
),
|
||||
))
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/mh_controller/message_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/component/jd.dart';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart';
|
||||
@@ -143,7 +144,7 @@ class _MinePageState extends State<NewMinePage> {
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 30.rpx, left: 60.rpx, bottom: 70.rpx),
|
||||
top: 30.rpx, left: 60.rpx, bottom: 190.rpx),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
@@ -305,7 +306,10 @@ class _MinePageState extends State<NewMinePage> {
|
||||
),
|
||||
_buildListTile('assets/img/icon/mall.svg', '网上商城',
|
||||
'最新的智能产品线上购买服务',
|
||||
path: ""),
|
||||
path: "", onTap: () {
|
||||
JDLauncher.openShop(
|
||||
"https://mall.jd.com/index-14587480.html");
|
||||
}),
|
||||
_buildListTile('assets/img/icon/address.svg',
|
||||
'地址管理', '用于收货和报修时联系您',
|
||||
path: "/addressListPage"),
|
||||
|
||||
Reference in New Issue
Block a user