first commit

dev
姜玉琦 2023-08-10 01:21:29 +08:00
parent c80571d4af
commit 4c58727a4f
941 changed files with 64594 additions and 0 deletions

8
.idea/.gitignore vendored 100644
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/construction.iml" filepath="$PROJECT_DIR$/.idea/construction.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml 100644
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,7 @@
{
"permissions": {
"openapi": [
"customerServiceMessage.send"
]
}
}

View File

@ -0,0 +1,26 @@
const cloud = require('wx-server-sdk')
cloud.init({
// API 调用都保持和云函数当前所在环境一致
env: cloud.DYNAMIC_CURRENT_ENV
})
// 云函数入口函数
exports.main = async (event, context) => {
console.log(event)
const { OPENID } = cloud.getWXContext()
const result = await cloud.openapi.customerServiceMessage.send({
touser: OPENID,
msgtype: 'text',
text: {
content: '收到:' + event.Content,
}
})
console.log(result)
return result
}

View File

@ -0,0 +1,14 @@
{
"name": "callback",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "~2.1.2"
}
}

View File

@ -0,0 +1,5 @@
{
"permissions": {
"openapi": []
}
}

View File

@ -0,0 +1,8 @@
const cloud = require('wx-server-sdk')
exports.main = async (event, context) => {
// event.userInfo 是已废弃的保留字段,在此不做展示
// 获取 OPENID 等微信上下文请使用 cloud.getWXContext()
delete event.userInfo
return event
}

View File

@ -0,0 +1,14 @@
{
"name": "echo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "~2.1.2"
}
}

View File

@ -0,0 +1,5 @@
{
"permissions": {
"openapi": []
}
}

View File

@ -0,0 +1,36 @@
// 云函数模板
// 部署:在 cloud-functions/login 文件夹右击选择 “上传并部署”
const cloud = require('wx-server-sdk')
// 初始化 cloud
cloud.init({
// API 调用都保持和云函数当前所在环境一致
env: cloud.DYNAMIC_CURRENT_ENV
})
/**
* 这个示例将经自动鉴权过的小程序用户 openid 返回给小程序端
*
* event 参数包含小程序端调用传入的 data
*
*/
exports.main = async (event, context) => {
console.log(event)
console.log(context)
// 可执行其他自定义逻辑
// console.log 的内容可以在云开发云函数调用日志查看
// 获取 WX Context (微信调用上下文),包括 OPENID、APPID、及 UNIONID需满足 UNIONID 获取条件)等信息
const wxContext = cloud.getWXContext()
return {
event,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
env: wxContext.ENV,
}
}

View File

@ -0,0 +1,14 @@
{
"name": "login",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "~2.1.2"
}
}

View File

@ -0,0 +1,15 @@
{
"permissions": {
"openapi": [
"wxacode.get",
"subscribeMessage.send",
"subscribeMessage.addTemplate",
"templateMessage.send",
"templateMessage.addTemplate",
"templateMessage.deleteTemplate",
"templateMessage.getTemplateList",
"templateMessage.getTemplateLibraryById",
"templateMessage.getTemplateLibraryList"
]
}
}

View File

@ -0,0 +1,87 @@
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
// 云函数入口函数
exports.main = async (event, context) => {
console.log(event)
switch (event.action) {
case 'requestSubscribeMessage': {
return requestSubscribeMessage(event)
}
case 'sendSubscribeMessage': {
return sendSubscribeMessage(event)
}
case 'getWXACode': {
return getWXACode(event)
}
case 'getOpenData': {
return getOpenData(event)
}
default: {
return
}
}
}
async function requestSubscribeMessage(event) {
// 此处为模板 ID开发者需要到小程序管理后台 - 订阅消息 - 公共模板库中添加模板,
// 然后在我的模板中找到对应模板的 ID填入此处
return '请到管理后台申请模板 ID 然后在此替换' // 如 'N_J6F05_bjhqd6zh2h1LHJ9TAv9IpkCiAJEpSw0PrmQ'
}
async function sendSubscribeMessage(event) {
const { OPENID } = cloud.getWXContext()
const { templateId } = event
const sendResult = await cloud.openapi.subscribeMessage.send({
touser: OPENID,
templateId,
miniprogram_state: 'developer',
page: 'pages/openapi/openapi',
// 此处字段应修改为所申请模板所要求的字段
data: {
thing1: {
value: '咖啡',
},
time3: {
value: '2020-01-01 00:00',
},
}
})
return sendResult
}
async function getWXACode(event) {
// 此处将获取永久有效的小程序码,并将其保存在云文件存储中,最后返回云文件 ID 给前端使用
const wxacodeResult = await cloud.openapi.wxacode.get({
path: 'pages/openapi/openapi',
})
const fileExtensionMatches = wxacodeResult.contentType.match(/\/([^\/]+)/)
const fileExtension = (fileExtensionMatches && fileExtensionMatches[1]) || 'jpg'
const uploadResult = await cloud.uploadFile({
// 云文件路径,此处为演示采用一个固定名称
cloudPath: `wxacode_default_openapi_page.${fileExtension}`,
// 要上传的文件内容可直接传入图片 Buffer
fileContent: wxacodeResult.buffer,
})
if (!uploadResult.fileID) {
throw new Error(`upload failed with empty fileID and storage server status code ${uploadResult.statusCode}`)
}
return uploadResult.fileID
}
async function getOpenData(event) {
return cloud.getOpenData({
list: event.openData.list,
})
}

View File

@ -0,0 +1,14 @@
{
"name": "openapi",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "~2.1.2"
}
}

152
miniprogram/app.js 100644
View File

@ -0,0 +1,152 @@
//app.js
//全局分享
!function(){
var PageTmp = Page;
Page =function (pageConfig) {
// 设置全局默认分享
pageConfig = Object.assign({
//右上角分享功能
onShareAppMessage () {
return {
title: '智慧工地优管',//分享标题
path: '/pages/login/login',//分享用户点开后页面
success (res) {
console.log('分享成功!')
}
}
}
},pageConfig);
PageTmp(pageConfig);
};
}();
App({
globalData: {
paramDeptId:'',
userProjectId:'',
appId: "wxc44b5d588f599758",
// 智慧工地后台接口访问域名
// reqUrl:"http://wxw.ngrok.makalu.cc",
//reqUrl:'https://jaapplets.makalu.cc',
//reqUrl:'https://sxyanzhu.com/jhwxapp',
//reqUrl:'https://cf.makalu.cc',
reqUrl:'http://127.0.0.1:8091',
//御景路数字化集成管控平台接口访问域名
szhUrl:'https://szh.makalu.cc',
// szhUrl:'http://127.0.0.1:9004',
// szhUrl:'http://192.168.31.49:9004',
//劳务实名制平台接口访问域名
smzUrl:'https://smz.makalu.cc',
//安全智管平台接口访问域名
aqzgUrl:'https://aqzg.makalu.cc',
//地图相关参数
scale:'',
initialLon:'',
initialLat:'',
markers:[],
//页面跳转参数
type:'',
value1:'省',
value2:'市/区',
value3:'公司',
projectInfoList:{},
projectId:'',
projectName:'',
companyName:'',
deptId:'',
},
onLaunch: function () {
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
} else {
wx.cloud.init({
// env 参数说明:
// env 参数决定接下来小程序发起的云开发调用wx.cloud.xxx会默认请求到哪个云环境的资源
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
// 如不填则使用默认环境(第一个创建的环境)
// env: 'my-env-id',
traceUser: true,
})
}
this.update();
},
onLoad(){
},
/**
* 获取用户openid
*/
getOPenId:function () {
wx.login({
success :res=>{
console.log(res)
wx.request({
url: this.globalData.reqUrl+'/weixin/userLogin/getOpenId',
data:{
"code": res.code,
"appId":"wxc44b5d588f599758",
},
success:(res)=>{
wx.setStorageSync('openId', res.data.openid)
}
})
}
})
},
//页面弹窗
toast: function (msg) {
wx.showToast({
title: msg,
icon: 'none',
duration: 2000,
mask: true
});
},
//版本更新
update(){
//使用更新对象之前判断是否可用
if (wx.canIUse('getUpdateManager')){
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
console.log(res.hasUpdate)//res.hasUpdate返回boolean类型
if (res.hasUpdate) {
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启当前应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好调用applyUpdate应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
// 新版本下载失败时执行
updateManager.onUpdateFailed(function () {
wx.showModal({
title: '发现新版本',
content: '请删除当前小程序,重新搜索打开...',
})
})
}
})
}else{
//如果小程序需要在最新的微信版本体验,如下提示
wx.showModal({
title: '更新提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
}
})

