master
CGW 2 years ago
parent 68da532b36
commit 00b091385d

@ -0,0 +1,14 @@
# Windows
[Dd]esktop.ini
Thumbs.db
$RECYCLE.BIN/
# macOS
.DS_Store
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
# Node.js
node_modules/

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

@ -0,0 +1,72 @@
// 云函数入口文件
const cloud = require('wx-server-sdk')
const TcbRouter = require('tcb-router');
const axios = require('axios')
const Qs= require('qs')
cloud.init({
env: "cloud1-0gle9p5m591ea29f"
})
let db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
let {
APPID,
OPENID
} = wxContext
const app = new TcbRouter({
event
})
//提供通过文本进行垃圾分类查询的能力
app.router('garbageTextSearch', async (ctx, next) => {
let {
text,
} = event
ctx.body = axios({
method:'post',
url:'https://apis.tianapi.com/lajifenlei/index',
data:Qs.stringify({key:'ff5c44567b996ea8090d1abb7c1f3bc9',word:text}),
headers:{'Content-Type': 'application/x-www-form-urlencoded'}
}).then(res => {
return res.data
})
})
//通过图片进行垃圾分类查询的能力
app.router('garbageImageSearch', async (ctx, next) => {
let {
imgBase64,
} = event
const img = await cloud.downloadFile({
fileID: imgBase64
})
let buffer = new Buffer.from(img.fileContent)
cloud.deleteFile({
fileList: [imgBase64]
})
let str = buffer.toString('base64')
ctx.body = axios({
method:'post',
url:'https://apis.tianapi.com/imglajifenlei/index',
data:Qs.stringify({key:'ff5c44567b996ea8090d1abb7c1f3bc9',img:str}),
headers:{'Content-Type': 'application/x-www-form-urlencoded'}
}).then(res => {
return res.data
})
});
//获取用户openID
app.router('openId', async (ctx, next) => {
ctx.body = {
openId: OPENID
}
})
return app.serve()
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,20 @@
{
"name": "api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.20.0",
"debug": "^4.3.1",
"jdcloud-sdk-signer": "^2.0.2",
"md5-node": "^1.0.1",
"qs": "^6.9.4",
"tcb-router": "^1.1.2",
"wx-server-sdk": "~2.3.0"
}
}

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

@ -0,0 +1,520 @@
const cloud = require('wx-server-sdk')
const TcbRouter = require('tcb-router');
const xlsx = require('node-xlsx');
let {
FormatData
} = require('./util.js');
cloud.init({
env: "cloud1-0gle9p5m591ea29f"
})
let db = cloud.database()
const _ = db.command
const $ = db.command.aggregate
const MAXANSWER = 10
const MAX_LIMIT = 100
const INTEGRAL = {
SHARE: 50
}
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
let {
APPID,
OPENID
} = wxContext
const app = new TcbRouter({
event
})
//添加搜索历史
app.router('addHot', async (ctx, next) => {
let {
hot_text,
} = event
let hot = db.collection('hot')
let {
total
} = await hot.where({
hot_text: hot_text
}).count()
if (total) {
await hot.where({
hot_text: hot_text
})
.update({
data: {
hot_num: _.inc(1)
}
})
} else {
await hot.add({
data: {
hot_text: hot_text,
hot_time: new Date(),
hot_num: 1
}
})
}
ctx.body = {
code: 1,
msg: "添加成功"
}
})
//获取热点搜索
app.router('getHot', async (ctx, next) => {
let hot = db.collection('hot')
let {
data
} = await hot.orderBy('hot_num', 'desc').limit(10).get()
ctx.body = {
code: 1,
data
}
})
//用户登录
app.router('login', async (ctx, next) => {
let {
userInfo
} = event
let user = db.collection('user')
let {
total
} = await user.where({
OPENID: OPENID
}).count()
if (total) {
await user.where({
OPENID: OPENID
})
.update({
data: userInfo
})
} else {
await user.add({
data: {
nickName: userInfo.nickName,
gender: userInfo.gender,
avatarUrl: userInfo.avatarUrl,
OPENID: OPENID,
integral: 0,
answerIntegral: 0
}
})
}
let {
data
} = await user.where({
OPENID: OPENID
}).get()
ctx.body = {
code: 1,
msg: "添加成功",
userInfo: data[0]
}
})
//获取个人信息
app.router('getUserInfo', async (ctx, next) => {
let user = db.collection('user')
let {
data
} = await user.where({
OPENID: OPENID
}).get()
ctx.body = {
code: 1,
userInfo: data[0]
}
})
//获得题目
app.router('answerList', async (ctx, next) => {
let answer = db.collection('answer')
let {
list
} = await answer.aggregate()
.sample({
size: MAXANSWER
}).end()
ctx.body = {
code: 1,
data: list
}
})
//添加题目
app.router('addAnswer', async (ctx, next) => {
let {
name,
type
} = event
let answer = db.collection('answer')
let {
total
} = await answer.where({
name
}).count()
if (total) {
ctx.body = {
code: 2,
data: "无法重复添加"
}
} else {
await answer.add({
data: {
name,
type
}
})
ctx.body = {
code: 1,
data: "添加成功"
}
}
})
//扫码获取积分
app.router('scanCode', async (ctx, next) => {
let {
integral
} = event
let user = db.collection('user')
/**
* 添加用户积分
*/
await user.where({
OPENID: OPENID
}).update({
data: {
integral: _.inc(Number(integral))
}
})
ctx.body = {
code: 1
}
})
//添加反馈
app.router('addFeedback', async (ctx, next) => {
let {
content
} = event
let feedback = db.collection('feedback')
await feedback.add({
data: {
content,
isRead: false,
time: db.serverDate(),
OPENID
}
})
ctx.body = {
code: 1,
data: "添加成功"
}
})
//删除错题
app.router('delWrongUser', async (ctx, next) => {
let {
_id
} = event
let wrong = db.collection('wrong')
await wrong.where({
_id: _id
}).remove()
ctx.body = {
code: 1,
msg: "删除成功",
data: ''
}
})
//获取用户答题积分排名列表
app.router('getUserAnswerlist', async (ctx, next) => {
let user = db.collection('user')
let {
data
} = await user.orderBy('answerIntegral', 'desc').limit(MAX_LIMIT).get()
ctx.body = {
code: 1,
data: data
}
})
//获取用户答题积分排名
app.router('getUseRanking', async (ctx, next) => {
let user = db.collection('user')
const countResult = await user.count()
const total = countResult.total
const batchTimes = Math.ceil(total / MAX_LIMIT)
const tasks = []
for (let i = 0; i < batchTimes; i++) {
const promise = user.orderBy('answerIntegral', 'desc').skip(i * MAX_LIMIT).limit(MAX_LIMIT).get()
tasks.push(promise)
}
let allData = (await Promise.all(tasks)).reduce((acc, cur) => {
return acc.concat(cur.data)
}, [])
let userIndex = allData.findIndex(item => item.OPENID == OPENID)
if (~userIndex) {
userIndex += 1
}
ctx.body = {
code: 1,
data: {
userIndex
}
}
})
//获取用户答题记录
app.router('getHistoryList', async (ctx, next) => {
let answerHistory = db.collection('answer-history')
let {
data
} = await answerHistory.where({
OPENID: OPENID
}).orderBy('historyDate', 'desc').get()
ctx.body = {
code: 1,
data: FormatData(data, {
historyDate: "time"
})
}
})
/**
* 分享他人他人进入小程序
*/
app.router('shareOther', async (ctx, next) => {
let user = db.collection('user')
let share = db.collection('share')
let {
otherOPENID
} = event
let {
total
} = await user.where({
OPENID: OPENID
}).count()
if (total) {
ctx.body = {
code: 2,
msg: "用户已注册"
}
} else {
await share.add({
data: {
OPENID: OPENID,
otherOPENID: otherOPENID,
addIntegral: INTEGRAL.SHARE,
time: new Date()
}
})
await user.where({
OPENID: otherOPENID
}).update({
data: {
integral: _.inc(Number(INTEGRAL.SHARE))
}
})
ctx.body = {
code: 1,
msg: "分享成功"
}
}
})
/**
* 获取我邀请的用户
*/
app.router('shareUser', async (ctx, next) => {
let share = db.collection('share')
let {
list
} = await share.aggregate()
.lookup({
from: "user",
localField: 'OPENID',
foreignField: 'OPENID',
as: 'uapproval'
}).match({
otherOPENID: OPENID
})
.project({
otherOPENID: 1,
time: 1,
addIntegral: 1,
OPENID: 1,
userInfo: $.arrayElemAt(['$uapproval', 0])
}).end()
ctx.body = {
code: 1,
data: FormatData(list, {
time: "time"
})
}
})
/**
* 后台代码
*/
//获取用户列表
app.router('getUserlist', async (ctx, next) => {
let {
page,
limit
} = event
let goods = db.collection('user')
let {
data
} = await goods.skip((page - 1) * limit)
.limit(limit).get()
ctx.body = {
code: 1,
data: data
}
})
//获取用户反馈未读的数量
app.router('getUserFeedbackNoreadNum', async (ctx, next) => {
let feedback = db.collection('feedback')
let {
total
} = await feedback.where({
isRead: false
}).count()
ctx.body = {
code: 1,
msg: "获取成功",
data: total
}
})
//获取用户反馈
app.router('getFeedbackAdminlist', async (ctx, next) => {
let {
page,
limit
} = event
let feedback = db.collection('feedback')
let {
list
} = await feedback.aggregate()
.lookup({
from: "user",
localField: 'OPENID',
foreignField: 'OPENID',
as: 'userInfo'
})
.unwind('$userInfo')
.project({
content: true,
time: true,
isRead: true,
nickName: "$userInfo.nickName",
avatarUrl: "$userInfo.avatarUrl",
gender: "$userInfo.gender",
integral: "$userInfo.integral",
userId: "$userInfo._id"
})
.skip((page - 1) * limit)
.limit(limit)
.end()
console.log(list)
ctx.body = {
code: 1,
data: FormatData(list, {
time: "date"
})
}
})
//改变反馈状态
app.router('updataFeedbackReadAdmin', async (ctx, next) => {
let {
_id
} = event
let feedback = db.collection('feedback')
await feedback.where({
_id: _id
}).update({
data: {
isRead: true
}
})
ctx.body = {
code: 1,
msg: "修改成功",
data: ''
}
})
/**
* 导入垃圾分类的题目
*/
app.router('importAnswer', async (ctx, next) => {
const answer = db.collection('answer')
let {
fileID
} = event
const res = await cloud.downloadFile({
fileID: fileID
})
const buffer = res.fileContent
const tasks = []
var sheets = xlsx.parse(buffer);
sheets.forEach(async function (sheet) {
for (var rowId in sheet['data']) {
var row = sheet['data'][rowId];
if (rowId > 0 && row) {
let name = row[0]
let type = row[1]
let {
total
} = await answer.where({
name
}).count()
if (!total) {
tasks.push(answer.add({
data: {
name: name,
type: type
}
}))
}
}
}
})
await Promise.all(tasks)
ctx.body = {
code: 1,
msg: "导入成功"
}
})
return app.serve();
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,16 @@
{
"name": "db",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"node-xlsx": "^0.16.1",
"tcb-router": "^1.1.2",
"wx-server-sdk": "~2.3.0"
}
}

