欢迎光临,了解微信小程序开发,就上易用通!

当前位置 : 易用通 > 小程序模板
微信日常相册处理,细节至上,初级版微信日常相册处理,细节至上,初级版
立即下载

微信日常相册处理,细节至上,初级版

模板分类 : 小程序模板 模板编号 : Y426 源码文件 : 完全开源 下载权限 : VIP会员
模板大小 :  模板指数 :  更新时间 : 2018-01-20 15:29 模板等级 : ☆☆☆☆☆

模板截图:

具体的截图,今天由于时间关系,不做详细描述若需要具体数据信息,或者了解更多小小艺人平台信息 可在网上搜索“艺人邦”,或者访问“http://www.300hu.com/”官网,下载APP,或者注册,即可获得相关接口,已经相应数据内容和用法 1.相册进入界面 列表样式显示图片 2.点击图片 进入高级画册 3.高级画册 可点选对应的图片,查看高品质图片,由于网络影响,速度可能会比较慢 大图,可以通过点击它显示左右切换功能,也可以手动滑动(一般会受网络影响) 同时,图片在3秒后可以点击close关闭 微信日常相册处理,细节至上,初级版(图1) 
  1. var util = require('../../utils/util.js')
  2. var cfg = require('../../utils/cfg.js')
  3. Page({
  4.   data: {
  5.     album: {},
  6.     show: true,
  7.     pid: 0,
  8.     cid: 0,
  9.     savatar: '',
  10.     showGallery: true,
  11.     showBtn: true,
  12.     height: cfg.height,
  13.     width: cfg.width,
  14.     scale: cfg.height / cfg.width,
  15.     img: cfg.img,
  16.     imageWidth: cfg.width,
  17.     imageHeight: cfg.height,
  18.     time: 0,
  19.     params: {
  20.       client_ver: '0.4.4',
  21.       from_client: 'cc',
  22.       openid: '',
  23.       page: 1,
  24.       pagesize: 10,
  25.       title: '',
  26.       uid: 1140518
  27.     }
  28.   },
  29.   formSubmit: function (e) {
  30.     var val = e.detail.value
  31.     console.log('form发生了submit事件,携带数据为:', val.input)
  32.     var that = this
  33.     var obj = that.data.params
  34.     obj.title = val.input
  35.     that.setData({ params: obj })
  36.     setTimeout(function () {
  37.       that.getConImages()
  38.     }, 1000)
  39.   },
  40.   getConImages: function () {
  41.     var that = this
  42.     var obj = that.data.params
  43.     console.log('album---params--name:' + obj.username)
  44.     util.get(cfg.host + 'api/cc/act?mod=user3&act=photos', obj,
  45.       function (res) {
  46.         obj = res.data
  47.         obj = obj.data.list
  48.         that.setData({
  49.           album: obj,
  50.           time: 0
  51.         })
  52.       })
  53.   },
  54.   showMadel(e) {
  55.     console.log('showMadel:' + e.currentTarget.id)
  56.     var that = this
  57.     that.setData({
  58.       showGallery: false,
  59.       cid: e.currentTarget.id
  60.     })
  61.   },
  62.   showView(e) {
  63.     var that = this
  64.     var savatar = that.data.album[e.currentTarget.id].photo
  65.     savatar = savatar.split('.jpg')
  66.     savatar = savatar[0] + '.jpg'
  67.     var imageSize = util.imgUtil(savatar)
  68.     that.setData({
  69.       show: false,
  70.       pid: e.currentTarget.id,
  71.       savatar: savatar,
  72.       imageWidth: imageSize.imageWidth,
  73.       imageHeight: imageSize.imageHeight
  74.     })
  75.   },
  76.   showBtns(e) {
  77.     var that = this
  78.     that.setData({showBtn: false})
  79.     setTimeout(
  80.       function() {
  81.         if (!that.data.showBtn) {
  82.           that.setData({showBtn: true})
  83.         }
  84.       }, 3000)
  85.   },
  86.   closeImg(e) {
  87.     console.log('e:' + e)
  88.     console.log('closeImg:' + e.currentTarget.id)
  89.     var that = this
  90. //    var pid = that.data.pid
  91.     var show = that.data.show
  92.     if (show) {
  93.       // 当处于浏览状态时,点击关闭,隐藏浏览界面
  94.       that.setData({showGallery: true})
  95.     } else {
  96.       // 当处于浏览状态时,点击关闭,隐藏浏览界面
  97.       that.setData({show: true})
  98.     }
  99.   },
  100.   nextImg(e) {
  101.     // 点击时,获取当前图片ID,或者pid
  102.     var that = this
  103.     var id = that.data.cid
  104.     var length = that.data.length
  105.     var time = that.data.time
  106.     if (id === (length - 2)) {
  107.       if (time !== 1) {
  108.         time = 1
  109.         setTimeout(function () {
  110.           that.getMoreImg()
  111.         }, 1000)
  112.       } else {
  113.         return
  114.       }
  115.       wx.showToast({
  116.         title: '更多,请等待加载',
  117.         icon: 'successs',
  118.         duration: 2000
  119.       })
  120.     } else {
  121.       that.setData({cid: id + 1, pid: id + 1})
  122.     }
  123.   },
  124.   prevImg(e) {
  125.   // 点击时,获取当前图片ID,或者pid
  126.     var that = this
  127.     var id = that.data.pid
  128.     //    var length = that.data.album.length
  129.     if (id === 0) {
  130.       wx.showToast({
  131.         title: '这是第一张图片',
  132.         icon: 'successs',
  133.         duration: 2000
  134.       })
  135.       return
  136.     }
  137.     that.setData({cid: id - 1, pid: id - 1})
  138.   },
  139.  
  140.   changeId(e) {
  141.     console.log('changeId:' + e.detail.current)
  142.     var that = this
  143.     var id = e.detail.current
  144.     var time = that.data.time
  145.     if (id >= that.data.album.length - 2) {
  146.       wx.showToast({
  147.         title: '更多,请等待加载',
  148.         icon: 'successs',
  149.         duration: 2000
  150.       })
  151.       if (time !== 1) {
  152.         time = 1
  153.         setTimeout(function () {
  154.           that.getMoreImg()
  155.         }, 1000)
  156.       } else {
  157.         id = id - 1
  158.       }
  159.     }
  160.     var show = that.data.show
  161.     var savatar = that.data.album[id].photo
  162.     if (!show) {
  163.       savatar = savatar.split('.jpg')
  164.       savatar = savatar[0] + '.jpg'
  165.     }
  166.     that.setData({
  167.       cid: id,
  168.       pid: id,
  169.       savatar: savatar
  170.     })
  171.   },
  172.   bindCid(e) {
  173.     console.log('closeView:' + e.currentTarget.id)
  174.     var that = this
  175.     that.setData({cid: e.currentTarget.id})
  176.   },
  177.   scrollEvent: function (e) {
  178.     var that = this
  179.     setTimeout(function () {
  180.       that.getMoreImg()
  181.     }, 1000)
  182.   },
  183.   getMoreImg: function () {
  184.     var that = this
  185.     var obj = that.data.params
  186.     var album = that.data.album
  187.     if (album.length === obj.pagesize) {
  188.       obj.pagesize += 10
  189.       that.setData({
  190.         params: obj
  191.       })
  192.     }
  193.     setTimeout(function () {
  194.       that.getConImages()
  195.     }, 1000)
  196.   },
  197.   onLoad: function () {
  198.     var that = this
  199.     var width = cfg.width
  200.     var height = cfg.height
  201.     console.log('width:' + width + 'height:' + height)
  202.     var scale = height / width
  203.     that.setData({
  204.       width: width,
  205.       height: height,
  206.       scale: scale
  207.     })
  208.     setTimeout(function () {
  209.       that.getConImages()
  210.     }, 1000)
  211.   }
  212. })
  213. // # sourceMappingURL=album.js.map