View File

@ -0,0 +1,71 @@
//app.js
//全局分享
!function(){
var PageTmp = Page;
Page =function (pageConfig) {
// 设置全局默认分享
pageConfig = Object.assign({
//右上角分享功能
onShareAppMessage () {
return {
title: '智能工地+',//分享标题
path: '/pages/login/login',//分享用户点开后页面
success (res) {
console.log('分享成功!')
}
}
}
},pageConfig);
PageTmp(pageConfig);
};
}();
App({
globalData: {
paramDeptId:'',
//请求地址参数
//reqUrl:"http://192.168.31.126:9981",
//reqUrl:'https://zngdtest.makalu.cc/',
reqUrl:'https://zngd.makalu.cc',
//地图相关参数
scale:'',
initialLon:'',
initialLat:'',
markers:[],
//页面跳转参数
type:'',
value1:'省',
value2:'市/区',
value3:'公司',
projectInfoList:{},
projectId:'',
projectName:'',
},
onLaunch: function () {
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
} else {
wx.cloud.init({
// env 参数说明:
// env 参数决定接下来小程序发起的云开发调用wx.cloud.xxx会默认请求到哪个云环境的资源
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
// 如不填则使用默认环境(第一个创建的环境)
// env: 'my-env-id',
traceUser: true,
})
}
},
//页面弹窗
toast: function (msg) {
wx.showToast({
title: msg,
icon: 'none',
duration: 2000,
mask: true
});
}
})

View File

@ -0,0 +1,147 @@
{
"pages": [
"pages/login/login",
"pages/gongchengliebiao/gongchengliebiao",
"pages/gengduogongneng/gengduogongneng",
"pages/xiangmugaikuang/xiangmugaikuang",
"pages/renyuanguanli/renyuanguanli",
"pages/shebieguanli-tzsb/taji",
"pages/shebieguanli-jxsb/shajiangguan",
"pages/ranyuanguanli-map/map",
"pages/map/map",
"pages/shebeiguanli-map/jixiedingwei",
"pages/deepExcavation/index",
"pages/Information-review/index",
"pages/newAddPage/safetyManagement/index",
"pages/learn-page/index",
"pages/Personnel-information-binding/index",
"pages/winter-training/index",
"pages/saft-qr-view/index",
"pages/saft-education-user-bind/index",
"pages/temporaryToExamine/index",
"pages/tempRegistration/index",
"pages/newAddPage/safetyBriefingLearning/index",
"pages/newAddPage2/safetyBriefingLearning/index",
"pages/Highlight-photos/index",
"pages/newAddPage/letterCommitment/index",
"pages/newAddPage2/letterCommitment/index",
"pages/Security-control-echarts/index",
"pages/Concrete-usage/index",
"pages/Quality-Assurance/index",
"pages/Standard-maintenance-room-monitoring/index",
"pages/hnt-strong/index",
"pages/construction/index",
"pages/Construction-Log/index",
"pages/construction-details/index",
"pages/measures/index",
"pages/measures-Chakan/index",
"pages/updatePassword/updatePassword"
],
"subpackages": [
{
"root": "pageage",
"name": "pageage",
"pages": [
"educations-add/index",
"educations-details/index",
"educations-list/index",
"xiangmuhuanjing/xiangmuhuanjing",
"xiangmuyujing/xiangmuyujing",
"yujingxinxi/yujingxinxi",
"xiangmushipin/xiangmushipin",
"AIvideoAnalysis/index",
"AIWarningList/index",
"vehicleManage/index",
"shipinquanping/shipingquanping",
"voucherManagement/index",
"voucherManagementAddto/index",
"biangeng/index",
"suishoupai/suishoupai",
"suishoupai-psh/suishoupai-psh",
"lw-index/lw-index",
"lw-baobiaochaxun/lw-baobiaochaxun",
"lw-gerenxinxi/lw-gerenxinxi",
"lw-jibenxinxi/lw-jibenxinxi",
"safetyManagement/securityCheckGR/index",
"safetyManagement/securityCheck/index",
"safetyManagement/problemRectificationGR/index",
"safetyManagement/problemRectification/index",
"safetyManagement/securityCheckRectified/index",
"safetyManagement/addSafetyInspect/index",
"Security-control-echarts/index",
"dangerousProject/index",
"samplingRetesting/index",
"samplingRetestingDeliver/index",
"samplingRetestingUpload/index",
"samplingAddRetestingDeliver/index",
"samplingRetestingDetail/index",
"Progress-management/index",
"Material-Management/index",
"technical-management/index"
],
"independent": false
}
],
"usingComponents": {
"van-row": "@vant/weapp/row",
"van-col": "@vant/weapp/col",
"van-popup": "@vant/weapp/popup/index",
"van-picker": "@vant/weapp/picker/index",
"van-uploader": "@vant/weapp/uploader/index",
"van-datetime-picker": "@vant/weapp/datetime-picker/index",
"van-radio": "@vant/weapp/radio/index",
"van-radio-group": "@vant/weapp/radio-group/index",
"van-toast": "@vant/weapp/toast/index",
"ec-canvas": "ec-canvas/ec-canvas",
"van-sticky": "@vant/weapp/sticky",
"van-calendar": "@vant/weapp/calendar/index",
"van-icon": "@vant/weapp/icon/index",
"van-image": "@vant/weapp/image/index",
"pie-chart": "pages/components/pie-chart/index",
"deep-select": "pages/components/deep-select/index",
"select-btn": "pages/components/select-btn/index",
"bar-chart": "pages/components/bar-chart/index",
"bar-chart-warning": "pages/components/bar-chart-warning/index",
"pz-screen": "pages/components/pz-screen/index",
"pz-screen-training": "pages/components/pz-screen-training/index",
"pz-screen-training-index": "pages/components/pz-screen-training-index/index",
"select-date": "pages/components/select-date/index",
"voucher-select": "pages/components/voucher-select/index",
"voucher-selects": "pages/components/voucher-selects/index",
"voucher-selected": "pages/components/voucher-selected/index",
"voucher-date": "pages/components/voucher-date/index",
"voucher-date-copy": "pages/components/voucher-date-copy/index",
"file-uploader": "pages/components/file-uploader/index",
"project-select": "pages/components/project-select/index",
"safety-pie-chart": "./newComponents/safety-pie-chart/index",
"safety-pie-charts": "./newComponents/safety-pie-charts/index",
"safety-bar-chart": "./newComponents/safety-bar-chart/index",
"safety-bar-charts": "./newComponents/safety-bar-charts/index",
"safety-bar-chartss": "./newComponents/safety-bar-chartss/index",
"file-uploader-copy": "pages/components/file-uploader-copy/index",
"voucher-many-select": "pages/components/voucher-many-select/index",
"sign": "pages/components/sign/sign",
"safety-number": "./newComponents/number/index",
"select-person": "./newComponents/select-person/index",
"van-dropdown-menu": "@vant/weapp/dropdown-menu/index",
"van-dropdown-item": "@vant/weapp/dropdown-item/index",
"curve-echarts": "pages/components/curve-echarts/index",
"curve-echarts-copy": "pages/components/curve-echarts-copy/index"
},
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#191d28",
"navigationBarTextStyle": "white"
},
"style": "v2",
"sitemapLocation": "sitemap.json",
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"requiredPrivateInfos": [
"getLocation"
]
}