@ -0,0 +1,56 @@
function formateDate(datetime, type = 's') {
function addDateZero(num) {
return (num < 10 ? "0" + num : num);
}
let d = new Date(datetime);
console.log(d)
let formatdatetime;
if (type == 's') {
formatdatetime = d.getFullYear() + '-' + addDateZero(d.getMonth() + 1) + '-' + addDateZero(d.getDate()) + ' ' + addDateZero(d.getHours()) + ':' + addDateZero(d.getMinutes()) + ':' + addDateZero(d.getSeconds());
} else if (type == 'd') {
formatdatetime = d.getFullYear() + '-' + addDateZero(d.getMonth() + 1) + '-' + addDateZero(d.getDate());
}
return formatdatetime;
}
function FormatData(data, obj) {
let val = data
if (Array.isArray(val)) {
val.forEach(info => {
Object.entries(obj).forEach(item => {
if (item[1] === '' || item[1] === null || item[1] === undefined) {
return;
}
let format = item[1].split('|')
format.forEach(k => {
if (k == 'json') {
info[item[0]] = JSON.parse(info[item[0]])
} else if (k == 'date') {
info[item[0]] = formateDate(info[item[0]])
} else if (k == 'time') {
info[item[0]] = formateDate(info[item[0]], 'd')
}
})
})
})
} else {
Object.entries(obj).forEach(item => {
if (item[1] === '' || item[1] === null || item[1] === undefined) {
return;
}
let format = item[1].split('|')
format.forEach(k => {
if (k == 'json') {
console.log(val, val[item[0]])
val[item[0]] = JSON.parse(val[item[0]])
} else if (k == 'date') {
val[item[0]] = formateDate(val[item[0]])
} else if (k == 'time') {
val[item[0]] = formateDate(val[item[0]], 'd')
}
})
})
}
return val
}
exports.FormatData = FormatData;

@ -0,0 +1 @@
{"_id":"79550af260aa3c441974adb65a2c8c6c","OPENID":"obt995TUKes91H6qGLsCC96JP324","historyIntervalTime":"00:03","historyDate":{"$date":"2021-05-23T11:28:04.056Z"},"historyFraction":10,"historyIntegral":10}

@ -0,0 +1,3 @@
{"_id":"8e5be7055f65d4e80021de7315079ff7","name":"苹果","type":"厨余垃圾"}
{"_id":"d782d4875f66e939001e664f58227153","name":"电视机","type":"可回收物"}
{"_id":"1b64dd7b5f66ea3300252d952d0238cc","name":"电冰箱","type":"可回收物"}

@ -0,0 +1 @@
{"_id":"28ee4e3e604d85b70a86bcb269744214","content":"测试","time":{"$date":"2021-03-14T03:40:39.911Z"},"OPENID":"omiwO5CUdC1CeXVAoxvcBbLFkYb8","isRead":true}

@ -0,0 +1,17 @@
{"_id":"6518b7395f5e0d15016bcfda4cc9c437","hot_num":10.0,"hot_text":"面包","hot_time":{"$date":"2020-09-13T12:13:44.018Z"}}
{"_id":"65825b355f5e11aa01384e29526eebd2","hot_text":"桌子","hot_time":{"$date":"2020-09-13T12:33:47.019Z"},"hot_num":3}
{"_id":"aa133ce55f5e14540127c6ab10096d0d","hot_text":"洗衣机","hot_time":{"$date":"2020-09-13T12:45:08.316Z"},"hot_num":3}
{"_id":"aa133ce55f5e14ed0127cb5863456447","hot_text":"洗面奶","hot_time":{"$date":"2020-09-13T12:47:42.143Z"},"hot_num":2}
{"_id":"7498b5fe5f5e15450175c1612fe4be17","hot_text":"豆浆","hot_time":{"$date":"2020-09-13T12:49:09.704Z"},"hot_num":2}
{"_id":"aa133ce55f5e35fc0128bcf7038438ef","hot_text":"土豆","hot_time":{"$date":"2020-09-13T15:08:44.497Z"},"hot_num":2}
{"_id":"ac5f38825f5ebf4b017d60ab56cc4d58","hot_text":"电饭煲","hot_time":{"$date":"2020-09-14T00:54:35.443Z"},"hot_num":4}
{"_id":"b333e0365fa40a6f004a72707c95dc5e","hot_text":"平板电脑","hot_time":{"$date":"2020-11-05T14:21:35.762Z"},"hot_num":1}
{"_id":"9f2a34705fdcb60d002154d7644a9a97","hot_text":"女朋友","hot_time":{"$date":"2020-12-18T14:00:45.379Z"},"hot_num":2}
{"_id":"a8831daa5fddc3870033081c622cbbaa","hot_text":"手机","hot_time":{"$date":"2020-12-19T09:10:31.37Z"},"hot_num":1}
{"_id":"2f6ab8515fdef0f8002e88c048099659","hot_text":"被子","hot_time":{"$date":"2020-12-20T06:36:40.943Z"},"hot_num":1}
{"_id":"73f70d5c5fe412af006f5fec64a5323b","hot_text":"水杯","hot_time":{"$date":"2020-12-24T04:01:51.847Z"},"hot_num":1}
{"_id":"85ff8afa5fe88ab600c5e1ac4d8e5bab","hot_text":"牛奶","hot_time":{"$date":"2020-12-27T13:23:02.176Z"},"hot_num":1}
{"_id":"be7fb3985ff6ae360315d712395d9107","hot_text":"水浒","hot_time":{"$date":"2021-01-07T06:46:14.844Z"},"hot_num":1}
{"_id":"b45a21d55ff6ae4203f810da27b8e00e","hot_text":"苹果","hot_time":{"$date":"2021-01-07T06:46:26.624Z"},"hot_num":1}
{"_id":"ce805e785ffaa6f503e146e5121750f4","hot_text":"香蕉","hot_time":{"$date":"2021-01-10T07:04:21.778Z"},"hot_num":1}
{"_id":"1526e12a6006b0980015dbdc35c85841","hot_text":"口罩","hot_time":{"$date":"2021-01-19T10:12:40.008Z"},"hot_num":1}

@ -0,0 +1,2 @@
{"_id":"407a0a0563491b9a0229898b5a7a1e53"}
{"_id":"8655d51b63552272001431cf1595c687","nickName":"。","gender":0,"avatarUrl":"https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83er8FogaAiaPVKLZOIEiaCLnajQ1AjZmC1IZ6V4SmZg7h1nXMqyHZ4Xbzf5C4OjSbyABks8pHXvQ5LJQ/132","OPENID":"o58l05K41tf8fcoDL_TjEnLc1PJM","integral":35,"answerIntegral":90}

@ -0,0 +1,3 @@
{"_id":"79550af2600982c7005f48324cb1fb7f","OPENID":"omiwO5HzbJGkXCAUm0s1EnoHgkQ8","name":"苹果","type":"厨余垃圾","check":"有害垃圾"}
{"_id":"b00064a7600982c7006665990505577e","OPENID":"omiwO5HzbJGkXCAUm0s1EnoHgkQ8","name":"电视机","type":"可回收物","check":"有害垃圾"}
{"_id":"79550af2600982c7005f48334f8edd02","OPENID":"omiwO5HzbJGkXCAUm0s1EnoHgkQ8","name":"电冰箱","type":"可回收物","check":"厨余垃圾"}

@ -1 +0,0 @@
Subproject commit 3fba150fc62a4e489e177edb728d29004c7b9fea

@ -0,0 +1,137 @@
import * as db from './util/db.js';
import * as util from './util/util.js';
let userInfo = db.get("userInfo") || {}
let isLogin = JSON.stringify(userInfo) != "{}"
var plugin = requirePlugin("chatbot");
App({
onLaunch: function () {
this.autoUpdate()
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
} else {
wx.cloud.init({
env:'cloud1-0gle9p5m591ea29f',
TraceUser:true
})
}
wx.cloud.callFunction({
name: 'api',
data: {
$url: "openId"
}
}).then(res => {
plugin.init({
appid: "wxb410947324244ff9",
openid: res.result.openId,
guideList: ['苹果是什么垃圾?', '帮我查下垃圾分类'],
welcome: "你好",
guideCardHeight: 36,
operateCardHeight: 56,
textToSpeech: false,
hideMovableButton: false,
success: () => {},
fail: error => {}
});
})
},
onShow() {
this.onNetworkStatusChange()
},
onNetworkStatusChange() {
var that = this
wx.getNetworkType({
success: function (res) {
const networkType = res.networkType
if ('none' != networkType) {
that.globalData.nonetwork = true
wx.onNetworkStatusChange(function (res) {
if (res.isConnected) {
that.globalData.nonetwork = true
} else {
that.globalData.nonetwork = false
}
})
} else {
wx.onNetworkStatusChange(function (res) {
if (res.isConnected) {
that.globalData.nonetwork = true
} else {
that.globalData.nonetwork = false
}
})
}
},
})
},
$db: db,
$util: util,
globalData: {
nonetwork: false,
userInfo: userInfo,
isLogin: isLogin,
appInfo: {
appName: "垃圾分类管理"
}
},
autoUpdate: function () {
var self = this
// 获取小程序更新机制兼容
if (wx.canIUse('getUpdateManager')) {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
if (res.hasUpdate) {
//检测到新版本,需要更新,给出提示
wx.showModal({
title: '更新提示',
content: '检测到新版本,是否下载新版本并重启小程序?',
success: function (res) {
if (res.confirm) {
self.downLoadAndUpdate(updateManager)
} else if (res.cancel) {
wx.showModal({
title: '温馨提示~',
content: '本次版本更新涉及到新的功能添加',
confirmText: "确定更新",
success: function (res) {
if (res.confirm) {
self.downLoadAndUpdate(updateManager)
}
}
})
}
}
})
}
})
}
},
/**
* 下载小程序新版本并重启应用
*/
downLoadAndUpdate: function (updateManager) {
wx.showLoading();
updateManager.onUpdateReady(function () {
wx.hideLoading()
updateManager.applyUpdate()
})
updateManager.onUpdateFailed(function () {
wx.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
})
})
},
deductionIntegral: new Map([
//使用文字识别垃圾消耗的积分数目
['garbageTextSearch', 0],
//使用图片识别垃圾消耗的积分数目
['garbageImageSearch', 0]
])
})

@ -0,0 +1,74 @@
{
"pages": [
"pages/index/index",
"pages/search/search",
"pages/photo/photo",
"pages/detail/detail",
"pages/answer/answer-home/answer-home",
"pages/answer/answer-run/answer-run",
"pages/user/user",
"pages/result/result",
"pages/admin/admin",
"pages/adminList/adminList",
"pages/adminAnswer/adminAnswer",
"pages/download/download",
"pages/feedback/feedback",
"pages/adminUser/userList/userList",
"pages/adminFeedback/feedbackList/feedbackList",
"pages/answer/answer-ranking/answer-ranking",
"pages/answer/answer-history/answer-history",
"pages/shareList/shareList"
],
"window": {
"backgroundColor": "#F6F6F6",
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#F6F6F6",
"navigationBarTitleText": "垃圾分类",
"navigationBarTextStyle": "black"
},
"plugins": {
"chatbot": {
"version": "1.1.24",
"provider": "wx8c631f7e9f2465e1"
},
"WechatSI": {
"version": "0.3.1",
"provider": "wx069ba97219f66d99"
}
},
"requiredBackgroundModes": [
"audio"
],
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"tabBar": {
"color": "#000000",
"selectedColor": "#00cc77",
"backgroundColor": "#FFFFFF",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "/static/image/home.png",
"selectedIconPath": "/static/image/home_action.png"
},
{
"pagePath": "pages/answer/answer-home/answer-home",
"text": " 答题",
"iconPath": "/static/image/answer.png",
"selectedIconPath": "/static/image/answer_action.png"
},
{
"pagePath": "pages/user/user",
"text": " 用户",
"iconPath": "/static/image/user.png",
"selectedIconPath": "/static/image/user_action.png"
}
]
},
"sitemapLocation": "sitemap.json",
"style": "v2"
}

