《仿盒马》app开发技术分享-- 回收订单详情页(46)

简介: 上一节我们实现了订单列表的所有功能,展示了待取件、已取消、运输中、已完成等订单列表的数据展示,并且在对应的订单中点击功能按钮实现了订单的状态切换,这一节我们就要通过点击对应列表内的订单进入相应的订单详情页,展示当前订单的状态和对应的信息,当进入的是已完成订单时展示当前订单的收益,分别显示收入多少金额和对应的积分

技术栈

Appgallery connect

开发准备

上一节我们实现了订单列表的所有功能,展示了待取件、已取消、运输中、已完成等订单列表的数据展示,并且在对应的订单中点击功能按钮实现了订单的状态切换,这一节我们就要通过点击对应列表内的订单进入相应的订单详情页,展示当前订单的状态和对应的信息,当进入的是已完成订单时展示当前订单的收益,分别显示收入多少金额和对应的积分

功能分析

要实现订单详情查看的功能,首先需要在对应的item添加点击事件,传递当前的订单id过去详情页面,在详情页面接收对应的id,根据id查询当前对应的订单,展示到对应的组件内,然后根据订单内的weightid查询出当前订单的重量,件数,金额收益,积分收益,展示到已完成订单的详情内

代码实现

首先我们先吧对应的实体添加一下

//订单
class RecycleInfo {
   
    id: number;
    user_id: number = 0;
    nike_name: string;
    phone: string;
    address: string;
    day: string;
    start_time: string;
    end_time: string;
    msg: string;
    weight_id: string;
    create_time: string;
    express_code: string;
    express_people: string;
    express_company: string;
    order_type: number;
    logistics_id: number;

    constructor() {
   
    }



    setId(id: number): void {
   
        this.id = id;
    }

    getId(): number  {
   
        return this.id;
    }

    setUser_id(user_id: number): void {
   
        this.user_id = user_id;
    }

    getUser_id(): number  {
   
        return this.user_id;
    }

    setNike_name(nike_name: string): void {
   
        this.nike_name = nike_name;
    }

    getNike_name(): string  {
   
        return this.nike_name;
    }

    setPhone(phone: string): void {
   
        this.phone = phone;
    }

    getPhone(): string  {
   
        return this.phone;
    }

    setAddress(address: string): void {
   
        this.address = address;
    }

    getAddress(): string  {
   
        return this.address;
    }

    setDay(day: string): void {
   
        this.day = day;
    }

    getDay(): string  {
   
        return this.day;
    }

    setStart_time(start_time: string): void {
   
        this.start_time = start_time;
    }

    getStart_time(): string  {
   
        return this.start_time;
    }

    setEnd_time(end_time: string): void {
   
        this.end_time = end_time;
    }

    getEnd_time(): string  {
   
        return this.end_time;
    }

    setMsg(msg: string): void {
   
        this.msg = msg;
    }

    getMsg(): string  {
   
        return this.msg;
    }

    setWeight_id(weight_id: string): void {
   
        this.weight_id = weight_id;
    }

    getWeight_id(): string  {
   
        return this.weight_id;
    }

    setCreate_time(create_time: string): void {
   
        this.create_time = create_time;
    }

    getCreate_time(): string  {
   
        return this.create_time;
    }

    setExpress_code(express_code: string): void {
   
        this.express_code = express_code;
    }

    getExpress_code(): string  {
   
        return this.express_code;
    }

    setExpress_people(express_people: string): void {
   
        this.express_people = express_people;
    }

    getExpress_people(): string  {
   
        return this.express_people;
    }

    setExpress_company(express_company: string): void {
   
        this.express_company = express_company;
    }

    getExpress_company(): string  {
   
        return this.express_company;
    }

    setOrder_type(order_type: number): void {
   
        this.order_type = order_type;
    }

    getOrder_type(): number  {
   
        return this.order_type;
    }

    setLogistics_id(logistics_id: number): void {
   
        this.logistics_id = logistics_id;
    }

    getLogistics_id(): number  {
   
        return this.logistics_id;
    }

