shaogen1995 2 年之前
父节点
当前提交
b162527ee6

+ 27 - 0
package-lock.json

@@ -17,6 +17,7 @@
         "vue-infinite-scroll": "^2.0.2",
         "vue-lazyload": "^1.3.3",
         "vue-router": "^3.2.0",
+        "vuedraggable": "^2.24.3",
         "vuex": "^3.6.2"
       },
       "devDependencies": {
@@ -12965,6 +12966,11 @@
         "node": ">=0.10.0"
       }
     },
+    "node_modules/sortablejs": {
+      "version": "1.10.2",
+      "resolved": "https://registry.npmmirror.com/sortablejs/-/sortablejs-1.10.2.tgz",
+      "integrity": "sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A=="
+    },
     "node_modules/source-list-map": {
       "version": "2.0.1",
       "resolved": "https://registry.npmmirror.com/source-list-map/-/source-list-map-2.0.1.tgz",
@@ -14776,6 +14782,14 @@
         "source-map": "^0.6.1"
       }
     },
+    "node_modules/vuedraggable": {
+      "version": "2.24.3",
+      "resolved": "https://registry.npmmirror.com/vuedraggable/-/vuedraggable-2.24.3.tgz",
+      "integrity": "sha512-6/HDXi92GzB+Hcs9fC6PAAozK1RLt1ewPTLjK0anTYguXLAeySDmcnqE8IC0xa7shvSzRjQXq3/+dsZ7ETGF3g==",
+      "dependencies": {
+        "sortablejs": "1.10.2"
+      }
+    },
     "node_modules/vuex": {
       "version": "3.6.2",
       "resolved": "https://r2.cnpmjs.org/vuex/-/vuex-3.6.2.tgz",
@@ -26425,6 +26439,11 @@
         }
       }
     },
+    "sortablejs": {
+      "version": "1.10.2",
+      "resolved": "https://registry.npmmirror.com/sortablejs/-/sortablejs-1.10.2.tgz",
+      "integrity": "sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A=="
+    },
     "source-list-map": {
       "version": "2.0.1",
       "resolved": "https://registry.npmmirror.com/source-list-map/-/source-list-map-2.0.1.tgz",
@@ -27935,6 +27954,14 @@
       "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==",
       "dev": true
     },
