小红书小程序

小红书小程序

笔记详情轮播图指示点的随图片数量的变化动态变化

实图在这里插入图片描述
上代码(uni-app)

<template>
  <view class="dt-box">
    <view class="dt-con">
      <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y">
        <view id="demo1" class="dt-img">
          <swiper
            class="swiper"
            :indicator-dots="indicatorDots"
            :autoplay="autoplay"
            :interval="interval"
            :duration="duration"
            @change="imgChange"
          >
            <swiper-item v-for="(item, index) in dt_con" :key="index">
              <view class="img-box">
                <view class="img">
                  <img :src="item.url" alt="" width="100%" height="380" />
                </view>
                <view class="img-current">{{ current_img }}</view>
              </view>
            </swiper-item>
          </swiper>
          <!-- 图片长度<=5-->
          <view class="img-tips" v-if="dt_con.length <= 5&&dt_con.length>=2">
            <span
              class="tips"
              v-for="(item, index) in dt_con"
              :key="index"
              :class="[currentpage == index ? 'active' : '']"
            ></span>
          </view>
          <!-- 图片长度>5-->
          <view class="img-tips" v-if="dt_con.length > 5 && currentpage < 3">
            <span
              class="tips"
              v-for="(item, index) in 3"
              :key="index"
              :class="[currentpage == index ? 'active' : '']"
            ></span>
            <span class="tips"></span>
            <span class="tips tips-next-next"></span>
          </view>
          <view
            class="img-tips"
            v-if="
              dt_con.length > 5 &&
              currentpage >= 3 &&
              currentpage < dt_con.length - 3
            "
          >
            <span class="tips tips-next-next"></span>
            <span class="tips"></span>
            <span class="tips active"></span>
            <span class="tips"></span>
            <span class="tips tips-next-next"></span>
          </view>
          <view
            class="img-tips"
            v-if="dt_con.length > 5 && currentpage >= dt_con.length - 3"
          >
            <span class="tips tips-next-next"></span>
            <span class="tips"></span>
            <span
              class="tips"
              v-for="(item, index) in 3"
              :key="index"
              :class="[
                currentpage - (dt_con.length - 3) == index ? 'active' : '',
              ]"
            ></span>
          </view>
        </view>
        <view id="demo2" class="dt-user">B</view>
        <view id="demo3" class="dt-rec">C</view>
      </scroll-view>
    </view>
    <view class="dt-btn"> </view>
  </view>