@ -0,0 +1,29 @@
@import '/miniprogram_npm/weui-miniprogram/weui-wxss/dist/style/weui.wxss';
@import "./static/css/animation.wxss";
@import "./static/css/icon.wxss";
@import "./static/css/main.wxss";
@import "./static/css/my-icon.wxss";
page {
color: #333;
background: #fff;
--indexL: #00cc77;
--bg-c241: rgb(241, 241, 241);
--font-black6: rgba(0, 0, 0, 0.5);
}
.m-btn {
border-radius: 16rpx;
background-color: var(--indexL);
}
.info-lable {
position: fixed;
left: 0;
right: 0;
bottom: 20rpx;
color: #aaaaaa;
font-size: 22rpx;
text-align: center;
}

@ -0,0 +1,87 @@
let timter = null
Component({
properties: {
minuteTnterval: {
type: Number,
value: false
},
},
data: {
startTime: 0,
endTime: 0,
hour: 0,
minute: 0,
secondsec: 0
},
attached: function () {
var startTime = new Date().getTime()
var endTime = startTime + this.data.minuteTnterval * 60000
this.setData({
startTime: startTime,
endTime: endTime
})
this.countDown()
},
methods: {
countDown() {
var nowTime = new Date().getTime();
let timeLeft = this.data.endTime - nowTime;
if (timeLeft >= 0) {
var {
h,
m,
s
} = this.formatTime(timeLeft)
this.setData({
hour: h,
minute: m,
secondsec: s
})
timter = setTimeout(() => {
this.countDown()
}, 1000);
} else {
this.triggerEvent('stopTime');
this.setData({
hour: '00',
minute: '00',
secondsec: '00'
})
}
},
formatTime(time) {
var h, m, s;
h = Math.floor(time / 1000 / 60 / 60 % 24);
m = Math.floor(time / 1000 / 60 % 60);
s = Math.floor(time / 1000 % 60);
s = s < 10 ? "0" + s : s
m = m < 10 ? "0" + m : m
h = h < 10 ? "0" + h : h
return {
s,
m,
h
}
},
getIntervalTime() {
clearTimeout(timter)
var nowTime = new Date().getTime();
let timeLeft = nowTime - this.data.startTime;
let timeStrArr = []
var {
h,
m,
s
} = this.formatTime(timeLeft)
if (h !== '00') {
timeStrArr.push(h)
}
timeStrArr.push(m)
timeStrArr.push(s)
return timeStrArr.join(":")
},
clearTimter() {
clearTimeout(timter)
}
}
})

@ -0,0 +1,7 @@
<view class="count-time_cont">
<block wx:if="{{hour!=='00'}}">
<view>{{hour}}</view>:
</block>
<view>{{minute}}</view>:
<view>{{secondsec}}</view>
</view>

@ -0,0 +1,66 @@
// components/dhbfh.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,2 @@
<!--components/dhbfh.wxml-->
<text>components/dhbfh.wxml</text>

@ -0,0 +1,42 @@
const app = getApp();
Component({
options: {
addGlobalClass: true,
},
properties: {
show: {
type: Boolean,
value: false
},
text: {
type: String,
value: '暂无数据'
},
subText: {
type: String,
value: ''
}
},
data: {},
methods: {
onLoad(options) {
console.log(options);
},
onShow() {
console.log('onShow');
},
onReady() {
console.log('onReady');
},
},
lifetimes: {
attached: function () { },
moved: function () { },
detached: function () { },
},
pageLifetimes: {
show: function () { },
hide: function () { },
resize: function () { },
},
});

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

@ -0,0 +1,5 @@
<view class="no-data" hidden="{{!show}}">
<image class="image" src="./empty_tip.png" />
<view class="text">{{text}}</view>
<view class="sub-text">{{subText}}</view>
</view>

@ -0,0 +1 @@
.no-data{padding:270rpx 0 60rpx;text-align:center}.no-data .image{width:400rpx;height:325rpx;margin-bottom:60rpx}.no-data .text{margin-bottom:30rpx;font-size:32rpx;color:#333;font-weight:bold}.no-data .subtitle{font-size:28rpx;color:#a2a2a2;letter-spacing:4rpx}

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

@ -0,0 +1,23 @@
Component({
options: {
addGlobalClass: true
},
properties: {
info: {
type: Object
},
show: Boolean
},
data: {
},
methods: {
close: function () {
this.triggerEvent('close')
}
}
})

@ -0,0 +1,19 @@
<wxs src="../../util/comm.wxs" module="comm" />
<view class="fadeIn" wx:if="{{show}}">
<view class="weui-mask" bindtap="close"></view>
<view class="weui-dialog">
<view class="title">{{info.name}}</view>
<view class="body">
<view class="weui-dialog__bd text">
<text class="header">
❀描述:
</text>{{info.explain}}
<view class ="type">同类型的还有:</view>{{info.contain}}
<view class ="tip">投放技巧:</view>{{info.tip}}
</view>
</view>
<view class="weui-dialog__ft">
<a class="weui-dialog__btn weui-dialog__btn_primary qd" bindtap="close">确定</a>
</view>
</view>
</view>

@ -0,0 +1,52 @@
view.weui-mask {
background-color: rgba(66, 66, 66, 0.4);
}
.title {
font-size: 40rpx;
line-height: 90rpx;
margin-top: 20rpx;
}
.img {
width: 200rpx;
display: flex;
justify-content: center;
margin: auto;
}
.text {
/* margin-top: 40rpx; */
text-align: left;
font-size: 30rpx;
}
.type{
color:brown;
font-size: 35rpx;
}
.tip{
color:rgb(27, 228, 111);
font-size: 35rpx;
}
.header {
color: var(--indexL);
}
.qd {
color: var(--indexL);
font-weight: normal;
}
view.weui-dialog__ft {
line-height: 50px;
min-height: 50px;
}
view.weui-dialog {
min-height: 700rpx;
justify-content: flex-start;
width: 80%;
}
.body {
flex: 1;
}

@ -0,0 +1,23 @@
Component({
options: {
addGlobalClass: true
},
properties: {
info: {
type: Object
},
show: Boolean
},
data: {
},
methods: {
close: function () {
this.triggerEvent('close')
}
}
})

@ -0,0 +1,16 @@
<wxs src="../../util/comm.wxs" module="comm" />
<view class="fadeIn" wx:if="{{show}}">
<view class="weui-mask" bindtap="close"></view>
<view class="weui-dialog">
<view class="title">{{info.name}}</view>
<view class="body">
<!-- <view class="img">
<image wx:if="{{comm.textToImg(info.contain)}}" src="../../static/image/{{comm.textToImg(info.cate_name)}}" mode="widthFix"></image>
</view> -->
<view class ="type">详细介绍:</view>{{info.lajitip}}
</view>
<view class="weui-dialog__ft">
<a class="weui-dialog__btn weui-dialog__btn_primary qd" bindtap="close">确定</a>
</view>
</view>
</view>

@ -0,0 +1,49 @@
view.weui-mask {
background-color: rgba(66, 66, 66, 0.4);
}
.title {
font-size: 40rpx;
line-height: 90rpx;
margin-top: 20rpx;
}
.img {
width: 200rpx;
display: flex;
justify-content: center;
margin: auto;
}
.text {
/* margin-top: 40rpx; */
text-align: left;
font-size: 30rpx;
}
.type{
color:brown;
font-size: 35rpx;
}
.header {
color: var(--indexL);
}
.qd {
color: var(--indexL);
font-weight: normal;
}
view.weui-dialog__ft {
line-height: 50px;
min-height: 50px;
}
view.weui-dialog {
min-height: 700rpx;
justify-content: flex-start;
width: 80%;
}
.body {
flex: 1;
}

@ -0,0 +1,28 @@
Component({
properties: {
list: {
type: Array,
value: []
}
},
data: {
swiper: {
margin: "150rpx"
},
currentIndex: 0
},
methods: {
swiperChange: function (e) {
this.setData({
currentIndex: e.detail.current
})
},
cardClick(e) {
this.triggerEvent('cardClick', {
type:e.currentTarget.dataset.type
})
}
}
})

@ -0,0 +1,18 @@
<view class="helang-cardSwiper">
<view class="top-swiper">
<view class="bg">
<view class="image">
<image src="{{list[currentIndex].src}}" mode="aspectFill"></image>
</view>
</view>
<view class="box">
<view style="height: 44px;"></view>
<swiper class="swiper" previous-margin="{{swiper.margin}}" next-margin='{{swiper.margin}}' circular="{{true}}"
bindchange="swiperChange">
<swiper-item wx:for="{{list}}" wx:key="index" bindtap="cardClick" data-type="{{item.type}}">
<image src='{{item.src}}' class="{{['le-img',(currentIndex==index)?'le-active':'']}}"></image>
</swiper-item>
</swiper>
</view>
</view>
</view>

@ -0,0 +1,77 @@
.top-swiper {
margin-bottom: 30rpx;
}
.top-swiper .bg {
padding-top: 25px;
box-sizing: content-box;
width: 100%;
position: relative;
}
.top-swiper .bg .image {
box-sizing: content-box;
z-index: 1;
overflow: hidden;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 0;
}
.top-swiper .bg .image::after {
content: "";
position: absolute;
width: 100%;
height: 100%;
z-index: 1;
bottom: 0;
left: 0;
height: 65%;
background-image: linear-gradient(to bottom, transparent, #FFF);
}
.top-swiper .bg .image>image {
position: absolute;
box-sizing: content-box;
padding: 60px;
top: 0;
left: 0;
width: 100%;
height: 80%;
top: -60px;
left: -60px;
filter: blur(50px);
}
.top-swiper .box {
padding-top: 25px;
box-sizing: content-box;
position: absolute;
z-index: 5;
top: 0;
left: 0;
width: 100%;
height: auto;
}
.top-swiper .swiper {
height: 600rpx;
margin: 0 20rpx;
}
.top-swiper .swiper .le-img {
width: 100%;
height: 100%;
display: block;
transform: scale(0.9);
transition: transform 0.3s ease-in-out 0s;
border-radius: 4px;
}
.top-swiper .swiper .le-img.le-active {
transform: scale(1);
}

@ -0,0 +1,14 @@
Component({
externalClasses: ['i-class'],
properties: {
loading: {
type: Boolean,
value: true
},
tip: {
type: String,
value: ''
}
},
});

@ -0,0 +1,8 @@
<view class="i-class i-load-more {{ loading ? '' : 'i-load-more-line' }}">
<view class="i-load-more-loading" wx:if="{{ loading }}"></view>
<view class="i-load-more-tip">
<view wx:if="{{ tip !== '' }}">{{ tip }}</view>
<view wx:elif="{{ tip === '' && loading }}">正在加载</view>
<view class="i-load-more-empty" wx:else></view>
</view>
</view>

@ -0,0 +1 @@
.i-load-more{width:65%;margin:1.5em auto;line-height:1.6em;font-size:14px;text-align:center}.i-load-more-loading{display:inline-block;margin-right:12px;vertical-align:middle;width:14px;height:14px;background:0 0;border-radius:50%;border:2px solid #e9eaec;border-color:#e9eaec #e9eaec #e9eaec #2d8cf0;animation:btn-spin .6s linear;animation-iteration-count:infinite}.i-load-more-tip{display:inline-block;vertical-align:middle;color:#495060}.i-load-more-line{border-top:1px solid #dddee1;display:flex;border-top:0}.i-load-more-line::before{position:relative;top:-1px;-webkit-box-flex:1;-webkit-flex:1;flex:1;content:'';border-top:1px solid #dddee1}.i-load-more-line::after{position:relative;top:-1px;-webkit-box-flex:1;-webkit-flex:1;flex:1;content:'';border-top:1px solid #dddee1}.i-load-more-line .i-load-more-tip{position:relative;top:-.9em;padding:0 .55em}.i-load-more-empty{width:4px;height:4px;border-radius:50%;background-color:#e5e5e5;display:inline-block;position:relative;vertical-align:0;top:-.16em}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}

@ -0,0 +1,42 @@
let app = getApp()
Component({
options: {
addGlobalClass: true,
},
data: {
elements: [{
title: '搜索垃圾',
name: 'search',
color: 'green',
icon: 'search',
login: true
},
{
title: '拍照识别',
name: 'photo',
color: 'olive',
icon: 'album',
login: true
}
]
},
methods: {
goMenu(e) {
let {
login
} = e.currentTarget.dataset.item
if (login) {
if (!app.globalData.isLogin) {
app.$util.errorToShow("请先登录", () => {
app.$util.switchTabTo("/pages/user/user")
})
return
}
}
let url = e.currentTarget.dataset.url
wx.navigateTo({
url: url
})
}
}
})

@ -0,0 +1,12 @@
<scroll-view scroll-y class="scrollPage">
<view class='nav-list'>
<view bindtap="goMenu" hover-class='none' data-url="/pages/{{item.name}}/{{item.name}}"
data-item="{{item}}"
class="nav-li bg-{{item.color}}"
wx:for="{{elements}}" wx:key>
<view class="nav-title">{{item.title}}</view>
<view class="nav-name">{{item.name}}</view>
<text class='cuIcon-{{item.icon}}'></text>
</view>
</view>
</scroll-view>

@ -0,0 +1,101 @@
.nav-list {
display: flex;
flex-wrap: wrap;
padding: 0px 40rpx 0px;
justify-content: space-between;
}
.nav-li {
padding: 30rpx;
border-radius: 12rpx;
width: 45%;
margin: 0 2.5% 40rpx;
background-size: cover;
background-position: center;
position: relative;
z-index: 1;
}
.nav-li::after {
content: "";
position: absolute;
z-index: -1;
background-color: inherit;
width: 100%;
height: 100%;
left: 0;
bottom: -10%;
border-radius: 10rpx;
opacity: 0.2;
transform: scale(0.9, 0.9);
}
.nav-li.cur {
color: #fff;
background: rgb(94, 185, 94);
box-shadow: 4rpx 4rpx 6rpx rgba(94, 185, 94, 0.4);
}
.nav-title {
font-size: 32rpx;
font-weight: 300;
}
.nav-title::first-letter {
font-size: 40rpx;
margin-right: 4rpx;
}
.nav-name {
font-size: 28rpx;
text-transform: Capitalize;
margin-top: 20rpx;
position: relative;
}
.nav-name::before {
content: "";
position: absolute;
display: block;
width: 40rpx;
height: 6rpx;
background: #fff;
bottom: 0;
right: 0;
opacity: 0.5;
}
.nav-name::after {
content: "";
position: absolute;
display: block;
width: 100rpx;
height: 1px;
background: #fff;
bottom: 0;
right: 40rpx;
opacity: 0.3;
}
.nav-name::first-letter {
font-weight: bold;
font-size: 36rpx;
margin-right: 1px;
}
.nav-li text {
position: absolute;
right: 30rpx;
top: 30rpx;
font-size: 52rpx;
width: 60rpx;
height: 60rpx;
text-align: center;
line-height: 60rpx;
}
.text-light {
font-weight: 300;
}

@ -0,0 +1,128 @@
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
properties: {
rowKey: {
type: String,
value: 'id'
},
columns: {
type: Array,
value: []
},
item: {
type: Object,
value: {}
},
index: {
type: Number,
},
select: {
type: Boolean,
value: false
},
scrollX: {
type: Boolean,
value: false
},
checked: {
type: Boolean,
value: false
},
isExpand: {
type: Boolean,
value: false
},
expandValueKey: {
type: String,
},
initExpandValue: {
type: String,
value: '暂无信息'
},
expandStyle: {
type: String,
},
dynamicValue: {
type: Object,
optionalTypes: [Array, String, Number, Boolean, null]
},
},
data: {
expandAimation: null,
expandAimationData: null,
expanded: false
},
methods: {
handleClickListItem(e) {
const { index } = e.currentTarget.dataset;
this.setExpand();
this.triggerEvent('clicklistitem', {
value: {
index,
item: e.currentTarget.dataset.item
}
});
},
handleClickAction(e) {
this.triggerEvent('clickaction', {
value: e.detail.value
});
},
handleClickExpand(e) {
this.triggerEvent('clickexpand', {
value: e.detail.value
});
},
handleClickCheck(e) {
const { item } = e.currentTarget.dataset;
const { index } = this.data;
this.triggerEvent('checkkey', {
value: {
item,
index
}
});
},
setExpand() {
const { isExpand, expanded, expandAimation } = this.data;
if (isExpand && expandAimation) {
if (expanded) {
expandAimation.opacity(0).height(0).step();
}
else {
expandAimation.opacity(1).height('auto').step();
}
this.setData({
expandAimationData: expandAimation.export(),
expanded: !expanded
});
}
},
initAnimate() {
const { isExpand } = this.data;
if (!isExpand)
return;
const expandAimation = wx.createAnimation({
duration: 500,
timingFunction: 'ease',
});
this.data.expandAimation = expandAimation;
},
},
lifetimes: {
attached: function () { },
ready: function () {
this.initAnimate();
},
moved: function () { },
detached: function () { },
},
pageLifetimes: {
show: function () { },
hide: function () { },
resize: function () { },
},
});

@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {},
"componentGenerics": {
"action-td": true,
"expand-component": true
}
}

