3 Commits

Author SHA1 Message Date
uiiang
6a43a25a9b Merge 5ba4fbb383 into 2eadb6fb23 2024-07-31 19:42:08 +08:00
uiiang
5ba4fbb383 readme 2021-09-08 16:11:09 +08:00
uiiang
1c29c3a737 增加微信小程序版 2021-09-08 16:04:03 +08:00
307 changed files with 195481 additions and 2342 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,11 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

View File

@@ -1,29 +0,0 @@
name: Build and Deploy
on:
push:
branches: [main]
permissions:
contents: write
jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
run: |
pnpm install
pnpm xlsx2json
pnpm build
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: template # The folder the action should deploy.

31
.github/workflows/node.js.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npm run build --if-present
- run: npm test

5
.gitignore vendored
View File

@@ -107,7 +107,4 @@ utils/xlsxTransform-*
/.idea
__localStorage.json
template/public
public/data
__localStorage.json

3
.jshintrc Normal file
View File

@@ -0,0 +1,3 @@
{
"esversion": 9
}

29
.vscode/launch.json vendored
View File

@@ -4,15 +4,40 @@
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome",
"request": "launch",
"type": "pwa-chrome",
"url": "http://127.0.0.1:8000/public/index.html",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "test",
"program": "${workspaceFolder}/test",
"skipFiles": [
"<node_internals>/**",
"**/node_modumes/**"
"<node_internals>/**"
]
},
{
"type": "node",
"request": "launch",
"name": "xlsx2json",
"program": "${workspaceFolder}/node_modules/v-transform/src/index.js",
"args": ["transform", "jobs/xlsx2json/config.json"],
"skipFiles": [
"<node_internals>/**"
]
},
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
]
}

5
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"cSpell.words": [
"Laya"
]
}

1
CNAME Normal file
View File

@@ -0,0 +1 @@
liferestart.syaro.io

View File

