import "./index.css";
/* script */
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
import { createComponentName, componentMixin } from '../_utils/component';
const __vue_script__ = {
  name: createComponentName('rate'),
  mixins: [componentMixin],
  model: {
    name: 'value',
    event: 'change'
  },
  props: {
    value: {
      type: Number,
      default: 0
    },
    maxValue: {
      type: Number,
      default: 5
    },
    tips: {
      type: Array,

      default() {
        return ['非常不满意', '不满意', '一般', '满意', '非常满意'];
      }

    }
  },

  data() {
    return {
      hover: false,
      hoverValue: 0
    };
  },

  computed: {
    innerValue() {
      if (this.hover) {
        return this.hoverValue;
      }

      return this.value;
    }

  },
  methods: {
    mouseenter(e) {
      this.hover = true;
      this.hoverValue = +e.target.getAttribute('data-value');
    },

    mouseleave() {
      this.hover = false;
      this.hoverValue = 0;
    },

    click(value) {
      this.mouseleave();
      this.$emit('change', value);
    }

  }
};
/* template */

var __vue_render__ = function () {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c("div", {
    class: _vm.bem({
      hover: _vm.hover
    })
  }, [_vm._l(_vm.maxValue, function (i) {
    return _c("div", {
      key: i,
      class: _vm.bem("star-wrapper"),
      attrs: {
        "data-value": i
      },
      on: {
        mouseenter: _vm.mouseenter,
        mouseleave: _vm.mouseleave,
        click: function ($event) {
          _vm.click(i);
        }
      }
    }, [_c("i", {
      class: _vm.bem("star")
    }), _vm._v(" "), _c("transition", {
      attrs: {
        name: "gd-fade"
      }
    }, [_c("i", {
      directives: [{
        name: "show",
        rawName: "v-show",
        value: i <= _vm.innerValue,
        expression: "i <= innerValue"
      }],
      class: _vm.bem("star", ["active"])
    })]), _vm._v(" "), _c("transition", {
      attrs: {
        name: "gd-fade"
      }
    }, [_c("i", {
      directives: [{
        name: "show",
        rawName: "v-show",
        value: i <= _vm.innerValue && _vm.hover,
        expression: "(i <= innerValue) && hover"
      }],
      class: _vm.bem("star", ["hover"])
    })])], 1);
  }), _vm._v(" "), _vm.innerValue ? _c("div", {
    class: _vm.bem("tip")
  }, [_vm._v(_vm._s(_vm.tips[_vm.innerValue - 1]))]) : _vm._e()], 2);
};

var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */

const __vue_inject_styles__ = undefined;
/* scoped */

const __vue_scope_id__ = undefined;
/* module identifier */

const __vue_module_identifier__ = undefined;
/* functional template */

const __vue_is_functional_template__ = false;
/* component normalizer */

import __vue_normalize__ from '../_utils/vue-normalize-component.js';
/* style inject */

/* style inject SSR */

export default __vue_normalize__({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);