listimage1.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view class="container">
  3. <view style="width: 100%;height: 250rpx;padding: 20rpx;">
  4. <view style="font-size: 24px;">家族合影</view>
  5. <view style="font-size: 16px;color: #8f8f94;">134张/照片</view>
  6. </view>
  7. <view v-for="(item, index) in images" :key="index">
  8. <text style="margin: 1.6%;font-size: 28rpx;">{{ item.time }}</text>
  9. <view :data-index="index">
  10. <view style="width: 30%;height: 250rpx;margin: 1.6%;float: left;" v-for="(items, indexs) in item.list">
  11. <image style="width: 100%;height: 100%;" :src="items.imgurl" :data-src="items.imgurl" @tap="previewOpen"></image>
  12. </view>
  13. </view>
  14. </view>
  15. <previewImage ref="previewImage" :opacity="0.8" :imgs="images[0].imgurl" :descs="images[0].descs" @longPress="longPress"></previewImage>
  16. </view>
  17. </template>
  18. <script>
  19. import previewImage from '@/components/kxj-previewImage/kxj-previewImage.vue'; //引用插件
  20. export default {
  21. components: { previewImage }, //注册插件
  22. data() {
  23. return {
  24. images: [
  25. {
  26. time: '2020/8/1',
  27. list: [
  28. {
  29. imgurl: '../../../static/img/family/listimage/1.jpg',
  30. descs: '合照1'
  31. },{
  32. imgurl: '../../../static/img/family/listimage/2.jpg',
  33. descs: '合照2'
  34. },{
  35. imgurl: '../../../static/img/family/listimage/3.jpg',
  36. descs: '合照3'
  37. }
  38. ]
  39. }
  40. ],
  41. };
  42. },
  43. onNavigationBarButtonTap(e) {
  44. uni.navigateTo({
  45. url: '/pages/family/listimage/uploadimg/uploadimg'
  46. });
  47. },
  48. methods: {
  49. //打开预览e
  50. previewOpen(e) {
  51. var param = e.currentTarget.dataset.src;
  52. console.log(param);
  53. this.$refs.previewImage.open(param); // 传入当前选中的图片地址或序号
  54. return; //如需测试和uni原生预览差别可注释这两行
  55. //以下是效果对比相关
  56. var _this = this;
  57. uni.showModal({
  58. title: '请选择',
  59. content: '请选择使用uni原生图片预览或非原生自定义的图片预览。',
  60. cancelText: 'uni',
  61. confirmText: '自定义',
  62. success: function(res) {
  63. if (res.confirm) {
  64. _this.$refs.previewImage.open(param); // 传入当前选中的图片地址或序号
  65. } else if (res.cancel) {
  66. uni.previewImage({
  67. current: param,
  68. urls: _this.imgs
  69. });
  70. }
  71. }
  72. });
  73. },
  74. //长按事件
  75. longPress(data) {
  76. console.log(data);
  77. uni.showModal({
  78. showCancel: false,
  79. title: '长按事件',
  80. content: '已触发长按事件,你可以在这里做更多',
  81. success: showResult => {
  82. }
  83. });
  84. }
  85. }
  86. };
  87. </script>
  88. <style>
  89. page {
  90. background-color: #f7f7f7;
  91. }
  92. .container {
  93. padding-bottom: 110rpx;
  94. width: 100%;
  95. }
  96. .text-area {
  97. display: flex;
  98. justify-content: center;
  99. }
  100. .title {
  101. font-size: 26rpx;
  102. color: #999999;
  103. }
  104. </style>