当前位置: 首页 > 编程日记 > 正文

小程序判断用户在线状态

在页面的两个生命周期组件里面

 onShow() {console.log('-----上线线')let info = wx.getStorageSync('chat_item')DB.collection('friends').where({_id: info._id}).get().then(res => {console.log('-----', res)if (res.data[0].a == wx.getStorageSync('userInfo')._openid) {console.log('-----a上线',res.data[0].a,wx.getStorageSync('userInfo')._openid)DB.collection('friends').doc(info._id).update({data: {a_zaixian: true}})} else {console.log('-----b上线',res.data[0].b,wx.getStorageSync('userInfo')._openid)DB.collection('friends').doc(info._id).update({data: {b_zaixian: true}})}})},onUnload() {console.log('-----离线')let info = wx.getStorageSync('chat_item')DB.collection('friends').where({_id: info._id}).get().then(res => {if (res.data[0].a == wx.getStorageSync('userInfo')._openid) {console.log('-----a离线')DB.collection('friends').doc(info._id).update({data: {a_zaixian: false}})} else {console.log('-----b离线')DB.collection('friends').doc(info._id).update({data: {b_zaixian: false}})}})},

相关文章:

react.js做小程序_如何使用React.js构建现代的聊天应用程序

react.js做小程序In this tutorial, I will guide you to build your own group chat application using React, React Router, and CometChat Pro. Yes, rather than roll out our own server, we will instead use CometChat Pro to handle the real-time sending and receiv…

RAP Mock.js语法规范

Mock.js 的语法规范包括两部分: 数据模板定义规范(Data Template Definition,DTD)数据占位符定义规范(Data Placeholder Definition,DPD)1.数据模板定义规范 DTD 数据模板中的每个属性由 3 部分…

NSDictionary、NSMutableDictionary基本使用

郝萌主倾心贡献,尊重作者的劳动成果。请勿转载。假设文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额任意,重在心意^_^ 我要捐赠: 点击捐赠Cocos2d-X源代码下载:点我传送游戏官方下载:htt…

h5轮播图及效果图

效果图&#xff1a; 代码&#xff1a; <!doctype html> <html><head><meta charset"utf-8"><title>jQuery响应式卡片轮播切换代码</title><link rel"stylesheet" type"text/css" href"css/style.c…

性能测试回归测试_自动网站性能回归测试

