This commit is contained in:
uiiang
2025-04-05 12:31:04 +08:00
committed by GitHub
208 changed files with 5936 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
liferestartWX/.DS_Store vendored Normal file

Binary file not shown.

18
liferestartWX/README.md Normal file
View File

@@ -0,0 +1,18 @@
# lifeRestartWX - 人生重开模拟器微信小程序版
人生重开模拟器[微信小程序版](https://github.com/uiiang/lifeRestartWX)
## 简介
- 根据[人生重开模拟器](https://github.com/VickScarlet/lifeRestart)开发的微信小程序版
- 数据和核心逻辑代码均采用VickScarlet版
## 开发笔记
- age, events, telents数据修改为微信本地读取js
## 快速体验
- 微信小程序搜索 奇奇怪怪的软件
- 微信扫描二维码
<img src="/assets/images/app_qcode.jpg" width="40%">

19
liferestartWX/app.js Normal file
View File

@@ -0,0 +1,19 @@
// app.js
App({
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
},
globalData: {
userInfo: null
}
})

19
liferestartWX/app.json Normal file
View File

@@ -0,0 +1,19 @@
{
"pages":[
"pages/index",
"pages/talents",
"pages/summary",
"pages/trajectory",
"pages/property",
"pages/ranking"
],
"window":{
"backgroundColor": "#000",
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#F6F6F6",
"navigationBarTitleText": "人生重开模拟器",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}

14
liferestartWX/app.wxss Normal file
View File

@@ -0,0 +1,14 @@
/**
* 全局样式表
* 使用@import语句可以导入外联样式表@import后跟需要导入的外联样式表的相对路径用;表示语句结束
* 如果需要增加额外的WXSS样式表, 直接import即可, 但需注意引用顺序
*/
@import 'assets/styles/weui.wxss';
@import 'assets/styles/example.wxss';
page {
height: 100%;
background-color: #222831;
}

BIN
liferestartWX/assets/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,97 @@
page {
width: 100%;
height: 100%;
position: relative;
color: rgba(0, 0, 0, .85);
background-color: #f8f8f8;
font-size: 16px;
font-family: PingFang SC, Helvetica Neue, Hiragino Sans GB, Helvetica, Microsoft YaHei, Arial;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent;
}
.page__hd {
padding: 40px;
}
.page__bd {
padding-bottom: 40px;
}
.page__bd_spacing {
padding-left: 10px;
padding-right: 10px;
}
.page__ft {
padding-bottom: 10px;
text-align: center;
}
.page__title {
text-align: left;
font-size: 20px;
font-weight: 400;
}
.page__desc {
margin-top: 5px;
color: rgba(0, 0, 0, .45);
text-align: left;
font-size: 14px;
}
.placeholder {
background-color: #ebebef;
color: #bbb;
text-align: center;
height: 30px;
line-height: 30px;
width: 100%;
box-sizing: border-box;
}
.sub-title {
padding: 30rpx 30rpx 18rpx;
font-size: 28rpx;
color: rgba(0, 0, 0, .65);
width: 100%;
box-sizing: border-box;
}
.button-sp-area {
margin: 20px auto 0;
width: 80%;
text-align: center;
}
.btn-area {
margin: 1.17647059em 15px 0.3em;
}
.btn-area button {
margin-bottom: 10px;
}
.btn-area button:last-child {
margin-bottom: 0;
}
.text-left {
text-align: left;
}
.text-center {
text-align: center;
}
.text-right {
text-align: right;
}
.btn-group {
position: relative;
z-index: 1010;
margin-bottom: 50px;
}

File diff suppressed because it is too large Load Diff

BIN
liferestartWX/pages/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,44 @@
// miniprogram/pages/liferestart/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
},
toRanking(e) {
wx.navigateTo({
url: 'ranking'
})
},
toTalents(e) {
wx.navigateTo({
url: 'talents'
})
},
onShareTimeline(e) {
return {
title: "人生重开模拟器",
imageUrl: "../../../images/liferestart_cover.jpg",
}
},
onShareAppMessage: function () {
return {
title: '人生重开模拟器',
imageUrl: '../../../images/liferestart_cover.jpg',
path: '/pages/index/index',
}
},
})

View File

@@ -0,0 +1,8 @@
{
"usingComponents": {
"wux-icon": "/utils/wux/icon/index",
"wux-button": "/utils/wux/button/index",
"wux-wing-blank": "/utils/wux/wing-blank/index",
"wux-white-space": "/utils/wux/white-space/index"
}
}

View File

@@ -0,0 +1,19 @@
<!--miniprogram/pages/liferestart/index.wxml-->
<view class="container">
<view class="title1">人生重开模拟器</view>
<view class="title2">这垃圾人生一秒也不想呆了</view>
<wux-white-space size="large" />
<wux-white-space size="large" />
<wux-white-space size="large" />
<wux-white-space size="large" />
<view class="btn-view">
<view bindtap="toTalents" class="btn">
<view class="btn-text">立即重开</view>
</view>
</view>
<!-- <view class="btn2-view">
<view bindtap="toRanking" class="btn2">
<view class="btn2-text">卷起来</view>
</view>
</view> -->
</view>

View File