@@ -14,22 +14,38 @@
<summary><strong>网页版</strong></summary>
<br />
1. 下载项目代码。
```bash
# 1. 下载项目代码
git clone https://github.com/VickScarlet/lifeRestart.git my-project
# 2. 进入目录安装依赖
cd my-project
pnpm install
# 3. 转换XLSX表
pnpm xlsx2json
# 4. 启动本地开发服务器
pnpm dev
```
启动完成后打开浏览器访问 [http://localhost:5173](http://localhost:5173)
2. 进入目录安装依赖
```bash
yarn install
```
或者
```bash
npm install
```
3. 启动本地服务器。
```bash
yarn dev
```
或者
```bash
npm run dev
```
4. 启动完成后会自动打开浏览器访问 [http://localhost:8081/view/index.html](http://localhost:8081/view/index.html)。
</details>

View File

@@ -14,23 +14,38 @@ English | [简体中文](./README-zh_CN.md)
<summary><strong>Web Version</strong></summary>
<br />
1. Clone project code.
```bash
# 1. Clone project code.
git clone git@github.com:VickScarlet/lifeRestart.git my-project
cd my-project
# 2. Installation dependence.
pnpm install
# 3. Transform XLSX
pnpm xlsx2json
# 4. Start local dev server.
pnpm dev
```
After the startup is complete, open a browser and visit [http://localhost:5173](http://localhost:5173).
2. Installation dependence.
```bash
yarn install
```
Or
```bash
npm install
```
3. Start local server.
```bash
yarn dev
```
Or
```bash
npm run dev
```
4. After the startup is complete, will automatically open a browser and visit [http://localhost:8081/view/index.html](http://localhost:8081/view/index.html).
</details>
<details>

View File

@@ -2,7 +2,10 @@
<html lang="{{ site.lang | default: "en-US" }}">
<head>
<meta charset="UTF-8">
<script data-ad-client="ca-pub-9857163863537600" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
{% seo %}
<link rel="preconnect" href="https://fonts.gstatic.com">
<link rel="preload" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap" as="style" type="text/css" crossorigin>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#157878">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
@@ -15,7 +18,8 @@
<header class="page-header" role="banner">
<h1 class="project-name">{{ page.title | default: site.title | default: site.github.repository_name }}</h1>
<h2 class="project-tagline">{{ page.description | default: site.description | default: site.github.project_tagline }}</h2>
<a href="/public/" class="btn">RESTART</a>
<a href="/view/" class="btn">RESTART</a>
<a href="/view/test.html" class="btn">Source Version</a>
{% if site.github.is_project_page %}
<a href="{{ site.github.repository_url }}" class="btn">View on GitHub</a>
{% endif %}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,10 +1,12 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=759670
// for the documentation about the jsconfig.json format
"compilerOptions": {
"module": "esnext",
"target": "es6",
},
"include":["src", "repl", "vite.config.js"],
"exclude": ["node_modules", "public", "view"]
// See http://go.microsoft.com/fwlink/?LinkId=759670
// for the documentation about the jsconfig.json format
"compilerOptions": {
"target": "es5"
},
"exclude": [
"node_modules",
"public",
"view"
]
}

View File

@@ -1,8 +1,8 @@
{
"x":0,
"type":"View",
"selectedBox":93,
"selecteID":94,
"selectedBox":1,
"selecteID":12,
"props":{"y":1218,"x":562,"width":1125,"sceneColor":"#000000","sceneBg":"laya/views/view/CyberTheme/CyberMain.png","runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5},
"nodeParent":-1,
"label":"View",
@@ -548,13 +548,14 @@
"props":{"width":1,"left":0,"height":1,"bottom":0},
"nodeParent":1,
"label":"Box",
"isOpen":false,
"isOpen":true,
"isDirectory":true,
"isAniNode":true,
"hasChild":true,
"compId":85,
"child":[
{
"x":30,
"type":"Box",
"props":{"y":-175,"x":100,"width":160,"var":"btnGithub","runtime":"Laya.runtime.ScaleButton","name":"btnGithub","height":160,"anchorY":0.5,"anchorX":0.5},
"nodeParent":85,
@@ -579,6 +580,7 @@
}]
},
{
"x":30,
"type":"Box",
"props":{"y":-355,"x":100,"width":160,"var":"btnDiscord","runtime":"Laya.runtime.ScaleButton","name":"btnDiscord","height":160,"anchorY":0.5,"anchorX":0.5},
"nodeParent":85,
@@ -609,13 +611,14 @@
"props":{"right":0,"bottom":0},
"nodeParent":1,
"label":"Box",
"isOpen":false,
"isOpen":true,
"isDirectory":true,
"isAniNode":true,
"hasChild":true,
"compId":88,
"child":[
{
"x":30,
"type":"Box",
"props":{"y":-300,"x":-100,"width":110,"runtime":"Laya.runtime.ScaleButton","height":110,"anchorY":0.5,"anchorX":0.5},
"nodeParent":88,
@@ -627,6 +630,7 @@
"compId":90,
"child":[
{
"x":45,
"type":"Box",
"props":{"width":110,"var":"btnSaveLoad","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","height":110,"centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5},
"nodeParent":90,
@@ -638,6 +642,7 @@
"compId":91,
"child":[
{
"x":60,
"type":"Image",
"props":{"width":80,"skin":"images/icons/icon_save.png","height":80,"centerY":0,"centerX":0},
"nodeParent":91,
@@ -652,6 +657,7 @@
}]
},
{
"x":30,
"type":"Box",
"props":{"y":-175,"x":-100,"width":110,"runtime":"Laya.runtime.ScaleButton","height":110,"anchorY":0.5,"anchorX":0.5},
"nodeParent":88,
@@ -663,6 +669,7 @@
"compId":89,
"child":[
{
"x":45,
"type":"Box",
"props":{"width":110,"var":"btnThemes","runtime":"Laya.runtime.ColorfulBox","name":"btnThemes","height":110,"centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5},
"nodeParent":89,
@@ -687,32 +694,6 @@
}]
}]
}]
},
{
"x":15,
"type":"Box",
"props":{"x":572,"var":"banner","centerX":0,"bottom":100,"anchorY":1,"anchorX":0.5},
"nodeParent":1,
"label":"Box(banner)",
"isOpen":true,
"isDirectory":true,
"isAniNode":true,
"hasChild":true,
"compId":93,
"child":[
{
"x":30,
"type":"Label",
"props":{"text":"UI_Banner","fontSize":40,"font":"方正像素12","color":"#00fffd"},
"nodeParent":93,
"label":"Label",
"isDirectory":false,
"isAniNode":true,
"hasChild":false,
"compId":94,
"child":[
]
}]
}],
"animations":[
{

View File

@@ -1,8 +1,8 @@
{
"x":0,
"type":"View",
"selectedBox":101,
"selecteID":102,
"selectedBox":99,
"selecteID":100,
"props":{"y":1218,"x":562,"width":1125,"sceneColor":"#000000","runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5},
"nodeParent":-1,
"label":"View",
@@ -276,32 +276,6 @@
"child":[
]
}]
},
{
"x":15,
"type":"Box",
"props":{"x":562,"var":"banner","centerX":0,"bottom":100,"anchorY":1,"anchorX":0.5},
"nodeParent":1,
"label":"Box(banner)",
"isOpen":true,
"isDirectory":true,
"isAniNode":true,
"hasChild":true,
"compId":101,
"child":[
{
"x":30,
"type":"Label",
"props":{"text":"UI_Banner","name":"title","fontSize":40,"font":"SimHei","color":"#ffffff"},
"nodeParent":101,
"label":"Label(title)",
"isDirectory":false,
"isAniNode":true,
"hasChild":false,
"compId":102,
"child":[
]
}]
}],
"animations":[
{

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
}

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