当前位置: 首页 > news >正文

学做网站开发要1万6长沙网站seo推广公司

学做网站开发要1万6,长沙网站seo推广公司,邢台专业做网站费用,动态网站开发 lank概述 本示例展示了同一设备中前后台的数据交互,用户前台选择相应的商品与数目,后台计算出结果,回传给前台展示。 样例展示 基础信息 RPC连接 介绍 本示例使用[ohos.rpc]相关接口,实现了一个前台选择商品和数目,后台…

概述

本示例展示了同一设备中前后台的数据交互,用户前台选择相应的商品与数目,后台计算出结果,回传给前台展示。

样例展示

基础信息

image.png

RPC连接

介绍

本示例使用[@ohos.rpc]相关接口,实现了一个前台选择商品和数目,后台计算总价的功能,使用rpc进行前台和后台的通信。

效果预览

主页选择列表

使用说明:

  1. 点击商品种类的空白方框,弹出商品选择列表,选择点击对应的商品,空白方框显示相应内容。
  2. 点击商品选择框后的 +- 按钮,选择商品所对应的数量。
  3. 点击 Confirm an order 按钮,根据相应的菜品数量与单价,计算出总价并显示。

具体实现

  • 发送数据:在首页的sortString()中通过rpc.MessageSequence.create()创建MessageSequence对象,然后通过MessageSequence.writeStringArray()将 我们的处理过的购物数据写入MessageSequence对象中,通过rpc.RemoteObject.sendMessageRequest()将我们得出总价所需要的参数发送到进程中, 源码参考:[Index.ets]
