lion 3 years ago
parent 05470e94b2
commit 7b3b0c9ade

@ -1,7 +1,7 @@
export const appConfig = {
appId: 'wx9b4762770771d98a', //孕育邦
//appId:"wx3dc65ce9b588727a",//孕育咨询
//baseUrl: 'http://yunyubang.localhost.com',
// baseUrl: 'http://yunyubang.localhost.com',
baseUrl:'https://yunyubang.ali251.langye.net',// 'https://yunyubang2021.langye.net', //孕育邦
// baseUrl: 'https://yybtest.ali251.langye.net',

@ -7,7 +7,6 @@
"select"
],
"dependencies": {
"uview": "^0.1.0",
"uview-ui": "^1.8.4"
}
}

@ -119,8 +119,9 @@
<text class="iconfont icon-Icon_customerservice"></text>
<text>客服</text>
</button>
</view>
<view class="buyBtn" @click="toBuy"></view>
</view>
<view class="buyBtn" v-if="info.state=='active'" @click="toBuy">{{buyName}}</view>
<view class="buyBtn buyNoBtn" v-else>{{buyName}}</view>
</view>
<u-popup v-model="showPop" mode="bottom" closeable="true">
@ -246,7 +247,8 @@
showPass: false,
info: {},
viewCounts:'',
dataList: [],
dataList: [],
buyName:'',
form: {
product_type: "product",
product_id: "",
@ -894,15 +896,17 @@
})
},
loadInfo: function() {
this.loadView();
this.loadView();
let that = this
weixin.request({
api: '/api/member/get-product/' + this.id,
method: 'GET',
utilSuccess: r => {
//r.data.poster = this.baseUrl + r.data.poster;
this.info = r.data;
this.info.poster = (weixin.isNull(this.info.poster) ? "../../static/750x500.jpg" :
this.info.poster_url)
that.info = r.data;
that.info.poster = (weixin.isNull(that.info.poster) ? "../../static/750x500.jpg" :
that.info.poster_url)
that.buyName = that.info.state=='active'?'立即购买':'已下架'
},
utilFail: r => {
console.log(r);
@ -1094,6 +1098,9 @@
text-align: center;
line-height: 72rpx;
color: #fff;
}
.buyNoBtn{
background: linear-gradient(90deg, #ddd 0%, #ddd 100%);
}
}

@ -17,13 +17,17 @@
<!-- 占位盒子 它的高度=状态栏高度+导航栏高度-->
<view class="placeholder" :style="{ height: navBarHeight + statusBarHeight + 'px', background: 'red' }">
</view>
<view class="termBox">
<!-- <view class="termOuter">
<view class="termCol cur">综合排序<text class="iconfont icon-arrowbottom"></text></view>
<view class="termCol">距离最近<text class="iconfont icon-arrowbottom"></text></view>
<view class="termCol">优质商户<text class="iconfont icon-arrowbottom"></text></view>
<view class="termCol">筛选<text class="iconfont icon-filter"></text></view>
</view> -->
<view class="termBox">
<view class="tabsnav" :style="{top:navBarHeight + statusBarHeight + 'px'}">
<u-tabs lineWidth="100" active-color="#FF578A" lineHeight="2" :scrollable="false" :list="tablist" lineColor="#FF578A"
:is-scroll="false" :current="current" @change="activeChange"></u-tabs>
</view>
<!-- <view class="termOuter">
<view class="termCol cur">综合排序<text class="iconfont icon-arrowbottom"></text></view>
<view class="termCol">距离最近<text class="iconfont icon-arrowbottom"></text></view>
<view class="termCol">优质商户<text class="iconfont icon-arrowbottom"></text></view>
<view class="termCol">筛选<text class="iconfont icon-filter"></text></view>
</view> -->
</view>
<view class="shopContent">
<!--为您推荐-->
@ -83,7 +87,15 @@
dataList: [],
currentPage: 1,
product_type_id: 0,
isLoading: false
isLoading: false,
current:0,
tablist:[{
name: '当前产品',
idx: 0
}, {
name: '往期回顾',
idx: 1
}]
}
},
@ -165,6 +177,13 @@
uni.navigateTo({
url: "../shopDetail/shopDetail?id=" + id
})
},
activeChange(e) {
let that = this
that.current = e;
that.dataList = []
this.loadPage(1);
},
loadPage: function(page) {
uni.hideKeyboard()
@ -180,7 +199,8 @@
keyword: that.keyword,
product_type_id: that.product_type_id,
sort_name:'sortnumber',
sort_type:"ASC"
sort_type:"ASC",
previous:that.tablist[that.current].idx
},
utilSuccess: function(r) {
var res = r.data.data;

@ -368,8 +368,9 @@
<uni-popup ref="shareCode" :mask-click="true" type="bottom" class="shareBox">
<view class="codeOuter">
<view class="shareCon" @click="shareClose">
<canvas style="width:90%;margin-left:5%;position: absolute;"
:style="{ height:(shareHeight*scare) + 'px', marginTop:(cropperH-(shareHeight*scare))/2+'rpx'}"
<canvas
style="width:90%;margin-left:5%;position: absolute;"
:style="{ height:isType3?(shareHeight*scare)*.89 +10 + 'px':(shareHeight*scare)+ 'px', marginTop:(cropperH-(shareHeight*scare))/2+'rpx'}"
canvas-id="firstCanvas" id="firstCanvas"></canvas>
<!-- <image class="shareBg" mode="widthFix" src="../../static/bg_haibao@2x.png"></image> -->
<!-- <image class="code" src="../../static/300_qr.png"></image> -->
@ -480,7 +481,7 @@
illustration:'',
showUser: false,
showPhone: false,
isType3:false
}
},
onShareAppMessage() {
@ -788,55 +789,123 @@
if (r.data.status === 1) {
uni.getImageInfo({
src: this.baseUrl + r.data.data, //
success: res => {
var ctx = uni.createCanvasContext('firstCanvas')
var w = SCREEN_WIDTH * 0.9;
var h = this. shareHeight* this.scare;
ctx.drawImage('../../static/bg_haibao1.png', 0, 40,
w, h*.9);
console.log("this.poster",this.poster)
ctx.drawImage(this.poster, 11, 51,
w-22, (h+5) * 0.3);
ctx.font = "16rpx bold";
//
ctx.fillStyle = "#000";
// xy
let active_title = this.info.template == '新' ? '课程' : '活动'
// ctx.fillText(active_title, w*0.1, (h + 50) * 0.6 + 20);
ctx.font = "14rpx bold";
//
ctx.fillStyle = "#333";
success: res => {
if(this.info.active_type_id==3){
this.isType3 = false
var ctx = uni.createCanvasContext('firstCanvas')
var w = SCREEN_WIDTH * 0.9;
var h = this.shareHeight * this.scare;
console.log(1)
ctx.drawImage('../../static/bg_haibao@2x.jpg', 0, 0,
w, h
);
ctx.drawImage('../../static/bg_haibao2.png', 20, 30 + 40,
w -
40, h - 100);
ctx.drawImage(this.poster, 20, 30 + 40,
w -
40, (h - 60 - 60) * 0.5);
ctx.font = "22rpx bold";
//
ctx.fillStyle = "#fff";
// xy
ctx.fillText(this.info.active_name, 20, 50);
ctx.font = "16rpx bold";
//
ctx.fillStyle = "#000";
// xy
ctx.fillText("活动", 40, (h + 50) * 0.5 + 20);
ctx.font = "14rpx bold";
//
ctx.fillStyle = "#3377b7";
// xy
let packagesFirst = this.info
let address1 = this.info.address.length>16?this.info.address.substring(0,16):this.info.address
let address2 = this.info.address.length>16?this.info.address.substring(16,this.info.address.length-1):''
let active_name1 = this.info.active_name.length>17?this.info.active_name.substring(0,17):this.info.active_name
let active_name2 = this.info.active_name.length>17?this.info.active_name.substring(17,this.info.active_name.length-1):''
ctx.fillText("" + active_name1, 40, (h + 50) * 0.5 + 50);
ctx.fillText("" + active_name2, 40, (h + 50) * 0.5 + 70);
ctx.fillText("活动时间:" + this.info.apply_start, 40, (h + 50) * 0.5 + 120);
ctx.fillText("活动地点:" + address1, 40, (h + 50) * 0.5 + 140);
ctx.fillText("" + address2, 40, (h + 50) * 0.5 + 160);
let user_info = uni.getStorageSync("user_info_yunyuhui");
let userProfile = uni.getStorageSync('user_profile');
var img = this.imgAvatar;
uni.getImageInfo({
src: userProfile.avatarUrl, //
success: rlogo => {
img = rlogo.path;
}
});
// that.circleImg(ctx,
// img,
// 40, h - 50 - w * 0.15,
// w * 0.15 / 2);
ctx.font = "12rpx normal";
//
ctx.fillStyle = "#000";
// xy
// if (!weixin.isNull(user_info.name))
// ctx.fillText(user_info.name,
// 40, h - 40);
// else
// ctx.fillText("",
// 40, h - 40);
this.circleImg(ctx, res.path, w - 40 - w * 0.2, h - 40 -
w *
0.2, w * 0.2 / 2);
}else{
this.isType3 = true
var ctx = uni.createCanvasContext('firstCanvas')
var w = SCREEN_WIDTH * 0.9;
var h = this. shareHeight* this.scare;
ctx.drawImage('../../static/bg_haibao1.png', 0, 0,
w, h*.89+10);
console.log("this.poster",this.poster)
ctx.drawImage(this.poster, 11, 11,
w-22, (h+5) * 0.3);
ctx.font = "16rpx bold";
//
ctx.fillStyle = "#000";
// xy
let active_title = this.info.template == '新' ? '课程' : '活动'
ctx.font = "14rpx bold";
//
ctx.fillStyle = "#333";
// xy
let packagesFirst = this.info
let lecturer = this.info.lecturer?this.info.lecturer:''
// let lecturer = ''
ctx.fillText(this.info.start_date + ' ' +
this.info.start_time, w*0.1+15, (h - 50) * 0.5+10);
let address = this.info.address.length > 17? this.info
.address.substring(0, 17) : this.info.address
let address1 = this.info.address.length > 17 ? this.info
.address.substring(17,this.info.address.length) : ''
ctx.fillText(address, w*0.1+15, (h - 50) * 0.6 + 20);
ctx.fillText(address1, w*0.1+15, (h - 50) * 0.6 + 40);
ctx.fillText(lecturer, w*0.1+15, (h - 50) * 0.6 + 100);
this.circleImg(ctx, res.path, w - 20 - w * 0.2, h - 10 -w *0.4, w * 0.2 / 2);
}
// xy
let packagesFirst = this.info
let active_time = this.info.template == '新' ? '时间:' :
'时间:'
let active_add = this.info.template == '新' ? '地点:' :
'地点:'
let active_name = this.info.active_name.length > 17 ? this
.info.active_name.substring(0, 17) : this.info
.active_name
let active_name1 = this.info.active_name.length > 17 ? this
.info.active_name.substring(17, this.info.active_name
.length) : ''
let lecturer = this.info.lecturer?this.info.lecturer:''
ctx.fillText(this.info.start_date + ' ' +
this.info.start_time, w*0.1+15, (h - 50) * 0.6);
let address = this.info.address.length > 17? this.info
.address.substring(0, 17) : this.info.address
let address1 = this.info.address.length > 17 ? this.info
.address.substring(17,this.info.address.length) : ''
ctx.fillText(address, w*0.1+15, (h - 50) * 0.6 + 60);
ctx.fillText(address1, w*0.1+15, (h - 50) * 0.6 + 80);
ctx.fillText(lecturer, w*0.1+15, (h - 50) * 0.6 + 140);
this.circleImg(ctx, res.path, w - 20 - w * 0.2, h - 10 -w *0.3, w * 0.2 / 2);
ctx.draw(),
// r:
setTimeout(() => {
@ -1139,6 +1208,13 @@
min-height: 150px !important;
margin: 20px auto;
height:auto!important
}
.yuezi{
width:90%;margin-left:5%;position: absolute;
}
.other{
width:90%;margin-left:5%;position: absolute;
height:540px!important
}
</style>
<style lang="scss" scoped>
@ -1484,7 +1560,8 @@
display: inline-block;
font-size: 36rpx;
font-weight: 500;
color: #333333;
color: #333333;
padding-right:60rpx
}
.dataGroup {

@ -16,15 +16,68 @@
</swiper-item>
</swiper>
</view>
</view>
<view class="menuBox">
</view>
<view class="album_swiper menu_swiper">
<swiper :style="{'height':indexNav.length>8?'400rpx':'360rpx'}" :autoplay="false" :interval="interval" :duration="duration" :indicator-dots="indexNav.length>8?true:false"
indicator-active-color="#FF578A" indicator-color="rgba(255,255,255,1)">
<swiper-item>
<view class="menuBox" style='justify-content: normal'>
<block v-for="(item,index) in indexNav" :key="item.id">
<block v-if="index<8">
<view class="menuCol" @click="toAction(item)" data-id="-1">
<image :src="item.icon"></image>
<view>{{item.name}}</view>
</view>
</block>
</block>
</view>
</swiper-item>
<swiper-item v-if="indexNav.length>8 && indexNav.length<17">
<view class="menuBox" style='justify-content: normal'>
<block v-for="(item,index) in indexNav" :key="item.id">
<block v-if="index>7">
<view class="menuCol" @click="toAction(item)" data-id="-1">
<image :src="item.icon"></image>
<view>{{item.name}}</view>
</view>
</block>
</block>
</view>
</swiper-item>
</swiper>
</view>
<!-- <uv-scroll-list>
<view class="menuBox">
<block v-for="item in indexNav" :key="item.id">
<view class="menuCol" @click="toAction(item)" data-id="-1">
<image :src="item.icon"></image>
<view>{{item.name}}</view>
</view>
</block>
</view>
<view class="menuBox">
<block v-for="item in indexNav" :key="item.id">
<view class="menuCol" @click="toAction(item)" data-id="-1">
<image :src="item.icon"></image>
<view>{{item.name}}</view>
</view>
</block>
</view>
<view v-for="(item, index) in indexNav" :key="index">
<image :src="item.icon" style="width:94rpx;height: 94rpx;"></image>
</view>
</uv-scroll-list> -->
<!-- <view class="menuBox">
<block v-for="item in indexNav" :key="item.id">
<view class="menuCol" @click="toAction(item)" data-id="-1">
<image :src="item.icon"></image>
<view>{{item.name}}</view>
</view>
</block>
</view>
</view> -->
<!--为您精选活动-->
<view class="introBox">
<view class="normal_tit">为您精选</view>
@ -98,7 +151,15 @@
dataList: [],
dataActiveList: [],
indexNav: [],
isLoading: false
isLoading: false,
modeIndex: -1,
styleIndex: -1,
current: 0,
mode: 'default',
dotsStyles: {},
swiperDotIndex: 0,
}
},
onLoad() {
@ -124,7 +185,13 @@
if (true)
this.loadPage((this.currentPage + 1), '', 6, 1)
},
methods: {
methods: {
change(e) {
this.current = e.detail.current
},
clickItem(e) {
this.swiperDotIndex = e
},
toSearch(e) {
console.log(e)
uni.navigateTo({
@ -137,7 +204,7 @@
api: '/api/member/applet-menu-first/index',
data: {
page: 1,
page_size: 8,
page_size: 16,
sort_name: "sort_number",
sort_type: "asc"
},
@ -274,12 +341,21 @@
}
}
</script>
<style>
<style scoped>
page {
background-color: #F6F6F6;
}
}
.menu_swiper{
padding:20rpx 0;
padding-bottom: 0;
}
/* .menu_swiper swiper{
min-height:400rpx;
} */
</style>
<style lang="scss" scoped>
<style lang="scss" scoped>
.activeTop {
width: 100%;
background: linear-gradient(180deg, #FF578A 0%, rgba(255, 87, 138, 0) 100%);
@ -339,7 +415,6 @@
}
}
}
.menuBox {
display: flex;
flex-wrap: wrap;

@ -0,0 +1,8 @@
## 1.0.32023-08-19
1. 修复报错导致不能移动指示器的BUG
## 1.0.22023-08-08
1. 修复vue2编译报错的BUG
## 1.0.12023-07-21
1. 优化
## 1.0.02023-07-21
1. 新增uv-scroll-liast 横向滚动表组件

@ -0,0 +1,29 @@
// 引入bindingx此库类似于微信小程序wxs目的是让js运行在视图层减少视图层和逻辑层的通信折损
const BindingX = uni.requireNativePlugin('bindingx')
export default {
methods: {
// 此处不写注释,请自行体会
nvueScrollHandler(e) {
if (this.indicator) {
const anchor = this.$refs['uv-scroll-list__scroll-view'].ref
const element = this.$refs['uv-scroll-list__indicator__line__bar'].ref
const scrollLeft = e.contentOffset.x
const contentSize = e.contentSize.width
const { scrollWidth } = this
const barAllMoveWidth = this.indicatorWidth - this.indicatorBarWidth
// 在安卓和iOS上需要除的倍数不一样iOS需要除以2
const actionNum = this.$uv.os() === 'ios' ? 2 : 1
const expression = `(x / ${actionNum}) / ${contentSize - scrollWidth} * ${barAllMoveWidth}`
BindingX.bind({
anchor,
eventType: 'scroll',
props: [{
element,
property: 'transform.translateX',
expression
}]
})
}
}
}
}

@ -0,0 +1,35 @@
export default {
props: {
// 指示器的整体宽度
indicatorWidth: {
type: [String, Number],
default: 50
},
// 滑块的宽度
indicatorBarWidth: {
type: [String, Number],
default: 20
},
// 是否显示面板指示器
indicator: {
type: Boolean,
default: true
},
// 指示器非激活颜色
indicatorColor: {
type: String,
default: '#f2f2f2'
},
// 指示器的激活颜色
indicatorActiveColor: {
type: String,
default: '#3c9cff'
},
// 指示器样式可通过bottomleftright进行定位
indicatorStyle: {
type: [String, Object],
default: ''
},
...uni.$uv?.props?.scrollList
}
}

@ -0,0 +1,50 @@
function scroll(event, ownerInstance) {
// detail中含有scroll-view的信息比如scroll-view的实际宽度当前时间点scroll-view的移动距离等
var detail = event.detail
var scrollWidth = detail.scrollWidth
var scrollLeft = detail.scrollLeft
// 获取当前组件的dataset说白了就是祸国殃民的腾xun搞出来的垃ji
var dataset = event.currentTarget.dataset
// 此为scroll-view外部包裹元素的宽度
// 某些HX版本(3.1.18)发现view元素中大写的data-scrollWidth在wxs中变成了全部小写所以这里需要特别处理
var scrollComponentWidth = dataset.scrollWidth || dataset.scrollwidth || 0
// 指示器和滑块的宽度
var indicatorWidth = dataset.indicatorWidth || dataset.indicatorwidth || 0
var barWidth = dataset.barWidth || dataset.barwidth || 0
// 此处的计算理由为scroll-view的滚动距离与目标滚动距离(scroll-view的实际宽度减去包裹元素的宽度)之比,等于滑块当前移动距离与总需
// 滑动距离(指示器的总宽度减去滑块宽度)的比值
var x = scrollLeft / (scrollWidth - scrollComponentWidth) * (indicatorWidth - barWidth)
setBarStyle(ownerInstance, x)
}
// 由于webview的无能无法保证scroll-view在滑动过程中一直触发scroll事件会导致
// 无法监听到某些滚动值,当在首尾临界值无法监听到时,这是致命的,因为错失这些值会导致滑块无法回到起点和终点
// 所以这里需要对临界值做监听并处理
function scrolltolower(event, ownerInstance) {
ownerInstance.callMethod('scrollEvent', 'right')
// 获取当前组件的dataset
var dataset = event.currentTarget.dataset
// 指示器和滑块的宽度
var indicatorWidth = dataset.indicatorWidth || dataset.indicatorwidth || 0
var barWidth = dataset.barWidth || dataset.barwidth || 0
// scroll-view滚动到右边终点时将滑块也设置为到右边的终点它所需移动的距离为指示器宽度 - 滑块宽度
setBarStyle(ownerInstance, indicatorWidth - barWidth)
}
function scrolltoupper(event, ownerInstance) {
ownerInstance.callMethod('scrollEvent', 'left')
// 滚动到左边时将滑块设置为0的偏移距离回到起点
setBarStyle(ownerInstance, 0)
}
function setBarStyle(ownerInstance, x) {
ownerInstance.selectComponent('.uv-scroll-list__indicator__line__bar') && ownerInstance.selectComponent('.uv-scroll-list__indicator__line__bar').setStyle({
transform: 'translateX(' + x + 'px)'
})
}
module.exports = {
scroll: scroll,
scrolltolower: scrolltolower,
scrolltoupper: scrolltoupper
}

@ -0,0 +1,217 @@
<template>
<view
class="uv-scroll-list"
ref="uv-scroll-list"
>
<!-- #ifdef APP-NVUE -->
<!-- nvue使用bindingX实现以得到更好的性能 -->
<scroller
class="uv-scroll-list__scroll-view"
ref="uv-scroll-list__scroll-view"
scroll-direction="horizontal"
:show-scrollbar="false"
:offset-accuracy="1"
@scroll="nvueScrollHandler"
>
<view class="uv-scroll-list__scroll-view__content">
<slot />
</view>
</scroller>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<!-- #ifdef MP-WEIXIN || APP-VUE || H5 || MP-QQ -->
<!-- 以上平台支持wxs -->
<scroll-view
class="uv-scroll-list__scroll-view"
scroll-x
@scroll="wxs.scroll"
@scrolltoupper="wxs.scrolltoupper"
@scrolltolower="wxs.scrolltolower"
:data-scrollWidth="scrollWidth"
:data-barWidth="$uv.getPx(indicatorBarWidth)"
:data-indicatorWidth="$uv.getPx(indicatorWidth)"
:show-scrollbar="false"
:upper-threshold="0"
:lower-threshold="0"
>
<!-- #endif -->
<!-- #ifndef APP-NVUE || MP-WEIXIN || H5 || APP-VUE || MP-QQ -->
<!-- 非以上平台只能使用普通js实现 -->
<scroll-view
class="uv-scroll-list__scroll-view"
scroll-x
@scroll="scrollHandler"
@scrolltoupper="scrolltoupperHandler"
@scrolltolower="scrolltolowerHandler"
:show-scrollbar="false"
:upper-threshold="0"
:lower-threshold="0"
>
<!-- #endif -->
<view class="uv-scroll-list__scroll-view__content">
<slot />
</view>
</scroll-view>
<!-- #endif -->
<view
class="uv-scroll-list__indicator"
v-if="indicator"
:style="[$uv.addStyle(indicatorStyle)]"
>
<view
class="uv-scroll-list__indicator__line"
:style="[lineStyle]"
>
<view
class="uv-scroll-list__indicator__line__bar"
:style="[barStyle]"
ref="uv-scroll-list__indicator__line__bar"
></view>
</view>
</view>
<!-- 避免报错 -->
<!-- #ifdef H5 -->
<view v-else class="uv-scroll-list__indicator__line__bar"></view>
<!-- #endif -->
</view>
</template>
<script src="./scrollWxs.wxs" module="wxs" lang="wxs"></script>
<script>
/**
* scrollList 横向滚动列表
* @description 该组件一般用于同时展示多个商品分类的场景也可以完成左右滑动的列表
* @tutorial https://www.uviewui.com/components/scrollList.html
* @property {String | Number} indicatorWidth 指示器的整体宽度 (默认 50 )
* @property {String | Number} indicatorBarWidth 滑块的宽度 (默认 20 )
* @property {Boolean} indicator 是否显示面板指示器 (默认 true )
* @property {String} indicatorColor 指示器非激活颜色 (默认 '#f2f2f2' )
* @property {String} indicatorActiveColor 指示器的激活颜色 (默认 '#3c9cff' )
* @property {String | Object} indicatorStyle 指示器样式可通过bottomleftright进行定位
* @event {Function} left 滑动到左边时触发
* @event {Function} right 滑动到右边时触发
* @example
*/
// #ifdef APP-NVUE
const dom = uni.requireNativePlugin('dom')
import nvueMixin from "./nvue.js"
// #endif
import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
import props from './props.js';
export default {
name: 'uv-scroll-list',
// #ifndef APP-NVUE
mixins: [mpMixin, mixin, props],
// #endif
// #ifdef APP-NVUE
mixins: [mpMixin, mixin, nvueMixin, props],
// #endif
data() {
return {
scrollInfo: {
scrollLeft: 0,
scrollWidth: 0
},
scrollWidth: 0
}
},
computed: {
// 线
barStyle() {
const style = {}
// #ifndef APP-NVUE || MP-WEIXIN || H5 || APP-VUE || MP-QQ
// jsnvuewxs使
// scroll-view(scroll-view)
// ()
const scrollLeft = this.scrollInfo.scrollLeft,
scrollWidth = this.scrollInfo.scrollWidth,
barAllMoveWidth = this.indicatorWidth - this.indicatorBarWidth
const x = scrollLeft / (scrollWidth - this.scrollWidth) * barAllMoveWidth
style.transform = `translateX(${ x }px)`
// #endif
//
style.width = this.$uv.addUnit(this.indicatorBarWidth)
style.backgroundColor = this.indicatorActiveColor
return style
},
lineStyle() {
const style = {}
//
style.width = this.$uv.addUnit(this.indicatorWidth)
style.backgroundColor = this.indicatorColor
return style
}
},
mounted() {
this.init()
},
methods: {
init() {
this.getComponentWidth()
},
// #ifndef APP-NVUE || MP-WEIXIN || H5 || APP-VUE || MP-QQ
// scroll-view
scrollHandler(e) {
this.scrollInfo = e.detail
},
scrolltoupperHandler() {
this.scrollEvent('left')
this.scrollInfo.scrollLeft = 0
},
scrolltolowerHandler() {
this.scrollEvent('right')
// jsthis.scrollInfo
// computed
this.scrollInfo.scrollLeft = this.$uv.getPx(this.indicatorWidth) - this.$uv.getPx(this.indicatorBarWidth)
},
// #endif
scrollEvent(status) {
this.$emit(status)
},
//
async getComponentWidth() {
// dom
await this.$uv.sleep(30)
// #ifndef APP-NVUE
this.$uvGetRect('.uv-scroll-list').then(size => {
this.scrollWidth = size.width
})
// #endif
// #ifdef APP-NVUE
const ref = this.$refs['uv-scroll-list']
ref && dom.getComponentRect(ref, (res) => {
this.scrollWidth = res.size.width
})
// #endif
},
}
}
</script>
<style lang="scss" scoped>
@import '@/uni_modules/uv-ui-tools/libs/css/components.scss';
.uv-scroll-list {
padding-bottom: 10px;
&__scroll-view {
@include flex;
&__content {
@include flex;
}
}
&__indicator {
@include flex;
justify-content: center;
margin-top: 15px;
&__line {
width: 60px;
height: 4px;
border-radius: 100px;
overflow: hidden;
&__bar {
width: 20px;
height: 4px;
border-radius: 100px;
}
}
}
}
</style>

@ -0,0 +1,87 @@
{
"id": "uv-scroll-list",
"displayName": "uv-scroll-list 横向滚动列表 全面兼容vue3+2、app、h5、小程序等多端",
"version": "1.0.3",
"description": "该组件一般用于同时展示多个商品、分类的场景,也可以完成左右滑动的列表,往往数量不确定,数量较多支持左右滚动。灵活配置,开箱即用。",
"keywords": [
"uv-scroll-list",
"uvui",
"uv-ui",
"横向滚动列表",
"scroll-view"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [
"uv-ui-tools"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}

@ -0,0 +1,19 @@
## ScrollList 横向滚动列表
> **组件名uv-scroll-list**
该组件一般用于同时展示多个商品、分类的场景,也可以完成左右滑动的列表,往往数量不确定,数量较多支持左右滚动。灵活配置,开箱即用。
# <a href="https://www.uvui.cn/components/scrollList.html" target="_blank">查看文档</a>
## [下载完整示例项目](https://ext.dcloud.net.cn/plugin?name=uv-ui) <small>(请不要 下载插件ZIP</small>
### [更多插件请关注uv-ui组件库](https://ext.dcloud.net.cn/plugin?name=uv-ui)
<a href="https://ext.dcloud.net.cn/plugin?name=uv-ui" target="_blank">
![image](https://mp-a667b617-c5f1-4a2d-9a54-683a67cff588.cdn.bspapp.com/uv-ui/banner.png)
</a>
#### 如使用过程中有任何问题反馈或者您对uv-ui有一些好的建议欢迎加入uv-ui官方交流群<a href="https://www.uvui.cn/components/addQQGroup.html" target="_blank">官方QQ群</a>
Loading…
Cancel
Save