@ -0,0 +1,42 @@
<wxs src="../../table.wxs" module="table" />
<!-- 标识符字符串是传进来的 -->
<view class="table-line">
<view class="tr" bindtap="handleClickListItem" data-item="{{item}}" data-index="{{index}}">
<view class="td select" wx:if="{{select}}">
<checkbox checked="{{checked}}" catchtap="handleClickCheck" data-item="{{item}}" data-index="{{index}}" />
</view>
<block wx:for="{{columns}}" wx:for-index="cIndex" wx:for-item="cItem" wx:key="key">
<view class="action-td"
style="width:{{table.computedTdWidth(columns,select)}};{{cIndex===columns.length-1?'flex-grow:1;flex-shrink:1':''}}"
wx:if="{{cItem.type=='action'}}">
<action-td item="{{item}}" index="{{index}}" columns="{{cItem}}" dynamicValue="{{dynamicValue}}"
bindclickaction="handleClickAction" slot="action-td"></action-td>
</view>
<view class="td img"
style="width:{{table.computedTdWidth(columns,cItem,select,scrollX)}};{{cIndex===columns.length-1?'flex-grow:1;flex-shrink:1':''}}"
data-key="{{cItem.key}}" data-index="{{index}}" wx:elif="{{cItem.type=='img'}}">
<image src="{{item[cItem.key]}}" mode="scaleToFill"
style="width: {{cItem.imgWidth||'80%'}};height: {{cItem.imgHeight||'auto'}};">
</image>
</view>
<view class="td"
style="width:{{table.computedTdWidth(columns,cItem,select,scrollX)}};{{cIndex===columns.length-1?'flex-grow:1;flex-shrink:1':''}}"
data-key="{{cItem.key}}" data-index="{{index}}" wx:else>
{{item[cItem.key]}}
</view>
</block>
</view>
<view class="expand" style="{{expandStyle}}" wx:if="{{isExpand}}" animation="{{expandAimationData}}">
<view class="expand-box" wx:if="{{expandValueKey}}">
{{item[expandValueKey]||initExpandValue}}
</view>
<view wx:else>
<expand-component item="{{item}}" index="{{index}}" dynamicValue="{{dynamicValue}}"
bindclickexpand="handleClickExpand"></expand-component>
</view>
</view>
</view>

@ -0,0 +1,60 @@
.table-line {
border-bottom: 2rpx solid #DDDDDD
}
.table-line .tr {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
min-height: 120rpx
}
.table-line .tr .td {
padding: 35rpx 10rpx;
text-align: center;
white-space: normal;
word-break: break-all;
font-size: 24rpx;
color: #333;
word-break: break-all;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-flow: wrap;
flex-flow: wrap;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center
}
.table-line .tr .td.select {
width: 60rpx;
padding: 0 1rpx
}
.table-line .expand {
height: 0;
font-size: 24rpx;
color: #A2A2A2;
line-height: 54rpx;
word-wrap: break-word;
word-break: break-all;
overflow: hidden;
opacity: 0
}
.table-line .expand .expand-box {
padding: 0 50rpx 35rpx
}
.table-line .tr .td.img {
padding: 0px;
}
.table-line .tr .td image{
width: 100%;
}

