| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- import 'dart:convert';
- import 'package:bbyyy/beans/goods_bean_entity.dart';
- import 'package:bbyyy/beans/my_shop_bean_entity.dart';
- import 'package:bbyyy/https/MyDio.dart';
- import 'package:bbyyy/https/url.dart';
- import 'package:bbyyy/my_tools/AsperctRaioImage.dart';
- import 'package:bbyyy/my_tools/dims.dart';
- import 'package:bbyyy/my_tools/event_bus.dart';
- import 'package:bbyyy/my_tools/global.dart';
- import 'package:bbyyy/my_tools/my_colors.dart';
- import 'package:bbyyy/my_tools/my_cookie.dart';
- import 'package:bbyyy/my_tools/my_tools.dart';
- import 'package:bbyyy/my_tools/my_views.dart';
- import 'package:bbyyy/paegs/chat_page/chat_page.dart';
- import 'package:bbyyy/paegs/gang_page/gang_in_page/gang_in_page.dart';
- import 'package:bbyyy/paegs/place_an_order_page/place_an_order_page.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- class ProductDetailsPage extends StatefulWidget {
- GoodsBeanDataData data;
- ProductDetailsPage(this.data);
- @override
- _ProductDetailsPageState createState() => _ProductDetailsPageState();
- }
- class _ProductDetailsPageState extends State<ProductDetailsPage> {
- int statusIndex = 0;
- _ProductDetailsPageState();
- MyShopBeanDataData shop;
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- queryStoreInformation();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: MyColors.cF7F7F7,
- body: Column(
- children: [
- MyViews().myAppBar(
- '商品详情',
- context,
- shop != null && shop.ownerUid == MyCookie().getUID()
- ? [
- GestureDetector(
- onTap: () {
- showSimpleDialog(
- '确认下架商品(${widget.data.title})', context, () {
- Navigator.pop(context);
- MyDio().update({
- 'key': 'commodity',
- 'values': {
- 'id': widget.data.id,
- 'on_sale': false,
- }
- }, (response, hasError) {
- if (!hasError) {
- showToast('已下架');
- Navigator.pop(context);
- EventBus().emit('商品变动');
- }
- }, (error) {});
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- border:
- Border.all(color: MyColors.cFF4233, width: 1),
- borderRadius: BorderRadius.circular(12.5),
- ),
- height: 25,
- width: 50,
- child: MyViews().myText('下架', MyColors.cFF4233, 14),
- alignment: Alignment.center,
- ),
- ),
- GestureDetector(
- onTap: () {
- showSimpleDialog(
- '确认删除商品(${widget.data.title})', context, () {
- Navigator.pop(context);
- MyDio().del({
- 'key': 'commodity',
- 'ids': [widget.data.id]
- }, (response, hasError) {
- if (!hasError) {
- showToast('删除成功');
- Navigator.pop(context);
- EventBus().emit('商品变动');
- }
- }, (error) {});
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- margin: EdgeInsets.symmetric(horizontal: 10),
- decoration: BoxDecoration(
- color: MyColors.cFF4233,
- borderRadius: BorderRadius.circular(12.5),
- ),
- height: 25,
- width: 50,
- child: MyViews().myText('删除', Colors.white, 14),
- alignment: Alignment.center,
- ),
- ),
- ]
- : []),
- Expanded(
- child: Stack(
- children: [
- SingleChildScrollView(
- child: Column(
- children: [
- MyViews().netImg(
- imgURL(widget.data.coverPath), 314, double.infinity,
- placeholder: 'images/svg/goodsDefImg.svg'),
- Container(
- color: Colors.white,
- padding: EdgeInsets.fromLTRB(15, 15, 15, 18),
- child: Column(
- children: [
- Container(
- margin: EdgeInsets.only(bottom: 11),
- child: Text(
- '${widget.data.title}',
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 15,
- height: 1.4),
- ),
- ),
- Row(
- children: [
- Row(
- children: [
- Text(
- '¥',
- style: TextStyle(
- color: MyColors.cFF4233,
- fontSize: 14,
- height: 1),
- ),
- Text(
- '${widget.data.price}',
- style: TextStyle(
- color: MyColors.cFF4233,
- fontSize: 20,
- height: 1),
- ),
- Container(
- width: 8,
- ),
- Text(
- '价格¥',
- style: TextStyle(
- color: MyColors.c999999,
- fontSize: 13,
- height: 1),
- ),
- Text(
- '${widget.data.originalPrice}',
- style: TextStyle(
- color: MyColors.c999999,
- fontSize: 13,
- decoration:
- TextDecoration.lineThrough,
- height: 1),
- ),
- ],
- crossAxisAlignment: CrossAxisAlignment.end,
- ),
- Text(
- '库存:${widget.data.stock}',
- style: TextStyle(
- color: MyColors.c666666, fontSize: 14),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- )
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- Container(
- color: Colors.white,
- child: Column(
- children: [
- MyViews().myText('商品描述', MyColors.c333333, 14),
- Container(
- child: MyViews().myText(
- '${widget.data.description}',
- MyColors.c666666,
- 12),
- margin: EdgeInsets.only(top: 5),
- )
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- alignment: Alignment.centerLeft,
- padding:
- EdgeInsets.symmetric(horizontal: 14, vertical: 12),
- margin: EdgeInsets.only(top: 5),
- ),
- Container(
- color: Colors.white,
- child: MyViews().myText('商品详情', MyColors.c333333, 14),
- alignment: Alignment.centerLeft,
- margin: EdgeInsets.only(top: 5, bottom: 2),
- padding:
- EdgeInsets.symmetric(horizontal: 14, vertical: 12),
- ),
- Column(
- children: images(),
- ),
- Container(
- height: 10,
- )
- ],
- ),
- ),
- GestureDetector(
- onTap: () {
- toGangPage();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- bottomRight: Radius.circular(21),
- bottomLeft: Radius.circular(21),
- ),
- color: Colors.white),
- height: 56,
- padding: EdgeInsets.only(left: 16, right: 14),
- child: Row(
- children: [
- ClipRRect(
- child: MyViews()
- .netImg(imgURL(widget.data.shopPic), 40, 40),
- borderRadius: BorderRadius.all(Radius.circular(20)),
- ),
- Expanded(
- child: Container(
- margin: EdgeInsets.only(left: 10),
- child: MyViews().myText(
- widget.data.shopName, MyColors.c333333, 15),
- ),
- ),
- Container(
- child: MyViews().myText('进店逛逛', Colors.white, 12),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(12),
- color: MyColors.cFF4233),
- height: 24,
- width: 60,
- alignment: Alignment.center,
- ),
- // Container(
- // decoration: BoxDecoration(
- // color: MyColors.cFFCD74,
- // borderRadius: BorderRadius.circular(10),
- // ),
- // child: Icon(
- // Icons.chevron_right,
- // color: Colors.white,
- // size: 20,
- // ),
- // height: 20,
- // width: 20,
- // alignment: Alignment.center,
- // )
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- Container(
- color: Colors.white,
- child: SafeArea(
- top: false,
- child: Container(
- padding: EdgeInsets.symmetric(horizontal: 37),
- width: double.infinity,
- height: 60,
- child: Row(
- children: [
- Expanded(
- child: GestureDetector(
- onTap: () {
- queryShopMembers();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(20),
- bottomLeft: Radius.circular(20),
- ),
- border: Border.all(
- color: MyColors.cFF4233, width: 1)),
- height: 40,
- child:
- MyViews().myText('联系卖家', MyColors.cFF4233, 14),
- alignment: Alignment.center),
- ),
- ),
- Expanded(
- child: GestureDetector(
- onTap: () {
- MyTools().toPage(context,
- PlaceAnOrderPage(widget.data), (then) {});
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(20),
- bottomRight: Radius.circular(20),
- ),
- color: MyColors.cFF4233),
- height: 40,
- child: MyViews().myText('立即下单', Colors.white, 14),
- alignment: Alignment.center),
- ),
- )
- ],
- ),
- ),
- ),
- )
- ],
- ),
- );
- }
- images() {
- List<Widget> imgs = [];
- widget.data.pictures.split(',').forEach((element) {
- imgs.add(AsperctRaioImage.network(imgURL(element),
- builder: (context, snapshot, url) {
- return MyViews().netImg(
- imgURL(element),
- (snapshot.data.height.toDouble() / 5) /
- (snapshot.data.width.toDouble() / 5) *
- MediaQuery.of(context).size.width,
- MediaQuery.of(context).size.width,
- placeholder: 'images/svg/goodsDefImg.svg');
- }));
- });
- return imgs;
- }
- List<MyShopBeanDataData> member = [];
- List<MyShopBeanDataData> helper = [];
- queryShopMembers() {
- MyShopBeanDataData chatWith = MyShopBeanDataData();
- chatWith.userName = widget.data.userName;
- chatWith.userUid = widget.data.userUid;
- chatWith.userPic = widget.data.userPic;
- MyTools().toPage(context, ChatPage(chatWith, widget.data), (then) {});
- // MyDio().query({
- // "key": "shop_user",
- // "filters": {
- // "conditions": ["shop_uid==${data.shopUid}", "review_state==1"]
- // },
- // "dims": shopUserDims,
- // "paging": [1, 2000]
- // }, (response, hasError) {
- // if (!hasError) {
- // MyShopBeanEntity entity =
- // MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
- // member = entity.data.data;
- // helper.clear();
- // member.forEach((element) {
- // if (element.role == shopUserStaff) {
- // helper.add(element);
- // }
- // });
- // MyShopBeanDataData chatWith;
- //
- // if(helper.length==0){
- // chatWith = member[member.indexWhere((element) => element.role==shopUserOwner)];
- // }else{
- // chatWith = helper[Random().nextInt(helper.length)];
- // }
- // MyTools().toPage(context, ChatPage(chatWith,data), (then){});
- // }
- // }, (error) {});
- }
- void toGangPage() {
- navigatorKey.currentState
- .push(MaterialPageRoute(builder: (context) => GangInPage(shop, null)));
- }
- void queryStoreInformation() {
- MyDio().query({
- "key": "shop_user",
- "filters": {
- "conditions": ["shop_uid==${widget.data.shopUid}"]
- },
- "dims": shopUserDims,
- "paging": [1, 1],
- "order_by": ["shop_name,DESC"]
- }, (response, hasError) {
- if (!hasError) {
- MyShopBeanEntity entity =
- MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
- shop = entity.data.data[0];
- setState(() {});
- }
- }, (error) {});
- }
- }
|