@@ -0,0 +1,80 @@
/* miniprogram/pages/liferestart/index.wxss */
.container {
height: 100%;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
padding: 100rpx 50rpx;
box-sizing: border-box;
background-color: #222831;
color: #fff;
}
.title1 {
font-size: 82rpx;
color: white;
background-size: cover;
}
.title2 {
font-size: 42rpx;
color: white;
background-size: cover;
}
.btn-view {
display:flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.btn {
width: 400rpx;
height: 400rpx;
background-image: -webkit-radial-gradient(45px 45px, circle cover, #99CC33, #003366);
animation-name: spin;
animation-duration: 3s; /* 3 seconds */
animation-iteration-count: infinite;
animation-timing-function: linear;
border-radius: 50%;
}
.btn-text {
width: 400rpx;
height: 400rpx;
text-align: center;
font-size: 82rpx;
line-height: 400rpx;
color: white;
}
.btn2-view {
position:fixed;
bottom:0;
left:0;
padding-left: 50px;
padding-bottom: 50px;
}
.btn2 {
width: 200rpx;
height: 200rpx;
background-image: -webkit-radial-gradient(45px 45px, circle cover, #99CC33, #003366);
animation-name: spin;
animation-duration: 3s; /* 3 seconds */
animation-iteration-count: infinite;
animation-timing-function: linear;
border-radius: 50%;
}
.btn2-text {
width: 200rpx;
height: 200rpx;
text-align: center;
font-size: 42rpx;
line-height: 200rpx;
color: white;
}

View File

@@ -0,0 +1,170 @@
// miniprogram/pages/liferestart/property.js
import {
$wuxToptips
} from '../utils/wux/index';
import {computeTalentsStatus, computeUseableProp, randomProp} from '../utils/liferestart/data/dataUtils.js';
Page({
/**
* 页面的初始数据
*/
data: {
propertyResidue : 0,
propertyCHR : 0,
propertyINT : 0,
propertySTR : 0,
propertyMNY : 0,
propertyCHRMAX : 10,
propertyINTMAX : 10,
propertySTRMAX : 10,
propertyMNYMAX : 10,
propertyMaxInit : 0,
selectedTalentsID : [],
selectedTalents : []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
this.computeProperty()
},
randomProperty(e) {
const arr = randomProp(this.data.propertyMaxInit, [10,10,10,10])
// console.log('randomProperty', t, arr)
this.setData({
propertyCHR : 10 - arr[0],
propertyINT : 10 - arr[1],
propertySTR : 10 - arr[2],
propertyMNY : 10 - arr[3],
propertyCHRMAX : 10 - arr[0],
propertyINTMAX : 10 - arr[1],
propertySTRMAX : 10 - arr[2],
propertyMNYMAX : 10 - arr[3],
propertyResidue : 0
})
},
bron(e) {
const tData = this.data
if (tData.propertyResidue > 0) {
$wuxToptips().error({
hidden: false,
text: '你还有'+tData.propertyResidue+'属性点没有分配完',
duration: 5000,
success() {},
})
return
}
wx.setStorage({
key: 'propertyCHR',
data: tData.propertyCHR
})
wx.setStorage({
key: 'propertyINT',
data: tData.propertyINT
})
wx.setStorage({
key: 'propertySTR',
data: tData.propertySTR
})
wx.setStorage({
key: 'propertyMNY',
data: tData.propertyMNY
})
wx.redirectTo({
url: 'trajectory'
})
},
onChange(e) {
const id = e.currentTarget.id
const value = e.detail.value
const tdata = this.data
switch (id) {
case 'propertyCHR':
this.setData({
propertyCHR : value
})
break
case 'propertyINT':
this.setData({
propertyINT : value
})
break
case 'propertySTR':
this.setData({
propertySTR : value
})
break
case 'propertyMNY':
this.setData({
propertyMNY : value
})
break
}
// console.log(tdata.propertyCHR
// , tdata.propertyINT
// , tdata.propertySTR
// , tdata.propertyMNY)
var max = tdata.propertyMaxInit
- tdata.propertyCHR
- tdata.propertyINT
- tdata.propertySTR
- tdata.propertyMNY
max = max < 0 ? 0 : max
// console.log(id, value, max)
this.setData({
propertyResidue : max < 0 ? 0 : max,
propertyCHRMAX : max + tdata.propertyCHR >= 10? 10 : max + tdata.propertyCHR,
propertyINTMAX : max + tdata.propertyINT >= 10? 10 : max + tdata.propertyINT,
propertySTRMAX : max + tdata.propertySTR >= 10? 10 : max + tdata.propertySTR,
propertyMNYMAX : max + tdata.propertyMNY >= 10? 10 : max + tdata.propertyMNY,
})
// console.log(tdata.propertyCHRMAX,tdata.propertyINTMAX,tdata.propertySTRMAX,tdata.propertyMNYMAX)
},
computeProperty: function() {
const selectedTalents = wx.getStorageSync('selectedTalents')
const selectedTalentsID = wx.getStorageSync('selectedTalentsID')
console.log('selectedTalents', selectedTalents)
var status = computeTalentsStatus(selectedTalents)
// console.log('status', status)
var proNum = computeUseableProp(20, status)
this.setData({
propertyResidue: proNum,
propertyMaxInit: proNum,
selectedTalents: selectedTalents,
selectedTalentsID: selectedTalentsID
})
// console.log('proNum', proNum)
},
onShareTimeline(e) {
return {
title: "人生重开模拟器",
imageUrl: "../../../images/liferestart_cover.jpg",
}
},
onShareAppMessage: function () {
return {
title: '人生重开模拟器',
imageUrl: '../../../images/liferestart_cover.jpg',
path: '/pages/index/index',
}
},
// change(prop, value) {
// if(Array.isArray(value)) {
// for(const v of value)
// this.change(prop, Number(v));
// return;
// }
// }
})

View File

@@ -0,0 +1,11 @@
{
"usingComponents": {
"wux-toptips": "/utils/wux/toptips/index",
"wux-button": "/utils/wux/button/index",
"wux-cell-group": "/utils/wux/cell-group/index",
"wux-cell": "/utils/wux/cell/index",
"wux-input-number": "/utils/wux/input-number/index",
"wux-wing-blank": "/utils/wux/wing-blank/index",
"wux-white-space": "/utils/wux/white-space/index"
}
}

View File

@@ -0,0 +1,44 @@
<!--miniprogram/pages/liferestart/property.wxml-->
<wux-toptips id="wux-toptips" />
<view class="container">
<wux-white-space size="large" />
<wux-white-space size="large" />
<view class="title1 wux-text--center">调整初始属性</view>
<view class="title2 wux-text--center">可用属性点:{{propertyResidue}}</view>
<wux-white-space size="large" />
<wux-white-space size="large" />
<wux-wing-blank size="large">
<wux-cell-group>
<wux-cell title="颜值" hover-class="none">
<wux-input-number id="propertyCHR" value="{{ propertyCHR }}"
controlled min="{{ 0 }}" max="{{ propertyCHRMAX }}" bind:change="onChange" longpress
color="assertive" slot="footer" />
</wux-cell>
<wux-cell title="智力" hover-class="none">
<wux-input-number id="propertyINT" value="{{ propertyINT }}"
controlled min="{{ 0 }}" max="{{ propertyINTMAX }}" bind:change="onChange" longpress
color="assertive" slot="footer" />
</wux-cell>
<wux-cell title="体质" hover-class="none">
<wux-input-number id="propertySTR" value="{{ propertySTR }}"
controlled min="{{ 0 }}" max="{{ propertySTRMAX }}" bind:change="onChange" longpress
color="assertive" slot="footer" />
</wux-cell>
<wux-cell title="家境" hover-class="none">
<wux-input-number id="propertyMNY" value="{{ propertyMNY }}"
controlled min="{{ 0 }}" max="{{ propertyMNYMAX }}"bind:change="onChange" longpress
color="assertive" slot="footer" />
</wux-cell>
</wux-cell-group>
<wux-white-space size="large" />
<view class="title2 wux-text--center">已选天赋</view>
<view class="talentsTable">
<block wx:for="{{selectedTalents}}" wx:key="*this">
<view class="grade{{item.grade}}b">{{item.name}} ({{item.description}})</view>
</block>
</view>
<wux-button block type="royal" bindtap="randomProperty">随机分配</wux-button>
<wux-button block type="balanced" bindtap="bron">开启新人生</wux-button>
</wux-wing-blank>
</view>

View File

@@ -0,0 +1,72 @@
/* miniprogram/pages/liferestart/property.wxss */
/* miniprogram/pages/liferestart/index.wxss */
@import '../utils/wux/styles/index.wxss';
.container {
justify-content: center;
flex-direction: column;
align-items: center;
/* padding: 50rpx 100rpx; */
box-sizing: border-box;
background-color: #222831;
/* color: #fff; */
}
.checkbox {
position: static !important;
}
.title1 {
font-size: 82rpx;
color: white;
background-size: cover;
}
.title2 {
font-size: 42rpx;
color: white;
background-size: cover;
}
.input {
width: 120rpx !important;
border-color: transparent !important;
}
.sub,
.add {
width: 52rpx !important;
border: 2rpx solid #ececec !important;
border-radius: 10rpx !important;
}
.talentsTable{
width: 100%;
position: relative;
border: 1px #ccc solid;
display: inline-block;
margin: 0.1rem 2px;
font-size: 42rpx;
text-align: center;
border-radius: 0.2rem;
color: white;
}
.grade0b {
background-color: #464646;
border: #f8f8f8 2px solid !important;
}
.grade1b {
background-color: #6495ed;
border: #f8f8f8 2px solid !important;
}
.grade2b {
background-color: #e2a7ff;
border: #f8f8f8 2px solid !important;
}
.grade3b {
background-color: #ffa07a;
border: #f8f8f8 2px solid !important;
}

View File

@@ -0,0 +1,45 @@
// miniprogram/page/liferestart/pages/ranking.js
Page({
/**
* 页面的初始数据
*/
data: {
rankingAGE: [],//最长寿
rankingSPR: [],//最快乐
rankingMNY: [],//最有钱
rankingSTR: [],//最健康
rankingINT: [],//最聪明
rankingCHR: [],//最漂亮
rankingSCO: [],//最NB
},
loadRanking() {
console.log('loadRanking')
wx.cloud.callFunction({
name: 'ranking',
data: {
handle: 'getRankingAll'
}
}).then(res => {
console.log('ranking page ', res.result)
this.setData({
rankingAGE: res.result.recordAGE.data,//最长寿
rankingSPR: res.result.recordSPR.data,//最快乐
rankingMNY: res.result.recordMNY.data,//最有钱
rankingSTR: res.result.recordSTR.data,//最健康
rankingINT: res.result.recordINT.data,//最聪明
rankingCHR: res.result.recordCHR.data,//最漂亮
rankingSCO: res.result.recordFinal.data,//最NB
})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.loadRanking()
},
})

View File

@@ -0,0 +1,9 @@
{
"usingComponents": {
"wux-button": "/utils/wux/button/index",
"wux-row": "/utils/wux/row/index",
"wux-col": "/utils/wux/col/index",
"wux-wing-blank": "/utils/wux/wing-blank/index",
"wux-white-space": "/utils/wux/white-space/index"
}
}

View File

@@ -0,0 +1,29 @@
<import src="./ranking_item_template.wxml" />
<view class="container">
<wux-white-space size="large" />
<wux-white-space size="large" />
<view class="title1 wux-text--center">内卷世界</view>
<wux-white-space size="large" />
<wux-wing-blank size="large">
<template is="ranking_item" data="{{title_name:'最快乐',rankingData:rankingSPR,type:'rankingSPR'}}"/>
<template is="ranking_item" data="{{title_name:'最健康',rankingData:rankingSTR,type:'rankingSTR'}}"/>
<template is="ranking_item" data="{{title_name:'最长寿',rankingData:rankingAGE,type:'rankingAGE'}}"/>
<template is="ranking_item" data="{{title_name:'最有钱',rankingData:rankingMNY,type:'rankingMNY'}}"/>
<template is="ranking_item" data="{{title_name:'最聪明',rankingData:rankingINT,type:'rankingINT'}}"/>
<template is="ranking_item" data="{{title_name:'最漂亮',rankingData:rankingCHR,type:'rankingCHR'}}"/>
<template is="ranking_item" data="{{title_name:'最NB',rankingData:rankingSCO,type:'rankingSCO'}}"/>
<wux-white-space size="large" />
<wux-white-space size="large" />
<wux-button block
type="light" class="title2" bindtap="again">
再来一次
</wux-button>
</wux-wing-blank>
</view>

View File

@@ -0,0 +1,76 @@
/* miniprogram/pages/liferestart/index.wxss */
@import '../utils/wux/styles/index.wxss';
.container {
justify-content: center;
flex-direction: column;
align-items: center;
/* padding: 50rpx 100rpx; */
box-sizing: border-box;
background-color: #222831;
/* color: #fff; */
}
.checkbox {
position: static !important;
}
.title1 {
font-size: 82rpx;
color: white;
background-size: cover;
}
.title2 {
font-size: 42rpx;
color: white;
background-size: cover;
}
.rankingTable{
width: 100%;
position: relative;
border: 1px #ccc solid;
display: inline-block;
padding: 6px 6px 6px 6px;
font-size: 42rpx;
text-align: center;
border-radius: 0.2rem;
color: white;
}
.userinfo-avatar {
width: 70rpx;
height: 70rpx;
margin: 5rpx;
border-radius: 50%;
}
.main {
border-style: solid;
border: 1px #ccc solid;
border-width: 2px 2px;
border-radius: 0.2rem;
margin-top: 10px;
color: #fff;
}
.item {
margin-top: 10px;
font-size: 42rpx;
box-sizing: border-box;
display: flex;
padding: 0 10px;
border-bottom: 1px dashed #cecece;
color: white;
}
.index {
flex: 1;
color: #fff;
}
.desc {
flex: 4;
color: #fff;
}

View File

@@ -0,0 +1,27 @@
<template name="ranking_item">
<wux-white-space size="large" />
<view class="title2 wux-text--center">{{title_name}}</view>
<view class="rankingTable">
<block wx:for="{{rankingData}}" wx:key="*this">
<wux-row>
<wux-col span="2">
<view>
<image class="userinfo-avatar" src="{{item.avatar_url.length>0?item.avatar_url:j%2?'https://mmbiz.qpic.cn/mmbiz_png/G4dLFC4lBdRbLc31wbuQNFicqASrMdIK6zSRHzz0Q79EPfa5mDn2d8Jfu6lRI2kXe4o2y2UibR5P6ic97sNFeUAEQ/0?wx_fmt=png':'https://mmbiz.qpic.cn/mmbiz_png/G4dLFC4lBdRbLc31wbuQNFicqASrMdIK6aGmbKnmjDIxrROurLe5gop744hE2NUzR929XN3grVtl0ia0k2ISV1vg/0?wx_fmt=png'}}" />
</view>
</wux-col>
<wux-col span="7">
<view>{{item.nick_name}}</view>
</wux-col>
<wux-col span="3">
<view wx:if="{{type == 'rankingSPR'}}">{{item.recordSPR.value}} {{item.recordSPR.judge}}</view>
<view wx:if="{{type == 'rankingSTR'}}">{{item.recordSTR.value}} {{item.recordSTR.judge}}</view>
<view wx:if="{{type == 'rankingAGE'}}">{{item.recordAGE.value}} {{item.recordAGE.judge}}</view>
<view wx:if="{{type == 'rankingMNY'}}">{{item.recordMNY.value}} {{item.recordMNY.judge}}</view>
<view wx:if="{{type == 'rankingINT'}}">{{item.recordINT.value}} {{item.recordINT.judge}}</view>
<view wx:if="{{type == 'rankingCHR'}}">{{item.recordCHR.value}} {{item.recordCHR.judge}}</view>
<view wx:if="{{type == 'rankingSCO'}}">{{item.recordFinal.value}} {{item.recordFinal.judge}}</view>
</wux-col>
</wux-row>
</block>
</view>
</template>

View File

@@ -0,0 +1,75 @@
// miniprogram/pages/liferestart/summary.js
import {buildSummary,finalSummary} from "../utils/liferestart/data/dataUtils.js";
Page({
/**
* 页面的初始数据
*/
data: {
summaryCHR : {},
summaryINT : {},
summarySTR : {},
summaryMNY : {},
summaryFinal:{}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
this.initData()
},
initData() {
var nickName = "神秘人"
var avatarUrl = ""
wx.getUserInfo({
success: function(res) {
var userInfo = res.userInfo
nickName = userInfo.nickName
avatarUrl = userInfo.avatarUrl
}
})
const record = wx.getStorageSync('currentRecord')
const recordCHR = buildSummary(record, 'CHR')
const recordINT = buildSummary(record, 'INT');
const recordSTR = buildSummary(record, 'STR');
const recordMNY = buildSummary(record, 'MNY');
const recordSPR = buildSummary(record, 'SPR');
const recordAGE = buildSummary(record, 'AGE');
const recordFinal = finalSummary(record)
this.setData({
summaryCHR : recordCHR,
summaryINT : recordINT,
summarySTR : recordSTR,
summaryMNY : recordMNY,
summarySPR : recordSPR,
summaryAGE : recordAGE,
summaryFinal : recordFinal
})
console.log('initData',this.data.summaryFinal)
},
again(e) {
wx.redirectTo({
url: 'index'
})
},
onShareTimeline(e) {
return {
title: "人生重开模拟器",
imageUrl: "../../../images/liferestart_cover.jpg",
}
},
onShareAppMessage: function () {
return {
title: '人生重开模拟器',
imageUrl: '../../../images/liferestart_cover.jpg',
path: '/pages/index/index',
}
},
})

View File

@@ -0,0 +1,9 @@
{
"usingComponents": {
"wux-button": "/utils/wux/button/index",
"wux-row": "/utils/wux/row/index",
"wux-col": "/utils/wux/col/index",
"wux-wing-blank": "/utils/wux/wing-blank/index",
"wux-white-space": "/utils/wux/white-space/index"
}
}

View File

@@ -0,0 +1,70 @@
<view class="container">
<wux-white-space size="large" />
<wux-white-space size="large" />
<view class="title1 wux-text--center">人生总结</view>
<wux-white-space size="large" />
<wux-wing-blank size="large">
<wux-row>
<wux-col span="3">
<view class="userinfo-avatar">
<open-data type="userAvatarUrl"></open-data>
</view>
</wux-col>
<wux-col span="9">
<view class="userinfo-nickname">
<open-data type="userNickName"></open-data> 的来生
</view>
</wux-col>
</wux-row>
<view>
<wux-row>
<wux-col span="12">
<view class="lifeProperty grade{{summaryCHR.grade}}b">颜值:{{summaryCHR.value}} {{summaryCHR.judge}}</view>
</wux-col>
</wux-row>
<wux-row>
<wux-col span="12">
<view class="lifeProperty grade{{summaryINT.grade}}b">智力:{{summaryINT.value}} {{summaryINT.judge}}</view>
</wux-col>
</wux-row>
<wux-row>
<wux-col span="12">
<view class="lifeProperty grade{{summarySTR.grade}}b">体质:{{summarySTR.value}} {{summarySTR.judge}}</view>
</wux-col>
</wux-row>
<wux-row>
<wux-col span="12">
<view class="lifeProperty grade{{summaryMNY.grade}}b">家境:{{summaryMNY.value}} {{summaryMNY.judge}}</view>
</wux-col>
</wux-row>
<wux-row>
<wux-col span="12">
<view class="lifeProperty grade{{summarySPR.grade}}b">快乐:{{summarySPR.value}} {{summarySPR.judge}}</view>
</wux-col>
</wux-row>
<wux-row class="">
<wux-col span="12">
<view class="lifeProperty grade{{summaryAGE.grade}}b">享年:{{summaryAGE.value}} {{summaryAGE.judge}}</view>
</wux-col>
</wux-row>
<wux-row class="">
<wux-col span="12">
<view class="lifeProperty grade{{summaryFinal.grade}}b">总评:{{summaryFinal.value}} {{summaryFinal.judge}}</view>
</wux-col>
</wux-row>
</view>
<wux-white-space size="large" />
<wux-white-space size="large" />
<view class="qcode-view">
<image class="qcode" src="../assets/images/app_qcode.jpg" />
</view>
<wux-white-space size="large" />
<wux-white-space size="large" />
<wux-button block
type="light" class="title2" bindtap="again">
再来一次
</wux-button>
</wux-wing-blank>
</view>

View File

@@ -0,0 +1,94 @@
/* miniprogram/pages/liferestart/index.wxss */
@import '../utils/wux/styles/index.wxss';
.container {
justify-content: center;
flex-direction: column;
align-items: center;
/* padding: 50rpx 100rpx; */
box-sizing: border-box;
background-color: #222831;
/* color: #fff; */
}
.checkbox {
position: static !important;
}
.title1 {
font-size: 82rpx;
color: white;
background-size: cover;
}
.title2 {
font-size: 42rpx;
color: white;
background-size: cover;
}
.main {
border-style: solid;
border: 1px #ccc solid;
border-width: 2px 2px;
border-radius: 0.2rem;
margin-top: 10px;
color: #fff;
}
.lifeProperty{
width: 100%;
position: relative;
display: inline-block;
margin: 0.1rem 2px;
font-size: 38rpx;
text-align: center;
border-radius: 0.2rem;
color: white;
border-bottom: 1px dashed #cecece;
}
.grade0b {
background-color: #464646;
border: #f8f8f8 2px solid !important;
}
.grade1b {
background-color: #6495ed;
border: #f8f8f8 2px solid !important;
}
.grade2b {
background-color: #e2a7ff;
border: #f8f8f8 2px solid !important;
}
.grade3b {
background-color: #ffa07a;
border: #f8f8f8 2px solid !important;
}
.qcode-view {
display:flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.qcode {
width: 300rpx;
height: 300rpx;
border-radius: 50%;
}
.userinfo-avatar {
width: 160rpx;
height: 150rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
font-size: 42rpx;
color: white;
text-align: center;
background-size: cover;
}

View File

@@ -0,0 +1,202 @@
// miniprogram/pages/liferestart/talents.js
// 颜值 charm CHR
// 智力 intelligence INT
// 体质 strength STR
// 家境 money MNY
// 快乐 spirit SPR
// 生命 life LIF
// 天赋 talent TLT
// 事件 event EVT
import {
$wuxToptips
} from '../utils/wux/index';
import {randomTalents,computeTalentsStatus, computeUseableProp, randomProp} from '../utils/liferestart/data/dataUtils.js';
Page({
/**
* 页面的初始数据
*/
data: {
talentsArray: [],
selectedTalentsID:[],
selectedTalents:[],
showSelectTalents: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function () {
// console.log('telents page onLoad')
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
this.clearStorage()
this.loadTalents()
},
clearStorage: function() {
this.setData({
talentsArray: [],
selectedTalentsID: [],
selectedTalents: []
})
wx.removeStorageSync('selectedTalentsID')
wx.removeStorageSync('selectedTalents')
wx.removeStorageSync('propertyCHR')
wx.removeStorageSync('propertyINT')
wx.removeStorageSync('propertySTR')
wx.removeStorageSync('propertyMNY')
wx.removeStorageSync('currentRecord')
wx.removeStorageSync('trajectory')
},
loadTalents: function() {
const showTalents = randomTalents(10)
// console.log('telents page loadTalents', showTalents)
this.setData({
talentsArray: showTalents
})
},
onSelectTalents(e) {
// console.log('onSelectTalents e',e)
const selectedIndex = e.detail.selectedIndex
const selectedValue = e.detail.selectedValue
if (selectedValue.length > 3) {
$wuxToptips().error({
hidden: false,
text: '只能选三个天赋',
duration: 5000,
success() {},
})
// e.detail.selectedValue.pop()
e.detail.selectedIndex.pop()
}// else {
const tData = this.data
tData.talentsArray.forEach((item) => {
item.disabled = false
});
tData.selectedTalents = []
// console.log('selectedIndex',selectedValue)
if (selectedValue.length == 3) {
tData.talentsArray.forEach(function(item, idx) {
// console.log('item',item._id,(selectedValue.includes(item._id)))
if (selectedValue.includes(item._id)) {
item.disabled = false
} else {
// console.log('item2',idx,item.inputChecked)
item.disabled = true
}
})
}
selectedIndex.forEach(function (item, idx) {
// for (var i = 0; i < selectedIndex.length; i++) {
const currentTalents = tData.talentsArray[item]
// console.log('currentTalents=',idx,currentTalents)
tData.selectedTalents.push(currentTalents)
if ('exclusive' in currentTalents) {
const currexc = currentTalents.exclusive
// console.log('currexc',currexc.length)
currexc.forEach(function (itemexc, idxexc) {
// console.log('currexc',itemexc)
tData.talentsArray.forEach(function(itemTal, idxTal) {
if (itemTal._id == itemexc) {
// console.log('itemTal',itemTal)
itemTal.disabled = itemTal._id == itemexc
}
})
})
}
})
this.setData({
talentsArray: tData.talentsArray,
selectedTalentsID: e.detail.selectedValue,
selectedTalents: tData.selectedTalents
})
wx.setStorage({
key: 'selectedTalentsID',
data: this.data.selectedTalentsID
})
wx.setStorage({
key: 'selectedTalents',
data: tData.selectedTalents
})
// console.log('checkbox发生change事件携带value值为', this.data.selectedTalents)
// }
},
showTalents(e) {
this.setData({
showSelectTalents: true
})
},
randomLife(e) {
const selectedTalents = randomTalents(3)
const selectedTalentsID = selectedTalents.map(function(item) {
return item._id
});
const status = computeTalentsStatus(selectedTalents)
// console.log('status', status)
const proNum = computeUseableProp(20, status)
const arr = randomProp(proNum, [10,10,10,10])
console.log('selectedTalentsID', selectedTalentsID, proNum, arr)
wx.setStorage({
key: 'selectedTalentsID',
data: selectedTalentsID
})
wx.setStorage({
key: 'selectedTalents',
data: selectedTalents
})
wx.setStorage({
key: 'propertyCHR',
data: arr[0]
})
wx.setStorage({
key: 'propertyINT',
data: arr[1]
})
wx.setStorage({
key: 'propertySTR',
data: arr[2]
})
wx.setStorage({
key: 'propertyMNY',
data: arr[3]
})
wx.redirectTo({
url: 'trajectory'
})
},
toProperty(e) {
if (this.data.selectedTalents.length < 3) {
$wuxToptips().error({
hidden: false,
text: '请选择三个天赋',
duration: 5000,
success() {},
})
} else {
wx.redirectTo({
url: 'property'
})
}
},
onShareTimeline(e) {
return {
title: "人生重开模拟器",
imageUrl: "../../../images/liferestart_cover.jpg",
}
},
onShareAppMessage: function () {
return {
title: '人生重开模拟器',
imageUrl: '../../../images/liferestart_cover.jpg',
path: '/pages/index/index',
}
},
})

View File

@@ -0,0 +1,13 @@
{
"usingComponents": {
"wux-toptips": "/utils/wux/toptips/index",
"wux-checkbox-group": "/utils/wux/checkbox-group/index",
"wux-checkbox": "/utils/wux/checkbox/index",
"wux-cell-group": "/utils/wux/cell-group/index",
"wux-cell": "/utils/wux/cell/index",
"wux-icon": "/utils/wux/icon/index",
"wux-button": "/utils/wux/button/index",
"wux-wing-blank": "/utils/wux/wing-blank/index",
"wux-white-space": "/utils/wux/white-space/index"
}
}

View File

@@ -0,0 +1,42 @@
<!--miniprogram/pages/liferestart/talents.wxml-->
<wux-toptips id="wux-toptips" />
<view class="container">
<wux-white-space size="large" />
<wux-white-space size="large" />
<view class="title1 wux-text--center">天赋抽卡</view>
<wux-white-space size="large" />
<wux-white-space size="large" />
<wux-wing-blank size="large" wx:if="{{showSelectTalents}}">
<scroll-view style="height:100%;width:100%;display: flex;flex-direction: column;" scroll-y="true">
<wux-checkbox-group name="talentsList"
value="{{ selectedTalentsID }}"
bind:change="onSelectTalents">
<block wx:for="{{talentsArray}}" wx:key="*this">
<wux-checkbox class="grade{{item.grade}}b"
title="{{item.name}} ({{item.description}})"
value="{{item._id}}" disabled="{{item.disabled?true:false}}"/>
</block>
</wux-checkbox-group>
</scroll-view>
<wux-white-space size="large" />
<wux-button block bindtap="toProperty" type="light" class="title2">
请选择3个
</wux-button>
</wux-wing-blank>
<wux-wing-blank size="large" wx:if="{{!showSelectTalents}}">
<wux-white-space size="large" />
<wux-white-space size="large" />
<wux-white-space size="large" />
<wux-white-space size="large" />
<view class="btn-view">
<view bindtap="randomLife" class="btn">
<view class="btn-text">盲盒人生</view>
</view>
<wux-white-space size="large" />
<wux-white-space size="large" />
<view bindtap="showTalents" class="btn">
<view class="btn-text">十连抽</view>
</view>
</view>
</wux-wing-blank>
</view>

View File

@@ -0,0 +1,87 @@
/* miniprogram/pages/liferestart/index.wxss */
@import '../utils/wux/styles/index.wxss';
.container {
justify-content: center;
flex-direction: column;
align-items: center;
/* padding: 50rpx 100rpx; */
box-sizing: border-box;
background-color: #222831;
/* color: #fff; */
}
.checkbox {
position: static !important;
}
.title1 {
font-size: 82rpx;
color: white;
background-size: cover;
}
.title2 {
font-size: 42rpx;
color: white;
background-size: cover;
}
.main {
border-style: solid;
border: 1px #ccc solid;
border-width: 2px 2px;
border-radius: 0.2rem;
margin-top: 10px;
color: #fff;
}
.item {
font-size: 32rpx;
box-sizing: border-box;
display: flex;
align-items: center;
padding: 0 10px;
}
.btn-view {
display:flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.btn {
width: 400rpx;
height: 400rpx;
background-image: -webkit-radial-gradient(45px 45px, circle cover, #99CC33, #003366);
animation-name: spin;
animation-duration: 3s; /* 3 seconds */
animation-iteration-count: infinite;
animation-timing-function: linear;
border-radius: 50%;
}
.btn-text {
width: 400rpx;
height: 400rpx;
text-align: center;
font-size: 82rpx;
line-height: 400rpx;
color: white;
}
.grade0b {
background-color: #464646;
/* border: #f8f8f8 2px solid !important; */
}
.grade1b {
background-color: #6495ed;
/* border: #f8f8f8 2px solid !important; */
}
.grade2b {
background-color: #e2a7ff;
/* border: #f8f8f8 2px solid !important; */
}
.grade3b {
background-color: #ffa07a;
/* border: #f8f8f8 2px solid !important; */
}

View File

@@ -0,0 +1,106 @@
// miniprogram/pages/liferestart/trajectory.js
import Life from "../utils/liferestart/life";
import Property from "../utils/liferestart/property";
import {allAge} from "../utils/liferestart/data/dataUtils.js";
Page({
/**
* 页面的初始数据
*/
data: {
propertyCHR : 0,
propertyINT : 0,
propertySTR : 0,
propertyMNY : 0,
selectedTalentsID : [],
isEnd : false,
items : []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.initialData()
},
initialData() {
const tData = this.data
const _this = this
const propertyCHR = wx.getStorageSync('propertyCHR')
const propertyINT = wx.getStorageSync('propertyINT')
const propertySTR = wx.getStorageSync('propertySTR')
const propertyMNY = wx.getStorageSync('propertyMNY')
const selectedTalentsID = wx.getStorageSync('selectedTalentsID')
this.property = new Property(this);
this.life = new Life(this)
this.life.initial()
this.life.restart({
CHR: propertyCHR,
INT: propertyINT,
STR: propertySTR,
MNY: propertyMNY,
SPR: 5,
TLT: selectedTalentsID,
});
var trajectory = this.life.next()
wx.setStorage({
key: 'currentRecord',
data: this.life.getRecord()
})
const { age, content, isEnd } = trajectory
tData.items.push(trajectory)
const newprop = this.life.getLastRecord()
_this.setData({
items : tData.items,
selectedTalentsID : selectedTalentsID,
propertyCHR : newprop.CHR,
propertyINT : newprop.INT,
propertySTR : newprop.STR,
propertyMNY : newprop.MNY,
scrollTopVal: 0,
isEnd: isEnd,
pageHeight: wx.getSystemInfoSync().windowHeight - (isEnd?200:150),
})
},
nextAge(e) {
const tData = this.data
// console.log('trajectorypage nextAge')
if (!tData.isEnd) {
const _this = this
var trajectory = this.life.next()
const { age, content, isEnd } = trajectory
tData.items.push(trajectory)
const newprop = this.life.getLastRecord()
_this.setData({
items : tData.items,
propertyCHR : newprop.CHR,
propertyINT : newprop.INT,
propertySTR : newprop.STR,
propertyMNY : newprop.MNY,
scrollTopVal: tData.items.length * 999,
isEnd: isEnd,
pageHeight: wx.getSystemInfoSync().windowHeight - (isEnd?200:150),
})
}
},
toSummary(e) {
wx.setStorage({
key: 'currentRecord',
data: this.life.getRecord()
})
wx.setStorage({
key: 'trajectory',
data: this.data.items
})
wx.redirectTo({
url: 'summary'
})
},
})

View File

@@ -0,0 +1,10 @@
{
"usingComponents": {
"wux-divider": "/utils/wux/divider/index",
"wux-button": "/utils/wux/button/index",
"wux-row": "/utils/wux/row/index",
"wux-col": "/utils/wux/col/index",
"wux-wing-blank": "/utils/wux/wing-blank/index",
"wux-white-space": "/utils/wux/white-space/index"
}
}

View File

@@ -0,0 +1,61 @@
<!--miniprogram/pages/liferestart/talents.wxml-->
<view class="container">
<wux-white-space size="large" />
<wux-white-space size="large" />
<wux-wing-blank size="large">
<wux-row>
<wux-col span="4">
<view class="lifeProperty">颜值:{{propertyCHR}}</view>
</wux-col>
<wux-col span="4">
<view class="lifeProperty">智力:{{propertyINT}}</view>
</wux-col>
<wux-col span="4">
<view class="lifeProperty">体质:{{propertySTR}}</view>
</wux-col>
</wux-row>
<wux-row>
<wux-col span="6">
<view class="lifeProperty">家境:{{propertyMNY}}</view>
</wux-col>
<wux-col span="6">
<view class="lifeProperty">快乐:{{propertyMNY}}</view>
</wux-col>
</wux-row>
<view class="main"
bindtap="nextAge">
<wux-wing-blank size="large">
<scroll-view style="height:{{pageHeight}}px;width: 100%;display: flex;flex-direction: column;margin-top: 54rpx;" scroll-y="true" scroll-top="{{scrollTopVal}}" bindtap="resetInputStatus">
<block wx:for="{{items}}" wx:key="index">
<wux-row>
<wux-col span="2">
{{ item.age }}岁:
</wux-col>
<wux-col span="10">
<block wx:for="{{item.content}}" wx:for-item="itemContent" wx:key="index">
<wux-row wx:if="{{itemContent.type == 'TLT'}}">
<wux-col span="12">
<view>天赋【{{itemContent.name}}】发动:{{itemContent.description}}</view>
</wux-col>
</wux-row>
<wux-row wx:if="{{itemContent.type == 'EVT'}}">
<wux-col span="12">
<view>
{{itemContent.description}} \r\n{{itemContent.postEvent}}</view>
</wux-col>
</wux-row>
</block>
</wux-col>
</wux-row>
<wux-divider show-text="{{ false }}" dashed />
</block>
</scroll-view>
</wux-wing-blank>
</view>
<wux-button block wx:if="{{isEnd}}"
type="light" class="title2" bindtap="toSummary">
人生总结
</wux-button>
</wux-wing-blank>
</view>

View File

@@ -0,0 +1,71 @@
/* miniprogram/pages/liferestart/index.wxss */
@import '../utils/wux/styles/index.wxss';
.container {
justify-content: center;
flex-direction: column;
align-items: center;
/* padding: 50rpx 100rpx; */
box-sizing: border-box;
background-color: #222831;
/* color: #fff; */
}
.checkbox {
position: static !important;
}
.title1 {
font-size: 82rpx;
color: white;
background-size: cover;
}
.title2 {
font-size: 42rpx;
color: white;
background-size: cover;
}
.lifeProperty{
width: 100%;
position: relative;
border: 1px #ccc solid;
display: inline-block;
margin: 0.1rem 2px;
font-size: 1rem;
text-align: center;
border-radius: 0.2rem;
color: white;
}
.main {
border-style: solid;
border: 1px #ccc solid;
border-width: 2px 2px;
border-radius: 0.2rem;
margin-top: 10px;
color: #fff;
}
.item {
margin-top: 10px;
font-size: 42rpx;
box-sizing: border-box;
display: flex;
padding: 0 10px;
border-bottom: 1px dashed #cecece;
color: white;
}
.index {
flex: 1;
color: #fff;
}
.desc {
flex: 4;
color: #fff;
}

View File

@@ -0,0 +1,68 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"bundle": false,
"userConfirmedBundleSwitch": false,
"urlCheck": true,
"scopeDataCheck": false,
"coverView": true,
"es6": true,
"postcss": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"preloadBackgroundData": false,
"minified": true,
"autoAudits": false,
"newFeature": false,
"uglifyFileName": false,
"uploadWithSourceMap": true,
"useIsolateContext": true,
"nodeModules": false,
"enhance": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": false,
"showShadowRootInWxmlPanel": true,
"packNpmManually": false,
"enableEngineNative": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"showES6CompileOption": false
},
"compileType": "miniprogram",
"libVersion": "2.19.4",
"appid": "wx88fe4c0115ad33dd",
"projectname": "liferestart",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"staticServerOptions": {
"baseURL": "",
"servePath": ""
},
"isGameTourist": false,
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"list": []
},
"plugin": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": []
}
}
}

View File

@@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}

View File

@@ -0,0 +1,144 @@
page {
background: #f6f6f6;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
.list {
margin-top: 40rpx;
height: auto;
width: 100%;
background: #fff;
padding: 0 40rpx;
border: 1px solid rgba(0, 0, 0, 0.1);
border-left: none;
border-right: none;
transition: all 300ms ease;
display: flex;
flex-direction: column;
align-items: stretch;
box-sizing: border-box;
}
.list-item {
width: 100%;
padding: 0;
line-height: 104rpx;
font-size: 34rpx;
color: #007aff;
border-top: 1px solid rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: row;
align-content: center;
justify-content: space-between;
box-sizing: border-box;
}
.list-item:first-child {
border-top: none;
}
.list-item image {
max-width: 100%;
max-height: 20vh;
margin: 20rpx 0;
}
.request-text {
color: #222;
padding: 20rpx 0;
font-size: 24rpx;
line-height: 36rpx;
word-break: break-all;
}
.guide {
width: 100%;
padding: 40rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
}
.guide .headline {
font-size: 34rpx;
font-weight: bold;
color: #555;
line-height: 40rpx;
}
.guide .p {
margin-top: 20rpx;
font-size: 28rpx;
line-height: 36rpx;
color: #666;
}
.guide .code {
margin-top: 20rpx;
font-size: 28rpx;
line-height: 36rpx;
color: #666;
background: white;
white-space: pre;
}
.guide .code-dark {
margin-top: 20rpx;
background: rgba(0, 0, 0, 0.8);
padding: 20rpx;
font-size: 28rpx;
line-height: 36rpx;
border-radius: 6rpx;
color: #fff;
white-space: pre
}
.guide image {
max-width: 100%;
}
.guide .image1 {
margin-top: 20rpx;
max-width: 100%;
width: 356px;
height: 47px;
}
.guide .image2 {
margin-top: 20rpx;
width: 264px;
height: 100px;
}
.guide .flat-image {
height: 100px;
}
.guide .code-image {
max-width: 100%;
}
.guide .copyBtn {
width: 180rpx;
font-size: 20rpx;
margin-top: 16rpx;
margin-left: 0;
}
.guide .nav {
margin-top: 50rpx;
display: flex;
flex-direction: row;
align-content: space-between;
}
.guide .nav .prev {
margin-left: unset;
}
.guide .nav .next {
margin-right: unset;
}

BIN
liferestartWX/utils/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View 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 };

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View 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;

View 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 };

View 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 };

View 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 };