@ -0,0 +1,254 @@
const getNowPage = () => {
const pages = getCurrentPages();
return pages[pages.length - 1];
};
function debounce(fun, delay) {
let timer = null;
return function (...args) {
let _this = this;
let _args = args;
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function () {
fun.call(_this, ..._args);
}, delay);
};
}
Component({
options: {
addGlobalClass: true,
},
properties: {
rowKey: {
type: String,
value: 'id'
},
scrollViewHeight: {
type: String,
value: '600rpx'
},
scrollX: {
type: Boolean,
value: false
},
columns: {
type: Array,
value: []
},
dataList: {
type: Array,
value: []
},
getListLoading: {
type: Boolean,
value: false
},
showTipImage: {
type: Boolean,
value: false
},
tipTitle: {
type: String,
value: '提示'
},
tipSubtitle: {
type: String,
value: '暂无数据'
},
select: {
type: Boolean,
value: false
},
selectKeys: {
type: Array,
value: []
},
isExpand: {
type: Boolean,
value: false
},
expandValueKey: {
type: String,
},
initExpandValue: {
type: String,
},
expandStyle: {
type: String,
},
dynamicValue: {
type: Object,
optionalTypes: [Array, String, Number, Boolean, null],
value: {}
},
},
data: {
scrollTop: 0,
scrollLeftHeader: 0,
scrollLeftContent: 0,
scrollTag: null,
touchStatus: 'end',
checkObj: {},
},
observers: {
'dataList': function (dataList) {
if (dataList && dataList.length > 0) {
this.createShowDataList();
}
else {
this.setScrollTop();
}
},
'selectKeys': function (selectKeys) {
const newCheckObj = {};
selectKeys.forEach(item => {
newCheckObj[item] = true;
});
this.setData({
checkObj: newCheckObj
});
}
},
methods: {
createShowDataList() {
const { columns, dataList, rowKey } = this.data;
const needReaderColums = columns.filter(item => item.render);
this.setData({
showDataList: dataList.map((item, index) => {
let newItem = Object.assign(Object.assign({}, item), { row_key: `${item[rowKey]}` });
needReaderColums.forEach((item1) => {
newItem[item1.key] = item1.render(newItem[item1.key], item, index, getNowPage().data);
});
return newItem;
})
});
},
setScrollTop() {
this.setData({
scrollTop: 0
});
},
setScrollLeft(e) {
const { tag } = e.currentTarget.dataset;
const { scrollLeft } = e.detail;
const { scrollTag } = this.data;
if (tag !== scrollTag)
return;
if (tag === 'header') {
this.setData({
scrollLeftContent: scrollLeft
});
}
else if (tag === 'content') {
this.setData({
scrollLeftHeader: scrollLeft
});
}
},
clearScrollTag: debounce(function (e) {
const { touchStatus } = this.data;
if (touchStatus === 'start')
return;
this.setData({
scrollTag: null
});
}, 100),
handleScroll(e) {
const { scrollX, touchStatus } = this.data;
if (!scrollX)
return;
this.setScrollLeft(e);
if (touchStatus === 'end') {
this.clearScrollTag(e);
}
},
handleTouchStart(e) {
const { scrollX, scrollTag, touchStatus } = this.data;
if (!scrollX)
return;
if (scrollTag || touchStatus === 'start')
return;
const { tag } = e.currentTarget.dataset;
this.setData({
touchStatus: 'start',
scrollTag: tag,
});
},
handleTouchEnd(e) {
const { scrollX, scrollTag } = this.data;
if (!scrollX)
return;
const { tag } = e.currentTarget.dataset;
if (tag !== scrollTag)
return;
this.setData({
touchStatus: 'end'
});
},
handleScrolltolower() {
const { showTipImage } = this.data;
if (showTipImage)
return;
this.triggerEvent('scrolltolower');
},
handleScrolltoupper() {
this.triggerEvent('scrolltoupper');
},
handleClickListItem(e) {
this.triggerEvent('clicklistitem', {
value: e.detail.value
});
},
handleClickAction(e) {
this.triggerEvent('clickaction', {
value: e.detail.value
});
},
handleClickExpand(e) {
this.triggerEvent('clickexpand', {
value: e.detail.value
});
},
handleClickCheck(e) {
const { item } = e.detail.value;
const { checkObj, rowKey } = this.data;
const newCheckObj = Object.assign({}, checkObj);
newCheckObj[item[rowKey]] = !newCheckObj[item[rowKey]];
this.setData({
checkObj: newCheckObj
}, () => {
const value = [];
for (let i in newCheckObj) {
if (newCheckObj[i]) {
value.push(i);
}
}
this.triggerEvent('checkkey', {
value
});
});
},
tipFc() {
const { rowKey, columns } = this.data;
if (!rowKey) {
console.error('table组件必须指明每一行的唯一标识的字段名且必须为字符串数字将会被转为字符串,for循环中的wx:key不使用该字段用的是createShowDataList中设置的row_key字段');
}
if (!columns) {
console.error('table组件必须指明columns');
}
}
},
lifetimes: {
attached: function () {
this.tipFc();
},
moved: function () { },
detached: function () { },
},
pageLifetimes: {
show: function () { },
hide: function () { },
resize: function () { },
},
});

@ -0,0 +1,12 @@
{
"component": true,
"usingComponents": {
"zml-tr": "./components/tr/tr",
"zml-empty": "../empty/empty",
"zml-load-more": "../load_more/index"
},
"componentGenerics": {
"action-td": true,
"expand-component": true
}
}

@ -0,0 +1,20 @@
<wxs src="./table.wxs" module="table" />
<view class="list">
<scroll-view class="table-header" scroll-x="{{scrollX}}" bindscroll="handleScroll" bindtouchstart="handleTouchStart" bindtouchend="handleTouchEnd" data-tag="header" scroll-left="{{scrollLeftHeader}}">
<view class="inline-block">
<view class="tr tr-th">
<view class="th select" wx:if="{{select}}"></view>
<view class="th" style="width:{{table.computedTdWidth(columns,item, select,scrollX)}};{{index===columns.length-1?'flex-grow:1;flex-shrink:1':''}}" wx:for="{{columns}}" wx:key="key">
{{item.title}}
</view>
</view>
</view>
</scroll-view>
<scroll-view class="scroll-view" scroll-y scroll-x="{{scrollX}}" bindscroll="handleScroll" bindtouchstart="handleTouchStart" bindtouchend="handleTouchEnd" data-tag="content" scroll-left="{{scrollLeftContent}}" scroll-top="{{scrollTop}}" style="height:{{scrollViewHeight}}" bindscrolltolower="handleScrolltolower" bindscrolltoupper="handleScrolltoupper" upper-threshold="{{0}}" lower-threshold="{{100}}">
<view class="table-content" wx:if="{{!showTipImage}}">
<zml-tr bindclicklistitem="handleClickListItem" bindclickaction="handleClickAction" bindclickexpand="handleClickExpand" bindcheckkey="handleClickCheck" wx:for="{{showDataList}}" wx:key="row_key" data-rowkey="{{item[rowKey]}}" rowKey="{{rowKey}}" columns="{{columns}}" item="{{item}}" index="{{index}}" select="{{select}}" scrollX="{{scrollX}}" checked="{{checkObj[item[rowKey]]}}" isExpand="{{isExpand}}" expandValueKey="{{expandValueKey}}" initExpandValue="{{initExpandValue}}" dynamicValue="{{dynamicValue}}" generic:action-td="action-td" generic:expand-component="expand-component"></zml-tr>
<zml-load-more tip="{{getListLoading?'请求中':'暂无更多数据'}}" loading="{{ getListLoading }}" />
</view>
<zml-empty show="{{showTipImage}}" text="{{tipTitle}}" subText="{{tipSubtitle}}"></zml-empty>
</scroll-view>
</view>

@ -0,0 +1,17 @@
function computedTdWidth(columns, column, select, scrollX) {
if (column.width) {
return column.width
} else if (scrollX) {
return '200rpx'
} else {
if (select) {
return 'calc( (calc(100% - 60rpx)) / ' + columns.length + ')'
} else {
return 'calc( 100% / ' + columns.length + ')'
}
}
}
module.exports = {
computedTdWidth: computedTdWidth
}

@ -0,0 +1,115 @@
page,
view,
scroll-view,
swiper,
movable-area,
cover-view,
text,
icon,
rich-text,
progress,
button,
checkbox-group,
checkbox,
form,
input,
label,
picker,
picker-view,
radio-group,
slider,
switch,
textarea,
navigator,
audio,
image,
video,
live-player,
live-pusher,
open-data,
web-view {
-webkit-box-sizing: border-box;
box-sizing: border-box
}
.list {
position: relative;
background-color: #fff;
overflow: hidden
}
.list .tip-image-block {
width: 100%;
height: 100%
}
.list .tip-image-block .icon {
width: 270rpx;
height: 209rpx;
margin-bottom: 40rpx
}
.list .tip-image-block .title {
margin-bottom: 30rpx;
font-size: 32rpx;
color: #333;
font-weight: bold
}
.list .tip-image-block .subtitle {
font-size: 28rpx;
color: #a2a2a2;
letter-spacing: 4rpx
}
.table-header {
overflow: hidden;
white-space: nowrap
}
.table-header .inline-block {
display: inline-block;
min-width: 100%
}
.table-header .tr {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
border-bottom: 2rpx solid #DDDDDD
}
.table-header .tr .th {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-flow: wrap;
flex-flow: wrap;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding: 35rpx 10rpx;
font-size: 28rpx;
white-space: normal;
word-break: break-all;
color: #333;
font-weight: bold
}
.table-header .tr .th.select {
width: 60rpx;
padding: 0 1rpx
}
.scroll-view {
overflow: hidden;
white-space: nowrap
}
.scroll-view .table-content {
display: inline-block;
min-width: 100%
}

@ -0,0 +1,193 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */,
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Component({
options: {
multipleSlots: true,
// 在组件定义时的选项中启用多slot支持
addGlobalClass: true
},
properties: {
title: {
// 标题
type: String,
value: ''
},
showCancel: {
// 是否显示取消按钮
type: Boolean,
value: true
},
cancelText: {
// 取消按钮文案
type: String,
value: '取消'
},
maskClass: {
// 遮罩层class
type: String,
value: ''
},
extClass: {
// 弹出窗 class
type: String,
value: ''
},
maskClosable: {
// 点击遮罩 关闭 actionsheet
type: Boolean,
value: true
},
mask: {
// 是否需要 遮罩层
type: Boolean,
value: true
},
show: {
// 是否开启 actionsheet
type: Boolean,
value: false
},
actions: {
// actions 列表
type: Array,
value: [],
// {text, extClass}
observer: '_groupChange'
}
},
methods: {
_groupChange(e) {
// 支持 一维数组 写法
if (e.length > 0 && typeof e[0] !== 'string' && !(e[0] instanceof Array)) {
this.setData({
actions: [this.data.actions]
});
}
},
buttonTap(e) {
const {
value,
groupindex,
index
} = e.currentTarget.dataset;
this.triggerEvent('actiontap', {
value,
groupindex,
index
});
},
closeActionSheet(e) {
const {
type
} = e.currentTarget.dataset;
if (this.data.maskClosable || type) {
// 点击 action 里面的 取消
this.setData({
show: false
}); // 关闭回调事件
this.triggerEvent('close');
}
}
}
});
/***/ })
/******/ ]);

@ -0,0 +1,51 @@
<wxs module="utils">
var join = function(a,b) {
return a+b
};
var isNotSlot = function(v) {
return typeof v !== 'string'
}
module.exports = {
join: join,
isNotSlot: isNotSlot
}
</wxs>
<view wx:if="{{mask}}" class="weui-mask {{show ? '' : 'weui-mask_hidden'}} {{maskClass}}" bindtap="closeActionSheet"></view>
<view class="weui-actionsheet {{show ? 'weui-actionsheet_toggle' : ''}} {{extClass}}">
<!-- 标题 -->
<block wx:if="{{title}}">
<view class="weui-actionsheet__title">
<view class="weui-actionsheet__title-text">{{title}}</view>
</view>
</block>
<slot name="title" wx:else></slot>
<view
class="{{ !showCancel && index === actions.length-1 ? 'weui-actionsheet__action' : 'weui-actionsheet__menu' }}"
wx:key="index"
wx:for-item="actionItem"
wx:for-index="index"
wx:for="{{actions}}"
>
<block wx:if="{{utils.isNotSlot(actionItem)}}">
<view
class="weui-actionsheet__cell {{item.type === 'warn' ? 'weui-actionsheet__cell_warn' : '' }}"
hover-class="weui-active"
wx:key="actionIndex"
wx:for="{{actionItem}}"
wx:for-index="actionIndex"
data-groupindex="{{index}}"
data-index="{{actionIndex}}"
data-value="{{item.value}}"
bindtap="buttonTap"
>
{{item.text}}
</view>
</block>
<slot name="{{actionItem}}" wx:else></slot>
</view>
<!-- 取消按钮 -->
<view class="weui-actionsheet__action" wx:if="{{showCancel}}">
<view class="weui-actionsheet__cell" hover-class="weui-active" data-type="close" id="iosActionsheetCancel" bindtap="closeActionSheet">{{cancelText}}</view>
</view>
</view>

