Commit 67e2fe53 authored by cc_inu's avatar cc_inu

vlog相册

parent 8e35f636
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
let openid=uni.getStorageSync("openid") let openid=uni.getStorageSync("openid")
if(!openid&&path.indexOf("pages/ourPayment/ourPayment")==-1){//扫码支付页面不需要在此登录 if(!openid&&path.indexOf("pages/ourPayment/ourPayment")==-1){//扫码支付页面不需要在此登录
setTimeout(()=>{//解决关联普通二维码扫码首次进入时一直显示登录中 setTimeout(()=>{//解决关联普通二维码扫码首次进入时一直显示登录中
// uni.navigateTo({ uni.navigateTo({
// url: "/pages/login/login" url: "/pages/login/login"
// }) })
},300) },300)
} }
//#ifdef MP-ALIPAY //#ifdef MP-ALIPAY
......
...@@ -5,13 +5,14 @@ ...@@ -5,13 +5,14 @@
:class="['item', cur == index ? 'cur' : '', curZ == index ? 'zIndex' : '', itemTransition && index !== cur ? 'itemTransition' : '']" :class="['item', cur == index ? 'cur' : '', curZ == index ? 'zIndex' : '', itemTransition && index !== cur ? 'itemTransition' : '']"
v-for="(item, index) in list" :key="index" :id="'item' + index" :data-key="item.key" :data-index="index" v-for="(item, index) in list" :key="index" :id="'item' + index" :data-key="item.key" :data-index="index"
:style="{ transform: `translate3d(${index === cur ? tranX : item.tranX}px, ${index === cur ? tranY : item.tranY}px, 0px)`, width: `${100 / columns}%` }" :style="{ transform: `translate3d(${index === cur ? tranX : item.tranX}px, ${index === cur ? tranY : item.tranY}px, 0px)`, width: `${100 / columns}%` }"
@tap="itemClick(index,item.data.images)" @longpress="longPress" @touchmove.stop="touchMove" @touchend.stop="touchEnd"> @tap="itemClick(index,item.data.images)" @longpress="longPress" @touchmove.stop="touchMove"
@touchend.stop="touchEnd">
<!-- start:请在该区域编写自己的渲染逻辑 --> <!-- start:请在该区域编写自己的渲染逻辑 -->
<view class="info"> <view class="info">
<view class="info__item"> <view class="info__item">
<image class="image" :src="item.data.images" mode="widthFix"></image> <image class="image" :src="item.data.images" mode="widthFix"></image>
</view> </view>
<view class="info__item_btn" @click.stop="replace(item.key)"> <view class="info__item_btn" @click.stop="replace(item)">
更换 更换
</view> </view>
</view> </view>
...@@ -20,8 +21,9 @@ ...@@ -20,8 +21,9 @@
</view> </view>
<u-popup v-model="show" mode="bottom" height="50%"> <u-popup v-model="show" mode="bottom" height="50%">
<view style="display: flex;flex-wrap: wrap;width: 100%;"> <view style="display: flex;flex-wrap: wrap;width: 100%;">
<view style="width: 25%;padding: 10rpx;" v-for="(item,index) in listData" :key="index"> <view style="width: 25%;padding: 10rpx;" v-for="(item,index) in alternateImages" :key="index">
<image :src="item.images" style="width: 100%;" mode="widthFix" @click="changeImglist(item.images)"></image> <image :src="item.images" style="width: 100%;" mode="widthFix" @click="changeImglist(item.images)">
</image>
</view> </view>
</view> </view>
</u-popup> </u-popup>
...@@ -31,21 +33,52 @@ ...@@ -31,21 +33,52 @@
<script> <script>
export default { export default {
props: { props: {
listData: {// 数据源 listData: { // 数据源
type: Array, type: Array,
default: () => { default: () => {
return [] return []
} }
}, },
columns: {// 列数 columns: { // 列数
type: Number, type: Number,
default: 0 default: 0
}, },
}, },
data() { data() {
return { return {
alterKey:"",//点击更改图片的key alternateImages: [{
show:false,//照片图库弹出层 images: '/static/images/swipe/1.png'
},
{
images: '/static/images/swipe/2.png'
},
{
images: '/static/images/swipe/3.png'
},
{
images: '/static/images/swipe/4.png'
},
{
images: '/static/images/swipe/5.png'
},
{
images: '/static/images/swipe/6.png'
},
{
images: '/static/images/swipe/7.png'
},
{
images: '/static/images/swipe/8.png'
},
{
images: '/static/images/swipe/9.png'
},
{
images: '/static/images/swipe/10.png'
}
], //备选图片
checkImg: "", //点击更改图片的key
show: false, //照片图库弹出层
cur: -1, // 当前激活的元素 cur: -1, // 当前激活的元素
curZ: -1, // 当前激活的元素, 用于控制激活元素z轴显示 curZ: -1, // 当前激活的元素, 用于控制激活元素z轴显示
tranX: 0, // 当前激活元素的 X轴 偏移量 tranX: 0, // 当前激活元素的 X轴 偏移量
...@@ -55,12 +88,12 @@ ...@@ -55,12 +88,12 @@
list: [], //数据 list: [], //数据
overOnePage: false, // 整个区域是否超过一个屏幕 overOnePage: false, // 整个区域是否超过一个屏幕
itemTransition: false, // item 变换是否需要过渡动画, 首次渲染不需要 itemTransition: false, // item 变换是否需要过渡动画, 首次渲染不需要
platform: "" ,//使用平台 platform: "", //使用平台
} }
}, },
watch: { watch: {
columns(newVal, oldVal) { columns(newVal, oldVal) {
this.columns=newVal this.columns = newVal
this.dataChange() this.dataChange()
}, },
}, },
...@@ -68,24 +101,20 @@ ...@@ -68,24 +101,20 @@
this.init() this.init()
}, },
methods: { methods: {
changeImglist(src){ changeImglist(src) {//选择更换图片
this.list[this.alterKey].data.images=src this.checkImg.data.images = src
this.alterKey="" this.show = false
this.show=false
let list=JSON.parse(JSON.stringify(this.list))
let listData = [] let listData = []
list.forEach(item => { this.list.forEach(item => {
listData[item.key] = item.data listData[item.key] = item.data
}) })
this.$emit('change', { //给父组件传递数据 this.$emit('change', { //给父组件传递数据
listData: listData listData: listData
}) })
}, },
replace(key){//更换图片 replace(item) { //更换图片
this.show=true this.checkImg = item
this.alterKey=key this.show = true
console.log(this.alterKey);
}, },
init() { init() {
// 空值判断, 避免获取不到节点信息报错问题 // 空值判断, 避免获取不到节点信息报错问题
...@@ -116,7 +145,7 @@ ...@@ -116,7 +145,7 @@
setTimeout(() => { //需要等页面渲染完成后执行函数,否则获取不到节点信息 setTimeout(() => { //需要等页面渲染完成后执行函数,否则获取不到节点信息
let queryItem = uni.createSelectorQuery().in(this); let queryItem = uni.createSelectorQuery().in(this);
queryItem.select('.item').boundingClientRect(res => {// 获取每一项的宽高等属性 queryItem.select('.item').boundingClientRect(res => { // 获取每一项的宽高等属性
let rows = Math.ceil(this.list.length / this.columns) let rows = Math.ceil(this.list.length / this.columns)
this.item = res this.item = res
this.getPosition(this.list, false) this.getPosition(this.list, false)
...@@ -138,7 +167,7 @@ ...@@ -138,7 +167,7 @@
.exec() .exec()
}, 200) }, 200)
}, },
getPosition(data, vibrate = true) {//根据排序后 list 数据进行位移计算 getPosition(data, vibrate = true) { //根据排序后 list 数据进行位移计算
let list = data.map((item, index) => { let list = data.map((item, index) => {
item.tranX = this.item.width * (item.key % this.columns) item.tranX = this.item.width * (item.key % this.columns)
item.tranY = Math.floor(item.key / this.columns) * this.item.height item.tranY = Math.floor(item.key / this.columns) * this.item.height
...@@ -157,7 +186,7 @@ ...@@ -157,7 +186,7 @@
listData: listData listData: listData
}) })
}, },
longPress(e) {//长按触发移动排序 longPress(e) { //长按触发移动排序
// 防止多指触发 drag 动作, 如果已经在 drag 中则返回, touchstart 事件中有效果 // 防止多指触发 drag 动作, 如果已经在 drag 中则返回, touchstart 事件中有效果
if (this.dragging) return if (this.dragging) return
let { let {
...@@ -165,22 +194,22 @@ ...@@ -165,22 +194,22 @@
} = e.currentTarget.dataset } = e.currentTarget.dataset
// 如果是固定 item 则 return // 如果是固定 item 则 return
// if (this.isFixed(index)) return // if (this.isFixed(index)) return
// 存储初始化触摸点信息 // 存储初始化触摸点信息
this.startTouch = e.changedTouches[0] this.startTouch = e.changedTouches[0]
// 如果未获取到触摸点信息 return // 如果未获取到触摸点信息 return
if (!this.startTouch) return if (!this.startTouch) return
// 表示 drag 动作开始 // 表示 drag 动作开始
this.dragging = true this.dragging = true
let {// 获取初始化点的 pageX 和 pageY let { // 获取初始化点的 pageX 和 pageY
pageX: startPageX, pageX: startPageX,
pageY: startPageY pageY: startPageY
} = this.startTouch } = this.startTouch
if (this.columns === 1) {// 单列时候X轴初始不做位移 if (this.columns === 1) { // 单列时候X轴初始不做位移
this.tranX = 0 this.tranX = 0
} else {// 多列的时候计算X轴初始位移, 使 item 水平中心移动到点击处 } else { // 多列的时候计算X轴初始位移, 使 item 水平中心移动到点击处
this.tranX = startPageX - this.item.width / 2 - this.itemWrap.left this.tranX = startPageX - this.item.width / 2 - this.itemWrap.left
} }
// 计算Y轴初始位移, 使 item 垂直中心移动到点击处 // 计算Y轴初始位移, 使 item 垂直中心移动到点击处
...@@ -223,13 +252,13 @@ ...@@ -223,13 +252,13 @@
// 单列时候X轴初始不做位移 // 单列时候X轴初始不做位移
if (this.columns === 1) tranX = 0 if (this.columns === 1) tranX = 0
if(this.overOnePage) {// 判断是否超过一屏幕, 超过则需要判断当前位置动态滚动page的位置 if (this.overOnePage) { // 判断是否超过一屏幕, 超过则需要判断当前位置动态滚动page的位置
if(currentClientY > this.windowHeight - this.item.height) { if (currentClientY > this.windowHeight - this.item.height) {
uni.pageScrollTo({ uni.pageScrollTo({
scrollTop: currentPageY + this.item.height - this.windowHeight, scrollTop: currentPageY + this.item.height - this.windowHeight,
duration: 300 duration: 300
}); });
} else if(currentClientY < this.item.height) { } else if (currentClientY < this.item.height) {
uni.pageScrollTo({ uni.pageScrollTo({
scrollTop: currentPageY - this.item.height, scrollTop: currentPageY - this.item.height,
duration: 300 duration: 300
...@@ -277,27 +306,27 @@ ...@@ -277,27 +306,27 @@
this.curZ = -1 this.curZ = -1
}, 3000) }, 3000)
}, },
l2r(key, origin) {//正序拖动 key 值和固定项判断逻辑 l2r(key, origin) { //正序拖动 key 值和固定项判断逻辑
if (key == origin) return origin if (key == origin) return origin
// if (this.list && this.list[key] && this.list[key].fixed) { // if (this.list && this.list[key] && this.list[key].fixed) {
// return this.l2r(key - 1, origin) // return this.l2r(key - 1, origin)
// }else { // }else {
return key return key
// } // }
}, },
r2l(key, origin) {//倒序拖动 key 值和固定项判断逻辑 r2l(key, origin) { //倒序拖动 key 值和固定项判断逻辑
if (key == origin) return origin if (key == origin) return origin
// if (this.list && this.list[key] && this.list[key].fixed) { // if (this.list && this.list[key] && this.list[key].fixed) {
// return this.r2l(key + 1, origin) // return this.r2l(key + 1, origin)
// } else { // } else {
return key return key
// } // }
}, },
//根据起始key和目标key去重新计算每一项的新的key //根据起始key和目标key去重新计算每一项的新的key
insert(origin, end) { insert(origin, end) {
this.itemTransition = true this.itemTransition = true
let list let list
if (origin < end) {// 正序拖动 if (origin < end) { // 正序拖动
list = this.list.map(item => { list = this.list.map(item => {
// if (item.fixed) return item // if (item.fixed) return item
if (item.key > origin && item.key <= end) { if (item.key > origin && item.key <= end) {
...@@ -308,7 +337,7 @@ ...@@ -308,7 +337,7 @@
return item return item
}) })
this.getPosition(list) this.getPosition(list)
} else if (origin > end) {// 倒序拖动 } else if (origin > end) { // 倒序拖动
list = this.list.map(item => { list = this.list.map(item => {
// if (item.fixed) return item // if (item.fixed) return item
if (item.key >= end && item.key < origin) { if (item.key >= end && item.key < origin) {
...@@ -346,19 +375,18 @@ ...@@ -346,19 +375,18 @@
}, 0) }, 0)
}, },
//点击每一项后触发事件 //点击每一项后触发事件
itemClick(index,src) { itemClick(index, src) {
let urls=[] let urls = []
urls.push(src) urls.push(src)
console.log(urls); uni.previewImage({//点击查看大图
uni.previewImage({ urls: urls,
urls:urls,
})
let item = this.list[index]
this.$emit('click', {
oldKey: index,
newKey: item.key,
data: item.data
}) })
// let item = this.list[index]
// this.$emit('click', {
// oldKey: index,
// newKey: item.key,
// data: item.data
// })
} }
} }
} }
...@@ -435,12 +463,14 @@ ...@@ -435,12 +463,14 @@
overflow: hidden; overflow: hidden;
padding: 10rpx; padding: 10rpx;
box-sizing: border-box; box-sizing: border-box;
.image { .image {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
} }
&__item_btn{
&__item_btn {
height: 50rpx; height: 50rpx;
width: 50rpx; width: 50rpx;
position: absolute; position: absolute;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<u-icon name="bell-fill" color="#6C8EF3"></u-icon><text style="margin-left: 20rpx;">提醒:长按拖拽排序</text> <u-icon name="bell-fill" color="#6C8EF3"></u-icon><text style="margin-left: 20rpx;">提醒:长按拖拽排序</text>
</view> </view>
<view class="top"> <view class="top">
<dragImg :listData="imgList" @change="changeImgList" :columns="4" @click="clickItem" ></dragImg> <dragImg :listData="imgList" @change="changeImgList" :columns="4"></dragImg>
</view> </view>
<view class="bottom" @click="next"> <view class="bottom" @click="next">
下一步 下一步
...@@ -60,11 +60,7 @@ ...@@ -60,11 +60,7 @@
}, },
methods: { methods: {
changeImgList(res) { changeImgList(res) {
this.sortImglist=res this.sortImglist=res.listData
console.log(this.sortImglist);
},
clickItem(res){
console.log(res);
}, },
next(){//下一步 next(){//下一步
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
export default { export default {
data() { data() {
return { return {
maxImg:12, maxImg:24,
imgList:[ imgList:[
{url:"https://cdn.uviewui.com/uview/swiper/1.jpg",check:0}, {url:"https://cdn.uviewui.com/uview/swiper/1.jpg",check:0},
{url:"https://cdn.uviewui.com/uview/swiper/2.jpg",check:0}, {url:"https://cdn.uviewui.com/uview/swiper/2.jpg",check:0},
...@@ -85,9 +85,14 @@ export default { ...@@ -85,9 +85,14 @@ export default {
}, },
methods: { methods: {
confirm(){//确定提交 confirm(){//确定提交
this.$u.route({ if(this.checkList.length<this.maxImg){
url:"pages/vlog/pictureFormat/pictureFormat" uni.showModal({title: '提示',content: '相册规格'+this.maxImg+"张,请按照标准选择确定",});
}) }else{
this.$u.route({
url:"pages/vlog/pictureFormat/pictureFormat"
})
}
}, },
del(){//删除图片 del(){//删除图片
}, },
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</navigator> </navigator>
<view class="title"> <view class="title">
<view class="shuxian"></view> <view class="shuxian"></view>
<view>定制我的相片集</view> <view>我的相片集</view>
</view> </view>
<navigator url="../product/product"> <navigator url="../product/product">
<view class="photoGallery"> <view class="photoGallery">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment