Просмотр исходного кода

Merge branch 'master' of http://192.168.0.115:3000/chenzhiguang/FD_Pano

任一存 3 лет назад
Родитель
Сommit
84faa2a596

+ 1 - 1
src/assets/style/component.less

@@ -778,7 +778,7 @@ textarea:-ms-input-placeholder {
     .ui-message-main{
       text-align: left;
       min-height: 80px;
-      margin-top: 60px;
+      margin-top: 40px;
     }
   }
 }

+ 37 - 6
src/components/range/index.vue

@@ -21,13 +21,23 @@ export default {
       default: Infinity
     },
     isGradient:{
-      type: Boolean,
-      default: false
+      type: Number,
+      default: 0
     }
   },
   data() {
+    let gradientArr = []
+    if(this.max > this.isGradient){
+      let  temp = Array(Math.ceil(this.max / this.isGradient)).fill(0)
+      gradientArr = temp.map((item,i)=>{
+        return [i*this.isGradient,(i+1)*this.isGradient]
+      })
+      console.log(gradientArr);
+    }
     return {
-      current: Number(this.value)
+      current: Number(this.value),
+      isLegal:this.max > this.isGradient && this.isGradient,
+      gradientArr
     }
   },
   mounted() {
@@ -40,9 +50,30 @@ export default {
     this.$refs.bar.removeEventListener('touchstart', this.downHandle, false)
   },
   methods: {
+
+    toChangeNum(tmp){
+      
+        let max = [0,0]
+        if (this.isLegal) {
+          max = this.gradientArr.find(item=>{
+            return tmp >= item[0] && tmp < item[1]
+          })
+        }
+
+        if (tmp == 0 || tmp == this.max) {
+          this.current = tmp
+          return 
+        }
+
+        return Number(this.isLegal ? (max ? max[1] : tmp) : tmp)
+
+    },
     clickHandle(ev) {
       let tmp = this.min + this.len * (ev.offsetX / this.width)
-      this.current = this.isGradient ? Math.ceil(tmp) : tmp
+
+      
+        this.current = this.toChangeNum(tmp)
+
     },
     downHandle(ev) {
       let $layer = document.documentElement
@@ -50,7 +81,7 @@ export default {
       let initV = this.current
       let move = ev => {
         let tmp = initV - ((startX - (ev.pageX || ev.touches[0].pageX)) / this.width) * this.len
-        this.current = this.isGradient ? Math.ceil(tmp) : tmp
+        this.current = this.toChangeNum(tmp)
       }
       let end = ev => {
         $layer.removeEventListener('touchmove', move, false)
@@ -80,7 +111,7 @@ export default {
   },
   watch: {
     current() {
-      let current = Number(this.current.toFixed(2))
+      let current = Number(this.current ? this.current.toFixed(2) : this.current)
       if (current !== this.current) return this.current = current
       
       if (!this.current.toString()) {

+ 1 - 1
src/views/base/EditPanel/opening.vue

@@ -83,7 +83,7 @@ export default {
             value: 1,
             min: 0,
             max: 3,
-            gradient: true,
+            gradient: 1,
             tip:true
         }
       }

+ 1 - 0
src/views/hotspot/EditPanel.vue

@@ -231,6 +231,7 @@ export default {
       rang: {
         label: '图标大小',
         unit: "倍",
+        gradient: 0.5,
         value: 1,
         min: 0.5,
         max: 2