| New file |
| | |
| | | <template>
|
| | | <view class="content">
|
| | | <uni-card :is-shadow="false" is-full>
|
| | | <text class="uni-h6">æ
é䏿¥åï¼å®å人åä¼ç¬¬ä¸æ¶é´æ¶å°éç¥å¹¶è§£å³æ
éã请填åçå®æè¿°åå
¶ä»ä¿¡æ¯ï¼æ¹ä¾¿ç¸å
³åç»æ¹æ¡ã ââââ 䏿¬ç«åº</text>
|
| | | </uni-card>
|
| | | <view class="uni-common-mt">
|
| | | <form>
|
| | | <view class="uni-list">
|
| | | <!-- æå±é¡¹ç® -->
|
| | | <view class="uni-list-cell">
|
| | | <view class="uni-list-cell-left">
|
| | | <view class="uni-label redDot">æå±é¡¹ç®</view>
|
| | | </view>
|
| | | <view class="uni-list-cell-right">
|
| | | <picker :range="host" @change="hostChange" :value="hostIndex" mode="selector">
|
| | | <view class="uni-input">{{host[hostIndex]}}</view>
|
| | | </picker>
|
| | | </view>
|
| | | </view>
|
| | | <!-- æ
éç±»å -->
|
| | | <view class="uni-list-cell">
|
| | | <view class="uni-list-cell-left">
|
| | | <view class="uni-label redDot">æ
éç±»å</view>
|
| | | </view>
|
| | | <view class="uni-list-cell-right">
|
| | | <picker :range="issueType" @change="issueTypeChange" :value="issueTypeIndex" mode="selector">
|
| | | <view class="uni-input">{{issueType[issueTypeIndex]}}</view>
|
| | | </picker>
|
| | | </view>
|
| | | </view>
|
| | | <!-- è系人 -->
|
| | | <view class="uni-list-cell">
|
| | | <view class="uni-list-cell-left">
|
| | | <view class="uni-label">è系人</view>
|
| | | </view>
|
| | | <view class="uni-list-cell-right">
|
| | | <input class="uni-input" v-model="discoverer" placeholder="请è¾å
¥" />
|
| | | </view>
|
| | | </view>
|
| | | <!-- èç³»æ¹å¼ -->
|
| | | <view class="uni-list-cell">
|
| | | <view class="uni-list-cell-left">
|
| | | <view class="uni-label redDot">èç³»æ¹å¼</view>
|
| | | </view>
|
| | | <view class="uni-list-cell-right">
|
| | | <input class="uni-input" v-model="tel" placeholder="请è¾å
¥" />
|
| | | </view>
|
| | | </view>
|
| | | <!-- åçæ¥æ -->
|
| | | <view class="uni-list-cell">
|
| | | <view class="uni-list-cell-left">
|
| | | <view class="uni-label redDot">åçæ¥æ</view>
|
| | | </view>
|
| | | <view class="uni-list-cell-right">
|
| | | <picker mode="date" :value="startTime" @change="bindDateChange">
|
| | | <view class="uni-input">{{startTime}}</view>
|
| | | </picker>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | | <view class="uni-list" style="margin-top: 15rpx;">
|
| | | <view class="uni-title uni-common-pl redDot" style="padding: 20rpx 30rpx 10rpx 30rpx;">é®é¢æ¦è¿°</view>
|
| | | <view class="uni-textarea">
|
| | | <textarea placeholder="请è¾å
¥å
·ä½æè¿°..." v-model="title" style="text-indent:15rpx;"/>
|
| | | </view>
|
| | | </view>
|
| | | <view class="uni-list" style="margin-top: 15rpx;">
|
| | | <view class="uni-list-cell cell-pd">
|
| | | <view class="uni-uploader">
|
| | | <view class="uni-uploader-head">
|
| | | <view class="uni-uploader-title">ç¸å
³å¾çä¸ä¼ </view>
|
| | | <view class="uni-uploader-info">{{imageList.length}}/9</view>
|
| | | </view>
|
| | | <view class="uni-uploader-body">
|
| | | <view class="uni-uploader__files">
|
| | | <block v-for="(image,index) in imageList" :key="index">
|
| | | <view class="uni-uploader__file">
|
| | | <image class="uni-uploader__img" :src="image" :data-src="image" @tap="previewImage"></image>
|
| | | </view>
|
| | | </block>
|
| | | <view class="uni-uploader__input-box">
|
| | | <view class="uni-uploader__input" @tap="chooseImage"></view>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | | <view style="margin-top: 15rpx;">
|
| | | <template v-if="!videoSrc">
|
| | | <view class="uni-hello-addfile" @tap="chooseVideo">+ æ·»å è§é¢</view>
|
| | | </template>
|
| | | <template v-else>
|
| | | <video :src="videoSrc" class="video"></video>
|
| | | </template>
|
| | | </view>
|
| | | |
| | | <view class="uni-padding-wrap uni-common-mt" style="margin-bottom: 30rpx;">
|
| | | <button type="primary" @click="save">确认æäº¤</button>
|
| | | </view>
|
| | | </form>
|
| | | </view>
|
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import permision from "@/common/permission.js"
|
| | | import uniPopup from '@/components/uni-popup/uni-popup.vue'
|
| | | var util = require('../../common/util.js');
|
| | | |
| | | var formatLocation = util.formatLocation;
|
| | | var sourceType = [
|
| | | ['camera'],
|
| | | ['album'],
|
| | | ['camera', 'album']
|
| | | ]
|
| | | var sizeType = [
|
| | | ['compressed'],
|
| | | ['original'],
|
| | | ['compressed', 'original']
|
| | | ]
|
| | | function getParam(path, name) {
|
| | | Â Â Â Â var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
|
| | | Â Â Â Â if (reg.test(path))
|
| | | Â Â Â Â return unescape(RegExp.$2.replace(/\+/g, " "));
|
| | | Â Â Â Â return "";
|
| | | Â Â }
|
| | | function getDate(type) {
|
| | | const date = new Date();
|
| | |
|
| | | let year = date.getFullYear();
|
| | | let month = date.getMonth() + 1;
|
| | | let day = date.getDate();
|
| | |
|
| | | if (type === 'start') {
|
| | | year = year - 10;
|
| | | } else if (type === 'end') {
|
| | | year = year + 10;
|
| | | }
|
| | | month = month > 9 ? month : '0' + month;;
|
| | | day = day > 9 ? day : '0' + day;
|
| | |
|
| | | return `${year}-${month}-${day}`;
|
| | | }
|
| | | function isEmpty(obj){
|
| | | return typeof obj == "undefined" || obj == null || obj === "";
|
| | | }
|
| | | export default {
|
| | | components: {
|
| | | uniPopup
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | // è¡¨åæ°æ®
|
| | | title: null,
|
| | | tel: null,
|
| | | discoverer: null,
|
| | | startTime: getDate({
|
| | | format: true
|
| | | }),
|
| | | desc: null,
|
| | | memo: null,
|
| | | imageList: [],
|
| | | imageFileList: [],
|
| | | hostIndex: 0,
|
| | | host: ["è¯·éæ©é¡¹ç®"],
|
| | | issueTypeIndex: 0,
|
| | | issueType: ["è¯·éæ©ç±»å"],
|
| | | sourceTypeIndex: 2,
|
| | | sourceType: ['æç
§', 'ç¸å', 'æç
§æç¸å'],
|
| | | countIndex: 8,
|
| | | count: [1, 2, 3, 4, 5, 6, 7, 8, 9],
|
| | | hasLocation: false,
|
| | | location: {},
|
| | | locationAddress: '',
|
| | | type: '',
|
| | | videoSrc: ''
|
| | | }
|
| | | },
|
| | | onLoad() {
|
| | | this.initHost();
|
| | | this.initIssueType();
|
| | | },
|
| | | methods: {
|
| | | // åå§å项ç®å表
|
| | | initHost: function() {
|
| | | uni.request({
|
| | | url: this.baseUrl + '/app/host/list/auth',
|
| | | data: {
|
| | | },
|
| | | header: {
|
| | | "token": uni.getStorageSync('token')
|
| | | },
|
| | | success: (result) => {
|
| | | let res = result.data;
|
| | | if (res.code == 200) {
|
| | | for (let item of res.data) {
|
| | | this.host.push(item.name);
|
| | | }
|
| | | } else if (res.code == 403) {
|
| | | uni.showToast({title: res.msg, icon: "none",position: 'top'})
|
| | | setTimeout(() => {
|
| | | uni.reLaunch({
|
| | | url: '../login/login'
|
| | | });
|
| | | }, 500);
|
| | | } else {
|
| | | uni.showToast({title: res.msg,icon: "none",position: 'top'})
|
| | | }
|
| | | }
|
| | | });
|
| | | },
|
| | | // åå§åæ
éç±»å
|
| | | initIssueType: function() {
|
| | | uni.request({
|
| | | url: this.baseUrl + '/app/issue/type/auth',
|
| | | data: {
|
| | | },
|
| | | header: {
|
| | | // "token": uni.getStorageSync('token')
|
| | | },
|
| | | success: (result) => {
|
| | | let res = result.data;
|
| | | if (res.code == 200) {
|
| | | for (let item of res.data) {
|
| | | this.issueType.push(item.name);
|
| | | }
|
| | | } else if (res.code == 403) {
|
| | | uni.showToast({title: res.msg, icon: "none",position: 'top'})
|
| | | setTimeout(() => {
|
| | | uni.reLaunch({
|
| | | url: '../login/login'
|
| | | });
|
| | | }, 500);
|
| | | } else {
|
| | | uni.showToast({title: res.msg,icon: "none",position: 'top'})
|
| | | }
|
| | | }
|
| | | });
|
| | | },
|
| | | // ä¿åæäº¤
|
| | | save: function() {
|
| | | let that = this;
|
| | | if (that.hostIndex === 0) {
|
| | | uni.showToast({title: "è¯·éæ©æå±é¡¹ç®",icon: "none",position: 'top'})
|
| | | return;
|
| | | }
|
| | | let hostName = that.host[that.hostIndex];
|
| | | if (that.issueTypeIndex === 0) {
|
| | | uni.showToast({title: "è¯·éæ©æ
éç±»å",icon: "none",position: 'top'})
|
| | | return;
|
| | | }
|
| | | let issueTypeName = that.issueType[that.issueTypeIndex];
|
| | | if (isEmpty(that.tel)) {
|
| | | uni.showToast({title: "请è¾å
¥èç³»æ¹å¼",icon: "none",position: 'top'})
|
| | | return;
|
| | | }
|
| | | if (isEmpty(that.title)) {
|
| | | uni.showToast({title: "请è¾å
¥é®é¢æ¦è¿°",icon: "none",position: 'top'})
|
| | | return;
|
| | | }
|
| | | uni.showLoading();
|
| | | uni.request({
|
| | | url: that.baseUrl + '/app/issue/save/auth',
|
| | | data: {
|
| | | hostName: hostName,
|
| | | issueTypeName: issueTypeName,
|
| | | discoverer: that.discoverer,
|
| | | tel: that.tel,
|
| | | startTime: that.startTime,
|
| | | title: that.title,
|
| | | imgArr: that.imageList,
|
| | | memo: that.memo,
|
| | | videoSrc: [that.videoSrc]
|
| | | },
|
| | | header: {
|
| | | "token": uni.getStorageSync('token')
|
| | | },
|
| | | success: (result) => {
|
| | | uni.hideLoading();
|
| | | let res = result.data;
|
| | | if (res.code == 200) {
|
| | | uni.showToast({title: res.msg,position: 'top'})
|
| | | that.hostIndex = 0;
|
| | | that.issueTypeIndex = 0;
|
| | | that.discoverer = null;
|
| | | that.tel = null;
|
| | | that.title = null;
|
| | | that.memo = null;
|
| | | that.imageList = [];
|
| | | that.imageFileList = [];
|
| | | that.startTime = getDate({
|
| | | format: true
|
| | | });
|
| | | that.videoSrc = null;
|
| | | } else if (res.code == 403) {
|
| | | uni.showToast({title: res.msg, icon: "none", position: 'top'})
|
| | | setTimeout(() => {
|
| | | uni.reLaunch({
|
| | | url: '../login/login'
|
| | | });
|
| | | }, 500);
|
| | | } else {
|
| | | uni.showToast({title: res.msg,icon: "none",position: 'top'})
|
| | | }
|
| | | }
|
| | | });
|
| | | },
|
| | | chooseLocation: function () {
|
| | | uni.chooseLocation({
|
| | | success: (res) => {
|
| | | this.hasLocation = true,
|
| | | this.location = formatLocation(res.longitude, res.latitude),
|
| | | this.locationAddress = res.address
|
| | | }
|
| | | })
|
| | | },
|
| | | issueTypeChange: function(e) {
|
| | | this.issueTypeIndex = parseInt(e.detail.value);
|
| | | },
|
| | | hostChange: function(e) {
|
| | | this.hostIndex = parseInt(e.detail.value);
|
| | | },
|
| | | sumbit: function(e){
|
| | | uni.showToast({title: "ok",icon: "none",position: 'top'})
|
| | | },
|
| | | bindPickerChange: function(e) {
|
| | | this.index = e.detail.value
|
| | | },
|
| | | bindDateChange: function(e) {
|
| | | this.startTime = e.detail.value
|
| | | },
|
| | | chooseImage: async function() {
|
| | | // #ifdef APP-PLUS
|
| | | // TODO éæ©ç¸æºæç¸åæ¶ éè¦å¼¹åºactionsheetï¼ç®åæ æ³è·å¾æ¯ç¸æºè¿æ¯ç¸åï¼å¨å¤±è´¥åè°ä¸å¤ç
|
| | | if (this.sourceTypeIndex !== 2) {
|
| | | let status = await this.checkPermission();
|
| | | if (status !== 1) {
|
| | | return;
|
| | | }
|
| | | }
|
| | | // #endif
|
| | | |
| | | if (this.imageList.length === 9) {
|
| | | let isContinue = await this.isFullImg();
|
| | | if (!isContinue) {
|
| | | return;
|
| | | }
|
| | | }
|
| | | uni.chooseImage({
|
| | | sourceType: sourceType[this.sourceTypeIndex],
|
| | | sizeType: sizeType[this.sizeTypeIndex],
|
| | | count: this.imageList.length + this.count[this.countIndex] > 9 ? 9 - this.imageList.length : this.count[this.countIndex],
|
| | | success: (res) => {
|
| | | let that = this;
|
| | | uni.showLoading();
|
| | | for (var filePath of res.tempFilePaths) {
|
| | | uni.uploadFile({
|
| | | url : that.baseUrl + '/upload.action',
|
| | | filePath: filePath,
|
| | | name: 'file',
|
| | | success: function (result) {
|
| | | var result0 = JSON.parse(result.data);
|
| | | if(result0.code === 200) {
|
| | | that.imageList = that.imageList.concat(result0.data.url);
|
| | | } else {
|
| | | uni.showToast({title: result0.msg,icon: "none",position: 'top'})
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | uni.hideLoading();
|
| | | uni.showToast({title: "ç
§çä¸ä¼ æåï¼è¯·èå¿çå¾
...",icon: "none",position: 'top'})
|
| | | that.imageFileList = that.imageFileList.concat(res.tempFiles);
|
| | | // this.imageList = this.imageList.concat(res.tempFilePaths);
|
| | | },
|
| | | fail: (err) => {
|
| | | // #ifdef APP-PLUS
|
| | | if (err['code'] && err.code !== 0 && this.sourceTypeIndex === 2) {
|
| | | this.checkPermission(err.code);
|
| | | }
|
| | | // #endif
|
| | | // #ifdef MP
|
| | | if(err.errMsg.indexOf('cancel') !== '-1'){
|
| | | return;
|
| | | }
|
| | | uni.getSetting({
|
| | | success: (res) => {
|
| | | let authStatus = false;
|
| | | switch (this.sourceTypeIndex) {
|
| | | case 0:
|
| | | authStatus = res.authSetting['scope.camera'];
|
| | | break;
|
| | | case 1:
|
| | | authStatus = res.authSetting['scope.album'];
|
| | | break;
|
| | | case 2:
|
| | | authStatus = res.authSetting['scope.album'] && res.authSetting['scope.camera'];
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | if (!authStatus) {
|
| | | uni.showModal({
|
| | | title: 'ææå¤±è´¥',
|
| | | content: 'Hello uni-appéè¦ä»æ¨çç¸æºæç¸åè·åå¾çï¼è¯·å¨è®¾ç½®ç颿å¼ç¸å
³æé',
|
| | | success: (res) => {
|
| | | if (res.confirm) {
|
| | | uni.openSetting()
|
| | | }
|
| | | }
|
| | | })
|
| | | }
|
| | | }
|
| | | })
|
| | | // #endif
|
| | | }
|
| | | })
|
| | | },
|
| | | isFullImg: function() {
|
| | | return new Promise((res) => {
|
| | | uni.showModal({
|
| | | content: "å·²ç»æ9å¼ å¾çäº,æ¯å¦æ¸
ç©ºç°æå¾çï¼",
|
| | | success: (e) => {
|
| | | if (e.confirm) {
|
| | | this.imageList = [];
|
| | | this.imageFileList = [];
|
| | | res(true);
|
| | | } else {
|
| | | res(false)
|
| | | }
|
| | | },
|
| | | fail: () => {
|
| | | res(false)
|
| | | }
|
| | | })
|
| | | })
|
| | | },
|
| | | previewImage: function(e) {
|
| | | var current = e.target.dataset.src
|
| | | uni.previewImage({
|
| | | current: current,
|
| | | urls: this.imageList
|
| | | })
|
| | | },
|
| | | async checkPermission(code) {
|
| | | let type = code ? code - 1 : this.sourceTypeIndex;
|
| | | let status = permision.isIOS ? await permision.requestIOS(sourceType[type][0]) :
|
| | | await permision.requestAndroid(type === 0 ? 'android.permission.CAMERA' :
|
| | | 'android.permission.READ_EXTERNAL_STORAGE');
|
| | | |
| | | if (status === null || status === 1) {
|
| | | status = 1;
|
| | | } else {
|
| | | uni.showModal({
|
| | | content: "没æå¼å¯æé",
|
| | | confirmText: "设置",
|
| | | success: function(res) {
|
| | | if (res.confirm) {
|
| | | permision.gotoAppSetting();
|
| | | }
|
| | | }
|
| | | })
|
| | | }
|
| | | |
| | | return status;
|
| | | }
|
| | | ,
|
| | | // å®ä½
|
| | | togglePopup(type) {
|
| | | this.type = type;
|
| | | },
|
| | | showConfirm() {
|
| | | this.type = 'showpopup';
|
| | | },
|
| | | hideConfirm() {
|
| | | this.type = '';
|
| | | },
|
| | | async getLocation() {
|
| | | // #ifdef APP-PLUS
|
| | | let status = await this.checkPermission();
|
| | | if (status !== 1) {
|
| | | return;
|
| | | }
|
| | | // #endif
|
| | | // #ifdef MP-WEIXIN || MP-TOUTIAO || MP-QQ
|
| | | let status = await this.getSetting();
|
| | | if (status === 2) {
|
| | | this.showConfirm();
|
| | | return;
|
| | | }
|
| | | // #endif
|
| | | |
| | | this.doGetLocation();
|
| | | },
|
| | | doGetLocation() {
|
| | | uni.getLocation({
|
| | | success: (res) => {
|
| | | this.hasLocation = true;
|
| | | this.location = formatLocation(res.longitude, res.latitude);
|
| | | },
|
| | | fail: (err) => {
|
| | | // #ifdef MP-BAIDU
|
| | | if (err.errCode === 202 || err.errCode === 10003) { // 202模æå¨ 10003çæº user deny
|
| | | this.showConfirm();
|
| | | }
|
| | | // #endif
|
| | | // #ifndef MP-BAIDU
|
| | | if (err.errMsg.indexOf("auth deny") >= 0) {
|
| | | uni.showToast({
|
| | | title: "访é®ä½ç½®è¢«æç»"
|
| | | })
|
| | | } else {
|
| | | uni.showToast({
|
| | | title: err.errMsg
|
| | | })
|
| | | }
|
| | | // #endif
|
| | | }
|
| | | })
|
| | | },
|
| | | getSetting: function() {
|
| | | return new Promise((resolve, reject) => {
|
| | | uni.getSetting({
|
| | | success: (res) => {
|
| | | if (res.authSetting['scope.userLocation'] === undefined) {
|
| | | resolve(0);
|
| | | return;
|
| | | }
|
| | | if (res.authSetting['scope.userLocation']) {
|
| | | resolve(1);
|
| | | } else {
|
| | | resolve(2);
|
| | | }
|
| | | }
|
| | | });
|
| | | });
|
| | | },
|
| | | openSetting: function() {
|
| | | this.hideConfirm();
|
| | | uni.openSetting({
|
| | | success: (res) => {
|
| | | if (res.authSetting && res.authSetting['scope.userLocation']) {
|
| | | this.doGetLocation();
|
| | | }
|
| | | },
|
| | | fail: (err) => {}
|
| | | })
|
| | | },
|
| | | async checkPermission() {
|
| | | let status = permision.isIOS ? await permision.requestIOS('location') :
|
| | | await permision.requestAndroid('android.permission.ACCESS_FINE_LOCATION');
|
| | | |
| | | if (status === null || status === 1) {
|
| | | status = 1;
|
| | | } else if (status === 2) {
|
| | | uni.showModal({
|
| | | content: "ç³»ç»å®ä½å·²å
³é",
|
| | | confirmText: "ç¡®å®",
|
| | | showCancel: false,
|
| | | success: function(res) {
|
| | | }
|
| | | })
|
| | | } else if (status.code) {
|
| | | uni.showModal({
|
| | | content: status.message
|
| | | })
|
| | | } else {
|
| | | uni.showModal({
|
| | | content: "éè¦å®ä½æé",
|
| | | confirmText: "设置",
|
| | | success: function(res) {
|
| | | if (res.confirm) {
|
| | | permision.gotoAppSetting();
|
| | | }
|
| | | }
|
| | | })
|
| | | }
|
| | | |
| | | return status;
|
| | | },
|
| | | clear: function() {
|
| | | this.hasLocation = false;
|
| | | },
|
| | | chooseVideo: function() {
|
| | | let that = this;
|
| | | uni.chooseVideo({
|
| | | camera: 'back',
|
| | | sourceType: ['camera', 'album'],
|
| | | success: (res) => {
|
| | | uni.showLoading();
|
| | | uni.uploadFile({
|
| | | url : that.baseUrl + '/upload.action',
|
| | | filePath: res.tempFilePath,
|
| | | name: 'file',
|
| | | success: function (result) {
|
| | | uni.hideLoading();
|
| | | var result0 = JSON.parse(result.data);
|
| | | if(result0.code === 200) {
|
| | | that.videoSrc = result0.data.url;
|
| | | } else {
|
| | | uni.showToast({title: result0.msg,icon: "none",position: 'top'})
|
| | | }
|
| | | }
|
| | | });
|
| | | uni.showToast({title: "è§é¢ä¸ä¼ æåï¼è¯·èå¿çå¾
...",icon: "none",position: 'top'})
},
|
| | | fail: (err) => {
|
| | | uni.getSetting({
|
| | | success: (res) => {
|
| | | let authStatus = false;
|
| | | switch (this.sourceTypeIndex) {
|
| | | case 0:
|
| | | authStatus = res.authSetting['scope.camera'];
|
| | | break;
|
| | | case 1:
|
| | | authStatus = res.authSetting['scope.album'];
|
| | | break;
|
| | | case 2:
|
| | | authStatus = res.authSetting['scope.album'] && res.authSetting['scope.camera'];
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | if (!authStatus) {
|
| | | uni.showModal({
|
| | | title: 'ææå¤±è´¥',
|
| | | content: 'éè¦ä»æ¨çç¸æºæç¸åè·åè§é¢ï¼è¯·å¨è®¾ç½®ç颿å¼ç¸å
³æé',
|
| | | success: (res) => {
|
| | | if (res.confirm) {
|
| | | uni.openSetting()
|
| | | }
|
| | | }
|
| | | })
|
| | | }
|
| | | }
|
| | | })
|
| | | }
|
| | | })
|
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style>
|
| | | @import '../../common/uni.css';
|
| | | |
| | | .uni-title {
|
| | | color: rgb(102, 102, 102);
|
| | | }
|
| | | .uni-label {
|
| | | color: rgb(102, 102, 102);
|
| | | }
|
| | | .uni-form-item .title {
|
| | | padding: 20rpx 0;
|
| | | }
|
| | | .cell-pd {
|
| | | padding: 22rpx 30rpx;
|
| | | }
|
| | | |
| | | .list-pd {
|
| | | margin-top: 50rpx;
|
| | | }
|
| | | .redDot:after {
|
| | | content: ' *';
|
| | | color: red;
|
| | | }
|
| | | .popup-view {
|
| | | width: 500rpx;
|
| | | }
|
| | | |
| | | .popup-title {
|
| | | display: block;
|
| | | font-size: 16px;
|
| | | line-height: 3;
|
| | | margin-bottom: 10px;
|
| | | text-align: center;
|
| | | }
|
| | | |
| | | .popup-buttons button {
|
| | | margin-left: 4px;
|
| | | margin-right: 4px;
|
| | | }
|
| | | |
| | | .video {
|
| | | width: 100%;
|
| | | }
|
| | | |
| | | .camera-tips {
|
| | | padding: 10rpx 30rpx;
|
| | | }
|
| | | </style>
|
| New file |
| | |
| | | <template> |
| | | </template> |
| | | |
| | | <script> |
| | | </script> |
| | | |
| | | <style> |
| | | </style> |
| New file |
| | |
| | | ## 1.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-badge](https://uniapp.dcloud.io/component/uniui/uni-badge) |
| | | ## 1.1.7ï¼2021-11-08ï¼ |
| | | - ä¼å å级ui |
| | | - ä¿®æ¹ size 屿§é»è®¤å¼è°æ´ä¸º small |
| | | - ä¿®æ¹ type 屿§ï¼é»è®¤å¼è°æ´ä¸º errorï¼info æ¿æ¢ default |
| | | ## 1.1.6ï¼2021-09-22ï¼ |
| | | - ä¿®å¤ å¨åèå°ç¨åºä¸æ ·å¼ä¸çæç bug |
| | | ## 1.1.5ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.1.4ï¼2021-07-29ï¼ |
| | | - ä¿®å¤ å»æ nvue 䏿¯æcss ç align-self 屿§ï¼nvue ä¸ä¸ææ¯æ absolute 屿§ |
| | | ## 1.1.3ï¼2021-06-24ï¼ |
| | | - ä¼å 示ä¾é¡¹ç® |
| | | ## 1.1.1ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.1.0ï¼2021-05-12ï¼ |
| | | - æ°å¢ uni-badge ç absolute 屿§ï¼æ¯æå®ä½ |
| | | - æ°å¢ uni-badge ç offset 屿§ï¼æ¯æå®ä½åç§» |
| | | - æ°å¢ uni-badge ç is-dot 屿§ï¼æ¯æä»
æ¾ç¤ºæä¸ä¸ªå°ç¹ |
| | | - æ°å¢ uni-badge ç max-num 屿§ï¼æ¯æèªå®ä¹å°é¡¶çæ°åå¼ï¼è¶
è¿ 99 æ¾ç¤º99+ |
| | | - ä¼å uni-badge 屿§ custom-styleï¼ æ¯æä»¥å¯¹è±¡å½¢å¼èªå®ä¹æ ·å¼ |
| | | ## 1.0.7ï¼2021-05-07ï¼ |
| | | - ä¿®å¤ uni-badge å¨ App ç«¯ï¼æ°åå°äº10æ¶ä¸æ¯åå½¢çbug |
| | | - ä¿®å¤ uni-badge å¨ç¶å
ç´ ä¸æ¯ flex å¸å±æ¶ï¼å®½åº¦ç¼©å°çbug |
| | | - æ°å¢ uni-badge 屿§ custom-styleï¼ æ¯æèªå®ä¹æ ·å¼ |
| | | ## 1.0.6ï¼2021-02-04ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | <template> |
| | | <view class="uni-badge--x"> |
| | | <slot /> |
| | | <text v-if="text" :class="classNames" :style="[badgeWidth, positionStyle, customStyle, dotStyle]" |
| | | class="uni-badge" @click="onClick()">{{displayValue}}</text> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * Badge æ°åè§æ |
| | | * @description æ°åè§æ ä¸è¬åå
¶å®æ§ä»¶ï¼å表ã9å®«æ ¼çï¼é
å使ç¨ï¼ç¨äºè¿è¡æ°éæç¤ºï¼é»è®¤ä¸ºå®å¿ç°è²èæ¯ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=21 |
| | | * @property {String} text è§æ å
容 |
| | | * @property {String} size = [normal|small] è§æ å
容 |
| | | * @property {String} type = [info|primary|success|warning|error] é¢è²ç±»å |
| | | * @value info ç°è² |
| | | * @value primary èè² |
| | | * @value success ç»¿è² |
| | | * @value warning é»è² |
| | | * @value error çº¢è² |
| | | * @property {String} inverted = [true|false] æ¯å¦æ éèæ¯é¢è² |
| | | * @property {Number} maxNum å±ç¤ºå°é¡¶çæ°åå¼ï¼è¶
è¿ 99 æ¾ç¤º 99+ |
| | | * @property {String} absolute = [rightTop|rightBottom|leftBottom|leftTop] å¼å¯ç»å¯¹å®ä½, è§æ å°å®ä½å°å
¶å
è£¹çæ ç¾çåè§ä¸ |
| | | * @value rightTop å³ä¸ |
| | | * @value rightBottom å³ä¸ |
| | | * @value leftTop å·¦ä¸ |
| | | * @value leftBottom å·¦ä¸ |
| | | * @property {Array[number]} offset è·å®ä½è§ä¸å¿ç¹çåç§»éï¼åªæåå¨ absolute 屿§æ¶ææï¼ä¾å¦ï¼[-10, -10] 表示åå¤åç§» 10pxï¼[10, 10] 表示å absolute æå®çå
åç§» 10px |
| | | * @property {String} isDot = [true|false] æ¯å¦æ¾ç¤ºä¸ºä¸ä¸ªå°ç¹ |
| | | * @event {Function} click ç¹å» Badge 触åäºä»¶ |
| | | * @example <uni-badge text="1"></uni-badge> |
| | | */ |
| | | |
| | | export default { |
| | | name: 'UniBadge', |
| | | emits: ['click'], |
| | | props: { |
| | | type: { |
| | | type: String, |
| | | default: 'error' |
| | | }, |
| | | inverted: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | isDot: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | maxNum: { |
| | | type: Number, |
| | | default: 99 |
| | | }, |
| | | absolute: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | offset: { |
| | | type: Array, |
| | | default () { |
| | | return [0, 0] |
| | | } |
| | | }, |
| | | text: { |
| | | type: [String, Number], |
| | | default: '' |
| | | }, |
| | | size: { |
| | | type: String, |
| | | default: 'small' |
| | | }, |
| | | customStyle: { |
| | | type: Object, |
| | | default () { |
| | | return {} |
| | | } |
| | | } |
| | | }, |
| | | data() { |
| | | return {}; |
| | | }, |
| | | computed: { |
| | | width() { |
| | | return String(this.text).length * 8 + 12 |
| | | }, |
| | | classNames() { |
| | | const { |
| | | inverted, |
| | | type, |
| | | size, |
| | | absolute |
| | | } = this |
| | | return [ |
| | | inverted ? 'uni-badge--' + type + '-inverted' : '', |
| | | 'uni-badge--' + type, |
| | | 'uni-badge--' + size, |
| | | absolute ? 'uni-badge--absolute' : '' |
| | | ].join(' ') |
| | | }, |
| | | positionStyle() { |
| | | if (!this.absolute) return {} |
| | | let w = this.width / 2, |
| | | h = 10 |
| | | if (this.isDot) { |
| | | w = 5 |
| | | h = 5 |
| | | } |
| | | const x = `${- w + this.offset[0]}px` |
| | | const y = `${- h + this.offset[1]}px` |
| | | |
| | | const whiteList = { |
| | | rightTop: { |
| | | right: x, |
| | | top: y |
| | | }, |
| | | rightBottom: { |
| | | right: x, |
| | | bottom: y |
| | | }, |
| | | leftBottom: { |
| | | left: x, |
| | | bottom: y |
| | | }, |
| | | leftTop: { |
| | | left: x, |
| | | top: y |
| | | } |
| | | } |
| | | const match = whiteList[this.absolute] |
| | | return match ? match : whiteList['rightTop'] |
| | | }, |
| | | badgeWidth() { |
| | | return { |
| | | width: `${this.width}px` |
| | | } |
| | | }, |
| | | dotStyle() { |
| | | if (!this.isDot) return {} |
| | | return { |
| | | width: '10px', |
| | | height: '10px', |
| | | borderRadius: '10px' |
| | | } |
| | | }, |
| | | displayValue() { |
| | | const { |
| | | isDot, |
| | | text, |
| | | maxNum |
| | | } = this |
| | | return isDot ? '' : (Number(text) > maxNum ? `${maxNum}+` : text) |
| | | } |
| | | }, |
| | | methods: { |
| | | onClick() { |
| | | this.$emit('click'); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | $uni-primary: #2979ff !default; |
| | | $uni-success: #4cd964 !default; |
| | | $uni-warning: #f0ad4e !default; |
| | | $uni-error: #dd524d !default; |
| | | $uni-info: #909399 !default; |
| | | |
| | | |
| | | $bage-size: 12px; |
| | | $bage-small: scale(0.8); |
| | | |
| | | .uni-badge--x { |
| | | /* #ifdef APP-NVUE */ |
| | | // align-self: flex-start; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | display: inline-block; |
| | | /* #endif */ |
| | | position: relative; |
| | | } |
| | | |
| | | .uni-badge--absolute { |
| | | position: absolute; |
| | | } |
| | | |
| | | .uni-badge--small { |
| | | transform: $bage-small; |
| | | transform-origin: center center; |
| | | } |
| | | |
| | | .uni-badge { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | overflow: hidden; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | justify-content: center; |
| | | flex-direction: row; |
| | | height: 20px; |
| | | line-height: 18px; |
| | | color: #fff; |
| | | border-radius: 100px; |
| | | background-color: $uni-info; |
| | | background-color: transparent; |
| | | border: 1px solid #fff; |
| | | text-align: center; |
| | | font-family: 'Helvetica Neue', Helvetica, sans-serif; |
| | | font-size: $bage-size; |
| | | /* #ifdef H5 */ |
| | | z-index: 999; |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | |
| | | &--info { |
| | | color: #fff; |
| | | background-color: $uni-info; |
| | | } |
| | | |
| | | &--primary { |
| | | background-color: $uni-primary; |
| | | } |
| | | |
| | | &--success { |
| | | background-color: $uni-success; |
| | | } |
| | | |
| | | &--warning { |
| | | background-color: $uni-warning; |
| | | } |
| | | |
| | | &--error { |
| | | background-color: $uni-error; |
| | | } |
| | | |
| | | &--inverted { |
| | | padding: 0 5px 0 0; |
| | | color: $uni-info; |
| | | } |
| | | |
| | | &--info-inverted { |
| | | color: $uni-info; |
| | | background-color: transparent; |
| | | } |
| | | |
| | | &--primary-inverted { |
| | | color: $uni-primary; |
| | | background-color: transparent; |
| | | } |
| | | |
| | | &--success-inverted { |
| | | color: $uni-success; |
| | | background-color: transparent; |
| | | } |
| | | |
| | | &--warning-inverted { |
| | | color: $uni-warning; |
| | | background-color: transparent; |
| | | } |
| | | |
| | | &--error-inverted { |
| | | color: $uni-error; |
| | | background-color: transparent; |
| | | } |
| | | |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-badge", |
| | | "displayName": "uni-badge æ°åè§æ ", |
| | | "version": "1.2.0", |
| | | "description": "æ°åè§æ ï¼å¾½ç« ï¼ç»ä»¶ï¼å¨å
ç´ å¨å´å±ç¤ºæ¶æ¯æéï¼ä¸è¬ç¨äºå表ãä¹å®«æ ¼ãæé®çå°æ¹ã", |
| | | "keywords": [ |
| | | "", |
| | | "badge", |
| | | "uni-ui", |
| | | "uniui", |
| | | "æ°åè§æ ", |
| | | "å¾½ç« " |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "y", |
| | | "èç": "y" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | ## Badge æ°åè§æ |
| | | > **ç»ä»¶åï¼uni-badge** |
| | | > 代ç åï¼ `uBadge` |
| | | |
| | | æ°åè§æ ä¸è¬åå
¶å®æ§ä»¶ï¼å表ã9å®«æ ¼çï¼é
å使ç¨ï¼ç¨äºè¿è¡æ°éæç¤ºï¼é»è®¤ä¸ºå®å¿ç°è²èæ¯ï¼ |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-badge) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| | | |
| | | |
| New file |
| | |
| | | ## 1.4.5ï¼2022-02-25ï¼ |
| | | - ä¿®å¤ æ¡ä»¶ç¼è¯ nvue 䏿¯æç css æ ·å¼ |
| | | ## 1.4.4ï¼2022-02-25ï¼ |
| | | - ä¿®å¤ æ¡ä»¶ç¼è¯ nvue 䏿¯æç css æ ·å¼ |
| | | ## 1.4.3ï¼2021-09-22ï¼ |
| | | - ä¿®å¤ startDateã endDate 屿§å¤±æç bug |
| | | ## 1.4.2ï¼2021-08-24ï¼ |
| | | - æ°å¢ æ¯æå½é
å |
| | | ## 1.4.1ï¼2021-08-05ï¼ |
| | | - ä¿®å¤ å¼¹åºå±è¢« tabbar é®ç bug |
| | | ## 1.4.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.3.16ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.3.15ï¼2021-02-04ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | /** |
| | | * @1900-2100åºé´å
çå
¬åãååäºè½¬ |
| | | * @charset UTF-8 |
| | | * @github https://github.com/jjonline/calendar.js |
| | | * @Author Jeaæ¨(JJonline@JJonline.Cn) |
| | | * @Time 2014-7-21 |
| | | * @Time 2016-8-13 Fixed 2033hexãAttribution Annals |
| | | * @Time 2016-9-25 Fixed lunar LeapMonth Param Bug |
| | | * @Time 2017-7-24 Fixed use getTerm Func Param Error.use solar year,NOT lunar year |
| | | * @Version 1.0.3 |
| | | * @å
¬å转ååï¼calendar.solar2lunar(1987,11,01); //[you can ignore params of prefix 0] |
| | | * @åå转å
¬åï¼calendar.lunar2solar(1987,09,10); //[you can ignore params of prefix 0] |
| | | */ |
| | | /* eslint-disable */ |
| | | var calendar = { |
| | | |
| | | /** |
| | | * åå1900-2100çæ¶¦å¤§å°ä¿¡æ¯è¡¨ |
| | | * @Array Of Property |
| | | * @return Hex |
| | | */ |
| | | lunarInfo: [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, // 1900-1909 |
| | | 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, // 1910-1919 |
| | | 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, // 1920-1929 |
| | | 0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, // 1930-1939 |
| | | 0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, // 1940-1949 |
| | | 0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0, // 1950-1959 |
| | | 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, // 1960-1969 |
| | | 0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6, // 1970-1979 |
| | | 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, // 1980-1989 |
| | | 0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x05ac0, 0x0ab60, 0x096d5, 0x092e0, // 1990-1999 |
| | | 0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, // 2000-2009 |
| | | 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, // 2010-2019 |
| | | 0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, // 2020-2029 |
| | | 0x05aa0, 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, // 2030-2039 |
| | | 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, // 2040-2049 |
| | | /** Add By JJonline@JJonline.Cn**/ |
| | | 0x14b63, 0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, 0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, // 2050-2059 |
| | | 0x0a2e0, 0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, 0x05d55, 0x056a0, 0x0a6d0, 0x055d4, // 2060-2069 |
| | | 0x052d0, 0x0a9b8, 0x0a950, 0x0b4a0, 0x0b6a6, 0x0ad50, 0x055a0, 0x0aba4, 0x0a5b0, 0x052b0, // 2070-2079 |
| | | 0x0b273, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160, // 2080-2089 |
| | | 0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252, // 2090-2099 |
| | | 0x0d520], // 2100 |
| | | |
| | | /** |
| | | * å
¬åæ¯ä¸ªæä»½çå¤©æ°æ®é表 |
| | | * @Array Of Property |
| | | * @return Number |
| | | */ |
| | | solarMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], |
| | | |
| | | /** |
| | | * 天干尿¯ä¹å¤©å¹²éæ¥è¡¨ |
| | | * @Array Of Property trans["ç²","ä¹","ä¸","ä¸","æ","å·±","åº","è¾","壬","ç¸"] |
| | | * @return Cn string |
| | | */ |
| | | Gan: ['\u7532', '\u4e59', '\u4e19', '\u4e01', '\u620a', '\u5df1', '\u5e9a', '\u8f9b', '\u58ec', '\u7678'], |
| | | |
| | | /** |
| | | * 天干尿¯ä¹å°æ¯éæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans["å","ä¸","å¯
","å¯","è¾°","å·³","å","æª","ç³","é
","æ","亥"] |
| | | * @return Cn string |
| | | */ |
| | | Zhi: ['\u5b50', '\u4e11', '\u5bc5', '\u536f', '\u8fb0', '\u5df3', '\u5348', '\u672a', '\u7533', '\u9149', '\u620c', '\u4ea5'], |
| | | |
| | | /** |
| | | * 天干尿¯ä¹å°æ¯éæ¥è¡¨<=>çè |
| | | * @Array Of Property |
| | | * @trans["é¼ ","ç","è","å
","é¾","è","马","ç¾","ç´","鸡","ç","çª"] |
| | | * @return Cn string |
| | | */ |
| | | Animals: ['\u9f20', '\u725b', '\u864e', '\u5154', '\u9f99', '\u86c7', '\u9a6c', '\u7f8a', '\u7334', '\u9e21', '\u72d7', '\u732a'], |
| | | |
| | | /** |
| | | * 24èæ°éæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans["å°å¯","大å¯","ç«æ¥","鍿°´","æè°","æ¥å","æ¸
æ","è°·é¨","ç«å¤","å°æ»¡","èç§","å¤è³","å°æ","大æ","ç«ç§","夿","ç½é²","ç§å","å¯é²","éé","ç«å¬","å°éª","大éª","å¬è³"] |
| | | * @return Cn string |
| | | */ |
| | | solarTerm: ['\u5c0f\u5bd2', '\u5927\u5bd2', '\u7acb\u6625', '\u96e8\u6c34', '\u60ca\u86f0', '\u6625\u5206', '\u6e05\u660e', '\u8c37\u96e8', '\u7acb\u590f', '\u5c0f\u6ee1', '\u8292\u79cd', '\u590f\u81f3', '\u5c0f\u6691', '\u5927\u6691', '\u7acb\u79cb', '\u5904\u6691', '\u767d\u9732', '\u79cb\u5206', '\u5bd2\u9732', '\u971c\u964d', '\u7acb\u51ac', '\u5c0f\u96ea', '\u5927\u96ea', '\u51ac\u81f3'], |
| | | |
| | | /** |
| | | * 1900-2100åå¹´ç24èæ°æ¥æéæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @return 0x string For splice |
| | | */ |
| | | sTermInfo: ['9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f', |
| | | '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f', |
| | | 'b027097bd097c36b0b6fc9274c91aa', '9778397bd19801ec9210c965cc920e', '97b6b97bd19801ec95f8c965cc920f', |
| | | '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd197c36c9210c9274c91aa', |
| | | '97b6b97bd19801ec95f8c965cc920e', '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2', |
| | | '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec95f8c965cc920e', '97bcf97c3598082c95f8e1cfcc920f', |
| | | '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', |
| | | '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', |
| | | '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf97c359801ec95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd097bd07f595b0b6fc920fb0722', |
| | | '9778397bd097c36b0b6fc9210c8dc2', '9778397bd19801ec9210c9274c920e', '97b6b97bd19801ec95f8c965cc920f', |
| | | '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e', |
| | | '97b6b97bd19801ec95f8c965cc920f', '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', |
| | | '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bd07f1487f595b0b0bc920fb0722', |
| | | '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', |
| | | '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f531b0b0bb0b6fb0722', |
| | | '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf7f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', |
| | | '9778397bd097c36b0b6fc9210c91aa', '97b6b97bd197c36c9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722', |
| | | '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e', |
| | | '97b6b7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', |
| | | '9778397bd097c36b0b70c9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722', |
| | | '7f0e397bd097c35b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', |
| | | '7f0e27f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', |
| | | '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', |
| | | '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', |
| | | '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b7f0e47f531b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', |
| | | '9778397bd097c36b0b6fc9210c91aa', '97b6b7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', |
| | | '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '977837f0e37f149b0723b0787b0721', |
| | | '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c35b0b6fc9210c8dc2', |
| | | '977837f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722', |
| | | '7f0e397bd097c35b0b6fc9210c8dc2', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', |
| | | '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '977837f0e37f14998082b0787b06bd', |
| | | '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', |
| | | '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', |
| | | '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', |
| | | '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd', |
| | | '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', |
| | | '977837f0e37f14998082b0723b06bd', '7f07e7f0e37f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', |
| | | '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b0721', |
| | | '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f595b0b0bb0b6fb0722', '7f0e37f0e37f14898082b0723b02d5', |
| | | '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f531b0b0bb0b6fb0722', |
| | | '7f0e37f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', |
| | | '7f0e37f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd', |
| | | '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35', |
| | | '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', |
| | | '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f149b0723b0787b0721', |
| | | '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0723b06bd', |
| | | '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', '7f0e37f0e366aa89801eb072297c35', |
| | | '7ec967f0e37f14998082b0723b06bd', '7f07e7f0e37f14998083b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', |
| | | '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14898082b0723b02d5', '7f07e7f0e37f14998082b0787b0721', |
| | | '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66aa89801e9808297c35', '665f67f0e37f14898082b0723b02d5', |
| | | '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66a449801e9808297c35', |
| | | '665f67f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', |
| | | '7f0e36665b66a449801e9808297c35', '665f67f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd', |
| | | '7f07e7f0e47f531b0723b0b6fb0721', '7f0e26665b66a449801e9808297c35', '665f67f0e37f1489801eb072297c35', |
| | | '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722'], |
| | | |
| | | /** |
| | | * æ°åè½¬ä¸æéæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans ['æ¥','ä¸','äº','ä¸','å','äº','å
','ä¸','å
«','ä¹','å'] |
| | | * @return Cn string |
| | | */ |
| | | nStr1: ['\u65e5', '\u4e00', '\u4e8c', '\u4e09', '\u56db', '\u4e94', '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341'], |
| | | |
| | | /** |
| | | * æ¥æè½¬ååç§°å¼éæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans ['å','å','廿','å
'] |
| | | * @return Cn string |
| | | */ |
| | | nStr2: ['\u521d', '\u5341', '\u5eff', '\u5345'], |
| | | |
| | | /** |
| | | * æä»½è½¬ååç§°å¼éæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans ['æ£','ä¸','äº','ä¸','å','äº','å
','ä¸','å
«','ä¹','å','å¬','è
'] |
| | | * @return Cn string |
| | | */ |
| | | nStr3: ['\u6b63', '\u4e8c', '\u4e09', '\u56db', '\u4e94', '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341', '\u51ac', '\u814a'], |
| | | |
| | | /** |
| | | * è¿åååy年䏿´å¹´çæ»å¤©æ° |
| | | * @param lunar Year |
| | | * @return Number |
| | | * @eg:var count = calendar.lYearDays(1987) ;//count=387 |
| | | */ |
| | | lYearDays: function (y) { |
| | | var i; var sum = 348 |
| | | for (i = 0x8000; i > 0x8; i >>= 1) { sum += (this.lunarInfo[y - 1900] & i) ? 1 : 0 } |
| | | return (sum + this.leapDays(y)) |
| | | }, |
| | | |
| | | /** |
| | | * è¿åååyå¹´é°ææ¯åªä¸ªæï¼è¥y年没æé°æ åè¿å0 |
| | | * @param lunar Year |
| | | * @return Number (0-12) |
| | | * @eg:var leapMonth = calendar.leapMonth(1987) ;//leapMonth=6 |
| | | */ |
| | | leapMonth: function (y) { // é°åç¼ç \u95f0 |
| | | return (this.lunarInfo[y - 1900] & 0xf) |
| | | }, |
| | | |
| | | /** |
| | | * è¿åååyå¹´é°æçå¤©æ° è¥è¯¥å¹´æ²¡æé°æåè¿å0 |
| | | * @param lunar Year |
| | | * @return Number (0ã29ã30) |
| | | * @eg:var leapMonthDay = calendar.leapDays(1987) ;//leapMonthDay=29 |
| | | */ |
| | | leapDays: function (y) { |
| | | if (this.leapMonth(y)) { |
| | | return ((this.lunarInfo[y - 1900] & 0x10000) ? 30 : 29) |
| | | } |
| | | return (0) |
| | | }, |
| | | |
| | | /** |
| | | * è¿åååyå¹´mæï¼éé°æï¼çæ»å¤©æ°ï¼è®¡ç®mä¸ºé°ææ¶ç天æ°è¯·ä½¿ç¨leapDaysæ¹æ³ |
| | | * @param lunar Year |
| | | * @return Number (-1ã29ã30) |
| | | * @eg:var MonthDay = calendar.monthDays(1987,9) ;//MonthDay=29 |
| | | */ |
| | | monthDays: function (y, m) { |
| | | if (m > 12 || m < 1) { return -1 }// æä»½åæ°ä»1è³12ï¼åæ°é误è¿å-1 |
| | | return ((this.lunarInfo[y - 1900] & (0x10000 >> m)) ? 30 : 29) |
| | | }, |
| | | |
| | | /** |
| | | * è¿åå
¬å(!)yå¹´mæçå¤©æ° |
| | | * @param solar Year |
| | | * @return Number (-1ã28ã29ã30ã31) |
| | | * @eg:var solarMonthDay = calendar.leapDays(1987) ;//solarMonthDay=30 |
| | | */ |
| | | solarDays: function (y, m) { |
| | | if (m > 12 || m < 1) { return -1 } // è¥åæ°é误 è¿å-1 |
| | | var ms = m - 1 |
| | | if (ms == 1) { // 2æä»½çé°å¹³è§å¾æµç®å确认è¿å28æ29 |
| | | return (((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) ? 29 : 28) |
| | | } else { |
| | | return (this.solarMonth[ms]) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * åå年份转æ¢ä¸ºå¹²æ¯çºªå¹´ |
| | | * @param lYear ååå¹´çå¹´ä»½æ° |
| | | * @return Cn string |
| | | */ |
| | | toGanZhiYear: function (lYear) { |
| | | var ganKey = (lYear - 3) % 10 |
| | | var zhiKey = (lYear - 3) % 12 |
| | | if (ganKey == 0) ganKey = 10// 妿使°ä¸º0å为æåä¸ä¸ªå¤©å¹² |
| | | if (zhiKey == 0) zhiKey = 12// 妿使°ä¸º0å为æåä¸ä¸ªå°æ¯ |
| | | return this.Gan[ganKey - 1] + this.Zhi[zhiKey - 1] |
| | | }, |
| | | |
| | | /** |
| | | * å
¬åæãæ¥å¤ææå±æåº§ |
| | | * @param cMonth [description] |
| | | * @param cDay [description] |
| | | * @return Cn string |
| | | */ |
| | | toAstro: function (cMonth, cDay) { |
| | | var s = '\u9b54\u7faf\u6c34\u74f6\u53cc\u9c7c\u767d\u7f8a\u91d1\u725b\u53cc\u5b50\u5de8\u87f9\u72ee\u5b50\u5904\u5973\u5929\u79e4\u5929\u874e\u5c04\u624b\u9b54\u7faf' |
| | | var arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22] |
| | | return s.substr(cMonth * 2 - (cDay < arr[cMonth - 1] ? 2 : 0), 2) + '\u5ea7'// 座 |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥offsetåç§»éè¿åå¹²æ¯ |
| | | * @param offset ç¸å¯¹ç²åçåç§»é |
| | | * @return Cn string |
| | | */ |
| | | toGanZhi: function (offset) { |
| | | return this.Gan[offset % 10] + this.Zhi[offset % 12] |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥å
¬å(!)yå¹´è·å¾è¯¥å¹´ç¬¬nä¸ªèæ°çå
¬åæ¥æ |
| | | * @param yå
¬åå¹´(1900-2100)ï¼näºååèæ°ä¸ç第å ä¸ªèæ°(1~24)ï¼ä»n=1(å°å¯)ç®èµ· |
| | | * @return day Number |
| | | * @eg:var _24 = calendar.getTerm(1987,3) ;//_24=4;æå³1987å¹´2æ4æ¥ç«æ¥ |
| | | */ |
| | | getTerm: function (y, n) { |
| | | if (y < 1900 || y > 2100) { return -1 } |
| | | if (n < 1 || n > 24) { return -1 } |
| | | var _table = this.sTermInfo[y - 1900] |
| | | var _info = [ |
| | | parseInt('0x' + _table.substr(0, 5)).toString(), |
| | | parseInt('0x' + _table.substr(5, 5)).toString(), |
| | | parseInt('0x' + _table.substr(10, 5)).toString(), |
| | | parseInt('0x' + _table.substr(15, 5)).toString(), |
| | | parseInt('0x' + _table.substr(20, 5)).toString(), |
| | | parseInt('0x' + _table.substr(25, 5)).toString() |
| | | ] |
| | | var _calday = [ |
| | | _info[0].substr(0, 1), |
| | | _info[0].substr(1, 2), |
| | | _info[0].substr(3, 1), |
| | | _info[0].substr(4, 2), |
| | | |
| | | _info[1].substr(0, 1), |
| | | _info[1].substr(1, 2), |
| | | _info[1].substr(3, 1), |
| | | _info[1].substr(4, 2), |
| | | |
| | | _info[2].substr(0, 1), |
| | | _info[2].substr(1, 2), |
| | | _info[2].substr(3, 1), |
| | | _info[2].substr(4, 2), |
| | | |
| | | _info[3].substr(0, 1), |
| | | _info[3].substr(1, 2), |
| | | _info[3].substr(3, 1), |
| | | _info[3].substr(4, 2), |
| | | |
| | | _info[4].substr(0, 1), |
| | | _info[4].substr(1, 2), |
| | | _info[4].substr(3, 1), |
| | | _info[4].substr(4, 2), |
| | | |
| | | _info[5].substr(0, 1), |
| | | _info[5].substr(1, 2), |
| | | _info[5].substr(3, 1), |
| | | _info[5].substr(4, 2) |
| | | ] |
| | | return parseInt(_calday[n - 1]) |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥ååæ°åæä»½è¿åæ±è¯éä¿è¡¨ç¤ºæ³ |
| | | * @param lunar month |
| | | * @return Cn string |
| | | * @eg:var cnMonth = calendar.toChinaMonth(12) ;//cnMonth='è
æ' |
| | | */ |
| | | toChinaMonth: function (m) { // æ => \u6708 |
| | | if (m > 12 || m < 1) { return -1 } // è¥åæ°é误 è¿å-1 |
| | | var s = this.nStr3[m - 1] |
| | | s += '\u6708'// å 䏿å |
| | | return s |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥ååæ¥ææ°åè¿åæ±åè¡¨ç¤ºæ³ |
| | | * @param lunar day |
| | | * @return Cn string |
| | | * @eg:var cnDay = calendar.toChinaDay(21) ;//cnMonth='廿ä¸' |
| | | */ |
| | | toChinaDay: function (d) { // æ¥ => \u65e5 |
| | | var s |
| | | switch (d) { |
| | | case 10: |
| | | s = '\u521d\u5341'; break |
| | | case 20: |
| | | s = '\u4e8c\u5341'; break |
| | | break |
| | | case 30: |
| | | s = '\u4e09\u5341'; break |
| | | break |
| | | default : |
| | | s = this.nStr2[Math.floor(d / 10)] |
| | | s += this.nStr1[d % 10] |
| | | } |
| | | return (s) |
| | | }, |
| | | |
| | | /** |
| | | * 年份转çè[!ä»
è½å¤§è´è½¬æ¢] => 精确ååçèåç线æ¯âç«æ¥â |
| | | * @param y year |
| | | * @return Cn string |
| | | * @eg:var animal = calendar.getAnimal(1987) ;//animal='å
' |
| | | */ |
| | | getAnimal: function (y) { |
| | | return this.Animals[(y - 4) % 12] |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥é³åå¹´ææ¥è·å¾è¯¦ç»çå
¬åãååobjectä¿¡æ¯ <=>JSON |
| | | * @param y solar year |
| | | * @param m solar month |
| | | * @param d solar day |
| | | * @return JSON object |
| | | * @eg:console.log(calendar.solar2lunar(1987,11,01)); |
| | | */ |
| | | solar2lunar: function (y, m, d) { // åæ°åºé´1900.1.31~2100.12.31 |
| | | // 年份éå®ãä¸é |
| | | if (y < 1900 || y > 2100) { |
| | | return -1// undefined转æ¢ä¸ºæ°åå为NaN |
| | | } |
| | | // å
¬åä¼ åæä¸é |
| | | if (y == 1900 && m == 1 && d < 31) { |
| | | return -1 |
| | | } |
| | | // æªä¼ å è·å¾å½å¤© |
| | | if (!y) { |
| | | var objDate = new Date() |
| | | } else { |
| | | var objDate = new Date(y, parseInt(m) - 1, d) |
| | | } |
| | | var i; var leap = 0; var temp = 0 |
| | | // ä¿®æ£ymdåæ° |
| | | var y = objDate.getFullYear() |
| | | var m = objDate.getMonth() + 1 |
| | | var d = objDate.getDate() |
| | | var offset = (Date.UTC(objDate.getFullYear(), objDate.getMonth(), objDate.getDate()) - Date.UTC(1900, 0, 31)) / 86400000 |
| | | for (i = 1900; i < 2101 && offset > 0; i++) { |
| | | temp = this.lYearDays(i) |
| | | offset -= temp |
| | | } |
| | | if (offset < 0) { |
| | | offset += temp; i-- |
| | | } |
| | | |
| | | // æ¯å¦ä»å¤© |
| | | var isTodayObj = new Date() |
| | | var isToday = false |
| | | if (isTodayObj.getFullYear() == y && isTodayObj.getMonth() + 1 == m && isTodayObj.getDate() == d) { |
| | | isToday = true |
| | | } |
| | | // ææå |
| | | var nWeek = objDate.getDay() |
| | | var cWeek = this.nStr1[nWeek] |
| | | // æ°å表示å¨å 顺åºå¤©æå¨ä¸å¼å§çæ¯ä¾ |
| | | if (nWeek == 0) { |
| | | nWeek = 7 |
| | | } |
| | | // ååå¹´ |
| | | var year = i |
| | | var leap = this.leapMonth(i) // é°åªä¸ªæ |
| | | var isLeap = false |
| | | |
| | | // æéªé°æ |
| | | for (i = 1; i < 13 && offset > 0; i++) { |
| | | // é°æ |
| | | if (leap > 0 && i == (leap + 1) && isLeap == false) { |
| | | --i |
| | | isLeap = true; temp = this.leapDays(year) // 计ç®ååé°æå¤©æ° |
| | | } else { |
| | | temp = this.monthDays(year, i)// 计ç®ååæ®éæå¤©æ° |
| | | } |
| | | // è§£é¤é°æ |
| | | if (isLeap == true && i == (leap + 1)) { isLeap = false } |
| | | offset -= temp |
| | | } |
| | | // é°æå¯¼è´æ°ç»ä¸æ éå åå |
| | | if (offset == 0 && leap > 0 && i == leap + 1) { |
| | | if (isLeap) { |
| | | isLeap = false |
| | | } else { |
| | | isLeap = true; --i |
| | | } |
| | | } |
| | | if (offset < 0) { |
| | | offset += temp; --i |
| | | } |
| | | // ååæ |
| | | var month = i |
| | | // å忥 |
| | | var day = offset + 1 |
| | | // 天干尿¯å¤ç |
| | | var sm = m - 1 |
| | | var gzY = this.toGanZhiYear(year) |
| | | |
| | | // 彿çä¸¤ä¸ªèæ° |
| | | // bugfix-2017-7-24 11:03:38 use lunar Year Param `y` Not `year` |
| | | var firstNode = this.getTerm(y, (m * 2 - 1))// è¿å彿ãèãä¸ºå æ¥å¼å§ |
| | | var secondNode = this.getTerm(y, (m * 2))// è¿å彿ãèãä¸ºå æ¥å¼å§ |
| | | |
| | | // 便®12èæ°ä¿®æ£å¹²æ¯æ |
| | | var gzM = this.toGanZhi((y - 1900) * 12 + m + 11) |
| | | if (d >= firstNode) { |
| | | gzM = this.toGanZhi((y - 1900) * 12 + m + 12) |
| | | } |
| | | |
| | | // ä¼ å
¥çæ¥æçèæ°ä¸å¦ |
| | | var isTerm = false |
| | | var Term = null |
| | | if (firstNode == d) { |
| | | isTerm = true |
| | | Term = this.solarTerm[m * 2 - 2] |
| | | } |
| | | if (secondNode == d) { |
| | | isTerm = true |
| | | Term = this.solarTerm[m * 2 - 1] |
| | | } |
| | | // æ¥æ± 彿䏿¥ä¸ 1900/1/1 ç¸å·®å¤©æ° |
| | | var dayCyclical = Date.UTC(y, sm, 1, 0, 0, 0, 0) / 86400000 + 25567 + 10 |
| | | var gzD = this.toGanZhi(dayCyclical + d - 1) |
| | | // è¯¥æ¥ææå±çæåº§ |
| | | var astro = this.toAstro(m, d) |
| | | |
| | | return { 'lYear': year, 'lMonth': month, 'lDay': day, 'Animal': this.getAnimal(year), 'IMonthCn': (isLeap ? '\u95f0' : '') + this.toChinaMonth(month), 'IDayCn': this.toChinaDay(day), 'cYear': y, 'cMonth': m, 'cDay': d, 'gzYear': gzY, 'gzMonth': gzM, 'gzDay': gzD, 'isToday': isToday, 'isLeap': isLeap, 'nWeek': nWeek, 'ncWeek': '\u661f\u671f' + cWeek, 'isTerm': isTerm, 'Term': Term, 'astro': astro } |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥ååå¹´ææ¥ä»¥åä¼ å
¥çæä»½æ¯å¦é°æè·å¾è¯¦ç»çå
¬åãååobjectä¿¡æ¯ <=>JSON |
| | | * @param y lunar year |
| | | * @param m lunar month |
| | | * @param d lunar day |
| | | * @param isLeapMonth lunar month is leap or not.[妿æ¯ååé°æç¬¬åä¸ªåæ°èµå¼trueå³å¯] |
| | | * @return JSON object |
| | | * @eg:console.log(calendar.lunar2solar(1987,9,10)); |
| | | */ |
| | | lunar2solar: function (y, m, d, isLeapMonth) { // åæ°åºé´1900.1.31~2100.12.1 |
| | | var isLeapMonth = !!isLeapMonth |
| | | var leapOffset = 0 |
| | | var leapMonth = this.leapMonth(y) |
| | | var leapDay = this.leapDays(y) |
| | | if (isLeapMonth && (leapMonth != m)) { return -1 }// ä¼ åè¦æ±è®¡ç®è¯¥é°æå
¬å ä½è¯¥å¹´å¾åºçé°æä¸ä¼ åçæä»½å¹¶ä¸å |
| | | if (y == 2100 && m == 12 && d > 1 || y == 1900 && m == 1 && d < 31) { return -1 }// è¶
åºäºæå¤§æéå¼ |
| | | var day = this.monthDays(y, m) |
| | | var _day = day |
| | | // bugFix 2016-9-25 |
| | | // if month is leap, _day use leapDays method |
| | | if (isLeapMonth) { |
| | | _day = this.leapDays(y, m) |
| | | } |
| | | if (y < 1900 || y > 2100 || d > _day) { return -1 }// åæ°åæ³æ§æéª |
| | | |
| | | // 计ç®ååçæ¶é´å·® |
| | | var offset = 0 |
| | | for (var i = 1900; i < y; i++) { |
| | | offset += this.lYearDays(i) |
| | | } |
| | | var leap = 0; var isAdd = false |
| | | for (var i = 1; i < m; i++) { |
| | | leap = this.leapMonth(y) |
| | | if (!isAdd) { // å¤çé°æ |
| | | if (leap <= i && leap > 0) { |
| | | offset += this.leapDays(y); isAdd = true |
| | | } |
| | | } |
| | | offset += this.monthDays(y, i) |
| | | } |
| | | // 转æ¢é°æåå éè¡¥å
è¯¥å¹´é°æçåä¸ä¸ªæçæ¶å·® |
| | | if (isLeapMonth) { offset += day } |
| | | // 1900å¹´å忣æä¸æ¥çå
¬åæ¶é´ä¸º1900å¹´1æ30æ¥0æ¶0å0ç§(该æ¶é´ä¹æ¯æ¬ååçæå¼å§èµ·å§ç¹) |
| | | var stmap = Date.UTC(1900, 1, 30, 0, 0, 0) |
| | | var calObj = new Date((offset + d - 31) * 86400000 + stmap) |
| | | var cY = calObj.getUTCFullYear() |
| | | var cM = calObj.getUTCMonth() + 1 |
| | | var cD = calObj.getUTCDate() |
| | | |
| | | return this.solar2lunar(cY, cM, cD) |
| | | } |
| | | } |
| | | |
| | | export default calendar |
| New file |
| | |
| | | { |
| | | "uni-calender.ok": "ok", |
| | | "uni-calender.cancel": "cancel", |
| | | "uni-calender.today": "today", |
| | | "uni-calender.MON": "MON", |
| | | "uni-calender.TUE": "TUE", |
| | | "uni-calender.WED": "WED", |
| | | "uni-calender.THU": "THU", |
| | | "uni-calender.FRI": "FRI", |
| | | "uni-calender.SAT": "SAT", |
| | | "uni-calender.SUN": "SUN" |
| | | } |
| New file |
| | |
| | | import en from './en.json' |
| | | import zhHans from './zh-Hans.json' |
| | | import zhHant from './zh-Hant.json' |
| | | export default { |
| | | en, |
| | | 'zh-Hans': zhHans, |
| | | 'zh-Hant': zhHant |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-calender.ok": "ç¡®å®", |
| | | "uni-calender.cancel": "åæ¶", |
| | | "uni-calender.today": "仿¥", |
| | | "uni-calender.SUN": "æ¥", |
| | | "uni-calender.MON": "ä¸", |
| | | "uni-calender.TUE": "äº", |
| | | "uni-calender.WED": "ä¸", |
| | | "uni-calender.THU": "å", |
| | | "uni-calender.FRI": "äº", |
| | | "uni-calender.SAT": "å
" |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-calender.ok": "確å®", |
| | | "uni-calender.cancel": "åæ¶", |
| | | "uni-calender.today": "仿¥", |
| | | "uni-calender.SUN": "æ¥", |
| | | "uni-calender.MON": "ä¸", |
| | | "uni-calender.TUE": "äº", |
| | | "uni-calender.WED": "ä¸", |
| | | "uni-calender.THU": "å", |
| | | "uni-calender.FRI": "äº", |
| | | "uni-calender.SAT": "å
" |
| | | } |
| New file |
| | |
| | | <template> |
| | | <view class="uni-calendar-item__weeks-box" :class="{ |
| | | 'uni-calendar-item--disable':weeks.disable, |
| | | 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay, |
| | | 'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) , |
| | | 'uni-calendar-item--before-checked':weeks.beforeMultiple, |
| | | 'uni-calendar-item--multiple': weeks.multiple, |
| | | 'uni-calendar-item--after-checked':weeks.afterMultiple, |
| | | }" |
| | | @click="choiceDate(weeks)"> |
| | | <view class="uni-calendar-item__weeks-box-item"> |
| | | <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text> |
| | | <text class="uni-calendar-item__weeks-box-text" :class="{ |
| | | 'uni-calendar-item--isDay-text': weeks.isDay, |
| | | 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay, |
| | | 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay, |
| | | 'uni-calendar-item--before-checked':weeks.beforeMultiple, |
| | | 'uni-calendar-item--multiple': weeks.multiple, |
| | | 'uni-calendar-item--after-checked':weeks.afterMultiple, |
| | | 'uni-calendar-item--disable':weeks.disable, |
| | | }">{{weeks.date}}</text> |
| | | <text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text" :class="{ |
| | | 'uni-calendar-item--isDay-text':weeks.isDay, |
| | | 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay, |
| | | 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay, |
| | | 'uni-calendar-item--before-checked':weeks.beforeMultiple, |
| | | 'uni-calendar-item--multiple': weeks.multiple, |
| | | 'uni-calendar-item--after-checked':weeks.afterMultiple, |
| | | }">{{todayText}}</text> |
| | | <text v-if="lunar&&!weeks.extraInfo" class="uni-calendar-item__weeks-lunar-text" :class="{ |
| | | 'uni-calendar-item--isDay-text':weeks.isDay, |
| | | 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay, |
| | | 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay, |
| | | 'uni-calendar-item--before-checked':weeks.beforeMultiple, |
| | | 'uni-calendar-item--multiple': weeks.multiple, |
| | | 'uni-calendar-item--after-checked':weeks.afterMultiple, |
| | | 'uni-calendar-item--disable':weeks.disable, |
| | | }">{{weeks.isDay ? todayText : (weeks.lunar.IDayCn === 'åä¸'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text> |
| | | <text v-if="weeks.extraInfo&&weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar-text" :class="{ |
| | | 'uni-calendar-item--extra':weeks.extraInfo.info, |
| | | 'uni-calendar-item--isDay-text':weeks.isDay, |
| | | 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay, |
| | | 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay, |
| | | 'uni-calendar-item--before-checked':weeks.beforeMultiple, |
| | | 'uni-calendar-item--multiple': weeks.multiple, |
| | | 'uni-calendar-item--after-checked':weeks.afterMultiple, |
| | | 'uni-calendar-item--disable':weeks.disable, |
| | | }">{{weeks.extraInfo.info}}</text> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | initVueI18n |
| | | } from '@dcloudio/uni-i18n' |
| | | import messages from './i18n/index.js' |
| | | const { t } = initVueI18n(messages) |
| | | export default { |
| | | emits:['change'], |
| | | props: { |
| | | weeks: { |
| | | type: Object, |
| | | default () { |
| | | return {} |
| | | } |
| | | }, |
| | | calendar: { |
| | | type: Object, |
| | | default: () => { |
| | | return {} |
| | | } |
| | | }, |
| | | selected: { |
| | | type: Array, |
| | | default: () => { |
| | | return [] |
| | | } |
| | | }, |
| | | lunar: { |
| | | type: Boolean, |
| | | default: false |
| | | } |
| | | }, |
| | | computed: { |
| | | todayText() { |
| | | return t("uni-calender.today") |
| | | }, |
| | | }, |
| | | methods: { |
| | | choiceDate(weeks) { |
| | | this.$emit('change', weeks) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .uni-calendar-item__weeks-box { |
| | | flex: 1; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | | |
| | | .uni-calendar-item__weeks-box-text { |
| | | font-size: $uni-font-size-base; |
| | | color: $uni-text-color; |
| | | } |
| | | |
| | | .uni-calendar-item__weeks-lunar-text { |
| | | font-size: $uni-font-size-sm; |
| | | color: $uni-text-color; |
| | | } |
| | | |
| | | .uni-calendar-item__weeks-box-item { |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | align-items: center; |
| | | width: 100rpx; |
| | | height: 100rpx; |
| | | } |
| | | |
| | | .uni-calendar-item__weeks-box-circle { |
| | | position: absolute; |
| | | top: 5px; |
| | | right: 5px; |
| | | width: 8px; |
| | | height: 8px; |
| | | border-radius: 8px; |
| | | background-color: $uni-color-error; |
| | | |
| | | } |
| | | |
| | | .uni-calendar-item--disable { |
| | | background-color: rgba(249, 249, 249, $uni-opacity-disabled); |
| | | color: $uni-text-color-disable; |
| | | } |
| | | |
| | | .uni-calendar-item--isDay-text { |
| | | color: $uni-color-primary; |
| | | } |
| | | |
| | | .uni-calendar-item--isDay { |
| | | background-color: $uni-color-primary; |
| | | opacity: 0.8; |
| | | color: #fff; |
| | | } |
| | | |
| | | .uni-calendar-item--extra { |
| | | color: $uni-color-error; |
| | | opacity: 0.8; |
| | | } |
| | | |
| | | .uni-calendar-item--checked { |
| | | background-color: $uni-color-primary; |
| | | color: #fff; |
| | | opacity: 0.8; |
| | | } |
| | | |
| | | .uni-calendar-item--multiple { |
| | | background-color: $uni-color-primary; |
| | | color: #fff; |
| | | opacity: 0.8; |
| | | } |
| | | .uni-calendar-item--before-checked { |
| | | background-color: #ff5a5f; |
| | | color: #fff; |
| | | } |
| | | .uni-calendar-item--after-checked { |
| | | background-color: #ff5a5f; |
| | | color: #fff; |
| | | } |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view class="uni-calendar"> |
| | | <view v-if="!insert&&show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}" @click="clean"></view> |
| | | <view v-if="insert || show" class="uni-calendar__content" :class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow}"> |
| | | <view v-if="!insert" class="uni-calendar__header uni-calendar--fixed-top"> |
| | | <view class="uni-calendar__header-btn-box" @click="close"> |
| | | <text class="uni-calendar__header-text uni-calendar--fixed-width">{{cancelText}}</text> |
| | | </view> |
| | | <view class="uni-calendar__header-btn-box" @click="confirm"> |
| | | <text class="uni-calendar__header-text uni-calendar--fixed-width">{{okText}}</text> |
| | | </view> |
| | | </view> |
| | | <view class="uni-calendar__header"> |
| | | <view class="uni-calendar__header-btn-box" @click.stop="pre"> |
| | | <view class="uni-calendar__header-btn uni-calendar--left"></view> |
| | | </view> |
| | | <picker mode="date" :value="date" fields="month" @change="bindDateChange"> |
| | | <text class="uni-calendar__header-text">{{ (nowDate.year||'') +' / '+( nowDate.month||'')}}</text> |
| | | </picker> |
| | | <view class="uni-calendar__header-btn-box" @click.stop="next"> |
| | | <view class="uni-calendar__header-btn uni-calendar--right"></view> |
| | | </view> |
| | | <text class="uni-calendar__backtoday" @click="backtoday">{{todayText}}</text> |
| | | |
| | | </view> |
| | | <view class="uni-calendar__box"> |
| | | <view v-if="showMonth" class="uni-calendar__box-bg"> |
| | | <text class="uni-calendar__box-bg-text">{{nowDate.month}}</text> |
| | | </view> |
| | | <view class="uni-calendar__weeks"> |
| | | <view class="uni-calendar__weeks-day"> |
| | | <text class="uni-calendar__weeks-day-text">{{SUNText}}</text> |
| | | </view> |
| | | <view class="uni-calendar__weeks-day"> |
| | | <text class="uni-calendar__weeks-day-text">{{monText}}</text> |
| | | </view> |
| | | <view class="uni-calendar__weeks-day"> |
| | | <text class="uni-calendar__weeks-day-text">{{TUEText}}</text> |
| | | </view> |
| | | <view class="uni-calendar__weeks-day"> |
| | | <text class="uni-calendar__weeks-day-text">{{WEDText}}</text> |
| | | </view> |
| | | <view class="uni-calendar__weeks-day"> |
| | | <text class="uni-calendar__weeks-day-text">{{THUText}}</text> |
| | | </view> |
| | | <view class="uni-calendar__weeks-day"> |
| | | <text class="uni-calendar__weeks-day-text">{{FRIText}}</text> |
| | | </view> |
| | | <view class="uni-calendar__weeks-day"> |
| | | <text class="uni-calendar__weeks-day-text">{{SATText}}</text> |
| | | </view> |
| | | </view> |
| | | <view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex"> |
| | | <view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex"> |
| | | <calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar" :selected="selected" :lunar="lunar" @change="choiceDate"></calendar-item> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import Calendar from './util.js'; |
| | | import calendarItem from './uni-calendar-item.vue' |
| | | import { |
| | | initVueI18n |
| | | } from '@dcloudio/uni-i18n' |
| | | import messages from './i18n/index.js' |
| | | const { t } = initVueI18n(messages) |
| | | /** |
| | | * Calendar æ¥å |
| | | * @description æ¥åç»ä»¶å¯ä»¥æ¥çæ¥æï¼éæ©ä»»æèå´å
çæ¥æï¼æç¹æä½ã常ç¨åºæ¯å¦ï¼é
åºæ¥æé¢è®¢ãç«è½¦æºç¥¨éæ©è´ä¹°æ¥æãä¸ä¸çæå¡ç |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=56 |
| | | * @property {String} date èªå®ä¹å½åæ¶é´ï¼é»è®¤ä¸ºä»å¤© |
| | | * @property {Boolean} lunar æ¾ç¤ºåå |
| | | * @property {String} startDate æ¥æéæ©èå´-å¼å§æ¥æ |
| | | * @property {String} endDate æ¥æéæ©èå´-ç»ææ¥æ |
| | | * @property {Boolean} range èå´éæ© |
| | | * @property {Boolean} insert = [true|false] æå
¥æ¨¡å¼,é»è®¤ä¸ºfalse |
| | | * @value true å¼¹çªæ¨¡å¼ |
| | | * @value false æå
¥æ¨¡å¼ |
| | | * @property {Boolean} clearDate = [true|false] å¼¹çªæ¨¡å¼æ¯å¦æ¸
ç©ºä¸æ¬¡éæ©å
容 |
| | | * @property {Array} selected æç¹ï¼æå¾
æ ¼å¼[{date: '2019-06-27', info: 'ç¾å°', data: { custom: 'èªå®ä¹ä¿¡æ¯', name: 'èªå®ä¹æ¶æ¯å¤´',xxx:xxx... }}] |
| | | * @property {Boolean} showMonth æ¯å¦éæ©æä»½ä¸ºèæ¯ |
| | | * @event {Function} change æ¥ææ¹åï¼`insert :ture` æ¶çæ |
| | | * @event {Function} confirm ç¡®è®¤éæ©`insert :false` æ¶çæ |
| | | * @event {Function} monthSwitch 忢æä»½æ¶è§¦å |
| | | * @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" /> |
| | | */ |
| | | export default { |
| | | components: { |
| | | calendarItem |
| | | }, |
| | | emits:['close','confirm','change','monthSwitch'], |
| | | props: { |
| | | date: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | selected: { |
| | | type: Array, |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | lunar: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | startDate: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | endDate: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | range: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | insert: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | showMonth: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | clearDate: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | show: false, |
| | | weeks: [], |
| | | calendar: {}, |
| | | nowDate: '', |
| | | aniMaskShow: false |
| | | } |
| | | }, |
| | | computed:{ |
| | | /** |
| | | * for i18n |
| | | */ |
| | | |
| | | okText() { |
| | | return t("uni-calender.ok") |
| | | }, |
| | | cancelText() { |
| | | return t("uni-calender.cancel") |
| | | }, |
| | | todayText() { |
| | | return t("uni-calender.today") |
| | | }, |
| | | monText() { |
| | | return t("uni-calender.MON") |
| | | }, |
| | | TUEText() { |
| | | return t("uni-calender.TUE") |
| | | }, |
| | | WEDText() { |
| | | return t("uni-calender.WED") |
| | | }, |
| | | THUText() { |
| | | return t("uni-calender.THU") |
| | | }, |
| | | FRIText() { |
| | | return t("uni-calender.FRI") |
| | | }, |
| | | SATText() { |
| | | return t("uni-calender.SAT") |
| | | }, |
| | | SUNText() { |
| | | return t("uni-calender.SUN") |
| | | }, |
| | | }, |
| | | watch: { |
| | | date(newVal) { |
| | | // this.cale.setDate(newVal) |
| | | this.init(newVal) |
| | | }, |
| | | startDate(val){ |
| | | this.cale.resetSatrtDate(val) |
| | | this.cale.setDate(this.nowDate.fullDate) |
| | | this.weeks = this.cale.weeks |
| | | }, |
| | | endDate(val){ |
| | | this.cale.resetEndDate(val) |
| | | this.cale.setDate(this.nowDate.fullDate) |
| | | this.weeks = this.cale.weeks |
| | | }, |
| | | selected(newVal) { |
| | | this.cale.setSelectInfo(this.nowDate.fullDate, newVal) |
| | | this.weeks = this.cale.weeks |
| | | } |
| | | }, |
| | | created() { |
| | | // è·åæ¥åæ¹æ³å®ä¾ |
| | | this.cale = new Calendar({ |
| | | // date: new Date(), |
| | | selected: this.selected, |
| | | startDate: this.startDate, |
| | | endDate: this.endDate, |
| | | range: this.range, |
| | | }) |
| | | // é䏿ä¸å¤© |
| | | // this.cale.setDate(this.date) |
| | | this.init(this.date) |
| | | // this.setDay |
| | | }, |
| | | methods: { |
| | | // åæ¶ç©¿é |
| | | clean() {}, |
| | | bindDateChange(e) { |
| | | const value = e.detail.value + '-1' |
| | | console.log(this.cale.getDate(value)); |
| | | this.init(value) |
| | | }, |
| | | /** |
| | | * åå§åæ¥ææ¾ç¤º |
| | | * @param {Object} date |
| | | */ |
| | | init(date) { |
| | | this.cale.setDate(date) |
| | | this.weeks = this.cale.weeks |
| | | this.nowDate = this.calendar = this.cale.getInfo(date) |
| | | }, |
| | | /** |
| | | * æå¼æ¥åå¼¹çª |
| | | */ |
| | | open() { |
| | | // å¼¹çªæ¨¡å¼å¹¶ä¸æ¸
çæ°æ® |
| | | if (this.clearDate && !this.insert) { |
| | | this.cale.cleanMultipleStatus() |
| | | // this.cale.setDate(this.date) |
| | | this.init(this.date) |
| | | } |
| | | this.show = true |
| | | this.$nextTick(() => { |
| | | setTimeout(() => { |
| | | this.aniMaskShow = true |
| | | }, 50) |
| | | }) |
| | | }, |
| | | /** |
| | | * å
³éæ¥åå¼¹çª |
| | | */ |
| | | close() { |
| | | this.aniMaskShow = false |
| | | this.$nextTick(() => { |
| | | setTimeout(() => { |
| | | this.show = false |
| | | this.$emit('close') |
| | | }, 300) |
| | | }) |
| | | }, |
| | | /** |
| | | * 确认æé® |
| | | */ |
| | | confirm() { |
| | | this.setEmit('confirm') |
| | | this.close() |
| | | }, |
| | | /** |
| | | * åå触å |
| | | */ |
| | | change() { |
| | | if (!this.insert) return |
| | | this.setEmit('change') |
| | | }, |
| | | /** |
| | | * éæ©æä»½è§¦å |
| | | */ |
| | | monthSwitch() { |
| | | let { |
| | | year, |
| | | month |
| | | } = this.nowDate |
| | | this.$emit('monthSwitch', { |
| | | year, |
| | | month: Number(month) |
| | | }) |
| | | }, |
| | | /** |
| | | * æ´¾åäºä»¶ |
| | | * @param {Object} name |
| | | */ |
| | | setEmit(name) { |
| | | let { |
| | | year, |
| | | month, |
| | | date, |
| | | fullDate, |
| | | lunar, |
| | | extraInfo |
| | | } = this.calendar |
| | | this.$emit(name, { |
| | | range: this.cale.multipleStatus, |
| | | year, |
| | | month, |
| | | date, |
| | | fulldate: fullDate, |
| | | lunar, |
| | | extraInfo: extraInfo || {} |
| | | }) |
| | | }, |
| | | /** |
| | | * éæ©å¤©è§¦å |
| | | * @param {Object} weeks |
| | | */ |
| | | choiceDate(weeks) { |
| | | if (weeks.disable) return |
| | | this.calendar = weeks |
| | | // 设置å¤é |
| | | this.cale.setMultiple(this.calendar.fullDate) |
| | | this.weeks = this.cale.weeks |
| | | this.change() |
| | | }, |
| | | /** |
| | | * åå°ä»å¤© |
| | | */ |
| | | backtoday() { |
| | | console.log(this.cale.getDate(new Date()).fullDate); |
| | | let date = this.cale.getDate(new Date()).fullDate |
| | | // this.cale.setDate(date) |
| | | this.init(date) |
| | | this.change() |
| | | }, |
| | | /** |
| | | * ä¸ä¸ªæ |
| | | */ |
| | | pre() { |
| | | const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate |
| | | this.setDate(preDate) |
| | | this.monthSwitch() |
| | | |
| | | }, |
| | | /** |
| | | * ä¸ä¸ªæ |
| | | */ |
| | | next() { |
| | | const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate |
| | | this.setDate(nextDate) |
| | | this.monthSwitch() |
| | | }, |
| | | /** |
| | | * è®¾ç½®æ¥æ |
| | | * @param {Object} date |
| | | */ |
| | | setDate(date) { |
| | | this.cale.setDate(date) |
| | | this.weeks = this.cale.weeks |
| | | this.nowDate = this.cale.getInfo(date) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .uni-calendar { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | } |
| | | |
| | | .uni-calendar__mask { |
| | | position: fixed; |
| | | bottom: 0; |
| | | top: 0; |
| | | left: 0; |
| | | right: 0; |
| | | background-color: $uni-bg-color-mask; |
| | | transition-property: opacity; |
| | | transition-duration: 0.3s; |
| | | opacity: 0; |
| | | /* #ifndef APP-NVUE */ |
| | | z-index: 99; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-calendar--mask-show { |
| | | opacity: 1 |
| | | } |
| | | |
| | | .uni-calendar--fixed { |
| | | position: fixed; |
| | | /* #ifdef APP-NVUE */ |
| | | bottom: 0; |
| | | /* #endif */ |
| | | left: 0; |
| | | right: 0; |
| | | transition-property: transform; |
| | | transition-duration: 0.3s; |
| | | transform: translateY(460px); |
| | | /* #ifndef APP-NVUE */ |
| | | bottom: calc(var(--window-bottom)); |
| | | z-index: 99; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-calendar--ani-show { |
| | | transform: translateY(0); |
| | | } |
| | | |
| | | .uni-calendar__content { |
| | | background-color: #fff; |
| | | } |
| | | |
| | | .uni-calendar__header { |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | justify-content: center; |
| | | align-items: center; |
| | | height: 50px; |
| | | border-bottom-color: $uni-border-color; |
| | | border-bottom-style: solid; |
| | | border-bottom-width: 1px; |
| | | } |
| | | |
| | | .uni-calendar--fixed-top { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | justify-content: space-between; |
| | | border-top-color: $uni-border-color; |
| | | border-top-style: solid; |
| | | border-top-width: 1px; |
| | | } |
| | | |
| | | .uni-calendar--fixed-width { |
| | | width: 50px; |
| | | // padding: 0 15px; |
| | | } |
| | | |
| | | .uni-calendar__backtoday { |
| | | position: absolute; |
| | | right: 0; |
| | | top: 25rpx; |
| | | padding: 0 5px; |
| | | padding-left: 10px; |
| | | height: 25px; |
| | | line-height: 25px; |
| | | font-size: 12px; |
| | | border-top-left-radius: 25px; |
| | | border-bottom-left-radius: 25px; |
| | | color: $uni-text-color; |
| | | background-color: $uni-bg-color-hover; |
| | | } |
| | | |
| | | .uni-calendar__header-text { |
| | | text-align: center; |
| | | width: 100px; |
| | | font-size: $uni-font-size-base; |
| | | color: $uni-text-color; |
| | | } |
| | | |
| | | .uni-calendar__header-btn-box { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | align-items: center; |
| | | justify-content: center; |
| | | width: 50px; |
| | | height: 50px; |
| | | } |
| | | |
| | | .uni-calendar__header-btn { |
| | | width: 10px; |
| | | height: 10px; |
| | | border-left-color: $uni-text-color-placeholder; |
| | | border-left-style: solid; |
| | | border-left-width: 2px; |
| | | border-top-color: $uni-color-subtitle; |
| | | border-top-style: solid; |
| | | border-top-width: 2px; |
| | | } |
| | | |
| | | .uni-calendar--left { |
| | | transform: rotate(-45deg); |
| | | } |
| | | |
| | | .uni-calendar--right { |
| | | transform: rotate(135deg); |
| | | } |
| | | |
| | | |
| | | .uni-calendar__weeks { |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | } |
| | | |
| | | .uni-calendar__weeks-item { |
| | | flex: 1; |
| | | } |
| | | |
| | | .uni-calendar__weeks-day { |
| | | flex: 1; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | align-items: center; |
| | | height: 45px; |
| | | border-bottom-color: #F5F5F5; |
| | | border-bottom-style: solid; |
| | | border-bottom-width: 1px; |
| | | } |
| | | |
| | | .uni-calendar__weeks-day-text { |
| | | font-size: 14px; |
| | | } |
| | | |
| | | .uni-calendar__box { |
| | | position: relative; |
| | | } |
| | | |
| | | .uni-calendar__box-bg { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | justify-content: center; |
| | | align-items: center; |
| | | position: absolute; |
| | | top: 0; |
| | | left: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | } |
| | | |
| | | .uni-calendar__box-bg-text { |
| | | font-size: 200px; |
| | | font-weight: bold; |
| | | color: $uni-text-color-grey; |
| | | opacity: 0.1; |
| | | text-align: center; |
| | | /* #ifndef APP-NVUE */ |
| | | line-height: 1; |
| | | /* #endif */ |
| | | } |
| | | </style> |
| New file |
| | |
| | | import CALENDAR from './calendar.js' |
| | | |
| | | class Calendar { |
| | | constructor({ |
| | | date, |
| | | selected, |
| | | startDate, |
| | | endDate, |
| | | range |
| | | } = {}) { |
| | | // å½åæ¥æ |
| | | this.date = this.getDate(new Date()) // å½ååå
¥æ¥æ |
| | | // æç¹ä¿¡æ¯ |
| | | this.selected = selected || []; |
| | | // èå´å¼å§ |
| | | this.startDate = startDate |
| | | // èå´ç»æ |
| | | this.endDate = endDate |
| | | this.range = range |
| | | // å¤éç¶æ |
| | | this.cleanMultipleStatus() |
| | | // æ¯å¨æ¥æ |
| | | this.weeks = {} |
| | | // this._getWeek(this.date.fullDate) |
| | | } |
| | | /** |
| | | * è®¾ç½®æ¥æ |
| | | * @param {Object} date |
| | | */ |
| | | setDate(date) { |
| | | this.selectDate = this.getDate(date) |
| | | this._getWeek(this.selectDate.fullDate) |
| | | } |
| | | |
| | | /** |
| | | * æ¸
çå¤éç¶æ |
| | | */ |
| | | cleanMultipleStatus() { |
| | | this.multipleStatus = { |
| | | before: '', |
| | | after: '', |
| | | data: [] |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éç½®å¼å§æ¥æ |
| | | */ |
| | | resetSatrtDate(startDate) { |
| | | // èå´å¼å§ |
| | | this.startDate = startDate |
| | | |
| | | } |
| | | |
| | | /** |
| | | * éç½®ç»ææ¥æ |
| | | */ |
| | | resetEndDate(endDate) { |
| | | // èå´ç»æ |
| | | this.endDate = endDate |
| | | } |
| | | |
| | | /** |
| | | * è·åä»»ææ¶é´ |
| | | */ |
| | | getDate(date, AddDayCount = 0, str = 'day') { |
| | | if (!date) { |
| | | date = new Date() |
| | | } |
| | | if (typeof date !== 'object') { |
| | | date = date.replace(/-/g, '/') |
| | | } |
| | | const dd = new Date(date) |
| | | switch (str) { |
| | | case 'day': |
| | | dd.setDate(dd.getDate() + AddDayCount) // è·åAddDayCount天åçæ¥æ |
| | | break |
| | | case 'month': |
| | | if (dd.getDate() === 31) { |
| | | dd.setDate(dd.getDate() + AddDayCount) |
| | | } else { |
| | | dd.setMonth(dd.getMonth() + AddDayCount) // è·åAddDayCount天åçæ¥æ |
| | | } |
| | | break |
| | | case 'year': |
| | | dd.setFullYear(dd.getFullYear() + AddDayCount) // è·åAddDayCount天åçæ¥æ |
| | | break |
| | | } |
| | | const y = dd.getFullYear() |
| | | const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // è·åå½åæä»½çæ¥æï¼ä¸è¶³10è¡¥0 |
| | | const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // è·åå½åå å·ï¼ä¸è¶³10è¡¥0 |
| | | return { |
| | | fullDate: y + '-' + m + '-' + d, |
| | | year: y, |
| | | month: m, |
| | | date: d, |
| | | day: dd.getDay() |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è·å䏿å©ä½å¤©æ° |
| | | */ |
| | | _getLastMonthDays(firstDay, full) { |
| | | let dateArr = [] |
| | | for (let i = firstDay; i > 0; i--) { |
| | | const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate() |
| | | dateArr.push({ |
| | | date: beforeDate, |
| | | month: full.month - 1, |
| | | lunar: this.getlunar(full.year, full.month - 1, beforeDate), |
| | | disable: true |
| | | }) |
| | | } |
| | | return dateArr |
| | | } |
| | | /** |
| | | * è·åæ¬æå¤©æ° |
| | | */ |
| | | _currentMonthDys(dateData, full) { |
| | | let dateArr = [] |
| | | let fullDate = this.date.fullDate |
| | | for (let i = 1; i <= dateData; i++) { |
| | | let isinfo = false |
| | | let nowDate = full.year + '-' + (full.month < 10 ? |
| | | full.month : full.month) + '-' + (i < 10 ? |
| | | '0' + i : i) |
| | | // æ¯å¦ä»å¤© |
| | | let isDay = fullDate === nowDate |
| | | // è·åæç¹ä¿¡æ¯ |
| | | let info = this.selected && this.selected.find((item) => { |
| | | if (this.dateEqual(nowDate, item.date)) { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | // æ¥æç¦ç¨ |
| | | let disableBefore = true |
| | | let disableAfter = true |
| | | if (this.startDate) { |
| | | // let dateCompBefore = this.dateCompare(this.startDate, fullDate) |
| | | // disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate) |
| | | disableBefore = this.dateCompare(this.startDate, nowDate) |
| | | } |
| | | |
| | | if (this.endDate) { |
| | | // let dateCompAfter = this.dateCompare(fullDate, this.endDate) |
| | | // disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate) |
| | | disableAfter = this.dateCompare(nowDate, this.endDate) |
| | | } |
| | | let multiples = this.multipleStatus.data |
| | | let checked = false |
| | | let multiplesStatus = -1 |
| | | if (this.range) { |
| | | if (multiples) { |
| | | multiplesStatus = multiples.findIndex((item) => { |
| | | return this.dateEqual(item, nowDate) |
| | | }) |
| | | } |
| | | if (multiplesStatus !== -1) { |
| | | checked = true |
| | | } |
| | | } |
| | | let data = { |
| | | fullDate: nowDate, |
| | | year: full.year, |
| | | date: i, |
| | | multiple: this.range ? checked : false, |
| | | beforeMultiple: this.dateEqual(this.multipleStatus.before, nowDate), |
| | | afterMultiple: this.dateEqual(this.multipleStatus.after, nowDate), |
| | | month: full.month, |
| | | lunar: this.getlunar(full.year, full.month, i), |
| | | disable: !(disableBefore && disableAfter), |
| | | isDay |
| | | } |
| | | if (info) { |
| | | data.extraInfo = info |
| | | } |
| | | |
| | | dateArr.push(data) |
| | | } |
| | | return dateArr |
| | | } |
| | | /** |
| | | * è·åä¸æå¤©æ° |
| | | */ |
| | | _getNextMonthDays(surplus, full) { |
| | | let dateArr = [] |
| | | for (let i = 1; i < surplus + 1; i++) { |
| | | dateArr.push({ |
| | | date: i, |
| | | month: Number(full.month) + 1, |
| | | lunar: this.getlunar(full.year, Number(full.month) + 1, i), |
| | | disable: true |
| | | }) |
| | | } |
| | | return dateArr |
| | | } |
| | | |
| | | /** |
| | | * è·åå½åæ¥æè¯¦æ
|
| | | * @param {Object} date |
| | | */ |
| | | getInfo(date) { |
| | | if (!date) { |
| | | date = new Date() |
| | | } |
| | | const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate) |
| | | return dateInfo |
| | | } |
| | | |
| | | /** |
| | | * æ¯è¾æ¶é´å¤§å° |
| | | */ |
| | | dateCompare(startDate, endDate) { |
| | | // è®¡ç®æªæ¢æ¶é´ |
| | | startDate = new Date(startDate.replace('-', '/').replace('-', '/')) |
| | | // 计ç®è¯¦ç»é¡¹çæªæ¢æ¶é´ |
| | | endDate = new Date(endDate.replace('-', '/').replace('-', '/')) |
| | | if (startDate <= endDate) { |
| | | return true |
| | | } else { |
| | | return false |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¯è¾æ¶é´æ¯å¦ç¸ç |
| | | */ |
| | | dateEqual(before, after) { |
| | | // è®¡ç®æªæ¢æ¶é´ |
| | | before = new Date(before.replace('-', '/').replace('-', '/')) |
| | | // 计ç®è¯¦ç»é¡¹çæªæ¢æ¶é´ |
| | | after = new Date(after.replace('-', '/').replace('-', '/')) |
| | | if (before.getTime() - after.getTime() === 0) { |
| | | return true |
| | | } else { |
| | | return false |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è·åæ¥æèå´å
æææ¥æ |
| | | * @param {Object} begin |
| | | * @param {Object} end |
| | | */ |
| | | geDateAll(begin, end) { |
| | | var arr = [] |
| | | var ab = begin.split('-') |
| | | var ae = end.split('-') |
| | | var db = new Date() |
| | | db.setFullYear(ab[0], ab[1] - 1, ab[2]) |
| | | var de = new Date() |
| | | de.setFullYear(ae[0], ae[1] - 1, ae[2]) |
| | | var unixDb = db.getTime() - 24 * 60 * 60 * 1000 |
| | | var unixDe = de.getTime() - 24 * 60 * 60 * 1000 |
| | | for (var k = unixDb; k <= unixDe;) { |
| | | k = k + 24 * 60 * 60 * 1000 |
| | | arr.push(this.getDate(new Date(parseInt(k))).fullDate) |
| | | } |
| | | return arr |
| | | } |
| | | /** |
| | | * 计ç®é´åæ¥ææ¾ç¤º |
| | | */ |
| | | getlunar(year, month, date) { |
| | | return CALENDAR.solar2lunar(year, month, date) |
| | | } |
| | | /** |
| | | * 设置æç¹ |
| | | */ |
| | | setSelectInfo(data, value) { |
| | | this.selected = value |
| | | this._getWeek(data) |
| | | } |
| | | |
| | | /** |
| | | * è·åå¤éç¶æ |
| | | */ |
| | | setMultiple(fullDate) { |
| | | let { |
| | | before, |
| | | after |
| | | } = this.multipleStatus |
| | | |
| | | if (!this.range) return |
| | | if (before && after) { |
| | | this.multipleStatus.before = '' |
| | | this.multipleStatus.after = '' |
| | | this.multipleStatus.data = [] |
| | | } else { |
| | | if (!before) { |
| | | this.multipleStatus.before = fullDate |
| | | } else { |
| | | this.multipleStatus.after = fullDate |
| | | if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { |
| | | this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after); |
| | | } else { |
| | | this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before); |
| | | } |
| | | } |
| | | } |
| | | this._getWeek(fullDate) |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¯å¨æ°æ® |
| | | * @param {Object} dateData |
| | | */ |
| | | _getWeek(dateData) { |
| | | const { |
| | | fullDate, |
| | | year, |
| | | month, |
| | | date, |
| | | day |
| | | } = this.getDate(dateData) |
| | | let firstDay = new Date(year, month - 1, 1).getDay() |
| | | let currentDay = new Date(year, month, 0).getDate() |
| | | let dates = { |
| | | lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // ä¸ä¸ªææ«å°¾å 天 |
| | | currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // æ¬æå¤©æ° |
| | | nextMonthDays: [], // ä¸ä¸ªæå¼å§å 天 |
| | | weeks: [] |
| | | } |
| | | let canlender = [] |
| | | const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length) |
| | | dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData)) |
| | | canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays) |
| | | let weeks = {} |
| | | // æ¼æ¥æ°ç» ä¸ä¸ªæå¼å§å 天 + æ¬æå¤©æ°+ ä¸ä¸ªæå¼å§å 天 |
| | | for (let i = 0; i < canlender.length; i++) { |
| | | if (i % 7 === 0) { |
| | | weeks[parseInt(i / 7)] = new Array(7) |
| | | } |
| | | weeks[parseInt(i / 7)][i % 7] = canlender[i] |
| | | } |
| | | this.canlender = canlender |
| | | this.weeks = weeks |
| | | } |
| | | |
| | | //éææ¹æ³ |
| | | // static init(date) { |
| | | // if (!this.instance) { |
| | | // this.instance = new Calendar(date); |
| | | // } |
| | | // return this.instance; |
| | | // } |
| | | } |
| | | |
| | | |
| | | export default Calendar |
| New file |
| | |
| | | { |
| | | "id": "uni-calendar", |
| | | "displayName": "uni-calendar æ¥å", |
| | | "version": "1.4.5", |
| | | "description": "æ¥åç»ä»¶", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "æ¥å", |
| | | "", |
| | | "æå¡", |
| | | "æ¥åéæ©" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Calendar æ¥å |
| | | > **ç»ä»¶åï¼uni-calendar** |
| | | > 代ç åï¼ `uCalendar` |
| | | |
| | | |
| | | æ¥åç»ä»¶ |
| | | |
| | | > **注æäºé¡¹** |
| | | > 为äºé¿å
é误使ç¨ï¼ç»å¤§å®¶å¸¦æ¥ä¸å¥½çå¼åä½éªï¼è¯·å¨ä½¿ç¨ç»ä»¶åä»ç»é
读ä¸é¢ç注æäºé¡¹ï¼å¯ä»¥å¸®ä½ é¿å
ä¸äºé误ã |
| | | > - æ¬ç»ä»¶åå转æ¢ä½¿ç¨çjsæ¯ [@1900-2100åºé´å
çå
¬åãååäºè½¬](https://github.com/jjonline/calendar.js) |
| | | > - ä»
æ¯æèªå®ä¹ç»ä»¶æ¨¡å¼ |
| | | > - `date`屿§ä¼ å
¥çåºè¯¥æ¯ä¸ä¸ª String ï¼å¦ï¼ 2019-06-27 ï¼è䏿¯ new Date() |
| | | > - éè¿ `insert` 屿§æ¥ç¡®å®å½åçäºä»¶æ¯ @change è¿æ¯ @confirm ãçåºå并为ä¸ä¸ªäºä»¶ï¼ä½æ¯ä¸ºäºåºå模å¼ï¼ç°ä½¿ç¨ä¸¤ä¸ªäºä»¶ï¼è¿ééè¦æ³¨æ |
| | | > - å¼¹çªæ¨¡å¼ä¸æ æ³é»æ¢åé¢çå
ç´ æ»å¨ï¼å¦æéè¦é»æ¢ï¼è¯·å¨å¼¹çªå¼¹åºåï¼æå¨è®¾ç½®æ»å¨å
ç´ ä¸ºä¸å¯æ»å¨ |
| | | |
| | | |
| | | ### å®è£
æ¹å¼ |
| | | |
| | | æ¬ç»ä»¶ç¬¦å[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)è§èï¼`HBuilderX 2.5.5`èµ·ï¼åªéå°æ¬ç»ä»¶å¯¼å
¥é¡¹ç®ï¼å¨é¡µé¢`template`ä¸å³å¯ç´æ¥ä½¿ç¨ï¼æ éå¨é¡µé¢ä¸`import`åæ³¨å`components`ã |
| | | |
| | | å¦ééè¿`npm`æ¹å¼ä½¿ç¨`uni-ui`ç»ä»¶ï¼å¦è§ææ¡£ï¼[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55) |
| | | |
| | | ### åºæ¬ç¨æ³ |
| | | |
| | | å¨ ``template`` ä¸ä½¿ç¨ç»ä»¶ |
| | | |
| | | ```html |
| | | <view> |
| | | <uni-calendar |
| | | :insert="true" |
| | | :lunar="true" |
| | | :start-date="'2019-3-2'" |
| | | :end-date="'2019-5-20'" |
| | | @change="change" |
| | | /> |
| | | </view> |
| | | ``` |
| | | |
| | | ### éè¿æ¹æ³æå¼æ¥å |
| | | |
| | | éè¦è®¾ç½® `insert` 为 `false` |
| | | |
| | | ```html |
| | | <view> |
| | | <uni-calendar |
| | | ref="calendar" |
| | | :insert="false" |
| | | @confirm="confirm" |
| | | /> |
| | | <button @click="open">æå¼æ¥å</button> |
| | | </view> |
| | | ``` |
| | | |
| | | ```javascript |
| | | |
| | | export default { |
| | | data() { |
| | | return {}; |
| | | }, |
| | | methods: { |
| | | open(){ |
| | | this.$refs.calendar.open(); |
| | | }, |
| | | confirm(e) { |
| | | console.log(e); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | ``` |
| | | |
| | | |
| | | ## API |
| | | |
| | | ### Calendar Props |
| | | |
| | | | 屿§å | ç±»å | é»è®¤å¼| 说æ | |
| | | | | | |
| | | | date | String |- | èªå®ä¹å½åæ¶é´ï¼é»è®¤ä¸ºä»å¤© | |
| | | | lunar | Boolean | false | æ¾ç¤ºåå | |
| | | | startDate | String |- | æ¥æéæ©èå´-å¼å§æ¥æ | |
| | | | endDate | String |- | æ¥æéæ©èå´-ç»ææ¥æ | |
| | | | range | Boolean | false | èå´éæ© | |
| | | | insert | Boolean | false | æå
¥æ¨¡å¼,å¯éå¼ï¼tureï¼æå
¥æ¨¡å¼ï¼falseï¼å¼¹çªæ¨¡å¼ï¼é»è®¤ä¸ºæå
¥æ¨¡å¼ | |
| | | |clearDate |Boolean |true |å¼¹çªæ¨¡å¼æ¯å¦æ¸
ç©ºä¸æ¬¡éæ©å
容 | |
| | | | selected | Array |- | æç¹ï¼æå¾
æ ¼å¼[{date: '2019-06-27', info: 'ç¾å°', data: { custom: 'èªå®ä¹ä¿¡æ¯', name: 'èªå®ä¹æ¶æ¯å¤´',xxx:xxx... }}] | |
| | | |showMonth | Boolean | true | æ¯å¦æ¾ç¤ºæä»½ä¸ºèæ¯ | |
| | | |
| | | ### Calendar Events |
| | | |
| | | | äºä»¶å | 说æ |è¿åå¼| |
| | | | | | | |
| | | | open | å¼¹åºæ¥åç»ä»¶ï¼`insert :false` æ¶çæ|- | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | ## ç»ä»¶ç¤ºä¾ |
| | | |
| | | ç¹å»æ¥çï¼[https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar](https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar) |
| New file |
| | |
| | | ## 1.3.1ï¼2021-12-20ï¼ |
| | | - ä¿®å¤ å¨vue页é¢ä¸ç¥ç¼©å¾æ¾ç¤ºä¸æ£å¸¸çbug |
| | | ## 1.3.0ï¼2021-11-19ï¼ |
| | | - éæææ§½çç¨æ³ ï¼header æ¿æ¢ä¸º title |
| | | - æ°å¢ actions ææ§½ |
| | | - æ°å¢ cover å°é¢å¾å±æ§åææ§½ |
| | | - æ°å¢ padding å
容é»è®¤å
è¾¹è·ç¦» |
| | | - æ°å¢ margin å¡çé»è®¤å¤è¾¹è·ç¦» |
| | | - æ°å¢ spacing å¡çé»è®¤å
è¾¹è· |
| | | - æ°å¢ shadow å¡çé´å½±å±æ§ |
| | | - åæ¶ mode 屿§ï¼å¯ä½¿ç¨ç»åææ§½ä»£æ¿ |
| | | - åæ¶ note 屿§ ï¼ä½¿ç¨actionsææ§½ä»£æ¿ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-card](https://uniapp.dcloud.io/component/uniui/uni-card) |
| | | ## 1.2.1ï¼2021-07-30ï¼ |
| | | - ä¼å vue3ä¸äºä»¶è¦åçé®é¢ |
| | | ## 1.2.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.1.8ï¼2021-07-01ï¼ |
| | | - ä¼å 徿å¡çæ å¾çå è½½æ¶ï¼æä¾å ä½å¾æ |
| | | - æ°å¢ header ææ§½ï¼èªå®ä¹å¡ç头é¨ï¼ 徿å¡ç mode="style" æ¶ï¼ä¸æ¯æï¼ |
| | | - ä¿®å¤ thumbnail ä¸åå¨ä»ç¶å ä½ç bug |
| | | ## 1.1.7ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.1.6ï¼2021-02-04ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | <template> |
| | | <view class="uni-card" :class="{ 'uni-card--full': isFull, 'uni-card--shadow': isShadow,'uni-card--border':border}" |
| | | :style="{'margin':isFull?0:margin,'padding':spacing,'box-shadow':isShadow?shadow:''}"> |
| | | <!-- å°é¢ --> |
| | | <slot name="cover"> |
| | | <view v-if="cover" class="uni-card__cover"> |
| | | <image class="uni-card__cover-image" mode="widthFix" @click="onClick('cover')" :src="cover"></image> |
| | | </view> |
| | | </slot> |
| | | <slot name="title"> |
| | | <view v-if="title || extra" class="uni-card__header"> |
| | | <!-- å¡çæ é¢ --> |
| | | <view class="uni-card__header-box" @click="onClick('title')"> |
| | | <view v-if="thumbnail" class="uni-card__header-avatar"> |
| | | <image class="uni-card__header-avatar-image" :src="thumbnail" mode="aspectFit" /> |
| | | </view> |
| | | <view class="uni-card__header-content"> |
| | | <text class="uni-card__header-content-title uni-ellipsis">{{ title }}</text> |
| | | <text v-if="title&&subTitle" |
| | | class="uni-card__header-content-subtitle uni-ellipsis">{{ subTitle }}</text> |
| | | </view> |
| | | </view> |
| | | <view class="uni-card__header-extra" @click="onClick('extra')"> |
| | | <text class="uni-card__header-extra-text">{{ extra }}</text> |
| | | </view> |
| | | </view> |
| | | </slot> |
| | | <!-- å¡çå
容 --> |
| | | <view class="uni-card__content" :style="{padding:padding}" @click="onClick('content')"> |
| | | <slot></slot> |
| | | </view> |
| | | <view class="uni-card__actions" @click="onClick('actions')"> |
| | | <slot name="actions"></slot> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * Card å¡ç |
| | | * @description å¡çè§å¾ç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=22 |
| | | * @property {String} title æ 颿å |
| | | * @property {String} subTitle 坿 é¢ |
| | | * @property {Number} padding å
容å
è¾¹è· |
| | | * @property {Number} margin å¡çå¤è¾¹è· |
| | | * @property {Number} spacing å¡çå
è¾¹è· |
| | | * @property {String} extra æ é¢é¢å¤ä¿¡æ¯ |
| | | * @property {String} cover å°é¢å¾ï¼æ¬å°è·¯å¾éè¦å¼å
¥ï¼ |
| | | * @property {String} thumbnail æ é¢å·¦ä¾§ç¼©ç¥å¾ |
| | | * @property {Boolean} is-full = [true | false] å¡çå
容æ¯å¦éæ ï¼ä¸º true æ¶å°å»é¤paddingå¼ |
| | | * @property {Boolean} is-shadow = [true | false] å¡çå
容æ¯å¦å¼å¯é´å½± |
| | | * @property {String} shadow å¡çé´å½± |
| | | * @property {Boolean} border å¡çè¾¹æ¡ |
| | | * @event {Function} click ç¹å» Card 触åäºä»¶ |
| | | */ |
| | | export default { |
| | | name: 'UniCard', |
| | | emits: ['click'], |
| | | props: { |
| | | title: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | subTitle: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | padding: { |
| | | type: String, |
| | | default: '10px' |
| | | }, |
| | | margin: { |
| | | type: String, |
| | | default: '15px' |
| | | }, |
| | | spacing: { |
| | | type: String, |
| | | default: '0 10px' |
| | | }, |
| | | extra: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | cover: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | thumbnail: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | isFull: { |
| | | // å
容åºåæ¯å¦éæ |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | isShadow: { |
| | | // æ¯å¦å¼å¯é´å½± |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | shadow: { |
| | | type: String, |
| | | default: '0px 0px 3px 1px rgba(0, 0, 0, 0.08)' |
| | | }, |
| | | border: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | methods: { |
| | | onClick(type) { |
| | | this.$emit('click', type) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | $uni-border-3: #EBEEF5 !default; |
| | | $uni-shadow-base:0 0px 6px 1px rgba($color: #a5a5a5, $alpha: 0.2) !default; |
| | | $uni-main-color: #3a3a3a !default; |
| | | $uni-base-color: #6a6a6a !default; |
| | | $uni-secondary-color: #909399 !default; |
| | | $uni-spacing-sm: 8px !default; |
| | | $uni-border-color:$uni-border-3; |
| | | $uni-shadow: $uni-shadow-base; |
| | | $uni-card-title: 15px; |
| | | $uni-cart-title-color:$uni-main-color; |
| | | $uni-card-subtitle: 12px; |
| | | $uni-cart-subtitle-color:$uni-secondary-color; |
| | | $uni-card-spacing: 10px; |
| | | $uni-card-content-color: $uni-base-color; |
| | | |
| | | .uni-card { |
| | | margin: $uni-card-spacing; |
| | | padding: 0 $uni-spacing-sm; |
| | | border-radius: 4px; |
| | | overflow: hidden; |
| | | font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif; |
| | | background-color: #fff; |
| | | flex: 1; |
| | | |
| | | .uni-card__cover { |
| | | position: relative; |
| | | margin-top: $uni-card-spacing; |
| | | flex-direction: row; |
| | | overflow: hidden; |
| | | border-radius: 4px; |
| | | .uni-card__cover-image { |
| | | flex: 1; |
| | | // width: 100%; |
| | | /* #ifndef APP-PLUS */ |
| | | vertical-align: middle; |
| | | /* #endif */ |
| | | } |
| | | } |
| | | |
| | | .uni-card__header { |
| | | display: flex; |
| | | border-bottom: 1px $uni-border-color solid; |
| | | flex-direction: row; |
| | | align-items: center; |
| | | padding: $uni-card-spacing; |
| | | overflow: hidden; |
| | | |
| | | .uni-card__header-box { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex: 1; |
| | | flex-direction: row; |
| | | align-items: center; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-card__header-avatar { |
| | | width: 40px; |
| | | height: 40px; |
| | | overflow: hidden; |
| | | border-radius: 5px; |
| | | margin-right: $uni-card-spacing; |
| | | .uni-card__header-avatar-image { |
| | | flex: 1; |
| | | width: 40px; |
| | | height: 40px; |
| | | } |
| | | } |
| | | |
| | | .uni-card__header-content { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | flex: 1; |
| | | // height: 40px; |
| | | overflow: hidden; |
| | | |
| | | .uni-card__header-content-title { |
| | | font-size: $uni-card-title; |
| | | color: $uni-cart-title-color; |
| | | // line-height: 22px; |
| | | } |
| | | |
| | | .uni-card__header-content-subtitle { |
| | | font-size: $uni-card-subtitle; |
| | | margin-top: 5px; |
| | | color: $uni-cart-subtitle-color; |
| | | } |
| | | } |
| | | |
| | | .uni-card__header-extra { |
| | | line-height: 12px; |
| | | |
| | | .uni-card__header-extra-text { |
| | | font-size: 12px; |
| | | color: $uni-cart-subtitle-color; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .uni-card__content { |
| | | padding: $uni-card-spacing; |
| | | font-size: 14px; |
| | | color: $uni-card-content-color; |
| | | line-height: 22px; |
| | | } |
| | | |
| | | .uni-card__actions { |
| | | font-size: 12px; |
| | | } |
| | | } |
| | | |
| | | .uni-card--border { |
| | | border: 1px solid $uni-border-color; |
| | | } |
| | | |
| | | .uni-card--shadow { |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | box-shadow: $uni-shadow; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-card--full { |
| | | margin: 0; |
| | | border-left-width: 0; |
| | | border-left-width: 0; |
| | | border-radius: 0; |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | .uni-card--full:after { |
| | | border-radius: 0; |
| | | } |
| | | |
| | | /* #endif */ |
| | | .uni-ellipsis { |
| | | /* #ifndef APP-NVUE */ |
| | | overflow: hidden; |
| | | white-space: nowrap; |
| | | text-overflow: ellipsis; |
| | | /* #endif */ |
| | | /* #ifdef APP-NVUE */ |
| | | lines: 1; |
| | | /* #endif */ |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-card", |
| | | "displayName": "uni-card å¡ç", |
| | | "version": "1.3.1", |
| | | "description": "Card ç»ä»¶ï¼æä¾å¸¸è§çå¡çæ ·å¼ã", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "card", |
| | | "", |
| | | "å¡ç" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-icons", |
| | | "uni-scss" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Card å¡ç |
| | | > **ç»ä»¶åï¼uni-card** |
| | | > 代ç åï¼ `uCard` |
| | | |
| | | å¡çè§å¾ç»ä»¶ã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-card) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| | | |
| | | |
| New file |
| | |
| | | ## 1.4.3ï¼2022-01-25ï¼ |
| | | - ä¿®å¤ åå§åçæ¶å ï¼open 屿§å¤±æçbug |
| | | ## 1.4.2ï¼2022-01-21ï¼ |
| | | - ä¿®å¤ å¾®ä¿¡å°ç¨åºresizeåç»ä»¶æ¶èµ·çbug |
| | | ## 1.4.1ï¼2021-11-22ï¼ |
| | | - ä¿®å¤ vue3ä¸ä¸ªå«scssåéæ æ³æ¾å°çé®é¢ |
| | | ## 1.4.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-collapse](https://uniapp.dcloud.io/component/uniui/uni-collapse) |
| | | ## 1.3.3ï¼2021-08-17ï¼ |
| | | - ä¼å show-arrow 屿§é»è®¤ä¸ºtrue |
| | | ## 1.3.2ï¼2021-08-17ï¼ |
| | | - æ°å¢ show-arrow 屿§ï¼æ§å¶æ¯å¦æ¾ç¤ºå³ä¾§ç®å¤´ |
| | | ## 1.3.1ï¼2021-07-30ï¼ |
| | | - ä¼å vue3ä¸å°ç¨åºäºä»¶è¦åçé®é¢ |
| | | ## 1.3.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.2.2ï¼2021-07-21ï¼ |
| | | - ä¿®å¤ ç±1.2.0çæ¬å¼èµ·ç change äºä»¶è¿å undefined çBug |
| | | ## 1.2.1ï¼2021-07-21ï¼ |
| | | - ä¼å ç»ä»¶ç¤ºä¾ |
| | | ## 1.2.0ï¼2021-07-21ï¼ |
| | | - æ°å¢ ç»ä»¶æå å¨ç» |
| | | - æ°å¢ value\v-model 屿§ ï¼å¨æä¿®æ¹é¢æ¿æå ç¶æ |
| | | - æ°å¢ title ææ§½ ï¼å¯å®ä¹é¢æ¿æ é¢ |
| | | - æ°å¢ border 屿§ ï¼æ¾ç¤ºéè颿¿å
容åé线 |
| | | - æ°å¢ title-border 屿§ ï¼æ¾ç¤ºéè颿¿æ é¢åé线 |
| | | - ä¿®å¤ resize æ¹æ³å¤±æçBug |
| | | - ä¿®å¤ change äºä»¶è¿å忰䏿£ç¡®çBug |
| | | - ä¼å H5ãApp å¹³å°èªå¨æ´å
·å
å®¹æ´æ°é«åº¦ï¼æ éè°ç¨ reszie() æ¹æ³ |
| | | ## 1.1.7ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.1.6ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | ## 1.1.5ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | <template> |
| | | <view class="uni-collapse-item"> |
| | | <!-- onClick(!isOpen) --> |
| | | <view @click="onClick(!isOpen)" class="uni-collapse-item__title" |
| | | :class="{'is-open':isOpen &&titleBorder === 'auto' ,'uni-collapse-item-border':titleBorder !== 'none'}"> |
| | | <view class="uni-collapse-item__title-wrap"> |
| | | <slot name="title"> |
| | | <view class="uni-collapse-item__title-box" :class="{'is-disabled':disabled}"> |
| | | <image v-if="thumb" :src="thumb" class="uni-collapse-item__title-img" /> |
| | | <text class="uni-collapse-item__title-text">{{ title }}</text> |
| | | </view> |
| | | </slot> |
| | | </view> |
| | | <view v-if="showArrow" |
| | | :class="{ 'uni-collapse-item__title-arrow-active': isOpen, 'uni-collapse-item--animation': showAnimation === true }" |
| | | class="uni-collapse-item__title-arrow"> |
| | | <uni-icons :color="disabled?'#ddd':'#bbb'" size="14" type="bottom" /> |
| | | </view> |
| | | </view> |
| | | <view class="uni-collapse-item__wrap" :class="{'is--transition':showAnimation}" |
| | | :style="{height: (isOpen?height:0) +'px'}"> |
| | | <view :id="elId" ref="collapse--hook" class="uni-collapse-item__wrap-content" |
| | | :class="{open:isheight,'uni-collapse-item--border':border&&isOpen}"> |
| | | <slot></slot> |
| | | </view> |
| | | </view> |
| | | |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | // #ifdef APP-NVUE |
| | | const dom = weex.requireModule('dom') |
| | | // #endif |
| | | /** |
| | | * CollapseItem æå 颿¿åç»ä»¶ |
| | | * @description æå 颿¿åç»ä»¶ |
| | | * @property {String} title æ 颿å |
| | | * @property {String} thumb æ é¢å·¦ä¾§ç¼©ç¥å¾ |
| | | * @property {String} name å¯ä¸æ å¿ç¬¦ |
| | | * @property {Boolean} open = [true|false] æ¯å¦å±å¼ç»ä»¶ |
| | | * @property {Boolean} titleBorder = [true|false] æ¯å¦æ¾ç¤ºæ é¢åé线 |
| | | * @property {Boolean} border = [true|false] æ¯å¦æ¾ç¤ºåé线 |
| | | * @property {Boolean} disabled = [true|false] æ¯å¦å±å¼é¢æ¿ |
| | | * @property {Boolean} showAnimation = [true|false] å¼å¯å¨ç» |
| | | * @property {Boolean} showArrow = [true|false] æ¯å¦æ¾ç¤ºå³ä¾§ç®å¤´ |
| | | */ |
| | | export default { |
| | | name: 'uniCollapseItem', |
| | | props: { |
| | | // å表æ é¢ |
| | | title: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | name: { |
| | | type: [Number, String], |
| | | default: '' |
| | | }, |
| | | // æ¯å¦ç¦ç¨ |
| | | disabled: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | // #ifdef APP-PLUS |
| | | // æ¯å¦æ¾ç¤ºå¨ç»,app 端é»è®¤ä¸å¼å¯å¨ç»ï¼å¡é¡¿ä¸¥é |
| | | showAnimation: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | // #endif |
| | | // #ifndef APP-PLUS |
| | | // æ¯å¦æ¾ç¤ºå¨ç» |
| | | showAnimation: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | // #endif |
| | | // æ¯å¦å±å¼ |
| | | open: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | // 缩ç¥å¾ |
| | | thumb: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // æ é¢åé线æ¾ç¤ºç±»å |
| | | titleBorder: { |
| | | type: String, |
| | | default: 'auto' |
| | | }, |
| | | border: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | showArrow: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | data() { |
| | | // TODO éæºççå
ç´ IDï¼è§£å³ç¾åº¦å°ç¨åºè·ååä¸ä¸ªå
ç´ ä½ç½®ä¿¡æ¯çbug |
| | | const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}` |
| | | return { |
| | | isOpen: false, |
| | | isheight: null, |
| | | height: 0, |
| | | elId, |
| | | nameSync: 0 |
| | | } |
| | | }, |
| | | watch: { |
| | | open(val) { |
| | | this.isOpen = val |
| | | this.onClick(val, 'init') |
| | | } |
| | | }, |
| | | updated(e) { |
| | | this.$nextTick(() => { |
| | | this.init(true) |
| | | }) |
| | | }, |
| | | created() { |
| | | this.collapse = this.getCollapse() |
| | | this.oldHeight = 0 |
| | | this.onClick(this.open, 'init') |
| | | }, |
| | | // #ifndef VUE3 |
| | | // TODO vue2 |
| | | destroyed() { |
| | | if (this.__isUnmounted) return |
| | | this.uninstall() |
| | | }, |
| | | // #endif |
| | | // #ifdef VUE3 |
| | | // TODO vue3 |
| | | unmounted() { |
| | | this.__isUnmounted = true |
| | | this.uninstall() |
| | | }, |
| | | // #endif |
| | | mounted() { |
| | | if (!this.collapse) return |
| | | if (this.name !== '') { |
| | | this.nameSync = this.name |
| | | } else { |
| | | this.nameSync = this.collapse.childrens.length + '' |
| | | } |
| | | if (this.collapse.names.indexOf(this.nameSync) === -1) { |
| | | this.collapse.names.push(this.nameSync) |
| | | } else { |
| | | console.warn(`name å¼ ${this.nameSync} éå¤`); |
| | | } |
| | | if (this.collapse.childrens.indexOf(this) === -1) { |
| | | this.collapse.childrens.push(this) |
| | | } |
| | | this.init() |
| | | }, |
| | | methods: { |
| | | init(type) { |
| | | // #ifndef APP-NVUE |
| | | this.getCollapseHeight(type) |
| | | // #endif |
| | | // #ifdef APP-NVUE |
| | | this.getNvueHwight(type) |
| | | // #endif |
| | | }, |
| | | uninstall() { |
| | | if (this.collapse) { |
| | | this.collapse.childrens.forEach((item, index) => { |
| | | if (item === this) { |
| | | this.collapse.childrens.splice(index, 1) |
| | | } |
| | | }) |
| | | this.collapse.names.forEach((item, index) => { |
| | | if (item === this.nameSync) { |
| | | this.collapse.names.splice(index, 1) |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | onClick(isOpen, type) { |
| | | if (this.disabled) return |
| | | this.isOpen = isOpen |
| | | if (this.isOpen && this.collapse) { |
| | | this.collapse.setAccordion(this) |
| | | } |
| | | if (type !== 'init') { |
| | | this.collapse.onChange(isOpen, this) |
| | | } |
| | | }, |
| | | getCollapseHeight(type, index = 0) { |
| | | const views = uni.createSelectorQuery().in(this) |
| | | views |
| | | .select(`#${this.elId}`) |
| | | .fields({ |
| | | size: true |
| | | }, data => { |
| | | // TODO ç¾åº¦ä¸å¯è½è·åä¸å°èç¹ä¿¡æ¯ ï¼éè¦å¾ªç¯è·å |
| | | if (index >= 10) return |
| | | if (!data) { |
| | | index++ |
| | | this.getCollapseHeight(false, index) |
| | | return |
| | | } |
| | | // #ifdef APP-NVUE |
| | | this.height = data.height + 1 |
| | | // #endif |
| | | // #ifndef APP-NVUE |
| | | this.height = data.height |
| | | // #endif |
| | | this.isheight = true |
| | | if (type) return |
| | | this.onClick(this.isOpen, 'init') |
| | | }) |
| | | .exec() |
| | | }, |
| | | getNvueHwight(type) { |
| | | const result = dom.getComponentRect(this.$refs['collapse--hook'], option => { |
| | | if (option && option.result && option.size) { |
| | | // #ifdef APP-NVUE |
| | | this.height = option.size.height + 1 |
| | | // #endif |
| | | // #ifndef APP-NVUE |
| | | this.height = option.size.height |
| | | // #endif |
| | | this.isheight = true |
| | | if (type) return |
| | | this.onClick(this.open, 'init') |
| | | } |
| | | }) |
| | | }, |
| | | /** |
| | | * è·åç¶å
ç´ å®ä¾ |
| | | */ |
| | | getCollapse(name = 'uniCollapse') { |
| | | let parent = this.$parent; |
| | | let parentName = parent.$options.name; |
| | | while (parentName !== name) { |
| | | parent = parent.$parent; |
| | | if (!parent) return false; |
| | | parentName = parent.$options.name; |
| | | } |
| | | return parent; |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .uni-collapse-item { |
| | | /* #ifndef APP-NVUE */ |
| | | box-sizing: border-box; |
| | | |
| | | /* #endif */ |
| | | &__title { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | width: 100%; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | align-items: center; |
| | | transition: border-bottom-color .3s; |
| | | |
| | | // transition-property: border-bottom-color; |
| | | // transition-duration: 5s; |
| | | &-wrap { |
| | | width: 100%; |
| | | flex: 1; |
| | | |
| | | } |
| | | |
| | | &-box { |
| | | padding: 0 15px; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | width: 100%; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | height: 48px; |
| | | line-height: 48px; |
| | | background-color: #fff; |
| | | color: #303133; |
| | | font-size: 13px; |
| | | font-weight: 500; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | outline: none; |
| | | |
| | | /* #endif */ |
| | | &.is-disabled { |
| | | .uni-collapse-item__title-text { |
| | | color: #999; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | &.uni-collapse-item-border { |
| | | border-bottom: 1px solid #ebeef5; |
| | | } |
| | | |
| | | &.is-open { |
| | | border-bottom-color: transparent; |
| | | } |
| | | |
| | | &-img { |
| | | height: 22px; |
| | | width: 22px; |
| | | margin-right: 10px; |
| | | } |
| | | |
| | | &-text { |
| | | flex: 1; |
| | | font-size: 14px; |
| | | /* #ifndef APP-NVUE */ |
| | | white-space: nowrap; |
| | | color: inherit; |
| | | /* #endif */ |
| | | /* #ifdef APP-NVUE */ |
| | | lines: 1; |
| | | /* #endif */ |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | } |
| | | |
| | | &-arrow { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | align-items: center; |
| | | justify-content: center; |
| | | width: 20px; |
| | | height: 20px; |
| | | margin-right: 10px; |
| | | transform: rotate(0deg); |
| | | |
| | | &-active { |
| | | transform: rotate(-180deg); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | &__wrap { |
| | | /* #ifndef APP-NVUE */ |
| | | will-change: height; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | background-color: #fff; |
| | | overflow: hidden; |
| | | position: relative; |
| | | height: 0; |
| | | |
| | | &.is--transition { |
| | | // transition: all 0.3s; |
| | | transition-property: height, border-bottom-width; |
| | | transition-duration: 0.3s; |
| | | /* #ifndef APP-NVUE */ |
| | | will-change: height; |
| | | /* #endif */ |
| | | } |
| | | |
| | | |
| | | |
| | | &-content { |
| | | position: absolute; |
| | | font-size: 13px; |
| | | color: #303133; |
| | | // transition: height 0.3s; |
| | | border-bottom-color: transparent; |
| | | border-bottom-style: solid; |
| | | border-bottom-width: 0; |
| | | |
| | | &.uni-collapse-item--border { |
| | | border-bottom-width: 1px; |
| | | border-bottom-color: red; |
| | | border-bottom-color: #ebeef5; |
| | | } |
| | | |
| | | &.open { |
| | | position: relative; |
| | | } |
| | | } |
| | | } |
| | | |
| | | &--animation { |
| | | transition-property: transform; |
| | | transition-duration: 0.3s; |
| | | transition-timing-function: ease; |
| | | } |
| | | |
| | | } |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view class="uni-collapse"> |
| | | <slot /> |
| | | </view> |
| | | </template> |
| | | <script> |
| | | /** |
| | | * Collapse æå 颿¿ |
| | | * @description å±ç¤ºå¯ä»¥æå / å±å¼çå
容åºå |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=23 |
| | | * @property {String|Array} value å½åæ¿æ´»é¢æ¿æ¹åæ¶è§¦å(å¦ææ¯æé£ç´æ¨¡å¼ï¼åæ°ç±»å为stringï¼å¦å为array) |
| | | * @property {Boolean} accordion = [true|false] æ¯å¦å¼å¯æé£ç´æææ¯å¦å¼å¯æé£ç´ææ |
| | | * @event {Function} change 忢颿¿æ¶è§¦åï¼å¦ææ¯æé£ç´æ¨¡å¼ï¼è¿åç±»å为stringï¼å¦å为array |
| | | */ |
| | | export default { |
| | | name: 'uniCollapse', |
| | | emits:['change','activeItem','input','update:modelValue'], |
| | | props: { |
| | | value: { |
| | | type: [String, Array], |
| | | default: '' |
| | | }, |
| | | modelValue: { |
| | | type: [String, Array], |
| | | default: '' |
| | | }, |
| | | accordion: { |
| | | // æ¯å¦å¼å¯æé£ç´ææ |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | }, |
| | | data() { |
| | | return {} |
| | | }, |
| | | computed: { |
| | | // TODO å
¼å®¹ vue2 å vue3 |
| | | dataValue() { |
| | | let value = (typeof this.value === 'string' && this.value === '') || |
| | | (Array.isArray(this.value) && this.value.length === 0) |
| | | let modelValue = (typeof this.modelValue === 'string' && this.modelValue === '') || |
| | | (Array.isArray(this.modelValue) && this.modelValue.length === 0) |
| | | if (value) { |
| | | return this.modelValue |
| | | } |
| | | if (modelValue) { |
| | | return this.value |
| | | } |
| | | |
| | | return this.value |
| | | } |
| | | }, |
| | | watch: { |
| | | dataValue(val) { |
| | | this.setOpen(val) |
| | | } |
| | | }, |
| | | created() { |
| | | this.childrens = [] |
| | | this.names = [] |
| | | }, |
| | | mounted() { |
| | | this.$nextTick(()=>{ |
| | | this.setOpen(this.dataValue) |
| | | }) |
| | | }, |
| | | methods: { |
| | | setOpen(val) { |
| | | let str = typeof val === 'string' |
| | | let arr = Array.isArray(val) |
| | | this.childrens.forEach((vm, index) => { |
| | | if (str) { |
| | | if (val === vm.nameSync) { |
| | | if (!this.accordion) { |
| | | console.warn('accordion 屿§ä¸º false ,v-model ç±»ååºè¯¥ä¸º array') |
| | | return |
| | | } |
| | | vm.isOpen = true |
| | | } |
| | | } |
| | | if (arr) { |
| | | val.forEach(v => { |
| | | if (v === vm.nameSync) { |
| | | if (this.accordion) { |
| | | console.warn('accordion 屿§ä¸º true ,v-model ç±»ååºè¯¥ä¸º string') |
| | | return |
| | | } |
| | | vm.isOpen = true |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | this.emit(val) |
| | | }, |
| | | setAccordion(self) { |
| | | if (!this.accordion) return |
| | | this.childrens.forEach((vm, index) => { |
| | | if (self !== vm) { |
| | | vm.isOpen = false |
| | | } |
| | | }) |
| | | }, |
| | | resize() { |
| | | this.childrens.forEach((vm, index) => { |
| | | // #ifndef APP-NVUE |
| | | vm.getCollapseHeight() |
| | | // #endif |
| | | // #ifdef APP-NVUE |
| | | vm.getNvueHwight() |
| | | // #endif |
| | | }) |
| | | }, |
| | | onChange(isOpen, self) { |
| | | let activeItem = [] |
| | | |
| | | if (this.accordion) { |
| | | activeItem = isOpen ? self.nameSync : '' |
| | | } else { |
| | | this.childrens.forEach((vm, index) => { |
| | | if (vm.isOpen) { |
| | | activeItem.push(vm.nameSync) |
| | | } |
| | | }) |
| | | } |
| | | this.$emit('change', activeItem) |
| | | this.emit(activeItem) |
| | | }, |
| | | emit(val){ |
| | | this.$emit('input', val) |
| | | this.$emit('update:modelValue', val) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style lang="scss" > |
| | | .uni-collapse { |
| | | /* #ifndef APP-NVUE */ |
| | | width: 100%; |
| | | display: flex; |
| | | /* #endif */ |
| | | /* #ifdef APP-NVUE */ |
| | | flex: 1; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | background-color: #fff; |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-collapse", |
| | | "displayName": "uni-collapse æå 颿¿", |
| | | "version": "1.4.3", |
| | | "description": "Collapse ç»ä»¶ï¼å¯ä»¥æå / å±å¼çå
容åºåã", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "æå ", |
| | | "æå 颿¿", |
| | | "æé£ç´" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Collapse æå 颿¿ |
| | | > **ç»ä»¶åï¼uni-collapse** |
| | | > 代ç åï¼ `uCollapse` |
| | | > å
³èç»ä»¶ï¼`uni-collapse-item`ã`uni-icons`ã |
| | | |
| | | |
| | | æå 颿¿ç¨æ¥æå /æ¾ç¤ºè¿é¿çå
容æè
æ¯å表ãé常æ¯å¨å¤å
容å类项使ç¨ï¼æå ä¸éè¦çå
å®¹ï¼æ¾ç¤ºéè¦å
容ãç¹å»å¯ä»¥å±å¼æå é¨åã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-collapse) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.0.1ï¼2021-11-23ï¼ |
| | | - ä¼å labelãlabel-width 屿§ |
| | | ## 1.0.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-combox](https://uniapp.dcloud.io/component/uniui/uni-combox) |
| | | ## 0.1.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 0.0.6ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 0.0.5ï¼2021-04-21ï¼ |
| | | - ä¼å æ·»å ä¾èµ uni-icons, 导å
¥åèªå¨ä¸è½½ä¾èµ |
| | | ## 0.0.4ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | ## 0.0.3ï¼2021-02-04ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | <template> |
| | | <view class="uni-combox" :class="border ? '' : 'uni-combox__no-border'"> |
| | | <view v-if="label" class="uni-combox__label" :style="labelStyle"> |
| | | <text>{{label}}</text> |
| | | </view> |
| | | <view class="uni-combox__input-box"> |
| | | <input class="uni-combox__input" type="text" :placeholder="placeholder" |
| | | placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus" |
| | | @blur="onBlur" /> |
| | | <uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector"> |
| | | </uni-icons> |
| | | </view> |
| | | <view class="uni-combox__selector" v-if="showSelector"> |
| | | <view class="uni-popper__arrow"></view> |
| | | <scroll-view scroll-y="true" class="uni-combox__selector-scroll"> |
| | | <view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0"> |
| | | <text>{{emptyTips}}</text> |
| | | </view> |
| | | <view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index" |
| | | @click="onSelectorClick(index)"> |
| | | <text>{{item}}</text> |
| | | </view> |
| | | </scroll-view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * Combox ç»åè¾å
¥æ¡ |
| | | * @description ç»åè¾å
¥æ¡ä¸è¬ç¨äºæ¢å¯ä»¥è¾å
¥ä¹å¯ä»¥éæ©çåºæ¯ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=1261 |
| | | * @property {String} label 左侧æå |
| | | * @property {String} labelWidth 左侧å
容宽度 |
| | | * @property {String} placeholder è¾å
¥æ¡å ä½ç¬¦ |
| | | * @property {Array} candidates åé项å表 |
| | | * @property {String} emptyTips çéç»æä¸ºç©ºæ¶æ¾ç¤ºçæå |
| | | * @property {String} value ç»åæ¡çå¼ |
| | | */ |
| | | export default { |
| | | name: 'uniCombox', |
| | | emits: ['input', 'update:modelValue'], |
| | | props: { |
| | | border: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | label: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | labelWidth: { |
| | | type: String, |
| | | default: 'auto' |
| | | }, |
| | | placeholder: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | candidates: { |
| | | type: Array, |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | emptyTips: { |
| | | type: String, |
| | | default: 'æ å¹é
项' |
| | | }, |
| | | // #ifndef VUE3 |
| | | value: { |
| | | type: [String, Number], |
| | | default: '' |
| | | }, |
| | | // #endif |
| | | // #ifdef VUE3 |
| | | modelValue: { |
| | | type: [String, Number], |
| | | default: '' |
| | | }, |
| | | // #endif |
| | | }, |
| | | data() { |
| | | return { |
| | | showSelector: false, |
| | | inputVal: '' |
| | | } |
| | | }, |
| | | computed: { |
| | | labelStyle() { |
| | | if (this.labelWidth === 'auto') { |
| | | return "" |
| | | } |
| | | return `width: ${this.labelWidth}` |
| | | }, |
| | | filterCandidates() { |
| | | return this.candidates.filter((item) => { |
| | | return item.toString().indexOf(this.inputVal) > -1 |
| | | }) |
| | | }, |
| | | filterCandidatesLength() { |
| | | return this.filterCandidates.length |
| | | } |
| | | }, |
| | | watch: { |
| | | // #ifndef VUE3 |
| | | value: { |
| | | handler(newVal) { |
| | | this.inputVal = newVal |
| | | }, |
| | | immediate: true |
| | | }, |
| | | // #endif |
| | | // #ifdef VUE3 |
| | | modelValue: { |
| | | handler(newVal) { |
| | | this.inputVal = newVal |
| | | }, |
| | | immediate: true |
| | | }, |
| | | // #endif |
| | | }, |
| | | methods: { |
| | | toggleSelector() { |
| | | this.showSelector = !this.showSelector |
| | | }, |
| | | onFocus() { |
| | | this.showSelector = true |
| | | }, |
| | | onBlur() { |
| | | setTimeout(() => { |
| | | this.showSelector = false |
| | | }, 153) |
| | | }, |
| | | onSelectorClick(index) { |
| | | this.inputVal = this.filterCandidates[index] |
| | | this.showSelector = false |
| | | this.$emit('input', this.inputVal) |
| | | this.$emit('update:modelValue', this.inputVal) |
| | | }, |
| | | onInput() { |
| | | setTimeout(() => { |
| | | this.$emit('input', this.inputVal) |
| | | this.$emit('update:modelValue', this.inputVal) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .uni-combox { |
| | | font-size: 14px; |
| | | border: 1px solid #DCDFE6; |
| | | border-radius: 4px; |
| | | padding: 6px 10px; |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | // height: 40px; |
| | | flex-direction: row; |
| | | align-items: center; |
| | | // border-bottom: solid 1px #DDDDDD; |
| | | } |
| | | |
| | | .uni-combox__label { |
| | | font-size: 16px; |
| | | line-height: 22px; |
| | | padding-right: 10px; |
| | | color: #999999; |
| | | } |
| | | |
| | | .uni-combox__input-box { |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex: 1; |
| | | flex-direction: row; |
| | | align-items: center; |
| | | } |
| | | |
| | | .uni-combox__input { |
| | | flex: 1; |
| | | font-size: 14px; |
| | | height: 22px; |
| | | line-height: 22px; |
| | | } |
| | | |
| | | .uni-combox__input-plac { |
| | | font-size: 14px; |
| | | color: #999; |
| | | } |
| | | |
| | | .uni-combox__selector { |
| | | /* #ifndef APP-NVUE */ |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | position: absolute; |
| | | top: calc(100% + 12px); |
| | | left: 0; |
| | | width: 100%; |
| | | background-color: #FFFFFF; |
| | | border: 1px solid #EBEEF5; |
| | | border-radius: 6px; |
| | | box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); |
| | | z-index: 2; |
| | | padding: 4px 0; |
| | | } |
| | | |
| | | .uni-combox__selector-scroll { |
| | | /* #ifndef APP-NVUE */ |
| | | max-height: 200px; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-combox__selector-empty, |
| | | .uni-combox__selector-item { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | line-height: 36px; |
| | | font-size: 14px; |
| | | text-align: center; |
| | | // border-bottom: solid 1px #DDDDDD; |
| | | padding: 0px 10px; |
| | | } |
| | | |
| | | .uni-combox__selector-item:hover { |
| | | background-color: #f9f9f9; |
| | | } |
| | | |
| | | .uni-combox__selector-empty:last-child, |
| | | .uni-combox__selector-item:last-child { |
| | | /* #ifndef APP-NVUE */ |
| | | border-bottom: none; |
| | | /* #endif */ |
| | | } |
| | | |
| | | // picker å¼¹åºå±éç¨çæç¤ºå°ä¸è§ |
| | | .uni-popper__arrow, |
| | | .uni-popper__arrow::after { |
| | | position: absolute; |
| | | display: block; |
| | | width: 0; |
| | | height: 0; |
| | | border-color: transparent; |
| | | border-style: solid; |
| | | border-width: 6px; |
| | | } |
| | | |
| | | .uni-popper__arrow { |
| | | filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03)); |
| | | top: -6px; |
| | | left: 10%; |
| | | margin-right: 3px; |
| | | border-top-width: 0; |
| | | border-bottom-color: #EBEEF5; |
| | | } |
| | | |
| | | .uni-popper__arrow::after { |
| | | content: " "; |
| | | top: 1px; |
| | | margin-left: -6px; |
| | | border-top-width: 0; |
| | | border-bottom-color: #fff; |
| | | } |
| | | |
| | | .uni-combox__no-border { |
| | | border: none; |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-combox", |
| | | "displayName": "uni-combox ç»åæ¡", |
| | | "version": "1.0.1", |
| | | "description": "å¯ä»¥éæ©ä¹å¯ä»¥è¾å
¥ç表å项 ", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "combox", |
| | | "ç»åæ¡", |
| | | "select" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "n" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Combox ç»åæ¡ |
| | | > **ç»ä»¶åï¼uni-combox** |
| | | > 代ç åï¼ `uCombox` |
| | | |
| | | |
| | | ç»åæ¡ç»ä»¶ã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-combox) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.2.2ï¼2022-01-19ï¼ |
| | | - ä¿®å¤ å¨å¾®ä¿¡å°ç¨åºä¸æ ·å¼ä¸çæçbug |
| | | ## 1.2.1ï¼2022-01-18ï¼ |
| | | - æ°å¢ update æ¹æ³ ï¼å¨å¨ææ´æ°æ¶é´åï¼å·æ°ç»ä»¶ |
| | | ## 1.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-countdown](https://uniapp.dcloud.io/component/uniui/uni-countdown) |
| | | ## 1.1.3ï¼2021-10-18ï¼ |
| | | - éæ |
| | | - æ°å¢ font-size æ¯æèªå®ä¹åä½å¤§å° |
| | | ## 1.1.2ï¼2021-08-24ï¼ |
| | | - æ°å¢ æ¯æå½é
å |
| | | ## 1.1.1ï¼2021-07-30ï¼ |
| | | - ä¼å vue3ä¸å°ç¨åºäºä»¶è¦åçé®é¢ |
| | | ## 1.1.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.0.5ï¼2021-06-18ï¼ |
| | | - ä¿®å¤ uni-countdown éå¤èµå¼è·³ä¸¤ç§ç bug |
| | | ## 1.0.4ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.3ï¼2021-05-08ï¼ |
| | | - ä¿®å¤ uni-countdown ä¸è½æ§å¶å计æ¶ç bug |
| | | ## 1.0.2ï¼2021-02-04ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | { |
| | | "uni-countdown.day": "day", |
| | | "uni-countdown.h": "h", |
| | | "uni-countdown.m": "m", |
| | | "uni-countdown.s": "s" |
| | | } |
| New file |
| | |
| | | import en from './en.json' |
| | | import zhHans from './zh-Hans.json' |
| | | import zhHant from './zh-Hant.json' |
| | | export default { |
| | | en, |
| | | 'zh-Hans': zhHans, |
| | | 'zh-Hant': zhHant |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-countdown.day": "天", |
| | | "uni-countdown.h": "æ¶", |
| | | "uni-countdown.m": "å", |
| | | "uni-countdown.s": "ç§" |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-countdown.day": "天", |
| | | "uni-countdown.h": "æ", |
| | | "uni-countdown.m": "å", |
| | | "uni-countdown.s": "ç§" |
| | | } |
| New file |
| | |
| | | <template> |
| | | <view class="uni-countdown"> |
| | | <text v-if="showDay" :style="[timeStyle]" class="uni-countdown__number">{{ d }}</text> |
| | | <text v-if="showDay" :style="[splitorStyle]" class="uni-countdown__splitor">{{dayText}}</text> |
| | | <text :style="[timeStyle]" class="uni-countdown__number">{{ h }}</text> |
| | | <text :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : hourText }}</text> |
| | | <text :style="[timeStyle]" class="uni-countdown__number">{{ i }}</text> |
| | | <text :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : minuteText }}</text> |
| | | <text :style="[timeStyle]" class="uni-countdown__number">{{ s }}</text> |
| | | <text v-if="!showColon" :style="[splitorStyle]" class="uni-countdown__splitor">{{secondText}}</text> |
| | | </view> |
| | | </template> |
| | | <script> |
| | | import { |
| | | initVueI18n |
| | | } from '@dcloudio/uni-i18n' |
| | | import messages from './i18n/index.js' |
| | | const { |
| | | t |
| | | } = initVueI18n(messages) |
| | | /** |
| | | * Countdown åè®¡æ¶ |
| | | * @description å计æ¶ç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=25 |
| | | * @property {String} backgroundColor èæ¯è² |
| | | * @property {String} color æåé¢è² |
| | | * @property {Number} day å¤©æ° |
| | | * @property {Number} hour å°æ¶ |
| | | * @property {Number} minute åé |
| | | * @property {Number} second ç§ |
| | | * @property {Number} timestamp æ¶é´æ³ |
| | | * @property {Boolean} showDay = [true|false] æ¯å¦æ¾ç¤ºå¤©æ° |
| | | * @property {Boolean} show-colon = [true|false] æ¯å¦ä»¥åå·ä¸ºåé符 |
| | | * @property {String} splitorColor åå²ç¬¦å·é¢è² |
| | | * @event {Function} timeup åè®¡æ¶æ¶é´å°è§¦åäºä»¶ |
| | | * @example <uni-countdown :day="1" :hour="1" :minute="12" :second="40"></uni-countdown> |
| | | */ |
| | | export default { |
| | | name: 'UniCountdown', |
| | | emits: ['timeup'], |
| | | props: { |
| | | showDay: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | showColon: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | start: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | backgroundColor: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | color: { |
| | | type: String, |
| | | default: '#333' |
| | | }, |
| | | fontSize: { |
| | | type: Number, |
| | | default: 14 |
| | | }, |
| | | splitorColor: { |
| | | type: String, |
| | | default: '#333' |
| | | }, |
| | | day: { |
| | | type: Number, |
| | | default: 0 |
| | | }, |
| | | hour: { |
| | | type: Number, |
| | | default: 0 |
| | | }, |
| | | minute: { |
| | | type: Number, |
| | | default: 0 |
| | | }, |
| | | second: { |
| | | type: Number, |
| | | default: 0 |
| | | }, |
| | | timestamp: { |
| | | type: Number, |
| | | default: 0 |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | timer: null, |
| | | syncFlag: false, |
| | | d: '00', |
| | | h: '00', |
| | | i: '00', |
| | | s: '00', |
| | | leftTime: 0, |
| | | seconds: 0 |
| | | } |
| | | }, |
| | | computed: { |
| | | dayText() { |
| | | return t("uni-countdown.day") |
| | | }, |
| | | hourText(val) { |
| | | return t("uni-countdown.h") |
| | | }, |
| | | minuteText(val) { |
| | | return t("uni-countdown.m") |
| | | }, |
| | | secondText(val) { |
| | | return t("uni-countdown.s") |
| | | }, |
| | | timeStyle() { |
| | | const { |
| | | color, |
| | | backgroundColor, |
| | | fontSize |
| | | } = this |
| | | return { |
| | | color, |
| | | backgroundColor, |
| | | fontSize: `${fontSize}px`, |
| | | width: `${fontSize * 22 / 14}px`, // æåä½å¤§å°ä¸º 14px æ¶çæ¯ä¾ç¼©æ¾ |
| | | lineHeight: `${fontSize * 20 / 14}px`, |
| | | borderRadius: `${fontSize * 3 / 14}px`, |
| | | } |
| | | }, |
| | | splitorStyle() { |
| | | const { splitorColor, fontSize, backgroundColor } = this |
| | | return { |
| | | color: splitorColor, |
| | | fontSize: `${fontSize * 12 / 14}px`, |
| | | margin: backgroundColor ? `${fontSize * 4 / 14}px` : '' |
| | | } |
| | | } |
| | | }, |
| | | watch: { |
| | | day(val) { |
| | | this.changeFlag() |
| | | }, |
| | | hour(val) { |
| | | this.changeFlag() |
| | | }, |
| | | minute(val) { |
| | | this.changeFlag() |
| | | }, |
| | | second(val) { |
| | | this.changeFlag() |
| | | }, |
| | | start: { |
| | | immediate: true, |
| | | handler(newVal, oldVal) { |
| | | if (newVal) { |
| | | this.startData(); |
| | | } else { |
| | | if (!oldVal) return |
| | | clearInterval(this.timer) |
| | | } |
| | | } |
| | | |
| | | } |
| | | }, |
| | | created: function(e) { |
| | | this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second) |
| | | this.countDown() |
| | | }, |
| | | // #ifndef VUE3 |
| | | destroyed() { |
| | | clearInterval(this.timer) |
| | | }, |
| | | // #endif |
| | | // #ifdef VUE3 |
| | | unmounted() { |
| | | clearInterval(this.timer) |
| | | }, |
| | | // #endif |
| | | methods: { |
| | | toSeconds(timestamp, day, hours, minutes, seconds) { |
| | | if (timestamp) { |
| | | return timestamp - parseInt(new Date().getTime() / 1000, 10) |
| | | } |
| | | return day * 60 * 60 * 24 + hours * 60 * 60 + minutes * 60 + seconds |
| | | }, |
| | | timeUp() { |
| | | clearInterval(this.timer) |
| | | this.$emit('timeup') |
| | | }, |
| | | countDown() { |
| | | let seconds = this.seconds |
| | | let [day, hour, minute, second] = [0, 0, 0, 0] |
| | | if (seconds > 0) { |
| | | day = Math.floor(seconds / (60 * 60 * 24)) |
| | | hour = Math.floor(seconds / (60 * 60)) - (day * 24) |
| | | minute = Math.floor(seconds / 60) - (day * 24 * 60) - (hour * 60) |
| | | second = Math.floor(seconds) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60) |
| | | } else { |
| | | this.timeUp() |
| | | } |
| | | if (day < 10) { |
| | | day = '0' + day |
| | | } |
| | | if (hour < 10) { |
| | | hour = '0' + hour |
| | | } |
| | | if (minute < 10) { |
| | | minute = '0' + minute |
| | | } |
| | | if (second < 10) { |
| | | second = '0' + second |
| | | } |
| | | this.d = day |
| | | this.h = hour |
| | | this.i = minute |
| | | this.s = second |
| | | }, |
| | | startData() { |
| | | this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second) |
| | | if (this.seconds <= 0) { |
| | | this.seconds = this.toSeconds(0, 0, 0, 0, 0) |
| | | this.countDown() |
| | | return |
| | | } |
| | | clearInterval(this.timer) |
| | | this.countDown() |
| | | this.timer = setInterval(() => { |
| | | this.seconds-- |
| | | if (this.seconds < 0) { |
| | | this.timeUp() |
| | | return |
| | | } |
| | | this.countDown() |
| | | }, 1000) |
| | | }, |
| | | update(){ |
| | | this.startData(); |
| | | }, |
| | | changeFlag() { |
| | | if (!this.syncFlag) { |
| | | this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second) |
| | | this.startData(); |
| | | this.syncFlag = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | $font-size: 14px; |
| | | |
| | | .uni-countdown { |
| | | display: flex; |
| | | flex-direction: row; |
| | | justify-content: flex-start; |
| | | align-items: center; |
| | | |
| | | &__splitor { |
| | | margin: 0 2px; |
| | | font-size: $font-size; |
| | | color: #333; |
| | | } |
| | | |
| | | &__number { |
| | | border-radius: 3px; |
| | | text-align: center; |
| | | font-size: $font-size; |
| | | } |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-countdown", |
| | | "displayName": "uni-countdown å计æ¶", |
| | | "version": "1.2.2", |
| | | "description": "CountDown å计æ¶ç»ä»¶", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "countdown", |
| | | "å计æ¶" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-scss"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## CountDown åè®¡æ¶ |
| | | > **ç»ä»¶åï¼uni-countdown** |
| | | > 代ç åï¼ `uCountDown` |
| | | |
| | | å计æ¶ç»ä»¶ã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-countdown) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.0.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-data-checkbox](https://uniapp.dcloud.io/component/uniui/uni-data-checkbox) |
| | | ## 0.2.5ï¼2021-08-23ï¼ |
| | | - ä¿®å¤ å¨uni-formsä¸ modelValue ä¸ä¸åå¨å½ååæ®µï¼å½ååæ®µå¿
å¡«åä¹ä¸å䏿 ¡éªçé®é¢ |
| | | ## 0.2.4ï¼2021-08-17ï¼ |
| | | - ä¿®å¤ åé list 模å¼ä¸ ï¼icon 为 left æ¶ï¼éä¸å¾æ 䏿¾ç¤ºçé®é¢ |
| | | ## 0.2.3ï¼2021-08-11ï¼ |
| | | - ä¿®å¤ å¨ uni-forms ä¸é置表åï¼éè¯¯ä¿¡æ¯æ æ³æ¸
é¤çé®é¢ |
| | | ## 0.2.2ï¼2021-07-30ï¼ |
| | | - ä¼å å¨uni-formsç»ä»¶ï¼ä¸labelä¸å¯¹é½çé®é¢ |
| | | ## 0.2.1ï¼2021-07-27ï¼ |
| | | - ä¿®å¤ åéé»è®¤å¼ä¸º0ä¸è½éä¸çBug |
| | | ## 0.2.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 0.1.11ï¼2021-07-06ï¼ |
| | | - ä¼å å 餿 ç¨æ¥å¿ |
| | | ## 0.1.10ï¼2021-07-05ï¼ |
| | | - ä¿®å¤ ç± 0.1.9 å¼èµ·çé nvue ç«¯å¾æ 䏿¾ç¤ºçé®é¢ |
| | | ## 0.1.9ï¼2021-07-05ï¼ |
| | | - ä¿®å¤ nvue 黿¡æ ·å¼é®é¢ |
| | | ## 0.1.8ï¼2021-06-28ï¼ |
| | | - ä¿®å¤ selectedTextColor 屿§ä¸çæçBug |
| | | ## 0.1.7ï¼2021-06-02ï¼ |
| | | - æ°å¢ map 屿§ï¼å¯ä»¥æ¹ä¾¿æ å°text/value屿§ |
| | | ## 0.1.6ï¼2021-05-26ï¼ |
| | | - ä¿®å¤ ä¸å
³èæå¡ç©ºé´çæ
åµä¸ç»ä»¶æ¥éçBug |
| | | ## 0.1.5ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 0.1.4ï¼2021-04-09ï¼ |
| | | - ä¿®å¤ nvue 䏿 æ³éä¸çé®é¢ |
| | | ## 0.1.3ï¼2021-03-22ï¼ |
| | | - æ°å¢ disabled屿§ |
| | | ## 0.1.2ï¼2021-02-24ï¼ |
| | | - ä¼å é»è®¤é¢è²æ¾ç¤º |
| | | ## 0.1.1ï¼2021-02-24ï¼ |
| | | - æ°å¢ æ¯ænvue |
| | | ## 0.1.0ï¼2021-02-18ï¼ |
| | | - âææ æ°æ®âæ¾ç¤ºå±
ä¸ |
| New file |
| | |
| | | <template> |
| | | <view class="uni-data-checklist" :style="{'margin-top':isTop+'px'}"> |
| | | <template v-if="!isLocal"> |
| | | <view class="uni-data-loading"> |
| | | <uni-load-more v-if="!mixinDatacomErrorMessage" status="loading" iconType="snow" :iconSize="18" :content-text="contentText"></uni-load-more> |
| | | <text v-else>{{mixinDatacomErrorMessage}}</text> |
| | | </view> |
| | | </template> |
| | | <template v-else> |
| | | <checkbox-group v-if="multiple" class="checklist-group" :class="{'is-list':mode==='list' || wrap}" @change="chagne"> |
| | | <label class="checklist-box" :class="['is--'+mode,item.selected?'is-checked':'',(disabled || !!item.disabled)?'is-disable':'',index!==0&&mode==='list'?'is-list-border':'']" |
| | | :style="item.styleBackgroud" v-for="(item,index) in dataList" :key="index"> |
| | | <checkbox class="hidden" hidden :disabled="disabled || !!item.disabled" :value="item[map.value]+''" :checked="item.selected" /> |
| | | <view v-if="(mode !=='tag' && mode !== 'list') || ( mode === 'list' && icon === 'left')" class="checkbox__inner" :style="item.styleIcon"> |
| | | <view class="checkbox__inner-icon"></view> |
| | | </view> |
| | | <view class="checklist-content" :class="{'list-content':mode === 'list' && icon ==='left'}"> |
| | | <text class="checklist-text" :style="item.styleIconText">{{item[map.text]}}</text> |
| | | <view v-if="mode === 'list' && icon === 'right'" class="checkobx__list" :style="item.styleBackgroud"></view> |
| | | </view> |
| | | </label> |
| | | </checkbox-group> |
| | | <radio-group v-else class="checklist-group" :class="{'is-list':mode==='list','is-wrap':wrap}" @change="chagne"> |
| | | <!-- --> |
| | | <label class="checklist-box" :class="['is--'+mode,item.selected?'is-checked':'',(disabled || !!item.disabled)?'is-disable':'',index!==0&&mode==='list'?'is-list-border':'']" |
| | | :style="item.styleBackgroud" v-for="(item,index) in dataList" :key="index"> |
| | | <radio class="hidden" hidden :disabled="disabled || item.disabled" :value="item[map.value]+''" :checked="item.selected" /> |
| | | <view v-if="(mode !=='tag' && mode !== 'list') || ( mode === 'list' && icon === 'left')" class="radio__inner" |
| | | :style="item.styleBackgroud"> |
| | | <view class="radio__inner-icon" :style="item.styleIcon"></view> |
| | | </view> |
| | | <view class="checklist-content" :class="{'list-content':mode === 'list' && icon ==='left'}"> |
| | | <text class="checklist-text" :style="item.styleIconText">{{item[map.text]}}</text> |
| | | <view v-if="mode === 'list' && icon === 'right'" :style="item.styleRightIcon" class="checkobx__list"></view> |
| | | </view> |
| | | </label> |
| | | </radio-group> |
| | | </template> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * DataChecklist æ°æ®éæ©å¨ |
| | | * @description éè¿æ°æ®æ¸²æ checkbox å radio |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=xxx |
| | | * @property {String} mode = [default| list | button | tag] æ¾ç¤ºæ¨¡å¼ |
| | | * @value default é»è®¤æ¨ªææ¨¡å¼ |
| | | * @value list åè¡¨æ¨¡å¼ |
| | | * @value button æé®æ¨¡å¼ |
| | | * @value tag æ ç¾æ¨¡å¼ |
| | | * @property {Boolean} multiple = [true|false] æ¯å¦å¤é |
| | | * @property {Array|String|Number} value é»è®¤å¼ |
| | | * @property {Array} localdata æ¬å°æ°æ® ï¼æ ¼å¼ [{text:'',value:''}] |
| | | * @property {Number|String} min æå°éæ©ä¸ªæ° ï¼multiple为trueæ¶çæ |
| | | * @property {Number|String} max æå¤§éæ©ä¸ªæ° ï¼multiple为trueæ¶çæ |
| | | * @property {Boolean} wrap æ¯å¦æ¢è¡æ¾ç¤º |
| | | * @property {String} icon = [left|right] list å表模å¼ä¸iconæ¾ç¤ºä½ç½® |
| | | * @property {Boolean} selectedColor éä¸é¢è² |
| | | * @property {Boolean} emptyText æ²¡ææ°æ®æ¶æ¾ç¤ºçæå ï¼æ¬å°æ°æ®æ æ |
| | | * @property {Boolean} selectedTextColor é䏿æ¬é¢è²ï¼å¦ä¸å¡«ååèªå¨æ¾ç¤º |
| | | * @property {Object} map åæ®µæ å°ï¼ é»è®¤ map={text:'text',value:'value'} |
| | | * @value left 左侧æ¾ç¤º |
| | | * @value right å³ä¾§æ¾ç¤º |
| | | * @event {Function} change éä¸åçåå触å |
| | | */ |
| | | |
| | | export default { |
| | | name: 'uniDataChecklist', |
| | | mixins: [uniCloud.mixinDatacom || {}], |
| | | emits:['input','update:modelValue','change'], |
| | | props: { |
| | | mode: { |
| | | type: String, |
| | | default: 'default' |
| | | }, |
| | | |
| | | multiple: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | value: { |
| | | type: [Array, String, Number], |
| | | default () { |
| | | return '' |
| | | } |
| | | }, |
| | | // TODO vue3 |
| | | modelValue: { |
| | | type: [Array, String, Number], |
| | | default() { |
| | | return ''; |
| | | } |
| | | }, |
| | | localdata: { |
| | | type: Array, |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | min: { |
| | | type: [Number, String], |
| | | default: '' |
| | | }, |
| | | max: { |
| | | type: [Number, String], |
| | | default: '' |
| | | }, |
| | | wrap: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | icon: { |
| | | type: String, |
| | | default: 'left' |
| | | }, |
| | | selectedColor: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | selectedTextColor: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | emptyText:{ |
| | | type: String, |
| | | default: 'ææ æ°æ®' |
| | | }, |
| | | disabled:{ |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | map:{ |
| | | type: Object, |
| | | default(){ |
| | | return { |
| | | text:'text', |
| | | value:'value' |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | watch: { |
| | | localdata: { |
| | | handler(newVal) { |
| | | this.range = newVal |
| | | this.dataList = this.getDataList(this.getSelectedValue(newVal)) |
| | | }, |
| | | deep: true |
| | | }, |
| | | mixinDatacomResData(newVal) { |
| | | this.range = newVal |
| | | this.dataList = this.getDataList(this.getSelectedValue(newVal)) |
| | | }, |
| | | value(newVal) { |
| | | this.dataList = this.getDataList(newVal) |
| | | // fix by mehaotian is_reset å¨ uni-forms ä¸å®ä¹ |
| | | if(!this.is_reset){ |
| | | this.is_reset = false |
| | | this.formItem && this.formItem.setValue(newVal) |
| | | } |
| | | }, |
| | | modelValue(newVal) { |
| | | this.dataList = this.getDataList(newVal); |
| | | if(!this.is_reset){ |
| | | this.is_reset = false |
| | | this.formItem && this.formItem.setValue(newVal) |
| | | } |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | dataList: [], |
| | | range: [], |
| | | contentText: { |
| | | contentdown: 'æ¥çæ´å¤', |
| | | contentrefresh: 'å è½½ä¸', |
| | | contentnomore: 'æ²¡ææ´å¤' |
| | | }, |
| | | isLocal:true, |
| | | styles: { |
| | | selectedColor: '#2979ff', |
| | | selectedTextColor: '#666', |
| | | }, |
| | | isTop:0 |
| | | }; |
| | | }, |
| | | computed:{ |
| | | dataValue(){ |
| | | if(this.value === '')return this.modelValue |
| | | if(this.modelValue === '') return this.value |
| | | return this.value |
| | | } |
| | | }, |
| | | created() { |
| | | this.form = this.getForm('uniForms') |
| | | this.formItem = this.getForm('uniFormsItem') |
| | | // this.formItem && this.formItem.setValue(this.value) |
| | | |
| | | if (this.formItem) { |
| | | this.isTop = 6 |
| | | if (this.formItem.name) { |
| | | // 妿åå¨nameæ·»å é»è®¤å¼,å¦åformData ä¸ä¸åå¨è¿ä¸ªåæ®µä¸æ ¡éª |
| | | if(!this.is_reset){ |
| | | this.is_reset = false |
| | | this.formItem.setValue(this.dataValue) |
| | | } |
| | | this.rename = this.formItem.name |
| | | this.form.inputChildrens.push(this) |
| | | } |
| | | } |
| | | |
| | | if (this.localdata && this.localdata.length !== 0) { |
| | | this.isLocal = true |
| | | this.range = this.localdata |
| | | this.dataList = this.getDataList(this.getSelectedValue(this.range)) |
| | | } else { |
| | | if (this.collection) { |
| | | this.isLocal = false |
| | | this.loadData() |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | loadData() { |
| | | this.mixinDatacomGet().then(res=>{ |
| | | this.mixinDatacomResData = res.result.data |
| | | if(this.mixinDatacomResData.length === 0){ |
| | | this.isLocal = false |
| | | this.mixinDatacomErrorMessage = this.emptyText |
| | | }else{ |
| | | this.isLocal = true |
| | | } |
| | | }).catch(err=>{ |
| | | this.mixinDatacomErrorMessage = err.message |
| | | }) |
| | | }, |
| | | /** |
| | | * è·åç¶å
ç´ å®ä¾ |
| | | */ |
| | | getForm(name = 'uniForms') { |
| | | let parent = this.$parent; |
| | | let parentName = parent.$options.name; |
| | | while (parentName !== name) { |
| | | parent = parent.$parent; |
| | | if (!parent) return false |
| | | parentName = parent.$options.name; |
| | | } |
| | | return parent; |
| | | }, |
| | | chagne(e) { |
| | | const values = e.detail.value |
| | | |
| | | let detail = { |
| | | value: [], |
| | | data: [] |
| | | } |
| | | |
| | | if (this.multiple) { |
| | | this.range.forEach(item => { |
| | | |
| | | if (values.includes(item[this.map.value] + '')) { |
| | | detail.value.push(item[this.map.value]) |
| | | detail.data.push(item) |
| | | } |
| | | }) |
| | | } else { |
| | | const range = this.range.find(item => (item[this.map.value] + '') === values) |
| | | if (range) { |
| | | detail = { |
| | | value: range[this.map.value], |
| | | data: range |
| | | } |
| | | } |
| | | } |
| | | this.formItem && this.formItem.setValue(detail.value) |
| | | // TODO å
¼å®¹ vue2 |
| | | this.$emit('input', detail.value); |
| | | // // TOTO å
¼å®¹ vue3 |
| | | this.$emit('update:modelValue', detail.value); |
| | | this.$emit('change', { |
| | | detail |
| | | }) |
| | | if (this.multiple) { |
| | | // 妿 v-model 没æç»å® ï¼åèµ°å
é¨é»è¾ |
| | | // if (this.value.length === 0) { |
| | | this.dataList = this.getDataList(detail.value, true) |
| | | // } |
| | | } else { |
| | | this.dataList = this.getDataList(detail.value) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * è·å渲æçæ°æ°ç» |
| | | * @param {Object} value éä¸å
容 |
| | | */ |
| | | getDataList(value) { |
| | | // è§£é¤å¼ç¨å
³ç³»ï¼ç ´ååå¼ç¨å
³ç³»ï¼é¿å
æ±¡ææºæ°æ® |
| | | let dataList = JSON.parse(JSON.stringify(this.range)) |
| | | let list = [] |
| | | if (this.multiple) { |
| | | if (!Array.isArray(value)) { |
| | | value = [] |
| | | } |
| | | } |
| | | dataList.forEach((item, index) => { |
| | | item.disabled = item.disable || item.disabled || false |
| | | if (this.multiple) { |
| | | if (value.length > 0) { |
| | | let have = value.find(val => val === item[this.map.value]) |
| | | item.selected = have !== undefined |
| | | } else { |
| | | item.selected = false |
| | | } |
| | | } else { |
| | | item.selected = value === item[this.map.value] |
| | | } |
| | | |
| | | list.push(item) |
| | | }) |
| | | return this.setRange(list) |
| | | }, |
| | | /** |
| | | * å¤çæå¤§æå°å¼ |
| | | * @param {Object} list |
| | | */ |
| | | setRange(list) { |
| | | let selectList = list.filter(item => item.selected) |
| | | let min = Number(this.min) || 0 |
| | | let max = Number(this.max) || '' |
| | | list.forEach((item, index) => { |
| | | if (this.multiple) { |
| | | if (selectList.length <= min) { |
| | | let have = selectList.find(val => val[this.map.value] === item[this.map.value]) |
| | | if (have !== undefined) { |
| | | item.disabled = true |
| | | } |
| | | } |
| | | |
| | | if (selectList.length >= max && max !== '') { |
| | | let have = selectList.find(val => val[this.map.value] === item[this.map.value]) |
| | | if (have === undefined) { |
| | | item.disabled = true |
| | | } |
| | | } |
| | | } |
| | | this.setStyles(item, index) |
| | | list[index] = item |
| | | }) |
| | | return list |
| | | }, |
| | | /** |
| | | * 设置 class |
| | | * @param {Object} item |
| | | * @param {Object} index |
| | | */ |
| | | setStyles(item, index) { |
| | | // 设置èªå®ä¹æ ·å¼ |
| | | item.styleBackgroud = this.setStyleBackgroud(item) |
| | | item.styleIcon = this.setStyleIcon(item) |
| | | item.styleIconText = this.setStyleIconText(item) |
| | | item.styleRightIcon = this.setStyleRightIcon(item) |
| | | }, |
| | | |
| | | /** |
| | | * è·åéä¸å¼ |
| | | * @param {Object} range |
| | | */ |
| | | getSelectedValue(range) { |
| | | if (!this.multiple) return this.dataValue |
| | | let selectedArr = [] |
| | | range.forEach((item) => { |
| | | if (item.selected) { |
| | | selectedArr.push(item[this.map.value]) |
| | | } |
| | | }) |
| | | return this.dataValue.length > 0 ? this.dataValue : selectedArr |
| | | }, |
| | | |
| | | /** |
| | | * è®¾ç½®èæ¯æ ·å¼ |
| | | */ |
| | | setStyleBackgroud(item) { |
| | | let styles = {} |
| | | let selectedColor = this.selectedColor?this.selectedColor:'#2979ff' |
| | | if (this.mode !== 'list') { |
| | | styles['border-color'] = item.selected?selectedColor:'#DCDFE6' |
| | | } |
| | | if (this.mode === 'tag') { |
| | | styles['background-color'] = item.selected? selectedColor:'#f5f5f5' |
| | | } |
| | | let classles = '' |
| | | for (let i in styles) { |
| | | classles += `${i}:${styles[i]};` |
| | | } |
| | | return classles |
| | | }, |
| | | setStyleIcon(item) { |
| | | let styles = {} |
| | | let classles = '' |
| | | let selectedColor = this.selectedColor?this.selectedColor:'#2979ff' |
| | | styles['background-color'] = item.selected?selectedColor:'#fff' |
| | | styles['border-color'] = item.selected?selectedColor:'#DCDFE6' |
| | | |
| | | if(!item.selected && item.disabled){ |
| | | styles['background-color'] = '#F2F6FC' |
| | | styles['border-color'] = item.selected?selectedColor:'#DCDFE6' |
| | | } |
| | | |
| | | for (let i in styles) { |
| | | classles += `${i}:${styles[i]};` |
| | | } |
| | | return classles |
| | | }, |
| | | setStyleIconText(item) { |
| | | let styles = {} |
| | | let classles = '' |
| | | let selectedColor = this.selectedColor?this.selectedColor:'#2979ff' |
| | | if (this.mode === 'tag') { |
| | | styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:'#fff'):'#666' |
| | | } else { |
| | | styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:selectedColor):'#666' |
| | | } |
| | | if(!item.selected && item.disabled){ |
| | | styles.color = '#999' |
| | | } |
| | | |
| | | for (let i in styles) { |
| | | classles += `${i}:${styles[i]};` |
| | | } |
| | | return classles |
| | | }, |
| | | setStyleRightIcon(item) { |
| | | let styles = {} |
| | | let classles = '' |
| | | if (this.mode === 'list') { |
| | | styles['border-color'] = item.selected?this.styles.selectedColor:'#DCDFE6' |
| | | } |
| | | for (let i in styles) { |
| | | classles += `${i}:${styles[i]};` |
| | | } |
| | | |
| | | return classles |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | $checked-color: #2979ff; |
| | | $border-color: #DCDFE6; |
| | | $disable:0.4; |
| | | |
| | | @mixin flex { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-data-loading { |
| | | @include flex; |
| | | flex-direction: row; |
| | | justify-content: center; |
| | | align-items: center; |
| | | height: 36px; |
| | | padding-left: 10px; |
| | | color: #999; |
| | | } |
| | | |
| | | .uni-data-checklist { |
| | | position: relative; |
| | | z-index: 0; |
| | | flex: 1; |
| | | // å¤éæ ·å¼ |
| | | .checklist-group { |
| | | @include flex; |
| | | flex-direction: row; |
| | | flex-wrap: wrap; |
| | | |
| | | &.is-list { |
| | | flex-direction: column; |
| | | } |
| | | |
| | | .checklist-box { |
| | | @include flex; |
| | | flex-direction: row; |
| | | align-items: center; |
| | | position: relative; |
| | | margin: 5px 0; |
| | | margin-right: 25px; |
| | | |
| | | .hidden { |
| | | position: absolute; |
| | | opacity: 0; |
| | | } |
| | | |
| | | // æåæ ·å¼ |
| | | .checklist-content { |
| | | @include flex; |
| | | flex: 1; |
| | | flex-direction: row; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | .checklist-text { |
| | | font-size: 14px; |
| | | color: #666; |
| | | margin-left: 5px; |
| | | line-height: 14px; |
| | | } |
| | | |
| | | .checkobx__list { |
| | | border-right-width: 1px; |
| | | border-right-color: #007aff; |
| | | border-right-style: solid; |
| | | border-bottom-width:1px; |
| | | border-bottom-color: #007aff; |
| | | border-bottom-style: solid; |
| | | height: 12px; |
| | | width: 6px; |
| | | left: -5px; |
| | | transform-origin: center; |
| | | transform: rotate(45deg); |
| | | opacity: 0; |
| | | } |
| | | } |
| | | |
| | | // å¤éæ ·å¼ |
| | | .checkbox__inner { |
| | | /* #ifndef APP-NVUE */ |
| | | flex-shrink: 0; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | position: relative; |
| | | width: 16px; |
| | | height: 16px; |
| | | border: 1px solid $border-color; |
| | | border-radius: 4px; |
| | | background-color: #fff; |
| | | z-index: 1; |
| | | .checkbox__inner-icon { |
| | | position: absolute; |
| | | /* #ifdef APP-NVUE */ |
| | | top: 2px; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | top: 1px; |
| | | /* #endif */ |
| | | left: 5px; |
| | | height: 8px; |
| | | width: 4px; |
| | | border-right-width: 1px; |
| | | border-right-color: #fff; |
| | | border-right-style: solid; |
| | | border-bottom-width:1px ; |
| | | border-bottom-color: #fff; |
| | | border-bottom-style: solid; |
| | | opacity: 0; |
| | | transform-origin: center; |
| | | transform: rotate(40deg); |
| | | } |
| | | } |
| | | |
| | | // åéæ ·å¼ |
| | | .radio__inner { |
| | | @include flex; |
| | | /* #ifndef APP-NVUE */ |
| | | flex-shrink: 0; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | justify-content: center; |
| | | align-items: center; |
| | | position: relative; |
| | | width: 16px; |
| | | height: 16px; |
| | | border: 1px solid $border-color; |
| | | border-radius: 16px; |
| | | background-color: #fff; |
| | | z-index: 1; |
| | | |
| | | .radio__inner-icon { |
| | | width: 8px; |
| | | height: 8px; |
| | | border-radius: 10px; |
| | | opacity: 0; |
| | | } |
| | | } |
| | | |
| | | // é»è®¤æ ·å¼ |
| | | &.is--default { |
| | | |
| | | // ç¦ç¨ |
| | | &.is-disable { |
| | | /* #ifdef H5 */ |
| | | cursor: not-allowed; |
| | | /* #endif */ |
| | | .checkbox__inner { |
| | | background-color: #F2F6FC; |
| | | border-color: $border-color; |
| | | /* #ifdef H5 */ |
| | | cursor: not-allowed; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .radio__inner { |
| | | background-color: #F2F6FC; |
| | | border-color: $border-color; |
| | | } |
| | | .checklist-text { |
| | | color: #999; |
| | | } |
| | | } |
| | | |
| | | // éä¸ |
| | | &.is-checked { |
| | | .checkbox__inner { |
| | | border-color: $checked-color; |
| | | background-color: $checked-color; |
| | | |
| | | .checkbox__inner-icon { |
| | | opacity: 1; |
| | | transform: rotate(45deg); |
| | | } |
| | | } |
| | | .radio__inner { |
| | | border-color: $checked-color; |
| | | .radio__inner-icon { |
| | | opacity: 1; |
| | | background-color: $checked-color; |
| | | } |
| | | } |
| | | .checklist-text { |
| | | color: $checked-color; |
| | | } |
| | | // éä¸ç¦ç¨ |
| | | &.is-disable { |
| | | .checkbox__inner { |
| | | opacity: $disable; |
| | | } |
| | | |
| | | .checklist-text { |
| | | opacity: $disable; |
| | | } |
| | | .radio__inner { |
| | | opacity: $disable; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // æé®æ ·å¼ |
| | | &.is--button { |
| | | margin-right: 10px; |
| | | padding: 5px 10px; |
| | | border: 1px $border-color solid; |
| | | border-radius: 3px; |
| | | transition: border-color 0.2s; |
| | | |
| | | // ç¦ç¨ |
| | | &.is-disable { |
| | | /* #ifdef H5 */ |
| | | cursor: not-allowed; |
| | | /* #endif */ |
| | | border: 1px #eee solid; |
| | | opacity: $disable; |
| | | .checkbox__inner { |
| | | background-color: #F2F6FC; |
| | | border-color: $border-color; |
| | | /* #ifdef H5 */ |
| | | cursor: not-allowed; |
| | | /* #endif */ |
| | | } |
| | | .radio__inner { |
| | | background-color: #F2F6FC; |
| | | border-color: $border-color; |
| | | /* #ifdef H5 */ |
| | | cursor: not-allowed; |
| | | /* #endif */ |
| | | } |
| | | .checklist-text { |
| | | color: #999; |
| | | } |
| | | } |
| | | |
| | | &.is-checked { |
| | | border-color: $checked-color; |
| | | .checkbox__inner { |
| | | border-color: $checked-color; |
| | | background-color: $checked-color; |
| | | .checkbox__inner-icon { |
| | | opacity: 1; |
| | | transform: rotate(45deg); |
| | | } |
| | | } |
| | | |
| | | .radio__inner { |
| | | border-color: $checked-color; |
| | | |
| | | .radio__inner-icon { |
| | | opacity: 1; |
| | | background-color: $checked-color; |
| | | } |
| | | } |
| | | |
| | | .checklist-text { |
| | | color: $checked-color; |
| | | } |
| | | |
| | | // éä¸ç¦ç¨ |
| | | &.is-disable { |
| | | opacity: $disable; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // æ ç¾æ ·å¼ |
| | | &.is--tag { |
| | | margin-right: 10px; |
| | | padding: 5px 10px; |
| | | border: 1px $border-color solid; |
| | | border-radius: 3px; |
| | | background-color: #f5f5f5; |
| | | |
| | | .checklist-text { |
| | | margin: 0; |
| | | color: #666; |
| | | } |
| | | |
| | | // ç¦ç¨ |
| | | &.is-disable { |
| | | /* #ifdef H5 */ |
| | | cursor: not-allowed; |
| | | /* #endif */ |
| | | opacity: $disable; |
| | | } |
| | | |
| | | &.is-checked { |
| | | background-color: $checked-color; |
| | | border-color: $checked-color; |
| | | |
| | | .checklist-text { |
| | | color: #fff; |
| | | } |
| | | } |
| | | } |
| | | // åè¡¨æ ·å¼ |
| | | &.is--list { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | padding: 10px 15px; |
| | | padding-left: 0; |
| | | margin: 0; |
| | | |
| | | &.is-list-border { |
| | | border-top: 1px #eee solid; |
| | | } |
| | | |
| | | // ç¦ç¨ |
| | | &.is-disable { |
| | | /* #ifdef H5 */ |
| | | cursor: not-allowed; |
| | | /* #endif */ |
| | | .checkbox__inner { |
| | | background-color: #F2F6FC; |
| | | border-color: $border-color; |
| | | /* #ifdef H5 */ |
| | | cursor: not-allowed; |
| | | /* #endif */ |
| | | } |
| | | .checklist-text { |
| | | color: #999; |
| | | } |
| | | } |
| | | |
| | | &.is-checked { |
| | | .checkbox__inner { |
| | | border-color: $checked-color; |
| | | background-color: $checked-color; |
| | | |
| | | .checkbox__inner-icon { |
| | | opacity: 1; |
| | | transform: rotate(45deg); |
| | | } |
| | | } |
| | | .radio__inner { |
| | | .radio__inner-icon { |
| | | opacity: 1; |
| | | } |
| | | } |
| | | .checklist-text { |
| | | color: $checked-color; |
| | | } |
| | | |
| | | .checklist-content { |
| | | .checkobx__list { |
| | | opacity: 1; |
| | | border-color: $checked-color; |
| | | } |
| | | } |
| | | |
| | | // éä¸ç¦ç¨ |
| | | &.is-disable { |
| | | .checkbox__inner { |
| | | opacity: $disable; |
| | | } |
| | | |
| | | .checklist-text { |
| | | opacity: $disable; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-data-checkbox", |
| | | "displayName": "uni-data-checkbox æ°æ®éæ©å¨", |
| | | "version": "1.0.0", |
| | | "description": "éè¿æ°æ®é©±å¨çåéæ¡åå¤éæ¡", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "checkbox", |
| | | "åé", |
| | | "å¤é", |
| | | "åéå¤é" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "^3.1.1" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-load-more","uni-scss"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## DataCheckbox æ°æ®é©±å¨çåéå¤éæ¡ |
| | | > **ç»ä»¶åï¼uni-data-checkbox** |
| | | > 代ç åï¼ `uDataCheckbox` |
| | | |
| | | |
| | | æ¬ç»ä»¶æ¯åºäºuni-appåºç¡ç»ä»¶checkboxçå°è£
ãæ¬ç»ä»¶è¦è§£å³é®é¢å
æ¬ï¼ |
| | | |
| | | 1. æ°æ®ç»å®åç»ä»¶ï¼ç»æ¬ç»ä»¶ç»å®ä¸ä¸ªdataï¼ä¼èªå¨æ¸²æä¸ç»åéå
容ãå以å¾ï¼å¼åè
éè¦ç¼åä¸å°ä»£ç å®ç°ç±»ä¼¼åè½ |
| | | 2. èªå¨çè¡¨åæ ¡éªï¼ç»ä»¶ç»å®äºdataï¼ä¸ç¬¦å[uni-forms](https://ext.dcloud.net.cn/plugin?id=2773)ç»ä»¶çè¡¨åæ ¡éªè§èï¼æé
使ç¨ä¼èªå¨å®ç°è¡¨åæ ¡éª |
| | | 3. æ¬ç»ä»¶åå¹¶äºåéå¤é |
| | | 4. æ¬ç»ä»¶æè¥å¹²é£æ ¼éæ©ï¼å¦æ®éçåéå¤éæ¡ãå¹¶åbutton飿 ¼ãtag飿 ¼ãå¼åè
å¯ä»¥å¿«ééæ©éè¦ç飿 ¼ãä½ä½ä¸ºä¸ä¸ªå°è£
ç»ä»¶ï¼æ ·å¼ä»£ç è½ç¶ä¸ç¨èªå·±åäºï¼å´ä¼çºç²ä¸å®çæ ·å¼èªå®ä¹æ§ |
| | | |
| | | å¨uniCloudå¼åä¸ï¼`DB Schema`ä¸é
ç½®äºenumæä¸¾çç±»ååï¼å¨webæ§å¶å°ç[èªå¨çæè¡¨å](https://uniapp.dcloud.io/uniCloud/schema?id=autocode)åè½ä¸ï¼ä¼èªå¨çæ``uni-data-checkbox``ç»ä»¶å¹¶ç»å®å¥½data |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-data-checkbox) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.0.3ï¼2022-02-25ï¼ |
| | | - ä¿®å¤ nvue 䏿¯æç v-show ç bug |
| | | ## 1.0.2ï¼2022-02-25ï¼ |
| | | - ä¿®å¤ æ¡ä»¶ç¼è¯ nvue 䏿¯æç css æ ·å¼ |
| | | ## 1.0.1ï¼2021-11-23ï¼ |
| | | - ä¿®å¤ ç±ä¸ä¸ªçæ¬å¼åçmapãv-modelç屿§ä¸çæçbug |
| | | ## 1.0.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶ UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-data-picker](https://uniapp.dcloud.io/component/uniui/uni-data-picker) |
| | | ## 0.4.9ï¼2021-10-28ï¼ |
| | | - ä¿®å¤ VUE2 v-model æ¦çæ æç bug |
| | | ## 0.4.8ï¼2021-10-27ï¼ |
| | | - ä¿®å¤ v-model æ¦çæ æç bug |
| | | ## 0.4.7ï¼2021-10-25ï¼ |
| | | - æ°å¢ 屿§ spaceInfo æå¡ç©ºé´é
ç½® HBuilderX 3.2.11+ |
| | | - ä¿®å¤ æ å uniCloud æ°æ®ç±»å为 int æ¶æ¥éç bug |
| | | ## 0.4.6ï¼2021-10-19ï¼ |
| | | - ä¿®å¤ é VUE3 v-model 为 0 æ¶æ æ³éä¸ç bug |
| | | ## 0.4.5ï¼2021-09-26ï¼ |
| | | - æ°å¢ æ¸
é¤å·²é项çåè½ï¼éè¿ clearIcon 屿§é
ç½®æ¯å¦æ¾ç¤ºæé®ï¼ï¼åæ¶æä¾ clear æ¹æ³ä»¥ä¾è°ç¨ï¼äºè
çæ |
| | | - ä¿®å¤ readonly 为 true æ¶æ¥éç bug |
| | | ## 0.4.4ï¼2021-09-26ï¼ |
| | | - ä¿®å¤ ä¸ä¸çæ¬é æç map 屿§å¤±æç bug |
| | | - æ°å¢ ellipsis 屿§ï¼æ¯æé
ç½® tab é项é¿åº¦è¿é¿æ¶æ¯å¦èªå¨çç¥ |
| | | ## 0.4.3ï¼2021-09-24ï¼ |
| | | - ä¿®å¤ æäºæ
åµä¸çº§èæªè§¦åç bug |
| | | ## 0.4.2ï¼2021-09-23ï¼ |
| | | - æ°å¢ æä¾ show å hide æ¹æ³ï¼å¼åè
å¯ä»¥éè¿ ref è°ç¨ |
| | | - æ°å¢ é项å
容è¿é¿èªå¨æ·»å çç¥å· |
| | | ## 0.4.1ï¼2021-09-15ï¼ |
| | | - æ°å¢ map 屿§ åæ®µæ å°ï¼å° text/value æ å°å°æ°æ®ä¸çå
¶ä»å段 |
| | | ## 0.4.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建 vue3 项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 0.3.5ï¼2021-06-04ï¼ |
| | | - ä¿®å¤ æ æ³å è½½äºç«¯æ°æ®çé®é¢ |
| | | ## 0.3.4ï¼2021-05-28ï¼ |
| | | - ä¿®å¤ v-model æ æé®é¢ |
| | | - ä¿®å¤ loaddata ä¸ºç©ºæ°æ®ç»æ¶å è½½æ¶é´è¿é¿é®é¢ |
| | | - ä¿®å¤ ä¸ä¸ªçæ¬å¼åºçæ¬å°æ°æ®æ æ³éæ©å¸¦æ children ç 2 级èç¹ |
| | | ## 0.3.3ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 0.3.2ï¼2021-04-22ï¼ |
| | | - ä¿®å¤ éæ å½¢æ°æ®æ where 屿§æ¥è¯¢æ¥éçé®é¢ |
| | | ## 0.3.1ï¼2021-04-15ï¼ |
| | | - ä¿®å¤ æ¬å°æ°æ®æ¦çæ æ³åæ¾æ¶é®é¢ |
| | | ## 0.3.0ï¼2021-04-07ï¼ |
| | | - æ°å¢ æ¯æäºç«¯éæ å½¢è¡¨ç»ææ°æ® |
| | | - ä¿®å¤ æ ¹èç¹ parent_field åæ®µçäº null æ¶éæ©çé¢éä¹±é®é¢ |
| | | ## 0.2.0ï¼2021-03-15ï¼ |
| | | - ä¿®å¤ nodeclickãpopupopenedãpopupclosed äºä»¶æ æ³è§¦åçé®é¢ |
| | | ## 0.1.9ï¼2021-03-09ï¼ |
| | | - ä¿®å¤ å¾®ä¿¡å°ç¨åºæäºæ
åµä¸æ æ³éæ©çé®é¢ |
| | | ## 0.1.8ï¼2021-02-05ï¼ |
| | | - ä¼å é¨åæ ·å¼å¨ nvue ä¸çå
¼å®¹è¡¨ç° |
| | | ## 0.1.7ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸º uni_modules ç®å½è§è |
| New file |
| | |
| | | // #ifdef H5 |
| | | export default { |
| | | name: 'Keypress', |
| | | props: { |
| | | disable: { |
| | | type: Boolean, |
| | | default: false |
| | | } |
| | | }, |
| | | mounted () { |
| | | const keyNames = { |
| | | esc: ['Esc', 'Escape'], |
| | | tab: 'Tab', |
| | | enter: 'Enter', |
| | | space: [' ', 'Spacebar'], |
| | | up: ['Up', 'ArrowUp'], |
| | | left: ['Left', 'ArrowLeft'], |
| | | right: ['Right', 'ArrowRight'], |
| | | down: ['Down', 'ArrowDown'], |
| | | delete: ['Backspace', 'Delete', 'Del'] |
| | | } |
| | | const listener = ($event) => { |
| | | if (this.disable) { |
| | | return |
| | | } |
| | | const keyName = Object.keys(keyNames).find(key => { |
| | | const keyName = $event.key |
| | | const value = keyNames[key] |
| | | return value === keyName || (Array.isArray(value) && value.includes(keyName)) |
| | | }) |
| | | if (keyName) { |
| | | // é¿å
åå
¶ä»æé®äºä»¶å²çª |
| | | setTimeout(() => { |
| | | this.$emit(keyName, {}) |
| | | }, 0) |
| | | } |
| | | } |
| | | document.addEventListener('keyup', listener) |
| | | this.$once('hook:beforeDestroy', () => { |
| | | document.removeEventListener('keyup', listener) |
| | | }) |
| | | }, |
| | | render: () => {} |
| | | } |
| | | // #endif |
| New file |
| | |
| | | <template> |
| | | <view class="uni-data-tree"> |
| | | <view class="uni-data-tree-input" @click="handleInput"> |
| | | <slot :options="options" :data="inputSelected" :error="errorMessage"> |
| | | <view class="input-value" :class="{'input-value-border': border}"> |
| | | <text v-if="errorMessage" class="selected-area error-text">{{errorMessage}}</text> |
| | | <view v-else-if="loading && !isOpened" class="selected-area"> |
| | | <uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more> |
| | | </view> |
| | | <scroll-view v-else-if="inputSelected.length" class="selected-area" scroll-x="true"> |
| | | <view class="selected-list"> |
| | | <view class="selected-item" v-for="(item,index) in inputSelected" :key="index"> |
| | | <text>{{item.text}}</text><text v-if="index<inputSelected.length-1" |
| | | class="input-split-line">{{split}}</text> |
| | | </view> |
| | | </view> |
| | | </scroll-view> |
| | | <text v-else class="selected-area placeholder">{{placeholder}}</text> |
| | | <view v-if="clearIcon && !readonly && inputSelected.length" class="icon-clear" |
| | | @click.stop="clear"> |
| | | <uni-icons type="clear" color="#e1e1e1" size="14"></uni-icons> |
| | | </view> |
| | | <view class="arrow-area" v-if="(!clearIcon || !inputSelected.length) && !readonly "> |
| | | <view class="input-arrow"></view> |
| | | </view> |
| | | </view> |
| | | </slot> |
| | | </view> |
| | | <view class="uni-data-tree-cover" v-if="isOpened" @click="handleClose"></view> |
| | | <view class="uni-data-tree-dialog" v-if="isOpened"> |
| | | <view class="uni-popper__arrow"></view> |
| | | <view class="dialog-caption"> |
| | | <view class="title-area"> |
| | | <text class="dialog-title">{{popupTitle}}</text> |
| | | </view> |
| | | <view class="dialog-close" @click="handleClose"> |
| | | <view class="dialog-close-plus" data-id="close"></view> |
| | | <view class="dialog-close-plus dialog-close-rotate" data-id="close"></view> |
| | | </view> |
| | | </view> |
| | | <data-picker-view class="picker-view" ref="pickerView" v-model="dataValue" :localdata="localdata" |
| | | :preload="preload" :collection="collection" :field="field" :orderby="orderby" :where="where" |
| | | :step-searh="stepSearh" :self-field="selfField" :parent-field="parentField" :managed-mode="true" |
| | | :map="map" :ellipsis="ellipsis" @change="onchange" @datachange="ondatachange" @nodeclick="onnodeclick"> |
| | | </data-picker-view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import dataPicker from "../uni-data-pickerview/uni-data-picker.js" |
| | | import DataPickerView from "../uni-data-pickerview/uni-data-pickerview.vue" |
| | | |
| | | /** |
| | | * DataPicker 级èéæ© |
| | | * @description æ¯æååãåå¤å级èéæ©ãåæ°æ²¡æéå¶ï¼å¦æå±å¹æ¾ç¤ºä¸å
¨ï¼é¡¶é¨tabåºåä¼å·¦å³æ»å¨ã |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=3796 |
| | | * @property {String} popup-title å¼¹åºçªå£æ é¢ |
| | | * @property {Array} localdata æ¬å°æ°æ®ï¼åè |
| | | * @property {Boolean} border = [true|false] æ¯å¦æè¾¹æ¡ |
| | | * @property {Boolean} readonly = [true|false] æ¯å¦ä»
读 |
| | | * @property {Boolean} preload = [true|false] æ¯å¦é¢å è½½æ°æ® |
| | | * @value true å¼å¯é¢å è½½æ°æ®ï¼ç¹å»å¼¹åºçªå£åæ¾ç¤ºå·²å è½½æ°æ® |
| | | * @value false å
³éé¢å è½½æ°æ®ï¼ç¹å»å¼¹åºçªå£åå¼å§å è½½æ°æ® |
| | | * @property {Boolean} step-searh = [true|false] æ¯å¦å叿¥è¯¢ |
| | | * @value true å¯ç¨å叿¥è¯¢ï¼ä»
æ¥è¯¢å½åéä¸èç¹ |
| | | * @value false å
³éå叿¥è¯¢ï¼ä¸æ¬¡æ¥è¯¢åºæææ°æ® |
| | | * @property {String|DBFieldString} self-field å叿¥è¯¢å½ååæ®µåç§° |
| | | * @property {String|DBFieldString} parent-field å叿¥è¯¢ç¶å段åç§° |
| | | * @property {String|DBCollectionString} collection 表å |
| | | * @property {String|DBFieldString} field æ¥è¯¢å段ï¼å¤ä¸ªåæ®µç¨ `,` åå² |
| | | * @property {String} orderby æåºåæ®µåæ£åºåå设置 |
| | | * @property {String|JQLString} where æ¥è¯¢æ¡ä»¶ |
| | | * @event {Function} popupshow å¼¹åºçéæ©çªå£æå¼æ¶è§¦åæ¤äºä»¶ |
| | | * @event {Function} popuphide å¼¹åºçéæ©çªå£å
³éæ¶è§¦åæ¤äºä»¶ |
| | | */ |
| | | export default { |
| | | name: 'UniDataPicker', |
| | | emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue'], |
| | | mixins: [dataPicker], |
| | | components: { |
| | | DataPickerView |
| | | }, |
| | | props: { |
| | | options: { |
| | | type: [Object, Array], |
| | | default () { |
| | | return {} |
| | | } |
| | | }, |
| | | popupTitle: { |
| | | type: String, |
| | | default: 'è¯·éæ©' |
| | | }, |
| | | placeholder: { |
| | | type: String, |
| | | default: 'è¯·éæ©' |
| | | }, |
| | | heightMobile: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | readonly: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | clearIcon: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | border: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | split: { |
| | | type: String, |
| | | default: '/' |
| | | }, |
| | | ellipsis: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | isOpened: false, |
| | | inputSelected: [] |
| | | } |
| | | }, |
| | | created() { |
| | | this.form = this.getForm('uniForms') |
| | | this.formItem = this.getForm('uniFormsItem') |
| | | if (this.formItem) { |
| | | if (this.formItem.name) { |
| | | this.rename = this.formItem.name |
| | | this.form.inputChildrens.push(this) |
| | | } |
| | | } |
| | | |
| | | this.$nextTick(() => { |
| | | this.load() |
| | | }) |
| | | }, |
| | | methods: { |
| | | clear() { |
| | | this.inputSelected.splice(0) |
| | | this._dispatchEvent([]) |
| | | }, |
| | | onPropsChange() { |
| | | this._treeData = [] |
| | | this.selectedIndex = 0 |
| | | this.load() |
| | | }, |
| | | load() { |
| | | if (this.readonly) { |
| | | this._processReadonly(this.localdata, this.dataValue) |
| | | return |
| | | } |
| | | |
| | | if (this.isLocaldata) { |
| | | this.loadData() |
| | | this.inputSelected = this.selected.slice(0) |
| | | } else if (!this.parentField && !this.selfField && this.hasValue) { |
| | | this.getNodeData(() => { |
| | | this.inputSelected = this.selected.slice(0) |
| | | }) |
| | | } else if (this.hasValue) { |
| | | this.getTreePath(() => { |
| | | this.inputSelected = this.selected.slice(0) |
| | | }) |
| | | } |
| | | }, |
| | | getForm(name = 'uniForms') { |
| | | let parent = this.$parent; |
| | | let parentName = parent.$options.name; |
| | | while (parentName !== name) { |
| | | parent = parent.$parent; |
| | | if (!parent) return false; |
| | | parentName = parent.$options.name; |
| | | } |
| | | return parent; |
| | | }, |
| | | show() { |
| | | this.isOpened = true |
| | | this.$nextTick(() => { |
| | | this.$refs.pickerView.updateData({ |
| | | treeData: this._treeData, |
| | | selected: this.selected, |
| | | selectedIndex: this.selectedIndex |
| | | }) |
| | | }) |
| | | this.$emit('popupopened') |
| | | }, |
| | | hide() { |
| | | this.isOpened = false |
| | | this.$emit('popupclosed') |
| | | }, |
| | | handleInput() { |
| | | if (this.readonly) { |
| | | return |
| | | } |
| | | this.show() |
| | | }, |
| | | handleClose(e) { |
| | | this.hide() |
| | | }, |
| | | onnodeclick(e) { |
| | | this.$emit('nodeclick', e) |
| | | }, |
| | | ondatachange(e) { |
| | | this._treeData = this.$refs.pickerView._treeData |
| | | }, |
| | | onchange(e) { |
| | | this.hide() |
| | | this.inputSelected = e |
| | | this._dispatchEvent(e) |
| | | }, |
| | | _processReadonly(dataList, value) { |
| | | var isTree = dataList.findIndex((item) => { |
| | | return item.children |
| | | }) |
| | | if (isTree > -1) { |
| | | let inputValue |
| | | if (Array.isArray(value)) { |
| | | inputValue = value[value.length - 1] |
| | | if (typeof inputValue === 'object' && inputValue.value) { |
| | | inputValue = inputValue.value |
| | | } |
| | | } else { |
| | | inputValue = value |
| | | } |
| | | this.inputSelected = this._findNodePath(inputValue, this.localdata) |
| | | return |
| | | } |
| | | |
| | | if (!this.hasValue) { |
| | | this.inputSelected = [] |
| | | return |
| | | } |
| | | |
| | | let result = [] |
| | | for (let i = 0; i < value.length; i++) { |
| | | var val = value[i] |
| | | var item = dataList.find((v) => { |
| | | return v.value == val |
| | | }) |
| | | if (item) { |
| | | result.push(item) |
| | | } |
| | | } |
| | | if (result.length) { |
| | | this.inputSelected = result |
| | | } |
| | | }, |
| | | _filterForArray(data, valueArray) { |
| | | var result = [] |
| | | for (let i = 0; i < valueArray.length; i++) { |
| | | var value = valueArray[i] |
| | | var found = data.find((item) => { |
| | | return item.value == value |
| | | }) |
| | | if (found) { |
| | | result.push(found) |
| | | } |
| | | } |
| | | return result |
| | | }, |
| | | _dispatchEvent(selected) { |
| | | let item = {} |
| | | if (selected.length) { |
| | | var value = new Array(selected.length) |
| | | for (var i = 0; i < selected.length; i++) { |
| | | value[i] = selected[i].value |
| | | } |
| | | item = selected[selected.length - 1] |
| | | } else { |
| | | item.value = '' |
| | | } |
| | | if (this.formItem) { |
| | | this.formItem.setValue(item.value) |
| | | } |
| | | |
| | | this.$emit('input', item.value) |
| | | this.$emit('update:modelValue', item.value) |
| | | this.$emit('change', { |
| | | detail: { |
| | | value: selected |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style > |
| | | .uni-data-tree { |
| | | position: relative; |
| | | font-size: 14px; |
| | | } |
| | | |
| | | .error-text { |
| | | color: #DD524D; |
| | | } |
| | | |
| | | .input-value { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | align-items: center; |
| | | flex-wrap: nowrap; |
| | | font-size: 14px; |
| | | line-height: 38px; |
| | | padding: 0 5px; |
| | | overflow: hidden; |
| | | /* #ifdef APP-NVUE */ |
| | | height: 40px; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .input-value-border { |
| | | border: 1px solid #e5e5e5; |
| | | border-radius: 5px; |
| | | } |
| | | |
| | | .selected-area { |
| | | flex: 1; |
| | | overflow: hidden; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | } |
| | | |
| | | .load-more { |
| | | /* #ifndef APP-NVUE */ |
| | | margin-right: auto; |
| | | /* #endif */ |
| | | /* #ifdef APP-NVUE */ |
| | | width: 40px; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .selected-list { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | flex-wrap: nowrap; |
| | | padding: 0 5px; |
| | | } |
| | | |
| | | .selected-item { |
| | | flex-direction: row; |
| | | padding: 0 1px; |
| | | /* #ifndef APP-NVUE */ |
| | | white-space: nowrap; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .placeholder { |
| | | color: grey; |
| | | } |
| | | |
| | | .input-split-line { |
| | | opacity: .5; |
| | | } |
| | | |
| | | .arrow-area { |
| | | position: relative; |
| | | width: 20px; |
| | | /* #ifndef APP-NVUE */ |
| | | margin-bottom: 5px; |
| | | margin-left: auto; |
| | | display: flex; |
| | | /* #endif */ |
| | | justify-content: center; |
| | | transform: rotate(-45deg); |
| | | transform-origin: center; |
| | | } |
| | | |
| | | .input-arrow { |
| | | width: 7px; |
| | | height: 7px; |
| | | border-left: 1px solid #999; |
| | | border-bottom: 1px solid #999; |
| | | } |
| | | |
| | | .uni-data-tree-cover { |
| | | position: fixed; |
| | | left: 0; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | background-color: rgba(0, 0, 0, .4); |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | z-index: 100; |
| | | } |
| | | |
| | | .uni-data-tree-dialog { |
| | | position: fixed; |
| | | left: 0; |
| | | top: 20%; |
| | | right: 0; |
| | | bottom: 0; |
| | | background-color: #FFFFFF; |
| | | border-top-left-radius: 10px; |
| | | border-top-right-radius: 10px; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | z-index: 102; |
| | | overflow: hidden; |
| | | /* #ifdef APP-NVUE */ |
| | | width: 750rpx; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .dialog-caption { |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | /* border-bottom: 1px solid #f0f0f0; */ |
| | | } |
| | | |
| | | .title-area { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | align-items: center; |
| | | /* #ifndef APP-NVUE */ |
| | | margin: auto; |
| | | /* #endif */ |
| | | padding: 0 10px; |
| | | } |
| | | |
| | | .dialog-title { |
| | | /* font-weight: bold; */ |
| | | line-height: 44px; |
| | | } |
| | | |
| | | .dialog-close { |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | align-items: center; |
| | | padding: 0 15px; |
| | | } |
| | | |
| | | .dialog-close-plus { |
| | | width: 16px; |
| | | height: 2px; |
| | | background-color: #666; |
| | | border-radius: 2px; |
| | | transform: rotate(45deg); |
| | | } |
| | | |
| | | .dialog-close-rotate { |
| | | position: absolute; |
| | | transform: rotate(-45deg); |
| | | } |
| | | |
| | | .picker-view { |
| | | flex: 1; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | /* #ifdef H5 */ |
| | | @media all and (min-width: 768px) { |
| | | .uni-data-tree-cover { |
| | | background-color: transparent; |
| | | } |
| | | |
| | | .uni-data-tree-dialog { |
| | | position: absolute; |
| | | top: 55px; |
| | | height: auto; |
| | | min-height: 400px; |
| | | max-height: 50vh; |
| | | background-color: #fff; |
| | | border: 1px solid #EBEEF5; |
| | | box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); |
| | | border-radius: 4px; |
| | | overflow: unset; |
| | | } |
| | | |
| | | .dialog-caption { |
| | | display: none; |
| | | } |
| | | |
| | | .icon-clear { |
| | | margin-right: 5px; |
| | | } |
| | | } |
| | | |
| | | /* #endif */ |
| | | |
| | | /* picker å¼¹åºå±éç¨çæç¤ºå°ä¸è§, todoï¼æ©å±è³ä¸ä¸å·¦å³æ¹åå®ä½ */ |
| | | /* #ifndef APP-NVUE */ |
| | | .uni-popper__arrow, |
| | | .uni-popper__arrow::after { |
| | | position: absolute; |
| | | display: block; |
| | | width: 0; |
| | | height: 0; |
| | | border-color: transparent; |
| | | border-style: solid; |
| | | border-width: 6px; |
| | | } |
| | | |
| | | .uni-popper__arrow { |
| | | filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03)); |
| | | top: -6px; |
| | | left: 10%; |
| | | margin-right: 3px; |
| | | border-top-width: 0; |
| | | border-bottom-color: #EBEEF5; |
| | | } |
| | | |
| | | .uni-popper__arrow::after { |
| | | content: " "; |
| | | top: 1px; |
| | | margin-left: -6px; |
| | | border-top-width: 0; |
| | | border-bottom-color: #fff; |
| | | } |
| | | /* #endif */ |
| | | </style> |
| New file |
| | |
| | | export default { |
| | | props: { |
| | | localdata: { |
| | | type: [Array, Object], |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | spaceInfo: { |
| | | type: Object, |
| | | default () { |
| | | return {} |
| | | } |
| | | }, |
| | | collection: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | action: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | field: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | orderby: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | where: { |
| | | type: [String, Object], |
| | | default: '' |
| | | }, |
| | | pageData: { |
| | | type: String, |
| | | default: 'add' |
| | | }, |
| | | pageCurrent: { |
| | | type: Number, |
| | | default: 1 |
| | | }, |
| | | pageSize: { |
| | | type: Number, |
| | | default: 20 |
| | | }, |
| | | getcount: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | getone: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | gettree: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | manual: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | value: { |
| | | type: [Array, String, Number], |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | modelValue: { |
| | | type: [Array, String, Number], |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | preload: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | stepSearh: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | selfField: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | parentField: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | multiple: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | map: { |
| | | type: Object, |
| | | default() { |
| | | return { |
| | | text: "text", |
| | | value: "value" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | loading: false, |
| | | errorMessage: '', |
| | | loadMore: { |
| | | contentdown: '', |
| | | contentrefresh: '', |
| | | contentnomore: '' |
| | | }, |
| | | dataList: [], |
| | | selected: [], |
| | | selectedIndex: 0, |
| | | page: { |
| | | current: this.pageCurrent, |
| | | size: this.pageSize, |
| | | count: 0 |
| | | } |
| | | } |
| | | }, |
| | | computed: { |
| | | isLocaldata() { |
| | | return !this.collection.length |
| | | }, |
| | | postField() { |
| | | let fields = [this.field]; |
| | | if (this.parentField) { |
| | | fields.push(`${this.parentField} as parent_value`); |
| | | } |
| | | return fields.join(','); |
| | | }, |
| | | dataValue() { |
| | | let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null || this.modelValue !== undefined) |
| | | return isModelValue ? this.modelValue : this.value |
| | | }, |
| | | hasValue() { |
| | | if (typeof this.dataValue === 'number') { |
| | | return true |
| | | } |
| | | return (this.dataValue != null) && (this.dataValue.length > 0) |
| | | } |
| | | }, |
| | | created() { |
| | | this.$watch(() => { |
| | | var al = []; |
| | | ['pageCurrent', |
| | | 'pageSize', |
| | | 'spaceInfo', |
| | | 'value', |
| | | 'modelValue', |
| | | 'localdata', |
| | | 'collection', |
| | | 'action', |
| | | 'field', |
| | | 'orderby', |
| | | 'where', |
| | | 'getont', |
| | | 'getcount', |
| | | 'gettree' |
| | | ].forEach(key => { |
| | | al.push(this[key]) |
| | | }); |
| | | return al |
| | | }, (newValue, oldValue) => { |
| | | let needReset = false |
| | | for (let i = 2; i < newValue.length; i++) { |
| | | if (newValue[i] != oldValue[i]) { |
| | | needReset = true |
| | | break |
| | | } |
| | | } |
| | | if (newValue[0] != oldValue[0]) { |
| | | this.page.current = this.pageCurrent |
| | | } |
| | | this.page.size = this.pageSize |
| | | |
| | | this.onPropsChange() |
| | | }) |
| | | this._treeData = [] |
| | | }, |
| | | methods: { |
| | | onPropsChange() { |
| | | this._treeData = [] |
| | | }, |
| | | getCommand(options = {}) { |
| | | /* eslint-disable no-undef */ |
| | | let db = uniCloud.database(this.spaceInfo) |
| | | |
| | | const action = options.action || this.action |
| | | if (action) { |
| | | db = db.action(action) |
| | | } |
| | | |
| | | const collection = options.collection || this.collection |
| | | db = db.collection(collection) |
| | | |
| | | const where = options.where || this.where |
| | | if (!(!where || !Object.keys(where).length)) { |
| | | db = db.where(where) |
| | | } |
| | | |
| | | const field = options.field || this.field |
| | | if (field) { |
| | | db = db.field(field) |
| | | } |
| | | |
| | | const orderby = options.orderby || this.orderby |
| | | if (orderby) { |
| | | db = db.orderBy(orderby) |
| | | } |
| | | |
| | | const current = options.pageCurrent !== undefined ? options.pageCurrent : this.page.current |
| | | const size = options.pageSize !== undefined ? options.pageSize : this.page.size |
| | | const getCount = options.getcount !== undefined ? options.getcount : this.getcount |
| | | const getTree = options.gettree !== undefined ? options.gettree : this.gettree |
| | | |
| | | const getOptions = { |
| | | getCount, |
| | | getTree |
| | | } |
| | | if (options.getTreePath) { |
| | | getOptions.getTreePath = options.getTreePath |
| | | } |
| | | |
| | | db = db.skip(size * (current - 1)).limit(size).get(getOptions) |
| | | |
| | | return db |
| | | }, |
| | | getNodeData(callback) { |
| | | if (this.loading) { |
| | | return |
| | | } |
| | | this.loading = true |
| | | this.getCommand({ |
| | | field: this.postField, |
| | | where: this._pathWhere() |
| | | }).then((res) => { |
| | | this.loading = false |
| | | this.selected = res.result.data |
| | | callback && callback() |
| | | }).catch((err) => { |
| | | this.loading = false |
| | | this.errorMessage = err |
| | | }) |
| | | }, |
| | | getTreePath(callback) { |
| | | if (this.loading) { |
| | | return |
| | | } |
| | | this.loading = true |
| | | |
| | | this.getCommand({ |
| | | field: this.postField, |
| | | getTreePath: { |
| | | startWith: `${this.selfField}=='${this.dataValue}'` |
| | | } |
| | | }).then((res) => { |
| | | this.loading = false |
| | | let treePath = [] |
| | | this._extractTreePath(res.result.data, treePath) |
| | | this.selected = treePath |
| | | callback && callback() |
| | | }).catch((err) => { |
| | | this.loading = false |
| | | this.errorMessage = err |
| | | }) |
| | | }, |
| | | loadData() { |
| | | if (this.isLocaldata) { |
| | | this._processLocalData() |
| | | return |
| | | } |
| | | |
| | | if (this.dataValue != null) { |
| | | this._loadNodeData((data) => { |
| | | this._treeData = data |
| | | this._updateBindData() |
| | | this._updateSelected() |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (this.stepSearh) { |
| | | this._loadNodeData((data) => { |
| | | this._treeData = data |
| | | this._updateBindData() |
| | | }) |
| | | } else { |
| | | this._loadAllData((data) => { |
| | | this._treeData = [] |
| | | this._extractTree(data, this._treeData, null) |
| | | this._updateBindData() |
| | | }) |
| | | } |
| | | }, |
| | | _loadAllData(callback) { |
| | | if (this.loading) { |
| | | return |
| | | } |
| | | this.loading = true |
| | | |
| | | this.getCommand({ |
| | | field: this.postField, |
| | | gettree: true, |
| | | startwith: `${this.selfField}=='${this.dataValue}'` |
| | | }).then((res) => { |
| | | this.loading = false |
| | | callback(res.result.data) |
| | | this.onDataChange() |
| | | }).catch((err) => { |
| | | this.loading = false |
| | | this.errorMessage = err |
| | | }) |
| | | }, |
| | | _loadNodeData(callback, pw) { |
| | | if (this.loading) { |
| | | return |
| | | } |
| | | this.loading = true |
| | | |
| | | this.getCommand({ |
| | | field: this.postField, |
| | | where: pw || this._postWhere(), |
| | | pageSize: 500 |
| | | }).then((res) => { |
| | | this.loading = false |
| | | callback(res.result.data) |
| | | this.onDataChange() |
| | | }).catch((err) => { |
| | | this.loading = false |
| | | this.errorMessage = err |
| | | }) |
| | | }, |
| | | _pathWhere() { |
| | | let result = [] |
| | | let where_field = this._getParentNameByField(); |
| | | if (where_field) { |
| | | result.push(`${where_field} == '${this.dataValue}'`) |
| | | } |
| | | |
| | | if (this.where) { |
| | | return `(${this.where}) && (${result.join(' || ')})` |
| | | } |
| | | |
| | | return result.join(' || ') |
| | | }, |
| | | _postWhere() { |
| | | let result = [] |
| | | let selected = this.selected |
| | | let parentField = this.parentField |
| | | if (parentField) { |
| | | result.push(`${parentField} == null || ${parentField} == ""`) |
| | | } |
| | | if (selected.length) { |
| | | for (var i = 0; i < selected.length - 1; i++) { |
| | | result.push(`${parentField} == '${selected[i].value}'`) |
| | | } |
| | | } |
| | | |
| | | let where = [] |
| | | if (this.where) { |
| | | where.push(`(${this.where})`) |
| | | } |
| | | if (result.length) { |
| | | where.push(`(${result.join(' || ')})`) |
| | | } |
| | | |
| | | return where.join(' && ') |
| | | }, |
| | | _nodeWhere() { |
| | | let result = [] |
| | | let selected = this.selected |
| | | if (selected.length) { |
| | | result.push(`${this.parentField} == '${selected[selected.length - 1].value}'`) |
| | | } |
| | | |
| | | if (this.where) { |
| | | return `(${this.where}) && (${result.join(' || ')})` |
| | | } |
| | | |
| | | return result.join(' || ') |
| | | }, |
| | | _getParentNameByField() { |
| | | const fields = this.field.split(','); |
| | | let where_field = null; |
| | | for (let i = 0; i < fields.length; i++) { |
| | | const items = fields[i].split('as'); |
| | | if (items.length < 2) { |
| | | continue; |
| | | } |
| | | if (items[1].trim() === 'value') { |
| | | where_field = items[0].trim(); |
| | | break; |
| | | } |
| | | } |
| | | return where_field |
| | | }, |
| | | _isTreeView() { |
| | | return (this.parentField && this.selfField) |
| | | }, |
| | | _updateSelected() { |
| | | var dl = this.dataList |
| | | var sl = this.selected |
| | | let textField = this.map.text |
| | | let valueField = this.map.value |
| | | for (var i = 0; i < sl.length; i++) { |
| | | var value = sl[i].value |
| | | var dl2 = dl[i] |
| | | for (var j = 0; j < dl2.length; j++) { |
| | | var item2 = dl2[j] |
| | | if (item2[valueField] === value) { |
| | | sl[i].text = item2[textField] |
| | | break |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | _updateBindData(node) { |
| | | const { |
| | | dataList, |
| | | hasNodes |
| | | } = this._filterData(this._treeData, this.selected) |
| | | |
| | | let isleaf = this._stepSearh === false && !hasNodes |
| | | |
| | | if (node) { |
| | | node.isleaf = isleaf |
| | | } |
| | | |
| | | this.dataList = dataList |
| | | this.selectedIndex = dataList.length - 1 |
| | | |
| | | if (!isleaf && this.selected.length < dataList.length) { |
| | | this.selected.push({ |
| | | value: null, |
| | | text: "è¯·éæ©" |
| | | }) |
| | | } |
| | | |
| | | return { |
| | | isleaf, |
| | | hasNodes |
| | | } |
| | | }, |
| | | _filterData(data, paths) { |
| | | let dataList = [] |
| | | let hasNodes = true |
| | | |
| | | dataList.push(data.filter((item) => { |
| | | return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '') |
| | | })) |
| | | for (let i = 0; i < paths.length; i++) { |
| | | var value = paths[i].value |
| | | var nodes = data.filter((item) => { |
| | | return item.parent_value === value |
| | | }) |
| | | |
| | | if (nodes.length) { |
| | | dataList.push(nodes) |
| | | } else { |
| | | hasNodes = false |
| | | } |
| | | } |
| | | |
| | | return { |
| | | dataList, |
| | | hasNodes |
| | | } |
| | | }, |
| | | _extractTree(nodes, result, parent_value) { |
| | | let list = result || [] |
| | | let valueField = this.map.value |
| | | for (let i = 0; i < nodes.length; i++) { |
| | | let node = nodes[i] |
| | | |
| | | let child = {} |
| | | for (let key in node) { |
| | | if (key !== 'children') { |
| | | child[key] = node[key] |
| | | } |
| | | } |
| | | if (parent_value !== null && parent_value !== undefined && parent_value !== '') { |
| | | child.parent_value = parent_value |
| | | } |
| | | result.push(child) |
| | | |
| | | let children = node.children |
| | | if (children) { |
| | | this._extractTree(children, result, node[valueField]) |
| | | } |
| | | } |
| | | }, |
| | | _extractTreePath(nodes, result) { |
| | | let list = result || [] |
| | | for (let i = 0; i < nodes.length; i++) { |
| | | let node = nodes[i] |
| | | |
| | | let child = {} |
| | | for (let key in node) { |
| | | if (key !== 'children') { |
| | | child[key] = node[key] |
| | | } |
| | | } |
| | | result.push(child) |
| | | |
| | | let children = node.children |
| | | if (children) { |
| | | this._extractTreePath(children, result) |
| | | } |
| | | } |
| | | }, |
| | | _findNodePath(key, nodes, path = []) { |
| | | let textField = this.map.text |
| | | let valueField = this.map.value |
| | | for (let i = 0; i < nodes.length; i++) { |
| | | let node = nodes[i] |
| | | let children = node.children |
| | | let text = node[textField] |
| | | let value = node[valueField] |
| | | |
| | | path.push({ |
| | | value, |
| | | text |
| | | }) |
| | | |
| | | if (value === key) { |
| | | return path |
| | | } |
| | | |
| | | if (children) { |
| | | const p = this._findNodePath(key, children, path) |
| | | if (p.length) { |
| | | return p |
| | | } |
| | | } |
| | | |
| | | path.pop() |
| | | } |
| | | return [] |
| | | }, |
| | | _processLocalData() { |
| | | this._treeData = [] |
| | | this._extractTree(this.localdata, this._treeData) |
| | | |
| | | var inputValue = this.dataValue |
| | | if (inputValue === undefined) { |
| | | return |
| | | } |
| | | |
| | | if (Array.isArray(inputValue)) { |
| | | inputValue = inputValue[inputValue.length - 1] |
| | | if (typeof inputValue === 'object' && inputValue[this.map.value]) { |
| | | inputValue = inputValue[this.map.value] |
| | | } |
| | | } |
| | | |
| | | this.selected = this._findNodePath(inputValue, this.localdata) |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | <template> |
| | | <view class="uni-data-pickerview"> |
| | | <scroll-view class="selected-area" scroll-x="true" scroll-y="false" :show-scrollbar="false"> |
| | | <view class="selected-list"> |
| | | <template v-for="(item,index) in selected"> |
| | | <view class="selected-item" |
| | | :class="{'selected-item-active':index==selectedIndex, 'selected-item-text-overflow': ellipsis}" |
| | | :key="index" v-if="item.text" @click="handleSelect(index)"> |
| | | <text class="">{{item.text}}</text> |
| | | </view> |
| | | </template> |
| | | </view> |
| | | </scroll-view> |
| | | <view class="tab-c"> |
| | | <template v-for="(child, i) in dataList"> |
| | | <scroll-view class="list" :key="i" v-if="i==selectedIndex" :scroll-y="true"> |
| | | <view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in child" :key="j" |
| | | @click="handleNodeClick(item, i, j)"> |
| | | <text class="item-text item-text-overflow">{{item[map.text]}}</text> |
| | | <view class="check" v-if="selected.length > i && item[map.value] == selected[i].value"></view> |
| | | </view> |
| | | </scroll-view> |
| | | </template> |
| | | |
| | | <view class="loading-cover" v-if="loading"> |
| | | <uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more> |
| | | </view> |
| | | <view class="error-message" v-if="errorMessage"> |
| | | <text class="error-text">{{errorMessage}}</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import dataPicker from "./uni-data-picker.js" |
| | | |
| | | /** |
| | | * DataPickerview |
| | | * @description uni-data-pickerview |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=3796 |
| | | * @property {Array} localdata æ¬å°æ°æ®ï¼åè |
| | | * @property {Boolean} step-searh = [true|false] æ¯å¦å叿¥è¯¢ |
| | | * @value true å¯ç¨å叿¥è¯¢ï¼ä»
æ¥è¯¢å½åéä¸èç¹ |
| | | * @value false å
³éå叿¥è¯¢ï¼ä¸æ¬¡æ¥è¯¢åºæææ°æ® |
| | | * @property {String|DBFieldString} self-field å叿¥è¯¢å½ååæ®µåç§° |
| | | * @property {String|DBFieldString} parent-field å叿¥è¯¢ç¶å段åç§° |
| | | * @property {String|DBCollectionString} collection 表å |
| | | * @property {String|DBFieldString} field æ¥è¯¢å段ï¼å¤ä¸ªåæ®µç¨ `,` åå² |
| | | * @property {String} orderby æåºåæ®µåæ£åºåå设置 |
| | | * @property {String|JQLString} where æ¥è¯¢æ¡ä»¶ |
| | | */ |
| | | export default { |
| | | name: 'UniDataPickerView', |
| | | emits: ['nodeclick', 'change', 'datachange', 'update:modelValue'], |
| | | mixins: [dataPicker], |
| | | props: { |
| | | managedMode: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | ellipsis: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | data() { |
| | | return {} |
| | | }, |
| | | created() { |
| | | if (this.managedMode) { |
| | | return |
| | | } |
| | | |
| | | this.$nextTick(() => { |
| | | this.load() |
| | | }) |
| | | }, |
| | | methods: { |
| | | onPropsChange() { |
| | | this._treeData = [] |
| | | this.selectedIndex = 0 |
| | | this.load() |
| | | }, |
| | | load() { |
| | | if (this.isLocaldata) { |
| | | this.loadData() |
| | | } else if (this.dataValue.length) { |
| | | this.getTreePath((res) => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | }, |
| | | handleSelect(index) { |
| | | this.selectedIndex = index |
| | | }, |
| | | handleNodeClick(item, i, j) { |
| | | if (item.disable) { |
| | | return |
| | | } |
| | | const node = this.dataList[i][j] |
| | | const text = node[this.map.text] |
| | | const value = node[this.map.value] |
| | | if (i < this.selected.length - 1) { |
| | | this.selected.splice(i, this.selected.length - i) |
| | | this.selected.push({ |
| | | text, |
| | | value |
| | | }) |
| | | } else if (i === this.selected.length - 1) { |
| | | this.selected.splice(i, 1, { |
| | | text, |
| | | value |
| | | }) |
| | | } |
| | | |
| | | if (node.isleaf) { |
| | | this.onSelectedChange(node, node.isleaf) |
| | | return |
| | | } |
| | | |
| | | const { |
| | | isleaf, |
| | | hasNodes |
| | | } = this._updateBindData() |
| | | |
| | | if (!this._isTreeView() && !hasNodes) { |
| | | this.onSelectedChange(node, true) |
| | | return |
| | | } |
| | | |
| | | if (this.isLocaldata && (!hasNodes || isleaf)) { |
| | | this.onSelectedChange(node, true) |
| | | return |
| | | } |
| | | |
| | | if (!isleaf && !hasNodes) { |
| | | this._loadNodeData((data) => { |
| | | if (!data.length) { |
| | | node.isleaf = true |
| | | } else { |
| | | this._treeData.push(...data) |
| | | this._updateBindData(node) |
| | | } |
| | | this.onSelectedChange(node, node.isleaf) |
| | | }, this._nodeWhere()) |
| | | return |
| | | } |
| | | |
| | | this.onSelectedChange(node, false) |
| | | }, |
| | | updateData(data) { |
| | | this._treeData = data.treeData |
| | | this.selected = data.selected |
| | | if (!this._treeData.length) { |
| | | this.loadData() |
| | | } else { |
| | | //this.selected = data.selected |
| | | this._updateBindData() |
| | | } |
| | | }, |
| | | onDataChange() { |
| | | this.$emit('datachange') |
| | | }, |
| | | onSelectedChange(node, isleaf) { |
| | | if (isleaf) { |
| | | this._dispatchEvent() |
| | | } |
| | | |
| | | if (node) { |
| | | this.$emit('nodeclick', node) |
| | | } |
| | | }, |
| | | _dispatchEvent() { |
| | | this.$emit('change', this.selected.slice(0)) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style > |
| | | .uni-data-pickerview { |
| | | flex: 1; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | overflow: hidden; |
| | | height: 100%; |
| | | } |
| | | |
| | | .error-text { |
| | | color: #DD524D; |
| | | } |
| | | |
| | | .loading-cover { |
| | | position: absolute; |
| | | left: 0; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | background-color: rgba(255, 255, 255, .5); |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | align-items: center; |
| | | z-index: 1001; |
| | | } |
| | | |
| | | .load-more { |
| | | /* #ifndef APP-NVUE */ |
| | | margin: auto; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .error-message { |
| | | background-color: #fff; |
| | | position: absolute; |
| | | left: 0; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | padding: 15px; |
| | | opacity: .9; |
| | | z-index: 102; |
| | | } |
| | | |
| | | /* #ifdef APP-NVUE */ |
| | | .selected-area { |
| | | width: 750rpx; |
| | | } |
| | | |
| | | /* #endif */ |
| | | |
| | | .selected-list { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | flex-wrap: nowrap; |
| | | padding: 0 5px; |
| | | border-bottom: 1px solid #f8f8f8; |
| | | } |
| | | |
| | | .selected-item { |
| | | margin-left: 10px; |
| | | margin-right: 10px; |
| | | padding: 12px 0; |
| | | text-align: center; |
| | | /* #ifndef APP-NVUE */ |
| | | white-space: nowrap; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .selected-item-text-overflow { |
| | | width: 168px; |
| | | /* fix nvue */ |
| | | overflow: hidden; |
| | | /* #ifndef APP-NVUE */ |
| | | width: 6em; |
| | | white-space: nowrap; |
| | | text-overflow: ellipsis; |
| | | -o-text-overflow: ellipsis; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .selected-item-active { |
| | | border-bottom: 2px solid #007aff; |
| | | } |
| | | |
| | | .selected-item-text { |
| | | color: #007aff; |
| | | } |
| | | |
| | | .tab-c { |
| | | position: relative; |
| | | flex: 1; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .list { |
| | | flex: 1; |
| | | } |
| | | |
| | | .item { |
| | | padding: 12px 15px; |
| | | /* border-bottom: 1px solid #f0f0f0; */ |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | .is-disabled { |
| | | opacity: .5; |
| | | } |
| | | |
| | | .item-text { |
| | | /* flex: 1; */ |
| | | color: #333333; |
| | | } |
| | | |
| | | .item-text-overflow { |
| | | width: 280px; |
| | | /* fix nvue */ |
| | | overflow: hidden; |
| | | /* #ifndef APP-NVUE */ |
| | | width: 20em; |
| | | white-space: nowrap; |
| | | text-overflow: ellipsis; |
| | | -o-text-overflow: ellipsis; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .check { |
| | | margin-right: 5px; |
| | | border: 2px solid #007aff; |
| | | border-left: 0; |
| | | border-top: 0; |
| | | height: 12px; |
| | | width: 6px; |
| | | transform-origin: center; |
| | | /* #ifndef APP-NVUE */ |
| | | transition: all 0.3s; |
| | | /* #endif */ |
| | | transform: rotate(45deg); |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-data-picker", |
| | | "displayName": "uni-data-picker æ°æ®é©±å¨çpickeréæ©å¨", |
| | | "version": "1.0.3", |
| | | "description": "ååãå¤å级èéæ©å¨ï¼å¸¸ç¨äºçå¸åºåå¸éæ©ãå
¬å¸é¨é¨éæ©ãå¤çº§åç±»çåºæ¯", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "picker", |
| | | "级è", |
| | | "çå¸åº", |
| | | "" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-load-more", |
| | | "uni-icons", |
| | | "uni-scss" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | ## DataPicker 级èéæ© |
| | | > **ç»ä»¶åï¼uni-data-picker** |
| | | > 代ç åï¼ `uDataPicker` |
| | | > å
³èç»ä»¶ï¼`uni-data-pickerview`ã`uni-load-more`ã |
| | | |
| | | |
| | | `<uni-data-picker>` æ¯ä¸ä¸ªéæ©ç±»[datacomç»ä»¶](https://uniapp.dcloud.net.cn/component/datacom)ã |
| | | |
| | | æ¯æååãåå¤å级èéæ©ãåæ°æ²¡æéå¶ï¼å¦æå±å¹æ¾ç¤ºä¸å
¨ï¼é¡¶é¨tabåºåä¼å·¦å³æ»å¨ã |
| | | |
| | | åéæ°æ®æ¯æä¸æ¬¡æ§å è½½å®æ¯ï¼ä¹æ¯ææå è½½ï¼æ¯å¦ç¤ºä¾å¾ä¸ï¼éæ©äºâå京âåï¼å¨æå è½½å京çåºå¿æ°æ®ã |
| | | |
| | | `<uni-data-picker>` ç»ä»¶å°¤å
¶éç¨äºå°åéæ©ãåç±»éæ©çéæ©ç±»ã |
| | | |
| | | `<uni-data-picker>` æ¯ææ¬å°æ°æ®ãäºç«¯éææ°æ®(json)ï¼uniCloudäºæ°æ®åºæ°æ®ã |
| | | |
| | | `<uni-data-picker>` å¯ä»¥éè¿JQLç´è¿uniCloudäºæ°æ®åºï¼é
å¥[DB Schema](https://uniapp.dcloud.net.cn/uniCloud/schema)ï¼å¯å¨schema2codeä¸èªå¨çæå端页é¢ï¼è¿æ¯ææå¡å¨ç«¯æ ¡éªã |
| | | |
| | | å¨uniCloudæ°æ®è¡¨ä¸æ°å»ºè¡¨âuni-id-addressâåâopendb-city-chinaâï¼è¿2个表çschemaèªå¸¦foreignKeyå
³èãå¨âuni-id-addressâ表çè¡¨ç»æé¡µé¢ä½¿ç¨schema2codeçæå端页é¢ï¼ä¼èªå¨çæå°å管ççç»´æ¤é¡µé¢ï¼èªå¨ä»âopendb-city-chinaâ表å
å«çä¸å½ææçå¸åºä¿¡æ¯ééæ©å°åã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-data-picker) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.0.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-dateformat](https://uniapp.dcloud.io/component/uniui/uni-dateformat) |
| | | ## 0.0.5ï¼2021-07-08ï¼ |
| | | - è°æ´ é»è®¤æ¶é´ä¸åæ¯å½åæ¶é´ï¼èæ¯æ¾ç¤º'-'å符 |
| | | ## 0.0.4ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 0.0.3ï¼2021-02-04ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| | | - ä¿®å¤ iOS 平尿¥ææ ¼å¼ååºéçé®é¢ |
| New file |
| | |
| | | // yyyy-MM-dd hh:mm:ss.SSS æææ¯æçç±»å |
| | | function pad(str, length = 2) { |
| | | str += '' |
| | | while (str.length < length) { |
| | | str = '0' + str |
| | | } |
| | | return str.slice(-length) |
| | | } |
| | | |
| | | const parser = { |
| | | yyyy: (dateObj) => { |
| | | return pad(dateObj.year, 4) |
| | | }, |
| | | yy: (dateObj) => { |
| | | return pad(dateObj.year) |
| | | }, |
| | | MM: (dateObj) => { |
| | | return pad(dateObj.month) |
| | | }, |
| | | M: (dateObj) => { |
| | | return dateObj.month |
| | | }, |
| | | dd: (dateObj) => { |
| | | return pad(dateObj.day) |
| | | }, |
| | | d: (dateObj) => { |
| | | return dateObj.day |
| | | }, |
| | | hh: (dateObj) => { |
| | | return pad(dateObj.hour) |
| | | }, |
| | | h: (dateObj) => { |
| | | return dateObj.hour |
| | | }, |
| | | mm: (dateObj) => { |
| | | return pad(dateObj.minute) |
| | | }, |
| | | m: (dateObj) => { |
| | | return dateObj.minute |
| | | }, |
| | | ss: (dateObj) => { |
| | | return pad(dateObj.second) |
| | | }, |
| | | s: (dateObj) => { |
| | | return dateObj.second |
| | | }, |
| | | SSS: (dateObj) => { |
| | | return pad(dateObj.millisecond, 3) |
| | | }, |
| | | S: (dateObj) => { |
| | | return dateObj.millisecond |
| | | }, |
| | | } |
| | | |
| | | // è¿é½nå¹´äºiOSä¾ç¶ä¸è®¤è¯2020-12-12ï¼éè¦è½¬æ¢ä¸º2020/12/12 |
| | | function getDate(time) { |
| | | if (time instanceof Date) { |
| | | return time |
| | | } |
| | | switch (typeof time) { |
| | | case 'string': |
| | | { |
| | | // 2020-12-12T12:12:12.000Zã2020-12-12T12:12:12.000 |
| | | if (time.indexOf('T') > -1) { |
| | | return new Date(time) |
| | | } |
| | | return new Date(time.replace(/-/g, '/')) |
| | | } |
| | | default: |
| | | return new Date(time) |
| | | } |
| | | } |
| | | |
| | | export function formatDate(date, format = 'yyyy/MM/dd hh:mm:ss') { |
| | | if (!date && date !== 0) { |
| | | return '' |
| | | } |
| | | date = getDate(date) |
| | | const dateObj = { |
| | | year: date.getFullYear(), |
| | | month: date.getMonth() + 1, |
| | | day: date.getDate(), |
| | | hour: date.getHours(), |
| | | minute: date.getMinutes(), |
| | | second: date.getSeconds(), |
| | | millisecond: date.getMilliseconds() |
| | | } |
| | | const tokenRegExp = /yyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S/ |
| | | let flag = true |
| | | let result = format |
| | | while (flag) { |
| | | flag = false |
| | | result = result.replace(tokenRegExp, function(matched) { |
| | | flag = true |
| | | return parser[matched](dateObj) |
| | | }) |
| | | } |
| | | return result |
| | | } |
| | | |
| | | export function friendlyDate(time, { |
| | | locale = 'zh', |
| | | threshold = [60000, 3600000], |
| | | format = 'yyyy/MM/dd hh:mm:ss' |
| | | }) { |
| | | if (time === '-') { |
| | | return time |
| | | } |
| | | if (!time && time !== 0) { |
| | | return '' |
| | | } |
| | | const localeText = { |
| | | zh: { |
| | | year: 'å¹´', |
| | | month: 'æ', |
| | | day: '天', |
| | | hour: 'å°æ¶', |
| | | minute: 'åé', |
| | | second: 'ç§', |
| | | ago: 'å', |
| | | later: 'å', |
| | | justNow: 'åå', |
| | | soon: '马ä¸', |
| | | template: '{num}{unit}{suffix}' |
| | | }, |
| | | en: { |
| | | year: 'year', |
| | | month: 'month', |
| | | day: 'day', |
| | | hour: 'hour', |
| | | minute: 'minute', |
| | | second: 'second', |
| | | ago: 'ago', |
| | | later: 'later', |
| | | justNow: 'just now', |
| | | soon: 'soon', |
| | | template: '{num} {unit} {suffix}' |
| | | } |
| | | } |
| | | const text = localeText[locale] || localeText.zh |
| | | let date = getDate(time) |
| | | let ms = date.getTime() - Date.now() |
| | | let absMs = Math.abs(ms) |
| | | if (absMs < threshold[0]) { |
| | | return ms < 0 ? text.justNow : text.soon |
| | | } |
| | | if (absMs >= threshold[1]) { |
| | | return formatDate(date, format) |
| | | } |
| | | let num |
| | | let unit |
| | | let suffix = text.later |
| | | if (ms < 0) { |
| | | suffix = text.ago |
| | | ms = -ms |
| | | } |
| | | const seconds = Math.floor((ms) / 1000) |
| | | const minutes = Math.floor(seconds / 60) |
| | | const hours = Math.floor(minutes / 60) |
| | | const days = Math.floor(hours / 24) |
| | | const months = Math.floor(days / 30) |
| | | const years = Math.floor(months / 12) |
| | | switch (true) { |
| | | case years > 0: |
| | | num = years |
| | | unit = text.year |
| | | break |
| | | case months > 0: |
| | | num = months |
| | | unit = text.month |
| | | break |
| | | case days > 0: |
| | | num = days |
| | | unit = text.day |
| | | break |
| | | case hours > 0: |
| | | num = hours |
| | | unit = text.hour |
| | | break |
| | | case minutes > 0: |
| | | num = minutes |
| | | unit = text.minute |
| | | break |
| | | default: |
| | | num = seconds |
| | | unit = text.second |
| | | break |
| | | } |
| | | |
| | | if (locale === 'en') { |
| | | if (num === 1) { |
| | | num = 'a' |
| | | } else { |
| | | unit += 's' |
| | | } |
| | | } |
| | | |
| | | return text.template.replace(/{\s*num\s*}/g, num + '').replace(/{\s*unit\s*}/g, unit).replace(/{\s*suffix\s*}/g, |
| | | suffix) |
| | | } |
| New file |
| | |
| | | <template> |
| | | <text>{{dateShow}}</text> |
| | | </template> |
| | | |
| | | <script> |
| | | import {friendlyDate} from './date-format.js' |
| | | /** |
| | | * Dateformat æ¥ææ ¼å¼å |
| | | * @description æ¥ææ ¼å¼åç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=3279 |
| | | * @property {Object|String|Number} date æ¥æå¯¹è±¡/æ¥æå符串/æ¶é´æ³ |
| | | * @property {String} locale æ ¼å¼å使ç¨çè¯è¨ |
| | | * @value zh 䏿 |
| | | * @value en è±æ |
| | | * @property {Array} threshold åºç¨ä¸åç±»åæ ¼å¼åçéå¼ |
| | | * @property {String} format è¾åºæ¥æå符串æ¶çæ ¼å¼ |
| | | */ |
| | | export default { |
| | | name: 'uniDateformat', |
| | | props: { |
| | | date: { |
| | | type: [Object, String, Number], |
| | | default () { |
| | | return '-' |
| | | } |
| | | }, |
| | | locale: { |
| | | type: String, |
| | | default: 'zh', |
| | | }, |
| | | threshold: { |
| | | type: Array, |
| | | default () { |
| | | return [0, 0] |
| | | } |
| | | }, |
| | | format: { |
| | | type: String, |
| | | default: 'yyyy/MM/dd hh:mm:ss' |
| | | }, |
| | | // refreshRate使ç¨ä¸å½å¯è½å¯¼è´æ§è½é®é¢ï¼è°¨æ
ä½¿ç¨ |
| | | refreshRate: { |
| | | type: [Number, String], |
| | | default: 0 |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | refreshMark: 0 |
| | | } |
| | | }, |
| | | computed: { |
| | | dateShow() { |
| | | this.refreshMark |
| | | return friendlyDate(this.date, { |
| | | locale: this.locale, |
| | | threshold: this.threshold, |
| | | format: this.format |
| | | }) |
| | | } |
| | | }, |
| | | watch: { |
| | | refreshRate: { |
| | | handler() { |
| | | this.setAutoRefresh() |
| | | }, |
| | | immediate: true |
| | | } |
| | | }, |
| | | methods: { |
| | | refresh() { |
| | | this.refreshMark++ |
| | | }, |
| | | setAutoRefresh() { |
| | | clearInterval(this.refreshInterval) |
| | | if (this.refreshRate) { |
| | | this.refreshInterval = setInterval(() => { |
| | | this.refresh() |
| | | }, parseInt(this.refreshRate)) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-dateformat", |
| | | "displayName": "uni-dateformat æ¥ææ ¼å¼å", |
| | | "version": "1.0.0", |
| | | "description": "æ¥ææ ¼å¼åç»ä»¶ï¼å¯ä»¥å°æ¥ææ ¼å¼å为1åéåãååçå½¢å¼", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "æ¥ææ ¼å¼å", |
| | | "æ¶é´æ ¼å¼å", |
| | | "æ ¼å¼åæ¶é´", |
| | | "" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-scss"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "y", |
| | | "èç": "y" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ### DateFormat æ¥ææ ¼å¼å |
| | | > **ç»ä»¶åï¼uni-dateformat** |
| | | > 代ç åï¼ `uDateformat` |
| | | |
| | | |
| | | æ¥ææ ¼å¼åç»ä»¶ã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-dateformat) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | /** |
| | | * @1900-2100åºé´å
çå
¬åãååäºè½¬ |
| | | * @charset UTF-8 |
| | | * @github https://github.com/jjonline/calendar.js |
| | | * @Author Jeaæ¨(JJonline@JJonline.Cn) |
| | | * @Time 2014-7-21 |
| | | * @Time 2016-8-13 Fixed 2033hexãAttribution Annals |
| | | * @Time 2016-9-25 Fixed lunar LeapMonth Param Bug |
| | | * @Time 2017-7-24 Fixed use getTerm Func Param Error.use solar year,NOT lunar year |
| | | * @Version 1.0.3 |
| | | * @å
¬å转ååï¼calendar.solar2lunar(1987,11,01); //[you can ignore params of prefix 0] |
| | | * @åå转å
¬åï¼calendar.lunar2solar(1987,09,10); //[you can ignore params of prefix 0] |
| | | */ |
| | | /* eslint-disable */ |
| | | var calendar = { |
| | | |
| | | /** |
| | | * åå1900-2100çæ¶¦å¤§å°ä¿¡æ¯è¡¨ |
| | | * @Array Of Property |
| | | * @return Hex |
| | | */ |
| | | lunarInfo: [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, // 1900-1909 |
| | | 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, // 1910-1919 |
| | | 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, // 1920-1929 |
| | | 0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, // 1930-1939 |
| | | 0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, // 1940-1949 |
| | | 0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0, // 1950-1959 |
| | | 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, // 1960-1969 |
| | | 0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6, // 1970-1979 |
| | | 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, // 1980-1989 |
| | | 0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x05ac0, 0x0ab60, 0x096d5, 0x092e0, // 1990-1999 |
| | | 0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, // 2000-2009 |
| | | 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, // 2010-2019 |
| | | 0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, // 2020-2029 |
| | | 0x05aa0, 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, // 2030-2039 |
| | | 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, // 2040-2049 |
| | | /** Add By JJonline@JJonline.Cn**/ |
| | | 0x14b63, 0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, 0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, // 2050-2059 |
| | | 0x0a2e0, 0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, 0x05d55, 0x056a0, 0x0a6d0, 0x055d4, // 2060-2069 |
| | | 0x052d0, 0x0a9b8, 0x0a950, 0x0b4a0, 0x0b6a6, 0x0ad50, 0x055a0, 0x0aba4, 0x0a5b0, 0x052b0, // 2070-2079 |
| | | 0x0b273, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160, // 2080-2089 |
| | | 0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252, // 2090-2099 |
| | | 0x0d520], // 2100 |
| | | |
| | | /** |
| | | * å
¬åæ¯ä¸ªæä»½çå¤©æ°æ®é表 |
| | | * @Array Of Property |
| | | * @return Number |
| | | */ |
| | | solarMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], |
| | | |
| | | /** |
| | | * 天干尿¯ä¹å¤©å¹²éæ¥è¡¨ |
| | | * @Array Of Property trans["ç²","ä¹","ä¸","ä¸","æ","å·±","åº","è¾","壬","ç¸"] |
| | | * @return Cn string |
| | | */ |
| | | Gan: ['\u7532', '\u4e59', '\u4e19', '\u4e01', '\u620a', '\u5df1', '\u5e9a', '\u8f9b', '\u58ec', '\u7678'], |
| | | |
| | | /** |
| | | * 天干尿¯ä¹å°æ¯éæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans["å","ä¸","å¯
","å¯","è¾°","å·³","å","æª","ç³","é
","æ","亥"] |
| | | * @return Cn string |
| | | */ |
| | | Zhi: ['\u5b50', '\u4e11', '\u5bc5', '\u536f', '\u8fb0', '\u5df3', '\u5348', '\u672a', '\u7533', '\u9149', '\u620c', '\u4ea5'], |
| | | |
| | | /** |
| | | * 天干尿¯ä¹å°æ¯éæ¥è¡¨<=>çè |
| | | * @Array Of Property |
| | | * @trans["é¼ ","ç","è","å
","é¾","è","马","ç¾","ç´","鸡","ç","çª"] |
| | | * @return Cn string |
| | | */ |
| | | Animals: ['\u9f20', '\u725b', '\u864e', '\u5154', '\u9f99', '\u86c7', '\u9a6c', '\u7f8a', '\u7334', '\u9e21', '\u72d7', '\u732a'], |
| | | |
| | | /** |
| | | * 24èæ°éæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans["å°å¯","大å¯","ç«æ¥","鍿°´","æè°","æ¥å","æ¸
æ","è°·é¨","ç«å¤","å°æ»¡","èç§","å¤è³","å°æ","大æ","ç«ç§","夿","ç½é²","ç§å","å¯é²","éé","ç«å¬","å°éª","大éª","å¬è³"] |
| | | * @return Cn string |
| | | */ |
| | | solarTerm: ['\u5c0f\u5bd2', '\u5927\u5bd2', '\u7acb\u6625', '\u96e8\u6c34', '\u60ca\u86f0', '\u6625\u5206', '\u6e05\u660e', '\u8c37\u96e8', '\u7acb\u590f', '\u5c0f\u6ee1', '\u8292\u79cd', '\u590f\u81f3', '\u5c0f\u6691', '\u5927\u6691', '\u7acb\u79cb', '\u5904\u6691', '\u767d\u9732', '\u79cb\u5206', '\u5bd2\u9732', '\u971c\u964d', '\u7acb\u51ac', '\u5c0f\u96ea', '\u5927\u96ea', '\u51ac\u81f3'], |
| | | |
| | | /** |
| | | * 1900-2100åå¹´ç24èæ°æ¥æéæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @return 0x string For splice |
| | | */ |
| | | sTermInfo: ['9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f', |
| | | '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f', |
| | | 'b027097bd097c36b0b6fc9274c91aa', '9778397bd19801ec9210c965cc920e', '97b6b97bd19801ec95f8c965cc920f', |
| | | '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd197c36c9210c9274c91aa', |
| | | '97b6b97bd19801ec95f8c965cc920e', '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2', |
| | | '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec95f8c965cc920e', '97bcf97c3598082c95f8e1cfcc920f', |
| | | '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', |
| | | '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', |
| | | '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf97c359801ec95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd097bd07f595b0b6fc920fb0722', |
| | | '9778397bd097c36b0b6fc9210c8dc2', '9778397bd19801ec9210c9274c920e', '97b6b97bd19801ec95f8c965cc920f', |
| | | '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e', |
| | | '97b6b97bd19801ec95f8c965cc920f', '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', |
| | | '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bd07f1487f595b0b0bc920fb0722', |
| | | '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', |
| | | '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f531b0b0bb0b6fb0722', |
| | | '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', |
| | | '97bcf7f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b97bd19801ec9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', |
| | | '9778397bd097c36b0b6fc9210c91aa', '97b6b97bd197c36c9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722', |
| | | '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e', |
| | | '97b6b7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', |
| | | '9778397bd097c36b0b70c9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722', |
| | | '7f0e397bd097c35b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', |
| | | '7f0e27f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', |
| | | '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', |
| | | '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', |
| | | '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9274c91aa', |
| | | '97b6b7f0e47f531b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', |
| | | '9778397bd097c36b0b6fc9210c91aa', '97b6b7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', |
| | | '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '977837f0e37f149b0723b0787b0721', |
| | | '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c35b0b6fc9210c8dc2', |
| | | '977837f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722', |
| | | '7f0e397bd097c35b0b6fc9210c8dc2', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', |
| | | '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '977837f0e37f14998082b0787b06bd', |
| | | '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', |
| | | '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', |
| | | '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', |
| | | '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd', |
| | | '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', |
| | | '977837f0e37f14998082b0723b06bd', '7f07e7f0e37f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', |
| | | '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b0721', |
| | | '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f595b0b0bb0b6fb0722', '7f0e37f0e37f14898082b0723b02d5', |
| | | '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f531b0b0bb0b6fb0722', |
| | | '7f0e37f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', |
| | | '7f0e37f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd', |
| | | '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35', |
| | | '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', |
| | | '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f149b0723b0787b0721', |
| | | '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0723b06bd', |
| | | '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', '7f0e37f0e366aa89801eb072297c35', |
| | | '7ec967f0e37f14998082b0723b06bd', '7f07e7f0e37f14998083b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', |
| | | '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14898082b0723b02d5', '7f07e7f0e37f14998082b0787b0721', |
| | | '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66aa89801e9808297c35', '665f67f0e37f14898082b0723b02d5', |
| | | '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66a449801e9808297c35', |
| | | '665f67f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', |
| | | '7f0e36665b66a449801e9808297c35', '665f67f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd', |
| | | '7f07e7f0e47f531b0723b0b6fb0721', '7f0e26665b66a449801e9808297c35', '665f67f0e37f1489801eb072297c35', |
| | | '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722'], |
| | | |
| | | /** |
| | | * æ°åè½¬ä¸æéæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans ['æ¥','ä¸','äº','ä¸','å','äº','å
','ä¸','å
«','ä¹','å'] |
| | | * @return Cn string |
| | | */ |
| | | nStr1: ['\u65e5', '\u4e00', '\u4e8c', '\u4e09', '\u56db', '\u4e94', '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341'], |
| | | |
| | | /** |
| | | * æ¥æè½¬ååç§°å¼éæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans ['å','å','廿','å
'] |
| | | * @return Cn string |
| | | */ |
| | | nStr2: ['\u521d', '\u5341', '\u5eff', '\u5345'], |
| | | |
| | | /** |
| | | * æä»½è½¬ååç§°å¼éæ¥è¡¨ |
| | | * @Array Of Property |
| | | * @trans ['æ£','ä¸','äº','ä¸','å','äº','å
','ä¸','å
«','ä¹','å','å¬','è
'] |
| | | * @return Cn string |
| | | */ |
| | | nStr3: ['\u6b63', '\u4e8c', '\u4e09', '\u56db', '\u4e94', '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341', '\u51ac', '\u814a'], |
| | | |
| | | /** |
| | | * è¿åååy年䏿´å¹´çæ»å¤©æ° |
| | | * @param lunar Year |
| | | * @return Number |
| | | * @eg:var count = calendar.lYearDays(1987) ;//count=387 |
| | | */ |
| | | lYearDays: function (y) { |
| | | var i; var sum = 348 |
| | | for (i = 0x8000; i > 0x8; i >>= 1) { sum += (this.lunarInfo[y - 1900] & i) ? 1 : 0 } |
| | | return (sum + this.leapDays(y)) |
| | | }, |
| | | |
| | | /** |
| | | * è¿åååyå¹´é°ææ¯åªä¸ªæï¼è¥y年没æé°æ åè¿å0 |
| | | * @param lunar Year |
| | | * @return Number (0-12) |
| | | * @eg:var leapMonth = calendar.leapMonth(1987) ;//leapMonth=6 |
| | | */ |
| | | leapMonth: function (y) { // é°åç¼ç \u95f0 |
| | | return (this.lunarInfo[y - 1900] & 0xf) |
| | | }, |
| | | |
| | | /** |
| | | * è¿åååyå¹´é°æçå¤©æ° è¥è¯¥å¹´æ²¡æé°æåè¿å0 |
| | | * @param lunar Year |
| | | * @return Number (0ã29ã30) |
| | | * @eg:var leapMonthDay = calendar.leapDays(1987) ;//leapMonthDay=29 |
| | | */ |
| | | leapDays: function (y) { |
| | | if (this.leapMonth(y)) { |
| | | return ((this.lunarInfo[y - 1900] & 0x10000) ? 30 : 29) |
| | | } |
| | | return (0) |
| | | }, |
| | | |
| | | /** |
| | | * è¿åååyå¹´mæï¼éé°æï¼çæ»å¤©æ°ï¼è®¡ç®mä¸ºé°ææ¶ç天æ°è¯·ä½¿ç¨leapDaysæ¹æ³ |
| | | * @param lunar Year |
| | | * @return Number (-1ã29ã30) |
| | | * @eg:var MonthDay = calendar.monthDays(1987,9) ;//MonthDay=29 |
| | | */ |
| | | monthDays: function (y, m) { |
| | | if (m > 12 || m < 1) { return -1 }// æä»½åæ°ä»1è³12ï¼åæ°é误è¿å-1 |
| | | return ((this.lunarInfo[y - 1900] & (0x10000 >> m)) ? 30 : 29) |
| | | }, |
| | | |
| | | /** |
| | | * è¿åå
¬å(!)yå¹´mæçå¤©æ° |
| | | * @param solar Year |
| | | * @return Number (-1ã28ã29ã30ã31) |
| | | * @eg:var solarMonthDay = calendar.leapDays(1987) ;//solarMonthDay=30 |
| | | */ |
| | | solarDays: function (y, m) { |
| | | if (m > 12 || m < 1) { return -1 } // è¥åæ°é误 è¿å-1 |
| | | var ms = m - 1 |
| | | if (ms == 1) { // 2æä»½çé°å¹³è§å¾æµç®å确认è¿å28æ29 |
| | | return (((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) ? 29 : 28) |
| | | } else { |
| | | return (this.solarMonth[ms]) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * åå年份转æ¢ä¸ºå¹²æ¯çºªå¹´ |
| | | * @param lYear ååå¹´çå¹´ä»½æ° |
| | | * @return Cn string |
| | | */ |
| | | toGanZhiYear: function (lYear) { |
| | | var ganKey = (lYear - 3) % 10 |
| | | var zhiKey = (lYear - 3) % 12 |
| | | if (ganKey == 0) ganKey = 10// 妿使°ä¸º0å为æåä¸ä¸ªå¤©å¹² |
| | | if (zhiKey == 0) zhiKey = 12// 妿使°ä¸º0å为æåä¸ä¸ªå°æ¯ |
| | | return this.Gan[ganKey - 1] + this.Zhi[zhiKey - 1] |
| | | }, |
| | | |
| | | /** |
| | | * å
¬åæãæ¥å¤ææå±æåº§ |
| | | * @param cMonth [description] |
| | | * @param cDay [description] |
| | | * @return Cn string |
| | | */ |
| | | toAstro: function (cMonth, cDay) { |
| | | var s = '\u9b54\u7faf\u6c34\u74f6\u53cc\u9c7c\u767d\u7f8a\u91d1\u725b\u53cc\u5b50\u5de8\u87f9\u72ee\u5b50\u5904\u5973\u5929\u79e4\u5929\u874e\u5c04\u624b\u9b54\u7faf' |
| | | var arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22] |
| | | return s.substr(cMonth * 2 - (cDay < arr[cMonth - 1] ? 2 : 0), 2) + '\u5ea7'// 座 |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥offsetåç§»éè¿åå¹²æ¯ |
| | | * @param offset ç¸å¯¹ç²åçåç§»é |
| | | * @return Cn string |
| | | */ |
| | | toGanZhi: function (offset) { |
| | | return this.Gan[offset % 10] + this.Zhi[offset % 12] |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥å
¬å(!)yå¹´è·å¾è¯¥å¹´ç¬¬nä¸ªèæ°çå
¬åæ¥æ |
| | | * @param yå
¬åå¹´(1900-2100)ï¼näºååèæ°ä¸ç第å ä¸ªèæ°(1~24)ï¼ä»n=1(å°å¯)ç®èµ· |
| | | * @return day Number |
| | | * @eg:var _24 = calendar.getTerm(1987,3) ;//_24=4;æå³1987å¹´2æ4æ¥ç«æ¥ |
| | | */ |
| | | getTerm: function (y, n) { |
| | | if (y < 1900 || y > 2100) { return -1 } |
| | | if (n < 1 || n > 24) { return -1 } |
| | | var _table = this.sTermInfo[y - 1900] |
| | | var _info = [ |
| | | parseInt('0x' + _table.substr(0, 5)).toString(), |
| | | parseInt('0x' + _table.substr(5, 5)).toString(), |
| | | parseInt('0x' + _table.substr(10, 5)).toString(), |
| | | parseInt('0x' + _table.substr(15, 5)).toString(), |
| | | parseInt('0x' + _table.substr(20, 5)).toString(), |
| | | parseInt('0x' + _table.substr(25, 5)).toString() |
| | | ] |
| | | var _calday = [ |
| | | _info[0].substr(0, 1), |
| | | _info[0].substr(1, 2), |
| | | _info[0].substr(3, 1), |
| | | _info[0].substr(4, 2), |
| | | |
| | | _info[1].substr(0, 1), |
| | | _info[1].substr(1, 2), |
| | | _info[1].substr(3, 1), |
| | | _info[1].substr(4, 2), |
| | | |
| | | _info[2].substr(0, 1), |
| | | _info[2].substr(1, 2), |
| | | _info[2].substr(3, 1), |
| | | _info[2].substr(4, 2), |
| | | |
| | | _info[3].substr(0, 1), |
| | | _info[3].substr(1, 2), |
| | | _info[3].substr(3, 1), |
| | | _info[3].substr(4, 2), |
| | | |
| | | _info[4].substr(0, 1), |
| | | _info[4].substr(1, 2), |
| | | _info[4].substr(3, 1), |
| | | _info[4].substr(4, 2), |
| | | |
| | | _info[5].substr(0, 1), |
| | | _info[5].substr(1, 2), |
| | | _info[5].substr(3, 1), |
| | | _info[5].substr(4, 2) |
| | | ] |
| | | return parseInt(_calday[n - 1]) |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥ååæ°åæä»½è¿åæ±è¯éä¿è¡¨ç¤ºæ³ |
| | | * @param lunar month |
| | | * @return Cn string |
| | | * @eg:var cnMonth = calendar.toChinaMonth(12) ;//cnMonth='è
æ' |
| | | */ |
| | | toChinaMonth: function (m) { // æ => \u6708 |
| | | if (m > 12 || m < 1) { return -1 } // è¥åæ°é误 è¿å-1 |
| | | var s = this.nStr3[m - 1] |
| | | s += '\u6708'// å 䏿å |
| | | return s |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥ååæ¥ææ°åè¿åæ±åè¡¨ç¤ºæ³ |
| | | * @param lunar day |
| | | * @return Cn string |
| | | * @eg:var cnDay = calendar.toChinaDay(21) ;//cnMonth='廿ä¸' |
| | | */ |
| | | toChinaDay: function (d) { // æ¥ => \u65e5 |
| | | var s |
| | | switch (d) { |
| | | case 10: |
| | | s = '\u521d\u5341'; break |
| | | case 20: |
| | | s = '\u4e8c\u5341'; break |
| | | break |
| | | case 30: |
| | | s = '\u4e09\u5341'; break |
| | | break |
| | | default : |
| | | s = this.nStr2[Math.floor(d / 10)] |
| | | s += this.nStr1[d % 10] |
| | | } |
| | | return (s) |
| | | }, |
| | | |
| | | /** |
| | | * 年份转çè[!ä»
è½å¤§è´è½¬æ¢] => 精确ååçèåç线æ¯âç«æ¥â |
| | | * @param y year |
| | | * @return Cn string |
| | | * @eg:var animal = calendar.getAnimal(1987) ;//animal='å
' |
| | | */ |
| | | getAnimal: function (y) { |
| | | return this.Animals[(y - 4) % 12] |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥é³åå¹´ææ¥è·å¾è¯¦ç»çå
¬åãååobjectä¿¡æ¯ <=>JSON |
| | | * @param y solar year |
| | | * @param m solar month |
| | | * @param d solar day |
| | | * @return JSON object |
| | | * @eg:console.log(calendar.solar2lunar(1987,11,01)); |
| | | */ |
| | | solar2lunar: function (y, m, d) { // åæ°åºé´1900.1.31~2100.12.31 |
| | | // 年份éå®ãä¸é |
| | | if (y < 1900 || y > 2100) { |
| | | return -1// undefined转æ¢ä¸ºæ°åå为NaN |
| | | } |
| | | // å
¬åä¼ åæä¸é |
| | | if (y == 1900 && m == 1 && d < 31) { |
| | | return -1 |
| | | } |
| | | // æªä¼ å è·å¾å½å¤© |
| | | if (!y) { |
| | | var objDate = new Date() |
| | | } else { |
| | | var objDate = new Date(y, parseInt(m) - 1, d) |
| | | } |
| | | var i; var leap = 0; var temp = 0 |
| | | // ä¿®æ£ymdåæ° |
| | | var y = objDate.getFullYear() |
| | | var m = objDate.getMonth() + 1 |
| | | var d = objDate.getDate() |
| | | var offset = (Date.UTC(objDate.getFullYear(), objDate.getMonth(), objDate.getDate()) - Date.UTC(1900, 0, 31)) / 86400000 |
| | | for (i = 1900; i < 2101 && offset > 0; i++) { |
| | | temp = this.lYearDays(i) |
| | | offset -= temp |
| | | } |
| | | if (offset < 0) { |
| | | offset += temp; i-- |
| | | } |
| | | |
| | | // æ¯å¦ä»å¤© |
| | | var isTodayObj = new Date() |
| | | var isToday = false |
| | | if (isTodayObj.getFullYear() == y && isTodayObj.getMonth() + 1 == m && isTodayObj.getDate() == d) { |
| | | isToday = true |
| | | } |
| | | // ææå |
| | | var nWeek = objDate.getDay() |
| | | var cWeek = this.nStr1[nWeek] |
| | | // æ°å表示å¨å 顺åºå¤©æå¨ä¸å¼å§çæ¯ä¾ |
| | | if (nWeek == 0) { |
| | | nWeek = 7 |
| | | } |
| | | // ååå¹´ |
| | | var year = i |
| | | var leap = this.leapMonth(i) // é°åªä¸ªæ |
| | | var isLeap = false |
| | | |
| | | // æéªé°æ |
| | | for (i = 1; i < 13 && offset > 0; i++) { |
| | | // é°æ |
| | | if (leap > 0 && i == (leap + 1) && isLeap == false) { |
| | | --i |
| | | isLeap = true; temp = this.leapDays(year) // 计ç®ååé°æå¤©æ° |
| | | } else { |
| | | temp = this.monthDays(year, i)// 计ç®ååæ®éæå¤©æ° |
| | | } |
| | | // è§£é¤é°æ |
| | | if (isLeap == true && i == (leap + 1)) { isLeap = false } |
| | | offset -= temp |
| | | } |
| | | // é°æå¯¼è´æ°ç»ä¸æ éå åå |
| | | if (offset == 0 && leap > 0 && i == leap + 1) { |
| | | if (isLeap) { |
| | | isLeap = false |
| | | } else { |
| | | isLeap = true; --i |
| | | } |
| | | } |
| | | if (offset < 0) { |
| | | offset += temp; --i |
| | | } |
| | | // ååæ |
| | | var month = i |
| | | // å忥 |
| | | var day = offset + 1 |
| | | // 天干尿¯å¤ç |
| | | var sm = m - 1 |
| | | var gzY = this.toGanZhiYear(year) |
| | | |
| | | // 彿çä¸¤ä¸ªèæ° |
| | | // bugfix-2017-7-24 11:03:38 use lunar Year Param `y` Not `year` |
| | | var firstNode = this.getTerm(y, (m * 2 - 1))// è¿å彿ãèãä¸ºå æ¥å¼å§ |
| | | var secondNode = this.getTerm(y, (m * 2))// è¿å彿ãèãä¸ºå æ¥å¼å§ |
| | | |
| | | // 便®12èæ°ä¿®æ£å¹²æ¯æ |
| | | var gzM = this.toGanZhi((y - 1900) * 12 + m + 11) |
| | | if (d >= firstNode) { |
| | | gzM = this.toGanZhi((y - 1900) * 12 + m + 12) |
| | | } |
| | | |
| | | // ä¼ å
¥çæ¥æçèæ°ä¸å¦ |
| | | var isTerm = false |
| | | var Term = null |
| | | if (firstNode == d) { |
| | | isTerm = true |
| | | Term = this.solarTerm[m * 2 - 2] |
| | | } |
| | | if (secondNode == d) { |
| | | isTerm = true |
| | | Term = this.solarTerm[m * 2 - 1] |
| | | } |
| | | // æ¥æ± 彿䏿¥ä¸ 1900/1/1 ç¸å·®å¤©æ° |
| | | var dayCyclical = Date.UTC(y, sm, 1, 0, 0, 0, 0) / 86400000 + 25567 + 10 |
| | | var gzD = this.toGanZhi(dayCyclical + d - 1) |
| | | // è¯¥æ¥ææå±çæåº§ |
| | | var astro = this.toAstro(m, d) |
| | | |
| | | return { 'lYear': year, 'lMonth': month, 'lDay': day, 'Animal': this.getAnimal(year), 'IMonthCn': (isLeap ? '\u95f0' : '') + this.toChinaMonth(month), 'IDayCn': this.toChinaDay(day), 'cYear': y, 'cMonth': m, 'cDay': d, 'gzYear': gzY, 'gzMonth': gzM, 'gzDay': gzD, 'isToday': isToday, 'isLeap': isLeap, 'nWeek': nWeek, 'ncWeek': '\u661f\u671f' + cWeek, 'isTerm': isTerm, 'Term': Term, 'astro': astro } |
| | | }, |
| | | |
| | | /** |
| | | * ä¼ å
¥ååå¹´ææ¥ä»¥åä¼ å
¥çæä»½æ¯å¦é°æè·å¾è¯¦ç»çå
¬åãååobjectä¿¡æ¯ <=>JSON |
| | | * @param y lunar year |
| | | * @param m lunar month |
| | | * @param d lunar day |
| | | * @param isLeapMonth lunar month is leap or not.[妿æ¯ååé°æç¬¬åä¸ªåæ°èµå¼trueå³å¯] |
| | | * @return JSON object |
| | | * @eg:console.log(calendar.lunar2solar(1987,9,10)); |
| | | */ |
| | | lunar2solar: function (y, m, d, isLeapMonth) { // åæ°åºé´1900.1.31~2100.12.1 |
| | | var isLeapMonth = !!isLeapMonth |
| | | var leapOffset = 0 |
| | | var leapMonth = this.leapMonth(y) |
| | | var leapDay = this.leapDays(y) |
| | | if (isLeapMonth && (leapMonth != m)) { return -1 }// ä¼ åè¦æ±è®¡ç®è¯¥é°æå
¬å ä½è¯¥å¹´å¾åºçé°æä¸ä¼ åçæä»½å¹¶ä¸å |
| | | if (y == 2100 && m == 12 && d > 1 || y == 1900 && m == 1 && d < 31) { return -1 }// è¶
åºäºæå¤§æéå¼ |
| | | var day = this.monthDays(y, m) |
| | | var _day = day |
| | | // bugFix 2016-9-25 |
| | | // if month is leap, _day use leapDays method |
| | | if (isLeapMonth) { |
| | | _day = this.leapDays(y, m) |
| | | } |
| | | if (y < 1900 || y > 2100 || d > _day) { return -1 }// åæ°åæ³æ§æéª |
| | | |
| | | // 计ç®ååçæ¶é´å·® |
| | | var offset = 0 |
| | | for (var i = 1900; i < y; i++) { |
| | | offset += this.lYearDays(i) |
| | | } |
| | | var leap = 0; var isAdd = false |
| | | for (var i = 1; i < m; i++) { |
| | | leap = this.leapMonth(y) |
| | | if (!isAdd) { // å¤çé°æ |
| | | if (leap <= i && leap > 0) { |
| | | offset += this.leapDays(y); isAdd = true |
| | | } |
| | | } |
| | | offset += this.monthDays(y, i) |
| | | } |
| | | // 转æ¢é°æåå éè¡¥å
è¯¥å¹´é°æçåä¸ä¸ªæçæ¶å·® |
| | | if (isLeapMonth) { offset += day } |
| | | // 1900å¹´å忣æä¸æ¥çå
¬åæ¶é´ä¸º1900å¹´1æ30æ¥0æ¶0å0ç§(该æ¶é´ä¹æ¯æ¬ååçæå¼å§èµ·å§ç¹) |
| | | var stmap = Date.UTC(1900, 1, 30, 0, 0, 0) |
| | | var calObj = new Date((offset + d - 31) * 86400000 + stmap) |
| | | var cY = calObj.getUTCFullYear() |
| | | var cM = calObj.getUTCMonth() + 1 |
| | | var cD = calObj.getUTCDate() |
| | | |
| | | return this.solar2lunar(cY, cM, cD) |
| | | } |
| | | } |
| | | |
| | | export default calendar |
| New file |
| | |
| | | ## 1.2.2ï¼2021-12-29ï¼ |
| | | - æ´æ° ç»ä»¶ä¾èµ |
| | | ## 1.2.1ï¼2021-11-19ï¼ |
| | | - ä¿®å¤ é´å½±é¢è²ä¸æ£ç¡®çbug |
| | | ## 1.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-fab](https://uniapp.dcloud.io/component/uniui/uni-fab) |
| | | ## 1.1.1ï¼2021-11-09ï¼ |
| | | - æ°å¢ æä¾ç»ä»¶è®¾è®¡èµæºï¼ç»ä»¶æ ·å¼è°æ´ |
| | | ## 1.1.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.0.7ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.6ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| | | - ä¼å æé®èæ¯è²è°æ´ |
| | | - ä¼å å
¼å®¹pc端 |
| New file |
| | |
| | | <template> |
| | | <view class="uni-cursor-point"> |
| | | <view v-if="popMenu && (leftBottom||rightBottom||leftTop||rightTop) && content.length > 0" :class="{ |
| | | 'uni-fab--leftBottom': leftBottom, |
| | | 'uni-fab--rightBottom': rightBottom, |
| | | 'uni-fab--leftTop': leftTop, |
| | | 'uni-fab--rightTop': rightTop |
| | | }" class="uni-fab"> |
| | | <view :class="{ |
| | | 'uni-fab__content--left': horizontal === 'left', |
| | | 'uni-fab__content--right': horizontal === 'right', |
| | | 'uni-fab__content--flexDirection': direction === 'vertical', |
| | | 'uni-fab__content--flexDirectionStart': flexDirectionStart, |
| | | 'uni-fab__content--flexDirectionEnd': flexDirectionEnd, |
| | | 'uni-fab__content--other-platform': !isAndroidNvue |
| | | }" :style="{ width: boxWidth, height: boxHeight, backgroundColor: styles.backgroundColor }" |
| | | class="uni-fab__content" elevation="5"> |
| | | <view v-if="flexDirectionStart || horizontalLeft" class="uni-fab__item uni-fab__item--first" /> |
| | | <view v-for="(item, index) in content" :key="index" :class="{ 'uni-fab__item--active': isShow }" |
| | | class="uni-fab__item" @click="_onItemClick(index, item)"> |
| | | <image :src="item.active ? item.selectedIconPath : item.iconPath" class="uni-fab__item-image" |
| | | mode="aspectFit" /> |
| | | <text class="uni-fab__item-text" |
| | | :style="{ color: item.active ? styles.selectedColor : styles.color }">{{ item.text }}</text> |
| | | </view> |
| | | <view v-if="flexDirectionEnd || horizontalRight" class="uni-fab__item uni-fab__item--first" /> |
| | | </view> |
| | | </view> |
| | | <view :class="{ |
| | | 'uni-fab__circle--leftBottom': leftBottom, |
| | | 'uni-fab__circle--rightBottom': rightBottom, |
| | | 'uni-fab__circle--leftTop': leftTop, |
| | | 'uni-fab__circle--rightTop': rightTop, |
| | | 'uni-fab__content--other-platform': !isAndroidNvue |
| | | }" class="uni-fab__circle uni-fab__plus" :style="{ 'background-color': styles.buttonColor }" @click="_onClick"> |
| | | <uni-icons class="fab-circle-icon" type="plusempty" :color="styles.iconColor" size="32" |
| | | :class="{'uni-fab__plus--active': isShow && content.length > 0}"></uni-icons> |
| | | <!-- <view class="fab-circle-v" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> |
| | | <view class="fab-circle-h" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> --> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | let platform = 'other' |
| | | // #ifdef APP-NVUE |
| | | platform = uni.getSystemInfoSync().platform |
| | | // #endif |
| | | |
| | | /** |
| | | * Fab æ¬æµ®æé® |
| | | * @description ç¹å»å¯å±å¼ä¸ä¸ªå¾å½¢æé®èå |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=144 |
| | | * @property {Object} pattern å¯éæ ·å¼é
置项 |
| | | * @property {Object} horizontal = [left | right] æ°´å¹³å¯¹é½æ¹å¼ |
| | | * @value left å·¦å¯¹é½ |
| | | * @value right å³å¯¹é½ |
| | | * @property {Object} vertical = [bottom | top] åç´å¯¹é½æ¹å¼ |
| | | * @value bottom ä¸å¯¹é½ |
| | | * @value top ä¸å¯¹é½ |
| | | * @property {Object} direction = [horizontal | vertical] å±å¼èåæ¾ç¤ºæ¹å¼ |
| | | * @value horizontal æ°´å¹³æ¾ç¤º |
| | | * @value vertical åç´æ¾ç¤º |
| | | * @property {Array} content å±å¼èåå
容é
置项 |
| | | * @property {Boolean} popMenu æ¯å¦ä½¿ç¨å¼¹åºèå |
| | | * @event {Function} trigger å±å¼èåç¹å»äºä»¶ï¼è¿åç¹å»ä¿¡æ¯ |
| | | * @event {Function} fabClick æ¬æµ®æé®ç¹å»äºä»¶ |
| | | */ |
| | | export default { |
| | | name: 'UniFab', |
| | | emits: ['fabClick', 'trigger'], |
| | | props: { |
| | | pattern: { |
| | | type: Object, |
| | | default () { |
| | | return {} |
| | | } |
| | | }, |
| | | horizontal: { |
| | | type: String, |
| | | default: 'left' |
| | | }, |
| | | vertical: { |
| | | type: String, |
| | | default: 'bottom' |
| | | }, |
| | | direction: { |
| | | type: String, |
| | | default: 'horizontal' |
| | | }, |
| | | content: { |
| | | type: Array, |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | show: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | popMenu: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | fabShow: false, |
| | | isShow: false, |
| | | isAndroidNvue: platform === 'android', |
| | | styles: { |
| | | color: '#3c3e49', |
| | | selectedColor: '#007AFF', |
| | | backgroundColor: '#fff', |
| | | buttonColor: '#007AFF', |
| | | iconColor: '#fff' |
| | | } |
| | | } |
| | | }, |
| | | computed: { |
| | | contentWidth(e) { |
| | | return (this.content.length + 1) * 55 + 15 + 'px' |
| | | }, |
| | | contentWidthMin() { |
| | | return '55px' |
| | | }, |
| | | // å¨æè®¡ç®å®½åº¦ |
| | | boxWidth() { |
| | | return this.getPosition(3, 'horizontal') |
| | | }, |
| | | // å¨æè®¡ç®é«åº¦ |
| | | boxHeight() { |
| | | return this.getPosition(3, 'vertical') |
| | | }, |
| | | // 计ç®å·¦ä¸ä½ç½® |
| | | leftBottom() { |
| | | return this.getPosition(0, 'left', 'bottom') |
| | | }, |
| | | // 计ç®å³ä¸ä½ç½® |
| | | rightBottom() { |
| | | return this.getPosition(0, 'right', 'bottom') |
| | | }, |
| | | // 计ç®å·¦ä¸ä½ç½® |
| | | leftTop() { |
| | | return this.getPosition(0, 'left', 'top') |
| | | }, |
| | | rightTop() { |
| | | return this.getPosition(0, 'right', 'top') |
| | | }, |
| | | flexDirectionStart() { |
| | | return this.getPosition(1, 'vertical', 'top') |
| | | }, |
| | | flexDirectionEnd() { |
| | | return this.getPosition(1, 'vertical', 'bottom') |
| | | }, |
| | | horizontalLeft() { |
| | | return this.getPosition(2, 'horizontal', 'left') |
| | | }, |
| | | horizontalRight() { |
| | | return this.getPosition(2, 'horizontal', 'right') |
| | | } |
| | | }, |
| | | watch: { |
| | | pattern: { |
| | | handler(val, oldVal) { |
| | | this.styles = Object.assign({}, this.styles, val) |
| | | }, |
| | | deep: true |
| | | } |
| | | }, |
| | | created() { |
| | | this.isShow = this.show |
| | | if (this.top === 0) { |
| | | this.fabShow = true |
| | | } |
| | | // åå§åæ ·å¼ |
| | | this.styles = Object.assign({}, this.styles, this.pattern) |
| | | }, |
| | | methods: { |
| | | _onClick() { |
| | | this.$emit('fabClick') |
| | | if (!this.popMenu) { |
| | | return |
| | | } |
| | | this.isShow = !this.isShow |
| | | }, |
| | | open() { |
| | | this.isShow = true |
| | | }, |
| | | close() { |
| | | this.isShow = false |
| | | }, |
| | | /** |
| | | * æé®ç¹å»äºä»¶ |
| | | */ |
| | | _onItemClick(index, item) { |
| | | this.$emit('trigger', { |
| | | index, |
| | | item |
| | | }) |
| | | }, |
| | | /** |
| | | * è·å ä½ç½®ä¿¡æ¯ |
| | | */ |
| | | getPosition(types, paramA, paramB) { |
| | | if (types === 0) { |
| | | return this.horizontal === paramA && this.vertical === paramB |
| | | } else if (types === 1) { |
| | | return this.direction === paramA && this.vertical === paramB |
| | | } else if (types === 2) { |
| | | return this.direction === paramA && this.horizontal === paramB |
| | | } else { |
| | | return this.isShow && this.direction === paramA ? this.contentWidth : this.contentWidthMin |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" > |
| | | $uni-shadow-base:0 1px 5px 2px rgba($color: #000000, $alpha: 0.3) !default; |
| | | |
| | | .uni-fab { |
| | | position: fixed; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | justify-content: center; |
| | | align-items: center; |
| | | z-index: 10; |
| | | border-radius: 45px; |
| | | box-shadow: $uni-shadow-base; |
| | | } |
| | | |
| | | .uni-cursor-point { |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-fab--active { |
| | | opacity: 1; |
| | | } |
| | | |
| | | .uni-fab--leftBottom { |
| | | left: 15px; |
| | | bottom: 30px; |
| | | /* #ifdef H5 */ |
| | | left: calc(15px + var(--window-left)); |
| | | bottom: calc(30px + var(--window-bottom)); |
| | | /* #endif */ |
| | | // padding: 10px; |
| | | } |
| | | |
| | | .uni-fab--leftTop { |
| | | left: 15px; |
| | | top: 30px; |
| | | /* #ifdef H5 */ |
| | | left: calc(15px + var(--window-left)); |
| | | top: calc(30px + var(--window-top)); |
| | | /* #endif */ |
| | | // padding: 10px; |
| | | } |
| | | |
| | | .uni-fab--rightBottom { |
| | | right: 15px; |
| | | bottom: 30px; |
| | | /* #ifdef H5 */ |
| | | right: calc(15px + var(--window-right)); |
| | | bottom: calc(30px + var(--window-bottom)); |
| | | /* #endif */ |
| | | // padding: 10px; |
| | | } |
| | | |
| | | .uni-fab--rightTop { |
| | | right: 15px; |
| | | top: 30px; |
| | | /* #ifdef H5 */ |
| | | right: calc(15px + var(--window-right)); |
| | | top: calc(30px + var(--window-top)); |
| | | /* #endif */ |
| | | // padding: 10px; |
| | | } |
| | | |
| | | .uni-fab__circle { |
| | | position: fixed; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | justify-content: center; |
| | | align-items: center; |
| | | width: 55px; |
| | | height: 55px; |
| | | background-color: #3c3e49; |
| | | border-radius: 45px; |
| | | z-index: 11; |
| | | // box-shadow: $uni-shadow-base; |
| | | } |
| | | |
| | | .uni-fab__circle--leftBottom { |
| | | left: 15px; |
| | | bottom: 30px; |
| | | /* #ifdef H5 */ |
| | | left: calc(15px + var(--window-left)); |
| | | bottom: calc(30px + var(--window-bottom)); |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-fab__circle--leftTop { |
| | | left: 15px; |
| | | top: 30px; |
| | | /* #ifdef H5 */ |
| | | left: calc(15px + var(--window-left)); |
| | | top: calc(30px + var(--window-top)); |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-fab__circle--rightBottom { |
| | | right: 15px; |
| | | bottom: 30px; |
| | | /* #ifdef H5 */ |
| | | right: calc(15px + var(--window-right)); |
| | | bottom: calc(30px + var(--window-bottom)); |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-fab__circle--rightTop { |
| | | right: 15px; |
| | | top: 30px; |
| | | /* #ifdef H5 */ |
| | | right: calc(15px + var(--window-right)); |
| | | top: calc(30px + var(--window-top)); |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-fab__circle--left { |
| | | left: 0; |
| | | } |
| | | |
| | | .uni-fab__circle--right { |
| | | right: 0; |
| | | } |
| | | |
| | | .uni-fab__circle--top { |
| | | top: 0; |
| | | } |
| | | |
| | | .uni-fab__circle--bottom { |
| | | bottom: 0; |
| | | } |
| | | |
| | | .uni-fab__plus { |
| | | font-weight: bold; |
| | | } |
| | | |
| | | // .fab-circle-v { |
| | | // position: absolute; |
| | | // width: 2px; |
| | | // height: 24px; |
| | | // left: 0; |
| | | // top: 0; |
| | | // right: 0; |
| | | // bottom: 0; |
| | | // /* #ifndef APP-NVUE */ |
| | | // margin: auto; |
| | | // /* #endif */ |
| | | // background-color: white; |
| | | // transform: rotate(0deg); |
| | | // transition: transform 0.3s; |
| | | // } |
| | | |
| | | // .fab-circle-h { |
| | | // position: absolute; |
| | | // width: 24px; |
| | | // height: 2px; |
| | | // left: 0; |
| | | // top: 0; |
| | | // right: 0; |
| | | // bottom: 0; |
| | | // /* #ifndef APP-NVUE */ |
| | | // margin: auto; |
| | | // /* #endif */ |
| | | // background-color: white; |
| | | // transform: rotate(0deg); |
| | | // transition: transform 0.3s; |
| | | // } |
| | | |
| | | .fab-circle-icon { |
| | | transform: rotate(0deg); |
| | | transition: transform 0.3s; |
| | | font-weight: 200; |
| | | } |
| | | |
| | | .uni-fab__plus--active { |
| | | transform: rotate(135deg); |
| | | } |
| | | |
| | | .uni-fab__content { |
| | | /* #ifndef APP-NVUE */ |
| | | box-sizing: border-box; |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | border-radius: 55px; |
| | | overflow: hidden; |
| | | transition-property: width, height; |
| | | transition-duration: 0.2s; |
| | | width: 55px; |
| | | border-color: #DDDDDD; |
| | | border-width: 1rpx; |
| | | border-style: solid; |
| | | } |
| | | |
| | | .uni-fab__content--other-platform { |
| | | border-width: 0px; |
| | | box-shadow: $uni-shadow-base; |
| | | } |
| | | |
| | | .uni-fab__content--left { |
| | | justify-content: flex-start; |
| | | } |
| | | |
| | | .uni-fab__content--right { |
| | | justify-content: flex-end; |
| | | } |
| | | |
| | | .uni-fab__content--flexDirection { |
| | | flex-direction: column; |
| | | justify-content: flex-end; |
| | | } |
| | | |
| | | .uni-fab__content--flexDirectionStart { |
| | | flex-direction: column; |
| | | justify-content: flex-start; |
| | | } |
| | | |
| | | .uni-fab__content--flexDirectionEnd { |
| | | flex-direction: column; |
| | | justify-content: flex-end; |
| | | } |
| | | |
| | | .uni-fab__item { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | align-items: center; |
| | | width: 55px; |
| | | height: 55px; |
| | | opacity: 0; |
| | | transition: opacity 0.2s; |
| | | } |
| | | |
| | | .uni-fab__item--active { |
| | | opacity: 1; |
| | | } |
| | | |
| | | .uni-fab__item-image { |
| | | width: 20px; |
| | | height: 20px; |
| | | margin-bottom: 4px; |
| | | } |
| | | |
| | | .uni-fab__item-text { |
| | | color: #FFFFFF; |
| | | font-size: 12px; |
| | | line-height: 12px; |
| | | margin-top: 2px; |
| | | } |
| | | |
| | | .uni-fab__item--first { |
| | | width: 55px; |
| | | } |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view> |
| | | <view :class="{ |
| | | leftBottom: leftBottom, |
| | | rightBottom: rightBottom, |
| | | leftTop: leftTop, |
| | | rightTop: rightTop |
| | | }" v-if="leftBottom||rightBottom||leftTop||rightTop" class="fab-box fab"> |
| | | <view :class="{ |
| | | left: horizontal === 'left' && direction === 'horizontal', |
| | | top: vertical === 'top' && direction === 'vertical', |
| | | bottom: vertical === 'bottom' && direction === 'vertical', |
| | | right: horizontal === 'right' && direction === 'horizontal' |
| | | }" :style="{ 'background-color': styles.buttonColor }" class="fab-circle" @click="_onClick"> |
| | | <view class="fab-circle-box" :class="{ active: isShow }"> |
| | | <view class="fab-circle-v"></view> |
| | | <view class="fab-circle-h"></view> |
| | | </view> |
| | | </view> |
| | | <view :class="{ |
| | | left: horizontal === 'left', |
| | | right: horizontal === 'right', |
| | | flexDirection: direction === 'vertical', |
| | | flexDirectionStart: flexDirectionStart, |
| | | flexDirectionEnd: flexDirectionEnd |
| | | }" :style="{ width: boxWidth, height: boxHeight, background: styles.backgroundColor }" class="fab-content"> |
| | | <view v-if="flexDirectionStart || horizontalLeft" class="fab-item first" /> |
| | | <view v-for="(item, index) in content" :key="index" :class="{ active: isShow }" :style="{ |
| | | color: item.active ? styles.selectedColor : styles.color |
| | | }" class="fab-item" @click="_onItemClick(index, item)"> |
| | | <image :src="item.active ? item.selectedIconPath : item.iconPath" class="content-image" mode="widthFix" /> |
| | | <text class="text">{{ item.text }}</text> |
| | | </view> |
| | | <view v-if="flexDirectionEnd || horizontalRight" class="fab-item first" /> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: 'UniFab', |
| | | props: { |
| | | pattern: { |
| | | type: Object, |
| | | default () { |
| | | return {} |
| | | } |
| | | }, |
| | | horizontal: { |
| | | type: String, |
| | | default: 'left' |
| | | }, |
| | | vertical: { |
| | | type: String, |
| | | default: 'bottom' |
| | | }, |
| | | direction: { |
| | | type: String, |
| | | default: 'horizontal' |
| | | }, |
| | | content: { |
| | | type: Array, |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | show: { |
| | | type: Boolean, |
| | | default: false |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | fabShow: false, |
| | | flug: true, |
| | | isShow: false, |
| | | styles: { |
| | | color: '#3c3e49', |
| | | selectedColor: '#007AFF', |
| | | backgroundColor: '#fff', |
| | | buttonColor: '#3c3e49' |
| | | } |
| | | } |
| | | }, |
| | | computed: { |
| | | contentWidth(e) { |
| | | return uni.upx2px((this.content.length + 1) * 110 + 20) + 'px' |
| | | }, |
| | | contentWidthMin() { |
| | | return uni.upx2px(110) + 'px' |
| | | }, |
| | | // å¨æè®¡ç®å®½åº¦ |
| | | boxWidth() { |
| | | return this.getPosition(3, 'horizontal') |
| | | }, |
| | | // å¨æè®¡ç®é«åº¦ |
| | | boxHeight() { |
| | | return this.getPosition(3, 'vertical') |
| | | }, |
| | | // 计ç®å·¦ä¸ä½ç½® |
| | | leftBottom() { |
| | | return this.getPosition(0, 'left', 'bottom') |
| | | }, |
| | | // 计ç®å³ä¸ä½ç½® |
| | | rightBottom() { |
| | | return this.getPosition(0, 'right', 'bottom') |
| | | }, |
| | | // 计ç®å·¦ä¸ä½ç½® |
| | | leftTop() { |
| | | return this.getPosition(0, 'left', 'top') |
| | | }, |
| | | rightTop() { |
| | | return this.getPosition(0, 'right', 'top') |
| | | }, |
| | | flexDirectionStart() { |
| | | return this.getPosition(1, 'vertical', 'top') |
| | | }, |
| | | flexDirectionEnd() { |
| | | return this.getPosition(1, 'vertical', 'bottom') |
| | | }, |
| | | horizontalLeft() { |
| | | return this.getPosition(2, 'horizontal', 'left') |
| | | }, |
| | | horizontalRight() { |
| | | return this.getPosition(2, 'horizontal', 'right') |
| | | } |
| | | }, |
| | | watch: { |
| | | pattern(newValue, oldValue) { |
| | | //console.log(JSON.stringify(newValue)) |
| | | this.styles = Object.assign({}, this.styles, newValue) |
| | | } |
| | | }, |
| | | created() { |
| | | this.isShow = this.show |
| | | if (this.top === 0) { |
| | | this.fabShow = true |
| | | } |
| | | // åå§åæ ·å¼ |
| | | this.styles = Object.assign({}, this.styles, this.pattern) |
| | | }, |
| | | methods: { |
| | | _onClick() { |
| | | this.isShow = !this.isShow |
| | | }, |
| | | open() { |
| | | this.isShow = true |
| | | }, |
| | | close() { |
| | | this.isShow = false |
| | | }, |
| | | /** |
| | | * æé®ç¹å»äºä»¶ |
| | | */ |
| | | _onItemClick(index, item) { |
| | | this.$emit('trigger', { |
| | | index, |
| | | item |
| | | }) |
| | | }, |
| | | /** |
| | | * è·å ä½ç½®ä¿¡æ¯ |
| | | */ |
| | | getPosition(types, paramA, paramB) { |
| | | if (types === 0) { |
| | | return this.horizontal === paramA && this.vertical === paramB |
| | | } else if (types === 1) { |
| | | return this.direction === paramA && this.vertical === paramB |
| | | } else if (types === 2) { |
| | | return this.direction === paramA && this.horizontal === paramB |
| | | } else { |
| | | return this.isShow && this.direction === paramA ? this.contentWidth : this.contentWidthMin |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | |
| | | .uni-icon { |
| | | font-family: uniicons; |
| | | font-size: 30px; |
| | | font-weight: normal; |
| | | font-style: normal; |
| | | line-height: 1; |
| | | display: inline-block; |
| | | text-decoration: none; |
| | | -webkit-font-smoothing: antialiased; |
| | | } |
| | | |
| | | .fab-box { |
| | | position: fixed; |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | z-index: 2; |
| | | } |
| | | |
| | | .fab-box.top { |
| | | width: 60rpx; |
| | | height: 60rpx; |
| | | right: 30rpx; |
| | | bottom: 60rpx; |
| | | border: 1px #5989b9 solid; |
| | | background: #6699cc; |
| | | border-radius: 10rpx; |
| | | color: #fff; |
| | | transition: all 0.3; |
| | | opacity: 0; |
| | | } |
| | | |
| | | .fab-box.active { |
| | | opacity: 1; |
| | | } |
| | | |
| | | .fab-box.fab { |
| | | z-index: 10; |
| | | } |
| | | |
| | | .fab-box.fab.leftBottom { |
| | | left: 30rpx; |
| | | bottom: 60rpx; |
| | | } |
| | | |
| | | .fab-box.fab.leftTop { |
| | | left: 30rpx; |
| | | top: 80rpx; |
| | | /* #ifdef H5 */ |
| | | top: calc(80rpx + var(--window-top)); |
| | | /* #endif */ |
| | | } |
| | | |
| | | .fab-box.fab.rightBottom { |
| | | right: 30rpx; |
| | | bottom: 60rpx; |
| | | } |
| | | |
| | | .fab-box.fab.rightTop { |
| | | right: 30rpx; |
| | | top: 80rpx; |
| | | /* #ifdef H5 */ |
| | | top: calc(80rpx + var(--window-top)); |
| | | /* #endif */ |
| | | } |
| | | |
| | | .fab-circle { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | position: absolute; |
| | | width: 110rpx; |
| | | height: 110rpx; |
| | | background: #3c3e49; |
| | | /* background: #5989b9; */ |
| | | border-radius: 50%; |
| | | box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.2); |
| | | z-index: 11; |
| | | } |
| | | |
| | | .fab-circle-box { |
| | | position: absolute; |
| | | left: 0; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | transition: all 0.3s; |
| | | } |
| | | |
| | | .fab-circle-v { |
| | | position: absolute; |
| | | width: 8rpx; |
| | | height: 60rpx; |
| | | left: 50%; |
| | | top: 50%; |
| | | margin: -30rpx 0 0 -4rpx; |
| | | background-color: white; |
| | | } |
| | | |
| | | .fab-circle-h { |
| | | position: absolute; |
| | | width: 60rpx; |
| | | height: 8rpx; |
| | | left: 50%; |
| | | top: 50%; |
| | | margin: -4rpx 0 0 -30rpx; |
| | | background-color: white; |
| | | } |
| | | |
| | | .fab-circle.left { |
| | | left: 0; |
| | | } |
| | | |
| | | .fab-circle.right { |
| | | right: 0; |
| | | } |
| | | |
| | | .fab-circle.top { |
| | | top: 0; |
| | | } |
| | | |
| | | .fab-circle.bottom { |
| | | bottom: 0; |
| | | } |
| | | |
| | | .fab-circle .uni-icon-plusempty { |
| | | color: #ffffff; |
| | | font-size: 80rpx; |
| | | transition: all 0.3s; |
| | | font-weight: bold; |
| | | } |
| | | |
| | | .fab-circle-box.active { |
| | | transform: rotate(135deg); |
| | | font-size: 80rpx; |
| | | } |
| | | |
| | | .fab-content { |
| | | background: #6699cc; |
| | | box-sizing: border-box; |
| | | display: flex; |
| | | border-radius: 100rpx; |
| | | overflow: hidden; |
| | | box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.1); |
| | | transition: all 0.2s; |
| | | width: 110rpx; |
| | | } |
| | | |
| | | .fab-content.left { |
| | | justify-content: flex-start; |
| | | } |
| | | |
| | | .fab-content.right { |
| | | justify-content: flex-end; |
| | | } |
| | | |
| | | .fab-content.flexDirection { |
| | | flex-direction: column; |
| | | justify-content: flex-end; |
| | | } |
| | | |
| | | .fab-content.flexDirectionStart { |
| | | flex-direction: column; |
| | | justify-content: flex-start; |
| | | } |
| | | |
| | | .fab-content.flexDirectionEnd { |
| | | flex-direction: column; |
| | | justify-content: flex-end; |
| | | } |
| | | |
| | | .fab-content .fab-item { |
| | | display: flex; |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | align-items: center; |
| | | width: 110rpx; |
| | | height: 110rpx; |
| | | font-size: 24rpx; |
| | | color: #fff; |
| | | opacity: 0; |
| | | transition: opacity 0.2s; |
| | | } |
| | | |
| | | .fab-content .fab-item.active { |
| | | opacity: 1; |
| | | } |
| | | |
| | | .fab-content .fab-item .content-image { |
| | | width: 50rpx; |
| | | height: 50rpx; |
| | | margin-bottom: 5rpx; |
| | | } |
| | | |
| | | .fab-content .fab-item.first { |
| | | width: 110rpx; |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-fab", |
| | | "displayName": "uni-fab æ¬æµ®æé®", |
| | | "version": "1.2.2", |
| | | "description": "æ¬æµ®æé® fab button ï¼ç¹å»å¯å±å¼ä¸ä¸ªå¾æ æé®èåã", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "æé®", |
| | | "æ¬æµ®æé®", |
| | | "fab" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-scss","uni-icons"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | ## Fab æ¬æµ®æé® |
| | | > **ç»ä»¶åï¼uni-fab** |
| | | > 代ç åï¼ `uFab` |
| | | |
| | | |
| | | ç¹å»å¯å±å¼ä¸ä¸ªå¾å½¢æé®èå |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-fab) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-fav](https://uniapp.dcloud.io/component/uniui/uni-fav) |
| | | ## 1.1.1ï¼2021-08-24ï¼ |
| | | - æ°å¢ æ¯æå½é
å |
| | | ## 1.1.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.0.6ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.5ï¼2021-04-21ï¼ |
| | | - ä¼å æ·»å ä¾èµ uni-icons, 导å
¥åèªå¨ä¸è½½ä¾èµ |
| | | ## 1.0.4ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | ## 1.0.3ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | ## 1.0.2ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | { |
| | | "uni-fav.collect": "collect", |
| | | "uni-fav.collected": "collected" |
| | | } |
| New file |
| | |
| | | import en from './en.json' |
| | | import zhHans from './zh-Hans.json' |
| | | import zhHant from './zh-Hant.json' |
| | | export default { |
| | | en, |
| | | 'zh-Hans': zhHans, |
| | | 'zh-Hant': zhHant |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-fav.collect": "æ¶è", |
| | | "uni-fav.collected": "å·²æ¶è" |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-fav.collect": "æ¶è", |
| | | "uni-fav.collected": "å·²æ¶è" |
| | | } |
| New file |
| | |
| | | <template> |
| | | <view :class="[circle === true || circle === 'true' ? 'uni-fav--circle' : '']" :style="[{ backgroundColor: checked ? bgColorChecked : bgColor }]" |
| | | @click="onClick" class="uni-fav"> |
| | | <!-- #ifdef MP-ALIPAY --> |
| | | <view class="uni-fav-star" v-if="!checked && (star === true || star === 'true')"> |
| | | <uni-icons :color="fgColor" :style="{color: checked ? fgColorChecked : fgColor}" size="14" type="star-filled" /> |
| | | </view> |
| | | <!-- #endif --> |
| | | <!-- #ifndef MP-ALIPAY --> |
| | | <uni-icons :color="fgColor" :style="{color: checked ? fgColorChecked : fgColor}" class="uni-fav-star" size="14" type="star-filled" |
| | | v-if="!checked && (star === true || star === 'true')" /> |
| | | <!-- #endif --> |
| | | <text :style="{color: checked ? fgColorChecked : fgColor}" class="uni-fav-text">{{ checked ? contentFav : contentDefault }}</text> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | /** |
| | | * Fav æ¶èæé® |
| | | * @description ç¨äºæ¶èåè½ï¼å¯ç¹å»åæ¢éä¸ãä¸éä¸çç¶æ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=864 |
| | | * @property {Boolean} star = [true|false] æé®æ¯å¦å¸¦ææ |
| | | * @property {String} bgColor æªæ¶èæ¶çèæ¯è² |
| | | * @property {String} bgColorChecked å·²æ¶èæ¶çèæ¯è² |
| | | * @property {String} fgColor æªæ¶èæ¶çæåé¢è² |
| | | * @property {String} fgColorChecked å·²æ¶èæ¶çæåé¢è² |
| | | * @property {Boolean} circle = [true|false] æ¯å¦ä¸ºåè§ |
| | | * @property {Boolean} checked = [true|false] æ¯å¦ä¸ºå·²æ¶è |
| | | * @property {Object} contentText = [true|false] æ¶èæé®æå |
| | | * @event {Function} click ç¹å» favæé®è§¦åäºä»¶ |
| | | * @example <uni-fav :checked="true"/> |
| | | */ |
| | | |
| | | import { |
| | | initVueI18n |
| | | } from '@dcloudio/uni-i18n' |
| | | import messages from './i18n/index.js' |
| | | const { t } = initVueI18n(messages) |
| | | |
| | | export default { |
| | | name: "UniFav", |
| | | // TODO å
¼å®¹ vue3ï¼éè¦æ³¨åäºä»¶ |
| | | emits: ['click'], |
| | | props: { |
| | | star: { |
| | | type: [Boolean, String], |
| | | default: true |
| | | }, |
| | | bgColor: { |
| | | type: String, |
| | | default: "#eeeeee" |
| | | }, |
| | | fgColor: { |
| | | type: String, |
| | | default: "#666666" |
| | | }, |
| | | bgColorChecked: { |
| | | type: String, |
| | | default: "#007aff" |
| | | }, |
| | | fgColorChecked: { |
| | | type: String, |
| | | default: "#FFFFFF" |
| | | }, |
| | | circle: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | checked: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | contentText: { |
| | | type: Object, |
| | | default () { |
| | | return { |
| | | contentDefault: "", |
| | | contentFav: "" |
| | | }; |
| | | } |
| | | } |
| | | }, |
| | | computed: { |
| | | contentDefault() { |
| | | return this.contentText.contentDefault || t("uni-fav.collect") |
| | | }, |
| | | contentFav() { |
| | | return this.contentText.contentFav || t("uni-fav.collected") |
| | | }, |
| | | }, |
| | | watch: { |
| | | checked() { |
| | | if (uni.report) { |
| | | if (this.checked) { |
| | | uni.report("æ¶è", "æ¶è"); |
| | | } else { |
| | | uni.report("åæ¶æ¶è", "åæ¶æ¶è"); |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | onClick() { |
| | | this.$emit("click"); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | $fav-height: 25px; |
| | | |
| | | .uni-fav { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | align-items: center; |
| | | justify-content: center; |
| | | width: 60px; |
| | | height: $fav-height; |
| | | line-height: $fav-height; |
| | | text-align: center; |
| | | border-radius: 3px; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-fav--circle { |
| | | border-radius: 30px; |
| | | } |
| | | |
| | | .uni-fav-star { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | height: $fav-height; |
| | | line-height: 24px; |
| | | margin-right: 3px; |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .uni-fav-text { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | height: $fav-height; |
| | | line-height: $fav-height; |
| | | align-items: center; |
| | | justify-content: center; |
| | | font-size: 12px; |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-fav", |
| | | "displayName": "uni-fav æ¶èæé®", |
| | | "version": "1.2.0", |
| | | "description": " Fav æ¶èç»ä»¶ï¼å¯èªå®ä¹é¢è²ã大å°ã", |
| | | "keywords": [ |
| | | "fav", |
| | | "uni-ui", |
| | | "uniui", |
| | | "æ¶è" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Fav æ¶èæé® |
| | | > **ç»ä»¶åï¼uni-fav** |
| | | > 代ç åï¼ `uFav` |
| | | |
| | | ç¨äºæ¶èåè½ï¼å¯ç¹å»åæ¢éä¸ãä¸éä¸çç¶æã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-fav) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.0.1ï¼2021-11-23ï¼ |
| | | - ä¿®å¤ åæ°ä¸ºå¯¹è±¡çæ
åµä¸ï¼urlå¨æäºæ
嵿¾ç¤ºé误çbug |
| | | ## 1.0.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-file-picker](https://uniapp.dcloud.io/component/uniui/uni-file-picker) |
| | | ## 0.2.16ï¼2021-11-08ï¼ |
| | | - ä¿®å¤ ä¼ å
¥ç©ºå¯¹è±¡ ï¼æ¾ç¤ºé误çBug |
| | | ## 0.2.15ï¼2021-08-30ï¼ |
| | | - ä¿®å¤ return-type="object" æ¶ä¸åå¨v-modelæ¶ï¼æ æ³å 餿件çBug |
| | | ## 0.2.14ï¼2021-08-23ï¼ |
| | | - æ°å¢ åæ°ä¸è¿å fileID åæ®µ |
| | | ## 0.2.13ï¼2021-08-23ï¼ |
| | | - ä¿®å¤ è
¾è®¯äºä¼ å
¥fileID ä¸è½åæ¾çbug |
| | | - ä¿®å¤ éæ©å¾çåï¼ä¸è½æ¾å¤§çé®é¢ |
| | | ## 0.2.12ï¼2021-08-17ï¼ |
| | | - ä¿®å¤ ç±äº 0.2.11 çæ¬å¼èµ·çä¸è½åæ¾å¾ççBug |
| | | ## 0.2.11ï¼2021-08-16ï¼ |
| | | - æ°å¢ clearFiles(index) æ¹æ³ï¼å¯ä»¥æå¨å 餿宿件 |
| | | - ä¿®å¤ v-model å¼è®¾ä¸º null æ¥éçBug |
| | | ## 0.2.10ï¼2021-08-13ï¼ |
| | | - ä¿®å¤ return-type="object" æ¶ï¼æ æ³å 餿件çBug |
| | | ## 0.2.9ï¼2021-08-03ï¼ |
| | | - ä¿®å¤ auto-upload 屿§å¤±æçBug |
| | | ## 0.2.8ï¼2021-07-31ï¼ |
| | | - ä¿®å¤ fileExtname屿§ä¸æå®å¼æ¥éçBug |
| | | ## 0.2.7ï¼2021-07-31ï¼ |
| | | - ä¿®å¤ å¨æç§åºæ¯ä¸å¾çä¸åæ¾çBug |
| | | ## 0.2.6ï¼2021-07-30ï¼ |
| | | - ä¿®å¤ return-type为objectä¸ï¼è¿åå¼ä¸æ£ç¡®çBug |
| | | ## 0.2.5ï¼2021-07-30ï¼ |
| | | - ä¿®å¤ï¼éè¦ï¼ H5 å¹³å°ä¸å¦æåuni-formsç»ä»¶ä¸å使ç¨å¯¼è´é¡µé¢å¡æ»çé®é¢ |
| | | ## 0.2.3ï¼2021-07-28ï¼ |
| | | - ä¼å è°æ´ç¤ºä¾ä»£ç |
| | | ## 0.2.2ï¼2021-07-27ï¼ |
| | | - ä¿®å¤ vue3 ä¸èµå¼é误çBug |
| | | - ä¼å h5å¹³å°ä¸ä¸ä¼ æä»¶å¯¼è´é¡µé¢å¡æ»çé®é¢ |
| | | ## 0.2.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 0.1.1ï¼2021-07-02ï¼ |
| | | - ä¿®å¤ sourceType 缺å°é»è®¤å¼å¯¼è´ ios æ æ³éæ©æä»¶ |
| | | ## 0.1.0ï¼2021-06-30ï¼ |
| | | - ä¼å è§£è¦ä¸uniCloudç强ç»å®å
³ç³» ï¼å¦ä¸ç»å®æå¡ç©ºé´ï¼é»è®¤autoUpload为falseä¸ä¸å¯æ´æ¹ |
| | | ## 0.0.11ï¼2021-06-30ï¼ |
| | | - ä¿®å¤ ç± 0.0.10 çæ¬å¼åç returnType 屿§å¤±æçé®é¢ |
| | | ## 0.0.10ï¼2021-06-29ï¼ |
| | | - ä¼å æä»¶ä¸ä¼ åè¿åº¦æ¡æ¶å¤±æ¶æº |
| | | ## 0.0.9ï¼2021-06-29ï¼ |
| | | - ä¿®å¤ å¨uni-forms ä¸ï¼å 餿件 ï¼è·åçå¼ä¸å¯¹çBug |
| | | ## 0.0.8ï¼2021-06-15ï¼ |
| | | - ä¿®å¤ å é¤æä»¶æ¶æ æ³è§¦å v-model çBug |
| | | ## 0.0.7ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 0.0.6ï¼2021-04-09ï¼ |
| | | - ä¿®å¤ éæ©çæä»¶é file-extname åæ®µæå®çæ©å±åæ¥éçBug |
| | | ## 0.0.5ï¼2021-04-09ï¼ |
| | | - ä¼å æ´æ°ç»ä»¶ç¤ºä¾ |
| | | ## 0.0.4ï¼2021-04-09ï¼ |
| | | - ä¼å file-extname åæ®µæ¯æåç¬¦ä¸²åæ³ï¼å¤ä¸ªæ©å±åéè¦ç¨éå·åé |
| | | ## 0.0.3ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| | | - ä¿®å¤ å¾®ä¿¡å°ç¨åºä¸æå® fileExtname 屿§éæ©å¤±è´¥çBug |
| New file |
| | |
| | | 'use strict'; |
| | | |
| | | const ERR_MSG_OK = 'chooseAndUploadFile:ok'; |
| | | const ERR_MSG_FAIL = 'chooseAndUploadFile:fail'; |
| | | |
| | | function chooseImage(opts) { |
| | | const { |
| | | count, |
| | | sizeType = ['original', 'compressed'], |
| | | sourceType = ['album', 'camera'], |
| | | extension |
| | | } = opts |
| | | return new Promise((resolve, reject) => { |
| | | uni.chooseImage({ |
| | | count, |
| | | sizeType, |
| | | sourceType, |
| | | extension, |
| | | success(res) { |
| | | resolve(normalizeChooseAndUploadFileRes(res, 'image')); |
| | | }, |
| | | fail(res) { |
| | | reject({ |
| | | errMsg: res.errMsg.replace('chooseImage:fail', ERR_MSG_FAIL), |
| | | }); |
| | | }, |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function chooseVideo(opts) { |
| | | const { |
| | | camera, |
| | | compressed, |
| | | maxDuration, |
| | | sourceType = ['album', 'camera'], |
| | | extension |
| | | } = opts; |
| | | return new Promise((resolve, reject) => { |
| | | uni.chooseVideo({ |
| | | camera, |
| | | compressed, |
| | | maxDuration, |
| | | sourceType, |
| | | extension, |
| | | success(res) { |
| | | const { |
| | | tempFilePath, |
| | | duration, |
| | | size, |
| | | height, |
| | | width |
| | | } = res; |
| | | resolve(normalizeChooseAndUploadFileRes({ |
| | | errMsg: 'chooseVideo:ok', |
| | | tempFilePaths: [tempFilePath], |
| | | tempFiles: [ |
| | | { |
| | | name: (res.tempFile && res.tempFile.name) || '', |
| | | path: tempFilePath, |
| | | size, |
| | | type: (res.tempFile && res.tempFile.type) || '', |
| | | width, |
| | | height, |
| | | duration, |
| | | fileType: 'video', |
| | | cloudPath: '', |
| | | }, ], |
| | | }, 'video')); |
| | | }, |
| | | fail(res) { |
| | | reject({ |
| | | errMsg: res.errMsg.replace('chooseVideo:fail', ERR_MSG_FAIL), |
| | | }); |
| | | }, |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function chooseAll(opts) { |
| | | const { |
| | | count, |
| | | extension |
| | | } = opts; |
| | | return new Promise((resolve, reject) => { |
| | | let chooseFile = uni.chooseFile; |
| | | if (typeof wx !== 'undefined' && |
| | | typeof wx.chooseMessageFile === 'function') { |
| | | chooseFile = wx.chooseMessageFile; |
| | | } |
| | | if (typeof chooseFile !== 'function') { |
| | | return reject({ |
| | | errMsg: ERR_MSG_FAIL + ' 请æå® type ç±»åï¼è¯¥å¹³å°ä»
æ¯æéæ© image æ videoã', |
| | | }); |
| | | } |
| | | chooseFile({ |
| | | type: 'all', |
| | | count, |
| | | extension, |
| | | success(res) { |
| | | resolve(normalizeChooseAndUploadFileRes(res)); |
| | | }, |
| | | fail(res) { |
| | | reject({ |
| | | errMsg: res.errMsg.replace('chooseFile:fail', ERR_MSG_FAIL), |
| | | }); |
| | | }, |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function normalizeChooseAndUploadFileRes(res, fileType) { |
| | | res.tempFiles.forEach((item, index) => { |
| | | if (!item.name) { |
| | | item.name = item.path.substring(item.path.lastIndexOf('/') + 1); |
| | | } |
| | | if (fileType) { |
| | | item.fileType = fileType; |
| | | } |
| | | item.cloudPath = |
| | | Date.now() + '_' + index + item.name.substring(item.name.lastIndexOf('.')); |
| | | }); |
| | | if (!res.tempFilePaths) { |
| | | res.tempFilePaths = res.tempFiles.map((file) => file.path); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | function uploadCloudFiles(files, max = 5, onUploadProgress) { |
| | | files = JSON.parse(JSON.stringify(files)) |
| | | const len = files.length |
| | | let count = 0 |
| | | let self = this |
| | | return new Promise(resolve => { |
| | | while (count < max) { |
| | | next() |
| | | } |
| | | |
| | | function next() { |
| | | let cur = count++ |
| | | if (cur >= len) { |
| | | !files.find(item => !item.url && !item.errMsg) && resolve(files) |
| | | return |
| | | } |
| | | const fileItem = files[cur] |
| | | const index = self.files.findIndex(v => v.uuid === fileItem.uuid) |
| | | fileItem.url = '' |
| | | delete fileItem.errMsg |
| | | |
| | | uniCloud |
| | | .uploadFile({ |
| | | filePath: fileItem.path, |
| | | cloudPath: fileItem.cloudPath, |
| | | fileType: fileItem.fileType, |
| | | onUploadProgress: res => { |
| | | res.index = index |
| | | onUploadProgress && onUploadProgress(res) |
| | | } |
| | | }) |
| | | .then(res => { |
| | | fileItem.url = res.fileID |
| | | fileItem.index = index |
| | | if (cur < len) { |
| | | next() |
| | | } |
| | | }) |
| | | .catch(res => { |
| | | fileItem.errMsg = res.errMsg || res.message |
| | | fileItem.index = index |
| | | if (cur < len) { |
| | | next() |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | function uploadFiles(choosePromise, { |
| | | onChooseFile, |
| | | onUploadProgress |
| | | }) { |
| | | return choosePromise |
| | | .then((res) => { |
| | | if (onChooseFile) { |
| | | const customChooseRes = onChooseFile(res); |
| | | if (typeof customChooseRes !== 'undefined') { |
| | | return Promise.resolve(customChooseRes).then((chooseRes) => typeof chooseRes === 'undefined' ? |
| | | res : chooseRes); |
| | | } |
| | | } |
| | | return res; |
| | | }) |
| | | .then((res) => { |
| | | if (res === false) { |
| | | return { |
| | | errMsg: ERR_MSG_OK, |
| | | tempFilePaths: [], |
| | | tempFiles: [], |
| | | }; |
| | | } |
| | | return res |
| | | }) |
| | | } |
| | | |
| | | function chooseAndUploadFile(opts = { |
| | | type: 'all' |
| | | }) { |
| | | if (opts.type === 'image') { |
| | | return uploadFiles(chooseImage(opts), opts); |
| | | } |
| | | else if (opts.type === 'video') { |
| | | return uploadFiles(chooseVideo(opts), opts); |
| | | } |
| | | return uploadFiles(chooseAll(opts), opts); |
| | | } |
| | | |
| | | export { |
| | | chooseAndUploadFile, |
| | | uploadCloudFiles |
| | | }; |
| New file |
| | |
| | | <template> |
| | | <view class="uni-file-picker"> |
| | | <view v-if="title" class="uni-file-picker__header"> |
| | | <text class="file-title">{{ title }}</text> |
| | | <text class="file-count">{{ filesList.length }}/{{ limitLength }}</text> |
| | | </view> |
| | | <upload-image v-if="fileMediatype === 'image' && showType === 'grid'" :readonly="readonly" |
| | | :image-styles="imageStyles" :files-list="filesList" :limit="limitLength" :disablePreview="disablePreview" |
| | | :delIcon="delIcon" @uploadFiles="uploadFiles" @choose="choose" @delFile="delFile"> |
| | | <slot> |
| | | <view class="is-add"> |
| | | <view class="icon-add"></view> |
| | | <view class="icon-add rotate"></view> |
| | | </view> |
| | | </slot> |
| | | </upload-image> |
| | | <upload-file v-if="fileMediatype !== 'image' || showType !== 'grid'" :readonly="readonly" |
| | | :list-styles="listStyles" :files-list="filesList" :showType="showType" :delIcon="delIcon" |
| | | @uploadFiles="uploadFiles" @choose="choose" @delFile="delFile"> |
| | | <slot><button type="primary" size="mini">éæ©æä»¶</button></slot> |
| | | </upload-file> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | chooseAndUploadFile, |
| | | uploadCloudFiles |
| | | } from './choose-and-upload-file.js' |
| | | import { |
| | | get_file_ext, |
| | | get_extname, |
| | | get_files_and_is_max, |
| | | get_file_info, |
| | | get_file_data |
| | | } from './utils.js' |
| | | import uploadImage from './upload-image.vue' |
| | | import uploadFile from './upload-file.vue' |
| | | let fileInput = null |
| | | /** |
| | | * FilePicker æä»¶éæ©ä¸ä¼ |
| | | * @description æä»¶éæ©ä¸ä¼ ç»ä»¶ï¼å¯ä»¥éæ©å¾çãè§é¢çä»»ææä»¶å¹¶ä¸ä¼ å°å½åç»å®çæå¡ç©ºé´ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=4079 |
| | | * @property {Object|Array} value ç»ä»¶æ°æ®ï¼éå¸¸ç¨æ¥åæ¾ ,ç±»åç±return-type屿§å³å® |
| | | * @property {Boolean} disabled = [true|false] ç»ä»¶ç¦ç¨ |
| | | * @value true ç¦ç¨ |
| | | * @value false åæ¶ç¦ç¨ |
| | | * @property {Boolean} readonly = [true|false] ç»ä»¶åªè¯»ï¼ä¸å¯éæ©ï¼ä¸æ¾ç¤ºè¿åº¦ï¼ä¸æ¾ç¤ºå é¤æé® |
| | | * @value true åªè¯» |
| | | * @value false åæ¶åªè¯» |
| | | * @property {String} return-type = [array|object] éå¶ value æ ¼å¼ï¼å½ä¸º object æ¶ ï¼ç»ä»¶åªè½åéï¼ä¸ä¼è¦ç |
| | | * @value array è§å® value 屿§çç±»å为æ°ç» |
| | | * @value object è§å® value 屿§çç±»å为对象 |
| | | * @property {Boolean} disable-preview = [true|false] ç¦ç¨å¾çé¢è§ï¼ä»
mode:grid æ¶çæ |
| | | * @value true ç¦ç¨å¾çé¢è§ |
| | | * @value false åæ¶ç¦ç¨å¾çé¢è§ |
| | | * @property {Boolean} del-icon = [true|false] æ¯å¦æ¾ç¤ºå é¤æé® |
| | | * @value true æ¾ç¤ºå é¤æé® |
| | | * @value false 䏿¾ç¤ºå é¤æé® |
| | | * @property {Boolean} auto-upload = [true|false] æ¯å¦èªå¨ä¸ä¼ ï¼å¼ä¸ºtrueååªè§¦å@select,å¯èªè¡ä¸ä¼ |
| | | * @value true èªå¨ä¸ä¼ |
| | | * @value false åæ¶èªå¨ä¸ä¼ |
| | | * @property {Number|String} limit æå¤§éæ©ä¸ªæ° ï¼h5 ä¼èªå¨å¿½ç¥å¤éçé¨å |
| | | * @property {String} title ç»ä»¶æ é¢ï¼å³ä¾§æ¾ç¤ºä¸ä¼ è®¡æ° |
| | | * @property {String} mode = [list|grid] éæ©æä»¶åçæä»¶åè¡¨æ ·å¼ |
| | | * @value list å表æ¾ç¤º |
| | | * @value grid å®«æ ¼æ¾ç¤º |
| | | * @property {String} file-mediatype = [image|video|all] éæ©æä»¶ç±»å |
| | | * @value image åªéæ©å¾ç |
| | | * @value video åªéæ©è§é¢ |
| | | * @value all éæ©æææä»¶ |
| | | * @property {Array} file-extname éæ©æä»¶åç¼ï¼æ ¹æ® file-mediatype 屿§èä¸å |
| | | * @property {Object} list-style mode:list æ¶çæ ·å¼ |
| | | * @property {Object} image-styles éæ©æä»¶åç¼ï¼æ ¹æ® file-mediatype 屿§èä¸å |
| | | * @event {Function} select éæ©æä»¶å触å |
| | | * @event {Function} progress æä»¶ä¸ä¼ æ¶è§¦å |
| | | * @event {Function} success ä¸ä¼ æå触å |
| | | * @event {Function} fail ä¸ä¼ 失败触å |
| | | * @event {Function} delete æä»¶ä»åè¡¨ç§»é¤æ¶è§¦å |
| | | */ |
| | | export default { |
| | | name: 'uniFilePicker', |
| | | components: { |
| | | uploadImage, |
| | | uploadFile |
| | | }, |
| | | emits: ['select', 'success', 'fail', 'progress', 'delete', 'update:modelValue', 'input'], |
| | | props: { |
| | | // #ifdef VUE3 |
| | | modelValue: { |
| | | type: [Array, Object], |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | // #endif |
| | | |
| | | // #ifndef VUE3 |
| | | value: { |
| | | type: [Array, Object], |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | // #endif |
| | | |
| | | disabled: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | disablePreview: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | delIcon: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | // èªå¨ä¸ä¼ |
| | | autoUpload: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | // æå¤§éæ©ä¸ªæ° ï¼h5åªè½éå¶åéææ¯å¤é |
| | | limit: { |
| | | type: [Number, String], |
| | | default: 9 |
| | | }, |
| | | // åè¡¨æ ·å¼ grid | list | list-card |
| | | mode: { |
| | | type: String, |
| | | default: 'grid' |
| | | }, |
| | | // éæ©æä»¶ç±»å image/video/all |
| | | fileMediatype: { |
| | | type: String, |
| | | default: 'image' |
| | | }, |
| | | // æä»¶ç±»åçé |
| | | fileExtname: { |
| | | type: [Array, String], |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | title: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | listStyles: { |
| | | type: Object, |
| | | default () { |
| | | return { |
| | | // æ¯å¦æ¾ç¤ºè¾¹æ¡ |
| | | border: true, |
| | | // æ¯å¦æ¾ç¤ºåé线 |
| | | dividline: true, |
| | | // çº¿æ¡æ ·å¼ |
| | | borderStyle: {} |
| | | } |
| | | } |
| | | }, |
| | | imageStyles: { |
| | | type: Object, |
| | | default () { |
| | | return { |
| | | width: 'auto', |
| | | height: 'auto' |
| | | } |
| | | } |
| | | }, |
| | | readonly: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | returnType: { |
| | | type: String, |
| | | default: 'array' |
| | | }, |
| | | sizeType: { |
| | | type: Array, |
| | | default () { |
| | | return ['original', 'compressed'] |
| | | } |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | files: [], |
| | | localValue: [] |
| | | } |
| | | }, |
| | | watch: { |
| | | // #ifndef VUE3 |
| | | value: { |
| | | handler(newVal, oldVal) { |
| | | this.setValue(newVal, oldVal) |
| | | }, |
| | | immediate: true |
| | | }, |
| | | // #endif |
| | | // #ifdef VUE3 |
| | | modelValue: { |
| | | handler(newVal, oldVal) { |
| | | this.setValue(newVal, oldVal) |
| | | }, |
| | | immediate: true |
| | | }, |
| | | // #endif |
| | | }, |
| | | computed: { |
| | | filesList() { |
| | | let files = [] |
| | | this.files.forEach(v => { |
| | | files.push(v) |
| | | }) |
| | | return files |
| | | }, |
| | | showType() { |
| | | if (this.fileMediatype === 'image') { |
| | | return this.mode |
| | | } |
| | | return 'list' |
| | | }, |
| | | limitLength() { |
| | | if (this.returnType === 'object') { |
| | | return 1 |
| | | } |
| | | if (!this.limit) { |
| | | return 1 |
| | | } |
| | | if (this.limit >= 9) { |
| | | return 9 |
| | | } |
| | | return this.limit |
| | | } |
| | | }, |
| | | created() { |
| | | // TODO å
¼å®¹ä¸å¼éæå¡ç©ºé´çæ
åµ |
| | | if (!(uniCloud.config && uniCloud.config.provider)) { |
| | | this.noSpace = true |
| | | uniCloud.chooseAndUploadFile = chooseAndUploadFile |
| | | } |
| | | this.form = this.getForm('uniForms') |
| | | this.formItem = this.getForm('uniFormsItem') |
| | | if (this.form && this.formItem) { |
| | | if (this.formItem.name) { |
| | | this.rename = this.formItem.name |
| | | this.form.inputChildrens.push(this) |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | /** |
| | | * å
¬å¼ç¨æ·ä½¿ç¨ï¼æ¸
空æä»¶ |
| | | * @param {Object} index |
| | | */ |
| | | clearFiles(index) { |
| | | if (index !== 0 && !index) { |
| | | this.files = [] |
| | | this.$nextTick(() => { |
| | | this.setEmit() |
| | | }) |
| | | } else { |
| | | this.files.splice(index, 1) |
| | | } |
| | | this.$nextTick(() => { |
| | | this.setEmit() |
| | | }) |
| | | }, |
| | | /** |
| | | * å
¬å¼ç¨æ·ä½¿ç¨ï¼ç»§ç»ä¸ä¼ |
| | | */ |
| | | upload() { |
| | | let files = [] |
| | | this.files.forEach((v, index) => { |
| | | if (v.status === 'ready' || v.status === 'error') { |
| | | files.push(Object.assign({}, v)) |
| | | } |
| | | }) |
| | | this.uploadFiles(files) |
| | | }, |
| | | async setValue(newVal, oldVal) { |
| | | const newData = async (v) => { |
| | | const reg = /cloud:\/\/([\w.]+\/?)\S*/ |
| | | let url = '' |
| | | if(v.fileID){ |
| | | url = v.fileID |
| | | }else{ |
| | | url = v.url |
| | | } |
| | | if (reg.test(url)) { |
| | | v.fileID = url |
| | | v.url = await this.getTempFileURL(url) |
| | | } |
| | | if(v.url) v.path = v.url |
| | | return v |
| | | } |
| | | if (this.returnType === 'object') { |
| | | if (newVal) { |
| | | await newData(newVal) |
| | | } else { |
| | | newVal = {} |
| | | } |
| | | } else { |
| | | if (!newVal) newVal = [] |
| | | for(let i =0 ;i < newVal.length ;i++){ |
| | | let v = newVal[i] |
| | | await newData(v) |
| | | } |
| | | } |
| | | this.localValue = newVal |
| | | if (this.form && this.formItem &&!this.is_reset) { |
| | | this.is_reset = false |
| | | this.formItem.setValue(this.localValue) |
| | | } |
| | | let filesData = Object.keys(newVal).length > 0 ? newVal : []; |
| | | this.files = [].concat(filesData) |
| | | }, |
| | | |
| | | /** |
| | | * éæ©æä»¶ |
| | | */ |
| | | choose() { |
| | | |
| | | if (this.disabled) return |
| | | if (this.files.length >= Number(this.limitLength) && this.showType !== 'grid' && this.returnType === |
| | | 'array') { |
| | | uni.showToast({ |
| | | title: `æ¨æå¤éæ© ${this.limitLength} 个æä»¶`, |
| | | icon: 'none' |
| | | }) |
| | | return |
| | | } |
| | | this.chooseFiles() |
| | | }, |
| | | |
| | | /** |
| | | * éæ©æä»¶å¹¶ä¸ä¼ |
| | | */ |
| | | chooseFiles() { |
| | | const _extname = get_extname(this.fileExtname) |
| | | // è·ååç¼ |
| | | uniCloud |
| | | .chooseAndUploadFile({ |
| | | type: this.fileMediatype, |
| | | compressed: false, |
| | | sizeType: this.sizeType, |
| | | // TODO å¦æä¸ºç©ºï¼video æé®é¢ |
| | | extension: _extname.length > 0 ? _extname : undefined, |
| | | count: this.limitLength - this.files.length, //é»è®¤9 |
| | | onChooseFile: this.chooseFileCallback, |
| | | onUploadProgress: progressEvent => { |
| | | this.setProgress(progressEvent, progressEvent.index) |
| | | } |
| | | }) |
| | | .then(result => { |
| | | this.setSuccessAndError(result.tempFiles) |
| | | }) |
| | | .catch(err => { |
| | | console.log('éæ©å¤±è´¥', err) |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * éæ©æä»¶åè° |
| | | * @param {Object} res |
| | | */ |
| | | async chooseFileCallback(res) { |
| | | const _extname = get_extname(this.fileExtname) |
| | | const is_one = (Number(this.limitLength) === 1 && |
| | | this.disablePreview && |
| | | !this.disabled) || |
| | | this.returnType === 'object' |
| | | // å¦æè¿æä¸ä¸ªæä»¶ ï¼éè¦æ¸
空æ¬å°ç¼åæ°æ® |
| | | if (is_one) { |
| | | this.files = [] |
| | | } |
| | | |
| | | let { |
| | | filePaths, |
| | | files |
| | | } = get_files_and_is_max(res, _extname) |
| | | if (!(_extname && _extname.length > 0)) { |
| | | filePaths = res.tempFilePaths |
| | | files = res.tempFiles |
| | | } |
| | | |
| | | let currentData = [] |
| | | for (let i = 0; i < files.length; i++) { |
| | | if (this.limitLength - this.files.length <= 0) break |
| | | files[i].uuid = Date.now() |
| | | let filedata = await get_file_data(files[i], this.fileMediatype) |
| | | filedata.progress = 0 |
| | | filedata.status = 'ready' |
| | | this.files.push(filedata) |
| | | currentData.push({ |
| | | ...filedata, |
| | | file: files[i] |
| | | }) |
| | | } |
| | | this.$emit('select', { |
| | | tempFiles: currentData, |
| | | tempFilePaths: filePaths |
| | | }) |
| | | res.tempFiles = files |
| | | // 忢èªå¨ä¸ä¼ |
| | | if (!this.autoUpload || this.noSpace) { |
| | | res.tempFiles = [] |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * æ¹ä¼ |
| | | * @param {Object} e |
| | | */ |
| | | uploadFiles(files) { |
| | | files = [].concat(files) |
| | | uploadCloudFiles.call(this, files, 5, res => { |
| | | this.setProgress(res, res.index, true) |
| | | }) |
| | | .then(result => { |
| | | this.setSuccessAndError(result) |
| | | }) |
| | | .catch(err => { |
| | | console.log(err) |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * æåæå¤±è´¥ |
| | | */ |
| | | async setSuccessAndError(res, fn) { |
| | | let successData = [] |
| | | let errorData = [] |
| | | let tempFilePath = [] |
| | | let errorTempFilePath = [] |
| | | for (let i = 0; i < res.length; i++) { |
| | | const item = res[i] |
| | | const index = item.uuid ? this.files.findIndex(p => p.uuid === item.uuid) : item.index |
| | | |
| | | if (index === -1 || !this.files) break |
| | | if (item.errMsg === 'request:fail') { |
| | | this.files[index].url = item.path |
| | | this.files[index].status = 'error' |
| | | this.files[index].errMsg = item.errMsg |
| | | // this.files[index].progress = -1 |
| | | errorData.push(this.files[index]) |
| | | errorTempFilePath.push(this.files[index].url) |
| | | } else { |
| | | this.files[index].errMsg = '' |
| | | this.files[index].fileID = item.url |
| | | const reg = /cloud:\/\/([\w.]+\/?)\S*/ |
| | | if (reg.test(item.url)) { |
| | | this.files[index].url = await this.getTempFileURL(item.url) |
| | | }else{ |
| | | this.files[index].url = item.url |
| | | } |
| | | |
| | | this.files[index].status = 'success' |
| | | this.files[index].progress += 1 |
| | | successData.push(this.files[index]) |
| | | tempFilePath.push(this.files[index].fileID) |
| | | } |
| | | } |
| | | |
| | | if (successData.length > 0) { |
| | | this.setEmit() |
| | | // ç¶ææ¹åè¿å |
| | | this.$emit('success', { |
| | | tempFiles: this.backObject(successData), |
| | | tempFilePaths: tempFilePath |
| | | }) |
| | | } |
| | | |
| | | if (errorData.length > 0) { |
| | | this.$emit('fail', { |
| | | tempFiles: this.backObject(errorData), |
| | | tempFilePaths: errorTempFilePath |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * è·åè¿åº¦ |
| | | * @param {Object} progressEvent |
| | | * @param {Object} index |
| | | * @param {Object} type |
| | | */ |
| | | setProgress(progressEvent, index, type) { |
| | | const fileLenth = this.files.length |
| | | const percentNum = (index / fileLenth) * 100 |
| | | const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) |
| | | let idx = index |
| | | if (!type) { |
| | | idx = this.files.findIndex(p => p.uuid === progressEvent.tempFile.uuid) |
| | | } |
| | | if (idx === -1 || !this.files[idx]) return |
| | | // fix by mehaotian 100 就伿¶å¤±ï¼-1 æ¯ä¸ºäºè®©è¿åº¦æ¡æ¶å¤± |
| | | this.files[idx].progress = percentCompleted - 1 |
| | | // ä¸ä¼ ä¸ |
| | | this.$emit('progress', { |
| | | index: idx, |
| | | progress: parseInt(percentCompleted), |
| | | tempFile: this.files[idx] |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * å 餿件 |
| | | * @param {Object} index |
| | | */ |
| | | delFile(index) { |
| | | this.$emit('delete', { |
| | | tempFile: this.files[index], |
| | | tempFilePath: this.files[index].url |
| | | }) |
| | | this.files.splice(index, 1) |
| | | this.$nextTick(() => { |
| | | this.setEmit() |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * è·åæä»¶åååç¼ |
| | | * @param {Object} name |
| | | */ |
| | | getFileExt(name) { |
| | | const last_len = name.lastIndexOf('.') |
| | | const len = name.length |
| | | return { |
| | | name: name.substring(0, last_len), |
| | | ext: name.substring(last_len + 1, len) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * å¤çè¿åäºä»¶ |
| | | */ |
| | | setEmit() { |
| | | let data = [] |
| | | if (this.returnType === 'object') { |
| | | data = this.backObject(this.files)[0] |
| | | this.localValue = data?data:null |
| | | } else { |
| | | data = this.backObject(this.files) |
| | | if (!this.localValue) { |
| | | this.localValue = [] |
| | | } |
| | | this.localValue = [...data] |
| | | } |
| | | // #ifdef VUE3 |
| | | this.$emit('update:modelValue', this.localValue) |
| | | // #endif |
| | | // #ifndef VUE3 |
| | | this.$emit('input', this.localValue) |
| | | // #endif |
| | | }, |
| | | |
| | | /** |
| | | * å¤çè¿ååæ° |
| | | * @param {Object} files |
| | | */ |
| | | backObject(files) { |
| | | let newFilesData = [] |
| | | files.forEach(v => { |
| | | newFilesData.push({ |
| | | extname: v.extname, |
| | | fileType: v.fileType, |
| | | image: v.image, |
| | | name: v.name, |
| | | path: v.path, |
| | | size: v.size, |
| | | fileID:v.fileID, |
| | | url: v.url |
| | | }) |
| | | }) |
| | | return newFilesData |
| | | }, |
| | | async getTempFileURL(fileList) { |
| | | fileList = { |
| | | fileList: [].concat(fileList) |
| | | } |
| | | const urls = await uniCloud.getTempFileURL(fileList) |
| | | return urls.fileList[0].tempFileURL || '' |
| | | }, |
| | | /** |
| | | * è·åç¶å
ç´ å®ä¾ |
| | | */ |
| | | getForm(name = 'uniForms') { |
| | | let parent = this.$parent; |
| | | let parentName = parent.$options.name; |
| | | while (parentName !== name) { |
| | | parent = parent.$parent; |
| | | if (!parent) return false; |
| | | parentName = parent.$options.name; |
| | | } |
| | | return parent; |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | .uni-file-picker { |
| | | /* #ifndef APP-NVUE */ |
| | | box-sizing: border-box; |
| | | overflow: hidden; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-file-picker__header { |
| | | padding-top: 5px; |
| | | padding-bottom: 10px; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | .file-title { |
| | | font-size: 14px; |
| | | color: #333; |
| | | } |
| | | |
| | | .file-count { |
| | | font-size: 14px; |
| | | color: #999; |
| | | } |
| | | |
| | | .is-add { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .icon-add { |
| | | width: 50px; |
| | | height: 5px; |
| | | background-color: #f1f1f1; |
| | | border-radius: 2px; |
| | | } |
| | | |
| | | .rotate { |
| | | position: absolute; |
| | | transform: rotate(90deg); |
| | | } |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view class="uni-file-picker__files"> |
| | | <view v-if="!readonly" class="files-button" @click="choose"> |
| | | <slot></slot> |
| | | </view> |
| | | <!-- :class="{'is-text-box':showType === 'list'}" --> |
| | | <view v-if="list.length > 0" class="uni-file-picker__lists is-text-box" :style="borderStyle"> |
| | | <!-- ,'is-list-card':showType === 'list-card' --> |
| | | |
| | | <view class="uni-file-picker__lists-box" v-for="(item ,index) in list" :key="index" :class="{ |
| | | 'files-border':index !== 0 && styles.dividline}" |
| | | :style="index !== 0 && styles.dividline &&borderLineStyle"> |
| | | <view class="uni-file-picker__item"> |
| | | <!-- :class="{'is-text-image':showType === 'list'}" --> |
| | | <!-- <view class="files__image is-text-image"> |
| | | <image class="header-image" :src="item.logo" mode="aspectFit"></image> |
| | | </view> --> |
| | | <view class="files__name">{{item.name}}</view> |
| | | <view v-if="delIcon&&!readonly" class="icon-del-box icon-files" @click="delFile(index)"> |
| | | <view class="icon-del icon-files"></view> |
| | | <view class="icon-del rotate"></view> |
| | | </view> |
| | | </view> |
| | | <view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress"> |
| | | <progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4" |
| | | :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" /> |
| | | </view> |
| | | <view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="uploadFiles(item,index)"> |
| | | ç¹å»éè¯ |
| | | </view> |
| | | </view> |
| | | |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: "uploadFile", |
| | | emits:['uploadFiles','choose','delFile'], |
| | | props: { |
| | | filesList: { |
| | | type: Array, |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | delIcon: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | limit: { |
| | | type: [Number, String], |
| | | default: 9 |
| | | }, |
| | | showType: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | listStyles: { |
| | | type: Object, |
| | | default () { |
| | | return { |
| | | // æ¯å¦æ¾ç¤ºè¾¹æ¡ |
| | | border: true, |
| | | // æ¯å¦æ¾ç¤ºåé线 |
| | | dividline: true, |
| | | // çº¿æ¡æ ·å¼ |
| | | borderStyle: {} |
| | | } |
| | | } |
| | | }, |
| | | readonly:{ |
| | | type:Boolean, |
| | | default:false |
| | | } |
| | | }, |
| | | computed: { |
| | | list() { |
| | | let files = [] |
| | | this.filesList.forEach(v => { |
| | | files.push(v) |
| | | }) |
| | | return files |
| | | }, |
| | | styles() { |
| | | let styles = { |
| | | border: true, |
| | | dividline: true, |
| | | 'border-style': {} |
| | | } |
| | | return Object.assign(styles, this.listStyles) |
| | | }, |
| | | borderStyle() { |
| | | let { |
| | | borderStyle, |
| | | border |
| | | } = this.styles |
| | | let obj = {} |
| | | if (!border) { |
| | | obj.border = 'none' |
| | | } else { |
| | | let width = (borderStyle && borderStyle.width) || 1 |
| | | width = this.value2px(width) |
| | | let radius = (borderStyle && borderStyle.radius) || 5 |
| | | radius = this.value2px(radius) |
| | | obj = { |
| | | 'border-width': width, |
| | | 'border-style': (borderStyle && borderStyle.style) || 'solid', |
| | | 'border-color': (borderStyle && borderStyle.color) || '#eee', |
| | | 'border-radius': radius |
| | | } |
| | | } |
| | | let classles = '' |
| | | for (let i in obj) { |
| | | classles += `${i}:${obj[i]};` |
| | | } |
| | | return classles |
| | | }, |
| | | borderLineStyle() { |
| | | let obj = {} |
| | | let { |
| | | borderStyle |
| | | } = this.styles |
| | | if (borderStyle && borderStyle.color) { |
| | | obj['border-color'] = borderStyle.color |
| | | } |
| | | if (borderStyle && borderStyle.width) { |
| | | let width = borderStyle && borderStyle.width || 1 |
| | | let style = borderStyle && borderStyle.style || 0 |
| | | if (typeof width === 'number') { |
| | | width += 'px' |
| | | } else { |
| | | width = width.indexOf('px') ? width : width + 'px' |
| | | } |
| | | obj['border-width'] = width |
| | | |
| | | if (typeof style === 'number') { |
| | | style += 'px' |
| | | } else { |
| | | style = style.indexOf('px') ? style : style + 'px' |
| | | } |
| | | obj['border-top-style'] = style |
| | | } |
| | | let classles = '' |
| | | for (let i in obj) { |
| | | classles += `${i}:${obj[i]};` |
| | | } |
| | | return classles |
| | | } |
| | | }, |
| | | |
| | | methods: { |
| | | uploadFiles(item, index) { |
| | | this.$emit("uploadFiles", { |
| | | item, |
| | | index |
| | | }) |
| | | }, |
| | | choose() { |
| | | this.$emit("choose") |
| | | }, |
| | | delFile(index) { |
| | | this.$emit('delFile', index) |
| | | }, |
| | | value2px(value) { |
| | | if (typeof value === 'number') { |
| | | value += 'px' |
| | | } else { |
| | | value = value.indexOf('px') !== -1 ? value : value + 'px' |
| | | } |
| | | return value |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .uni-file-picker__files { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: flex-start; |
| | | } |
| | | |
| | | .files-button { |
| | | // border: 1px red solid; |
| | | } |
| | | |
| | | .uni-file-picker__lists { |
| | | position: relative; |
| | | margin-top: 5px; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .file-picker__mask { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | justify-content: center; |
| | | align-items: center; |
| | | position: absolute; |
| | | right: 0; |
| | | top: 0; |
| | | bottom: 0; |
| | | left: 0; |
| | | color: #fff; |
| | | font-size: 14px; |
| | | background-color: rgba(0, 0, 0, 0.4); |
| | | } |
| | | |
| | | .uni-file-picker__lists-box { |
| | | position: relative; |
| | | } |
| | | |
| | | .uni-file-picker__item { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | align-items: center; |
| | | padding: 8px 10px; |
| | | padding-right: 5px; |
| | | padding-left: 10px; |
| | | } |
| | | |
| | | .files-border { |
| | | border-top: 1px #eee solid; |
| | | } |
| | | |
| | | .files__name { |
| | | flex: 1; |
| | | font-size: 14px; |
| | | color: #666; |
| | | margin-right: 25px; |
| | | /* #ifndef APP-NVUE */ |
| | | word-break: break-all; |
| | | word-wrap: break-word; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .icon-files { |
| | | /* #ifndef APP-NVUE */ |
| | | position: static; |
| | | background-color: initial; |
| | | /* #endif */ |
| | | } |
| | | |
| | | // .icon-files .icon-del { |
| | | // background-color: #333; |
| | | // width: 12px; |
| | | // height: 1px; |
| | | // } |
| | | |
| | | |
| | | .is-list-card { |
| | | border: 1px #eee solid; |
| | | margin-bottom: 5px; |
| | | border-radius: 5px; |
| | | box-shadow: 0 0 2px 0px rgba(0, 0, 0, 0.1); |
| | | padding: 5px; |
| | | } |
| | | |
| | | .files__image { |
| | | width: 40px; |
| | | height: 40px; |
| | | margin-right: 10px; |
| | | } |
| | | |
| | | .header-image { |
| | | width: 100%; |
| | | height: 100%; |
| | | } |
| | | |
| | | .is-text-box { |
| | | border: 1px #eee solid; |
| | | border-radius: 5px; |
| | | } |
| | | |
| | | .is-text-image { |
| | | width: 25px; |
| | | height: 25px; |
| | | margin-left: 5px; |
| | | } |
| | | |
| | | .rotate { |
| | | position: absolute; |
| | | transform: rotate(90deg); |
| | | } |
| | | |
| | | .icon-del-box { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | margin: auto 0; |
| | | /* #endif */ |
| | | align-items: center; |
| | | justify-content: center; |
| | | position: absolute; |
| | | top: 0px; |
| | | bottom: 0; |
| | | right: 5px; |
| | | height: 26px; |
| | | width: 26px; |
| | | // border-radius: 50%; |
| | | // background-color: rgba(0, 0, 0, 0.5); |
| | | z-index: 2; |
| | | transform: rotate(-45deg); |
| | | } |
| | | |
| | | .icon-del { |
| | | width: 15px; |
| | | height: 1px; |
| | | background-color: #333; |
| | | // border-radius: 1px; |
| | | } |
| | | |
| | | /* #ifdef H5 */ |
| | | @media all and (min-width: 768px) { |
| | | .uni-file-picker__files { |
| | | max-width: 375px; |
| | | } |
| | | } |
| | | |
| | | /* #endif */ |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view class="uni-file-picker__container"> |
| | | <view class="file-picker__box" v-for="(item,index) in filesList" :key="index" :style="boxStyle"> |
| | | <view class="file-picker__box-content" :style="borderStyle"> |
| | | <image class="file-image" :src="item.url" mode="aspectFill" @click.stop="prviewImage(item,index)"></image> |
| | | <view v-if="delIcon && !readonly" class="icon-del-box" @click.stop="delFile(index)"> |
| | | <view class="icon-del"></view> |
| | | <view class="icon-del rotate"></view> |
| | | </view> |
| | | <view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress"> |
| | | <progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4" |
| | | :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" /> |
| | | </view> |
| | | <view v-if="item.errMsg" class="file-picker__mask" @click.stop="uploadFiles(item,index)"> |
| | | ç¹å»éè¯ |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view v-if="filesList.length < limit && !readonly" class="file-picker__box" :style="boxStyle"> |
| | | <view class="file-picker__box-content is-add" :style="borderStyle" @click="choose"> |
| | | <slot> |
| | | <view class="icon-add"></view> |
| | | <view class="icon-add rotate"></view> |
| | | </slot> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: "uploadImage", |
| | | emits:['uploadFiles','choose','delFile'], |
| | | props: { |
| | | filesList: { |
| | | type: Array, |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | disabled:{ |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | disablePreview: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | limit: { |
| | | type: [Number, String], |
| | | default: 9 |
| | | }, |
| | | imageStyles: { |
| | | type: Object, |
| | | default () { |
| | | return { |
| | | width: 'auto', |
| | | height: 'auto', |
| | | border: {} |
| | | } |
| | | } |
| | | }, |
| | | delIcon: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | readonly:{ |
| | | type:Boolean, |
| | | default:false |
| | | } |
| | | }, |
| | | computed: { |
| | | styles() { |
| | | let styles = { |
| | | width: 'auto', |
| | | height: 'auto', |
| | | border: {} |
| | | } |
| | | return Object.assign(styles, this.imageStyles) |
| | | }, |
| | | boxStyle() { |
| | | const { |
| | | width = 'auto', |
| | | height = 'auto' |
| | | } = this.styles |
| | | let obj = {} |
| | | if (height === 'auto') { |
| | | if (width !== 'auto') { |
| | | obj.height = this.value2px(width) |
| | | obj['padding-top'] = 0 |
| | | } else { |
| | | obj.height = 0 |
| | | } |
| | | } else { |
| | | obj.height = this.value2px(height) |
| | | obj['padding-top'] = 0 |
| | | } |
| | | |
| | | if (width === 'auto') { |
| | | if (height !== 'auto') { |
| | | obj.width = this.value2px(height) |
| | | } else { |
| | | obj.width = '33.3%' |
| | | } |
| | | } else { |
| | | obj.width = this.value2px(width) |
| | | } |
| | | |
| | | let classles = '' |
| | | for(let i in obj){ |
| | | classles+= `${i}:${obj[i]};` |
| | | } |
| | | return classles |
| | | }, |
| | | borderStyle() { |
| | | let { |
| | | border |
| | | } = this.styles |
| | | let obj = {} |
| | | const widthDefaultValue = 1 |
| | | const radiusDefaultValue = 3 |
| | | if (typeof border === 'boolean') { |
| | | obj.border = border ? '1px #eee solid' : 'none' |
| | | } else { |
| | | let width = (border && border.width) || widthDefaultValue |
| | | width = this.value2px(width) |
| | | let radius = (border && border.radius) || radiusDefaultValue |
| | | radius = this.value2px(radius) |
| | | obj = { |
| | | 'border-width': width, |
| | | 'border-style': (border && border.style) || 'solid', |
| | | 'border-color': (border && border.color) || '#eee', |
| | | 'border-radius': radius |
| | | } |
| | | } |
| | | let classles = '' |
| | | for(let i in obj){ |
| | | classles+= `${i}:${obj[i]};` |
| | | } |
| | | return classles |
| | | } |
| | | }, |
| | | methods: { |
| | | uploadFiles(item, index) { |
| | | this.$emit("uploadFiles", item) |
| | | }, |
| | | choose() { |
| | | this.$emit("choose") |
| | | }, |
| | | delFile(index) { |
| | | this.$emit('delFile', index) |
| | | }, |
| | | prviewImage(img, index) { |
| | | let urls = [] |
| | | if(Number(this.limit) === 1&&this.disablePreview&&!this.disabled){ |
| | | this.$emit("choose") |
| | | } |
| | | if(this.disablePreview) return |
| | | this.filesList.forEach(i => { |
| | | urls.push(i.url) |
| | | }) |
| | | |
| | | uni.previewImage({ |
| | | urls: urls, |
| | | current: index |
| | | }); |
| | | }, |
| | | value2px(value) { |
| | | if (typeof value === 'number') { |
| | | value += 'px' |
| | | } else { |
| | | if (value.indexOf('%') === -1) { |
| | | value = value.indexOf('px') !== -1 ? value : value + 'px' |
| | | } |
| | | } |
| | | return value |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .uni-file-picker__container { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | flex-wrap: wrap; |
| | | margin: -5px; |
| | | } |
| | | |
| | | .file-picker__box { |
| | | position: relative; |
| | | // flex: 0 0 33.3%; |
| | | width: 33.3%; |
| | | height: 0; |
| | | padding-top: 33.33%; |
| | | /* #ifndef APP-NVUE */ |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .file-picker__box-content { |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | left: 0; |
| | | margin: 5px; |
| | | border: 1px #eee solid; |
| | | border-radius: 5px; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .file-picker__progress { |
| | | position: absolute; |
| | | bottom: 0; |
| | | left: 0; |
| | | right: 0; |
| | | /* border: 1px red solid; */ |
| | | z-index: 2; |
| | | } |
| | | |
| | | .file-picker__progress-item { |
| | | width: 100%; |
| | | } |
| | | |
| | | .file-picker__mask { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | justify-content: center; |
| | | align-items: center; |
| | | position: absolute; |
| | | right: 0; |
| | | top: 0; |
| | | bottom: 0; |
| | | left: 0; |
| | | color: #fff; |
| | | font-size: 12px; |
| | | background-color: rgba(0, 0, 0, 0.4); |
| | | } |
| | | |
| | | .file-image { |
| | | width: 100%; |
| | | height: 100%; |
| | | } |
| | | |
| | | .is-add { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .icon-add { |
| | | width: 50px; |
| | | height: 5px; |
| | | background-color: #f1f1f1; |
| | | border-radius: 2px; |
| | | } |
| | | |
| | | .rotate { |
| | | position: absolute; |
| | | transform: rotate(90deg); |
| | | } |
| | | |
| | | .icon-del-box { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | align-items: center; |
| | | justify-content: center; |
| | | position: absolute; |
| | | top: 3px; |
| | | right: 3px; |
| | | height: 26px; |
| | | width: 26px; |
| | | border-radius: 50%; |
| | | background-color: rgba(0, 0, 0, 0.5); |
| | | z-index: 2; |
| | | transform: rotate(-45deg); |
| | | } |
| | | |
| | | .icon-del { |
| | | width: 15px; |
| | | height: 2px; |
| | | background-color: #fff; |
| | | border-radius: 2px; |
| | | } |
| | | </style> |
| New file |
| | |
| | | /** |
| | | * è·åæä»¶åååç¼ |
| | | * @param {String} name |
| | | */ |
| | | export const get_file_ext = (name) => { |
| | | const last_len = name.lastIndexOf('.') |
| | | const len = name.length |
| | | return { |
| | | name: name.substring(0, last_len), |
| | | ext: name.substring(last_len + 1, len) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åæ©å±å |
| | | * @param {Array} fileExtname |
| | | */ |
| | | export const get_extname = (fileExtname) => { |
| | | if (!Array.isArray(fileExtname)) { |
| | | let extname = fileExtname.replace(/(\[|\])/g, '') |
| | | return extname.split(',') |
| | | } else { |
| | | return fileExtname |
| | | } |
| | | return [] |
| | | } |
| | | |
| | | /** |
| | | * è·åæä»¶åæ£æµæ¯å¦å¯é |
| | | */ |
| | | export const get_files_and_is_max = (res, _extname) => { |
| | | let filePaths = [] |
| | | let files = [] |
| | | if(!_extname || _extname.length === 0){ |
| | | return { |
| | | filePaths, |
| | | files |
| | | } |
| | | } |
| | | res.tempFiles.forEach(v => { |
| | | let fileFullName = get_file_ext(v.name) |
| | | const extname = fileFullName.ext.toLowerCase() |
| | | if (_extname.indexOf(extname) !== -1) { |
| | | files.push(v) |
| | | filePaths.push(v.path) |
| | | } |
| | | }) |
| | | if (files.length !== res.tempFiles.length) { |
| | | uni.showToast({ |
| | | title: `å½åéæ©äº${res.tempFiles.length}个æä»¶ ï¼${res.tempFiles.length - files.length} 个æä»¶æ ¼å¼ä¸æ£ç¡®`, |
| | | icon: 'none', |
| | | duration: 5000 |
| | | }) |
| | | } |
| | | |
| | | return { |
| | | filePaths, |
| | | files |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è·åå¾çä¿¡æ¯ |
| | | * @param {Object} filepath |
| | | */ |
| | | export const get_file_info = (filepath) => { |
| | | return new Promise((resolve, reject) => { |
| | | uni.getImageInfo({ |
| | | src: filepath, |
| | | success(res) { |
| | | resolve(res) |
| | | }, |
| | | fail(err) { |
| | | reject(err) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | /** |
| | | * è·åå°è£
æ°æ® |
| | | */ |
| | | export const get_file_data = async (files, type = 'image') => { |
| | | // æç»éè¦ä¸ä¼ æ°æ®åºçæ°æ® |
| | | let fileFullName = get_file_ext(files.name) |
| | | const extname = fileFullName.ext.toLowerCase() |
| | | let filedata = { |
| | | name: files.name, |
| | | uuid: files.uuid, |
| | | extname: extname || '', |
| | | cloudPath: files.cloudPath, |
| | | fileType: files.fileType, |
| | | url: files.path || files.path, |
| | | size: files.size, //å使¯åè |
| | | image: {}, |
| | | path: files.path, |
| | | video: {} |
| | | } |
| | | if (type === 'image') { |
| | | const imageinfo = await get_file_info(files.path) |
| | | delete filedata.video |
| | | filedata.image.width = imageinfo.width |
| | | filedata.image.height = imageinfo.height |
| | | filedata.image.location = imageinfo.path |
| | | } else { |
| | | delete filedata.image |
| | | } |
| | | return filedata |
| | | } |
| New file |
| | |
| | | { |
| | | "id": "uni-file-picker", |
| | | "displayName": "uni-file-picker æä»¶éæ©ä¸ä¼ ", |
| | | "version": "1.0.1", |
| | | "description": "æä»¶éæ©ä¸ä¼ ç»ä»¶ï¼å¯ä»¥éæ©å¾çãè§é¢çä»»ææä»¶å¹¶ä¸ä¼ å°å½åç»å®çæå¡ç©ºé´", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "å¾çä¸ä¼ ", |
| | | "æä»¶ä¸ä¼ " |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-scss"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "n" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | ## FilePicker æä»¶éæ©ä¸ä¼ |
| | | |
| | | > **ç»ä»¶åï¼uni-file-picker** |
| | | > 代ç åï¼ `uFilePicker` |
| | | |
| | | |
| | | æä»¶éæ©ä¸ä¼ ç»ä»¶ï¼å¯ä»¥éæ©å¾çãè§é¢çä»»ææä»¶å¹¶ä¸ä¼ å°å½åç»å®çæå¡ç©ºé´ |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-file-picker) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.3.2ï¼2021-12-09ï¼ |
| | | - |
| | | ## 1.3.1ï¼2021-11-19ï¼ |
| | | - ä¿®å¤ label ææ§½ä¸çæçbug |
| | | ## 1.3.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-forms](https://uniapp.dcloud.io/component/uniui/uni-forms) |
| | | ## 1.2.7ï¼2021-08-13ï¼ |
| | | - ä¿®å¤ æ²¡ææ·»å æ ¡éªè§åçåæ®µä¾ç¶æ¥éçBug |
| | | ## 1.2.6ï¼2021-08-11ï¼ |
| | | - ä¿®å¤ é置表åéè¯¯ä¿¡æ¯æ æ³æ¸
é¤çé®é¢ |
| | | ## 1.2.5ï¼2021-08-11ï¼ |
| | | - ä¼å ç»ä»¶ææ¡£ |
| | | ## 1.2.4ï¼2021-08-11ï¼ |
| | | - ä¿®å¤ è¡¨åéªè¯åªçæä¸æ¬¡çé®é¢ |
| | | ## 1.2.3ï¼2021-07-30ï¼ |
| | | - ä¼å vue3ä¸äºä»¶è¦åçé®é¢ |
| | | ## 1.2.2ï¼2021-07-26ï¼ |
| | | - ä¿®å¤ vue2 䏿¡ä»¶ç¼è¯å¯¼è´destroyedçå½å¨æå¤±æçBug |
| | | - ä¿®å¤ 1.2.1 å¼èµ·ç示ä¾å¨å°ç¨åºå¹³å°æ¥éçBug |
| | | ## 1.2.1ï¼2021-07-22ï¼ |
| | | - ä¿®å¤ å¨ææ ¡éªè¡¨åï¼é»è®¤å¼ä¸ºç©ºçæ
åµä¸æ ¡éªå¤±æçBug |
| | | - ä¿®å¤ ä¸æå®name屿§æ¶ï¼è¿è¡æ¥éçBug |
| | | - ä¼å labelé»è®¤å®½åº¦ä»65è°æ´è³70ï¼ä½¿required为trueä¸å忶䏿¢è¡ |
| | | - ä¼å ç»ä»¶ç¤ºä¾ï¼æ°å¢å¨ææ ¡éªç¤ºä¾ä»£ç |
| | | - ä¼å ç»ä»¶ææ¡£ï¼ä½¿ç¨æ¹å¼æ´æ¸
æ° |
| | | ## 1.2.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.1.2ï¼2021-06-25ï¼ |
| | | - ä¿®å¤ pattern 屿§å¨å¾®ä¿¡å°ç¨åºå¹³å°æ æçé®é¢ |
| | | ## 1.1.1ï¼2021-06-22ï¼ |
| | | - ä¿®å¤ validate-trigger屿§ä¸ºsubmitä¸err-show-type屿§ä¸ºtoastæ¶ä¸è½å¼¹åºçBug |
| | | ## 1.1.0ï¼2021-06-22ï¼ |
| | | - ä¿®å¤ åªåsetRulesæ¹æ³èå¯¼è´æ ¡éªä¸çæçBug |
| | | - ä¿®å¤ ç±ä¸ä¸ªåæ³å¼åçé误æç¤ºæåéä½çBug |
| | | ## 1.0.48ï¼2021-06-21ï¼ |
| | | - ä¿®å¤ ä¸è®¾ç½® label 屿§ ï¼æ æ³è®¾ç½®labelææ§½çé®é¢ |
| | | ## 1.0.47ï¼2021-06-21ï¼ |
| | | - ä¿®å¤ ä¸è®¾ç½®label屿§ï¼label-width屿§ä¸çæçbug |
| | | - ä¿®å¤ setRules æ¹æ³ä¸rules屿§å²çªçé®é¢ |
| | | ## 1.0.46ï¼2021-06-04ï¼ |
| | | - ä¿®å¤ å¨æå åæ°æ®å¯¼è´æ¥éçé®é¢ |
| | | ## 1.0.45ï¼2021-06-04ï¼ |
| | | - æ°å¢ modelValue 屿§ ï¼value å³å°åºå¼ |
| | | ## 1.0.44ï¼2021-06-02ï¼ |
| | | - æ°å¢ uni-forms-item å¯ä»¥è®¾ç½®åç¬ç rules |
| | | - æ°å¢ validate äºä»¶å¢å keepitem åæ°ï¼å¯ä»¥éæ©é£äºå段ä¸è¿æ»¤ |
| | | - ä¼å submit äºä»¶éå½å为 validate |
| | | ## 1.0.43ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.42ï¼2021-04-30ï¼ |
| | | - ä¿®å¤ èªå®ä¹æ£éªå¨å¤±æçé®é¢ |
| | | ## 1.0.41ï¼2021-03-05ï¼ |
| | | - æ´æ° æ ¡éªå¨ |
| | | - ä¿®å¤ è¡¨åè§å设置类å为 number çæ
åµä¸ï¼å¼ä¸º0æ ¡éªå¤±è´¥çBug |
| | | ## 1.0.40ï¼2021-03-04ï¼ |
| | | - ä¿®å¤ å¨ææ¾ç¤ºuni-forms-itemçæ
åµä¸ï¼submit æ¹æ³è·åå¼é误çBug |
| | | ## 1.0.39ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| | | - ä¿®å¤ æ ¡éªå¨ä¼ å
¥ int çç±»å ï¼è¿åStringç±»åçBug |
| New file |
| | |
| | | <template> |
| | | <view class="uni-forms-item" :class="{ 'uni-forms-item--border': border, 'is-first-border': border && isFirstBorder, 'uni-forms-item-error': msg }"> |
| | | <view class="uni-forms-item__box"> |
| | | <view class="uni-forms-item__inner" :class="['is-direction-' + labelPos]"> |
| | | <view class="uni-forms-item__label" :style="{ width: labelWid , justifyContent: justifyContent }"> |
| | | <slot name="label"> |
| | | <text v-if="required" class="is-required">*</text> |
| | | <uni-icons v-if="leftIcon" class="label-icon" size="16" :type="leftIcon" :color="iconColor" /> |
| | | <text class="label-text">{{ label }}</text> |
| | | |
| | | <view v-if="label" class="label-seat"></view> |
| | | </slot> |
| | | </view> |
| | | <view class="uni-forms-item__content" :class="{ 'is-input-error-border': msg }"><slot></slot></view> |
| | | </view> |
| | | <view |
| | | v-if="msg" |
| | | class="uni-error-message" |
| | | :class="{ 'uni-error-msg--boeder': border }" |
| | | :style="{ |
| | | paddingLeft: labelLeft |
| | | }" |
| | | > |
| | | <text class="uni-error-message-text">{{ showMsg === 'undertext' ? msg : '' }}</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * Field è¾å
¥æ¡ |
| | | * @description æ¤ç»ä»¶å¯ä»¥å®ç°è¡¨åçè¾å
¥ä¸æ ¡éªï¼å
æ¬ "text" å "textarea" ç±»åã |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=21001 |
| | | * @property {Boolean} required æ¯å¦å¿
å¡«ï¼å·¦è¾¹æ¾ç¤ºçº¢è²"*"å·ï¼é»è®¤falseï¼ |
| | | * @property {String} validateTrigger = [bind|submit] æ ¡éªè§¦å卿¹å¼ é»è®¤ submit å¯é |
| | | * @value bind åçååæ¶è§¦å |
| | | * @value submit æäº¤æ¶è§¦å |
| | | * @property {String } leftIcon label左边ç徿 ï¼é uni-ui ç徿 åç§° |
| | | * @property {String } iconColor 左边éè¿iconé
ç½®ç徿 çé¢è²ï¼é»è®¤#606266ï¼ |
| | | * @property {String } label è¾å
¥æ¡å·¦è¾¹çæåæç¤º |
| | | * @property {Number } labelWidth labelç宽度ï¼åä½pxï¼é»è®¤65ï¼ |
| | | * @property {String } labelAlign = [left|center|right] labelçæå坹齿¹å¼ï¼é»è®¤leftï¼ |
| | | * @value left label 左侧æ¾ç¤º |
| | | * @value center label å±
ä¸ |
| | | * @value right label å³ä¾§å¯¹é½ |
| | | * @property {String } labelPosition = [top|left] labelçæåçä½ç½®ï¼é»è®¤leftï¼ |
| | | * @value top 顶鍿¾ç¤º label |
| | | * @value left 左侧æ¾ç¤º label |
| | | * @property {String } errorMessage æ¾ç¤ºçé误æç¤ºå
容ï¼å¦æä¸ºç©ºå符串æè
falseï¼å䏿¾ç¤ºéè¯¯ä¿¡æ¯ |
| | | * @property {String } name 表ååç屿§åï¼å¨ä½¿ç¨æ ¡éªè§åæ¶å¿
å¡« |
| | | */ |
| | | |
| | | export default { |
| | | name: 'uniFormsItem', |
| | | props: { |
| | | // èªå®ä¹å
容 |
| | | custom: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | // æ¯å¦æ¾ç¤ºæ¥éä¿¡æ¯ |
| | | showMessage: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | name: String, |
| | | required: Boolean, |
| | | validateTrigger: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | leftIcon: String, |
| | | iconColor: { |
| | | type: String, |
| | | default: '#606266' |
| | | }, |
| | | label: String, |
| | | // 左边æ é¢ç宽度åä½px |
| | | labelWidth: { |
| | | type: [Number, String], |
| | | default: '' |
| | | }, |
| | | // 坹齿¹å¼ï¼left|center|right |
| | | labelAlign: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // lableçä½ç½®ï¼å¯é为 left-左边ï¼top-ä¸è¾¹ |
| | | labelPosition: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | errorMessage: { |
| | | type: [String, Boolean], |
| | | default: '' |
| | | }, |
| | | // è¡¨åæ ¡éªè§å |
| | | rules: { |
| | | type: Array, |
| | | default() { |
| | | return []; |
| | | } |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | errorTop: false, |
| | | errorBottom: false, |
| | | labelMarginBottom: '', |
| | | errorWidth: '', |
| | | errMsg: '', |
| | | val: '', |
| | | labelPos: '', |
| | | labelWid: '', |
| | | labelAli: '', |
| | | showMsg: 'undertext', |
| | | border: false, |
| | | isFirstBorder: false, |
| | | isArray: false, |
| | | arrayField: '' |
| | | }; |
| | | }, |
| | | computed: { |
| | | msg() { |
| | | return this.errorMessage || this.errMsg; |
| | | }, |
| | | fieldStyle() { |
| | | let style = {}; |
| | | if (this.labelPos == 'top') { |
| | | style.padding = '0 0'; |
| | | this.labelMarginBottom = '6px'; |
| | | } |
| | | if (this.labelPos == 'left' && this.msg !== false && this.msg != '') { |
| | | style.paddingBottom = '0px'; |
| | | this.errorBottom = true; |
| | | this.errorTop = false; |
| | | } else if (this.labelPos == 'top' && this.msg !== false && this.msg != '') { |
| | | this.errorBottom = false; |
| | | this.errorTop = true; |
| | | } else { |
| | | // style.paddingBottom = '' |
| | | this.errorTop = false; |
| | | this.errorBottom = false; |
| | | } |
| | | return style; |
| | | }, |
| | | |
| | | // uni䏿¯æå¨computedä¸åstyle.justifyContent = 'center'çå½¢å¼ï¼æ
ç¨æ¤æ¹æ³ |
| | | justifyContent() { |
| | | if (this.labelAli === 'left') return 'flex-start'; |
| | | if (this.labelAli === 'center') return 'center'; |
| | | if (this.labelAli === 'right') return 'flex-end'; |
| | | }, |
| | | labelLeft(){ |
| | | return (this.labelPos === 'left' ? parseInt(this.labelWid) : 0) + 'px' |
| | | } |
| | | }, |
| | | watch: { |
| | | validateTrigger(trigger) { |
| | | this.formTrigger = trigger; |
| | | } |
| | | }, |
| | | created() { |
| | | this.form = this.getForm(); |
| | | this.group = this.getForm('uniGroup'); |
| | | this.formRules = []; |
| | | this.formTrigger = this.validateTrigger; |
| | | // å¤ç nameï¼æ¯å¦æ°ç» |
| | | if (this.name && this.name.indexOf('[') !== -1 && this.name.indexOf(']') !== -1) { |
| | | this.isArray = true; |
| | | this.arrayField = this.name |
| | | // fix by mehaotian ä¿®æ¹ä¸ä¿®æ¹çæ
åµï¼å¨æå¼ä¸æ£éªçé®é¢ |
| | | this.form.formData[this.name] = this.form._getValue(this.name, '') |
| | | } |
| | | }, |
| | | mounted() { |
| | | if (this.form) { |
| | | this.form.childrens.push(this); |
| | | } |
| | | this.init(); |
| | | }, |
| | | // #ifndef VUE3 |
| | | destroyed() { |
| | | if(this.__isUnmounted) return |
| | | this.unInit() |
| | | }, |
| | | // #endif |
| | | // #ifdef VUE3 |
| | | unmounted(){ |
| | | this.__isUnmounted = true |
| | | this.unInit() |
| | | }, |
| | | // #endif |
| | | methods: { |
| | | init() { |
| | | if (this.form) { |
| | | let { formRules, validator, formData, value, labelPosition, labelWidth, labelAlign, errShowType } = this.form; |
| | | this.labelPos = this.labelPosition ? this.labelPosition : labelPosition; |
| | | |
| | | if(this.label){ |
| | | this.labelWid = (this.labelWidth ? this.labelWidth : (labelWidth||70)) |
| | | }else{ |
| | | this.labelWid =( this.labelWidth ? this.labelWidth : (labelWidth||'auto')) |
| | | } |
| | | if(this.labelWid && this.labelWid !=='auto') { |
| | | this.labelWid +='px' |
| | | } |
| | | this.labelAli = this.labelAlign ? this.labelAlign : labelAlign; |
| | | |
| | | // å¤æç¬¬ä¸ä¸ª item |
| | | if (!this.form.isFirstBorder) { |
| | | this.form.isFirstBorder = true; |
| | | this.isFirstBorder = true; |
| | | } |
| | | |
| | | // 夿 group éç第ä¸ä¸ª item |
| | | if (this.group) { |
| | | if (!this.group.isFirstBorder) { |
| | | this.group.isFirstBorder = true; |
| | | this.isFirstBorder = true; |
| | | } |
| | | } |
| | | |
| | | this.border = this.form.border; |
| | | this.showMsg = errShowType; |
| | | let name = this.isArray ? this.arrayField : this.name; |
| | | if(!name) return |
| | | if (formRules && this.rules.length > 0) { |
| | | if (!formRules[name]) { |
| | | formRules[name] = { |
| | | rules: this.rules |
| | | } |
| | | } |
| | | validator.updateSchema(formRules); |
| | | } |
| | | this.formRules = formRules[name] || {}; |
| | | this.validator = validator; |
| | | } else { |
| | | this.labelPos = this.labelPosition || 'left'; |
| | | this.labelWid = this.labelWidth || 65; |
| | | this.labelAli = this.labelAlign || 'left'; |
| | | } |
| | | }, |
| | | unInit(){ |
| | | if (this.form) { |
| | | this.form.childrens.forEach((item, index) => { |
| | | if (item === this) { |
| | | this.form.childrens.splice(index, 1) |
| | | delete this.form.formData[item.name] |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | /** |
| | | * è·åç¶å
ç´ å®ä¾ |
| | | */ |
| | | getForm(name = 'uniForms') { |
| | | let parent = this.$parent; |
| | | let parentName = parent.$options.name; |
| | | while (parentName !== name) { |
| | | parent = parent.$parent; |
| | | if (!parent) return false; |
| | | parentName = parent.$options.name; |
| | | } |
| | | return parent; |
| | | }, |
| | | |
| | | /** |
| | | * ç§»é¤è¯¥è¡¨åé¡¹çæ ¡éªç»æ |
| | | */ |
| | | clearValidate() { |
| | | this.errMsg = ''; |
| | | }, |
| | | /** |
| | | * åç»ä»¶è°ç¨ï¼å¦ easyinput |
| | | * @param {Object} value |
| | | */ |
| | | setValue(value) { |
| | | let name = this.isArray ? this.arrayField : this.name; |
| | | if (name) { |
| | | if (this.errMsg) this.errMsg = ''; |
| | | // ç»ç»ä»¶èµå¼ |
| | | this.form.formData[name] = this.form._getValue(name, value); |
| | | if (!this.formRules || (typeof this.formRules && JSON.stringify(this.formRules) === '{}')) return; |
| | | this.triggerCheck(this.form._getValue(this.name, value)); |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * æ ¡éªè§å |
| | | * @param {Object} value |
| | | */ |
| | | async triggerCheck(value,formTrigger) { |
| | | let promise = null; |
| | | this.errMsg = ''; |
| | | // fix by mehaotian è§£å³æ²¡ææ£éªè§åçæ
åµä¸ï¼æåºé误çé®é¢ |
| | | if (!this.validator || Object.keys(this.formRules).length === 0) return; |
| | | const isNoField = this.isRequired(this.formRules.rules || []); |
| | | let isTrigger = this.isTrigger(this.formRules.validateTrigger, this.validateTrigger, this.form.validateTrigger); |
| | | let result = null; |
| | | if (!!isTrigger || formTrigger) { |
| | | let name = this.isArray ? this.arrayField : this.name; |
| | | result = await this.validator.validateUpdate( |
| | | { |
| | | [name]: value |
| | | }, |
| | | this.form.formData |
| | | ); |
| | | } |
| | | // 夿æ¯å¦å¿
å¡«,éå¿
å¡«ï¼ä¸å¡«ä¸æ ¡éªï¼å¡«åææ ¡éª |
| | | if (!isNoField && (value === undefined || value === '')) { |
| | | result = null; |
| | | } |
| | | const inputComp = this.form.inputChildrens.find(child => child.rename === this.name); |
| | | if ((isTrigger ||ãformTrigger) && result && result.errorMessage) { |
| | | if (inputComp) { |
| | | inputComp.errMsg = result.errorMessage; |
| | | } |
| | | if (this.form.errShowType === 'toast') { |
| | | uni.showToast({ |
| | | title: result.errorMessage || 'æ ¡éªé误', |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | if (this.form.errShowType === 'modal') { |
| | | uni.showModal({ |
| | | title: 'æç¤º', |
| | | content: result.errorMessage || 'æ ¡éªé误' |
| | | }); |
| | | } |
| | | } else { |
| | | if (inputComp) { |
| | | inputComp.errMsg = ''; |
| | | } |
| | | } |
| | | |
| | | this.errMsg = !result ? '' : result.errorMessage; |
| | | // 触åvalidateäºä»¶ |
| | | this.form.validateCheck(result ? result : null); |
| | | // typeof callback === 'function' && callback(result ? result : null); |
| | | // if (promise) return promise |
| | | return result ? result : null; |
| | | }, |
| | | /** |
| | | * è§¦åæ¶æº |
| | | * @param {Object} event |
| | | */ |
| | | isTrigger(rule, itemRlue, parentRule) { |
| | | let rl = true; |
| | | // bind submit |
| | | if (rule === 'submit' || !rule) { |
| | | if (rule === undefined) { |
| | | if (itemRlue !== 'bind') { |
| | | if (!itemRlue) { |
| | | return parentRule === 'bind' ? true : false; |
| | | } |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | return true; |
| | | }, |
| | | // æ¯å¦æå¿
å¡«åæ®µ |
| | | isRequired(rules) { |
| | | let isNoField = false; |
| | | for (let i = 0; i < rules.length; i++) { |
| | | const ruleData = rules[i]; |
| | | if (ruleData.required) { |
| | | isNoField = true; |
| | | break; |
| | | } |
| | | } |
| | | return isNoField; |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" > |
| | | .uni-forms-item { |
| | | position: relative; |
| | | padding: 0px; |
| | | text-align: left; |
| | | color: #333; |
| | | font-size: 14px; |
| | | // margin-bottom: 22px; |
| | | } |
| | | |
| | | .uni-forms-item__box { |
| | | position: relative; |
| | | } |
| | | |
| | | .uni-forms-item__inner { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | // flex-direction: row; |
| | | // align-items: center; |
| | | padding-bottom: 22px; |
| | | // margin-bottom: 22px; |
| | | } |
| | | |
| | | .is-direction-left { |
| | | flex-direction: row; |
| | | } |
| | | |
| | | .is-direction-top { |
| | | flex-direction: column; |
| | | } |
| | | |
| | | .uni-forms-item__label { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | flex-shrink: 0; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | align-items: center; |
| | | width: 65px; |
| | | // line-height: 2; |
| | | // margin-top: 3px; |
| | | padding: 5px 0; |
| | | height: 36px; |
| | | // margin-right: 5px; |
| | | |
| | | .label-text { |
| | | font-size: 13px; |
| | | color: #666666; |
| | | } |
| | | .label-seat { |
| | | margin-right: 5px; |
| | | } |
| | | } |
| | | |
| | | .uni-forms-item__content { |
| | | /* #ifndef APP-NVUE */ |
| | | width: 100%; |
| | | box-sizing: border-box; |
| | | min-height: 36px; |
| | | /* #endif */ |
| | | flex: 1; |
| | | } |
| | | |
| | | .label-icon { |
| | | margin-right: 5px; |
| | | margin-top: -1px; |
| | | } |
| | | |
| | | // å¿
å¡« |
| | | .is-required { |
| | | // color: $uni-color-error; |
| | | color: #dd524d; |
| | | font-weight: bold; |
| | | } |
| | | |
| | | .uni-error-message { |
| | | position: absolute; |
| | | bottom: 0px; |
| | | left: 0; |
| | | text-align: left; |
| | | } |
| | | |
| | | .uni-error-message-text { |
| | | line-height: 22px; |
| | | color: #dd524d; |
| | | font-size: 12px; |
| | | } |
| | | |
| | | .uni-error-msg--boeder { |
| | | position: relative; |
| | | bottom: 0; |
| | | line-height: 22px; |
| | | } |
| | | |
| | | .is-input-error-border { |
| | | border-color: #dd524d; |
| | | } |
| | | |
| | | .uni-forms-item--border { |
| | | margin-bottom: 0; |
| | | padding: 10px 0; |
| | | // padding-bottom: 0; |
| | | border-top: 1px #eee solid; |
| | | |
| | | .uni-forms-item__inner { |
| | | padding: 0; |
| | | } |
| | | } |
| | | |
| | | .uni-forms-item-error { |
| | | // padding-bottom: 0; |
| | | } |
| | | |
| | | .is-first-border { |
| | | /* #ifndef APP-NVUE */ |
| | | border: none; |
| | | /* #endif */ |
| | | /* #ifdef APP-NVUE */ |
| | | border-width: 0; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-forms--no-padding { |
| | | padding: 0; |
| | | } |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view class="uni-forms" :class="{ 'uni-forms--top': !border }"> |
| | | <form @submit.stop="submitForm" @reset="resetForm"> |
| | | <slot></slot> |
| | | </form> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | // #ifndef VUE3 |
| | | import Vue from 'vue'; |
| | | Vue.prototype.binddata = function(name, value, formName) { |
| | | if (formName) { |
| | | this.$refs[formName].setValue(name, value); |
| | | } else { |
| | | let formVm; |
| | | for (let i in this.$refs) { |
| | | const vm = this.$refs[i]; |
| | | if (vm && vm.$options && vm.$options.name === 'uniForms') { |
| | | formVm = vm; |
| | | break; |
| | | } |
| | | } |
| | | if (!formVm) return console.error('å½å uni-froms ç»ä»¶ç¼ºå° ref 屿§'); |
| | | formVm.setValue(name, value); |
| | | } |
| | | }; |
| | | // #endif |
| | | |
| | | |
| | | |
| | | import Validator from './validate.js'; |
| | | /** |
| | | * Forms 表å |
| | | * @description ç±è¾å
¥æ¡ãéæ©å¨ãåéæ¡ãå¤éæ¡çæ§ä»¶ç»æï¼ç¨ä»¥æ¶éãæ ¡éªãæäº¤æ°æ® |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=2773 |
| | | * @property {Object} rules è¡¨åæ ¡éªè§å |
| | | * @property {String} validateTrigger = [bind|submit] æ ¡éªè§¦å卿¹å¼ é»è®¤ submit |
| | | * @value bind åçååæ¶è§¦å |
| | | * @value submit æäº¤æ¶è§¦å |
| | | * @property {String} labelPosition = [top|left] label ä½ç½® é»è®¤ left |
| | | * @value top 顶鍿¾ç¤º label |
| | | * @value left 左侧æ¾ç¤º label |
| | | * @property {String} labelWidth label 宽度ï¼é»è®¤ 65px |
| | | * @property {String} labelAlign = [left|center|right] label å±
䏿¹å¼ é»è®¤ left |
| | | * @value left label 左侧æ¾ç¤º |
| | | * @value center label å±
ä¸ |
| | | * @value right label å³ä¾§å¯¹é½ |
| | | * @property {String} errShowType = [undertext|toast|modal] æ ¡éªéè¯¯ä¿¡æ¯æç¤ºæ¹å¼ |
| | | * @value undertext é误信æ¯å¨åºé¨æ¾ç¤º |
| | | * @value toast é误信æ¯toastæ¾ç¤º |
| | | * @value modal é误信æ¯modalæ¾ç¤º |
| | | * @event {Function} submit æäº¤æ¶è§¦å |
| | | */ |
| | | |
| | | export default { |
| | | name: 'uniForms', |
| | | components: {}, |
| | | emits:['input','reset','validate','submit'], |
| | | props: { |
| | | // å³å°å¼ç¨ |
| | | value: { |
| | | type: Object, |
| | | default () { |
| | | return {}; |
| | | } |
| | | }, |
| | | // æ¿æ¢ value 屿§ |
| | | modelValue: { |
| | | type: Object, |
| | | default () { |
| | | return {}; |
| | | } |
| | | }, |
| | | // è¡¨åæ ¡éªè§å |
| | | rules: { |
| | | type: Object, |
| | | default () { |
| | | return {}; |
| | | } |
| | | }, |
| | | // æ ¡éªè§¦å卿¹å¼ï¼é»è®¤ å
³é |
| | | validateTrigger: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // label ä½ç½®ï¼å¯éå¼ top/left |
| | | labelPosition: { |
| | | type: String, |
| | | default: 'left' |
| | | }, |
| | | // label 宽度ï¼åä½ px |
| | | labelWidth: { |
| | | type: [String, Number], |
| | | default: '' |
| | | }, |
| | | // label å±
䏿¹å¼ï¼å¯éå¼ left/center/right |
| | | labelAlign: { |
| | | type: String, |
| | | default: 'left' |
| | | }, |
| | | errShowType: { |
| | | type: String, |
| | | default: 'undertext' |
| | | }, |
| | | border: { |
| | | type: Boolean, |
| | | default: false |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | formData: {} |
| | | }; |
| | | }, |
| | | computed: { |
| | | dataValue() { |
| | | if (JSON.stringify(this.modelValue) === '{}') { |
| | | return this.value |
| | | } else { |
| | | return this.modelValue |
| | | } |
| | | } |
| | | }, |
| | | watch: { |
| | | rules(newVal) { |
| | | // 妿è§ååçååï¼è¦åå§åç»ä»¶ |
| | | this.init(newVal); |
| | | }, |
| | | labelPosition() { |
| | | this.childrens.forEach(vm => { |
| | | vm.init() |
| | | }) |
| | | } |
| | | }, |
| | | created() { |
| | | // #ifdef VUE3 |
| | | let getbinddata = getApp().$vm.$.appContext.config.globalProperties.binddata |
| | | if (!getbinddata) { |
| | | getApp().$vm.$.appContext.config.globalProperties.binddata = function(name, value, formName) { |
| | | if (formName) { |
| | | this.$refs[formName].setValue(name, value); |
| | | } else { |
| | | let formVm; |
| | | for (let i in this.$refs) { |
| | | const vm = this.$refs[i]; |
| | | if (vm && vm.$options && vm.$options.name === 'uniForms') { |
| | | formVm = vm; |
| | | break; |
| | | } |
| | | } |
| | | if (!formVm) return console.error('å½å uni-froms ç»ä»¶ç¼ºå° ref 屿§'); |
| | | formVm.setValue(name, value); |
| | | } |
| | | } |
| | | } |
| | | // #endif |
| | | |
| | | // åæ¾watch ç嬿°ç» |
| | | this.unwatchs = []; |
| | | // åæ¾åç»ä»¶æ°ç» |
| | | this.childrens = []; |
| | | // åæ¾ easyInput ç»ä»¶ |
| | | this.inputChildrens = []; |
| | | // åæ¾ dataCheckbox ç»ä»¶ |
| | | this.checkboxChildrens = []; |
| | | // åæ¾è§å |
| | | this.formRules = []; |
| | | this.init(this.rules); |
| | | }, |
| | | // mounted() { |
| | | // this.init(this.rules) |
| | | // }, |
| | | methods: { |
| | | init(formRules) { |
| | | // 夿æ¯å¦æè§å |
| | | if (Object.keys(formRules).length === 0) { |
| | | this.formData = this.dataValue |
| | | return |
| | | }; |
| | | this.formRules = formRules; |
| | | this.validator = new Validator(formRules); |
| | | this.registerWatch(); |
| | | }, |
| | | // çå¬ watch |
| | | registerWatch() { |
| | | // åæ¶çå¬,é¿å
夿¬¡è°ç¨ init é夿§è¡ $watch |
| | | this.unwatchs.forEach(v => v()); |
| | | this.childrens.forEach((v) => { |
| | | v.init() |
| | | }) |
| | | // watch æ¯ä¸ªå±æ§ ï¼éè¦ç¥éå
·ä½é£ä¸ªå±æ§ååå |
| | | Object.keys(this.dataValue).forEach(key => { |
| | | let watch = this.$watch( |
| | | 'dataValue.' + key, |
| | | value => { |
| | | if (!value) return |
| | | // 妿æ¯å¯¹è±¡ ï¼åå¹³éºå
容 |
| | | if (value.toString() === '[object Object]') { |
| | | for (let i in value) { |
| | | let name = `${key}[${i}]`; |
| | | this.formData[name] = this._getValue(name, value[i]); |
| | | } |
| | | } else { |
| | | this.formData[key] = this._getValue(key, value); |
| | | } |
| | | }, |
| | | { |
| | | deep: true, |
| | | immediate: true |
| | | } |
| | | ); |
| | | this.unwatchs.push(watch); |
| | | }); |
| | | }, |
| | | /** |
| | | * å
¬å¼ç»ç¨æ·ä½¿ç¨ |
| | | * è®¾ç½®æ ¡éªè§å |
| | | * @param {Object} formRules |
| | | */ |
| | | setRules(formRules) { |
| | | this.init(formRules); |
| | | }, |
| | | /** |
| | | * å
¬å¼ç»ç¨æ·ä½¿ç¨ |
| | | * 设置èªå®ä¹è¡¨åç»ä»¶ value å¼ |
| | | * @param {String} name åæ®µåç§° |
| | | * @param {String} value åæ®µå¼ |
| | | */ |
| | | setValue(name, value, callback) { |
| | | let example = this.childrens.find(child => child.name === name); |
| | | if (!example) return null; |
| | | value = this._getValue(example.name, value); |
| | | this.formData[name] = value; |
| | | example.val = value; |
| | | return example.triggerCheck(value, callback); |
| | | }, |
| | | |
| | | /** |
| | | * 表åéç½® |
| | | * @param {Object} event |
| | | */ |
| | | resetForm(event) { |
| | | this.childrens.forEach(item => { |
| | | item.errMsg = ''; |
| | | const inputComp = this.inputChildrens.find(child => child.rename === item.name); |
| | | if (inputComp) { |
| | | inputComp.errMsg = ''; |
| | | // fix by mehaotian ä¸è§¦åå
¶ä»ç»ä»¶ç setValue |
| | | inputComp.is_reset = true |
| | | inputComp.$emit('input', inputComp.multiple ? [] : ''); |
| | | inputComp.$emit('update:modelValue', inputComp.multiple ? [] : ''); |
| | | } |
| | | }); |
| | | |
| | | this.childrens.forEach(item => { |
| | | if (item.name) { |
| | | this.formData[item.name] = this._getValue(item.name, ''); |
| | | } |
| | | }); |
| | | |
| | | this.$emit('reset', event); |
| | | }, |
| | | |
| | | /** |
| | | * 触åè¡¨åæ ¡éªï¼éè¿ @validate è·å |
| | | * @param {Object} validate |
| | | */ |
| | | validateCheck(validate) { |
| | | if (validate === null) validate = null; |
| | | this.$emit('validate', validate); |
| | | }, |
| | | /** |
| | | * æ ¡éªæææè
é¨å表å |
| | | */ |
| | | async validateAll(invalidFields, type, keepitem, callback) { |
| | | let childrens = [] |
| | | for (let i in invalidFields) { |
| | | const item = this.childrens.find(v => v.name === i) |
| | | if (item) { |
| | | childrens.push(item) |
| | | } |
| | | } |
| | | |
| | | if (!callback && typeof keepitem === 'function') { |
| | | callback = keepitem; |
| | | } |
| | | |
| | | let promise; |
| | | if (!callback && typeof callback !== 'function' && Promise) { |
| | | promise = new Promise((resolve, reject) => { |
| | | callback = function(valid, invalidFields) { |
| | | !valid ? resolve(invalidFields) : reject(valid); |
| | | }; |
| | | }); |
| | | } |
| | | |
| | | let results = []; |
| | | let newFormData = {}; |
| | | if (this.validator) { |
| | | for (let key in childrens) { |
| | | const child = childrens[key]; |
| | | let name = child.isArray ? child.arrayField : child.name; |
| | | if (child.isArray) { |
| | | if (child.name.indexOf('[') !== -1 && child.name.indexOf(']') !== -1) { |
| | | const fieldData = child.name.split('['); |
| | | const fieldName = fieldData[0]; |
| | | const fieldValue = fieldData[1].replace(']', ''); |
| | | if (!newFormData[fieldName]) { |
| | | newFormData[fieldName] = {}; |
| | | } |
| | | newFormData[fieldName][fieldValue] = this._getValue(name, invalidFields[name]); |
| | | } |
| | | } else { |
| | | newFormData[name] = this._getValue(name, invalidFields[name]); |
| | | } |
| | | const result = await child.triggerCheck(invalidFields[name], true); |
| | | if (result) { |
| | | results.push(result); |
| | | if (this.errShowType === 'toast' || this.errShowType === 'modal') break; |
| | | } |
| | | } |
| | | } else { |
| | | newFormData = invalidFields |
| | | } |
| | | if (Array.isArray(results)) { |
| | | if (results.length === 0) results = null; |
| | | } |
| | | |
| | | if (Array.isArray(keepitem)) { |
| | | keepitem.forEach(v => { |
| | | newFormData[v] = this.dataValue[v]; |
| | | }); |
| | | } |
| | | |
| | | if (type === 'submit') { |
| | | this.$emit('submit', { |
| | | detail: { |
| | | value: newFormData, |
| | | errors: results |
| | | } |
| | | }); |
| | | } else { |
| | | this.$emit('validate', results); |
| | | } |
| | | |
| | | callback && typeof callback === 'function' && callback(results, newFormData); |
| | | |
| | | if (promise && callback) { |
| | | return promise; |
| | | } else { |
| | | return null; |
| | | } |
| | | }, |
| | | submitForm() {}, |
| | | /** |
| | | * å¤é¨è°ç¨æ¹æ³ |
| | | * æå¨æäº¤æ ¡éªè¡¨å |
| | | * 对æ´ä¸ªè¡¨åè¿è¡æ ¡éªçæ¹æ³ï¼åæ°ä¸ºä¸ä¸ªåè°å½æ°ã |
| | | */ |
| | | submit(keepitem, callback, type) { |
| | | for (let i in this.dataValue) { |
| | | const itemData = this.childrens.find(v => v.name === i); |
| | | if (itemData) { |
| | | if (this.formData[i] === undefined) { |
| | | this.formData[i] = this._getValue(i, this.dataValue[i]); |
| | | } |
| | | } |
| | | } |
| | | if (!type) { |
| | | console.warn('submit æ¹æ³å³å°åºå¼ï¼è¯·ä½¿ç¨validateæ¹æ³ä»£æ¿ï¼'); |
| | | } |
| | | return this.validateAll(this.formData, 'submit', keepitem, callback); |
| | | }, |
| | | |
| | | /** |
| | | * å¤é¨è°ç¨æ¹æ³ |
| | | * æ ¡éªè¡¨å |
| | | * 对æ´ä¸ªè¡¨åè¿è¡æ ¡éªçæ¹æ³ï¼åæ°ä¸ºä¸ä¸ªåè°å½æ°ã |
| | | */ |
| | | validate(keepitem, callback) { |
| | | return this.submit(keepitem, callback, true); |
| | | }, |
| | | |
| | | /** |
| | | * é¨åè¡¨åæ ¡éª |
| | | * @param {Object} props |
| | | * @param {Object} cb |
| | | */ |
| | | validateField(props, callback) { |
| | | props = [].concat(props); |
| | | let invalidFields = {}; |
| | | this.childrens.forEach(item => { |
| | | if (props.indexOf(item.name) !== -1) { |
| | | invalidFields = Object.assign({}, invalidFields, { |
| | | [item.name]: this.formData[item.name] |
| | | }); |
| | | } |
| | | }); |
| | | return this.validateAll(invalidFields, 'submit', [], callback); |
| | | }, |
| | | |
| | | /** |
| | | * 对æ´ä¸ªè¡¨åè¿è¡éç½®ï¼å°ææå段å¼é置为åå§å¼å¹¶ç§»é¤æ ¡éªç»æ |
| | | */ |
| | | resetFields() { |
| | | this.resetForm(); |
| | | }, |
| | | |
| | | /** |
| | | * ç§»é¤è¡¨åé¡¹çæ ¡éªç»æãä¼ å
¥å¾
ç§»é¤ç表å项ç prop 屿§æè
prop ç»æçæ°ç»ï¼å¦ä¸ä¼ åç§»é¤æ´ä¸ªè¡¨åçæ ¡éªç»æ |
| | | */ |
| | | clearValidate(props) { |
| | | props = [].concat(props); |
| | | this.childrens.forEach(item => { |
| | | const inputComp = this.inputChildrens.find(child => child.rename === item.name); |
| | | if (props.length === 0) { |
| | | item.errMsg = ''; |
| | | if (inputComp) { |
| | | inputComp.errMsg = ''; |
| | | } |
| | | } else { |
| | | if (props.indexOf(item.name) !== -1) { |
| | | item.errMsg = ''; |
| | | if (inputComp) { |
| | | inputComp.errMsg = ''; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | /** |
| | | * æ value è½¬æ¢ææå®çç±»å |
| | | * @param {Object} key |
| | | * @param {Object} value |
| | | */ |
| | | _getValue(key, value) { |
| | | const rules = (this.formRules[key] && this.formRules[key].rules) || []; |
| | | const isRuleNum = rules.find(val => val.format && this.type_filter(val.format)); |
| | | const isRuleBool = rules.find(val => (val.format && val.format === 'boolean') || val.format === 'bool'); |
| | | // è¾å
¥å¼ä¸º number |
| | | if (isRuleNum) { |
| | | value = isNaN(value) ? value : value === '' || value === null ? null : Number(value); |
| | | } |
| | | // ç®å夿çåå¼ |
| | | if (isRuleBool) { |
| | | value = !value ? false : true; |
| | | } |
| | | return value; |
| | | }, |
| | | /** |
| | | * è¿æ»¤æ°åç±»å |
| | | * @param {Object} format |
| | | */ |
| | | type_filter(format) { |
| | | return format === 'int' || format === 'double' || format === 'number' || format === 'timestamp'; |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" > |
| | | .uni-forms { |
| | | // overflow: hidden; |
| | | // padding: 10px 15px; |
| | | } |
| | | |
| | | .uni-forms--top { |
| | | // padding: 10px 15px; |
| | | // padding-top: 22px; |
| | | } |
| | | </style> |
| New file |
| | |
| | | var pattern = { |
| | | email: /^\S+?@\S+?\.\S+?$/, |
| | | idcard: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, |
| | | url: new RegExp( |
| | | "^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$", |
| | | 'i') |
| | | }; |
| | | |
| | | const FORMAT_MAPPING = { |
| | | "int": 'integer', |
| | | "bool": 'boolean', |
| | | "double": 'number', |
| | | "long": 'number', |
| | | "password": 'string' |
| | | // "fileurls": 'array' |
| | | } |
| | | |
| | | function formatMessage(args, resources = '') { |
| | | var defaultMessage = ['label'] |
| | | defaultMessage.forEach((item) => { |
| | | if (args[item] === undefined) { |
| | | args[item] = '' |
| | | } |
| | | }) |
| | | |
| | | let str = resources |
| | | for (let key in args) { |
| | | let reg = new RegExp('{' + key + '}') |
| | | str = str.replace(reg, args[key]) |
| | | } |
| | | return str |
| | | } |
| | | |
| | | function isEmptyValue(value, type) { |
| | | if (value === undefined || value === null) { |
| | | return true; |
| | | } |
| | | |
| | | if (typeof value === 'string' && !value) { |
| | | return true; |
| | | } |
| | | |
| | | if (Array.isArray(value) && !value.length) { |
| | | return true; |
| | | } |
| | | |
| | | if (type === 'object' && !Object.keys(value).length) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | const types = { |
| | | integer(value) { |
| | | return types.number(value) && parseInt(value, 10) === value; |
| | | }, |
| | | string(value) { |
| | | return typeof value === 'string'; |
| | | }, |
| | | number(value) { |
| | | if (isNaN(value)) { |
| | | return false; |
| | | } |
| | | return typeof value === 'number'; |
| | | }, |
| | | "boolean": function(value) { |
| | | return typeof value === 'boolean'; |
| | | }, |
| | | "float": function(value) { |
| | | return types.number(value) && !types.integer(value); |
| | | }, |
| | | array(value) { |
| | | return Array.isArray(value); |
| | | }, |
| | | object(value) { |
| | | return typeof value === 'object' && !types.array(value); |
| | | }, |
| | | date(value) { |
| | | return value instanceof Date; |
| | | }, |
| | | timestamp(value) { |
| | | if (!this.integer(value) || Math.abs(value).toString().length > 16) { |
| | | return false |
| | | } |
| | | return true; |
| | | }, |
| | | file(value) { |
| | | return typeof value.url === 'string'; |
| | | }, |
| | | email(value) { |
| | | return typeof value === 'string' && !!value.match(pattern.email) && value.length < 255; |
| | | }, |
| | | url(value) { |
| | | return typeof value === 'string' && !!value.match(pattern.url); |
| | | }, |
| | | pattern(reg, value) { |
| | | try { |
| | | return new RegExp(reg).test(value); |
| | | } catch (e) { |
| | | return false; |
| | | } |
| | | }, |
| | | method(value) { |
| | | return typeof value === 'function'; |
| | | }, |
| | | idcard(value) { |
| | | return typeof value === 'string' && !!value.match(pattern.idcard); |
| | | }, |
| | | 'url-https'(value) { |
| | | return this.url(value) && value.startsWith('https://'); |
| | | }, |
| | | 'url-scheme'(value) { |
| | | return value.startsWith('://'); |
| | | }, |
| | | 'url-web'(value) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | class RuleValidator { |
| | | |
| | | constructor(message) { |
| | | this._message = message |
| | | } |
| | | |
| | | async validateRule(fieldKey, fieldValue, value, data, allData) { |
| | | var result = null |
| | | |
| | | let rules = fieldValue.rules |
| | | |
| | | let hasRequired = rules.findIndex((item) => { |
| | | return item.required |
| | | }) |
| | | if (hasRequired < 0) { |
| | | if (value === null || value === undefined) { |
| | | return result |
| | | } |
| | | if (typeof value === 'string' && !value.length) { |
| | | return result |
| | | } |
| | | } |
| | | |
| | | var message = this._message |
| | | |
| | | if (rules === undefined) { |
| | | return message['default'] |
| | | } |
| | | |
| | | for (var i = 0; i < rules.length; i++) { |
| | | let rule = rules[i] |
| | | let vt = this._getValidateType(rule) |
| | | |
| | | Object.assign(rule, { |
| | | label: fieldValue.label || `["${fieldKey}"]` |
| | | }) |
| | | |
| | | if (RuleValidatorHelper[vt]) { |
| | | result = RuleValidatorHelper[vt](rule, value, message) |
| | | if (result != null) { |
| | | break |
| | | } |
| | | } |
| | | |
| | | if (rule.validateExpr) { |
| | | let now = Date.now() |
| | | let resultExpr = rule.validateExpr(value, allData, now) |
| | | if (resultExpr === false) { |
| | | result = this._getMessage(rule, rule.errorMessage || this._message['default']) |
| | | break |
| | | } |
| | | } |
| | | |
| | | if (rule.validateFunction) { |
| | | result = await this.validateFunction(rule, value, data, allData, vt) |
| | | if (result !== null) { |
| | | break |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (result !== null) { |
| | | result = message.TAG + result |
| | | } |
| | | |
| | | return result |
| | | } |
| | | |
| | | async validateFunction(rule, value, data, allData, vt) { |
| | | let result = null |
| | | try { |
| | | let callbackMessage = null |
| | | const res = await rule.validateFunction(rule, value, allData || data, (message) => { |
| | | callbackMessage = message |
| | | }) |
| | | if (callbackMessage || (typeof res === 'string' && res) || res === false) { |
| | | result = this._getMessage(rule, callbackMessage || res, vt) |
| | | } |
| | | } catch (e) { |
| | | result = this._getMessage(rule, e.message, vt) |
| | | } |
| | | return result |
| | | } |
| | | |
| | | _getMessage(rule, message, vt) { |
| | | return formatMessage(rule, message || rule.errorMessage || this._message[vt] || message['default']) |
| | | } |
| | | |
| | | _getValidateType(rule) { |
| | | var result = '' |
| | | if (rule.required) { |
| | | result = 'required' |
| | | } else if (rule.format) { |
| | | result = 'format' |
| | | } else if (rule.arrayType) { |
| | | result = 'arrayTypeFormat' |
| | | } else if (rule.range) { |
| | | result = 'range' |
| | | } else if (rule.maximum !== undefined || rule.minimum !== undefined) { |
| | | result = 'rangeNumber' |
| | | } else if (rule.maxLength !== undefined || rule.minLength !== undefined) { |
| | | result = 'rangeLength' |
| | | } else if (rule.pattern) { |
| | | result = 'pattern' |
| | | } else if (rule.validateFunction) { |
| | | result = 'validateFunction' |
| | | } |
| | | return result |
| | | } |
| | | } |
| | | |
| | | const RuleValidatorHelper = { |
| | | required(rule, value, message) { |
| | | if (rule.required && isEmptyValue(value, rule.format || typeof value)) { |
| | | return formatMessage(rule, rule.errorMessage || message.required); |
| | | } |
| | | |
| | | return null |
| | | }, |
| | | |
| | | range(rule, value, message) { |
| | | const { |
| | | range, |
| | | errorMessage |
| | | } = rule; |
| | | |
| | | let list = new Array(range.length); |
| | | for (let i = 0; i < range.length; i++) { |
| | | const item = range[i]; |
| | | if (types.object(item) && item.value !== undefined) { |
| | | list[i] = item.value; |
| | | } else { |
| | | list[i] = item; |
| | | } |
| | | } |
| | | |
| | | let result = false |
| | | if (Array.isArray(value)) { |
| | | result = (new Set(value.concat(list)).size === list.length); |
| | | } else { |
| | | if (list.indexOf(value) > -1) { |
| | | result = true; |
| | | } |
| | | } |
| | | |
| | | if (!result) { |
| | | return formatMessage(rule, errorMessage || message['enum']); |
| | | } |
| | | |
| | | return null |
| | | }, |
| | | |
| | | rangeNumber(rule, value, message) { |
| | | if (!types.number(value)) { |
| | | return formatMessage(rule, rule.errorMessage || message.pattern.mismatch); |
| | | } |
| | | |
| | | let { |
| | | minimum, |
| | | maximum, |
| | | exclusiveMinimum, |
| | | exclusiveMaximum |
| | | } = rule; |
| | | let min = exclusiveMinimum ? value <= minimum : value < minimum; |
| | | let max = exclusiveMaximum ? value >= maximum : value > maximum; |
| | | |
| | | if (minimum !== undefined && min) { |
| | | return formatMessage(rule, rule.errorMessage || message['number'][exclusiveMinimum ? |
| | | 'exclusiveMinimum' : 'minimum' |
| | | ]) |
| | | } else if (maximum !== undefined && max) { |
| | | return formatMessage(rule, rule.errorMessage || message['number'][exclusiveMaximum ? |
| | | 'exclusiveMaximum' : 'maximum' |
| | | ]) |
| | | } else if (minimum !== undefined && maximum !== undefined && (min || max)) { |
| | | return formatMessage(rule, rule.errorMessage || message['number'].range) |
| | | } |
| | | |
| | | return null |
| | | }, |
| | | |
| | | rangeLength(rule, value, message) { |
| | | if (!types.string(value) && !types.array(value)) { |
| | | return formatMessage(rule, rule.errorMessage || message.pattern.mismatch); |
| | | } |
| | | |
| | | let min = rule.minLength; |
| | | let max = rule.maxLength; |
| | | let val = value.length; |
| | | |
| | | if (min !== undefined && val < min) { |
| | | return formatMessage(rule, rule.errorMessage || message['length'].minLength) |
| | | } else if (max !== undefined && val > max) { |
| | | return formatMessage(rule, rule.errorMessage || message['length'].maxLength) |
| | | } else if (min !== undefined && max !== undefined && (val < min || val > max)) { |
| | | return formatMessage(rule, rule.errorMessage || message['length'].range) |
| | | } |
| | | |
| | | return null |
| | | }, |
| | | |
| | | pattern(rule, value, message) { |
| | | if (!types['pattern'](rule.pattern, value)) { |
| | | return formatMessage(rule, rule.errorMessage || message.pattern.mismatch); |
| | | } |
| | | |
| | | return null |
| | | }, |
| | | |
| | | format(rule, value, message) { |
| | | var customTypes = Object.keys(types); |
| | | var format = FORMAT_MAPPING[rule.format] ? FORMAT_MAPPING[rule.format] : (rule.format || rule.arrayType); |
| | | |
| | | if (customTypes.indexOf(format) > -1) { |
| | | if (!types[format](value)) { |
| | | return formatMessage(rule, rule.errorMessage || message.typeError); |
| | | } |
| | | } |
| | | |
| | | return null |
| | | }, |
| | | |
| | | arrayTypeFormat(rule, value, message) { |
| | | if (!Array.isArray(value)) { |
| | | return formatMessage(rule, rule.errorMessage || message.typeError); |
| | | } |
| | | |
| | | for (let i = 0; i < value.length; i++) { |
| | | const element = value[i]; |
| | | let formatResult = this.format(rule, element, message) |
| | | if (formatResult !== null) { |
| | | return formatResult |
| | | } |
| | | } |
| | | |
| | | return null |
| | | } |
| | | } |
| | | |
| | | class SchemaValidator extends RuleValidator { |
| | | |
| | | constructor(schema, options) { |
| | | super(SchemaValidator.message); |
| | | |
| | | this._schema = schema |
| | | this._options = options || null |
| | | } |
| | | |
| | | updateSchema(schema) { |
| | | this._schema = schema |
| | | } |
| | | |
| | | async validate(data, allData) { |
| | | let result = this._checkFieldInSchema(data) |
| | | if (!result) { |
| | | result = await this.invokeValidate(data, false, allData) |
| | | } |
| | | return result.length ? result[0] : null |
| | | } |
| | | |
| | | async validateAll(data, allData) { |
| | | let result = this._checkFieldInSchema(data) |
| | | if (!result) { |
| | | result = await this.invokeValidate(data, true, allData) |
| | | } |
| | | return result |
| | | } |
| | | |
| | | async validateUpdate(data, allData) { |
| | | let result = this._checkFieldInSchema(data) |
| | | if (!result) { |
| | | result = await this.invokeValidateUpdate(data, false, allData) |
| | | } |
| | | return result.length ? result[0] : null |
| | | } |
| | | |
| | | async invokeValidate(data, all, allData) { |
| | | let result = [] |
| | | let schema = this._schema |
| | | for (let key in schema) { |
| | | let value = schema[key] |
| | | let errorMessage = await this.validateRule(key, value, data[key], data, allData) |
| | | if (errorMessage != null) { |
| | | result.push({ |
| | | key, |
| | | errorMessage |
| | | }) |
| | | if (!all) break |
| | | } |
| | | } |
| | | return result |
| | | } |
| | | |
| | | async invokeValidateUpdate(data, all, allData) { |
| | | let result = [] |
| | | for (let key in data) { |
| | | let errorMessage = await this.validateRule(key, this._schema[key], data[key], data, allData) |
| | | if (errorMessage != null) { |
| | | result.push({ |
| | | key, |
| | | errorMessage |
| | | }) |
| | | if (!all) break |
| | | } |
| | | } |
| | | return result |
| | | } |
| | | |
| | | _checkFieldInSchema(data) { |
| | | var keys = Object.keys(data) |
| | | var keys2 = Object.keys(this._schema) |
| | | if (new Set(keys.concat(keys2)).size === keys2.length) { |
| | | return '' |
| | | } |
| | | |
| | | var noExistFields = keys.filter((key) => { |
| | | return keys2.indexOf(key) < 0; |
| | | }) |
| | | var errorMessage = formatMessage({ |
| | | field: JSON.stringify(noExistFields) |
| | | }, SchemaValidator.message.TAG + SchemaValidator.message['defaultInvalid']) |
| | | return [{ |
| | | key: 'invalid', |
| | | errorMessage |
| | | }] |
| | | } |
| | | } |
| | | |
| | | function Message() { |
| | | return { |
| | | TAG: "", |
| | | default: 'éªè¯é误', |
| | | defaultInvalid: 'æäº¤çåæ®µ{field}卿°æ®åºä¸å¹¶ä¸åå¨', |
| | | validateFunction: 'éªè¯æ æ', |
| | | required: '{label}å¿
å¡«', |
| | | 'enum': '{label}è¶
åºèå´', |
| | | timestamp: '{label}æ ¼å¼æ æ', |
| | | whitespace: '{label}ä¸è½ä¸ºç©º', |
| | | typeError: '{label}ç±»åæ æ', |
| | | date: { |
| | | format: '{label}æ¥æ{value}æ ¼å¼æ æ', |
| | | parse: '{label}æ¥ææ æ³è§£æ,{value}æ æ', |
| | | invalid: '{label}æ¥æ{value}æ æ' |
| | | }, |
| | | length: { |
| | | minLength: '{label}é¿åº¦ä¸è½å°äº{minLength}', |
| | | maxLength: '{label}é¿åº¦ä¸è½è¶
è¿{maxLength}', |
| | | range: '{label}å¿
é¡»ä»äº{minLength}å{maxLength}ä¹é´' |
| | | }, |
| | | number: { |
| | | minimum: '{label}ä¸è½å°äº{minimum}', |
| | | maximum: '{label}ä¸è½å¤§äº{maximum}', |
| | | exclusiveMinimum: '{label}ä¸è½å°äºçäº{minimum}', |
| | | exclusiveMaximum: '{label}ä¸è½å¤§äºçäº{maximum}', |
| | | range: '{label}å¿
é¡»ä»äº{minimum}and{maximum}ä¹é´' |
| | | }, |
| | | pattern: { |
| | | mismatch: '{label}æ ¼å¼ä¸å¹é
' |
| | | } |
| | | }; |
| | | } |
| | | |
| | | |
| | | SchemaValidator.message = new Message(); |
| | | |
| | | export default SchemaValidator |
| New file |
| | |
| | | { |
| | | "id": "uni-forms", |
| | | "displayName": "uni-forms 表å", |
| | | "version": "1.3.2", |
| | | "description": "ç±è¾å
¥æ¡ãéæ©å¨ãåéæ¡ãå¤éæ¡çæ§ä»¶ç»æï¼ç¨ä»¥æ¶éãæ ¡éªãæäº¤æ°æ®", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "表å", |
| | | "æ ¡éª", |
| | | "è¡¨åæ ¡éª", |
| | | "表åéªè¯" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Forms 表å |
| | | |
| | | > **ç»ä»¶åï¼uni-forms** |
| | | > 代ç åï¼ `uForms`ã`uni-forms-item` |
| | | > å
³èç»ä»¶ï¼`uni-forms-item`ã`uni-easyinput`ã`uni-data-checkbox`ã`uni-group`ã |
| | | |
| | | |
| | | uni-appçå
ç½®ç»ä»¶å·²ç»æäº `<form>`ç»ä»¶ï¼ç¨äºæäº¤è¡¨åå
容ã |
| | | |
| | | ç¶èå 乿¯ä¸ªè¡¨åé½éè¦å表åéªè¯ï¼ä¸ºäºæ¹ä¾¿å表åéªè¯ï¼åå°éå¤å¼åï¼`uni ui` ååºäº `<form>`ç»ä»¶å°è£
äº `<uni-forms>`ç»ä»¶ï¼å
ç½®äºè¡¨åéªè¯åè½ã |
| | | |
| | | `<uni-forms>` æä¾äº `rules`屿§æ¥æè¿°æ ¡éªè§åã`<uni-forms-item>`åç»ä»¶æ¥å
裹å
·ä½ç表å项ï¼ä»¥åç»åçæä¸æ¹ç»ä»¶æä¾äº `binddata()` æ¥è®¾ç½®è¡¨åå¼ã |
| | | |
| | | æ¯ä¸ªè¦æ ¡éªç表å项ï¼ä¸ç®¡inputè¿æ¯checkboxï¼é½å¿
é¡»æ¾å¨`<uni-forms-item>`ç»ä»¶ä¸ï¼ä¸ä¸ä¸ª`<uni-forms-item>`ç»ä»¶åªè½æ¾ç½®ä¸ä¸ªè¡¨å项ã |
| | | |
| | | `<uni-forms-item>`ç»ä»¶å
é¨é¢çäºæ¾ç¤ºerror messageçåºåï¼é»è®¤æ¯å¨è¡¨å项çåºé¨ã |
| | | |
| | | å¦å¤ï¼`<uni-forms>`ç»ä»¶ä¸é¢çå个表å项ï¼å¯ä»¥éè¿`<uni-group>`å
裹为ä¸åçåç»ãåä¸`<uni-group>`ä¸çä¸å表å项ç®å°èæ¢å¨ä¸èµ·ï¼åå
¶ä»groupä¿æåç´é´è·ã`<uni-group>`ä»
å½±åè§è§ææã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-forms) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-goods-nav](https://uniapp.dcloud.io/component/uniui/uni-goods-nav) |
| | | ## 1.1.1ï¼2021-08-24ï¼ |
| | | - æ°å¢ æ¯æå½é
å |
| | | ## 1.1.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.0.7ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.6ï¼2021-04-21ï¼ |
| | | - ä¼å æ·»å ä¾èµ uni-icons, 导å
¥åèªå¨ä¸è½½ä¾èµ |
| | | ## 1.0.5ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | |
| | | ## 1.0.4ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | { |
| | | "uni-goods-nav.options.shop": "shop", |
| | | "uni-goods-nav.options.cart": "cart", |
| | | "uni-goods-nav.buttonGroup.addToCart": "add to cart", |
| | | "uni-goods-nav.buttonGroup.buyNow": "buy now" |
| | | } |
| New file |
| | |
| | | import en from './en.json' |
| | | import zhHans from './zh-Hans.json' |
| | | import zhHant from './zh-Hant.json' |
| | | export default { |
| | | en, |
| | | 'zh-Hans': zhHans, |
| | | 'zh-Hant': zhHant |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-goods-nav.options.shop": "åºéº", |
| | | "uni-goods-nav.options.cart": "è´ç©è½¦", |
| | | "uni-goods-nav.buttonGroup.addToCart": "å å
¥è´ç©è½¦", |
| | | "uni-goods-nav.buttonGroup.buyNow": "ç«å³è´ä¹°" |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-goods-nav.options.shop": "åºéª", |
| | | "uni-goods-nav.options.cart": "è³¼ç©è»", |
| | | "uni-goods-nav.buttonGroup.addToCart": "å å
¥è³¼ç©è»", |
| | | "uni-goods-nav.buttonGroup.buyNow": "ç«å³è³¼è²·" |
| | | } |
| New file |
| | |
| | | <template> |
| | | <view class="uni-goods-nav"> |
| | | <!-- åºé¨å ä½ --> |
| | | <view class="uni-tab__seat" /> |
| | | <view class="uni-tab__cart-box flex"> |
| | | <view class="flex uni-tab__cart-sub-left"> |
| | | <view v-for="(item,index) in options" :key="index" class="flex uni-tab__cart-button-left uni-tab__shop-cart" @click="onClick(index,item)"> |
| | | <view class="uni-tab__icon"> |
| | | <uni-icons :type="item.icon" size="20" color="#646566"></uni-icons> |
| | | <!-- <image class="image" :src="item.icon" mode="widthFix" /> --> |
| | | </view> |
| | | <text class="uni-tab__text">{{ item.text }}</text> |
| | | <view class="flex uni-tab__dot-box"> |
| | | <text v-if="item.info" :class="{ 'uni-tab__dots': item.info > 9 }" class="uni-tab__dot " :style="{'backgroundColor':item.infoBackgroundColor?item.infoBackgroundColor:'#ff0000', |
| | | color:item.infoColor?item.infoColor:'#fff' |
| | | }">{{ item.info }}</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view :class="{'uni-tab__right':fill}" class="flex uni-tab__cart-sub-right "> |
| | | <view v-for="(item,index) in buttonGroup" :key="index" :style="{background:item.backgroundColor,color:item.color}" |
| | | class="flex uni-tab__cart-button-right" @click="buttonClick(index,item)"><text :style="{color:item.color}" class="uni-tab__cart-button-right-text">{{ item.text }}</text></view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | initVueI18n |
| | | } from '@dcloudio/uni-i18n' |
| | | import messages from './i18n/index.js' |
| | | const { t } = initVueI18n(messages) |
| | | /** |
| | | * GoodsNav ååå¯¼èª |
| | | * @description ååå å
¥è´ç©è½¦ãç«å³è´ä¹°ç |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=865 |
| | | * @property {Array} options ç»ä»¶åæ° |
| | | * @property {Array} buttonGroup ç»ä»¶æé®ç»åæ° |
| | | * @property {Boolean} fill = [true | false] ç»ä»¶æé®ç»åæ° |
| | | * @event {Function} click 左侧ç¹å»äºä»¶ |
| | | * @event {Function} buttonClick å³ä¾§æé®ç»ç¹å»äºä»¶ |
| | | * @example <uni-goods-nav :fill="true" options="" buttonGroup="buttonGroup" @click="" @buttonClick="" /> |
| | | */ |
| | | export default { |
| | | name: 'UniGoodsNav', |
| | | emits:['click','buttonClick'], |
| | | props: { |
| | | options: { |
| | | type: Array, |
| | | default () { |
| | | return [{ |
| | | icon: 'shop', |
| | | text: t("uni-goods-nav.options.shop"), |
| | | }, { |
| | | icon: 'cart', |
| | | text: t("uni-goods-nav.options.cart") |
| | | }] |
| | | } |
| | | }, |
| | | buttonGroup: { |
| | | type: Array, |
| | | default () { |
| | | return [{ |
| | | text: t("uni-goods-nav.buttonGroup.addToCart"), |
| | | backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)', |
| | | color: '#fff' |
| | | }, |
| | | { |
| | | text: t("uni-goods-nav.buttonGroup.buyNow"), |
| | | backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)', |
| | | color: '#fff' |
| | | } |
| | | ] |
| | | } |
| | | }, |
| | | fill: { |
| | | type: Boolean, |
| | | default: false |
| | | } |
| | | }, |
| | | methods: { |
| | | onClick(index, item) { |
| | | this.$emit('click', { |
| | | index, |
| | | content: item, |
| | | }) |
| | | }, |
| | | buttonClick(index, item) { |
| | | if (uni.report) { |
| | | uni.report(item.text, item.text) |
| | | } |
| | | this.$emit('buttonClick', { |
| | | index, |
| | | content: item |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .flex { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | } |
| | | |
| | | .uni-goods-nav { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex: 1; |
| | | flex-direction: row; |
| | | } |
| | | |
| | | .uni-tab__cart-box { |
| | | flex: 1; |
| | | height: 50px; |
| | | background-color: #fff; |
| | | z-index: 900; |
| | | } |
| | | |
| | | .uni-tab__cart-sub-left { |
| | | padding: 0 5px; |
| | | } |
| | | |
| | | .uni-tab__cart-sub-right { |
| | | flex: 1; |
| | | } |
| | | |
| | | .uni-tab__right { |
| | | margin: 5px 0; |
| | | margin-right: 10px; |
| | | border-radius: 100px; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-tab__cart-button-left { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | // flex: 1; |
| | | position: relative; |
| | | justify-content: center; |
| | | align-items: center; |
| | | flex-direction: column; |
| | | margin: 0 10px; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-tab__icon { |
| | | width: 18px; |
| | | height: 18px; |
| | | } |
| | | |
| | | .image { |
| | | width: 18px; |
| | | height: 18px; |
| | | } |
| | | |
| | | .uni-tab__text { |
| | | margin-top: 3px; |
| | | font-size: 12px; |
| | | color: #646566; |
| | | } |
| | | |
| | | .uni-tab__cart-button-right { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | flex-direction: column; |
| | | /* #endif */ |
| | | flex: 1; |
| | | justify-content: center; |
| | | align-items: center; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-tab__cart-button-right-text { |
| | | font-size: 14px; |
| | | color: #fff; |
| | | } |
| | | |
| | | .uni-tab__cart-button-right:active { |
| | | opacity: 0.7; |
| | | } |
| | | |
| | | .uni-tab__dot-box { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | flex-direction: column; |
| | | /* #endif */ |
| | | position: absolute; |
| | | right: -2px; |
| | | top: 2px; |
| | | justify-content: center; |
| | | align-items: center; |
| | | // width: 0; |
| | | // height: 0; |
| | | } |
| | | |
| | | .uni-tab__dot { |
| | | // width: 30rpx; |
| | | // height: 30rpx; |
| | | padding: 0 4px; |
| | | line-height: 15px; |
| | | color: #ffffff; |
| | | text-align: center; |
| | | font-size: 12px; |
| | | background-color: #ff0000; |
| | | border-radius: 15px; |
| | | } |
| | | |
| | | .uni-tab__dots { |
| | | padding: 0 4px; |
| | | // width: auto; |
| | | border-radius: 15px; |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-goods-nav", |
| | | "displayName": "uni-goods-nav åå导èª", |
| | | "version": "1.2.0", |
| | | "description": "åå导èªç»ä»¶ä¸»è¦ç¨äºçµåç±»åºç¨åºé¨å¯¼èªï¼å¯èªå®ä¹å å
¥è´ç©è½¦ï¼è´ä¹°çæä½", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "åå导èª" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## GoodsNav ååå¯¼èª |
| | | > **ç»ä»¶åï¼uni-goods-nav** |
| | | > 代ç åï¼ `uGoodsNav` |
| | | |
| | | ååå å
¥è´ç©è½¦ï¼ç«å³è´ä¹°çã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-goods-nav) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.4.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-grid](https://uniapp.dcloud.io/component/uniui/uni-grid) |
| | | ## 1.3.2ï¼2021-11-09ï¼ |
| | | - æ°å¢ æä¾ç»ä»¶è®¾è®¡èµæºï¼ç»ä»¶æ ·å¼è°æ´ |
| | | ## 1.3.1ï¼2021-07-30ï¼ |
| | | - ä¼å vue3ä¸äºä»¶è¦åçé®é¢ |
| | | ## 1.3.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.2.4ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.2.3ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | <template> |
| | | <view v-if="width" :style="'width:'+width+';'+(square?'height:'+width:'')" class="uni-grid-item"> |
| | | <view :class="{ 'uni-grid-item--border': showBorder, 'uni-grid-item--border-top': showBorder && index < column, 'uni-highlight': highlight }" |
| | | :style="{'border-right-color': borderColor ,'border-bottom-color': borderColor ,'border-top-color': borderColor }" |
| | | class="uni-grid-item__box" @click="_onClick"> |
| | | <slot /> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * GridItem å®«æ ¼ |
| | | * @description å®«æ ¼ç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=27 |
| | | * @property {Number} index åç»ä»¶çå¯ä¸æ è¯ ï¼ç¹å»girdä¼è¿åå½åçæ è¯ |
| | | */ |
| | | export default { |
| | | name: 'UniGridItem', |
| | | inject: ['grid'], |
| | | props: { |
| | | index: { |
| | | type: Number, |
| | | default: 0 |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | column: 0, |
| | | showBorder: true, |
| | | square: true, |
| | | highlight: true, |
| | | left: 0, |
| | | top: 0, |
| | | openNum: 2, |
| | | width: 0, |
| | | borderColor: '#e5e5e5' |
| | | } |
| | | }, |
| | | created() { |
| | | this.column = this.grid.column |
| | | this.showBorder = this.grid.showBorder |
| | | this.square = this.grid.square |
| | | this.highlight = this.grid.highlight |
| | | this.top = this.hor === 0 ? this.grid.hor : this.hor |
| | | this.left = this.ver === 0 ? this.grid.ver : this.ver |
| | | this.borderColor = this.grid.borderColor |
| | | this.grid.children.push(this) |
| | | // this.grid.init() |
| | | this.width = this.grid.width |
| | | }, |
| | | beforeDestroy() { |
| | | this.grid.children.forEach((item, index) => { |
| | | if (item === this) { |
| | | this.grid.children.splice(index, 1) |
| | | } |
| | | }) |
| | | }, |
| | | methods: { |
| | | _onClick() { |
| | | this.grid.change({ |
| | | detail: { |
| | | index: this.index |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .uni-grid-item { |
| | | /* #ifndef APP-NVUE */ |
| | | height: 100%; |
| | | display: flex; |
| | | /* #endif */ |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-grid-item__box { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | width: 100%; |
| | | /* #endif */ |
| | | position: relative; |
| | | flex: 1; |
| | | flex-direction: column; |
| | | // justify-content: center; |
| | | // align-items: center; |
| | | } |
| | | |
| | | .uni-grid-item--border { |
| | | position: relative; |
| | | /* #ifdef APP-NVUE */ |
| | | border-bottom-color: #D2D2D2; |
| | | border-bottom-style: solid; |
| | | border-bottom-width: 0.5px; |
| | | border-right-color: #D2D2D2; |
| | | border-right-style: solid; |
| | | border-right-width: 0.5px; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | z-index: 0; |
| | | border-bottom: 1px #D2D2D2 solid; |
| | | border-right: 1px #D2D2D2 solid; |
| | | /* #endif */ |
| | | } |
| | | .uni-grid-item--border-top { |
| | | position: relative; |
| | | /* #ifdef APP-NVUE */ |
| | | border-top-color: #D2D2D2; |
| | | border-top-style: solid; |
| | | border-top-width: 0.5px; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | border-top: 1px #D2D2D2 solid; |
| | | z-index: 0; |
| | | /* #endif */ |
| | | } |
| | | |
| | | |
| | | .uni-highlight:active { |
| | | background-color: #f1f1f1; |
| | | } |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view class="uni-grid-wrap"> |
| | | <view :id="elId" ref="uni-grid" class="uni-grid" :class="{ 'uni-grid--border': showBorder }" :style="{ 'border-left-color':borderColor}"> |
| | | <slot /> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | // #ifdef APP-NVUE |
| | | const dom = uni.requireNativePlugin('dom'); |
| | | // #endif |
| | | |
| | | /** |
| | | * Grid å®«æ ¼ |
| | | * @description å®«æ ¼ç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=27 |
| | | * @property {Number} column æ¯åæ¾ç¤ºä¸ªæ° |
| | | * @property {String} borderColor è¾¹æ¡é¢è² |
| | | * @property {Boolean} showBorder æ¯å¦æ¾ç¤ºè¾¹æ¡ |
| | | * @property {Boolean} square æ¯å¦æ¹å½¢æ¾ç¤º |
| | | * @property {Boolean} Boolean ç¹å»èæ¯æ¯å¦é«äº® |
| | | * @event {Function} change ç¹å» grid 触åï¼e={detail:{index:0}}ï¼index 为å½åç¹å» gird 䏿 |
| | | */ |
| | | export default { |
| | | name: 'UniGrid', |
| | | emits:['change'], |
| | | props: { |
| | | // æ¯åæ¾ç¤ºä¸ªæ° |
| | | column: { |
| | | type: Number, |
| | | default: 3 |
| | | }, |
| | | // æ¯å¦æ¾ç¤ºè¾¹æ¡ |
| | | showBorder: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | // è¾¹æ¡é¢è² |
| | | borderColor: { |
| | | type: String, |
| | | default: '#D2D2D2' |
| | | }, |
| | | // æ¯å¦æ£æ¹å½¢æ¾ç¤º,é»è®¤ä¸º true |
| | | square: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | highlight: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | provide() { |
| | | return { |
| | | grid: this |
| | | } |
| | | }, |
| | | data() { |
| | | const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}` |
| | | return { |
| | | elId, |
| | | width: 0 |
| | | } |
| | | }, |
| | | created() { |
| | | this.children = [] |
| | | }, |
| | | mounted() { |
| | | this.$nextTick(()=>{ |
| | | this.init() |
| | | }) |
| | | }, |
| | | methods: { |
| | | init() { |
| | | setTimeout(() => { |
| | | this._getSize((width) => { |
| | | this.children.forEach((item, index) => { |
| | | item.width = width |
| | | }) |
| | | }) |
| | | }, 50) |
| | | }, |
| | | change(e) { |
| | | this.$emit('change', e) |
| | | }, |
| | | _getSize(fn) { |
| | | // #ifndef APP-NVUE |
| | | uni.createSelectorQuery() |
| | | .in(this) |
| | | .select(`#${this.elId}`) |
| | | .boundingClientRect() |
| | | .exec(ret => { |
| | | this.width = parseInt((ret[0].width - 1) / this.column) + 'px' |
| | | fn(this.width) |
| | | }) |
| | | // #endif |
| | | // #ifdef APP-NVUE |
| | | dom.getComponentRect(this.$refs['uni-grid'], (ret) => { |
| | | this.width = parseInt((ret.size.width - 1) / this.column) + 'px' |
| | | fn(this.width) |
| | | }) |
| | | // #endif |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .uni-grid-wrap { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex: 1; |
| | | flex-direction: column; |
| | | /* #ifdef H5 */ |
| | | width: 100%; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-grid { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | // flex: 1; |
| | | flex-direction: row; |
| | | flex-wrap: wrap; |
| | | } |
| | | |
| | | .uni-grid--border { |
| | | position: relative; |
| | | /* #ifdef APP-NVUE */ |
| | | border-left-color: #D2D2D2; |
| | | border-left-style: solid; |
| | | border-left-width: 0.5px; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | z-index: 1; |
| | | border-left: 1px #D2D2D2 solid; |
| | | /* #endif */ |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-grid", |
| | | "displayName": "uni-grid å®«æ ¼", |
| | | "version": "1.4.0", |
| | | "description": "Grid å®«æ ¼ç»ä»¶ï¼æä¾ç§»å¨ç«¯å¸¸è§çå®«æ ¼å¸å±ï¼å¦ä¹å®«æ ¼ã", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "ä¹å®«æ ¼", |
| | | "è¡¨æ ¼" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-scss","uni-icons"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Grid å®«æ ¼ |
| | | > **ç»ä»¶åï¼uni-grid** |
| | | > 代ç åï¼ `uGrid` |
| | | |
| | | |
| | | å®«æ ¼ç»ä»¶ã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-grid) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.2.1ï¼2021-11-22ï¼ |
| | | - ä¿®å¤ vue3䏿äºscssåéæ æ³æ¾å°çé®é¢ |
| | | ## 1.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-indexed-list](https://uniapp.dcloud.io/component/uniui/uni-indexed-list) |
| | | ## 1.1.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.0.11ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.10ï¼2021-04-21ï¼ |
| | | - ä¼å æ·»å ä¾èµ uni-icons, 导å
¥åèªå¨ä¸è½½ä¾èµ |
| | | ## 1.0.9ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | |
| | | ## 1.0.8ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| | | - æ°å¢ æ¯æ PC 端 |
| New file |
| | |
| | | <template> |
| | | <view> |
| | | <view v-if="loaded || list.itemIndex < 15" class="uni-indexed-list__title-wrapper"> |
| | | <text v-if="list.items && list.items.length > 0" class="uni-indexed-list__title">{{ list.key }}</text> |
| | | </view> |
| | | <view v-if="(loaded || list.itemIndex < 15) && list.items && list.items.length > 0" class="uni-indexed-list__list"> |
| | | <view v-for="(item, index) in list.items" :key="index" class="uni-indexed-list__item" hover-class="uni-indexed-list__item--hover"> |
| | | <view class="uni-indexed-list__item-container" @click="onClick(idx, index)"> |
| | | <view class="uni-indexed-list__item-border" :class="{'uni-indexed-list__item-border--last':index===list.items.length-1}"> |
| | | <view v-if="showSelect" style="margin-right: 20rpx;"> |
| | | <uni-icons :type="item.checked ? 'checkbox-filled' : 'circle'" :color="item.checked ? '#007aff' : '#C0C0C0'" size="24" /> |
| | | </view> |
| | | <text class="uni-indexed-list__item-content">{{ item.name }}</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: 'UniIndexedList', |
| | | emits:['itemClick'], |
| | | props: { |
| | | loaded: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | idx: { |
| | | type: Number, |
| | | default: 0 |
| | | }, |
| | | list: { |
| | | type: Object, |
| | | default () { |
| | | return {} |
| | | } |
| | | }, |
| | | showSelect: { |
| | | type: Boolean, |
| | | default: false |
| | | } |
| | | }, |
| | | methods: { |
| | | onClick(idx, index) { |
| | | this.$emit("itemClick", { |
| | | idx, |
| | | index |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .uni-indexed-list__list { |
| | | background-color: $uni-bg-color; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | border-top-style: solid; |
| | | border-top-width: 1px; |
| | | border-top-color: #DEDEDE; |
| | | } |
| | | |
| | | .uni-indexed-list__item { |
| | | font-size: 14px; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex: 1; |
| | | flex-direction: row; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | } |
| | | |
| | | .uni-indexed-list__item-container { |
| | | padding-left: 15px; |
| | | flex: 1; |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-indexed-list__item-border { |
| | | flex: 1; |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | height: 50px; |
| | | padding: 25px; |
| | | padding-left: 0; |
| | | border-bottom-style: solid; |
| | | border-bottom-width: 1px; |
| | | border-bottom-color: #DEDEDE; |
| | | } |
| | | |
| | | .uni-indexed-list__item-border--last { |
| | | border-bottom-width: 0px; |
| | | } |
| | | |
| | | .uni-indexed-list__item-content { |
| | | flex: 1; |
| | | font-size: 14px; |
| | | color: #191919; |
| | | } |
| | | |
| | | .uni-indexed-list { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | } |
| | | |
| | | .uni-indexed-list__title-wrapper { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | width: 100%; |
| | | /* #endif */ |
| | | background-color: #f7f7f7; |
| | | } |
| | | |
| | | .uni-indexed-list__title { |
| | | padding: 6px 12px; |
| | | line-height: 24px; |
| | | font-size: 16px; |
| | | font-weight: 500; |
| | | } |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view class="uni-indexed-list" ref="list" id="list"> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <list class="uni-indexed-list__scroll" scrollable="true" show-scrollbar="false"> |
| | | <cell v-for="(list, idx) in lists" :key="idx" :ref="'uni-indexed-list-' + idx"> |
| | | <!-- #endif --> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <scroll-view :scroll-into-view="scrollViewId" class="uni-indexed-list__scroll" scroll-y> |
| | | <view v-for="(list, idx) in lists" :key="idx" :id="'uni-indexed-list-' + idx"> |
| | | <!-- #endif --> |
| | | <indexed-list-item :list="list" :loaded="loaded" :idx="idx" :showSelect="showSelect" |
| | | @itemClick="onClick"></indexed-list-item> |
| | | <!-- #ifndef APP-NVUE --> |
| | | </view> |
| | | </scroll-view> |
| | | <!-- #endif --> |
| | | <!-- #ifdef APP-NVUE --> |
| | | </cell> |
| | | </list> |
| | | <!-- #endif --> |
| | | <view class="uni-indexed-list__menu" @touchstart="touchStart" @touchmove.stop.prevent="touchMove" |
| | | @touchend="touchEnd" @mousedown.stop="mousedown" @mousemove.stop.prevent="mousemove" |
| | | @mouseleave.stop="mouseleave"> |
| | | <view v-for="(list, key) in lists" :key="key" class="uni-indexed-list__menu-item" |
| | | :class="touchmoveIndex == key ? 'uni-indexed-list__menu--active' : ''"> |
| | | <text class="uni-indexed-list__menu-text" |
| | | :class="touchmoveIndex == key ? 'uni-indexed-list__menu-text--active' : ''">{{ list.key }}</text> |
| | | </view> |
| | | </view> |
| | | <view v-if="touchmove" class="uni-indexed-list__alert-wrapper"> |
| | | <text class="uni-indexed-list__alert">{{ lists[touchmoveIndex].key }}</text> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | <script> |
| | | import indexedListItem from './uni-indexed-list-item.vue' |
| | | // #ifdef APP-NVUE |
| | | const dom = weex.requireModule('dom'); |
| | | // #endif |
| | | // #ifdef APP-PLUS |
| | | function throttle(func, delay) { |
| | | var prev = Date.now(); |
| | | return function() { |
| | | var context = this; |
| | | var args = arguments; |
| | | var now = Date.now(); |
| | | if (now - prev >= delay) { |
| | | func.apply(context, args); |
| | | prev = Date.now(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | function touchMove(e) { |
| | | let pageY = e.touches[0].pageY |
| | | let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight) |
| | | if (this.touchmoveIndex === index) { |
| | | return false |
| | | } |
| | | let item = this.lists[index] |
| | | if (item) { |
| | | // #ifndef APP-NVUE |
| | | this.scrollViewId = 'uni-indexed-list-' + index |
| | | this.touchmoveIndex = index |
| | | // #endif |
| | | // #ifdef APP-NVUE |
| | | dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], { |
| | | animated: false |
| | | }) |
| | | this.touchmoveIndex = index |
| | | // #endif |
| | | } |
| | | } |
| | | const throttleTouchMove = throttle(touchMove, 40) |
| | | // #endif |
| | | |
| | | /** |
| | | * IndexedList ç´¢å¼å表 |
| | | * @description ç¨äºå±ç¤ºç´¢å¼å表 |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=375 |
| | | * @property {Boolean} showSelect = [true|false] å±ç¤ºæ¨¡å¼ |
| | | * @value true å±ç¤ºæ¨¡å¼ |
| | | * @value false éæ©æ¨¡å¼ |
| | | * @property {Object} options ç´¢å¼å表éè¦çæ°æ®å¯¹è±¡ |
| | | * @event {Function} click ç¹å»å表äºä»¶ ï¼è¿åå½å鿩项çäºä»¶å¯¹è±¡ |
| | | * @example <uni-indexed-list options="" showSelect="false" @click=""></uni-indexed-list> |
| | | */ |
| | | export default { |
| | | name: 'UniIndexedList', |
| | | components: { |
| | | indexedListItem |
| | | }, |
| | | emits: ['click'], |
| | | props: { |
| | | options: { |
| | | type: Array, |
| | | default () { |
| | | return [] |
| | | } |
| | | }, |
| | | showSelect: { |
| | | type: Boolean, |
| | | default: false |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | lists: [], |
| | | winHeight: 0, |
| | | itemHeight: 0, |
| | | winOffsetY: 0, |
| | | touchmove: false, |
| | | touchmoveIndex: -1, |
| | | scrollViewId: '', |
| | | touchmovable: true, |
| | | loaded: false, |
| | | isPC: false |
| | | } |
| | | }, |
| | | watch: { |
| | | options: { |
| | | handler: function() { |
| | | this.setList() |
| | | }, |
| | | deep: true |
| | | } |
| | | }, |
| | | mounted() { |
| | | // #ifdef H5 |
| | | this.isPC = this.IsPC() |
| | | // #endif |
| | | setTimeout(() => { |
| | | this.setList() |
| | | }, 50) |
| | | setTimeout(() => { |
| | | this.loaded = true |
| | | }, 300); |
| | | }, |
| | | methods: { |
| | | setList() { |
| | | let index = 0; |
| | | this.lists = [] |
| | | this.options.forEach((value, index) => { |
| | | if (value.data.length === 0) { |
| | | return |
| | | } |
| | | let indexBefore = index |
| | | let items = value.data.map(item => { |
| | | let obj = {} |
| | | obj['key'] = value.letter |
| | | obj['name'] = item |
| | | obj['itemIndex'] = index |
| | | index++ |
| | | obj.checked = item.checked ? item.checked : false |
| | | return obj |
| | | }) |
| | | this.lists.push({ |
| | | title: value.letter, |
| | | key: value.letter, |
| | | items: items, |
| | | itemIndex: indexBefore |
| | | }) |
| | | }) |
| | | // #ifndef APP-NVUE |
| | | uni.createSelectorQuery() |
| | | .in(this) |
| | | .select('#list') |
| | | .boundingClientRect() |
| | | .exec(ret => { |
| | | this.winOffsetY = ret[0].top |
| | | this.winHeight = ret[0].height |
| | | this.itemHeight = this.winHeight / this.lists.length |
| | | }) |
| | | // #endif |
| | | // #ifdef APP-NVUE |
| | | dom.getComponentRect(this.$refs['list'], (res) => { |
| | | this.winOffsetY = res.size.top |
| | | this.winHeight = res.size.height |
| | | this.itemHeight = this.winHeight / this.lists.length |
| | | }) |
| | | // #endif |
| | | }, |
| | | touchStart(e) { |
| | | this.touchmove = true |
| | | let pageY = this.isPC ? e.pageY : e.touches[0].pageY |
| | | let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight) |
| | | let item = this.lists[index] |
| | | if (item) { |
| | | this.scrollViewId = 'uni-indexed-list-' + index |
| | | this.touchmoveIndex = index |
| | | // #ifdef APP-NVUE |
| | | dom.scrollToElement(this.$refs['uni-indexed-list-' + index][0], { |
| | | animated: false |
| | | }) |
| | | // #endif |
| | | } |
| | | }, |
| | | touchMove(e) { |
| | | // #ifndef APP-PLUS |
| | | let pageY = this.isPC ? e.pageY : e.touches[0].pageY |
| | | let index = Math.floor((pageY - this.winOffsetY) / this.itemHeight) |
| | | if (this.touchmoveIndex === index) { |
| | | return false |
| | | } |
| | | let item = this.lists[index] |
| | | if (item) { |
| | | this.scrollViewId = 'uni-indexed-list-' + index |
| | | this.touchmoveIndex = index |
| | | } |
| | | // #endif |
| | | // #ifdef APP-PLUS |
| | | throttleTouchMove.call(this, e) |
| | | // #endif |
| | | }, |
| | | touchEnd() { |
| | | this.touchmove = false |
| | | // this.touchmoveIndex = -1 |
| | | }, |
| | | |
| | | /** |
| | | * å
¼å®¹ PC @tian |
| | | */ |
| | | |
| | | mousedown(e) { |
| | | if (!this.isPC) return |
| | | this.touchStart(e) |
| | | }, |
| | | mousemove(e) { |
| | | if (!this.isPC) return |
| | | this.touchMove(e) |
| | | }, |
| | | mouseleave(e) { |
| | | if (!this.isPC) return |
| | | this.touchEnd(e) |
| | | }, |
| | | |
| | | // #ifdef H5 |
| | | IsPC() { |
| | | var userAgentInfo = navigator.userAgent; |
| | | var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; |
| | | var flag = true; |
| | | for (let v = 0; v < Agents.length - 1; v++) { |
| | | if (userAgentInfo.indexOf(Agents[v]) > 0) { |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | return flag; |
| | | }, |
| | | // #endif |
| | | |
| | | |
| | | onClick(e) { |
| | | let { |
| | | idx, |
| | | index |
| | | } = e |
| | | let obj = {} |
| | | for (let key in this.lists[idx].items[index]) { |
| | | obj[key] = this.lists[idx].items[index][key] |
| | | } |
| | | let select = [] |
| | | if (this.showSelect) { |
| | | this.lists[idx].items[index].checked = !this.lists[idx].items[index].checked |
| | | this.lists.forEach((value, idx) => { |
| | | value.items.forEach((item, index) => { |
| | | if (item.checked) { |
| | | let obj = {} |
| | | for (let key in this.lists[idx].items[index]) { |
| | | obj[key] = this.lists[idx].items[index][key] |
| | | } |
| | | select.push(obj) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | this.$emit('click', { |
| | | item: obj, |
| | | select: select |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | .uni-indexed-list { |
| | | position: absolute; |
| | | left: 0; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | } |
| | | |
| | | .uni-indexed-list__scroll { |
| | | flex: 1; |
| | | } |
| | | |
| | | .uni-indexed-list__menu { |
| | | width: 24px; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | } |
| | | |
| | | .uni-indexed-list__menu-item { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex: 1; |
| | | align-items: center; |
| | | justify-content: center; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-indexed-list__menu-text { |
| | | font-size: 12px; |
| | | text-align: center; |
| | | color: #aaa; |
| | | } |
| | | |
| | | .uni-indexed-list__menu--active { |
| | | // background-color: rgb(200, 200, 200); |
| | | } |
| | | |
| | | .uni-indexed-list__menu--active {} |
| | | |
| | | .uni-indexed-list__menu-text--active { |
| | | border-radius: 16px; |
| | | width: 16px; |
| | | height: 16px; |
| | | line-height: 16px; |
| | | background-color: #007aff; |
| | | color: #fff; |
| | | } |
| | | |
| | | .uni-indexed-list__alert-wrapper { |
| | | position: absolute; |
| | | left: 0; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .uni-indexed-list__alert { |
| | | width: 80px; |
| | | height: 80px; |
| | | border-radius: 80px; |
| | | text-align: center; |
| | | line-height: 80px; |
| | | font-size: 35px; |
| | | color: #fff; |
| | | background-color: rgba(0, 0, 0, 0.5); |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-indexed-list", |
| | | "displayName": "uni-indexed-list ç´¢å¼å表", |
| | | "version": "1.2.1", |
| | | "description": "ç´¢å¼å表ç»ä»¶ï¼å³ä¾§å¸¦ç´¢å¼çåè¡¨ï¼æ¹ä¾¿å¿«éå®ä½å°å
·ä½å
容ï¼é常ç¨äºåå¸/æºåºéæ©çåºæ¯", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "ç´¢å¼å表", |
| | | "ç´¢å¼", |
| | | "å表" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## IndexedList ç´¢å¼å表 |
| | | > **ç»ä»¶åï¼uni-indexed-list** |
| | | > 代ç åï¼ `uIndexedList` |
| | | |
| | | |
| | | ç¨äºå±ç¤ºç´¢å¼å表ã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-indexed-list) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.0.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-link](https://uniapp.dcloud.io/component/uniui/uni-link) |
| | | ## 1.1.7ï¼2021-11-08ï¼ |
| | | ## 0.0.7ï¼2021-09-03ï¼ |
| | | - ä¿®å¤ å¨ nvue ä¸ä¸æ¾ç¤ºç bug |
| | | ## 0.0.6ï¼2021-07-30ï¼ |
| | | - æ°å¢ æ¯æèªå®ä¹ææ§½ |
| | | ## 0.0.5ï¼2021-06-21ï¼ |
| | | - æ°å¢ download 屿§ï¼H5å¹³å°ä¸è½½æä»¶å |
| | | ## 0.0.4ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 0.0.3ï¼2021-03-09ï¼ |
| | | - æ°å¢ href 屿§æ¯æ tel:|mailto: |
| | | |
| | | ## 0.0.2ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | <template> |
| | | <a v-if="isShowA" class="uni-link" :href="href" |
| | | :class="{'uni-link--withline':showUnderLine===true||showUnderLine==='true'}" |
| | | :style="{color,fontSize:fontSize+'px'}" :download="download"> |
| | | <slot>{{text}}</slot> |
| | | </a> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <text v-else class="uni-link" :class="{'uni-link--withline':showUnderLine===true||showUnderLine==='true'}" |
| | | :style="{color,fontSize:fontSize+'px'}" @click="openURL"> |
| | | <slot>{{text}}</slot> |
| | | </text> |
| | | <!-- #endif --> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <text v-else class="uni-link" :class="{'uni-link--withline':showUnderLine===true||showUnderLine==='true'}" |
| | | :style="{color,fontSize:fontSize+'px'}" @click="openURL"> |
| | | {{text}} |
| | | </text> |
| | | <!-- #endif --> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * Link å¤é¨ç½é¡µè¶
龿¥ç»ä»¶ |
| | | * @description uni-linkæ¯ä¸ä¸ªå¤é¨ç½é¡µè¶
龿¥ç»ä»¶ï¼å¨å°ç¨åºå
å¤å¶urlï¼å¨appå
æå¼å¤é¨æµè§å¨ï¼å¨h5端æå¼æ°ç½é¡µ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=1182 |
| | | * @property {String} href ç¹å»åæå¼çå¤é¨ç½é¡µurl |
| | | * @property {String} text æ¾ç¤ºçæå |
| | | * @property {String} downlaod H5å¹³å°ä¸è½½æä»¶å |
| | | * @property {Boolean} showUnderLine æ¯å¦æ¾ç¤ºä¸å线 |
| | | * @property {String} copyTips å¨å°ç¨åºç«¯å¤å¶é¾æ¥æ¶æ¾ç¤ºçæç¤ºè¯ |
| | | * @property {String} color 龿¥æåé¢è² |
| | | * @property {String} fontSize 龿¥æåå¤§å° |
| | | * @example * <uni-link href="https://ext.dcloud.net.cn" text="https://ext.dcloud.net.cn"></uni-link> |
| | | */ |
| | | export default { |
| | | name: 'uniLink', |
| | | props: { |
| | | href: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | text: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | download: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | showUnderLine: { |
| | | type: [Boolean, String], |
| | | default: true |
| | | }, |
| | | copyTips: { |
| | | type: String, |
| | | default: 'å·²èªå¨å¤å¶ç½åï¼è¯·å¨ææºæµè§å¨éç²è´´è¯¥ç½å' |
| | | }, |
| | | color: { |
| | | type: String, |
| | | default: '#999999' |
| | | }, |
| | | fontSize: { |
| | | type: [Number, String], |
| | | default: 14 |
| | | } |
| | | }, |
| | | computed: { |
| | | isShowA() { |
| | | // #ifdef H5 |
| | | this._isH5 = true; |
| | | // #endif |
| | | if ((this.isMail() || this.isTel()) && this._isH5 === true) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | }, |
| | | created() { |
| | | this._isH5 = null; |
| | | }, |
| | | methods: { |
| | | isMail() { |
| | | return this.href.startsWith('mailto:'); |
| | | }, |
| | | isTel() { |
| | | return this.href.startsWith('tel:'); |
| | | }, |
| | | openURL() { |
| | | // #ifdef APP-PLUS |
| | | if (this.isTel()) { |
| | | this.makePhoneCall(this.href.replace('tel:', '')); |
| | | } else { |
| | | plus.runtime.openURL(this.href); |
| | | } |
| | | // #endif |
| | | // #ifdef H5 |
| | | window.open(this.href) |
| | | // #endif |
| | | // #ifdef MP |
| | | uni.setClipboardData({ |
| | | data: this.href |
| | | }); |
| | | uni.showModal({ |
| | | content: this.copyTips, |
| | | showCancel: false |
| | | }); |
| | | // #endif |
| | | }, |
| | | makePhoneCall(phoneNumber) { |
| | | uni.makePhoneCall({ |
| | | phoneNumber |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | /* #ifndef APP-NVUE */ |
| | | .uni-link { |
| | | cursor: pointer; |
| | | } |
| | | |
| | | /* #endif */ |
| | | .uni-link--withline { |
| | | text-decoration: underline; |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-link", |
| | | "displayName": "uni-link è¶
龿¥", |
| | | "version": "1.0.0", |
| | | "description": "uni-linkæ¯ä¸ä¸ªå¤é¨ç½é¡µè¶
龿¥ç»ä»¶ï¼å¨å°ç¨åºå
å¤å¶urlï¼å¨appå
æå¼å¤é¨æµè§å¨ï¼å¨h5端æ", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "link", |
| | | "è¶
龿¥", |
| | | "" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-scss"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "y", |
| | | "èç": "y" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Link 龿¥ |
| | | > **ç»ä»¶åï¼uni-link** |
| | | > 代ç åï¼ `uLink` |
| | | |
| | | |
| | | uni-linkæ¯ä¸ä¸ªå¤é¨ç½é¡µè¶
龿¥ç»ä»¶ï¼å¨å°ç¨åºå
å¤å¶urlï¼å¨appå
æå¼å¤é¨æµè§å¨ï¼å¨h5端æå¼æ°ç½é¡µã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-link) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.2.0ï¼2021-11-23ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-list](https://uniapp.dcloud.io/component/uniui/uni-list) |
| | | ## 1.1.3ï¼2021-08-30ï¼ |
| | | - ä¿®å¤ å¨vue3ä¸to屿§å¨åè¡åºç¨çæ¶åæ¥éçbug |
| | | ## 1.1.2ï¼2021-07-30ï¼ |
| | | - ä¼å vue3ä¸äºä»¶è¦åçé®é¢ |
| | | ## 1.1.1ï¼2021-07-21ï¼ |
| | | - ä¿®å¤ ä¸å
¶ä»ç»ä»¶åµå¥ä½¿ç¨æ¶ï¼ç¹å»å¤±æçBug |
| | | ## 1.1.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.0.17ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.16ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | ## 1.0.15ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| | | - ä¿®å¤ uni-list-chat è§æ æ¾ç¤ºä¸æ£å¸¸çé®é¢ |
| New file |
| | |
| | | <template> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <cell> |
| | | <!-- #endif --> |
| | | <view class="uni-list-ad"> |
| | | <view v-if="borderShow" :class="{'uni-list--border':border,'uni-list-item--first':isFirstChild}"></view> |
| | | <ad style="width: 200px;height: 300px;border-width: 1px;border-color: red;border-style: solid;" adpid="1111111111" |
| | | unit-id="" appid="" apid="" type="feed" @error="aderror" @close="closeAd"></ad> |
| | | </view> |
| | | <!-- #ifdef APP-NVUE --> |
| | | </cell> |
| | | <!-- #endif --> |
| | | |
| | | </template> |
| | | |
| | | <script> |
| | | // #ifdef APP-NVUE |
| | | const dom = uni.requireNativePlugin('dom'); |
| | | // #endif |
| | | export default { |
| | | name: 'UniListAd', |
| | | props: { |
| | | title: { |
| | | type: String, |
| | | default: '', |
| | | |
| | | } |
| | | }, |
| | | // inject: ['list'], |
| | | data() { |
| | | return { |
| | | isFirstChild: false, |
| | | border: false, |
| | | borderShow: true, |
| | | } |
| | | }, |
| | | |
| | | mounted() { |
| | | this.list = this.getForm() |
| | | if (this.list) { |
| | | if (!this.list.firstChildAppend) { |
| | | this.list.firstChildAppend = true |
| | | this.isFirstChild = true |
| | | } |
| | | this.border = this.list.border |
| | | } |
| | | }, |
| | | methods: { |
| | | /** |
| | | * è·åç¶å
ç´ å®ä¾ |
| | | */ |
| | | getForm(name = 'uniList') { |
| | | let parent = this.$parent; |
| | | let parentName = parent.$options.name; |
| | | while (parentName !== name) { |
| | | parent = parent.$parent; |
| | | if (!parent) return false |
| | | parentName = parent.$options.name; |
| | | } |
| | | return parent; |
| | | }, |
| | | aderror(e) { |
| | | console.log("aderror: " + JSON.stringify(e.detail)); |
| | | }, |
| | | closeAd(e) { |
| | | this.borderShow = false |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .uni-list-ad { |
| | | position: relative; |
| | | border: 1px red solid; |
| | | } |
| | | |
| | | .uni-list--border { |
| | | position: relative; |
| | | padding-bottom: 1px; |
| | | /* #ifdef APP-PLUS */ |
| | | border-top-color: $uni-border-color; |
| | | border-top-style: solid; |
| | | border-top-width: 0.5px; |
| | | /* #endif */ |
| | | margin-left: $uni-spacing-row-lg; |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | .uni-list--border:after { |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | left: 0; |
| | | height: 1px; |
| | | content: ''; |
| | | -webkit-transform: scaleY(.5); |
| | | transform: scaleY(.5); |
| | | background-color: $uni-border-color; |
| | | } |
| | | |
| | | .uni-list-item--first:after { |
| | | height: 0px; |
| | | } |
| | | |
| | | /* #endif */ |
| | | </style> |
| New file |
| | |
| | | /** |
| | | * è¿éæ¯ uni-list ç»ä»¶å
ç½®çå¸¸ç¨æ ·å¼åé |
| | | * 妿éè¦è¦çæ ·å¼ï¼è¿éæä¾äºåºæ¬çç»ä»¶æ ·å¼åéï¼æ¨å¯ä»¥å°è¯ä¿®æ¹è¿éçåéï¼å»å®ææ ·å¼æ¿æ¢ï¼èä¸ç¨å»ä¿®æ¹æºç |
| | | * |
| | | */ |
| | | |
| | | // èæ¯è² |
| | | $background-color : #fff; |
| | | // åå²çº¿é¢è² |
| | | $divide-line-color : #e5e5e5; |
| | | |
| | | // é»è®¤å¤´å大å°ï¼å¦éè¦ä¿®æ¹æ¤å¼ï¼æ³¨æåæ¥ä¿®æ¹ js ä¸çå¼ const avatarWidth = xx ï¼ç®ååªæ¯ææ¹å½¢å¤´å |
| | | // nvue 页é¢ä¸æ¯æä¿®æ¹å¤´åå¤§å° |
| | | $avatar-width : 45px ; |
| | | |
| | | // 头åè¾¹æ¡ |
| | | $avatar-border-radius: 5px; |
| | | $avatar-border-color: #eee; |
| | | $avatar-border-width: 1px; |
| | | |
| | | // æ é¢æåæ ·å¼ |
| | | $title-size : 16px; |
| | | $title-color : #3b4144; |
| | | $title-weight : normal; |
| | | |
| | | // æè¿°æåæ ·å¼ |
| | | $note-size : 12px; |
| | | $note-color : #999; |
| | | $note-weight : normal; |
| | | |
| | | // å³ä¾§é¢å¤å
容é»è®¤æ ·å¼ |
| | | $right-text-size : 12px; |
| | | $right-text-color : #999; |
| | | $right-text-weight : normal; |
| | | |
| | | // è§æ æ ·å¼ |
| | | // nvue 页é¢ä¸æ¯æä¿®æ¹åç¹ä½ç½®ä»¥åå¤§å° |
| | | // è§æ å¨å·¦ä¾§æ¶ï¼è§æ çä½ç½®ï¼é»è®¤ä¸º 0 ï¼è´æ°å·¦/ä¸ç§»å¨ï¼æ£æ°å³/ä¸ç§»å¨ |
| | | $badge-left: 0px; |
| | | $badge-top: 0px; |
| | | |
| | | // æ¾ç¤ºåç¹æ¶ï¼åç¹å¤§å° |
| | | $dot-width: 10px; |
| | | $dot-height: 10px; |
| | | |
| | | // æ¾ç¤ºè§æ æ¶ï¼è§æ 大å°ååä½å¤§å° |
| | | $badge-size : 18px; |
| | | $badge-font : 12px; |
| | | // æ¾ç¤ºè§æ æ¶ï¼è§æ åæ¯è² |
| | | $badge-color : #fff; |
| | | // æ¾ç¤ºè§æ æ¶ï¼è§æ èæ¯è² |
| | | $badge-background-color : #ff5a5f; |
| | | // æ¾ç¤ºè§æ æ¶ï¼è§æ å·¦å³é´è· |
| | | $badge-space : 6px; |
| | | |
| | | // ç¶ææ ·å¼ |
| | | // éä¸é¢è² |
| | | $hover : #f5f5f5; |
| New file |
| | |
| | | <template> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <cell> |
| | | <!-- #endif --> |
| | | <view :hover-class="!clickable && !link ? '' : 'uni-list-chat--hover'" class="uni-list-chat" @click.stop="onClick"> |
| | | <view :class="{ 'uni-list--border': border, 'uni-list-chat--first': isFirstChild }"></view> |
| | | <view class="uni-list-chat__container"> |
| | | <view class="uni-list-chat__header-warp"> |
| | | <view v-if="avatarCircle || avatarList.length === 0" class="uni-list-chat__header" :class="{ 'header--circle': avatarCircle }"> |
| | | <image class="uni-list-chat__header-image" :src="avatar" mode="aspectFill"></image> |
| | | </view> |
| | | <!-- 头åç» --> |
| | | <view v-else class="uni-list-chat__header"> |
| | | <view v-for="(item, index) in avatarList" :key="index" class="uni-list-chat__header-box" :class="computedAvatar" |
| | | :style="{ width: imageWidth + 'px', height: imageWidth + 'px' }"> |
| | | <image class="uni-list-chat__header-image" :style="{ width: imageWidth + 'px', height: imageWidth + 'px' }" :src="item.url" |
| | | mode="aspectFill"></image> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view v-if="badgeText && badgePositon === 'left'" class="uni-list-chat__badge uni-list-chat__badge-pos" :class="[isSingle]"> |
| | | <text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text> |
| | | </view> |
| | | <view class="uni-list-chat__content"> |
| | | <view class="uni-list-chat__content-main"> |
| | | <text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text> |
| | | <text class="uni-list-chat__content-note uni-ellipsis">{{ note }}</text> |
| | | </view> |
| | | <view class="uni-list-chat__content-extra"> |
| | | <slot> |
| | | <text class="uni-list-chat__content-extra-text">{{ time }}</text> |
| | | <view v-if="badgeText && badgePositon === 'right'" class="uni-list-chat__badge" :class="[isSingle, badgePositon === 'right' ? 'uni-list-chat--right' : '']"> |
| | | <text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text> |
| | | </view> |
| | | </slot> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <!-- #ifdef APP-NVUE --> |
| | | </cell> |
| | | <!-- #endif --> |
| | | </template> |
| | | |
| | | <script> |
| | | // 头åå¤§å° |
| | | const avatarWidth = 45; |
| | | |
| | | /** |
| | | * ListChat è天å表 |
| | | * @description è天å表,ç¨äºå建è天类å表 |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=24 |
| | | * @property {String} title æ é¢ |
| | | * @property {String} note æè¿° |
| | | * @property {Boolean} clickable = [true|false] æ¯å¦å¼å¯ç¹å»åé¦ï¼é»è®¤ä¸ºfalse |
| | | * @property {String} badgeText æ°åè§æ å
容 |
| | | * @property {String} badgePositon = [left|right] è§æ ä½ç½®ï¼é»è®¤ä¸º right |
| | | * @property {String} link = [falseï½navigateTo|redirectTo|reLaunch|switchTab] æ¯å¦å±ç¤ºå³ä¾§ç®å¤´å¹¶å¼å¯ç¹å»åé¦ï¼é»è®¤ä¸ºfalse |
| | | * @value false ä¸å¼å¯ |
| | | * @value navigateTo å uni.navigateTo() |
| | | * @value redirectTo å uni.redirectTo() |
| | | * @value reLaunch å uni.reLaunch() |
| | | * @value switchTab å uni.switchTab() |
| | | * @property {String | PageURIString} to è·³è½¬ç®æ é¡µé¢ |
| | | * @property {String} time å³ä¾§æ¶é´æ¾ç¤º |
| | | * @property {Boolean} avatarCircle = [true|false] æ¯å¦æ¾ç¤ºå形头åï¼é»è®¤ä¸ºfalse |
| | | * @property {String} avatar 头åå°åï¼avatarCircle ä¸å¡«æ¶çæ |
| | | * @property {Array} avatarList 头åç»ï¼æ ¼å¼ä¸º [{url:''}] |
| | | * @event {Function} click ç¹å» uniListChat 触åäºä»¶ |
| | | */ |
| | | export default { |
| | | name: 'UniListChat', |
| | | emits:['click'], |
| | | props: { |
| | | title: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | note: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | clickable: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | link: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | to: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | badgeText: { |
| | | type: [String, Number], |
| | | default: '' |
| | | }, |
| | | badgePositon: { |
| | | type: String, |
| | | default: 'right' |
| | | }, |
| | | time: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | avatarCircle: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | avatar: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | avatarList: { |
| | | type: Array, |
| | | default () { |
| | | return []; |
| | | } |
| | | } |
| | | }, |
| | | // inject: ['list'], |
| | | computed: { |
| | | isSingle() { |
| | | if (this.badgeText === 'dot') { |
| | | return 'uni-badge--dot'; |
| | | } else { |
| | | const badgeText = this.badgeText.toString(); |
| | | if (badgeText.length > 1) { |
| | | return 'uni-badge--complex'; |
| | | } else { |
| | | return 'uni-badge--single'; |
| | | } |
| | | } |
| | | }, |
| | | computedAvatar() { |
| | | if (this.avatarList.length > 4) { |
| | | this.imageWidth = avatarWidth * 0.31; |
| | | return 'avatarItem--3'; |
| | | } else if (this.avatarList.length > 1) { |
| | | this.imageWidth = avatarWidth * 0.47; |
| | | return 'avatarItem--2'; |
| | | } else { |
| | | this.imageWidth = avatarWidth; |
| | | return 'avatarItem--1'; |
| | | } |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | isFirstChild: false, |
| | | border: true, |
| | | // avatarList: 3, |
| | | imageWidth: 50 |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.list = this.getForm() |
| | | if (this.list) { |
| | | if (!this.list.firstChildAppend) { |
| | | this.list.firstChildAppend = true; |
| | | this.isFirstChild = true; |
| | | } |
| | | this.border = this.list.border; |
| | | } |
| | | }, |
| | | methods: { |
| | | /** |
| | | * è·åç¶å
ç´ å®ä¾ |
| | | */ |
| | | getForm(name = 'uniList') { |
| | | let parent = this.$parent; |
| | | let parentName = parent.$options.name; |
| | | while (parentName !== name) { |
| | | parent = parent.$parent; |
| | | if (!parent) return false |
| | | parentName = parent.$options.name; |
| | | } |
| | | return parent; |
| | | }, |
| | | onClick() { |
| | | if (this.to !== '') { |
| | | this.openPage(); |
| | | return; |
| | | } |
| | | |
| | | if (this.clickable || this.link) { |
| | | this.$emit('click', { |
| | | data: {} |
| | | }); |
| | | } |
| | | }, |
| | | openPage() { |
| | | if (['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'].indexOf(this.link) !== -1) { |
| | | this.pageApi(this.link); |
| | | } else { |
| | | this.pageApi('navigateTo'); |
| | | } |
| | | }, |
| | | pageApi(api) { |
| | | uni[api]({ |
| | | url: this.to, |
| | | success: res => { |
| | | this.$emit('click', { |
| | | data: res |
| | | }); |
| | | }, |
| | | fail: err => { |
| | | this.$emit('click', { |
| | | data: err |
| | | }); |
| | | console.error(err.errMsg); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | $uni-font-size-lg:16px; |
| | | $uni-spacing-row-sm: 5px; |
| | | $uni-spacing-row-base: 10px; |
| | | $uni-spacing-row-lg: 15px; |
| | | $background-color: #fff; |
| | | $divide-line-color: #e5e5e5; |
| | | $avatar-width: 45px; |
| | | $avatar-border-radius: 5px; |
| | | $avatar-border-color: #eee; |
| | | $avatar-border-width: 1px; |
| | | $title-size: 16px; |
| | | $title-color: #3b4144; |
| | | $title-weight: normal; |
| | | $note-size: 12px; |
| | | $note-color: #999; |
| | | $note-weight: normal; |
| | | $right-text-size: 12px; |
| | | $right-text-color: #999; |
| | | $right-text-weight: normal; |
| | | $badge-left: 0px; |
| | | $badge-top: 0px; |
| | | $dot-width: 10px; |
| | | $dot-height: 10px; |
| | | $badge-size: 18px; |
| | | $badge-font: 12px; |
| | | $badge-color: #fff; |
| | | $badge-background-color: #ff5a5f; |
| | | $badge-space: 6px; |
| | | $hover: #f5f5f5; |
| | | |
| | | .uni-list-chat { |
| | | font-size: $uni-font-size-lg; |
| | | position: relative; |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | | background-color: $background-color; |
| | | } |
| | | |
| | | // .uni-list-chat--disabled { |
| | | // opacity: 0.3; |
| | | // } |
| | | |
| | | .uni-list-chat--hover { |
| | | background-color: $hover; |
| | | } |
| | | |
| | | .uni-list--border { |
| | | position: relative; |
| | | margin-left: $uni-spacing-row-lg; |
| | | /* #ifdef APP-PLUS */ |
| | | border-top-color: $divide-line-color; |
| | | border-top-style: solid; |
| | | border-top-width: 0.5px; |
| | | /* #endif */ |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | .uni-list--border:after { |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | left: 0; |
| | | height: 1px; |
| | | content: ''; |
| | | -webkit-transform: scaleY(0.5); |
| | | transform: scaleY(0.5); |
| | | background-color: $divide-line-color; |
| | | } |
| | | |
| | | .uni-list-item--first:after { |
| | | height: 0px; |
| | | } |
| | | |
| | | /* #endif */ |
| | | |
| | | .uni-list-chat--first { |
| | | border-top-width: 0px; |
| | | } |
| | | |
| | | .uni-ellipsis { |
| | | /* #ifndef APP-NVUE */ |
| | | overflow: hidden; |
| | | white-space: nowrap; |
| | | text-overflow: ellipsis; |
| | | /* #endif */ |
| | | /* #ifdef APP-NVUE */ |
| | | lines: 1; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-ellipsis-2 { |
| | | /* #ifndef APP-NVUE */ |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | display: -webkit-box; |
| | | -webkit-line-clamp: 2; |
| | | -webkit-box-orient: vertical; |
| | | /* #endif */ |
| | | |
| | | /* #ifdef APP-NVUE */ |
| | | lines: 2; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-list-chat__container { |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | flex: 1; |
| | | padding: $uni-spacing-row-base $uni-spacing-row-lg; |
| | | position: relative; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-list-chat__header-warp { |
| | | position: relative; |
| | | } |
| | | |
| | | .uni-list-chat__header { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | align-content: center; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | justify-content: center; |
| | | align-items: center; |
| | | flex-wrap: wrap-reverse; |
| | | /* #ifdef APP-NVUE */ |
| | | width: 50px; |
| | | height: 50px; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | width: $avatar-width; |
| | | height: $avatar-width; |
| | | /* #endif */ |
| | | |
| | | border-radius: $avatar-border-radius; |
| | | border-color: $avatar-border-color; |
| | | border-width: $avatar-border-width; |
| | | border-style: solid; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-list-chat__header-box { |
| | | /* #ifndef APP-PLUS */ |
| | | box-sizing: border-box; |
| | | display: flex; |
| | | width: $avatar-width; |
| | | height: $avatar-width; |
| | | /* #endif */ |
| | | /* #ifdef APP-NVUE */ |
| | | width: 50px; |
| | | height: 50px; |
| | | /* #endif */ |
| | | overflow: hidden; |
| | | border-radius: 2px; |
| | | } |
| | | |
| | | .uni-list-chat__header-image { |
| | | margin: 1px; |
| | | /* #ifdef APP-NVUE */ |
| | | width: 50px; |
| | | height: 50px; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | width: $avatar-width; |
| | | height: $avatar-width; |
| | | /* #endif */ |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | .uni-list-chat__header-image { |
| | | display: block; |
| | | width: 100%; |
| | | height: 100%; |
| | | } |
| | | |
| | | .avatarItem--1 { |
| | | width: 100%; |
| | | height: 100%; |
| | | } |
| | | |
| | | .avatarItem--2 { |
| | | width: 47%; |
| | | height: 47%; |
| | | } |
| | | |
| | | .avatarItem--3 { |
| | | width: 32%; |
| | | height: 32%; |
| | | } |
| | | |
| | | /* #endif */ |
| | | .header--circle { |
| | | border-radius: 50%; |
| | | } |
| | | |
| | | .uni-list-chat__content { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | flex: 1; |
| | | overflow: hidden; |
| | | padding: 2px 0; |
| | | } |
| | | |
| | | .uni-list-chat__content-main { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | | padding-left: $uni-spacing-row-base; |
| | | flex: 1; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-list-chat__content-title { |
| | | font-size: $title-size; |
| | | color: $title-color; |
| | | font-weight: $title-weight; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-list-chat__content-note { |
| | | margin-top: 3px; |
| | | color: $note-color; |
| | | font-size: $note-size; |
| | | font-weight: $title-weight; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-list-chat__content-extra { |
| | | /* #ifndef APP-NVUE */ |
| | | flex-shrink: 0; |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | | align-items: flex-end; |
| | | margin-left: 5px; |
| | | } |
| | | |
| | | .uni-list-chat__content-extra-text { |
| | | color: $right-text-color; |
| | | font-size: $right-text-size; |
| | | font-weight: $right-text-weight; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-list-chat__badge-pos { |
| | | position: absolute; |
| | | /* #ifdef APP-NVUE */ |
| | | left: 55px; |
| | | top: 3px; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | left: calc(#{$avatar-width} + 10px - #{$badge-space} + #{$badge-left}); |
| | | top: calc(#{$uni-spacing-row-base}/ 2 + 1px + #{$badge-top}); |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-list-chat__badge { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | justify-content: center; |
| | | align-items: center; |
| | | border-radius: 100px; |
| | | background-color: $badge-background-color; |
| | | } |
| | | |
| | | .uni-list-chat__badge-text { |
| | | color: $badge-color; |
| | | font-size: $badge-font; |
| | | } |
| | | |
| | | .uni-badge--single { |
| | | /* #ifndef APP-NVUE */ |
| | | // left: calc(#{$avatar-width} + 7px + #{$badge-left}); |
| | | /* #endif */ |
| | | width: $badge-size; |
| | | height: $badge-size; |
| | | } |
| | | |
| | | .uni-badge--complex { |
| | | /* #ifdef APP-NVUE */ |
| | | left: 50px; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | width: auto; |
| | | /* #endif */ |
| | | height: $badge-size; |
| | | padding: 0 $badge-space; |
| | | } |
| | | |
| | | .uni-badge--dot { |
| | | /* #ifdef APP-NVUE */ |
| | | left: 60px; |
| | | top: 6px; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | left: calc(#{$avatar-width} + 15px - #{$dot-width}/ 2 + 1px + #{$badge-left}); |
| | | /* #endif */ |
| | | width: $dot-width; |
| | | height: $dot-height; |
| | | padding: 0; |
| | | } |
| | | |
| | | .uni-list-chat--right { |
| | | /* #ifdef APP-NVUE */ |
| | | left: 0; |
| | | /* #endif */ |
| | | } |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <cell> |
| | | <!-- #endif --> |
| | | |
| | | <view :class="{ 'uni-list-item--disabled': disabled }" |
| | | :hover-class="(!clickable && !link) || disabled || showSwitch ? '' : 'uni-list-item--hover'" |
| | | class="uni-list-item" @click="onClick"> |
| | | <view v-if="!isFirstChild" class="border--left" :class="{ 'uni-list--border': border }"></view> |
| | | <view class="uni-list-item__container" |
| | | :class="{ 'container--right': showArrow || link, 'flex--direction': direction === 'column' }"> |
| | | <slot name="header"> |
| | | <view class="uni-list-item__header"> |
| | | <view v-if="thumb" class="uni-list-item__icon"> |
| | | <image :src="thumb" class="uni-list-item__icon-img" :class="['uni-list--' + thumbSize]" /> |
| | | </view> |
| | | <view v-else-if="showExtraIcon" class="uni-list-item__icon"> |
| | | <uni-icons :color="extraIcon.color" :size="extraIcon.size" :type="extraIcon.type" /> |
| | | </view> |
| | | </view> |
| | | </slot> |
| | | <slot name="body"> |
| | | <view class="uni-list-item__content" |
| | | :class="{ 'uni-list-item__content--center': thumb || showExtraIcon || showBadge || showSwitch }"> |
| | | <text v-if="title" class="uni-list-item__content-title" |
| | | :class="[ellipsis !== 0 && ellipsis <= 2 ? 'uni-ellipsis-' + ellipsis : '']">{{ title }}</text> |
| | | <text v-if="note" class="uni-list-item__content-note">{{ note }}</text> |
| | | </view> |
| | | </slot> |
| | | <slot name="footer"> |
| | | <view v-if="rightText || showBadge || showSwitch" class="uni-list-item__extra" |
| | | :class="{ 'flex--justify': direction === 'column' }"> |
| | | <text v-if="rightText" class="uni-list-item__extra-text">{{ rightText }}</text> |
| | | <uni-badge v-if="showBadge" :type="badgeType" :text="badgeText" /> |
| | | <switch v-if="showSwitch" :disabled="disabled" :checked="switchChecked" |
| | | @change="onSwitchChange" /> |
| | | </view> |
| | | </slot> |
| | | </view> |
| | | <uni-icons v-if="showArrow || link" :size="16" class="uni-icon-wrapper" color="#bbb" type="arrowright" /> |
| | | </view> |
| | | <!-- #ifdef APP-NVUE --> |
| | | </cell> |
| | | <!-- #endif --> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * ListItem å表åç»ä»¶ |
| | | * @description å表åç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=24 |
| | | * @property {String} title æ é¢ |
| | | * @property {String} note æè¿° |
| | | * @property {String} thumb 左侧缩ç¥å¾ï¼è¥thumbæå¼ï¼åä¸ä¼æ¾ç¤ºæ©å±å¾æ |
| | | * @property {String} thumbSize = [lg|base|sm] ç¥ç¼©å¾å¤§å° |
| | | * @value lg å¤§å¾ |
| | | * @value base ä¸è¬ |
| | | * @value sm å°å¾ |
| | | * @property {String} badgeText æ°åè§æ å
容 |
| | | * @property {String} badgeType æ°åè§æ ç±»åï¼åè[uni-icons](https://ext.dcloud.net.cn/plugin?id=21) |
| | | * @property {String} rightText å³ä¾§æåå
容 |
| | | * @property {Boolean} disabled = [true|false] æ¯å¦ç¦ç¨ |
| | | * @property {Boolean} clickable = [true|false] æ¯å¦å¼å¯ç¹å»åé¦ |
| | | * @property {String} link = [navigateTo|redirectTo|reLaunch|switchTab] æ¯å¦å±ç¤ºå³ä¾§ç®å¤´å¹¶å¼å¯ç¹å»åé¦ |
| | | * @value navigateTo å uni.navigateTo() |
| | | * @value redirectTo å uni.redirectTo() |
| | | * @value reLaunch å uni.reLaunch() |
| | | * @value switchTab å uni.switchTab() |
| | | * @property {String | PageURIString} to è·³è½¬ç®æ é¡µé¢ |
| | | * @property {Boolean} showBadge = [true|false] æ¯å¦æ¾ç¤ºæ°åè§æ |
| | | * @property {Boolean} showSwitch = [true|false] æ¯å¦æ¾ç¤ºSwitch |
| | | * @property {Boolean} switchChecked = [true|false] Switchæ¯å¦è¢«éä¸ |
| | | * @property {Boolean} showExtraIcon = [true|false] 左侧æ¯å¦æ¾ç¤ºæ©å±å¾æ |
| | | * @property {Object} extraIcon æ©å±å¾æ åæ°ï¼æ ¼å¼ä¸º {color: '#4cd964',size: '22',type: 'spinner'} |
| | | * @property {String} direction = [row|column] æçæ¹å |
| | | * @value row æ°´å¹³æå |
| | | * @value column åç´æå |
| | | * @event {Function} click ç¹å» uniListItem 触åäºä»¶ |
| | | * @event {Function} switchChange ç¹å»åæ¢ Switch æ¶è§¦å |
| | | */ |
| | | export default { |
| | | name: 'UniListItem', |
| | | emits: ['click', 'switchChange'], |
| | | props: { |
| | | direction: { |
| | | type: String, |
| | | default: 'row' |
| | | }, |
| | | title: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | note: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | ellipsis: { |
| | | type: [Number,String], |
| | | default: 0 |
| | | }, |
| | | disabled: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | clickable: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | showArrow: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | link: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | to: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | showBadge: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | showSwitch: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | switchChecked: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | badgeText: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | badgeType: { |
| | | type: String, |
| | | default: 'success' |
| | | }, |
| | | rightText: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | thumb: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | thumbSize: { |
| | | type: String, |
| | | default: 'base' |
| | | }, |
| | | showExtraIcon: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | extraIcon: { |
| | | type: Object, |
| | | default () { |
| | | return { |
| | | type: 'contact', |
| | | color: '#000000', |
| | | size: 20 |
| | | }; |
| | | } |
| | | }, |
| | | border: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | // inject: ['list'], |
| | | data() { |
| | | return { |
| | | isFirstChild: false |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.list = this.getForm() |
| | | // 夿æ¯å¦åå¨ uni-list ç»ä»¶ |
| | | if (this.list) { |
| | | if (!this.list.firstChildAppend) { |
| | | this.list.firstChildAppend = true; |
| | | this.isFirstChild = true; |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | /** |
| | | * è·åç¶å
ç´ å®ä¾ |
| | | */ |
| | | getForm(name = 'uniList') { |
| | | let parent = this.$parent; |
| | | let parentName = parent.$options.name; |
| | | while (parentName !== name) { |
| | | parent = parent.$parent; |
| | | if (!parent) return false |
| | | parentName = parent.$options.name; |
| | | } |
| | | return parent; |
| | | }, |
| | | onClick() { |
| | | if (this.to !== '') { |
| | | this.openPage(); |
| | | return; |
| | | } |
| | | if (this.clickable || this.link) { |
| | | this.$emit('click', { |
| | | data: {} |
| | | }); |
| | | } |
| | | }, |
| | | onSwitchChange(e) { |
| | | this.$emit('switchChange', e.detail); |
| | | }, |
| | | openPage() { |
| | | if (['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'].indexOf(this.link) !== -1) { |
| | | this.pageApi(this.link); |
| | | } else { |
| | | this.pageApi('navigateTo'); |
| | | } |
| | | }, |
| | | pageApi(api) { |
| | | let callback = { |
| | | url: this.to, |
| | | success: res => { |
| | | this.$emit('click', { |
| | | data: res |
| | | }); |
| | | }, |
| | | fail: err => { |
| | | this.$emit('click', { |
| | | data: err |
| | | }); |
| | | } |
| | | } |
| | | switch (api) { |
| | | case 'navigateTo': |
| | | uni.navigateTo(callback) |
| | | break |
| | | case 'redirectTo': |
| | | uni.redirectTo(callback) |
| | | break |
| | | case 'reLaunch': |
| | | uni.reLaunch(callback) |
| | | break |
| | | case 'switchTab': |
| | | uni.switchTab(callback) |
| | | break |
| | | default: |
| | | uni.navigateTo(callback) |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | $uni-font-size-sm:12px; |
| | | $uni-font-size-base:14px; |
| | | $uni-font-size-lg:16px; |
| | | $uni-spacing-col-lg: 12px; |
| | | $uni-spacing-row-lg: 15px; |
| | | $uni-img-size-sm:20px; |
| | | $uni-img-size-base:26px; |
| | | $uni-img-size-lg:40px; |
| | | $uni-border-color:#e5e5e5; |
| | | $uni-bg-color-hover:#f1f1f1; |
| | | $uni-text-color-grey:#999; |
| | | $list-item-pd: $uni-spacing-col-lg $uni-spacing-row-lg; |
| | | |
| | | .uni-list-item { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | font-size: $uni-font-size-lg; |
| | | position: relative; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | background-color: #fff; |
| | | flex-direction: row; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-list-item--disabled { |
| | | opacity: 0.3; |
| | | } |
| | | |
| | | .uni-list-item--hover { |
| | | background-color: $uni-bg-color-hover; |
| | | } |
| | | |
| | | .uni-list-item__container { |
| | | position: relative; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | padding: $list-item-pd; |
| | | padding-left: $uni-spacing-row-lg; |
| | | flex: 1; |
| | | overflow: hidden; |
| | | // align-items: center; |
| | | } |
| | | |
| | | .container--right { |
| | | padding-right: 0; |
| | | } |
| | | |
| | | // .border--left { |
| | | // margin-left: $uni-spacing-row-lg; |
| | | // } |
| | | |
| | | .uni-list--border { |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | left: 0; |
| | | /* #ifdef APP-NVUE */ |
| | | border-top-color: $uni-border-color; |
| | | border-top-style: solid; |
| | | border-top-width: 0.5px; |
| | | /* #endif */ |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | .uni-list--border:after { |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | left: 0; |
| | | height: 1px; |
| | | content: ''; |
| | | -webkit-transform: scaleY(0.5); |
| | | transform: scaleY(0.5); |
| | | background-color: $uni-border-color; |
| | | } |
| | | |
| | | /* #endif */ |
| | | |
| | | .uni-list-item__content { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | padding-right: 8px; |
| | | flex: 1; |
| | | color: #3b4144; |
| | | // overflow: hidden; |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-list-item__content--center { |
| | | justify-content: center; |
| | | } |
| | | |
| | | .uni-list-item__content-title { |
| | | font-size: $uni-font-size-base; |
| | | color: #3b4144; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-list-item__content-note { |
| | | margin-top: 6rpx; |
| | | color: $uni-text-color-grey; |
| | | font-size: $uni-font-size-sm; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-list-item__extra { |
| | | // width: 25%; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | justify-content: flex-end; |
| | | align-items: center; |
| | | } |
| | | |
| | | .uni-list-item__header { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | align-items: center; |
| | | } |
| | | |
| | | .uni-list-item__icon { |
| | | margin-right: 18rpx; |
| | | flex-direction: row; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | | |
| | | .uni-list-item__icon-img { |
| | | /* #ifndef APP-NVUE */ |
| | | display: block; |
| | | /* #endif */ |
| | | height: $uni-img-size-base; |
| | | width: $uni-img-size-base; |
| | | margin-right: 10px; |
| | | } |
| | | |
| | | .uni-icon-wrapper { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | align-items: center; |
| | | padding: 0 10px; |
| | | } |
| | | |
| | | .flex--direction { |
| | | flex-direction: column; |
| | | /* #ifndef APP-NVUE */ |
| | | align-items: initial; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .flex--justify { |
| | | /* #ifndef APP-NVUE */ |
| | | justify-content: initial; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-list--lg { |
| | | height: $uni-img-size-lg; |
| | | width: $uni-img-size-lg; |
| | | } |
| | | |
| | | .uni-list--base { |
| | | height: $uni-img-size-base; |
| | | width: $uni-img-size-base; |
| | | } |
| | | |
| | | .uni-list--sm { |
| | | height: $uni-img-size-sm; |
| | | width: $uni-img-size-sm; |
| | | } |
| | | |
| | | .uni-list-item__extra-text { |
| | | color: $uni-text-color-grey; |
| | | font-size: $uni-font-size-sm; |
| | | } |
| | | |
| | | .uni-ellipsis-1 { |
| | | /* #ifndef APP-NVUE */ |
| | | overflow: hidden; |
| | | white-space: nowrap; |
| | | text-overflow: ellipsis; |
| | | /* #endif */ |
| | | /* #ifdef APP-NVUE */ |
| | | lines: 1; |
| | | text-overflow:ellipsis; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-ellipsis-2 { |
| | | /* #ifndef APP-NVUE */ |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | display: -webkit-box; |
| | | -webkit-line-clamp: 2; |
| | | -webkit-box-orient: vertical; |
| | | /* #endif */ |
| | | |
| | | /* #ifdef APP-NVUE */ |
| | | lines: 2; |
| | | text-overflow:ellipsis; |
| | | /* #endif */ |
| | | } |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <view class="uni-list uni-border-top-bottom"> |
| | | <view v-if="border" class="uni-list--border-top"></view> |
| | | <slot /> |
| | | <view v-if="border" class="uni-list--border-bottom"></view> |
| | | </view> |
| | | <!-- #endif --> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <list class="uni-list" :class="{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop" loadmoreoffset="15"><slot /></list> |
| | | <!-- #endif --> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * List å表 |
| | | * @description å表ç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=24 |
| | | * @property {String} border = [true|false] æ é¢ |
| | | */ |
| | | export default { |
| | | name: 'uniList', |
| | | 'mp-weixin': { |
| | | options: { |
| | | multipleSlots: false |
| | | } |
| | | }, |
| | | props: { |
| | | enableBackToTop: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | scrollY: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | border: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | // provide() { |
| | | // return { |
| | | // list: this |
| | | // }; |
| | | // }, |
| | | created() { |
| | | this.firstChildAppend = false; |
| | | }, |
| | | methods: { |
| | | loadMore(e) { |
| | | this.$emit('scrolltolower'); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | .uni-list { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | background-color: $uni-bg-color; |
| | | position: relative; |
| | | flex-direction: column; |
| | | } |
| | | |
| | | .uni-list--border { |
| | | position: relative; |
| | | /* #ifdef APP-NVUE */ |
| | | border-top-color: $uni-border-color; |
| | | border-top-style: solid; |
| | | border-top-width: 0.5px; |
| | | border-bottom-color: $uni-border-color; |
| | | border-bottom-style: solid; |
| | | border-bottom-width: 0.5px; |
| | | /* #endif */ |
| | | z-index: -1; |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | |
| | | .uni-list--border-top { |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | left: 0; |
| | | height: 1px; |
| | | -webkit-transform: scaleY(0.5); |
| | | transform: scaleY(0.5); |
| | | background-color: $uni-border-color; |
| | | z-index: 1; |
| | | } |
| | | |
| | | .uni-list--border-bottom { |
| | | position: absolute; |
| | | bottom: 0; |
| | | right: 0; |
| | | left: 0; |
| | | height: 1px; |
| | | -webkit-transform: scaleY(0.5); |
| | | transform: scaleY(0.5); |
| | | background-color: $uni-border-color; |
| | | } |
| | | |
| | | /* #endif */ |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <view class="uni-list uni-border-top-bottom"> |
| | | <view v-if="border" class="uni-list--border-top"></view> |
| | | <slot /> |
| | | <view v-if="border" class="uni-list--border-bottom"></view> |
| | | </view> |
| | | <!-- #endif --> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <list class="uni-list" :class="{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop" loadmoreoffset="15"><slot /></list> |
| | | <!-- #endif --> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * List å表 |
| | | * @description å表ç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=24 |
| | | * @property {String} border = [true|false] æ é¢ |
| | | */ |
| | | export default { |
| | | name: 'uniList', |
| | | 'mp-weixin': { |
| | | options: { |
| | | multipleSlots: false |
| | | } |
| | | }, |
| | | props: { |
| | | enableBackToTop: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | scrollY: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | border: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | // provide() { |
| | | // return { |
| | | // list: this |
| | | // }; |
| | | // }, |
| | | created() { |
| | | this.firstChildAppend = false; |
| | | }, |
| | | methods: { |
| | | loadMore(e) { |
| | | this.$emit('scrolltolower'); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | $uni-bg-color:#ffffff; |
| | | $uni-border-color:#e5e5e5; |
| | | .uni-list { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | background-color: $uni-bg-color; |
| | | position: relative; |
| | | flex-direction: column; |
| | | } |
| | | |
| | | .uni-list--border { |
| | | position: relative; |
| | | /* #ifdef APP-NVUE */ |
| | | border-top-color: $uni-border-color; |
| | | border-top-style: solid; |
| | | border-top-width: 0.5px; |
| | | border-bottom-color: $uni-border-color; |
| | | border-bottom-style: solid; |
| | | border-bottom-width: 0.5px; |
| | | /* #endif */ |
| | | z-index: -1; |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | |
| | | .uni-list--border-top { |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | left: 0; |
| | | height: 1px; |
| | | -webkit-transform: scaleY(0.5); |
| | | transform: scaleY(0.5); |
| | | background-color: $uni-border-color; |
| | | z-index: 1; |
| | | } |
| | | |
| | | .uni-list--border-bottom { |
| | | position: absolute; |
| | | bottom: 0; |
| | | right: 0; |
| | | left: 0; |
| | | height: 1px; |
| | | -webkit-transform: scaleY(0.5); |
| | | transform: scaleY(0.5); |
| | | background-color: $uni-border-color; |
| | | } |
| | | |
| | | /* #endif */ |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <refresh :display="display" @refresh="onrefresh" @pullingdown="onpullingdown"> |
| | | <slot /> |
| | | </refresh> |
| | | <!-- #endif --> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <view ref="uni-refresh" class="uni-refresh" v-show="isShow"> |
| | | <slot /> |
| | | </view> |
| | | <!-- #endif --> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: 'UniRefresh', |
| | | props: { |
| | | display: { |
| | | type: [String], |
| | | default: "hide" |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | pulling: false |
| | | } |
| | | }, |
| | | computed: { |
| | | isShow() { |
| | | if (this.display === "show" || this.pulling === true) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | }, |
| | | created() {}, |
| | | methods: { |
| | | onchange(value) { |
| | | this.pulling = value; |
| | | }, |
| | | onrefresh(e) { |
| | | this.$emit("refresh", e); |
| | | }, |
| | | onpullingdown(e) { |
| | | // #ifdef APP-NVUE |
| | | this.$emit("pullingdown", e); |
| | | // #endif |
| | | // #ifndef APP-NVUE |
| | | var detail = { |
| | | viewHeight: 90, |
| | | pullingDistance: e.height |
| | | } |
| | | this.$emit("pullingdown", detail); |
| | | // #endif |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | .uni-refresh { |
| | | height: 0; |
| | | overflow: hidden; |
| | | } |
| | | </style> |
| New file |
| | |
| | | var pullDown = { |
| | | threshold: 95, |
| | | maxHeight: 200, |
| | | callRefresh: 'onrefresh', |
| | | callPullingDown: 'onpullingdown', |
| | | refreshSelector: '.uni-refresh' |
| | | }; |
| | | |
| | | function ready(newValue, oldValue, ownerInstance, instance) { |
| | | var state = instance.getState() |
| | | state.canPullDown = newValue; |
| | | // console.log(newValue); |
| | | } |
| | | |
| | | function touchStart(e, instance) { |
| | | var state = instance.getState(); |
| | | state.refreshInstance = instance.selectComponent(pullDown.refreshSelector); |
| | | state.canPullDown = (state.refreshInstance != null && state.refreshInstance != undefined); |
| | | if (!state.canPullDown) { |
| | | return |
| | | } |
| | | |
| | | // console.log("touchStart"); |
| | | |
| | | state.height = 0; |
| | | state.touchStartY = e.touches[0].pageY || e.changedTouches[0].pageY; |
| | | state.refreshInstance.setStyle({ |
| | | 'height': 0 |
| | | }); |
| | | state.refreshInstance.callMethod("onchange", true); |
| | | } |
| | | |
| | | function touchMove(e, ownerInstance) { |
| | | var instance = e.instance; |
| | | var state = instance.getState(); |
| | | if (!state.canPullDown) { |
| | | return |
| | | } |
| | | |
| | | var oldHeight = state.height; |
| | | var endY = e.touches[0].pageY || e.changedTouches[0].pageY; |
| | | var height = endY - state.touchStartY; |
| | | if (height > pullDown.maxHeight) { |
| | | return; |
| | | } |
| | | |
| | | var refreshInstance = state.refreshInstance; |
| | | refreshInstance.setStyle({ |
| | | 'height': height + 'px' |
| | | }); |
| | | |
| | | height = height < pullDown.maxHeight ? height : pullDown.maxHeight; |
| | | state.height = height; |
| | | refreshInstance.callMethod(pullDown.callPullingDown, { |
| | | height: height |
| | | }); |
| | | } |
| | | |
| | | function touchEnd(e, ownerInstance) { |
| | | var state = e.instance.getState(); |
| | | if (!state.canPullDown) { |
| | | return |
| | | } |
| | | |
| | | state.refreshInstance.callMethod("onchange", false); |
| | | |
| | | var refreshInstance = state.refreshInstance; |
| | | if (state.height > pullDown.threshold) { |
| | | refreshInstance.callMethod(pullDown.callRefresh); |
| | | return; |
| | | } |
| | | |
| | | refreshInstance.setStyle({ |
| | | 'height': 0 |
| | | }); |
| | | } |
| | | |
| | | function propObserver(newValue, oldValue, instance) { |
| | | pullDown = newValue; |
| | | } |
| | | |
| | | module.exports = { |
| | | touchmove: touchMove, |
| | | touchstart: touchStart, |
| | | touchend: touchEnd, |
| | | propObserver: propObserver |
| | | } |
| New file |
| | |
| | | { |
| | | "id": "uni-list", |
| | | "displayName": "uni-list å表", |
| | | "version": "1.2.0", |
| | | "description": "List ç»ä»¶ ï¼å¸®å©ä½¿ç¨è
å¿«éæå»ºå表ã", |
| | | "keywords": [ |
| | | "", |
| | | "uni-ui", |
| | | "uniui", |
| | | "å表", |
| | | "", |
| | | "list" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-badge", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## List å表 |
| | | > **ç»ä»¶åï¼uni-list** |
| | | > 代ç åï¼ `uList`ã`uListItem` |
| | | > å
³èç»ä»¶ï¼`uni-list-item`ã`uni-badge`ã`uni-icons`ã`uni-list-chat`ã`uni-list-ad` |
| | | |
| | | |
| | | List å表ç»ä»¶ï¼å
å«åºæ¬åè¡¨æ ·å¼ã坿©å±ææ§½æºå¶ãé¿å表æ§è½ä¼åãå¤ç«¯å
¼å®¹ã |
| | | |
| | | å¨vue页é¢éï¼å®é»è®¤ä½¿ç¨é¡µé¢çº§æ»å¨ãå¨app-nvue页é¢éï¼å®é»è®¤ä½¿ç¨åçlistç»ä»¶æ»å¨ãè¿æ ·çé¿å表ï¼å¨æ»å¨åºå±å¹å¤åï¼ç³»ç»ä¼åæ¶ä¸å¯è§åºåçæ¸²æå
åèµæºï¼ä¸ä¼é ææ»å¨è¶é¿ææºè¶å¡çé®é¢ã |
| | | |
| | | uni-listç»ä»¶æ¯ç¶å®¹å¨ï¼éé¢çæ ¸å¿æ¯uni-list-itemåç»ä»¶ï¼å®ä»£è¡¨å表ä¸çä¸ä¸ªå¯éå¤è¡ï¼åç»ä»¶å¯ä»¥æ é循ç¯ã |
| | | |
| | | uni-list-itemæå¾å¤é£æ ¼ï¼uni-list-itemç»ä»¶éè¿å
ç½®ç屿§ï¼æ»¡è¶³ä¸äºå¸¸ç¨çåºæ¯ãå½å
ç½®å±æ§ä¸æ»¡è¶³éæ±æ¶ï¼å¯ä»¥éè¿æ©å±ææ§½æ¥èªå®ä¹å表å
容ã |
| | | |
| | | å
ç½®å±æ§å¯ä»¥è¦ççåºæ¯å
æ¬ï¼å¯¼èªå表ã设置å表ãå°å¾æ å表ãéä¿¡å½å表ãè天记å½å表ã |
| | | |
| | | æ¶åå¾å¤å¤§å¾æä¸°å¯å
容çåè¡¨ï¼æ¯å¦ç±»ä»æ¥å¤´æ¡çæ°é»å表ãç±»æ·å®ççµåå表ï¼éè¦éè¿æ©å±ææ§½å®ç°ã |
| | | |
| | | 䏿忿 ·ä¾ç»åºã |
| | | |
| | | uni-listä¸å
å«ä¸æå·æ°åä¸æç¿»é¡µãä¸æç¿»é¡µå¦è§ç»ä»¶ï¼[uni-load-more](https://ext.dcloud.net.cn/plugin?id=29) |
| | | |
| | | |
| | | ### å®è£
æ¹å¼ |
| | | |
| | | æ¬ç»ä»¶ç¬¦å[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)è§èï¼`HBuilderX 2.5.5`èµ·ï¼åªéå°æ¬ç»ä»¶å¯¼å
¥é¡¹ç®ï¼å¨é¡µé¢`template`ä¸å³å¯ç´æ¥ä½¿ç¨ï¼æ éå¨é¡µé¢ä¸`import`åæ³¨å`components`ã |
| | | |
| | | å¦ééè¿`npm`æ¹å¼ä½¿ç¨`uni-ui`ç»ä»¶ï¼å¦è§ææ¡£ï¼[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55) |
| | | |
| | | > **注æäºé¡¹** |
| | | > 为äºé¿å
é误使ç¨ï¼ç»å¤§å®¶å¸¦æ¥ä¸å¥½çå¼åä½éªï¼è¯·å¨ä½¿ç¨ç»ä»¶åä»ç»é
读ä¸é¢ç注æäºé¡¹ï¼å¯ä»¥å¸®ä½ é¿å
ä¸äºé误ã |
| | | > - ç»ä»¶éè¦ä¾èµ `sass` æä»¶ ï¼è¯·èªè¡æå¨å®è£
|
| | | > - ç»ä»¶å
é¨ä¾èµ `'uni-icons'` ã`uni-badge` ç»ä»¶ |
| | | > - `uni-list` å `uni-list-item` éè¦é
å¥ä½¿ç¨ï¼æä¸æ¯æåç¬ä½¿ç¨ `uni-list-item` |
| | | > - åªæå¼å¯ç¹å»åé¦åï¼ä¼æç¹å»é䏿æ |
| | | > - ä½¿ç¨ææ§½æ¶ï¼å¯ä»¥å®å
¨èªå®ä¹å
容 |
| | | > - note ãrightText 屿§ææ¶æ²¡åéå¶ï¼ä¸æ¯ææå溢åºéèï¼ä½¿ç¨æ¶åºè¯¥æ§å¶é¿åº¦æ¾ç¤ºæéè¿é»è®¤ææ§½èªè¡æ©å± |
| | | > - æ¯ä»å®å°ç¨åºå¹³å°éè¦å¨æ¯ä»å®å°ç¨åºå¼åè
å·¥å
·éå¼å¯ component2 ç¼è¯æ¨¡å¼ï¼å¼å¯æ¹å¼ï¼ 详æ
--> 项ç®é
ç½® --> å¯ç¨ component2 ç¼è¯ |
| | | > - 妿éè¦ä¿®æ¹ `switch`ã`badge` æ ·å¼ï¼è¯·ä½¿ç¨ææ§½èªå®ä¹ |
| | | > - å¨ `HBuilderX` ä½çæ¬ä¸ï¼å¯è½ä¼åºç°ç»ä»¶æ¾ç¤º `undefined` çé®é¢ï¼è¯·åçº§ææ°ç `HBuilderX` æè
`cli` |
| | | > - å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| | | |
| | | |
| | | ### åºæ¬ç¨æ³ |
| | | |
| | | - 设置 `title` 屿§ï¼å¯ä»¥æ¾ç¤ºå表æ é¢ |
| | | - 设置 `disabled` 屿§ï¼å¯ä»¥ç¦ç¨å½å项 |
| | | |
| | | ```html |
| | | <uni-list> |
| | | <uni-list-item title="å表æå" ></uni-list-item> |
| | | <uni-list-item :disabled="true" title="å表ç¦ç¨ç¶æ" ></uni-list-item> |
| | | </uni-list> |
| | | |
| | | ``` |
| | | |
| | | ### å¤è¡å
容æ¾ç¤º |
| | | |
| | | - 设置 `note` 屿§ ï¼å¯ä»¥å¨ç¬¬äºè¡æ¾ç¤ºæè¿°ææ¬ä¿¡æ¯ |
| | | |
| | | ```html |
| | | <uni-list> |
| | | <uni-list-item title="å表æå" note="å表æè¿°ä¿¡æ¯"></uni-list-item> |
| | | <uni-list-item :disabled="true" title="å表æå" note="å表ç¦ç¨ç¶æ"></uni-list-item> |
| | | </uni-list> |
| | | |
| | | ``` |
| | | |
| | | ### å³ä¾§æ¾ç¤ºè§æ ãswitch |
| | | |
| | | - 设置 `show-badge` 屿§ ï¼å¯ä»¥æ¾ç¤ºè§æ å
容 |
| | | - 设置 `show-switch` 屿§ï¼å¯ä»¥æ¾ç¤º switch å¼å
³ |
| | | |
| | | ```html |
| | | <uni-list> |
| | | <uni-list-item title="å表å³ä¾§æ¾ç¤ºè§æ " :show-badge="true" badge-text="12" ></uni-list-item> |
| | | <uni-list-item title="å表å³ä¾§æ¾ç¤º switch" :show-switch="true" @switchChange="switchChange" ></uni-list-item> |
| | | </uni-list> |
| | | |
| | | ``` |
| | | |
| | | ### 左侧æ¾ç¤ºç¥ç¼©å¾ã徿 |
| | | |
| | | - 设置 `thumb` 屿§ ï¼å¯ä»¥å¨å表左侧æ¾ç¤ºç¥ç¼©å¾ |
| | | - 设置 `show-extra-icon` 屿§ï¼å¹¶æå® `extra-icon` å¯ä»¥å¨å·¦ä¾§æ¾ç¤ºå¾æ |
| | | |
| | | ```html |
| | | <uni-list> |
| | | <uni-list-item title="å表左侧带ç¥ç¼©å¾" note="å表æè¿°ä¿¡æ¯" thumb="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png" |
| | | thumb-size="lg" rightText="å³ä¾§æå"></uni-list-item> |
| | | <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon1" title="å表左侧带æ©å±å¾æ " ></uni-list-item> |
| | | </uni-list> |
| | | ``` |
| | | |
| | | ### å¼å¯ç¹å»åé¦åå³ä¾§ç®å¤´ |
| | | - 设置 `clickable` 为 `true` ï¼åè¡¨ç¤ºè¿æ¯ä¸ä¸ªå¯ç¹å»çå表ï¼ä¼é»è®¤ç»ä¸ä¸ªç¹å»ææï¼å¹¶å¯ä»¥çå¬ `click` äºä»¶ |
| | | - 设置 `link` 屿§ï¼ä¼èªå¨å¼å¯ç¹å»åé¦ï¼å¹¶ç»å表å³ä¾§æ·»å ä¸ä¸ªç®å¤´ |
| | | - 设置 `to` 屿§ï¼å¯ä»¥è·³è½¬é¡µé¢ï¼`link` çå¼è¡¨ç¤ºè·³è½¬æ¹å¼ï¼å¦æä¸æå®ï¼é»è®¤ä¸º `navigateTo` |
| | | |
| | | ```html |
| | | |
| | | <uni-list> |
| | | <uni-list-item title="å¼å¯ç¹å»åé¦" clickable @click="onClick" ></uni-list-item> |
| | | <uni-list-item title="é»è®¤ navigateTo æ¹å¼è·³è½¬é¡µé¢" link to="/pages/vue/index/index" @click="onClick($event,1)" ></uni-list-item> |
| | | <uni-list-item title="reLaunch æ¹å¼è·³è½¬é¡µé¢" link="reLaunch" to="/pages/vue/index/index" @click="onClick($event,1)" ></uni-list-item> |
| | | </uni-list> |
| | | |
| | | ``` |
| | | |
| | | |
| | | ### è天åè¡¨ç¤ºä¾ |
| | | - 设置 `clickable` 为 `true` ï¼åè¡¨ç¤ºè¿æ¯ä¸ä¸ªå¯ç¹å»çå表ï¼ä¼é»è®¤ç»ä¸ä¸ªç¹å»ææï¼å¹¶å¯ä»¥çå¬ `click` äºä»¶ |
| | | - 设置 `link` 屿§ï¼ä¼èªå¨å¼å¯ç¹å»åé¦ï¼`link` çå¼è¡¨ç¤ºè·³è½¬æ¹å¼ï¼å¦æä¸æå®ï¼é»è®¤ä¸º `navigateTo` |
| | | - 设置 `to` 屿§ï¼å¯ä»¥è·³è½¬é¡µé¢ |
| | | - `time` 屿§ï¼é常ä¼è®¾ç½®ææ¶é´æ¾ç¤ºï¼ä½æ¯è¿ä¸ªå±æ§ä¸ä»
ä»
å¯ä»¥è®¾ç½®æ¶é´ï¼ä½ å¯ä»¥ä¼ å
¥ä»»ä½ææ¬ï¼æ³¨æææ¬é¿åº¦å¯è½ä¼å½±åæ¾ç¤º |
| | | - `avatar` å `avatarList` 屿§åæ¶åªä¼æä¸ä¸ªçæï¼åæ¶è®¾ç½®çè¯ï¼`avatarList` 屿§çé¿åº¦å¤§äº1 ï¼`avatar` 屿§å°å¤±æ |
| | | - å¯ä»¥éè¿é»è®¤ææ§½èªå®ä¹å表å³ä¾§å
容 |
| | | |
| | | ```html |
| | | |
| | | <uni-list> |
| | | <uni-list :border="true"> |
| | | <!-- æ¾ç¤ºå形头å --> |
| | | <uni-list-chat :avatar-circle="true" title="uni-app" avatar="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png" note="æ¨æ¶å°ä¸æ¡æ°çæ¶æ¯" time="2020-02-02 20:20" ></uni-list-chat> |
| | | <!-- å³ä¾§å¸¦è§æ --> |
| | | <uni-list-chat title="uni-app" avatar="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png" note="æ¨æ¶å°ä¸æ¡æ°çæ¶æ¯" time="2020-02-02 20:20" badge-text="12"></uni-list-chat> |
| | | <!-- å¤´åæ¾ç¤ºåç¹ --> |
| | | <uni-list-chat title="uni-app" avatar="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png" note="æ¨æ¶å°ä¸æ¡æ°çæ¶æ¯" time="2020-02-02 20:20" badge-positon="left" badge-text="dot"></uni-list-chat> |
| | | <!-- å¤´åæ¾ç¤ºè§æ --> |
| | | <uni-list-chat title="uni-app" avatar="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png" note="æ¨æ¶å°ä¸æ¡æ°çæ¶æ¯" time="2020-02-02 20:20" badge-positon="left" badge-text="99"></uni-list-chat> |
| | | <!-- æ¾ç¤ºå¤å¤´å --> |
| | | <uni-list-chat title="uni-app" :avatar-list="avatarList" note="æ¨æ¶å°ä¸æ¡æ°çæ¶æ¯" time="2020-02-02 20:20" badge-positon="left" badge-text="dot"></uni-list-chat> |
| | | <!-- èªå®ä¹å³ä¾§å
容 --> |
| | | <uni-list-chat title="uni-app" :avatar-list="avatarList" note="æ¨æ¶å°ä¸æ¡æ°çæ¶æ¯" time="2020-02-02 20:20" badge-positon="left" badge-text="dot"> |
| | | <view class="chat-custom-right"> |
| | | <text class="chat-custom-text">åå</text> |
| | | <!-- éè¦ä½¿ç¨ uni-icons 请èªè¡å¼å
¥ --> |
| | | <uni-icons type="star-filled" color="#999" size="18"></uni-icons> |
| | | </view> |
| | | </uni-list-chat> |
| | | </uni-list> |
| | | </uni-list> |
| | | |
| | | ``` |
| | | |
| | | ```javascript |
| | | |
| | | export default { |
| | | components: {}, |
| | | data() { |
| | | return { |
| | | avatarList: [{ |
| | | url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png' |
| | | }, { |
| | | url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png' |
| | | }, { |
| | | url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png' |
| | | }] |
| | | } |
| | | } |
| | | } |
| | | |
| | | ``` |
| | | |
| | | |
| | | ```css |
| | | |
| | | .chat-custom-right { |
| | | flex: 1; |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | | align-items: flex-end; |
| | | } |
| | | |
| | | .chat-custom-text { |
| | | font-size: 12px; |
| | | color: #999; |
| | | } |
| | | |
| | | ``` |
| | | |
| | | ## API |
| | | |
| | | ### List Props |
| | | |
| | | 屿§å |ç±»å |é»è®¤å¼ | 说æ |
| | | :-: |:-: |:-: | :-: |
| | | border |Boolean |true | æ¯å¦æ¾ç¤ºè¾¹æ¡ |
| | | |
| | | |
| | | ### ListItem Props |
| | | |
| | | 屿§å |ç±»å |é»è®¤å¼ | 说æ |
| | | :-: |:-: |:-: | :-: |
| | | title |String |- | æ é¢ |
| | | note |String |- | æè¿° |
| | | ellipsis |Number |0 | title æ¯å¦æº¢åºéèï¼å¯éå¼ï¼0:é»è®¤; 1:æ¾ç¤ºä¸è¡; 2:æ¾ç¤ºä¸¤è¡;ãnvue æä¸æ¯æã |
| | | thumb |String |- | 左侧缩ç¥å¾ï¼è¥thumbæå¼ï¼åä¸ä¼æ¾ç¤ºæ©å±å¾æ |
| | | thumbSize |String |medium | ç¥ç¼©å¾å°ºå¯¸ï¼å¯éå¼ï¼lg:大å¾; medium:ä¸è¬; sm:å°å¾; |
| | | showBadge |Boolean |false | æ¯å¦æ¾ç¤ºæ°åè§æ |
| | | badgeText |String |- | æ°åè§æ å
容 |
| | | badgeType |String |- | æ°åè§æ ç±»åï¼åè[uni-icons](https://ext.dcloud.net.cn/plugin?id=21) |
| | | rightText |String |- | å³ä¾§æåå
容 |
| | | disabled |Boolean |false | æ¯å¦ç¦ç¨ |
| | | showArrow |Boolean |true | æ¯å¦æ¾ç¤ºç®å¤´å¾æ |
| | | link |String |navigateTo | æ°é¡µé¢è·³è½¬æ¹å¼ï¼å¯éå¼è§ä¸è¡¨ |
| | | to |String |- | æ°é¡µé¢è·³è½¬å°åï¼å¦å¡«åæ¤å±æ§ï¼click ä¼è¿å页颿¯å¦è·³è½¬æå |
| | | clickable |Boolean |false | æ¯å¦å¼å¯ç¹å»åé¦ |
| | | showSwitch |Boolean |false | æ¯å¦æ¾ç¤ºSwitch |
| | | switchChecked |Boolean |false | Switchæ¯å¦è¢«éä¸ |
| | | showExtraIcon |Boolean |false | 左侧æ¯å¦æ¾ç¤ºæ©å±å¾æ |
| | | extraIcon |Object |- | æ©å±å¾æ åæ°ï¼æ ¼å¼ä¸º ``{color: '#4cd964',size: '22',type: 'spinner'}``ï¼åè [uni-icons](https://ext.dcloud.net.cn/plugin?id=28) |
| | | direction | String |row | æçæ¹åï¼å¯éå¼ï¼row:æ°´å¹³æå; column:åç´æå; 3ä¸ªææ§½æ¯æ°´å¹³æè¿æ¯åç´æï¼ä¹åæ¤å±æ§æ§å¶ |
| | | |
| | | |
| | | #### Link Options |
| | | |
| | | 屿§å | 说æ |
| | | :-: | :-: |
| | | navigateTo | å uni.navigateTo() |
| | | redirectTo | å uni.reLaunch() |
| | | reLaunch | å uni.reLaunch() |
| | | switchTab | å uni.switchTab() |
| | | |
| | | ### ListItem Events |
| | | |
| | | äºä»¶ç§°å |说æ |è¿ååæ° |
| | | :-: |:-: |:-: |
| | | click |ç¹å» uniListItem 触åäºä»¶ï¼éå¼å¯ç¹å»åé¦ |- |
| | | switchChange |ç¹å»åæ¢ Switch æ¶è§¦åï¼éæ¾ç¤º switch |e={value:checked} |
| | | |
| | | |
| | | |
| | | ### ListItem Slots |
| | | |
| | | åç§° | 说æ |
| | | :-: | :-: |
| | | header | å·¦/ä¸å
å®¹ææ§½ï¼å¯å®å
¨èªå®ä¹é»è®¤æ¾ç¤º |
| | | body | ä¸é´å
å®¹ææ§½ï¼å¯å®å
¨èªå®ä¹ä¸é´å
容 |
| | | footer | å³/ä¸å
å®¹ææ§½ï¼å¯å®å
¨èªå®ä¹å³ä¾§å
容 |
| | | |
| | | |
| | | > **éè¿ææ§½æ©å±** |
| | | > éè¦æ³¨æçæ¯å½ä½¿ç¨ææ§½æ¶ï¼å
ç½®æ ·å¼å°ä¼å¤±æï¼åªä¿çæçæ ·å¼ï¼æ¤æ¶çæ ·å¼éè¦å¼åè
èªå·±å®ç° |
| | | > 妿 `uni-list-item` ç»ä»¶å
ç½®å±æ§æ ·å¼æ æ³æ»¡è¶³éæ±ï¼å¯ä»¥ä½¿ç¨ææ§½æ¥èªå®ä¹uni-list-iteméçå
容ã |
| | | > uni-list-itemæä¾äº3ä¸ªå¯æ©å±çææ§½ï¼`header`ã`body`ã`footer` |
| | | > - å½ `direction` 屿§ä¸º `row` æ¶è¡¨ç¤ºæ°´å¹³æåï¼æ¤æ¶ `header` 表示å表ç左边é¨åï¼`body` 表示å表çä¸é´é¨åï¼`footer` 表示å表çå³è¾¹é¨å |
| | | > - å½ `direction` 屿§ä¸º `column` æ¶è¡¨ç¤ºåç´æåï¼æ¤æ¶ `header` 表示å表çä¸è¾¹é¨åï¼`body` 表示å表çä¸é´é¨åï¼`footer` 表示å表çä¸è¾¹é¨å |
| | | > å¼åè
å¯ä»¥åªç¨1ä¸ªææ§½ï¼ä¹å¯ä»¥3个ä¸èµ·ä½¿ç¨ãå¨ææ§½ä¸å¯èªä¸»ç¼åviewæ ç¾ï¼å®ç°èªå·±æéçææã |
| | | |
| | | |
| | | **示ä¾** |
| | | |
| | | ```html |
| | | <uni-list> |
| | | <uni-list-item title="èªå®ä¹å³ä¾§ææ§½" note="å表æè¿°ä¿¡æ¯" link> |
| | | <template slot="header"> |
| | | <image class="slot-image" src="/static/logo.png" mode="widthFix"></image> |
| | | </template> |
| | | </uni-list-item> |
| | | <uni-list-item> |
| | | <!-- èªå®ä¹ header --> |
| | | <view slot="header" class="slot-box"><image class="slot-image" src="/static/logo.png" mode="widthFix"></image></view> |
| | | <!-- èªå®ä¹ body --> |
| | | <text slot="body" class="slot-box slot-text">èªå®ä¹ææ§½</text> |
| | | <!-- èªå®ä¹ footer--> |
| | | <template slot="footer"> |
| | | <image class="slot-image" src="/static/logo.png" mode="widthFix"></image> |
| | | </template> |
| | | </uni-list-item> |
| | | </uni-list> |
| | | ``` |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | ### ListItemChat Props |
| | | |
| | | 屿§å |ç±»å |é»è®¤å¼ | 说æ |
| | | :-: |:-: |:-: | :-: |
| | | title |String |- | æ é¢ |
| | | note |String |- | æè¿° |
| | | clickable |Boolean |false | æ¯å¦å¼å¯ç¹å»åé¦ |
| | | badgeText |String |- | æ°åè§æ å
容ï¼è®¾ç½®ä¸º `dot` å°æ¾ç¤ºåç¹ |
| | | badgePositon |String |right | è§æ ä½ç½® |
| | | link |String |navigateTo | æ¯å¦å±ç¤ºå³ä¾§ç®å¤´å¹¶å¼å¯ç¹å»åé¦ï¼å¯éå¼è§ä¸è¡¨ |
| | | clickable |Boolean |false | æ¯å¦å¼å¯ç¹å»åé¦ |
| | | to |String |- | 跳转页é¢å°åï¼å¦å¡«åæ¤å±æ§ï¼click ä¼è¿å页颿¯å¦è·³è½¬æå |
| | | time |String |- | å³ä¾§æ¶é´æ¾ç¤º |
| | | avatarCircle |Boolean |false | æ¯å¦æ¾ç¤ºå形头å |
| | | avatar |String |- | 头åå°åï¼avatarCircle ä¸å¡«æ¶çæ |
| | | avatarList |Array |- | 头åç»ï¼æ ¼å¼ä¸º [{url:''}] |
| | | |
| | | #### Link Options |
| | | |
| | | 屿§å | 说æ |
| | | :-: | :-: |
| | | navigateTo | å uni.navigateTo() |
| | | redirectTo | å uni.reLaunch() |
| | | reLaunch | å uni.reLaunch() |
| | | switchTab | å uni.switchTab() |
| | | |
| | | ### ListItemChat Slots |
| | | |
| | | åç§° | 说æ |
| | | :- | :- |
| | | default | èªå®ä¹å表å³ä¾§å
容ï¼å
æ¬æ¶é´åè§æ æ¾ç¤ºï¼ |
| | | |
| | | ### ListItemChat Events |
| | | äºä»¶ç§°å | 说æ | è¿ååæ° |
| | | :-: | :-: | :-: |
| | | @click | ç¹å» uniListChat 触åäºä»¶ | {data:{}} ï¼å¦æ to 屿§ï¼ä¼è¿å页é¢è·³è½¬ä¿¡æ¯ |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | ## åºäºuni-listæ©å±ç页颿¨¡æ¿ |
| | | |
| | | éè¿æ©å±ææ§½ï¼å¯å®ç°å¤ç§å¸¸è§æ ·å¼çå表 |
| | | |
| | | **æ°é»å表类** |
| | | |
| | | 1. äºç«¯ä¸ä½æ··åå¸å±ï¼[https://ext.dcloud.net.cn/plugin?id=2546](https://ext.dcloud.net.cn/plugin?id=2546) |
| | | 2. äºç«¯ä¸ä½åç´å¸å±ï¼å¤§å¾æ¨¡å¼ï¼[https://ext.dcloud.net.cn/plugin?id=2583](https://ext.dcloud.net.cn/plugin?id=2583) |
| | | 3. äºç«¯ä¸ä½åç´å¸å±ï¼å¤è¡å¾ææ··æï¼[https://ext.dcloud.net.cn/plugin?id=2584](https://ext.dcloud.net.cn/plugin?id=2584) |
| | | 4. äºç«¯ä¸ä½åç´å¸å±ï¼å¤å¾æ¨¡å¼ï¼[https://ext.dcloud.net.cn/plugin?id=2585](https://ext.dcloud.net.cn/plugin?id=2585) |
| | | 5. äºç«¯ä¸ä½æ°´å¹³å¸å±ï¼å·¦å¾å³æï¼[https://ext.dcloud.net.cn/plugin?id=2586](https://ext.dcloud.net.cn/plugin?id=2586) |
| | | 6. äºç«¯ä¸ä½æ°´å¹³å¸å±ï¼å·¦æå³å¾ï¼[https://ext.dcloud.net.cn/plugin?id=2587](https://ext.dcloud.net.cn/plugin?id=2587) |
| | | 7. äºç«¯ä¸ä½åç´å¸å±ï¼æ 徿¨¡å¼ï¼ä¸»æ é¢+坿 é¢ï¼[https://ext.dcloud.net.cn/plugin?id=2588](https://ext.dcloud.net.cn/plugin?id=2588) |
| | | |
| | | **ååå表类** |
| | | |
| | | 1. äºç«¯ä¸ä½å表/å®«æ ¼è§å¾äºåï¼[https://ext.dcloud.net.cn/plugin?id=2651](https://ext.dcloud.net.cn/plugin?id=2651) |
| | | 2. äºç«¯ä¸ä½å表ï¼å®«æ ¼æ¨¡å¼ï¼ï¼[https://ext.dcloud.net.cn/plugin?id=2671](https://ext.dcloud.net.cn/plugin?id=2671) |
| | | 3. äºç«¯ä¸ä½å表ï¼å表模å¼ï¼ï¼[https://ext.dcloud.net.cn/plugin?id=2672](https://ext.dcloud.net.cn/plugin?id=2672) |
| | | |
| | | ## ç»ä»¶ç¤ºä¾ |
| | | |
| | | ç¹å»æ¥çï¼[https://hellouniapp.dcloud.net.cn/pages/extUI/list/list](https://hellouniapp.dcloud.net.cn/pages/extUI/list/list) |
| New file |
| | |
| | | ## 1.3.3ï¼2022-01-20ï¼ |
| | | - æ°å¢ showText屿§ ï¼æ¯å¦æ¾ç¤ºææ¬ |
| | | ## 1.3.2ï¼2022-01-19ï¼ |
| | | - ä¿®å¤ nvue å¹³å°ä¸ä¸æ¾ç¤ºææ¬çbug |
| | | ## 1.3.1ï¼2022-01-19ï¼ |
| | | - ä¿®å¤ å¾®ä¿¡å°ç¨åºå¹³å°æ ·å¼éæ©å¨æ¥è¦åçé®é¢ |
| | | ## 1.3.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-load-more](https://uniapp.dcloud.io/component/uniui/uni-load-more) |
| | | ## 1.2.1ï¼2021-08-24ï¼ |
| | | - æ°å¢ æ¯æå½é
å |
| | | ## 1.2.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.1.8ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.1.7ï¼2021-03-30ï¼ |
| | | - ä¿®å¤ uni-load-more å¨é¦é¡µä½¿ç¨æ¶ï¼h5 平尿¥ 'uni is not defined' ç bug |
| | | ## 1.1.6ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | { |
| | | "uni-load-more.contentdown": "Pull up to show more", |
| | | "uni-load-more.contentrefresh": "loading...", |
| | | "uni-load-more.contentnomore": "No more data" |
| | | } |
| New file |
| | |
| | | import en from './en.json' |
| | | import zhHans from './zh-Hans.json' |
| | | import zhHant from './zh-Hant.json' |
| | | export default { |
| | | en, |
| | | 'zh-Hans': zhHans, |
| | | 'zh-Hant': zhHant |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-load-more.contentdown": "䏿æ¾ç¤ºæ´å¤", |
| | | "uni-load-more.contentrefresh": "æ£å¨å è½½...", |
| | | "uni-load-more.contentnomore": "æ²¡ææ´å¤æ°æ®äº" |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-load-more.contentdown": "ä¸æé¡¯ç¤ºæ´å¤", |
| | | "uni-load-more.contentrefresh": "æ£å¨å è¼...", |
| | | "uni-load-more.contentnomore": "æ²ææ´å¤æ¸æäº" |
| | | } |
| New file |
| | |
| | | <template> |
| | | <view class="uni-load-more" @click="onClick"> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <loading-indicator v-if="!webviewHide && status === 'loading' && showIcon" |
| | | :style="{color: color,width:iconSize+'px',height:iconSize+'px'}" :animating="true" |
| | | class="uni-load-more__img uni-load-more__img--nvue"></loading-indicator> |
| | | <!-- #endif --> |
| | | <!-- #ifdef H5 --> |
| | | <svg width="24" height="24" viewBox="25 25 50 50" |
| | | v-if="!webviewHide && (iconType==='circle' || iconType==='auto' && platform === 'android') && status === 'loading' && showIcon" |
| | | :style="{width:iconSize+'px',height:iconSize+'px'}" |
| | | class="uni-load-more__img uni-load-more__img--android-H5"> |
| | | <circle cx="50" cy="50" r="20" fill="none" :style="{color:color}" :stroke-width="3"></circle> |
| | | </svg> |
| | | <!-- #endif --> |
| | | <!-- #ifndef APP-NVUE || H5 --> |
| | | <view |
| | | v-if="!webviewHide && (iconType==='circle' || iconType==='auto' && platform === 'android') && status === 'loading' && showIcon" |
| | | :style="{width:iconSize+'px',height:iconSize+'px'}" |
| | | class="uni-load-more__img uni-load-more__img--android-MP"> |
| | | <view class="uni-load-more__img-icon" :style="{borderTopColor:color,borderTopWidth:iconSize/12}"></view> |
| | | <view class="uni-load-more__img-icon" :style="{borderTopColor:color,borderTopWidth:iconSize/12}"></view> |
| | | <view class="uni-load-more__img-icon" :style="{borderTopColor:color,borderTopWidth:iconSize/12}"></view> |
| | | </view> |
| | | <!-- #endif --> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <view v-else-if="!webviewHide && status === 'loading' && showIcon" |
| | | :style="{width:iconSize+'px',height:iconSize+'px'}" class="uni-load-more__img uni-load-more__img--ios-H5"> |
| | | <image :src="imgBase64" mode="widthFix"></image> |
| | | </view> |
| | | <!-- #endif --> |
| | | <text v-if="showText" class="uni-load-more__text" |
| | | :style="{color: color}">{{ status === 'more' ? contentdownText : status === 'loading' ? contentrefreshText : contentnomoreText }}</text> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | let platform |
| | | setTimeout(() => { |
| | | platform = uni.getSystemInfoSync().platform |
| | | }, 16) |
| | | |
| | | import { |
| | | initVueI18n |
| | | } from '@dcloudio/uni-i18n' |
| | | import messages from './i18n/index.js' |
| | | const { |
| | | t |
| | | } = initVueI18n(messages) |
| | | |
| | | /** |
| | | * LoadMore å è½½æ´å¤ |
| | | * @description ç¨äºå表ä¸ï¼åæ»å¨å 载使ç¨ï¼å±ç¤º loading çåç§ç¶æ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=29 |
| | | * @property {String} status = [more|loading|noMore] loading çç¶æ |
| | | * @value more loadingå |
| | | * @value loading loadingä¸ |
| | | * @value noMore æ²¡ææ´å¤äº |
| | | * @property {Number} iconSize æå®å¾æ å¤§å° |
| | | * @property {Boolean} iconSize = [true|false] æ¯å¦æ¾ç¤º loading 徿 |
| | | * @property {String} iconType = [snow|circle|auto] æå®å¾æ æ ·å¼ |
| | | * @value snow ioséªè±å è½½æ ·å¼ |
| | | * @value circle å®åå¤éå è½½æ ·å¼ |
| | | * @value auto æ ¹æ®å¹³å°èªå¨éæ©å è½½æ ·å¼ |
| | | * @property {String} color 徿 åæåé¢è² |
| | | * @property {Object} contentText åç¶ææå说æï¼å¼ä¸ºï¼{contentdown: "䏿æ¾ç¤ºæ´å¤",contentrefresh: "æ£å¨å è½½...",contentnomore: "æ²¡ææ´å¤æ°æ®äº"} |
| | | * @event {Function} clickLoadMore ç¹å»å è½½æ´å¤æ¶è§¦å |
| | | */ |
| | | export default { |
| | | name: 'UniLoadMore', |
| | | emits: ['clickLoadMore'], |
| | | props: { |
| | | status: { |
| | | // 䏿çç¶æï¼more-loadingåï¼loading-loadingä¸ï¼noMore-æ²¡ææ´å¤äº |
| | | type: String, |
| | | default: 'more' |
| | | }, |
| | | showIcon: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | iconType: { |
| | | type: String, |
| | | default: 'auto' |
| | | }, |
| | | iconSize: { |
| | | type: Number, |
| | | default: 24 |
| | | }, |
| | | color: { |
| | | type: String, |
| | | default: '#777777' |
| | | }, |
| | | contentText: { |
| | | type: Object, |
| | | default () { |
| | | return { |
| | | contentdown: '', |
| | | contentrefresh: '', |
| | | contentnomore: '' |
| | | } |
| | | } |
| | | }, |
| | | showText: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | webviewHide: false, |
| | | platform: platform, |
| | | imgBase64: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QzlBMzU3OTlEOUM0MTFFOUI0NTZDNERBQURBQzI4RkUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QzlBMzU3OUFEOUM0MTFFOUI0NTZDNERBQURBQzI4RkUiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpDOUEzNTc5N0Q5QzQxMUU5QjQ1NkM0REFBREFDMjhGRSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpDOUEzNTc5OEQ5QzQxMUU5QjQ1NkM0REFBREFDMjhGRSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pt+ALSwAAA6CSURBVHja1FsLkFZVHb98LM+F5bHL8khA1iSeiyQBCRM+YGqKUnnJTDLGI0BGZlKDIU2MMglUiDApEZvSsZnQtBRJtKwQNKQMFYeRDR10WOLd8ljYXdh+v8v5fR3Od+797t1dnOnO/Ofce77z+J//+b/P+ZqtXbs2sJ9MJhNUV1cHJ06cCJo3bx7EPc2aNcvpy7pWrVoF+/fvDyoqKoI2bdoE9fX1F7TjN8a+EXBn/fkfvw942Tf+wYMHg9mzZwfjxo0LDhw4EPa1x2MbFw/fOGfPng1qa2tzcCkILsLDydq2bRsunpOTMM7TD/W/tZDZhPdeKD+yGxHhdu3aBV27dg3OnDlzMVANMheLAO3btw8KCwuDmpoaX5OxbgUIMEq7K8IcPnw4KCsrC/r37x8cP378/4cAXAB3vqSkJMuiDhTkw+XcuXNhOWbMmKBly5YhUT8xArhyFvP0BfwRsAuwxJZJsm/nzp2DTp06he/OU+cZ64K6o0ePBkOHDg2GDx8e6gEbJ5Q/NHNuAJQ1hgBeHUDlR7nVTkY8rQAvAi4z34vR/mPs1FoRsaCgIJThI0eOBC1atEiFGGV+5MiRoS45efJkqFjJFXV1dQuA012m2WcwTw98fy6CqBdsaiIO4CScrGPHjvk4odhavPquRtFWXEC25VgkREKOCh/qDSq+vn37htzD/mZTOmOc5U7zKzBPEedygWshcDyWvs30igAbU+6oyMgJBCFhwQE0fccxN60Ay9iebbjoDh06hMowjQxT4fXq1SskArmHZpkArvixp/kWzHdMeArExSJEaiXIjjRjRJ4DaAGWpibLzXN3Fm1vA5teBgh3j1Rv3bp1YgKwPdmf2p9zcyNYYgPKMfY0T5f5nNYdw158nJ8QawW4CLKwiOBSEgO/hok2eBydR+3dYH+PLxA5J8Vv0KBBwenTp0P2JWAx6+yFEBfs8lMY+y0SWMBNI9E4ThKi58VKTg3FQZS1RQF1cz27eC0QHMu+3E0SkUowjhVt5VdaWhp07949ZHv2Qd1EjDXM2cla1M0nl3GxAs3J9yREzyTdFVKVFOaE9qRA8GM0WebRuo9JGZKA7Mv2SeS/Z8+eoQ9BArMfFrLGo6jvxbhHbJZnKX2Rzz1O7QhJJ9Cs2ZMaWIyq/zhdeqPNfIoHd58clIQD+JSXl4dKlyIAuBdVXZwFVWKspSSoxE++h8x4k3uCnEhE4I5KwRiFWGOU0QWKiCYLbdoRMRKAu2kQ9vkfLU6dOhX06NEjlH+yMRZSinnuyWnYosVcji8CEA/6Cg2JF+IIUBqnGKUTCNwtwBN4f89RiK1R96DEgO2o0NDmtEdvVFdVVYV+P3UAPUEs6GFwV3PHmXkD4vh74iDFJysVI/MlaQhwKeBNTLYX5VuA8T4/gZxA4MRGFxDB6R7OmYPfyykGRJbyie+XnGYnQIC/coH9+vULiYrxrkL9ZA9+0ykaHIfEpM7ge8TiJ2CsHYwyMfafAF1yCGBHYIbCVDjDjKt7BeB51D+LgQa6OkG7IDYEEtvQ7lnXLKLtLdLuJBpE4gPUXcW2+PkZwOex+4cGDhwYDBkyRL7/HFcEwUGPo/8uWRUpYnfxGHco8HkewLHLyYmAawAPuIFZxhOpDfJQ8gbUv41yORAptMWBNr6oqMhWird5+u+iHmBb2nhjDV7HWBNQTgK8y11l5NetWzc5ULscAtSj7nbNI0skhWeUZCc0W4nyH/jO4Vz0u1IeYhbk4AiwM6tjxIWByHsoZ9qcIBPJd/y+DwPfBESOmCa/QF3WiZHucLlEDpNxcNhmheEOPgdQNx6/VZFQzFZ5TN08AHXQt2Ii3EdyFuUsPtTcGPhW5iMiCNELvz+Gdn9huG4HUJaW/w3g0wxV0XaG7arG2WeKiUWYM4Y7GO5ezshTARbbWGw/DvXkpp/ivVvE0JVoMxN4rpGzJMhE5Pl+xlATsDIqikP9F9D2z3h9nOksEUFhK+qO4rcPkoalMQ/HqJLIyb3F3JdjrCcw1yZ8joyJLR5gCo54etlag7qIoeNh1N1BRYj3DTFJ0elotxPlVzkGuYAmL0VSJVGAJA41c4Z6A3BzTLfn0HYwYKEI6CUAMzZEWvLsIcQOo1AmmyyM72nHJCfYsogflGV6jEk9vyQZXSuq6w4c16NsGcGZbwOPr+H1RkOk2LEzjNepxQkihHSCQ4ynAYNRx2zMKV92CQMWqj8J0BRE8EShxRFN6YrfCRhC0x3r/Zm4IbQCcmJoV0kMamllccR6FjHqUC5F2R/wS2dcymOlfAKOS4KmzQb5cpNC2MC7JhVn5wjXoJ44rYhLh8n0eXOCorJxa7POjbSlCGVczr34/RsAmrcvo9s+wGp3tzVhntxiXiJ4nvEYb4FJkf0O8HocAePmLvCxnL0AORraVekJk6TYjDabRVXfRE2lCN1h6ZQRN1+InUbsCpKwoBZHh0dODN9JBCUffItXxEavTQkUtnfTVAplCWL3JISz29h4NjotnuSsQKJCk8dF+kJR6RARjrqFVmfPnj3ZbK8cIJ0msd6jgHPGtfVTQ8VLmlvh4mct9sobRmPic0DyDQQnx/NlfYUgyz59+oScsH379pAwXABD32nTpoUHIToESeI5mnbE/UqDdyLcafEBf2MCqgC7NwxIbMREJQ0g4D4sfJwnD+AmRrII05cfMWJE+L1169bQr+fip06dGp4oJ83lmYd5wj/EmMa4TaHivo4EeCguYZBnkB5g2aWA69OIEnUHOaGysjIYMGBAMGnSpODYsWPZwCpFmm4lNq+4gSLQA7jcX8DwtjEyRC8wjabnXEx9kfWnTJkSJkAo90xpJVV+FmcVNeYAF5zWngS4C4O91MBxmAv8blLEpbjI5sz9MTdAhcgkCT1RO8mZkAjfiYpTEvStAS53Uw1vAiUGgZ3GpuQEYvoiBqlIan7kSDHnTwJQFNiPu0+5VxCVYhcZIjNrdXUDdp+Eq5AZ3Gkg8QAyVZRZIk4Tl4QAbF9cXJxNYZMAtAokgs4BrNxEpCtteXg7DDTMDKYNSuQdKsnJBek7HxewvxaosWxLYXtw+cJp18217wql4aKCfBNoEu0O5VU+PhctJ0YeXD4C6JQpyrlpSLTojpGGGN5YwNziChdIZLk4lvLcFJ9jMX3QdiImY9bmGQU+TRUL5CHITTRlgF8D9ouD1MfmLoEPl5xokIumZ2cfgMpHt47IW9N64Hsh7wQYYjyIugWuF5fCqYncXRd5vPMWyizzvhi/32+nvG0dZc9vR6fZOu0md5e+uC408FvKSIOZwXlGvxPv95izA2Vtvg1xKFWARI+vMX66HUhpQQb643uW1bSjuTWyw2SBvDrBvjFic1eGGlz5esq3ko9uSIlBRqPuFcCv8F4WIcN12nVaBd0SaYwI6PDDImR11JkqgHcPmQssjxIn6bUshygDFJUTxPMpHk+jfjPgupgdnYV2R/g7xSjtpah8RJBewhwf0gGK6XI92u4wXFEU40afJ4DN4h5LcAd+40HI3JgJecuT0c062W0i2hQJUTcxan3/CMW1PF2K6bbA+Daz4xRs1D3Br1Cm0OihKCqizW78/nXAF/G5TXrEcVzaNMH6CyMswqsAHqDyDLEyou8lwOXnKF8DjI6KjV3KzMBiXkDH8ij/H214J5A596ekrZ3F0zXlWeL7+P5eUrNo3/QwC15uxthuzidy7DzKRwEDaAViiDgKbTbz7CJnzo0bN7pIfIiid8SuPwn25o3QCmpnyjlZkyxPP8EomCJzrGb7GJMx7tNsq4MT2xMUYaiErZOluTzKsnz3gwCeCZyVRZJfYplNEokEjwrPtxlxjeYAk+F1F74VAzPxQRNYYdtpOUvWs8J1sGhBJMNsb7igN8plJs1eSmLIhLKE4rvaCX27gOhLpLOsIzJ7qn/i+wZzcvSOZ23/du8TZjwV8zHIXoP4R3ifBxiFz1dcVpa3aPntPE+c6TmIWE9EtcMmAcPdWAhYhAXxcLOQi9L1WhD1Sc8p1d2oL7XGiRKp8F4A2i8K/nfI+y/gsTDJ/YC/8+AD5Uh04KHiGl+cIFPnBDDrPMjwRGkLXyxO4VGbfQWnDH2v0bVWE3C9QOXlepbgjEfIJQI6XDG3z5ahD9cw2pS78ipB85wyScNTvsVzlzzhL8/jRrnmVjfFJK/m3m4nj9vbgQTguT8XZTjsm672R5uJKEaQmBI/c58gyus8ZDagLpEVSJBIyHp4jn++xqPV71OgQgJYEWOtZ/haxRtKmWOBu8xdBLftWltsY84zE6WIEy/eIOWL+BaayMx+KHtL7EAkqdNDLiEXmEMUHniedtJqg9HmZtfvt26vNi0BdG3Ft3g8ZOf7PAu59TxtzivLNIekyi+wD1i8CuUiD9FXAa8C+/xS3JPmZnomyc7H+fb4/Se0bk41Fel621r4cgVxbq91V4jVqwB7HTe2M7jgB+QWHavZkDRPmZcASoZEmBx6i75bGjPcMdL4/VKGFAGWZkGzPG0XAbdL9A81G5LOmUnC9hHKJeO7dcUMjblSl12867ElFTtaGl20xvvLGPdVz/8TVuU7y0x1PG7vtNg24oz9Uo/Z412++VFWI7Fcog9tu9Lm6gvRmIPv9x1xmQAu6RDkXtbOtlGEmpgD5Nvnyc0dcv0EE6cfdi1HmhMf9wDF3k3gtRvEedhxjpgfqPb9PU9iEJHnyOUA7bQUXh6kq/D7l2iTjWv7XOD530BDr8jIrus+srXjt4MzumJMHuTsBa63YKE1+RR5lBjEikCCnWKWiHdzOgKO+nRIBAF88za/IFmJ3eMZov4CYxGBabcpGL8EYx+SeMXJeRwHNsV/h+vdxeuhEpN3ZyNY78Gm2fknJxVGhyjixPiQvVkNzT1elD9Py/aTAL64Hb9vcYmC9zfdXdT/C1LeGbg4rnBaAihDFJH12W5ulfNCNe/xTsP3bp8ikzJs5BF+5PNfAQYAPaseTdsEcaYAAAAASUVORK5CYII=' |
| | | } |
| | | }, |
| | | computed: { |
| | | iconSnowWidth() { |
| | | return (Math.floor(this.iconSize / 24) || 1) * 2 |
| | | }, |
| | | contentdownText() { |
| | | return this.contentText.contentdown || t("uni-load-more.contentdown") |
| | | }, |
| | | contentrefreshText() { |
| | | return this.contentText.contentrefresh || t("uni-load-more.contentrefresh") |
| | | }, |
| | | contentnomoreText() { |
| | | return this.contentText.contentnomore || t("uni-load-more.contentnomore") |
| | | } |
| | | }, |
| | | mounted() { |
| | | // #ifdef APP-PLUS |
| | | var pages = getCurrentPages(); |
| | | var page = pages[pages.length - 1]; |
| | | var currentWebview = page.$getAppWebview(); |
| | | currentWebview.addEventListener('hide', () => { |
| | | this.webviewHide = true |
| | | }) |
| | | currentWebview.addEventListener('show', () => { |
| | | this.webviewHide = false |
| | | }) |
| | | // #endif |
| | | }, |
| | | methods: { |
| | | onClick() { |
| | | this.$emit('clickLoadMore', { |
| | | detail: { |
| | | status: this.status, |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" > |
| | | .uni-load-more { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | height: 40px; |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .uni-load-more__text { |
| | | font-size: 14px; |
| | | margin-left: 8px; |
| | | } |
| | | |
| | | .uni-load-more__img { |
| | | width: 24px; |
| | | height: 24px; |
| | | // margin-right: 8px; |
| | | } |
| | | |
| | | .uni-load-more__img--nvue { |
| | | color: #666666; |
| | | } |
| | | |
| | | .uni-load-more__img--android, |
| | | .uni-load-more__img--ios { |
| | | width: 24px; |
| | | height: 24px; |
| | | transform: rotate(0deg); |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | .uni-load-more__img--android { |
| | | animation: loading-ios 1s 0s linear infinite; |
| | | } |
| | | |
| | | @keyframes loading-android { |
| | | 0% { |
| | | transform: rotate(0deg); |
| | | } |
| | | |
| | | 100% { |
| | | transform: rotate(360deg); |
| | | } |
| | | } |
| | | |
| | | .uni-load-more__img--ios-H5 { |
| | | position: relative; |
| | | animation: loading-ios-H5 1s 0s step-end infinite; |
| | | } |
| | | |
| | | .uni-load-more__img--ios-H5 image { |
| | | position: absolute; |
| | | width: 100%; |
| | | height: 100%; |
| | | left: 0; |
| | | top: 0; |
| | | } |
| | | |
| | | @keyframes loading-ios-H5 { |
| | | 0% { |
| | | transform: rotate(0deg); |
| | | } |
| | | |
| | | 8% { |
| | | transform: rotate(30deg); |
| | | } |
| | | |
| | | 16% { |
| | | transform: rotate(60deg); |
| | | } |
| | | |
| | | 24% { |
| | | transform: rotate(90deg); |
| | | } |
| | | |
| | | 32% { |
| | | transform: rotate(120deg); |
| | | } |
| | | |
| | | 40% { |
| | | transform: rotate(150deg); |
| | | } |
| | | |
| | | 48% { |
| | | transform: rotate(180deg); |
| | | } |
| | | |
| | | 56% { |
| | | transform: rotate(210deg); |
| | | } |
| | | |
| | | 64% { |
| | | transform: rotate(240deg); |
| | | } |
| | | |
| | | 73% { |
| | | transform: rotate(270deg); |
| | | } |
| | | |
| | | 82% { |
| | | transform: rotate(300deg); |
| | | } |
| | | |
| | | 91% { |
| | | transform: rotate(330deg); |
| | | } |
| | | |
| | | 100% { |
| | | transform: rotate(360deg); |
| | | } |
| | | } |
| | | |
| | | /* #endif */ |
| | | |
| | | /* #ifdef H5 */ |
| | | .uni-load-more__img--android-H5 { |
| | | animation: loading-android-H5-rotate 2s linear infinite; |
| | | transform-origin: center center; |
| | | } |
| | | |
| | | .uni-load-more__img--android-H5 circle { |
| | | display: inline-block; |
| | | animation: loading-android-H5-dash 1.5s ease-in-out infinite; |
| | | stroke: currentColor; |
| | | stroke-linecap: round; |
| | | } |
| | | |
| | | @keyframes loading-android-H5-rotate { |
| | | 0% { |
| | | transform: rotate(0deg); |
| | | } |
| | | |
| | | 100% { |
| | | transform: rotate(360deg); |
| | | } |
| | | } |
| | | |
| | | @keyframes loading-android-H5-dash { |
| | | 0% { |
| | | stroke-dasharray: 1, 200; |
| | | stroke-dashoffset: 0; |
| | | } |
| | | |
| | | 50% { |
| | | stroke-dasharray: 90, 150; |
| | | stroke-dashoffset: -40; |
| | | } |
| | | |
| | | 100% { |
| | | stroke-dasharray: 90, 150; |
| | | stroke-dashoffset: -120; |
| | | } |
| | | } |
| | | |
| | | /* #endif */ |
| | | |
| | | /* #ifndef APP-NVUE || H5 */ |
| | | .uni-load-more__img--android-MP { |
| | | position: relative; |
| | | width: 24px; |
| | | height: 24px; |
| | | transform: rotate(0deg); |
| | | animation: loading-ios 1s 0s ease infinite; |
| | | } |
| | | |
| | | .uni-load-more__img--android-MP .uni-load-more__img-icon { |
| | | position: absolute; |
| | | box-sizing: border-box; |
| | | width: 100%; |
| | | height: 100%; |
| | | border-radius: 50%; |
| | | border: solid 2px transparent; |
| | | border-top: solid 2px #777777; |
| | | transform-origin: center; |
| | | } |
| | | |
| | | .uni-load-more__img--android-MP .uni-load-more__img-icon:nth-child(1) { |
| | | animation: loading-android-MP-1 1s 0s linear infinite; |
| | | } |
| | | |
| | | .uni-load-more__img--android-MP .uni-load-more__img-icon:nth-child(2) { |
| | | animation: loading-android-MP-2 1s 0s linear infinite; |
| | | } |
| | | |
| | | .uni-load-more__img--android-MP .uni-load-more__img-icon:nth-child(3) { |
| | | animation: loading-android-MP-3 1s 0s linear infinite; |
| | | } |
| | | |
| | | @keyframes loading-android { |
| | | 0% { |
| | | transform: rotate(0deg); |
| | | } |
| | | |
| | | 100% { |
| | | transform: rotate(360deg); |
| | | } |
| | | } |
| | | |
| | | @keyframes loading-android-MP-1 { |
| | | 0% { |
| | | transform: rotate(0deg); |
| | | } |
| | | |
| | | 50% { |
| | | transform: rotate(90deg); |
| | | } |
| | | |
| | | 100% { |
| | | transform: rotate(360deg); |
| | | } |
| | | } |
| | | |
| | | @keyframes loading-android-MP-2 { |
| | | 0% { |
| | | transform: rotate(0deg); |
| | | } |
| | | |
| | | 50% { |
| | | transform: rotate(180deg); |
| | | } |
| | | |
| | | 100% { |
| | | transform: rotate(360deg); |
| | | } |
| | | } |
| | | |
| | | @keyframes loading-android-MP-3 { |
| | | 0% { |
| | | transform: rotate(0deg); |
| | | } |
| | | |
| | | 50% { |
| | | transform: rotate(270deg); |
| | | } |
| | | |
| | | 100% { |
| | | transform: rotate(360deg); |
| | | } |
| | | } |
| | | |
| | | /* #endif */ |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-load-more", |
| | | "displayName": "uni-load-more å è½½æ´å¤", |
| | | "version": "1.3.3", |
| | | "description": "LoadMore ç»ä»¶ï¼å¸¸ç¨å¨å表éé¢ï¼åæ»å¨å 载使ç¨ã", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "å è½½æ´å¤", |
| | | "load-more" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-scss"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ### LoadMore å è½½æ´å¤ |
| | | > **ç»ä»¶åï¼uni-load-more** |
| | | > 代ç åï¼ `uLoadMore` |
| | | |
| | | |
| | | ç¨äºå表ä¸ï¼åæ»å¨å 载使ç¨ï¼å±ç¤º loading çåç§ç¶æã |
| | | |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-load-more) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| | | |
| | | |
| New file |
| | |
| | | ## 1.3.4ï¼2022-01-24ï¼ |
| | | - æ´æ° ç»ä»¶ç¤ºä¾ |
| | | ## 1.3.3ï¼2022-01-24ï¼ |
| | | - æ°å¢ left-width/right-width屿§ ï¼å¯ä¿®æ¹å·¦å³ä¸¤ä¾§ç宽度 |
| | | ## 1.3.2ï¼2022-01-18ï¼ |
| | | - ä¿®å¤ å¨vueä¸ï¼æ é¢ä¸åç´å±
ä¸çbug |
| | | ## 1.3.1ï¼2022-01-18ï¼ |
| | | - ä¿®å¤ height 屿§ç±»åé误 |
| | | ## 1.3.0ï¼2022-01-18ï¼ |
| | | - æ°å¢ height 屿§,å¯ä¿®æ¹ç»ä»¶é«åº¦ |
| | | - æ°å¢ dark 屿§å¯å¯å¼å¯æé»æ¨¡å¼ |
| | | - ä¼å æ é¢åæ°è¿å¤æ¾ç¤ºçç¥å· |
| | | - ä¼å ææ§½ï¼æå
¥å
容å¯å®å
¨è¦ç |
| | | ## 1.2.1ï¼2022-01-10ï¼ |
| | | - ä¿®å¤ color 屿§ä¸çæçbug |
| | | ## 1.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-nav-bar](https://uniapp.dcloud.io/component/uniui/uni-nav-bar) |
| | | ## 1.1.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.0.11ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.10ï¼2021-04-30ï¼ |
| | | - ä¿®å¤ å¨nvueä¸fixed为trueï¼å®½åº¦ä¸è½ææ»¡çBug |
| | | ## 1.0.9ï¼2021-04-21ï¼ |
| | | - ä¼å æ·»å ä¾èµ uni-icons, 导å
¥åèªå¨ä¸è½½ä¾èµ |
| | | ## 1.0.8ï¼2021-04-14ï¼ |
| | | - uni-ui ä¿®å¤ uni-nav-bar å½ fixed 屿§ä¸º true æ¶éºä¸æ»¡å±å¹ç bug |
| | | |
| | | ## 1.0.7ï¼2021-02-25ï¼ |
| | | - ä¿®å¤ easycom ä¸ï¼æ¾ä¸å° uni-status-bar çbug |
| | | |
| | | ## 1.0.6ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | |
| | | ## 1.0.5ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | <template> |
| | | <view class="uni-navbar" :class="{'uni-dark':dark}"> |
| | | <view :class="{ 'uni-navbar--fixed': fixed, 'uni-navbar--shadow': shadow, 'uni-navbar--border': border }" |
| | | :style="{ 'background-color': themeBgColor }" class="uni-navbar__content"> |
| | | <status-bar v-if="statusBar" /> |
| | | <view :style="{ color: themeColor,backgroundColor: themeBgColor ,height:navbarHeight}" |
| | | class="uni-navbar__header"> |
| | | <view @tap="onClickLeft" class="uni-navbar__header-btns uni-navbar__header-btns-left" |
| | | :style="{width:leftIconWidth}"> |
| | | <slot name="left"> |
| | | <view class="uni-navbar__content_view" v-if="leftIcon.length > 0"> |
| | | <uni-icons :color="themeColor" :type="leftIcon" size="20" /> |
| | | </view> |
| | | <view :class="{ 'uni-navbar-btn-icon-left': !leftIcon.length > 0 }" class="uni-navbar-btn-text" |
| | | v-if="leftText.length"> |
| | | <text :style="{ color: themeColor, fontSize: '12px' }">{{ leftText }}</text> |
| | | </view> |
| | | </slot> |
| | | </view> |
| | | <view class="uni-navbar__header-container " @tap="onClickTitle"> |
| | | <slot> |
| | | <view class="uni-navbar__header-container-inner" v-if="title.length>0"> |
| | | <text class="uni-nav-bar-text uni-ellipsis-1" |
| | | :style="{color: themeColor }">{{ title }}</text> |
| | | </view> |
| | | </slot> |
| | | </view> |
| | | <view @click="onClickRight" class="uni-navbar__header-btns uni-navbar__header-btns-right" |
| | | :style="{width:rightIconWidth}"> |
| | | <slot name="right"> |
| | | <view v-if="rightIcon.length"> |
| | | <uni-icons :color="themeColor" :type="rightIcon" size="22" /> |
| | | </view> |
| | | <view class="uni-navbar-btn-text" v-if="rightText.length && !rightIcon.length"> |
| | | <text class="uni-nav-bar-right-text" :style="{ color: themeColor}">{{ rightText }}</text> |
| | | </view> |
| | | </slot> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view class="uni-navbar__placeholder" v-if="fixed"> |
| | | <status-bar v-if="statusBar" /> |
| | | <view class="uni-navbar__placeholder-view" :style="{ height:navbarHeight}" /> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import statusBar from "./uni-status-bar.vue"; |
| | | const getVal = (val) => typeof val === 'number' ? val + 'px' : val; |
| | | |
| | | /** |
| | | * NavBar èªå®ä¹å¯¼èªæ |
| | | * @description å¯¼èªæ ç»ä»¶ï¼ä¸»è¦ç¨äºå¤´é¨å¯¼èª |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=52 |
| | | * @property {Boolean} dark å¼å¯é»ææ¨¡å¼ |
| | | * @property {String} title æ 颿å |
| | | * @property {String} leftText 左侧æé®ææ¬ |
| | | * @property {String} rightText å³ä¾§æé®ææ¬ |
| | | * @property {String} leftIcon 左侧æé®å¾æ ï¼å¾æ ç±»ååè [Icon 徿 ](http://ext.dcloud.net.cn/plugin?id=28) type 屿§ï¼ |
| | | * @property {String} rightIcon å³ä¾§æé®å¾æ ï¼å¾æ ç±»ååè [Icon 徿 ](http://ext.dcloud.net.cn/plugin?id=28) type 屿§ï¼ |
| | | * @property {String} color 徿 åæåé¢è² |
| | | * @property {String} backgroundColor å¯¼èªæ èæ¯é¢è² |
| | | * @property {Boolean} fixed = [true|false] æ¯å¦åºå®é¡¶é¨ |
| | | * @property {Boolean} statusBar = [true|false] æ¯å¦å
å«ç¶ææ |
| | | * @property {Boolean} shadow = [true|false] å¯¼èªæ 䏿¯å¦æé´å½± |
| | | * @event {Function} clickLeft 左侧æé®ç¹å»æ¶è§¦å |
| | | * @event {Function} clickRight å³ä¾§æé®ç¹å»æ¶è§¦å |
| | | * @event {Function} clickTitle ä¸é´æ é¢ç¹å»æ¶è§¦å |
| | | */ |
| | | export default { |
| | | name: "UniNavBar", |
| | | components: { |
| | | statusBar |
| | | }, |
| | | emits: ['clickLeft', 'clickRight', 'clickTitle'], |
| | | props: { |
| | | dark: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | title: { |
| | | type: String, |
| | | default: "" |
| | | }, |
| | | leftText: { |
| | | type: String, |
| | | default: "" |
| | | }, |
| | | rightText: { |
| | | type: String, |
| | | default: "" |
| | | }, |
| | | leftIcon: { |
| | | type: String, |
| | | default: "" |
| | | }, |
| | | rightIcon: { |
| | | type: String, |
| | | default: "" |
| | | }, |
| | | fixed: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | color: { |
| | | type: String, |
| | | default: "" |
| | | }, |
| | | backgroundColor: { |
| | | type: String, |
| | | default: "" |
| | | }, |
| | | statusBar: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | shadow: { |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | border: { |
| | | type: [Boolean, String], |
| | | default: true |
| | | }, |
| | | height: { |
| | | type: [Number, String], |
| | | default: 44 |
| | | }, |
| | | leftWidth: { |
| | | type: [Number, String], |
| | | default: 60 |
| | | }, |
| | | rightWidth: { |
| | | type: [Number, String], |
| | | default: 60 |
| | | }, |
| | | }, |
| | | computed: { |
| | | themeBgColor() { |
| | | if (this.dark) { |
| | | // é»è®¤å¼ |
| | | if (this.backgroundColor) { |
| | | return this.backgroundColor |
| | | } else { |
| | | return this.dark ? '#333' : '#FFF' |
| | | } |
| | | } |
| | | return this.backgroundColor || '#FFF' |
| | | }, |
| | | themeColor() { |
| | | if (this.dark) { |
| | | // é»è®¤å¼ |
| | | if (this.color) { |
| | | return this.color |
| | | } else { |
| | | return this.dark ? '#fff' : '#333' |
| | | } |
| | | } |
| | | return this.color || '#333' |
| | | }, |
| | | navbarHeight() { |
| | | return getVal(this.height) |
| | | }, |
| | | leftIconWidth() { |
| | | return getVal(this.leftWidth) |
| | | }, |
| | | rightIconWidth() { |
| | | return getVal(this.rightWidth) |
| | | } |
| | | }, |
| | | mounted() { |
| | | if (uni.report && this.title !== '') { |
| | | uni.report('title', this.title) |
| | | } |
| | | }, |
| | | methods: { |
| | | onClickLeft() { |
| | | this.$emit("clickLeft"); |
| | | }, |
| | | onClickRight() { |
| | | this.$emit("clickRight"); |
| | | }, |
| | | onClickTitle() { |
| | | this.$emit("clickTitle"); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | $nav-height: 44px; |
| | | |
| | | .uni-navbar { |
| | | // box-sizing: border-box; |
| | | } |
| | | |
| | | .uni-nav-bar-text { |
| | | /* #ifdef APP-PLUS */ |
| | | font-size: 34rpx; |
| | | /* #endif */ |
| | | /* #ifndef APP-PLUS */ |
| | | font-size: 14px; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-nav-bar-right-text { |
| | | font-size: 12px; |
| | | } |
| | | |
| | | .uni-navbar__content { |
| | | position: relative; |
| | | // background-color: #fff; |
| | | // box-sizing: border-box; |
| | | background-color: transparent; |
| | | } |
| | | |
| | | .uni-navbar__content_view { |
| | | // box-sizing: border-box; |
| | | } |
| | | |
| | | .uni-navbar-btn-text { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: column; |
| | | justify-content: flex-start; |
| | | align-items: center; |
| | | line-height: 12px; |
| | | } |
| | | |
| | | .uni-navbar__header { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | padding: 0 10px; |
| | | flex-direction: row; |
| | | height: $nav-height; |
| | | font-size: 12px; |
| | | } |
| | | |
| | | .uni-navbar__header-btns { |
| | | /* #ifndef APP-NVUE */ |
| | | overflow: hidden; |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-wrap: nowrap; |
| | | flex-direction: row; |
| | | width: 120rpx; |
| | | // padding: 0 6px; |
| | | justify-content: center; |
| | | align-items: center; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-navbar__header-btns-left { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | width: 120rpx; |
| | | justify-content: flex-start; |
| | | align-items: center; |
| | | } |
| | | |
| | | .uni-navbar__header-btns-right { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | // width: 150rpx; |
| | | // padding-right: 30rpx; |
| | | justify-content: flex-end; |
| | | align-items: center; |
| | | } |
| | | |
| | | .uni-navbar__header-container { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex: 1; |
| | | padding: 0 10px; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-navbar__header-container-inner { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex: 1; |
| | | flex-direction: row; |
| | | align-items: center; |
| | | justify-content: center; |
| | | font-size: 12px; |
| | | overflow: hidden; |
| | | // box-sizing: border-box; |
| | | } |
| | | |
| | | |
| | | .uni-navbar__placeholder-view { |
| | | height: $nav-height; |
| | | } |
| | | |
| | | .uni-navbar--fixed { |
| | | position: fixed; |
| | | z-index: 998; |
| | | /* #ifdef H5 */ |
| | | left: var(--window-left); |
| | | right: var(--window-right); |
| | | /* #endif */ |
| | | /* #ifndef H5 */ |
| | | left: 0; |
| | | right: 0; |
| | | /* #endif */ |
| | | |
| | | } |
| | | |
| | | .uni-navbar--shadow { |
| | | box-shadow: 0 1px 6px #ccc; |
| | | } |
| | | |
| | | .uni-navbar--border { |
| | | border-bottom-width: 1rpx; |
| | | border-bottom-style: solid; |
| | | border-bottom-color: #eee; |
| | | } |
| | | |
| | | .uni-ellipsis-1 { |
| | | overflow: hidden; |
| | | /* #ifndef APP-NVUE */ |
| | | white-space: nowrap; |
| | | text-overflow: ellipsis; |
| | | /* #endif */ |
| | | /* #ifdef APP-NVUE */ |
| | | lines: 1; |
| | | text-overflow: ellipsis; |
| | | /* #endif */ |
| | | } |
| | | |
| | | // æä¸»é¢é
ç½® |
| | | .uni-dark {} |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view :style="{ height: statusBarHeight }" class="uni-status-bar"> |
| | | <slot /> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: 'UniStatusBar', |
| | | data() { |
| | | return { |
| | | statusBarHeight: 20 |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px' |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" > |
| | | .uni-status-bar { |
| | | // width: 750rpx; |
| | | height: 20px; |
| | | // height: var(--status-bar-height); |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-nav-bar", |
| | | "displayName": "uni-nav-bar èªå®ä¹å¯¼èªæ ", |
| | | "version": "1.3.4", |
| | | "description": "èªå®ä¹å¯¼èªæ ç»ä»¶ï¼ä¸»è¦ç¨äºå¤´é¨å¯¼èªã", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "导èª", |
| | | "å¯¼èªæ ", |
| | | "èªå®ä¹å¯¼èªæ " |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## NavBar å¯¼èªæ |
| | | > **ç»ä»¶åï¼uni-nav-bar** |
| | | > 代ç åï¼ `uNavBar` |
| | | |
| | | å¯¼èªæ ç»ä»¶ï¼ä¸»è¦ç¨äºå¤´é¨å¯¼èªã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-nav-bar) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| | | |
| | | |
| | | |
| | | |
| | | |
| New file |
| | |
| | | ## 1.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-notice-bar](https://uniapp.dcloud.io/component/uniui/uni-notice-bar) |
| | | ## 1.1.1ï¼2021-11-09ï¼ |
| | | - æ°å¢ æä¾ç»ä»¶è®¾è®¡èµæºï¼ç»ä»¶æ ·å¼è°æ´ |
| | | ## 1.1.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.0.9ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.8ï¼2021-04-21ï¼ |
| | | - ä¼å æ·»å ä¾èµ uni-icons, 导å
¥åèªå¨ä¸è½½ä¾èµ |
| | | ## 1.0.7ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | |
| | | ## 1.0.6ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | <template> |
| | | <view v-if="show" class="uni-noticebar" :style="{ backgroundColor: backgroundColor }" @click="onClick"> |
| | | <uni-icons v-if="showIcon === true || showIcon === 'true'" class="uni-noticebar-icon" type="sound" |
| | | :color="color" size="22" /> |
| | | <view ref="textBox" class="uni-noticebar__content-wrapper" |
| | | :class="{'uni-noticebar__content-wrapper--scrollable':scrollable, 'uni-noticebar__content-wrapper--single':!scrollable && (single || moreText)}"> |
| | | <view :id="elIdBox" class="uni-noticebar__content" |
| | | :class="{'uni-noticebar__content--scrollable':scrollable, 'uni-noticebar__content--single':!scrollable && (single || moreText)}"> |
| | | <text :id="elId" ref="animationEle" class="uni-noticebar__content-text" |
| | | :class="{'uni-noticebar__content-text--scrollable':scrollable,'uni-noticebar__content-text--single':!scrollable && (single || showGetMore)}" |
| | | :style="{color:color, width:wrapWidth+'px', 'animationDuration': animationDuration, '-webkit-animationDuration': animationDuration ,animationPlayState: webviewHide?'paused':animationPlayState,'-webkit-animationPlayState':webviewHide?'paused':animationPlayState, animationDelay: animationDelay, '-webkit-animationDelay':animationDelay}">{{text}}</text> |
| | | </view> |
| | | </view> |
| | | <view v-if="showGetMore === true || showGetMore === 'true'" class="uni-noticebar__more uni-cursor-point" |
| | | @click="clickMore"> |
| | | <text v-if="moreText.length > 0" :style="{ color: moreColor }" class="uni-noticebar__more-text">{{ moreText }}</text> |
| | | <uni-icons v-else type="right" :color="moreColor" size="16" /> |
| | | </view> |
| | | <view class="uni-noticebar-close uni-cursor-point" v-if="(showClose === true || showClose === 'true') && (showGetMore === false || showGetMore === 'false')"> |
| | | <uni-icons |
| | | type="closeempty" :color="color" size="16" @click="close" /> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | // #ifdef APP-NVUE |
| | | const dom = weex.requireModule('dom'); |
| | | const animation = weex.requireModule('animation'); |
| | | // #endif |
| | | |
| | | /** |
| | | * NoticeBar èªå®ä¹å¯¼èªæ |
| | | * @description éåæ ç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=30 |
| | | * @property {Number} speed æåæ»å¨çé度ï¼é»è®¤100px/ç§ |
| | | * @property {String} text æ¾ç¤ºæå |
| | | * @property {String} backgroundColor èæ¯é¢è² |
| | | * @property {String} color æåé¢è² |
| | | * @property {String} moreColor æ¥çæ´å¤æåçé¢è² |
| | | * @property {String} moreText è®¾ç½®âæ¥çæ´å¤âçææ¬ |
| | | * @property {Boolean} single = [true|false] æ¯å¦åè¡ |
| | | * @property {Boolean} scrollable = [true|false] æ¯å¦æ»å¨ï¼ä¸ºtrueæ¶ï¼NoticeBar为åè¡ |
| | | * @property {Boolean} showIcon = [true|false] æ¯å¦æ¾ç¤ºå·¦ä¾§åå徿 |
| | | * @property {Boolean} showClose = [true|false] æ¯å¦æ¾ç¤ºå·¦ä¾§å
³éæé® |
| | | * @property {Boolean} showGetMore = [true|false] æ¯å¦æ¾ç¤ºå³ä¾§æ¥çæ´å¤å¾æ ï¼ä¸ºtrueæ¶ï¼NoticeBar为åè¡ |
| | | * @event {Function} click ç¹å» NoticeBar 触åäºä»¶ |
| | | * @event {Function} close å
³é NoticeBar 触åäºä»¶ |
| | | * @event {Function} getmore ç¹å»âæ¥çæ´å¤âæ¶è§¦åäºä»¶ |
| | | */ |
| | | |
| | | export default { |
| | | name: 'UniNoticeBar', |
| | | emits: ['click', 'getmore', 'close'], |
| | | props: { |
| | | text: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | moreText: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | backgroundColor: { |
| | | type: String, |
| | | default: '#FFF9EA' |
| | | }, |
| | | speed: { |
| | | // é»è®¤1sæ»å¨100px |
| | | type: Number, |
| | | default: 100 |
| | | }, |
| | | color: { |
| | | type: String, |
| | | default: '#FF9A43' |
| | | }, |
| | | moreColor: { |
| | | type: String, |
| | | default: '#FF9A43' |
| | | }, |
| | | single: { |
| | | // æ¯å¦åè¡ |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | scrollable: { |
| | | // æ¯å¦æ»å¨ï¼æ·»å åæ§å¶åè¡ææåæ¶ |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | showIcon: { |
| | | // æ¯å¦æ¾ç¤ºå·¦ä¾§icon |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | showGetMore: { |
| | | // æ¯å¦æ¾ç¤ºå³ä¾§æ¥çæ´å¤ |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | showClose: { |
| | | // æ¯å¦æ¾ç¤ºå·¦ä¾§å
³éæé® |
| | | type: [Boolean, String], |
| | | default: false |
| | | } |
| | | }, |
| | | data() { |
| | | const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}` |
| | | const elIdBox = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}` |
| | | return { |
| | | textWidth: 0, |
| | | boxWidth: 0, |
| | | wrapWidth: '', |
| | | webviewHide: false, |
| | | // #ifdef APP-NVUE |
| | | stopAnimation: false, |
| | | // #endif |
| | | elId: elId, |
| | | elIdBox: elIdBox, |
| | | show: true, |
| | | animationDuration: 'none', |
| | | animationPlayState: 'paused', |
| | | animationDelay: '0s' |
| | | } |
| | | }, |
| | | mounted() { |
| | | // #ifdef APP-PLUS |
| | | var pages = getCurrentPages(); |
| | | var page = pages[pages.length - 1]; |
| | | var currentWebview = page.$getAppWebview(); |
| | | currentWebview.addEventListener('hide', () => { |
| | | this.webviewHide = true |
| | | }) |
| | | currentWebview.addEventListener('show', () => { |
| | | this.webviewHide = false |
| | | }) |
| | | // #endif |
| | | this.$nextTick(() => { |
| | | this.initSize() |
| | | }) |
| | | }, |
| | | // #ifdef APP-NVUE |
| | | beforeDestroy() { |
| | | this.stopAnimation = true |
| | | }, |
| | | // #endif |
| | | methods: { |
| | | initSize() { |
| | | if (this.scrollable) { |
| | | // #ifndef APP-NVUE |
| | | let query = [], |
| | | boxWidth = 0, |
| | | textWidth = 0; |
| | | let textQuery = new Promise((resolve, reject) => { |
| | | uni.createSelectorQuery() |
| | | // #ifndef MP-ALIPAY |
| | | .in(this) |
| | | // #endif |
| | | .select(`#${this.elId}`) |
| | | .boundingClientRect() |
| | | .exec(ret => { |
| | | this.textWidth = ret[0].width |
| | | resolve() |
| | | }) |
| | | }) |
| | | let boxQuery = new Promise((resolve, reject) => { |
| | | uni.createSelectorQuery() |
| | | // #ifndef MP-ALIPAY |
| | | .in(this) |
| | | // #endif |
| | | .select(`#${this.elIdBox}`) |
| | | .boundingClientRect() |
| | | .exec(ret => { |
| | | this.boxWidth = ret[0].width |
| | | resolve() |
| | | }) |
| | | }) |
| | | query.push(textQuery) |
| | | query.push(boxQuery) |
| | | Promise.all(query).then(() => { |
| | | this.animationDuration = `${this.textWidth / this.speed}s` |
| | | this.animationDelay = `-${this.boxWidth / this.speed}s` |
| | | setTimeout(() => { |
| | | this.animationPlayState = 'running' |
| | | }, 1000) |
| | | }) |
| | | // #endif |
| | | // #ifdef APP-NVUE |
| | | dom.getComponentRect(this.$refs['animationEle'], (res) => { |
| | | let winWidth = uni.getSystemInfoSync().windowWidth |
| | | this.textWidth = res.size.width |
| | | animation.transition(this.$refs['animationEle'], { |
| | | styles: { |
| | | transform: `translateX(-${winWidth}px)` |
| | | }, |
| | | duration: 0, |
| | | timingFunction: 'linear', |
| | | delay: 0 |
| | | }, () => { |
| | | if (!this.stopAnimation) { |
| | | animation.transition(this.$refs['animationEle'], { |
| | | styles: { |
| | | transform: `translateX(-${this.textWidth}px)` |
| | | }, |
| | | timingFunction: 'linear', |
| | | duration: (this.textWidth - winWidth) / this.speed * 1000, |
| | | delay: 1000 |
| | | }, () => { |
| | | if (!this.stopAnimation) { |
| | | this.loopAnimation() |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }) |
| | | // #endif |
| | | } |
| | | // #ifdef APP-NVUE |
| | | if (!this.scrollable && (this.single || this.moreText)) { |
| | | dom.getComponentRect(this.$refs['textBox'], (res) => { |
| | | this.wrapWidth = res.size.width |
| | | }) |
| | | } |
| | | // #endif |
| | | }, |
| | | loopAnimation() { |
| | | // #ifdef APP-NVUE |
| | | animation.transition(this.$refs['animationEle'], { |
| | | styles: { |
| | | transform: `translateX(0px)` |
| | | }, |
| | | duration: 0 |
| | | }, () => { |
| | | if (!this.stopAnimation) { |
| | | animation.transition(this.$refs['animationEle'], { |
| | | styles: { |
| | | transform: `translateX(-${this.textWidth}px)` |
| | | }, |
| | | duration: this.textWidth / this.speed * 1000, |
| | | timingFunction: 'linear', |
| | | delay: 0 |
| | | }, () => { |
| | | if (!this.stopAnimation) { |
| | | this.loopAnimation() |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | // #endif |
| | | }, |
| | | clickMore() { |
| | | this.$emit('getmore') |
| | | }, |
| | | close() { |
| | | this.show = false; |
| | | this.$emit('close') |
| | | }, |
| | | onClick() { |
| | | this.$emit('click') |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .uni-noticebar { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | width: 100%; |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | align-items: center; |
| | | padding: 10px 12px; |
| | | margin-bottom: 10px; |
| | | } |
| | | |
| | | .uni-cursor-point { |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-noticebar-close { |
| | | margin-left: 8px; |
| | | margin-right: 5px; |
| | | } |
| | | |
| | | .uni-noticebar-icon { |
| | | margin-right: 5px; |
| | | } |
| | | |
| | | .uni-noticebar__content-wrapper { |
| | | flex: 1; |
| | | flex-direction: column; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .uni-noticebar__content-wrapper--single { |
| | | /* #ifndef APP-NVUE */ |
| | | line-height: 18px; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-noticebar__content-wrapper--single, |
| | | .uni-noticebar__content-wrapper--scrollable { |
| | | flex-direction: row; |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | .uni-noticebar__content-wrapper--scrollable { |
| | | position: relative; |
| | | height: 18px; |
| | | } |
| | | |
| | | /* #endif */ |
| | | |
| | | .uni-noticebar__content--scrollable { |
| | | /* #ifdef APP-NVUE */ |
| | | flex: 0; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | flex: 1; |
| | | display: block; |
| | | overflow: hidden; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-noticebar__content--single { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | flex: none; |
| | | width: 100%; |
| | | justify-content: center; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-noticebar__content-text { |
| | | font-size: 14px; |
| | | line-height: 18px; |
| | | /* #ifndef APP-NVUE */ |
| | | word-break: break-all; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-noticebar__content-text--single { |
| | | /* #ifdef APP-NVUE */ |
| | | lines: 1; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | display: block; |
| | | width: 100%; |
| | | white-space: nowrap; |
| | | /* #endif */ |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | } |
| | | |
| | | .uni-noticebar__content-text--scrollable { |
| | | /* #ifdef APP-NVUE */ |
| | | lines: 1; |
| | | padding-left: 750rpx; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | position: absolute; |
| | | display: block; |
| | | height: 18px; |
| | | line-height: 18px; |
| | | white-space: nowrap; |
| | | padding-left: 100%; |
| | | animation: notice 10s 0s linear infinite both; |
| | | animation-play-state: paused; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-noticebar__more { |
| | | /* #ifndef APP-NVUE */ |
| | | display: inline-flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | flex-wrap: nowrap; |
| | | align-items: center; |
| | | padding-left: 5px; |
| | | } |
| | | |
| | | .uni-noticebar__more-text { |
| | | font-size: 14px; |
| | | } |
| | | |
| | | @keyframes notice { |
| | | 100% { |
| | | transform: translate3d(-100%, 0, 0); |
| | | } |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-notice-bar", |
| | | "displayName": "uni-notice-bar éåæ ", |
| | | "version": "1.2.0", |
| | | "description": "NoticeBar éåæ ç»ä»¶ï¼å¸¸ç¨äºå±ç¤ºå
¬åä¿¡æ¯ï¼å¯è®¾ä¸ºæ»å¨å
Œ", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "éåæ ", |
| | | "å
Œ", |
| | | "è·é©¬ç¯" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## NoticeBar éåæ |
| | | > **ç»ä»¶åï¼uni-notice-bar** |
| | | > 代ç åï¼ `uNoticeBar` |
| | | |
| | | |
| | | éåæ ç»ä»¶ ã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-notice-bar) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| | | |
| | | |
| New file |
| | |
| | | ## 1.2.1ï¼2021-11-22ï¼ |
| | | - ä¿®å¤ vue3䏿äºscssåéæ æ³æ¾å°çé®é¢ |
| | | ## 1.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-pagination](https://uniapp.dcloud.io/component/uniui/uni-pagination) |
| | | ## 1.1.2ï¼2021-10-08ï¼ |
| | | - ä¿®å¤ current ãvalue 屿§æªçå¬ï¼å¯¼è´é«äº®æ ·å¼å¤±æç bug |
| | | ## 1.1.1ï¼2021-08-20ï¼ |
| | | - æ°å¢ æ¯æå½é
å |
| | | ## 1.1.0ï¼2021-07-30ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.0.7ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.0.6ï¼2021-04-12ï¼ |
| | | - æ°å¢ PC å ç§»å¨ç«¯éé
ä¸åç ui |
| | | ## 1.0.5ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | |
| | | ## 1.0.4ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| New file |
| | |
| | | { |
| | | "uni-pagination.prevText": "prev", |
| | | "uni-pagination.nextText": "next" |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-pagination.prevText": "anterior", |
| | | "uni-pagination.nextText": "próxima" |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-pagination.prevText": "précédente", |
| | | "uni-pagination.nextText": "suivante" |
| | | } |
| New file |
| | |
| | | import en from './en.json' |
| | | import es from './es.json' |
| | | import fr from './fr.json' |
| | | import zhHans from './zh-Hans.json' |
| | | import zhHant from './zh-Hant.json' |
| | | export default { |
| | | en, |
| | | es, |
| | | fr, |
| | | 'zh-Hans': zhHans, |
| | | 'zh-Hant': zhHant |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-pagination.prevText": "ä¸ä¸é¡µ", |
| | | "uni-pagination.nextText": "ä¸ä¸é¡µ" |
| | | } |
| New file |
| | |
| | | { |
| | | "uni-pagination.prevText": "ä¸ä¸é ", |
| | | "uni-pagination.nextText": "ä¸ä¸é " |
| | | } |
| New file |
| | |
| | | <template> |
| | | <view class="uni-pagination"> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <view class="uni-pagination__total is-phone-hide">å
± {{ total }} æ¡</view> |
| | | <!-- #endif --> |
| | | <view class="uni-pagination__btn" |
| | | :class="currentIndex === 1 ? 'uni-pagination--disabled' : 'uni-pagination--enabled'" |
| | | :hover-class="currentIndex === 1 ? '' : 'uni-pagination--hover'" :hover-start-time="20" |
| | | :hover-stay-time="70" @click="clickLeft"> |
| | | <template v-if="showIcon === true || showIcon === 'true'"> |
| | | <uni-icons color="#666" size="16" type="left" /> |
| | | </template> |
| | | <template v-else> |
| | | <text class="uni-pagination__child-btn">{{ prevPageText }}</text> |
| | | </template> |
| | | </view> |
| | | <view class="uni-pagination__num uni-pagination__num-flex-none"> |
| | | <view class="uni-pagination__num-current"> |
| | | <text class="uni-pagination__num-current-text is-pc-hide" |
| | | style="color:#409EFF">{{ currentIndex }}</text> |
| | | <text class="uni-pagination__num-current-text is-pc-hide">/{{ maxPage || 0 }}</text> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <view v-for="(item, index) in paper" :key="index" :class="{ 'page--active': item === currentIndex }" |
| | | class="uni-pagination__num-tag tag--active is-phone-hide" @click.top="selectPage(item, index)"> |
| | | <text>{{ item }}</text> |
| | | </view> |
| | | <!-- #endif --> |
| | | |
| | | </view> |
| | | </view> |
| | | <view class="uni-pagination__btn" |
| | | :class="currentIndex >= maxPage ? 'uni-pagination--disabled' : 'uni-pagination--enabled'" |
| | | :hover-class="currentIndex === maxPage ? '' : 'uni-pagination--hover'" :hover-start-time="20" |
| | | :hover-stay-time="70" @click="clickRight"> |
| | | <template v-if="showIcon === true || showIcon === 'true'"> |
| | | <uni-icons color="#666" size="16" type="right" /> |
| | | </template> |
| | | <template v-else> |
| | | <text class="uni-pagination__child-btn">{{ nextPageText }}</text> |
| | | </template> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * Pagination åé¡µå¨ |
| | | * @description å页å¨ç»ä»¶ï¼ç¨äºå±ç¤ºé¡µç ãè¯·æ±æ°æ®ç |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=32 |
| | | * @property {String} prevText 左侧æé®æå |
| | | * @property {String} nextText å³ä¾§æé®æå |
| | | * @property {Number} current å½å页 |
| | | * @property {Number} total æ°æ®æ»é |
| | | * @property {Number} pageSize æ¯é¡µæ°æ®é |
| | | * @property {Number} showIcon = [true|false] æ¯å¦ä»¥ icon å½¢å¼å±ç¤ºæé® |
| | | * @event {Function} change ç¹å»é¡µç æé®æ¶è§¦å ,e={type,current} current为å½å页ï¼typeå¼ä¸ºï¼next/prevï¼è¡¨ç¤ºç¹å»çæ¯ä¸ä¸é¡µè¿æ¯ä¸ä¸ä¸ª |
| | | */ |
| | | |
| | | import { |
| | | initVueI18n |
| | | } from '@dcloudio/uni-i18n' |
| | | import messages from './i18n/index.js' |
| | | const { |
| | | t |
| | | } = initVueI18n(messages) |
| | | export default { |
| | | name: 'UniPagination', |
| | | emits: ['update:modelValue', 'input', 'change'], |
| | | props: { |
| | | value: { |
| | | type: [Number, String], |
| | | default: 1 |
| | | }, |
| | | modelValue: { |
| | | type: [Number, String], |
| | | default: 1 |
| | | }, |
| | | prevText: { |
| | | type: String, |
| | | }, |
| | | nextText: { |
| | | type: String, |
| | | }, |
| | | current: { |
| | | type: [Number, String], |
| | | default: 1 |
| | | }, |
| | | total: { |
| | | // æ°æ®æ»é |
| | | type: [Number, String], |
| | | default: 0 |
| | | }, |
| | | pageSize: { |
| | | // æ¯é¡µæ°æ®é |
| | | type: [Number, String], |
| | | default: 10 |
| | | }, |
| | | showIcon: { |
| | | // æ¯å¦ä»¥ icon å½¢å¼å±ç¤ºæé® |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | pagerCount: { |
| | | type: Number, |
| | | default: 7 |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | currentIndex: 1, |
| | | paperData: [] |
| | | } |
| | | }, |
| | | computed: { |
| | | prevPageText() { |
| | | return this.prevText || t('uni-pagination.prevText') |
| | | }, |
| | | nextPageText() { |
| | | return this.nextText || t('uni-pagination.nextText') |
| | | }, |
| | | maxPage() { |
| | | let maxPage = 1 |
| | | let total = Number(this.total) |
| | | let pageSize = Number(this.pageSize) |
| | | if (total && pageSize) { |
| | | maxPage = Math.ceil(total / pageSize) |
| | | } |
| | | return maxPage |
| | | }, |
| | | paper() { |
| | | const num = this.currentIndex |
| | | // TODO æå¤§é¡µæ° |
| | | const pagerCount = this.pagerCount |
| | | // const total = 181 |
| | | const total = this.total |
| | | const pageSize = this.pageSize |
| | | let totalArr = [] |
| | | let showPagerArr = [] |
| | | let pagerNum = Math.ceil(total / pageSize) |
| | | for (let i = 0; i < pagerNum; i++) { |
| | | totalArr.push(i + 1) |
| | | } |
| | | showPagerArr.push(1) |
| | | const totalNum = totalArr[totalArr.length - (pagerCount + 1) / 2] |
| | | totalArr.forEach((item, index) => { |
| | | if ((pagerCount + 1) / 2 >= num) { |
| | | if (item < pagerCount + 1 && item > 1) { |
| | | showPagerArr.push(item) |
| | | } |
| | | } else if (num + 2 <= totalNum) { |
| | | if (item > num - (pagerCount + 1) / 2 && item < num + (pagerCount + 1) / 2) { |
| | | showPagerArr.push(item) |
| | | } |
| | | } else { |
| | | if ((item > num - (pagerCount + 1) / 2 || pagerNum - pagerCount < item) && item < totalArr[ |
| | | totalArr.length - 1]) { |
| | | showPagerArr.push(item) |
| | | } |
| | | } |
| | | }) |
| | | if (pagerNum > pagerCount) { |
| | | if ((pagerCount + 1) / 2 >= num) { |
| | | showPagerArr[showPagerArr.length - 1] = '...' |
| | | } else if (num + 2 <= totalNum) { |
| | | showPagerArr[1] = '...' |
| | | showPagerArr[showPagerArr.length - 1] = '...' |
| | | } else { |
| | | showPagerArr[1] = '...' |
| | | } |
| | | showPagerArr.push(totalArr[totalArr.length - 1]) |
| | | } else { |
| | | if ((pagerCount + 1) / 2 >= num) {} else if (num + 2 <= totalNum) {} else { |
| | | showPagerArr.shift() |
| | | showPagerArr.push(totalArr[totalArr.length - 1]) |
| | | } |
| | | } |
| | | |
| | | return showPagerArr |
| | | } |
| | | }, |
| | | watch: { |
| | | current: { |
| | | immediate: true, |
| | | handler(val, old) { |
| | | if (val < 1) { |
| | | this.currentIndex = 1 |
| | | } else { |
| | | this.currentIndex = val |
| | | } |
| | | } |
| | | }, |
| | | value: { |
| | | immediate: true, |
| | | handler(val) { |
| | | if (Number(this.current) !== 1) return |
| | | if (val < 1) { |
| | | this.currentIndex = 1 |
| | | } else { |
| | | this.currentIndex = val |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | // éæ©æ ç¾ |
| | | selectPage(e, index) { |
| | | if (parseInt(e)) { |
| | | this.currentIndex = e |
| | | this.change('current') |
| | | } else { |
| | | let pagerNum = Math.ceil(this.total / this.pageSize) |
| | | // let pagerNum = Math.ceil(181 / this.pageSize) |
| | | // ä¸ä¸é¡µ |
| | | if (index <= 1) { |
| | | if (this.currentIndex - 5 > 1) { |
| | | this.currentIndex -= 5 |
| | | } else { |
| | | this.currentIndex = 1 |
| | | } |
| | | return |
| | | } |
| | | // ä¸ä¸é¡µ |
| | | if (index >= 6) { |
| | | if (this.currentIndex + 5 > pagerNum) { |
| | | this.currentIndex = pagerNum |
| | | } else { |
| | | this.currentIndex += 5 |
| | | } |
| | | return |
| | | } |
| | | } |
| | | }, |
| | | clickLeft() { |
| | | if (Number(this.currentIndex) === 1) { |
| | | return |
| | | } |
| | | this.currentIndex -= 1 |
| | | this.change('prev') |
| | | }, |
| | | clickRight() { |
| | | if (Number(this.currentIndex) >= this.maxPage) { |
| | | return |
| | | } |
| | | this.currentIndex += 1 |
| | | this.change('next') |
| | | }, |
| | | change(e) { |
| | | this.$emit('input', this.currentIndex) |
| | | this.$emit('update:modelValue', this.currentIndex) |
| | | this.$emit('change', { |
| | | type: e, |
| | | current: this.currentIndex |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | $uni-primary: #2979ff; |
| | | .uni-pagination { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | position: relative; |
| | | overflow: hidden; |
| | | flex-direction: row; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | | |
| | | .uni-pagination__total { |
| | | font-size: 14px; |
| | | color: #999; |
| | | margin-right: 15px; |
| | | } |
| | | |
| | | .uni-pagination__btn { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | padding: 0 8px; |
| | | line-height: 30px; |
| | | font-size: 12px; |
| | | position: relative; |
| | | background-color: #F0F0F0; |
| | | flex-direction: row; |
| | | justify-content: center; |
| | | align-items: center; |
| | | text-align: center; |
| | | border-radius: 5px; |
| | | // border-width: 1px; |
| | | // border-style: solid; |
| | | // border-color: $uni-border-color; |
| | | } |
| | | |
| | | .uni-pagination__child-btn { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | font-size: 12px; |
| | | position: relative; |
| | | flex-direction: row; |
| | | justify-content: center; |
| | | align-items: center; |
| | | text-align: center; |
| | | color: #666; |
| | | font-size: 12px; |
| | | } |
| | | |
| | | .uni-pagination__num { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex: 1; |
| | | flex-direction: row; |
| | | justify-content: center; |
| | | align-items: center; |
| | | height: 30px; |
| | | line-height: 30px; |
| | | font-size: 12px; |
| | | color: #666; |
| | | margin: 0 5px; |
| | | } |
| | | |
| | | .uni-pagination__num-tag { |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | min-width: 30px; |
| | | /* #endif */ |
| | | margin: 0 5px; |
| | | height: 30px; |
| | | text-align: center; |
| | | line-height: 30px; |
| | | // border: 1px red solid; |
| | | color: #999; |
| | | border-radius: 4px; |
| | | // border-width: 1px; |
| | | // border-style: solid; |
| | | // border-color: $uni-border-color; |
| | | } |
| | | |
| | | .uni-pagination__num-current { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | } |
| | | |
| | | .uni-pagination__num-current-text { |
| | | font-size: 15px; |
| | | } |
| | | |
| | | .uni-pagination--enabled { |
| | | color: #333333; |
| | | opacity: 1; |
| | | } |
| | | |
| | | .uni-pagination--disabled { |
| | | opacity: 0.5; |
| | | /* #ifdef H5 */ |
| | | cursor: default; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-pagination--hover { |
| | | color: rgba(0, 0, 0, 0.6); |
| | | background-color: #eee; |
| | | } |
| | | |
| | | .tag--active:hover { |
| | | color: $uni-primary; |
| | | } |
| | | |
| | | .page--active { |
| | | color: #fff; |
| | | background-color: $uni-primary; |
| | | } |
| | | |
| | | .page--active:hover { |
| | | color: #fff; |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | .is-pc-hide { |
| | | display: block; |
| | | } |
| | | |
| | | .is-phone-hide { |
| | | display: none; |
| | | } |
| | | |
| | | @media screen and (min-width: 450px) { |
| | | .is-pc-hide { |
| | | display: none; |
| | | } |
| | | |
| | | .is-phone-hide { |
| | | display: block; |
| | | } |
| | | |
| | | .uni-pagination__num-flex-none { |
| | | flex: none; |
| | | } |
| | | } |
| | | |
| | | /* #endif */ |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-pagination", |
| | | "displayName": "uni-pagination å页å¨", |
| | | "version": "1.2.1", |
| | | "description": "Pagination å页å¨ç»ä»¶ï¼ç¨äºå±ç¤ºé¡µç ãè¯·æ±æ°æ®çã", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "å页å¨", |
| | | "页ç " |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-scss","uni-icons"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Pagination åé¡µå¨ |
| | | > **ç»ä»¶åï¼uni-pagination** |
| | | > 代ç åï¼ `uPagination` |
| | | |
| | | |
| | | å页å¨ç»ä»¶ï¼ç¨äºå±ç¤ºé¡µç ãè¯·æ±æ°æ®çã |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-pagination) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| | | |
| | | |
| New file |
| | |
| | | ## 1.3.1ï¼2022-02-25ï¼ |
| | | - ä¿®å¤ æ¡ä»¶å¤æ `NaN` é误ç bug |
| | | ## 1.3.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-rate](https://uniapp.dcloud.io/component/uniui/uni-rate) |
| | | ## 1.2.2ï¼2021-09-10ï¼ |
| | | - ä¼å é»è®¤å¼ä¿®æ¹ä¸º 0 颿 |
| | | ## 1.2.1ï¼2021-07-30ï¼ |
| | | - ä¼å vue3ä¸äºä»¶è¦åçé®é¢ |
| | | ## 1.2.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 1.1.2ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 1.1.1ï¼2021-04-21ï¼ |
| | | - ä¿®å¤ å¸å±ååå uni-rate ææè®¡ç®ä¸åç¡®ç bug |
| | | - ä¼å æ·»å ä¾èµ uni-icons, 导å
¥ uni-rate èªå¨ä¸è½½ä¾èµ |
| | | ## 1.1.0ï¼2021-04-16ï¼ |
| | | - ä¿®å¤ uni-rate 屿§ margin å¼ä¸º string ç»ä»¶å¤±æç bug |
| | | |
| | | ## 1.0.9ï¼2021-02-05ï¼ |
| | | - ä¼å ç»ä»¶å¼ç¨å
³ç³»ï¼éè¿uni_moduleså¼ç¨ç»ä»¶ |
| | | |
| | | ## 1.0.8ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| | | - æ¯æ pc 端 |
| New file |
| | |
| | | <template> |
| | | <view> |
| | | <view ref="uni-rate" class="uni-rate"> |
| | | <view class="uni-rate__icon" :class="{'uni-cursor-not-allowed': disabled}" |
| | | :style="{ 'margin-right': marginNumber + 'px' }" v-for="(star, index) in stars" :key="index" |
| | | @touchstart.stop="touchstart" @touchmove.stop="touchmove" @mousedown.stop="mousedown" |
| | | @mousemove.stop="mousemove" @mouseleave="mouseleave"> |
| | | <uni-icons :color="color" :size="size" :type="isFill ? 'star-filled' : 'star'" /> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <view :style="{ width: star.activeWitch.replace('%','')*size/100+'px'}" class="uni-rate__icon-on"> |
| | | <uni-icons style="text-align: left;" :color="disabled?'#ccc':activeColor" :size="size" |
| | | type="star-filled" /> |
| | | </view> |
| | | <!-- #endif --> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <view :style="{ width: star.activeWitch}" class="uni-rate__icon-on"> |
| | | <uni-icons :color="disabled?disabledColor:activeColor" :size="size" type="star-filled" /> |
| | | </view> |
| | | <!-- #endif --> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | // #ifdef APP-NVUE |
| | | const dom = uni.requireNativePlugin('dom'); |
| | | // #endif |
| | | /** |
| | | * Rate è¯å |
| | | * @description è¯åç»ä»¶ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=33 |
| | | * @property {Boolean} isFill = [true|false] ææçç±»åï¼æ¯å¦ä¸ºå®å¿ç±»å, é»è®¤ä¸ºå®å¿ |
| | | * @property {String} color æªéä¸ç¶æçææé¢è²ï¼é»è®¤ä¸º "#ececec" |
| | | * @property {String} activeColor éä¸ç¶æçææé¢è²ï¼é»è®¤ä¸º "#ffca3e" |
| | | * @property {String} disabledColor ç¦ç¨ç¶æçææé¢è²ï¼é»è®¤ä¸º "#c0c0c0" |
| | | * @property {Number} size ææçå¤§å° |
| | | * @property {Number} value/v-model å½åè¯å |
| | | * @property {Number} max æå¤§è¯åè¯åæ°éï¼ç®åä¸åä¸é¢æ |
| | | * @property {Number} margin ææçé´è·ï¼åä½ px |
| | | * @property {Boolean} disabled = [true|false] æ¯å¦ä¸ºç¦ç¨ç¶æï¼é»è®¤ä¸º false |
| | | * @property {Boolean} readonly = [true|false] æ¯å¦ä¸ºåªè¯»ç¶æï¼é»è®¤ä¸º false |
| | | * @property {Boolean} allowHalf = [true|false] æ¯å¦å®ç°åæï¼é»è®¤ä¸º false |
| | | * @property {Boolean} touchable = [true|false] æ¯å¦æ¯ææ»å¨æå¿ï¼é»è®¤ä¸º true |
| | | * @event {Function} change uniRate ç value æ¹åæ¶è§¦åäºä»¶ï¼e={value:Number} |
| | | */ |
| | | |
| | | export default { |
| | | name: "UniRate", |
| | | props: { |
| | | isFill: { |
| | | // ææçç±»åï¼æ¯å¦é空 |
| | | type: [Boolean, String], |
| | | default: true |
| | | }, |
| | | color: { |
| | | // æææªéä¸çé¢è² |
| | | type: String, |
| | | default: "#ececec" |
| | | }, |
| | | activeColor: { |
| | | // ææéä¸ç¶æé¢è² |
| | | type: String, |
| | | default: "#ffca3e" |
| | | }, |
| | | disabledColor: { |
| | | // ææç¦ç¨ç¶æé¢è² |
| | | type: String, |
| | | default: "#c0c0c0" |
| | | }, |
| | | size: { |
| | | // ææçå¤§å° |
| | | type: [Number, String], |
| | | default: 24 |
| | | }, |
| | | value: { |
| | | // å½åè¯å |
| | | type: [Number, String], |
| | | default: 0 |
| | | }, |
| | | modelValue: { |
| | | // å½åè¯å |
| | | type: [Number, String], |
| | | default: 0 |
| | | }, |
| | | max: { |
| | | // æå¤§è¯å |
| | | type: [Number, String], |
| | | default: 5 |
| | | }, |
| | | margin: { |
| | | // ææçé´è· |
| | | type: [Number, String], |
| | | default: 0 |
| | | }, |
| | | disabled: { |
| | | // æ¯å¦å¯ç¹å» |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | readonly: { |
| | | // æ¯å¦åªè¯» |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | allowHalf: { |
| | | // æ¯å¦æ¾ç¤ºåæ |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | touchable: { |
| | | // æ¯å¦æ¯ææ»å¨æå¿ |
| | | type: [Boolean, String], |
| | | default: true |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | valueSync: "", |
| | | userMouseFristMove: true, |
| | | userRated: false, |
| | | userLastRate: 1 |
| | | }; |
| | | }, |
| | | watch: { |
| | | value(newVal) { |
| | | this.valueSync = Number(newVal); |
| | | }, |
| | | modelValue(newVal) { |
| | | this.valueSync = Number(newVal); |
| | | }, |
| | | }, |
| | | computed: { |
| | | stars() { |
| | | const value = this.valueSync ? this.valueSync : 0; |
| | | const starList = []; |
| | | const floorValue = Math.floor(value); |
| | | const ceilValue = Math.ceil(value); |
| | | for (let i = 0; i < this.max; i++) { |
| | | if (floorValue > i) { |
| | | starList.push({ |
| | | activeWitch: "100%" |
| | | }); |
| | | } else if (ceilValue - 1 === i) { |
| | | starList.push({ |
| | | activeWitch: (value - floorValue) * 100 + "%" |
| | | }); |
| | | } else { |
| | | starList.push({ |
| | | activeWitch: "0" |
| | | }); |
| | | } |
| | | } |
| | | return starList; |
| | | }, |
| | | |
| | | marginNumber() { |
| | | return Number(this.margin) |
| | | } |
| | | }, |
| | | created() { |
| | | this.valueSync = Number(this.value || this.modelValue); |
| | | this._rateBoxLeft = 0 |
| | | this._oldValue = null |
| | | }, |
| | | mounted() { |
| | | setTimeout(() => { |
| | | this._getSize() |
| | | }, 100) |
| | | // #ifdef H5 |
| | | this.PC = this.IsPC() |
| | | // #endif |
| | | }, |
| | | methods: { |
| | | touchstart(e) { |
| | | // #ifdef H5 |
| | | if (this.IsPC()) return |
| | | // #endif |
| | | if (this.readonly || this.disabled) return |
| | | const { |
| | | clientX, |
| | | screenX |
| | | } = e.changedTouches[0] |
| | | // TODO åä¸ä¸å
¼å®¹ï¼åªæ Nvue 䏿æ screenXï¼å
¶ä»å¹³å°å¼ clientX |
| | | this._getRateCount(clientX || screenX) |
| | | }, |
| | | touchmove(e) { |
| | | // #ifdef H5 |
| | | if (this.IsPC()) return |
| | | // #endif |
| | | if (this.readonly || this.disabled || !this.touchable) return |
| | | const { |
| | | clientX, |
| | | screenX |
| | | } = e.changedTouches[0] |
| | | this._getRateCount(clientX || screenX) |
| | | }, |
| | | |
| | | /** |
| | | * å
¼å®¹ PC @tian |
| | | */ |
| | | |
| | | mousedown(e) { |
| | | // #ifdef H5 |
| | | if (!this.IsPC()) return |
| | | if (this.readonly || this.disabled) return |
| | | const { |
| | | clientX, |
| | | } = e |
| | | this.userLastRate = this.valueSync |
| | | this._getRateCount(clientX) |
| | | this.userRated = true |
| | | // #endif |
| | | }, |
| | | mousemove(e) { |
| | | // #ifdef H5 |
| | | if (!this.IsPC()) return |
| | | if (this.userRated) return |
| | | if (this.userMouseFristMove) { |
| | | console.log('---mousemove----', this.valueSync); |
| | | this.userLastRate = this.valueSync |
| | | this.userMouseFristMove = false |
| | | } |
| | | if (this.readonly || this.disabled || !this.touchable) return |
| | | const { |
| | | clientX, |
| | | } = e |
| | | this._getRateCount(clientX) |
| | | // #endif |
| | | }, |
| | | mouseleave(e) { |
| | | // #ifdef H5 |
| | | if (!this.IsPC()) return |
| | | if (this.readonly || this.disabled || !this.touchable) return |
| | | if (this.userRated) { |
| | | this.userRated = false |
| | | return |
| | | } |
| | | this.valueSync = this.userLastRate |
| | | // #endif |
| | | }, |
| | | // #ifdef H5 |
| | | IsPC() { |
| | | var userAgentInfo = navigator.userAgent; |
| | | var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; |
| | | var flag = true; |
| | | for (let v = 0; v < Agents.length - 1; v++) { |
| | | if (userAgentInfo.indexOf(Agents[v]) > 0) { |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | return flag; |
| | | }, |
| | | // #endif |
| | | |
| | | /** |
| | | * è·åææä¸ªæ° |
| | | */ |
| | | _getRateCount(clientX) { |
| | | this._getSize() |
| | | const size = Number(this.size) |
| | | if (isNaN(size)) { |
| | | return new Error('size 屿§åªè½è®¾ç½®ä¸ºæ°å') |
| | | } |
| | | const rateMoveRange = clientX - this._rateBoxLeft |
| | | let index = parseInt(rateMoveRange / (size + this.marginNumber)) |
| | | index = index < 0 ? 0 : index; |
| | | index = index > this.max ? this.max : index; |
| | | const range = parseInt(rateMoveRange - (size + this.marginNumber) * index); |
| | | let value = 0; |
| | | if (this._oldValue === index && !this.PC) return; |
| | | this._oldValue = index; |
| | | if (this.allowHalf) { |
| | | if (range > (size / 2)) { |
| | | value = index + 1 |
| | | } else { |
| | | value = index + 0.5 |
| | | } |
| | | } else { |
| | | value = index + 1 |
| | | } |
| | | |
| | | value = Math.max(0.5, Math.min(value, this.max)) |
| | | this.valueSync = value |
| | | this._onChange() |
| | | }, |
| | | |
| | | /** |
| | | * 触åå¨æä¿®æ¹ |
| | | */ |
| | | _onChange() { |
| | | |
| | | this.$emit("input", this.valueSync); |
| | | this.$emit("update:modelValue", this.valueSync); |
| | | this.$emit("change", { |
| | | value: this.valueSync |
| | | }); |
| | | }, |
| | | /** |
| | | * è·åææè·ç¦»å±å¹å·¦ä¾§è·ç¦» |
| | | */ |
| | | _getSize() { |
| | | // #ifndef APP-NVUE |
| | | uni.createSelectorQuery() |
| | | .in(this) |
| | | .select('.uni-rate') |
| | | .boundingClientRect() |
| | | .exec(ret => { |
| | | if (ret) { |
| | | this._rateBoxLeft = ret[0].left |
| | | } |
| | | }) |
| | | // #endif |
| | | // #ifdef APP-NVUE |
| | | dom.getComponentRect(this.$refs['uni-rate'], (ret) => { |
| | | const size = ret.size |
| | | if (size) { |
| | | this._rateBoxLeft = size.left |
| | | } |
| | | }) |
| | | // #endif |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .uni-rate { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | line-height: 1; |
| | | font-size: 0; |
| | | flex-direction: row; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-rate__icon { |
| | | position: relative; |
| | | line-height: 1; |
| | | font-size: 0; |
| | | } |
| | | |
| | | .uni-rate__icon-on { |
| | | overflow: hidden; |
| | | position: absolute; |
| | | top: 0; |
| | | left: 0; |
| | | line-height: 1; |
| | | text-align: left; |
| | | } |
| | | |
| | | .uni-cursor-not-allowed { |
| | | /* #ifdef H5 */ |
| | | cursor: not-allowed !important; |
| | | /* #endif */ |
| | | } |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-rate", |
| | | "displayName": "uni-rate è¯å", |
| | | "version": "1.3.1", |
| | | "description": "Rate è¯åç»ä»¶ï¼å¯èªå®ä¹è¯åææå¾æ ç大å°ãé´éãè¯åæ°ã", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "è¯å" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | |
| | | ## Rate è¯å |
| | | > **ç»ä»¶åï¼uni-rate** |
| | | > 代ç åï¼ `uRate` |
| | | > å
³èç»ä»¶ï¼`uni-icons` |
| | | |
| | | |
| | | è¯åç»ä»¶ï¼å¤ç¨äºè´ä¹°åååï¼å¯¹ååè¿è¡è¯ä»·çåºæ¯ |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-rate) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |
| New file |
| | |
| | | ## 1.0.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæºï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§»ï¼è¯¦è§:[https://uniapp.dcloud.io/component/uniui/uni-row](https://uniapp.dcloud.io/component/uniui/uni-row) |
| | | ## 0.1.0ï¼2021-07-13ï¼ |
| | | - ç»ä»¶å
¼å®¹ vue3ï¼å¦ä½å建vue3项ç®ï¼è¯¦è§ [uni-app é¡¹ç®æ¯æ vue3 ä»ç»](https://ask.dcloud.net.cn/article/37834) |
| | | ## 0.0.4ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 0.0.3ï¼2021-02-05ï¼ |
| | | - è°æ´ä¸ºuni_modulesç®å½è§è |
| | | - æ°å¢uni-rowç»ä»¶ |
| New file |
| | |
| | | <template> |
| | | <!-- #ifndef APP-NVUE --> |
| | | <view :class="['uni-col', sizeClass, pointClassList]" :style="{ |
| | | paddingLeft:`${Number(gutter)}rpx`, |
| | | paddingRight:`${Number(gutter)}rpx`, |
| | | }"> |
| | | <slot></slot> |
| | | </view> |
| | | <!-- #endif --> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <!-- å¨nvueä¸ï¼ç±»åæ ·å¼ä¸çæï¼æ¢ä¸ºstyle --> |
| | | <!-- 设置rightæ£å¼å¤±æï¼è®¾ç½® left è´å¼ --> |
| | | <view :class="['uni-col']" :style="{ |
| | | paddingLeft:`${Number(gutter)}rpx`, |
| | | paddingRight:`${Number(gutter)}rpx`, |
| | | width:`${nvueWidth}rpx`, |
| | | position:'relative', |
| | | marginLeft:`${marginLeft}rpx`, |
| | | left:`${right === 0 ? left : -right}rpx` |
| | | }"> |
| | | <slot></slot> |
| | | </view> |
| | | <!-- #endif --> |
| | | </template> |
| | | |
| | | <script> |
| | | /** |
| | | * Col å¸å±-å |
| | | * @description æé
uni-row使ç¨ï¼æå»ºå¸å±ã |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=3958 |
| | | * |
| | | * @property {span} type = Number æ
æ ¼å æ®çåæ° |
| | | * é»è®¤ 24 |
| | | * @property {offset} type = Number æ
æ ¼å·¦ä¾§çé´éæ ¼æ° |
| | | * @property {push} type = Number æ
æ ¼åå³ç§»å¨æ ¼æ° |
| | | * @property {pull} type = Number æ
æ ¼åå·¦ç§»å¨æ ¼æ° |
| | | * @property {xs} type = [Number, Object] <768px ååºå¼æ
æ ¼æ°æè
æ
æ ¼å±æ§å¯¹è±¡ |
| | | * @description Numberæ¶è¡¨ç¤ºå¨æ¤å±å¹å®½åº¦ä¸ï¼æ
æ ¼å æ®çåæ°ãObjectæ¶å¯é
ç½®å¤ä¸ªæè¿°{span: 4, offset: 4} |
| | | * @property {sm} type = [Number, Object] â¥768px ååºå¼æ
æ ¼æ°æè
æ
æ ¼å±æ§å¯¹è±¡ |
| | | * @description Numberæ¶è¡¨ç¤ºå¨æ¤å±å¹å®½åº¦ä¸ï¼æ
æ ¼å æ®çåæ°ãObjectæ¶å¯é
ç½®å¤ä¸ªæè¿°{span: 4, offset: 4} |
| | | * @property {md} type = [Number, Object] â¥992px ååºå¼æ
æ ¼æ°æè
æ
æ ¼å±æ§å¯¹è±¡ |
| | | * @description Numberæ¶è¡¨ç¤ºå¨æ¤å±å¹å®½åº¦ä¸ï¼æ
æ ¼å æ®çåæ°ãObjectæ¶å¯é
ç½®å¤ä¸ªæè¿°{span: 4, offset: 4} |
| | | * @property {lg} type = [Number, Object] â¥1200px ååºå¼æ
æ ¼æ°æè
æ
æ ¼å±æ§å¯¹è±¡ |
| | | * @description Numberæ¶è¡¨ç¤ºå¨æ¤å±å¹å®½åº¦ä¸ï¼æ
æ ¼å æ®çåæ°ãObjectæ¶å¯é
ç½®å¤ä¸ªæè¿°{span: 4, offset: 4} |
| | | * @property {xl} type = [Number, Object] â¥1920px ååºå¼æ
æ ¼æ°æè
æ
æ ¼å±æ§å¯¹è±¡ |
| | | * @description Numberæ¶è¡¨ç¤ºå¨æ¤å±å¹å®½åº¦ä¸ï¼æ
æ ¼å æ®çåæ°ãObjectæ¶å¯é
ç½®å¤ä¸ªæè¿°{span: 4, offset: 4} |
| | | */ |
| | | const ComponentClass = 'uni-col'; |
| | | |
| | | // -1 é»è®¤å¼ï¼å 为å¨å¾®ä¿¡å°ç¨åºç«¯åªç»Number伿é»è®¤å¼0 |
| | | export default { |
| | | name: 'uniCol', |
| | | // #ifdef MP-WEIXIN |
| | | options: { |
| | | virtualHost: true // å¨å¾®ä¿¡å°ç¨åºä¸å°ç»ä»¶èç¹æ¸²æä¸ºèæèç¹ï¼æ´å æ¥è¿Vueç»ä»¶çè¡¨ç° |
| | | }, |
| | | // #endif |
| | | props: { |
| | | span: { |
| | | type: Number, |
| | | default: 24 |
| | | }, |
| | | offset: { |
| | | type: Number, |
| | | default: -1 |
| | | }, |
| | | pull: { |
| | | type: Number, |
| | | default: -1 |
| | | }, |
| | | push: { |
| | | type: Number, |
| | | default: -1 |
| | | }, |
| | | xs: [Number, Object], |
| | | sm: [Number, Object], |
| | | md: [Number, Object], |
| | | lg: [Number, Object], |
| | | xl: [Number, Object] |
| | | }, |
| | | data() { |
| | | return { |
| | | gutter: 0, |
| | | sizeClass: '', |
| | | parentWidth: 0, |
| | | nvueWidth: 0, |
| | | marginLeft: 0, |
| | | right: 0, |
| | | left: 0 |
| | | } |
| | | }, |
| | | created() { |
| | | // åèå°ç¨åºä¸ï¼å¨computedä¸è¯»å$parent为undefined |
| | | let parent = this.$parent; |
| | | |
| | | while (parent && parent.$options.componentName !== 'uniRow') { |
| | | parent = parent.$parent; |
| | | } |
| | | |
| | | this.updateGutter(parent.gutter) |
| | | parent.$watch('gutter', (gutter) => { |
| | | this.updateGutter(gutter) |
| | | }) |
| | | |
| | | // #ifdef APP-NVUE |
| | | this.updateNvueWidth(parent.width) |
| | | parent.$watch('width', (width) => { |
| | | this.updateNvueWidth(width) |
| | | }) |
| | | // #endif |
| | | }, |
| | | computed: { |
| | | sizeList() { |
| | | let { |
| | | span, |
| | | offset, |
| | | pull, |
| | | push |
| | | } = this; |
| | | |
| | | return { |
| | | span, |
| | | offset, |
| | | pull, |
| | | push |
| | | } |
| | | }, |
| | | // #ifndef APP-NVUE |
| | | pointClassList() { |
| | | let classList = []; |
| | | |
| | | ['xs', 'sm', 'md', 'lg', 'xl'].forEach(point => { |
| | | const props = this[point]; |
| | | if (typeof props === 'number') { |
| | | classList.push(`${ComponentClass}-${point}-${props}`) |
| | | } else if (typeof props === 'object' && props) { |
| | | Object.keys(props).forEach(pointProp => { |
| | | classList.push( |
| | | pointProp === 'span' ? |
| | | `${ComponentClass}-${point}-${props[pointProp]}` : |
| | | `${ComponentClass}-${point}-${pointProp}-${props[pointProp]}` |
| | | ) |
| | | }) |
| | | } |
| | | }); |
| | | |
| | | // æ¯ä»å®å°ç¨åºä½¿ç¨ :class=[ ['a','b'] ]ï¼æ¸²æé误 |
| | | return classList.join(' '); |
| | | } |
| | | // #endif |
| | | }, |
| | | methods: { |
| | | updateGutter(parentGutter) { |
| | | parentGutter = Number(parentGutter); |
| | | if (!isNaN(parentGutter)) { |
| | | this.gutter = parentGutter / 2 |
| | | } |
| | | }, |
| | | // #ifdef APP-NVUE |
| | | updateNvueWidth(width) { |
| | | // ç¨äºå¨nvue端ï¼spanï¼offsetï¼pullï¼pushçè®¡ç® |
| | | this.parentWidth = width; |
| | | ['span', 'offset', 'pull', 'push'].forEach(size => { |
| | | const curSize = this[size]; |
| | | if ((curSize || curSize === 0) && curSize !== -1) { |
| | | let RPX = 1 / 24 * curSize * width |
| | | RPX = Number(RPX); |
| | | switch (size) { |
| | | case 'span': |
| | | this.nvueWidth = RPX |
| | | break; |
| | | case 'offset': |
| | | this.marginLeft = RPX |
| | | break; |
| | | case 'pull': |
| | | this.right = RPX |
| | | break; |
| | | case 'push': |
| | | this.left = RPX |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | // #endif |
| | | }, |
| | | watch: { |
| | | sizeList: { |
| | | immediate: true, |
| | | handler(newVal) { |
| | | // #ifndef APP-NVUE |
| | | let classList = []; |
| | | for (let size in newVal) { |
| | | const curSize = newVal[size]; |
| | | if ((curSize || curSize === 0) && curSize !== -1) { |
| | | classList.push( |
| | | size === 'span' ? |
| | | `${ComponentClass}-${curSize}` : |
| | | `${ComponentClass}-${size}-${curSize}` |
| | | ) |
| | | } |
| | | } |
| | | // æ¯ä»å®å°ç¨åºä½¿ç¨ :class=[ ['a','b'] ]ï¼æ¸²æé误 |
| | | this.sizeClass = classList.join(' '); |
| | | // #endif |
| | | // #ifdef APP-NVUE |
| | | this.updateNvueWidth(this.parentWidth); |
| | | // #endif |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang='scss' scoped> |
| | | /* breakpoints */ |
| | | $--sm: 768px !default; |
| | | $--md: 992px !default; |
| | | $--lg: 1200px !default; |
| | | $--xl: 1920px !default; |
| | | |
| | | $breakpoints: ('xs' : (max-width: $--sm - 1), |
| | | 'sm' : (min-width: $--sm), |
| | | 'md' : (min-width: $--md), |
| | | 'lg' : (min-width: $--lg), |
| | | 'xl' : (min-width: $--xl)); |
| | | |
| | | $layout-namespace: ".uni-"; |
| | | $col: $layout-namespace+"col"; |
| | | |
| | | @function getSize($size) { |
| | | /* TODO 1/24 * $size * 100 * 1%; 使ç¨è®¡ç®åçå¼ï¼ä¸ºäºè§£å³ vue3 æ§å¶å°æ¥é */ |
| | | @return 0.04166666666 * $size * 100 * 1%; |
| | | } |
| | | |
| | | @mixin res($key, $map:$breakpoints) { |
| | | @if map-has-key($map, $key) { |
| | | @media screen and #{inspect(map-get($map,$key))} { |
| | | @content; |
| | | } |
| | | } |
| | | |
| | | @else { |
| | | @warn "Undeinfed point: `#{$key}`"; |
| | | } |
| | | } |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | #{$col} { |
| | | float: left; |
| | | box-sizing: border-box; |
| | | } |
| | | |
| | | #{$col}-0 { |
| | | /* #ifdef APP-NVUE */ |
| | | width: 0; |
| | | height: 0; |
| | | margin-top: 0; |
| | | margin-right: 0; |
| | | margin-bottom: 0; |
| | | margin-left: 0; |
| | | /* #endif */ |
| | | /* #ifndef APP-NVUE */ |
| | | display: none; |
| | | /* #endif */ |
| | | } |
| | | |
| | | @for $i from 0 through 24 { |
| | | #{$col}-#{$i} { |
| | | width: getSize($i); |
| | | } |
| | | |
| | | #{$col}-offset-#{$i} { |
| | | margin-left: getSize($i); |
| | | } |
| | | |
| | | #{$col}-pull-#{$i} { |
| | | position: relative; |
| | | right: getSize($i); |
| | | } |
| | | |
| | | #{$col}-push-#{$i} { |
| | | position: relative; |
| | | left: getSize($i); |
| | | } |
| | | } |
| | | |
| | | @each $point in map-keys($breakpoints) { |
| | | @include res($point) { |
| | | #{$col}-#{$point}-0 { |
| | | display: none; |
| | | } |
| | | |
| | | @for $i from 0 through 24 { |
| | | #{$col}-#{$point}-#{$i} { |
| | | width: getSize($i); |
| | | } |
| | | |
| | | #{$col}-#{$point}-offset-#{$i} { |
| | | margin-left: getSize($i); |
| | | } |
| | | |
| | | #{$col}-#{$point}-pull-#{$i} { |
| | | position: relative; |
| | | right: getSize($i); |
| | | } |
| | | |
| | | #{$col}-#{$point}-push-#{$i} { |
| | | position: relative; |
| | | left: getSize($i); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /* #endif */ |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <view :class="[ 'uni-row', typeClass , justifyClass, alignClass, ]" :style="{ |
| | | marginLeft:`${Number(marginValue)}rpx`, |
| | | marginRight:`${Number(marginValue)}rpx`, |
| | | }"> |
| | | <slot></slot> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | const ComponentClass = 'uni-row'; |
| | | const modifierSeparator = '--'; |
| | | /** |
| | | * Row å¸å±-è¡ |
| | | * @description æµå¼æ
æ ¼ç³»ç»ï¼éçå±å¹æè§å£å为 24 份ï¼å¯ä»¥è¿
éç®ä¾¿å°å建å¸å±ã |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=3958 |
| | | * |
| | | * @property {gutter} type = Number æ
æ ¼é´é |
| | | * @property {justify} type = String flex å¸å±ä¸çæ°´å¹³æåæ¹å¼ |
| | | * å¯é start/end/center/space-around/space-between start |
| | | * é»è®¤å¼ start |
| | | * @property {align} type = String flex å¸å±ä¸çåç´æåæ¹å¼ |
| | | * å¯é top/middle/bottom |
| | | * é»è®¤å¼ top |
| | | * @property {width} type = String|Number nvueä¸éè¦èªè¡é
置宽度ç¨äºè®¡ç® |
| | | * é»è®¤å¼ 750 |
| | | */ |
| | | |
| | | |
| | | export default { |
| | | name: 'uniRow', |
| | | componentName: 'uniRow', |
| | | // #ifdef MP-WEIXIN |
| | | options: { |
| | | virtualHost: true // å¨å¾®ä¿¡å°ç¨åºä¸å°ç»ä»¶èç¹æ¸²æä¸ºèæèç¹ï¼æ´å æ¥è¿Vueç»ä»¶ç表ç°ï¼å¯ä½¿ç¨flexå¸å± |
| | | }, |
| | | // #endif |
| | | props: { |
| | | type: String, |
| | | gutter: Number, |
| | | justify: { |
| | | type: String, |
| | | default: 'start' |
| | | }, |
| | | align: { |
| | | type: String, |
| | | default: 'top' |
| | | }, |
| | | // nvueå¦æä½¿ç¨spanç屿§ï¼éè¦é
置宽度 |
| | | width: { |
| | | type: [String, Number], |
| | | default: 750 |
| | | } |
| | | }, |
| | | created() { |
| | | // #ifdef APP-NVUE |
| | | this.type = 'flex'; |
| | | // #endif |
| | | }, |
| | | computed: { |
| | | marginValue() { |
| | | // #ifndef APP-NVUE |
| | | if (this.gutter) { |
| | | return -(this.gutter / 2); |
| | | } |
| | | // #endif |
| | | return 0; |
| | | }, |
| | | typeClass() { |
| | | return this.type === 'flex' ? `${ComponentClass + modifierSeparator}flex` : ''; |
| | | }, |
| | | justifyClass() { |
| | | return this.justify !== 'start' ? `${ComponentClass + modifierSeparator}flex-justify-${this.justify}` : '' |
| | | }, |
| | | alignClass() { |
| | | return this.align !== 'top' ? `${ComponentClass + modifierSeparator}flex-align-${this.align}` : '' |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | $layout-namespace: ".uni-"; |
| | | $row:$layout-namespace+"row"; |
| | | $modifier-separator: "--"; |
| | | |
| | | @mixin utils-clearfix { |
| | | $selector: &; |
| | | |
| | | @at-root { |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | #{$selector}::before, |
| | | #{$selector}::after { |
| | | display: table; |
| | | content: ""; |
| | | } |
| | | |
| | | #{$selector}::after { |
| | | clear: both; |
| | | } |
| | | |
| | | /* #endif */ |
| | | } |
| | | |
| | | } |
| | | |
| | | @mixin utils-flex ($direction: row) { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: $direction; |
| | | } |
| | | |
| | | @mixin set-flex($state) { |
| | | @at-root &-#{$state} { |
| | | @content |
| | | } |
| | | } |
| | | |
| | | #{$row} { |
| | | position: relative; |
| | | flex-direction: row; |
| | | |
| | | /* #ifdef APP-NVUE */ |
| | | flex: 1; |
| | | /* #endif */ |
| | | |
| | | /* #ifndef APP-NVUE */ |
| | | box-sizing: border-box; |
| | | /* #endif */ |
| | | |
| | | // énvue使ç¨floatå¸å± |
| | | @include utils-clearfix; |
| | | |
| | | // å¨QQãåèãç¾åº¦å°ç¨åºå¹³å°ï¼ç¼è¯å使ç¨shadow domï¼ä¸å¯ä½¿ç¨flexå¸å±ï¼ä½¿ç¨float |
| | | @at-root { |
| | | |
| | | /* #ifndef MP-QQ || MP-TOUTIAO || MP-BAIDU */ |
| | | &#{$modifier-separator}flex { |
| | | @include utils-flex; |
| | | flex-wrap: wrap; |
| | | flex: 1; |
| | | |
| | | &:before, |
| | | &:after { |
| | | /* #ifndef APP-NVUE */ |
| | | display: none; |
| | | /* #endif */ |
| | | } |
| | | |
| | | @include set-flex(justify-center) { |
| | | justify-content: center; |
| | | } |
| | | |
| | | @include set-flex(justify-end) { |
| | | justify-content: flex-end; |
| | | } |
| | | |
| | | @include set-flex(justify-space-between) { |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | @include set-flex(justify-space-around) { |
| | | justify-content: space-around; |
| | | } |
| | | |
| | | @include set-flex(align-middle) { |
| | | align-items: center; |
| | | } |
| | | |
| | | @include set-flex(align-bottom) { |
| | | align-items: flex-end; |
| | | } |
| | | } |
| | | |
| | | /* #endif */ |
| | | } |
| | | |
| | | } |
| | | |
| | | // åèãQQé
ç½®åä¸çæ |
| | | // æ¤å¤ç¨æ³æ æ³ä½¿ç¨scoped |
| | | /* #ifdef MP-WEIXIN || MP-TOUTIAO || MP-QQ */ |
| | | :host { |
| | | display: block; |
| | | } |
| | | |
| | | /* #endif */ |
| | | </style> |
| New file |
| | |
| | | { |
| | | "id": "uni-row", |
| | | "displayName": "uni-row å¸å±-è¡", |
| | | "version": "1.0.0", |
| | | "description": "æµå¼æ
æ ¼ç³»ç»ï¼éçå±å¹æè§å£å为 24 份ï¼å¯ä»¥è¿
éç®ä¾¿å°å建å¸å±ã", |
| | | "keywords": [ |
| | | "uni-ui", |
| | | "uniui", |
| | | "æ
æ ¼", |
| | | "å¸å±", |
| | | "layout" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "category": [ |
| | | "å端ç»ä»¶", |
| | | "éç¨ç»ä»¶" |
| | | ], |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-scss"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "y" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "u" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| uni_modules/uni-row/readme.md
uni_modules/uni-scss/manifest.json
uni_modules/uni-search-bar/changelog.md
uni_modules/uni-search-bar/components/uni-search-bar/i18n/en.json
uni_modules/uni-search-bar/components/uni-search-bar/i18n/index.js
uni_modules/uni-search-bar/components/uni-search-bar/i18n/zh-Hans.json
uni_modules/uni-search-bar/components/uni-search-bar/i18n/zh-Hant.json
uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.vue
uni_modules/uni-search-bar/package.json
uni_modules/uni-search-bar/readme.md
uni_modules/uni-segmented-control/changelog.md
uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.vue
uni_modules/uni-segmented-control/package.json
uni_modules/uni-segmented-control/readme.md
uni_modules/uni-steps/changelog.md
uni_modules/uni-steps/components/uni-steps/uni-steps.vue
uni_modules/uni-steps/package.json
uni_modules/uni-steps/readme.md
uni_modules/uni-swipe-action/changelog.md
uni_modules/uni-swipe-action/components/uni-swipe-action-item/bindingx.js
uni_modules/uni-swipe-action/components/uni-swipe-action-item/index.wxs
uni_modules/uni-swipe-action/components/uni-swipe-action-item/isPC.js
uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpalipay.js
uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpother.js
uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpwxs.js
uni_modules/uni-swipe-action/components/uni-swipe-action-item/render.js
uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item.vue
uni_modules/uni-swipe-action/components/uni-swipe-action-item/wx.wxs
uni_modules/uni-swipe-action/components/uni-swipe-action/uni-swipe-action.vue
uni_modules/uni-swipe-action/package.json
uni_modules/uni-swipe-action/readme.md
uni_modules/uni-swiper-dot/changelog.md
uni_modules/uni-swiper-dot/components/uni-swiper-dot/uni-swiper-dot.vue
uni_modules/uni-swiper-dot/package.json
uni_modules/uni-swiper-dot/readme.md
uni_modules/uni-tag/changelog.md
uni_modules/uni-tag/components/uni-tag/uni-tag.vue
uni_modules/uni-tag/package.json
uni_modules/uni-tag/readme.md
uni_modules/uni-title/changelog.md
uni_modules/uni-title/components/uni-title/uni-title.vue
uni_modules/uni-title/package.json
uni_modules/uni-title/readme.md
uni_modules/uni-upgrade-center-app/changelog.md
uni_modules/uni-upgrade-center-app/images/app_update_close.png
uni_modules/uni-upgrade-center-app/images/bg_top.png
uni_modules/uni-upgrade-center-app/package.json
uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
uni_modules/uni-upgrade-center-app/pages_init.json
uni_modules/uni-upgrade-center-app/readme.md
uni_modules/uni-upgrade-center-app/static/app_update_close.png
uni_modules/uni-upgrade-center-app/static/bg_top.png
uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version/check-version.param.json
uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version/index.js
uni_modules/uni-upgrade-center-app/utils/call-check-version.js
uni_modules/uni-upgrade-center-app/utils/check-update.js |