1525
miniprogram/app.wxss 100644

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,37 @@
import { link } from '../mixins/link';
import { VantComponent } from '../common/component';
VantComponent({
classes: [
'title-class',
'label-class',
'value-class',
'right-icon-class',
'hover-class',
],
mixins: [link],
props: {
title: null,
value: null,
icon: String,
size: String,
label: String,
center: Boolean,
isLink: Boolean,
required: Boolean,
clickable: Boolean,
titleWidth: String,
customStyle: String,
arrowDirection: String,
useLabelSlot: Boolean,
border: {
type: Boolean,
value: true,
},
},
methods: {
onClick(event) {
this.$emit('click', event.detail);
this.jumpLink();
},
},
});

View File

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

View File

@ -0,0 +1,45 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<view
class="custom-class {{ utils.bem('cell', [size, { center, required, borderless: !border, clickable: isLink || clickable }]) }}"
hover-class="van-cell--hover hover-class"
hover-stay-time="70"
style="{{ customStyle }}"
bind:tap="onClick"
>
<van-icon
wx:if="{{ icon }}"
name="{{ icon }}"
class="van-cell__left-icon-wrap"
custom-class="van-cell__left-icon"
/>
<slot wx:else name="icon" />
<view
style="{{ titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth : '' }}"
class="van-cell__title title-class"
>
<block wx:if="{{ title }}">{{ title }}</block>
<slot wx:else name="title" />
<view wx:if="{{ label || useLabelSlot }}" class="van-cell__label label-class">
<slot wx:if="{{ useLabelSlot }}" name="label" />
<block wx:elif="{{ label }}">{{ label }}</block>
</view>
</view>
<view class="van-cell__value value-class">
<block wx:if="{{ value || value === 0 }}">{{ value }}</block>
<slot wx:else />
</view>
<van-icon
wx:if="{{ isLink }}"
name="{{ arrowDirection ? 'arrow' + '-' + arrowDirection : 'arrow' }}"
class="van-cell__right-icon-wrap right-icon-class"
custom-class="van-cell__right-icon"
/>
<slot wx:else name="right-icon" />
<slot name="extra" />
</view>

View File

@ -0,0 +1 @@
@import '../common/index.wxss';.van-cell{position:relative;display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:10px 16px;padding:var(--cell-vertical-padding,10px) var(--cell-horizontal-padding,16px);font-size:14px;font-size:var(--cell-font-size,14px);line-height:24px;line-height:var(--cell-line-height,24px);color:#323233;color:var(--cell-text-color,#323233);background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:auto;right:0;bottom:0;left:16px;border-bottom:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell__label{margin-top:3px;margin-top:var(--cell-label-margin-top,3px);font-size:12px;font-size:var(--cell-label-font-size,12px);line-height:18px;line-height:var(--cell-label-line-height,18px);color:#969799;color:var(--cell-label-color,#969799)}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle;color:#969799;color:var(--cell-value-color,#969799)}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px;height:var(--cell-line-height,24px);font-size:16px;font-size:var(--cell-icon-size,16px)}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#969799;color:var(--cell-right-icon-color,#969799)}.van-cell__left-icon{vertical-align:middle}.van-cell__left-icon,.van-cell__right-icon{line-height:24px;line-height:var(--cell-line-height,24px)}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5;background-color:var(--cell-active-color,#f2f3f5)}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;content:"*";left:8px;left:var(--padding-xs,8px);font-size:14px;font-size:var(--cell-font-size,14px);color:#ee0a24;color:var(--cell-required-color,#ee0a24)}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-top:var(--cell-large-vertical-padding,12px);padding-bottom:12px;padding-bottom:var(--cell-large-vertical-padding,12px)}.van-cell--large .van-cell__title{font-size:16px;font-size:var(--cell-large-title-font-size,16px)}.van-cell--large .van-cell__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,92 @@
import { VantComponent } from "../common/component";
const nextTick = () => new Promise((resolve) => setTimeout(resolve, 20));
VantComponent({
classes: ["title-class", "content-class"],
relation: {
name: "collapse",
type: "ancestor",
current: "collapse-item",
},
props: {
name: null,
title: null,
value: null,
icon: String,
label: String,
disabled: Boolean,
clickable: Boolean,
border: {
type: Boolean,
value: true,
},
isLink: {
type: Boolean,
value: true,
},
},
data: {
contentHeight: 0,
expanded: false,
transition: false,
},
mounted() {
this.updateExpanded()
.then(nextTick)
.then(() => {
const data = { transition: true };
if (this.data.expanded) {
data.contentHeight = "auto";
}
this.setData(data);
});
},
methods: {
updateExpanded() {
if (!this.parent) {
return Promise.resolve();
}
const { value, accordion } = this.parent.data;
const { children = [] } = this.parent;
const { name } = this.data;
const index = children.indexOf(this);
const currentName = name == null ? index : name;
const expanded = accordion ? value === currentName : (value || []).some((name) => name === currentName);
const stack = [];
if (expanded !== this.data.expanded) {
stack.push(this.updateStyle(expanded));
}
stack.push(this.set({ index, expanded }));
return Promise.all(stack);
},
updateStyle(expanded) {
return this.getRect(".van-collapse-item__content")
.then((rect) => rect.height)
.then((height) => {
if (expanded) {
return this.set({
contentHeight: height ? `${height}px` : "auto",
});
}
return this.set({ contentHeight: `${height}px` })
.then(nextTick)
.then(() => this.set({ contentHeight: 0 }));
});
},
onClick() {
if (this.data.disabled) {
return;
}
const { name, expanded } = this.data;
const index = this.parent.children.indexOf(this);
const currentName = name == null ? index : name;
this.parent.switch(currentName, !expanded);
},
onTransitionEnd() {
if (this.data.expanded) {
this.setData({
contentHeight: "auto",
});
}
},
},
});

View File

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

View File

@ -0,0 +1,15 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<view class="van-collapse-item custom-class mkl-collapse {{ index !== 0 ? 'van-hairline--top' : '' }}">
<van-cell custom-class="van-cell mkl-cell {{expanded?'mkl-cell__expanded':''}}" title="{{ title }}" title-class="title-class" icon="{{ icon }}" value="{{ value }}" label="{{ label }}" is-link="{{ isLink }}" clickable="{{ clickable }}" border="{{ border && expanded }}" class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}" right-icon-class="van-cell__right-icon" hover-class="van-cell--hover" bind:click="onClick">
<slot name="title" slot="title" />
<slot name="icon" slot="icon" />
<slot name="value" />
<slot name="right-icon" slot="right-icon" />
</van-cell>
<view class="mkl-collapse-container {{ utils.bem('collapse-item__wrapper', { transition }) }}" style="height: {{ contentHeight }};" bind:transitionend="onTransitionEnd">
<!-- <view class="mkl-cell__bottom"></view> -->
<view class="van-collapse-item__content content-class">
<slot />
</view>
</view>
</view>

View File

