智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1 lines
4.4 KiB

import{_ as t}from"./u-icon.d58f766c.js";import{a4 as e,a5 as a,a6 as i,az as o,a8 as n,a7 as s,aA as c,aB as r,aC as l,g as d,i as u,o as h,c as m,w as v,b as f,B as _,Q as p,R as g,a3 as I,S as y,n as x,f as C,j as b,ao as w}from"./index-ed377420.js";import{_ as S}from"./_plugin-vue_export-helper.1b428a4d.js";const W=S({name:"u-rate",mixins:[a,i,{props:{modelValue:{type:[String,Number],default:()=>e.rate.value},count:{type:[String,Number],default:()=>e.rate.count},disabled:{type:Boolean,default:()=>e.rate.disabled},readonly:{type:Boolean,default:()=>e.rate.readonly},size:{type:[String,Number],default:()=>e.rate.size},inactiveColor:{type:String,default:()=>e.rate.inactiveColor},activeColor:{type:String,default:()=>e.rate.activeColor},gutter:{type:[String,Number],default:()=>e.rate.gutter},minCount:{type:[String,Number],default:()=>e.rate.minCount},allowHalf:{type:Boolean,default:()=>e.rate.allowHalf},activeIcon:{type:String,default:()=>e.rate.activeIcon},inactiveIcon:{type:String,default:()=>e.rate.inactiveIcon},touchable:{type:Boolean,default:()=>e.rate.touchable}}}],data(){return{elId:o(),elClass:o(),rateBoxLeft:0,activeIndex:this.modelValue,rateWidth:0,moving:!1}},watch:{modelValue(t){this.activeIndex=t},activeIndex:"emitEvent"},emits:["update:modelValue","change"],methods:{addStyle:n,addUnit:s,init(){c().then((()=>{this.getRateItemRect(),this.getRateIconWrapRect()}))},async getRateItemRect(){await c(),this.$uGetRect("#"+this.elId).then((t=>{this.rateBoxLeft=t.left}))},getRateIconWrapRect(){this.$uGetRect("."+this.elClass).then((t=>{this.rateWidth=t.width}))},touchMove(t){if(!this.touchable)return;this.preventEvent(t);const e=t.changedTouches[0].pageX;this.getActiveIndex(e)},touchEnd(t){if(!this.touchable)return;this.preventEvent(t);const e=t.changedTouches[0].pageX;this.getActiveIndex(e)},clickHandler(t,e){if("ios"===r()&&this.moving)return;this.preventEvent(t);let a=0;a=t.changedTouches[0].pageX,this.getActiveIndex(a,!0)},emitEvent(){this.$emit("change",this.activeIndex),this.$emit("update:modelValue",this.activeIndex)},getActiveIndex(t,e=!1){if(this.disabled||this.readonly)return;const a=this.rateWidth*this.count+this.rateBoxLeft,i=t=l(this.rateBoxLeft,a,t)-this.rateBoxLeft;let o;if(this.allowHalf){o=Math.floor(i/this.rateWidth);const t=i%this.rateWidth;t<=this.rateWidth/2&&t>0?o+=.5:t>this.rateWidth/2&&o++}else{o=Math.floor(i/this.rateWidth);const t=i%this.rateWidth;e?t>0&&o++:t>this.rateWidth/2&&o++}this.activeIndex=Math.min(o,this.count),this.activeIndex<this.minCount&&(this.activeIndex=this.minCount),setTimeout((()=>{this.moving=!0}),10),setTimeout((()=>{this.moving=!1}),10)}},mounted(){this.init()}},[["render",function(e,a,i,o,n,s){const c=d(u("u-icon"),t),r=b;return h(),m(r,{class:"u-rate",id:n.elId,ref:"u-rate",style:x([s.addStyle(e.customStyle)])},{default:v((()=>[f(r,{class:"u-rate__content",onTouchmove:_(s.touchMove,["stop"]),onTouchend:_(s.touchEnd,["stop"])},{default:v((()=>[(h(!0),p(g,null,I(Number(e.count),((t,a)=>(h(),m(r,{class:y(["u-rate__content__item cursor-pointer",[n.elClass]]),key:a},{default:v((()=>[f(r,{class:"u-rate__content__item__icon-wrap",ref_for:!0,ref:"u-rate__content__item__icon-wrap",onClick:_((t=>s.clickHandler(t,a+1)),["stop"])},{default:v((()=>[f(c,{name:Math.floor(n.activeIndex)>a?e.activeIcon:e.inactiveIcon,color:e.disabled?"#c8c9cc":Math.floor(n.activeIndex)>a?e.activeColor:e.inactiveColor,"custom-style":{padding:`0 ${s.addUnit(e.gutter/2)}`},size:e.size},null,8,["name","color","custom-style","size"])])),_:2},1032,["onClick"]),e.allowHalf?(h(),m(r,{key:0,onClick:_((t=>s.clickHandler(t,a+1)),["stop"]),class:"u-rate__content__item__icon-wrap u-rate__content__item__icon-wrap--half",style:x([{width:s.addUnit(n.rateWidth/2)}]),ref_for:!0,ref:"u-rate__content__item__icon-wrap"},{default:v((()=>[f(c,{name:Math.ceil(n.activeIndex)>a?e.activeIcon:e.inactiveIcon,color:e.disabled?"#c8c9cc":Math.ceil(n.activeIndex)>a?e.activeColor:e.inactiveColor,"custom-style":{padding:`0 ${s.addUnit(e.gutter/2)}`},size:e.size},null,8,["name","color","custom-style","size"])])),_:2},1032,["onClick","style"])):C("v-if",!0)])),_:2},1032,["class"])))),128))])),_:1},8,["onTouchmove","onTouchend"])])),_:1},8,["id","style"])}],["__scopeId","data-v-2d03dda9"]]);function B(t){return w.get("shop/goods/evaluate",t)}function R(t){return w.post("shop/goods/evaluate",t,{showSuccessMessage:!0})}function M(t){return w.get(`shop/order/evaluate/${t}`)}export{W as _,M as a,B as g,R as s};