sms_page.dart
3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/provider/SmsModel.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/app_bar.dart';
import 'package:one_key/widgets/common_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
class SmsPage extends StatefulWidget{
final String rid;//预订订单id
SmsPage(this.rid);
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new SmsPageState();
}
}
class SmsPageState extends State<SmsPage>{
SmsModel smsModel=new SmsModel();
UserModel userModel;
String smsContent="";//短信内容
@override
void initState() {
// TODO: implement initState
super.initState();
userModel=Provider.of<UserModel>(context,listen: false);
WidgetsBinding.instance.addPostFrameCallback((_){
_getSmsContent();
});
}
//获取短信内容
_getSmsContent() async {
Map<String,String> params={
"rid":widget.rid,
"sid":userModel.user.sellerid
};
String sms=await smsModel.getSmsContent(context, params);
setState(() {
smsContent=sms;
});
}
//发送短信
_sendSms(){
Map<String,String> params={
"rid":widget.rid,
"sid":userModel.user.sellerid
};
smsModel.sendSms(context, params);
}
@override
Widget build(BuildContext context) {
// TODO: implement build
return SafeArea(
child: DefaultTextStyle(style: TextStyle(decoration: TextDecoration.none), child: Container(
color: MyColours.color_ffffff,
child: Column(
children: <Widget>[
MyAppBar("发短信"),
Container(
alignment: Alignment.centerLeft,
margin: EdgeInsets.only(top: ScreenUtil().setHeight(30),left: ScreenUtil().setWidth(38)),
child: Text("已自动生成短信通知,可直接发送",style: TextStyle(color: MyColours.color_353535,fontSize: ScreenUtil().setSp(22)),),
),
Container(
width: ScreenUtil().setWidth(673),
margin: EdgeInsets.only(left:ScreenUtil().setWidth(38), right:ScreenUtil().setWidth(38), top:ScreenUtil().setWidth(38)),
padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(23),vertical: ScreenUtil().setHeight(36)),
decoration: BoxDecoration(
border: Border.all(color: MyColours.color_dbe3e3,width: ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setWidth(8))),
),
child: Text(smsContent,style: TextStyle(color: MyColours.color_353535,fontSize: ScreenUtil().setSp(26),))
),
Container(
margin: EdgeInsets.only(top: ScreenUtil().setHeight(143)),
child: Column(
children: <Widget>[
CommonButton(
width: 672,
height: 76,
fontSize: 26,
content: "直接发送",
state: 1,
onPress: (){
_sendSms();
},
),
VEmptyView(20),
CommonButton(
width: 672,
height: 76,
fontSize: 26,
content: "复制短信",
state: 0,
onPress: () async {
await Clipboard.setData(ClipboardData(text: smsContent));
Utils.showToast("复制成功!");
},
)
],
),
)
],
),
)),
);
}
}