@ -0,0 +1,60 @@
@import "../common/index.wxss";
.van-collapse-item__title .van-cell__right-icon {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
transition: -webkit-transform 0.3s;
transition: transform 0.3s;
transition: transform 0.3s, -webkit-transform 0.3s;
}
.van-collapse-item__title--expanded .van-cell__right-icon {
-webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
}
.van-collapse-item__title--disabled .van-cell,
.van-collapse-item__title--disabled .van-cell__right-icon {
color: #c8c9cc !important;
}
.van-collapse-item__title--disabled .van-cell--hover {
background-color: #fff !important;
}
.van-collapse-item__wrapper {
overflow: hidden;
}
.van-collapse-item__wrapper--transition {
transition: height 0.3s ease-in-out;
}
.van-collapse-item__content {
padding: 0 25rpx;
color: #969799;
font-size: 13px;
line-height: 1.5;
}
.mkl-collapse {
padding: 0 25rpx;
margin-bottom: 40rpx;
}
.mkl-cell {
background: #fff;
padding: 25rpx;
border-radius: 20rpx;
/* border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx; */
box-shadow: 0px 0px 10px #ddd;
/* margin-bottom: 40rpx; */
}
.mkl-cell__expanded {
border-radius: 20rpx 20rpx 0 0;
}
.mkl-cell__bottom {
height: 40rpx;
}
.mkl-collapse-container {
box-shadow: 0px 0px 10px #ddd;
transition: height 0.2s;
border-radius: 0 0 20rpx 20rpx;
background: #f5f5f5;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,47 @@
import { VantComponent } from '../common/component';
VantComponent({
relation: {
name: 'collapse-item',
type: 'descendant',
current: 'collapse',
},
props: {
value: {
type: null,
observer: 'updateExpanded',
},
accordion: {
type: Boolean,
observer: 'updateExpanded',
},
border: {
type: Boolean,
value: true,
},
},
methods: {
updateExpanded() {
this.children.forEach((child) => {
child.updateExpanded();
});
},
switch(name, expanded) {
const { accordion, value } = this.data;
const changeItem = name;
if (!accordion) {
name = expanded
? (value || []).concat(name)
: (value || []).filter((activeName) => activeName !== name);
} else {
name = expanded ? name : '';
}
if (expanded) {
this.$emit('open', changeItem);
} else {
this.$emit('close', changeItem);
}
this.$emit('change', name);
this.$emit('input', name);
},
},
});

View File

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

View File

@ -0,0 +1,3 @@
<view class="custom-class van-collapse {{ border ? 'van-hairline--top-bottom' : '' }} ">
<slot />
</view>

View File

@ -0,0 +1 @@
@import "../common/index.wxss";

View File

@ -0,0 +1,7 @@
export declare const RED = "#ee0a24";
export declare const BLUE = "#1989fa";
export declare const WHITE = "#fff";
export declare const GREEN = "#07c160";
export declare const ORANGE = "#ff976a";
export declare const GRAY = "#323233";
export declare const GRAY_DARK = "#969799";

View File

@ -0,0 +1,7 @@
export const RED = '#ee0a24';
export const BLUE = '#1989fa';
export const WHITE = '#fff';
export const GREEN = '#07c160';
export const ORANGE = '#ff976a';
export const GRAY = '#323233';
export const GRAY_DARK = '#969799';

View File

@ -0,0 +1,3 @@
import { VantComponentOptions, CombinedComponentInstance } from '../definitions/index';
declare function VantComponent<Data, Props, Methods>(vantOptions?: VantComponentOptions<Data, Props, Methods, CombinedComponentInstance<Data, Props, Methods>>): void;
export { VantComponent };

View File

@ -0,0 +1,101 @@
import { basic } from '../mixins/basic';
const relationFunctions = {
ancestor: {
linked(parent) {
this.parent = parent;
},
unlinked() {
this.parent = null;
},
},
descendant: {
linked(child) {
this.children = this.children || [];
this.children.push(child);
},
unlinked(child) {
this.children = (this.children || []).filter((it) => it !== child);
},
},
};
function mapKeys(source, target, map) {
Object.keys(map).forEach((key) => {
if (source[key]) {
target[map[key]] = source[key];
}
});
}
function makeRelation(options, vantOptions, relation) {
const { type, name, linked, unlinked, linkChanged } = relation;
const { beforeCreate, destroyed } = vantOptions;
if (type === 'descendant') {
options.created = function () {
beforeCreate && beforeCreate.bind(this)();
this.children = this.children || [];
};
options.detached = function () {
this.children = [];
destroyed && destroyed.bind(this)();
};
}
options.relations = Object.assign(options.relations || {}, {
[`../${name}/index`]: {
type,
linked(node) {
relationFunctions[type].linked.bind(this)(node);
linked && linked.bind(this)(node);
},
linkChanged(node) {
linkChanged && linkChanged.bind(this)(node);
},
unlinked(node) {
relationFunctions[type].unlinked.bind(this)(node);
unlinked && unlinked.bind(this)(node);
},
},
});
}
function VantComponent(vantOptions = {}) {
const options = {};
mapKeys(vantOptions, options, {
data: 'data',
props: 'properties',
mixins: 'behaviors',
methods: 'methods',
beforeCreate: 'created',
created: 'attached',
mounted: 'ready',
relations: 'relations',
destroyed: 'detached',
classes: 'externalClasses',
});
const { relation } = vantOptions;
if (relation) {
makeRelation(options, vantOptions, relation);
}
// add default externalClasses
options.externalClasses = options.externalClasses || [];
options.externalClasses.push('custom-class');
// add default behaviors
options.behaviors = options.behaviors || [];
options.behaviors.push(basic);
// map field to form-field behavior
if (vantOptions.field) {
options.behaviors.push('wx://form-field');
}
if (options.properties) {
Object.keys(options.properties).forEach((name) => {
if (Array.isArray(options.properties[name])) {
// miniprogram do not allow multi type
options.properties[name] = null;
}
});
}
// add default options
options.options = {
multipleSlots: true,
addGlobalClass: true,
};
Component(options);
}
export { VantComponent };

View File

@ -0,0 +1 @@
.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{display:table;clear:both;content:""}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #eee;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px}

View File

@ -0,0 +1 @@
.van-clearfix:after{display:table;clear:both;content:""}

View File

@ -0,0 +1 @@
.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}

View File

@ -0,0 +1 @@
.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #eee;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px}

View File

@ -0,0 +1,8 @@
/// <reference types="miniprogram-api-typings" />
export declare function isDef(value: any): boolean;
export declare function isObj(x: any): boolean;
export declare function isNumber(value: any): boolean;
export declare function range(num: number, min: number, max: number): number;
export declare function nextTick(fn: Function): void;
export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSyncResult;
export declare function addUnit(value?: string | number): string | undefined;

View File

@ -0,0 +1,32 @@
export function isDef(value) {
return value !== undefined && value !== null;
}
export function isObj(x) {
const type = typeof x;
return x !== null && (type === 'object' || type === 'function');
}
export function isNumber(value) {
return /^\d+(\.\d+)?$/.test(value);
}
export function range(num, min, max) {
return Math.min(Math.max(num, min), max);
}
export function nextTick(fn) {
setTimeout(() => {
fn();
}, 1000 / 30);
}
let systemInfo = null;
export function getSystemInfoSync() {
if (systemInfo == null) {
systemInfo = wx.getSystemInfoSync();
}
return systemInfo;
}
export function addUnit(value) {
if (!isDef(value)) {
return undefined;
}
value = String(value);
return isNumber(value) ? `${value}px` : value;
}

View File

@ -0,0 +1,2 @@
export declare function canIUseModel(): boolean;
export declare function canIUseFormFieldButton(): boolean;

