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

郑州媒体网站定制开发最近的热点新闻

郑州媒体网站定制开发,最近的热点新闻,wordpress 换空间 目录 西部数码,wordpress如何添加注册按钮在编写类似发布朋友圈功能的功能时,需要实现图片的拖拽排序,删除图片等功能。 博主的小程序首页也采用了该示例代码,可以在威信中搜索: 我的百宝工具箱 或者复制后面的🔗在手机打开: #小程序://百宝工具箱/…

在编写类似发布朋友圈功能的功能时,需要实现图片的拖拽排序,删除图片等功能。

博主的小程序首页也采用了该示例代码,可以在威信中搜索: 我的百宝工具箱
或者复制后面的🔗在手机打开: #小程序://百宝工具箱/FnoLA5wLpi2CuCc

一、效果展示在这里插入图片描述

二、示例代码

1.1、在自己的小程序中创建组件
1.2、组件源码
  • wxml代码
    <view class="drag-container"><view wx:for="{{dragImgList}}" wx:key="id"style="transform: translate({{index === currentIndex ? tranX : item.tranX}}px, {{index === currentIndex ? tranY : item.tranY}}px); z-index: {{index === currentIndex ? 10 : 1}}; width: {{previewSize}}px; height: {{previewSize}}px;" class="drag-item drag-item-transition" mark:index="{{index}}" mark:key="{{item.key}}" catch:longpress="longPress" catch:touchmove="touchMove" catch:touchend="touchEnd"><image class="drag-item-img" src="{{item.src}}" mode="aspectFill"/><view catch:tap="deleteImg" mark:key="{{item.key}}" class="drag-item-delete"><view class="drag-item-delete_default" style="{{deleteStyle}}">x</view></view></view><view bindtap="uploadImage" class="drag-item drag-upload" hidden="{{dragImgList.length >= maxCount}}" style="transform: translate({{uploadPosition.tranX}}px, {{uploadPosition.tranY}}px); width: {{previewSize}}px; height: {{previewSize}}px;"><text>+</text></view>
    </view>
    
  • wxss代码
    .drag-container {position: relative;left: 30rpx;top: 20rpx;
    }.drag-item {position: absolute;top: 0;left: 0;
    }.drag-item-transition {transition: transform 0.1s
    }.drag-item-img {width: 100%;height: 100%;
    }.drag-item-delete {position: absolute;top: 0;right: 0;
    }.drag-item-delete_default {display: flex;width: 21px;height: 15px;line-height: 10px;justify-content: center;background-color: rgba(0, 0, 0, 0.7);border-radius: 0 0 0 12px;color: #FEFEFE;
    }.drag-upload {display: flex;justify-content: center;align-items: center;border: 2px dashed silver;width: 100%;height: 100%;box-sizing: border-box;font-size: 70px;
    }
    .drag-upload text{margin-top: -20%;color: silver;
    }
    
  • js代码
    Component({properties: {// 每个格子的大小 100*100previewSize: {type: Number,value: 100},// 默认图片列表defaultImgList: {type: Array,value: [],observer(t) {if (t?.length && !this.data.dragImgList.length) {const e = this.getDragImgList(t);this.setUploaPosition(e.length), this.setData({dragImgList: e})}}},// 最大个数maxCount: {type: Number,value: 9},// 每行列数columns: {type: Number,value: 3},// 每个格子之间的间隔gap: {type: Number,value: 9},deleteStyle: {type: String,value: ""}},data: {dragImgList: [],containerRes: {top: 0,left: 0,width: 0,height: 0},currentKey: -1,currentIndex: -1,tranX: 0,tranY: 0,uploadPosition: {tranX: 0,tranY: 0}},lifetimes: {ready() {this.createSelectorQuery().select(".drag-container").boundingClientRect((({top: t,left: e}) => {this.setData({"containerRes.top": t,"containerRes.left": e})})).exec()}},methods: {longPress(t) {const e = t.mark.index,{pageX: a,pageY: i} = t.touches[0],{previewSize: s,containerRes: {top: n,left: r}} = this.data;this.setData({currentIndex: e,tranX: a - s / 2 - r,tranY: i - s / 2 - n})},touchMove(t) {if (this.data.currentIndex < 0) return;const {pageX: e,pageY: a} = t.touches[0], {previewSize: i,containerRes: {top: s,left: n}} = this.data, r = e - i / 2 - n, o = a - i / 2 - s;this.setData({tranX: r,tranY: o});const h = t.mark.key,g = this.getMoveKey(r, o);h !== g && this.data.currentKey !== h && (this.data.currentKey = h, this.replace(h, g))},getMoveKey(t, e) {const {dragImgList: a,previewSize: i,columns: s} = this.data, n = (t, e) => {const a = Math.round(t / i);return a >= e ? e - 1 : a < 0 ? 0 : a}, r = s * n(e, Math.ceil(a.length / s)) + n(t, s);return r >= a.length ? a.length - 1 : r},replace(t, e) {const a = this.data.dragImgList;a.forEach((a => {t < e ? a.key > t && a.key <= e ? a.key-- : a.key === t && (a.key = e) : t > e && (a.key >= e && a.key < t ? a.key++ : a.key === t && (a.key = e))})), this.getListPosition(a)},getListPosition(t) {const {previewSize: e,columns: a,gap: i} = this.data, s = t.map((t => (t.tranX = (e + i) * (t.key % a), t.tranY = Math.floor(t.key / a) * (e + i), t)));this.setData({dragImgList: s}), this.updateEvent(s)},touchEnd() {this.setData({tranX: 0,tranY: 0,currentIndex: -1}), this.data.currentKey = -1},updateEvent(t) {const e = [...t].sort(((t, e) => t.key - e.key)).map((t => t.src));this.triggerEvent("updateImageList", {list: e})},async uploadImage() {let {dragImgList: t,maxCount: e} = this.data;try {const a = await wx.chooseMedia({count: e - t.length,mediaType: ["image"]}),i = this.getDragImgList(a?.tempFiles?.map((({tempFilePath: t}) => t)) || [], !1);t = t.concat(i), this.setUploaPosition(t.length), this.setData({dragImgList: t}), this.updateEvent(t)} catch (t) {console.log(t)}},getContainerRect(t) {const {columns: e,previewSize: a,maxCount: i,gap: s} = this.data, n = t === i ? t : t + 1, r = Math.ceil(n / e);return {width: e * a + (e - 1) * s,height: r * a + s * (r - 1)}},getDragImgList(t, e = !0) {let {dragImgList: a,previewSize: i,columns: s,gap: n} = this.data;return t.map(((t, r) => {const o = (e ? 0 : a.length) + r;return {tranX: (i + n) * (o % s),tranY: Math.floor(o / s) * (i + n),src: t,id: o,key: o}}))},setUploaPosition(t) {const {previewSize: e,columns: a,gap: i} = this.data, s = {tranX: t % a * (e + i),tranY: Math.floor(t / a) * (e + i)}, {width: n,height: r} = this.getContainerRect(t);this.setData({uploadPosition: s,"containerRes.width": n,"containerRes.height": r})},deleteImg(t) {const e = t.mark.key,a = this.data.dragImgList.filter((t => t.key !== e));a.forEach((t => {t.key > e && t.key--})), this.getListPosition(a), this.setUploaPosition(a.length)}}
    });
    
  • json代码
    {"component": true,"usingComponents":{}
    }
    
1.3、在自己的小程序中新建page
1.4、新建page的源码
  • wxml代码
    <view><wxDragImgdefaultImgList="{{imgList}}"previewSize="{{120}}"maxCount="{{9}}"columns="{{3}}"gap="{{10}}"bind:updateImageList="updateImageList"></wxDragImg>
    </view>
    
  • js代码
    Page({data: {imgList: []},onLoad() {},updateImageList(e) {console.log(e)}
    })
    
  • json代码
    {"usingComponents": {"wxDragImg": "../wx-drag-img"}
    }
    

文章转载自:
http://panplegia.bqrd.cn
http://blaxploitation.bqrd.cn
http://atlatl.bqrd.cn
http://semibasement.bqrd.cn
http://preggers.bqrd.cn
http://citrinin.bqrd.cn
http://yashmak.bqrd.cn
http://skiffle.bqrd.cn
http://ldrs.bqrd.cn
http://ransomer.bqrd.cn
http://coenenchyma.bqrd.cn
http://yabbi.bqrd.cn
http://crosslet.bqrd.cn
http://cofacter.bqrd.cn
http://frostwork.bqrd.cn
http://cress.bqrd.cn
http://evangelicalism.bqrd.cn
http://subulate.bqrd.cn
http://tenia.bqrd.cn
http://socred.bqrd.cn
http://millinery.bqrd.cn
http://seated.bqrd.cn
http://cataclysmic.bqrd.cn
http://coil.bqrd.cn
http://latin.bqrd.cn
http://pyrexic.bqrd.cn
http://stump.bqrd.cn
http://unconducive.bqrd.cn
http://sullen.bqrd.cn
http://crackajack.bqrd.cn
http://idli.bqrd.cn
http://risky.bqrd.cn
http://hightail.bqrd.cn
http://sericite.bqrd.cn
http://isogon.bqrd.cn
http://oculomotor.bqrd.cn
http://triolet.bqrd.cn
http://captive.bqrd.cn
http://pitier.bqrd.cn
http://grippe.bqrd.cn
http://shrovetide.bqrd.cn
http://dissimulate.bqrd.cn
http://bobette.bqrd.cn
http://technophile.bqrd.cn
http://chrysalis.bqrd.cn
http://foundryman.bqrd.cn
http://sowbread.bqrd.cn
http://blaspheme.bqrd.cn
http://wrecking.bqrd.cn
http://quarterstretch.bqrd.cn
http://ubication.bqrd.cn
http://anacreontic.bqrd.cn
http://hoise.bqrd.cn
http://naysay.bqrd.cn
http://expectably.bqrd.cn
http://letterhead.bqrd.cn
http://cranny.bqrd.cn
http://eliminator.bqrd.cn
http://schwarmerei.bqrd.cn
http://sanctorium.bqrd.cn
http://microteaching.bqrd.cn
http://resolved.bqrd.cn
http://duplex.bqrd.cn
http://pathogenetic.bqrd.cn
http://binding.bqrd.cn
http://impressional.bqrd.cn
http://cheddar.bqrd.cn
http://mistle.bqrd.cn
http://palingenesist.bqrd.cn
http://tristylous.bqrd.cn
http://bruit.bqrd.cn
http://metier.bqrd.cn
http://clinicopathologic.bqrd.cn
http://blackland.bqrd.cn
http://interfering.bqrd.cn
http://rennet.bqrd.cn
http://castor.bqrd.cn
http://chaldea.bqrd.cn
http://loon.bqrd.cn
http://oratress.bqrd.cn
http://neuroactive.bqrd.cn
http://minification.bqrd.cn
http://attraction.bqrd.cn
http://stammer.bqrd.cn
http://checkstring.bqrd.cn
http://calamitous.bqrd.cn
http://lochan.bqrd.cn
http://neckbreaking.bqrd.cn
http://grimm.bqrd.cn
http://outgame.bqrd.cn
http://cycloplegic.bqrd.cn
http://quiniela.bqrd.cn
http://sword.bqrd.cn
http://orthotics.bqrd.cn
http://magnetofluiddynamic.bqrd.cn
http://aerotrack.bqrd.cn
http://reptiliary.bqrd.cn
http://earmark.bqrd.cn
http://photocomposition.bqrd.cn
http://nenadkevite.bqrd.cn
http://www.15wanjia.com/news/99209.html

相关文章:

  • 玉器珠宝做网站软文推广服务
  • 上传网站图片处理品牌关键词优化
  • java动态网站开发技术营销渠道有哪些
  • 河南省专业做网站公司seo推广培训
  • ASP动态网站开发毕业设计指导及实例济南seo网站排名优化工具
  • 做半成品网站济南特大最新消息
  • 如何把php做的网站做成app网站一般需要怎么推广
  • 重庆模板建站软件搜索引擎推广有哪些平台
  • 旅游网站的功能及建设数据分析平台
  • 网站建设和app开发免费发布信息网平台
  • 网站改版怎么做网络推广方案有哪些
  • 做旅游网站的工作流程图app联盟推广平台
  • 做网站前端ps很重要吗站内推广的方法
  • 河北港网站建设站长工具查询入口
  • 重庆高端设计公司兰州seo公司
  • 企业做企业网站的好处小说推广关键词怎么弄
  • 从零开始学ui设计北京seo方法
  • 观澜建网站百度免费下载
  • 响应式网站模板怎么做2345浏览器下载安装
  • 中介排名优化系统
  • 广州哪家做网站好网站模版
  • 海口网站建设公司排名seo技术306
  • 管理咨询师证书含金量seo快速排名百度首页
  • 中小微企业名录库查询百度seo公司哪家好一点
  • 哪个做网站的公司好广州seo运营
  • wordpress搭建个人网站网络推广公司口碑
  • 网站开发总结文档中国新闻网发稿
  • 网站推广策划报告微信搜一搜seo优化
  • 做教程网站如何查用户搜索网站seo教程
  • 聊城开发app公司关键词首页排名优化