    static parseFrom(inputObject: any): RecycleInfo {
   
        let result = new RecycleInfo();
        if (!inputObject) {
   
            return result;
        }
        if (inputObject.id) {
   
            result.id = inputObject.id;
        }
        if (inputObject.user_id) {
   
            result.user_id = inputObject.user_id;
        }
        if (inputObject.nike_name) {
   
            result.nike_name = inputObject.nike_name;
        }
        if (inputObject.phone) {
   
            result.phone = inputObject.phone;
        }
        if (inputObject.address) {
   
            result.address = inputObject.address;
        }
        if (inputObject.day) {
   
            result.day = inputObject.day;
        }
        if (inputObject.start_time) {
   
            result.start_time = inputObject.start_time;
        }
        if (inputObject.end_time) {
   
            result.end_time = inputObject.end_time;
        }
        if (inputObject.msg) {
   
            result.msg = inputObject.msg;
        }
        if (inputObject.weight_id) {
   
            result.weight_id = inputObject.weight_id;
        }
        if (inputObject.create_time) {
   
            result.create_time = inputObject.create_time;
        }
        if (inputObject.express_code) {
   
            result.express_code = inputObject.express_code;
        }
        if (inputObject.express_people) {
   
            result.express_people = inputObject.express_people;
        }
        if (inputObject.express_company) {
   
            result.express_company = inputObject.express_company;
        }
        if (inputObject.order_type) {
   
            result.order_type = inputObject.order_type;
        }
        if (inputObject.logistics_id) {
   
            result.logistics_id = inputObject.logistics_id;
        }
        return result;
    }
}

export {
    RecycleInfo };


//规格
class WeightInfo {
   
    id: number;
    weight_id: number;
    weight: string;
    txt: string;
    integral: number;
    money: number;

    constructor() {
   
    }


    setId(id: number): void {
   
        this.id = id;
    }

    getId(): number  {
   
        return this.id;
    }

    setWeight_id(weight_id: number): void {
   
        this.weight_id = weight_id;
    }

    getWeight_id(): number  {
   
        return this.weight_id;
    }

    setWeight(weight: string): void {
   
        this.weight = weight;
    }

    getWeight(): string  {
   
        return this.weight;
    }

    setTxt(txt: string): void {
   
        this.txt = txt;
    }

    getTxt(): string  {
   
        return this.txt;
    }

    setIntegral(integral: number): void {
   
        this.integral = integral;
    }

    getIntegral(): number  {
   
        return this.integral;
    }

    setMoney(money: number): void {
   
        this.money = money;
    }

    getMoney(): number  {
   
        return this.money;
    }

}

export {
    WeightInfo };

首先添加对应的点击事件,在所有的列表都要添加上

 .onClick(()=>{
   
                router.pushUrl({
   url:"pages/recycle/order/RecycleOrderDetailsPage",params:{
   code:item.id}})
              })

然后在订单详情页面接收对应的id

 let params = (this.getUIContext().getRouter().getParams() as Record<string, string>)['code']
    if (params!=undefined&& params!=''){
   
      this.orderCode=params
    }

根据id查询出对应的订单详情

let databaseZone = cloudDatabase.zone('default');
    let condition = new cloudDatabase.DatabaseQuery(recycle_info);
    condition.equalTo("id",this.orderCode!)
    let listData = await databaseZone.query(condition);
    let json = JSON.stringify(listData)
    let data1:RecycleInfo[]= JSON.parse(json)
    this.orderInfo=data1[0]

拿到id对应的订单之后,我们根据当前订单的weightid查询出对应的重量、收益、积分等信息

    let condition1 = new cloudDatabase.DatabaseQuery(weight_info);
    condition1.equalTo("weight_id",data1[0].weight_id)
    let listData1 = await databaseZone.query(condition1);
    let json1 = JSON.stringify(listData1)
    let data:WeightInfo[]= JSON.parse(json1)
    this.weightInfo=data[0]

然后我们把对应的信息填充到组件上