性能测试回归测试by Adam Henson亚当汉森(Adam Henson) 如何使用Foo自动执行网站性能回归测试 (How to automate website performance regression testing with Foo) 使用部署后步骤自动执行连续交付工作流程中的性能回归测试 (Using a post deploy step to automate performa…

【html】【13】特效篇--下拉导航

html代码&#xff1a; 1 <!DOCTYPE html>2 <html>3 <head>4 <meta http-equiv"Content-Type" content"text/html; charsetUTF-8">5 <title>Bootstrap导航条鼠标悬停下拉菜单</title>6 <li…

小程序获取用户所在城市完整代码

小程序目录结构 插入提示: 1. 申请开发者密钥&#xff08;key&#xff09;&#xff1a; 申请密钥 2. 下载微信小程序JavaScriptSDK&#xff0c;下载地址 下载完成后放入utils文件夹下引用即可 3. 安全域名设置&#xff0c;在“设置” -> “开发设置”中设置req…

prolog_如何通过观看权力的游戏学习Prolog

prologby Rachel Wiles瑞秋威尔斯(Rachel Wiles) 如何通过观看权力的游戏学习Prolog (How to learn Prolog by watching Game of Thrones) 他们死了吗&#xff1f; 他们还活着吗&#xff1f; 她是他的姨妈吗&#xff1f; 不用把精力浪费在2011年&#xff0c;而可以使用Prolog节…

身份证号码对应地区-官方措辞:行政区划代码

身份证前6位代表着该身份证的籍贯在哪里&#xff0c;而官方的措辞则为&#xff1a;行政区划代码 如何找到最新的行政区划代码了&#xff1f; 通过&#xff1a;http://blog.sina.com.cn/s/blog_5a76dae20100tqv5.html 此人的博客得知&#xff0c;行政区划代码是国家统计局统计的…

Jquery_操作cookies

首先引入jquery.cookie.js jquery.cookie.js下地址&#xff1a;http://plugins.jquery.com/cookie/ 操作文档&#xff1a; https://github.com/carhartl/jquery-cookie#readme 创建cookies&#xff1a; $.cookie(name, value); 设置有效期&#xff1a; 设置七天过期 $.cookie(n…

rem转rpx工具

对样式进行格式化&#xff0c;然后根据 “rem” 进行拆分&#xff0c;这样就会拆分成一个数组 [str1,str2,str3...,str6], 除了最后一个元素&#xff0c;前边的元素都会以 “rem” 样式的数值结尾&#xff0c; 然后在对数组中的元素字符串进行再次根据 “&#xff1a;” 进行…

colab中的变量怎么读取_Fizyr Retinanet在Colab中进行目标检测

colab中的变量怎么读取by RomRoc由RomRoc 带有Fizyr Retinanet的Google Colab中的对象检测 (Object Detection in Google Colab with Fizyr Retinanet) Let’s continue our journey to explore the best machine learning frameworks in computer vision.让我们继续我们的旅程…

c++重载(以运算符重载为主)

重载&#xff08;OverLoading&#xff09;是面向对象程序设计多态性的一种体现。所谓重载&#xff0c;是指“同一标识符”在同一作用域的不同场合具有不同的语义&#xff0c;这个标识符可以是函数名或运算符。也就是说&#xff0c;重载可以使多个函数使用同一个函数名&#xff…

记录-MySQL中的事件调度Event Scheduler

下面是自己的实例 /*查询event是否开启&#xff08;查询结果Off为关闭 On为开启&#xff09;*/show variables like %sche%; /*开启/关闭命令&#xff08;1开启--0关闭&#xff09;*/set global event_scheduler1; /*关闭事件任务: */alter event e_test_insert ON COMPLETION…

JS 实现下载Blod文件

实现代码&#xff1a; //下载Blod文件 const downLoadBlobFile (filename, res) > {if (!res) return;let a document.createElement(a);let blob new Blob([res], { type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charsetutf-8 });let blo…

盖尔-沙普利算法_盖尔定律-及其与初创企业的关系

盖尔-沙普利算法I realized something fascinating the other day: I realized that, as a startup entrepreneur and founder, I’m a builder of systems.前几天&#xff0c;我意识到了一件令人着迷的事情&#xff1a;我意识到&#xff0c;作为一名初创企业家和创始人&#x…

使用VS Code开发.Net Core 2.0 MVC Web应用程序教程之三(配置文件读取)

干了一天的活&#xff0c;还有点时间&#xff0c;给兄弟们写点东西吧。 大家有没有发现一个问题&#xff1f;那就是在.Net Core的MVC项目里面&#xff0c;没有.config文件了&#xff01;&#xff01;&#xff01;同志们&#xff0c;没有config文件了啊&#xff0c;这样搞&#…

小程序云开发数据库在网站读取

使用TCB JS SDK Tencent Cloud Base(TCB) JavaScript SDK 介绍 TCB 提供开发应用所需服务和基础设施。TCB JS SDK 让你可以在网页端使用 JavaScript 代码服务访问 TCB 的的服务。你可以使用该 SDK 构建自己的公众号页面或者独立的网站等 Web 服务。 安装 TCB JS SDK 可以…

设计模式学习心得4

1.组合模式 定义一个父类&#xff0c;其中包括所有子类的方法接口&#xff0c;那么对于任何一个子类来说对外界都是封闭的&#xff0c;外界只调用父类的接口&#xff0c;而不知道子类是否有实现。 2.迭代器模式 这个很常见&#xff0c;在C中常常会用在标准模版类中&#xff0c;…

react创建组件_如何使用React创建时间轴组件

react创建组件These days I’ve been working on a new page for my website. I wanted to have a Timeline to showcase some of my professional accomplishments over the years.这些天来&#xff0c;我一直在为网站创建新页面。 我希望有一个时间表来展示我多年来的一些专业…

oracle根据一张表更新另外一张表

知道是两张表进行更新&#xff0c;之前作过mysql的,直接就写了&#xff1a; update a,b set a.code b.code wehre a.id b.id 然后就报错了&#xff0c;上网查了下知道oracle不能这样子写 之后找到如下的办法&#xff1a; UPDATE a set a.code (select b.code from b where…

应用内设置语言不重启方法

1、设置本应用方法网上有很多&#xff0c;大概如下 Resources resources getResources(); Configuration config resources.getConfiguration(); DisplayMetrics dm resources.getDisplayMetrics(); config.locale locale; //目标语言 resources.updateConfiguration(confi…

小程序内容审核违规过滤,在小程序使用security.msgSecCheck

使用微信提供的API security.msgSecCheck 查看文档 1.开通云开发&#xff0c;创建云环境。 2.在云函数的目录中&#xff0c;创建一个云函数&#xff08;ContentCheck&#xff09;&#xff0c;如果小程序代码没有云函数的目录&#xff0c;可以在 project.config.json 目录中配置…

如何在JavaScript中切片和拼接数组

.slice() and .splice() are similar methods in JavaScript. They look similar, they sound similar, and they do similar things. For those reasons, it’s important to know the differences between them. Also, they’re used very often, so understanding their usa…

jQuery中getJSON跨域原理详解

详见&#xff1a;http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp28 jQuery中getJSON跨域原理详解 前几天我再开发一个叫 河蟹工具条 的时候&#xff0c;其中有个功能就是获取本页面的短网址。 这个想法是好的&#xff0c;可是在我付诸于行动的时候&#xff0c;发…

样式集(七)仿微信发现页样式

效果图&#xff1a; <!--pages/find/find.wxml--><include src"/components/common/common" /> <view class"item" catchtap"nav1"><image class"icon" mode"widthFix" src"/images/icon_5.png&q…

html向js传递id

html获取id方法&#xff1a; <div id"thediv1" style"display:block" onclick"ceshi(this.id)">技术A组</div> this.id ------>本身id转载于:https://www.cnblogs.com/wanlibingfeng/p/7613575.html

javascript功能_功能性JavaScript简介

javascript功能Hey everybody! I’ve written a book called Discover Functional JavaScript, and it’s now ready in both paperback and Kindle formats.大家好&#xff01; 我已经写了一本书《 发现功能JavaScript》 &#xff0c;现在已经可以使用平装本和Kindle格式。 A…

样式集,小程序群聊,聊天室样式,效果图

效果图 注&#xff1a;&#xff08;码云 group_chat_yun &#xff09; 代码&#xff1a; <!-- <view class"top"><image class"page_editright" catchtap"navBack" mode"widthFix" src"/images/editright.png&quo…

GeoQuiz项目的开发与总结2

时间过得很快&#xff0c;第二阶段的学习结束了。 本周的主要工作是完成了Geoquiz项目的剩余部分。 首先是学到了些什么&#xff0c;最主要的是工作的流程&#xff0c;然后是界面的布局&#xff0c;菜单栏的设计到等。当然我觉得我学到的应该是工作制作的思维方式吧。 再来说说…