View File

@ -0,0 +1,31 @@
import { getSystemInfoSync } from './utils';
function compareVersion(v1, v2) {
v1 = v1.split('.');
v2 = v2.split('.');
const len = Math.max(v1.length, v2.length);
while (v1.length < len) {
v1.push('0');
}
while (v2.length < len) {
v2.push('0');
}
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1[i], 10);
const num2 = parseInt(v2[i], 10);
if (num1 > num2) {
return 1;
}
if (num1 < num2) {
return -1;
}
}
return 0;
}
export function canIUseModel() {
const system = getSystemInfoSync();
return compareVersion(system.SDKVersion, '2.9.3') >= 0;
}
export function canIUseFormFieldButton() {
const system = getSystemInfoSync();
return compareVersion(system.SDKVersion, '2.10.3') >= 0;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,27 @@
import { VantComponent } from '../common/component';
VantComponent({
props: {
dot: Boolean,
info: null,
size: null,
color: String,
customStyle: String,
classPrefix: {
type: String,
value: 'van-icon',
},
name: {
type: String,
observer(val) {
this.setData({
isImageName: val.indexOf('/') !== -1,
});
},
},
},
methods: {
onClick() {
this.$emit('click');
},
},
});

View File

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

View File

@ -0,0 +1,20 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<view
class="custom-class {{ classPrefix }} {{ isImageName ? 'van-icon--image' : classPrefix + '-' + name }}"
style="color: {{ color }};font-size: {{ utils.addUnit(size) }};{{ customStyle }}"
bind:tap="onClick"
>
<van-info
wx:if="{{ info !== null || dot }}"
dot="{{ dot }}"
info="{{ info }}"
custom-class="van-icon__info"
/>
<image
wx:if="{{ isImageName }}"
src="{{ name }}"
mode="aspectFit"
class="van-icon__image"
/>
</view>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,8 @@
import { VantComponent } from '../common/component';
VantComponent({
props: {
dot: Boolean,
info: null,
customStyle: String,
},
});

View File

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

View File

@ -0,0 +1,7 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<view
wx:if="{{ info !== null && info !== '' || dot }}"
class="custom-class van-info {{ utils.bem('info', { dot }) }}"
style="{{ customStyle }}"
>{{ dot ? '' : info }}</view>

View File

@ -0,0 +1 @@
@import '../common/index.wxss';.van-info{position:absolute;top:0;right:0;box-sizing:border-box;white-space:nowrap;text-align:center;-webkit-transform:translate(50%,-50%);transform:translate(50%,-50%);-webkit-transform-origin:100%;transform-origin:100%;min-width:16px;min-width:var(--info-size,16px);padding:0 3px;padding:var(--info-padding,0 3px);color:#fff;color:var(--info-color,#fff);font-weight:500;font-weight:var(--info-font-weight,500);font-size:12px;font-size:var(--info-font-size,12px);font-family:Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--info-font-family,Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif);line-height:14px;line-height:calc(var(--info-size, 16px) - var(--info-border-width, 1px)*2);background-color:#ee0a24;background-color:var(--info-background-color,#ee0a24);border:1px solid #fff;border:var(--info-border-width,1px) solid var(--white,#fff);border-radius:16px;border-radius:var(--info-size,16px)}.van-info--dot{min-width:0;border-radius:100%;width:8px;width:var(--info-dot-size,8px);height:8px;height:var(--info-dot-size,8px);background-color:#ee0a24;background-color:var(--info-dot-color,#ee0a24)}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,16 @@
import { VantComponent } from '../common/component';
VantComponent({
props: {
color: String,
vertical: Boolean,
type: {
type: String,
value: 'circular',
},
size: String,
textSize: String,
},
data: {
array12: Array.from({ length: 12 }),
},
});

View File

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

View File

@ -0,0 +1,18 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<view class="custom-class van-loading {{ vertical ? 'van-loading--vertical' : '' }}">
<view
class="van-loading__spinner van-loading__spinner--{{ type }}"
style="color: {{ color }}; width: {{ utils.addUnit(size) }}; height: {{ utils.addUnit(size) }}"
>
<view
wx:if="{{ type === 'spinner' }}"
wx:for="{{ array12 }}"
wx:key="index"
class="van-loading__dot"
/>
</view>
<view class="van-loading__text" style="font-size: {{ utils.addUnit(textSize) }};">
<slot />
</view>
</view>

View File

@ -0,0 +1 @@
@import '../common/index.wxss';:host{font-size:0;line-height:1}.van-loading{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#c8c9cc;color:var(--loading-spinner-color,#c8c9cc)}.van-loading__spinner{position:relative;box-sizing:border-box;width:30px;width:var(--loading-spinner-size,30px);max-width:100%;max-height:100%;height:30px;height:var(--loading-spinner-size,30px);-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite;-webkit-animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite;animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid transparent;border-top-color:initial;border-radius:100%}.van-loading__text{margin-left:8px;margin-left:var(--padding-xs,8px);color:#969799;color:var(--loading-text-color,#969799);font-size:14px;font-size:var(--loading-text-font-size,14px);line-height:20px;line-height:var(--loading-text-line-height,20px)}.van-loading__text:empty{display:none}.van-loading--vertical{-webkit-flex-direction:column;flex-direction:column}.van-loading--vertical .van-loading__text{margin:8px 0 0;margin:var(--padding-xs,8px) 0 0}.van-loading__dot{position:absolute;top:0;left:0;width:100%;height:100%}.van-loading__dot:before{display:block;width:2px;height:25%;margin:0 auto;background-color:currentColor;border-radius:40%;content:" "}.van-loading__dot:first-of-type{-webkit-transform:rotate(30deg);transform:rotate(30deg);opacity:1}.van-loading__dot:nth-of-type(2){-webkit-transform:rotate(60deg);transform:rotate(60deg);opacity:.9375}.van-loading__dot:nth-of-type(3){-webkit-transform:rotate(90deg);transform:rotate(90deg);opacity:.875}.van-loading__dot:nth-of-type(4){-webkit-transform:rotate(120deg);transform:rotate(120deg);opacity:.8125}.van-loading__dot:nth-of-type(5){-webkit-transform:rotate(150deg);transform:rotate(150deg);opacity:.75}.van-loading__dot:nth-of-type(6){-webkit-transform:rotate(180deg);transform:rotate(180deg);opacity:.6875}.van-loading__dot:nth-of-type(7){-webkit-transform:rotate(210deg);transform:rotate(210deg);opacity:.625}.van-loading__dot:nth-of-type(8){-webkit-transform:rotate(240deg);transform:rotate(240deg);opacity:.5625}.van-loading__dot:nth-of-type(9){-webkit-transform:rotate(270deg);transform:rotate(270deg);opacity:.5}.van-loading__dot:nth-of-type(10){-webkit-transform:rotate(300deg);transform:rotate(300deg);opacity:.4375}.van-loading__dot:nth-of-type(11){-webkit-transform:rotate(330deg);transform:rotate(330deg);opacity:.375}.van-loading__dot:nth-of-type(12){-webkit-transform:rotate(1turn);transform:rotate(1turn);opacity:.3125}@-webkit-keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}

View File

@ -0,0 +1 @@
export declare const basic: string;

View File

@ -0,0 +1,27 @@
export const basic = Behavior({
methods: {
$emit(...args) {
this.triggerEvent(...args);
},
set(data, callback) {
this.setData(data, callback);
return new Promise((resolve) => wx.nextTick(resolve));
},
getRect(selector, all) {
return new Promise((resolve) => {
wx.createSelectorQuery()
.in(this)
[all ? 'selectAll' : 'select'](selector)
.boundingClientRect((rect) => {
if (all && Array.isArray(rect) && rect.length) {
resolve(rect);
}
if (!all && rect) {
resolve(rect);
}
})
.exec();
});
},
},
});

View File

@ -0,0 +1 @@
export declare const button: string;

View File

@ -0,0 +1,15 @@
export const button = Behavior({
externalClasses: ['hover-class'],
properties: {
id: String,
lang: String,
businessId: Number,
sessionFrom: String,
sendMessageTitle: String,
sendMessagePath: String,
sendMessageImg: String,
showMessageCard: Boolean,
appParameter: String,
ariaLabel: String,
},
});

View File

@ -0,0 +1 @@
export declare const link: string;

View File

@ -0,0 +1,17 @@
export const link = Behavior({
properties: {
url: String,
linkType: {
type: String,
value: 'navigateTo',
},
},
methods: {
jumpLink(urlKey = 'url') {
const url = this.data[urlKey];
if (url) {
wx[this.data.linkType]({ url });
}
},
},
});

View File

@ -0,0 +1 @@
export declare const openType: string;

View File

@ -0,0 +1,25 @@
export const openType = Behavior({
properties: {
openType: String,
},
methods: {
bindGetUserInfo(event) {
this.$emit('getuserinfo', event.detail);
},
bindContact(event) {
this.$emit('contact', event.detail);
},
bindGetPhoneNumber(event) {
this.$emit('getphonenumber', event.detail);
},
bindError(event) {
this.$emit('error', event.detail);
},
bindLaunchApp(event) {
this.$emit('launchapp', event.detail);
},
bindOpenSetting(event) {
this.$emit('opensetting', event.detail);
},
},
});

View File

@ -0,0 +1,5 @@
/// <reference types="miniprogram-api-typings" />
declare type IPageScrollOption = WechatMiniprogram.Page.IPageScrollOption;
declare type Scroller = (event: IPageScrollOption) => void;
export declare const pageScrollMixin: (scroller: Scroller) => string;
export {};

View File

@ -0,0 +1,33 @@
function getCurrentPage() {
const pages = getCurrentPages();
return pages[pages.length - 1] || {};
}
function onPageScroll(event) {
const { vanPageScroller = [] } = getCurrentPage();
vanPageScroller.forEach((scroller) => {
if (typeof scroller === 'function') {
scroller(event);
}
});
}
export const pageScrollMixin = (scroller) =>
Behavior({
attached() {
const page = getCurrentPage();
if (Array.isArray(page.vanPageScroller)) {
page.vanPageScroller.push(scroller.bind(this));
} else {
page.vanPageScroller =
typeof page.onPageScroll === 'function'
? [page.onPageScroll.bind(page), scroller.bind(this)]
: [scroller.bind(this)];
}
page.onPageScroll = onPageScroll;
},
detached() {
const page = getCurrentPage();
page.vanPageScroller = (page.vanPageScroller || []).filter(
(item) => item !== scroller
);
},
});

View File

@ -0,0 +1 @@
export declare const touch: string;

View File

@ -0,0 +1,36 @@
const MIN_DISTANCE = 10;
function getDirection(x, y) {
if (x > y && x > MIN_DISTANCE) {
return 'horizontal';
}
if (y > x && y > MIN_DISTANCE) {
return 'vertical';
}
return '';
}
export const touch = Behavior({
methods: {
resetTouchStatus() {
this.direction = '';
this.deltaX = 0;
this.deltaY = 0;
this.offsetX = 0;
this.offsetY = 0;
},
touchStart(event) {
this.resetTouchStatus();
const touch = event.touches[0];
this.startX = touch.clientX;
this.startY = touch.clientY;
},
touchMove(event) {
const touch = event.touches[0];
this.deltaX = touch.clientX - this.startX;
this.deltaY = touch.clientY - this.startY;
this.offsetX = Math.abs(this.deltaX);
this.offsetY = Math.abs(this.deltaY);
this.direction =
this.direction || getDirection(this.offsetX, this.offsetY);
},
},
});

View File

@ -0,0 +1 @@
export declare const transition: (showDefaultValue: boolean) => string;

View File

@ -0,0 +1,118 @@
import { isObj } from '../common/utils';
const getClassNames = (name) => ({
enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`,
'enter-to': `van-${name}-enter-to van-${name}-enter-active enter-to-class enter-active-class`,
leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`,
'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class`,
});
const nextTick = () => new Promise((resolve) => setTimeout(resolve, 1000 / 30));
export const transition = function (showDefaultValue) {
return Behavior({
properties: {
customStyle: String,
// @ts-ignore
show: {
type: Boolean,
value: showDefaultValue,
observer: 'observeShow',
},
// @ts-ignore
duration: {
type: null,
value: 300,
observer: 'observeDuration',
},
name: {
type: String,
value: 'fade',
},
},
data: {
type: '',
inited: false,
display: false,
},
methods: {
observeShow(value, old) {
if (value === old) {
return;
}
value ? this.enter() : this.leave();
},
enter() {
const { duration, name } = this.data;
const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.enter : duration;
this.status = 'enter';
this.$emit('before-enter');
Promise.resolve()
.then(nextTick)
.then(() => {
this.checkStatus('enter');
this.$emit('enter');
this.setData({
inited: true,
display: true,
classes: classNames.enter,
currentDuration,
});
})
.then(nextTick)
.then(() => {
this.checkStatus('enter');
this.transitionEnded = false;
this.setData({
classes: classNames['enter-to'],
});
})
.catch(() => {});
},
leave() {
if (!this.data.display) {
return;
}
const { duration, name } = this.data;
const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.leave : duration;
this.status = 'leave';
this.$emit('before-leave');
Promise.resolve()
.then(nextTick)
.then(() => {
this.checkStatus('leave');
this.$emit('leave');
this.setData({
classes: classNames.leave,
currentDuration,
});
})
.then(nextTick)
.then(() => {
this.checkStatus('leave');
this.transitionEnded = false;
setTimeout(() => this.onTransitionEnd(), currentDuration);
this.setData({
classes: classNames['leave-to'],
});
})
.catch(() => {});
},
checkStatus(status) {
if (status !== this.status) {
throw new Error(`incongruent status: ${status}`);
}
},
onTransitionEnd() {
if (this.transitionEnded) {
return;
}
this.transitionEnded = true;
this.$emit(`after-${this.status}`);
const { show, display } = this.data;
if (!show && display) {
this.setData({ display: false });
}
},
},
});
};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,145 @@
import { VantComponent } from "../common/component";
import { pickerProps } from "../picker/shared";
const COLUMNSPLACEHOLDERCODE = "000000";
VantComponent({
classes: ["active-class", "toolbar-class", "column-class"],
props: Object.assign(Object.assign({}, pickerProps), {
value: {
type: Array,
observer(value) {
this.value = value;
this.getSelect();
this.setValues();
},
},
columns: {
type: Array,
value: [],
observer(value) {
this.getSelect();
this.setValues();
},
},
}),
data: {
displayColumns: [],
typeToColumnsPlaceholder: {},
},
mounted() {
// setTimeout(() => {
// this.setValues();
// }, 0);
},
methods: {
getPicker() {
if (this.picker == null) {
this.picker = this.selectComponent(".van-multi-select__picker");
}
return this.picker;
},
onCancel(event) {
this.emit("cancel", event.detail);
},
onConfirm(event) {
const detail = event.detail;
const values = this.parseOutputValues(detail.value);
this.emit("confirm", {text:values.map((x) => x.text),value: values.map((x) => x.key), index:detail.index });
},
emit(type, detail) {
detail.values = detail.value;
delete detail.value;
this.$emit(type, detail);
},
// parse output columns data
parseOutputValues(values) {
return values.map((value, index) => {
return {
key: value.key,
text: value.text,
};
});
},
onChange(event) {
const { index, picker, value } = event.detail;
this.select = { value, index };
this.setValues();
const values = this.parseOutputValues(value);
this.$emit("change", {
picker,
values: values,
value: values.map((x) => x.key),
text: values.map((x) => x.text),
index,
});
},
//初始化赋值核心方法
getSelect(columns = this.data.columns, index = 0, displayColumns = []) {
if (this.value && this.value.length > 0) {
const key = this.value[index];
if (columns && columns.length > 0) {
let selectColumn = columns.find((x) => key == x.key);
if (selectColumn) {
displayColumns.push(selectColumn);
if (selectColumn.childs && selectColumn.childs.length > 0) {
this.getSelect(selectColumn.childs, index + 1, displayColumns);
}
}
}
this.select = {
index: this.value.length - 1,
value: displayColumns,
};
}
},
getColumns(columns = this.data.columns, index = 0, displayColumns = [], select) {
if (columns && columns.length > 0) {
let defaultIndex = 0;
if (select) {
if (index <= select.index) {
const val = select.value[index];
if(val&&val.key){
columns.forEach((x, i) => {
if (x.key == val.key) {
defaultIndex = i;
}
});
}
}
}
displayColumns.push({
values: columns,
defaultIndex: defaultIndex,
});
let firstColumn = columns[defaultIndex];
if (firstColumn.childs && firstColumn.childs.length > 0) {
index++;
this.getColumns(firstColumn.childs, index, displayColumns, select);
}
}
return displayColumns;
},
setValues() {
// const picker = this.getPicker();
// if (!picker) {
// return;
// }
let { select } = this;
const stack = this.getColumns(undefined, undefined, undefined, select);
this.setData({
displayColumns: stack,
});
},
getValues() {
const picker = this.getPicker();
return picker ? picker.getValues().filter((value) => !!value) : [];
},
reset(value) {
this.value = value || [];
return this.setValues();
},
},
});

View File

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

View File

@ -0,0 +1 @@
<van-picker class="van-multi-select__picker" active-class="active-class" toolbar-class="toolbar-class" column-class="column-class" show-toolbar value-key="text" title="{{ title }}" loading="{{ loading }}" columns="{{ displayColumns }}" item-height="{{ itemHeight }}" visible-item-count="{{ visibleItemCount }}" cancel-button-text="{{ cancelButtonText }}" confirm-button-text="{{ confirmButtonText }}" bind:change="onChange" bind:confirm="onConfirm" bind:cancel="onCancel" />

View File

@ -0,0 +1 @@
@import '../common/index.wxss';

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,123 @@
import { VantComponent } from '../common/component';
import { isObj, range } from '../common/utils';
const DEFAULT_DURATION = 200;
VantComponent({
classes: ['active-class'],
props: {
valueKey: String,
className: String,
itemHeight: Number,
visibleItemCount: Number,
initialOptions: {
type: Array,
value: [],
},
defaultIndex: {
type: Number,
value: 0,
observer(value) {
this.setIndex(value);
},
},
},
data: {
startY: 0,
offset: 0,
duration: 0,
startOffset: 0,
options: [],
currentIndex: 0,
},
created() {
const { defaultIndex, initialOptions } = this.data;
this.set({
currentIndex: defaultIndex,
options: initialOptions,
}).then(() => {
this.setIndex(defaultIndex);
});
},
methods: {
getCount() {
return this.data.options.length;
},
onTouchStart(event) {
this.setData({
startY: event.touches[0].clientY,
startOffset: this.data.offset,
duration: 0,
});
},
onTouchMove(event) {
const { data } = this;
const deltaY = event.touches[0].clientY - data.startY;
this.setData({
offset: range(
data.startOffset + deltaY,
-(this.getCount() * data.itemHeight),
data.itemHeight
),
});
},
onTouchEnd() {
const { data } = this;
if (data.offset !== data.startOffset) {
this.setData({ duration: DEFAULT_DURATION });
const index = range(
Math.round(-data.offset / data.itemHeight),
0,
this.getCount() - 1
);
this.setIndex(index, true);
}
},
onClickItem(event) {
const { index } = event.currentTarget.dataset;
this.setIndex(index, true);
},
adjustIndex(index) {
const { data } = this;
const count = this.getCount();
index = range(index, 0, count);
for (let i = index; i < count; i++) {
if (!this.isDisabled(data.options[i])) return i;
}
for (let i = index - 1; i >= 0; i--) {
if (!this.isDisabled(data.options[i])) return i;
}
},
isDisabled(option) {
return isObj(option) && option.disabled;
},
getOptionText(option) {
const { data } = this;
return isObj(option) && data.valueKey in option
? option[data.valueKey]
: option;
},
setIndex(index, userAction) {
const { data } = this;
index = this.adjustIndex(index) || 0;
const offset = -index * data.itemHeight;
if (index !== data.currentIndex) {
return this.set({ offset, currentIndex: index }).then(() => {
userAction && this.$emit('change', index);
});
}
return this.set({ offset });
},
setValue(value) {
const { options } = this.data;
for (let i = 0; i < options.length; i++) {
if (this.getOptionText(options[i]) === value) {
return this.setIndex(i);
}
}
return Promise.resolve();
},
getValue() {
const { data } = this;
return data.options[data.currentIndex];
},
},
});

View File

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

View File

@ -0,0 +1,22 @@
<wxs src="./index.wxs" module="getOptionText" />
<view
class="van-picker-column custom-class"
style="height: {{ itemHeight * visibleItemCount }}px"
bind:touchstart="onTouchStart"
catch:touchmove="onTouchMove"
bind:touchend="onTouchEnd"
bind:touchcancel="onTouchEnd"
>
<view style="transition: transform {{ duration }}ms; line-height: {{ itemHeight }}px; transform: translate3d(0, {{ offset + (itemHeight * (visibleItemCount - 1)) / 2 }}px, 0)">
<view
wx:for="{{ options }}"
wx:for-item="option"
wx:key="index"
data-index="{{ index }}"
style="height: {{ itemHeight }}px"
class="van-ellipsis van-picker-column__item {{ option && option.disabled ? 'van-picker-column__item--disabled' : '' }} {{ index === currentIndex ? 'van-picker-column__item--selected active-class' : '' }}"
bindtap="onClickItem"
>{{ getOptionText(option, valueKey) }}</view>
</view>
</view>

View File

@ -0,0 +1,8 @@
function isObj(x) {
var type = typeof x;
return x !== null && (type === 'object' || type === 'function');
}
module.exports = function (option, valueKey) {
return isObj(option) && option[valueKey] != null ? option[valueKey] : option;
}

View File

@ -0,0 +1 @@
@import '../common/index.wxss';.van-picker-column{overflow:hidden;text-align:center;color:#000;color:var(--picker-option-text-color,#000);font-size:16px;font-size:var(--picker-option-font-size,16px)}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{font-weight:500;font-weight:var(--font-weight-bold,500);color:#323233;color:var(--picker-option-selected-text-color,#323233)}.van-picker-column__item--disabled{opacity:.3;opacity:var(--picker-option-disabled-opacity,.3)}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,145 @@
import { VantComponent } from '../common/component';
import { pickerProps } from './shared';
VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: Object.assign(Object.assign({}, pickerProps), {
valueKey: {
type: String,
value: 'text',
},
toolbarPosition: {
type: String,
value: 'top',
},
defaultIndex: {
type: Number,
value: 0,
},
columns: {
type: Array,
value: [],
observer(columns = []) {
this.simple = columns.length && !columns[0].values;
this.children = this.selectAllComponents('.van-picker__column');
if (Array.isArray(this.children) && this.children.length) {
this.setColumns().catch(() => {});
}
},
},
}),
beforeCreate() {
this.children = [];
},
methods: {
noop() {},
setColumns() {
const { data } = this;
const columns = this.simple ? [{ values: data.columns }] : data.columns;
const stack = columns.map((column, index) =>
this.setColumnValues(index, column.values)
);
return Promise.all(stack);
},
emit(event) {
const { type } = event.currentTarget.dataset;
if (this.simple) {
this.$emit(type, {
value: this.getColumnValue(0),
index: this.getColumnIndex(0),
});
} else {
this.$emit(type, {
value: this.getValues(),
index: this.getIndexes(),
});
}
},
onChange(event) {
if (this.simple) {
this.$emit('change', {
picker: this,
value: this.getColumnValue(0),
index: this.getColumnIndex(0),
});
} else {
this.$emit('change', {
picker: this,
value: this.getValues(),
index: event.currentTarget.dataset.index,
});
}
},
// get column instance by index
getColumn(index) {
return this.children[index];
},
// get column value by index
getColumnValue(index) {
const column = this.getColumn(index);
return column && column.getValue();
},
// set column value by index
setColumnValue(index, value) {
const column = this.getColumn(index);
if (column == null) {
return Promise.reject(new Error('setColumnValue: 对应列不存在'));
}
return column.setValue(value);
},
// get column option index by column index
getColumnIndex(columnIndex) {
return (this.getColumn(columnIndex) || {}).data.currentIndex;
},
// set column option index by column index
setColumnIndex(columnIndex, optionIndex) {
const column = this.getColumn(columnIndex);
if (column == null) {
return Promise.reject(new Error('setColumnIndex: 对应列不存在'));
}
return column.setIndex(optionIndex);
},
// get options of column by index
getColumnValues(index) {
return (this.children[index] || {}).data.options;
},
// set options of column by index
setColumnValues(index, options, needReset = true) {
const column = this.children[index];
if (column == null) {
return Promise.reject(new Error('setColumnValues: 对应列不存在'));
}
const isSame =
JSON.stringify(column.data.options) === JSON.stringify(options);
if (isSame) {
return Promise.resolve();
}
return column.set({ options }).then(() => {
if (needReset) {
column.setIndex(0);
}
});
},
// get values of all columns
getValues() {
return this.children.map((child) => child.getValue());
},
// set values of all columns
setValues(values) {
const stack = values.map((value, index) =>
this.setColumnValue(index, value)
);
return Promise.all(stack);
},
// get indexes of all columns
getIndexes() {
return this.children.map((child) => child.data.currentIndex);
},
// set indexes of all columns
setIndexes(indexes) {
const stack = indexes.map((optionIndex, columnIndex) =>
this.setColumnIndex(columnIndex, optionIndex)
);
return Promise.all(stack);
},
},
});

View File

@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"picker-column": "../picker-column/index",
"loading": "../loading/index"
}
}