```c
import { hilog } from '@kit.PerformanceAnalysisKit';
import { cloudDatabase } from '@kit.CloudFoundationKit';
import { CommonTopBar } from '../../widget/CommonTopBar';
import { recycle_info } from '../../clouddb/recycle_info';
import { RecycleInfo } from '../../entity/RecycleInfo';
import { weight_info } from '../../clouddb/weight_info';
import { WeightInfo } from '../../entity/WeightInfo';

@Entry
@Component
struct OrderDetailsPage {

@State orderInfo:RecycleInfo|null=null
@State orderCode:string=''
@State flag:boolean=false
@State titleStr:string=''
@State msgStr:string=''
@State weightInfo:WeightInfo|null=null

async aboutToAppear(): Promise {
let params = (this.getUIContext().getRouter().getParams() as Record)['code']
if (params!=undefined&& params!=''){
this.orderCode=params
}
let databaseZone = cloudDatabase.zone('default');
let condition = new cloudDatabase.DatabaseQuery(recycle_info);
condition.equalTo("id",this.orderCode!)
let listData = await databaseZone.query(condition);
let json = JSON.stringify(listData)
let data1:RecycleInfo[]= JSON.parse(json)
this.orderInfo=data1[0]

let condition1 = new cloudDatabase.DatabaseQuery(weight_info);
condition1.equalTo("weight_id",data1[0].weight_id)
let listData1 = await databaseZone.query(condition1);
let json1 = JSON.stringify(listData1)
let data:WeightInfo[]= JSON.parse(json1)
this.weightInfo=data[0]



hilog.info(0x0000, 'testTag', `Succeeded in querying data, result: ${JSON.parse(json)}`);
if (this.orderInfo?.order_type==0) {
  this.titleStr="待取件"
  this.msgStr='已通知快递小哥按时上门取件,请耐心等候'
}
if (this.orderInfo?.order_type==1) {
  this.titleStr="已取消"
  this.msgStr='订单已取消,感谢您的使用'
}
if (this.orderInfo?.order_type==2) {
  this.titleStr="运输中"
  this.msgStr='包裹已寄出,将会根据订单发放奖励'
}

if (this.orderInfo?.order_type==3) {
  this.titleStr="已完成"
  this.msgStr='奖励已发放'
}

this.flag=true

}
build() {
if (this.flag){
Column(){
CommonTopBar({ title: "订单详情", alpha: 0, titleAlignment: TextAlign.Center ,backButton:true})
Scroll(){
Column() {
Column({space:15}){
Text(this.titleStr)
.fontSize(20)
.width('100%')
.textAlign(TextAlign.Center)
.fontColor(Color.Black)
.fontWeight(FontWeight.Bold)

          Text(this.msgStr)
            .fontSize(16)
            .fontColor(Color.Black)
            .width('100%')
            .textAlign(TextAlign.Center)
        }.width('100%')
        .padding(15)
        .backgroundColor("#fff3574a")
        .alignItems(HorizontalAlign.Start
        )
        Divider().width('100%').height(5)
          .color("#e6e6e6")
        Column(){
          Row({space:20}){
            Image($r('app.media.order_location'))
              .height(20)
              .width(20)
            Column(){
              Row(){
                Text(this.orderInfo?.nike_name)
                  .fontColor(Color.Black)
                  .fontSize(16)
                  .fontWeight(FontWeight.Bold)
                Text(this.orderInfo?.phone)
                  .fontColor(Color.Black)
                  .fontSize(16)
                  .fontWeight(FontWeight.Bold)
                  .margin({left:20})
              }
              Text(this.orderInfo?.address)
                .fontColor(Color.Black)
                .fontSize(16)
                .margin({top:10})
            }
            .padding(10)
            .alignItems(HorizontalAlign.Start)
            .width('100%')

          }
        }
        .padding(10)
        .alignItems(HorizontalAlign.Start)
        .width('100%')
        Divider().width('100%').height(0.8)
          .color("#e6e6e6")
              Column(){
                Row() {
                  Row({ space: 10 }) {
                    Image($r('app.media.background'))
                      .height(70)
                      .width(70)
                      .margin({ left: 10 })
                      .borderRadius(10)
                    Column({ space: 5 }) {
                      Text("衣帽鞋包")
                        .fontColor(Color.Black)
                        .fontSize(14)

                      Text("回收重量:"+this.weightInfo?.weight)
                        .fontColor(Color.Grey)
                        .fontSize(14)
                    }
                    .alignItems(HorizontalAlign.Start)

                  }

                  .justifyContent(FlexAlign.Start)
                  .alignItems(VerticalAlign.Top)


                }
                .padding(10)
                .width('100%')
                .alignItems(VerticalAlign.Top)
                .justifyContent(FlexAlign.SpaceBetween)


                Divider()
                  .width('100%')
                  .height(1)
                  .backgroundColor("#f7f7f7")

              }

              if (this.orderInfo?.order_type==3){
                Row(){
                  Text()
                  Blank()
                  Text() {
                    Span("订单奖励:")
                      .fontSize(16)
                      .fontColor(Color.Black)
                    Span("¥"+String(this.weightInfo?.money))
                      .fontSize(12)
                      .fontColor(Color.Red)
                    Span("积分:"+String(this.weightInfo?.integral))
                      .fontSize(12)
                      .fontColor(Color.Red)
                  }
                }
                .padding(10)
                .width('100%')
                .justifyContent(FlexAlign.SpaceBetween)
              }

        Divider().width('100%').height(5)
          .color("#e6e6e6")



        Text("快递信息")
          .fontSize(18)
          .fontColor(Color.Black)
          .fontWeight(FontWeight.Bold)
          .margin({left:15})
        Divider().width('100%').height(5)
          .color("#e6e6e6")
        Row(){
          Text("运单编号:")
            .fontSize(16)
            .fontColor(Color.Black)
          Blank()
          Text(this.orderInfo?.express_code)
            .fontColor(Color.Black)
            .fontSize(14)
        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .padding(10)

        Divider().width('100%').height(0.8)
          .color("#e6e6e6")

        Row(){
          Text("快递公司:")
            .fontSize(16)
            .fontColor(Color.Black)
          Blank()
          Text(this.orderInfo?.express_company)
            .fontColor(Color.Black)
            .fontSize(14)
        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .padding(10)
        Divider().width('100%').height(0.8)
          .color("#e6e6e6")
        Row(){
          Text("快递员:")
            .fontSize(16)
            .fontColor(Color.Black)
          Blank()
          Text(this.orderInfo?.express_people)
            .fontSize(16)
            .fontColor(Color.Black)
        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .padding(10)
        Divider().width('100%').height(5)
          .color("#e6e6e6")








        Text("下单信息")
          .fontSize(18)
          .fontColor(Color.Black)
          .fontWeight(FontWeight.Bold)
          .margin({left:15})
        Divider().width('100%').height(5)
          .color("#e6e6e6")
        Row(){
          Text("联系人:")
            .fontSize(16)
            .fontColor(Color.Black)
          Blank()
          Text(this.orderInfo?.nike_name+" "+this.orderInfo?.phone)
            .fontColor(Color.Black)
            .fontSize(14)
        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .padding(10)

        Divider().width('100%').height(0.8)
          .color("#e6e6e6")

        Row(){
          Text("取件地址:")
            .fontSize(16)
            .fontColor(Color.Black)
          Blank()
          Text(this.orderInfo?.address)
            .fontColor(Color.Black)
            .fontSize(14)
        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .padding(10)
        Divider().width('100%').height(0.8)
          .color("#e6e6e6")
        Row(){
          Text("预约时间:")
            .fontSize(16)
            .fontColor(Color.Black)
          Blank()
          Text(this.orderInfo!.day+this.orderInfo?.start_time+"--"+this.orderInfo?.end_time)
            .fontSize(16)
            .fontColor(Color.Black)
        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .padding(10)
        Divider().width('100%').height(0.8)
          .color("#e6e6e6")
        Row(){
          Text("备注:")
            .fontSize(16)
            .fontColor(Color.Black)
          Blank()
          Text(this.orderInfo?.msg!=''?this.orderInfo?.msg:"无")
            .fontColor(Color.Black)
            .fontSize(14)
        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .padding(10)
        Divider().width('100%').height(0.8)
          .color("#e6e6e6")
        Row(){
          Text("订单编号:")
            .fontSize(16)
            .fontColor(Color.Black)
          Blank()
          Text(String(this.orderInfo?.id))
            .fontColor(Color.Black)
            .fontSize(14)
        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .padding(10)



        Row(){
          Text("创建时间:")
            .fontSize(16)
            .fontColor(Color.Black)
          Blank()
          Text(this.orderInfo!.day+this.orderInfo?.start_time)
            .fontColor(Color.Black)
            .fontSize(14)
        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .padding(10)
      }
      .height('100%')
      .margin({bottom:50})
      .backgroundColor(Color.White)
      .alignItems(HorizontalAlign.Start)
    }
    .height('100%')
    .width('100%')
  }
  .backgroundColor(Color.White)


}

}

}

相关文章
|
算法 5G
【5G NR】手机身份证号IMEI与IMEISV
手机上的“IMEI”是指国际移动设备识别码(IMEI),通常称为手机序列号。它用于识别移动网络中的各个独立手机和其他移动通信设备,相当于手机身份证号,它是全球唯一的。
2612 0
【5G NR】手机身份证号IMEI与IMEISV
|
5月前
|
存储 人工智能 运维
一份可信来源,终结 Skill 管理混乱:Skill 治理最佳实践
从本机同步到统一治理可信 Skill 管理实践指南。
845 29
|
11月前
|
存储 人工智能 弹性计算
云原生AI赋能服务型民企转型:玄晶引擎基于阿里云生态的全链路落地实践
在数字经济深化背景下,服务型民企面临人力成本高、获客难、服务标准不一等转型困境。玄晶引擎依托阿里云云原生架构与AI技术,打造专为咨询、会计、人力资源等行业定制的数字化解决方案,通过AI智能体替代重复劳动、全矩阵精准获客、无人值守私域闭环三大模块,实现降本增效与服务标准化,助力企业构建可持续竞争壁垒。
648 9
|
6月前
|
Web App开发 人工智能 Cloud Native
一人买多用不完,多人分享被封号——"Key池化"破解 AI 订阅共享困局
Claude用户面临“独用浪费、共享封号”困局:Max 20x额度闲置,多人拼车却因IP跳变、指纹泄露等触发风控。Key池化方案通过本地代理+虚拟Key分发,实现额度共享而不共号,规避风控,降低成本(3人仅$200/月),提升安全与体验。
1402 7
|
5月前
|
存储 人工智能 JSON
Qwen 本地部署搭配 ComfyUI AI 漫剧完整实操指南|零基础小白落地,零成本无限生成,解决角色一致性难题
2026全网唯一零成本、纯本地AI漫剧全自动流水线:Ollama+Qwen3.5离线写剧本,ComfyUI+Qwen-Image3.0精准绘图,IPAdapter+FaceID三重锁人,8G显卡流畅运行,全程角色统一、隐私安全、无限量产。(239字)
1234 0
|
6月前
|
人工智能 供应链 监控
1688 没流量怎么办 ——B2B 店铺数字化诊断与增长破局方案
本文为1688商家提供系统化流量破局方案:从基础配置、权重提升、多渠道拓展到长效运营四大维度,详解曝光与点击率归因、交易权重优化、活动/付费/内容引流及老客复利机制,强调数据驱动与合规经营,助力实现可持续流量增长。
|
6月前
|
人工智能 小程序 安全
个人全栈开发实战 依靠口述编程完成外包小程序项目
作为独立全栈开发者,我以“口述需求→AI生成→迭代优化”为日常核心工作流。TRAE凭借98%代码准确率、多模型切换、免费永久使用及优秀中文理解能力,完美适配小程序与后端外包开发,显著提升30%+效率,大幅降低单人全栈交付门槛。(239字)
|
6月前
|
移动开发 安全 开发工具
阿里云实人认证对接使用完全指南:从产品选型到代码落地
本文提供一份完整的阿里云实人认证对接使用指南。首先梳理了产品家族的核心差异,重点聚焦当前主售的金融级实人认证,涵盖实人认证方案、活体人脸验证方案、多因子意愿认证方案等多种产品方案的适用场景。接着详细拆解了从开通服务、创建RAM子账号、配置认证场景到实际接入的完整流程,核心部分分别讲解了App SDK接入和H5网页接入两大场景的时序与代码实现,给出了Java服务端、Python服务端以及Android客户端集成的完整示例。同时深入探讨了生产环境的安全加固策略,包括RAM最小权限授权、参数传输加密和敏感信息脱敏处理。最后梳理了计费逻辑、常见报错排查思路以及最佳实践建议,帮助开发者从零到一顺利完成与
|
5月前
|
数据采集 SQL 人工智能
数据中台与智能中台合流的架构设计与技术路径——AI用数成为企业标配能力
本文探讨数据中台与智能中台深度融合的架构逻辑,提出“治理机器可读、资产AI导航、用数自然语言”三条路径,构建“治理层—语义层—应用层”能力框架,并通过政务等落地案例验证合流可行性。
500 0
|
12月前
|
小程序 JavaScript Android开发
独立开发者必收,移动端多端适配好烦?试试滴滴这套开源星河小程序框架,一键跑通 Android / iOS / 鸿蒙 / Web
滴滴开源的星河小程序框架Dimina,支持Android、iOS、鸿蒙及Web四端适配,一套代码一键打包多端运行。沿用小程序语法,开发门槛低,性能优化佳,适合独立开发者与企业级项目,助力跨平台应用高效落地。
735 0