@ -0,0 +1 @@
.weui-mask.weui-mask_hidden{opacity:0;transform:scale3d(1, 1, 0)}.weui-mask{opacity:1;transform:scale3d(1, 1, 1);transition:all .3s}

@ -0,0 +1,114 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 15);
/******/ })
/************************************************************************/
/******/ ({
/***/ 15:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Component({
options: {
addGlobalClass: true
},
properties: {
extClass: {
type: String,
value: ''
},
content: {
type: String,
value: ''
}
}
});
/***/ })
/******/ });

@ -0,0 +1 @@
<view class="weui-badge {{extClass}} {{!content ? 'weui-badge_dot' : ''}}">{{content}}</view>

@ -0,0 +1,308 @@
module.exports =
/******/
(function (modules) { // webpackBootstrap
/******/ // The module cache
/******/
var installedModules = {};
/******/
/******/ // The require function
/******/
function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/
if (installedModules[moduleId]) {
/******/
return installedModules[moduleId].exports;
/******/
}
/******/ // Create a new module (and put it into the cache)
/******/
var module = installedModules[moduleId] = {
/******/
i: moduleId,
/******/
l: false,
/******/
exports: {}
/******/
};
/******/
/******/ // Execute the module function
/******/
modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/
module.l = true;
/******/
/******/ // Return the exports of the module
/******/
return module.exports;
/******/
}
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/
__webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/
__webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/
__webpack_require__.d = function (exports, name, getter) {
/******/
if (!__webpack_require__.o(exports, name)) {
/******/
Object.defineProperty(exports, name, {
enumerable: true,
get: getter
});
/******/
}
/******/
};
/******/
/******/ // define __esModule on exports
/******/
__webpack_require__.r = function (exports) {
/******/
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/
Object.defineProperty(exports, Symbol.toStringTag, {
value: 'Module'
});
/******/
}
/******/
Object.defineProperty(exports, '__esModule', {
value: true
});
/******/
};
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/
__webpack_require__.t = function (value, mode) {
/******/
if (mode & 1) value = __webpack_require__(value);
/******/
if (mode & 8) return value;
/******/
if ((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/
var ns = Object.create(null);
/******/
__webpack_require__.r(ns);
/******/
Object.defineProperty(ns, 'default', {
enumerable: true,
value: value
});
/******/
if (mode & 2 && typeof value != 'string')
for (var key in value) __webpack_require__.d(ns, key, function (key) {
return value[key];
}.bind(null, key));
/******/
return ns;
/******/
};
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/
__webpack_require__.n = function (module) {
/******/
var getter = module && module.__esModule ?
/******/
function getDefault() {
return module['default'];
} :
/******/
function getModuleExports() {
return module;
};
/******/
__webpack_require__.d(getter, 'a', getter);
/******/
return getter;
/******/
};
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/
__webpack_require__.o = function (object, property) {
return Object.prototype.hasOwnProperty.call(object, property);
};
/******/
/******/ // __webpack_public_path__
/******/
__webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/
return __webpack_require__(__webpack_require__.s = 9);
/******/
})
/************************************************************************/
/******/
({
/***/
9:
/***/
(function (module, exports, __webpack_require__) {
"use strict";
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
properties: {
hover: {
type: Boolean,
value: false
},
link: {
type: Boolean,
value: false
},
extClass: {
type: String,
value: ''
},
iconClass: {
type: String,
value: ''
},
bodyClass: {
type: String,
value: ''
},
icon: {
type: String,
value: ''
},
title: {
// 和icon二选一都是放在cell_hd里面
type: String,
value: ''
},
value: {
type: String,
value: ''
},
cotent: {
type: String,
value: ''
},
showError: {
type: Boolean,
value: false
},
prop: {
// 校验的属性给父元素form使用
type: String,
value: ''
},
url: {
// 在link为true的时候有效表示navigator的跳转url
type: String,
value: ''
},
footerClass: {
type: String,
value: ''
},
footer: {
type: String,
value: ''
},
inline: {
// 左右布局样式还是上下布局
type: Boolean,
value: true
},
hasHeader: {
type: Boolean,
value: true
},
hasFooter: {
type: Boolean,
value: true
},
hasBody: {
type: Boolean,
value: true
},
extHoverClass: {
// 提供给需要定制 hover-class 的场景,要求 hover 为 false
type: String,
value: ''
}
},
relations: {
'../form/form': {
type: 'ancestor'
},
'../cells/cells': {
type: 'ancestor'
}
},
data: {
inForm: false
},
methods: {
setError(error) {
this.setData({
error: error || false
});
},
setInForm() {
this.setData({
inForm: true
});
},
setOuterClass(className) {
this.setData({
outerClass: className
});
},
navigateTo() {
const data = this.data;
if (data.url && data.link) {
this.triggerEvent('navigate', data.url);
// wx.navigateTo({
// url: data.url,
// success: res => {
// this.triggerEvent('navigatesuccess', res, {});
// },
// fail: fail => {
// this.triggerEvent('navigateerror', fail, {});
// }
// });
}
}
}
});
/***/
})
/******/
});

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"mp-cells": "../cells/cells"
}
}

@ -0,0 +1,85 @@
<block wx:if="{{link}}">
<view bindtap="navigateTo"
class="weui-cell weui-cell_access {{extClass}} {{outerClass}}{{inForm ? ' weui-cell-inform' : ''}}{{inline ? '' : ' .weui-cell_label-block'}}"
hover-class="{{hover ? 'weui-cell_active weui-active' : extHoverClass}}">
<view wx:if="{{hasHeader}}" class="weui-cell__hd {{iconClass}}">
<block wx:if="{{icon}}">
<image src="{{icon}}" class="weui-cell__icon" mode="aspectFit"></image>
</block>
<block wx:else>
<slot name="icon"></slot>
</block>
<block wx:if="{{inForm}}">
<block wx:if="{{title}}">
<view class="weui-label">{{title}}</view>
</block>
<block wx:else>
<slot name="title"></slot>
</block>
</block>
<block wx:else>
<block wx:if="{{title}}">{{title}}</block>
<block wx:else>
<slot name="title"></slot>
</block>
</block>
</view>
<view wx:if="{{hasBody}}" class="weui-cell__bd">
<block wx:if="{{value}}">{{value}}</block>
<block wx:else>
<slot></slot>
</block>
<view>{{cotent}}</view>
</view>
<view wx:if="{{hasFooter}}" class="weui-cell__ft weui-cell__ft_in-access {{footerClass}}">
<block wx:if="{{footer}}">{{footer}}</block>
<block wx:else>
<slot name="footer"></slot>
</block>
</view>
</view>
</block>
<block wx:else>
<view bindtap="navigateTo"
class="weui-cell {{showError && error ? 'weui-cell_warn' : ''}} {{inForm ? 'weui-cell-inform' : ''}} {{extClass}} {{outerClass}}"
hover-class="{{hover ? 'weui-cell_active weui-active' : extHoverClass}}">
<view wx:if="{{hasHeader}}" class="weui-cell__hd {{iconClass}}">
<block wx:if="{{icon}}">
<image src="{{icon}}" class="weui-cell__icon" mode="aspectFit"></image>
</block>
<block wx:else>
<slot name="icon"></slot>
</block>
<block wx:if="{{inForm}}">
<block wx:if="{{title}}">
<view class="weui-label">{{title}}</view>
</block>
<block wx:else>
<slot name="title"></slot>
</block>
</block>
<block wx:else>
<block wx:if="{{title}}">{{title}}</block>
<block wx:else>
<slot name="title"></slot>
</block>
</block>
</view>
<view wx:if="{{hasBody}}" class="weui-cell__bd {{bodyClass}}">
<view>
<block wx:if="{{value}}">{{value}}</block>
<block wx:else>
<slot></slot>
</block>
</view>
</view>
<view wx:if="{{hasFooter}}" class="weui-cell__ft {{footerClass}}">
<block wx:if="{{footer}}">{{footer}}</block>
<block wx:else>
<slot name="footer"></slot>
</block>
<icon wx:if="{{showError && error}}" type="warn" size="23" color="#E64340"></icon>
</view>
</view>
</block>

@ -0,0 +1,12 @@
.weui-cell_wxss.weui-cell_wxss:before {
display: block
}
view.weui-cell__bd {
font-size: 28rpx;
}
view.weui-cell__ft{
font-size: 24rpx;
}

@ -0,0 +1,183 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 8);
/******/ })
/************************************************************************/
/******/ ({
/***/ 8:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
properties: {
title: {
type: String,
value: ''
},
extClass: {
type: String,
value: ''
},
footer: {
type: String,
value: ''
}
},
data: {
firstItem: null,
checkboxCount: 0,
checkboxIsMulti: false,
outerClass: '',
childClass: ''
},
relations: {
'../cell/cell': {
type: 'descendant',
linked(target) {
if (!this.data.firstItem) {
this.data.firstItem = target;
}
if (target !== this.data.firstItem) {
target.setOuterClass('weui-cell_wxss');
}
}
},
'../form-page/form-page': {
type: 'ancestor'
},
'../checkbox-group/checkbox-group': {
type: 'descendant',
linked(target) {
this.setData({
checkboxCount: this.data.checkboxCount + 1,
checkboxIsMulti: target.data.multi
});
},
unlinked(target) {
this.setData({
checkboxCount: this.data.checkboxCount - 1,
checkboxIsMulti: target.data.multi
});
}
}
},
methods: {
setCellMulti(multi) {
this.setData({
checkboxIsMulti: multi
});
},
setCellsClass(className) {
this.setData({
childClass: className
});
},
setOuterClass(className) {
this.setData({
outerClass: className
});
}
}
});
/***/ })
/******/ });

@ -0,0 +1,8 @@
<view class="{{extClass}} weui-cells__group {{outerClass}} {{childClass}}">
<view wx:if="{{title}}" class="weui-cells__title">{{title}}</view>
<view class="weui-cells weui-cells_after-title {{checkboxCount > 0 && checkboxIsMulti ? 'weui-cells_checkbox' : ''}}">
<slot></slot>
</view>
<view wx:if="{{footer}}" class="weui-cells__tips">{{footer}}</view>
<slot name="footer" wx:else></slot>
</view>

@ -0,0 +1 @@
.weui-cells__group_wxss.weui-cells__group_wxss .weui-cells__title{margin-top:24px}.weui-cells__group_form .weui-cells__tips{margin-top:8px;padding:0 32px;color:var(--weui-FG-1)}

