添加新文件

This commit is contained in:
hejiangming
2025-05-07 10:09:55 +08:00
parent 007b002b81
commit 7e7a096151
776 changed files with 92603 additions and 0 deletions
@@ -0,0 +1,74 @@
"use strict";
const uni_modules_uviewPlus_libs_vue = require("../../libs/vue.js");
const uni_modules_uviewPlus_libs_config_props = require("../../libs/config/props.js");
const props = uni_modules_uviewPlus_libs_vue.defineMixin({
props: {
// 用于v-model双向绑定选中的星星数量
modelValue: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.value
},
// 要显示的星星数量
count: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.count
},
// 是否不可选中
disabled: {
type: Boolean,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.disabled
},
// 是否只读
readonly: {
type: Boolean,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.readonly
},
// 星星的大小,单位px
size: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.size
},
// 未选中时的颜色
inactiveColor: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.inactiveColor
},
// 选中的颜色
activeColor: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.activeColor
},
// 星星之间的间距,单位px
gutter: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.gutter
},
// 最少能选择的星星个数
minCount: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.minCount
},
// 是否允许半星
allowHalf: {
type: Boolean,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.allowHalf
},
// 选中时的图标(星星)
activeIcon: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.activeIcon
},
// 未选中时的图标(星星)
inactiveIcon: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.inactiveIcon
},
// 是否可以通过滑动手势选择评分
touchable: {
type: Boolean,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.rate.touchable
}
}
});
exports.props = props;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-plus/components/u-rate/props.js.map
@@ -0,0 +1,180 @@
"use strict";
const uni_modules_uviewPlus_components_uRate_props = require("./props.js");
const uni_modules_uviewPlus_libs_mixin_mpMixin = require("../../libs/mixin/mpMixin.js");
const uni_modules_uviewPlus_libs_mixin_mixin = require("../../libs/mixin/mixin.js");
const uni_modules_uviewPlus_libs_function_index = require("../../libs/function/index.js");
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "u-rate",
mixins: [uni_modules_uviewPlus_libs_mixin_mpMixin.mpMixin, uni_modules_uviewPlus_libs_mixin_mixin.mixin, uni_modules_uviewPlus_components_uRate_props.props],
data() {
return {
// 生成一个唯一id,否则一个页面多个评分组件,会造成冲突
elId: uni_modules_uviewPlus_libs_function_index.guid(),
elClass: uni_modules_uviewPlus_libs_function_index.guid(),
rateBoxLeft: 0,
// 评分盒子左边到屏幕左边的距离,用于滑动选择时计算距离
activeIndex: this.modelValue,
rateWidth: 0,
// 每个星星的宽度
// 标识是否正在滑动,由于iOS事件上touch比click先触发,导致快速滑动结束后,接着触发click,导致事件混乱而出错
moving: false
};
},
watch: {
modelValue(val) {
this.activeIndex = val;
},
activeIndex: "emitEvent"
},
emits: ["update:modelValue", "change"],
methods: {
addStyle: uni_modules_uviewPlus_libs_function_index.addStyle,
addUnit: uni_modules_uviewPlus_libs_function_index.addUnit,
init() {
uni_modules_uviewPlus_libs_function_index.sleep().then(() => {
this.getRateItemRect();
this.getRateIconWrapRect();
});
},
// 获取评分组件盒子的布局信息
async getRateItemRect() {
await uni_modules_uviewPlus_libs_function_index.sleep();
this.$uGetRect("#" + this.elId).then((res) => {
this.rateBoxLeft = res.left;
});
},
// 获取单个星星的尺寸
getRateIconWrapRect() {
this.$uGetRect("." + this.elClass).then((res) => {
this.rateWidth = res.width;
});
},
// 手指滑动
touchMove(e) {
if (!this.touchable) {
return;
}
this.preventEvent(e);
const x = e.changedTouches[0].pageX;
this.getActiveIndex(x);
},
// 停止滑动
touchEnd(e) {
if (!this.touchable) {
return;
}
this.preventEvent(e);
const x = e.changedTouches[0].pageX;
this.getActiveIndex(x);
},
// 通过点击,直接选中
clickHandler(e, index) {
if (uni_modules_uviewPlus_libs_function_index.os() === "ios" && this.moving) {
return;
}
this.preventEvent(e);
let x = 0;
x = e.changedTouches[0].pageX;
this.getActiveIndex(x, true);
},
// 发出事件
emitEvent() {
this.$emit("change", this.activeIndex);
this.$emit("update:modelValue", this.activeIndex);
},
// 获取当前激活的评分图标
getActiveIndex(x, isClick = false) {
if (this.disabled || this.readonly) {
return;
}
const allRateWidth = this.rateWidth * this.count + this.rateBoxLeft;
x = uni_modules_uviewPlus_libs_function_index.range(this.rateBoxLeft, allRateWidth, x) - this.rateBoxLeft;
const distance = x;
let index;
if (this.allowHalf) {
index = Math.floor(distance / this.rateWidth);
const decimal = distance % this.rateWidth;
if (decimal <= this.rateWidth / 2 && decimal > 0) {
index += 0.5;
} else if (decimal > this.rateWidth / 2) {
index++;
}
} else {
index = Math.floor(distance / this.rateWidth);
const decimal = distance % this.rateWidth;
if (isClick) {
if (decimal > 0)
index++;
} else {
if (decimal > this.rateWidth / 2)
index++;
}
}
this.activeIndex = Math.min(index, this.count);
if (this.activeIndex < this.minCount) {
this.activeIndex = this.minCount;
}
setTimeout(() => {
this.moving = true;
}, 10);
setTimeout(() => {
this.moving = false;
}, 10);
}
},
mounted() {
this.init();
}
};
if (!Array) {
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
_easycom_u_icon2();
}
const _easycom_u_icon = () => "../u-icon/u-icon.js";
if (!Math) {
_easycom_u_icon();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.f(Number(_ctx.count), (item, index, i0) => {
return common_vendor.e({
a: "69a384ee-0-" + i0,
b: common_vendor.p({
name: Math.floor($data.activeIndex) > index ? _ctx.activeIcon : _ctx.inactiveIcon,
color: _ctx.disabled ? "#c8c9cc" : Math.floor($data.activeIndex) > index ? _ctx.activeColor : _ctx.inactiveColor,
["custom-style"]: {
padding: `0 ${$options.addUnit(_ctx.gutter / 2)}`
},
size: _ctx.size
}),
c: common_vendor.o(($event) => $options.clickHandler($event, index + 1), index)
}, _ctx.allowHalf ? {
d: "69a384ee-1-" + i0,
e: common_vendor.p({
name: Math.ceil($data.activeIndex) > index ? _ctx.activeIcon : _ctx.inactiveIcon,
color: _ctx.disabled ? "#c8c9cc" : Math.ceil($data.activeIndex) > index ? _ctx.activeColor : _ctx.inactiveColor,
["custom-style"]: {
padding: `0 ${$options.addUnit(_ctx.gutter / 2)}`
},
size: _ctx.size
}),
f: common_vendor.o(($event) => $options.clickHandler($event, index + 1), index),
g: common_vendor.s({
width: $options.addUnit($data.rateWidth / 2)
})
} : {}, {
h: index
});
}),
b: _ctx.allowHalf,
c: common_vendor.n($data.elClass),
d: common_vendor.o((...args) => $options.touchMove && $options.touchMove(...args)),
e: common_vendor.o((...args) => $options.touchEnd && $options.touchEnd(...args)),
f: $data.elId,
g: common_vendor.s($options.addStyle(_ctx.customStyle))
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-69a384ee"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-plus/components/u-rate/u-rate.js.map
@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"u-icon": "../u-icon/u-icon"
}
}
@@ -0,0 +1 @@
<view class="u-rate data-v-69a384ee" id="{{f}}" ref="u-rate" style="{{g}}"><view class="u-rate__content data-v-69a384ee" catchtouchmove="{{d}}" catchtouchend="{{e}}"><view wx:for="{{a}}" wx:for-item="item" wx:key="h" class="{{['u-rate__content__item', 'cursor-pointer', 'data-v-69a384ee', c]}}"><view class="u-rate__content__item__icon-wrap data-v-69a384ee" ref="u-rate__content__item__icon-wrap" catchtap="{{item.c}}"><u-icon wx:if="{{item.b}}" class="data-v-69a384ee" u-i="{{item.a}}" bind:__l="__l" u-p="{{item.b}}"></u-icon></view><view wx:if="{{b}}" catchtap="{{item.f}}" class="u-rate__content__item__icon-wrap u-rate__content__item__icon-wrap--half data-v-69a384ee" style="{{item.g}}" ref="u-rate__content__item__icon-wrap"><u-icon wx:if="{{item.e}}" class="data-v-69a384ee" u-i="{{item.d}}" bind:__l="__l" u-p="{{item.e}}"></u-icon></view></view></view></view>
@@ -0,0 +1,72 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/* uni.scss */
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
.u-empty.data-v-69a384ee,
.u-empty__wrap.data-v-69a384ee,
.u-tabs.data-v-69a384ee,
.u-tabs__wrapper.data-v-69a384ee,
.u-tabs__wrapper__scroll-view-wrapper.data-v-69a384ee,
.u-tabs__wrapper__scroll-view.data-v-69a384ee,
.u-tabs__wrapper__nav.data-v-69a384ee,
.u-tabs__wrapper__nav__line.data-v-69a384ee,
.up-empty.data-v-69a384ee,
.up-empty__wrap.data-v-69a384ee,
.up-tabs.data-v-69a384ee,
.up-tabs__wrapper.data-v-69a384ee,
.up-tabs__wrapper__scroll-view-wrapper.data-v-69a384ee,
.up-tabs__wrapper__scroll-view.data-v-69a384ee,
.up-tabs__wrapper__nav.data-v-69a384ee,
.up-tabs__wrapper__nav__line.data-v-69a384ee {
display: flex;
flex-direction: column;
flex-shrink: 0;
flex-grow: 0;
flex-basis: auto;
align-items: stretch;
align-content: flex-start;
}
.u-rate.data-v-69a384ee {
display: flex;
flex-direction: row;
align-items: center;
margin: 0;
padding: 0;
touch-action: none;
}
.u-rate__content.data-v-69a384ee {
display: flex;
flex-direction: row;
}
.u-rate__content__item.data-v-69a384ee {
position: relative;
}
.u-rate__content__item__icon-wrap--half.data-v-69a384ee {
position: absolute;
overflow: hidden;
top: 0;
left: 0;
}
.u-icon.data-v-69a384ee {
box-sizing: border-box;
}