123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- <template>
- <view class="swiper-content">
- <view class="hander-top p-lr-32 w-s flex-j-sb--a-ct">
- <view class="icon-back-wrap"
- @click="onBack">
- <image class="icon-back"
- src="/static/xb-swiper-preview/icon-back.png"
- mode="widthFix" />
- </view>
- <view class="count">{{currentImg + 1}} / {{ imgs.length }}</view>
- </view>
-
- <swiper class="swiper-img"
- :current="currentImg"
- :duration="300"
- @change="changeSwiper">
- <swiper-item class="swiper-item"
- v-for="(item, index) in imgs"
- :key="index">
- <view class="img-page">
- <movable-area scale-area>
- <movable-view direction="all"
- scale="true"
- scale-min="1"
- scale-max="4">
- <image class="max-img"
- :src="item"
- :lazy-load="true"
- mode="aspectFill" />
- </movable-view>
- </movable-area>
- </view>
- </swiper-item>
- </swiper>
- <view class="item-bottom">
- <scroll-view class="scroll-view_H "
- :scroll-x="true"
- :scroll-into-view="scrollTopIndex"
- :scroll-with-animation="true"
- scroll-left="20">
- <view class="img-page-box scroll-view-item_H"
- :class="currentImg == index ? 'img-page-checked' : ''"
- v-for="(item, index) in imgs"
- :key="index"
- :id="`scrollToIndex${index}`"
- @click.stop="toImg(index)">
- <image class="img"
- :src="item"
- mode="aspectFill" />
- </view>
- </scroll-view>
- </view>
- <!-- <view class="handle-wrap flex-j-sb--a-ct p-lr-32">
- <view class="w-64 h-64"
- @click="isScale = !isScale">
- <image v-show="isScale"
- class="w-64 h-64"
- src="/static/xb-swiper-preview/icon-scale-yes.png"
- mode="widthFix" />
- <image v-show="!isScale"
- class="w-64 h-64"
- src="/static/xb-swiper-preview/icon-scale.png"
- mode="widthFix" />
- </view>
- <view class="w-64 h-64"
- @click="isCollect = !isCollect">
- <image v-show="isCollect"
- class="w-64 h-64"
- src="/static/xb-swiper-preview/icon-collect-yes.png"
- mode="widthFix" />
- <image v-show="!isCollect"
- class="w-64 h-64"
- src="/static/xb-swiper-preview/icon-collect.png"
- mode="widthFix" />
- </view>
- <view class="w-64 h-64"
- @click="isLike = !isLike">
- <image v-show="isLike"
- class="w-64 h-64"
- src="/static/xb-swiper-preview/icon-like-yes.png"
- mode="widthFix" />
- <image v-show="!isLike"
- class="w-64 h-64"
- src="/static/xb-swiper-preview/icon-like.png"
- mode="widthFix" />
- </view>
- <image class="w-64 h-64"
- src="/static/xb-swiper-preview/icon-set-wallpaper-yes.png"
- mode="widthFix" />
- <image class="w-64 h-64"
- src="/static/xb-swiper-preview/icon-share.png"
- mode="widthFix" />
- <image class="w-64 h-64"
- src="/static/xb-swiper-preview/icon-download.png"
- mode="widthFix" />
- </view> -->
- <view class="pop"
- v-if="isPop">
- <view class="item"
- @click.stop="share()">分享图片</view>
- <!-- #ifndef H5 -->
- <view class="item"
- @click.stop="saveImg(false)">保存图片</view>
- <view class="item"
- @click.stop="saveImg(true)">保存全部图片</view>
- <!-- #endif -->
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- imgs: [
- ],
- currentImg: 0,
- isPop: false,
- scrollTopIndex: "",
- isScale: false,
- isCollect: false,
- isLike: false,
- };
- },
- created() {
- this.getSmallPig()
- },
- onLoad(options) {
- // let { imgs, current } = options;
- // this.imgs = JSON.parse(imgs);
- // this.currentImg = current;
- },
- methods: {
- async getSmallPig() {
- const {data: result} = await uni.$http.get('/education/strategy/getSmallPig')
- this.imgs = result.data.list
- },
- changeSwiper(e) {
- this.currentImg = e.detail.current;
- // console.log("e", e);
- this.scrollTopIndex = `scrollToIndex${e.detail.current}`;
- },
- toImg(index) {
- this.currentImg = index;
- },
- onBack() {
- uni.navigateBack();
- },
- share() {
- uni.downloadFile({
- // 下面一行时拼接预览PDF的地址!!!
- url: this.imgs[this.currentImg],
- success: function (res) {
- var filePath = res.tempFilePath;
- if (!filePath) return;
- uni.openDocument({
- filePath: filePath,
- success: function (res) {
- console.log(res);
- console.log("打开文档成功");
- },
- });
- },
- });
- },
- saveImg(isAll = false) {
- const that = this;
- if (!isAll) {
- uni.downloadFile({
- url: this.imgs[this.currentImg],
- success: (res) => {
- if (res.statusCode === 200) {
- uni.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success: function () {
- uni.showToast({
- icon: "none",
- title: "保存成功",
- });
- that.isPop = false;
- },
- fail: function () {},
- });
- } else {
- }
- },
- });
- return;
- }
- this.imgs.forEach((item) => {
- uni.downloadFile({
- url: item,
- success: (res) => {
- if (res.statusCode === 200) {
- uni.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success: function () {
- uni.showToast({
- icon: "none",
- title: "保存全部成功",
- });
- that.isPop = false;
- },
- fail: function () {},
- });
- } else {
- }
- },
- });
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .swiper-content{
- width: 100%;
- height: 100vh;
- position: relative;
- }
- movable-view {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 100%;
- }
- movable-area {
- position: fixed;
- overflow: hidden;
- width: 100%;
- height: 100%;
- transform: scale();
- }
- movable-view image {
- width: 100%;
- }
- uni-image > img {
- z-index: -1 !important;
- }
- .hander-top {
- position: absolute;
- z-index: 1000;
- top: 48rpx;
- left: 0;
- display: flex;
- justify-content: space-between;
- width: 100%;
- padding: 0 32rpx;
- box-sizing: border-box;
- .icon-back-wrap {
- width: 64rpx;
- height: 64rpx;
- .icon-back{
- width: 64rpx;
- height: 64rpx;
- }
- }
- .count {
- box-sizing: border-box;
- padding: 8rpx 24rpx;
- color: #fff;
- border-radius: 24rpx;
- background: rgba(0, 0, 0, .4);
- font-size: 28rpx;
- }
- }
- .swiper-img {
- width: 100vw;
- height: 100vh;
-
- background-color: #000;
- .swiper-item {
- width: 100vw;
- height: 100vh;
- .img-page {
- display: flex;
- align-items: center;
- width: 100vw;
- height: 100vh;
- .max-img {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- .handle-wrap {
- position: absolute;
- z-index: 100;
- bottom: 40rpx;
- left: 0;
-
- width: 100%;
- display: flex;
- justify-content: space-between;
- padding: 32rpx;
- box-sizing: border-box;
- image{
- width: 64rpx;
- height: 64rpx;
- }
- width: 100%;
- }
- .item-bottom {
- position: fixed;
- z-index: 9999;
- bottom: 10rpx;
- left: 0rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- width: 100vw;
- // height: 200rpx;
- padding: 30rpx;
- transition: ease-in-out .3s;
- }
- .small-list-page {
- min-height: 60rpx;
- }
- .scroll-Y {
- height: 300rpx;
- }
- .scroll-view_H {
- width: 100%;
- box-sizing: border-box;
- padding-right: 32rpx;
- white-space: nowrap;
- }
- .scroll-view-item_H {
- display: inline-block;
- margin-right: 10rpx;
- transition: ease-in .1s;
- transform: scale(.8);
- border-radius: 11rpx;
- background: #c2c2c2;
- &:last-child {
- margin-right: 0;
- }
- .img {
- display: block;
- width: 160rpx;
- height: 272rpx;
- }
- }
- .img-page-checked {
- transform: translateY(-28rpx) scale(1);
- }
- .pop {
- position: fixed;
- z-index: 999999;
- top: 50%;
- left: 50%;
- overflow: hidden;
- width: 500rpx;
- transform: translate(-50%, -50%);
- border-radius: 20rpx;
- background-color: #fff;
- .item {
- height: 100rpx;
- padding: 0 50rpx;
- transition: all .2s;
- border-radius: 20rpx;
- line-height: 100rpx;
- &:active {
- background-color: #eee;
- }
- }
- }
- </style>
|