commit
3d624d7a23
744 changed files with 26933 additions and 0 deletions
@ -0,0 +1 @@ |
|||
node_modules |
@ -0,0 +1,8 @@ |
|||
{ |
|||
"files.associations": { |
|||
"*.cjson": "jsonc", |
|||
"*.wxss": "css", |
|||
"*.wxs": "javascript", |
|||
"*.wxml": "wxml" |
|||
} |
|||
} |
@ -0,0 +1 @@ |
|||
# e锦水小程序-志愿者端 |
@ -0,0 +1,16 @@ |
|||
const request = require("../utils/request") |
|||
/** |
|||
* 获取欢迎页信息 |
|||
*/ |
|||
export function getStartupPage () { |
|||
return request.get("startup/getStartupPage") |
|||
} |
|||
|
|||
/** |
|||
* 获取欢迎页信息 v2 |
|||
*/ |
|||
export default function getStartupPageV2 () { |
|||
return request.get("startup/v2/getStartupPage", { |
|||
platform: '1' |
|||
}) |
|||
} |
@ -0,0 +1,25 @@ |
|||
const request = require("../utils/request") |
|||
/** |
|||
* 获取积分核销兑换码 |
|||
*/ |
|||
export function getCode() { |
|||
return request.get("userpointsverification/getqrcode") |
|||
} |
|||
/** |
|||
* 获取居民兑换记录接口 |
|||
* @param behaviorCode 积分动作编码 |
|||
* @param pageIndex Number 页码 |
|||
* @param pageSize Number 页容量 |
|||
*/ |
|||
|
|||
export function getPointsLogs({ |
|||
behaviorCode, |
|||
pageIndex, |
|||
pageSize |
|||
}) { |
|||
return request.get("userpointsverification/getpointslogs", { |
|||
behaviorCode, |
|||
pageIndex, |
|||
pageSize |
|||
}) |
|||
} |
@ -0,0 +1,56 @@ |
|||
App({ |
|||
onLaunch: function (options) { |
|||
// 判断是否由分享进入小程序
|
|||
if (options.scene == 1007 || options.scene == 1008) { |
|||
this.globalData.share = true |
|||
} else { |
|||
this.globalData.share = false |
|||
} |
|||
//获取设备顶部窗口的高度(不同设备窗口高度不一样,根据这个来设置自定义导航栏的高度)
|
|||
//这个最初我是在组件中获取,但是出现了一个问题,当第一次进入小程序时导航栏会把
|
|||
//页面内容盖住一部分,当打开调试重新进入时就没有问题,这个问题弄得我是莫名其妙
|
|||
//虽然最后解决了,但是花费了不少时间
|
|||
const menuButtonInfo = wx.getMenuButtonBoundingClientRect() |
|||
wx.getSystemInfo({ |
|||
success: (res) => { |
|||
this.globalData.height = res.statusBarHeight |
|||
this.globalData.deviceInfo.statusHeight = res.statusBarHeight |
|||
this.globalData.deviceInfo.navigationHeight = menuButtonInfo.height + (menuButtonInfo.top - res.statusBarHeight) * 2 |
|||
this.globalData.screen.height = res.screenHeight |
|||
this.globalData.screen.width = res.screenWidth |
|||
} |
|||
}) |
|||
}, |
|||
globalData: { |
|||
flag: false, |
|||
exitApp: false, |
|||
accountState: 0, // 未注册
|
|||
share: false, // 分享默认为false
|
|||
height: 0, |
|||
infoCompleted: 0, // 0-未完善 1,2,3...-已完善
|
|||
tempGridId: "", |
|||
userInfo : { // 当前登陆的用户信息
|
|||
userId: "", |
|||
username: "", |
|||
userMobile: "", |
|||
partyFlag: "" |
|||
}, |
|||
groupInfo: { // 友邻社群-当前展示的社群信息
|
|||
groupAvatar: "", |
|||
groupLeader: "", |
|||
groupName:"", |
|||
groupId: "", |
|||
lordFlag: "" |
|||
}, |
|||
previewImage: false, // 预览图片后会触发onShow,加个状态区分一下
|
|||
deviceInfo: { |
|||
statusHeight: 20, |
|||
navigationHeight: 40 |
|||
}, |
|||
screen: { |
|||
width: 375, |
|||
height: 667 |
|||
}, |
|||
volunteerChange: false, // 志愿者信息是否有更新
|
|||
} |
|||
}) |
@ -0,0 +1,93 @@ |
|||
{ |
|||
"pages": [ |
|||
"pages/start/start", |
|||
"pages/heartNew/heartNew", |
|||
"pages/mine/mine", |
|||
"pages/toRegister/toRegister", |
|||
"pages/toScan/toScan", |
|||
"pages/complete/complete", |
|||
"pages/formid/formid", |
|||
"pages/register/register", |
|||
"pages/accept/accept", |
|||
"pages/gridLeaderRegister/gridLeaderRegister" |
|||
], |
|||
"subPackages": [ |
|||
{ |
|||
"root": "subpages/changegrid", |
|||
"name": "changeGrid", |
|||
"pages": [ |
|||
"pages/changeGrid/changeGrid" |
|||
] |
|||
}, |
|||
{ |
|||
"root": "subpages/mine", |
|||
"name": "mine", |
|||
"pages": [ |
|||
"pages/eventDetail/eventDetail", |
|||
"pages/inviteRecord/inviteRecord", |
|||
"pages/gridManage/gridManage" |
|||
] |
|||
}, |
|||
{ |
|||
"root": "subpages/integralCentre", |
|||
"name": "integralCentre", |
|||
"pages": [ |
|||
"pages/index/index", |
|||
"pages/exchangeIndex/exchangeIndex" |
|||
] |
|||
}, |
|||
{ |
|||
"root": "subpages/heart", |
|||
"pages": [ |
|||
"pages/heartDetail/heartDetail", |
|||
"pages/leaderboard/leaderboard", |
|||
"pages/leaderboardNew/leaderboardNew", |
|||
"pages/myNews/myNews", |
|||
"pages/clockIn/clockIn", |
|||
"pages/volunteer/volunteer", |
|||
"pages/signed/signed", |
|||
"pages/refusedOrEndedDetail/refusedOrEndedDetail", |
|||
"pages/cancelDetail/cancelDetail", |
|||
"pages/noticeDetail/noticeDetail", |
|||
"pages/myApply/myApply", |
|||
"pages/myApplyList/myApplyList", |
|||
"pages/myApplyDetail/myApplyDetail", |
|||
"pages/bannerDetail/bannerDetail", |
|||
"pages/groupBuyList/groupBuyList", |
|||
"pages/groupBuyListMy/groupBuyListMy", |
|||
"pages/groupBuyDetail/groupBuyDetail", |
|||
"pages/groupBuyConfirmList/groupBuyConfirmList", |
|||
"pages/evaluate/evaluate", |
|||
"pages/dropByList/dropByList", |
|||
"pages/groupBuyPublish/groupBuyPublish", |
|||
"pages/dropByPublish/dropByPublish", |
|||
"pages/noticeNewDetail/noticeNewDetail", |
|||
"pages/noticeNewList/noticeNewList", |
|||
"pages/scanCodeSignin/scanCodeSignin" |
|||
] |
|||
} |
|||
], |
|||
"preloadRule": { |
|||
"pages/mine/mine": { |
|||
"network": "all", |
|||
"packages": [ |
|||
"mine" |
|||
] |
|||
} |
|||
}, |
|||
"window": { |
|||
"backgroundTextStyle": "light", |
|||
"navigationBarBackgroundColor": "#fff", |
|||
"navigationBarTitleText": "WeChat", |
|||
"navigationBarTextStyle": "black" |
|||
}, |
|||
"networkTimeout": { |
|||
"request": 6000 |
|||
}, |
|||
"permission": { |
|||
"scope.userLocation": { |
|||
"desc": "志愿者小程序将获取您的位置信息" |
|||
} |
|||
}, |
|||
"sitemapLocation": "sitemap.json" |
|||
} |
@ -0,0 +1,71 @@ |
|||
/**app.wxss**/ |
|||
/* Wux Weapp Utility 工具类 */ |
|||
@import './dist/styles/index.wxss'; |
|||
|
|||
page { |
|||
height: 100%; |
|||
} |
|||
.card { |
|||
display: flex; |
|||
margin: 10px 10px 10px 10px; |
|||
background: #ffffff; |
|||
border-radius: 8px; |
|||
height: calc(100% - 20px); |
|||
box-shadow: 0px 0px 5px #eeeeee; |
|||
flex-direction: column; |
|||
} |
|||
.fixed{ |
|||
margin: auto; |
|||
position: fixed; |
|||
bottom: 50px; |
|||
left: 0; |
|||
right: 0; |
|||
} |
|||
.fixed2{ |
|||
margin: auto; |
|||
position: fixed; |
|||
bottom: 125px; |
|||
left: 0; |
|||
right: 0; |
|||
} |
|||
.buttons { |
|||
width: 560rpx; |
|||
height: 84rpx; |
|||
font-size: 32rpx; |
|||
font-weight: bold; |
|||
margin: auto; |
|||
left: 0; |
|||
right: 0; |
|||
} |
|||
.btn_label{ |
|||
position: absolute; |
|||
color: #fff; |
|||
z-index: 99; |
|||
width: 560rpx; |
|||
height: 84rpx; |
|||
text-align: center; |
|||
line-height: 84rpx; |
|||
} |
|||
.btn_label2{ |
|||
position: absolute; |
|||
color: #fff; |
|||
z-index: 99; |
|||
width: 560rpx; |
|||
height: 84rpx; |
|||
text-align: center; |
|||
line-height: 84rpx; |
|||
} |
|||
.ic_btn { |
|||
width: 560rpx; |
|||
height: 84rpx; |
|||
position: fixed; |
|||
} |
|||
.ic_btn2 { |
|||
width: 560rpx; |
|||
height: 84rpx; |
|||
} |
|||
.btn { |
|||
width: 560rpx; |
|||
height: 84rpx; |
|||
opacity: 0; |
|||
} |
@ -0,0 +1,151 @@ |
|||
"use strict"; |
|||
var date = new Date(); |
|||
var years = []; |
|||
var months = []; |
|||
var days = []; |
|||
var hours = []; |
|||
var minutes = []; |
|||
for (var i = date.getFullYear(); i < (date.getFullYear() + 2); i++) { |
|||
years.push(i + "年"); |
|||
} |
|||
// for (var i = date.getFullYear(); i > (date.getFullYear() - 3); i--) {
|
|||
// years.push(i + "年");
|
|||
// }
|
|||
for (var i = 1; i <= 12; i++) { |
|||
months.push(i + "月"); |
|||
} |
|||
for (var i = 1; i <= 31; i++) { |
|||
days.push(i + "日"); |
|||
} |
|||
for (var i = 0; i <= 23; i++) { |
|||
hours.push(i + ""); |
|||
} |
|||
for (var i = 0; i <= 59; i++) { |
|||
minutes.push(i + ""); |
|||
} |
|||
var mGetDate = function (year, month) { |
|||
var d = new Date(year, month, 0); |
|||
return d.getDate(); |
|||
}; |
|||
var getDate = function (year, month, day, hour, minute) { |
|||
var newyear = year.substr(0, year.length - 1); |
|||
var setmonth = month.substr(0, month.length - 1); |
|||
var newmonth = setmonth < 10 ? '0' + setmonth : setmonth; |
|||
var setday = day.substr(0, day.length - 1); |
|||
var newday = setday < 10 ? '0' + setday : setday; |
|||
var newhour = hour < 10 ? '0' + hour : hour; |
|||
var newminute = minute < 10 ? '0' + minute : minute; |
|||
return newyear + '-' + newmonth + '-' + newday + ' ' + newhour + ":" + newminute + ":00"; |
|||
}; |
|||
var getInitDate = function (initTime) { |
|||
var t = initTime.split(' '); |
|||
var date = t[0].split('-'); |
|||
var time = t[1].split(':'); |
|||
var y = 0; |
|||
var m = 0; |
|||
var d = 0; |
|||
var h = 0; |
|||
var M = 0; |
|||
years.forEach(function (item, index) { |
|||
if (item == (date[0] + '年')) { |
|||
y = index; |
|||
} |
|||
}); |
|||
months.forEach(function (item, index) { |
|||
if (item == (parseInt(date[1]) + '月')) { |
|||
m = index; |
|||
} |
|||
}); |
|||
days.forEach(function (item, index) { |
|||
if (item == (parseInt(date[2]) + '日')) { |
|||
d = index; |
|||
} |
|||
}); |
|||
hours.forEach(function (item, index) { |
|||
if (item == parseInt(time[0])) { |
|||
h = index; |
|||
} |
|||
}); |
|||
minutes.forEach(function (item, index) { |
|||
if (item == parseInt(time[1])) { |
|||
M = index; |
|||
} |
|||
}); |
|||
return [y, m, d, h, M]; |
|||
}; |
|||
Component({ |
|||
properties: { |
|||
initTime: { |
|||
type: String, |
|||
observer: function (newTime) { |
|||
this.data.timevalue = getInitDate(newTime); |
|||
this.setData({ |
|||
timevalue: this.data.timevalue |
|||
}); |
|||
} |
|||
} |
|||
}, |
|||
observers: {}, |
|||
data: { |
|||
timevalue: [], |
|||
years: years, |
|||
months: months, |
|||
days: days, |
|||
hours: hours, |
|||
minutes: minutes, |
|||
year: '', |
|||
month: '', |
|||
day: '', |
|||
hour: '', |
|||
minute: '' |
|||
}, |
|||
lifetimes: { |
|||
attached: function () { |
|||
var year = this.data.years[this.data.timevalue[0]||0]; |
|||
var month = this.data.months[this.data.timevalue[1]||0]; |
|||
var day = this.data.days[this.data.timevalue[2]||0]; |
|||
var hour = this.data.hours[this.data.timevalue[3]||0]; |
|||
var minute = this.data.minutes[this.data.timevalue[4]||0]; |
|||
this.setData({ |
|||
year: year, |
|||
month: month, |
|||
day: day, |
|||
hour: hour, |
|||
minute: minute, |
|||
}); |
|||
}, |
|||
detached: function () { |
|||
}, |
|||
}, |
|||
methods: { |
|||
cancel: function () { |
|||
this.triggerEvent("cancel"); |
|||
}, |
|||
confirm: function () { |
|||
var _a = this.data, year = _a.year, month = _a.month, day = _a.day, hour = _a.hour, minute = _a.minute; |
|||
var time = getDate(year, month, day, hour, minute); |
|||
this.triggerEvent("confirm", { time: time }); |
|||
}, |
|||
fnbindChange: function (e) { |
|||
var val = e.detail.value; |
|||
var year = this.data.years[val[0]]; |
|||
var month = this.data.months[val[1]]; |
|||
var day = this.data.days[val[2]]; |
|||
var hour = this.data.hours[val[3]]; |
|||
var minute = this.data.minutes[val[4]]; |
|||
var days = []; |
|||
var daynum = mGetDate(year.substr(0, year.length - 1), month.substr(0, month.length - 1)); |
|||
for (var i = 1; i <= daynum; i++) { |
|||
days.push(i + "日"); |
|||
} |
|||
this.setData({ |
|||
days: days, |
|||
year: year, |
|||
month: month, |
|||
day: day, |
|||
hour: hour, |
|||
minute: minute, |
|||
}); |
|||
} |
|||
} |
|||
}); |
@ -0,0 +1,4 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": {} |
|||
} |
@ -0,0 +1,39 @@ |
|||
<!-- 组件模板 --> |
|||
<view class="wrapper"> |
|||
<slot></slot> |
|||
<view >{{title}}</view> |
|||
<!-- 日期模态框 --> |
|||
<view class="modelboxbg"></view> |
|||
<view class="modelbox"> |
|||
<view class = "model_picker"> |
|||
<view class = "button_model"> |
|||
<text catchtap='cancel' >取消</text> |
|||
<text catchtap='confirm' >确定</text> |
|||
</view> |
|||
<view class = "cont_model"> |
|||
<picker-view indicator-style="height: 50px;" style="width: 100%; height: 300px;" value="{{timevalue}}" catchchange="fnbindChange"> |
|||
<!-- 年 --> |
|||
<picker-view-column wx:if="{{years.length > 0}}"> |
|||
<view wx:for="{{years}}" wx:key="index" style="line-height: 50px">{{item}}</view> |
|||
</picker-view-column> |
|||
<!-- 月 --> |
|||
<picker-view-column wx:if="{{months.length > 0}}"> |
|||
<view wx:for="{{months}}" wx:key="index" style="line-height: 50px">{{item}}</view> |
|||
</picker-view-column> |
|||
<!-- 日 --> |
|||
<picker-view-column wx:if="{{days.length > 0}}"> |
|||
<view wx:for="{{days}}" wx:key="index" style="line-height: 50px">{{item}}</view> |
|||
</picker-view-column> |
|||
<!-- 时 --> |
|||
<picker-view-column wx:if="{{hours.length > 0}}"> |
|||
<view wx:for="{{hours}}" wx:key="index" style="line-height: 50px">{{item}}</view> |
|||
</picker-view-column> |
|||
<!-- 分 --> |
|||
<picker-view-column wx:if="{{minutes.length > 0}}"> |
|||
<view wx:for="{{minutes}}" wx:key="index" style="line-height: 50px">{{item}}</view> |
|||
</picker-view-column> |
|||
</picker-view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
@ -0,0 +1,45 @@ |
|||
/* 模态框开始 */ |
|||
/* 蒙层 */ |
|||
.modelboxbg{ |
|||
position:absolute; |
|||
top:0; |
|||
z-index:10000; |
|||
width:100%; |
|||
height: 100%; |
|||
background: #000; |
|||
opacity: 0.3; |
|||
} |
|||
.modelbox{ |
|||
position: fixed; |
|||
bottom:0; |
|||
z-index:999999; |
|||
width:100%; |
|||
background: #fff; |
|||
} |
|||
picker-view-column{ |
|||
text-align: center; |
|||
} |
|||
view.model_picker{ |
|||
position: relative; |
|||
} |
|||
.button_model{ |
|||
height: 80rpx; |
|||
width: 100%; |
|||
background: #fff; |
|||
position: relative; |
|||
border-bottom: 1px solid #d9d9d9; |
|||
} |
|||
.button_model text{ |
|||
color: #007aff; |
|||
position: absolute; |
|||
background:transparent; |
|||
border: none; |
|||
line-height: 80rpx; |
|||
} |
|||
.button_model text:first-child{ |
|||
left: 32rpx; |
|||
} |
|||
.button_model text:last-child{ |
|||
right: 32rpx; |
|||
} |
|||
/* 模态框结束 */ |
@ -0,0 +1,75 @@ |
|||
var api = require("../../utils/activity.js") |
|||
Component({ |
|||
properties: { |
|||
state: Number, |
|||
}, |
|||
data: { |
|||
activityList: [], |
|||
nomore: false |
|||
}, |
|||
attached: function () {}, |
|||
ready: function () {}, |
|||
pageLifetimes: { |
|||
show: function () {}, |
|||
}, |
|||
methods: { |
|||
getActivityList (params) { |
|||
let that = this |
|||
that.setData({ |
|||
selectedTab: params.selectedTab |
|||
}) |
|||
if (params.qkdat == true) { |
|||
console.log("清空") |
|||
that.setData({ |
|||
activityList: [], |
|||
nomore: false |
|||
}) |
|||
} |
|||
|
|||
api.getActivityList(params).then((res) => { |
|||
console.log(res.data) |
|||
that.setData({ |
|||
activityList: that.data.activityList.concat(res.data) |
|||
}) |
|||
//console.log(res.data.length)
|
|||
//数据访问成功
|
|||
var myEventDetail = { |
|||
listLength: res.data.length |
|||
} |
|||
that.triggerEvent("toActDetail", myEventDetail) |
|||
if (res.data.length == 0) { |
|||
that.setData({ |
|||
nomore: true |
|||
}) |
|||
} |
|||
}) |
|||
}, |
|||
|
|||
toActDetail (e) { |
|||
console.log("selectedTab::::"+this.data.selectedTab) |
|||
const id = e.currentTarget.dataset.id |
|||
const actcurrentstate = e.currentTarget.dataset.actcurrentstate |
|||
const signupflag = e.currentTarget.dataset.signupflag |
|||
this.triggerEvent("toActDetail", { |
|||
actId: id |
|||
}) |
|||
wx.navigateTo({ |
|||
url: `/subpages/heart/pages/heartDetail/heartDetail?id=${id}&actcurrentstate=${actcurrentstate}&signupflag=${signupflag}&selectedTab=${this.data.selectedTab}` |
|||
}) |
|||
}, |
|||
updateActivityList (params) { |
|||
api.getActivityList(params).then(res => { |
|||
console.log("详情回列表刷新数据", res) |
|||
const index = this.data.activityList.findIndex(item => item.id === res.data[0].id) |
|||
if (index > -1) { |
|||
this.data.activityList.splice(index, 1, res.data[0]) |
|||
} else { |
|||
this.data.activityList.splice(index, 1) |
|||
} |
|||
this.setData({ |
|||
activityList: this.data.activityList |
|||
}) |
|||
}) |
|||
} |
|||
} |
|||
}) |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,39 @@ |
|||
<view class="layout" wx:for="{{activityList}}" wx:key="index"> |
|||
<view class="activity-box" |
|||
data-id="{{item.id}}" |
|||
data-actCurrentState="{{item.actCurrentState}}" |
|||
data-signupFlag="{{item.signupFlag}}" |
|||
bindtap="toActDetail"> |
|||
<view class="img"> |
|||
<image class="imgsrc" src="{{item.headPic}}" mode="aspectFill"/> |
|||
<view class="user-state" wx:if="{{item.actCurrentState=='0'}}">报名中</view> |
|||
<view class="user-state" wx:if="{{item.actCurrentState=='1'}}">已报满</view> |
|||
<view class="user-state" wx:if="{{item.actCurrentState=='2'}}">未开始</view> |
|||
<view class="user-state" wx:if="{{item.actCurrentState=='3'}}">进行中</view> |
|||
<view class="user-state" wx:if="{{item.actCurrentState=='4'}}">已结束</view> |
|||
<view class="user-state" wx:if="{{item.actCurrentState=='5'}}">已取消</view> |
|||
</view> |
|||
<view class="infos"><view class="infos-flex"> |
|||
<view class="infos_title">{{item.title}}</view> |
|||
<view class="infos_times"> |
|||
<image class="imgsize" src="https://epdc-kongcun.elinkit.com.cn/epdcFile/M00/00/07/rBAB7165A6WAcS1lAAABQRNkl7Y828.png" /> |
|||
<text >时间:{{item.actStartTime}}至</text> |
|||
<view class="endtime">{{item.actEndTime}}</view> |
|||
</view> |
|||
<view class="infos_addr"> |
|||
<image class="imgsize" src="https://epdc-kongcun.elinkit.com.cn/epdcFile/M00/00/07/rBAB7165A7-AKfhbAAABTg-ZMDk458.png" /> |
|||
<text>地点:{{item.actAddress}}</text> |
|||
</view> |
|||
<view class="infos_nums" wx:if="{{!(state==2)}}"> |
|||
|
|||
<span wx:if="{{item.actQuotaCategory == 0}}" class="total">不限名额</span> |
|||
<span wx:else class="total">活动名额 {{item.actQuota}}人</span> |
|||
<!-- <span class="signed">已报名 {{item.signupNum}}人</span> --> |
|||
<!-- <image src="https://epdc-kongcun.elinkit.com.cn/epdcFile/M00/00/20/rBAB718X06CAfNqkAABIcXHcQv0363.png" /> --> |
|||
</view> |
|||
</view></view> |
|||
</view> |
|||
<image class="signed-logo" wx:if="{{item.signupFlag=='1'}}" src="https://epdc-kongcun.elinkit.com.cn/epdcFile/M00/00/07/rBAB7165A-CAIEeKAABSBTxj8ns662.png" /> |
|||
</view> |
|||
<!-- <view hidden="{{nomore}}" class="loadmore">上滑加载更多</view> |
|||
<view hidden="{{!nomore}}" class="loadmore">没有更多了~</view> --> |
@ -0,0 +1,173 @@ |
|||
.layout { |
|||
|
|||
} |
|||
.activity-box { |
|||
width: 750rpx; |
|||
height: 286rpx; |
|||
background-color: #ffffff; |
|||
margin-bottom: 14rpx; |
|||
display: flex; |
|||
align-items: center; |
|||
position: relative; |
|||
} |
|||
|
|||
.img { |
|||
width: 190rpx; |
|||
height: 246rpx; |
|||
margin-left: 30rpx; |
|||
position: relative; |
|||
} |
|||
|
|||
.img .imgsrc { |
|||
width: 190rpx; |
|||
height: 246rpx; |
|||
background: #f1f1f1; |
|||
border-radius: 16rpx; |
|||
} |
|||
|
|||
.left { |
|||
width: 190rpx; |
|||
height: 246rpx; |
|||
border-radius: 16rpx; |
|||
overflow: hidden; |
|||
} |
|||
|
|||
.activity-image { |
|||
width: 100%; |
|||
height: 100%; |
|||
object-fit: cover; |
|||
} |
|||
|
|||
.user-state { |
|||
position: absolute; |
|||
left: 0; |
|||
top: 0; |
|||
z-index: 955; |
|||
font-size: 24rpx; |
|||
color: #fff; |
|||
width: 92rpx; |
|||
height: 36rpx; |
|||
line-height: 37rpx; |
|||
text-align: center; |
|||
border-radius: 16rpx 0; |
|||
background: rgba(0, 0, 0, 0.3); |
|||
} |
|||
|
|||
.signed-logo { |
|||
width: 174rpx; |
|||
height: 118rpx; |
|||
right: 20rpx; |
|||
margin: -262rpx 20rpx 0rpx 0rpx; |
|||
/* object-fit: cover; *//* right: 0; |
|||
top: 20rpx; */ |
|||
position: absolute; |
|||
z-index: 955; |
|||
} |
|||
|
|||
.infos { |
|||
height: 246rpx; |
|||
overflow: hidden; |
|||
margin-left: 18rpx; |
|||
margin-right: 28rpx; |
|||
-webkit-box-sizing: border-box; |
|||
-moz-box-sizing: border-box; |
|||
box-sizing: border-box; |
|||
} |
|||
|
|||
.infos .infos_title { |
|||
font-size: 34rpx; |
|||
line-height: 40rpx; |
|||
height: 80rpx; |
|||
overflow: hidden; |
|||
color: #333; |
|||
display: -webkit-box; |
|||
-webkit-box-orient: vertical; |
|||
-webkit-line-clamp: 2; |
|||
} |
|||
.infos .infos-flex { |
|||
height: 100%; |
|||
display: flex; |
|||
flex-direction: column; |
|||
justify-content: space-around; |
|||
} |
|||
.infos .infos_times { |
|||
height: 56rpx; |
|||
line-height: 28rpx; |
|||
font-size: 24rpx; |
|||
overflow: hidden; |
|||
color: #a8a8a8; |
|||
margin-top: 20rpx; |
|||
} |
|||
.infos .infos_addr { |
|||
height: 28rpx; |
|||
line-height: 28rpx; |
|||
font-size: 24rpx; |
|||
overflow: hidden; |
|||
color: #a8a8a8; |
|||
display: flex; |
|||
margin-top: 8rpx; |
|||
} |
|||
.infos .infos_addr text { |
|||
display: -webkit-box; |
|||
-webkit-box-orient: vertical; |
|||
-webkit-line-clamp: 1; |
|||
} |
|||
|
|||
.endtime { |
|||
text-indent: 100rpx; |
|||
} |
|||
|
|||
.imgsize { |
|||
width: 24rpx; |
|||
height: 24rpx; |
|||
margin-right: 4rpx; |
|||
} |
|||
|
|||
.infos .infos_nums { |
|||
font-size: 26rpx; |
|||
height: 36rpx; |
|||
color: #666; |
|||
} |
|||
|
|||
.infos .infos_nums { |
|||
height: 40rpx; |
|||
width: 100%; |
|||
display: flex; |
|||
justify-content: space-between; |
|||
margin-top: 18rpx; |
|||
} |
|||
.infos_nums image { |
|||
width: 150rpx; |
|||
height: 42rpx; |
|||
} |
|||
|
|||
.loadmore { |
|||
width: 100%; |
|||
text-align: center; |
|||
height: 50px; |
|||
line-height: 50px; |
|||
background: #f6f8f8; |
|||
font-size: 12px; |
|||
color: #999; |
|||
} |
|||
|
|||
.total, .signed { |
|||
display: block; |
|||
font-size: 28rpx; |
|||
padding: 0px 20rpx 0px 0rpx; |
|||
height: 40rpx; |
|||
line-height: 40rpx; |
|||
border-radius: 20rpx; |
|||
/* margin: 10rpx 20rpx 0rpx 0rpx; */ |
|||
float: left; |
|||
} |
|||
|
|||
.total { |
|||
/* background: #d9d9d9; |
|||
color: #666; */ |
|||
} |
|||
|
|||
.signed { |
|||
background: #ffeaea; |
|||
color: #fc5555; |
|||
} |
@ -0,0 +1,34 @@ |
|||
Component({ |
|||
data: { |
|||
visible: false |
|||
}, |
|||
properties: { |
|||
completeInfoDialogVisible: { |
|||
type: Boolean, |
|||
value: false, |
|||
observer () { |
|||
this.setData({ |
|||
visible: !this.data.visible |
|||
}) |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
navigateToComplete () { |
|||
wx.navigateTo({ |
|||
url: "/pages/complete/complete" |
|||
}) |
|||
this.setData({ |
|||
visible: false |
|||
}) |
|||
}, |
|||
closeDialog () { |
|||
this.setData({ |
|||
visible: false |
|||
}) |
|||
}, |
|||
catchmove () { |
|||
|
|||
} |
|||
} |
|||
}) |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,13 @@ |
|||
<view class="complete-info-dialog" wx:if="{{visible}}" catchtouchmove="catchmove"> |
|||
<view class="content"> |
|||
<view class="close-dialog"> |
|||
<image bindtap="closeDialog" src="../../images/IC_guanbi@2x.png" /> |
|||
</view> |
|||
<view class="title">提示</view> |
|||
<view class="tip">请先完善用户信息</view> |
|||
<view class="operation"> |
|||
<view class="cancel" bindtap="closeDialog">下次再说</view> |
|||
<view class="confirm" bindtap="navigateToComplete">立即完善</view> |
|||
</view> |
|||
</view> |
|||
</view> |
@ -0,0 +1,75 @@ |
|||
.complete-info-dialog { |
|||
width: 100%; |
|||
height:100vh; |
|||
position: fixed; |
|||
left: 0; |
|||
top: 0; |
|||
background: rgba(0,0,0, 0.6); |
|||
display: flex; |
|||
justify-content: center; |
|||
align-items: center; |
|||
z-index: 1000; |
|||
} |
|||
.complete-info-dialog .content { |
|||
width: 530rpx; |
|||
border-radius: 16rpx; |
|||
background: #fff; |
|||
box-sizing: border-box; |
|||
padding: 0 20rpx; |
|||
} |
|||
.complete-info-dialog .content .close-dialog { |
|||
width: 100%; |
|||
height: 60rpx; |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: flex-end; |
|||
} |
|||
.complete-info-dialog .content .close-dialog image { |
|||
width:24rpx; |
|||
height:24rpx; |
|||
} |
|||
.complete-info-dialog .content .title { |
|||
font-size: 36rpx; |
|||
color: #333; |
|||
width:100%; |
|||
line-height: 60rpx; |
|||
height: 60rpx; |
|||
text-align: center; |
|||
margin-bottom: 27rpx; |
|||
} |
|||
.complete-info-dialog .content .tip { |
|||
font-size: 32rpx; |
|||
color: #666; |
|||
line-height: 50rpx; |
|||
text-align:center; |
|||
margin-bottom: 36rpx; |
|||
} |
|||
.complete-info-dialog .content .operation { |
|||
width: 100%; |
|||
height: 105rpx; |
|||
box-sizing: border-box; |
|||
padding: 15rpx 0; |
|||
display: flex; |
|||
justify-content: space-around; |
|||
align-items: center; |
|||
border-top: 1rpx solid #eaeaea; |
|||
} |
|||
.complete-info-dialog .content .operation .cancel { |
|||
width: 100%; |
|||
height:100%; |
|||
text-align: center; |
|||
line-height: 75rpx; |
|||
font-size: 36rpx; |
|||
color: #666; |
|||
} |
|||
.complete-info-dialog .content .operation .cancel + .confirm { |
|||
border-left: 1rpx solid #eaeaea; |
|||
} |
|||
.complete-info-dialog .content .operation .confirm { |
|||
width: 100%; |
|||
height:100%; |
|||
text-align: center; |
|||
line-height: 75rpx; |
|||
font-size: 36rpx; |
|||
color: #04BCA0; |
|||
} |
@ -0,0 +1,14 @@ |
|||
Component({ |
|||
externalClasses: ['load-more-child'], |
|||
data: {}, |
|||
properties: { |
|||
loadMoreVisible: { |
|||
type: Boolean, |
|||
value: false |
|||
}, |
|||
loadMoreType: { |
|||
type: String, |
|||
value: "loading" |
|||
} |
|||
} |
|||
}) |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,7 @@ |
|||
<view class="load-more load-more-child" style="visibility: {{loadMoreVisible ? 'visible' : 'hidden'}}"> |
|||
<block wx:if="{{loadMoreType == 'loading'}}"> |
|||
<image class="load-image" src="../../images/loading.gif" /> |
|||
<view class="load-text">正在加载中...</view> |
|||
</block> |
|||
<view wx:else class="load-text">没有更多了~</view> |
|||
</view> |
@ -0,0 +1,18 @@ |
|||
.load-more { |
|||
width: 100%; |
|||
height: 100rpx; |
|||
background: #f7f7f7; |
|||
display: flex; |
|||
justify-content: center; |
|||
align-items: center; |
|||
} |
|||
.load-more .load-text { |
|||
color: #999; |
|||
font-size: 26rpx; |
|||
} |
|||
.load-more .load-image { |
|||
width: 30rpx; |
|||
height: 30rpx; |
|||
object-fit: cover; |
|||
margin-right: 10rpx; |
|||
} |
@ -0,0 +1,47 @@ |
|||
Component({ |
|||
data: { |
|||
}, |
|||
properties: { |
|||
areaTop: { |
|||
type: Number, |
|||
value: 0 |
|||
}, |
|||
areaLeft: { |
|||
type: Number, |
|||
value: 0 |
|||
}, |
|||
areaWidth: { |
|||
type: String, |
|||
value: '100%' |
|||
}, |
|||
areaHeight: { |
|||
type: String, |
|||
value: '100%' |
|||
}, |
|||
buttonWidth: { |
|||
type: Number, |
|||
value: 178 |
|||
}, |
|||
buttonHeight: { |
|||
type: Number, |
|||
value: 178 |
|||
}, |
|||
buttonTop: { |
|||
type: Number, |
|||
value: 1000 |
|||
}, |
|||
buttonLeft: { |
|||
type: Number, |
|||
value: 560 |
|||
}, |
|||
imgUrl: { |
|||
type: String, |
|||
value: '' |
|||
} |
|||
}, |
|||
methods: { |
|||
onClickButton () { |
|||
this.triggerEvent('movebtnCallBack') |
|||
} |
|||
} |
|||
}) |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,8 @@ |
|||
<movable-area class="movable-area" style="top:{{areaTop}}rpx;left:{{areaLeft}}rpx;width:{{areaWidth}};height:{{areaHeight}};"> |
|||
<movable-view class="movable-view" direction="all" inertia="true" friction="10" |
|||
style="width:{{buttonWidth}}rpx;height:{{buttonHeight}}rpx;top:{{buttonTop}}rpx;left:{{buttonLeft}}rpx;"> |
|||
<view class="img-box" bindtap="onClickButton"> |
|||
<image src="{{imgUrl}}" /> |
|||
</view> |
|||
</movable-view> |
|||
</movable-area> |
@ -0,0 +1,34 @@ |
|||
|
|||
/* 悬浮按钮 -start- */ |
|||
.movable-area{ |
|||
pointer-events:none; |
|||
z-index: 999; |
|||
width: 100%; |
|||
height: 90%; |
|||
position: fixed; |
|||
top: 60px; |
|||
left: 0; |
|||
right: 0; |
|||
bottom: 0; |
|||
} |
|||
.movable-view{ |
|||
pointer-events:auto; |
|||
width: 178rpx; |
|||
height: 178rpx; |
|||
transform: translateX(560rpx) translateY(680rpx) translateZ(0rpx) scale(1); |
|||
transform-origin: center center; |
|||
will-change: auto; |
|||
position: absolute; |
|||
top: 1100rpx; |
|||
left: 560rpx; |
|||
} |
|||
.img-box { |
|||
width: 100%; |
|||
height: 100%; |
|||
} |
|||
.img-box image { |
|||
width: 100%; |
|||
height: 100%; |
|||
object-fit: cover; |
|||
} |
|||
/* 悬浮按钮 -end- */ |
@ -0,0 +1,39 @@ |
|||
const app = getApp() |
|||
Component({ |
|||
properties: { |
|||
navbarData: { //navbarData 由父页面传递的数据,变量名字自命名
|
|||
type: Object, |
|||
value: {} |
|||
} |
|||
}, |
|||
data: { |
|||
height: "", |
|||
//默认值 默认显示左上角
|
|||
navbarData: { |
|||
showCapsule: 1 |
|||
} |
|||
}, |
|||
attached: function () { |
|||
// 获取是否是通过分享进入的小程序
|
|||
this.setData({ |
|||
share: app.globalData.share |
|||
}) |
|||
// 定义导航栏的高度 方便对齐
|
|||
this.setData({ |
|||
height: app.globalData.height |
|||
}) |
|||
}, |
|||
methods: { |
|||
// 返回上一页面
|
|||
_navback () { |
|||
wx.navigateBack() |
|||
}, |
|||
//返回到首页
|
|||
_backhome () { |
|||
wx.navigateTo({ |
|||
url: "/pages/heartNew/heartNew", |
|||
}) |
|||
} |
|||
} |
|||
|
|||
}) |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,14 @@ |
|||
<view class='nav-wrap' style='height: {{height*2 + 20}}px;'> |
|||
<view class='nav-title' style='line-height: {{height*2 + 44}}px;'>{{navbarData.title}}</view> |
|||
<view style='display: flex; justify-content: space-around;flex-direction: column'> |
|||
<view class='nav-capsule' style='height: {{height*2 + 44}}px;' wx:if='{{navbarData.showCapsule}}'> |
|||
<!-- <view bindtap='_navback' wx:if='{{!share}}'> |
|||
<image src='/imgs/back-pre.png' mode='aspectFill' class='back-pre'></image> |
|||
</view> |
|||
<view class='navbar-v-line' wx:if='{{!share}}'></view> --> |
|||
<view bindtap='_backhome'> |
|||
<image src='/images/back-home.png' mode='aspectFill' class='back-home'></image> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
@ -0,0 +1,53 @@ |
|||
/* 顶部要固定定位 标题要居中 自定义按钮和标题要和右边微信原生的胶囊上下对齐 */ |
|||
.nav-wrap { |
|||
position: fixed; |
|||
width: 100%; |
|||
top: 0; |
|||
background: #fff; |
|||
color: #000; |
|||
z-index: 9999999; |
|||
} |
|||
/* 标题要居中 */ |
|||
.nav-title { |
|||
position: absolute; |
|||
text-align: center; |
|||
max-width: 400rpx; |
|||
overflow: hidden; |
|||
text-overflow: ellipsis; |
|||
white-space: nowrap; |
|||
top: 0; |
|||
left: 0; |
|||
right: 0; |
|||
bottom: 0; |
|||
margin: auto; |
|||
font-size: 36rpx; |
|||
color: #2c2b2b; |
|||
font-weight: 600; |
|||
} |
|||
|
|||
.nav-capsule { |
|||
display: flex; |
|||
align-items: center; |
|||
margin-left: 30rpx; |
|||
width: 140rpx; |
|||
justify-content: space-between; |
|||
height: 100%; |
|||
} |
|||
|
|||
.navbar-v-line { |
|||
width: 1px; |
|||
height: 32rpx; |
|||
background-color: #e5e5e5; |
|||
} |
|||
|
|||
.back-pre, .back-home { |
|||
width: 36rpx; |
|||
height: 36rpx; |
|||
margin-top: 8rpx; |
|||
padding: 10rpx; |
|||
} |
|||
.nav-capsule .back-home { |
|||
width: 36rpx; |
|||
height: 36rpx; |
|||
margin-top: 6rpx; |
|||
} |
@ -0,0 +1,9 @@ |
|||
Component({ |
|||
properties: { |
|||
isShow: { |
|||
type: Boolean |
|||
} |
|||
}, |
|||
data: {}, |
|||
methods: {} |
|||
}); |
@ -0,0 +1,4 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": {} |
|||
} |
@ -0,0 +1,5 @@ |
|||
<!--components/nodata/nodata.wxml--> |
|||
<view class="box" wx:if="{{isShow}}"> |
|||
<image src="https://epdc-kongcun.elinkit.com.cn/epdcFile/M00/00/07/rBAB71646bOAXiYnAAB-svV4uWY962.png" class="image"/> |
|||
<text class="text">暂无数据~</text> |
|||
</view> |
@ -0,0 +1,19 @@ |
|||
/* components/nodata/nodata.wxss */ |
|||
.box{ |
|||
width: 100%; |
|||
height: auto; |
|||
box-sizing: border-box; |
|||
text-align: center; |
|||
margin-top: 100rpx; |
|||
} |
|||
.image{ |
|||
width: 450rpx; |
|||
height: 240rpx; |
|||
} |
|||
.text{ |
|||
width: 100%; |
|||
height: auto; |
|||
font-size: 28rpx; |
|||
color: #BCBCBC; |
|||
display: block; |
|||
} |
@ -0,0 +1,97 @@ |
|||
const cfg = require('./config.js'), |
|||
isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); |
|||
|
|||
function CssHandler(tagStyle) { |
|||
var styles = Object.assign(Object.create(null), cfg.userAgentStyles); |
|||
for (var item in tagStyle) |
|||
styles[item] = (styles[item] ? styles[item] + ';' : '') + tagStyle[item]; |
|||
this.styles = styles; |
|||
} |
|||
CssHandler.prototype.getStyle = function (data) { |
|||
this.styles = new parser(data, this.styles).parse(); |
|||
} |
|||
CssHandler.prototype.match = function (name, attrs) { |
|||
var tmp, matched = (tmp = this.styles[name]) ? tmp + ';' : ''; |
|||
if (attrs.class) { |
|||
var items = attrs.class.split(' '); |
|||
for (var i = 0, item; item = items[i]; i++) |
|||
if (tmp = this.styles['.' + item]) |
|||
matched += tmp + ';'; |
|||
} |
|||
if (tmp = this.styles['#' + attrs.id]) |
|||
matched += tmp + ';'; |
|||
return matched; |
|||
} |
|||
module.exports = CssHandler; |
|||
|
|||
function parser(data, init) { |
|||
this.data = data; |
|||
this.floor = 0; |
|||
this.i = 0; |
|||
this.list = []; |
|||
this.res = init; |
|||
this.state = this.Space; |
|||
} |
|||
parser.prototype.parse = function () { |
|||
for (var c; c = this.data[this.i]; this.i++) |
|||
this.state(c); |
|||
return this.res; |
|||
} |
|||
parser.prototype.section = function () { |
|||
return this.data.substring(this.start, this.i); |
|||
} |
|||
// 状态机
|
|||
parser.prototype.Space = function (c) { |
|||
if (c == '.' || c == '#' || isLetter(c)) { |
|||
this.start = this.i; |
|||
this.state = this.Name; |
|||
} else if (c == '/' && this.data[this.i + 1] == '*') |
|||
this.Comment(); |
|||
else if (!cfg.blankChar[c] && c != ';') |
|||
this.state = this.Ignore; |
|||
} |
|||
parser.prototype.Comment = function () { |
|||
this.i = this.data.indexOf('*/', this.i) + 1; |
|||
if (!this.i) this.i = this.data.length; |
|||
this.state = this.Space; |
|||
} |
|||
parser.prototype.Ignore = function (c) { |
|||
if (c == '{') this.floor++; |
|||
else if (c == '}' && !--this.floor) this.state = this.Space; |
|||
} |
|||
parser.prototype.Name = function (c) { |
|||
if (cfg.blankChar[c]) { |
|||
this.list.push(this.section()); |
|||
this.state = this.NameSpace; |
|||
} else if (c == '{') { |
|||
this.list.push(this.section()); |
|||
this.Content(); |
|||
} else if (c == ',') { |
|||
this.list.push(this.section()); |
|||
this.Comma(); |
|||
} else if (!isLetter(c) && (c < '0' || c > '9') && c != '-' && c != '_') |
|||
this.state = this.Ignore; |
|||
} |
|||
parser.prototype.NameSpace = function (c) { |
|||
if (c == '{') this.Content(); |
|||
else if (c == ',') this.Comma(); |
|||
else if (!cfg.blankChar[c]) this.state = this.Ignore; |
|||
} |
|||
parser.prototype.Comma = function () { |
|||
while (cfg.blankChar[this.data[++this.i]]); |
|||
if (this.data[this.i] == '{') this.Content(); |
|||
else { |
|||
this.start = this.i--; |
|||
this.state = this.Name; |
|||
} |
|||
} |
|||
parser.prototype.Content = function () { |
|||
this.start = ++this.i; |
|||
if ((this.i = this.data.indexOf('}', this.i)) == -1) this.i = this.data.length; |
|||
var content = this.section(); |
|||
for (var i = 0, item; item = this.list[i++];) |
|||
if (this.res[item]) this.res[item] += ';' + content; |
|||
else this.res[item] = content; |
|||
this.list = []; |
|||
this.state = this.Space; |
|||
} |
@ -0,0 +1,525 @@ |
|||
/** |
|||
* html 解析器 |
|||
* @tutorial https://github.com/jin-yufeng/Parser
|
|||
* @version 20200719 |
|||
* @author JinYufeng |
|||
* @listens MIT |
|||
*/ |
|||
const cfg = require('./config.js'), |
|||
blankChar = cfg.blankChar, |
|||
CssHandler = require('./CssHandler.js'), |
|||
windowWidth = wx.getSystemInfoSync().windowWidth; |
|||
var emoji; |
|||
|
|||
function MpHtmlParser(data, options = {}) { |
|||
this.attrs = {}; |
|||
this.CssHandler = new CssHandler(options.tagStyle, windowWidth); |
|||
this.data = data; |
|||
this.domain = options.domain; |
|||
this.DOM = []; |
|||
this.i = this.start = this.audioNum = this.imgNum = this.videoNum = 0; |
|||
options.prot = (this.domain || '').includes('://') ? this.domain.split('://')[0] : 'http'; |
|||
this.options = options; |
|||
this.state = this.Text; |
|||
this.STACK = []; |
|||
// 工具函数
|
|||
this.bubble = () => { |
|||
for (var i = this.STACK.length, item; item = this.STACK[--i];) { |
|||
if (cfg.richOnlyTags[item.name]) { |
|||
if (item.name == 'table' && !Object.hasOwnProperty.call(item, 'c')) item.c = 1; |
|||
return false; |
|||
} |
|||
item.c = 1; |
|||
} |
|||
return true; |
|||
} |
|||
this.decode = (val, amp) => { |
|||
var i = -1, |
|||
j, en; |
|||
while (1) { |
|||
if ((i = val.indexOf('&', i + 1)) == -1) break; |
|||
if ((j = val.indexOf(';', i + 2)) == -1) break; |
|||
if (val[i + 1] == '#') { |
|||
en = parseInt((val[i + 2] == 'x' ? '0' : '') + val.substring(i + 2, j)); |
|||
if (!isNaN(en)) val = val.substr(0, i) + String.fromCharCode(en) + val.substr(j + 1); |
|||
} else { |
|||
en = val.substring(i + 1, j); |
|||
if (cfg.entities[en] || en == amp) |
|||
val = val.substr(0, i) + (cfg.entities[en] || '&') + val.substr(j + 1); |
|||
} |
|||
} |
|||
return val; |
|||
} |
|||
this.getUrl = url => { |
|||
if (url[0] == '/') { |
|||
if (url[1] == '/') url = this.options.prot + ':' + url; |
|||
else if (this.domain) url = this.domain + url; |
|||
} else if (this.domain && url.indexOf('data:') != 0 && !url.includes('://')) |
|||
url = this.domain + '/' + url; |
|||
return url; |
|||
} |
|||
this.isClose = () => this.data[this.i] == '>' || (this.data[this.i] == '/' && this.data[this.i + 1] == '>'); |
|||
this.section = () => this.data.substring(this.start, this.i); |
|||
this.parent = () => this.STACK[this.STACK.length - 1]; |
|||
this.siblings = () => this.STACK.length ? this.parent().children : this.DOM; |
|||
} |
|||
MpHtmlParser.prototype.parse = function () { |
|||
if (emoji) this.data = emoji.parseEmoji(this.data); |
|||
for (var c; c = this.data[this.i]; this.i++) |
|||
this.state(c); |
|||
if (this.state == this.Text) this.setText(); |
|||
while (this.STACK.length) this.popNode(this.STACK.pop()); |
|||
return this.DOM; |
|||
} |
|||
// 设置属性
|
|||
MpHtmlParser.prototype.setAttr = function () { |
|||
var name = this.attrName.toLowerCase(), |
|||
val = this.attrVal; |
|||
if (cfg.boolAttrs[name]) this.attrs[name] = 'T'; |
|||
else if (val) { |
|||
if (name == 'src' || (name == 'data-src' && !this.attrs.src)) this.attrs.src = this.getUrl(this.decode(val, 'amp')); |
|||
else if (name == 'href' || name == 'style') this.attrs[name] = this.decode(val, 'amp'); |
|||
else if (name.substr(0, 5) != 'data-') this.attrs[name] = val; |
|||
} |
|||
this.attrVal = ''; |
|||
while (blankChar[this.data[this.i]]) this.i++; |
|||
if (this.isClose()) this.setNode(); |
|||
else { |
|||
this.start = this.i; |
|||
this.state = this.AttrName; |
|||
} |
|||
} |
|||
// 设置文本节点
|
|||
MpHtmlParser.prototype.setText = function () { |
|||
var back, text = this.section(); |
|||
if (!text) return; |
|||
text = (cfg.onText && cfg.onText(text, () => back = true)) || text; |
|||
if (back) { |
|||
this.data = this.data.substr(0, this.start) + text + this.data.substr(this.i); |
|||
let j = this.start + text.length; |
|||
for (this.i = this.start; this.i < j; this.i++) this.state(this.data[this.i]); |
|||
return; |
|||
} |
|||
if (!this.pre) { |
|||
// 合并空白符
|
|||
var flag, tmp = []; |
|||
for (let i = text.length, c; c = text[--i];) |
|||
if (!blankChar[c]) { |
|||
tmp.unshift(c); |
|||
if (!flag) flag = 1; |
|||
} else { |
|||
if (tmp[0] != ' ') tmp.unshift(' '); |
|||
if (c == '\n' && flag == void 0) flag = 0; |
|||
} |
|||
if (flag == 0) return; |
|||
text = tmp.join(''); |
|||
} |
|||
this.siblings().push({ |
|||
type: 'text', |
|||
text: this.decode(text) |
|||
}); |
|||
} |
|||
// 设置元素节点
|
|||
MpHtmlParser.prototype.setNode = function () { |
|||
var node = { |
|||
name: this.tagName.toLowerCase(), |
|||
attrs: this.attrs |
|||
}, |
|||
close = cfg.selfClosingTags[node.name]; |
|||
this.attrs = {}; |
|||
if (!cfg.ignoreTags[node.name]) { |
|||
// 处理属性
|
|||
var attrs = node.attrs, |
|||
style = this.CssHandler.match(node.name, attrs, node) + (attrs.style || ''), |
|||
styleObj = {}; |
|||
if (attrs.id) { |
|||
if (this.options.compress & 1) attrs.id = void 0; |
|||
else if (this.options.useAnchor) this.bubble(); |
|||
} |
|||
if ((this.options.compress & 2) && attrs.class) attrs.class = void 0; |
|||
switch (node.name) { |
|||
case 'a': |
|||
case 'ad': |
|||
this.bubble(); |
|||
break; |
|||
case 'font': |
|||
if (attrs.color) { |
|||
styleObj['color'] = attrs.color; |
|||
attrs.color = void 0; |
|||
} |
|||
if (attrs.face) { |
|||
styleObj['font-family'] = attrs.face; |
|||
attrs.face = void 0; |
|||
} |
|||
if (attrs.size) { |
|||
var size = parseInt(attrs.size); |
|||
if (size < 1) size = 1; |
|||
else if (size > 7) size = 7; |
|||
var map = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large']; |
|||
styleObj['font-size'] = map[size - 1]; |
|||
attrs.size = void 0; |
|||
} |
|||
break; |
|||
case 'embed': |
|||
var src = node.attrs.src || '', |
|||
type = node.attrs.type || ''; |
|||
if (type.includes('video') || src.includes('.mp4') || src.includes('.3gp') || src.includes('.m3u8')) |
|||
node.name = 'video'; |
|||
else if (type.includes('audio') || src.includes('.m4a') || src.includes('.wav') || src.includes('.mp3') || src.includes('.aac')) |
|||
node.name = 'audio'; |
|||
else break; |
|||
if (node.attrs.autostart) |
|||
node.attrs.autoplay = 'T'; |
|||
node.attrs.controls = 'T'; |
|||
// falls through
|
|||
case 'video': |
|||
case 'audio': |
|||
if (!attrs.id) attrs.id = node.name + (++this[`${node.name}Num`]); |
|||
else this[`${node.name}Num`]++; |
|||
if (node.name == 'video') { |
|||
if (this.videoNum > 3) |
|||
node.lazyLoad = 1; |
|||
if (attrs.width) { |
|||
styleObj.width = parseFloat(attrs.width) + (attrs.width.includes('%') ? '%' : 'px'); |
|||
attrs.width = void 0; |
|||
} |
|||
if (attrs.height) { |
|||
styleObj.height = parseFloat(attrs.height) + (attrs.height.includes('%') ? '%' : 'px'); |
|||
attrs.height = void 0; |
|||
} |
|||
} |
|||
if (!attrs.controls && !attrs.autoplay) attrs.controls = 'T'; |
|||
attrs.source = []; |
|||
if (attrs.src) { |
|||
attrs.source.push(attrs.src); |
|||
attrs.src = void 0; |
|||
} |
|||
this.bubble(); |
|||
break; |
|||
case 'td': |
|||
case 'th': |
|||
if (attrs.colspan || attrs.rowspan) |
|||
for (var k = this.STACK.length, item; item = this.STACK[--k];) |
|||
if (item.name == 'table') { |
|||
item.c = void 0; |
|||
break; |
|||
} |
|||
} |
|||
if (attrs.align) { |
|||
styleObj['text-align'] = attrs.align; |
|||
attrs.align = void 0; |
|||
} |
|||
// 压缩 style
|
|||
var styles = style.split(';'); |
|||
style = ''; |
|||
for (var i = 0, len = styles.length; i < len; i++) { |
|||
var info = styles[i].split(':'); |
|||
if (info.length < 2) continue; |
|||
let key = info[0].trim().toLowerCase(), |
|||
value = info.slice(1).join(':').trim(); |
|||
if (value[0] == '-' || value.includes('safe')) |
|||
style += `;${key}:${value}`; |
|||
else if (!styleObj[key] || value.includes('import') || !styleObj[key].includes('import')) |
|||
styleObj[key] = value; |
|||
} |
|||
if (node.name == 'img') { |
|||
if (attrs.src && !attrs.ignore) { |
|||
if (this.bubble()) |
|||
attrs.i = (this.imgNum++).toString(); |
|||
else attrs.ignore = 'T'; |
|||
} |
|||
if (attrs.ignore) { |
|||
style += ';-webkit-touch-callout:none'; |
|||
styleObj['max-width'] = '100%'; |
|||
} |
|||
var width; |
|||
if (styleObj.width) width = styleObj.width; |
|||
else if (attrs.width) width = attrs.width.includes('%') ? attrs.width : attrs.width + 'px'; |
|||
if (width) { |
|||
styleObj.width = width; |
|||
attrs.width = '100%'; |
|||
if (parseInt(width) > windowWidth) { |
|||
styleObj.height = ''; |
|||
if (attrs.height) attrs.height = void 0; |
|||
} |
|||
} |
|||
if (styleObj.height) { |
|||
attrs.height = styleObj.height; |
|||
styleObj.height = ''; |
|||
} else if (attrs.height && !attrs.height.includes('%')) |
|||
attrs.height += 'px'; |
|||
} |
|||
for (var key in styleObj) { |
|||
var value = styleObj[key]; |
|||
if (!value) continue; |
|||
if (key.includes('flex') || key == 'order' || key == 'self-align') node.c = 1; |
|||
// 填充链接
|
|||
if (value.includes('url')) { |
|||
var j = value.indexOf('('); |
|||
if (j++ != -1) { |
|||
while (value[j] == '"' || value[j] == "'" || blankChar[value[j]]) j++; |
|||
value = value.substr(0, j) + this.getUrl(value.substr(j)); |
|||
} |
|||
} |
|||
// 转换 rpx
|
|||
else if (value.includes('rpx')) |
|||
value = value.replace(/[0-9.]+\s*rpx/g, $ => parseFloat($) * windowWidth / 750 + 'px'); |
|||
else if (key == 'white-space' && value.includes('pre') && !close) |
|||
this.pre = node.pre = true; |
|||
style += `;${key}:${value}`; |
|||
} |
|||
style = style.substr(1); |
|||
if (style) attrs.style = style; |
|||
if (!close) { |
|||
node.children = []; |
|||
if (node.name == 'pre' && cfg.highlight) { |
|||
this.remove(node); |
|||
this.pre = node.pre = true; |
|||
} |
|||
this.siblings().push(node); |
|||
this.STACK.push(node); |
|||
} else if (!cfg.filter || cfg.filter(node, this) != false) |
|||
this.siblings().push(node); |
|||
} else { |
|||
if (!close) this.remove(node); |
|||
else if (node.name == 'source') { |
|||
var parent = this.parent(); |
|||
if (parent && (parent.name == 'video' || parent.name == 'audio') && node.attrs.src) |
|||
parent.attrs.source.push(node.attrs.src); |
|||
} else if (node.name == 'base' && !this.domain) this.domain = node.attrs.href; |
|||
} |
|||
if (this.data[this.i] == '/') this.i++; |
|||
this.start = this.i + 1; |
|||
this.state = this.Text; |
|||
} |
|||
// 移除标签
|
|||
MpHtmlParser.prototype.remove = function (node) { |
|||
var name = node.name, |
|||
j = this.i; |
|||
// 处理 svg
|
|||
var handleSvg = () => { |
|||
var src = this.data.substring(j, this.i + 1); |
|||
if (!node.attrs.xmlns) src = ' xmlns="http://www.w3.org/2000/svg"' + src; |
|||
var i = j; |
|||
while (this.data[j] != '<') j--; |
|||
src = this.data.substring(j, i).replace("viewbox", "viewBox") + src; |
|||
var parent = this.parent(); |
|||
if (node.attrs.width == '100%' && parent && (parent.attrs.style || '').includes('inline')) |
|||
parent.attrs.style = 'width:300px;max-width:100%;' + parent.attrs.style; |
|||
this.siblings().push({ |
|||
name: 'img', |
|||
attrs: { |
|||
src: 'data:image/svg+xml;utf8,' + src.replace(/#/g, '%23'), |
|||
style: (/vertical[^;]+/.exec(node.attrs.style) || []).shift(), |
|||
ignore: 'T' |
|||
} |
|||
}) |
|||
} |
|||
if (node.name == 'svg' && this.data[j] == '/') return handleSvg(this.i++); |
|||
while (1) { |
|||
if ((this.i = this.data.indexOf('</', this.i + 1)) == -1) { |
|||
if (name == 'pre' || name == 'svg') this.i = j; |
|||
else this.i = this.data.length; |
|||
return; |
|||
} |
|||
this.start = (this.i += 2); |
|||
while (!blankChar[this.data[this.i]] && !this.isClose()) this.i++; |
|||
if (this.section().toLowerCase() == name) { |
|||
// 代码块高亮
|
|||
if (name == 'pre') { |
|||
this.data = this.data.substr(0, j + 1) + cfg.highlight(this.data.substring(j + 1, this.i - 5), node.attrs) + this.data.substr(this.i - 5); |
|||
return this.i = j; |
|||
} else if (name == 'style') |
|||
this.CssHandler.getStyle(this.data.substring(j + 1, this.i - 7)); |
|||
else if (name == 'title') |
|||
this.DOM.title = this.data.substring(j + 1, this.i - 7); |
|||
if ((this.i = this.data.indexOf('>', this.i)) == -1) this.i = this.data.length; |
|||
if (name == 'svg') handleSvg(); |
|||
return; |
|||
} |
|||
} |
|||
} |
|||
// 节点出栈处理
|
|||
MpHtmlParser.prototype.popNode = function (node) { |
|||
// 空白符处理
|
|||
if (node.pre) { |
|||
node.pre = this.pre = void 0; |
|||
for (let i = this.STACK.length; i--;) |
|||
if (this.STACK[i].pre) |
|||
this.pre = true; |
|||
} |
|||
var siblings = this.siblings(), |
|||
len = siblings.length, |
|||
childs = node.children; |
|||
if (node.name == 'head' || (cfg.filter && cfg.filter(node, this) == false)) |
|||
return siblings.pop(); |
|||
var attrs = node.attrs; |
|||
// 替换一些标签名
|
|||
if (cfg.blockTags[node.name]) node.name = 'div'; |
|||
else if (!cfg.trustTags[node.name]) node.name = 'span'; |
|||
// 处理列表
|
|||
if (node.c && (node.name == 'ul' || node.name == 'ol')) { |
|||
if ((node.attrs.style || '').includes('list-style:none')) { |
|||
for (let i = 0, child; child = childs[i++];) |
|||
if (child.name == 'li') |
|||
child.name = 'div'; |
|||
} else if (node.name == 'ul') { |
|||
var floor = 1; |
|||
for (let i = this.STACK.length; i--;) |
|||
if (this.STACK[i].name == 'ul') floor++; |
|||
if (floor != 1) |
|||
for (let i = childs.length; i--;) |
|||
childs[i].floor = floor; |
|||
} else { |
|||
for (let i = 0, num = 1, child; child = childs[i++];) |
|||
if (child.name == 'li') { |
|||
child.type = 'ol'; |
|||
child.num = ((num, type) => { |
|||
if (type == 'a') return String.fromCharCode(97 + (num - 1) % 26); |
|||
if (type == 'A') return String.fromCharCode(65 + (num - 1) % 26); |
|||
if (type == 'i' || type == 'I') { |
|||
num = (num - 1) % 99 + 1; |
|||
var one = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'], |
|||
ten = ['X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'], |
|||
res = (ten[Math.floor(num / 10) - 1] || '') + (one[num % 10 - 1] || ''); |
|||
if (type == 'i') return res.toLowerCase(); |
|||
return res; |
|||
} |
|||
return num; |
|||
})(num++, attrs.type) + '.'; |
|||
} |
|||
} |
|||
} |
|||
// 处理表格的边框
|
|||
if (node.name == 'table') { |
|||
var padding = attrs.cellpadding, |
|||
spacing = attrs.cellspacing, |
|||
border = attrs.border; |
|||
if (node.c) { |
|||
this.bubble(); |
|||
attrs.style = (attrs.style || '') + ';display:table'; |
|||
if (!padding) padding = 2; |
|||
if (!spacing) spacing = 2; |
|||
} |
|||
if (border) attrs.style = `border:${border}px solid gray;${attrs.style || ''}`; |
|||
if (spacing) attrs.style = `border-spacing:${spacing}px;${attrs.style || ''}`; |
|||
if (border || padding || node.c) |
|||
(function f(ns) { |
|||
for (var i = 0, n; n = ns[i]; i++) { |
|||
if (n.type == 'text') continue; |
|||
var style = n.attrs.style || ''; |
|||
if (node.c && n.name[0] == 't') { |
|||
n.c = 1; |
|||
style += ';display:table-' + (n.name == 'th' || n.name == 'td' ? 'cell' : (n.name == 'tr' ? 'row' : 'row-group')); |
|||
} |
|||
if (n.name == 'th' || n.name == 'td') { |
|||
if (border) style = `border:${border}px solid gray;${style}`; |
|||
if (padding) style = `padding:${padding}px;${style}`; |
|||
} else f(n.children || []); |
|||
if (style) n.attrs.style = style; |
|||
} |
|||
})(childs) |
|||
if (this.options.autoscroll) { |
|||
var table = Object.assign({}, node); |
|||
node.name = 'div'; |
|||
node.attrs = { |
|||
style: 'overflow:scroll' |
|||
} |
|||
node.children = [table]; |
|||
} |
|||
} |
|||
this.CssHandler.pop && this.CssHandler.pop(node); |
|||
// 自动压缩
|
|||
if (node.name == 'div' && !Object.keys(attrs).length && childs.length == 1 && childs[0].name == 'div') |
|||
siblings[len - 1] = childs[0]; |
|||
} |
|||
// 状态机
|
|||
MpHtmlParser.prototype.Text = function (c) { |
|||
if (c == '<') { |
|||
var next = this.data[this.i + 1], |
|||
isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); |
|||
if (isLetter(next)) { |
|||
this.setText(); |
|||
this.start = this.i + 1; |
|||
this.state = this.TagName; |
|||
} else if (next == '/') { |
|||
this.setText(); |
|||
if (isLetter(this.data[++this.i + 1])) { |
|||
this.start = this.i + 1; |
|||
this.state = this.EndTag; |
|||
} else this.Comment(); |
|||
} else if (next == '!' || next == '?') { |
|||
this.setText(); |
|||
this.Comment(); |
|||
} |
|||
} |
|||
} |
|||
MpHtmlParser.prototype.Comment = function () { |
|||
var key; |
|||
if (this.data.substring(this.i + 2, this.i + 4) == '--') key = '-->'; |
|||
else if (this.data.substring(this.i + 2, this.i + 9) == '[CDATA[') key = ']]>'; |
|||
else key = '>'; |
|||
if ((this.i = this.data.indexOf(key, this.i + 2)) == -1) this.i = this.data.length; |
|||
else this.i += key.length - 1; |
|||
this.start = this.i + 1; |
|||
this.state = this.Text; |
|||
} |
|||
MpHtmlParser.prototype.TagName = function (c) { |
|||
if (blankChar[c]) { |
|||
this.tagName = this.section(); |
|||
while (blankChar[this.data[this.i]]) this.i++; |
|||
if (this.isClose()) this.setNode(); |
|||
else { |
|||
this.start = this.i; |
|||
this.state = this.AttrName; |
|||
} |
|||
} else if (this.isClose()) { |
|||
this.tagName = this.section(); |
|||
this.setNode(); |
|||
} |
|||
} |
|||
MpHtmlParser.prototype.AttrName = function (c) { |
|||
if (c == '=' || blankChar[c] || this.isClose()) { |
|||
this.attrName = this.section(); |
|||
if (blankChar[c]) |
|||
while (blankChar[this.data[++this.i]]); |
|||
if (this.data[this.i] == '=') { |
|||
while (blankChar[this.data[++this.i]]); |
|||
this.start = this.i--; |
|||
this.state = this.AttrValue; |
|||
} else this.setAttr(); |
|||
} |
|||
} |
|||
MpHtmlParser.prototype.AttrValue = function (c) { |
|||
if (c == '"' || c == "'") { |
|||
this.start++; |
|||
if ((this.i = this.data.indexOf(c, this.i + 1)) == -1) return this.i = this.data.length; |
|||
this.attrVal = this.section(); |
|||
this.i++; |
|||
} else { |
|||
for (; !blankChar[this.data[this.i]] && !this.isClose(); this.i++); |
|||
this.attrVal = this.section(); |
|||
} |
|||
this.setAttr(); |
|||
} |
|||
MpHtmlParser.prototype.EndTag = function (c) { |
|||
if (blankChar[c] || c == '>' || c == '/') { |
|||
var name = this.section().toLowerCase(); |
|||
for (var i = this.STACK.length; i--;) |
|||
if (this.STACK[i].name == name) break; |
|||
if (i != -1) { |
|||
var node; |
|||
while ((node = this.STACK.pop()).name != name) this.popNode(node); |
|||
this.popNode(node); |
|||
} else if (name == 'p' || name == 'br') |
|||
this.siblings().push({ |
|||
name, |
|||
attrs: {} |
|||
}); |
|||
this.i = this.data.indexOf('>', this.i); |
|||
this.start = this.i + 1; |
|||
if (this.i == -1) this.i = this.data.length; |
|||
else this.state = this.Text; |
|||
} |
|||
} |
|||
module.exports = MpHtmlParser; |
@ -0,0 +1,63 @@ |
|||
/* 配置文件 */ |
|||
const canIUse = wx.canIUse('editor'); // 高基础库标识,用于兼容
|
|||
module.exports = { |
|||
// 出错占位图
|
|||
errorImg: null, |
|||
// 过滤器函数
|
|||
filter: null, |
|||
// 代码高亮函数
|
|||
highlight: null, |
|||
// 文本处理函数
|
|||
onText: null, |
|||
// 实体编码列表
|
|||
entities: { |
|||
quot: '"', |
|||
apos: "'", |
|||
semi: ';', |
|||
nbsp: '\xA0', |
|||
ndash: '–', |
|||
mdash: '—', |
|||
middot: '·', |
|||
lsquo: '‘', |
|||
rsquo: '’', |
|||
ldquo: '“', |
|||
rdquo: '”', |
|||
bull: '•', |
|||
hellip: '…' |
|||
}, |
|||
blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'), |
|||
boolAttrs: makeMap('autoplay,autostart,controls,ignore,loop,muted'), |
|||
// 块级标签,将被转为 div
|
|||
blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,section' + (canIUse ? '' : ',pre')), |
|||
// 将被移除的标签
|
|||
ignoreTags: makeMap('area,base,canvas,frame,iframe,input,link,map,meta,param,script,source,style,svg,textarea,title,track,wbr' + (canIUse ? ',rp' : '')), |
|||
// 只能被 rich-text 显示的标签
|
|||
richOnlyTags: makeMap('a,colgroup,fieldset,legend,table' + (canIUse ? ',bdi,bdo,rt,ruby' : '')), |
|||
// 自闭合的标签
|
|||
selfClosingTags: makeMap('area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr'), |
|||
// 信任的标签
|
|||
trustTags: makeMap('a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video' + (canIUse ? ',bdi,bdo,caption,pre,rt,ruby' : '')), |
|||
// 默认的标签样式
|
|||
userAgentStyles: { |
|||
address: 'font-style:italic', |
|||
big: 'display:inline;font-size:1.2em', |
|||
blockquote: 'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px', |
|||
caption: 'display:table-caption;text-align:center', |
|||
center: 'text-align:center', |
|||
cite: 'font-style:italic', |
|||
dd: 'margin-left:40px', |
|||
mark: 'background-color:yellow', |
|||
pre: 'font-family:monospace;white-space:pre;overflow:scroll', |
|||
s: 'text-decoration:line-through', |
|||
small: 'display:inline;font-size:0.8em', |
|||
u: 'text-decoration:underline' |
|||
} |
|||
} |
|||
|
|||
function makeMap(str) { |
|||
var map = Object.create(null), |
|||
list = str.split(','); |
|||
for (var i = list.length; i--;) |
|||
map[list[i]] = true; |
|||
return map; |
|||
} |
@ -0,0 +1,213 @@ |
|||
/** |
|||
* Parser 富文本组件 |
|||
* @tutorial https://github.com/jin-yufeng/Parser
|
|||
* @version 20200728 |
|||
* @author JinYufeng |
|||
* @listens MIT |
|||
*/ |
|||
var cache = {}, |
|||
Parser = require('./libs/MpHtmlParser.js'), |
|||
fs = wx.getFileSystemManager && wx.getFileSystemManager(); |
|||
var dom; |
|||
var search; |
|||
// 计算 cache 的 key
|
|||
function hash(str) { |
|||
for (var i = str.length, val = 5381; i--;) |
|||
val += (val << 5) + str.charCodeAt(i); |
|||
return val; |
|||
} |
|||
Component({ |
|||
options: { |
|||
pureDataPattern: /^[acdgtu]|W/ |
|||
}, |
|||
data: { |
|||
nodes: [] |
|||
}, |
|||
properties: { |
|||
html: { |
|||
type: String, |
|||
observer(html) { |
|||
this.setContent(html); |
|||
} |
|||
}, |
|||
autopause: { |
|||
type: Boolean, |
|||
value: true |
|||
}, |
|||
autoscroll: Boolean, |
|||
autosetTitle: { |
|||
type: Boolean, |
|||
value: true |
|||
}, |
|||
compress: Number, |
|||
domain: String, |
|||
lazyLoad: Boolean, |
|||
loadingImg: String, |
|||
selectable: Boolean, |
|||
tagStyle: Object, |
|||
showWithAnimation: Boolean, |
|||
useAnchor: Boolean, |
|||
useCache: Boolean |
|||
}, |
|||
relations: { |
|||
'../parser-group/parser-group': { |
|||
type: 'ancestor' |
|||
} |
|||
}, |
|||
created() { |
|||
// 图片数组
|
|||
this.imgList = []; |
|||
this.imgList.setItem = function(i, src) { |
|||
if (!i || !src) return; |
|||
// 去重
|
|||
if (src.indexOf('http') == 0 && this.includes(src)) { |
|||
var newSrc = ''; |
|||
for (var j = 0, c; c = src[j]; j++) { |
|||
if (c == '/' && src[j - 1] != '/' && src[j + 1] != '/') break; |
|||
newSrc += Math.random() > 0.5 ? c.toUpperCase() : c; |
|||
} |
|||
newSrc += src.substr(j); |
|||
return this[i] = newSrc; |
|||
} |
|||
this[i] = src; |
|||
// 暂存 data src
|
|||
if (src.includes('data:image')) { |
|||
var info = src.match(/data:image\/(\S+?);(\S+?),(.+)/); |
|||
if (!info) return; |
|||
var filePath = `${wx.env.USER_DATA_PATH}/${Date.now()}.${info[1]}`; |
|||
fs && fs.writeFile({ |
|||
filePath, |
|||
data: info[3], |
|||
encoding: info[2], |
|||
success: () => this[i] = filePath |
|||
}) |
|||
} |
|||
} |
|||
this.imgList.each = function(f) { |
|||
for (var i = 0, len = this.length; i < len; i++) |
|||
this.setItem(i, f(this[i], i, this)); |
|||
} |
|||
if (dom) this.document = new dom(this); |
|||
if (search) this.search = args => search(this, args); |
|||
}, |
|||
detached() { |
|||
// 删除暂存
|
|||
this.imgList.each(src => { |
|||
if (src && src.includes(wx.env.USER_DATA_PATH) && fs) |
|||
fs.unlink({ |
|||
filePath: src |
|||
}) |
|||
}) |
|||
clearInterval(this._timer); |
|||
}, |
|||
methods: { |
|||
// 锚点跳转
|
|||
in (obj) { |
|||
if (obj.page && obj.selector && obj.scrollTop) this._in = obj; |
|||
}, |
|||
navigateTo(obj) { |
|||
if (!this.data.useAnchor) return obj.fail && obj.fail('Anchor is disabled'); |
|||
var selector = (this._in ? this._in.page : this).createSelectorQuery().select((this._in ? this._in.selector : '.top') + (obj.id ? '>>>#' + obj.id : '')).boundingClientRect(); |
|||
if (this._in) selector.select(this._in.selector).fields({ |
|||
rect: true, |
|||
scrollOffset: true |
|||
}); |
|||
else selector.selectViewport().scrollOffset(); |
|||
selector.exec(res => { |
|||
if (!res[0]) return this.group ? this.group.navigateTo(this.i, obj) : obj.fail && obj.fail('Label not found'); |
|||
var scrollTop = res[1].scrollTop + res[0].top - (res[1].top || 0) + (obj.offset || 0); |
|||
if (this._in) { |
|||
var data = {}; |
|||
data[this._in.scrollTop] = scrollTop; |
|||
this._in.page.setData(data); |
|||
} else wx.pageScrollTo({ |
|||
scrollTop |
|||
}) |
|||
obj.success && obj.success(); |
|||
}) |
|||
}, |
|||
// 获取文本
|
|||
getText(ns = this.data.nodes) { |
|||
var txt = ''; |
|||
for (var i = 0, n; n = ns[i++];) { |
|||
if (n.type == 'text') txt += n.text.replace(/ /g, '\u00A0').replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&'); |
|||
else if (n.type == 'br') txt += '\n'; |
|||
else { |
|||
// 块级标签前后加换行
|
|||
var br = n.name == 'p' || n.name == 'div' || n.name == 'tr' || n.name == 'li' || (n.name[0] == 'h' && n.name[1] > '0' && n.name[1] < '7'); |
|||
if (br && txt && txt[txt.length - 1] != '\n') txt += '\n'; |
|||
if (n.children) txt += this.getText(n.children); |
|||
if (br && txt[txt.length - 1] != '\n') txt += '\n'; |
|||
else if (n.name == 'td' || n.name == 'th') txt += '\t'; |
|||
} |
|||
} |
|||
return txt; |
|||
}, |
|||
// 获取视频 context
|
|||
getVideoContext(id) { |
|||
if (!id) return this.videoContexts; |
|||
for (var i = this.videoContexts.length; i--;) |
|||
if (this.videoContexts[i].id == id) return this.videoContexts[i]; |
|||
}, |
|||
// 渲染富文本
|
|||
setContent(html, append) { |
|||
var nodes, parser = new Parser(html, this.data); |
|||
// 缓存读取
|
|||
if (this.data.useCache) { |
|||
var hashVal = hash(html); |
|||
if (cache[hashVal]) nodes = cache[hashVal]; |
|||
else cache[hashVal] = nodes = parser.parse(); |
|||
} else nodes = parser.parse(); |
|||
this.triggerEvent('parse', nodes); |
|||
var data = {}; |
|||
if (append) |
|||
for (let i = this.data.nodes.length, j = nodes.length; j--;) |
|||
data[`nodes[${i + j}]`] = nodes[j]; |
|||
else data.nodes = nodes; |
|||
if (this.showWithAnimation) data.showAm = 'animation: show .5s'; |
|||
this.setData(data, () => { |
|||
this.triggerEvent('load') |
|||
}); |
|||
// 设置标题
|
|||
if (nodes.title && this.data.autosetTitle) |
|||
wx.setNavigationBarTitle({ |
|||
title: nodes.title |
|||
}) |
|||
this.imgList.length = 0; |
|||
this.videoContexts = []; |
|||
var ns = this.selectAllComponents('.top,.top>>>._node'); |
|||
for (let i = 0, n; n = ns[i++];) { |
|||
n.top = this; |
|||
for (let j = 0, item; item = n.data.nodes[j++];) { |
|||
if (item.c) continue; |
|||
// 获取图片列表
|
|||
if (item.name == 'img') |
|||
this.imgList.setItem(item.attrs.i, item.attrs.src); |
|||
// 音视频控制
|
|||
else if (item.name == 'video' || item.name == 'audio') { |
|||
var ctx; |
|||
if (item.name == 'video') ctx = wx.createVideoContext(item.attrs.id, n); |
|||
else ctx = n.selectComponent('#' + item.attrs.id); |
|||
if (ctx) { |
|||
ctx.id = item.attrs.id; |
|||
this.videoContexts.push(ctx); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
var height; |
|||
clearInterval(this._timer); |
|||
this._timer = setInterval(() => { |
|||
this.createSelectorQuery().select('.top').boundingClientRect(res => { |
|||
if (!res) return; |
|||
this.rect = res; |
|||
if (res.height == height) { |
|||
this.triggerEvent('ready', res) |
|||
clearInterval(this._timer); |
|||
} |
|||
height = res.height; |
|||
}).exec(); |
|||
}, 350) |
|||
} |
|||
} |
|||
}) |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": { |
|||
"trees": "./trees/trees" |
|||
} |
|||
} |
@ -0,0 +1,3 @@ |
|||
<!--parser 主组件--> |
|||
<slot wx:if="{{!nodes.length}}" /> |
|||
<trees class="top" style="{{selectable?'user-select:text;-webkit-user-select:text;':''}}{{showAm}}" lazy-load="{{lazyLoad}}" loading="{{loadingImg}}" nodes="{{nodes}}" /> |
@ -0,0 +1,19 @@ |
|||
:host { |
|||
display: block; |
|||
overflow: scroll; |
|||
-webkit-overflow-scrolling: touch; |
|||
} |
|||
|
|||
.top { |
|||
display: inherit; |
|||
} |
|||
|
|||
@keyframes show { |
|||
0% { |
|||
opacity: 0; |
|||
} |
|||
|
|||
100% { |
|||
opacity: 1; |
|||
} |
|||
} |
@ -0,0 +1,122 @@ |
|||
const errorImg = require('../libs/config.js').errorImg; |
|||
Component({ |
|||
data: { |
|||
canIUse: !!wx.chooseMessageFile, |
|||
placeholder: "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='225'/>", |
|||
ctrl: [] |
|||
}, |
|||
properties: { |
|||
nodes: Array, |
|||
lazyLoad: Boolean, |
|||
loading: String |
|||
}, |
|||
methods: { |
|||
// 视频播放事件
|
|||
play(e) { |
|||
this.top.group && this.top.group.pause(this.top.i); |
|||
if (this.top.videoContexts.length > 1 && this.top.data.autopause) |
|||
for (var i = this.top.videoContexts.length; i--;) |
|||
if (this.top.videoContexts[i].id != e.currentTarget.id) |
|||
this.top.videoContexts[i].pause(); |
|||
}, |
|||
// 图片事件
|
|||
imgtap(e) { |
|||
var attrs = e.currentTarget.dataset.attrs; |
|||
if (!attrs.ignore) { |
|||
var preview = true; |
|||
this.top.triggerEvent('imgtap', { |
|||
id: e.currentTarget.id, |
|||
src: attrs.src, |
|||
ignore: () => preview = false |
|||
}) |
|||
if (preview) { |
|||
if (this.top.group) return this.top.group.preview(this.top.i, attrs.i); |
|||
var urls = this.top.imgList, |
|||
current = urls[attrs.i] ? urls[attrs.i] : (urls = [attrs.src], attrs.src); |
|||
wx.previewImage({ |
|||
current, |
|||
urls |
|||
}) |
|||
} |
|||
} |
|||
}, |
|||
loadImg(e) { |
|||
var i = e.target.dataset.i; |
|||
if (this.data.lazyLoad && !this.data.ctrl[i]) |
|||
this.setData({ |
|||
[`ctrl[${i}]`]: 1 |
|||
}) |
|||
else if (this.data.loading && this.data.ctrl[i] != 2) |
|||
this.setData({ |
|||
[`ctrl[${i}]`]: 2 |
|||
}) |
|||
}, |
|||
// 链接点击事件
|
|||
linkpress(e) { |
|||
var jump = true, |
|||
attrs = e.currentTarget.dataset.attrs; |
|||
attrs.ignore = () => jump = false; |
|||
this.top.triggerEvent('linkpress', attrs); |
|||
if (jump) { |
|||
if (attrs['app-id']) |
|||
wx.navigateToMiniProgram({ |
|||
appId: attrs['app-id'], |
|||
path: attrs.path |
|||
}) |
|||
else if (attrs.href) { |
|||
if (attrs.href[0] == '#') |
|||
this.top.navigateTo({ |
|||
id: attrs.href.substring(1) |
|||
}) |
|||
else if (attrs.href.indexOf('http') == 0 || attrs.href.indexOf('//') == 0) |
|||
wx.setClipboardData({ |
|||
data: attrs.href, |
|||
success: () => |
|||
wx.showToast({ |
|||
title: '链接已复制' |
|||
}) |
|||
}) |
|||
else |
|||
wx.navigateTo({ |
|||
url: attrs.href, |
|||
fail() { |
|||
wx.switchTab({ |
|||
url: attrs.href, |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
}, |
|||
// 错误事件
|
|||
error(e) { |
|||
var source = e.target.dataset.source, |
|||
i = e.target.dataset.i, |
|||
node = this.data.nodes[i]; |
|||
if (source == 'video' || source == 'audio') { |
|||
// 加载其他 source
|
|||
var index = (node.i || 0) + 1; |
|||
if (index < node.attrs.source.length) |
|||
return this.setData({ |
|||
[`nodes[${i}].i`]: index |
|||
}) |
|||
} else if (source == 'img' && errorImg) { |
|||
this.top.imgList.setItem(e.target.dataset.index, errorImg); |
|||
this.setData({ |
|||
[`nodes[${i}].attrs.src`]: errorImg |
|||
}) |
|||
} |
|||
this.top && this.top.triggerEvent('error', { |
|||
source, |
|||
target: e.target, |
|||
errMsg: e.detail.errMsg |
|||
}) |
|||
}, |
|||
// 加载视频
|
|||
loadVideo(e) { |
|||
this.setData({ |
|||
[`nodes[${e.target.dataset.i}].attrs.autoplay`]: true |
|||
}) |
|||
} |
|||
} |
|||
}) |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": { |
|||
"trees": "./trees" |
|||
} |
|||
} |
@ -0,0 +1,67 @@ |
|||
<!--trees 递归子组件--> |
|||
<wxs module="handler"> |
|||
var inline = { |
|||
abbr: 1, |
|||
b: 1, |
|||
big: 1, |
|||
code: 1, |
|||
del: 1, |
|||
em: 1, |
|||
i: 1, |
|||
ins: 1, |
|||
label: 1, |
|||
q: 1, |
|||
small: 1, |
|||
span: 1, |
|||
strong: 1, |
|||
sub: 1, |
|||
sup: 1 |
|||
} |
|||
module.exports = { |
|||
visited: function (e, owner) { |
|||
if (!e.instance.hasClass('_visited')) |
|||
e.instance.addClass('_visited') |
|||
owner.callMethod('linkpress', e) |
|||
}, |
|||
use: function (item) { |
|||
return !item.c && !inline[item.name] && (item.attrs.style || '').indexOf('display:inline') == -1 |
|||
} |
|||
} |
|||
</wxs> |
|||
<block wx:for="{{nodes}}" wx:for-item="n" wx:for-index="i" wx:key="i"> |
|||
<!--图片--> |
|||
<view wx:if="{{n.name=='img'}}" id="{{n.attrs.id}}" class="_img {{n.attrs.class}}" style="{{n.attrs.style}}" data-attrs="{{n.attrs}}" bindtap="imgtap"> |
|||
<rich-text nodes="{{[{attrs:{src:loading&&ctrl[i]!=2?loading:(lazyLoad&&!ctrl[i]?placeholder:n.attrs.src||''),alt:n.attrs.alt||'',width:n.attrs.width||'',style:'-webkit-touch-callout:none;max-width:100%;display:block'+(n.attrs.height?';height:'+n.attrs.height:'')},name:'img'}]}}" /> |
|||
<image class="_image" src="{{lazyLoad&&!ctrl[i]?placeholder:n.attrs.src}}" lazy-load="{{lazyLoad}}" show-menu-by-longpress="{{!n.attrs.ignore}}" data-i="{{i}}" data-index="{{n.attrs.i}}" data-source="img" bindload="loadImg" binderror="error" /> |
|||
</view> |
|||
<!--文本--> |
|||
<text wx:elif="{{n.type=='text'}}" decode>{{n.text}}</text> |
|||
<text wx:elif="{{n.name=='br'}}">\n</text> |
|||
<!--链接--> |
|||
<view wx:elif="{{n.name=='a'}}" id="{{n.attrs.id}}" class="_a {{n.attrs.class}}" hover-class="_hover" style="{{n.attrs.style}}" data-attrs="{{n.attrs}}" bindtap="{{canIUse?handler.visited:'linkpress'}}"> |
|||
<trees class="_node" nodes="{{n.children}}" /> |
|||
</view> |
|||
<!--视频--> |
|||
<block wx:elif="{{n.name=='video'}}"> |
|||
<view wx:if="{{n.lazyLoad&&!n.attrs.autoplay}}" id="{{n.attrs.id}}" class="_video {{n.attrs.class}}" style="{{n.attrs.style}}" data-i="{{i}}" bindtap="loadVideo" /> |
|||
<video wx:else id="{{n.attrs.id}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" autoplay="{{n.attrs.autoplay}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" muted="{{n.attrs.muted}}" poster="{{n.attrs.poster}}" src="{{n.attrs.source[n.i||0]}}" unit-id="{{n.attrs['unit-id']}}" data-i="{{i}}" data-source="video" binderror="error" bindplay="play" /> |
|||
</block> |
|||
<!--音频--> |
|||
<audio wx:elif="{{n.name=='audio'}}" id="{{n.attrs.id}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" author="{{n.attrs.author}}" autoplay="{{n.attrs.autoplay}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" name="{{n.attrs.name}}" poster="{{n.attrs.poster}}" src="{{n.attrs.source[n.i||0]}}" data-i="{{i}}" data-source="audio" binderror="error" bindplay="play" /> |
|||
<!--广告--> |
|||
<ad wx:elif="{{n.name=='ad'}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" unit-id="{{n.attrs['unit-id']}}" data-source="ad" binderror="error" /> |
|||
<!--列表--> |
|||
<view wx:elif="{{n.name=='li'}}" id="{{n.attrs.id}}" class="{{n.attrs.class}}" style="{{n.attrs.style}};display:flex"> |
|||
<view wx:if="{{n.type=='ol'}}" class="_ol-bef">{{n.num}}</view> |
|||
<view wx:else class="_ul-bef"> |
|||
<view wx:if="{{n.floor%3==0}}" class="_ul-p1">█</view> |
|||
<view wx:elif="{{n.floor%3==2}}" class="_ul-p2" /> |
|||
<view wx:else class="_ul-p1" style="border-radius:50%">█</view> |
|||
</view> |
|||
<trees class="_node _li" lazyLoad="{{lazyLoad}}" loading="{{loading}}" nodes="{{n.children}}" /> |
|||
</view> |
|||
<!--富文本--> |
|||
<rich-text wx:elif="{{handler.use(n)}}" id="{{n.attrs.id}}" class="_p __{{n.name}}" nodes="{{[n]}}" /> |
|||
<!--继续递归--> |
|||
<trees wx:else id="{{n.attrs.id}}" class="_node _{{n.name}} {{n.attrs.class}}" style="{{n.attrs.style}}" lazyLoad="{{lazyLoad}}" loading="{{loading}}" nodes="{{n.children}}" /> |
|||
</block> |
@ -0,0 +1,180 @@ |
|||
/* 在这里引入自定义样式 */ |
|||
|
|||
/* 链接和图片效果 */ |
|||
._a { |
|||
display: inline; |
|||
padding: 1.5px 0 1.5px 0; |
|||
color: #366092; |
|||
word-break: break-all; |
|||
} |
|||
|
|||
._hover { |
|||
text-decoration: underline; |
|||
opacity: 0.7; |
|||
} |
|||
|
|||
._visited { |
|||
color: #551a8b; |
|||
} |
|||
|
|||
._img { |
|||
display: inline-block; |
|||
max-width: 100%; |
|||
overflow: hidden; |
|||
} |
|||
|
|||
/* 内部样式 */ |
|||
:host { |
|||
display: inline; |
|||
} |
|||
|
|||
._blockquote, |
|||
._div, |
|||
._p, |
|||
._ul, |
|||
._ol, |
|||
._li { |
|||
display: block; |
|||
} |
|||
|
|||
._b, |
|||
._strong { |
|||
font-weight: bold; |
|||
} |
|||
|
|||
._code { |
|||
font-family: monospace; |
|||
} |
|||
|
|||
._del { |
|||
text-decoration: line-through; |
|||
} |
|||
|
|||
._em, |
|||
._i { |
|||
font-style: italic; |
|||
} |
|||
|
|||
._h1 { |
|||
font-size: 2em; |
|||
} |
|||
|
|||
._h2 { |
|||
font-size: 1.5em; |
|||
} |
|||
|
|||
._h3 { |
|||
font-size: 1.17em; |
|||
} |
|||
|
|||
._h5 { |
|||
font-size: 0.83em; |
|||
} |
|||
|
|||
._h6 { |
|||
font-size: 0.67em; |
|||
} |
|||
|
|||
._h1, |
|||
._h2, |
|||
._h3, |
|||
._h4, |
|||
._h5, |
|||
._h6 { |
|||
display: block; |
|||
font-weight: bold; |
|||
} |
|||
|
|||
._image { |
|||
display: block; |
|||
width: 100%; |
|||
height: 360px; |
|||
margin-top: -360px; |
|||
opacity: 0; |
|||
} |
|||
|
|||
._ins { |
|||
text-decoration: underline; |
|||
} |
|||
|
|||
._li { |
|||
flex: 1; |
|||
width: 0; |
|||
} |
|||
|
|||
._ol-bef { |
|||
width: 36px; |
|||
margin-right: 5px; |
|||
text-align: right; |
|||
} |
|||
|
|||
._ul-bef { |
|||
margin: 0 12px 0 23px; |
|||
line-height: normal; |
|||
} |
|||
|
|||
._ol-bef, |
|||
._ul-bef { |
|||
flex: none; |
|||
user-select: none; |
|||
} |
|||
|
|||
._ul-p1 { |
|||
display: inline-block; |
|||
width: 0.3em; |
|||
height: 0.3em; |
|||
overflow: hidden; |
|||
line-height: 0.3em; |
|||
} |
|||
|
|||
._ul-p2 { |
|||
display: inline-block; |
|||
width: 0.23em; |
|||
height: 0.23em; |
|||
border: 0.05em solid black; |
|||
border-radius: 50%; |
|||
} |
|||
|
|||
._q::before { |
|||
content: '"'; |
|||
} |
|||
|
|||
._q::after { |
|||
content: '"'; |
|||
} |
|||
|
|||
._sub { |
|||
font-size: smaller; |
|||
vertical-align: sub; |
|||
} |
|||
|
|||
._sup { |
|||
font-size: smaller; |
|||
vertical-align: super; |
|||
} |
|||
|
|||
.__bdi, |
|||
.__bdo, |
|||
.__ruby, |
|||
.__rt { |
|||
display: inline-block; |
|||
} |
|||
|
|||
._video { |
|||
position: relative; |
|||
display: inline-block; |
|||
width: 300px; |
|||
height: 225px; |
|||
background-color: black; |
|||
} |
|||
|
|||
._video::after { |
|||
position: absolute; |
|||
top: 50%; |
|||
left: 50%; |
|||
margin: -15px 0 0 -15px; |
|||
content: ''; |
|||
border-color: transparent transparent transparent white; |
|||
border-style: solid; |
|||
border-width: 15px 0 15px 30px; |
|||
} |
@ -0,0 +1,70 @@ |
|||
Component({ |
|||
data: { |
|||
lastY: "", |
|||
translateHeight: 0, |
|||
state: -1, |
|||
scrollTop: 0, |
|||
enablePulldownFresh: false |
|||
}, |
|||
options: { |
|||
multipleSlots: true |
|||
}, |
|||
properties: { |
|||
upperDistance: { |
|||
type: Number, |
|||
value: 80 |
|||
} |
|||
}, |
|||
methods: { |
|||
onPageScroll (e) { |
|||
this.data.scrollTop = e.scrollTop |
|||
this.data.enablePulldownFresh = false |
|||
}, |
|||
touchstart (e) { |
|||
this.data.lastY = e.touches[0].clientY |
|||
if (this.data.scrollTop === 0) { |
|||
this.data.enablePulldownFresh = true |
|||
} else { |
|||
this.data.enablePulldownFresh = false |
|||
} |
|||
}, |
|||
touchmove (e) { |
|||
let clientY = e.touches[0].clientY |
|||
let offset = clientY - this.data.lastY |
|||
if (this.data.scrollTop > 0 || offset < 0) { |
|||
return false |
|||
} |
|||
this.data.translateHeight = offset |
|||
this.data.state = 1 |
|||
|
|||
if (this.data.enablePulldownFresh) { |
|||
if (this.data.translateHeight > this.data.upperDistance) { |
|||
this.data.state = 2 |
|||
} |
|||
this.setData({ |
|||
translateHeight: this.data.translateHeight > 100 ? 100 : this.data.translateHeight, |
|||
state: this.data.state |
|||
}) |
|||
} |
|||
}, |
|||
touchend () { |
|||
if (this.data.translateHeight > this.data.upperDistance) { |
|||
if (this.data.enablePulldownFresh) { |
|||
this.setData({ |
|||
translateHeight: 100, |
|||
state: 3 |
|||
}) |
|||
this.triggerEvent("pullDownRefresh") |
|||
} |
|||
} else if (this.data.scrollTop <= 0) { |
|||
this.stopRefresh() |
|||
} |
|||
}, |
|||
stopRefresh () { |
|||
this.setData({ |
|||
translateHeight: 0, |
|||
state: -1 |
|||
}) |
|||
} |
|||
} |
|||
}) |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,9 @@ |
|||
<view class="pulldown-refresh" bindtouchstart="touchstart" bindtouchmove="touchmove" bindtouchend="touchend"> |
|||
<view class="pulldown-state"> |
|||
<image class="loading" src="../../images/loading.gif" /> |
|||
<view class="loading-state">{{state == 1 ? '下拉刷新' : state == 2 ? '松开刷新' : '刷新中...'}}</view> |
|||
</view> |
|||
<view class="pulldown-content" style="transform: translateY({{translateHeight}}rpx)"> |
|||
<slot name="content"></slot> |
|||
</view> |
|||
</view> |
@ -0,0 +1,28 @@ |
|||
.pulldown-refresh { |
|||
/* width:calc(100% - 40rpx); */ |
|||
/* margin-left: 20rpx; */ |
|||
background: #f7f7f7; |
|||
} |
|||
.pulldown-refresh .pulldown-state { |
|||
width:100%; |
|||
height: 100rpx; |
|||
display:flex; |
|||
justify-content: center; |
|||
align-items: center; |
|||
margin-bottom: -100rpx; |
|||
} |
|||
.pulldown-refresh .pulldown-state .loading { |
|||
width: 30rpx; |
|||
height: 30rpx; |
|||
margin-right: 10rpx; |
|||
} |
|||
.pulldown-refresh .pulldown-state .loading-state { |
|||
font-size: 25rpx; |
|||
color:#666; |
|||
} |
|||
|
|||
.pulldown-refresh .pulldown-content { |
|||
width:100%; |
|||
height:auto; |
|||
transition: transform 0.05s linear; |
|||
} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames7=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(n,!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var defaults={prefixCls:"wux-actionsheet",theme:"ios",className:"",titleText:"",buttons:[],buttonClicked:function(){},cancelText:"取消",cancel:function(){}};(0,_baseComponent.default)({useFunc:!0,data:defaults,computed:{classes:["prefixCls, theme, buttons, cancelText",function(n,e,t,r){var o,c=(0,_classNames7.default)(n),a="".concat(n,"__popup"),s=(0,_classNames7.default)("".concat(n,"__content"),(_defineProperty(o={},"".concat(n,"__content--theme-").concat(e),e),_defineProperty(o,"".concat(n,"__content--has-cancel"),r),o)),i=(0,_classNames7.default)("".concat(n,"__group"),_defineProperty({},"".concat(n,"__group--options"),!0)),u="".concat(n,"__title"),d=(0,_classNames7.default)("".concat(n,"__button"),_defineProperty({},"".concat(n,"__button--destructive"),!0));return{wrap:c,popup:a,content:s,options:i,title:u,button:t.map(function(e){var t;return{wrap:(0,_classNames7.default)("".concat(n,"__button"),(_defineProperty(t={},"".concat(n,"__button--option"),!0),_defineProperty(t,"".concat(n,"__button--disabled"),e.disabled),_defineProperty(t,"".concat(e.className),e.className),t)),hover:e.hoverClass&&"default"!==e.hoverClass?e.hoverClass:"".concat(n,"__button--hover")}}),icon:"".concat(n,"__icon"),text:"".concat(n,"__text"),destructive:d,group:(0,_classNames7.default)("".concat(n,"__group"),_defineProperty({},"".concat(n,"__group--cancel"),!0)),cancel:(0,_classNames7.default)("".concat(n,"__button"),_defineProperty({},"".concat(n,"__button--cancel"),!0)),hover:"".concat(n,"__button--hover")}}]},methods:{showSheet:function(e){var t=0<arguments.length&&void 0!==e?e:{},n=this.$$mergeOptionsAndBindMethods(Object.assign({},defaults,t));return this.removed=!1,this.$$setData(_objectSpread({in:!0},n)),this.cancel.bind(this)},removeSheet:function(e){if(this.removed)return!1;this.removed=!0,this.$$setData({in:!1}),"function"==typeof e&&e(this.data.buttons)},buttonClicked:function(e){var t=e.currentTarget.dataset.index;!0===this.fns.buttonClicked(t,this.data.buttons[t])&&this.removeSheet()},destructiveButtonClicked:function(){!0===this.fns.destructiveButtonClicked()&&this.removeSheet()},cancel:function(){this.removeSheet(this.fns.cancel)},bindgetuserinfo:function(e){this.triggerEvent("getuserinfo",_objectSpread({},e.detail,{},e.currentTarget.dataset))},bindcontact:function(e){this.triggerEvent("contact",_objectSpread({},e.detail,{},e.currentTarget.dataset))},bindgetphonenumber:function(e){this.triggerEvent("getphonenumber",_objectSpread({},e.detail,{},e.currentTarget.dataset))},bindopensetting:function(e){this.triggerEvent("opensetting",_objectSpread({},e.detail,{},e.currentTarget.dataset))},onError:function(e){this.triggerEvent("error",_objectSpread({},e.detail,{},e.currentTarget.dataset))}}}); |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": { |
|||
"wux-popup": "../popup/index" |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
<wux-popup wux-content-class="{{ theme === 'ios' ? classes.popup : '' }}" position="bottom" visible="{{ in }}" safeArea="bottom" bind:close="cancel"> |
|||
<view class="wux-class {{ classes.wrap }}"> |
|||
<view class="{{ classes.content }}"> |
|||
<view class="{{ classes.options }}"> |
|||
<view class="{{ classes.title }}" wx:if="{{ titleText }}">{{ titleText }}</view> |
|||
<block wx:for="{{ buttons }}" wx:for-item="button" wx:key="index"> |
|||
<button |
|||
class="{{ classes.button[index].wrap }}" |
|||
data-index="{{ index }}" |
|||
disabled="{{ button.disabled }}" |
|||
open-type="{{ button.openType }}" |
|||
hover-class="{{ !button.disabled ? classes.button[index].hover : 'none' }}" |
|||
hover-stop-propagation="{{ button.hoverStopPropagation }}" |
|||
hover-start-time="{{ button.hoverStartTime }}" |
|||
hover-stay-time="{{ button.hoverStayTime }}" |
|||
lang="{{ button.lang }}" |
|||
bindgetuserinfo="bindgetuserinfo" |
|||
session-from="{{ button.sessionFrom }}" |
|||
send-message-title="{{ button.sendMessageTitle }}" |
|||
send-message-path="{{ button.sendMessagePath }}" |
|||
send-message-img="{{ button.sendMessageImg }}" |
|||
show-message-card="{{ button.showMessageCard }}" |
|||
bindcontact="bindcontact" |
|||
bindgetphonenumber="bindgetphonenumber" |
|||
app-parameter="{{ button.appParameter }}" |
|||
binderror="onError" |
|||
bindopensetting="bindopensetting" |
|||
catchtap="buttonClicked" |
|||
> |
|||
<image class="{{ classes.icon }}" src="{{ button.icon }}" wx:if="{{ button.icon }}" /> |
|||
<text class="{{ classes.text }}">{{ button.text }}</text> |
|||
</button> |
|||
</block> |
|||
<button class="{{ classes.destructive }}" wx:if="{{ destructiveText }}" catchtap="destructiveButtonClicked">{{ destructiveText }}</button> |
|||
</view> |
|||
<view class="{{ classes.group }}" wx:if="{{ cancelText }}"> |
|||
<button class="{{ classes.cancel }}" hover-class="{{ classes.hover }}" catchtap="cancel">{{ cancelText }}</button> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</wux-popup> |
@ -0,0 +1 @@ |
|||
.wux-actionsheet__popup{background-color:transparent}.wux-actionsheet__content{margin-left:16rpx;margin-right:16rpx;width:auto;overflow:hidden}.wux-actionsheet__content--theme-wx{margin-left:0;margin-right:0;margin-bottom:0}.wux-actionsheet__content--theme-wx .wux-actionsheet__group{border-radius:0;margin-bottom:12rpx}.wux-actionsheet__content--theme-wx .wux-actionsheet__group--options{background-color:#fff}.wux-actionsheet__content--theme-wx .wux-actionsheet__group--cancel{margin-bottom:0}.wux-actionsheet__content--theme-wx .wux-actionsheet__button{font-size:36rpx;color:#000}.wux-actionsheet__content--theme-wx .wux-actionsheet__button--cancel{font-weight:400}.wux-actionsheet__content--theme-wx.wux-actionsheet__content--has-cancel{background-color:#efeff4}.wux-actionsheet__group{margin-bottom:16rpx;border-radius:8rpx;background-color:#fff;overflow:hidden}.wux-actionsheet__group--options{background-color:#f1f2f3}.wux-actionsheet__title{padding:32rpx;color:#8f8f8f;text-align:center;font-size:26rpx}.wux-actionsheet__button{position:relative;display:block;margin:0;padding:0;min-width:104rpx;min-height:96rpx;vertical-align:top;text-align:center;text-overflow:ellipsis;cursor:pointer;width:100%;border-radius:0;background-color:transparent;color:#007aff;font-size:42rpx;line-height:96rpx;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.wux-actionsheet__button--hover{box-shadow:none;border-color:#d1d3d6;color:#007aff;background:#e4e5e7}.wux-actionsheet__button--destructive{color:#ff3b30!important}.wux-actionsheet__button--cancel{font-weight:500}.wux-actionsheet__button--disabled{opacity:.3!important}.wux-actionsheet__group .wux-actionsheet__button{border-top:none}.wux-actionsheet__group .wux-actionsheet__button:after{transform:none;transform-origin:none;border:none;border-radius:0;content:" ";position:absolute;left:0;top:0;right:0;height:2rpx;border-top:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:0 0;transform:scaleY(.5)}.wux-actionsheet__group .wux-actionsheet__button:first-child:last-child:after{border-width:0}.wux-actionsheet__icon{display:inline-block;width:48rpx;height:48rpx;margin-right:20rpx} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}(0,_baseComponent.default)({properties:{prefixCls:{type:String,value:"wux-alert"},classNames:{type:null,value:"wux-animate--fadeIn"},theme:{type:String,value:"balanced"},thumb:{type:String,value:""},title:{type:String,value:""},label:{type:String,value:""},closable:{type:Boolean,value:!1}},data:{visible:!0},computed:{classes:["prefixCls, theme",function(e,t){return{wrap:(0,_classNames2.default)(e,_defineProperty({},"".concat(e,"--").concat(t),t)),hd:"".concat(e,"__hd"),thumb:"".concat(e,"__thumb"),bd:"".concat(e,"__bd"),text:"".concat(e,"__text"),desc:"".concat(e,"__desc"),ft:"".concat(e,"__ft"),closable:"".concat(e,"__closable")}}]},methods:{onClose:function(){this.data.closable&&this.setData({visible:!1}),this.triggerEvent("click")},onClick:function(){this.triggerEvent("click")}}}); |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": { |
|||
"wux-animation-group": "../animation-group/index" |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
<wux-animation-group in="{{ visible }}" classNames="{{ classNames }}"> |
|||
<view class="wux-class {{ classes.wrap }}" bindtap="onClick"> |
|||
<view class="{{ classes.hd }}"> |
|||
<block wx:if="{{ thumb }}"> |
|||
<image class="{{ classes.thumb }}" src="{{ thumb }}" /> |
|||
</block> |
|||
<block wx:else> |
|||
<slot name="header"></slot> |
|||
</block> |
|||
</view> |
|||
<view class="{{ classes.bd }}"> |
|||
<view wx:if="{{ title }}" class="{{ classes.text }}">{{ title }}</view> |
|||
<view wx:if="{{ label }}" class="{{ classes.desc }}">{{ label }}</view> |
|||
<slot></slot> |
|||
</view> |
|||
<view class="{{ classes.ft }}"> |
|||
<block wx:if="{{ closable }}"> |
|||
<view class="{{ classes.closable }}" catchtap="onClose">×</view> |
|||
</block> |
|||
<block wx:else> |
|||
<slot name="footer"></slot> |
|||
</block> |
|||
</view> |
|||
</view> |
|||
</wux-animation-group> |
@ -0,0 +1 @@ |
|||
.wux-alert{padding:20rpx 30rpx;position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:4rpx;font-size:28rpx}.wux-alert__thumb{display:block;width:40rpx;height:40rpx;margin-right:10rpx}.wux-alert__bd{-ms-flex:1;flex:1}.wux-alert__text{text-align:left}.wux-alert__desc{text-align:left;line-height:1.2;font-size:24rpx}.wux-alert--light{color:#fff;background-color:#ddd}.wux-alert--stable{color:#fff;background-color:#b2b2b2}.wux-alert--positive{color:#fff;background-color:#387ef5}.wux-alert--calm{color:#fff;background-color:#11c1f3}.wux-alert--assertive{color:#fff;background-color:#ef473a}.wux-alert--balanced{color:#fff;background-color:#33cd5f}.wux-alert--energized{color:#fff;background-color:#ffc900}.wux-alert--royal{color:#fff;background-color:#886aea}.wux-alert--dark{color:#fff;background-color:#444} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,3 @@ |
|||
<view class="wux-class {{ wrapCls }} {{ animateCss }}" bindtap="onTap" catchtouchmove="{{ disableScroll ? 'noop' : '' }}" bindtransitionend="onTransitionEnd" bindanimationend="onAnimationEnd" wx:if="{{ animateStatus !== 'unmounted' }}" style="{{ extStyle }}"> |
|||
<slot></slot> |
|||
</view> |
@ -0,0 +1 @@ |
|||
.wux-animate--fadeIn-enter{transition:opacity .3s;opacity:0}.wux-animate--fadeIn-enter-active,.wux-animate--fadeIn-enter-done{opacity:1}.wux-animate--fadeIn-exit{transition:opacity .3s;opacity:1}.wux-animate--fadeIn-exit-active,.wux-animate--fadeIn-exit-done{opacity:0}.wux-animate--fadeInDown-enter{transition:opacity .3s,transform .3s;opacity:0;transform:translate3d(0,-100%,0)}.wux-animate--fadeInDown-enter-active,.wux-animate--fadeInDown-enter-done{opacity:1;transform:none}.wux-animate--fadeInDown-exit{transition:opacity .3s,transform .3s;opacity:1;transform:none}.wux-animate--fadeInDown-exit-active,.wux-animate--fadeInDown-exit-done{opacity:0;transform:translate3d(0,-100%,0)}.wux-animate--fadeInLeft-enter{transition:opacity .3s,transform .3s;opacity:0;transform:translate3d(-100%,0,0)}.wux-animate--fadeInLeft-enter-active,.wux-animate--fadeInLeft-enter-done{opacity:1;transform:none}.wux-animate--fadeInLeft-exit{transition:opacity .3s,transform .3s;opacity:1;transform:none}.wux-animate--fadeInLeft-exit-active,.wux-animate--fadeInLeft-exit-done{opacity:0;transform:translate3d(-100%,0,0)}.wux-animate--fadeInRight-enter{transition:opacity .3s,transform .3s;opacity:0;transform:translate3d(100%,0,0)}.wux-animate--fadeInRight-enter-active,.wux-animate--fadeInRight-enter-done{opacity:1;transform:none}.wux-animate--fadeInRight-exit{transition:opacity .3s,transform .3s;opacity:1;transform:none}.wux-animate--fadeInRight-exit-active,.wux-animate--fadeInRight-exit-done{opacity:0;transform:translate3d(100%,0,0)}.wux-animate--fadeInUp-enter{transition:opacity .3s,transform .3s;opacity:0;transform:translate3d(0,100%,0)}.wux-animate--fadeInUp-enter-active,.wux-animate--fadeInUp-enter-done{opacity:1;transform:none}.wux-animate--fadeInUp-exit{transition:opacity .3s,transform .3s;opacity:1;transform:none}.wux-animate--fadeInUp-exit-active,.wux-animate--fadeInUp-exit-done{opacity:0;transform:translate3d(0,100%,0)}.wux-animate--slideInUp-enter{transition:transform .3s;transform:translate3d(0,100%,0);visibility:visible}.wux-animate--slideInUp-enter-active,.wux-animate--slideInUp-enter-done{transform:translateZ(0)}.wux-animate--slideInUp-exit{transition:transform .3s;transform:translateZ(0)}.wux-animate--slideInUp-exit-active,.wux-animate--slideInUp-exit-done{transform:translate3d(0,100%,0);visibility:visible}.wux-animate--slideInDown-enter{transition:transform .3s;transform:translate3d(0,-100%,0);visibility:visible}.wux-animate--slideInDown-enter-active,.wux-animate--slideInDown-enter-done{transform:translateZ(0)}.wux-animate--slideInDown-exit{transition:transform .3s;transform:translateZ(0)}.wux-animate--slideInDown-exit-active,.wux-animate--slideInDown-exit-done{transform:translate3d(0,-100%,0);visibility:visible}.wux-animate--slideInLeft-enter{transition:transform .3s;transform:translate3d(-100%,0,0);visibility:visible}.wux-animate--slideInLeft-enter-active,.wux-animate--slideInLeft-enter-done{transform:translateZ(0)}.wux-animate--slideInLeft-exit{transition:transform .3s;transform:translateZ(0)}.wux-animate--slideInLeft-exit-active,.wux-animate--slideInLeft-exit-done{transform:translate3d(-100%,0,0);visibility:visible}.wux-animate--slideInRight-enter{transition:transform .3s;transform:translate3d(100%,0,0);visibility:visible}.wux-animate--slideInRight-enter-active,.wux-animate--slideInRight-enter-done{transform:none}.wux-animate--slideInRight-exit{transition:transform .3s;transform:none}.wux-animate--slideInRight-exit-active,.wux-animate--slideInRight-exit-done{transform:translate3d(100%,0,0);visibility:visible}.wux-animate--zoom-enter{transition:all .3s cubic-bezier(.215,.61,.355,1);opacity:.01;transform:scale(.75)}.wux-animate--zoom-enter-active,.wux-animate--zoom-enter-done{opacity:1;transform:none}.wux-animate--zoom-exit{transition:all .25s linear;transform:none}.wux-animate--zoom-exit-active,.wux-animate--zoom-exit-done{opacity:.01;transform:scale(.75)}.wux-animate--punch-enter{transition:all .3s cubic-bezier(.215,.61,.355,1);opacity:.01;transform:scale(1.35)}.wux-animate--punch-enter-active,.wux-animate--punch-enter-done{opacity:1;transform:none}.wux-animate--punch-exit{transition:all .25s linear;transform:none}.wux-animate--punch-exit-active,.wux-animate--punch-exit-done{opacity:.01;transform:scale(1.35)} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames")),_styleToCssString=_interopRequireDefault(require("../helpers/styleToCssString"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(e,t){var r=[],n=!0,a=!1,i=void 0;try{for(var l,o=e[Symbol.iterator]();!(n=(l=o.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(a)throw i}}return r}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}(0,_baseComponent.default)({properties:{prefixCls:{type:String,value:"wux-avatar"},shape:{type:String,value:"circle"},size:{type:String,value:"default"},src:{type:String,value:""},bodyStyle:{type:[String,Object],value:"",observer:function(e){this.setData({extStyle:(0,_styleToCssString.default)(e)})}},scale:{type:Boolean,value:!1}},data:{extStyle:"",childrenStyle:""},computed:{classes:["prefixCls, shape, size, src",function(e,t,r,n){var a;return{wrap:(0,_classNames2.default)(e,(_defineProperty(a={},"".concat(e,"--").concat(t),t),_defineProperty(a,"".concat(e,"--").concat(r),r),_defineProperty(a,"".concat(e,"--thumb"),n),a)),string:"".concat(e,"__string")}}]},methods:{setScale:function(){var l=this,e=this.data.prefixCls,t=wx.createSelectorQuery().in(this);t.select(".".concat(e)).boundingClientRect(),t.select(".".concat(e,"__string")).boundingClientRect(),t.exec(function(e){if(!e.filter(function(e){return!e}).length){var t=_slicedToArray(e,2),r=t[0],n=t[1],a=r.width-8<n.width?(r.width-8)/n.width:1,i=1!=a?"position: absolute; display: inline-block; transform: scale(".concat(a,"); left: calc(50% - ").concat(Math.round(n.width/2),"px)"):"";l.setData({childrenStyle:i})}})}},ready:function(){!this.data.src&&this.data.scale&&this.setScale()}}); |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,6 @@ |
|||
<view class="wux-class {{ classes.wrap }}" style="{{ extStyle }}"> |
|||
<image src="{{ src }}" wx:if="{{ src }}" /> |
|||
<text class="{{ classes.string }}" style="{{ childrenStyle }}" wx:else> |
|||
<slot></slot> |
|||
</text> |
|||
</view> |
@ -0,0 +1 @@ |
|||
.wux-avatar{font-family:Monospaced Number,Chinese Quote,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-size:28rpx;line-height:1.5;color:rgba(0,0,0,.65);box-sizing:border-box;display:inline-block;text-align:center;background:#ccc;color:#fff;white-space:nowrap;position:relative;overflow:hidden;vertical-align:middle;width:64rpx;height:64rpx;line-height:64rpx;border-radius:32rpx;font-size:36rpx}.wux-avatar .wux-avatar__string{line-height:64rpx}.wux-avatar--small{width:48rpx;height:48rpx;line-height:48rpx;border-radius:24rpx;font-size:28rpx}.wux-avatar--small .wux-avatar__string{line-height:48rpx}.wux-avatar--large{width:80rpx;height:80rpx;line-height:80rpx;border-radius:40rpx;font-size:48rpx}.wux-avatar--large .wux-avatar__string{line-height:80rpx}.wux-avatar--square{border-radius:8rpx}.wux-avatar--thumb{background:0 0}.wux-avatar>image{width:100%;height:100%} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(0,_baseComponent.default)({properties:{prefixCls:{type:String,value:"wux-backdrop"},transparent:{type:Boolean,value:!1},zIndex:{type:Number,value:1e3},classNames:{type:null,value:"wux-animate--fadeIn"}},computed:{classes:["prefixCls, transparent",function(e,t){return{wrap:t?"".concat(e,"--transparent"):e}}]},methods:{retain:function(){"number"==typeof this.backdropHolds&&this.backdropHolds||(this.backdropHolds=0),this.backdropHolds=this.backdropHolds+1,1===this.backdropHolds&&this.setData({in:!0})},release:function(){1===this.backdropHolds&&this.setData({in:!1}),this.backdropHolds=Math.max(0,this.backdropHolds-1)},onClick:function(){this.triggerEvent("click")}}}); |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": { |
|||
"wux-animation-group": "../animation-group/index" |
|||
} |
|||
} |
@ -0,0 +1 @@ |
|||
<wux-animation-group wux-class="{{ classes.wrap }}" in="{{ in }}" classNames="{{ classNames }}" bind:click="onClick" wrapStyle="{{ { zIndex } }}" disableScroll /> |
@ -0,0 +1 @@ |
|||
.wux-backdrop{background:rgba(0,0,0,.4)}.wux-backdrop,.wux-backdrop--transparent{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0}.wux-backdrop--transparent{background:0 0} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}(0,_baseComponent.default)({externalClasses:["wux-class-badge"],properties:{prefixCls:{type:String,value:"wux-badge"},count:{type:Number,value:0,observer:"updated"},overflowCount:{type:Number,value:99},dot:{type:Boolean,value:!1},showZero:{type:Boolean,value:!1},status:{type:String,value:""},text:{type:String,value:""}},data:{finalCount:0},computed:{classes:["prefixCls, status",function(e,t){return{wrap:(0,_classNames2.default)(e),status:"".concat(e,"__status"),statusDot:(0,_classNames2.default)("".concat(e,"__status-dot"),_defineProperty({},"".concat(e,"__status-dot--").concat(t),t)),statusText:"".concat(e,"__status-text"),dot:"".concat(e,"__dot"),count:"".concat(e,"__count")}}]},methods:{updated:function(e){var t=0<arguments.length&&void 0!==e?e:this.data.count,a=this.data.overflowCount,s=a<=t?"".concat(a,"+"):t;this.setData({finalCount:s})}}}); |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,10 @@ |
|||
<view class="wux-class {{ classes.wrap }}"> |
|||
<slot></slot> |
|||
<view class="{{ classes.status }}" wx:if="{{ status }}"> |
|||
<view class="{{ classes.statusDot }}"></view> |
|||
<view class="{{ classes.statusText }}" wx:if="{{ text }}">{{ text }}</view> |
|||
</view> |
|||
<view class="{{ classes.dot }}" wx:elif="{{ dot }}"></view> |
|||
<view class="{{ classes.count }} wux-class-badge" wx:elif="{{ showZero && count === 0 }}">{{ finalCount }}</view> |
|||
<view class="{{ classes.count }} wux-class-badge" wx:elif="{{ count !== 0 }}">{{ finalCount }}</view> |
|||
</view> |
@ -0,0 +1 @@ |
|||
.wux-badge{position:relative;display:inline-block;line-height:1;vertical-align:middle}.wux-badge__count{position:absolute;transform:translateX(50%);top:-12rpx;right:0;height:36rpx;border-radius:18rpx;min-width:36rpx;background:#ed3f14;border:2rpx solid transparent;color:#fff;line-height:36rpx;text-align:center;padding:0 10rpx;font-size:24rpx;white-space:nowrap;transform-origin:-10% center;z-index:10;box-shadow:0 0 0 2rpx #fff;box-sizing:border-box;text-rendering:optimizeLegibility}.wux-badge__dot{position:absolute;transform:translateX(-50%);transform-origin:0 center;top:-8rpx;right:-16rpx;height:16rpx;width:16rpx;border-radius:100%;background:#ed3f14;z-index:10;box-shadow:0 0 0 2rpx #fff}.wux-badge__status{line-height:inherit;vertical-align:baseline}.wux-badge__status-dot{width:12rpx;height:12rpx;display:inline-block;border-radius:50%;vertical-align:middle;position:relative;top:-2rpx}.wux-badge__status-dot--success{background-color:#52c41a}.wux-badge__status-dot--processing{background-color:#1890ff;position:relative}.wux-badge__status-dot--processing:after{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:50%;border:2rpx solid #1890ff;content:"";animation:statusProcessing 1.2s infinite ease-in-out}.wux-badge__status-dot--default{background-color:#d9d9d9}.wux-badge__status-dot--error{background-color:#f5222d}.wux-badge__status-dot--warning{background-color:#faad14}.wux-badge__status-text{display:inline-block;color:rgba(0,0,0,.65);font-size:28rpx;margin-left:16rpx}@keyframes statusProcessing{0%{transform:scale(.8);opacity:.5}to{transform:scale(2.4);opacity:0}} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}(0,_baseComponent.default)({properties:{prefixCls:{type:String,value:"wux-button"},type:{type:String,value:"stable"},clear:{type:Boolean,value:!1},block:{type:Boolean,value:!1},full:{type:Boolean,value:!1},outline:{type:Boolean,value:!1},bordered:{type:Boolean,value:!0},size:{type:String,value:"default"},disabled:{type:Boolean,value:!1},loading:{type:Boolean,value:!1},formType:{type:String,value:""},openType:{type:String,value:""},hoverClass:{type:String,value:"default"},hoverStopPropagation:{type:Boolean,value:!1},hoverStartTime:{type:Number,value:20},hoverStayTime:{type:Number,value:70},lang:{type:String,value:"en"},sessionFrom:{type:String,value:""},sendMessageTitle:{type:String,value:""},sendMessagePath:{type:String,value:""},sendMessageImg:{type:String,value:""},showMessageCard:{type:Boolean,value:!1},appParameter:{type:String,value:""}},computed:{classes:["prefixCls, hoverClass, type, size, block, full, clear, outline, bordered, disabled",function(e,t,n,r,a,o,i,l,u,s){var p;return{wrap:(0,_classNames2.default)(e,(_defineProperty(p={},"".concat(e,"--").concat(n),n),_defineProperty(p,"".concat(e,"--").concat(r),r),_defineProperty(p,"".concat(e,"--block"),a),_defineProperty(p,"".concat(e,"--full"),o),_defineProperty(p,"".concat(e,"--clear"),i),_defineProperty(p,"".concat(e,"--outline"),l),_defineProperty(p,"".concat(e,"--bordered"),u),_defineProperty(p,"".concat(e,"--disabled"),s),p)),hover:t&&"default"!==t?t:"".concat(e,"--hover")}}]},methods:{onTap:function(){this.data.disabled||this.data.loading||this.triggerEvent("click")},bindgetuserinfo:function(e){this.triggerEvent("getuserinfo",e.detail)},bindcontact:function(e){this.triggerEvent("contact",e.detail)},bindgetphonenumber:function(e){this.triggerEvent("getphonenumber",e.detail)},bindopensetting:function(e){this.triggerEvent("opensetting",e.detail)},onError:function(e){this.triggerEvent("error",e.detail)}}}); |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,26 @@ |
|||
<button |
|||
class="wux-class {{ classes.wrap }}" |
|||
disabled="{{ disabled }}" |
|||
loading="{{ loading }}" |
|||
form-type="{{ formType }}" |
|||
open-type="{{ openType }}" |
|||
hover-class="wux-hover-class {{ !disabled ? classes.hover : 'none' }}" |
|||
hover-stop-propagation="{{ hoverStopPropagation }}" |
|||
hover-start-time="{{ hoverStartTime }}" |
|||
hover-stay-time="{{ hoverStayTime }}" |
|||
lang="{{ lang }}" |
|||
bindgetuserinfo="bindgetuserinfo" |
|||
session-from="{{ sessionFrom }}" |
|||
send-message-title="{{ sendMessageTitle }}" |
|||
send-message-path="{{ sendMessagePath }}" |
|||
send-message-img="{{ sendMessageImg }}" |
|||
show-message-card="{{ showMessageCard }}" |
|||
bindcontact="bindcontact" |
|||
bindgetphonenumber="bindgetphonenumber" |
|||
app-parameter="{{ appParameter }}" |
|||
binderror="onError" |
|||
bindopensetting="bindopensetting" |
|||
bindtap="onTap" |
|||
> |
|||
<slot></slot> |
|||
</button> |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,6 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": { |
|||
"wux-popup": "../popup/index" |
|||
} |
|||
} |
@ -0,0 +1,67 @@ |
|||
<wux-popup position="bottom" visible="{{ in }}" zIndex="1010" safeArea="bottom" bind:close="close"> |
|||
<view class="wux-class {{ classes.wrap }}"> |
|||
<view class="{{ classes.content }}"> |
|||
<view class="{{ classes.hd }}" wx:if="{{ toolbar }}"> |
|||
<view class="{{ classes.toolbar }}"> |
|||
<view class="{{ classes.picker }}"> |
|||
<view class="{{ classes.link }}" bindtap="prevMonth"> |
|||
<view class="{{ classes.prev }}"></view> |
|||
</view> |
|||
<view class="{{ classes.value }}">{{ currentMonthName }}</view> |
|||
<view class="{{ classes.link }}" bindtap="nextMonth"> |
|||
<view class="{{ classes.next }}"></view> |
|||
</view> |
|||
</view> |
|||
<view class="{{ classes.picker }}"> |
|||
<view class="{{ classes.link }}" bindtap="prevYear"> |
|||
<view class="{{ classes.prev }}"></view> |
|||
</view> |
|||
<text class="{{ classes.value }}">{{ currentYear }}</text> |
|||
<view class="{{ classes.link }}" bindtap="nextYear"> |
|||
<view class="{{ classes.next }}"></view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="{{ classes.bd }}"> |
|||
<view class="{{ classes.weekdays }}" wx:if="{{ weekHeader }}"> |
|||
<block wx:for="{{ weeks }}" wx:key=""> |
|||
<view class="{{ classes.weekday }} {{ item.weekend ? prefixCls + '__weekday--weekend' : '' }}"> |
|||
{{ item.dayName }} |
|||
</view> |
|||
</block> |
|||
</view> |
|||
<view class="{{ classes.months }}"> |
|||
<view class="{{ classes.monthsContent }}" bindtouchstart="onTouchStart" catchtouchmove="{{ swiping ? 'noop' : '' }}" capture-bind:touchmove="onTouchMove" bindtouchend="onTouchEnd" style="{{ wrapperTranslate }}"> |
|||
<block wx:for="{{ months }}" wx:for-item="month" wx:key=""> |
|||
<view |
|||
data-year="{{ month.year }}" |
|||
data-month="{{ month.month }}" |
|||
class="{{ classes.month }} {{ index === 0 ? (prefixCls + '__month--prev') : index === 1 ? (prefixCls + '__month--current') : (prefixCls + '__month--next') }}" |
|||
style="{{ monthsTranslate[index] }}" |
|||
> |
|||
<block wx:for="{{ month.items }}" wx:for-item="row" wx:key=""> |
|||
<view class="{{ classes.days }}"> |
|||
<block wx:for="{{ row }}" wx:for-item="col" wx:key=""> |
|||
<view |
|||
data-year="{{ col.year }}" |
|||
data-month="{{ col.month }}" |
|||
data-day="{{ col.day }}" |
|||
data-date="{{ col.date }}" |
|||
data-type="{{ col.type }}" |
|||
class="{{ classes.day }} {{ col.type.prev ? prefixCls + '__day--prev' : '' }} {{ col.type.next ? prefixCls + '__day--next' : '' }} {{ col.type.today ? prefixCls + '__day--today' : '' }} {{ col.type.selected ? prefixCls + '__day--selected' : '' }} {{ col.type.weekend ? prefixCls + '__day--weekend' : '' }} {{ col.type.disabled ? prefixCls + '__day--disabled' : '' }}" |
|||
bindtap="onDayClick" |
|||
> |
|||
<text class="{{ classes.text }}">{{ col.day }}</text> |
|||
</view> |
|||
</block> |
|||
</view> |
|||
</block> |
|||
</view> |
|||
</block> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</wux-popup> |
@ -0,0 +1 @@ |
|||
.wux-calendar{position:relative;background:#fff;height:600rpx;width:100%;overflow:hidden}.wux-calendar__content{position:relative;width:100%;height:100%;transition:transform .3s}.wux-calendar__bd{height:100%;position:relative;overflow:hidden}.wux-calendar__hd{position:relative;width:100%}.wux-calendar__hd:before{content:" ";position:absolute;left:0;top:0;right:0;height:2rpx;border-top:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:0 0;transform:scaleY(.5)}.wux-calendar__hd+.wux-calendar__bd{height:calc(97.8%)}.wux-calendar__toolbar{height:2.2rem;display:-ms-flexbox;display:flex;text-align:center}.wux-calendar__picker{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;width:50%;max-width:400rpx;-ms-flex-negative:10;flex-shrink:10;display:block;line-height:2.2rem}.wux-calendar__link{float:left;width:25%;height:2.2rem;line-height:2rem;min-width:72rpx}.wux-calendar__icon{display:inline-block;vertical-align:middle;background-size:100% auto;background-position:center}.wux-calendar__icon--next,.wux-calendar__icon--prev{width:.75rem;height:.75rem}.wux-calendar__icon--next{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2015%2015'%3E%3Cg%3E%3Cpath%20fill%3D'%23007aff'%20d%3D'M1%2C1.6l11.8%2C5.8L1%2C13.4V1.6%20M0%2C0v15l15-7.6L0%2C0L0%2C0z'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E")}.wux-calendar__icon--prev{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2015%2015'%3E%3Cg%3E%3Cpath%20fill%3D'%23007aff'%20d%3D'M14%2C1.6v11.8L2.2%2C7.6L14%2C1.6%20M15%2C0L0%2C7.6L15%2C15V0L15%2C0z'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E")}.wux-calendar__value{-ms-flex-negative:1;flex-shrink:1;position:relative;overflow:hidden;text-overflow:ellipsis;float:left;width:50%;height:2.2rem}.wux-calendar__weekdays{height:36rpx;background:#f7f7f8;display:-ms-flexbox;display:flex;font-size:22rpx;box-sizing:border-box;position:relative}.wux-calendar__weekdays:after{content:" ";position:absolute;left:0;bottom:0;right:0;height:2rpx;border-bottom:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:0 100%;transform:scaleY(.5)}.wux-calendar__weekdays+.wux-calendar__months{height:calc(82%)}.wux-calendar__weekday{-ms-flex-negative:1;flex-shrink:1;width:14.28571429%;width:calc(14.28571429%);line-height:34rpx;text-align:center}.wux-calendar__months{width:100%;height:100%;overflow:hidden;position:relative}.wux-calendar__months-content{width:100%;height:100%;display:-ms-flexbox;display:flex;position:relative;-webkit-backface-visibility:hidden;transform:translate3d(0,0,0)}.wux-calendar__month{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;width:100%;height:100%;position:absolute;left:0;top:0}.wux-calendar__days{height:16.66666667%;height:calc(16.66666667%);display:-ms-flexbox;display:flex;-ms-flex-negative:1;flex-shrink:1;width:100%;position:relative}.wux-calendar__days:after{content:" ";position:absolute;left:0;bottom:0;right:0;height:2rpx;border-bottom:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:0 100%;transform:scaleY(.5)}.wux-calendar__days:last-child:after{display:none}.wux-calendar__day{-ms-flex-negative:1;flex-shrink:1;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;box-sizing:border-box;width:14.28571429%;width:calc(14.28571429%);text-align:center;color:#3d4145;font-size:30rpx;cursor:pointer}.wux-calendar__day--next,.wux-calendar__day--prev{color:#ccc}.wux-calendar__day--disabled{color:#d4d4d4;cursor:auto}.wux-calendar__day--today .wux-calendar__text{background:#e3e3e3}.wux-calendar__day--selected .wux-calendar__text{background:#0894ec;color:#fff}.wux-calendar__text{display:inline-block;border-radius:100%;width:60rpx;height:60rpx;line-height:60rpx} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames3=_interopRequireDefault(require("../helpers/classNames")),_styleToCssString=_interopRequireDefault(require("../helpers/styleToCssString"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}(0,_baseComponent.default)({properties:{prefixCls:{type:String,value:"wux-card"},bordered:{type:Boolean,value:!0},full:{type:Boolean,value:!1},title:{type:String,value:""},thumb:{type:String,value:""},thumbStyle:{type:[String,Object],value:"",observer:function(e){this.setData({extStyle:(0,_styleToCssString.default)(e)})}},extra:{type:String,value:""},actions:{type:Array,value:[]}},data:{extStyle:""},computed:{classes:["prefixCls, bordered, full, actions",function(a,e,t,n){var r;return{wrap:(0,_classNames3.default)(a,(_defineProperty(r={},"".concat(a,"--bordered"),e),_defineProperty(r,"".concat(a,"--full"),t),_defineProperty(r,"".concat(a,"--has-actions"),0<n.length),r)),hd:"".concat(a,"__hd"),content:"".concat(a,"__content"),thumb:"".concat(a,"__thumb"),extra:"".concat(a,"__extra"),bd:"".concat(a,"__bd"),ft:"".concat(a,"__ft"),actions:"".concat(a,"__actions"),action:n.map(function(e){var t;return{wrap:(0,_classNames3.default)("".concat(a,"__action"),(_defineProperty(t={},"".concat(a,"__action--").concat(e.type||"default"),e.type||"default"),_defineProperty(t,"".concat(a,"__action--bold"),e.bold),_defineProperty(t,"".concat(a,"__action--disabled"),e.disabled),_defineProperty(t,"".concat(e.className),e.className),t)),hover:e.hoverClass&&"default"!==e.hoverClass?e.hoverClass:"".concat(a,"__action--hover")}})}}]},methods:{onAction:function(e){var t=e.currentTarget.dataset.index,a=this.data.actions,n=a[t];n.disabled||this.triggerEvent("action",{index:t,action:n,actions:a})}}}); |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,28 @@ |
|||
<view class="wux-class {{ classes.wrap }}"> |
|||
<view class="{{ classes.hd }}" wx:if="{{ thumb || title || extra }}"> |
|||
<view class="{{ classes.content }}" wx:if="{{ thumb || title }}"> |
|||
<image class="{{ classes.thumb }}" src="{{ thumb }}" mode="aspectFit" style="{{ extStyle }}" wx:if="{{ thumb }}" /> |
|||
<text>{{ title }}</text> |
|||
</view> |
|||
<view class="{{ classes.extra }}" wx:if="{{ extra }}">{{ extra }}</view> |
|||
<slot name="extra" wx:else></slot> |
|||
</view> |
|||
<view class="{{ classes.bd }}"> |
|||
<slot name="body"></slot> |
|||
</view> |
|||
<view class="{{ classes.ft }}"> |
|||
<slot name="footer"></slot> |
|||
</view> |
|||
<view class="{{ classes.actions }}" wx:if="{{ actions.length > 0 }}"> |
|||
<block wx:for="{{ actions }}" wx:for-item="action" wx:key=""> |
|||
<view |
|||
class="{{ classes.action[index].wrap }}" |
|||
hover-class="{{ !action.disabled ? classes.action[index].hover : 'none' }}" |
|||
data-index="{{ index }}" |
|||
bindtap="onAction" |
|||
> |
|||
{{ action.text }} |
|||
</view> |
|||
</block> |
|||
</view> |
|||
</view> |
@ -0,0 +1 @@ |
|||
.wux-card{position:relative;min-height:192rpx;padding-bottom:12rpx;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#fff}.wux-card--bordered:before{content:" ";position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #d9d9d9;border-radius:20rpx;border-top-width:2rpx;border-right-width:2rpx;border-bottom-width:2rpx;border-left-width:2rpx}.wux-card--full:before{border-radius:0;border-right-width:0;border-left-width:0}.wux-card--has-actions{padding-bottom:0}.wux-card__hd{position:relative;display:-ms-flexbox;display:flex;font-size:34rpx;padding:18rpx 30rpx;-ms-flex-align:center;align-items:center}.wux-card__hd:before{content:" ";position:absolute;left:0;bottom:0;right:0;height:2rpx;border-bottom:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:0 100%;transform:scaleY(.5)}.wux-card__content{-ms-flex:1;flex:1;text-align:left;color:#000}.wux-card__thumb{display:inline-block;width:64rpx;height:64rpx;position:relative;margin-left:auto;margin-right:10rpx;overflow:hidden;vertical-align:middle}.wux-card__extra{-ms-flex:1;flex:1;text-align:right;font-size:34rpx;color:#888}.wux-card__bd{position:relative;padding:30rpx 30rpx 12rpx;font-size:30rpx;color:#333;min-height:80rpx}.wux-card__ft{display:-ms-flexbox;display:flex;font-size:28rpx;color:#888;padding:0 30rpx}.wux-card__actions{position:relative;display:-ms-flexbox;display:flex;line-height:100rpx;margin-top:12rpx;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.wux-card__actions:before{content:" ";position:absolute;left:0;top:0;right:0;height:2rpx;border-top:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:0 0;transform:scaleY(.5)}.wux-card__action{position:relative;display:block;-ms-flex:1;flex:1;color:#33cd5f;text-align:center}.wux-card__action:before{content:" ";position:absolute;right:0;top:0;width:2rpx;bottom:0;border-right:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:100% 0;transform:scaleX(.5)}.wux-card__action:last-child:before{display:none}.wux-card__action--default{color:#353535}.wux-card__action--primary{color:#33cd5f!important}.wux-card__action--bold{font-weight:500!important}.wux-card__action--hover{background-color:#ececec!important}.wux-card__action--disabled{opacity:.3} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames=_interopRequireDefault(require("../helpers/classNames")),_arrayTreeFilter=_interopRequireDefault(require("../helpers/arrayTreeFilter")),_props=require("../multi-picker-view/props");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(r,!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(r).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}(0,_baseComponent.default)({properties:_objectSpread({},_props.props,{cols:{type:Number,value:3}}),data:{inputValue:[],showOptions:[],fieldNames:_props.defaultFieldNames},observers:_defineProperty({inputValue:function(e){var r=this.getFieldName("value"),n=this.getFieldName("label"),t=this.getShowOptions(e).reduce(function(e,t){return[].concat(_toConsumableArray(e),[t.map(function(e){var t;return _defineProperty(t={},r,e[r]),_defineProperty(t,n,e[n]),_defineProperty(t,"disabled",!!e.disabled),t})])},[]);this.setData({showOptions:t})}},"value, options, cols",function(e,t,r){this.setValue(e,t,r)}),methods:{updated:function(e){this.data.inputValue!==e&&this.setData({inputValue:e})},setValue:function(e,t,r){var n=0<arguments.length&&void 0!==e?e:this.data.inputValue,i=1<arguments.length&&void 0!==t?t:this.data.options,a=2<arguments.length&&void 0!==r?r:this.data.cols,o=this.getRealValue(i,n,a);this.updated(o)},onValueChange:function(e){var t=e.detail,r=t.value,n=t.index,i=this.getNextValue(r,n),a=this.getRealValue(this.data.options,i),o=this.getValue(a);this.updated(a),this.triggerEvent("valueChange",_objectSpread({},o,{index:n}))},getValue:function(e){var t=0<arguments.length&&void 0!==e?e:this.data.inputValue,r=this.getRealValue(this.data.options,t),n=this.getShowOptions(r);return this.picker=this.picker||this.selectComponent("#wux-picker"),this.picker.getValue(r,n)},getNextValue:function(r,n){for(var e=this.data.options,i=this.getFieldName("value"),t=this.getFieldName("children"),a=(0,_arrayTreeFilter.default)(e,function(e,t){return t<=n&&e[i]===r[t]},{childrenKeyName:t})[n],o=n+1;o<this.data.cols;)a&&a[t]&&a[t].length&&(a=a[t][0],r[o]=a[i]),o++;return r.length=o,r},getRealValue:function(o,u,e){var l=this,s=2<arguments.length&&void 0!==e?e:this.data.cols;if(!u||!u.length||-1<u.indexOf(void 0)||u.length!==s){var t=function(){for(var t=l.getFieldName("value"),e=l.getFieldName("children"),r=[],n=_toConsumableArray(o),i=0;i<s;){if(n&&n.length){r[i]=u[i]||n[0][t];var a=0;r[i]&&-1===(a=n.map(function(e){return e[t]}).indexOf(r[i]))&&(a=0,r[i]=n[0][t]),n=n[a][e]}i++}return{v:r}}();if("object"===_typeof(t))return t.v}return u},getActiveOptions:function(r){var e=this.data.options,n=this.getFieldName("value"),t=this.getFieldName("children");return(0,_arrayTreeFilter.default)(e,function(e,t){return e[n]===r[t]},{childrenKeyName:t})},getShowOptions:function(e){var t=this.data,r=t.options,n=t.cols,i=this.getFieldName("children"),a=this.getActiveOptions(e).map(function(e){return e[i]}).filter(function(e){return!!e});return[r].concat(_toConsumableArray(a)).filter(function(e,t){return t<n})},getFieldName:function(e){return this.data.fieldNames[e]}},attached:function(){var e=this.data,t=e.value,r=e.options,n=e.cols,i=Object.assign({},_props.defaultFieldNames,this.data.defaultFieldNames);this.setData({fieldNames:i}),this.setValue(t,r,n)}}); |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": { |
|||
"wux-multi-picker-view": "../multi-picker-view/index" |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
<wux-multi-picker-view |
|||
id="wux-picker" |
|||
prefixCls="{{ prefixCls }}" |
|||
pickerPrefixCls="{{ pickerPrefixCls }}" |
|||
value="{{ inputValue }}" |
|||
itemHeight="{{ itemHeight }}" |
|||
itemStyle="{{ itemStyle }}" |
|||
indicatorStyle="{{ indicatorStyle }}" |
|||
indicatorClass="{{ indicatorClass }}" |
|||
maskStyle="{{ maskStyle }}" |
|||
maskClass="{{ maskClass }}" |
|||
labelAlign="{{ labelAlign }}" |
|||
defaultFieldNames="{{ fieldNames }}" |
|||
options="{{ showOptions }}" |
|||
loading="{{ loading }}" |
|||
bind:valueChange="onValueChange" |
|||
/> |
File diff suppressed because one or more lines are too long
@ -0,0 +1,6 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": { |
|||
"wux-popup": "../popup/index" |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
<wux-popup position="bottom" visible="{{ visible }}" safeArea="bottom" bind:close="onPopupClose"> |
|||
<view class="wux-class {{ classes.wrap }}"> |
|||
<view class="{{ classes.hd }}"> |
|||
<view class="{{ classes.title }}" wx:if="{{ title }}">{{ title }}</view> |
|||
<view class="{{ classes.menus }}" wx:if="{{ activeOptions.length }}"> |
|||
<block wx:for="{{ activeOptions }}" wx:key=""> |
|||
<view class="{{ classes.menu }} {{ activeIndex === index ? prefixCls + '__menu--active' : '' }}" data-menu-index="{{ index }}" bindtap="onMenuClick">{{ item[fieldNames['label']] }}</view> |
|||
</block> |
|||
</view> |
|||
</view> |
|||
<view class="{{ classes.bd }}" style="{{ bodyStyle }}"> |
|||
<block wx:for="{{ showOptions }}" wx:for-item="option" wx:for-index="optionIndex" wx:key=""> |
|||
<view class="{{ classes.inner }}"> |
|||
<scroll-view scroll-y class="wux-scroll-view-class {{ classes.scrollView }}"> |
|||
<view class="{{ classes.option }}"> |
|||
<block wx:for="{{ option }}" wx:key=""> |
|||
<view |
|||
class="{{ classes.item }} {{ activeValue[optionIndex] === item[fieldNames['value']] ? prefixCls + '__item--active' : '' }} {{ item.disabled ? prefixCls + '__item--disabled' : '' }}" |
|||
data-option-index="{{ optionIndex }}" |
|||
data-item="{{ item }}" |
|||
bindtap="onItemSelect" |
|||
> |
|||
<text>{{ item[fieldNames['label']] }}</text> |
|||
<icon class="{{ classes.icon }}" type="success_no_circle" size="16" color="#ef473a" wx:if="{{ activeValue[optionIndex] === item[fieldNames['value']] }}" /> |
|||
</view> |
|||
</block> |
|||
</view> |
|||
</scroll-view> |
|||
</view> |
|||
</block> |
|||
</view> |
|||
</view> |
|||
</wux-popup> |
@ -0,0 +1 @@ |
|||
.wux-cascader__hd{position:relative;width:100%;font-size:34rpx;line-height:1.5;color:#444}.wux-cascader__hd:after{content:" ";position:absolute;left:0;bottom:0;right:0;height:2rpx;border-bottom:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:0 100%;transform:scaleY(.5)}.wux-cascader__title{position:relative;height:88rpx;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;text-align:center;box-sizing:border-box}.wux-cascader__title:after{content:" ";position:absolute;left:0;bottom:0;right:0;height:2rpx;border-bottom:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:0 100%;transform:scaleY(.5)}.wux-cascader__menus{display:-ms-flexbox;display:flex;height:88rpx;padding:0 20rpx;-ms-flex-align:center;align-items:center;box-sizing:border-box}.wux-cascader__menu{font-size:26rpx;padding:0 20rpx;max-width:40%;width:auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-wrap:normal}.wux-cascader__menu--active{color:#ef473a}.wux-cascader__bd{width:100%;display:-ms-flexbox;display:flex;transition:transform .3s;background-color:#f5f5f5}.wux-cascader__inner{display:block;height:inherit;width:50%;-ms-flex:0 0 50%;flex:0 0 50%;background-color:#fff}.wux-cascader__inner:nth-child(2n){background-color:#f5f5f5}.wux-cascader__scroll-view{max-height:540rpx}.wux-cascader__option{width:100%;height:inherit;display:block;padding:0 40rpx;box-sizing:border-box}.wux-cascader__item{position:relative;z-index:10;display:block;color:#333;font-size:26rpx;height:80rpx;line-height:80rpx;text-align:left;padding-right:36rpx;width:auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-wrap:normal}.wux-cascader__item:after{content:" ";position:absolute;left:0;bottom:0;right:0;height:2rpx;border-bottom:2rpx solid #d9d9d9;color:#d9d9d9;transform-origin:0 100%;transform:scaleY(.5)}.wux-cascader__item--active{color:#ef473a}.wux-cascader__item--disabled{opacity:.3}.wux-cascader__icon{position:absolute;top:24rpx;right:0;z-index:20;font-size:0;line-height:1} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames=_interopRequireDefault(require("../helpers/classNames"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(0,_baseComponent.default)({options:{multipleSlots:!1},relations:{"../cell/index":{type:"descendant",observer:function(){this.debounce(this.updateIsLastElement)}}},properties:{prefixCls:{type:String,value:"wux-cell-group"},title:{type:String,value:""},label:{type:String,value:""}},computed:{classes:["prefixCls",function(e){return{wrap:(0,_classNames.default)(e),hd:"".concat(e,"__hd"),bd:"".concat(e,"__bd"),ft:"".concat(e,"__ft")}}]},methods:{updateIsLastElement:function(){var e=this.getRelationNodes("../cell/index");if(0<e.length){var n=e.length-1;e.forEach(function(e,t){e.updateIsLastElement(t===n)})}},getBoundingClientRect:function(t){var n=this,e=".".concat(this.data.prefixCls);wx.createSelectorQuery().in(this).select(e).boundingClientRect(function(e){e&&t.call(n,e.height)}).exec()}}}); |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,7 @@ |
|||
<view class="wux-class {{ classes.wrap }}"> |
|||
<view class="{{ classes.hd }}" wx:if="{{ title }}">{{ title }}</view> |
|||
<view class="{{ classes.bd }}"> |
|||
<slot></slot> |
|||
</view> |
|||
<view class="{{ classes.ft }}" wx:if="{{ label }}">{{ label }}</view> |
|||
</view> |
@ -0,0 +1 @@ |
|||
.wux-cell-group__hd{padding:30rpx 30rpx 18rpx;font-size:28rpx;color:#888;width:100%;box-sizing:border-box}.wux-cell-group__bd{position:relative;background-color:#fff}.wux-cell-group__bd:after{content:" ";position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #d9d9d9;border-top-width:2rpx;border-bottom-width:2rpx}.wux-cell-group__ft{padding:18rpx 30rpx 30rpx;font-size:28rpx;color:#888} |
@ -0,0 +1 @@ |
|||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames")),_eventsMixin=_interopRequireDefault(require("../helpers/eventsMixin"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var defaultEvents={onClick:function(){},onError:function(){}};(0,_baseComponent.default)({behaviors:[(0,_eventsMixin.default)({defaultEvents:defaultEvents})],relations:{"../cell-group/index":{type:"ancestor"},"../picker/index":{type:"parent"},"../date-picker/index":{type:"parent"},"../popup-select/index":{type:"parent"}},properties:{prefixCls:{type:String,value:"wux-cell"},disabled:{type:Boolean,value:!1},hoverClass:{type:String,value:"default"},hoverStopPropagation:{type:Boolean,value:!1},hoverStartTime:{type:Number,value:20},hoverStayTime:{type:Number,value:70},lang:{type:String,value:"en"},sessionFrom:{type:String,value:""},sendMessageTitle:{type:String,value:""},sendMessagePath:{type:String,value:""},sendMessageImg:{type:String,value:""},showMessageCard:{type:Boolean,value:!1},appParameter:{type:String,value:""},thumb:{type:String,value:""},title:{type:String,value:""},label:{type:String,value:""},extra:{type:String,value:""},isLink:{type:Boolean,value:!1},openType:{type:String,value:"navigateTo"},url:{type:String,value:""},delta:{type:Number,value:1}},data:{isLast:!1},computed:{classes:["prefixCls, hoverClass, isLast, isLink, disabled",function(e,t,n,a,i){var r;return{wrap:(0,_classNames2.default)(e,(_defineProperty(r={},"".concat(e,"--last"),n),_defineProperty(r,"".concat(e,"--access"),a),_defineProperty(r,"".concat(e,"--disabled"),i),r)),hd:"".concat(e,"__hd"),thumb:"".concat(e,"__thumb"),bd:"".concat(e,"__bd"),text:"".concat(e,"__text"),desc:"".concat(e,"__desc"),ft:"".concat(e,"__ft"),hover:t&&"default"!==t?t:"".concat(e,"--hover")}}]},methods:{onTap:function(){this.data.disabled||(this.triggerEvent("click"),this.linkTo())},bindgetuserinfo:function(e){this.triggerEvent("getuserinfo",e.detail)},bindcontact:function(e){this.triggerEvent("contact",e.detail)},bindgetphonenumber:function(e){this.triggerEvent("getphonenumber",e.detail)},bindopensetting:function(e){this.triggerEvent("opensetting",e.detail)},onError:function(e){this.triggerEvent("error",e.detail)},linkTo:function(){var e=this.data,t=e.url,n=e.isLink,a=e.openType,i=e.delta;return!!(n&&t&&["navigateTo","redirectTo","switchTab","navigateBack","reLaunch"].includes(a))&&("navigateBack"===a?wx[a].call(wx,{delta:i}):wx[a].call(wx,{url:t}))},updateIsLastElement:function(e){this.setData({isLast:e})}}}); |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue