使用goEasy实现多对多实时点餐程序

  1. 新建一个uniapp项目,引入goEasy插件
npm install goeasy@2.6.2 --save
  1. 在main.js引入goeasy并注册
import App from './App'
import GoEasy from 'goeasy'// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({...App
})
app.$mount()
// #endifVue.prototype.GoEasy = GoEasy
let goeasy = GoEasy.getInstance({host:"hangzhou.goeasy.io",  //若是新加坡区域:singapore.goeasy.ioappkey:"BC-e1f69be1cd6e409f944f3e1285c257c7",modules:['pubsub']//根据需要,传入‘pubsub’或'im’,或数组方式同时传入
});Vue.prototype.goEasy = goeasy//建立连接
goeasy.connect({id:"test_channel", //pubsub选填,im必填,最大长度60字符// id:uni.getSystemInfoSync().deviceId, //pubsub选填,im必填,最大长度60字符data:{"avatar":"/www/xxx.png","nickname":"Neo"}, //必须是一个对象,pubsub选填,im必填,最大长度300字符,用于上下线提醒和查询在线用户列表时,扩展更多的属性onSuccess: function () {  //连接成功console.log("GoEasy connect successfully.") //连接成功},onFailed: function (error) { //连接失败console.log("Failed to connect GoEasy, code:"+error.code+ ",error:"+error.content);},onProgress:function(attempts) { //连接或自动重连中console.log("GoEasy is connecting", attempts);}
});
  1. 编写模板页面
<template><view class="content"><!--   <u-modal v-model="isModel" title="请输入用户名"><view><input style="padding: 20rpx;border: 1rpx solid #eee;margin: 30rpx;" v-model="userId" /></view></u-modal> --><!-- 顶部 --><view class="top-view"><view>{{number_people}}人就餐</view><view class="top-view-flex"><image src="/static/tab/fenxiang.svg" mode="widthFix" class="top-search"></image><image src="/static/tab/dingdan.svg" mode="widthFix" @click="my_order()"></image></view></view><view class="order-view"><view class="commodity"> <!-- 左 --> <view class="order-left"><scroll-view scroll-y="true" class="scroll-Hei" :scroll-with-animation="true" :enhanced="true":show-scrollbar="false"><block v-for="(item,index) in itemize" :key="index"><view class="itemize-text" :class="{active: index == trigger}"@click="itemIze(index,item.cid)"><text>{{item.value}}</text><text v-if="item.sele_quantity > 0">{{item.sele_quantity}}</text></view></block></scroll-view></view><!-- 右 --><view class="order-right"><scroll-view scroll-y="true" class="scroll-Hei" :scroll-with-animation="true" :enhanced="true":show-scrollbar="false" :scroll-into-view="scroll_into" @scroll="scroLl"><block v-for="(item,index) in goods" :key="index"><view :id="item.cid" class="rig-height"><view class="classif">{{item.category}}</view><view class="classif-goods" v-for="(itemgood,good_index) in item.good_query":key="good_index" @click="popup_item(true,index,good_index,item.cid,itemgood)"><view class="goods-image"><image :src="itemgood.image[0].url" mode="aspectFill"></image></view><view class="goods-Price"><view class="goods-name"><text class="Bold">{{itemgood.name}}</text><text class="Thinning">已售 {{itemgood.monthlysale}}</text></view><view class="unit-price"><text class="Symbol">¥</text><text class="Bold">{{itemgood.unitprice}}</text><text class="Thinning">/{{itemgood.unit}}</text></view></view><!-- 无规格 --><view class="quantity" v-if="!itemgood.att_hide"><view><image v-if="itemgood.quantity > 0" src="/static/tab/jianhao.png"mode="widthFix"@click.stop="channel('reduce',[index,good_index,item.cid,itemgood])"></image></view><view><text v-if="itemgood.quantity > 0">{{itemgood.quantity}}</text></view><view><image src="/static/tab/jia.png" mode="widthFix"@click.stop="channel('plus',[index,good_index,item.cid,itemgood])"></image></view></view><!-- 有规格 --><view class="quantity specs-view" v-if="itemgood.att_hide"><text>选规格</text><text v-if="itemgood.quantity > 0">{{itemgood.quantity}}</text></view></view></view></block><view style="height: 400rpx;"></view></scroll-view></view></view><!-- 底部 --><view class="order-bottom" @click="pop_Shopping()" :style="{'padding-bottom': Modelmes ? '68rpx' : ''}"><view class="Shopping" style="width: 115rpx;"><view class="Shopping-left"><image src="/static/tab/gouwuche.png" mode="widthFix"></image></view><view class="Shopping-number" v-if="total_quantity > 0">{{total_quantity}}</view></view><view class="Shopping-title" v-if="total_quantity > 0">已点{{total_quantity}}份菜品</view><view class="place-order" @click.stop="total_quantity == 0 ? false : true && placean_order()"><button plain="true" open-type="getUserInfo">选好了</button></view></view></view><!-- 购物车 --><Cart @empty_data="channel" @shopping_Cart_add_sub="channel" @close="pop_Shopping" v-if="card" :otherList="otherList" :shopping_card="shopping_card"></Cart><!-- 引入单个商品弹出 --><Details @reduce="channel" @plus="channel" @popup_item="popup_item" v-if="popupitem" :pro_details="pro_details"></Details><!-- 骨架屏 --><Home v-if="exist"></Home><!--    <input v-model="value" placeholder="请输入您的id" /><input v-model="valueB" placeholder="请输入您发送的id" /> --><!-- <button @click="onload()">确定</button> --><!-- <button @click="returnClick">发送</button> --></view>
</template>
  1. 订阅消息
//订阅消息goEasy.pubsub.subscribe({channel: "test_channel",//替换为您自己的channelonMessage: (message) => { //收到消息let obj = JSON.parse(message.content)// obj.data[3].uid = obj.uidthis[obj.fun](...obj.data)// if(this.userId !== obj.uid) {//   this.otherList = obj.shopList//    if(this.otherList.length <= 0) {//      this.otherList = [obj.data[3]]//   }// } else {// }console.log("Channel:" + message.channel + " content:" + message.content);},onSuccess: function () {console.log("Channel订阅成功。");},onFailed: function (error) {console.log("Channel订阅失败, 错误编码:" + error.code + " 错误信息:" + error.content)}});
  1. 发送消息
 //发送
channel(fun,data) {console.log('uni.getSystemInfoSync()-------',uni.getSystemInfoSync())//发送goEasy.pubsub.publish({channel: "test_channel",//替换为您自己的channelmessage: JSON.stringify({fun:fun,uid:this.userId,shopList:this.shopping_card,data:data}),//替换为您想要发送的消息内容onSuccess:res => {console.log("消息发布成功。");},onFailed: function (error) {console.log("消息发送失败,错误编码:"+error.code+" 错误信息:"+error.content);}})
}

项目预览

git:https://gitcode.net/qq_27161847/goEasy.git