复制代码
  1. <scroll-view scroll-y="true" hidden="{{!showGallery}}"style="height:{{(album.length)*100}}rpx;background-color:lightcyan;position:relative;top:125rpx;"
  2. >
  3. <form bindsubmit="formSubmit" class = "firstbox">
  4. <view class = "srft">
  5. <input name="input" style="background-color:gray;margin-top:-21rpx;margin-left:80rpx;width:330rpx;border:2rpx solid yellow;border-radius:8%"  />
  6. <button formType="submit" style="color:blue;margin-top:-21rpx;font-size:21rpx;height:60rpx;margin-left:100rpx;text-align:top;">搜索</button>
  7. </view>
  8. </form>
  9.   <view class="params" wx:for="{{album}}"
  10. wx:key="photo"
  11. wx:if="{{(index%3==0)}}">     
  12.         <view
  13.         style="margin-left:40rpx;"
  14.         bindtap="showMadel" id="{{index}}">
  15.     <image
  16.         class="userinfo-avatar"
  17.         src="{{img+album[index].photo}}"
  18.         ></image> </view>
  19.         <view
  20.         style="margin-left:10rpx;margin-right:10rpx;"
  21.         bindtap="showMadel"
  22.         id="{{index+1}}">
  23.         <image
  24.         class="userinfo-avatar"
  25.         src="{{img+album[index+1].photo}}"
  26.         ></image>
  27.         </view>
  28.         <view
  29.         style="margin-right:40rpx;"
  30.         bindtap="showMadel"
  31.         id="{{index+2}}">
  32.         <image
  33.         class="userinfo-avatar"
  34.         src="{{img+album[index+2].photo}}"
  35.         ></image>
  36.         </view>
  37.   </view>
  38. </scroll-view>
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. <view hidden="{{showGallery}}"style="position:absolute;top:0rpx;left:0rpx;width:100%;height:100%;z-index:1;background:linear-gradient(to bottom, lightblue , lightgray);opacity:0.6;">
  48. </view>
  49. <view hidden="{{showGallery}}" style="position:absolute;top:0rpx;left:0rpx;width:100%;height:100%;z-index:2;">
  50.  
  51.  
  52. <swiper indicator-dots="true" current="{{cid}}" bindchange="changeId"
  53.   autoplay="false" interval="60000" duration="400" circular="false" style="width:{{(show)?70:90}}%;height:{{(show)?50:90}}%;position:absolute;top:5%;left:{{(show)?15:5}}%;border-top: 3rpx solid lightgray;border-bottom: 4rpx solid gray;border-right:3rpx solid gray;border-left:2rpx solid lightgray;border-radius:2%;opacity:{{(show)?0.9:0}};background-color:aliceblue;z-index:{{(show)?3:5}}" >
  54.   <block wx:for="{{album}}" wx:key="photo">
  55.     <swiper-item id="{{index}}" bindtap="{{(show)?'showView':'showBtns'}}" >
  56.       <image
  57.       src="{{img+album[index].photo}}" style ="width:{{(show)?80:100}}%;height:{{(show)?80:100}}%;position:relative;top:{{(show)?10:0}}%;left:{{(show)?10:0}}%;"/>
  58.     </swiper-item>
  59.   </block>
  60. </swiper>
  61.  
  62. <scroll-view   scroll-x="true" bindscrolltolower="scrollEvent" style="position:absolute;top:60%;left:0rpx;width:100%;height:30%;"  lower-threshold ="10rpx" scroll-left="{{(cid>2)?(cid*130):0}}" >
  63. <view  class="box3" style = "width:{{(album.length)*240}}rpx;" > 
  64. <view  wx:for="{{album}}" wx:key="photo" >  
  65. <view bindtap="bindCid"  id="{{index}}"
  66. style ="display:flex;flex-direction:row;align-items:center;margin-left:40rpx;border-radius:8%;border:{{(index == cid)?'6rpx solid pink':'3rpx solid gray'}}"
  67. >
  68.      <image class="userinfo-avatar" src="{{img+album[index].photo}}"></image>
  69. </view >
  70. </view >
  71. </view >
  72. </scroll-view >
  73.  
  74. <view bindtap="showBtns"  hidden="{{show}}" style="position:absolute;top:0%;left:0%;width:100%;height:100%;z-index:3;background-color:black;opacity:0.6;">
  75. </view>
  76.       <!--<image bindtap="showBtns"  hidden="{{show}}" id ="{{pid}}" src="{{img+savatar}}" style ="width:{{imageWidth}}px;height:{{imageHeight}}px;position:absolute;left:{{(imageWidth==width)?0:(width-imageWidth)/2}}px;top:{{(imageHeight==height)?0:(height-imageHeight)/2}}px;z-index:4;"/>-->
  77. <image bindtap="showBtns"  hidden="{{show}}" id ="{{pid}}" src="{{img+savatar}}" style ="width:90%;height:80%;position:absolute;left:5%;top:10%;z-index:4;"/>
  78.  
  79. <view hidden="{{showBtn}}">
  80. <button bindtap="prevImg" style="position:absolute;top:40%;left:4%;width:10%;height:7%;background-color:white;z-index:6;opacity:0.8;border-radius:40%;color:black;border:1rpx solid lightgray;font-weight:bold;" >
  81. <--
  82. </button>
  83. <button bindtap="nextImg" style="position:absolute;top:40%;right:4%;width:10%;height:7%;background-color:white;z-index:6;opacity:0.8;border-radius:40%;color:black;border:1rpx solid  lightgray;font-weight:bold;" >
  84. >--
  85. </button>
  86. </view>
  87.  
  88. <button bindtap="closeImg" hidden="{{!showBtn}}" style="position:absolute;top:90%;left:39.9%;width:20%;height:7%;background-color:white;z-index:6;opacity:0.8;border-radius:30%;color:black;border:1rpx solid lightgray;font-weight:600;" >
  89. close
  90. </button>
  91. </view>
复制代码
 

加入收藏
立即下载
分享到微信朋友圈
X

免责声明:

1. 本站所有素材(未指定商用),仅限学习交流,请勿用于商业用途。
2. 本站所有小程序模板Demo和图片均来自用户分享上传和网络收集,模板和图片版权归原作者及原出处所有。
3. 未经合法授权,会员不得以任何形式发布、传播、复制、转售该素材。