mini-form-render 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.editorconfig +9 -0
- package/.eslintrc.js +15 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/babel.config.json +34 -0
- package/jsconfig.json +19 -0
- package/package.json +43 -0
- package/postcss.config.js +5 -0
- package/src/app.mpx +26 -0
- package/src/components/basic-input.mpx +35 -0
- package/src/components/basic-picker.mpx +75 -0
- package/src/components/form.mpx +135 -0
- package/src/components/list.mpx +23 -0
- package/src/image/caret-right.svg +3 -0
- package/src/pages/form-render.mpx +47 -0
- package/src/pages/index.mpx +48 -0
- package/src/pages/server-scheme.mpx +75 -0
- package/src/test/scheme1.js +22 -0
- package/src/test/server-relation-scheme.js +33 -0
- package/static/ali/mini.project.json +4 -0
- package/static/dd/project.config.json +15 -0
- package/static/swan/project.swan.json +14 -0
- package/static/tt/project.config.json +11 -0
- package/static/wx/project.config.json +62 -0
- package/vue.config.js +16 -0
package/.editorconfig
ADDED
package/.eslintrc.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module.exports = {
|
2
|
+
extends: ['@mpxjs'],
|
3
|
+
rules: {
|
4
|
+
// .mpx文件规则 https://mpx-ecology.github.io/eslint-plugin-mpx/rules/
|
5
|
+
'mpx/valid-wx-model': 0
|
6
|
+
},
|
7
|
+
overrides: [
|
8
|
+
{
|
9
|
+
files: ['**/*.js'],
|
10
|
+
rules: {
|
11
|
+
// .js文件规则 https://eslint.bootcss.com/docs/rules/
|
12
|
+
}
|
13
|
+
}
|
14
|
+
]
|
15
|
+
}
|
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 Huanyu Li
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"presets": [
|
3
|
+
[
|
4
|
+
"@babel/preset-env",
|
5
|
+
{
|
6
|
+
"modules": false,
|
7
|
+
"shippedProposals": true
|
8
|
+
}
|
9
|
+
]
|
10
|
+
],
|
11
|
+
"plugins": [
|
12
|
+
[
|
13
|
+
"@babel/transform-runtime",
|
14
|
+
{
|
15
|
+
"corejs": 3,
|
16
|
+
"version": "^7.10.4"
|
17
|
+
}
|
18
|
+
],
|
19
|
+
"@mpxjs/babel-plugin-inject-page-events"
|
20
|
+
],
|
21
|
+
"sourceType": "unambiguous",
|
22
|
+
"env": {
|
23
|
+
"test": {
|
24
|
+
"presets": [
|
25
|
+
[
|
26
|
+
"@babel/env",
|
27
|
+
{
|
28
|
+
"shippedProposals": true
|
29
|
+
}
|
30
|
+
]
|
31
|
+
]
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
package/jsconfig.json
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "es5",
|
4
|
+
"module": "esnext",
|
5
|
+
"baseUrl": "./",
|
6
|
+
"moduleResolution": "node",
|
7
|
+
"paths": {
|
8
|
+
"@/*": [
|
9
|
+
"src/*"
|
10
|
+
]
|
11
|
+
},
|
12
|
+
"lib": [
|
13
|
+
"esnext",
|
14
|
+
"dom",
|
15
|
+
"dom.iterable",
|
16
|
+
"scripthost"
|
17
|
+
]
|
18
|
+
}
|
19
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"name": "mini-form-render",
|
3
|
+
"version": "0.0.3",
|
4
|
+
"private": false,
|
5
|
+
"scripts": {
|
6
|
+
"serve": "mpx-cli-service serve:mp",
|
7
|
+
"build": "mpx-cli-service build:mp",
|
8
|
+
"lint": "eslint --ext .js,.ts,.mpx src/"
|
9
|
+
},
|
10
|
+
"dependencies": {
|
11
|
+
"@mpxjs/api-proxy": "^2.8.0",
|
12
|
+
"@mpxjs/core": "^2.8.0",
|
13
|
+
"@mpxjs/fetch": "^2.8.0",
|
14
|
+
"@mpxjs/pinia": "^2.8.0",
|
15
|
+
"@mpxjs/store": "^2.8.0",
|
16
|
+
"@mpxjs/utils": "^2.8.0",
|
17
|
+
"pinia": "^2.0.14",
|
18
|
+
"vue": "^2.6.14"
|
19
|
+
},
|
20
|
+
"devDependencies": {
|
21
|
+
"@babel/core": "^7.10.4",
|
22
|
+
"@babel/plugin-transform-runtime": "^7.10.4",
|
23
|
+
"@babel/preset-env": "^7.10.4",
|
24
|
+
"@babel/runtime-corejs3": "^7.10.4",
|
25
|
+
"@mpxjs/babel-plugin-inject-page-events": "^2.8.0",
|
26
|
+
"@mpxjs/eslint-config": "^1.0.5",
|
27
|
+
"@mpxjs/mpx-cli-service": "^1.0.0",
|
28
|
+
"@mpxjs/size-report": "^2.8.0",
|
29
|
+
"@mpxjs/vue-cli-plugin-mpx": "^1.0.0",
|
30
|
+
"@mpxjs/vue-cli-plugin-mpx-eslint": "^1.0.0",
|
31
|
+
"@mpxjs/vue-cli-plugin-mpx-mp": "^1.0.0",
|
32
|
+
"@vue/cli-service": "~5.0.0",
|
33
|
+
"autoprefixer": "*",
|
34
|
+
"eslint": "^7.0.0",
|
35
|
+
"stylus": "^0.55.0",
|
36
|
+
"stylus-loader": "^6.1.0",
|
37
|
+
"vue-template-compiler": "^2.6.14"
|
38
|
+
},
|
39
|
+
"publishConfig": {
|
40
|
+
"registry": "https://registry.npmjs.org"
|
41
|
+
},
|
42
|
+
"browserslist": "ios >= 9, chrome >= 47"
|
43
|
+
}
|
package/src/app.mpx
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<script>
|
2
|
+
import mpx, { createApp } from '@mpxjs/core'
|
3
|
+
import apiProxy from '@mpxjs/api-proxy'
|
4
|
+
|
5
|
+
mpx.use(apiProxy, { usePromise: true })
|
6
|
+
|
7
|
+
createApp({
|
8
|
+
onLaunch() {
|
9
|
+
//
|
10
|
+
}
|
11
|
+
})
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<style>
|
15
|
+
/*此处编写全局样式*/
|
16
|
+
</style>
|
17
|
+
|
18
|
+
<script type="application/json">
|
19
|
+
{
|
20
|
+
"pages": [
|
21
|
+
"./pages/index",
|
22
|
+
"./pages/form-render",
|
23
|
+
"./pages/server-scheme"
|
24
|
+
]
|
25
|
+
}
|
26
|
+
</script>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<template>
|
2
|
+
<view class="basic-input">
|
3
|
+
<view class="^form-item-title">{{item.title}}</view>
|
4
|
+
<input type="text" wx:model="{{inputData}}" />
|
5
|
+
</view>
|
6
|
+
</template>
|
7
|
+
|
8
|
+
<script>
|
9
|
+
import { createComponent } from '@mpxjs/core'
|
10
|
+
|
11
|
+
createComponent({
|
12
|
+
props: {
|
13
|
+
item: Object
|
14
|
+
},
|
15
|
+
data: {
|
16
|
+
inputData: ''
|
17
|
+
},
|
18
|
+
watch: {
|
19
|
+
inputData(val) {
|
20
|
+
this.triggerEvent('input', { value: val })
|
21
|
+
}
|
22
|
+
}
|
23
|
+
})
|
24
|
+
</script>
|
25
|
+
|
26
|
+
<style lang="stylus">
|
27
|
+
.basic-input
|
28
|
+
display flex
|
29
|
+
</style>
|
30
|
+
|
31
|
+
<script type="application/json">
|
32
|
+
{
|
33
|
+
"component": true
|
34
|
+
}
|
35
|
+
</script>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<template>
|
2
|
+
<view class="basic-picker">
|
3
|
+
<view class="^form-item-title">{{item.title}}</view>
|
4
|
+
<picker wx:model="{{resultIndex}}" wx:model-event="change" range="{{item.customData.pickerArr}}">
|
5
|
+
<view class="picker-box">
|
6
|
+
<view class="picker-show-title">
|
7
|
+
{{item.customData.pickerArr[resultIndex]}}
|
8
|
+
</view>
|
9
|
+
<image class="picker-title-arrow" src="../image/caret-right.svg" mode="widthFix"></image>
|
10
|
+
</view>
|
11
|
+
</picker>
|
12
|
+
</view>
|
13
|
+
</template>
|
14
|
+
|
15
|
+
<script>
|
16
|
+
import { createComponent } from '@mpxjs/core'
|
17
|
+
|
18
|
+
createComponent({
|
19
|
+
props: {
|
20
|
+
item: Object
|
21
|
+
},
|
22
|
+
data: {
|
23
|
+
resultIndex: null,
|
24
|
+
resultValue: ''
|
25
|
+
},
|
26
|
+
created() {
|
27
|
+
this.resultIndex = this.item.defaultValue || 0
|
28
|
+
},
|
29
|
+
watch: {
|
30
|
+
resultIndex(val) {
|
31
|
+
if (val !== null) {
|
32
|
+
this.resultValue = this.item.customData.pickerArr[val]
|
33
|
+
}
|
34
|
+
},
|
35
|
+
item(val) {
|
36
|
+
const value = val.customData.pickerArr[this.resultIndex]
|
37
|
+
if (!value) {
|
38
|
+
this.resultIndex = 0
|
39
|
+
}
|
40
|
+
if (value !== this.resultValue) {
|
41
|
+
this.resultValue = value
|
42
|
+
}
|
43
|
+
},
|
44
|
+
resultValue(value) {
|
45
|
+
this.triggerEvent('input', { value })
|
46
|
+
}
|
47
|
+
}
|
48
|
+
})
|
49
|
+
</script>
|
50
|
+
|
51
|
+
<style lang="stylus">
|
52
|
+
.basic-picker
|
53
|
+
display flex
|
54
|
+
justify-content space-between
|
55
|
+
|
56
|
+
.picker-box
|
57
|
+
display flex
|
58
|
+
align-items center
|
59
|
+
.picker-show-title
|
60
|
+
font-size 30rpx
|
61
|
+
padding-left 300rpx
|
62
|
+
color #666
|
63
|
+
|
64
|
+
.picker-title-arrow
|
65
|
+
display inline-block
|
66
|
+
width 28rpx
|
67
|
+
height 28rpx
|
68
|
+
margin-left 20rpx
|
69
|
+
</style>
|
70
|
+
|
71
|
+
<script type="application/json">
|
72
|
+
{
|
73
|
+
"component": true
|
74
|
+
}
|
75
|
+
</script>
|
@@ -0,0 +1,135 @@
|
|
1
|
+
<template>
|
2
|
+
<view class="mini-form-container">
|
3
|
+
<view wx:for="{{scheme.properties}}">
|
4
|
+
<view class="mini-form-item {{index !== scheme.properties.length - 1 ? 'retina-border-bottom' : ''}}">
|
5
|
+
<basic-picker wx:if="{{item.widget === 'picker'}}" item="{{item}}" wx:model="{{formRes[item.key]}}"/>
|
6
|
+
<basic-input wx:else item="{{item}}" wx:model="{{formRes[item.key]}}"/>
|
7
|
+
</view>
|
8
|
+
</view>
|
9
|
+
<!--<button bindtap="handleTap">提交</button>-->
|
10
|
+
</view>
|
11
|
+
</template>
|
12
|
+
|
13
|
+
<script>
|
14
|
+
import { toPureObject, createComponent } from '@mpxjs/core'
|
15
|
+
|
16
|
+
createComponent({
|
17
|
+
props: {
|
18
|
+
scheme: {
|
19
|
+
type: Object
|
20
|
+
}
|
21
|
+
},
|
22
|
+
data: {
|
23
|
+
formRes: {}
|
24
|
+
},
|
25
|
+
methods: {
|
26
|
+
parseScheme(scheme) {
|
27
|
+
this.formRes = {}
|
28
|
+
const properties = scheme.properties || []
|
29
|
+
properties.forEach(item => {
|
30
|
+
const key = item.key
|
31
|
+
this.$set(this.formRes, key)
|
32
|
+
})
|
33
|
+
}
|
34
|
+
// handleTap() {
|
35
|
+
// console.log('formRes', this.formRes)
|
36
|
+
// }
|
37
|
+
},
|
38
|
+
watch: {
|
39
|
+
scheme: {
|
40
|
+
handler(scheme) {
|
41
|
+
this.parseScheme(scheme)
|
42
|
+
},
|
43
|
+
immediate: true
|
44
|
+
},
|
45
|
+
formRes: {
|
46
|
+
handler(newVal) {
|
47
|
+
const formResult = toPureObject(newVal)
|
48
|
+
// console.log('trigger form change event:', formResult)
|
49
|
+
this.triggerEvent('formchange', formResult)
|
50
|
+
},
|
51
|
+
deep: true
|
52
|
+
}
|
53
|
+
}
|
54
|
+
})
|
55
|
+
</script>
|
56
|
+
|
57
|
+
<style lang="stylus">
|
58
|
+
.mini-form-container
|
59
|
+
.mini-form-item
|
60
|
+
padding 24rpx 0
|
61
|
+
|
62
|
+
.form-item-title
|
63
|
+
font-size 30rpx
|
64
|
+
width 200rpx
|
65
|
+
color #333
|
66
|
+
|
67
|
+
// 边框默认颜色
|
68
|
+
$defaultBorderColor = rgba(0, 0, 0, 0.18)
|
69
|
+
|
70
|
+
// retina 边框函数基础声明,不包含 border 部分,主要用于在 retina-border 函数里继承
|
71
|
+
.retina-border-basic
|
72
|
+
position: relative
|
73
|
+
&::before
|
74
|
+
content: ''
|
75
|
+
position: absolute
|
76
|
+
width: 100%
|
77
|
+
height: 100%
|
78
|
+
top: 0
|
79
|
+
left:0
|
80
|
+
transform-origin: left top
|
81
|
+
box-sizing: border-box
|
82
|
+
pointer-events: none
|
83
|
+
@media
|
84
|
+
(-webkit-min-device-pixel-ratio 2),
|
85
|
+
(min-resolution 2dppx)
|
86
|
+
&::before
|
87
|
+
width: 200%
|
88
|
+
height: 200%
|
89
|
+
transform: scale(.5)
|
90
|
+
@media
|
91
|
+
(-webkit-min-device-pixel-ratio 3),
|
92
|
+
(min-resolution 3dppx)
|
93
|
+
&::before
|
94
|
+
width: 300%
|
95
|
+
height: 300%
|
96
|
+
transform: scale(1 / 3)
|
97
|
+
|
98
|
+
// 设置圆角(如果圆角大于0,则添加圆角的代码)
|
99
|
+
retina-border-radius(borderRadius)
|
100
|
+
if unit(borderRadius, px) > 0
|
101
|
+
border-radius: borderRadius
|
102
|
+
@media
|
103
|
+
(-webkit-min-device-pixel-ratio 2),
|
104
|
+
(min-resolution 2dppx)
|
105
|
+
&::before
|
106
|
+
border-radius: unit(borderRadius, px) * 2
|
107
|
+
@media
|
108
|
+
(-webkit-min-device-pixel-ratio 3),
|
109
|
+
(min-resolution 3dppx)
|
110
|
+
&::before
|
111
|
+
border-radius: unit(borderRadius, px) * 3
|
112
|
+
|
113
|
+
// retina 边框函数声明
|
114
|
+
retina-border(borderWidth = 1px, borderStyle = solid, borderColor = $defaultBorderColor, borderRadius = 0)
|
115
|
+
@extends .retina-border-basic
|
116
|
+
retina-border-radius(borderRadius)
|
117
|
+
&::before
|
118
|
+
border-width: borderWidth
|
119
|
+
border-style: borderStyle
|
120
|
+
border-color: borderColor
|
121
|
+
|
122
|
+
// 下边框
|
123
|
+
.retina-border-bottom
|
124
|
+
retina-border(0 0 1px)
|
125
|
+
</style>
|
126
|
+
|
127
|
+
<script type="application/json">
|
128
|
+
{
|
129
|
+
"component": true,
|
130
|
+
"usingComponents": {
|
131
|
+
"basic-input": "./basic-input",
|
132
|
+
"basic-picker": "./basic-picker"
|
133
|
+
}
|
134
|
+
}
|
135
|
+
</script>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<template>
|
2
|
+
<view class="">
|
3
|
+
|
4
|
+
</view>
|
5
|
+
</template>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
import { createComponent } from '@mpxjs/core'
|
9
|
+
|
10
|
+
createComponent({
|
11
|
+
data: {}
|
12
|
+
})
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<style lang="stylus">
|
16
|
+
|
17
|
+
</style>
|
18
|
+
|
19
|
+
<script type="application/json">
|
20
|
+
{
|
21
|
+
"component": true
|
22
|
+
}
|
23
|
+
</script>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<template>
|
2
|
+
<view class="form-demo-page">
|
3
|
+
<view style="content: ''; overflow: hidden;"></view>
|
4
|
+
|
5
|
+
<view class="form-demo-container">
|
6
|
+
<view class="form-title">本地scheme渲染表单测试</view>
|
7
|
+
<form-render class="form-render-container" scheme="{{formScheme}}" />
|
8
|
+
</view>
|
9
|
+
</view>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
import { createPage } from '@mpxjs/core'
|
14
|
+
import formScheme from '../test/scheme1'
|
15
|
+
|
16
|
+
createPage({
|
17
|
+
data: {
|
18
|
+
formScheme
|
19
|
+
},
|
20
|
+
onLoad() {
|
21
|
+
console.log('onLoad')
|
22
|
+
}
|
23
|
+
})
|
24
|
+
</script>
|
25
|
+
|
26
|
+
<style lang="stylus">
|
27
|
+
page
|
28
|
+
background-color #f5f5f5
|
29
|
+
|
30
|
+
.form-demo-container
|
31
|
+
background #fff
|
32
|
+
margin 24rpx
|
33
|
+
border-radius 16rpx
|
34
|
+
padding 24rpx
|
35
|
+
|
36
|
+
.form-render-container {
|
37
|
+
margin-top 24rpx
|
38
|
+
}
|
39
|
+
</style>
|
40
|
+
|
41
|
+
<script type="application/json">
|
42
|
+
{
|
43
|
+
"usingComponents": {
|
44
|
+
"form-render": "../components/form"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
</script>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<template>
|
2
|
+
<view class="form-demo-index">
|
3
|
+
<view style="content: ''; overflow: hidden;"></view>
|
4
|
+
|
5
|
+
<view class="demo-index">
|
6
|
+
<view bindtap="handleJump('render')">跳转去本地表单渲染测试页</view>
|
7
|
+
<view bindtap="handleJump('server')">跳转去服务端协议渲染测试</view>
|
8
|
+
</view>
|
9
|
+
</view>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
import mpx, { createPage } from '@mpxjs/core'
|
14
|
+
|
15
|
+
createPage({
|
16
|
+
onLoad() {
|
17
|
+
console.log('onLoad')
|
18
|
+
},
|
19
|
+
methods: {
|
20
|
+
handleJump(action) {
|
21
|
+
if (action === 'render') {
|
22
|
+
mpx.navigateTo({ url: '/pages/form-render' })
|
23
|
+
} else if (action === 'server') {
|
24
|
+
mpx.navigateTo({ url: '/pages/server-scheme' })
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
})
|
29
|
+
</script>
|
30
|
+
|
31
|
+
<style lang="stylus">
|
32
|
+
page {
|
33
|
+
background-color: #f5f5f5;
|
34
|
+
}
|
35
|
+
|
36
|
+
.form-container {
|
37
|
+
background: #fff;
|
38
|
+
margin: 24rpx;
|
39
|
+
border-radius: 16rpx;
|
40
|
+
padding: 24rpx;
|
41
|
+
}
|
42
|
+
</style>
|
43
|
+
|
44
|
+
<script type="application/json">
|
45
|
+
{
|
46
|
+
"usingComponents": {}
|
47
|
+
}
|
48
|
+
</script>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<template>
|
2
|
+
<view class="form-demo-page">
|
3
|
+
<view style="content: ''; overflow: hidden;"></view>
|
4
|
+
|
5
|
+
<view class="form-demo-container">
|
6
|
+
<view class="form-title">服务端联动表单渲染测试</view>
|
7
|
+
<form-render class="form-render-container" scheme="{{formScheme}}" bindformchange="handleFormChange"/>
|
8
|
+
</view>
|
9
|
+
</view>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
import { createPage } from '@mpxjs/core'
|
14
|
+
import serverScheme from '../test/server-relation-scheme'
|
15
|
+
|
16
|
+
createPage({
|
17
|
+
data: {
|
18
|
+
formScheme: [],
|
19
|
+
formResult: null
|
20
|
+
},
|
21
|
+
onLoad() {
|
22
|
+
console.log('onLoad, server scheme is:', serverScheme)
|
23
|
+
// this.formScheme = scheme1
|
24
|
+
this.initFormScheme()
|
25
|
+
},
|
26
|
+
watch: {
|
27
|
+
formResult() {
|
28
|
+
this.initFormScheme()
|
29
|
+
}
|
30
|
+
},
|
31
|
+
methods: {
|
32
|
+
initFormScheme() {
|
33
|
+
const formProperties = []
|
34
|
+
serverScheme.properties.forEach(item => {
|
35
|
+
if (item.condition) {
|
36
|
+
const condition = item.condition
|
37
|
+
if (this.formResult && this.formResult[condition.key] === condition.value) {
|
38
|
+
formProperties.push(item)
|
39
|
+
}
|
40
|
+
} else {
|
41
|
+
formProperties.push(item)
|
42
|
+
}
|
43
|
+
})
|
44
|
+
this.formScheme = { properties: formProperties }
|
45
|
+
},
|
46
|
+
handleFormChange(e) {
|
47
|
+
console.log('form change handler: ', e.detail)
|
48
|
+
this.formResult = e.detail
|
49
|
+
}
|
50
|
+
}
|
51
|
+
})
|
52
|
+
</script>
|
53
|
+
|
54
|
+
<style lang="stylus">
|
55
|
+
page
|
56
|
+
background-color #f5f5f5
|
57
|
+
|
58
|
+
.form-demo-container
|
59
|
+
background #fff
|
60
|
+
margin 24rpx
|
61
|
+
border-radius 16rpx
|
62
|
+
padding 24rpx
|
63
|
+
|
64
|
+
.form-render-container {
|
65
|
+
margin-top 24rpx
|
66
|
+
}
|
67
|
+
</style>
|
68
|
+
|
69
|
+
<script type="application/json">
|
70
|
+
{
|
71
|
+
"usingComponents": {
|
72
|
+
"form-render": "../components/form"
|
73
|
+
}
|
74
|
+
}
|
75
|
+
</script>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
export default {
|
2
|
+
properties: [
|
3
|
+
{
|
4
|
+
key: 'model',
|
5
|
+
type: 'string',
|
6
|
+
title: '模型选择',
|
7
|
+
widget: 'picker',
|
8
|
+
customData: {
|
9
|
+
pickerArr: ['绘梦', '二次元', '真人']
|
10
|
+
}
|
11
|
+
},
|
12
|
+
{
|
13
|
+
key: 'template',
|
14
|
+
type: 'string',
|
15
|
+
title: '模板选择',
|
16
|
+
widget: 'picker',
|
17
|
+
customData: {
|
18
|
+
pickerArr: ['油画', '水彩', '风景']
|
19
|
+
}
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// 服务端下发且需要联动的scheme,前端整理后进行渲染
|
2
|
+
export default {
|
3
|
+
properties: [
|
4
|
+
{
|
5
|
+
key: 'model',
|
6
|
+
title: '模型选择',
|
7
|
+
widget: 'picker',
|
8
|
+
customData: {
|
9
|
+
pickerArr: ['绘梦', '二次元', '真人']
|
10
|
+
},
|
11
|
+
children: [
|
12
|
+
{
|
13
|
+
key: 'template',
|
14
|
+
title: '模板选择',
|
15
|
+
widget: 'picker',
|
16
|
+
condition: '绘梦',
|
17
|
+
customData: {
|
18
|
+
pickerArr: ['油画', '水彩', '风景']
|
19
|
+
}
|
20
|
+
},
|
21
|
+
{
|
22
|
+
key: 'template',
|
23
|
+
title: '模板选择',
|
24
|
+
widget: 'picker',
|
25
|
+
condition: '二次元',
|
26
|
+
customData: {
|
27
|
+
pickerArr: ['测试1', '测试2', '测试3']
|
28
|
+
}
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
]
|
33
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"setting": {
|
3
|
+
"newFeature": true,
|
4
|
+
"urlCheck": true,
|
5
|
+
"es6": false,
|
6
|
+
"postcss": false,
|
7
|
+
"minified": false,
|
8
|
+
"checkSiteMap": false,
|
9
|
+
"autoAudits": false
|
10
|
+
},
|
11
|
+
"appid": "touristappid",
|
12
|
+
"projectname": "mpxdemo",
|
13
|
+
"description": "A mpx project",
|
14
|
+
"condition": {}
|
15
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
{
|
2
|
+
"setting": {
|
3
|
+
"newFeature": true,
|
4
|
+
"urlCheck": true,
|
5
|
+
"es6": false,
|
6
|
+
"postcss": true,
|
7
|
+
"minified": false,
|
8
|
+
"checkSiteMap": false,
|
9
|
+
"autoAudits": false,
|
10
|
+
"coverView": true,
|
11
|
+
"lazyloadPlaceholderEnable": false,
|
12
|
+
"preloadBackgroundData": false,
|
13
|
+
"uglifyFileName": false,
|
14
|
+
"uploadWithSourceMap": true,
|
15
|
+
"enhance": false,
|
16
|
+
"useMultiFrameRuntime": true,
|
17
|
+
"showShadowRootInWxmlPanel": true,
|
18
|
+
"packNpmManually": false,
|
19
|
+
"packNpmRelationList": [],
|
20
|
+
"minifyWXSS": true,
|
21
|
+
"useStaticServer": true,
|
22
|
+
"showES6CompileOption": false,
|
23
|
+
"checkInvalidKey": true,
|
24
|
+
"babelSetting": {
|
25
|
+
"ignore": [],
|
26
|
+
"disablePlugins": [],
|
27
|
+
"outputPath": ""
|
28
|
+
},
|
29
|
+
"disableUseStrict": false,
|
30
|
+
"useCompilerPlugins": false,
|
31
|
+
"minifyWXML": true,
|
32
|
+
"compileHotReLoad": true,
|
33
|
+
"ignoreUploadUnusedFiles": false,
|
34
|
+
"condition": false
|
35
|
+
},
|
36
|
+
"appid": "wx74053e55da62dcd3",
|
37
|
+
"projectname": "mpxdemo",
|
38
|
+
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
39
|
+
"condition": {
|
40
|
+
"miniprogram": {
|
41
|
+
"list": [
|
42
|
+
{
|
43
|
+
"name": "服务端下发",
|
44
|
+
"pathName": "pages/server-scheme",
|
45
|
+
"query": "",
|
46
|
+
"launchMode": "default",
|
47
|
+
"scene": null
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
51
|
+
},
|
52
|
+
"compileType": "miniprogram",
|
53
|
+
"libVersion": "2.28.0",
|
54
|
+
"packOptions": {
|
55
|
+
"ignore": [],
|
56
|
+
"include": []
|
57
|
+
},
|
58
|
+
"editorSetting": {
|
59
|
+
"tabIndent": "insertSpaces",
|
60
|
+
"tabSize": 2
|
61
|
+
}
|
62
|
+
}
|
package/vue.config.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
const { defineConfig } = require('@vue/cli-service')
|
2
|
+
const path = require('path')
|
3
|
+
module.exports = defineConfig({
|
4
|
+
pluginOptions: {
|
5
|
+
mpx: {
|
6
|
+
srcMode: 'wx',
|
7
|
+
plugin: {
|
8
|
+
customOutputPath(type, name, hash, ext) {
|
9
|
+
// console.log(1111, path.join(type + 's', name, 'index' + ext))
|
10
|
+
return path.join(type + 's', name, 'index' + ext)
|
11
|
+
}
|
12
|
+
},
|
13
|
+
loader: {}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
})
|