Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-App
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Chad
2022-11-04 15:10:03 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d6f046aaf7d9533a0def822946473359bb448946
d6f046aa
1 parent
f1baba8a
修改代码
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
16 deletions
lib/apis/api_base.dart
lib/apis/api_order.dart
lib/payment/payment_sdk.dart
lib/poem/page/select_address_page.dart
lib/apis/api_base.dart
0 → 100644
View file @
d6f046a
import
'package:Parlando/apis/api_response.dart'
;
import
'package:Parlando/net/dio_utils.dart'
;
import
'package:dio/dio.dart'
;
import
'package:flutter/material.dart'
;
class
BaseApi
{
Future
<
Response
<
ApiResponse
<
T
>>>
post
<
T
>(
String
path
,
{
data
,
Map
<
String
,
dynamic
>?
queryParameters
,
Options
?
options
,
CancelToken
?
cancelToken
,
ProgressCallback
?
onSendProgress
,
ProgressCallback
?
onReceiveProgress
,
})
{
return
_getDio
().
post
<
ApiResponse
<
T
>>(
path
,
data:
data
,
queryParameters:
queryParameters
,
options:
options
,
cancelToken:
cancelToken
,
onSendProgress:
onSendProgress
,
onReceiveProgress:
onReceiveProgress
,
);
}
Dio
_getDio
()
{
return
DioUtils
.
instance
.
dio
;
}
}
lib/apis/api_order.dart
0 → 100644
View file @
d6f046a
import
'package:Parlando/apis/api_base.dart'
;
import
'package:dio/dio.dart'
;
import
'package:flutter/material.dart'
;
class
OrderApi
extends
BaseApi
{
OrderApi
.
_privateConstructor
();
static
final
OrderApi
_instance
=
OrderApi
.
_privateConstructor
();
static
OrderApi
get
request
{
return
_instance
;
}
Future
<
Response
>
createOrder
(
String
productId
)
{
return
post
(
"/order"
);
}
}
lib/payment/payment_sdk.dart
View file @
d6f046a
import
'dart:async'
;
import
'package:Parlando/apis/api_order.dart'
;
import
'package:flutter/material.dart'
;
import
'package:in_app_purchase/in_app_purchase.dart'
;
...
...
@@ -50,6 +51,7 @@ class PaymentSdk {
}
buy
(
ProductDetails
details
)
{
// OrderApi.request.createOrder()
final
PurchaseParam
purchaseParam
=
PurchaseParam
(
productDetails:
details
);
if
(
_isConsumable
(
details
))
{
InAppPurchase
.
instance
.
buyConsumable
(
purchaseParam:
purchaseParam
);
...
...
lib/poem/page/select_address_page.dart
View file @
d6f046a
...
...
@@ -21,14 +21,14 @@ class AddressSelectPage extends StatefulWidget {
}
class
AddressSelectPageState
extends
State
<
AddressSelectPage
>
{
List
<
nearby
.
Results
>
_
l
ist
=
[];
List
<
nearby
.
Results
>
_
nearByL
ist
=
[];
final
ScrollController
_controller
=
ScrollController
();
LatLng
?
_center
;
late
GoogleMapController
mapController
;
bool
isLoading
=
false
;
Map
<
MarkerId
,
Marker
>
markers
=
<
MarkerId
,
Marker
>{};
late
StreamSubscription
_locationSubscription
;
String
radius
=
"1000"
;
String
radius
Max
=
"1000"
;
String
apiKey
=
"AIzaSyDQZsMULyO-UtiSht4_MFi1uHT4BIqasjw"
;
nearby
.
NearbyPlacesResponse
nearbyPlacesResponse
=
nearby
.
NearbyPlacesResponse
();
...
...
@@ -70,15 +70,18 @@ class AddressSelectPageState extends State<AddressSelectPage> {
}
void
getNearbyPlaces
(
String
keyword
)
async
{
String
uri
=
'
${'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${_center?.latitude}
,
${_center?.longitude}
&radius=
$radius
'
}&
key
=
$apiKey
&
keyword
=
$keyword
';
String
host
=
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
;
String
location
=
'location=
${_center?.latitude}
,
${_center?.longitude}
'
;
String
radius
=
'radius=
$radiusMax
'
;
String
types
=
'type=point_of_interest'
;
String
uri
=
'
${'$host?$location&$radius'}
&key=
$apiKey
&keyword=
$keyword
&
$types
'
;
print
(
uri
);
var
url
=
Uri
.
parse
(
uri
);
var
response
=
await
http
.
post
(
url
);
nearbyPlacesResponse
=
nearby
.
NearbyPlacesResponse
.
fromJson
(
jsonDecode
(
response
.
body
));
_
l
ist = nearbyPlacesResponse.results!;
if (_
l
ist.isNotEmpty) {
selectItemLocation(_
l
ist[0]);
_
nearByL
ist
=
nearbyPlacesResponse
.
results
!;
if
(
_
nearByL
ist
.
isNotEmpty
)
{
selectItemLocation
(
_
nearByL
ist
[
0
]);
}
setState
(()
{
isLoading
=
false
;
...
...
@@ -102,13 +105,13 @@ class AddressSelectPageState extends State<AddressSelectPage> {
var
loaderView
=
const
GFLoader
().
expanded
(
flex:
11
);
var
realList
=
ListView
.
separated
(
controller:
_controller
,
itemCount: _
l
ist.length,
itemCount:
_
nearByL
ist
.
length
,
separatorBuilder:
(
_
,
index
)
=>
const
Divider
(),
itemBuilder:
(
_
,
index
)
{
var item = _
l
ist[index];
var
item
=
_
nearByL
ist
[
index
];
return
_AddressItem
(
isSelected:
item
.
isSelect
,
dat
e
: item,
dat
a
:
item
,
onTap:
()
{
selectItemLocation
(
item
);
},
...
...
@@ -130,6 +133,8 @@ class AddressSelectPageState extends State<AddressSelectPage> {
onMapCreated:
_onMapCreated
,
initialCameraPosition:
CameraPosition
(
target:
_center
??
const
LatLng
(
45.521563
,
-
122.677433
),
zoom:
16.0
),
markers:
Set
<
Marker
>.
of
(
markers
.
values
),
myLocationEnabled:
true
,
myLocationButtonEnabled:
true
,
).
expanded
(
flex:
9
);
return
Scaffold
(
...
...
@@ -144,7 +149,7 @@ class AddressSelectPageState extends State<AddressSelectPage> {
initButton
()
{
return
MyButton
(
onPressed:
()
{
var selected = _
l
ist.where((element) => element.isSelect);
var
selected
=
_
nearByL
ist
.
where
((
element
)
=>
element
.
isSelect
);
if
(
selected
.
isEmpty
)
{
Toast
.
show
(
'未选择地址!'
);
return
;
...
...
@@ -158,7 +163,7 @@ class AddressSelectPageState extends State<AddressSelectPage> {
void
buildMarkers
()
{
markers
.
clear
();
for (var value in _
l
ist) {
for
(
var
value
in
_
nearByL
ist
)
{
final
MarkerId
markerId
=
MarkerId
(
buildMarkerId
(
value
));
final
Marker
marker
=
Marker
(
icon:
value
.
isSelect
?
BitmapDescriptor
.
defaultMarker
:
BitmapDescriptor
.
defaultMarkerWithHue
(
BitmapDescriptor
.
hueBlue
),
...
...
@@ -183,7 +188,7 @@ class AddressSelectPageState extends State<AddressSelectPage> {
}
void
selectItemLocation
(
nearby
.
Results
item
)
{
for (var element in _
l
ist) {
for
(
var
element
in
_
nearByL
ist
)
{
element
.
isSelect
=
false
;
}
item
.
isSelect
=
true
;
...
...
@@ -201,12 +206,12 @@ class AddressSelectPageState extends State<AddressSelectPage> {
class
_AddressItem
extends
StatelessWidget
{
const
_AddressItem
({
Key
?
key
,
required this.dat
e
,
required
this
.
dat
a
,
this
.
isSelected
=
false
,
this
.
onTap
,
})
:
super
(
key:
key
);
final nearby.Results dat
e
;
final
nearby
.
Results
dat
a
;
final
bool
isSelected
;
final
GestureTapCallback
?
onTap
;
...
...
@@ -220,7 +225,7 @@ class _AddressItem extends StatelessWidget {
height:
50.0
,
child:
Row
(
children:
<
Widget
>[
Text('
$
{
dat
e
.
name
}
$
{
date
.
vicinity
}
').expanded(),
Text
(
'
${dat
a.name
}
'
).
expanded
(),
Visibility
(
visible:
isSelected
,
child:
const
Icon
(
Icons
.
done
,
color:
Colors
.
blue
))
],
),
...
...
Please
register
or
login
to post a comment