|
|
@@ -0,0 +1,244 @@
|
|
|
+import 'dart:convert';
|
|
|
+
|
|
|
+import 'package:bbyyy/beans/my_shop_bean_entity.dart';
|
|
|
+import 'package:bbyyy/beans/offline_payment_bean_entity.dart';
|
|
|
+import 'package:bbyyy/beans/store_bean_entity.dart';
|
|
|
+import 'package:bbyyy/https/MyDio.dart';
|
|
|
+import 'package:bbyyy/https/url.dart';
|
|
|
+import 'package:bbyyy/my_tools/const.dart';
|
|
|
+import 'package:bbyyy/my_tools/dims.dart';
|
|
|
+import 'package:bbyyy/my_tools/easy_loading/easy_loading.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/pay_page/order_information_page.dart';
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter/services.dart';
|
|
|
+
|
|
|
+class PayToTheGangPage extends StatefulWidget {
|
|
|
+ int shopUid;
|
|
|
+
|
|
|
+ PayToTheGangPage(this.shopUid);
|
|
|
+
|
|
|
+ @override
|
|
|
+ _PayToTheGangPageState createState() => _PayToTheGangPageState();
|
|
|
+}
|
|
|
+
|
|
|
+class _PayToTheGangPageState extends State<PayToTheGangPage> {
|
|
|
+ TextEditingController _controller = TextEditingController();
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ // TODO: implement initState
|
|
|
+ super.initState();
|
|
|
+ Future.delayed(Duration.zero,(){
|
|
|
+ queryStoreInformation();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ return GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ MyTools().hideKeyboard(context);
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Scaffold(
|
|
|
+ body: Column(
|
|
|
+ children: [
|
|
|
+ MyViews().myAppBar('付款给帮主', context, []),
|
|
|
+ Expanded(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ if(store!=null)
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(17, 24, 17, 0),
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ ClipRRect(
|
|
|
+ child: MyViews()
|
|
|
+ .netImg(imgURL(store.picture), 24, 24),
|
|
|
+ borderRadius: BorderRadius.circular(12),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ child: MyViews().myText(
|
|
|
+ store.name, MyColors.c666666, 15),
|
|
|
+ margin: EdgeInsets.only(left: 10),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
+ borderRadius: BorderRadius.circular(4)),
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 17, vertical: 14),
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ MyViews().myText('付款金额', MyColors.c333333, 16),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 15),
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ '¥',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.c333333, fontSize: 30),
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: TextField(
|
|
|
+ inputFormatters: [
|
|
|
+ FilteringTextInputFormatter.allow(
|
|
|
+ RegExp("[0-9.]")),
|
|
|
+ ],
|
|
|
+ controller: _controller,
|
|
|
+ cursorColor: MyColors.cFF4233,
|
|
|
+ cursorWidth: 1.0,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ border: InputBorder.none,
|
|
|
+ disabledBorder: InputBorder.none,
|
|
|
+ enabledBorder: InputBorder.none,
|
|
|
+ focusedBorder: InputBorder.none,
|
|
|
+ hintText: '请输入金额',
|
|
|
+ hintStyle: TextStyle(
|
|
|
+ color: MyColors.c999999,
|
|
|
+ fontSize: 16),
|
|
|
+ isDense: true,
|
|
|
+ contentPadding: const EdgeInsets.fromLTRB(
|
|
|
+ 14, 4.5, 8, 4.5)),
|
|
|
+ maxLines: 1,
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.c333333,
|
|
|
+ fontSize: 32,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ height: 1.3,
|
|
|
+ letterSpacing: 0.2),
|
|
|
+ keyboardType: TextInputType.numberWithOptions(
|
|
|
+ decimal: true),
|
|
|
+ onChanged: (t) {
|
|
|
+ setState(() {});
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ generateOrders();
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: MyColors.cFF4233,
|
|
|
+ borderRadius: BorderRadius.circular(20)),
|
|
|
+ child: MyViews().myText('付款', Colors.white, 14),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ height: 40,
|
|
|
+ margin: EdgeInsets.only(
|
|
|
+ top: 20, bottom: 15, left: 17, right: 17),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成订单
|
|
|
+ generateOrders() {
|
|
|
+ EasyLoading.show();
|
|
|
+ try {
|
|
|
+ amount = double.parse(_controller.text.toString());
|
|
|
+ MyDio().save({
|
|
|
+ 'key': 'order',
|
|
|
+ 'object': {
|
|
|
+ 'uuid': generateMd5(reOS('付款给店主${DateTime.now()}')),
|
|
|
+ 'shop_uid': store.uid,
|
|
|
+ 'shop_pic': store.picture,
|
|
|
+ 'shop_name': store.name,
|
|
|
+ 'seller_pic': store.ownerPic,
|
|
|
+ 'seller_uid': store.ownerUid,
|
|
|
+ 'seller_name': store.ownerName,
|
|
|
+ 'buyer_name': MyCookie().getName(),
|
|
|
+ 'buyer_uid': MyCookie().getUID(),
|
|
|
+ 'buyer_pic': MyCookie().userBean.picture,
|
|
|
+ 'type': orderTypeOfflinePay,
|
|
|
+ 'amount': amount
|
|
|
+ }
|
|
|
+ }, (response, hasError) {
|
|
|
+ if (!hasError) {
|
|
|
+ OfflinePaymentBeanEntity entity = OfflinePaymentBeanEntity()
|
|
|
+ .fromJson(json.decode(response.data.toString()));
|
|
|
+ payTheOrder(entity.data);
|
|
|
+ }
|
|
|
+ }, (error) {});
|
|
|
+ } catch (e) {
|
|
|
+ showToast('请输入正确的金额');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ StoreBeanDataData store;
|
|
|
+ double amount;
|
|
|
+
|
|
|
+ void queryStoreInformation() {
|
|
|
+ MyDio().query({
|
|
|
+ "key": "shop",
|
|
|
+ "filters": {
|
|
|
+ "conditions": ["uid == ${widget.shopUid}"]
|
|
|
+ },
|
|
|
+ "dims": shopDims,
|
|
|
+ "paging": [1, 5]
|
|
|
+ }, (response, hasError) {
|
|
|
+ if (!hasError) {
|
|
|
+ StoreBeanEntity entity =
|
|
|
+ StoreBeanEntity().fromJson(json.decode(response.data.toString()));
|
|
|
+ store = entity.data.data[0];
|
|
|
+ setState(() {
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, (error) {});
|
|
|
+ }
|
|
|
+
|
|
|
+ void payTheOrder(int orderUID) {
|
|
|
+ _controller.clear();
|
|
|
+ MyTools().toPage(
|
|
|
+ context,
|
|
|
+ OrderInformationPage(
|
|
|
+ true,
|
|
|
+ orderType: orderTypeOfflineTransfer,
|
|
|
+ amount: amount,
|
|
|
+ uid: orderUID,
|
|
|
+ buyerUid: MyCookie().getUID(),
|
|
|
+ buyerName: MyCookie().getName(),
|
|
|
+ buyerPic: MyCookie().getPic(),
|
|
|
+ commodityCount: 1,
|
|
|
+ commodityTitle: '到店支付',
|
|
|
+ commodityCover: '',
|
|
|
+ sellName: store.ownerName,
|
|
|
+ sellPic: store.ownerPic,
|
|
|
+ sellUid: store.ownerUid,
|
|
|
+ ),
|
|
|
+ (then) {
|
|
|
+ if(then is int && then ==1){
|
|
|
+ Navigator.pop(context);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // MyTools().toPage(context, PayPage(orderUID, true, amount), (then) {
|
|
|
+ // if (then is String) {
|
|
|
+ // if (then == '支付成功') {
|
|
|
+ // Navigator.pop(context);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ }
|
|
|
+}
|