@ -0,0 +1,226 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 24);
/******/ })
/************************************************************************/
/******/ ({
/***/ 24:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
properties: {
multi: {
type: Boolean,
value: true,
observer: '_multiChange'
},
extClass: {
type: String,
value: ''
},
prop: {
type: String,
value: ''
}
},
data: {
targetList: [],
parentCell: null
},
relations: {
'../checkbox/checkbox': {
type: 'descendant',
linked(target) {
this.data.targetList.push(target);
target.setMulti(this.data.multi);
if (!this.data.firstItem) {
this.data.firstItem = target;
}
if (target !== this.data.firstItem) {
target.setOuterClass('weui-cell_wxss');
}
},
unlinked(target) {
let index = -1;
this.data.targetList.forEach((item, idx) => {
if (item === target) {
index = idx;
}
});
this.data.targetList.splice(index, 1);
if (!this.data.targetList) {
this.data.firstItem = null;
}
}
},
'../form/form': {
type: 'ancestor'
},
'../cells/cells': {
type: 'ancestor',
linked(target) {
if (!this.data.parentCell) {
this.data.parentCell = target;
}
this.setParentCellsClass();
},
unlinked() {
this.data.parentCell = null; // 方便内存回收
}
}
},
methods: {
checkedChange(checked, target) {
if (this.data.multi) {
const vals = [];
this.data.targetList.forEach(item => {
if (item.data.checked) {
vals.push(item.data.value);
}
});
this.triggerEvent('change', {
value: vals
});
} else {
let val = '';
this.data.targetList.forEach(item => {
if (item === target) {
val = item.data.value;
} else {
item.setData({
checked: false
});
}
});
this.triggerEvent('change', {
value: val
}, {});
}
},
setParentCellsClass() {
const className = this.data.multi ? 'weui-cells_checkbox' : '';
if (this.data.parentCell) {
this.data.parentCell.setCellsClass(className);
}
},
_multiChange(multi) {
this.data.targetList.forEach(target => {
target.setMulti(multi);
});
if (this.data.parentCell) {
this.data.parentCell.setCellMulti(multi);
}
return multi;
}
}
});
/***/ })
/******/ });

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"mp-cells": "../cells/cells"
}
}

@ -0,0 +1,6 @@
<checkbox-group class="{{extClass}}" wx-if="{{multi}}" bindchange="checkedChange">
<slot></slot>
</checkbox-group>
<radio-group class="{{extClass}}" wx-else bindchange="checkedChange">
<slot></slot>
</radio-group>

@ -0,0 +1,184 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 25);
/******/ })
/************************************************************************/
/******/ ({
/***/ 25:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
properties: {
multi: {
type: Boolean,
value: true
},
checked: {
type: Boolean,
value: false
},
value: {
type: String,
value: ''
},
label: {
type: String,
value: 'label'
},
extClass: {
type: String,
value: ''
}
},
data: {},
relations: {
'../checkbox-group/checkbox-group': {
type: 'ancestor',
linked(target) {
this.data.group = target;
},
unlinked() {
this.data.group = null;
}
}
},
methods: {
setMulti(multi) {
this.setData({
multi
});
},
setOuterClass(className) {
this.setData({
outerClass: className
});
},
checkedChange() {
if (this.data.multi) {
const checked = !this.data.checked;
this.setData({
checked
});
if (this.data.group) {
this.data.group.checkedChange(checked, this);
}
} else {
const checked = this.data.checked;
if (checked) return;
this.setData({
checked: true
});
if (this.data.group) {
this.data.group.checkedChange(checked, this);
}
}
this.triggerEvent('change', {
value: this.data.value,
checked: this.data.checked
});
}
}
});
/***/ })
/******/ });

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

@ -0,0 +1,20 @@
<mp-cell
has-footer="{{!multi}}"
has-header="{{multi}}"
bindtap="checkedChange"
ext-class="weui-check__label {{outerClass}} {{extClass}} {{!multi ? '^weui-cell_radio' : '^weui-cell_checkbox'}}"
ext-hover-class="weui-active">
<view slot="icon" wx:if="{{multi}}">
<checkbox value="{{value}}" checked="{{checked}}" disabled="{{disabled}}" color="{{color}}" class="weui-check">
</checkbox>
<!-- 未勾选 -->
<icon class="weui-icon-checked"></icon>
</view>
<view>{{label}}</view>
<view slot="footer" wx:if="{{!multi}}">
<radio value="{{value}}" checked="{{checked}}" disabled="{{disabled}}" color="{{color}}" class="weui-check"></radio>
<!-- 已勾选 -->
<icon class="weui-icon-checked"></icon>
</view>
</mp-cell>

@ -0,0 +1 @@
.weui-cell_radio .weui-check+.weui-icon-checked{color:transparent}.weui-check[checked]+.weui-icon-checked{color:var(--weui-BRAND);-webkit-mask-image:url(data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M8.657%2018.435L3%2012.778l1.414-1.414%204.95%204.95L20.678%205l1.414%201.414-12.02%2012.021a1%201%200%2001-1.415%200z%22%20fill-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E);mask-image:url(data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M8.657%2018.435L3%2012.778l1.414-1.414%204.95%204.95L20.678%205l1.414%201.414-12.02%2012.021a1%201%200%2001-1.415%200z%22%20fill-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E)}

@ -0,0 +1,182 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 20);
/******/ })
/************************************************************************/
/******/ ({
/***/ 20:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Component({
options: {
multipleSlots: true,
// 在组件定义时的选项中启用多slot支持
addGlobalClass: true
},
properties: {
title: {
// 弹窗标题,也可以通过 slot 自定义
type: String,
value: ''
},
extClass: {
// 弹窗 class
type: String,
value: ''
},
maskClosable: {
type: Boolean,
value: true
},
mask: {
// 是否需要 遮罩层
type: Boolean,
value: true
},
show: {
// 是否开启弹窗
type: Boolean,
value: false,
observer: '_showChange'
},
buttons: {
type: Array,
value: [] // {text, extClass}
}
},
data: {
innerShow: false
},
ready() {
const buttons = this.data.buttons;
const len = buttons.length;
buttons.forEach((btn, index) => {
if (len === 1) {
btn.className = 'weui-dialog__btn_primary';
} else if (index === 0) {
btn.className = 'weui-dialog__btn_default';
} else {
btn.className = 'weui-dialog__btn_primary';
}
});
this.setData({
buttons
});
},
methods: {
buttonTap(e) {
const {
index
} = e.currentTarget.dataset;
this.triggerEvent('buttontap', {
index,
item: this.data.buttons[index]
}, {});
},
close() {
const data = this.data;
if (!data.maskClosable) return;
this.setData({
show: false
});
this.triggerEvent('close', {}, {});
},
stopEvent() {}
}
});
/***/ })
/******/ });

@ -0,0 +1,20 @@
<view bindtap="close" class="weui-mask {{!show ? 'weui-mask_hidden' : '' }}" wx:if="{{mask}}"></view>
<view wx:if="{{show}}" bindtap="close" class="weui-dialog__wrp {{extClass}}">
<view class="weui-dialog" catchtap="stopEvent">
<view class="weui-dialog__hd">
<view class="weui-dialog__title">{{title}}
<slot name="title"></slot>
</view>
</view>
<view class="weui-dialog__bd">
<slot></slot>
</view>
<view class="weui-dialog__ft">
<block wx:if="{{buttons && buttons.length}}">
<view wx:for="{{buttons}}" wx:key="index" class="weui-dialog__btn {{item.className}} {{item.extClass}}" hover-class="weui-active" data-index="{{index}}" bindtap="buttonTap">{{item.text}}</view>
</block>
<slot name="footer" wx:else></slot>
</view>
</view>
</view>

@ -0,0 +1 @@
.weui-dialog.weui-dialog_hidden{opacity:0;transform:scale3d(1, 1, 0)}.weui-dialog{opacity:1;-webkit-transform:scale3d(1, 1, 1) translateY(-50%);transform:scale3d(1, 1, 1) translateY(-50%);transition:all .2s ease-in}.weui-mask.weui-mask_hidden{opacity:0;transform:scale3d(1, 1, 0)}.weui-mask{opacity:1;transform:scale3d(1, 1, 1);transition:all .2s ease-in}

@ -0,0 +1,138 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
/******/ ({
/***/ 2:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
properties: {
title: {
// Msg 标题
type: String,
value: ''
},
subtitle: {
// icon 的 type
type: String,
value: ''
}
},
relations: {
'../cells/cells': {
type: 'descendant',
linked(target) {
if (!this.data.firstItem) {
this.data.firstItem = target;
}
target.setOuterClass('weui-cells__group weui-cells__group_form weui-cells_form');
if (target !== this.data.firstItem) {
target.setOuterClass('weui-cells__group_wxss weui-cells__group weui-cells__group_form weui-cells_form');
}
}
}
},
data: {
firstItem: null
}
});
/***/ })
/******/ });

@ -0,0 +1,31 @@
<view class="weui-form">
<block wx:if="{{title || subtitle}}">
<view class="weui-form__text-area">
<view class="weui-form__title">{{title}}</view>
<view class="weui-form__desc">{{subtitle}}</view>
</view>
</block>
<block wx:else>
<view class="weui-form__text-area">
<slot name="title"></slot>
</view>
</block>
<view class="weui-form__control-area">
<slot></slot>
</view>
<view class="weui-form__tips-area">
<slot name="tips"></slot>
</view>
<view class="weui-form__opr-area">
<slot name="button"></slot>
</view>
<view class="weui-form__tips-area">
<slot name="suffixtips"></slot>
</view>
<view class="weui-form__extra-area">
<view class="weui-footer">
<slot name="footer"></slot>
</view>
</view>
</view>