</template>
<script>
export default {
  data() {
    return {
      currentpage: 0,
      scrollTop: 0,
      indicatorDots: false,
      autoplay: false,
      interval: 2000,
      duration: 500,
      dt_con: [],
      current_img: "",
      dt_v: {
        0: [
          { img_id: "0", title: "first", url: "../../static/imgs/1.jpg" },
          { img_id: "1", title: "sec", url: "../../static/imgs/2.jpg" },
          { img_id: "2", title: "th", url: "../../static/imgs/3.jpg" },
          { img_id: "3", title: "fou", url: "../../static/imgs/4.jpg" },
          { img_id: "4", title: "fif", url: "../../static/imgs/5.jpg" },
          { img_id: "5", title: "six", url: "../../static/imgs/6.jpg" },
          { img_id: "6", title: "first", url: "../../static/imgs/1.jpg" },
          { img_id: "7", title: "sec", url: "../../static/imgs/2.jpg" },
          // { img_id: "8", title: "th", url: "../../static/imgs/3.jpg" },
          // { img_id: "9", title: "fou", url: "../../static/imgs/4.jpg" },
          // { img_id: "10", title: "fif", url: "../../static/imgs/5.jpg" },
          // { img_id: "11", title: "six", url: "../../static/imgs/6.jpg" },
        ],
        1: [
          { img_id: "0", title: "first", url: "../../static/imgs/4.jpg" },
          { img_id: "1", title: "sec", url: "../../static/imgs/5.jpg" },
          { img_id: "2", title: "th", url: "../../static/imgs/6.jpg" },
          { img_id: "3", title: "fou", url: "../../static/imgs/7.jpg" },
          { img_id: "4", title: "fif", url: "../../static/imgs/8.jpg" },
          { img_id: "5", title: "six", url: "../../static/imgs/9.jpg" },
        ],
      },
    };
  },
  onLoad(options) {
    this.dt_con = this.dt_v[options.id];//从上级页面获取笔记id
    if (this.dt_con && this.dt_con.length) {
      this.current_img = "1/" + this.dt_con.length;
    } else {
      this.current_img = "1/1";
    }
  },
  mounted() {},
  methods: {
    imgChange(e) {
      this.currentpage = e.detail.current;
      this.current_img = this.currentpage + 1 + "/" + this.dt_con.length;
      console.log(this.currentpage);
    },
  },
};
</script>
<style scoped>
uni-page-body {
  height: 100%;
}
.dt-box {
  height: 100%;
}
.dt-con {
  height: 92%;
  width: 100%;
}
.scroll-Y {
  height: 100%;
}
.dt-img {
  height: 400px;
  position: relative;
}
uni-swiper {
  height: 100%;
}
.img-box {
  position: relative;
}
.img-current {
  position: absolute;
  bottom: 30px;
  right: 15px;
  z-index: 999;
  width: 40px;
  height: 20px;
  border-radius: 10px;
  background-color: rgba(0, 0, 0, 0.4);
  color: #fff;
  text-align: center;
  line-height: 20px;
  font-size: 12px;
}
.img-tips {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  -webkit-transform: translateX(-50%);
}
.tips {
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: #ccc;
  border-radius: 50%;
  margin: 0 2px;
}
.tips-next {
  transform: scale(0.8);
}
.tips-next-next {
  transform: scale(0.6);
}
.active {
  background-color: orange;
}
.dt-user {
  height: 20rem;
}
.dt-rec {
  height: 20rem;
}
.dt-btn {
  height: 8%;
  width: 100%;
  background-color: #ccc;
}
</style>
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
“小”——给你安利几个小程序的“坑”微信小程序写在前面  小程序发布至今已有一年多时间,很多人都已经在小程序道路上狂奔。最近我也开始了学习小程序,学了一段时间后,想看看这段时间的学习效果,于是边学习边开始了我的第一个小程序。相信很多人都用过小吧,我可是被它安利了很多好东西呢,所以想着就仿写一个小的微信小程序吧。下面我就给大家“安利”几个我在写的过程中的“坑”。  因为花的时间不多,功能有很多没有完善,页面写的不是很好看,请各位将就着看啦。╮(╯▽╰)╭   准备工作  1. 开发环境:WXML(HTML),WXSS(CSS),Javascript  2. 开发工具:vscode,微信开发者工具  3. 辅助工具:Markman:图标标注工具,可用于取色、测量。Easy-Mock:可以伪造假数据,在js中引用就好了。点这里可以查看我的项目数据。Markdown:在线编辑器GifCam:Gif录制工具 微信小程序开发文档Iconfont-阿里巴巴矢量图标库:各种需要的小图标都有哦遇到的几个问题1、首页导航栏左右滑动效果图:  这部分,是通过微信小程序的scroll-view组件来完成的。代码如下:<scroll-view class="navBar-box" scroll-x="true"  一些使用scroll-view的注意事项:请勿在 scroll-view 中使用 textarea、map、canvas、video 组件scroll-into-view 的优先级高于 scroll-top在滚动 scroll-view 时会阻止页面回弹,所以在 scroll-view 中滚动,是无法触发 onPullDownRefresh若要使用下拉刷新,请使用页面的滚动,而不是 scroll-view ,这样也能通过点击顶部状态栏回到页面顶部2、首页文章列表随着点击导航栏列表改变效果图:  这部分,是通过微信小程序的swiper组件来完成的。代码如下:                                                                                                    {{notes.title}}                              <!-- 作者信息 -->                                              {{notes.writer}}                                                {{notes.like}}                                    使用swiper组件,将所有文章列表包起来,每个swiper-item表示不同的列表模块。之前在导航栏各列表项绑定了不同
要使用Python来抓取小的内容,可以参考以下步骤和方法: 1. 了解小页面结构与请求方式。从中可以得知小的文章url是固定的格式,可以通过获取这个url来获取文章内容。 2. 下载小的app或者查看微信的小小程序。根据中的描述,可以通过这些方式来了解小的页面结构和请求方式。 3. 使用抓包工具如Fiddler来分析小的网络请求。从和中可以看到,使用Fiddler可以抓取到小程序的请求,可以进一步分析请求头和参数。 4. 注意小对访问频率的限制。根据中的描述,小对频繁的访问有敏感度,并会弹出验证。可以尝试使用代理或者降低访问速度来解决这个问题。 5. 获取请求头中的关键参数。根据中的描述,大部分参数是固定的,只有请求头中的keyword和X-Sign是变动的,需要手动获取。 综上所述,你可以使用Python编写程序来模拟请求小的接口,获取文章的内容。通过分析小的页面结构和请求方式,使用抓包工具获取请求头和参数,解决访问频率的限制,最终完成抓取小的操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [Python-抓取小文章的心路历程!小原来这么实用!](https://blog.csdn.net/pythonlaodi/article/details/108432233)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值