使用goEasy实现多对多实时点餐程序相关推荐

  1. node mongoose_如何使用Express,Mongoose和Socket.io在Node.js中构建实时聊天应用程序

    node mongoose by Arun Mathew Kurian 通过阿伦·马修·库里安(Arun Mathew Kurian) 如何使用Express,Mongoose和Socket.io在N ...

  2. iftop是一个很好用的实时流量监测程序,跟使用iftop查看linux连接进程占用的实时流量...

    iftop是一个很好用的实时流量监测程序,跟top命令监测cpu内存等差不多 官方地址:http://www.ex-parrot.com/~pdw/iftop/ 安装方法: yum install - ...

  3. 用python编写一个点餐程序_Python写一个自动点餐程序

    原博文 2019-08-09 10:45 − # Python写一个自动点餐程序 ## 为什么要写这个 公司现在用meican作为点餐渠道,每天规定的时间是早7:00-9:40点餐,有时候我经常容易忘 ...

  4. [转载]实时 Java,第 5 部分: 编写和部署实时 Java 应用程序

    实时 Java,第 5 部分: 编写和部署实时 Java 应用程序 2007 年 7 月 11 日 这篇文章是讨论实时 JavaT™ 的 6 部分 系列文章 的第 5 部分,展示了如何使用 IBM W ...

  5. 2022外卖霸王餐程序、外系统霸王餐H5/APP程序源码|美团/饿了么霸王餐系统 粉丝裂变 自带账单 在线支付提现等

    2022外卖霸王餐程序.外系统霸王餐H5/APP程序源码|美团/饿了么霸王餐系统 粉丝裂变 自带账单 在线支付提现等 外卖霸王餐系统程序/H5/APP源码 2022最新霸王餐程序 霸王餐程序/H5/A ...

  6. 股市资深大牛用Python写了个股票价格实时MacOS应用程序!实时监控!

    导言 虽然Python很适合构建很多东西,但MacOS应用程序肯定不是其中之一.我想知道是否可以使用Python为MacOS构建菜单栏应用程序.我发现这不仅是可能的,而且"非常简单" ...

  7. Oracle JDE 财务实时对账程序概览

    JDE财务实时对账程序概览 交互式完整性检查程序使您能够通过实时财务对账即时识别潜在的财务完整性问题,而无需等待评估批处理的结果: 实时财务对账应用程序允许您: 通过查找和解决完整性问题而无需等待报告 ...

  8. 实现北京公交实时预警小程序

    实现北京公交实时预警小程序 北京的天冷的太快,在后厂村的公交站台冻的要死要活几年之后,终于决定动手写个公交到站时间预报的程序,以便能舒服坐在工位等我的公交车. 美好想法是:当我处在公司累死累活加班以致 ...

  9. Javascript | 模拟mvc实现点餐程序

    MVC模式是一个比较成熟的开发模式.M是指业务模型,V是指用户界面,C则是控制器,使用MVC的目的是将M和V的实现代码分离,从而使同一个程序可以使用不同的表现形式.其中,View的定义比较清晰,就是用 ...

最新文章

  1. 这些学霸的作息表“曝光”,太震撼了,快来找差距!
  2. 微机原理换行代码_微机原理课程设计——汇编输出杨辉三角
  3. 2151: 种树 - BZOJ
  4. 判断条件UVa 10192 - Vacation(LCS水题)
  5. Python中的依赖注入实现原理
  6. 【cookie,session】cookie和session基础知识入门
  7. 使用MCT6.0工具和fontconver制作MTK字库文件
  8. OpenProj打开不了或者提示”Failed to load Java VM Library”的错误的解决方案
  9. python测试工程师简历模板_自动化测试工程师简历专业技能怎么写
  10. PS教程淘宝美工平面设计入门自学课 photoshop软件零基础视频大全
  11. 为何会频繁收到垃圾短信?使用这3种方法,跟垃圾短信说再见
  12. win10 自动同步时间脚本
  13. 第5组 团队展示(组长)
  14. svg转成jpg/png图片跨域图片
  15. Springboot美食分享系统716y7计算机毕业设计-课程设计-期末作业-毕设程序代做
  16. 教学用计算机怎样关闭系统还原,关闭系统还原好吗 如何关闭系统还原【图文】...
  17. Win10+PL2030HXA或Prolific USB-to-Serial Comm Port驱动错误或者串口无法打开问题
  18. [创业之路-42] 创业是只有一小部分人活下来的游戏,探究创业失败的20个主要原因与提高成功率
  19. 电子电路中电容的作用
  20. Java编程——输出一个三角形

热门文章

  1. 64位版本的Windows不兼容,masm无法运行解决方法
  2. HeadFirst设计模式(模式总览速查)
  3. PJSIP-PJMEDIA【使用pjmedia 播放wav格式的音乐】
  4. 2023最新SSM计算机毕业设计选题大全(附源码+LW)之java毕业生书籍回购及租赁销售管理系统1c16w
  5. Servlet和JSP简述
  6. git 拉远端代码强制覆盖本地代码
  7. Winrunner8,0的安装问题与解决方案;
  8. 关于primer的学习
  9. js读取excel数据后的时间格式转换
  10. 2021-04《信息资源管理 02378》真卷(独家文字版),圈定章节考点+统计真题分布