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

小程序瀑布流实现

实现思路:把图片分成两排,创建两个数组,计算总数组中图片的宽高,对比上一个图片和当前的图片高度,低的就给另一个数组添加。效果图:

上代码:

// miniprogram/pages/find/index.js
const app = getApp();
var util = require('../../utils/util.js')
var userInfo,shang_height=0;
const DB = wx.cloud.database()
var that;
Page({data: {list: []},get_img_height(url){return new Promise(ress=>{wx.getImageInfo({src: url,success (res) {console.log(res.width)console.log(res.height)ress(res.height)return res.height}})})},onShow: function () {that = thisDB.collection('user').get({success: function (res) {console.log('有城列表', res.data)var see_list = wx.getStorageSync('see_list') || [];let fen = 0;var list = res.data;list.forEach((item, idx) => {console.log(item)that.get_img_height(item.userInfoDetail.hande).then(rr=>{item.img_height = rr})if (see_list.indexOf(item._openid) != -1) {item.seeStatus = true} else {item.seeStatus = false}if(item.character_list){for (var itt in item.character_list) {if (item.character_list[itt] == wx.getStorageSync('userInfo').character_list[itt]) {item.fen = (item.fen + 5) || 5} else {}}}})console.log(list)var vList = [];var v2List = [];for (var i = 0; i < list.length; i++) {if (shang_height<list[i].img_height) {vList.push(list[i])} else {v2List.push(list[i])}shang_height =list[i].img_height}that.setData({list,vList,v2List,_openid: wx.getStorageSync('userInfo').openid})}})},})
<view><view class='view_outer'><view><block wx:for="{{v2List}}" wx:key="index"><view class='user_callingcard' wx:if='{{item.userInfoDetail.name&&item._openid!=_openid}}' catchtap="nav_detail" data-userinfo="{{item}}"><view class="fen">性格 {{item.fen||0}}%</view><image class='view_li' mode="widthFix" src='{{item.userInfoDetail.hande}}'></image><view class='item_txt'>{{item.userInfoDetail.name}} {{item.userInfoDetail.nssmr}}</view><!-- <view class='item_txt'> --><!-- </view> --><view class='item_txt2'>{{item.seeStatus?"已查看":"查看详情1"}}</view></view></block></view><view><block wx:for="{{vList}}" wx:key="index"><view class='user_callingcard' wx:if='{{item.userInfoDetail.name&&item._openid!=_openid}}' catchtap="nav_detail" data-userinfo="{{item}}"><view class="fen">性格 {{item.fen||0}}%</view><image class='view_li' mode="widthFix" src='{{item.userInfoDetail.hande}}'></image><view class='item_txt'>{{item.userInfoDetail.name}} {{item.userInfoDetail.nssmr}}</view><!-- <view class='item_txt'> --><!-- </view> --><view class='item_txt2'>{{item.seeStatus?"已查看":"查看详情2"}}</view></view></block></view></view><!-- <view class='more' bindtap='to_arr' id='2'>点击查看更多</view> --></view>
/* miniprogram/pages/find/index.wxss */
.p_r {display: flex;flex-direction: row;text-align: center;
}.top_block {padding-top: 30rpx;padding-bottom: 20rpx;border-bottom: 1px solid darkblue;
}.mg_bo {flex: 1;
}.col {color: #757575
}.da {font-size: 26rpx;margin-top: 16rpx;
}.acaca {color: darkblue;
}.user_callingcard {/* display: block;border-radius: 20rpx;width: 43%; */box-shadow: 4rpx 4rpx 4rpx 4rpx #dfdfdf;/* margin: 20rpx; */width: 330rpx;/* height: 550rpx; */border-radius: 20rpx;float: left;margin: 4px 0 0 1px;margin-right: 24rpx;position: relative;margin-bottom: 30rpx;
}.user_callingcard image {display: block;width: 100%;
}.view_outer {padding-top: 10rpx;margin-left: 26rpx;display: flex; flex-direction: row;
}.view_li {width: 300rpx;border-radius: 20rpx 20rpx 0 0 ;
}
.fen{position: absolute;right: 20rpx;top: 10rpx;font-size: 22rpx;/* background: #dfdfdf; */color: white;text-shadow:5px 2px 6px #000;}
.more {text-align: center;margin: 20rpx auto;width: 70%;/* border: 1px solid #666; */border-radius: 15rpx;color: #999;padding: 5rpx
}.item_txt2 {text-align: center;width: 100%;height: 90rpx;position: relative;top: 10rpx;line-height: 90rpx;background: wheat;color: cadetblue;margin-top: 16rpx;border-radius: 0 0 20rpx 20rpx;
}

相关文章:

Webhooks上的一个简单方法:恐吓现在停止

Webhook.Webhook。 It sounds like what happens when you cross a spider and a pirate. In the world of the internet though, webhooks are something completely different. Webhooks help connect services together.听起来就像当您越过蜘蛛和海盗时会发生什么。 但是&a…

12.MySql关于获取当前时间的三个函数

这三个函数都是获取当前时间的&#xff0c;获取的详细格式如下图所示&#xff0c;可以根据需要来选用。 转载于:https://www.cnblogs.com/Nick-Hu/p/7566805.html

微信小程序云开发,使用阿里云短信服务,搜索员工生日定期发送短信。

相关API文档地址&#xff1a; 阿里云短信服务API文档地址 小程序云开发云函数正则匹配API文档地址 小程序云开发云函数定时触发器 1.登录阿里云&#xff0c;购买短信服务并添加签名和模板 2.&#xff0c; 登录阿里云&#xff0c;鼠标放在右上角的头像图标就会显示 AccessKey…

信息安全系统设计基础家庭作业

《深入理解计算机系统》家庭作业 * 8.9 答案&#xff1a; 进程对 是否并发 AB 否 AC 是 AD 是 BC 是 BD 是 CD 是 * 8.10 答案&#xff1a; A. 调用一次&#xff0c;返回两次&#xff1a; fork B. 调用一次&#xff0c;从不返回&#xff1a; execve, longjmp C. 调…

css游戏代码_介绍CSSBattle-第一个CSS代码搜寻游戏

css游戏代码by kushagra gour由kushagra gour 介绍CSSBattle-第一个CSS代码搜寻游戏 (Introducing CSSBattle — the first CSS code-golfing game) If you are learning Web development or are already a professional Web developer, there is a very high chance you have…

IOS手机全屏长按识别二维码HTML代码

代码段作用讲解&#xff1a; 1. 二维码的全屏样式, opacity: 0; 透明样式&#xff0c; touch-callout: none; -webkit-touch-callout: none; -ms-touch-callout: none; -moz-touch-callout: none; 禁止IOS默认长按事件 .codePage {position: absolute;touch-callout: none;…

[亲测]在Mac下配置php开发环境:Apache+php+MySql

公司给我们配上了高大上的Apple Mac Pro本本&#xff0c;这两天自己正在习惯中。通过虚拟机PD&#xff0c;确实解决了一些因为工作习惯无法在iOS上很好完成的事情&#xff0c;但是我想&#xff0c;既然用起了iOS就尽量将一些事务在iOS环境下处理&#xff0c;免得好似关羽耍着大…

RabbitMQ 异常与任务分发

RabbitMQ 异常与任务分发 异常情况处理 上篇最后提到了这个问题&#xff0c; consumer异常退出、queue出错、甚至rabbitMQ崩溃。因为它们都是软件 &#xff0c;软件都会有bug&#xff0c;这是无法避免的。所以RabbitMQ在设计的时候也想到了这一点 在之前&#xff0c;消息分发给…

reddit_如何使用Python创建自定义Reddit通知系统

redditby Kelsey Wang王凯西 如何使用Python创建自定义Reddit通知系统 (How to make a custom Reddit notification system with Python) Don’t you just love automated emails? I know I do. I mean, who doesn’t enjoy waking up to 236 new messages from Nike, Ticket…

1016. Phone Bills (25)

时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, Yue去掉非法数据计算账单A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the…

样式集(五)微信朋友圈样式模拟

效果图&#xff1a; 小图标&#xff1a; 源码&#xff1a; <!--pages/findList/findList.wxml--> <image class"xxiangji" catchtap"xxiangji" src"/images/xxiangji.png"></image> <image class"top_img" src&…

为什么要选择useState而不是useReducer

by Austin Malerba奥斯汀马勒巴(Austin Malerba) 为什么要选择useState而不是useReducer (Why you should choose useState instead of useReducer) 通过useState进行本地和全局状态管理的指南 (A guide to local and global state management via useState) Since the introd…

php 类中的变量的定义

php 如果在类中定义变量&#xff0c;在类的方法中调用时应该加上$this-> . class ClassName {private $a 333;function __construct(){$this->a 2222;}public function bbb($value){echo $this->a;} } $b new className(); echo $b->bbb();转载于:https://www.c…

微信小程序云数据库触底分页加载,下拉无限加载,第一次请求数据随机,随机获取数据库的数据

效果图 小程序云开发分页加载代码 <!--pages/chatList/chatList.wxml--> <view class"pageTitle">家博慧</view> <view class" search_arr"><icon class"searchcion" size16 typesearch></icon><input …

Linux(Centos)之安装Java JDK及注意事项

1.准备工作 a.因为Java JDK区分32位和64位系统&#xff0c;所以在安装之前必须先要判断以下我们的Centos系统为多少位系统&#xff0c;命令如下&#xff1a; uname -a解释&#xff1a;如果有x86_64就是64位的&#xff0c;没有就是32位的。后面是X686或X86_64则内核是64位的&…

2019web前端趋势_2019年最值得关注的Web开发趋势

2019web前端趋势by Mrudul Shah通过Mrudul Shah 2019年最值得关注的Web开发趋势 (Top Web Development trends to look out for in 2019) Do you know that nearly 200 websites are pushed out every minute? Sounds astonishing right? But it is a fact and that’s why …

WPF入门教程系列九——布局之DockPanel与ViewBox(四)

七. DockPanel DockPanel定义一个区域&#xff0c;在此区域中&#xff0c;您可以使子元素通过描点的形式排列&#xff0c;这些对象位于 Children 属性中。停靠面板其实就是在WinForm类似于Dock属性的元 素。DockPanel会对每个子元素进行排序&#xff0c;并停靠在面板的一侧&…

tabBar 自定义,小程序自定义底部导航栏

创建一个自定义组件 my_tab&#xff0c;组件代码在后面&#xff0c;先看调用自定义组件的代码&#xff0c;比如我需要在index 页面调用&#xff0c;就在index.json中引用组件&#xff0c;index.json 代码&#xff08;引用的路径为你创建的自定义组件路径&#xff09; {"n…

2015年最新出炉的JavaScript开发框架

前端框架简化了开发过程中&#xff0c;像 Bootstrap 和 Foundation 就是前端框架的佼佼者。在这篇文章了&#xff0c;我们编制了一组新鲜的&#xff0c;实用的&#xff0c;可以帮助您建立高质量的 Web 应用程序的 JavaScript 框架清单。 1.Aurelia Aurelia是下一代JavaScript客…

小程序前端性能测试_如何提高前端应用程序的性能

小程序前端性能测试If your website takes longer than 3 seconds to load, you could already be losing nearly half of your visitors.如果您的网站加载时间超过3秒&#xff0c;则可能已经失去了将近一半的访问者。 Yes this is a fact, proven by several research studie…

10-TypeScript中的接口

接口是一种规约的约定&#xff0c;从接口继承的类必须实现接口的约定。在高级开发中&#xff0c;通常接口是用于实现各种设计模式的基础&#xff0c;没有接口&#xff0c;设计模式无从谈起。 定义接口&#xff1a; interface ILog{recordlog():boolean; } 类从接口继承&#xf…

样式集(六)仿微信通讯录样式

效果图&#xff1a; 这里有引用到 自定义底部导航&#xff0c;自定义底部导航组件链接 <!--pages/chatList/chatList.wxml--><!-- <include src"/components/common/common" /> --> <view class"top"><view class"pageTi…

WCF动态添加ServiceKnownType

WCF中传输自定义类型时&#xff0c;必须在服务接口类&#xff08;服务协定&#xff09;上加上ServiceKnownType(typeof(yourClass)), 在实际应用中比较麻烦&#xff0c;可以用动态的办法来实现动态添加。 服务接口类&#xff0c;加上一行 [ServiceKnownType("GetKnownType…

博客 rss 如何使用_如何使用RSS从您的GatsbyJS博客自动交叉发布

博客 rss 如何使用With the recent exodus from Medium many developers are now creating their own GatsbyJS Blogs and then cross-posting to Medium or publications like freecodecamp.org and dev.to.随着Medium最近的离职&#xff0c;许多开发人员现在正在创建自己的Ga…

大型技术网站的技术( 高并发、大数据、高可用、分布式....)(一)

面对高并发、大流量、高可用、海量数据、用户分布广泛、网络情况复杂这类网站系统我们如何应对&#xff1f;&#xff1f;&#xff1f; 第一阶段 一台服务器不行就上多台服务器 1.应用程序与数据服务分离 将应用程序、数据库、文件等资源放在一台服务器上&#xff0c;面对海量…

BestCoder Round #65 B C D || HDU 5591 5592 5593

B 题意&#xff1a;ZYB在远足中,和同学们玩了一个“数字炸弹”游戏&#xff1a;由主持人心里想一个在[1,N][1,N]中的数字XX&#xff0c;然后玩家们轮流猜一个数字&#xff0c;如果一个玩家恰好猜中XX则算负&#xff0c;否则主持人将告诉全场的人当前的数和XX比是偏大还是偏小&a…

数组去重,ES6数组去重 new Set()

普通数组去重 var b [...new Set([1,2, 3, 4, 5, 5, 5, 5])]console.log(b); 输出结果&#xff1a; 包含对象的数组去重 var o {a:1}var b [...new Set([o, o, 3, 4, 5, 5, 5, 5])]console.log(b); 输出结果&#xff1a; 包含对象的数组去重有一个坑 var b [...new Set([{…

使用angular的好处_在项目中使用Angular的最大好处

使用angular的好处by Irina Sidorenko伊琳娜西多连科(Irina Sidorenko) 在项目中使用Angular的最大好处 (The top benefits of using Angular for your project) 在项目实施中使用Angular的11个理由及其好处 (11 reasons to use Angular and its benefits for your project im…

python之路——模块和包

一、模块 1、什么是模块&#xff1f; 常见的场景&#xff1a;一个模块就是一个包含了Python定义和声明的文件&#xff0c;文件名就是模块名字加上.py的后缀。 但其实import加载的模块分为四个通用类别&#xff1a; 1、使用Python编写的代码&#xff08;.py文件&#xff09; 2、…

夺命雷公狗---linux NO:3 centos_mini版的安装和备份

废话不多说&#xff0c;和前面的其实是差不多的&#xff0c;如下图所示&#xff1a; 安装其实是和桌面版的差不多的&#xff0c;但是经典版的不能自定义分区&#xff08;如详细区&#xff0c;如home之类的&#xff09;。。。 因为我们使用的是命令行方式的所以直接选英文&#…