+    "vuedraggable": {
+      "version": "2.24.3",
+      "resolved": "https://registry.npmmirror.com/vuedraggable/-/vuedraggable-2.24.3.tgz",
+      "integrity": "sha512-6/HDXi92GzB+Hcs9fC6PAAozK1RLt1ewPTLjK0anTYguXLAeySDmcnqE8IC0xa7shvSzRjQXq3/+dsZ7ETGF3g==",
+      "requires": {
+        "sortablejs": "1.10.2"
+      }
+    },
     "vuex": {
       "version": "3.6.2",
       "resolved": "https://r2.cnpmjs.org/vuex/-/vuex-3.6.2.tgz",

+ 1 - 0
package.json

@@ -16,6 +16,7 @@
     "vue-infinite-scroll": "^2.0.2",
     "vue-lazyload": "^1.3.3",
     "vue-router": "^3.2.0",
+    "vuedraggable": "^2.24.3",
     "vuex": "^3.6.2"
   },
   "devDependencies": {

+ 8 - 1
src/router/index.js

@@ -46,12 +46,19 @@ const routes = [{
     path: '/layout/interact/issue',
     name: 'interactIssue',
     meta: {
-      myInd: 3,
       myTitle: '悦·互动发布'
     },
     component: () => import('../views/Interact/components/InteractIssue.vue')
   },
+  // 定位,位置
   {
+    path: '/layout/interact/location',
+    name: 'interactLocation',
+    meta: {
+      myTitle: '位置'
+    },
+    component: () => import('../views/Interact/components/interactLocation.vue')
+  }, {
     path: '/layout',
     name: 'layout',
     component: () => import('../views/Layout/index.vue'),

+ 62 - 42
src/views/Interact/components/InteractIssue.vue

@@ -30,7 +30,7 @@
       </div>
     </div>
 
-    <div class="imgTit">
+    <div class="imgTit" @click="locationClick">
       <div class="rightInco">
         <van-icon name="arrow" />
       </div>
@@ -55,35 +55,41 @@
       <van-uploader accept=".png,.jpg">
         <div class="upImg"></div>
       </van-uploader>
-      <div
-        class="imgRow"
-        draggable="true"
-        @dragstart="handleDragStart($event, item)"
-        @dragover.prevent="handleDragOver($event, item)"
-        @dragenter="handleDragEnter($event, item)"
-        @dragend="handleDragEnd($event, item)"
-        v-for="(item, index) in imgList"
-        :key="item.name"
+      <Draggable
+        class="moveDraggable"
+        v-model="imgList"
+        group="itxst"
+        @start="start"
+        animation="300"
       >
-        <img
-          :src="require(`@/assets/img/interact/${item.url}.png`)"
-          alt=""
-          @click="lookImg"
-        />
-        <!-- 删除 -->
-        <div class="delImg" @click="delImg(item.name)"></div>
-        <!-- 封面 -->
-        <div class="imgCover" v-show="index === 0">封面</div>
-      </div>
+        <transition-group>
+          <div class="imgRow" v-for="(item, index) in imgList" :key="item.name">
+            <img
+              :src="require(`@/assets/img/interact/${item.url}.png`)"
+              alt=""
+              @click="lookImg"
+            />
+            <!-- 删除 -->
+            <div class="delImg" @click="delImg(item.name)"></div>
+            <!-- 封面 -->
+            <div class="imgCover" v-show="index === 0">封面</div>
+          </div>
+        </transition-group>
+      </Draggable>
     </div>
+    <div class="imgUpTit">可拖动图片调整顺序,首张图将作为封面。</div>
+    <!-- 发布按钮 -->
+    <div class="issueBtn" @click="issueDone">发 布</div>
   </div>
 </template>
 
 <script>
+//导入draggable组件
+import Draggable from "vuedraggable";
 import { Dialog, ImagePreview } from "vant";
 export default {
   name: "InteractIssue",
-  components: {},
+  components: { Draggable },
   data() {
     return {
       txt1: "",
@@ -115,6 +121,16 @@ export default {
   computed: {},
   watch: {},
   methods: {
+    // 点击定位
+    locationClick(){
+     this.$router.push('/layout/interact/location')
+    },
+    // 点击发布
+    issueDone(){
+      console.log('-------发布');
+    },
+    // 拖拽图片
+    start(e) {},
     // 查看大图
     lookImg() {
       ImagePreview({
@@ -135,26 +151,6 @@ export default {
         },
       });
     },
-    // 拖动图片
-    handleDragStart(e, items) {
-      console.log('--------',items);
-      this.dragging = items; //开始拖动时,暂时保存当前拖动的数据。
-    },
-    handleDragEnd(e, items) {
-      this.dragging = null; //拖动结束后,清除数据
-    },
-    handleDragOver(e) {
-      e.dataTransfer.dropEffect = "move"; //在dragenter中针对放置目标来设置!
-    },
-    handleDragEnter(e, items) {
-      e.dataTransfer.effectAllowed = "move"; //为需要移动的元素设置dragstart事件
-      if (items == this.dragging) return;
-      const newItems = [...this.imgList]; //拷贝一份数据进行交换操作。
-      const src = newItems.indexOf(this.dragging); //获取数组下标
-      const dst = newItems.indexOf(items);
-      newItems.splice(dst, 0, ...newItems.splice(src, 1)); //交换位置
-      this.imgList = newItems;
-    },
   },
   created() {},
   mounted() {},
@@ -291,7 +287,7 @@ export default {
   }
 
   .upFile {
-    margin: 20px 0 40px;
+    margin: 20px 0 0px;
     display: flex;
     flex-wrap: wrap;
     /deep/.van-uploader {
@@ -303,6 +299,13 @@ export default {
       background-image: url("../../../assets/img/interact/upload.png");
       background-size: 100% 100%;
     }
+    .moveDraggable{
+      width: calc(100% - 90px);
+    }
+    .moveDraggable span {
+      display: flex;
+      flex-wrap: wrap;
+    }
     .imgRow {
       position: relative;
       margin-right: 10px;
@@ -340,5 +343,22 @@ export default {
       }
     }
   }
+  .imgUpTit{
+    font-size: 14px;
+    color: #A6A6A6;
+    margin: 10px 0 40px;
+  }
+  .issueBtn{
+    width: 80%;
+    height: 50px;
+    max-width: 300px;
+    margin: 0 auto 30px;
+    line-height: 50px;
+    background-color: #FF7E89;
+    border-radius: 25px;
+    text-align: center;
+    color: #fff;
+    font-size: 18px;
+  }
 }
 </style>

+ 115 - 0
src/views/Interact/components/interactLocation.vue

@@ -0,0 +1,115 @@
+<template>
+  <div class="interactLocation">
+    <!-- 输入框 -->
+    <div class="inputBox" @keydown.enter="searchFu()">
+      <div class="searInco" @click="searchFu()">
+        <van-icon name="search" />
+      </div>
+      <van-field maxlength="20" v-model="txt" placeholder="搜索位置" />
+    </div>
+    <div class="locationBox">
+      <div class="row" v-for="item in locationData" :key="item.id">
+        <h3>{{item.name}}</h3>
+        <div class="row_floo">
+          <div class="row_flooLL">{{item.loc}}</div>
+          <div class="row_flooRR">{{item.num}}</div>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "interactLocation",
+  components: {},
+  data() {
+    return {
+      txt: "",
+      locationData:[
+        {id:1,name:'芜湖市',loc:'中国安徽省芜湖市',num:''},
+        {id:2,name:'鸠兹广场',loc:'安徽省芜湖市镜湖区滨江路桥口',num:'247m'},
+        {id:3,name:'中江塔',loc:'安徽省芜湖市镜湖区滨江路桥口',num:'425m'},
+        {id:4,name:'方特旅游区',loc:'安徽省芜湖市镜湖区银湖北路80号',num:'692m'},
+        {id:5,name:'芜湖滨江公园',loc:'芜湖市镜湖区新芜路7号',num:'849m'},
+        {id:6,name:'芜湖长江三桥',loc:'安徽省芜湖市',num:'945m'},
+        {id:7,name:'鸠兹古镇',loc:'安徽省芜湖市鸠江区陈棱路与徽州路交汇处西北角',num:'1007m'},
+        {id:8,name:'临江桥',loc:'安徽省芜湖市',num:'1205m'},
+        {id:9,name:'芜湖大剧院',loc:'安徽芜湖市镜湖区滨江路17号',num:'2351m'}
+      ]
+    };
+  },
+  computed: {},
+  watch: {},
+  methods: {
+    searchFu() {},
+  },
+  created() {},
+  mounted() {},
+  beforeCreate() {}, //生命周期 - 创建之前
+  beforeMount() {}, //生命周期 - 挂载之前
+  beforeUpdate() {}, //生命周期 - 更新之前
+  updated() {}, //生命周期 - 更新之后
+  beforeDestroy() {}, //生命周期 - 销毁之前
+  destroyed() {}, //生命周期 - 销毁完成
+  activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
+};
+</script>
+<style lang='less' scoped>
+.interactLocation {
+  width: 100%;
+  height: 100%;
+  padding: 10px 15px 40px;
+  overflow-y: auto;
+
+  .inputBox {
+    margin: 0px auto;
+    width: 100%;
+    height: 30px;
+    position: relative;
+
+    .searInco {
+      color: #a0a0a0;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      font-size: 20px;
+      position: absolute;
+      top: 0;
+      left: 10px;
+      z-index: 3;
+      width: 20px;
+      height: 30px;
+    }
+
+    /deep/.van-cell {
+      width: 100%;
+      height: 30px;
+      line-height: 30px;
+      padding: 0px 0 0px 36px;
+      background-color: #F9F9F9;
+      border-radius: 5px;
+    }
+  }
+  .locationBox{
+    margin-top: 20px;
+    .row{
+      padding-bottom: 15px;
+      border-bottom: 1px solid #E5E5E5;
+      padding-top: 15px;
+      &>h3{
+        font-size: 16px;
+        color: #393939;
+      }
+      .row_floo{
+        margin: 10px 0 0;
+        display: flex;
+        justify-content: space-between;
+        font-size: 14px;
+        color: #868686;
+
+      }
+    }
+  }
+}
+</style>

+ 50 - 44
src/views/Interact/index.vue

@@ -1,12 +1,16 @@
 <template>
-  <div class='My'>
+  <div class="My">
     <!-- 输入框 -->
     <div class="inputBox" @keydown.enter="searchFu()">
       <div class="searInco">
         <van-icon name="search" />
       </div>
       <div class="searBtn" @click="searchFu()">搜索</div>
-      <van-field maxlength="10" v-model="txt" placeholder="请输入要搜索的内容" />
+      <van-field
+        maxlength="10"
+        v-model="txt"
+        placeholder="请输入要搜索的内容"
+      />
     </div>
     <!-- 精彩必体验 -->
     <div class="titleTit">精彩必体验</div>
@@ -16,7 +20,7 @@
     <!-- 主体内容 -->
     <div class="mainBox">
       <div class="row" v-for="item in spotData" :key="item.id">
-        <img :src="require(`@/assets/img/interact/row${item.id}.png`)" alt="">
+        <img :src="require(`@/assets/img/interact/row${item.id}.png`)" alt="" />
         <div class="name">{{ item.name }}</div>
         <div class="author">
           <div class="author_ll">
@@ -24,61 +28,63 @@
             <span>{{ item.author }}</span>
           </div>
           <div class="author_rr">{{ item.time }}</div>
-
         </div>
       </div>
     </div>
     <!-- +号 -->
     <div class="issue">
-      <img src="../../assets/img/interact/issue.png" alt="" @click="$router.push('/layout/interact/issue')"/>
+      <img
+        src="../../assets/img/interact/issue.png"
+        alt=""
+        @click="$router.push('/layout/interact/issue')"
+      />
     </div>
-    
   </div>
 </template>
 
 <script>
-
 export default {
   components: {},
   data() {
     return {
-      txt: '',
+      txt: "",
       bsData: [
-        { id: 1, name: '梦幻游乐王国' },
-        { id: 2, name: '古建筑' },
-        { id: 3, name: '美食' },
-        { id: 4, name: '周边风景游玩' },
-        { id: 5, name: '美景' },
+        { id: 1, name: "梦幻游乐王国" },
+        { id: 2, name: "古建筑" },
+        { id: 3, name: "美食" },
+        { id: 4, name: "周边风景游玩" },
+        { id: 5, name: "美景" },
       ],
       spotData: [
-        { id: 1, name: '方特梦幻王国万圣夜', author: '王大锤', time: '2022-11-16' },
-        { id: 2, name: '芜湖老海关', author: '王大锤', time: '2022-11-16' },
-        { id: 3, name: '中江塔', author: '王大锤', time: '2022-11-16' },
-        { id: 4, name: '鸠兹古镇', author: '王大锤', time: '2022-11-16' },
-      ]
+        {
+          id: 1,
+          name: "方特梦幻王国万圣夜",
+          author: "王大锤",
+          time: "2022-11-16",
+        },
+        { id: 2, name: "芜湖老海关", author: "王大锤", time: "2022-11-16" },
+        { id: 3, name: "中江塔", author: "王大锤", time: "2022-11-16" },
+        { id: 4, name: "鸠兹古镇", author: "王大锤", time: "2022-11-16" },
+      ],
     };
   },
   computed: {},
   watch: {},
   methods: {
     searchFu() {
-      console.log('---------');
-    }
+      console.log("---------");
+    },
   },
-  created() {
-
-  },
-  mounted() {
-
-  },
-  beforeCreate() { }, //生命周期 - 创建之前
-  beforeMount() { }, //生命周期 - 挂载之前
-  beforeUpdate() { }, //生命周期 - 更新之前
-  updated() { }, //生命周期 - 更新之后
-  beforeDestroy() { }, //生命周期 - 销毁之前
-  destroyed() { }, //生命周期 - 销毁完成
-  activated() { }, //如果页面有keep-alive缓存功能,这个函数会触发
-}
+  created() {},
+  mounted() {},
+  beforeCreate() {}, //生命周期 - 创建之前
+  beforeMount() {}, //生命周期 - 挂载之前
+  beforeUpdate() {}, //生命周期 - 更新之前
+  updated() {}, //生命周期 - 更新之后
+  beforeDestroy() {}, //生命周期 - 销毁之前
+  destroyed() {}, //生命周期 - 销毁完成
+  activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
+};
 </script>
 <style lang='less' scoped>
 .My {
@@ -87,10 +93,10 @@ export default {
   overflow-y: auto;
   padding: 20px 15px;
   position: relative;
-  .issue{
+  .issue {
     margin: 20px 0;
     text-align: center;
-    &>img{
+    & > img {
       width: 40px;
     }
   }
@@ -108,7 +114,7 @@ export default {
       height: 30px;
       border-radius: 3px;
       z-index: 2;
-      background-color: #FE6E69;
+      background-color: #fe6e69;
       font-size: 14px;
       color: #fff;
       line-height: 30px;
@@ -116,7 +122,7 @@ export default {
     }
 
     .searInco {
-      color: #A0A0A0;
+      color: #a0a0a0;
       display: flex;
       justify-content: center;
       align-items: center;
@@ -134,7 +140,7 @@ export default {
       height: 30px;
       line-height: 30px;
       padding: 0px 0 0px 36px;
-      background-color: #F4F4F4;
+      background-color: #f4f4f4;
       border-radius: 15px;
     }
   }
@@ -150,14 +156,14 @@ export default {
     display: flex;
     flex-wrap: wrap;
 
-    &>div {
+    & > div {
       text-align: center;
       min-width: 60px;
       padding: 0 5px;
       height: 30px;
       line-height: 30px;
       border-radius: 2px;
-      background-color: #F4F4F4;
+      background-color: #f4f4f4;
       margin: 0 15px 15px 0;
       font-size: 12px;
       color: #333333;
@@ -174,7 +180,7 @@ export default {
       overflow: hidden;
       width: 48%;
       height: 260px;
-      background-color: #F7F8FA;
+      background-color: #f7f8fa;
       border-radius: 4px;
       color: #333333;
 
@@ -182,7 +188,7 @@ export default {
         margin-right: 0;
       }
 
-      &>img {
+      & > img {
         width: 100%;
         height: 180px;
         object-fit: cover;
@@ -205,7 +211,7 @@ export default {
         .author_ll {
           vertical-align: middle;
 
-          &>img {
+          & > img {
             margin-right: 5px;
             width: 12px;
             height: 12px;