浏览代码

2024-1-6 首页栏目订阅

dzl 1 年之前
父节点
当前提交
0ab7e20211

+ 18 - 10
components/dragSort/dragSort.vue

@@ -10,7 +10,7 @@
 				</template>
 				<text v-else class="dragSortBox-btn" @click="toggleEdit('edit')">编辑</text>
 			</view>
-			<movable-area id="dragSortArea" class="dragSort-area"  :style="{height: boxHeight + 'px'}">
+			<movable-area id="dragSortArea" class="dragSort-area"   :style="{height: boxHeight + 'px'}">
 				<block v-for="(item,index) in cloneList" :key="item.id" >
 					<movable-view class="dragSort-view" direction="all" 
 						:class="{'is-touched': item.isTouched}"
@@ -51,6 +51,7 @@
 				clearT: '', //onChange事件中使用
 				clearF: '', //点击“完成”文字按钮时使用
 				isEdit: false, //是否在编辑状态
+				type:null
 			}
 		},
 		props: { //props里属性Number的单位都为rpx,在操作的时候需要用rpxTopx进行转换
@@ -103,7 +104,7 @@
 		mounted() {
 			const query = uni.createSelectorQuery().in(this);
 			query.select('#dragSortArea').boundingClientRect(data => {
-				console.log("得到布局位置信息" + JSON.stringify(data));
+				// console.log("得到布局位置信息" + JSON.stringify(data));
 				this.columnWidth = (data.width - (this.columnNum - 1) * this.rpxTopx(this.columnSpace)) / this.columnNum
 				this.handleListData();
 			}).exec();
@@ -115,7 +116,7 @@
 			toggleEdit(type) {
 				if(type == 'finish') { //点击“完成”
 					this.isEdit = false;
-					console.log(this.getSortedIdArr(), 'sortedIdArr')
+					// console.log(this.getSortedIdArr(), 'sortedIdArr')
 					
 				}else if(type == 'cancel'){ //点击“取消”,将数据恢复到最近一次编辑时的状态
 					this.isEdit = false;
@@ -198,7 +199,7 @@
 				if(!this.isEdit) {
 					return false
 				};
-				
+				this.type = obj.id
 				this.curTouchPostionIndex = this.findPositionIndex(obj.id);
 				
 				// 将当前拖动的模块zindex调成当前队列里的最大
@@ -221,6 +222,7 @@
 				if(!this.isEdit) {
 					return false
 				};
+				this.type = null
 				this.startSort(this.curTouchPostionIndex, 'onTouchend'); //再次调用并传参数‘onTouchend’,使拖动后且没有找到目标位置的滑块归位
 				
 			},
@@ -376,16 +378,22 @@
 	.dragSortBox {
 		padding: 0 20rpx;
 	}
-	.dragSortBox-btns { padding: 20rpx; margin-bottom: 20rpx; text-align: right; color: red;display: flex;justify-content: flex-end;}
+	.dragSortBox-btns { padding: 20rpx; margin-bottom: 20rpx; text-align: right; color: #409EFF;display: flex;justify-content: flex-end;}
 	.dragSortBox-btn { margin-left: 20rpx;}
 
 	.dragSort-area {
 		width: 100%;
 		/* background-color: skyblue; */
 	}
-
+	.big{
+		width: 110% !important;
+		height: 110%!important;
+	}
 	.dragSort-view {
 		background-color: #eee;
+		/* border: 1px solid #ccc; */
+		border-radius: 20rpx;
+		font-size: 14px;
 		text-align: center;
 	}
 	.dragSort-view.is-touched { opacity: .9;}
@@ -395,15 +403,15 @@
 	/* transform: translate(50%, -50%); */
 	@-webkit-keyframes shake {
 	          0% { transform: rotate(0deg); } /* 初始状态不旋转 */
-	             25% { transform: rotate(-2deg); } /* 左右摇晃 */
-	             75% { transform: rotate(2deg); } /* 反向左右摇晃 */
+	             25% { transform: rotate(-1deg); } /* 左右摇晃 */
+	             75% { transform: rotate(1deg); } /* 反向左右摇晃 */
 	             100% { transform: rotate(0deg); } /* 结束时返回到初始状态 */
 	       }
 		
 	       @keyframes shake {
 	           0% { transform: rotate(0deg); } /* 初始状态不旋转 */
-	              25% { transform: rotate(-2deg); } /* 左右摇晃 */
-	              75% { transform: rotate(2deg); } /* 反向左右摇晃 */
+	              25% { transform: rotate(-1deg); } /* 左右摇晃 */
+	              75% { transform: rotate(1deg); } /* 反向左右摇晃 */
 	              100% { transform: rotate(0deg); } /* 结束时返回到初始状态 */
 	       }
 		

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "协同办公",
     "appid" : "__UNI__EEB5AF5",
     "description" : "",
-    "versionName" : "1.5.6",
-    "versionCode" : 156,
+    "versionName" : "1.5.9",
+    "versionCode" : 159,
     "transformPx" : false,
     "app-plus" : {
         /* 5+App特有相关 */

+ 12 - 12
pages/index/index.vue

@@ -102,7 +102,7 @@
 			this.getLbList()
 			this.getAllList()
 			this.getwgzlm()
-			// this.needUpdateApp()
+			this.needUpdateApp()
 		},
 		onShow() {
 			this.getUnreadEmail()
@@ -111,7 +111,7 @@
 		methods: {
 			wancheng(e){
 				if(e=='finish'){
-					console.log(1)
+					this.lmlist[this.current].xlList1 = true
 					let list = []
 					this.lmlist.forEach(item => {
 						let obj = {
@@ -121,14 +121,12 @@
 						}
 						list.push(obj);
 					})
-					console.log(list)
-					uni.$u.http.post('/oa/column/saveFollowCoulumn',{columns:list}).then(res=>{
-						console.log(res)
+					uni.$u.http.post('/oa/column/saveFollowCoulumn',list).then(res=>{
+						
 					})
 				}
 			},
 			del(e){
-				console.log(e)
 				uni.$u.http.delete('/system/subscribed/remove/'+e.data.id).then(res=>{
 					this.getwgzlm()
 					if(this.current > e.index ){
@@ -149,11 +147,9 @@
 				})
 			},
 			lmOpen(){
+				this.lmlist[this.current].xlList1 = false
 				this.$forceUpdate()
 			},
-			onDragSortChange(e){
-				console.log(e)
-			},
 			//点击更多
 			more() {
 				this.lmshow = true
@@ -340,7 +336,7 @@
 			//获取关注栏目
 			getwgzlm(){
 				uni.$u.http.get("/oa/column/app/notFollow").then(res=>{
-					console.log(res)
+					// console.log(res)
 					this.wgzlm = res
 				})
 			},
@@ -373,6 +369,10 @@
 			//保存栏目顺序
 			saveLmOrder(){
 				let list = []
+				this.lmlist[this.current].xlList1 = true
+				if(this.lmlist[this.current].list == 0){
+					this.lower(this.current)
+				}
 				this.lmlist.forEach(item => {
 					let obj = {
 						name:item.name,
@@ -382,8 +382,8 @@
 					list.push(obj);
 				})
 				this.lmshow = false
-				uni.$u.http.post('/oa/column/saveFollowCoulumn',{columns:list}).then(res=>{
-					console.log(res)
+				uni.$u.http.post('/oa/column/saveFollowCoulumn',list).then(res=>{
+					
 				})
 			},
 			//升级 

+ 2 - 0
uni_modules/csr-drag-sorts/changelog.md

@@ -0,0 +1,2 @@
+## 1.0.0(2023-06-11)
+发布初始版本

+ 107 - 0
uni_modules/csr-drag-sorts/components/csr-drag-sorts/1px.less

@@ -0,0 +1,107 @@
+.setLine(@c: #eee) {
+  content: " ";
+  position: absolute;
+  left: 0;
+  top: 0;
+  width: 200%;
+  border: 1rpx solid @c;
+  color: @c;
+  height: 200%;
+  transform-origin: left top;
+  transform: scale(0.5);
+}
+
+.vh-1px, .vh-1px-t, .vh-1px-b, .vh-1px-tb, .vh-1px-l, .vh-1px-r {
+  position: relative;
+}
+
+.vh-1px {
+  &:before {
+    .setLine();
+  }
+}
+
+.vh-1px-t {
+  &:before {
+    .setTopLine();
+  }
+}
+
+.vh-1px-b {
+  &:after {
+    .setBottomLine();
+  }
+}
+
+.vh-1px-tb {
+  &:before {
+    .setTopLine();
+  }
+  &:after {
+    .setBottomLine();
+  }
+}
+
+.vh-1px-l {
+  &:before {
+    .setLeftLine();
+  }
+}
+
+.vh-1px-r {
+  &:after {
+    .setRightLine();
+  }
+}
+
+.setTopLine(@c: #eee) {
+  content: " ";
+  position: absolute;
+  left: 0;
+  top: 0;
+  right: 0;
+  height: 1rpx;
+  border-top: 1rpx solid @c;
+  color: @c;
+  transform-origin: 0 0;
+  transform: scaleY(0.5);
+}
+
+.setBottomLine(@c: #eee) {
+  content: " ";
+  position: absolute;
+  left: 0;
+  bottom: 0;
+  right: 0;
+  height: 1rpx;
+  border-bottom: 1rpx solid @c;
+  color: @c;
+  transform-origin: 0 100%;
+  transform: scaleY(0.5);
+}
+
+.setLeftLine(@c: #eee) {
+  content: " ";
+  position: absolute;
+  left: 0;
+  top: 0;
+  width: 1rpx;
+  bottom: 0;
+  border-left: 1rpx solid @c;
+  color: @c;
+  transform-origin: 0 0;
+  transform: scaleX(0.5);
+}
+
+.setRightLine(@c: #eee) {
+  content: " ";
+  position: absolute;
+  right: 0;
+  top: 0;
+  width: 1rpx;
+  bottom: 0;
+  border-right: 1rpx solid @c;
+  color: @c;
+  transform-origin: 100% 0;
+  transform: scaleX(0.5);
+}

+ 295 - 0
uni_modules/csr-drag-sorts/components/csr-drag-sorts/csr-drag-sorts.vue

@@ -0,0 +1,295 @@
+<template>
+	<view class="">
+		  <movable-area class="drag-sort" :style="{height:boxHeight }" id="drag">
+			<movable-view
+			v-for="(item, index) in currentList"
+			:key="index"
+			:x="item.x"
+			v-if="item.isShow === 1"
+			:data-index="index"
+			@touchstart="touchstart"
+			@touchmove.stop="touchmove"
+			@touchend="touchend"
+			@click="close(index)"
+			:y="item.y"
+			:direction="direction"
+			disabled
+			damping="40"
+			:animation="item.animation"
+			class="drag-sort-item"
+			:class="{'active': active == index, 'vh-1px-t': item.index > 0}">
+			  <view class="item">
+				  <text>{{item[props.label]}}</text>
+			  </view>
+			</movable-view>
+		  </movable-area>
+	</view>
+
+</template>
+
+<script>
+export default {
+  name: 'drag-sort',
+  mixins: [],
+  components: {},
+  data () {
+    return {
+	  direction:"all",
+	  windowWidth:100, //屏幕宽度
+      height: 40, // 高度
+      currentList: [],
+      active: -1, // 当前激活的item
+      index: 0, // 当前激活的item的原index
+      topY: 0, // 距离顶部的距离
+	  topX: 0, // 距离左侧偏移位置
+	  deviationX: 0,
+      deviationY: 0// 偏移量
+    }
+  },
+  computed: {
+	  boxHeight(){
+		  return (Math.ceil((Number(this.list.length)+1)/4)) * this.height + 'px'  
+	  }
+  },
+  props: {
+    list: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    boxStyle: {
+      type: Object,
+      default: () => {
+        return {}
+      }
+    },
+    props: {
+      type: Object,
+      default: () => {
+        return {
+          label: 'label',
+          value: 'value'
+        }
+      }
+    }
+  },
+  watch: {
+    list:{
+		handler(){
+			debugger
+			this.onUpdateCurrentList()
+		},
+		deep:true
+      
+    }
+  },
+  created () {
+    const res = uni.getSystemInfoSync();
+	this.windowWidth = res.windowWidth
+    this.onUpdateCurrentList()
+  },
+  mounted () {
+  },
+  updated () {},
+  filters: {},
+  methods: {
+    onUpdateCurrentList (list = this.list) {
+      let arr = []
+      for (const key in list) {
+		  // console.log(key)
+		  let height =  Math.ceil((Number(key)+1)/4) - 1
+		  let x = 0
+		  if(key <= 3){
+			  x = key * this.windowWidth * 0.24 + this.windowWidth * 0.04 || this.windowWidth * 0.04
+		  }else{
+			  if((Number(key)+1)%4 === 0){
+				   x = 3 * this.windowWidth * 0.24 + this.windowWidth * 0.04 || this.windowWidth * 0.04
+			  }else{
+				  x = ((Number(key)+1)%4-1) * this.windowWidth * 0.24 + this.windowWidth * 0.04 || this.windowWidth * 0.04
+			  }
+			  
+		  }
+        arr.push({
+          ...list[key],
+		  isShow:1,
+          index: Number(key),
+		  SortNumber:Number(key),
+          y: height * this.height,
+		  x,
+          animation: true
+        })
+      }
+      this.currentList = arr
+    },
+	// 根据排序进行重新计算位置
+	moveUpdateCurrentList(index){
+      for (const i in this.currentList) {
+		  let key
+		  if(this.currentList[i].SortNumber || this.currentList[i].SortNumber === 0){
+			  key = this.currentList[i].SortNumber
+		  }else{
+			  key = Number(i)
+		  }
+		  // console.log(key)
+		  let temobj = { ...this.currentList[i] }
+		   // debugger
+		  this.currentList[i].y =  (Math.ceil((Number(key)+1)/4) - 1)*this.height 
+		  if(index == key){
+			  continue
+		  }else{
+			  if(key <= 3){
+				  this.currentList[i].x = key * this.windowWidth * 0.24 + this.windowWidth * 0.04 || this.windowWidth * 0.04
+			  }else{
+				  if((Number(key)+1)%4 === 0){
+					   this.currentList[i].x = 3 * this.windowWidth * 0.24 + this.windowWidth * 0.04 || this.windowWidth * 0.04
+				  }else{
+					   this.currentList[i].x = ((Number(key)+1)%4-1) * this.windowWidth * 0.24 + this.windowWidth * 0.04 || this.windowWidth * 0.04
+				  }
+			  } 
+		  }
+      }
+	  this.$emit('change', this.currentList)
+	},
+    touchstart (e) {
+      // 计算 x y 轴点击位置
+      var query = uni.createSelectorQuery().in(this)
+      query.select('#drag').boundingClientRect()
+      query.exec((res) => {
+        this.topY = res[0].top
+		this.topX  = res[0].left
+        let touchY = e.mp.touches[0].clientY - res[0].top
+        let touchX = e.mp.touches[0].clientX - res[0].left
+        this.deviationY = touchY % this.height
+		 this.deviationX = touchX % (this.windowWidth*0.2)
+		this.active = Number(e.currentTarget.dataset.index)
+		this.index = Number(e.currentTarget.dataset.index)
+      })
+    },
+    touchmove (e) {
+      if (this.active < 0) return
+	  let temY = e.mp.touches[0].clientY - this.topY
+	  let temX = e.mp.touches[0].clientX - this.topX
+      let touchY = temY - 15
+      let touchX = temX - this.windowWidth*0.1
+      this.currentList[this.active].y = touchY 
+      this.currentList[this.active].x = touchX
+      this.currentList[this.active].animation = false
+	  this.currentList.every( (res, index) => {
+			let absX =  Math.abs(touchX - res.x)
+			let absY =  Math.abs(touchY - res.y)
+			// 设置元素定点距离多少进行重排
+		  if( 0 < absX && absX <= 10 && absY > 0 && absY <= 10 && this.active != index){
+			  // debugger
+			  let temNumber = this.currentList[index].SortNumber
+			  this.currentList.every( (_res, _index) => {
+				  // 判断从大像小移还是从小向大移
+				  if( this.currentList[this.active].SortNumber < this.currentList[index].SortNumber){
+					  // 移动元素比目标元素所在位置小,之间元素排序--
+						if( this.currentList[_index].SortNumber > this.currentList[this.active].SortNumber && this.currentList[_index].SortNumber <= this.currentList[index].SortNumber){
+							  _res.SortNumber--
+						  }
+				  }else{
+					  // 反之++
+						if( this.currentList[_index].SortNumber < this.currentList[this.active].SortNumber && this.currentList[_index].SortNumber >= this.currentList[index].SortNumber){
+							  _res.SortNumber++
+						  }
+				  }
+				  return true
+			  }, this)
+			   this.currentList[this.active].SortNumber = temNumber 
+			  this.moveUpdateCurrentList(temNumber)
+			  return false
+		  }else{
+			  return true
+		  }
+	  }, this)
+    },
+    touchend (e) {
+	  if(this.currentList[this.active]){
+		   this.currentList[this.active].animation = true
+	  }
+	   this.moveUpdateCurrentList(-1)
+      this.active = -1
+    },
+	// 关闭按钮
+	close(index){
+		let _this=this;
+		uni.showModal({
+			title:'提示',
+			content:'确定删除吗?',
+			success: function (res) {
+				if (res.confirm) {
+					console.log('用户点击确定');
+					console.log("我是删除的index 的SortNumber")
+					console.log(_this.currentList[index].SortNumber)
+					_this.currentList.forEach( (item, i) => {
+						if(_this.currentList[i].SortNumber > _this.currentList[index].SortNumber){
+							item.SortNumber--
+						}
+					})
+					
+					_this.moveUpdateCurrentList(-1)
+					_this.currentList[index].isShow = 0 
+				} else if (res.cancel) {
+					console.log('用户点击取消');
+				}
+			}
+		})
+		// debugger
+	
+
+	}
+  }
+}
+</script>
+
+<style lang='less' scoped>
+@import "~./1px.less";
+.drag-sort {
+  width: 100%;
+}
+.drag-sort-item {
+  position: absolute !important;
+  display: flex;
+  height: 30px;
+  align-items: center;
+  width: 20%;
+  text-align: center;
+  background-color: #00557f;
+  color: #fff;
+  /* border-radius: 5px; */
+  box-sizing: border-box;
+  .item {
+	position: relative;
+    flex: 1;
+	font-size: 16px;
+  }
+  .close{
+	  position: absolute;
+	  right: -10upx;
+	  top: -10upx;
+	  width: 30upx;
+	  z-index: 99;
+	  height: 30upx;
+	  opacity: 0.8;
+  }
+  .close image{
+	  width: 100%;
+	  height: 100%;
+  }
+  .touch-tight {
+    width: 24px;
+    display: flex;
+    justify-content: center;
+  }
+}
+.touch {
+  height: 100%;
+  width: 50px;
+}
+.active {
+  box-shadow: 0 0 40rpx #DDDDDD;
+  z-index: 99;
+}
+</style>

+ 81 - 0
uni_modules/csr-drag-sorts/package.json

@@ -0,0 +1,81 @@
+{
+  "id": "csr-drag-sorts",
+  "displayName": "csr-drag-sorts",
+  "version": "1.0.0",
+  "description": "拖动排序,点击删除标签",
+  "keywords": [
+    "拖动、排序、删除、标签"
+],
+  "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": [],
+    "encrypt": [],
+    "platforms": {
+      "cloud": {
+        "tcb": "y",
+        "aliyun": "y"
+      },
+      "client": {
+        "Vue": {
+          "vue2": "y",
+          "vue3": "u"
+        },
+        "App": {
+          "app-vue": "y",
+          "app-nvue": "u"
+        },
+        "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",
+          "阿里": "u",
+          "百度": "u",
+          "字节跳动": "u",
+          "QQ": "u",
+          "钉钉": "u",
+          "快手": "u",
+          "飞书": "u",
+          "京东": "u"
+        },
+        "快应用": {
+          "华为": "u",
+          "联盟": "u"
+        }
+      }
+    }
+  }
+}

+ 12 - 0
uni_modules/csr-drag-sorts/readme.md

@@ -0,0 +1,12 @@
+# csr-drag-sorts
+# 属性
+|list				|props				|
+|:-:				|:-:				|
+|渲染数据(数组)	|对应需要显示的标题	|
+# 事件
+@change 当发生元素顺序发生变化或删除时触发,参数是改变后的数组其中 sortNumber 是该元素的排序
+删除的元素并没有从数组中真正去掉(因为会影响动画),只是改变了其 isShow 1显示 0隐藏
+
+|名称	|功能						|返回值												|
+|:-:	|:-:						|:-:												|
+|@change|点击删除事件	|改变了其 isShow 1显示 0隐藏的数组	|

+ 2 - 2
utils/request/index.js

@@ -1,6 +1,6 @@
 // 根域名
-// var baseUrl = 'http://121.28.24.104:13898/app/';
-var baseUrl = 'http://192.168.1.59:8080';
+var baseUrl = 'http://121.28.24.104:13898/app/';
+// var baseUrl = 'http://192.168.1.59:8080';
  
 module.exports = (vm) => {
     // 初始化请求配置:config 为默认全局配置