Skip to content

Commit

Permalink
1.5
Browse files Browse the repository at this point in the history
改版订单创建,返回真实接口参数,优化订单管理界面
  • Loading branch information
zlaazlaa committed Sep 24, 2022
1 parent b330331 commit d9693d5
Show file tree
Hide file tree
Showing 17 changed files with 488 additions and 42 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.Meiyong"
android:usesCleartextTraffic="true">
<activity
android:name=".NewNobodyCarOrder"
android:exported="false" />
<activity
android:name=".youtube"
android:exported="false" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/example/meiyong/GPSGetClass.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GPSGetClass {
.add("coorType", "bd09ll")//BaiduMap
// .add("coorType", "GCJ02")//GoogleMap
// .add("token", GPSLoginInformation.data.token)
.add("token", "8e1f56bf0e78669fdf774c91c55ed0f147047d1eb4b2ecf7284c90924c0b30ff")
.add("token", GPSLoginInformation.data.token)
.build()
http.GPSOkHttp.post("/locator-app/redis/getGps", GetGPSFormBody, object : Callback {
override fun onFailure(call: Call, e: IOException) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/example/meiyong/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class MainActivity : AppCompatActivity() {
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)

// val GPSSSS = GPSGetClass()
// GPSSSS.LoginGPS()
val GPSSSS = GPSGetClass()
GPSSSS.LoginGPS()

// GetAMapWrapper().getAMapWrapper(this)

Expand Down
24 changes: 20 additions & 4 deletions app/src/main/java/com/example/meiyong/ManageOrders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.meiyong.MyApplication.Companion.context
import com.example.meiyong.ReturnDataClass.OrderCancelReturn.OrderCancelReturn
import com.example.meiyong.ReturnDataClass.OrderListReturn.OrderListReturn
import com.example.meiyong.ReturnDataClass.OrderReturn.Body
import com.google.android.material.button.MaterialButton
Expand Down Expand Up @@ -87,11 +88,14 @@ class ManageOrders : AppCompatActivity() {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.order_information_card, parent, false)
val viewHolder = ViewHolder(view)
viewHolder.cuiOrder.setOnClickListener {
Toast.makeText(context, "催促成功,将优先安排配送", Toast.LENGTH_LONG).show()
}
viewHolder.cancelOrder.setOnClickListener {
val jsonObject = JSONObject()
val id = viewHolder.orderId.text.toString().toLong()
val status = viewHolder.orderStatus.text.toString()
if (status.toInt() <= 3) {
if (status.toInt() <= -1) {
Toast.makeText(context, "订单未在派送", Toast.LENGTH_LONG).show()
} else {
jsonObject
Expand All @@ -103,11 +107,23 @@ class ManageOrders : AppCompatActivity() {
}

override fun onResponse(call: Call, response: Response) {
val responseData = response.body.toString()
val responseData = response.body?.string()
Looper.prepare()
Toast.makeText(context, responseData, Toast.LENGTH_LONG).show()
val gson = Gson()

if (responseData != null) {
val orderCancelReturn =
gson.fromJson(responseData, OrderCancelReturn::class.java)
var text = ""
if (orderCancelReturn.status == 200) {
text = "取消成功"
} else {
text = "订单当前状态不允许取消"
}
Toast.makeText(context, text, Toast.LENGTH_LONG).show()
Log.e("OKHTTP_CANCEL_ORDER", responseData)
}
Looper.loop()
Log.e("OKHTTP_CANCEL_ORDER", responseData)
}

})
Expand Down
146 changes: 146 additions & 0 deletions app/src/main/java/com/example/meiyong/NewNobodyCarOrder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package com.example.meiyong

import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Looper
import android.util.Log
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import com.example.meiyong.MyApplication.Companion.context
import com.example.meiyong.ReturnDataClass.OrderCancelReturn.OrderCancelReturn
import com.example.meiyong.ReturnDataClass.OrderCreateReturn.OrderCreateReturn
import com.example.meiyong.ReturnDataClass.OrderListReturn.OrderListReturn
import com.google.android.material.button.MaterialButton
import com.google.gson.Gson
import http.OkHttp
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Response
import org.json.JSONObject
import org.w3c.dom.Text
import java.io.IOException

class NewNobodyCarOrder : AppCompatActivity() {
private val item_address =
arrayOf("梅苑", "兰苑", "竹苑", "菊苑", "桃苑", "李苑", "柳苑", "桂苑", "荷苑", "樱苑", "青教")

private val item_time =
arrayOf("9:00-11:00", "11:00-13:00", "13:00-15:00", "15:00-17:00", "17:00-19:00")

@SuppressLint("CutPasteId")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_new_nobody_car_order)
findViewById<TextView>(R.id.detail_address_textview).text = item_address[0]
findViewById<LinearLayout>(R.id.set_time_linear).setOnClickListener {
setTime()
}
findViewById<LinearLayout>(R.id.detail_address).setOnClickListener {
alertDialogListen()
}
findViewById<ImageButton>(R.id.set_adress).setOnClickListener {
alertDialogListen()
}
findViewById<MaterialButton>(R.id.confirm_address).setOnClickListener {
val receiveName = findViewById<TextView>(R.id.name).text
val receivePhone = findViewById<TextView>(R.id.phone_number_to_send).text
val packagePos =
findViewById<TextView>(R.id.Pos1).text.toString() + "-" + findViewById<TextView>(R.id.Pos2).text.toString() + "-" + findViewById<TextView>(
R.id.Pos3
).text.toString()
val jsonObjects = JSONObject()
jsonObjects
.put("userId", UserInformation.userId)
.put("expectedTime", findViewById<TextView>(R.id.time_set_is).text.toString())
.put("deliveryAddress", 2)
.put("receiverName", receiveName.toString())
.put("phone", receivePhone.toString().toLong())
// .put("deliveryAddress", 1)
.put("packagePos", packagePos)
.put("stationId", 2)
.put("status", 1)
OkHttp.post("/Order", jsonObjects, object : Callback {
override fun onFailure(call: Call, e: IOException) {
Toast.makeText(context, "网络连接错误,请检查本地网络连接", Toast.LENGTH_LONG).show()
Log.e("OKHTTP_NEW_ORDER", e.toString())
}

override fun onResponse(call: Call, response: Response) {
Looper.prepare()
val responseData = response.body?.string()
val gson = Gson()
if (responseData != null) {
Log.e("OKHTTP_NEW_ORDER", responseData)
val returnData = gson.fromJson(responseData, OrderCreateReturn::class.java)
if (returnData.status == 500) {
Toast.makeText(context, "驿站正在休息,请稍后再试", Toast.LENGTH_LONG).show()
} else {
Toast.makeText(context, "订单创建成功", Toast.LENGTH_LONG).show()
finish()
}
}
Looper.loop()
}
})
}
}

fun alertDialogListen() {
val txt = findViewById<TextView>(R.id.detail_address_textview)
var nowNumber = 0
for ((i, e) in item_address.withIndex())
if (e == txt.text) {
nowNumber = i
break
}
val alertDialog = AlertDialog.Builder(this)
.setTitle("请选择") //默认为0表示选中第一个项目
.setSingleChoiceItems(
item_address, nowNumber
) { dialog, which ->
txt.text = item_address[which]
// Toast.makeText(this@SendExpress, "你单选了" + item[which], Toast.LENGTH_LONG).show()
}
.setPositiveButton(
"确认"
) { dialog, which ->
// txt.setText(item[which])
}
.setNegativeButton("取消") { dialog, which ->
txt.text = item_address[nowNumber]
}
.create()
alertDialog.show()
}

private fun setTime() {
val txt = findViewById<TextView>(R.id.time_set_is)
var nowNumber = 0
for ((i, e) in item_time.withIndex())
if (e == txt.text) {
nowNumber = i
break
}
val alertDialog = android.app.AlertDialog.Builder(this)
.setTitle("请选择") //默认为0表示选中第一个项目
.setSingleChoiceItems(
item_time, nowNumber
) { dialog, which ->
txt.text = item_time[which]
// Toast.makeText(this@SendExpress, "你单选了" + item[which], Toast.LENGTH_LONG).show()
}
.setPositiveButton(
"确认"
) { dialog, which ->
}
.setNegativeButton("取消") { dialog, which ->
txt.text = item_time[nowNumber]
}
.create()
alertDialog.show()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.meiyong.ReturnDataClass.OrderCancelReturn

class OrderCancelReturn(
val status: Int,
val err: String?,
val body: String?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.meiyong.ReturnDataClass.OrderCreateReturn

class OrderCreateReturn(
val status: Int,
val err: String?,
val body: Int?
)
6 changes: 3 additions & 3 deletions app/src/main/java/com/example/meiyong/SendExpress.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ class SendExpress : AppCompatActivity() {

val jsonObjects = JSONObject()
jsonObjects
.put("userId", UserInformation.userId.toString())
.put("userId", UserInformation.userId)
.put("expectedTime", findViewById<TextView>(R.id.time_set_is).text.toString())
.put("deliveryAddress", 2)
.put("receiverName", receiveName.toString())
.put("phone", receivePhone.toString())
.put("phone", receivePhone.toString().toInt())
// .put("deliveryAddress", 1)
.put("packagePos", "25-5-4")
.put("stationId", 2)
.put("status",1)
OkHttp.post("/Order", jsonObjects, object : Callback {
override fun onFailure(call: Call, e: IOException) {
TODO("Not yet implemented")
// TODO("Not yet implemented")
Log.e("OKHTTP_NEW_ORDER", e.toString())
}

Expand Down
73 changes: 54 additions & 19 deletions app/src/main/java/com/example/meiyong/data/Data.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.example.meiyong.data

import android.os.Looper
import android.util.Log
import com.example.meiyong.ReceiveClass.StudyjsonData
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.meiyong.MyApplication
import com.example.meiyong.R
import com.example.meiyong.ReceiveClass.StudyjsonExpressData
import com.example.meiyong.ReturnDataClass.OrderListReturn.OrderListReturn
import com.google.gson.Gson
import http.OkHttp
import okhttp3.Call
Expand All @@ -19,28 +25,57 @@ class Data {
"http://123.56.232.18:8080/serverdemo/tag/queryTagList?offset=1231321&pageCount=10&tagId=3&tagType=all&userId=33"

fun updateExpressData() {
expressList.clear()
OkHttp.sendOkHttpRequestGET(StudyAPIurl, object : Callback {
OkHttp.get("/Order/1/100", object : Callback {
override fun onFailure(call: Call, e: IOException) {
Log.e("OKHTTP_ORDER", e.toString())
}

override fun onResponse(call: Call, response: Response) {
val gson = Gson()
val responseData = response.body?.string()
// val typeOf = object : TypeToken<ArrayList<queryOrder>>() {}.type
Log.e("OKHTTP", "$responseData")
val express_list = gson.fromJson(responseData, StudyjsonData::class.java)
expressList.clear()
for ((cnt, ex) in express_list.data.data.withIndex()) {
expressList.add(cnt, ex)
}

// val express_list = gson.fromJson(responseData, queryOrder::class.java)
// for ((cnt, ex) in express_list) {
// expressList.add(cnt, ex)
// val responseData = response.body?.string()
// val gson = Gson()
// val orderReturn = gson.fromJson(responseData, OrderListReturn::class.java)
// Log.e("OKHTTP_GSON", "$responseData")
// if (orderReturn.status == 200) {
// expressList = orderReturn.body!!
// val recyclerView = findViewById<RecyclerView>(R.id.orders_list)
// recyclerView.layoutManager = LinearLayoutManager(MyApplication.context)
// recyclerView.adapter = OrderListAdapter()
// } else {
// Looper.prepare();
// Toast.makeText(MyApplication.context, "用户未登录", Toast.LENGTH_LONG).show()
// finish()
// Looper.loop()
//
// }
}

override fun onFailure(call: Call, e: IOException) {
Log.e("OKHTTP", "ERROR")
}
})
}


// fun updateExpressData() {
// expressList.clear()
// OkHttp.sendOkHttpRequestGET(StudyAPIurl, object : Callback {
// override fun onResponse(call: Call, response: Response) {
// val gson = Gson()
// val responseData = response.body?.string()
//// val typeOf = object : TypeToken<ArrayList<queryOrder>>() {}.type
// Log.e("OKHTTP", "$responseData")
// val express_list = gson.fromJson(responseData, OrderListReturn::class.java)
// expressList.clear()
// for ((cnt, ex) in express_list.data.data.withIndex()) {
// expressList.add(cnt, ex)
// }
//
//// val express_list = gson.fromJson(responseData, queryOrder::class.java)
//// for ((cnt, ex) in express_list) {
//// expressList.add(cnt, ex)
//// }
// }
//
// override fun onFailure(call: Call, e: IOException) {
// Log.e("OKHTTP", "ERROR")
// }
// })
// }
}
Loading

0 comments on commit d9693d5

Please sign in to comment.