View File

@ -0,0 +1,19 @@
<import src="./toolbar.wxml" />
<view class="van-picker custom-class">
<template is="toolbar" wx:if="{{ toolbarPosition === 'top' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
<view wx:if="{{ loading }}" class="van-picker__loading">
<loading color="#1989fa" />
</view>
<view class="van-picker__columns" style="height: {{ itemHeight * visibleItemCount }}px" catch:touchmove="noop">
<picker-column class="van-picker__column" wx:for="{{ isSimple(columns) ? [columns] : columns }}" wx:key="index" data-index="{{ index }}" custom-class="column-class" value-key="{{ valueKey }}" initial-options="{{ isSimple(columns) ? item : item.values }}" default-index="{{ item.defaultIndex || defaultIndex }}" item-height="{{ itemHeight }}" visible-item-count="{{ visibleItemCount }}" active-class="active-class" bind:change="onChange" />
<view class="van-picker__mask" style="background-size: 100% {{ (itemHeight * visibleItemCount - itemHeight) / 2 }}px" />
<view class="van-picker__frame van-hairline--top-bottom" style="height: {{ itemHeight }}px" />
</view>
<template is="toolbar" wx:if="{{ toolbarPosition === 'bottom' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
</view>
<wxs module="isSimple">
function isSimple(columns) {
return columns.length && !columns[0].values;
}
module.exports = isSimple;
</wxs>