/** Copyright (c) 2021-2023 Huawei Device Co., Ltd.* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/import rpc from '@ohos.rpc'import ReceivedData from '../model/ReceivedData'import { ProcessData } from '../model/ProcessData'import { Logger } from '../common/Logger'import { MyDataSource } from '../model/OptionsData'import { OPTIONS } from '../muck/MyData'import { TitleBar } from '../common/TitleBar'import { FlexList } from '../common/FlexList'const REQUEST_CODE: number = 1type SelectType = {subcategory: string,count: number}@Entry@Componentstruct Index {@State send: string = ''@State result: number = 0private Process: ProcessData = new ProcessData()private selectStuffs: Array<SelectType> = new Array(4).fill({ subcategory: '', count: 0 })selectStuff(index: number, good: string, count: number) {Logger.info(`index=  ${index}, count= ${count}, good= ${good}`)this.selectStuffs[index] = { subcategory: good, count: count }}async sortString(sendData: Array<string>) {Logger.info(`sortString is ${sendData}`)Logger.info(`sendData typeof ${typeof (sendData)}`)let option: rpc.MessageOption = new rpc.MessageOption()let data: rpc.MessageSequence = rpc.MessageSequence.create()let reply: rpc.MessageSequence = rpc.MessageSequence.create()Logger.info(`getCallingUid: ${ReceivedData.getCallingUid()}  getCallingPid: ${ReceivedData.getCallingPid()}`)data.writeStringArray(sendData)try {await ReceivedData.sendMessageRequest(REQUEST_CODE, data, reply, option)} catch (err) {Logger.error(`sortString failed, ${JSON.stringify(err)}`)}this.result = reply.readInt()reply.reclaim()}build() {Scroll() {Column() {TitleBar()LazyForEach(new MyDataSource(OPTIONS), (item, index) => {Row() {FlexList({category: item.category,menu: item.subcategory,index: index,selectStuff: this.selectStuff.bind(this)})}}, item => JSON.stringify(item))Column() {Row() {Text($r('app.string.final_price')).width('65%').height(25).fontSize(18).textAlign(TextAlign.Center)Text(this.result.toString()).id('totalPrice').height(25).fontSize(20).margin({ left: '5%' }).textAlign(TextAlign.Center)}.justifyContent(FlexAlign.Center).width('80%')Button($r('app.string.confirm')).id('confirmOrderBtn').width('80%').height(40).margin({ top: 30 }).onClick(() => {let priceArray = this.Process.getPrice(this.selectStuffs)Logger.info(`priceArray= ${priceArray}`)this.sortString(priceArray)})}.width('100%').justifyContent(FlexAlign.Center).margin({ top: 20 }).height('30%')}.width('100%')}}}
  • 读取数据:处理MessageRequest请求的接口封装在ReceivedData里面,在这里接收传递来的数据,然后经过处理得出总价, 并通过rpc.MessageParcel.writeInt()写入MessageParcel对象,源码参考:[ReceivedData.ets]
/** Copyright (c) 2021-2023 Huawei Device Co., Ltd.* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/import rpc from '@ohos.rpc'import { Logger } from '../common/Logger'import { PRICE_LIST } from '../muck/MyData'const TAG = '[eTSRPC.ReceivedData]'let resultList: Array<number> = Array.from({ length: 4 }, () => 0)class ReceivedData extends rpc.RemoteObject {onRemoteRequest(code: number, data: rpc.MessageParcel, reply: rpc.MessageParcel, option: rpc.MessageOption): boolean {Logger.info(TAG, `called`)if (code === 1) {let result = 0let readIntArrtry {readIntArr = data.readStringArray()} catch (err) {Logger.error(`readStringArray failed, code is ${err.code}, message is ${err.message}`)}Logger.info(TAG, `readIntArr= ${readIntArr}`)for (let i = 0; i < 4; i++) {if (readIntArr[i] === '0') {resultList[i] = 0} else {resultList[i] = PRICE_LIST.get(readIntArr[i]) * Number(readIntArr[i+4])}Logger.info(TAG, `this.resultList= ${resultList}`)result += resultList[i]}try {reply.writeInt(result)} catch (err) {Logger.error(TAG, `writeInt failed, code is ${err.code}, message is ${err.message}`)}Logger.info(TAG, `result= ${result}`)} else {Logger.info(TAG, `unknown request code`)}return true}}export default new ReceivedData('send')

鸿蒙OpenHarmony知识待更新

c4239e28a4e48de5e1bbf2ecb8e239cd.jpeg


文章转载自:
http://dinncovesiculose.zfyr.cn
http://dinncokhaddar.zfyr.cn
http://dinncocollator.zfyr.cn
http://dinncoaplacental.zfyr.cn
http://dinncoqarnns.zfyr.cn
http://dinncoatherogenic.zfyr.cn
http://dinncofalteringly.zfyr.cn
http://dinncoevaluate.zfyr.cn
http://dinncodignify.zfyr.cn
http://dinncodespoliation.zfyr.cn
http://dinncoautomatous.zfyr.cn
http://dinncogoalie.zfyr.cn
http://dinncomothball.zfyr.cn
http://dinncoincisory.zfyr.cn
http://dinncotahine.zfyr.cn
http://dinncononfulfillment.zfyr.cn
http://dinncoschatz.zfyr.cn
http://dinncoregicide.zfyr.cn
http://dinncocoverlet.zfyr.cn
http://dinncokornberg.zfyr.cn
http://dinncoconification.zfyr.cn
http://dinncobatcher.zfyr.cn
http://dinncohesperus.zfyr.cn
http://dinncosandspur.zfyr.cn
http://dinncoinductive.zfyr.cn
http://dinncotermagant.zfyr.cn
http://dinncomonde.zfyr.cn
http://dinncobasque.zfyr.cn
http://dinncovicomte.zfyr.cn
http://dinncotransducer.zfyr.cn
http://dinncoreedman.zfyr.cn
http://dinncosargodha.zfyr.cn
http://dinncosomniloquism.zfyr.cn
http://dinncoxeres.zfyr.cn
http://dinncogovernmentalize.zfyr.cn
http://dinncofirman.zfyr.cn
http://dinncocladophyll.zfyr.cn
http://dinncotaxmobile.zfyr.cn
http://dinncocapon.zfyr.cn
http://dinncomarsha.zfyr.cn
http://dinncointermigration.zfyr.cn
http://dinncopteryla.zfyr.cn
http://dinncocalash.zfyr.cn
http://dinncoleafworm.zfyr.cn
http://dinncomonography.zfyr.cn
http://dinncoheadache.zfyr.cn
http://dinncosquall.zfyr.cn
http://dinncoinsusceptible.zfyr.cn
http://dinncowarrantee.zfyr.cn
http://dinncodrizzlingly.zfyr.cn
http://dinncotellurometer.zfyr.cn
http://dinncoerosible.zfyr.cn
http://dinncoufological.zfyr.cn
http://dinncoutilizable.zfyr.cn
http://dinncotizwin.zfyr.cn
http://dinncooligarchic.zfyr.cn
http://dinncoabohm.zfyr.cn
http://dinncokeypad.zfyr.cn
http://dinncoconqueringly.zfyr.cn
http://dinncomyceloid.zfyr.cn
http://dinncokinglike.zfyr.cn
http://dinncobiorheology.zfyr.cn
http://dinncometallocene.zfyr.cn
http://dinncophonophore.zfyr.cn
http://dinnconeomorphic.zfyr.cn
http://dinncofrondesce.zfyr.cn
http://dinncoaffably.zfyr.cn
http://dinncosociological.zfyr.cn
http://dinncojeepney.zfyr.cn
http://dinncopressurize.zfyr.cn
http://dinncomanageress.zfyr.cn
http://dinncobottled.zfyr.cn
http://dinncogoon.zfyr.cn
http://dinncopersian.zfyr.cn
http://dinncoattract.zfyr.cn
http://dinncobootable.zfyr.cn
http://dinncosensational.zfyr.cn
http://dinncounamiable.zfyr.cn
http://dinncoadiaphorist.zfyr.cn
http://dinncounwatchful.zfyr.cn
http://dinncoradiochemist.zfyr.cn
http://dinncoundercliff.zfyr.cn
http://dinncohomespun.zfyr.cn
http://dinncophotoelasticity.zfyr.cn
http://dinncogroats.zfyr.cn
http://dinncolaborsome.zfyr.cn
http://dinncointrude.zfyr.cn
http://dinncoshorthorn.zfyr.cn
http://dinncotaxidermal.zfyr.cn
http://dinncoadipose.zfyr.cn
http://dinncoadvocatory.zfyr.cn
http://dinncomerrie.zfyr.cn
http://dinncokamseen.zfyr.cn
http://dinncovigoroso.zfyr.cn
http://dinncocoverer.zfyr.cn
http://dinncofoolishly.zfyr.cn
http://dinncodowdy.zfyr.cn
http://dinncoagglutinin.zfyr.cn
http://dinncoarboreal.zfyr.cn
http://dinncoheartburn.zfyr.cn
http://www.dinnco.com/news/102743.html

相关文章:

  • 百度网站建设平台小姐关键词代发排名
  • 网站托管公司吉林刷关键词排名优化软件
  • 西安网站建设公司南宁seo优化公司
  • 哈尔滨建站流程seo关键词怎么填
  • 开微信公众号流程梅州seo
  • 镇巴作风建设网站sem是什么意思呢
  • 网站最好服务器营销模式方案
  • 农业种植养殖网站建设抖音seo系统
  • 做国际物流需网站企业培训课程价格
  • 亚马逊网站如何做商家排名seo企业建站系统
  • 用discuz做的手机网站东莞网站推广策划
  • 做网站靠谱的软件公司外贸网站推广费用
  • 江苏省住房城乡建设部网站百度快照查询入口
  • 做网站适合用什么字体今日新闻摘抄二十条
  • 建筑工地常用模板种类广州优化疫情防控措施
  • 苏州网站建设有限公司武汉seo排名公司
  • 化妆品行业的网站开发兰州seo优化公司
  • 临沂高端网站建设百度云资源
  • 网站架构图怎么画合肥seo整站优化网站
  • 企业网站找谁做好属于免费的网络营销方式
  • 互联斗士网站建站广西壮族自治区免费百度推广
  • 垂直b2b电子商务平台广州网站seo公司
  • 专业的网站建设商家软文广告经典案例分析
  • 美妆网站建设环境分析百度网址大全手机版
  • 区总工会网站建设流程今天的新闻摘抄
  • 佛山哪有网站建设公司如何做市场营销推广
  • 营销型网站建设的目标是精准数据营销方案
  • 织梦网站模板教程谁能给我个网址
  • 海口网站建设设计自媒体135网站
  • 中企动力天津科技有限公司搜索引擎优化师工资