mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-04-15 20:11:52 +08:00
增加微信小程序版
This commit is contained in:
BIN
liferestartWX/utils/.DS_Store
vendored
Normal file
BIN
liferestartWX/utils/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
liferestartWX/utils/liferestart/.DS_Store
vendored
Normal file
BIN
liferestartWX/utils/liferestart/.DS_Store
vendored
Normal file
Binary file not shown.
1
liferestartWX/utils/liferestart/data/age.js
Normal file
1
liferestartWX/utils/liferestart/data/age.js
Normal file
File diff suppressed because one or more lines are too long
96
liferestartWX/utils/liferestart/data/dataUtils.js
Normal file
96
liferestartWX/utils/liferestart/data/dataUtils.js
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
import talentsData from './talents.js';
|
||||
import ageData from './age.js';
|
||||
import eventsData from './events.js';
|
||||
import { max, sum } from '../functions/util.js';
|
||||
import { summary } from "../functions/summary.js";
|
||||
//"\d*": ->
|
||||
//"age": "(\d*)", -> "_id": "$1", "age": "$1",
|
||||
//"\d*": \{ -> {
|
||||
//"id": -> "_id":
|
||||
function allTalents() {
|
||||
// wx.setStorage({
|
||||
// key: 'talentsData',
|
||||
// data: talentsData
|
||||
// })
|
||||
return talentsData.slice(0)
|
||||
}
|
||||
function allAge() {
|
||||
// wx.setStorage({
|
||||
// key: 'agedata',
|
||||
// data: ageData
|
||||
// })
|
||||
return ageData.slice(0)
|
||||
}
|
||||
function allEvents() {
|
||||
// wx.setStorage({
|
||||
// key: 'eventsData',
|
||||
// data: eventsData
|
||||
// })
|
||||
return eventsData.slice(0)
|
||||
}
|
||||
|
||||
function randomTalents(max) {
|
||||
const result = getRandomInRange(talentsData, max)
|
||||
return result
|
||||
}
|
||||
function getRandomInRange(arr, count) {
|
||||
var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
|
||||
while (i-- > min) {
|
||||
index = Math.floor((i + 1) * Math.random());
|
||||
temp = shuffled[index];
|
||||
shuffled[index] = shuffled[i];
|
||||
shuffled[i] = temp;
|
||||
}
|
||||
return shuffled.slice(min).sort(function(a,b){return a-b;});
|
||||
}
|
||||
|
||||
function buildSummary(records, type) {
|
||||
const value = max(records.map(({[type]:v})=>v));
|
||||
const { judge, grade } = summary(type, value);
|
||||
return { judge, grade, value };
|
||||
}
|
||||
|
||||
function finalSummary(records) {
|
||||
const m = type=>max(records.map(({[type]: value})=>value));
|
||||
const value = Math.floor(sum(m('CHR'), m('INT'), m('STR'), m('MNY'), m('SPR'))*2 + m('AGE')/2);
|
||||
const { judge, grade } = summary('SUM', value);
|
||||
return { judge, grade, value };
|
||||
}
|
||||
|
||||
function computeTalentsStatus(talents) {
|
||||
var status = talents.map(function(item) {
|
||||
if ('status' in item) {
|
||||
return item.status
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
})
|
||||
return status
|
||||
}
|
||||
|
||||
function computeUseableProp(max, status) {
|
||||
var proNum = max
|
||||
status.forEach(function(item){
|
||||
proNum = proNum + item
|
||||
})
|
||||
return proNum
|
||||
}
|
||||
|
||||
function randomProp(max, init){
|
||||
// console.log('randomProperty', t)
|
||||
var arr = init
|
||||
while(max>0) {
|
||||
const sub = Math.round(Math.random() * (Math.min(max, 10) - 1)) + 1;
|
||||
while(true) {
|
||||
const select = Math.floor(Math.random() * 4) % 4;
|
||||
if(arr[select] - sub <0) continue;
|
||||
arr[select] -= sub;
|
||||
max -= sub;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
export { randomTalents, getRandomInRange, allTalents, allAge, allEvents, buildSummary, finalSummary, computeTalentsStatus, computeUseableProp, randomProp };
|
||||
1
liferestartWX/utils/liferestart/data/events.js
Normal file
1
liferestartWX/utils/liferestart/data/events.js
Normal file
File diff suppressed because one or more lines are too long
1
liferestartWX/utils/liferestart/data/talents.js
Normal file
1
liferestartWX/utils/liferestart/data/talents.js
Normal file
File diff suppressed because one or more lines are too long
61
liferestartWX/utils/liferestart/event.js
Normal file
61
liferestartWX/utils/liferestart/event.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { clone } from './functions/util.js';
|
||||
import { checkCondition } from './functions/condition.js';
|
||||
|
||||
class Event {
|
||||
constructor() {}
|
||||
|
||||
#events;
|
||||
|
||||
// 初始化传参数去掉{}
|
||||
initial(events) {
|
||||
this.#events = events;
|
||||
for(const id in events) {
|
||||
const event = events[id];
|
||||
if(!event.branch || !'branch' in event) continue;
|
||||
//判断事件是否被处理过
|
||||
event.branch = event.branch.map(b=>{
|
||||
b = b.indexOf(":") != -1?b.split(':'):b;
|
||||
b[1] = Number(b[1]);
|
||||
return b;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
check(eventId, property) {
|
||||
const { include, exclude, NoRandom } = this.get(eventId);
|
||||
if(NoRandom) return false;
|
||||
if(exclude && checkCondition(property, exclude)) return false;
|
||||
if(include) return checkCondition(property, include);
|
||||
return true;
|
||||
}
|
||||
|
||||
get(eventId) {
|
||||
// const event = this.#events[eventId];
|
||||
// console.log('event.js get',eventId, this.#events)
|
||||
var event
|
||||
this.#events.forEach(function(item){
|
||||
if (item._id == eventId) {
|
||||
event = item
|
||||
}
|
||||
})
|
||||
if(!event) throw new Error(`[ERROR] No Event[${eventId}]`);
|
||||
return clone(event);
|
||||
}
|
||||
|
||||
information(eventId) {
|
||||
const { event: description } = this.get(eventId)
|
||||
return { description };
|
||||
}
|
||||
|
||||
do(eventId, property) {
|
||||
const { effect, branch, event: description, postEvent } = this.get(eventId);
|
||||
if(branch)
|
||||
for(const [cond, next] of branch)
|
||||
if(checkCondition(property, cond))
|
||||
return { effect, next, description };
|
||||
return { effect, postEvent, description };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Event;
|
||||
129
liferestartWX/utils/liferestart/functions/condition.js
Normal file
129
liferestartWX/utils/liferestart/functions/condition.js
Normal file
@@ -0,0 +1,129 @@
|
||||
function parseCondition(condition) {
|
||||
|
||||
const conditions = [];
|
||||
const length = condition.length;
|
||||
const stack = [];
|
||||
stack.unshift(conditions);
|
||||
let cursor = 0;
|
||||
const catchString = i => {
|
||||
const str = condition.substring(cursor, i).trim();
|
||||
cursor = i;
|
||||
if(str) stack[0].push(str);
|
||||
};
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
switch(condition[i]) {
|
||||
case ' ': continue;
|
||||
|
||||
case '(':
|
||||
catchString(i);
|
||||
cursor ++;
|
||||
const sub = [];
|
||||
stack[0].push(sub);
|
||||
stack.unshift(sub);
|
||||
break;
|
||||
|
||||
case ')':
|
||||
catchString(i);
|
||||
cursor ++;
|
||||
stack.shift();
|
||||
break;
|
||||
|
||||
case '|':
|
||||
case '&':
|
||||
catchString(i);
|
||||
catchString(i+1);
|
||||
break;
|
||||
default: continue;
|
||||
}
|
||||
}
|
||||
|
||||
catchString(length);
|
||||
|
||||
return conditions;
|
||||
}
|
||||
|
||||
function checkCondition(property, condition) {
|
||||
const conditions = parseCondition(condition);
|
||||
return checkParsedConditions(property, conditions);
|
||||
}
|
||||
|
||||
function checkParsedConditions(property, conditions) {
|
||||
if(!Array.isArray(conditions)) return checkProp(property, conditions);
|
||||
if(conditions.length == 0) return true;
|
||||
if(conditions.length == 1) return checkParsedConditions(property, conditions[0]);
|
||||
|
||||
let ret = checkParsedConditions(property, conditions[0]);
|
||||
for(let i=1; i<conditions.length; i+=2) {
|
||||
switch(conditions[i]) {
|
||||
case '&':
|
||||
if(ret) ret = checkParsedConditions(property, conditions[i+1]);
|
||||
break;
|
||||
case '|':
|
||||
if(ret) return true;
|
||||
ret = checkParsedConditions(property, conditions[i+1]);
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function checkProp(property, condition) {
|
||||
|
||||
const length = condition.length;
|
||||
let i = condition.search(/[><\!\?=]/);
|
||||
|
||||
const prop = condition.substring(0,i);
|
||||
const symbol = condition.substring(i, i+=(condition[i+1]=='='?2:1));
|
||||
const d = condition.substring(i, length);
|
||||
|
||||
const propData = property.get(prop);
|
||||
const conditionData = d[0]=='['? JSON.parse(d): Number(d);
|
||||
|
||||
switch(symbol) {
|
||||
case '>': return propData > conditionData;
|
||||
case '<': return propData < conditionData;
|
||||
case '>=': return propData >= conditionData;
|
||||
case '<=': return propData <= conditionData;
|
||||
case '=':
|
||||
if(Array.isArray(propData))
|
||||
return propData.includes(conditionData);
|
||||
return propData == conditionData;
|
||||
case '!=':
|
||||
if(Array.isArray(propData))
|
||||
return !propData.includes(conditionData);
|
||||
return propData == conditionData;
|
||||
case '?':
|
||||
if(Array.isArray(propData)) {
|
||||
for(const p of propData)
|
||||
if(conditionData.includes(p)) return true;
|
||||
return false;
|
||||
}
|
||||
return conditionData.includes(propData);
|
||||
case '!':
|
||||
if(Array.isArray(propData)) {
|
||||
for(const p of propData)
|
||||
if(conditionData.includes(p)) return false;
|
||||
return true;
|
||||
}
|
||||
return !conditionData.includes(propData);
|
||||
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
function extractMaxTriggers(condition) {
|
||||
// Assuming only age related talents can be triggered multiple times.
|
||||
const RE_AGE_CONDITION = /AGE\?\[([0-9\,]+)\]/;
|
||||
const match_object = RE_AGE_CONDITION.exec(condition);
|
||||
if (match_object == null) {
|
||||
// Not age related, single trigger.
|
||||
return 1;
|
||||
}
|
||||
|
||||
const age_list = match_object[1].split(",");
|
||||
return age_list.length;
|
||||
}
|
||||
|
||||
export { checkCondition, extractMaxTriggers };
|
||||
89
liferestartWX/utils/liferestart/functions/summary.js
Normal file
89
liferestartWX/utils/liferestart/functions/summary.js
Normal file
@@ -0,0 +1,89 @@
|
||||
const data = {
|
||||
"CHR": [
|
||||
{"judge": "地狱", "grade": 0},
|
||||
{"min":1, "judge": "折磨", "grade": 0},
|
||||
{"min":2, "judge": "不佳", "grade": 0},
|
||||
{"min":4, "judge": "普通", "grade": 0},
|
||||
{"min":7, "judge": "优秀", "grade": 1},
|
||||
{"min":9, "judge": "罕见", "grade": 2},
|
||||
{"min":11, "judge": "逆天", "grade": 3},
|
||||
],
|
||||
"MNY": [
|
||||
{"judge": "地狱", "grade": 0},
|
||||
{"min":1, "judge": "折磨", "grade": 0},
|
||||
{"min":2, "judge": "不佳", "grade": 0},
|
||||
{"min":4, "judge": "普通", "grade": 0},
|
||||
{"min":7, "judge": "优秀", "grade": 1},
|
||||
{"min":9, "judge": "罕见", "grade": 2},
|
||||
{"min":11, "judge": "逆天", "grade": 3},
|
||||
],
|
||||
"SPR": [
|
||||
{"judge": "地狱", "grade": 0},
|
||||
{"min":1, "judge": "折磨", "grade": 0},
|
||||
{"min":2, "judge": "不幸", "grade": 0},
|
||||
{"min":4, "judge": "普通", "grade": 0},
|
||||
{"min":7, "judge": "幸福", "grade": 1},
|
||||
{"min":9, "judge": "极乐", "grade": 2},
|
||||
{"min":11, "judge": "天命", "grade": 3},
|
||||
],
|
||||
"INT": [
|
||||
{"judge": "地狱", "grade": 0},
|
||||
{"min":1, "judge": "折磨", "grade": 0},
|
||||
{"min":2, "judge": "不佳", "grade": 0},
|
||||
{"min":4, "judge": "普通", "grade": 0},
|
||||
{"min":7, "judge": "优秀", "grade": 1},
|
||||
{"min":9, "judge": "罕见", "grade": 2},
|
||||
{"min":11, "judge": "逆天", "grade": 3},
|
||||
{"min":21, "judge": "识海", "grade": 3},
|
||||
{"min":131, "judge": "元神", "grade": 3},
|
||||
{"min":501, "judge": "仙魂", "grade": 3},
|
||||
],
|
||||
"STR": [
|
||||
{"judge": "地狱", "grade": 0},
|
||||
{"min":1, "judge": "折磨", "grade": 0},
|
||||
{"min":2, "judge": "不佳", "grade": 0},
|
||||
{"min":4, "judge": "普通", "grade": 0},
|
||||
{"min":7, "judge": "优秀", "grade": 1},
|
||||
{"min":9, "judge": "罕见", "grade": 2},
|
||||
{"min":11, "judge": "逆天", "grade": 3},
|
||||
{"min":21, "judge": "凝气", "grade": 3},
|
||||
{"min":101, "judge": "筑基", "grade": 3},
|
||||
{"min":401, "judge": "金丹", "grade": 3},
|
||||
{"min":1001, "judge": "元婴", "grade": 3},
|
||||
{"min":2001, "judge": "仙体", "grade": 3},
|
||||
],
|
||||
"AGE": [
|
||||
{"judge": "胎死腹中", "grade": 0},
|
||||
{"min":1, "judge": "早夭", "grade": 0},
|
||||
{"min":10, "judge": "少年", "grade": 0},
|
||||
{"min":18, "judge": "盛年", "grade": 0},
|
||||
{"min":40, "judge": "中年", "grade": 0},
|
||||
{"min":60, "judge": "花甲", "grade": 1},
|
||||
{"min":70, "judge": "古稀", "grade": 1},
|
||||
{"min":80, "judge": "杖朝", "grade": 2},
|
||||
{"min":90, "judge": "南山", "grade": 2},
|
||||
{"min":95, "judge": "不老", "grade": 3},
|
||||
{"min":100, "judge": "修仙", "grade": 3},
|
||||
{"min":500, "judge": "仙寿", "grade": 3},
|
||||
],
|
||||
"SUM": [
|
||||
{"judge": "地狱", "grade": 0},
|
||||
{"min":41, "judge": "折磨", "grade": 0},
|
||||
{"min":50, "judge": "不佳", "grade": 0},
|
||||
{"min":60, "judge": "普通", "grade": 0},
|
||||
{"min":80, "judge": "优秀", "grade": 1},
|
||||
{"min":100, "judge": "罕见", "grade": 2},
|
||||
{"min":110, "judge": "逆天", "grade": 3},
|
||||
{"min":120, "judge": "传说", "grade": 3},
|
||||
]
|
||||
}
|
||||
|
||||
function summary(type, value) {
|
||||
let length = data[type].length;
|
||||
while(length--) {
|
||||
const {min, judge, grade} = data[type][length];
|
||||
if(min==void 0 || value >= min) return {judge, grade};
|
||||
}
|
||||
}
|
||||
|
||||
export { summary };
|
||||
31
liferestartWX/utils/liferestart/functions/util.js
Normal file
31
liferestartWX/utils/liferestart/functions/util.js
Normal file
@@ -0,0 +1,31 @@
|
||||
function clone(value) {
|
||||
switch(typeof value) {
|
||||
case 'object':
|
||||
if(Array.isArray(value)) return value.map(v=>clone(v));
|
||||
const newObj = {};
|
||||
for(const key in value) newObj[key] = clone(value[key]);
|
||||
return newObj;
|
||||
default: return value;
|
||||
}
|
||||
}
|
||||
|
||||
function max(...arr) {
|
||||
return Math.max(...arr.flat());
|
||||
}
|
||||
|
||||
function min(...arr) {
|
||||
return Math.min(...arr.flat());
|
||||
}
|
||||
|
||||
function sum(...arr) {
|
||||
let s = 0;
|
||||
arr.flat().forEach(v=>s+=v);
|
||||
return s;
|
||||
}
|
||||
|
||||
function average(...arr) {
|
||||
const s = sum(...arr);
|
||||
return s / arr.flat().length;
|
||||
}
|
||||
|
||||
export { clone, max, min, sum, average };
|
||||
135
liferestartWX/utils/liferestart/life.js
Normal file
135
liferestartWX/utils/liferestart/life.js
Normal file
@@ -0,0 +1,135 @@
|
||||
import Property from './property.js';
|
||||
import Event from './event.js';
|
||||
import Talent from './talent.js';
|
||||
import {allAge, allEvents, allTalents} from './data/dataUtils.js';
|
||||
|
||||
class Life {
|
||||
constructor() {
|
||||
this.#property = new Property();
|
||||
this.#event = new Event();
|
||||
this.#talent = new Talent();
|
||||
}
|
||||
|
||||
#property;
|
||||
#event;
|
||||
#talent;
|
||||
#triggerTalents;
|
||||
|
||||
async initial() {
|
||||
// console.log('life.js initial', property, event, talent)
|
||||
// 加载数据方式改为从本地读取JS
|
||||
var _this = this
|
||||
_this.#property.initial(allAge());
|
||||
_this.#talent.initial(allTalents());
|
||||
_this.#event.initial(allEvents());
|
||||
// console.log('life.js initial 2 p', _this.#property,'e', _this.#event, 'e',_this.#talent)
|
||||
// var age = []
|
||||
// var talents = []
|
||||
// var events = []
|
||||
// const age = await json('age');
|
||||
// const talents = await json('talents');
|
||||
// const events = await json('events');
|
||||
|
||||
}
|
||||
|
||||
restart(allocation) {
|
||||
this.#triggerTalents = {};
|
||||
this.#property.restart(allocation);
|
||||
this.doTalent();
|
||||
this.#property.record();
|
||||
}
|
||||
|
||||
getTalentAllocationAddition(talents) {
|
||||
return this.#talent.allocationAddition(talents);
|
||||
}
|
||||
|
||||
getTalentCurrentTriggerCount(talentId) {
|
||||
return this.#triggerTalents[talentId] || 0;
|
||||
}
|
||||
|
||||
next() {
|
||||
const {age, event, talent} = this.#property.ageNext();
|
||||
|
||||
const talentContent = this.doTalent(talent);
|
||||
const eventContent = this.doEvent(this.random(event));
|
||||
this.#property.record();
|
||||
|
||||
const isEnd = this.#property.isEnd();
|
||||
|
||||
const content = [talentContent, eventContent].flat();
|
||||
return { age, content, isEnd };
|
||||
}
|
||||
|
||||
doTalent(talents) {
|
||||
if(talents) this.#property.change(this.#property.TYPES.TLT, talents);
|
||||
talents = this.#property.get(this.#property.TYPES.TLT)
|
||||
.filter(talentId => this.getTalentCurrentTriggerCount(talentId) < this.#talent.get(talentId).max_triggers);
|
||||
|
||||
const contents = [];
|
||||
for(const talentId of talents) {
|
||||
const result = this.#talent.do(talentId, this.#property);
|
||||
if(!result) continue;
|
||||
this.#triggerTalents[talentId] = this.getTalentCurrentTriggerCount(talentId) + 1;
|
||||
const { effect, name, description, grade } = result;
|
||||
contents.push({
|
||||
type: this.#property.TYPES.TLT,
|
||||
name,
|
||||
grade,
|
||||
description,
|
||||
})
|
||||
if(!effect) continue;
|
||||
this.#property.effect(effect);
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
doEvent(eventId) {
|
||||
const { effect, next, description, postEvent } = this.#event.do(eventId, this.#property);
|
||||
this.#property.change(this.#property.TYPES.EVT, eventId);
|
||||
this.#property.effect(effect);
|
||||
const content = {
|
||||
type: this.#property.TYPES.EVT,
|
||||
description,
|
||||
postEvent,
|
||||
}
|
||||
if(next) return [content, this.doEvent(next)].flat();
|
||||
return [content];
|
||||
}
|
||||
|
||||
random(events) {
|
||||
events = events.filter(([eventId])=>this.#event.check(eventId, this.#property));
|
||||
|
||||
let totalWeights = 0;
|
||||
for(const [, weight] of events)
|
||||
totalWeights += weight;
|
||||
|
||||
let random = Math.random() * totalWeights;
|
||||
for(const [eventId, weight] of events)
|
||||
if((random-=weight)<0)
|
||||
return eventId;
|
||||
return events[events.length-1];
|
||||
}
|
||||
|
||||
talentRandom() {
|
||||
return this.#talent.talentRandom(JSON.parse(localStorage.extendTalent||'null'));
|
||||
}
|
||||
|
||||
talentExtend(talentId) {
|
||||
localStorage.extendTalent = JSON.stringify(talentId);
|
||||
}
|
||||
|
||||
getRecord() {
|
||||
return this.#property.getRecord();
|
||||
}
|
||||
|
||||
getLastRecord() {
|
||||
return this.#property.getLastRecord();
|
||||
}
|
||||
|
||||
exclusive(talents, exclusive) {
|
||||
return this.#talent.exclusive(talents, exclusive);
|
||||
}
|
||||
}
|
||||
|
||||
export default Life;
|
||||
|
||||
166
liferestartWX/utils/liferestart/property.js
Normal file
166
liferestartWX/utils/liferestart/property.js
Normal file
@@ -0,0 +1,166 @@
|
||||
import { clone } from './functions/util.js';
|
||||
|
||||
class Property {
|
||||
constructor() {}
|
||||
|
||||
TYPES = {
|
||||
AGE: "AGE",
|
||||
CHR: "CHR",
|
||||
INT: "INT",
|
||||
STR: "STR",
|
||||
MNY: "MNY",
|
||||
SPR: "SPR",
|
||||
LIF: "LIF",
|
||||
TLT: "TLT",
|
||||
EVT: "EVT",
|
||||
};
|
||||
|
||||
#ageData;
|
||||
#data;
|
||||
#record;
|
||||
|
||||
// 初始化传参数去掉{}
|
||||
initial(age) {
|
||||
|
||||
this.#ageData = age;
|
||||
for(const a in age) {
|
||||
let { event, talent } = age[a];
|
||||
if(!Array.isArray(event))
|
||||
event = event?.split(',') || [];
|
||||
|
||||
event = event.map(v=>{
|
||||
const value = `${v}`.split('*').map(n=>Number(n));
|
||||
if(value.length==1) value.push(1);
|
||||
return value;
|
||||
});
|
||||
|
||||
if(!Array.isArray(talent))
|
||||
talent = talent?.split(',') || [];
|
||||
|
||||
talent = talent.map(v=>Number(v));
|
||||
|
||||
age[a] = { event, talent };
|
||||
}
|
||||
}
|
||||
|
||||
restart(data) {
|
||||
this.#data = {
|
||||
[this.TYPES.AGE]: -1,
|
||||
[this.TYPES.CHR]: 0,
|
||||
[this.TYPES.INT]: 0,
|
||||
[this.TYPES.STR]: 0,
|
||||
[this.TYPES.MNY]: 0,
|
||||
[this.TYPES.SPR]: 0,
|
||||
[this.TYPES.LIF]: 1,
|
||||
[this.TYPES.TLT]: [],
|
||||
[this.TYPES.EVT]: [],
|
||||
};
|
||||
for(const key in data)
|
||||
this.change(key, data[key]);
|
||||
this.#record = [];
|
||||
}
|
||||
|
||||
get(prop) {
|
||||
switch(prop) {
|
||||
case this.TYPES.AGE:
|
||||
case this.TYPES.CHR:
|
||||
case this.TYPES.INT:
|
||||
case this.TYPES.STR:
|
||||
case this.TYPES.MNY:
|
||||
case this.TYPES.SPR:
|
||||
case this.TYPES.LIF:
|
||||
case this.TYPES.TLT:
|
||||
case this.TYPES.EVT:
|
||||
return clone(this.#data[prop]);
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
set(prop, value) {
|
||||
switch(prop) {
|
||||
case this.TYPES.AGE:
|
||||
case this.TYPES.CHR:
|
||||
case this.TYPES.INT:
|
||||
case this.TYPES.STR:
|
||||
case this.TYPES.MNY:
|
||||
case this.TYPES.SPR:
|
||||
case this.TYPES.LIF:
|
||||
case this.TYPES.TLT:
|
||||
case this.TYPES.EVT:
|
||||
this.#data[prop] = clone(value);
|
||||
break;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
record() {
|
||||
this.#record.push({
|
||||
[this.TYPES.AGE]: this.get(this.TYPES.AGE),
|
||||
[this.TYPES.CHR]: this.get(this.TYPES.CHR),
|
||||
[this.TYPES.INT]: this.get(this.TYPES.INT),
|
||||
[this.TYPES.STR]: this.get(this.TYPES.STR),
|
||||
[this.TYPES.MNY]: this.get(this.TYPES.MNY),
|
||||
[this.TYPES.SPR]: this.get(this.TYPES.SPR),
|
||||
});
|
||||
}
|
||||
|
||||
getRecord() {
|
||||
return clone(this.#record);
|
||||
}
|
||||
|
||||
getLastRecord() {
|
||||
return clone(this.#record[this.#record.length - 1]);
|
||||
}
|
||||
|
||||
change(prop, value) {
|
||||
if(Array.isArray(value)) {
|
||||
for(const v of value)
|
||||
this.change(prop, Number(v));
|
||||
return;
|
||||
}
|
||||
switch(prop) {
|
||||
case this.TYPES.AGE:
|
||||
case this.TYPES.CHR:
|
||||
case this.TYPES.INT:
|
||||
case this.TYPES.STR:
|
||||
case this.TYPES.MNY:
|
||||
case this.TYPES.SPR:
|
||||
case this.TYPES.LIF:
|
||||
this.#data[prop] += Number(value);
|
||||
break;
|
||||
case this.TYPES.TLT:
|
||||
case this.TYPES.EVT:
|
||||
const v = this.#data[prop];
|
||||
if(value<0) {
|
||||
const index = v.indexOf(value);
|
||||
if(index!=-1) v.splice(index,1);
|
||||
}
|
||||
if(!v.includes(value)) v.push(value);
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
effect(effects) {
|
||||
for(const prop in effects)
|
||||
this.change(prop, Number(effects[prop]));
|
||||
}
|
||||
|
||||
isEnd() {
|
||||
return this.get(this.TYPES.LIF) < 1;
|
||||
}
|
||||
|
||||
ageNext() {
|
||||
this.change(this.TYPES.AGE, 1);
|
||||
const age = this.get(this.TYPES.AGE);
|
||||
const {event, talent} = this.getAgeData(age);
|
||||
return {age, event, talent};
|
||||
}
|
||||
|
||||
getAgeData(age) {
|
||||
return clone(this.#ageData[age]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Property;
|
||||
103
liferestartWX/utils/liferestart/talent.js
Normal file
103
liferestartWX/utils/liferestart/talent.js
Normal file
@@ -0,0 +1,103 @@
|
||||
import { clone } from './functions/util.js';
|
||||
import { checkCondition, extractMaxTriggers } from './functions/condition.js';
|
||||
|
||||
class Talent {
|
||||
constructor() {}
|
||||
|
||||
#talents;
|
||||
|
||||
// 初始化传参数去掉{}
|
||||
initial(talents) {
|
||||
this.#talents = talents;
|
||||
for(const id in talents) {
|
||||
const talent = talents[id];
|
||||
talent.id= Number(id);
|
||||
talent.grade = Number(talent.grade);
|
||||
talent.max_triggers = extractMaxTriggers(talent.condition);
|
||||
}
|
||||
}
|
||||
|
||||
check(talentId, property) {
|
||||
const { condition } = this.get(talentId);
|
||||
return checkCondition(property, condition);
|
||||
}
|
||||
|
||||
get(talentId) {
|
||||
// console.log('talent.js get',talentId,this.#talents)
|
||||
var talent
|
||||
this.#talents.forEach(function(item){
|
||||
if (item._id == talentId) {
|
||||
talent = item
|
||||
}
|
||||
})
|
||||
if(!talent) throw new Error(`[ERROR] No Talent[${talentId}]`);
|
||||
return clone(talent);
|
||||
}
|
||||
|
||||
information(talentId) {
|
||||
const { grade, name, description } = this.get(talentId)
|
||||
return { grade, name, description };
|
||||
}
|
||||
|
||||
exclusive(talends, exclusiveId) {
|
||||
const { exclusive } = this.get(exclusiveId);
|
||||
if(!exclusive) return null;
|
||||
for(const talent of talends) {
|
||||
for(const e of exclusive) {
|
||||
if(talent == e) return talent;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
talentRandom(include) {
|
||||
// 1000, 100, 10, 1
|
||||
const talentList = {};
|
||||
for(const talentId in this.#talents) {
|
||||
const { id, grade, name, description } = this.#talents[talentId];
|
||||
if(id == include) {
|
||||
include = { grade, name, description, id };
|
||||
continue;
|
||||
}
|
||||
if(!talentList[grade]) talentList[grade] = [{ grade, name, description, id }];
|
||||
else talentList[grade].push({ grade, name, description, id });
|
||||
}
|
||||
|
||||
return new Array(10)
|
||||
.fill(1).map((v, i)=>{
|
||||
if(!i && include) return include;
|
||||
const gradeRandom = Math.random();
|
||||
let grade;
|
||||
if(gradeRandom>=0.111) grade = 0;
|
||||
else if(gradeRandom>=0.011) grade = 1;
|
||||
else if(gradeRandom>=0.001) grade = 2;
|
||||
else grade = 3;
|
||||
|
||||
while(talentList[grade].length == 0) grade--;
|
||||
|
||||
const length = talentList[grade].length;
|
||||
|
||||
const random = Math.floor(Math.random()*length) % length;
|
||||
return talentList[grade].splice(random,1)[0];
|
||||
});
|
||||
}
|
||||
|
||||
allocationAddition(talents) {
|
||||
if(Array.isArray(talents)) {
|
||||
let addition = 0;
|
||||
for(const talent of talents)
|
||||
addition += this.allocationAddition(talent);
|
||||
return addition;
|
||||
}
|
||||
return Number(this.get(talents).status) || 0;
|
||||
}
|
||||
|
||||
do(talentId, property) {
|
||||
const { effect, condition, grade, name, description } = this.get(talentId);
|
||||
if(condition && !checkCondition(property, condition))
|
||||
return null;
|
||||
return { effect, grade, name, description };
|
||||
}
|
||||
}
|
||||
|
||||
export default Talent;
|
||||
BIN
liferestartWX/utils/wux/.DS_Store
vendored
Normal file
BIN
liferestartWX/utils/wux/.DS_Store
vendored
Normal file
Binary file not shown.
1
liferestartWX/utils/wux/actionsheet/index.js
Normal file
1
liferestartWX/utils/wux/actionsheet/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames7=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(n,!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var defaults={prefixCls:"wux-actionsheet",theme:"ios",className:"",titleText:"",buttons:[],buttonClicked:function(){},cancelText:"取消",cancel:function(){}};(0,_baseComponent.default)({useFunc:!0,data:defaults,computed:{classes:["prefixCls, theme, buttons, cancelText",function(n,e,t,r){var o,c=(0,_classNames7.default)(n),a="".concat(n,"__popup"),s=(0,_classNames7.default)("".concat(n,"__content"),(_defineProperty(o={},"".concat(n,"__content--theme-").concat(e),e),_defineProperty(o,"".concat(n,"__content--has-cancel"),r),o)),i=(0,_classNames7.default)("".concat(n,"__group"),_defineProperty({},"".concat(n,"__group--options"),!0)),u="".concat(n,"__title"),d=(0,_classNames7.default)("".concat(n,"__button"),_defineProperty({},"".concat(n,"__button--destructive"),!0));return{wrap:c,popup:a,content:s,options:i,title:u,button:t.map(function(e){var t;return{wrap:(0,_classNames7.default)("".concat(n,"__button"),(_defineProperty(t={},"".concat(n,"__button--option"),!0),_defineProperty(t,"".concat(n,"__button--disabled"),e.disabled),_defineProperty(t,"".concat(e.className),e.className),t)),hover:e.hoverClass&&"default"!==e.hoverClass?e.hoverClass:"".concat(n,"__button--hover")}}),icon:"".concat(n,"__icon"),text:"".concat(n,"__text"),destructive:d,group:(0,_classNames7.default)("".concat(n,"__group"),_defineProperty({},"".concat(n,"__group--cancel"),!0)),cancel:(0,_classNames7.default)("".concat(n,"__button"),_defineProperty({},"".concat(n,"__button--cancel"),!0)),hover:"".concat(n,"__button--hover")}}]},methods:{showSheet:function(e){var t=0<arguments.length&&void 0!==e?e:{},n=this.$$mergeOptionsAndBindMethods(Object.assign({},defaults,t));return this.removed=!1,this.$$setData(_objectSpread({in:!0},n)),this.cancel.bind(this)},removeSheet:function(e){if(this.removed)return!1;this.removed=!0,this.$$setData({in:!1}),"function"==typeof e&&e(this.data.buttons)},buttonClicked:function(e){var t=e.currentTarget.dataset.index;!0===this.fns.buttonClicked(t,this.data.buttons[t])&&this.removeSheet()},destructiveButtonClicked:function(){!0===this.fns.destructiveButtonClicked()&&this.removeSheet()},cancel:function(){this.removeSheet(this.fns.cancel)},bindgetuserinfo:function(e){this.triggerEvent("getuserinfo",_objectSpread({},e.detail,{},e.currentTarget.dataset))},bindcontact:function(e){this.triggerEvent("contact",_objectSpread({},e.detail,{},e.currentTarget.dataset))},bindgetphonenumber:function(e){this.triggerEvent("getphonenumber",_objectSpread({},e.detail,{},e.currentTarget.dataset))},bindopensetting:function(e){this.triggerEvent("opensetting",_objectSpread({},e.detail,{},e.currentTarget.dataset))},onError:function(e){this.triggerEvent("error",_objectSpread({},e.detail,{},e.currentTarget.dataset))}}});
|
||||
6
liferestartWX/utils/wux/actionsheet/index.json
Normal file
6
liferestartWX/utils/wux/actionsheet/index.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wux-popup": "../popup/index"
|
||||
}
|
||||
}
|
||||
41
liferestartWX/utils/wux/actionsheet/index.wxml
Normal file
41
liferestartWX/utils/wux/actionsheet/index.wxml
Normal file
@@ -0,0 +1,41 @@
|
||||
<wux-popup wux-content-class="{{ theme === 'ios' ? classes.popup : '' }}" position="bottom" visible="{{ in }}" safeArea="bottom" bind:close="cancel">
|
||||
<view class="wux-class {{ classes.wrap }}">
|
||||
<view class="{{ classes.content }}">
|
||||
<view class="{{ classes.options }}">
|
||||
<view class="{{ classes.title }}" wx:if="{{ titleText }}">{{ titleText }}</view>
|
||||
<block wx:for="{{ buttons }}" wx:for-item="button" wx:key="index">
|
||||
<button
|
||||
class="{{ classes.button[index].wrap }}"
|
||||
data-index="{{ index }}"
|
||||
disabled="{{ button.disabled }}"
|
||||
open-type="{{ button.openType }}"
|
||||
hover-class="{{ !button.disabled ? classes.button[index].hover : 'none' }}"
|
||||
hover-stop-propagation="{{ button.hoverStopPropagation }}"
|
||||
hover-start-time="{{ button.hoverStartTime }}"
|
||||
hover-stay-time="{{ button.hoverStayTime }}"
|
||||
lang="{{ button.lang }}"
|
||||
bindgetuserinfo="bindgetuserinfo"
|
||||
session-from="{{ button.sessionFrom }}"
|
||||
send-message-title="{{ button.sendMessageTitle }}"
|
||||
send-message-path="{{ button.sendMessagePath }}"
|
||||
send-message-img="{{ button.sendMessageImg }}"
|
||||
show-message-card="{{ button.showMessageCard }}"
|
||||
bindcontact="bindcontact"
|
||||
bindgetphonenumber="bindgetphonenumber"
|
||||
app-parameter="{{ button.appParameter }}"
|
||||
binderror="onError"
|
||||
bindopensetting="bindopensetting"
|
||||
catchtap="buttonClicked"
|
||||
>
|
||||
<image class="{{ classes.icon }}" src="{{ button.icon }}" wx:if="{{ button.icon }}" />
|
||||
<text class="{{ classes.text }}">{{ button.text }}</text>
|
||||
</button>
|
||||
</block>
|
||||
<button class="{{ classes.destructive }}" wx:if="{{ destructiveText }}" catchtap="destructiveButtonClicked">{{ destructiveText }}</button>
|
||||
</view>
|
||||
<view class="{{ classes.group }}" wx:if="{{ cancelText }}">
|
||||
<button class="{{ classes.cancel }}" hover-class="{{ classes.hover }}" catchtap="cancel">{{ cancelText }}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wux-popup>
|
||||
1
liferestartWX/utils/wux/actionsheet/index.wxss
Normal file
1
liferestartWX/utils/wux/actionsheet/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.wux-actionsheet__popup{background-color:transparent}.wux-actionsheet__content{margin-left:16rpx;margin-right:16rpx;width:auto;overflow:hidden}.wux-actionsheet__content--theme-wx{margin-left:0;margin-right:0;margin-bottom:0}.wux-actionsheet__content--theme-wx .wux-actionsheet__group{border-radius:0;margin-bottom:12rpx}.wux-actionsheet__content--theme-wx .wux-actionsheet__group--options{background-color:#fff}.wux-actionsheet__content--theme-wx .wux-actionsheet__group--cancel{margin-bottom:0}.wux-actionsheet__content--theme-wx .wux-actionsheet__button{font-size:36rpx;color:#000}.wux-actionsheet__content--theme-wx .wux-actionsheet__button--cancel{font-weight:400}.wux-actionsheet__content--theme-wx.wux-actionsheet__content--has-cancel{background-color:#efeff4}.wux-actionsheet__group{margin-bottom:16rpx;border-radius:8rpx;background-color:#fff;overflow:hidden}.wux-actionsheet__group--options{background-color:#f1f2f3}.wux-actionsheet__title{padding:32rpx;color:#8f8f8f;text-align:center;font-size:26rpx}.wux-actionsheet__button{position:relative;display:block;margin:0;padding:0;min-width:104rpx;min-height:96rpx;vertical-align:top;text-align:center;text-overflow:ellipsis;cursor:pointer;width:100%;border-radius:0;background-color:transparent;color:#007aff;font-size:42rpx;line-height:96rpx;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.wux-actionsheet__button--hover{box-shadow:none;border-color:#d1d3d6;color:#007aff;background:#e4e5e7}.wux-actionsheet__button--destructive{color:#ff3b30!important}.wux-actionsheet__button--cancel{font-weight:500}.wux-actionsheet__button--disabled{opacity:.3!important}.wux-actionsheet__group .wux-actionsheet__button{border-top:none}.wux-actionsheet__group .wux-actionsheet__button::after{transform:none;transform-origin:none;border:none;border-radius:0;content:" ";position:absolute;left:0;top:0;right:0;height:1PX;border-top:1PX solid #d9d9d9;color:#d9d9d9;transform-origin:0 0;transform:scaleY(.5)}.wux-actionsheet__group .wux-actionsheet__button:first-child:last-child::after{border-width:0}.wux-actionsheet__icon{width:48rpx;height:48rpx;display:inline-block;margin-right:20rpx}
|
||||
1
liferestartWX/utils/wux/animation-group/index.js
Normal file
1
liferestartWX/utils/wux/animation-group/index.js
Normal file
File diff suppressed because one or more lines are too long
3
liferestartWX/utils/wux/animation-group/index.json
Normal file
3
liferestartWX/utils/wux/animation-group/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
3
liferestartWX/utils/wux/animation-group/index.wxml
Normal file
3
liferestartWX/utils/wux/animation-group/index.wxml
Normal file
@@ -0,0 +1,3 @@
|
||||
<view class="wux-class {{ wrapCls }} {{ animateCss }}" bindtap="onTap" catchtouchmove="{{ disableScroll ? 'noop' : '' }}" bindtransitionend="onTransitionEnd" bindanimationend="onAnimationEnd" wx:if="{{ animateStatus !== 'unmounted' }}" style="{{ extStyle }}">
|
||||
<slot></slot>
|
||||
</view>
|
||||
1
liferestartWX/utils/wux/animation-group/index.wxss
Normal file
1
liferestartWX/utils/wux/animation-group/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.wux-animate--fadeIn-enter{transition:opacity .3s;opacity:0}.wux-animate--fadeIn-enter-active,.wux-animate--fadeIn-enter-done{opacity:1}.wux-animate--fadeIn-exit{transition:opacity .3s;opacity:1}.wux-animate--fadeIn-exit-active,.wux-animate--fadeIn-exit-done{opacity:0}.wux-animate--fadeInDown-enter{transition:opacity .3s,transform .3s;opacity:0;transform:translate3d(0,-100%,0)}.wux-animate--fadeInDown-enter-active,.wux-animate--fadeInDown-enter-done{opacity:1;transform:none}.wux-animate--fadeInDown-exit{transition:opacity .3s,transform .3s;opacity:1;transform:none}.wux-animate--fadeInDown-exit-active,.wux-animate--fadeInDown-exit-done{opacity:0;transform:translate3d(0,-100%,0)}.wux-animate--fadeInLeft-enter{transition:opacity .3s,transform .3s;opacity:0;transform:translate3d(-100%,0,0)}.wux-animate--fadeInLeft-enter-active,.wux-animate--fadeInLeft-enter-done{opacity:1;transform:none}.wux-animate--fadeInLeft-exit{transition:opacity .3s,transform .3s;opacity:1;transform:none}.wux-animate--fadeInLeft-exit-active,.wux-animate--fadeInLeft-exit-done{opacity:0;transform:translate3d(-100%,0,0)}.wux-animate--fadeInRight-enter{transition:opacity .3s,transform .3s;opacity:0;transform:translate3d(100%,0,0)}.wux-animate--fadeInRight-enter-active,.wux-animate--fadeInRight-enter-done{opacity:1;transform:none}.wux-animate--fadeInRight-exit{transition:opacity .3s,transform .3s;opacity:1;transform:none}.wux-animate--fadeInRight-exit-active,.wux-animate--fadeInRight-exit-done{opacity:0;transform:translate3d(100%,0,0)}.wux-animate--fadeInUp-enter{transition:opacity .3s,transform .3s;opacity:0;transform:translate3d(0,100%,0)}.wux-animate--fadeInUp-enter-active,.wux-animate--fadeInUp-enter-done{opacity:1;transform:none}.wux-animate--fadeInUp-exit{transition:opacity .3s,transform .3s;opacity:1;transform:none}.wux-animate--fadeInUp-exit-active,.wux-animate--fadeInUp-exit-done{opacity:0;transform:translate3d(0,100%,0)}.wux-animate--slideInUp-enter{transition:transform .3s;transform:translate3d(0,100%,0);visibility:visible}.wux-animate--slideInUp-enter-active,.wux-animate--slideInUp-enter-done{transform:translateZ(0)}.wux-animate--slideInUp-exit{transition:transform .3s;transform:translateZ(0)}.wux-animate--slideInUp-exit-active,.wux-animate--slideInUp-exit-done{transform:translate3d(0,100%,0);visibility:visible}.wux-animate--slideInDown-enter{transition:transform .3s;transform:translate3d(0,-100%,0);visibility:visible}.wux-animate--slideInDown-enter-active,.wux-animate--slideInDown-enter-done{transform:translateZ(0)}.wux-animate--slideInDown-exit{transition:transform .3s;transform:translateZ(0)}.wux-animate--slideInDown-exit-active,.wux-animate--slideInDown-exit-done{transform:translate3d(0,-100%,0);visibility:visible}.wux-animate--slideInLeft-enter{transition:transform .3s;transform:translate3d(-100%,0,0);visibility:visible}.wux-animate--slideInLeft-enter-active,.wux-animate--slideInLeft-enter-done{transform:translateZ(0)}.wux-animate--slideInLeft-exit{transition:transform .3s;transform:translateZ(0)}.wux-animate--slideInLeft-exit-active,.wux-animate--slideInLeft-exit-done{transform:translate3d(-100%,0,0);visibility:visible}.wux-animate--slideInRight-enter{transition:transform .3s;transform:translate3d(100%,0,0);visibility:visible}.wux-animate--slideInRight-enter-active,.wux-animate--slideInRight-enter-done{transform:none}.wux-animate--slideInRight-exit{transition:transform .3s;transform:none}.wux-animate--slideInRight-exit-active,.wux-animate--slideInRight-exit-done{transform:translate3d(100%,0,0);visibility:visible}.wux-animate--zoom-enter{transition:all .3s cubic-bezier(.215,.61,.355,1);opacity:.01;transform:scale(.75)}.wux-animate--zoom-enter-active,.wux-animate--zoom-enter-done{opacity:1;transform:none}.wux-animate--zoom-exit{transition:all .25s linear;transform:none}.wux-animate--zoom-exit-active,.wux-animate--zoom-exit-done{opacity:.01;transform:scale(.75)}.wux-animate--punch-enter{transition:all .3s cubic-bezier(.215,.61,.355,1);opacity:.01;transform:scale(1.35)}.wux-animate--punch-enter-active,.wux-animate--punch-enter-done{opacity:1;transform:none}.wux-animate--punch-exit{transition:all .25s linear;transform:none}.wux-animate--punch-exit-active,.wux-animate--punch-exit-done{opacity:.01;transform:scale(1.35)}
|
||||
1
liferestartWX/utils/wux/backdrop/index.js
Normal file
1
liferestartWX/utils/wux/backdrop/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(0,_baseComponent.default)({properties:{prefixCls:{type:String,value:"wux-backdrop"},transparent:{type:Boolean,value:!1},zIndex:{type:Number,value:1e3},classNames:{type:null,value:"wux-animate--fadeIn"}},computed:{classes:["prefixCls, transparent",function(e,t){return{wrap:t?"".concat(e,"--transparent"):e}}]},methods:{retain:function(){"number"==typeof this.backdropHolds&&this.backdropHolds||(this.backdropHolds=0),this.backdropHolds=this.backdropHolds+1,1===this.backdropHolds&&this.setData({in:!0})},release:function(){1===this.backdropHolds&&this.setData({in:!1}),this.backdropHolds=Math.max(0,this.backdropHolds-1)},onClick:function(){this.triggerEvent("click")}}});
|
||||
6
liferestartWX/utils/wux/backdrop/index.json
Normal file
6
liferestartWX/utils/wux/backdrop/index.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wux-animation-group": "../animation-group/index"
|
||||
}
|
||||
}
|
||||
1
liferestartWX/utils/wux/backdrop/index.wxml
Normal file
1
liferestartWX/utils/wux/backdrop/index.wxml
Normal file
@@ -0,0 +1 @@
|
||||
<wux-animation-group wux-class="{{ classes.wrap }}" in="{{ in }}" classNames="{{ classNames }}" bind:click="onClick" wrapStyle="{{ { zIndex } }}" disableScroll />
|
||||
1
liferestartWX/utils/wux/backdrop/index.wxss
Normal file
1
liferestartWX/utils/wux/backdrop/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.wux-backdrop{background:rgba(0,0,0,.4)}.wux-backdrop,.wux-backdrop--transparent{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0}.wux-backdrop--transparent{background:0 0}
|
||||
1
liferestartWX/utils/wux/button/index.js
Normal file
1
liferestartWX/utils/wux/button/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}(0,_baseComponent.default)({properties:{prefixCls:{type:String,value:"wux-button"},type:{type:String,value:"stable"},clear:{type:Boolean,value:!1},block:{type:Boolean,value:!1},full:{type:Boolean,value:!1},outline:{type:Boolean,value:!1},bordered:{type:Boolean,value:!0},size:{type:String,value:"default"},disabled:{type:Boolean,value:!1},loading:{type:Boolean,value:!1},formType:{type:String,value:""},openType:{type:String,value:""},hoverClass:{type:String,value:"default"},hoverStopPropagation:{type:Boolean,value:!1},hoverStartTime:{type:Number,value:20},hoverStayTime:{type:Number,value:70},lang:{type:String,value:"en"},sessionFrom:{type:String,value:""},sendMessageTitle:{type:String,value:""},sendMessagePath:{type:String,value:""},sendMessageImg:{type:String,value:""},showMessageCard:{type:Boolean,value:!1},appParameter:{type:String,value:""}},computed:{classes:["prefixCls, hoverClass, type, size, block, full, clear, outline, bordered, disabled",function(e,t,n,r,a,o,i,l,u,s){var p;return{wrap:(0,_classNames2.default)(e,(_defineProperty(p={},"".concat(e,"--").concat(n),n),_defineProperty(p,"".concat(e,"--").concat(r),r),_defineProperty(p,"".concat(e,"--block"),a),_defineProperty(p,"".concat(e,"--full"),o),_defineProperty(p,"".concat(e,"--clear"),i),_defineProperty(p,"".concat(e,"--outline"),l),_defineProperty(p,"".concat(e,"--bordered"),u),_defineProperty(p,"".concat(e,"--disabled"),s),p)),hover:t&&"default"!==t?t:"".concat(e,"--hover")}}]},methods:{onTap:function(){this.data.disabled||this.data.loading||this.triggerEvent("click")},bindgetuserinfo:function(e){this.triggerEvent("getuserinfo",e.detail)},bindcontact:function(e){this.triggerEvent("contact",e.detail)},bindgetphonenumber:function(e){this.triggerEvent("getphonenumber",e.detail)},bindopensetting:function(e){this.triggerEvent("opensetting",e.detail)},onError:function(e){this.triggerEvent("error",e.detail)}}});
|
||||
3
liferestartWX/utils/wux/button/index.json
Normal file
3
liferestartWX/utils/wux/button/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
26
liferestartWX/utils/wux/button/index.wxml
Normal file
26
liferestartWX/utils/wux/button/index.wxml
Normal file
@@ -0,0 +1,26 @@
|
||||
<button
|
||||
class="wux-class {{ classes.wrap }}"
|
||||
disabled="{{ disabled }}"
|
||||
loading="{{ loading }}"
|
||||
form-type="{{ formType }}"
|
||||
open-type="{{ openType }}"
|
||||
hover-class="wux-hover-class {{ !disabled ? classes.hover : 'none' }}"
|
||||
hover-stop-propagation="{{ hoverStopPropagation }}"
|
||||
hover-start-time="{{ hoverStartTime }}"
|
||||
hover-stay-time="{{ hoverStayTime }}"
|
||||
lang="{{ lang }}"
|
||||
bindgetuserinfo="bindgetuserinfo"
|
||||
session-from="{{ sessionFrom }}"
|
||||
send-message-title="{{ sendMessageTitle }}"
|
||||
send-message-path="{{ sendMessagePath }}"
|
||||
send-message-img="{{ sendMessageImg }}"
|
||||
show-message-card="{{ showMessageCard }}"
|
||||
bindcontact="bindcontact"
|
||||
bindgetphonenumber="bindgetphonenumber"
|
||||
app-parameter="{{ appParameter }}"
|
||||
binderror="onError"
|
||||
bindopensetting="bindopensetting"
|
||||
bindtap="onTap"
|
||||
>
|
||||
<slot></slot>
|
||||
</button>
|
||||
1
liferestartWX/utils/wux/button/index.wxss
Normal file
1
liferestartWX/utils/wux/button/index.wxss
Normal file
File diff suppressed because one or more lines are too long
1
liferestartWX/utils/wux/card/index.js
Normal file
1
liferestartWX/utils/wux/card/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames3=_interopRequireDefault(require("../helpers/classNames")),_styleToCssString=_interopRequireDefault(require("../helpers/styleToCssString"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}(0,_baseComponent.default)({properties:{prefixCls:{type:String,value:"wux-card"},bordered:{type:Boolean,value:!0},full:{type:Boolean,value:!1},title:{type:String,value:""},thumb:{type:String,value:""},thumbStyle:{type:[String,Object],value:"",observer:function(e){this.setData({extStyle:(0,_styleToCssString.default)(e)})}},extra:{type:String,value:""},actions:{type:Array,value:[]}},data:{extStyle:""},computed:{classes:["prefixCls, bordered, full, actions",function(a,e,t,n){var r;return{wrap:(0,_classNames3.default)(a,(_defineProperty(r={},"".concat(a,"--bordered"),e),_defineProperty(r,"".concat(a,"--full"),t),_defineProperty(r,"".concat(a,"--has-actions"),0<n.length),r)),hd:"".concat(a,"__hd"),content:"".concat(a,"__content"),thumb:"".concat(a,"__thumb"),extra:"".concat(a,"__extra"),bd:"".concat(a,"__bd"),ft:"".concat(a,"__ft"),actions:"".concat(a,"__actions"),action:n.map(function(e){var t;return{wrap:(0,_classNames3.default)("".concat(a,"__action"),(_defineProperty(t={},"".concat(a,"__action--").concat(e.type||"default"),e.type||"default"),_defineProperty(t,"".concat(a,"__action--bold"),e.bold),_defineProperty(t,"".concat(a,"__action--disabled"),e.disabled),_defineProperty(t,"".concat(e.className),e.className),t)),hover:e.hoverClass&&"default"!==e.hoverClass?e.hoverClass:"".concat(a,"__action--hover")}})}}]},methods:{onAction:function(e){var t=e.currentTarget.dataset.index,a=this.data.actions,n=a[t];n.disabled||this.triggerEvent("action",{index:t,action:n,actions:a})}}});
|
||||
3
liferestartWX/utils/wux/card/index.json
Normal file
3
liferestartWX/utils/wux/card/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
28
liferestartWX/utils/wux/card/index.wxml
Normal file
28
liferestartWX/utils/wux/card/index.wxml
Normal file
@@ -0,0 +1,28 @@
|
||||
<view class="wux-class {{ classes.wrap }}">
|
||||
<view class="{{ classes.hd }}" wx:if="{{ thumb || title || extra }}">
|
||||
<view class="{{ classes.content }}" wx:if="{{ thumb || title }}">
|
||||
<image class="{{ classes.thumb }}" src="{{ thumb }}" mode="aspectFit" style="{{ extStyle }}" wx:if="{{ thumb }}" />
|
||||
<text>{{ title }}</text>
|
||||
</view>
|
||||
<view class="{{ classes.extra }}" wx:if="{{ extra }}">{{ extra }}</view>
|
||||
<slot name="extra" wx:else></slot>
|
||||
</view>
|
||||
<view class="{{ classes.bd }}">
|
||||
<slot name="body"></slot>
|
||||
</view>
|
||||
<view class="{{ classes.ft }}">
|
||||
<slot name="footer"></slot>
|
||||
</view>
|
||||
<view class="{{ classes.actions }}" wx:if="{{ actions.length > 0 }}">
|
||||
<block wx:for="{{ actions }}" wx:for-item="action" wx:key="">
|
||||
<view
|
||||
class="{{ classes.action[index].wrap }}"
|
||||
hover-class="{{ !action.disabled ? classes.action[index].hover : 'none' }}"
|
||||
data-index="{{ index }}"
|
||||
bindtap="onAction"
|
||||
>
|
||||
{{ action.text }}
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
1
liferestartWX/utils/wux/card/index.wxss
Normal file
1
liferestartWX/utils/wux/card/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.wux-card{position:relative;min-height:192rpx;padding-bottom:12rpx;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#fff}.wux-card--bordered{border-radius:20rpx}.wux-card--bordered::before{content:" ";position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #d9d9d9;border-radius:20rpx;border-top-width:1PX;border-right-width:1PX;border-bottom-width:1PX;border-left-width:1PX}.wux-card--full::before{border-radius:0;border-right-width:0;border-left-width:0}.wux-card--has-actions{padding-bottom:0}.wux-card__hd{position:relative;display:-ms-flexbox;display:flex;font-size:34rpx;padding:18rpx 30rpx;-ms-flex-align:center;align-items:center}.wux-card__hd::before{content:" ";position:absolute;left:0;bottom:0;right:0;height:1PX;border-bottom:1PX solid #d9d9d9;color:#d9d9d9;transform-origin:0 100%;transform:scaleY(.5)}.wux-card__content{-ms-flex:1;flex:1;text-align:left;color:#000}.wux-card__thumb{width:64rpx;height:64rpx;display:inline-block;position:relative;margin-left:auto;margin-right:10rpx;overflow:hidden;vertical-align:middle}.wux-card__extra{-ms-flex:1;flex:1;text-align:right;font-size:34rpx;color:rgba(0,0,0,.45)}.wux-card__bd{position:relative;padding:30rpx 30rpx 12rpx;font-size:30rpx;color:rgba(0,0,0,.85);min-height:80rpx}.wux-card__ft{display:-ms-flexbox;display:flex;font-size:28rpx;color:rgba(0,0,0,.45);padding:0 30rpx}.wux-card__actions{position:relative;display:-ms-flexbox;display:flex;line-height:100rpx;margin-top:12rpx;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.wux-card__actions::before{content:" ";position:absolute;left:0;top:0;right:0;height:1PX;border-top:1PX solid #d9d9d9;color:#d9d9d9;transform-origin:0 0;transform:scaleY(.5)}.wux-card__action{position:relative;display:block;-ms-flex:1;flex:1;color:#33cd5f;text-align:center}.wux-card__action::before{content:" ";position:absolute;right:0;top:0;width:1PX;bottom:0;border-right:1PX solid #d9d9d9;color:#d9d9d9;transform-origin:100% 0;transform:scaleX(.5)}.wux-card__action:last-child::before{display:none}.wux-card__action--default{color:#444}.wux-card__action--primary{color:#33cd5f!important}.wux-card__action--bold{font-weight:500!important}.wux-card__action--hover{background-color:#ececec!important}.wux-card__action--disabled{opacity:.3}
|
||||
311
liferestartWX/utils/wux/cascader/index.js
Normal file
311
liferestartWX/utils/wux/cascader/index.js
Normal file
@@ -0,0 +1,311 @@
|
||||
import baseComponent from '../helpers/baseComponent'
|
||||
import classNames from '../helpers/classNames'
|
||||
import arrayTreeFilter from '../helpers/arrayTreeFilter'
|
||||
|
||||
const WUX_CASCADER = 'wux-cascader'
|
||||
const defaultFieldNames = {
|
||||
label: 'label',
|
||||
value: 'value',
|
||||
children: 'children',
|
||||
}
|
||||
|
||||
baseComponent({
|
||||
externalClasses: ['wux-scroll-view-class'],
|
||||
properties: {
|
||||
prefixCls: {
|
||||
type: String,
|
||||
value: 'wux-cascader',
|
||||
},
|
||||
defaultValue: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
value: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
controlled: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
chooseTitle: {
|
||||
type: String,
|
||||
value: '请选择',
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
defaultFieldNames: {
|
||||
type: Object,
|
||||
value: defaultFieldNames,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
activeOptions: [],
|
||||
activeIndex: 0,
|
||||
bodyStyle: '',
|
||||
activeValue: [],
|
||||
showOptions: [],
|
||||
fieldNames: {},
|
||||
},
|
||||
computed: {
|
||||
classes: ['prefixCls', function(prefixCls) {
|
||||
const wrap = classNames(prefixCls)
|
||||
const hd = `${prefixCls}__hd`
|
||||
const title = `${prefixCls}__title`
|
||||
const menus = `${prefixCls}__menus`
|
||||
const menu = `${prefixCls}__menu`
|
||||
const bd = `${prefixCls}__bd`
|
||||
const inner = `${prefixCls}__inner`
|
||||
const scrollView = `${prefixCls}__scroll-view`
|
||||
const option = `${prefixCls}__option`
|
||||
const item = `${prefixCls}__item`
|
||||
const icon = `${prefixCls}__icon`
|
||||
const ft = `${prefixCls}__ft`
|
||||
|
||||
return {
|
||||
wrap,
|
||||
hd,
|
||||
title,
|
||||
menus,
|
||||
menu,
|
||||
bd,
|
||||
inner,
|
||||
scrollView,
|
||||
option,
|
||||
item,
|
||||
icon,
|
||||
ft,
|
||||
}
|
||||
}],
|
||||
},
|
||||
observers: {
|
||||
value(newVal) {
|
||||
if (this.data.controlled) {
|
||||
this.setData({ activeValue: newVal })
|
||||
this.getCurrentOptions(newVal)
|
||||
}
|
||||
},
|
||||
options() {
|
||||
this.getCurrentOptions(this.data.activeValue)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getActiveOptions(activeValue) {
|
||||
const { options } = this.data
|
||||
const value = this.getFieldName('value')
|
||||
const childrenKeyName = this.getFieldName('children')
|
||||
|
||||
return arrayTreeFilter(options, (option, level) => option[value] === activeValue[level], { childrenKeyName })
|
||||
},
|
||||
getShowOptions(activeValue) {
|
||||
const { options } = this.data
|
||||
const children = this.getFieldName('children')
|
||||
const result = this.getActiveOptions(activeValue).map((activeOption) => activeOption[children]).filter((activeOption) => !!activeOption)
|
||||
|
||||
return [options, ...result]
|
||||
},
|
||||
getMenus(activeValue = [], hasChildren) {
|
||||
const { options, chooseTitle } = this.data
|
||||
const activeOptions = this.getActiveOptions(activeValue)
|
||||
|
||||
if (hasChildren) {
|
||||
const value = this.getFieldName('value')
|
||||
const label = this.getFieldName('label')
|
||||
|
||||
activeOptions.push({
|
||||
[value]: WUX_CASCADER,
|
||||
[label]: chooseTitle,
|
||||
})
|
||||
}
|
||||
|
||||
return activeOptions
|
||||
},
|
||||
getNextActiveValue(value, optionIndex) {
|
||||
let { activeValue } = this.data
|
||||
|
||||
activeValue = activeValue.slice(0, optionIndex + 1)
|
||||
activeValue[optionIndex] = value
|
||||
|
||||
return activeValue
|
||||
},
|
||||
updated(currentOptions, optionIndex, condition, callback) {
|
||||
const value = this.getFieldName('value')
|
||||
const children = this.getFieldName('children')
|
||||
const hasChildren = currentOptions[children] && currentOptions[children].length > 0
|
||||
const activeValue = this.getNextActiveValue(currentOptions[value], optionIndex)
|
||||
const activeOptions = this.getMenus(activeValue, hasChildren)
|
||||
const activeIndex = activeOptions.length - 1
|
||||
const showOptions = this.getShowOptions(activeValue)
|
||||
const params = {
|
||||
activeValue,
|
||||
activeOptions,
|
||||
activeIndex,
|
||||
showOptions,
|
||||
}
|
||||
|
||||
// 判断 hasChildren 计算需要更新的数据
|
||||
if (hasChildren || (activeValue.length === showOptions.length && (optionIndex = Math.max(0, optionIndex - 1)))) {
|
||||
params.bodyStyle = `transform: translate(${-50 * optionIndex}%)`
|
||||
params.showOptions = showOptions
|
||||
}
|
||||
|
||||
// 判断是否需要 setData 更新数据
|
||||
if (condition) {
|
||||
this.setData(params)
|
||||
}
|
||||
|
||||
// 回调函数
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, currentOptions, activeOptions, !hasChildren)
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 更新级联数据
|
||||
* @param {Array} activeValue 当前选中值
|
||||
*/
|
||||
getCurrentOptions(activeValue = this.data.activeValue) {
|
||||
const optionIndex = Math.max(0, activeValue.length - 1)
|
||||
const activeOptions = this.getActiveOptions(activeValue)
|
||||
const currentOptions = activeOptions[optionIndex]
|
||||
|
||||
if (currentOptions) {
|
||||
this.updated(currentOptions, optionIndex, true)
|
||||
} else {
|
||||
const value = this.getFieldName('value')
|
||||
const label = this.getFieldName('label')
|
||||
|
||||
activeOptions.push({
|
||||
[value]: WUX_CASCADER,
|
||||
[label]: this.data.chooseTitle,
|
||||
})
|
||||
|
||||
const showOptions = this.getShowOptions(activeValue)
|
||||
const activeIndex = activeOptions.length - 1
|
||||
const params = {
|
||||
showOptions,
|
||||
activeOptions,
|
||||
activeIndex,
|
||||
bodyStyle: '',
|
||||
}
|
||||
|
||||
this.setData(params)
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 点击菜单时的回调函数
|
||||
*/
|
||||
onMenuClick(e) {
|
||||
const { menuIndex } = e.currentTarget.dataset
|
||||
const index = menuIndex > 1 ? menuIndex - 1 : 0
|
||||
const bodyStyle = `transform: translate(${-50 * index}%)`
|
||||
|
||||
this.setData({
|
||||
bodyStyle,
|
||||
activeIndex: menuIndex,
|
||||
})
|
||||
},
|
||||
onItemDelete(e){
|
||||
this.triggerEvent('close')
|
||||
this.triggerEvent('delete')
|
||||
},
|
||||
/**
|
||||
* 点击选项中的确认按钮的函数
|
||||
*/
|
||||
onItemCheck(e){
|
||||
const { item, optionIndex } = e.currentTarget.dataset
|
||||
|
||||
// 判断是否禁用
|
||||
if (!item || item.disabled) return
|
||||
|
||||
// updated
|
||||
this.updated(item, optionIndex
|
||||
, !this.data.controlled, this.onConfrim)
|
||||
},
|
||||
/**
|
||||
* 点击选项时的回调函数
|
||||
*/
|
||||
onItemSelect(e) {
|
||||
const { item, optionIndex } = e.currentTarget.dataset
|
||||
|
||||
// 判断是否禁用
|
||||
if (!item || item.disabled) return
|
||||
|
||||
// updated
|
||||
this.updated(item, optionIndex, !this.data.controlled, this.onChange)
|
||||
},
|
||||
/**
|
||||
* 组件关闭时的回调函数
|
||||
*/
|
||||
onPopupClose() {
|
||||
this.triggerEvent('close')
|
||||
},
|
||||
/**
|
||||
* 选择完成时的回调函数
|
||||
*/
|
||||
onConfrim(currentOptions = {}, activeOptions = [], done = false) {
|
||||
const options = activeOptions.filter((n) => n[this.getFieldName('value')] !== WUX_CASCADER)
|
||||
const value = options.map((n) => n[this.getFieldName('value')])
|
||||
|
||||
// 判断是否异步加载
|
||||
if (currentOptions.isLeaf === false && !currentOptions.children) {
|
||||
this.emitEventClose({ value, options, done: false })
|
||||
this.triggerEvent('load', { value, options })
|
||||
return
|
||||
}
|
||||
|
||||
// 正常加载
|
||||
this.emitEventClose({ value, options, done })
|
||||
},
|
||||
/**
|
||||
* 选择完成时的回调函数
|
||||
*/
|
||||
onChange(currentOptions = {}, activeOptions = [], done = false) {
|
||||
const options = activeOptions.filter((n) => n[this.getFieldName('value')] !== WUX_CASCADER)
|
||||
const value = options.map((n) => n[this.getFieldName('value')])
|
||||
|
||||
// 判断是否异步加载
|
||||
if (currentOptions.isLeaf === false && !currentOptions.children) {
|
||||
this.emitEvent({ value, options, done: false })
|
||||
this.triggerEvent('load', { value, options })
|
||||
return
|
||||
}
|
||||
|
||||
// 正常加载
|
||||
this.emitEvent({ value, options, done })
|
||||
},
|
||||
emitEvent(params = {}) {
|
||||
// console.log('emitEvent change')
|
||||
this.triggerEvent('change', params)
|
||||
},
|
||||
emitEventClose(params = {}) {
|
||||
// console.log('emitEvent close')
|
||||
this.triggerEvent('confrim', params)
|
||||
|
||||
// 当选择完成时关闭组件
|
||||
if (params.done) {
|
||||
this.onPopupClose()
|
||||
}
|
||||
},
|
||||
getFieldName(name) {
|
||||
return this.data.fieldNames[name]
|
||||
},
|
||||
},
|
||||
attached() {
|
||||
const { defaultValue, value, controlled } = this.data
|
||||
const activeValue = controlled ? value : defaultValue
|
||||
const fieldNames = Object.assign({}, defaultFieldNames, this.data.defaultFieldNames)
|
||||
|
||||
this.setData({ activeValue, fieldNames })
|
||||
this.getCurrentOptions(activeValue)
|
||||
},
|
||||
})
|
||||
8
liferestartWX/utils/wux/cascader/index.json
Normal file
8
liferestartWX/utils/wux/cascader/index.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wux-popup": "../popup/index",
|
||||
"wux-icon": "../icon/index",
|
||||
"wux-button": "../button/index"
|
||||
}
|
||||
}
|
||||
42
liferestartWX/utils/wux/cascader/index.wxml
Normal file
42
liferestartWX/utils/wux/cascader/index.wxml
Normal file
@@ -0,0 +1,42 @@
|
||||
<wux-popup position="bottom" visible="{{ visible }}" safeArea="bottom" bind:close="onPopupClose">
|
||||
<view class="wux-class {{ classes.wrap }}">
|
||||
<view class="{{ classes.hd }}">
|
||||
<wux-button block size="small" type="assertive"
|
||||
catchtap="onItemDelete" class="{{ classes.icon }}" >
|
||||
删除</wux-button>
|
||||
<view class="{{ classes.title }}" wx:if="{{ title }}">{{ title }}</view>
|
||||
<view class="{{ classes.menus }}" wx:if="{{ activeOptions.length }}">
|
||||
<block wx:for="{{ activeOptions }}" wx:key="">
|
||||
<view class="{{ classes.menu }} {{ activeIndex === index ? prefixCls + '__menu--active' : '' }}" data-menu-index="{{ index }}" bindtap="onMenuClick">{{ item[fieldNames['label']] }}</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<view class="{{ classes.bd }}" style="{{ bodyStyle }}">
|
||||
<block wx:for="{{ showOptions }}" wx:for-item="option" wx:for-index="optionIndex" wx:key="">
|
||||
<view class="{{ classes.inner }}">
|
||||
<scroll-view scroll-y class="wux-scroll-view-class {{ classes.scrollView }}">
|
||||
<view class="{{ classes.option }}">
|
||||
<block wx:for="{{ option }}" wx:key="">
|
||||
<view
|
||||
class="{{ classes.item }} {{ activeValue[optionIndex] === item[fieldNames['value']] ? prefixCls + '__item--active' : '' }} {{ item.disabled ? prefixCls + '__item--disabled' : '' }}"
|
||||
data-option-index="{{ optionIndex }}"
|
||||
data-item="{{ item }}"
|
||||
bindtap="onItemSelect"
|
||||
>
|
||||
<text>{{ item[fieldNames['label']] }}</text>
|
||||
<!-- <icon class="{{ classes.icon }}" type="success_no_circle" size="16" color="#ef473a" wx:if="{{ activeValue[optionIndex] === item[fieldNames['value']] }}" /> -->
|
||||
<wux-button block size="small"
|
||||
outline class="{{ classes.icon }}"
|
||||
wx:if="{{ item.isLeaf && activeValue[optionIndex] === item[fieldNames['value']] }}"
|
||||
type="balanced" data-item="{{ item }}"
|
||||
data-option-index="{{ optionIndex }}"
|
||||
catchtap="onItemCheck">选择</wux-button>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</wux-popup>
|
||||
144
liferestartWX/utils/wux/cascader/index.wxss
Normal file
144
liferestartWX/utils/wux/cascader/index.wxss
Normal file
@@ -0,0 +1,144 @@
|
||||
.wux-cascader__hd {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
font-size: 34rpx;
|
||||
line-height: 1.5;
|
||||
color: #444
|
||||
}
|
||||
.wux-cascader__hd::after {
|
||||
content: " ";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
height: 1PX;
|
||||
border-bottom: 1PX solid #d9d9d9;
|
||||
color: #d9d9d9;
|
||||
transform-origin: 0 100%;
|
||||
transform: scaleY(.5)
|
||||
}
|
||||
.wux-cascader__title {
|
||||
position: relative;
|
||||
height: 88rpx;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
box-sizing: border-box
|
||||
}
|
||||
.wux-cascader__title::after {
|
||||
content: " ";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
height: 1PX;
|
||||
border-bottom: 1PX solid #d9d9d9;
|
||||
color: #d9d9d9;
|
||||
transform-origin: 0 100%;
|
||||
transform: scaleY(.5)
|
||||
}
|
||||
.wux-cascader__menus {
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
height: 88rpx;
|
||||
padding: 0 20rpx;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
box-sizing: border-box
|
||||
}
|
||||
.wux-cascader__menu {
|
||||
font-size: 26rpx;
|
||||
padding: 0 20rpx;
|
||||
max-width: 40%;
|
||||
width: auto;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
word-wrap: normal
|
||||
}
|
||||
.wux-cascader__menu--active {
|
||||
color: #ef473a
|
||||
}
|
||||
.wux-cascader__bd {
|
||||
width: 100%;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
transition: transform .3s;
|
||||
background-color: #f5f5f5
|
||||
}
|
||||
.wux-cascader__inner {
|
||||
display: block;
|
||||
height: inherit;
|
||||
width: 50%;
|
||||
-ms-flex: 0 0 50%;
|
||||
flex: 0 0 50%;
|
||||
background-color: #fff
|
||||
}
|
||||
.wux-cascader__inner:nth-child(2n) {
|
||||
background-color: #f5f5f5
|
||||
}
|
||||
.wux-cascader__scroll-view {
|
||||
max-height: 540rpx
|
||||
}
|
||||
.wux-cascader__option {
|
||||
width: 100%;
|
||||
height: inherit;
|
||||
display: block;
|
||||
padding-left: 40rpx;
|
||||
padding-right: 10rpx;
|
||||
box-sizing: border-box
|
||||
}
|
||||
.wux-cascader__item {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
display: block;
|
||||
color: rgba(0,0,0,.85);
|
||||
font-size: 26rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
text-align: left;
|
||||
padding-right: 36rpx;
|
||||
width: auto;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
word-wrap: normal
|
||||
}
|
||||
.wux-cascader__item::after {
|
||||
content: " ";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
height: 1PX;
|
||||
border-bottom: 1PX solid #d9d9d9;
|
||||
color: #d9d9d9;
|
||||
transform-origin: 0 100%;
|
||||
transform: scaleY(.5)
|
||||
}
|
||||
.wux-cascader__item--active {
|
||||
color: #ef473a
|
||||
}
|
||||
.wux-cascader__item--disabled {
|
||||
opacity: .3
|
||||
}
|
||||
.wux-cascader__icon {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 20rpx;
|
||||
bottom: 50rpx;
|
||||
z-index: 20;
|
||||
font-size: 0;
|
||||
line-height: 1
|
||||
}
|
||||
.searchicon {
|
||||
top: 0;
|
||||
padding-right: 20rpx;
|
||||
z-index: 20;
|
||||
font-size: 0;
|
||||
line-height: 1
|
||||
}
|
||||
1
liferestartWX/utils/wux/cell-group/index.js
Normal file
1
liferestartWX/utils/wux/cell-group/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(0,_baseComponent.default)({options:{multipleSlots:!1},relations:{"../cell/index":{type:"descendant",observer:function(){this.debounce(this.updateIsLastElement)}}},properties:{prefixCls:{type:String,value:"wux-cell-group"},title:{type:String,value:""},label:{type:String,value:""}},computed:{classes:["prefixCls",function(e){return{wrap:(0,_classNames.default)(e),hd:"".concat(e,"__hd"),bd:"".concat(e,"__bd"),ft:"".concat(e,"__ft")}}]},methods:{updateIsLastElement:function(){var e=this.getRelationNodes("../cell/index");if(0<e.length){var n=e.length-1;e.forEach(function(e,t){e.updateIsLastElement(t===n)})}},getBoundingClientRect:function(t){var n=this,e=".".concat(this.data.prefixCls);wx.createSelectorQuery().in(this).select(e).boundingClientRect(function(e){e&&t.call(n,e.height)}).exec()}}});
|
||||
3
liferestartWX/utils/wux/cell-group/index.json
Normal file
3
liferestartWX/utils/wux/cell-group/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
7
liferestartWX/utils/wux/cell-group/index.wxml
Normal file
7
liferestartWX/utils/wux/cell-group/index.wxml
Normal file
@@ -0,0 +1,7 @@
|
||||
<view class="wux-class {{ classes.wrap }}">
|
||||
<view class="{{ classes.hd }}" wx:if="{{ title }}">{{ title }}</view>
|
||||
<view class="{{ classes.bd }}">
|
||||
<slot></slot>
|
||||
</view>
|
||||
<view class="{{ classes.ft }}" wx:if="{{ label }}">{{ label }}</view>
|
||||
</view>
|
||||
1
liferestartWX/utils/wux/cell-group/index.wxss
Normal file
1
liferestartWX/utils/wux/cell-group/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.wux-cell-group__hd{padding:30rpx 30rpx 18rpx;font-size:28rpx;color:rgba(0,0,0,.45);width:100%;box-sizing:border-box}.wux-cell-group__bd{position:relative;background-color:#fff}.wux-cell-group__bd::after{content:" ";position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #d9d9d9;border-top-width:1PX;border-bottom-width:1PX}.wux-cell-group__ft{padding:18rpx 30rpx 30rpx;font-size:28rpx;color:rgba(0,0,0,.45)}
|
||||
1
liferestartWX/utils/wux/cell/index.js
Normal file
1
liferestartWX/utils/wux/cell/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames")),_eventsMixin=_interopRequireDefault(require("../helpers/eventsMixin"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var defaultEvents={onClick:function(){},onError:function(){}};(0,_baseComponent.default)({behaviors:[(0,_eventsMixin.default)({defaultEvents:defaultEvents})],relations:{"../cell-group/index":{type:"ancestor"},"../picker/index":{type:"parent"},"../date-picker/index":{type:"parent"},"../popup-select/index":{type:"parent"}},properties:{prefixCls:{type:String,value:"wux-cell"},disabled:{type:Boolean,value:!1},hoverClass:{type:String,value:"default"},hoverStopPropagation:{type:Boolean,value:!1},hoverStartTime:{type:Number,value:20},hoverStayTime:{type:Number,value:70},lang:{type:String,value:"en"},sessionFrom:{type:String,value:""},sendMessageTitle:{type:String,value:""},sendMessagePath:{type:String,value:""},sendMessageImg:{type:String,value:""},showMessageCard:{type:Boolean,value:!1},appParameter:{type:String,value:""},thumb:{type:String,value:""},title:{type:String,value:""},label:{type:String,value:""},extra:{type:String,value:""},isLink:{type:Boolean,value:!1},openType:{type:String,value:"navigateTo"},url:{type:String,value:""},delta:{type:Number,value:1}},data:{isLast:!1},computed:{classes:["prefixCls, hoverClass, isLast, isLink, disabled",function(e,t,n,a,i){var r;return{wrap:(0,_classNames2.default)(e,(_defineProperty(r={},"".concat(e,"--last"),n),_defineProperty(r,"".concat(e,"--access"),a),_defineProperty(r,"".concat(e,"--disabled"),i),r)),hd:"".concat(e,"__hd"),thumb:"".concat(e,"__thumb"),bd:"".concat(e,"__bd"),text:"".concat(e,"__text"),desc:"".concat(e,"__desc"),ft:"".concat(e,"__ft"),hover:t&&"default"!==t?t:"".concat(e,"--hover")}}]},methods:{onTap:function(){this.data.disabled||(this.triggerEvent("click"),this.linkTo())},bindgetuserinfo:function(e){this.triggerEvent("getuserinfo",e.detail)},bindcontact:function(e){this.triggerEvent("contact",e.detail)},bindgetphonenumber:function(e){this.triggerEvent("getphonenumber",e.detail)},bindopensetting:function(e){this.triggerEvent("opensetting",e.detail)},onError:function(e){this.triggerEvent("error",e.detail)},linkTo:function(){var e=this.data,t=e.url,n=e.isLink,a=e.openType,i=e.delta;return!!(n&&t&&["navigateTo","redirectTo","switchTab","navigateBack","reLaunch"].includes(a))&&("navigateBack"===a?wx[a].call(wx,{delta:i}):wx[a].call(wx,{url:t}))},updateIsLastElement:function(e){this.setData({isLast:e})}}});
|
||||
3
liferestartWX/utils/wux/cell/index.json
Normal file
3
liferestartWX/utils/wux/cell/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
42
liferestartWX/utils/wux/cell/index.wxml
Normal file
42
liferestartWX/utils/wux/cell/index.wxml
Normal file
@@ -0,0 +1,42 @@
|
||||
<button
|
||||
class="wux-class {{ classes.wrap }}"
|
||||
disabled="{{ disabled }}"
|
||||
open-type="{{ openType }}"
|
||||
hover-class="{{ !disabled ? classes.hover : 'none' }}"
|
||||
hover-stop-propagation="{{ hoverStopPropagation }}"
|
||||
hover-start-time="{{ hoverStartTime }}"
|
||||
hover-stay-time="{{ hoverStayTime }}"
|
||||
lang="{{ lang }}"
|
||||
bindgetuserinfo="bindgetuserinfo"
|
||||
session-from="{{ sessionFrom }}"
|
||||
send-message-title="{{ sendMessageTitle }}"
|
||||
send-message-path="{{ sendMessagePath }}"
|
||||
send-message-img="{{ sendMessageImg }}"
|
||||
show-message-card="{{ showMessageCard }}"
|
||||
bindcontact="bindcontact"
|
||||
bindgetphonenumber="bindgetphonenumber"
|
||||
app-parameter="{{ appParameter }}"
|
||||
binderror="onError"
|
||||
bindopensetting="bindopensetting"
|
||||
bindtap="onTap"
|
||||
>
|
||||
<view class="{{ classes.hd }}">
|
||||
<block wx:if="{{ thumb }}">
|
||||
<image class="{{ classes.thumb }}" src="{{ thumb }}" />
|
||||
</block>
|
||||
<block wx:else>
|
||||
<slot name="header"></slot>
|
||||
</block>
|
||||
</view>
|
||||
<view class="{{ classes.bd }}">
|
||||
<view wx:if="{{ title }}" class="{{ classes.text }}">{{ title }}</view>
|
||||
<view wx:if="{{ label }}" class="{{ classes.desc }}">{{ label }}</view>
|
||||
<slot></slot>
|
||||
</view>
|
||||
<view class="{{ classes.ft }}">
|
||||
<block wx:if="{{ extra }}">{{ extra }}</block>
|
||||
<block wx:else>
|
||||
<slot name="footer"></slot>
|
||||
</block>
|
||||
</view>
|
||||
</button>
|
||||
1
liferestartWX/utils/wux/cell/index.wxss
Normal file
1
liferestartWX/utils/wux/cell/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.wux-cell{padding:0;margin:0;border-radius:0;color:inherit!important;background:0 0!important;font-size:inherit;font-weight:400;line-height:inherit;text-align:inherit;text-decoration:none;overflow:visible;min-height:0!important;width:auto!important;box-sizing:border-box;-webkit-tap-highlight-color:transparent;padding:20rpx 30rpx;position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;background:#fff}.wux-cell::after{display:block;position:static;top:auto;left:auto;width:auto;height:auto;border:none;border-radius:0;transform:none;transform-origin:0 0}.wux-cell::after{content:" ";position:absolute;left:0;bottom:0;right:0;height:1PX;border-bottom:1PX solid #d9d9d9;color:#d9d9d9;transform-origin:0 100%;transform:scaleY(.5);left:30rpx}.wux-cell--last::after{display:none}.wux-cell--hover{background-color:#ececec!important}.wux-cell--disabled{opacity:.3}.wux-cell__thumb{width:40rpx;height:40rpx;display:block;margin-right:10rpx}.wux-cell__bd{-ms-flex:1;flex:1}.wux-cell__text{text-align:left}.wux-cell__desc{text-align:left;line-height:1.2;font-size:24rpx;color:rgba(0,0,0,.45)}.wux-cell__ft{text-align:right;color:rgba(0,0,0,.45)}.wux-cell--access .wux-cell__ft{padding-right:34rpx;position:relative}.wux-cell--access .wux-cell__ft::after{content:" ";display:inline-block;width:30rpx;height:30rpx;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20width%3D%2216%22%20height%3D%2226%22%20viewBox%3D%220%200%2016%2026%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M2%200L0%202l11.5%2011L0%2024l2%202%2014-13z%22%20fill%3D%22%23c7c7cc%22%20fill-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E");background-size:contain;background-repeat:no-repeat;background-position:50% 50%;transform:rotate(0);transform:rotate(0) translateY(-50%);position:absolute;top:50%;right:0}
|
||||
148
liferestartWX/utils/wux/checkbox-group/index.js
Normal file
148
liferestartWX/utils/wux/checkbox-group/index.js
Normal file
@@ -0,0 +1,148 @@
|
||||
import baseComponent from '../helpers/baseComponent'
|
||||
import eventsMixin from '../helpers/eventsMixin'
|
||||
|
||||
function getOptions(options = []) {
|
||||
return options.map((option, index) => {
|
||||
if (typeof option === 'string') {
|
||||
return {
|
||||
title: option,
|
||||
value: option,
|
||||
index,
|
||||
}
|
||||
}
|
||||
return {
|
||||
...option,
|
||||
index,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getCheckedValues(newVal, oldVal = []) {
|
||||
let checkedValues = [...oldVal]
|
||||
checkedValues = checkedValues.indexOf(newVal) !== -1 ? checkedValues.filter((n) => n !== newVal) : [...checkedValues, newVal]
|
||||
return checkedValues
|
||||
}
|
||||
|
||||
baseComponent({
|
||||
useField: true,
|
||||
behaviors: [eventsMixin()],
|
||||
relations: {
|
||||
'../field/index': {
|
||||
type: 'ancestor',
|
||||
},
|
||||
'../checkbox/index': {
|
||||
type: 'descendant',
|
||||
observer() {
|
||||
this.debounce(this.changeValue)
|
||||
},
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
prefixCls: {
|
||||
type: String,
|
||||
value: 'wux-checkbox-group',
|
||||
},
|
||||
cellGroupPrefixCls: {
|
||||
type: String,
|
||||
value: 'wux-cell-group',
|
||||
},
|
||||
value: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
},
|
||||
data: {
|
||||
inputValue: [],
|
||||
keys: [],
|
||||
},
|
||||
observers: {
|
||||
value(newVal) {
|
||||
if (this.hasFieldDecorator) return
|
||||
this.updated(newVal)
|
||||
this.changeValue(newVal)
|
||||
},
|
||||
inputValue(newVal) {
|
||||
if (this.hasFieldDecorator) {
|
||||
this.changeValue(newVal)
|
||||
}
|
||||
},
|
||||
options(newVal) {
|
||||
this.changeValue(this.data.inputValue, newVal)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
updated(inputValue) {
|
||||
if (this.data.inputValue !== inputValue) {
|
||||
this.setData({ inputValue })
|
||||
}
|
||||
},
|
||||
changeValue(value = this.data.inputValue, options = this.data.options) {
|
||||
const showOptions = getOptions(options)
|
||||
const elements = this.getRelationNodes('../checkbox/index')
|
||||
const keys = showOptions.length > 0 ? showOptions : elements ? elements.map((element) => element.data) : []
|
||||
|
||||
// Elements should be updated when not using the options
|
||||
if (!showOptions.length && elements && elements.length > 0) {
|
||||
elements.forEach((element, index) => {
|
||||
element.changeValue(Array.isArray(value) && value.includes(element.data.value), index)
|
||||
})
|
||||
}
|
||||
|
||||
if (this.data.keys !== keys) {
|
||||
this.setData({
|
||||
keys,
|
||||
})
|
||||
}
|
||||
},
|
||||
onChange(item) {
|
||||
const checkedValues = getCheckedValues(item.value, this.data.inputValue)
|
||||
|
||||
// 如果使用 <Field /> 组件包裹时,value 返回值为数组
|
||||
if (this.hasFieldDecorator) {
|
||||
item.value = checkedValues
|
||||
}
|
||||
|
||||
this.triggerEvent('change', {
|
||||
...this.getValue(checkedValues),
|
||||
...item,
|
||||
name: this.data.name,
|
||||
value: item.value, // 兼容 3.6.1 之前版本,不改变 value
|
||||
})
|
||||
},
|
||||
onCheckboxChange(e) {
|
||||
// Set real index
|
||||
const { index } = e.currentTarget.dataset
|
||||
this.onChange({ ...e.detail, index })
|
||||
},
|
||||
getValue(value = this.data.inputValue, cols = this.data.keys) {
|
||||
const checkedValues = cols.filter((option) => value.includes(option.value))
|
||||
const displayValue = checkedValues.map((option) => option.title) || []
|
||||
const allValues = cols.map((option) => option.value)
|
||||
const selectedIndex = value.map((n) => allValues.indexOf(n))
|
||||
|
||||
return {
|
||||
value,
|
||||
displayValue,
|
||||
selectedIndex,
|
||||
selectedValue: value,
|
||||
cols,
|
||||
}
|
||||
},
|
||||
getBoundingClientRect(callback) {
|
||||
this.cellGroup = this.cellGroup || this.selectComponent('#wux-cell-group')
|
||||
return this.cellGroup && this.cellGroup.getBoundingClientRect(callback)
|
||||
},
|
||||
},
|
||||
})
|
||||
7
liferestartWX/utils/wux/checkbox-group/index.json
Normal file
7
liferestartWX/utils/wux/checkbox-group/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wux-cell-group": "../cell-group/index",
|
||||
"wux-checkbox": "../checkbox/index"
|
||||
}
|
||||
}
|
||||
26
liferestartWX/utils/wux/checkbox-group/index.wxml
Normal file
26
liferestartWX/utils/wux/checkbox-group/index.wxml
Normal file
@@ -0,0 +1,26 @@
|
||||
<wux-cell-group id="wux-cell-group" wux-class="{{ prefixCls }}" prefixCls="{{ cellGroupPrefixCls }}" title="{{ title }}" label="{{ label }}">
|
||||
<block wx:for="{{ common.getOptions(options) }}" wx:for-item="option" wx:key="index" wx:if="{{ options.length > 0 }}">
|
||||
<wux-checkbox
|
||||
prefixCls="{{ option.prefixCls || 'wux-checkbox' }}"
|
||||
cellPrefixCls="{{ option.cellPrefixCls || 'wux-cell' }}"
|
||||
selectablePrefixCls="{{ option.selectablePrefixCls || 'wux-selectable' }}"
|
||||
title="{{ option.title }}"
|
||||
label="{{ option.label }}"
|
||||
extra="{{ option.extra }}"
|
||||
value="{{ option.value }}"
|
||||
checked="{{ common.getChecked(inputValue, option) }}"
|
||||
disabled="{{ option.disabled }}"
|
||||
color="{{ option.color || 'balanced' }}"
|
||||
data-index="{{ index }}"
|
||||
bind:change="onCheckboxChange"
|
||||
/>
|
||||
</block>
|
||||
<block wx:if="{{ options.length === 0 }}">
|
||||
<slot></slot>
|
||||
</block>
|
||||
</wux-cell-group>
|
||||
|
||||
<wxs module="common">
|
||||
module.exports.getOptions = function(options) { return options.map(function(option) { if (option.constructor === 'String') { return { title: option, value: option } } return option }) }
|
||||
module.exports.getChecked = function(values, option) { return values.indexOf(option.value) !== -1 }
|
||||
</wxs>
|
||||
0
liferestartWX/utils/wux/checkbox-group/index.wxss
Normal file
0
liferestartWX/utils/wux/checkbox-group/index.wxss
Normal file
93
liferestartWX/utils/wux/checkbox/index.js
Normal file
93
liferestartWX/utils/wux/checkbox/index.js
Normal file
@@ -0,0 +1,93 @@
|
||||
import baseComponent from '../helpers/baseComponent'
|
||||
import classNames from '../helpers/classNames'
|
||||
|
||||
baseComponent({
|
||||
relations: {
|
||||
'../checkbox-group/index': {
|
||||
type: 'ancestor',
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
prefixCls: {
|
||||
type: String,
|
||||
value: 'wux-checkbox',
|
||||
},
|
||||
cellPrefixCls: {
|
||||
type: String,
|
||||
value: 'wux-cell',
|
||||
},
|
||||
selectablePrefixCls: {
|
||||
type: String,
|
||||
value: 'wux-selectable',
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
extra: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
checked: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
observer(newVal) {
|
||||
this.setData({
|
||||
inputChecked: newVal,
|
||||
})
|
||||
},
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
value: 'balanced',
|
||||
},
|
||||
},
|
||||
data: {
|
||||
index: 0,
|
||||
inputChecked: false,
|
||||
},
|
||||
computed: {
|
||||
classes: ['prefixCls', function(prefixCls) {
|
||||
const cell = classNames(prefixCls)
|
||||
const selectable = `${prefixCls}__selectable`
|
||||
|
||||
return {
|
||||
cell,
|
||||
selectable,
|
||||
}
|
||||
}],
|
||||
},
|
||||
methods: {
|
||||
checkboxChange(e) {
|
||||
const { value, index, disabled } = this.data
|
||||
const parent = this.getRelationNodes('../checkbox-group/index')[0]
|
||||
const item = {
|
||||
checked: e.detail.checked,
|
||||
value,
|
||||
index,
|
||||
}
|
||||
|
||||
if (disabled) return
|
||||
|
||||
parent ? parent.onChange(item) : this.triggerEvent('change', item)
|
||||
},
|
||||
changeValue(inputChecked = false, index = 0) {
|
||||
this.setData({
|
||||
inputChecked,
|
||||
index,
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
7
liferestartWX/utils/wux/checkbox/index.json
Normal file
7
liferestartWX/utils/wux/checkbox/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wux-cell": "../cell/index",
|
||||
"wux-selectable": "../selectable/index"
|
||||
}
|
||||
}
|
||||
3
liferestartWX/utils/wux/checkbox/index.wxml
Normal file
3
liferestartWX/utils/wux/checkbox/index.wxml
Normal file
@@ -0,0 +1,3 @@
|
||||
<wux-cell wux-class="{{ classes.cell }}" prefixCls="{{ cellPrefixCls }}" title="{{ title }}" label="{{ label }}" extra="{{ extra }}">
|
||||
<wux-selectable slot="header" wux-class="{{ classes.selectable }}" prefixCls="{{ selectablePrefixCls }}" value="{{ value }}" checked="{{ inputChecked }}" color="{{ color }}" disabled="{{ disabled }}" controlled bind:change="checkboxChange" />
|
||||
</wux-cell>
|
||||
3
liferestartWX/utils/wux/checkbox/index.wxss
Normal file
3
liferestartWX/utils/wux/checkbox/index.wxss
Normal file
@@ -0,0 +1,3 @@
|
||||
.wux-checkbox__selectable {
|
||||
position: static!important
|
||||
}
|
||||
1
liferestartWX/utils/wux/col/index.js
Normal file
1
liferestartWX/utils/wux/col/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}(0,_baseComponent.default)({relations:{"../row/index":{type:"parent"}},properties:{prefixCls:{type:String,value:"wux-col"},span:{value:0,type:Number},offset:{value:0,type:Number},pull:{value:0,type:Number},push:{value:0,type:Number}},data:{colStyle:""},computed:{classes:["prefixCls, span, offset, pull, push",function(e,t,r,a,n){var o;return{wrap:(0,_classNames2.default)(e,(_defineProperty(o={},"".concat(e,"--span-").concat(t),t),_defineProperty(o,"".concat(e,"--offset-").concat(r),r),_defineProperty(o,"".concat(e,"--pull-").concat(a),a),_defineProperty(o,"".concat(e,"--push-").concat(n),n),o))}}]},methods:{updateStyle:function(e){this.data.colStyle!==e&&this.setData({colStyle:e})}}});
|
||||
3
liferestartWX/utils/wux/col/index.json
Normal file
3
liferestartWX/utils/wux/col/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
3
liferestartWX/utils/wux/col/index.wxml
Normal file
3
liferestartWX/utils/wux/col/index.wxml
Normal file
@@ -0,0 +1,3 @@
|
||||
<view class="wux-class {{ classes.wrap }}" style="{{ colStyle }}">
|
||||
<slot></slot>
|
||||
</view>
|
||||
1
liferestartWX/utils/wux/col/index.wxss
Normal file
1
liferestartWX/utils/wux/col/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.wux-col{position:relative;min-height:2rpx;box-sizing:border-box}.wux-col--span-12{float:left;width:100%}.wux-col--pull-12{right:100%}.wux-col--push-12{left:100%}.wux-col--offset-12{margin-left:100%}.wux-col--span-11{float:left;width:91.66666667%}.wux-col--pull-11{right:91.66666667%}.wux-col--push-11{left:91.66666667%}.wux-col--offset-11{margin-left:91.66666667%}.wux-col--span-10{float:left;width:83.33333333%}.wux-col--pull-10{right:83.33333333%}.wux-col--push-10{left:83.33333333%}.wux-col--offset-10{margin-left:83.33333333%}.wux-col--span-9{float:left;width:75%}.wux-col--pull-9{right:75%}.wux-col--push-9{left:75%}.wux-col--offset-9{margin-left:75%}.wux-col--span-8{float:left;width:66.66666667%}.wux-col--pull-8{right:66.66666667%}.wux-col--push-8{left:66.66666667%}.wux-col--offset-8{margin-left:66.66666667%}.wux-col--span-7{float:left;width:58.33333333%}.wux-col--pull-7{right:58.33333333%}.wux-col--push-7{left:58.33333333%}.wux-col--offset-7{margin-left:58.33333333%}.wux-col--span-6{float:left;width:50%}.wux-col--pull-6{right:50%}.wux-col--push-6{left:50%}.wux-col--offset-6{margin-left:50%}.wux-col--span-5{float:left;width:41.66666667%}.wux-col--pull-5{right:41.66666667%}.wux-col--push-5{left:41.66666667%}.wux-col--offset-5{margin-left:41.66666667%}.wux-col--span-4{float:left;width:33.33333333%}.wux-col--pull-4{right:33.33333333%}.wux-col--push-4{left:33.33333333%}.wux-col--offset-4{margin-left:33.33333333%}.wux-col--span-3{float:left;width:25%}.wux-col--pull-3{right:25%}.wux-col--push-3{left:25%}.wux-col--offset-3{margin-left:25%}.wux-col--span-2{float:left;width:16.66666667%}.wux-col--pull-2{right:16.66666667%}.wux-col--push-2{left:16.66666667%}.wux-col--offset-2{margin-left:16.66666667%}.wux-col--span-1{float:left;width:8.33333333%}.wux-col--pull-1{right:8.33333333%}.wux-col--push-1{left:8.33333333%}.wux-col--offset-1{margin-left:8.33333333%}
|
||||
83
liferestartWX/utils/wux/config.json
Normal file
83
liferestartWX/utils/wux/config.json
Normal file
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"components": [
|
||||
"accordion",
|
||||
"actionsheet",
|
||||
"alert",
|
||||
"animation-group",
|
||||
"avatar",
|
||||
"backdrop",
|
||||
"badge",
|
||||
"barcode",
|
||||
"button",
|
||||
"calendar",
|
||||
"card",
|
||||
"cascader",
|
||||
"cascader-picker-view",
|
||||
"cell",
|
||||
"checkbox",
|
||||
"circle",
|
||||
"layout",
|
||||
"countdown",
|
||||
"countup",
|
||||
"date-picker",
|
||||
"date-picker-view",
|
||||
"dialog",
|
||||
"divider",
|
||||
"fab-button",
|
||||
"field",
|
||||
"filterbar",
|
||||
"form",
|
||||
"gallery",
|
||||
"grid",
|
||||
"icon",
|
||||
"image",
|
||||
"index",
|
||||
"input",
|
||||
"input-number",
|
||||
"keyboard",
|
||||
"landscape",
|
||||
"loading",
|
||||
"media",
|
||||
"multi-picker-view",
|
||||
"navbar",
|
||||
"notice-bar",
|
||||
"notification",
|
||||
"pagination",
|
||||
"picker",
|
||||
"picker-view",
|
||||
"popover",
|
||||
"popup",
|
||||
"popup-select",
|
||||
"progress",
|
||||
"prompt",
|
||||
"qrcode",
|
||||
"radio",
|
||||
"rater",
|
||||
"refresher",
|
||||
"result",
|
||||
"search-bar",
|
||||
"segmented-control",
|
||||
"select",
|
||||
"selectable",
|
||||
"skeleton",
|
||||
"slider",
|
||||
"spin",
|
||||
"steps",
|
||||
"sticky",
|
||||
"swipe-action",
|
||||
"switch",
|
||||
"tabs",
|
||||
"tabbar",
|
||||
"tag",
|
||||
"textarea",
|
||||
"timeago",
|
||||
"timeline",
|
||||
"toast",
|
||||
"toptips",
|
||||
"upload",
|
||||
"vcode",
|
||||
"virtual-list",
|
||||
"white-space",
|
||||
"wing-blank"
|
||||
]
|
||||
}
|
||||
1
liferestartWX/utils/wux/countdown/index.js
Normal file
1
liferestartWX/utils/wux/countdown/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function _createClass(t,e,n){return e&&_defineProperties(t.prototype,e),n&&_defineProperties(t,n),t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var Countdown=function(){function n(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:getCurrentPages()[getCurrentPages().length-1];_classCallCheck(this,n),Object.assign(this,{page:e,options:t}),this.__init()}return _createClass(n,[{key:"__init",value:function(){this.setData=this.page.setData.bind(this.page),this.restart(this.options)}},{key:"setDefaults",value:function(){return{date:"June 7, 2087 15:03:25",refresh:1e3,offset:0,onEnd:function(){},render:function(t){}}}},{key:"mergeOptions",value:function(t){var e=this.setDefaults();for(var n in e)e.hasOwnProperty(n)&&(this.options[n]=void 0!==t[n]?t[n]:e[n],"date"===n&&"object"!==_typeof(this.options.date)&&(this.options.date=new Date(this.options.date)),"function"==typeof this.options[n]&&(this.options[n]=this.options[n].bind(this)));"object"!==_typeof(this.options.date)&&(this.options.date=new Date(this.options.date))}},{key:"getDiffDate",value:function(){var t=(this.options.date.getTime()-Date.now()+this.options.offset)/1e3,e={years:0,days:0,hours:0,min:0,sec:0,millisec:0};return t<=0?this.interval&&(this.stop(),this.options.onEnd()):(31557600<=t&&(e.years=Math.floor(t/31557600),t-=365.25*e.years*86400),86400<=t&&(e.days=Math.floor(t/86400),t-=86400*e.days),3600<=t&&(e.hours=Math.floor(t/3600),t-=3600*e.hours),60<=t&&(e.min=Math.floor(t/60),t-=60*e.min),e.sec=Math.round(t),e.millisec=t%1*1e3),e}},{key:"leadingZeros",value:function(t,e){var n=1<arguments.length&&void 0!==e?e:2;return(t=String(t)).length>n?t:(Array(n+1).join("0")+t).substr(-n)}},{key:"update",value:function(t){return this.options.date="object"!==_typeof(t)?new Date(t):t,this.render(),this}},{key:"stop",value:function(){return this.interval&&(clearInterval(this.interval),this.interval=!1),this}},{key:"render",value:function(){return this.options.render(this.getDiffDate()),this}},{key:"start",value:function(){var t=this;return!this.interval&&(this.render(),this.options.refresh&&(this.interval=setInterval(function(){t.render()},this.options.refresh)),this)}},{key:"updateOffset",value:function(t){return this.options.offset=t,this}},{key:"restart",value:function(t){var e=0<arguments.length&&void 0!==t?t:{};return this.mergeOptions(e),this.interval=!1,this.start(),this}}]),n}(),_default=Countdown;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/countup/index.js
Normal file
1
liferestartWX/utils/wux/countup/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function _classCallCheck(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,i){for(var s=0;s<i.length;s++){var a=i[s];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function _createClass(t,i,s){return i&&_defineProperties(t.prototype,i),s&&_defineProperties(t,s),t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var CountUp=function(){function r(t,i,s,a){var e=4<arguments.length&&void 0!==arguments[4]?arguments[4]:{},n=5<arguments.length&&void 0!==arguments[5]?arguments[5]:getCurrentPages()[getCurrentPages().length-1];_classCallCheck(this,r),Object.assign(this,{page:n,startVal:t,endVal:i,decimals:s,duration:a,options:e}),this.__init()}return _createClass(r,[{key:"__init",value:function(){this.setData=this.page.setData.bind(this.page),this.lastTime=0,this.mergeOptions(this.options),this.startVal=Number(this.startVal),this.cacheVal=this.startVal,this.endVal=Number(this.endVal),this.countDown=this.startVal>this.endVal,this.frameVal=this.startVal,this.decimals=Math.max(0,this.decimals||0),this.dec=Math.pow(10,this.decimals),this.duration=1e3*Number(this.duration)||2e3,this.printValue(this.formattingFn(this.startVal))}},{key:"setDefaultOptions",value:function(){return{useEasing:!0,useGrouping:!0,separator:",",decimal:".",easingFn:null,formattingFn:null,printValue:function(t){}}}},{key:"mergeOptions",value:function(t){var i=this.setDefaultOptions();for(var s in i)i.hasOwnProperty(s)&&(this.options[s]=void 0!==t[s]?t[s]:i[s],"function"==typeof this.options[s]&&(this.options[s]=this.options[s].bind(this)));""===this.options.separator&&(this.options.useGrouping=!1),this.options.prefix||(this.options.prefix=""),this.options.suffix||(this.options.suffix=""),this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.printValue=this.options.printValue?this.options.printValue:function(){}}},{key:"requestAnimationFrame",value:function(t){var i=this,s=(new Date).getTime(),a=Math.max(0,16-(s-this.lastTime)),e=setTimeout(function(){t.bind(i)(s+a)},a);return this.lastTime=s+a,e}},{key:"cancelAnimationFrame",value:function(t){clearTimeout(t)}},{key:"formatNumber",value:function(t){var i,s,a,e;if(t=t.toFixed(this.decimals),s=(i=(t+="").split("."))[0],a=1<i.length?this.options.decimal+i[1]:"",e=/(\d+)(\d{3})/,this.options.useGrouping)for(;e.test(s);)s=s.replace(e,"$1"+this.options.separator+"$2");return this.options.prefix+s+a+this.options.suffix}},{key:"easeOutExpo",value:function(t,i,s,a){return s*(1-Math.pow(2,-10*t/a))*1024/1023+i}},{key:"count",value:function(t){this.startTime||(this.startTime=t);var i=(this.timestamp=t)-this.startTime;this.remaining=this.duration-i,this.options.useEasing?this.countDown?this.frameVal=this.startVal-this.easingFn(i,0,this.startVal-this.endVal,this.duration):this.frameVal=this.easingFn(i,this.startVal,this.endVal-this.startVal,this.duration):this.countDown?this.frameVal=this.startVal-(this.startVal-this.endVal)*(i/this.duration):this.frameVal=this.startVal+(this.endVal-this.startVal)*(i/this.duration),this.countDown?this.frameVal=this.frameVal<this.endVal?this.endVal:this.frameVal:this.frameVal=this.frameVal>this.endVal?this.endVal:this.frameVal,this.frameVal=Math.round(this.frameVal*this.dec)/this.dec,this.printValue(this.formattingFn(this.frameVal)),i<this.duration?this.rAF=this.requestAnimationFrame(this.count):this.callback&&this.callback()}},{key:"start",value:function(t){return this.callback=t,this.rAF=this.requestAnimationFrame(this.count),!1}},{key:"pauseResume",value:function(){this.paused?(this.paused=!1,delete this.startTime,this.duration=this.remaining,this.startVal=this.frameVal,this.requestAnimationFrame(this.count)):(this.paused=!0,this.cancelAnimationFrame(this.rAF))}},{key:"reset",value:function(){this.paused=!1,delete this.startTime,this.startVal=this.cacheVal,this.cancelAnimationFrame(this.rAF),this.printValue(this.formattingFn(this.startVal))}},{key:"update",value:function(t){this.cancelAnimationFrame(this.rAF),this.paused=!1,delete this.startTime,this.startVal=this.frameVal,this.endVal=Number(t),this.countDown=this.startVal>this.endVal,this.rAF=this.requestAnimationFrame(this.count)}}]),r}(),_default=CountUp;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/dialog/index.js
Normal file
1
liferestartWX/utils/wux/dialog/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames3=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(n,!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(n).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _defineProperty(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var defaults={prefixCls:"wux-dialog",title:"",content:"",buttons:[],verticalButtons:!1,resetOnClose:!1,closable:!1,mask:!0,maskClosable:!0,zIndex:1e3},defaultOptions={onCancel:function(){},cancelText:"取消",cancelType:"default",onConfirm:function(){},confirmText:"确定",confirmType:"primary"};(0,_baseComponent.default)({useFunc:!0,data:defaults,computed:{classes:["prefixCls, buttons, verticalButtons",function(n,t,e){return{prompt:"".concat(n,"__prompt"),input:"".concat(n,"__input"),buttons:(0,_classNames3.default)("".concat(n,"__buttons"),_defineProperty({},"".concat(n,"__buttons--").concat(e?"vertical":"horizontal"),!0)),button:t.map(function(t){var e;return{wrap:(0,_classNames3.default)("".concat(n,"__button"),(_defineProperty(e={},"".concat(n,"__button--").concat(t.type||"default"),t.type||"default"),_defineProperty(e,"".concat(n,"__button--bold"),t.bold),_defineProperty(e,"".concat(n,"__button--disabled"),t.disabled),_defineProperty(e,"".concat(t.className),t.className),e)),hover:t.hoverClass&&"default"!==t.hoverClass?t.hoverClass:"".concat(n,"__button--hover")}})}}]},methods:{onClosed:function(){if(this.data.resetOnClose){var t=_objectSpread({},this.$$mergeOptionsToData(defaults),{prompt:null});this.$$setData(t)}},onClose:function(){this.hide()},hide:function(t){this.$$setData({in:!1}),"function"==typeof t&&t.call(this)},show:function(t){var e=0<arguments.length&&void 0!==t?t:{},n=this.$$mergeOptionsAndBindMethods(Object.assign({},defaults,e));return this.$$setData(_objectSpread({in:!0},n)),this.originalButtons=n.buttons,this.hide.bind(this)},runCallbacks:function(t,e){var n=t.currentTarget.dataset.index,o=this.originalButtons[n];o.disabled||this.hide(function(){return"function"==typeof o[e]&&o[e](t)})},buttonTapped:function(t){this.runCallbacks(t,"onTap")},bindgetuserinfo:function(t){this.runCallbacks(t,"onGetUserInfo")},bindcontact:function(t){this.runCallbacks(t,"onContact")},bindgetphonenumber:function(t){this.runCallbacks(t,"onGotPhoneNumber")},bindopensetting:function(t){this.runCallbacks(t,"onOpenSetting")},onError:function(t){this.runCallbacks(t,"onError")},bindinput:function(t){this.$$setData({"prompt.response":t.detail.value})},open:function(t){var e=0<arguments.length&&void 0!==t?t:{};return this.show(e)},alert:function(t){var e=0<arguments.length&&void 0!==t?t:{};return this.open(Object.assign({buttons:[{text:e.confirmText||defaultOptions.confirmText,type:e.confirmType||defaultOptions.confirmType,onTap:function(t){"function"==typeof e.onConfirm&&e.onConfirm(t)}}]},e))},confirm:function(t){var e=0<arguments.length&&void 0!==t?t:{};return this.open(Object.assign({buttons:[{text:e.cancelText||defaultOptions.cancelText,type:e.cancelType||defaultOptions.cancelType,onTap:function(t){"function"==typeof e.onCancel&&e.onCancel(t)}},{text:e.confirmText||defaultOptions.confirmText,type:e.confirmType||defaultOptions.confirmType,onTap:function(t){"function"==typeof e.onConfirm&&e.onConfirm(t)}}]},e))},prompt:function(){var e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t={fieldtype:n.fieldtype?n.fieldtype:"text",password:!!n.password,response:n.defaultText?n.defaultText:"",placeholder:n.placeholder?n.placeholder:"",maxlength:n.maxlength?parseInt(n.maxlength):""};return this.open(Object.assign({prompt:t,buttons:[{text:n.cancelText||defaultOptions.cancelText,type:n.cancelType||defaultOptions.cancelType,onTap:function(t){"function"==typeof n.onCancel&&n.onCancel(t)}},{text:n.confirmText||defaultOptions.confirmText,type:n.confirmType||defaultOptions.confirmType,onTap:function(t){"function"==typeof n.onConfirm&&n.onConfirm(t,e.data.prompt.response)}}]},n))}}});
|
||||
6
liferestartWX/utils/wux/dialog/index.json
Normal file
6
liferestartWX/utils/wux/dialog/index.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wux-popup": "../popup/index"
|
||||
}
|
||||
}
|
||||
56
liferestartWX/utils/wux/dialog/index.wxml
Normal file
56
liferestartWX/utils/wux/dialog/index.wxml
Normal file
@@ -0,0 +1,56 @@
|
||||
<wux-popup
|
||||
visible="{{ in }}"
|
||||
z-index="{{ zIndex }}"
|
||||
closable="{{ closable }}"
|
||||
mask="{{ mask }}"
|
||||
mask-closable="{{ maskClosable }}"
|
||||
bind:close="onClose"
|
||||
bind:closed="onClosed"
|
||||
>
|
||||
<view slot="header">{{ title }}</view>
|
||||
<view wx:if="{{ content || prompt }}">
|
||||
<text>{{ content }}</text>
|
||||
<view class="{{ classes.prompt }}" wx:if="{{ prompt }}">
|
||||
<label>
|
||||
<input
|
||||
type="{{ prompt.fieldtype }}"
|
||||
class="{{ classes.input }}"
|
||||
value="{{ prompt.response }}"
|
||||
password="{{ prompt.password }}"
|
||||
placeholder="{{ prompt.placeholder }}"
|
||||
maxlength="{{ maxlength }}"
|
||||
bindinput="bindinput"
|
||||
/>
|
||||
</label>
|
||||
</view>
|
||||
</view>
|
||||
<view slot="footer" class="{{ classes.buttons }}">
|
||||
<block wx:for="{{ buttons }}" wx:for-item="button" wx:key="">
|
||||
<button
|
||||
class="{{ classes.button[index].wrap }}"
|
||||
disabled="{{ button.disabled }}"
|
||||
open-type="{{ button.openType }}"
|
||||
hover-class="{{ !button.disabled ? classes.button[index].hover : 'none' }}"
|
||||
hover-stop-propagation="{{ button.hoverStopPropagation }}"
|
||||
hover-start-time="{{ button.hoverStartTime || 20 }}"
|
||||
hover-stay-time="{{ button.hoverStayTime || 70 }}"
|
||||
lang="{{ button.lang || 'en' }}"
|
||||
bindgetuserinfo="bindgetuserinfo"
|
||||
session-from="{{ button.sessionFrom }}"
|
||||
send-message-title="{{ button.sendMessageTitle }}"
|
||||
send-message-path="{{ button.sendMessagePath }}"
|
||||
send-message-img="{{ button.sendMessageImg }}"
|
||||
show-message-card="{{ button.showMessageCard }}"
|
||||
bindcontact="bindcontact"
|
||||
bindgetphonenumber="bindgetphonenumber"
|
||||
app-parameter="{{ button.appParameter }}"
|
||||
binderror="onError"
|
||||
bindopensetting="bindopensetting"
|
||||
data-index="{{ index }}"
|
||||
bindtap="buttonTapped"
|
||||
>
|
||||
{{ button.text }}
|
||||
</button>
|
||||
</block>
|
||||
</view>
|
||||
</wux-popup>
|
||||
1
liferestartWX/utils/wux/dialog/index.wxss
Normal file
1
liferestartWX/utils/wux/dialog/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.wux-dialog__button{padding:0;margin:0;border-radius:0;color:inherit!important;background:0 0!important;font-size:inherit;font-weight:400;line-height:inherit;text-align:inherit;text-decoration:none;overflow:visible;min-height:0!important;width:auto!important;box-sizing:border-box;-webkit-tap-highlight-color:transparent;display:block;-ms-flex:1;flex:1;color:#33cd5f!important;position:relative}.wux-dialog__button::after{display:block;position:static;top:auto;left:auto;width:auto;height:auto;border:none;border-radius:0;transform:none;transform-origin:0 0}.wux-dialog__button--default{color:#444!important}.wux-dialog__button--primary{color:#33cd5f!important}.wux-dialog__button--bold{font-weight:500!important}.wux-dialog__button--hover{background-color:#ececec!important}.wux-dialog__button--disabled{opacity:.3}.wux-dialog__prompt{position:relative;margin-top:20rpx}.wux-dialog__prompt::after{content:" ";position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #d9d9d9;border-top-width:1PX;border-right-width:1PX;border-bottom-width:1PX;border-left-width:1PX;border-radius:12rpx}.wux-dialog__input{padding:8rpx 12rpx;height:72rpx;line-height:1;width:100%;text-align:left;box-sizing:border-box}.wux-dialog__buttons{display:-ms-flexbox;display:flex;-ms-flex:1;flex:1}.wux-dialog__buttons--horizontal .wux-dialog__button::after{content:" ";position:absolute;left:0;top:0;width:1PX;bottom:0;border-left:1PX solid #d9d9d9;color:#d9d9d9;transform-origin:0 0;transform:scaleX(.5)}.wux-dialog__buttons--horizontal .wux-dialog__button:first-child::after{display:none}.wux-dialog__buttons--vertical{display:block;height:auto}.wux-dialog__buttons--vertical .wux-dialog__button::after{content:" ";position:absolute;left:0;top:0;right:0;height:1PX;border-top:1PX solid #d9d9d9;color:#d9d9d9;transform-origin:0 0;transform:scaleY(.5)}
|
||||
42
liferestartWX/utils/wux/divider/index.js
Normal file
42
liferestartWX/utils/wux/divider/index.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import baseComponent from '../helpers/baseComponent'
|
||||
import classNames from '../helpers/classNames'
|
||||
|
||||
baseComponent({
|
||||
properties: {
|
||||
prefixCls: {
|
||||
type: String,
|
||||
value: 'wux-divider',
|
||||
},
|
||||
position: {
|
||||
type: String,
|
||||
value: 'center',
|
||||
},
|
||||
dashed: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
text: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
showText: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
classes: ['prefixCls, dashed, showText, position', function(prefixCls, dashed, showText, position) {
|
||||
const wrap = classNames(prefixCls, {
|
||||
[`${prefixCls}--dashed`]: dashed,
|
||||
[`${prefixCls}--text`]: showText,
|
||||
[`${prefixCls}--text-${position}`]: showText && position,
|
||||
})
|
||||
const text = `${prefixCls}__text`
|
||||
|
||||
return {
|
||||
wrap,
|
||||
text,
|
||||
}
|
||||
}],
|
||||
},
|
||||
})
|
||||
3
liferestartWX/utils/wux/divider/index.json
Normal file
3
liferestartWX/utils/wux/divider/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
6
liferestartWX/utils/wux/divider/index.wxml
Normal file
6
liferestartWX/utils/wux/divider/index.wxml
Normal file
@@ -0,0 +1,6 @@
|
||||
<view class="wux-class {{ classes.wrap }}">
|
||||
<view class="{{ classes.text }}" wx:if="{{ showText }}">
|
||||
{{ text }}
|
||||
<slot></slot>
|
||||
</view>
|
||||
</view>
|
||||
53
liferestartWX/utils/wux/divider/index.wxss
Normal file
53
liferestartWX/utils/wux/divider/index.wxss
Normal file
@@ -0,0 +1,53 @@
|
||||
.wux-divider {
|
||||
display: block;
|
||||
height: 2rpx;
|
||||
width: 100%;
|
||||
margin: 30rpx 0;
|
||||
clear: both;
|
||||
border-top: 2rpx solid #e8e8e8
|
||||
}
|
||||
.wux-divider--text {
|
||||
display: table;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
background: 0 0;
|
||||
font-weight: 500;
|
||||
color: rgba(0,0,0,.85);
|
||||
font-size: 32rpx;
|
||||
border-top: none!important
|
||||
}
|
||||
.wux-divider--text::after,
|
||||
.wux-divider--text::before {
|
||||
content: '';
|
||||
display: table-cell;
|
||||
position: relative;
|
||||
top: 50%;
|
||||
width: 50%;
|
||||
border-top-width: 2rpx;
|
||||
border-top-style: solid;
|
||||
border-top-color: #e8e8e8;
|
||||
transform: translateY(50%)
|
||||
}
|
||||
.wux-divider--dashed {
|
||||
border-top: 2rpx dashed #e8e8e8
|
||||
}
|
||||
.wux-divider--dashed.wux-divider--text::after,
|
||||
.wux-divider--dashed.wux-divider--text::before {
|
||||
border-top-style: dashed
|
||||
}
|
||||
.wux-divider--text-left::before {
|
||||
width: 5%
|
||||
}
|
||||
.wux-divider--text-left::after {
|
||||
width: 95%
|
||||
}
|
||||
.wux-divider--text-right::before {
|
||||
width: 95%
|
||||
}
|
||||
.wux-divider--text-right::after {
|
||||
width: 5%
|
||||
}
|
||||
.wux-divider__text {
|
||||
display: inline-block;
|
||||
padding: 0 30rpx
|
||||
}
|
||||
1
liferestartWX/utils/wux/field/index.js
Normal file
1
liferestartWX/utils/wux/field/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_createFieldsStore=_interopRequireDefault(require("../helpers/createFieldsStore"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(r,!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(r).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var DEFAULT_TRIGGER="onChange";function noop(){}function getValueFromEvent(e){return e&&e.detail?e.detail.value:"value"in e?e.value:e}var children=["picker","date-picker","popup-select","radio-group","checkbox-group","switch","input","input-number","rater","slider","textarea"],relations=children.map(function(e){return"../".concat(e,"/index")}).reduce(function(e,t){return _objectSpread({},e,_defineProperty({},t,{type:"descendant",observer:function(){this.debounce(this.changeValue)}}))},{});(0,_baseComponent.default)({useField:!0,relations:_objectSpread({"../form/index":{type:"ancestor"}},relations),properties:{initialValue:{type:null,value:null,observer:"changeValue"},valuePropName:{type:String,value:"inputValue"},trigger:{type:String,value:DEFAULT_TRIGGER}},methods:{getNodes:function(e){var t=this;return(0<arguments.length&&void 0!==e?e:[]).map(function(e){return t.getRelationNodes(e)[0]}).filter(function(e){return!!e})},changeValue:function(e){var t=this,r=0<arguments.length&&void 0!==e?e:this.data.value,n=this.getRelationsName(["descendant"]),o=this.getNodes(n);this.fieldsStore=this.fieldsStore||(0,_createFieldsStore.default)(),this.setValue(r),0<o.length&&o.forEach(function(e){e.hasFieldDecorator=!0,t.setValue(r,e,t.data.valuePropName,function(){t.forceUpdate(t.data.name,t.data,e)})})},setValue:function(e,t,r,n){var o=1<arguments.length&&void 0!==t?t:this,a=2<arguments.length&&void 0!==r?r:"value",i=3<arguments.length&&void 0!==n?n:noop;o.data[a]!==e?o.setData(_defineProperty({},a,e),i):i()},forceUpdate:function(e,t,r){var n=t.valuePropName,o=this.getFieldDecorator(e,t,r),a=o[n];delete o[n],r.setData(o),this.setValue(a,r,n)},onCollectCommon:function(e,t,r){var n=this.fieldsStore.getField(e),o=n.inputElem,a=n.oriInputProps.oriInputEvents;a&&a[t]&&a[t].apply(a,_toConsumableArray(r));var i=getValueFromEvent.apply(void 0,_toConsumableArray(r)),l=this.fieldsStore.getFieldValue(e),u=this.getRelationNodes("../form/index")[0];if(i!==l&&(this.setValue(i),this.setValue(i,o,n.valuePropName),u)){var s=_defineProperty({},e,i),p=this.fieldsStore.getFieldsValue();u.onChange(s,_objectSpread({},p,{},s))}return{name:e,field:_objectSpread({},n,{value:i})}},onCollect:function(e,t){for(var r=arguments.length,n=new Array(2<r?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];var a=this.onCollectCommon(e,t,n),i=a.name,l=a.field;this.fieldsStore.setFields(_defineProperty({},i,l))},getFieldDecorator:function(n,e,t){var o=this,r=this.fieldsStore.getField(n),a=t.data,i=e.trigger,l=void 0===i?DEFAULT_TRIGGER:i,u=_objectSpread({},r,{},e,{name:n,oriInputProps:a,inputElem:t});this.fieldsStore.setFields(_defineProperty({},n,u));var s=_objectSpread({},this.fieldsStore.getFieldValuePropValue(e));return l&&!a.oriInputEvents&&(s.oriInputEvents=_objectSpread({},a.inputEvents),s.inputEvents=_objectSpread({},a.inputEvents,_defineProperty({},l,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return o.onCollect.apply(o,[n,l].concat(t))}))),s}}});
|
||||
3
liferestartWX/utils/wux/field/index.json
Normal file
3
liferestartWX/utils/wux/field/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
1
liferestartWX/utils/wux/field/index.wxml
Normal file
1
liferestartWX/utils/wux/field/index.wxml
Normal file
@@ -0,0 +1 @@
|
||||
<slot></slot>
|
||||
0
liferestartWX/utils/wux/field/index.wxss
Normal file
0
liferestartWX/utils/wux/field/index.wxss
Normal file
1
liferestartWX/utils/wux/form/index.js
Normal file
1
liferestartWX/utils/wux/form/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_createFieldsStore=_interopRequireDefault(require("../helpers/createFieldsStore"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)}return i}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(i,!0).forEach(function(e){_defineProperty(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ownKeys(i).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(0,_baseComponent.default)({relations:{"../field/index":{type:"descendant",observer:function(e,t){var i=t.unlinked;this.renderFields[e.data.name]=!1===i,this.debounce(this.changeValue)}}},properties:{},methods:{changeValue:function(){var n=this,e=this.getRelationNodes("../field/index");if(0<e.length){var t=e.reduce(function(e,t){var i=t.data,r=i.name,s=_objectSpread({},i,{},n.fieldsStore.getField(r),{originalProps:i,fieldElem:t});return e[r]=s,n.renderFields[r]=!0,t.fieldsStore=n.fieldsStore,e},{});this.fieldsStore.updateFields(t),this.clearUnlinkedFields()}},clearUnlinkedFields:function(){var t=this,e=this.fieldsStore.getAllFieldsName().filter(function(e){return!t.renderFields[e]});0<e.length&&e.forEach(function(e){return t.clearField(e)})},clearField:function(e){this.fieldsStore.clearField(e),delete this.renderFields[e]},setFields:function(r){var s=this;Object.keys(r).forEach(function(e){var t=s.fieldsStore.getField(e),i=_objectSpread({},t,{value:r[e]});s.fieldsStore.setFields(_defineProperty({},e,i)),t&&t.fieldElem&&t.fieldElem.changeValue(r[e])})},setFieldsValue:function(i){var r=this.fieldsStore.fields,e=Object.keys(i).reduce(function(e,t){return r[t]&&(e[t]=i[t]),e},{});this.setFields(e);var t=this.getFieldsValue();this.onChange(e,t)},resetFields:function(e){var t=Array.isArray(e)?e:[e],i=this.fieldsStore.resetFields(t);0<Object.keys(i).length&&this.setFields(i)},getForm:function(){return{getFieldsValue:this.getFieldsValue,getFieldValue:this.getFieldValue,setFieldsValue:this.setFieldsValue,setFields:this.setFields,resetFields:this.resetFields}},onChange:function(e,t){this.triggerEvent("change",{form:this.getForm(),changedValues:e,allValues:t})}},created:function(){var i=this;this.fieldsStore=(0,_createFieldsStore.default)(),this.renderFields={},this.setFieldsValue=this.setFieldsValue.bind(this),this.setFields=this.setFields.bind(this),this.resetFields=this.resetFields.bind(this),["getFieldsValue","getFieldValue"].forEach(function(t){i[t]=function(){var e;return(e=i.fieldsStore)[t].apply(e,arguments)}})}});
|
||||
3
liferestartWX/utils/wux/form/index.json
Normal file
3
liferestartWX/utils/wux/form/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
1
liferestartWX/utils/wux/form/index.wxml
Normal file
1
liferestartWX/utils/wux/form/index.wxml
Normal file
@@ -0,0 +1 @@
|
||||
<slot></slot>
|
||||
0
liferestartWX/utils/wux/form/index.wxss
Normal file
0
liferestartWX/utils/wux/form/index.wxss
Normal file
1
liferestartWX/utils/wux/helpers/arrayTreeFilter.js
Normal file
1
liferestartWX/utils/wux/helpers/arrayTreeFilter.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function arrayTreeFilter(e,r,t){(t=t||{}).childrenKeyName=t.childrenKeyName||"children";var a=e||[],l=[],i=0;do{var d=a.filter(function(e){return r(e,i)})[0];if(!d)break;l.push(d),a=d[t.childrenKeyName]||[],i+=1}while(0<a.length);return l}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _default=arrayTreeFilter;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/baseComponent.js
Normal file
1
liferestartWX/utils/wux/helpers/baseComponent.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _computedBehavior=_interopRequireDefault(require("./computedBehavior")),_relationsBehavior=_interopRequireDefault(require("./relationsBehavior")),_safeAreaBehavior=_interopRequireDefault(require("./safeAreaBehavior")),_safeSetDataBehavior=_interopRequireDefault(require("./safeSetDataBehavior")),_funcBehavior=_interopRequireDefault(require("./funcBehavior")),_compareVersion=_interopRequireDefault(require("./compareVersion"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(t,!0).forEach(function(e){_defineProperty(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ownKeys(t).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}var _wx$getSystemInfoSync=wx.getSystemInfoSync(),platform=_wx$getSystemInfoSync.platform,SDKVersion=_wx$getSystemInfoSync.SDKVersion,libVersion="2.6.6";"devtools"===platform&&(0,_compareVersion.default)(SDKVersion,libVersion)<0&&wx&&wx.showModal&&wx.showModal({title:"提示",content:"当前基础库版本(".concat(SDKVersion,")过低,无法使用 Wux Weapp 组件库,请更新基础库版本 >=").concat(libVersion," 后重试。")});var baseComponent=function(e){var r=0<arguments.length&&void 0!==e?e:{};return r.externalClasses=["wux-class","wux-hover-class"].concat(_toConsumableArray(r.externalClasses=r.externalClasses||[])),r.behaviors=[_relationsBehavior.default,_safeSetDataBehavior.default].concat(_toConsumableArray(r.behaviors=r.behaviors||[]),[_computedBehavior.default]),r.useSafeArea&&(r.behaviors=[].concat(_toConsumableArray(r.behaviors),[_safeAreaBehavior.default]),delete r.useSafeArea),r.useFunc&&(r.behaviors=[].concat(_toConsumableArray(r.behaviors),[_funcBehavior.default]),delete r.useFunc),r.useField&&(r.behaviors=[].concat(_toConsumableArray(r.behaviors),["wx://form-field"]),delete r.useField),r.useExport&&(r.behaviors=[].concat(_toConsumableArray(r.behaviors),["wx://component-export"]),r.methods=_objectSpread({export:function(){return this}},r.methods),delete r.useExport),r.options=_objectSpread({multipleSlots:!0,addGlobalClass:!0},r.options),Component(r)},_default=baseComponent;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/checkIPhoneX.js
Normal file
1
liferestartWX/utils/wux/helpers/checkIPhoneX.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkIPhoneX=exports.safeAreaInset=exports.getSystemInfo=void 0;var systemInfo=null,getSystemInfo=function(e){if(!systemInfo||e)try{systemInfo=wx.getSystemInfoSync()}catch(e){}return systemInfo};exports.getSystemInfo=getSystemInfo;var safeAreaInset={top:88,left:0,right:0,bottom:34};exports.safeAreaInset=safeAreaInset;var isIPhoneX=function(e){var t=e.model,o=e.platform;return/iPhone X/.test(t)&&"ios"===o},checkIPhoneX=function(e){return isIPhoneX(getSystemInfo(e))};exports.checkIPhoneX=checkIPhoneX;
|
||||
1
liferestartWX/utils/wux/helpers/classNames.js
Normal file
1
liferestartWX/utils/wux/helpers/classNames.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var hasOwn={}.hasOwnProperty;function classNames(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var r=_typeof(o);if("string"===r||"number"===r)e.push(o);else if(Array.isArray(o)&&o.length){var n=classNames.apply(null,o);n&&e.push(n)}else if("object"===r)for(var s in o)hasOwn.call(o,s)&&o[s]&&e.push(s)}}return e.join(" ")}var _default=classNames;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/colors.js
Normal file
1
liferestartWX/utils/wux/helpers/colors.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isPresetColor=exports.colors=void 0;var colors={light:"#ddd",stable:"#b2b2b2",positive:"#387ef5",calm:"#11c1f3",balanced:"#33cd5f",energized:"#ffc900",assertive:"#ef473a",royal:"#886aea",dark:"#444"};exports.colors=colors;var isPresetColor=function(e){return!!e&&(colors[e]?colors[e]:e)};exports.isPresetColor=isPresetColor;
|
||||
1
liferestartWX/utils/wux/helpers/compareVersion.js
Normal file
1
liferestartWX/utils/wux/helpers/compareVersion.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function compareVersion(e,r){for(var t=e.split("."),a=r.split("."),n=Math.max(t.length,a.length);t.length<n;)t.push("0");for(;a.length<n;)a.push("0");for(var o=0;o<n;o++){var s=parseInt(t[o]),u=parseInt(a[o]);if(u<s)return 1;if(s<u)return-1}return 0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _default=compareVersion;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/computedBehavior.js
Normal file
1
liferestartWX/utils/wux/helpers/computedBehavior.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _isEmpty=_interopRequireDefault(require("./isEmpty")),_shallowEqual=_interopRequireDefault(require("./shallowEqual"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(t,!0).forEach(function(e){_defineProperty(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ownKeys(t).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(e,r){var t=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(t.push(a.value),!r||t.length!==r);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return t}function _arrayWithHoles(e){if(Array.isArray(e))return e}var ALL_DATA_KEY="**",trim=function(e){return(0<arguments.length&&void 0!==e?e:"").replace(/\s/g,"")},_default=Behavior({lifetimes:{attached:function(){this.initComputed()}},definitionFilter:function(e){var r=e.computed,n=void 0===r?{}:r,a=Object.keys(n).reduce(function(e,i){var r=_slicedToArray(Array.isArray(n[i])?n[i]:[ALL_DATA_KEY,n[i]],2),t=r[0],a=r[1];return _objectSpread({},e,_defineProperty({},t,function(){if("function"==typeof a){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=a.apply(this,r),o=this.data[i];(0,_isEmpty.default)(n)||(0,_shallowEqual.default)(n,o)||this.setData(_defineProperty({},i,n))}}))},{});Object.assign(e.observers=e.observers||{},a),Object.assign(e.methods=e.methods||{},{initComputed:function(e,r){var t=0<arguments.length&&void 0!==e?e:{},n=1<arguments.length&&void 0!==r&&r;if(!this.runInitComputed||n){this.runInitComputed=!1;var o=this,i=_objectSpread({},this.data,{},t);Object.keys(a).forEach(function(e){var r=trim(e).split(",").reduce(function(e,r){return[].concat(_toConsumableArray(e),[i[r]])},[]);a[e].apply(o,r)}),this.runInitComputed=!0}}})}});exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/createFieldsStore.js
Normal file
1
liferestartWX/utils/wux/helpers/createFieldsStore.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(r,!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(r).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=createFieldsStore;var FieldsStore=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,t),this.fields=e}return _createClass(t,[{key:"setFields",value:function(e){Object.assign(this.fields,e)}},{key:"updateFields",value:function(e){this.fields=e}},{key:"clearField",value:function(e){delete this.fields[e]}},{key:"getValueFromFields",value:function(e,t){var r=t[e];return r&&"value"in r?r.value:r.initialValue}},{key:"getAllFieldsName",value:function(){var e=this.fields;return e?Object.keys(e):[]}},{key:"getField",value:function(e){return _objectSpread({},this.fields[e],{name:e})}},{key:"getFieldValuePropValue",value:function(e){var t=e.name,r=e.valuePropName,n=this.getField(t);return _defineProperty({},r,"value"in n?n.value:n.initialValue)}},{key:"getFieldValue",value:function(e){return this.getValueFromFields(e,this.fields)}},{key:"getFieldsValue",value:function(e){var r=this;return(e||this.getAllFieldsName()).reduce(function(e,t){return e[t]=r.getFieldValue(t),e},{})}},{key:"resetFields",value:function(e){var n=this.fields;return(e||this.getAllFieldsName()).reduce(function(e,t){var r=n[t];return r&&(e[t]=r.initialValue),e},{})}}]),t}();function createFieldsStore(e){return new FieldsStore(e)}
|
||||
1
liferestartWX/utils/wux/helpers/debounce.js
Normal file
1
liferestartWX/utils/wux/helpers/debounce.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function debounce(t,o,i){var n,u,r,a,c;function d(){var e=+new Date-a;e<o&&0<=e?n=setTimeout(d,o-e):(n=void 0,i||(c=t.apply(r,u),n||(u=r=void 0)))}function e(){r=this,u=arguments,a=+new Date;var e=i&&!n;return n=n||setTimeout(d,o),e&&(c=t.apply(r,u),u=r=void 0),c}return e.cancel=function(){void 0!==n&&(clearTimeout(n),n=void 0),u=r=void 0},e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=debounce;
|
||||
1
liferestartWX/utils/wux/helpers/eventsMixin.js
Normal file
1
liferestartWX/utils/wux/helpers/eventsMixin.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=eventsMixin;var defaultEvents={onChange:function(){}};function eventsMixin(){return Behavior({lifetimes:{created:function(){this._oriTriggerEvent=this.triggerEvent,this.triggerEvent=this._triggerEvent}},properties:{events:{type:Object,value:defaultEvents}},data:{inputEvents:defaultEvents},definitionFilter:function(t){Object.assign(t.data=t.data||{},{inputEvents:Object.assign({},defaultEvents,t.inputEvents)}),Object.assign(t.methods=t.methods||{},{_triggerEvent:function(t,e,n,i){var s=!(2<arguments.length&&void 0!==n)||n,a=3<arguments.length?i:void 0,r=this.data.inputEvents["on".concat(t[0].toUpperCase()).concat(t.slice(1))];s&&"function"==typeof r&&r.call(this,e),this._oriTriggerEvent(t,e,a)}}),Object.assign(t.observers=t.observers||{},{events:function(t){this.setData({inputEvents:Object.assign({},defaultEvents,this.data.inputEvents,t)})}})}})}
|
||||
1
liferestartWX/utils/wux/helpers/funcBehavior.js
Normal file
1
liferestartWX/utils/wux/helpers/funcBehavior.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var mergeOptionsToData=function(t){var e=0<arguments.length&&void 0!==t?t:{},n=Object.assign({},e);for(var r in n)n.hasOwnProperty(r)&&"function"==typeof n[r]&&delete n[r];return n},bind=function(r,i){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.length?r.apply(i,e):r.call(i)}},assign=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return Object.assign.apply(Object,[{}].concat(e))},_default=Behavior({definitionFilter:function(t){t.data=mergeOptionsToData(t.data),t.data.in=!1,t.data.visible=!1},methods:{$$mergeOptionsToData:mergeOptionsToData,$$mergeOptionsAndBindMethods:function(t,e){var n=0<arguments.length&&void 0!==t?t:{},r=1<arguments.length&&void 0!==e?e:this.fns,i=Object.assign({},n);for(var a in i)i.hasOwnProperty(a)&&"function"==typeof i[a]&&(r[a]=bind(i[a],this),delete i[a]);return i},$$setData:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=assign.apply(void 0,[{}].concat(n));return new Promise(function(t){e.setData(i,t)})},$$requestAnimationFrame:function(t,e){var n=0<arguments.length&&void 0!==t?t:function(){},r=1<arguments.length&&void 0!==e?e:1e3/60;return new Promise(function(t){return setTimeout(t,r)}).then(n)}},created:function(){this.fns={}},detached:function(){this.fns={}}});exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/gestures.js
Normal file
1
liferestartWX/utils/wux/helpers/gestures.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSwipeDirection=exports.getPointsDistance=exports.isNearbyPoints=exports.isEqualPoints=exports.getPointsNumber=exports.getTouchPoints=void 0;var getTouchPoints=function(t,e){var s=1<arguments.length&&void 0!==e?e:0,o=t.touches,n=t.changedTouches,i=o&&0<o.length,r=n&&0<n.length,a=!i&&r?n[s]:i?o[s]:t;return{x:a.pageX,y:a.pageY}};exports.getTouchPoints=getTouchPoints;var getPointsNumber=function(t){return t.touches&&t.touches.length||t.changedTouches&&t.changedTouches.length};exports.getPointsNumber=getPointsNumber;var isEqualPoints=function(t,e){return t.x===e.x&&t.y===e.y};exports.isEqualPoints=isEqualPoints;var isNearbyPoints=function(t,e,s){var o=2<arguments.length&&void 0!==s?s:25;return Math.abs(t.x-e.x)<o&Math.abs(t.y-e.y)<o};exports.isNearbyPoints=isNearbyPoints;var getPointsDistance=function(t,e){var s=Math.abs(t.x-e.x),o=Math.abs(t.y-e.y);return Math.sqrt(s*s+o*o)};exports.getPointsDistance=getPointsDistance;var getSwipeDirection=function(t,e,s,o){return Math.abs(t-e)>=Math.abs(s-o)?0<t-e?"Left":"Right":0<s-o?"Up":"Down"};exports.getSwipeDirection=getSwipeDirection;
|
||||
1
liferestartWX/utils/wux/helpers/isEmpty.js
Normal file
1
liferestartWX/utils/wux/helpers/isEmpty.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function isEmpty(t){if(Array.isArray(t))return 0===t.length;if("object"!==_typeof(t))return!t;if(t)for(var e in t)return!1;return!0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _default=isEmpty;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/mergeOptionsToData.js
Normal file
1
liferestartWX/utils/wux/helpers/mergeOptionsToData.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var mergeOptionsToData=function(e){var t=0<arguments.length&&void 0!==e?e:{},o=Object.assign({},t);for(var r in o)o.hasOwnProperty(r)&&"function"==typeof o[r]&&delete o[r];return o},_default=mergeOptionsToData;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/popupMixin.js
Normal file
1
liferestartWX/utils/wux/helpers/popupMixin.js
Normal file
File diff suppressed because one or more lines are too long
1
liferestartWX/utils/wux/helpers/relationsBehavior.js
Normal file
1
liferestartWX/utils/wux/helpers/relationsBehavior.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _isEmpty=_interopRequireDefault(require("./isEmpty")),_debounce2=_interopRequireDefault(require("./debounce"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bindFunc(e,t,n){var i=e[t];e[t]=function(e){n&&n.call(this,e,_defineProperty({},t,!0)),i&&i.call(this,e)}}var methods=["linked","linkChanged","unlinked"],extProps=["observer"],_default=Behavior({lifetimes:{created:function(){this._debounce=null},detached:function(){this._debounce&&this._debounce.cancel&&this._debounce.cancel()}},definitionFilter:function(e){var n=e.relations;if(!(0,_isEmpty.default)(n)){var t=function(e){var t=n[e];methods.forEach(function(e){return bindFunc(t,e,t.observer)}),extProps.forEach(function(e){return delete t[e]})};for(var i in n)t(i)}Object.assign(e.methods=e.methods||{},{getRelationsName:function(e){var t=0<arguments.length&&void 0!==e?e:["parent","child","ancestor","descendant"];return Object.keys(n||{}).map(function(e){return n[e]&&t.includes(n[e].type)?e:null}).filter(function(e){return!!e})},debounce:function(e,t,n){var i=1<arguments.length&&void 0!==t?t:0,r=2<arguments.length&&void 0!==n&&n;return(this._debounce=this._debounce||(0,_debounce2.default)(e.bind(this),i,r)).call(this)}})}});exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/safeAreaBehavior.js
Normal file
1
liferestartWX/utils/wux/helpers/safeAreaBehavior.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _checkIPhoneX=require("./checkIPhoneX");function _defineProperty(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var defaultSafeArea={top:!1,bottom:!1},setSafeArea=function(e){return"boolean"==typeof e?Object.assign({},defaultSafeArea,{top:e,bottom:e}):null!==e&&"object"===_typeof(e)?Object.assign({},defaultSafeArea):"string"==typeof e?Object.assign({},defaultSafeArea,_defineProperty({},e,!0)):defaultSafeArea},_default=Behavior({properties:{safeArea:{type:[Boolean,String,Object],value:!1}},observers:{safeArea:function(e){this.setData({safeAreaConfig:setSafeArea(e)})}},definitionFilter:function(e){var t=((0,_checkIPhoneX.getSystemInfo)()||{}).statusBarHeight,o=(0,_checkIPhoneX.checkIPhoneX)();Object.assign(e.data=e.data||{},{safeAreaConfig:defaultSafeArea,statusBarHeight:t,isIPhoneX:o})}});exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/safeSetDataBehavior.js
Normal file
1
liferestartWX/utils/wux/helpers/safeSetDataBehavior.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _default=Behavior({lifetimes:{created:function(){this.nextCallback=null},detached:function(){this.cancelNextCallback()}},methods:{safeSetData:function(t,a){var e=this;this.pendingData=Object.assign({},this.data,t),a=this.setNextCallback(a),this.setData(t,function(){e.pendingData=null,a()})},setNextCallback:function(a){var e=this,l=!0;return this.nextCallback=function(t){l&&(l=!1,e.nextCallback=null,a.call(e,t))},this.nextCallback.cancel=function(){l=!1},this.nextCallback},cancelNextCallback:function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)}}});exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/shallowEqual.js
Normal file
1
liferestartWX/utils/wux/helpers/shallowEqual.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var hasOwnProperty=Object.prototype.hasOwnProperty;function is(t,e){return t===e?0!==t||0!==e||1/t==1/e:t!=t&&e!=e}function shallowEqual(t,e){if(is(t,e))return!0;if("object"!==_typeof(t)||null===t||"object"!==_typeof(e)||null===e)return!1;var o=Object.keys(t),r=Object.keys(e);if(o.length!==r.length)return!1;for(var n=0;n<o.length;n++)if(!hasOwnProperty.call(e,o[n])||!is(t[o[n]],e[o[n]]))return!1;return!0}var _default=shallowEqual;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/helpers/styleToCssString.js
Normal file
1
liferestartWX/utils/wux/helpers/styleToCssString.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var isUnitlessNumber={boxFlex:!(exports.default=void 0),boxFlexGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,strokeDashoffset:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)}var prefixes=["Webkit","ms","Moz","O"];Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})});var msPattern=/^ms-/,_uppercasePattern=/([A-Z])/g;function hyphenate(e){return e.replace(_uppercasePattern,"-$1").toLowerCase()}function hyphenateStyleName(e){return hyphenate(e).replace(msPattern,"-ms-")}var isArray=Array.isArray,keys=Object.keys,counter=1,unquotedContentValueRegex=/^(normal|none|(\b(url\([^)]*\)|chapter_counter|attr\([^)]*\)|(no-)?(open|close)-quote|inherit)((\b\s*)|$|\s+))+)$/;function buildRule(e,t){return isUnitlessNumber[e]||"number"!=typeof t?"content"!==e||unquotedContentValueRegex.test(t)||(t="'"+t.replace(/'/g,"\\'")+"'"):t+="px",hyphenateStyleName(e)+": "+t+"; "}function styleToCssString(e){var t="";if("string"==typeof e)return e;if(!e||0===keys(e).length)return t;for(var r=keys(e),n=0,s=r.length;n<s;n++){var o=r[n],i=e[o];if(isArray(i))for(var a=0,u=i.length;a<u;a++)t+=buildRule(o,i[a]);else t+=buildRule(o,i)}return t}var _default=styleToCssString;exports.default=_default;
|
||||
1
liferestartWX/utils/wux/icon/index.js
Normal file
1
liferestartWX/utils/wux/icon/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Component({externalClasses:["wux-class"],properties:{type:{type:String,value:""},size:{type:[String,Number],value:32,observer:"updated"},color:{type:String,value:""},hidden:{type:Boolean,value:!1}},data:{fontSize:""},methods:{updated:function(t){var e=0<arguments.length&&void 0!==t?t:this.data.size,a=e;"number"==typeof e?a="".concat(e,"px"):"string"==typeof e&&(isNaN(Number(e))||(a="".concat(e,"px"))),this.data.fontSize!==a&&this.setData({fontSize:a})}},attached:function(){this.updated()}});
|
||||
3
liferestartWX/utils/wux/icon/index.json
Normal file
3
liferestartWX/utils/wux/icon/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
1
liferestartWX/utils/wux/icon/index.wxml
Normal file
1
liferestartWX/utils/wux/icon/index.wxml
Normal file
@@ -0,0 +1 @@
|
||||
<view class="wux-class ion {{ type ? 'ion-' + type : '' }}" style="font-size: {{ fontSize }}; {{ color ? 'color: ' + color : '' }}" hidden="{{ hidden }}"></view>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user