View File

@ -0,0 +1 @@
@import '../common/index.wxss';.van-picker{position:relative;overflow:hidden;-webkit-text-size-adjust:100%;-webkit-user-select:none;user-select:none;background-color:#fff;background-color:var(--picker-background-color,#fff)}.van-picker__toolbar{display:-webkit-flex;display:flex;-webkit-justify-content:space-between;justify-content:space-between;height:44px;height:var(--picker-toolbar-height,44px);line-height:44px;line-height:var(--picker-toolbar-height,44px)}.van-picker__cancel,.van-picker__confirm{padding:0 16px;padding:var(--picker-action-padding,0 16px);font-size:14px;font-size:var(--picker-action-font-size,14px);color:#1989fa;color:var(--picker-action-text-color,#1989fa)}.van-picker__cancel--hover,.van-picker__confirm--hover{background-color:#f2f3f5;background-color:var(--picker-action-active-color,#f2f3f5)}.van-picker__title{max-width:50%;text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--picker-option-font-size,16px)}.van-picker__columns{position:relative;display:-webkit-flex;display:flex}.van-picker__column{-webkit-flex:1 1;flex:1 1;width:0}.van-picker__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:4;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;background-color:hsla(0,0%,100%,.9);background-color:var(--picker-loading-mask-color,hsla(0,0%,100%,.9))}.van-picker__mask{position:absolute;top:0;left:0;z-index:2;width:100%;height:100%;background-image:linear-gradient(180deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4)),linear-gradient(0deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4));background-repeat:no-repeat;background-position:top,bottom;-webkit-backface-visibility:hidden;backface-visibility:hidden;pointer-events:none}.van-picker__frame,.van-picker__loading .van-loading{position:absolute;top:50%;left:0;z-index:1;width:100%;-webkit-transform:translateY(-50%);transform:translateY(-50%);pointer-events:none}

View File

@ -0,0 +1,21 @@
export declare const pickerProps: {
title: StringConstructor;
loading: BooleanConstructor;
showToolbar: BooleanConstructor;
cancelButtonText: {
type: StringConstructor;
value: string;
};
confirmButtonText: {
type: StringConstructor;
value: string;
};
visibleItemCount: {
type: NumberConstructor;
value: number;
};
itemHeight: {
type: NumberConstructor;
value: number;
};
};

View File

@ -0,0 +1,21 @@
export const pickerProps = {
title: String,
loading: Boolean,
showToolbar: Boolean,
cancelButtonText: {
type: String,
value: '取消',
},
confirmButtonText: {
type: String,
value: '确认',
},
visibleItemCount: {
type: Number,
value: 5,
},
itemHeight: {
type: Number,
value: 44,
},
};

View File

@ -0,0 +1,28 @@
<template name="toolbar">
<view
wx:if="{{ showToolbar }}"
class="van-picker__toolbar van-hairline--top-bottom toolbar-class"
>
<view
class="van-picker__cancel"
hover-class="van-picker__cancel--hover"
hover-stay-time="70"
data-type="cancel"
bindtap="emit"
>
{{ cancelButtonText }}
</view>
<view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{
title
}}</view>
<view
class="van-picker__confirm"
hover-class="van-picker__confirm--hover"
hover-stay-time="70"
data-type="confirm"
bindtap="emit"
>
{{ confirmButtonText }}
</view>
</view>
</template>

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