@ -0,0 +1,745 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.diffObject = exports.diff = void 0;
const diff = (old, newVal) => {
if (!old && newVal || old && !newVal) return true;
for (const k in newVal) {
if (old[k] !== newVal[k]) return true;
}
for (const k in old) {
if (old[k] !== newVal[k]) return true;
}
return false;
};
exports.diff = diff;
const diffObject = (old, newVal) => {
if (!old && newVal) return newVal;
if (!newVal && old) return old;
const diffObj = {};
let isDiff = false;
for (const k in newVal) {
if (old[k] !== newVal[k]) {
isDiff = true;
diffObj[k] = newVal[k];
}
}
for (const k in old) {
if (old[k] !== newVal[k]) {
isDiff = true;
diffObj[k] = newVal[k];
}
}
return isDiff ? diffObj : null;
};
exports.diffObject = diffObject;
/***/ }),
/* 1 */,
/* 2 */,
/* 3 */,
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _formValidator = _interopRequireDefault(__webpack_require__(5));
var _object = __webpack_require__(0);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function linked(target) {
if (target.data.prop) {
this.data.formItems[target.data.prop] = target;
}
if (target.setInForm) {
target.setInForm();
}
if (!this.data.firstItem) {
this.data.firstItem = target;
}
}
function unlinked(target) {
if (target.data.prop) {
delete this.data.formItems[target.data.prop];
}
}
Component({
properties: {
models: {
type: Object,
value: {},
observer: '_modelChange'
},
rules: {
// 格式是[{name, rules: {}}]
type: Array,
value: [],
observer: '_rulesChange'
},
extClass: {
type: String,
value: ''
}
},
data: {
errors: {},
formItems: {},
firstItem: null
},
relations: {
'../cell/cell': {
type: 'descendant',
linked,
unlinked
},
'../checkbox-group/checkbox-group': {
type: 'descendant',
linked,
unlinked
}
},
attached() {
this.initRules();
this.formValidator = new _formValidator.default(this.data.models, this.data.newRules);
},
methods: {
initRules(rules) {
const newRules = {};
(rules || this.data.rules).forEach(rule => {
if (rule.name && rule.rules) {
newRules[rule.name] = rule.rules || [];
}
});
this.setData({
newRules
});
return newRules;
},
_modelChange(newVal, oldVal) {
if (!this.formValidator) {
return newVal;
} // 这个必须在前面
this.formValidator.setModel(newVal);
const diffObj = (0, _object.diffObject)(oldVal, newVal);
if (diffObj) {
let isValid = true;
const errors = [];
const errorMap = {};
Object.keys(diffObj).forEach(k => {
this.formValidator.validateField(k, diffObj[k], function (isValided, error) {
if (error && error[k]) {
errors.push(error[k]);
errorMap[k] = error[k];
}
isValid = isValided;
});
});
this._showErrors(diffObj, errorMap);
this.triggerEvent(isValid ? 'success' : 'fail', isValid ? {
trigger: 'change'
} : {
errors,
trigger: 'change'
});
}
return newVal;
},
_rulesChange(newVal) {
const newRules = this.initRules(newVal);
if (this.formValidator) {
this.formValidator.setRules(newRules);
}
return newVal;
},
_showAllErrors(errors) {
Object.keys(this.data.newRules).forEach(k => {
this._showError(k, errors && errors[k]);
});
},
_showErrors(objs, errors) {
Object.keys(objs).forEach(k => {
this._showError(k, errors && errors[k]);
});
},
_showError(prop, error) {
const formItem = this.data.formItems[prop];
if (formItem && formItem.data.showError) {
formItem.setError(error);
}
},
validate(cb) {
return this.formValidator.validate((isValid, errors) => {
this._showAllErrors(errors);
const handleError = this.handleErrors(errors);
this.triggerEvent(isValid ? 'success' : 'fail', isValid ? {
trigger: 'validate'
} : {
errors: handleError,
trigger: 'validate'
});
cb && cb(isValid, handleError);
});
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
validateField(name, value, cb = (v, error = null) => {}) {
return this.formValidator.validateField(name, value, (isValid, errors) => {
this._showError(name, errors);
const handleError = this.handleErrors(errors);
this.triggerEvent(isValid ? 'success' : 'fail', isValid ? {
trigger: 'validate'
} : {
errors: handleError,
trigger: 'validate'
});
cb && cb(isValid, handleError);
});
},
handleErrors(errors) {
if (errors) {
const newErrors = [];
this.data.rules.forEach(rule => {
if (errors[rule.name]) {
errors[rule.name].name = rule.name;
newErrors.push(errors[rule.name]);
}
});
return newErrors;
}
return errors;
},
addMethod(ruleName, method) {
return this.formValidator.addMethod(ruleName, method);
}
}
});
var _default = _formValidator.default;
exports.default = _default;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _validator = _interopRequireDefault(__webpack_require__(6));
var _object = __webpack_require__(0);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const toString = Object.prototype.toString;
const validateSingleRule = (rule, value, param = null, models = null) => {
let message = '';
const ruleKeys = Object.keys(rule);
for (let i = 0, l = ruleKeys.length; i < l; ++i) {
const ruleKey = ruleKeys[i];
if (ruleKey === 'name' || ruleKey === 'message') continue;
const validateMethod = typeof rule.validator !== 'undefined' ? rule.validator : _validator.default[ruleKey];
if (typeof validateMethod === 'function') {
message = validateMethod(rule, value, param, models);
if (message) {
return message;
}
}
}
return message;
};
class FormValidator {
constructor(models, rules) {
_defineProperty(this, "models", void 0);
_defineProperty(this, "rules", void 0);
_defineProperty(this, "errors", void 0);
this.models = models;
this.rules = rules;
this.errors = {};
}
validate(cb) {
return new Promise(resolve => {
let failCount = 0;
const errors = this.errors;
const models = this.models;
let errorChanged = false;
Object.keys(this.rules).forEach(fieldName => {
const oldError = errors[fieldName];
this._innerValidateField(fieldName, models[fieldName], (valid, newError) => {
if (!valid) failCount++;
if ((0, _object.diff)(oldError, newError)) {
errors[fieldName] = newError;
errorChanged = true;
}
});
});
const keys = Object.keys(errors);
keys.forEach(key => {
if (!errors[key]) delete errors[key];
}); // 先支持同步的接口吧
resolve({
isValid: !failCount,
errors: failCount ? errors : undefined
});
cb && cb(!failCount, failCount ? errors : undefined);
});
}
validateField(name, value, cb) {
return new Promise(resolve => {
this._innerValidateField(name, value, (valid, error) => {
const errObj = {};
errObj[name] = error;
resolve({
valid,
error: valid ? undefined : error
});
cb && cb(valid, valid ? undefined : errObj);
const oldError = this.errors[name];
const errorChanged = (0, _object.diff)(oldError, error);
if (errorChanged) {
if (!error) delete this.errors[name];
this.errors[name] = error;
}
});
});
}
_innerValidateField(name, value, cb) {
const rules = this.rules[name];
if (!rules) {
console.warn(`[form-validtor] rule name ${name} not exists.`);
cb(true);
return;
} // 处理参数
if (typeof value === 'function') {
cb = value;
value = undefined;
}
let isFail = false;
const models = this.models;
if (toString.call(rules) === '[object Array]') {
rules.forEach(rule => {
rule.name = name; // 字段名称
const resMessage = validateSingleRule(rule, value || models[name], rule.param, models); // 失败了直接中止
if (resMessage && !isFail) {
isFail = true; // errors[name] = {message: resMessage}
const error = resMessage ? {
message: resMessage,
rule
} : undefined;
cb(false, error);
}
}); // 成功的回调
if (!isFail) {
cb(!isFail);
}
} else {
const rule = rules;
rule.name = name;
const resMessage = validateSingleRule(rule, value || models[name], rule.param, models);
const error = resMessage ? {
message: resMessage,
rule
} : undefined;
if (resMessage) {
isFail = true;
}
cb(!isFail, error);
}
}
static addMethod(ruleName, method) {
_validator.default[ruleName] = method;
}
setModel(newModel) {
this.models = newModel;
}
setRules(newRules) {
this.rules = newRules;
}
}
var _default = FormValidator;
exports.default = _default;
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _string = __webpack_require__(7);
const defaultMessage = {
required: '%s必填',
minlength: '长度最少为%s',
maxlength: '长度最大为%s',
rangelength: '长度在%s和%s之间',
bytelength: '最多只能输入%s个字',
min: '值最小为%s',
max: '值最大为%s',
range: '值的范围为%s和%s之间',
mobile: '请输入正确的手机号',
email: '请输入正确的电子邮件',
url: '请输入正确的URL地址',
equalTo: '值和字段%s不相等'
};
const isEmpty = function (val) {
if (val === 0 || val === false) return false;
return !val;
};
var _default = {
required(r, val) {
if (r.required === false) return '';else if (isEmpty(val)) return (0, _string.sprintf)(r.message || defaultMessage.required, r.name);else return '';
},
minlength(r, val) {
const minlen = r.minlength;
val = val || '';
if (val.length < minlen) return (0, _string.sprintf)(r.message || defaultMessage.minlength, minlen);else return '';
},
maxlength(r, val) {
const maxlen = r.maxlength;
val = val || '';
if (val.length > maxlen) {
return (0, _string.sprintf)(r.message || defaultMessage.maxlength, maxlen);
} else {
return '';
}
},
rangelength(r, val) {
const range = r.rangelength;
val = val || '';
if (val.length > range[1] || val.length < range[0]) {
return (0, _string.sprintf)(r.message || defaultMessage.rangelength, range[0], range[1]);
} else {
return '';
}
},
min(r, val) {
const min = r.min;
if (val < min) {
return (0, _string.sprintf)(r.message || defaultMessage.min, min);
} else {
return '';
}
},
max(r, val) {
const max = r.max;
if (val > max) {
return (0, _string.sprintf)(r.message || defaultMessage.max, max);
} else {
return '';
}
},
range(r, val) {
const range = r.range;
if (val < range[0] || val > range[1]) {
return (0, _string.sprintf)(r.message || defaultMessage.range, range[0], range[1]);
} else {
return '';
}
},
mobile(r, val) {
val = val || '';
if (r.mobile === false) {
return '';
} else if (val.length !== 11) {
return (0, _string.sprintf)(r.message || defaultMessage.mobile);
} else {
return '';
}
},
email(r, value) {
if (r.email === false) return ''; // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
// eslint-disable-next-line
if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(value)) {
return (0, _string.sprintf)(r.message || defaultMessage.email);
} else {
return '';
}
},
// http://docs.jquery.com/Plugins/Validation/Methods/url
url(r, value) {
if (r.url === false) return ''; // contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
if ( // eslint-disable-next-line no-useless-escape
!/^(https?|s?ftp|weixin):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value)) {
return r.message || defaultMessage.url;
} else {
return '';
}
},
equalTo(r, value, param, models) {
const equalTo = r.equalTo;
if (value !== models[equalTo]) {
return (0, _string.sprintf)(r.message || defaultMessage.equalTo, r.name);
} else {
return '';
}
},
bytelength(r, value, param) {
param = r.param; // eslint-disable-next-line no-control-regex
const len = value.replace(/[^\x00-\xff]/g, '**').length;
if (len > param) {
return (0, _string.sprintf)(r.message || defaultMessage.bytelength, param);
} else {
return '';
}
}
};
exports.default = _default;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.sprintf = void 0;
/**
* 占位替换
* @method sprintf
* @method String.prototype.sprintf
* @example
* "my name is %s %s".sprintf("a","b") ="my name is a b"
*/
const sprintf = (...args) => {
let i;
let result = args[0] || '';
let para;
let reg;
const length = args.length - 1;
if (length < 1) {
return result;
}
i = 1;
while (i < length + 1) {
result = result.replace(/%s/, '{#' + i + '#}');
i++;
}
result.replace('%s', '');
i = 1; // eslint-disable-next-line
while (true) {
para = args[i];
if (para === undefined) {
// 0 也是可能的替换数字
break;
}
reg = new RegExp('{#' + i + '#}', 'g');
result = result.replace(reg, para);
i++;
}
return result;
};
exports.sprintf = sprintf;
/***/ })
/******/ ]);

@ -0,0 +1,192 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 21);
/******/ })
/************************************************************************/
/******/ ({
/***/ 21:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Component({
options: {
addGlobalClass: true
},
properties: {
imgUrls: {
type: Array,
value: [],
observer(newVal) {
this.setData({
currentImgs: newVal
});
}
},
showDelete: {
// 是否显示delete按钮
type: Boolean,
value: true
},
show: {
type: Boolean,
value: true
},
current: {
type: Number,
value: 0
},
hideOnClick: {
type: Boolean,
value: true
},
extClass: {
type: String,
value: ''
}
},
data: {
currentImgs: []
},
ready() {
const data = this.data;
this.setData({
currentImgs: data.imgUrls
});
},
methods: {
change(e) {
this.setData({
current: e.detail.current
});
this.triggerEvent('change', {
current: e.detail.current
}, {});
},
deleteImg() {
const data = this.data;
const imgs = data.currentImgs;
const url = imgs.splice(data.current, 1);
this.triggerEvent('delete', {
url: url[0],
index: data.current
}, {});
if (imgs.length === 0) {
// @ts-ignore
this.hideGallery();
return;
}
this.setData({
current: 0,
currentImgs: imgs
});
},
hideGallery() {
const data = this.data;
if (data.hideOnClick) {
this.setData({
show: false
});
this.triggerEvent('hide', {}, {});
}
}
}
});
/***/ })
/******/ });

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

Loading…
Cancel
Save