123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 |
- import 'dart:convert';
- import 'package:flustars/flustars.dart' as flustars;
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:fluwx/fluwx.dart' as fluwx;
- import 'package:liftmanager/common/common.dart';
- import 'package:liftmanager/internal/account/provider/user_provider.dart';
- import 'package:liftmanager/internal/bbs/model/expert_model.dart';
- import 'package:liftmanager/internal/wode/model/share_model.dart';
- import 'package:liftmanager/net/api_service.dart';
- import 'package:liftmanager/utils/toast.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- class Qrshare extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- return QrshareState();
- }
- }
- class QrshareState extends State<Qrshare> with AutomaticKeepAliveClientMixin {
- UserProvider provider = UserProvider();
- @override
- void initState() {
- // getMemberAllMenu();
- super.initState();
- getExpertDetail();
- getPayMoneyList();
- }
- bool _hasData = false;
- double total = 0.0;
- Records detailObj;
- Future getExpertDetail() async {
- await NewApiService().getExpertDetail(
- flustars.SpUtil.getString(Constant.userId), onSuccess: (res) {
- if (res != null) {
- detailObj = res;
- if (detailObj.requestCode == null || detailObj.qrCodeUrl == null) {
- getQrCode();
- } else {
- _hasData = true;
- }
- print(123456);
- print(jsonEncode(res));
- setState(() {});
- }
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- Future getQrCode() async {
- await NewApiService().getQrCode(onSuccess: (res) {
- getExpertDetail();
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- List<ShareModel> recordlist;
- Future getPayMoneyList() async {
- await NewApiService().getPayMoneyList(onSuccess: (res) {
- if (res != null) {
- recordlist = res;
- recordlist.forEach((element) {
- total += element.rebate;
- });
- print(123456);
- print(jsonEncode(res));
- setState(() {});
- }
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- @override
- void dispose() {
- // provider.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- double height = MediaQuery.of(context).size.height;
- return Container(
- child:
- // ListView(
- // children: <Widget>[
- Container(
- // width: width,
- // height:ScreenUtil().setWidth(1619),
- // decoration: BoxDecoration(
- // image: DecorationImage(
- // image: AssetImage("assets/images/bg.png"),
- // fit: BoxFit.fitHeight,
- // )),
- child: Scaffold(
- // backgroundColor: Colors.transparent,
- appBar: MyAppBar(
- centerTitle: "邀请朋友",
- titleColor: Colors.white,
- backgroundColor: Color(0xff3071FF),
- ),
- body:
- // Container(child:null)
- _hasData
- ? Stack(
- children: [
- Positioned(
- // top: 20,
- child: ListView(
- padding: EdgeInsets.all(0.0),
- children: <Widget>[
- Container(
- width: width,
- height: ScreenUtil().setWidth(1619),
- decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage("assets/images/bg.png"),
- fit: BoxFit.cover,
- )),
- child: Column(children: <Widget>[
- Container(
- width: width,
- padding: EdgeInsets.only(
- top: ScreenUtil().setWidth(230)),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: <Widget>[
- ClipRRect(
- borderRadius: BorderRadius.all(
- Radius.circular(12)),
- child: Container(
- width: ScreenUtil().setWidth(200),
- height: ScreenUtil().setWidth(200),
- color: Colors.white,
- child: Column(
- // mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- SizedBox(height: 10),
- Row(
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: <Widget>[
- Text(
- "邀请码:",
- style: TextStyle(
- color:
- Color(0xff222222),
- fontSize: ScreenUtil()
- .setSp(14)),
- textAlign:
- TextAlign.start,
- ),
- SizedBox(width: 5),
- Text(
- detailObj.requestCode !=
- null
- ? detailObj
- .requestCode
- .toString()
- : "",
- style: TextStyle(
- color:
- Color(0xffff0000),
- fontSize: ScreenUtil()
- .setSp(18)),
- textAlign:
- TextAlign.start,
- ),
- ],
- ),
- SizedBox(height: 10),
- Container(
- child: GestureDetector(
- onLongPress: () {
- print(
- "object-------------------");
- fluwx
- .shareToWeChat(fluwx
- .WeChatShareImageModel(
- scene: fluwx
- .WeChatScene.SESSION,
- title: "请扫码",
- image: detailObj
- .qrCodeUrl ??
- "assets/images/no_image.png",
- ))
- .then((result) {},
- onError: (msg) {
- // print(msg);
- });
- },
- child: LoadNetworkImage(
- detailObj.qrCodeUrl,
- width: ScreenUtil()
- .setWidth(110),
- height: ScreenUtil()
- .setWidth(110),
- // alignment: Alignment.centerLeft,
- ),
- )),
- SizedBox(height: 10),
- Text(
- "长按二维码可分享",
- style: TextStyle(
- color: Color(0xff999999),
- fontSize: ScreenUtil()
- .setSp(14)),
- textAlign: TextAlign.start,
- ),
- ],
- ),
- ),
- )
- ])),
- // Container(
- // padding: EdgeInsets.only(top:ScreenUtil().setWidth(30)),
- // child:Row(
- // mainAxisAlignment: MainAxisAlignment.center,
- // children: <Widget>[
- // Container(
- // child:LoadAssetImage(
- // "wode/btn",
- // width: ScreenUtil().setWidth(136),
- // height: ScreenUtil().setWidth(36),
- // // alignment: Alignment.centerLeft,
- // ),
- // )
- // ],
- // )
- // ),
- Container(
- padding: EdgeInsets.only(
- top: ScreenUtil().setWidth(30)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- child: LoadAssetImage(
- "wode/btn_2",
- width: ScreenUtil().setWidth(345),
- height: ScreenUtil().setWidth(246),
- // alignment: Alignment.centerLeft,
- ),
- )
- ],
- )),
- Container(
- padding: EdgeInsets.only(
- top: ScreenUtil().setWidth(30)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- child: LoadAssetImage(
- "wode/btn_3",
- width: ScreenUtil().setWidth(345),
- height: ScreenUtil().setWidth(251),
- // alignment: Alignment.centerLeft,
- ),
- )
- ],
- )),
- Container(
- padding: EdgeInsets.only(
- top: ScreenUtil().setWidth(30)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- width: ScreenUtil().setWidth(370),
- height: ScreenUtil().setWidth(522),
- decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage(
- "assets/images/wode/btn_4.png"),
- fit: BoxFit.cover,
- )),
- child: Column(
- children: <Widget>[
- Container(
- padding: EdgeInsets.only(
- left: ScreenUtil()
- .setWidth(40),
- right: ScreenUtil()
- .setWidth(40),
- top: ScreenUtil()
- .setWidth(58)),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment
- .spaceBetween,
- children: <Widget>[
- Container(
- child: Text(
- "好友账号",
- style: TextStyle(
- color: Color(
- 0xffff0000),
- fontSize:
- ScreenUtil()
- .setSp(
- 17)),
- textAlign:
- TextAlign.start,
- ),
- ),
- Container(
- child: Text(
- "获得奖励($total)",
- style: TextStyle(
- color: Color(
- 0xffff0000),
- fontSize:
- ScreenUtil()
- .setSp(
- 17)),
- textAlign:
- TextAlign.start,
- ),
- ),
- ],
- )),
- SizedBox(
- height: ScreenUtil()
- .setWidth(20)),
- Container(
- height: ScreenUtil()
- .setWidth(360),
- // color: Colors.red,
- child: ListView(
- children: recordlist !=
- null &&
- recordlist
- .length >
- 0
- ? recordlist
- .map((item) {
- return Container(
- padding: EdgeInsets.only(
- left: ScreenUtil()
- .setWidth(
- 40),
- right: ScreenUtil()
- .setWidth(
- 40),
- top: ScreenUtil()
- .setWidth(
- 10),
- bottom: ScreenUtil()
- .setWidth(
- 10)),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment
- .spaceBetween,
- children: <
- Widget>[
- Container(
- child:
- Text(
- item.mobile ??
- "",
- style: TextStyle(
- color: Color(0xFF00D9FF),
- fontSize: ScreenUtil().setSp(14)),
- textAlign:
- TextAlign.start,
- ),
- ),
- Container(
- child:
- Text(
- "获得${item.rebate.toString()}元",
- style: TextStyle(
- color: Color(0xFF00D9FF),
- fontSize: ScreenUtil().setSp(14)),
- textAlign:
- TextAlign.start,
- ),
- ),
- ],
- ));
- }).toList()
- : <Widget>[]))
- ],
- ))
- ],
- )),
- ]),
- ),
- ],
- ))
- ],
- )
- : Center(
- child: Text("正在加载..."),
- ),
- ),
- )
- // ],
- // )
- );
- }
- @override
- bool get wantKeepAlive => true;
- }
|