View 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;

View 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;

View 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

Binary file not shown.

View 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))}}});

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"wux-popup": "../popup/index"
}
}

View 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>

View 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}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
{
"component": true
}

View 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>

View 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)}

View 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")}}});

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"wux-animation-group": "../animation-group/index"
}
}

View File

@@ -0,0 +1 @@
<wux-animation-group wux-class="{{ classes.wrap }}" in="{{ in }}" classNames="{{ classNames }}" bind:click="onClick" wrapStyle="{{ { zIndex } }}" disableScroll />

View 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}

View 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)}}});

View File

@@ -0,0 +1,3 @@
{
"component": true
}

View 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>

File diff suppressed because one or more lines are too long

View 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})}}});

View File

@@ -0,0 +1,3 @@
{
"component": true
}

View 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>

View 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}

View 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)
},
})

View File

@@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"wux-popup": "../popup/index",
"wux-icon": "../icon/index",
"wux-button": "../button/index"
}
}

View 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>

View 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
}

View 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()}}});

View File

@@ -0,0 +1,3 @@
{
"component": true
}

View 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>

View 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)}

View 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})}}});

View File

@@ -0,0 +1,3 @@
{
"component": true
}

View 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>

View 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}

View 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)
},
},
})

View File

@@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"wux-cell-group": "../cell-group/index",
"wux-checkbox": "../checkbox/index"
}
}

View 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>

View 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,
})
},
},
})

View File

@@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"wux-cell": "../cell/index",
"wux-selectable": "../selectable/index"
}
}

Some files were not shown because too many files have changed in this diff Show More