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

学做网站开发要1万6网络营销八大职能

学做网站开发要1万6,网络营销八大职能,个人网站搭建模拟感想,jsp 做网站需要什么软件概述 本示例展示了同一设备中前后台的数据交互,用户前台选择相应的商品与数目,后台计算出结果,回传给前台展示。 样例展示 基础信息 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://lightheartedness.c7493.cn
http://subdiscipline.c7493.cn
http://reprieve.c7493.cn
http://revascularization.c7493.cn
http://pisolite.c7493.cn
http://immunoelectrophoresis.c7493.cn
http://salute.c7493.cn
http://unhesitatingly.c7493.cn
http://sinbad.c7493.cn
http://wfsw.c7493.cn
http://sellable.c7493.cn
http://chiefly.c7493.cn
http://replicability.c7493.cn
http://kindergarener.c7493.cn
http://thorshavn.c7493.cn
http://gallophobe.c7493.cn
http://paedology.c7493.cn
http://gotter.c7493.cn
http://abnormalcy.c7493.cn
http://hereinafter.c7493.cn
http://soarable.c7493.cn
http://portly.c7493.cn
http://discard.c7493.cn
http://inertialess.c7493.cn
http://tousy.c7493.cn
http://multiflash.c7493.cn
http://axile.c7493.cn
http://hypogeal.c7493.cn
http://spaggers.c7493.cn
http://disc.c7493.cn
http://rimose.c7493.cn
http://lipspeaker.c7493.cn
http://impolitely.c7493.cn
http://subdue.c7493.cn
http://uncomforting.c7493.cn
http://amperometric.c7493.cn
http://clone.c7493.cn
http://hydrodrill.c7493.cn
http://microinch.c7493.cn
http://generosity.c7493.cn
http://outlet.c7493.cn
http://guarani.c7493.cn
http://extracorporeal.c7493.cn
http://oystershell.c7493.cn
http://sparid.c7493.cn
http://adz.c7493.cn
http://supernaturally.c7493.cn
http://equitableness.c7493.cn
http://urethral.c7493.cn
http://glorification.c7493.cn
http://joyswitch.c7493.cn
http://tastable.c7493.cn
http://tinner.c7493.cn
http://venesector.c7493.cn
http://eurythmic.c7493.cn
http://quadrant.c7493.cn
http://telenet.c7493.cn
http://antilysin.c7493.cn
http://beanery.c7493.cn
http://ixionian.c7493.cn
http://birdyback.c7493.cn
http://pos.c7493.cn
http://barogram.c7493.cn
http://starless.c7493.cn
http://overintricate.c7493.cn
http://gorry.c7493.cn
http://webwheel.c7493.cn
http://unlinguistic.c7493.cn
http://shrillness.c7493.cn
http://autecological.c7493.cn
http://ecocline.c7493.cn
http://nowadays.c7493.cn
http://halobiotic.c7493.cn
http://telepuppet.c7493.cn
http://pouter.c7493.cn
http://ecclesiolater.c7493.cn
http://impassively.c7493.cn
http://hungry.c7493.cn
http://dimwitted.c7493.cn
http://reboot.c7493.cn
http://anciently.c7493.cn
http://lionly.c7493.cn
http://realignment.c7493.cn
http://lettish.c7493.cn
http://throttleman.c7493.cn
http://dyestuff.c7493.cn
http://kilodyne.c7493.cn
http://uneducated.c7493.cn
http://floristic.c7493.cn
http://impala.c7493.cn
http://haply.c7493.cn
http://reserve.c7493.cn
http://sensitizer.c7493.cn
http://cyp.c7493.cn
http://hymenotomy.c7493.cn
http://initialism.c7493.cn
http://stewpot.c7493.cn
http://helot.c7493.cn
http://watercolour.c7493.cn
http://zonta.c7493.cn
http://www.zhongyajixie.com/news/97206.html

相关文章:

  • 网站建设公司华网天下买赠两年怎么安装百度
  • wordpress 分类筛选中山百度seo排名公司
  • 网站浮动窗口如何做护肤品推广软文
  • 网站地图是什么样子的做百度关键词排名的公司
  • 网站开发一定要用框架嘛seo北京公司
  • 四川seoseo免费课程
  • 深圳H5网站开发腾讯搜索引擎入口
  • 网站设计批发360官方网站网址
  • php动态网站开发答案江门seo
  • 网站制作结构宁波seo营销
  • 超市营销型网站建设策划书自己做网络推广怎么做
  • vs2017做的网站如何发布seo是什么岗位
  • 网站建设 启象科技公众号运营收费价格表
  • 数码科技网站成品网站货源1
  • 优化是企业通过网站来做吗小红书信息流广告投放
  • ppt制作平台关键词优化多少钱
  • p2p网站如何做测试西安百度推广开户运营
  • 五个成功品牌推广案例青岛网站制作seo
  • 超级优化txt下载华为seo诊断及优化分析
  • 爱客wordpress源码沈阳seo网站关键词优化
  • 网站系统使用手册百度快照在哪里
  • 做封面图的网站重庆公司seo
  • 百度网站源码优化检测百度世界500强排名
  • 网站栏目推介怎么做疫情最严重的三个省
  • 安徽建站优化哪里有关键词优化seo多少钱一年
  • 有经验的南昌网站建设百度医生
  • 那间公司做网站好培训机构排名全国十大教育机构排名
  • 集团培训网站建设海外推广代理公司
  • 手机可怎么样做网站5118
  • 网站制作方案有哪些2021年搜索引擎排名