StrongPhoto.vue 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="Photo-box">
  3. <banner-swipe :list="photoBannerImages" />
  4. <div style="display: flex; aline-itme:center;margin-top: 30px;position:relative ">
  5. <!-- <div :class="`${classStyle?'Zhedie-box Donghua':'Zhedie-box'}`"> -->
  6. <div :class="{'Zhedie-box': true, 'expand': classStyle}">
  7. <!-- :class="`${clickStyle?'clickStyle':''}`" -->
  8. <div
  9. v-for="(item,i) in buttList"
  10. :key="i"
  11. @click="SeePhotos(i,item.packId)"
  12. :class="activeNum === i ? 'clickStyle':''"
  13. >{{item.name}}</div>
  14. </div>
  15. <van-icon
  16. v-show="iconShow"
  17. style="right:4vw; top: 0.6vh; position:absolute"
  18. :name="`${classStyle?'arrow-up ':'arrow-down'}`"
  19. @click="animations"
  20. />
  21. </div>
  22. <div class="PhotoList-box">
  23. <div class="PhotoList-box-images" v-for="(item, index) in newArrImageList" :key="index">
  24. <div class="PhotoList-box-text">
  25. <div></div>
  26. <span>{{item.createDate}}</span>
  27. </div>
  28. <van-image
  29. v-for="(image, index) in item.res"
  30. :key="index"
  31. width="31vw"
  32. :src="image.url"
  33. style="padding:0 3px 0 2px"
  34. @click="showBig(image.url)"
  35. />
  36. <van-image-preview v-model="imageShow" :images="bigImg" />
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import { getPhotoSotr, getPhotos } from '@/util/api'
  43. import { parseTime } from '@/util/formattingData'
  44. import { getBanner } from '@/util/api'
  45. export default {
  46. components: {
  47. BannerSwipe: () => import('./components/BannerSwipe.vue'),
  48. },
  49. data() {
  50. return {
  51. classStyle: false,
  52. clickStyle: false,
  53. iconShow: true,
  54. imageShow: false,
  55. bigImg: [],
  56. activeNum: 0, //下标
  57. buttList: [],
  58. photoBannerImages: [],
  59. imageList: [],
  60. newArrImageList: []
  61. }
  62. },
  63. watch: {
  64. buttList: {
  65. handler(val) {
  66. if (val.length !== 0) {
  67. this.SeePhotos(0, val[0].packId)
  68. }
  69. },
  70. immediate: true
  71. }
  72. },
  73. mounted() {
  74. this.onBanner()
  75. this.onLoadSort()
  76. this.dataResort()
  77. // if (this.buttList.length >= 2) {
  78. // this.iconShow = true
  79. // } else {
  80. // this.iconShow = false
  81. // }
  82. },
  83. methods: {
  84. showBig(val) {
  85. this.bigImg = [val]
  86. this.imageShow = true
  87. },
  88. parseTime,
  89. //日期按天分类
  90. dataResort(arr) {
  91. var newArr = []
  92. this.imageList.forEach(function (oldData, i) {
  93. var index = -1
  94. var createTime = parseTime(oldData.createDate, '{y}-{m}-{d}')
  95. var newTime = parseTime(createTime, '{y}-{m}-{d}')
  96. var alreadyExists = newArr.some(function (newData, j) {
  97. var noData = parseTime(newData.createDate, '{y}-{m}-{d}')
  98. if (newTime === noData) {
  99. index = j
  100. return true
  101. }
  102. })
  103. if (!alreadyExists) {
  104. var res = []
  105. res.push(oldData)
  106. newArr.push({
  107. createDate: createTime,
  108. res: res
  109. })
  110. } else {
  111. newArr[index].res.push(oldData)
  112. }
  113. })
  114. this.newArrImageList = newArr
  115. },
  116. onLoadSort() {
  117. getPhotoSotr().then((e) => {
  118. this.buttList = e.records
  119. })
  120. },
  121. animations() {
  122. this.classStyle = !this.classStyle
  123. if (this.classStyle === false) {
  124. var item = this.buttList[this.activeNum]
  125. this.buttList.splice(this.activeNum, 1)
  126. this.buttList.unshift(item)
  127. }
  128. },
  129. SeePhotos(i, id) {
  130. this.activeNum = i
  131. getPhotos(id).then((e) => {
  132. this.imageList = e.records
  133. this.dataResort()
  134. })
  135. // this.clickStyle = !this.clickStyle
  136. },
  137. onBanner() {
  138. getBanner('Wonderful').then((e) => {
  139. this.photoBannerImages = (e.records || []).map(x => x.thumb)
  140. // console.log(e)
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="less" scoped>
  147. .Photo-box {
  148. width: 100vw;
  149. height: 100%;
  150. background-color: #fff;
  151. padding-top: 10px;
  152. .Zhedie-box {
  153. padding: 0 4vw;
  154. overflow: hidden;
  155. display: flex;
  156. align-items: center;
  157. flex-wrap: wrap;
  158. height: 7vw;
  159. transition: height 0.2s ease;
  160. &.expand {
  161. height: 50vh;
  162. }
  163. > div {
  164. padding: 1.5vw 3vw;
  165. color: rgb(128, 128, 128);
  166. margin-right: 1.5vw;
  167. margin-bottom: 1vw;
  168. text-align: center;
  169. font-size: 10px;
  170. }
  171. .clickStyle {
  172. color: #12a89f;
  173. font-weight: 700;
  174. background-color: #f3f3f3;
  175. border-radius: 30px;
  176. }
  177. }
  178. .Donghua {
  179. animation: Donghua 0.2s 1 forwards;
  180. overflow: scroll;
  181. }
  182. .PhotoList-box {
  183. width: 100%;
  184. height: auto;
  185. background-color: #fff;
  186. .PhotoList-box-images {
  187. width: 97%;
  188. margin: 0 auto;
  189. padding-bottom: 10vh;
  190. .PhotoList-box-text {
  191. display: flex;
  192. align-items: center;
  193. margin: 1.2em 0 0.8em 0;
  194. > div {
  195. width: 6px;
  196. height: 6px;
  197. border-radius: 50%;
  198. background-color: #13c0b4;
  199. margin: 0 13px 0 9px;
  200. }
  201. > span {
  202. font-size: 12px;
  203. letter-spacing: 1px;
  204. color: rgb(128, 128, 128);
  205. }
  206. }
  207. }
  208. }
  209. }
  210. </style>