commit
43d87c344c
435 changed files with 18152 additions and 0 deletions
Unified View
Diff Options
-
2README.md
-
60api/axios.js
-
18api/chain.js
-
208api/request.js
-
104api/user.js
-
18api/ztb.js
-
76app.js
-
30app.json
-
76app.wxss
-
BINassets/icon/address.png
-
BINassets/icon/home-blue.png
-
BINassets/icon/home-gray.png
-
BINassets/icon/mall-blue.png
-
BINassets/icon/mall-gray.png
-
BINassets/icon/phone.png
-
BINassets/icon/storage-blue.png
-
BINassets/icon/storage-gray.png
-
BINassets/icon/store-blue.png
-
BINassets/icon/store-gray.png
-
BINassets/image/def_image.png
-
BINassets/image/icon-dbz-label.png
-
BINassets/image/icon-search.png
-
BINassets/image/icon_logo.png
-
BINassets/image/list_empty.png
-
BINassets/image/order-check-icon.png
-
BINassets/image/proxy-icon.png
-
BINassets/image/reconciliation-icon.png
-
BINassets/image/supplier-icon.png
-
BINassets/image/toggle-icon.png
-
BINassets/image/ygImg.png
-
BINassets/raw/ding.mp3
-
100colorui/components/cu-custom.js
-
4colorui/components/cu-custom.json
-
16colorui/components/cu-custom.wxml
-
5colorui/components/cu-custom.wxss
-
1226colorui/icon.wxss
-
1129colorui/main.wxss
-
62components/action-sheet/index.js
-
8components/action-sheet/index.json
-
34components/action-sheet/index.wxml
-
1components/action-sheet/index.wxss
-
383components/animation-group/index.js
-
3components/animation-group/index.json
-
5components/animation-group/index.wxml
-
206components/animation-group/index.wxss
-
210components/area/index.js
-
6components/area/index.json
-
18components/area/index.wxml
-
1components/area/index.wxss
-
62components/backdrop/index.js
-
6components/backdrop/index.json
-
1components/backdrop/index.wxml
-
15components/backdrop/index.wxss
-
69components/button/index.js
-
7components/button/index.json
-
44components/button/index.wxml
-
1components/button/index.wxss
-
10components/cell-group/index.js
-
3components/cell-group/index.json
-
9components/cell-group/index.wxml
-
1components/cell-group/index.wxss
-
35components/cell/index.js
-
6components/cell/index.json
-
30components/cell/index.wxml
-
1components/cell/index.wxss
-
76components/checkbox/index.js
-
6components/checkbox/index.json
-
20components/checkbox/index.wxml
-
20components/checkbox/index.wxs
-
1components/checkbox/index.wxss
-
58components/checker/index.js
-
7components/checker/index.json
-
22components/checker/index.wxml
-
12components/checker/index.wxs
-
1components/checker/index.wxss
-
21components/checker/shared.js
-
11components/checker/toolbar.wxml
-
24components/col/index.js
-
3components/col/index.json
-
8components/col/index.wxml
-
1components/col/index.wxss
-
95components/collapse-item/index.js
-
6components/collapse-item/index.json
-
18components/collapse-item/index.wxml
-
1components/collapse-item/index.wxss
-
47components/collapse/index.js
-
3components/collapse/index.json
-
3components/collapse/index.wxml
-
1components/collapse/index.wxss
-
1components/common/classNames.js
-
7components/common/color.js
-
101components/common/component.js
-
1components/common/index.wxss
-
1components/common/style/clearfix.wxss
-
1components/common/style/ellipsis.wxss
-
1components/common/style/hairline.wxss
-
0components/common/style/mixins/clearfix.wxss
-
0components/common/style/mixins/ellipsis.wxss
-
0components/common/style/mixins/hairline.wxss
-
0components/common/style/theme.wxss
@ -0,0 +1,2 @@ |
|||||
|
# zhitongbao-mini |
||||
|
|
||||
@ -0,0 +1,60 @@ |
|||||
|
const axios = (function () { |
||||
|
class Axios { |
||||
|
constructor() { |
||||
|
this.defaults = { baseUrl: "" } |
||||
|
this.interceptors = { request: new InterceptorManager(), response: new InterceptorManager() } |
||||
|
} |
||||
|
|
||||
|
wxRequest(c) { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
c = this.interceptors.request.func(c) |
||||
|
c.url = c.url.startsWith("http") ? c.url : c.baseUrl + c.url |
||||
|
c.success = (res) => { |
||||
|
resolve(this.interceptors.response.func(res)) |
||||
|
} |
||||
|
// c.enableHttpDNS = true,
|
||||
|
// c.httpDNSServiceId = 'wxa410372c837a5f26',
|
||||
|
c.fail = (res) => { |
||||
|
reject(this.interceptors.response.func(res)) |
||||
|
} |
||||
|
wx.request(c) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Array.prototype.forEach.call(["options", "get", "head", "post", "put", "delete", "trace", "connect"], function (m) { |
||||
|
Axios.prototype[m] = function (url, data, config) { |
||||
|
return this.wxRequest( |
||||
|
merge( this.defaults, { url: url, method: m, data: data }, config || {} ) |
||||
|
) |
||||
|
} |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
class InterceptorManager { |
||||
|
constructor() { |
||||
|
this.func = function (data) { |
||||
|
return data |
||||
|
} |
||||
|
} |
||||
|
use(fn) { |
||||
|
this.func = fn |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function merge(axiosDefaultConfig, data, config) { |
||||
|
let cloneAxios = deepClone(axiosDefaultConfig) |
||||
|
let cloneData = deepClone(data) |
||||
|
let cloneConfig = deepClone(config) |
||||
|
return Object.assign(cloneAxios, cloneData, cloneConfig) |
||||
|
} |
||||
|
|
||||
|
// 深拷贝
|
||||
|
function deepClone(obj) { |
||||
|
let _obj = JSON.stringify(obj), objClone = JSON.parse(_obj) |
||||
|
return objClone |
||||
|
} |
||||
|
return new Axios() |
||||
|
})() |
||||
|
|
||||
|
export default axios |
||||
@ -0,0 +1,18 @@ |
|||||
|
import { mGet, mPost } from "./request" |
||||
|
const app = getApp() |
||||
|
const urls = ['https://api-client-ztb-dev.qniao.cn', 'https://api-client-ztb-test.qniao.cn', 'https://api-client-ztb.qniao.cn'] |
||||
|
|
||||
|
const hconfig = { baseUrl: urls[app.evn] } |
||||
|
// *********************************************************账户业务***********************************************************
|
||||
|
const getUserInfo = (params) => mGet(`/ztb-supply-chain-service/get/user/base-info`, params, hconfig) |
||||
|
const getStoreInfo = (params) => mGet(`/ztb-supply-chain-service/scrap-paper/store/get/by/current-user`, params, hconfig) |
||||
|
const getChainList = (params) => mGet(`/ztb-supply-chain-service/list/scrap-paper/supply-chain/by/store-id`, params, hconfig) |
||||
|
const getIntentById = (shareEventId) => mGet(`/ztb-supply-chain-service/verify/share-event`, {shareEventId}, hconfig) |
||||
|
|
||||
|
export { |
||||
|
hconfig, |
||||
|
getUserInfo, |
||||
|
getStoreInfo, |
||||
|
getChainList, |
||||
|
getIntentById |
||||
|
} |
||||
@ -0,0 +1,208 @@ |
|||||
|
/** |
||||
|
* Copyright © 2020-present LiuDanYang. All rights Reserved. |
||||
|
*/ |
||||
|
|
||||
|
import axios from "./axios" |
||||
|
const event = require('../utils/event') |
||||
|
const util = require('../utils/util') |
||||
|
const app = getApp() |
||||
|
/** |
||||
|
* axios defaults 配置 |
||||
|
*/ |
||||
|
axios.defaults = { |
||||
|
timeout: 60000 |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 全局 请求拦截器, 支持添加多个拦截器 |
||||
|
* 例如: 配置token、添加一些默认的参数 |
||||
|
* `return config` 继续发送请求 |
||||
|
*/ |
||||
|
axios.interceptors.request.use( |
||||
|
config => { |
||||
|
config.header = { |
||||
|
...config.header, |
||||
|
'X-APP-ID': app.xAppId, |
||||
|
appversion: app.version |
||||
|
} |
||||
|
return config |
||||
|
}, |
||||
|
error => { |
||||
|
// 做一些请求错误
|
||||
|
console.error(error) |
||||
|
return Promise.reject(error) |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
/** |
||||
|
* 全局 响应拦截器, 支持添加多个拦截器 |
||||
|
* 例如: 根据状态码选择性拦截、过滤转换数据 |
||||
|
* @param {Object} res 请求返回的数据 |
||||
|
* @return {Promise<reject>} |
||||
|
*/ |
||||
|
axios.interceptors.response.use( |
||||
|
async (res) => { |
||||
|
const { data, statusCode: status } = res |
||||
|
try { |
||||
|
return await handleResponse({ data, status }) |
||||
|
} catch (err) { |
||||
|
return Promise.reject(err) |
||||
|
} |
||||
|
}, |
||||
|
(err) => { |
||||
|
// 做一些请求错误
|
||||
|
return Promise.reject(err) |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
/** |
||||
|
* 处理 HTTP 状态码 |
||||
|
* @param data {Object} 请求返回的数据 |
||||
|
* @param status {String} HTTP状态码 |
||||
|
* @returns {Promise<never>|*} |
||||
|
*/ |
||||
|
function handleResponse({ data, status }) { |
||||
|
if(!data){ |
||||
|
return Promise.reject('服务器错误') |
||||
|
} |
||||
|
const STATUS = { |
||||
|
"200"() { |
||||
|
if (data.code === 0) { |
||||
|
return Promise.resolve(data) |
||||
|
} |
||||
|
if (data.code === 401 && app.globalData.token) { |
||||
|
app.globalData.token = null |
||||
|
app.userInfo = null |
||||
|
wx.removeStorageSync('Authorization') |
||||
|
event.emit('EventMessage', { what: 888, desc: 'Logout' }) |
||||
|
let pages = getCurrentPages() //当前页面栈
|
||||
|
let prevPage = pages[pages.length - 1] //当前页面
|
||||
|
if (prevPage.route != 'pages/login/index') { |
||||
|
wx.showModal({ |
||||
|
title: '温馨提示', |
||||
|
content: '登录信息已经过期,请重新登录', |
||||
|
showCancel: false, |
||||
|
success: function (res) { |
||||
|
if (res.confirm) { |
||||
|
wx.reLaunch({ url: '/pages/login/index' }) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
var message = '' |
||||
|
if (data.message) { |
||||
|
message = data.message |
||||
|
} |
||||
|
return Promise.reject(message) |
||||
|
} |
||||
|
var message = '数据错误' |
||||
|
if (data.message) { |
||||
|
message = data.message |
||||
|
} |
||||
|
return Promise.reject(message) |
||||
|
}, |
||||
|
"400"() { |
||||
|
return Promise.reject('请求错误') |
||||
|
}, |
||||
|
"401"() { |
||||
|
return Promise.reject('请求未授权') |
||||
|
}, |
||||
|
"403"() { |
||||
|
return Promise.reject('拒绝请求') |
||||
|
}, |
||||
|
"404"() { |
||||
|
return Promise.reject('URL错误') |
||||
|
}, |
||||
|
"500"() { |
||||
|
return Promise.reject('服务器错误') |
||||
|
} |
||||
|
} |
||||
|
// 有状态码但不在这个封装的配置里,就直接返回错误
|
||||
|
return STATUS[status] ? STATUS[status]() : Promise.reject('请求错误') |
||||
|
} |
||||
|
|
||||
|
export default axios |
||||
|
|
||||
|
/** |
||||
|
* get 请求方式 |
||||
|
* @param url {String} 接口地址 |
||||
|
* @param params {Object} 接口参数 |
||||
|
* @returns {AxiosPromise} |
||||
|
* @constructor |
||||
|
*/ |
||||
|
export function mGet(url, params, config) { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
axios.get(url, params, config).then((res) => { |
||||
|
resolve(res) |
||||
|
}).catch(err => { |
||||
|
reject(err) |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* post 请求方式 |
||||
|
* @param url {String} 接口地址 |
||||
|
* @param data {Object} 接口参数 |
||||
|
* @returns {AxiosPromise} |
||||
|
* @constructor |
||||
|
*/ |
||||
|
export function mPost(url, data, config) { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
axios.post(url, data, config).then((res) => { |
||||
|
resolve(res) |
||||
|
}).catch((err) => { |
||||
|
reject(err) |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* put 请求方式-用于修改全部数据 |
||||
|
* @param url {String} 接口地址 |
||||
|
* @param data {Object} 接口参数 |
||||
|
* @returns {AxiosPromise} |
||||
|
* @constructor |
||||
|
*/ |
||||
|
export function mPut(url, data, config) { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
axios.put(url, data, config).then((res) => { |
||||
|
resolve(res) |
||||
|
}).catch((err) => { |
||||
|
reject(err) |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* patch 请求方式-用于修改单项或多项数据 |
||||
|
* @param url {String} 接口地址 |
||||
|
* @param data {Object} 接口参数 |
||||
|
* @returns {AxiosPromise} |
||||
|
* @constructor |
||||
|
*/ |
||||
|
export function mPatch(url, data, config) { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
axios.patch(url, data, config).then((res) => { |
||||
|
resolve(res) |
||||
|
}).catch((err) => { |
||||
|
reject(err) |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* delete 请求方式 |
||||
|
* @param url {String} 接口地址 |
||||
|
* @param params {Object} 接口参数 |
||||
|
* @returns {AxiosPromise} |
||||
|
*/ |
||||
|
export function mDelete(url, params, config) { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
axios.delete(url, params, config).then((res) => { |
||||
|
resolve(res) |
||||
|
}).catch((err) => { |
||||
|
reject(err) |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
@ -0,0 +1,104 @@ |
|||||
|
import { mPost } from "./request" |
||||
|
import { zconfig } from "./ztb" |
||||
|
import { hconfig } from "./chain" |
||||
|
const util = require('../utils/util') |
||||
|
const app = getApp() |
||||
|
const urls = ['https://api-client-uec-dev.qniao.cn', 'https://api-client-uec-test.qniao.cn', 'https://api-client-uec.qniao.cn'] |
||||
|
|
||||
|
const config = { |
||||
|
baseUrl: urls[app.evn] |
||||
|
} |
||||
|
const wechatApplet = (params) => mPost('/uec/authorize/by-oauth2', params, config) |
||||
|
|
||||
|
// ********************** 通过微信的方式登录******************************
|
||||
|
// 通过微信的方式登录,onGotPhoneNumber中统一处理/uec/authorize/by-wechat-applet-mobile
|
||||
|
function gotPhoneNumber(form, resolve, reject) { |
||||
|
wx.request({ |
||||
|
header: { 'X-APP-ID': app.xAppId }, |
||||
|
url: config.baseUrl + '/uec/authorize/by-wechat-applet-mobile', |
||||
|
data: form, |
||||
|
method: 'POST', |
||||
|
success: function (result) { |
||||
|
// 绑定手机号码,进行登录
|
||||
|
wx.hideLoading() |
||||
|
if (result.data.code != 0) { |
||||
|
util.showToast('登录失败,请稍后再试') |
||||
|
reject('登录失败,请稍后再试') |
||||
|
return |
||||
|
} |
||||
|
result.data.tmpAuthToken = form.tmpAuthToken |
||||
|
resolve(result.data) |
||||
|
}, |
||||
|
fail: function (res) { |
||||
|
wx.hideLoading() |
||||
|
util.showToast('登录失败,请稍后再试') |
||||
|
reject('登录失败,请稍后再试') |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
function phoneWechat(form) { |
||||
|
let promise = new Promise(function (resolve, reject) { |
||||
|
if (!form.encryptedData) { |
||||
|
util.showToast('授权被拒绝,登录失败') |
||||
|
reject('授权被拒绝,登录失败') |
||||
|
return |
||||
|
} |
||||
|
wx.showLoading({ title: '登录中', mask: true }) |
||||
|
// 没有获取到openId,获取之后进行登录
|
||||
|
wx.login({ |
||||
|
success: res => { |
||||
|
// 获取openId
|
||||
|
wx.request({ |
||||
|
header: { 'X-APP-ID': app.xAppId }, |
||||
|
url: config.baseUrl + '/uec/authorize/by-oauth2', |
||||
|
data: { authCode: res.code, authMethod: 'WeChatMiniProgram' }, |
||||
|
method: 'POST', |
||||
|
success: function (result) { |
||||
|
if (result.data.code == 0) { |
||||
|
if(result.data.data.tmpAuthToken){ |
||||
|
form.tmpAuthToken = result.data.data.tmpAuthToken |
||||
|
// 获取手机号码
|
||||
|
gotPhoneNumber(form, resolve, reject) |
||||
|
} else if(result.data.data.token){ |
||||
|
wx.hideLoading() |
||||
|
resolve(result.data) |
||||
|
} |
||||
|
} else if (result.data.code == 200101 && result.data.data.tmpAuthToken) { |
||||
|
form.tmpAuthToken = result.data.data.tmpAuthToken |
||||
|
gotPhoneNumber(form, resolve, reject) |
||||
|
} else { |
||||
|
wx.hideLoading() |
||||
|
util.showToast('登录失败,请稍后再试') |
||||
|
reject('登录失败,请稍后再试') |
||||
|
} |
||||
|
}, |
||||
|
fail: function (res) { |
||||
|
wx.hideLoading() |
||||
|
util.showToast('登录失败,请稍后再试') |
||||
|
reject('登录失败,请稍后再试') |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
fail: function (res) { |
||||
|
wx.hideLoading() |
||||
|
util.showToast('登录失败,请稍后再试') |
||||
|
reject('登录失败,请稍后再试') |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
return promise |
||||
|
} |
||||
|
|
||||
|
function finalizeToken(){ |
||||
|
config.header = null |
||||
|
zconfig.header = null |
||||
|
hconfig.header = null |
||||
|
} |
||||
|
|
||||
|
export { |
||||
|
config, |
||||
|
finalizeToken, |
||||
|
wechatApplet, |
||||
|
phoneWechat, |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
import { mGet, mPost } from "./request" |
||||
|
const app = getApp() |
||||
|
const urls = ['https://api-client-ztb-dev.qniao.cn', 'https://api-client-ztb-test.qniao.cn', 'https://api-client-ztb.qniao.cn'] |
||||
|
|
||||
|
const zconfig = { baseUrl: urls[app.evn] } |
||||
|
// ***************************************************************账户业务***********************************************************
|
||||
|
const loginToken = (params) => mPost(`/ztb-user-enterprise-service/authorize/get/product-line-token/by/login-token`, params, zconfig) |
||||
|
const getStationList = (params) => mGet(`/ztb-user-enterprise-service/get/recently-distance/packing-factory-list`, params, zconfig) |
||||
|
const getStationInfo = (params) => mGet(`/ztb-user-enterprise-service/get/packing-factory-detail`, params, zconfig) |
||||
|
const getPaperList = (params) => mGet(`/recycle-service/get/all-paper-category`, params, zconfig) |
||||
|
|
||||
|
export { |
||||
|
zconfig, |
||||
|
loginToken, |
||||
|
getStationList, |
||||
|
getStationInfo, |
||||
|
getPaperList |
||||
|
} |
||||
@ -0,0 +1,76 @@ |
|||||
|
App({ |
||||
|
//----------------------------------------------globalData--------------------------------------
|
||||
|
evn: 1,//0:开发环境,1:测试环境,2:生产环境
|
||||
|
version: 152, |
||||
|
xAppId: '503258978847965400', |
||||
|
nowLocation: null, |
||||
|
nowCity: null, |
||||
|
globalData: { |
||||
|
token: null, |
||||
|
kg: 0 |
||||
|
}, |
||||
|
onShow: function(options) { |
||||
|
if (wx.canIUse('getUpdateManager')) { |
||||
|
const updateManager = wx.getUpdateManager() |
||||
|
updateManager.onCheckForUpdate(function (res) { |
||||
|
// 请求完新版本信息的回调
|
||||
|
if (res.hasUpdate) { |
||||
|
updateManager.onUpdateReady(function () { |
||||
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||
|
updateManager.applyUpdate() |
||||
|
}) |
||||
|
updateManager.onUpdateFailed(function () { |
||||
|
// 新版本下载失败
|
||||
|
wx.showModal({ title: '已有新版本', content: '请您删除小程序,重新搜索进入' }) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} else { |
||||
|
wx.showModal({ title: '溫馨提示', content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' }) |
||||
|
} |
||||
|
if(this.globalData.Custom){ |
||||
|
return |
||||
|
} |
||||
|
// this.onShareMessage()
|
||||
|
wx.getSystemInfo({ |
||||
|
success: e => { |
||||
|
this.globalData.isIos = this.checkIos(e) |
||||
|
this.globalData.dev = e.platform == 'devtools' |
||||
|
|
||||
|
let custom = wx.getMenuButtonBoundingClientRect() |
||||
|
this.globalData.Custom = custom |
||||
|
// 顶部操作栏高度
|
||||
|
this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (this.globalData.isIos ? 4 : 0) |
||||
|
let windowHeight = e.windowHeight * (750 / e.windowWidth) |
||||
|
this.globalData.customHeight = this.globalData.CustomBar * (750 / e.windowWidth) |
||||
|
let safeBottom = e.windowHeight - e.safeArea.bottom |
||||
|
if(safeBottom > e.windowHeight){ |
||||
|
safeBottom = 34 |
||||
|
} |
||||
|
if(this.globalData.isIos){ |
||||
|
this.globalData.safeBottom = safeBottom * (750 / e.windowWidth) |
||||
|
} else { |
||||
|
this.globalData.safeBottom = 0 |
||||
|
} |
||||
|
// 状态栏高度
|
||||
|
this.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth) |
||||
|
let statusBarHeight = this.globalData.CustomBar * (750 / e.windowWidth) |
||||
|
this.globalData.statusBarHeight = statusBarHeight |
||||
|
this.globalData.windowHeight = windowHeight |
||||
|
// fragmentHeight:指的是整个页面statusBarHeight以下的高度
|
||||
|
this.globalData.fragmentHeight = windowHeight - statusBarHeight |
||||
|
this.globalData.safeFragmentHeight = windowHeight - statusBarHeight - this.globalData.safeBottom |
||||
|
this.globalData.windowWidth = e.windowWidth |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
checkIos: function (e) { |
||||
|
if ('ios' === e.platform) { |
||||
|
return true |
||||
|
} |
||||
|
if (e.system.startsWith('iOS')) { |
||||
|
return true |
||||
|
} |
||||
|
return false |
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,30 @@ |
|||||
|
{ |
||||
|
"pages": [ |
||||
|
"pages/login/index", |
||||
|
"pages/merchant/index", |
||||
|
"pages/station/index", |
||||
|
"pages/process/station-create/index", |
||||
|
"pages/process/order-appointment/index", |
||||
|
"pages/process/order-list/index", |
||||
|
"pages/process/order-info/index", |
||||
|
"pages/process/station-info/index", |
||||
|
"pages/process/store-info/index", |
||||
|
"pages/home/city-select/index", |
||||
|
"pages/html/agreement/index" |
||||
|
], |
||||
|
"permission": { |
||||
|
"scope.userLocation": { |
||||
|
"desc": "您的位置信息将用于获取您所在城市的最新纸厂和打包站信息。" |
||||
|
} |
||||
|
}, |
||||
|
"window": { |
||||
|
"navigationBarBackgroundColor": "#FFFFFF", |
||||
|
"navigationBarTitleText": "", |
||||
|
"navigationStyle": "custom", |
||||
|
"navigationBarTextStyle": "black" |
||||
|
}, |
||||
|
"usingComponents": { |
||||
|
"cu-custom": "/colorui/components/cu-custom" |
||||
|
}, |
||||
|
"sitemapLocation": "sitemap.json" |
||||
|
} |
||||
@ -0,0 +1,76 @@ |
|||||
|
@import "colorui/main.wxss"; |
||||
|
@import "colorui/icon.wxss"; |
||||
|
@import 'components/common/index.wxss'; |
||||
|
|
||||
|
/**app.wxss**/ |
||||
|
.scrollPage { |
||||
|
height: 100vh; |
||||
|
} |
||||
|
|
||||
|
.flex-center { |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
|
} |
||||
|
|
||||
|
.flex-column { |
||||
|
-webkit-box-orient: vertical; |
||||
|
-webkit-flex-direction: column; |
||||
|
-ms-flex-direction: column; |
||||
|
flex-direction: column; |
||||
|
} |
||||
|
|
||||
|
.flex-justify { |
||||
|
align-items: center; |
||||
|
-webkit-box-pack: justify; |
||||
|
-webkit-justify-content: space-between; |
||||
|
-ms-flex-pack: justify; |
||||
|
justify-content: space-between; |
||||
|
} |
||||
|
|
||||
|
.weui_goback { |
||||
|
font-size: 28rpx; |
||||
|
width: 1em; |
||||
|
height: 2em; |
||||
|
-webkit-mask: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E") no-repeat 50% 50%; |
||||
|
mask: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E") no-repeat 50% 50%; |
||||
|
-webkit-mask-size: cover; |
||||
|
mask-size: cover; |
||||
|
background-color: currentColor |
||||
|
} |
||||
|
|
||||
|
.weui_goback:active { |
||||
|
opacity: .5 |
||||
|
} |
||||
|
|
||||
|
.solid-bottom, |
||||
|
.solid-bottom::after { |
||||
|
border-bottom: 1rpx solid #f3f3ff; |
||||
|
} |
||||
|
|
||||
|
.wux-close { |
||||
|
width: 100%; |
||||
|
text-align: end; |
||||
|
display: inline-block; |
||||
|
padding-bottom: 24rpx; |
||||
|
} |
||||
|
|
||||
|
.wux-landscape{ |
||||
|
width: 100%; |
||||
|
max-width: 750rpx; |
||||
|
} |
||||
|
|
||||
|
.wux-landscape__popup { |
||||
|
background-color: transparent!important |
||||
|
} |
||||
|
|
||||
|
.wux-landscape__popup-body { |
||||
|
padding: 0!important |
||||
|
} |
||||
|
.wux-landscape__inner { |
||||
|
line-height: 1.5; |
||||
|
color: rgba(0,0,0,.65) |
||||
|
} |
||||
|
.wux-landscape__inner > image { |
||||
|
width: 100%; |
||||
|
max-width: 100% |
||||
|
} |
||||
@ -0,0 +1,100 @@ |
|||||
|
const event = require('../../utils/event') |
||||
|
const app = getApp() |
||||
|
|
||||
|
Component({ |
||||
|
/** |
||||
|
* 组件的一些选项 |
||||
|
*/ |
||||
|
options: { |
||||
|
addGlobalClass: true, |
||||
|
multipleSlots: true |
||||
|
}, |
||||
|
/** |
||||
|
* 组件的对外属性 |
||||
|
*/ |
||||
|
properties: { |
||||
|
bgColor: { |
||||
|
type: String, |
||||
|
default: '' |
||||
|
}, |
||||
|
isCustom: { |
||||
|
type: [Boolean, String], |
||||
|
default: false |
||||
|
}, |
||||
|
isBack: { |
||||
|
type: [Boolean, String], |
||||
|
default: false |
||||
|
}, |
||||
|
shadow: { |
||||
|
type: Boolean, |
||||
|
default: false |
||||
|
}, |
||||
|
intercept: { |
||||
|
type: Boolean, |
||||
|
default: false |
||||
|
}, |
||||
|
bgImage: { |
||||
|
type: String, |
||||
|
default: '' |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 组件的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
StatusBar: app.globalData.StatusBar, |
||||
|
CustomBar: app.globalData.CustomBar, |
||||
|
Custom: app.globalData.Custom |
||||
|
}, |
||||
|
lifetimes: { |
||||
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||||
|
attached: function () { |
||||
|
if(app.globalData.Custom){ |
||||
|
this.setData({ |
||||
|
StatusBar: app.globalData.StatusBar || 40, |
||||
|
CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 60), |
||||
|
Custom: app.globalData.Custom |
||||
|
}) |
||||
|
} else { |
||||
|
event.on('InitMessage', this, this.onEvent) |
||||
|
} |
||||
|
}, |
||||
|
detached: function(){ |
||||
|
if(!app.globalData.Custom){ |
||||
|
event.remove('InitMessage', this) |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 组件的方法列表 |
||||
|
*/ |
||||
|
methods: { |
||||
|
backspace() { |
||||
|
if (this.data.intercept) { |
||||
|
this.triggerEvent('customevent', null) |
||||
|
return |
||||
|
} |
||||
|
if (getCurrentPages().length == 1) { |
||||
|
this.toHome() |
||||
|
} else { |
||||
|
wx.navigateBack() |
||||
|
} |
||||
|
}, |
||||
|
onEvent: function(message){ |
||||
|
if (message.what == 8) { |
||||
|
this.setData({ |
||||
|
StatusBar: app.globalData.StatusBar || 40, |
||||
|
CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 80), |
||||
|
Custom: app.globalData.Custom |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
toHome() { |
||||
|
if (app.userInfo && app.userInfo.userId) { |
||||
|
wx.redirectTo({ url: '/pages/index/index' }) |
||||
|
} else { |
||||
|
wx.reLaunch({ url: '/pages/login/index' }) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,4 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": {} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
<view class="cu-custom" style="height:{{CustomBar}}px;z-index: 99;"> |
||||
|
<view class="cu-bar fixed {{bgColor}}" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}rpx;"> |
||||
|
<view class="action" bindtap="backspace" wx:if="{{isBack}}"> |
||||
|
<text class="weui_goback"></text> |
||||
|
<slot name="backText"></slot> |
||||
|
</view> |
||||
|
<view class="action border-custom" wx:if="{{isCustom}}" style="width:{{Custom.width}}px;height:{{Custom.height}}px;margin-left:calc(750rpx - {{Custom.right}}px)"> |
||||
|
<text class="cuIcon-back" bindtap="backspace"></text> |
||||
|
<text class="cuIcon-homefill" bindtap="toHome"></text> |
||||
|
</view> |
||||
|
<view class="content" style="top:{{StatusBar}}rpx;color:black;font-size:36rpx"> |
||||
|
<slot name="content"></slot> |
||||
|
</view> |
||||
|
<slot name="right"></slot> |
||||
|
</view> |
||||
|
</view> |
||||
@ -0,0 +1,5 @@ |
|||||
|
/* colorui/components/cu-custom.wxss */ |
||||
|
.shadow{ |
||||
|
box-shadow: 0 0rpx 0rpx rgba(0, 0, 0, 0.04) |
||||
|
} |
||||
|
|
||||
1226
colorui/icon.wxss
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1129
colorui/main.wxss
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,62 @@ |
|||||
|
import { VantComponent } from '../common/component'; |
||||
|
import { button } from '../mixins/button'; |
||||
|
import { openType } from '../mixins/open-type'; |
||||
|
VantComponent({ |
||||
|
mixins: [button, openType], |
||||
|
props: { |
||||
|
show: Boolean, |
||||
|
title: String, |
||||
|
cancelText: String, |
||||
|
description: String, |
||||
|
round: { |
||||
|
type: Boolean, |
||||
|
value: true |
||||
|
}, |
||||
|
zIndex: { |
||||
|
type: Number, |
||||
|
value: 100 |
||||
|
}, |
||||
|
actions: { |
||||
|
type: Array, |
||||
|
value: [] |
||||
|
}, |
||||
|
overlay: { |
||||
|
type: Boolean, |
||||
|
value: true |
||||
|
}, |
||||
|
closeOnClickOverlay: { |
||||
|
type: Boolean, |
||||
|
value: true |
||||
|
}, |
||||
|
closeOnClickAction: { |
||||
|
type: Boolean, |
||||
|
value: true |
||||
|
}, |
||||
|
safeAreaInsetBottom: { |
||||
|
type: Boolean, |
||||
|
value: true |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
onSelect(event) { |
||||
|
const { index } = event.currentTarget.dataset; |
||||
|
const item = this.data.actions[index]; |
||||
|
if (item && !item.disabled && !item.loading) { |
||||
|
this.$emit('select', item); |
||||
|
if (this.data.closeOnClickAction) { |
||||
|
this.onClose(); |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
onCancel() { |
||||
|
this.$emit('cancel'); |
||||
|
}, |
||||
|
onClose() { |
||||
|
this.$emit('close'); |
||||
|
}, |
||||
|
onClickOverlay() { |
||||
|
this.$emit('click-overlay'); |
||||
|
this.onClose(); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": { |
||||
|
"van-icon": "../icon/index", |
||||
|
"van-popup": "../popup/index", |
||||
|
"van-loading": "../loading/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
<wxs src="../wxs/utils.wxs" module="utils" /> |
||||
|
|
||||
|
<van-popup show="{{ show }}" position="bottom" round="{{ round }}" z-index="{{ zIndex }}" overlay="{{ overlay }}" |
||||
|
custom-class="van-action-sheet" safe-area-inset-bottom="{{ safeAreaInsetBottom }}" |
||||
|
close-on-click-overlay="{{ closeOnClickOverlay }}" bind:close="onClickOverlay"> |
||||
|
<view wx:if="{{ title }}" class="van-hairline--bottom van-action-sheet__header"> |
||||
|
{{ title }} |
||||
|
<van-icon name="close" custom-class="van-action-sheet__close" bind:click="onClose" /> |
||||
|
</view> |
||||
|
<view wx:if="{{ description }}" class="van-action-sheet__description">{{ description }}</view> |
||||
|
<view wx:if="{{ actions && actions.length }}"> |
||||
|
<!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 --> |
||||
|
<button wx:for="{{ actions }}" wx:key="index" open-type="{{ item.openType }}" |
||||
|
style="{{ item.color ? 'color: ' + item.color : '' }}" |
||||
|
class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} van-hairline--top {{ item.className || '' }}" |
||||
|
hover-class="van-action-sheet__item--hover" data-index="{{ index }}" bind:tap="onSelect" |
||||
|
bindgetuserinfo="bindGetUserInfo" bindcontact="bindContact" bindgetphonenumber="bindGetPhoneNumber" |
||||
|
binderror="bindError" bindlaunchapp="bindLaunchApp" bindopensetting="bindOpenSetting" lang="{{ lang }}" |
||||
|
session-from="{{ sessionFrom }}" send-message-title="{{ sendMessageTitle }}" |
||||
|
send-message-path="{{ sendMessagePath }}" send-message-img="{{ sendMessageImg }}" |
||||
|
show-message-card="{{ showMessageCard }}" app-parameter="{{ appParameter }}"> |
||||
|
<block wx:if="{{ !item.loading }}"> |
||||
|
{{ item.name }} |
||||
|
<text wx:if="{{ item.subname }}" class="van-action-sheet__subname">{{ item.subname }}</text> |
||||
|
</block> |
||||
|
<van-loading wx:else custom-class="van-action-sheet__loading" size="20px" /> |
||||
|
</button> |
||||
|
</view> |
||||
|
<slot /> |
||||
|
<view wx:if="{{ cancelText }}" class="van-action-sheet__cancel" hover-class="van-action-sheet__cancel--hover" |
||||
|
hover-stay-time="70" bind:tap="onCancel"> |
||||
|
{{ cancelText }} |
||||
|
</view> |
||||
|
</van-popup> |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;max-height:var(--action-sheet-max-height,90%)!important;color:#323233;color:var(--action-sheet-item-text-color,#323233)}.van-action-sheet__cancel,.van-action-sheet__item{text-align:center;font-size:16px;font-size:var(--action-sheet-item-font-size,16px);line-height:50px;line-height:var(--action-sheet-item-height,50px);background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-action-sheet__cancel:before{display:block;content:" ";height:8px;height:var(--action-sheet-cancel-padding-top,8px);background-color:#f7f8fa;background-color:var(--action-sheet-cancel-padding-color,#f7f8fa)}.van-action-sheet__item--disabled{color:#c8c9cc;color:var(--action-sheet-item-disabled-text-color,#c8c9cc)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{margin-left:4px;margin-left:var(--padding-base,4px);font-size:12px;font-size:var(--action-sheet-subname-font-size,12px);color:#646566;color:var(--action-sheet-subname-color,#646566)}.van-action-sheet__header{text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--action-sheet-header-font-size,16px);line-height:44px;line-height:var(--action-sheet-header-height,44px)}.van-action-sheet__description{text-align:center;padding:16px;padding:var(--padding-md,16px);color:#646566;color:var(--action-sheet-description-color,#646566);font-size:14px;font-size:var(--action-sheet-description-font-size,14px);line-height:20px;line-height:var(--action-sheet-description-line-height,20px)}.van-action-sheet__close{position:absolute!important;top:0;right:0;line-height:inherit!important;padding:0 12px;padding:var(--action-sheet-close-icon-padding,0 12px);font-size:18px!important;font-size:var(--action-sheet-close-icon-size,18px)!important;color:#969799;color:var(--action-sheet-close-icon-color,#969799)}.van-action-sheet__loading{display:-webkit-flex!important;display:flex!important;height:50px;height:var(--action-sheet-item-height,50px)} |
||||
@ -0,0 +1,383 @@ |
|||||
|
import baseComponent from '../helpers/baseComponent' |
||||
|
import styleToCssString from '../helpers/styleToCssString' |
||||
|
|
||||
|
const ENTER = 'enter' |
||||
|
const ENTERING = 'entering' |
||||
|
const ENTERED = 'entered' |
||||
|
const EXIT = 'exit' |
||||
|
const EXITING = 'exiting' |
||||
|
const EXITED = 'exited' |
||||
|
const UNMOUNTED = 'unmounted' |
||||
|
|
||||
|
const TRANSITION = 'transition' |
||||
|
const ANIMATION = 'animation' |
||||
|
|
||||
|
const TIMEOUT = 1000 / 60 |
||||
|
|
||||
|
const defaultClassNames = { |
||||
|
enter: '', // 进入过渡的开始状态,在过渡过程完成之后移除
|
||||
|
enterActive: '', // 进入过渡的结束状态,在过渡过程完成之后移除
|
||||
|
enterDone: '', // 进入过渡的完成状态
|
||||
|
exit: '', // 离开过渡的开始状态,在过渡过程完成之后移除
|
||||
|
exitActive: '', // 离开过渡的结束状态,在过渡过程完成之后移除
|
||||
|
exitDone: '', // 离开过渡的完成状态
|
||||
|
} |
||||
|
|
||||
|
baseComponent({ |
||||
|
properties: { |
||||
|
// 触发组件进入或离开过渡的状态
|
||||
|
in: { |
||||
|
type: Boolean, |
||||
|
value: false, |
||||
|
observer(newVal) { |
||||
|
if (this.data.isMounting) { |
||||
|
this.updated(newVal) |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
// 过渡的类名
|
||||
|
classNames: { |
||||
|
type: null, |
||||
|
value: defaultClassNames, |
||||
|
}, |
||||
|
// 过渡持续时间
|
||||
|
duration: { |
||||
|
type: null, |
||||
|
value: null, |
||||
|
}, |
||||
|
// 过渡动效的类型
|
||||
|
type: { |
||||
|
type: String, |
||||
|
value: TRANSITION, |
||||
|
}, |
||||
|
// 首次挂载时是否触发进入过渡
|
||||
|
appear: { |
||||
|
type: Boolean, |
||||
|
value: false, |
||||
|
}, |
||||
|
// 是否启用进入过渡
|
||||
|
enter: { |
||||
|
type: Boolean, |
||||
|
value: true, |
||||
|
}, |
||||
|
// 是否启用离开过渡
|
||||
|
exit: { |
||||
|
type: Boolean, |
||||
|
value: true, |
||||
|
}, |
||||
|
// 首次进入过渡时是否懒挂载组件
|
||||
|
mountOnEnter: { |
||||
|
type: Boolean, |
||||
|
value: true, |
||||
|
}, |
||||
|
// 离开过渡完成时是否卸载组件
|
||||
|
unmountOnExit: { |
||||
|
type: Boolean, |
||||
|
value: true, |
||||
|
}, |
||||
|
// 自定义类名
|
||||
|
wrapCls: { |
||||
|
type: String, |
||||
|
value: '', |
||||
|
}, |
||||
|
// 自定义样式
|
||||
|
wrapStyle: { |
||||
|
type: [String, Object], |
||||
|
value: '', |
||||
|
observer(newVal) { |
||||
|
this.setData({ |
||||
|
extStyle: styleToCssString(newVal), |
||||
|
}) |
||||
|
}, |
||||
|
}, |
||||
|
disableScroll: { |
||||
|
type: Boolean, |
||||
|
value: false, |
||||
|
}, |
||||
|
}, |
||||
|
data: { |
||||
|
animateCss: '', // 动画样式
|
||||
|
animateStatus: EXITED, // 动画状态,可选值 entering、entered、exiting、exited
|
||||
|
isMounting: false, // 是否首次挂载
|
||||
|
extStyle: '', // 组件样式
|
||||
|
}, |
||||
|
methods: { |
||||
|
/** |
||||
|
* 监听过渡或动画的回调函数 |
||||
|
*/ |
||||
|
addEventListener() { |
||||
|
const { animateStatus } = this.data |
||||
|
const { enter, exit } = this.getTimeouts() |
||||
|
|
||||
|
if (animateStatus === ENTERING && !enter && this.data.enter) { |
||||
|
this.performEntered() |
||||
|
} |
||||
|
|
||||
|
if (animateStatus === EXITING && !exit && this.data.exit) { |
||||
|
this.performExited() |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 会在 WXSS transition 或 wx.createAnimation 动画结束后触发 |
||||
|
*/ |
||||
|
onTransitionEnd() { |
||||
|
if (this.data.type === TRANSITION) { |
||||
|
this.addEventListener() |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 会在一个 WXSS animation 动画完成时触发 |
||||
|
*/ |
||||
|
onAnimationEnd() { |
||||
|
if (this.data.type === ANIMATION) { |
||||
|
this.addEventListener() |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 更新组件状态 |
||||
|
* @param {String} nextStatus 下一状态,ENTERING 或 EXITING |
||||
|
* @param {Boolean} mounting 是否首次挂载 |
||||
|
*/ |
||||
|
updateStatus(nextStatus, mounting = false) { |
||||
|
if (nextStatus !== null) { |
||||
|
this.cancelNextCallback() |
||||
|
this.isAppearing = mounting |
||||
|
|
||||
|
if (nextStatus === ENTERING) { |
||||
|
this.performEnter() |
||||
|
} else { |
||||
|
this.performExit() |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 进入过渡 |
||||
|
*/ |
||||
|
performEnter() { |
||||
|
const { className, activeClassName } = this.getClassNames(ENTER) |
||||
|
const { enter } = this.getTimeouts() |
||||
|
const enterParams = { |
||||
|
animateStatus: ENTER, |
||||
|
animateCss: className, |
||||
|
} |
||||
|
const enteringParams = { |
||||
|
animateStatus: ENTERING, |
||||
|
animateCss: `${className} ${activeClassName}`, |
||||
|
} |
||||
|
|
||||
|
// 若已禁用进入过渡,则更新状态至 ENTERED
|
||||
|
if (!this.isAppearing && !this.data.enter) { |
||||
|
return this.performEntered() |
||||
|
} |
||||
|
|
||||
|
// 第一阶段:设置进入过渡的开始状态,并触发 ENTER 事件
|
||||
|
// 第二阶段:延迟一帧后,设置进入过渡的结束状态,并触发 ENTERING 事件
|
||||
|
// 第三阶段:若已设置过渡的持续时间,则延迟指定时间后触发进入过渡完成 performEntered,否则等待触发 onTransitionEnd 或 onAnimationEnd
|
||||
|
this.safeSetData(enterParams, () => { |
||||
|
this.triggerEvent('change', { animateStatus: ENTER }) |
||||
|
this.triggerEvent(ENTER, { isAppearing: this.isAppearing }) |
||||
|
|
||||
|
// 由于有些时候不能正确的触发动画完成的回调,具体原因未知
|
||||
|
// 所以采用延迟一帧的方式来确保可以触发回调
|
||||
|
this.delayHandler(TIMEOUT, () => { |
||||
|
this.safeSetData(enteringParams, () => { |
||||
|
this.triggerEvent('change', { animateStatus: ENTERING }) |
||||
|
this.triggerEvent(ENTERING, { isAppearing: this.isAppearing }) |
||||
|
|
||||
|
if (enter) { |
||||
|
this.delayHandler(enter, this.performEntered) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
|
}, |
||||
|
/** |
||||
|
* 进入过渡完成 |
||||
|
*/ |
||||
|
performEntered() { |
||||
|
const { doneClassName } = this.getClassNames(ENTER) |
||||
|
const enteredParams = { |
||||
|
animateStatus: ENTERED, |
||||
|
animateCss: doneClassName, |
||||
|
} |
||||
|
|
||||
|
// 第三阶段:设置进入过渡的完成状态,并触发 ENTERED 事件
|
||||
|
this.safeSetData(enteredParams, () => { |
||||
|
this.triggerEvent('change', { animateStatus: ENTERED }) |
||||
|
this.triggerEvent(ENTERED, { isAppearing: this.isAppearing }) |
||||
|
}) |
||||
|
}, |
||||
|
/** |
||||
|
* 离开过渡 |
||||
|
*/ |
||||
|
performExit() { |
||||
|
const { className, activeClassName } = this.getClassNames(EXIT) |
||||
|
const { exit } = this.getTimeouts() |
||||
|
const exitParams = { |
||||
|
animateStatus: EXIT, |
||||
|
animateCss: className, |
||||
|
} |
||||
|
const exitingParams = { |
||||
|
animateStatus: EXITING, |
||||
|
animateCss: `${className} ${activeClassName}`, |
||||
|
} |
||||
|
|
||||
|
// 若已禁用离开过渡,则更新状态至 EXITED
|
||||
|
if (!this.data.exit) { |
||||
|
return this.performExited() |
||||
|
} |
||||
|
|
||||
|
// 第一阶段:设置离开过渡的开始状态,并触发 EXIT 事件
|
||||
|
// 第二阶段:延迟一帧后,设置离开过渡的结束状态,并触发 EXITING 事件
|
||||
|
// 第三阶段:若已设置过渡的持续时间,则延迟指定时间后触发离开过渡完成 performExited,否则等待触发 onTransitionEnd 或 onAnimationEnd
|
||||
|
this.safeSetData(exitParams, () => { |
||||
|
this.triggerEvent('change', { animateStatus: EXIT }) |
||||
|
this.triggerEvent(EXIT) |
||||
|
|
||||
|
this.delayHandler(TIMEOUT, () => { |
||||
|
this.safeSetData(exitingParams, () => { |
||||
|
this.triggerEvent('change', { animateStatus: EXITING }) |
||||
|
this.triggerEvent(EXITING) |
||||
|
|
||||
|
if (exit) { |
||||
|
this.delayHandler(exit, this.performExited) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
|
}, |
||||
|
/** |
||||
|
* 离开过渡完成 |
||||
|
*/ |
||||
|
performExited() { |
||||
|
const { doneClassName } = this.getClassNames(EXIT) |
||||
|
const exitedParams = { |
||||
|
animateStatus: EXITED, |
||||
|
animateCss: doneClassName, |
||||
|
} |
||||
|
|
||||
|
// 第三阶段:设置离开过渡的完成状态,并触发 EXITED 事件
|
||||
|
this.safeSetData(exitedParams, () => { |
||||
|
this.triggerEvent('change', { animateStatus: EXITED }) |
||||
|
this.triggerEvent(EXITED) |
||||
|
|
||||
|
// 判断离开过渡完成时是否卸载组件
|
||||
|
if (this.data.unmountOnExit) { |
||||
|
this.setData({ animateStatus: UNMOUNTED }, () => { |
||||
|
this.triggerEvent('change', { animateStatus: UNMOUNTED }) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
/** |
||||
|
* 获取指定状态下的类名 |
||||
|
* @param {String} type 过渡类型,enter 或 exit |
||||
|
*/ |
||||
|
getClassNames(type) { |
||||
|
const { classNames } = this.data |
||||
|
const className = typeof classNames !== 'string' ? classNames[type] : `${classNames}-${type}` |
||||
|
const activeClassName = typeof classNames !== 'string' ? classNames[`${type}Active`] : `${classNames}-${type}-active` |
||||
|
const doneClassName = typeof classNames !== 'string' ? classNames[`${type}Done`] : `${classNames}-${type}-done` |
||||
|
|
||||
|
return { |
||||
|
className, |
||||
|
activeClassName, |
||||
|
doneClassName, |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 获取过渡持续时间 |
||||
|
*/ |
||||
|
getTimeouts() { |
||||
|
const { duration } = this.data |
||||
|
|
||||
|
if (duration !== null && typeof duration === 'object') { |
||||
|
return { |
||||
|
enter: duration.enter, |
||||
|
exit: duration.exit, |
||||
|
} |
||||
|
} else if (typeof duration === 'number') { |
||||
|
return { |
||||
|
enter: duration, |
||||
|
exit: duration, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return {} |
||||
|
}, |
||||
|
/** |
||||
|
* 属性值 in 被更改时的响应函数 |
||||
|
* @param {Boolean} newVal 触发组件进入或离开过渡的状态 |
||||
|
*/ |
||||
|
updated(newVal) { |
||||
|
let { animateStatus } = this.pendingData || this.data |
||||
|
let nextStatus = null |
||||
|
|
||||
|
if (newVal) { |
||||
|
if (animateStatus === UNMOUNTED) { |
||||
|
animateStatus = EXITED |
||||
|
this.setData({ animateStatus: EXITED }, () => { |
||||
|
this.triggerEvent('change', { animateStatus: EXITED }) |
||||
|
}) |
||||
|
} |
||||
|
if (animateStatus !== ENTER && animateStatus !== ENTERING && animateStatus !== ENTERED) { |
||||
|
nextStatus = ENTERING |
||||
|
} |
||||
|
} else { |
||||
|
if (animateStatus === ENTER || animateStatus === ENTERING || animateStatus === ENTERED) { |
||||
|
nextStatus = EXITING |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
this.updateStatus(nextStatus) |
||||
|
}, |
||||
|
/** |
||||
|
* 延迟一段时间触发回调 |
||||
|
* @param {Number} timeout 延迟时间 |
||||
|
* @param {Function} handler 回调函数 |
||||
|
*/ |
||||
|
delayHandler(timeout, handler) { |
||||
|
if (timeout) { |
||||
|
this.setNextCallback(handler) |
||||
|
setTimeout(this.nextCallback, timeout) |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 点击事件 |
||||
|
*/ |
||||
|
onTap() { |
||||
|
this.triggerEvent('click') |
||||
|
}, |
||||
|
/** |
||||
|
* 阻止移动触摸 |
||||
|
*/ |
||||
|
noop() { |
||||
|
}, |
||||
|
}, |
||||
|
attached() { |
||||
|
let animateStatus = null |
||||
|
let appearStatus = null |
||||
|
|
||||
|
if (this.data.in) { |
||||
|
if (this.data.appear) { |
||||
|
animateStatus = EXITED |
||||
|
appearStatus = ENTERING |
||||
|
} else { |
||||
|
animateStatus = ENTERED |
||||
|
} |
||||
|
} else { |
||||
|
if (this.data.unmountOnExit || this.data.mountOnEnter) { |
||||
|
animateStatus = UNMOUNTED |
||||
|
} else { |
||||
|
animateStatus = EXITED |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 由于小程序组件首次挂载时 observer 事件总是优先于 attached 事件
|
||||
|
// 所以使用 isMounting 来强制优先触发 attached 事件
|
||||
|
this.safeSetData({ animateStatus, isMounting: true }, () => { |
||||
|
this.triggerEvent('change', { animateStatus }) |
||||
|
this.updateStatus(appearStatus, true) |
||||
|
}) |
||||
|
}, |
||||
|
}) |
||||
@ -0,0 +1,3 @@ |
|||||
|
{ |
||||
|
"component": true |
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
<view class="wux-class {{ wrapCls }} {{ animateCss }}" catchtap="onTap" |
||||
|
catchtouchmove="{{ disableScroll ? 'onTap' : '' }}" bindtransitionend="onTransitionEnd" |
||||
|
bindanimationend="onAnimationEnd" wx:if="{{ animateStatus !== 'unmounted' }}" style="{{ extStyle }}"> |
||||
|
<slot></slot> |
||||
|
</view> |
||||
@ -0,0 +1,206 @@ |
|||||
|
.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,210 @@ |
|||||
|
import { VantComponent } from '../common/component'; |
||||
|
import { pickerProps } from '../picker/shared'; |
||||
|
const COLUMNSPLACEHOLDERCODE = '000000'; |
||||
|
VantComponent({ |
||||
|
classes: ['active-class', 'toolbar-class', 'column-class'], |
||||
|
props: Object.assign(Object.assign({}, pickerProps), { value: { |
||||
|
type: String, |
||||
|
observer(value) { |
||||
|
this.code = value; |
||||
|
this.setValues(); |
||||
|
}, |
||||
|
}, areaList: { |
||||
|
type: Object, |
||||
|
value: {}, |
||||
|
observer: 'setValues' |
||||
|
}, columnsNum: { |
||||
|
type: null, |
||||
|
value: 3, |
||||
|
observer(value) { |
||||
|
this.setData({ |
||||
|
displayColumns: this.data.columns.slice(0, +value) |
||||
|
}); |
||||
|
} |
||||
|
}, columnsPlaceholder: { |
||||
|
type: Array, |
||||
|
observer(val) { |
||||
|
this.setData({ |
||||
|
typeToColumnsPlaceholder: { |
||||
|
province: val[0] || '', |
||||
|
city: val[1] || '', |
||||
|
county: val[2] || '', |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} }), |
||||
|
data: { |
||||
|
columns: [{ values: [] }, { values: [] }, { values: [] }], |
||||
|
displayColumns: [{ values: [] }, { values: [] }, { values: [] }], |
||||
|
typeToColumnsPlaceholder: {} |
||||
|
}, |
||||
|
mounted() { |
||||
|
setTimeout(() => { |
||||
|
this.setValues(); |
||||
|
}, 0); |
||||
|
}, |
||||
|
methods: { |
||||
|
getPicker() { |
||||
|
if (this.picker == null) { |
||||
|
this.picker = this.selectComponent('.van-area__picker'); |
||||
|
} |
||||
|
return this.picker; |
||||
|
}, |
||||
|
onCancel(event) { |
||||
|
this.emit('cancel', event.detail); |
||||
|
}, |
||||
|
onConfirm(event) { |
||||
|
const { index } = event.detail; |
||||
|
let { value } = event.detail; |
||||
|
value = this.parseOutputValues(value); |
||||
|
this.emit('confirm', { value, index }); |
||||
|
}, |
||||
|
emit(type, detail) { |
||||
|
detail.values = detail.value; |
||||
|
delete detail.value; |
||||
|
this.$emit(type, detail); |
||||
|
}, |
||||
|
// parse output columns data
|
||||
|
parseOutputValues(values) { |
||||
|
const { columnsPlaceholder } = this.data; |
||||
|
return values.map((value, index) => { |
||||
|
// save undefined value
|
||||
|
if (!value) |
||||
|
return value; |
||||
|
value = JSON.parse(JSON.stringify(value)); |
||||
|
if (!value.code || value.name === columnsPlaceholder[index]) { |
||||
|
value.code = ''; |
||||
|
value.name = ''; |
||||
|
} |
||||
|
return value; |
||||
|
}); |
||||
|
}, |
||||
|
onChange(event) { |
||||
|
const { index, picker, value } = event.detail; |
||||
|
this.code = value[index].code; |
||||
|
this.setValues().then(() => { |
||||
|
this.$emit('change', { |
||||
|
picker, |
||||
|
values: this.parseOutputValues(picker.getValues()), |
||||
|
index |
||||
|
}); |
||||
|
}); |
||||
|
}, |
||||
|
getConfig(type) { |
||||
|
const { areaList } = this.data; |
||||
|
return (areaList && areaList[`${type}_list`]) || {}; |
||||
|
}, |
||||
|
getList(type, code) { |
||||
|
const { typeToColumnsPlaceholder } = this.data; |
||||
|
let result = []; |
||||
|
if (type !== 'province' && !code) { |
||||
|
return result; |
||||
|
} |
||||
|
const list = this.getConfig(type); |
||||
|
result = Object.keys(list).map(code => ({ |
||||
|
code, |
||||
|
name: list[code] |
||||
|
})); |
||||
|
if (code) { |
||||
|
// oversea code
|
||||
|
if (code[0] === '9' && type === 'city') { |
||||
|
code = '9'; |
||||
|
} |
||||
|
result = result.filter(item => item.code.indexOf(code) === 0); |
||||
|
} |
||||
|
if (typeToColumnsPlaceholder[type] && result.length) { |
||||
|
// set columns placeholder
|
||||
|
const codeFill = type === 'province' ? '' : type === 'city' ? COLUMNSPLACEHOLDERCODE.slice(2, 4) : COLUMNSPLACEHOLDERCODE.slice(4, 6); |
||||
|
result.unshift({ |
||||
|
code: `${code}${codeFill}`, |
||||
|
name: typeToColumnsPlaceholder[type] |
||||
|
}); |
||||
|
} |
||||
|
return result; |
||||
|
}, |
||||
|
getIndex(type, code) { |
||||
|
let compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6; |
||||
|
const list = this.getList(type, code.slice(0, compareNum - 2)); |
||||
|
// oversea code
|
||||
|
if (code[0] === '9' && type === 'province') { |
||||
|
compareNum = 1; |
||||
|
} |
||||
|
code = code.slice(0, compareNum); |
||||
|
for (let i = 0; i < list.length; i++) { |
||||
|
if (list[i].code.slice(0, compareNum) === code) { |
||||
|
return i; |
||||
|
} |
||||
|
} |
||||
|
return 0; |
||||
|
}, |
||||
|
setValues() { |
||||
|
const county = this.getConfig('county'); |
||||
|
let { code } = this; |
||||
|
if (!code) { |
||||
|
if (this.data.columnsPlaceholder.length) { |
||||
|
code = COLUMNSPLACEHOLDERCODE; |
||||
|
} |
||||
|
else if (Object.keys(county)[0]) { |
||||
|
code = Object.keys(county)[0]; |
||||
|
} |
||||
|
else { |
||||
|
code = ''; |
||||
|
} |
||||
|
} |
||||
|
const province = this.getList('province'); |
||||
|
const city = this.getList('city', code.slice(0, 2)); |
||||
|
const picker = this.getPicker(); |
||||
|
if (!picker) { |
||||
|
return; |
||||
|
} |
||||
|
const stack = []; |
||||
|
stack.push(picker.setColumnValues(0, province, false)); |
||||
|
stack.push(picker.setColumnValues(1, city, false)); |
||||
|
if (city.length && code.slice(2, 4) === '00') { |
||||
|
[{ code }] = city; |
||||
|
} |
||||
|
stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false)); |
||||
|
return Promise.all(stack) |
||||
|
.catch(() => { }) |
||||
|
.then(() => picker.setIndexes([ |
||||
|
this.getIndex('province', code), |
||||
|
this.getIndex('city', code), |
||||
|
this.getIndex('county', code) |
||||
|
])) |
||||
|
.catch(() => { }); |
||||
|
}, |
||||
|
getValues() { |
||||
|
const picker = this.getPicker(); |
||||
|
return picker ? picker.getValues().filter(value => !!value) : []; |
||||
|
}, |
||||
|
getDetail() { |
||||
|
const values = this.getValues(); |
||||
|
const area = { |
||||
|
code: '', |
||||
|
country: '', |
||||
|
province: '', |
||||
|
city: '', |
||||
|
county: '' |
||||
|
}; |
||||
|
if (!values.length) { |
||||
|
return area; |
||||
|
} |
||||
|
const names = values.map((item) => item.name); |
||||
|
area.code = values[values.length - 1].code; |
||||
|
if (area.code[0] === '9') { |
||||
|
area.country = names[1] || ''; |
||||
|
area.province = names[2] || ''; |
||||
|
} |
||||
|
else { |
||||
|
area.province = names[0] || ''; |
||||
|
area.city = names[1] || ''; |
||||
|
area.county = names[2] || ''; |
||||
|
} |
||||
|
return area; |
||||
|
}, |
||||
|
reset(code) { |
||||
|
this.code = code || ''; |
||||
|
return this.setValues(); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": { |
||||
|
"van-picker": "../picker/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
<van-picker |
||||
|
class="van-area__picker" |
||||
|
active-class="active-class" |
||||
|
toolbar-class="toolbar-class" |
||||
|
column-class="column-class" |
||||
|
show-toolbar |
||||
|
value-key="name" |
||||
|
title="{{ title }}" |
||||
|
loading="{{ loading }}" |
||||
|
columns="{{ displayColumns }}" |
||||
|
item-height="{{ itemHeight }}" |
||||
|
visible-item-count="{{ visibleItemCount }}" |
||||
|
cancel-button-text="{{ cancelButtonText }}" |
||||
|
confirm-button-text="{{ confirmButtonText }}" |
||||
|
bind:change="onChange" |
||||
|
bind:confirm="onConfirm" |
||||
|
bind:cancel="onCancel" |
||||
|
/> |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss'; |
||||
@ -0,0 +1,62 @@ |
|||||
|
import baseComponent from '../helpers/baseComponent' |
||||
|
|
||||
|
baseComponent({ |
||||
|
properties: { |
||||
|
prefixCls: { |
||||
|
type: String, |
||||
|
value: 'wux-backdrop', |
||||
|
}, |
||||
|
transparent: { |
||||
|
type: Boolean, |
||||
|
value: false, |
||||
|
}, |
||||
|
zIndex: { |
||||
|
type: Number, |
||||
|
value: 1000, |
||||
|
}, |
||||
|
classNames: { |
||||
|
type: null, |
||||
|
value: 'wux-animate--fadeIn', |
||||
|
}, |
||||
|
}, |
||||
|
computed: { |
||||
|
classes: ['prefixCls, transparent', function(prefixCls, transparent) { |
||||
|
const wrap = transparent ? `${prefixCls}--transparent` : prefixCls |
||||
|
|
||||
|
return { |
||||
|
wrap, |
||||
|
} |
||||
|
}], |
||||
|
}, |
||||
|
methods: { |
||||
|
/** |
||||
|
* 保持锁定 |
||||
|
*/ |
||||
|
retain() { |
||||
|
if (typeof this.backdropHolds !== 'number' || !this.backdropHolds) { |
||||
|
this.backdropHolds = 0 |
||||
|
} |
||||
|
|
||||
|
this.backdropHolds = this.backdropHolds + 1 |
||||
|
|
||||
|
if (this.backdropHolds === 1) { |
||||
|
this.setData({ in: true }) |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 释放锁定 |
||||
|
*/ |
||||
|
release() { |
||||
|
if (this.backdropHolds === 1) { |
||||
|
this.setData({ in: false }) |
||||
|
} |
||||
|
this.backdropHolds = Math.max(0, this.backdropHolds - 1) |
||||
|
}, |
||||
|
/** |
||||
|
* 点击事件 |
||||
|
*/ |
||||
|
onClick() { |
||||
|
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,15 @@ |
|||||
|
.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,69 @@ |
|||||
|
import { VantComponent } from '../common/component'; |
||||
|
import { button } from '../mixins/button'; |
||||
|
import { openType } from '../mixins/open-type'; |
||||
|
VantComponent({ |
||||
|
mixins: [button, openType], |
||||
|
classes: ['hover-class', 'loading-class'], |
||||
|
data: { |
||||
|
baseStyle: '' |
||||
|
}, |
||||
|
props: { |
||||
|
icon: String, |
||||
|
plain: Boolean, |
||||
|
block: Boolean, |
||||
|
round: Boolean, |
||||
|
square: Boolean, |
||||
|
loading: Boolean, |
||||
|
hairline: Boolean, |
||||
|
disabled: Boolean, |
||||
|
loadingText: String, |
||||
|
customStyle: String, |
||||
|
loadingType: { |
||||
|
type: String, |
||||
|
value: 'circular' |
||||
|
}, |
||||
|
type: { |
||||
|
type: String, |
||||
|
value: 'default' |
||||
|
}, |
||||
|
size: { |
||||
|
type: String, |
||||
|
value: 'normal' |
||||
|
}, |
||||
|
loadingSize: { |
||||
|
type: String, |
||||
|
value: '20px' |
||||
|
}, |
||||
|
color: { |
||||
|
type: String, |
||||
|
observer(color) { |
||||
|
let style = ''; |
||||
|
if (color) { |
||||
|
style += `color: ${this.data.plain ? color : 'white'};`; |
||||
|
if (!this.data.plain) { |
||||
|
// Use background instead of backgroundColor to make linear-gradient work
|
||||
|
style += `background: ${color};`; |
||||
|
} |
||||
|
// hide border when color is linear-gradient
|
||||
|
if (color.indexOf('gradient') !== -1) { |
||||
|
style += 'border: 0;'; |
||||
|
} |
||||
|
else { |
||||
|
style += `border-color: ${color};`; |
||||
|
} |
||||
|
} |
||||
|
if (style !== this.data.baseStyle) { |
||||
|
this.setData({ baseStyle: style }); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
onClick() { |
||||
|
if (!this.data.loading) { |
||||
|
this.$emit('click'); |
||||
|
} |
||||
|
}, |
||||
|
noop() { } |
||||
|
} |
||||
|
}); |
||||
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": { |
||||
|
"van-icon": "../icon/index", |
||||
|
"van-loading": "../loading/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
<wxs src="../wxs/utils.wxs" module="utils" /> |
||||
|
|
||||
|
<button id="{{ id }}" |
||||
|
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}" |
||||
|
hover-class="van-button--active hover-class" lang="{{ lang }}" style="{{ baseStyle }} {{ customStyle }}" |
||||
|
open-type="{{ openType }}" business-id="{{ businessId }}" session-from="{{ sessionFrom }}" |
||||
|
send-message-title="{{ sendMessageTitle }}" send-message-path="{{ sendMessagePath }}" |
||||
|
send-message-img="{{ sendMessageImg }}" show-message-card="{{ showMessageCard }}" app-parameter="{{ appParameter }}" |
||||
|
aria-label="{{ ariaLabel }}" catchtap="{{ !disabled ? 'onClick' : 'noop' }}" |
||||
|
bindgetuserinfo="{{ !disabled ? 'bindGetUserInfo' : 'noop' }}" bindcontact="{{ !disabled ? 'bindContact' : 'noop' }}" |
||||
|
bindgetphonenumber="{{ !disabled ? 'bindGetPhoneNumber' : 'noop' }}" |
||||
|
binderror="{{ !disabled ? 'bindError' : 'noop' }}" bindlaunchapp="{{ !disabled ? 'bindLaunchApp' : 'noop' }}" |
||||
|
bindopensetting="{{ !disabled ? 'bindOpenSetting' : 'noop' }}"> |
||||
|
<block wx:if="{{ loading }}"> |
||||
|
<van-loading custom-class="loading-class" size="{{ loadingSize }}" type="{{ loadingType }}" |
||||
|
color="{{ loadingColor(type,color,plain) }}" /> |
||||
|
<view wx:if="{{ loadingText }}" class="van-button__loading-text"> |
||||
|
{{ loadingText }} |
||||
|
</view> |
||||
|
</block> |
||||
|
<block wx:else> |
||||
|
<van-icon wx:if="{{ icon }}" size="1.6em" name="{{ icon }}" class="van-button__icon" |
||||
|
custom-style="line-height: inherit;" /> |
||||
|
<view class="van-button__text"> |
||||
|
<slot /> |
||||
|
</view> |
||||
|
</block> |
||||
|
</button> |
||||
|
|
||||
|
|
||||
|
<wxs module="loadingColor"> |
||||
|
function get(type, color, plain) { |
||||
|
if (plain) { |
||||
|
return color ? color : '#c9c9c9'; |
||||
|
} |
||||
|
|
||||
|
if (type === 'default') { |
||||
|
return '#c9c9c9'; |
||||
|
} |
||||
|
return 'white'; |
||||
|
} |
||||
|
|
||||
|
module.exports = get; |
||||
|
</wxs> |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} |
||||
@ -0,0 +1,10 @@ |
|||||
|
import { VantComponent } from '../common/component'; |
||||
|
VantComponent({ |
||||
|
props: { |
||||
|
title: String, |
||||
|
border: { |
||||
|
type: Boolean, |
||||
|
value: true |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
@ -0,0 +1,3 @@ |
|||||
|
{ |
||||
|
"component": true |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
<view |
||||
|
wx:if="{{ title }}" |
||||
|
class="van-cell-group__title" |
||||
|
> |
||||
|
{{ title }} |
||||
|
</view> |
||||
|
<view class="custom-class van-cell-group {{ border ? 'van-hairline--top-bottom' : '' }}"> |
||||
|
<slot /> |
||||
|
</view> |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss';.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)} |
||||
@ -0,0 +1,35 @@ |
|||||
|
import { link } from '../mixins/link' |
||||
|
import { VantComponent } from '../common/component' |
||||
|
|
||||
|
VantComponent({ |
||||
|
classes: [ |
||||
|
'title-class', |
||||
|
'label-class', |
||||
|
'value-class', |
||||
|
'right-icon-class', |
||||
|
'hover-class' |
||||
|
], |
||||
|
mixins: [link], |
||||
|
props: { |
||||
|
title: null, |
||||
|
value: null, |
||||
|
icon: String, |
||||
|
size: String, |
||||
|
label: String, |
||||
|
center: Boolean, |
||||
|
isLink: Boolean, |
||||
|
required: Boolean, |
||||
|
clickable: Boolean, |
||||
|
titleWidth: String, |
||||
|
customStyle: String, |
||||
|
arrowDirection: String, |
||||
|
useLabelSlot: Boolean, |
||||
|
border: { type: Boolean, value: true } |
||||
|
}, |
||||
|
methods: { |
||||
|
onClick(event) { |
||||
|
this.$emit('click', event.detail) |
||||
|
this.jumpLink() |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": { |
||||
|
"van-icon": "../icon/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
<wxs src="../wxs/utils.wxs" module="utils" /> |
||||
|
|
||||
|
<view |
||||
|
class="custom-class {{ utils.bem('cell', [size, { center, required, borderless: !border, clickable: clickable }]) }}" |
||||
|
hover-class="van-cell--hover hover-class" hover-stay-time="70" style="{{ customStyle }}" bind:tap="onClick"> |
||||
|
<van-icon wx:if="{{ icon }}" name="{{ icon }}" class="van-cell__left-icon-wrap" custom-class="van-cell__left-icon" /> |
||||
|
<slot wx:else name="icon" /> |
||||
|
|
||||
|
<view style="{{ titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth : '' }}" |
||||
|
class="van-cell__title title-class"> |
||||
|
<block wx:if="{{ title }}">{{ title }}</block> |
||||
|
<slot wx:else name="title" /> |
||||
|
|
||||
|
<view wx:if="{{ label || useLabelSlot }}" class="van-cell__label label-class"> |
||||
|
<slot wx:if="{{ useLabelSlot }}" name="label" /> |
||||
|
<block wx:elif="{{ label }}">{{ label }}</block> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="van-cell__value value-class"> |
||||
|
<block wx:if="{{ value || value === 0 }}">{{ value }}</block> |
||||
|
<slot wx:else /> |
||||
|
</view> |
||||
|
|
||||
|
<van-icon wx:if="{{ isLink }}" name="{{ arrowDirection ? 'arrow' + '-' + arrowDirection : 'arrow' }}" |
||||
|
class="van-cell__right-icon-wrap right-icon-class" custom-class="van-cell__right-icon" /> |
||||
|
<slot wx:else name="right-icon" /> |
||||
|
|
||||
|
<slot name="extra" /> |
||||
|
</view> |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss';.van-cell{min-height: 96rpx;align-items: center;position:relative;display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:10px 16px;padding:var(--cell-vertical-padding,10px) var(--cell-horizontal-padding,16px);font-size:14px;font-size:var(--cell-font-size,14px);line-height:24px;line-height:var(--cell-line-height,24px);color:#323233;color:var(--cell-text-color,#323233);background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:auto;right:0;bottom:0;left:16px;border-bottom:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell__label{margin-top:3px;margin-top:var(--cell-label-margin-top,3px);font-size:12px;font-size:var(--cell-label-font-size,12px);line-height:18px;line-height:var(--cell-label-line-height,18px);color:#969799;color:var(--cell-label-color,#969799)}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle;color:#969799;color:var(--cell-value-color,#969799)}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px;height:var(--cell-line-height,24px);font-size:16px;font-size:var(--cell-icon-size,16px)}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#969799;color:var(--cell-right-icon-color,#969799)}.van-cell__left-icon{vertical-align:middle}.van-cell__left-icon,.van-cell__right-icon{line-height:24px;line-height:var(--cell-line-height,24px)}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5;background-color:var(--cell-active-color,#f2f3f5)}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;content:"*";left:8px;left:var(--padding-xs,8px);font-size:14px;font-size:var(--cell-font-size,14px);color:#ee0a24;color:var(--cell-required-color,#ee0a24)}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-top:var(--cell-large-vertical-padding,12px);padding-bottom:12px;padding-bottom:var(--cell-large-vertical-padding,12px)}.van-cell--large .van-cell__title{font-size:16px;font-size:var(--cell-large-title-font-size,16px)}.van-cell--large .van-cell__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)} |
||||
@ -0,0 +1,76 @@ |
|||||
|
import { VantComponent } from '../common/component'; |
||||
|
function emit(target, value) { |
||||
|
target.$emit('input', value); |
||||
|
target.$emit('change', value); |
||||
|
} |
||||
|
VantComponent({ |
||||
|
field: true, |
||||
|
relation: { |
||||
|
name: 'checkbox-group', |
||||
|
type: 'ancestor', |
||||
|
current: 'checkbox', |
||||
|
}, |
||||
|
classes: ['icon-class', 'label-class'], |
||||
|
props: { |
||||
|
value: Boolean, |
||||
|
disabled: Boolean, |
||||
|
useIconSlot: Boolean, |
||||
|
checkedColor: String, |
||||
|
labelPosition: String, |
||||
|
labelDisabled: Boolean, |
||||
|
shape: { |
||||
|
type: String, |
||||
|
value: 'round' |
||||
|
}, |
||||
|
iconSize: { |
||||
|
type: null, |
||||
|
value: 20 |
||||
|
} |
||||
|
}, |
||||
|
data: { |
||||
|
parentDisabled: false |
||||
|
}, |
||||
|
methods: { |
||||
|
emitChange(value) { |
||||
|
if (this.parent) { |
||||
|
this.setParentValue(this.parent, value); |
||||
|
} |
||||
|
else { |
||||
|
emit(this, value); |
||||
|
} |
||||
|
}, |
||||
|
toggle() { |
||||
|
const { parentDisabled, disabled, value } = this.data; |
||||
|
if (!disabled && !parentDisabled) { |
||||
|
this.emitChange(!value); |
||||
|
} |
||||
|
}, |
||||
|
onClickLabel() { |
||||
|
const { labelDisabled, parentDisabled, disabled, value } = this.data; |
||||
|
if (!disabled && !labelDisabled && !parentDisabled) { |
||||
|
this.emitChange(!value); |
||||
|
} |
||||
|
}, |
||||
|
setParentValue(parent, value) { |
||||
|
const parentValue = parent.data.value.slice(); |
||||
|
const { name } = this.data; |
||||
|
const { max } = parent.data; |
||||
|
if (value) { |
||||
|
if (max && parentValue.length >= max) { |
||||
|
return; |
||||
|
} |
||||
|
if (parentValue.indexOf(name) === -1) { |
||||
|
parentValue.push(name); |
||||
|
emit(parent, parentValue); |
||||
|
} |
||||
|
} |
||||
|
else { |
||||
|
const index = parentValue.indexOf(name); |
||||
|
if (index !== -1) { |
||||
|
parentValue.splice(index, 1); |
||||
|
emit(parent, parentValue); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": { |
||||
|
"van-icon": "../icon/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
<wxs src="../wxs/utils.wxs" module="utils" /> |
||||
|
<wxs src="./index.wxs" module="computed" /> |
||||
|
|
||||
|
<view class="van-checkbox custom-class"> |
||||
|
<view class="van-checkbox__icon-wrap" bindtap="toggle"> |
||||
|
<slot wx:if="{{ useIconSlot }}" name="icon" /> |
||||
|
<van-icon |
||||
|
wx:else |
||||
|
name="success" |
||||
|
size="0.8em" |
||||
|
class="{{ utils.bem('checkbox__icon', [shape, { disabled: disabled || parentDisabled, checked: value }]) }}" |
||||
|
style="{{ computed.iconStyle(checkedColor, value, disabled, parentDisabled, iconSize) }}" |
||||
|
custom-class="icon-class" |
||||
|
custom-style="line-height: 1.25em;" |
||||
|
/> |
||||
|
</view> |
||||
|
<view class="label-class {{ utils.bem('checkbox__label', [labelPosition, { disabled: disabled || parentDisabled }]) }}" bindtap="onClickLabel"> |
||||
|
<slot /> |
||||
|
</view> |
||||
|
</view> |
||||
@ -0,0 +1,20 @@ |
|||||
|
/* eslint-disable */ |
||||
|
var utils = require('../wxs/utils.wxs'); |
||||
|
|
||||
|
function iconStyle(checkedColor, value, disabled, parentDisabled, iconSize) { |
||||
|
var styles = [['font-size', utils.addUnit(iconSize)]]; |
||||
|
if (checkedColor && value && !disabled && !parentDisabled) { |
||||
|
styles.push(['border-color', checkedColor]); |
||||
|
styles.push(['background-color', checkedColor]); |
||||
|
} |
||||
|
|
||||
|
return styles |
||||
|
.map(function(item) { |
||||
|
return item.join(':'); |
||||
|
}) |
||||
|
.join(';'); |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
iconStyle: iconStyle |
||||
|
}; |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss';.van-checkbox{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{line-height:20px;line-height:var(--checkbox-size,20px)}.van-checkbox__icon-wrap{-webkit-flex:none;flex:none}.van-checkbox__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:1em;height:1em;color:transparent;text-align:center;transition-property:color,border-color,background-color;font-size:20px;font-size:var(--checkbox-size,20px);border:1px solid #c8c9cc;border:1px solid var(--checkbox-border-color,#c8c9cc);transition-duration:.2s;transition-duration:var(--checkbox-transition-duration,.2s)}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;color:var(--white,#fff);background-color:#1989fa;background-color:var(--checkbox-checked-icon-color,#1989fa);border-color:#1989fa;border-color:var(--checkbox-checked-icon-color,#1989fa)}.van-checkbox__icon--disabled{background-color:#ebedf0;background-color:var(--checkbox-disabled-background-color,#ebedf0);border-color:#c8c9cc;border-color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:#c8c9cc;color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__label{word-wrap:break-word;margin-left:10px;margin-left:var(--checkbox-label-margin,10px);color:#323233;color:var(--checkbox-label-color,#323233)}.van-checkbox__label--left{float:left;margin:0 10px 0 0;margin:0 var(--checkbox-label-margin,10px) 0 0}.van-checkbox__label--disabled{color:#c8c9cc;color:var(--checkbox-disabled-label-color,#c8c9cc)}.van-checkbox__label:empty{margin:0} |
||||
@ -0,0 +1,58 @@ |
|||||
|
import { VantComponent } from '../common/component'; |
||||
|
import { pickerProps } from './shared'; |
||||
|
|
||||
|
VantComponent({ |
||||
|
classes: ['active-class', 'toolbar-class', 'column-class'], |
||||
|
props: Object.assign(Object.assign({}, pickerProps), { |
||||
|
max: { |
||||
|
type: Number, |
||||
|
value: Infinity, |
||||
|
}, |
||||
|
activeId: { |
||||
|
type: Array, |
||||
|
value: [] |
||||
|
}, |
||||
|
toolbarPosition: { |
||||
|
type: String, |
||||
|
value: 'top' |
||||
|
}, |
||||
|
defaultIndex: { |
||||
|
type: Number, |
||||
|
value: 0 |
||||
|
}, |
||||
|
columns: { |
||||
|
type: Array, |
||||
|
value: [] |
||||
|
}, |
||||
|
selectedIcon: { |
||||
|
type: String, |
||||
|
value: 'success', |
||||
|
} |
||||
|
}), |
||||
|
methods: { |
||||
|
emit(event) { |
||||
|
const { type } = event.currentTarget.dataset; |
||||
|
if (this.data.columns.length) { |
||||
|
this.$emit(type, this.data.activeId ); |
||||
|
} else { |
||||
|
this.$emit(type, { }); |
||||
|
} |
||||
|
}, |
||||
|
onSelectItem(event) { |
||||
|
const { item } = event.currentTarget.dataset; |
||||
|
const isArray = Array.isArray(this.data.activeId); |
||||
|
// 判断有没有超出右侧选择的最大数
|
||||
|
const isOverMax = isArray && this.data.activeId.length >= this.data.max; |
||||
|
// 判断该项有没有被选中, 如果有被选中,则忽视是否超出的条件
|
||||
|
const index = this.data.activeId.indexOf(item.id) |
||||
|
if (!item.disabled && !isOverMax) { |
||||
|
if(index > -1){ |
||||
|
this.data.activeId.splice(index, 1) |
||||
|
} else { |
||||
|
this.data.activeId.push(item.id) |
||||
|
} |
||||
|
this.setData({ activeId: this.data.activeId }); |
||||
|
} |
||||
|
}, |
||||
|
} |
||||
|
}); |
||||
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": { |
||||
|
"van-icon": "../icon/index", |
||||
|
"loading": "../loading/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<import src="./toolbar.wxml" /> |
||||
|
<wxs src="../wxs/utils.wxs" module="utils" /> |
||||
|
<wxs src="./index.wxs" module="wxs" /> |
||||
|
|
||||
|
<view class="van-picker custom-class"> |
||||
|
<template is="toolbar" wx:if="{{ toolbarPosition === 'top' }}" |
||||
|
data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template> |
||||
|
<view wx:if="{{ loading }}" class="van-picker__loading"> |
||||
|
<loading color="#1989fa" /> |
||||
|
</view> |
||||
|
<scroll-view scroll-y class="van-tree-select__content" style="height: {{ itemHeight * visibleItemCount }}px; padding: 0rpx 32rpx"> |
||||
|
<slot name="content" /> |
||||
|
<view wx:for="{{ columns }}" wx:key="id" |
||||
|
class="van-ellipsis content-item-class {{ utils.bem('tree-select__item', { active: wxs.isActive(activeId, item.id), disabled: item.disabled }) }} {{ wxs.isActive(activeId, item.id) ? 'content-active-class' : '' }} {{ item.disabled ? 'content-disabled-class' : '' }}" |
||||
|
data-item="{{ item }}" style="height: {{ itemHeight }}px;border-bottom: 1rpx solid #f3f3f3" bind:tap="onSelectItem"> |
||||
|
{{ item.name }} |
||||
|
<van-icon wx:if="{{ wxs.isActive(activeId, item.id) }}" name="{{ selectedIcon }}" size="16px" class="van-tree-select__selected" /> |
||||
|
</view> |
||||
|
</scroll-view> |
||||
|
<template is="toolbar" wx:if="{{ toolbarPosition === 'bottom' }}" |
||||
|
data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template> |
||||
|
</view> |
||||
@ -0,0 +1,12 @@ |
|||||
|
/* eslint-disable */ |
||||
|
var array = require('../wxs/array.wxs'); |
||||
|
|
||||
|
function isActive (activeList, itemId) { |
||||
|
if (array.isArray(activeList)) { |
||||
|
return activeList.indexOf(itemId) > -1; |
||||
|
} |
||||
|
|
||||
|
return activeList === itemId; |
||||
|
} |
||||
|
|
||||
|
module.exports.isActive = isActive; |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss';.van-picker{position:relative;overflow:hidden;-webkit-text-size-adjust:100%;-webkit-user-select:none;user-select:none;background-color:#fff;background-color:var(--picker-background-color,#fff)}.van-picker__toolbar{display:-webkit-flex;display:flex;-webkit-justify-content:space-between;justify-content:space-between;height:44px;height:var(--picker-toolbar-height,44px);line-height:44px;line-height:var(--picker-toolbar-height,44px)}.van-picker__cancel{padding:0 16px;padding:var(--picker-action-padding,0 16px);font-size:14px;font-size:var(--picker-action-font-size,14px);color:#666666;color:var(--picker-action-text-color,#666666)}.van-picker__confirm{padding:0 16px;padding:var(--picker-action-padding,0 16px);font-size:14px;font-size:var(--picker-action-font-size,14px);color:#1989fa;color:var(--picker-action-text-color,#1989fa)}.van-picker__cancel--hover,.van-picker__confirm--hover{background-color:#f2f3f5;background-color:var(--picker-action-active-color,#f2f3f5)}.van-picker__title{max-width:50%;text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--picker-option-font-size,16px)}.van-picker__columns{position:relative;display:-webkit-flex;display:flex}.van-picker__column{-webkit-flex:1 1;flex:1 1;width:0}.van-picker__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:4;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;background-color:hsla(0,0%,100%,.9);background-color:var(--picker-loading-mask-color,hsla(0,0%,100%,.9))}.van-picker__mask{position:absolute;top:0;left:0;z-index:2;width:100%;height:100%;background-image:linear-gradient(180deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4)),linear-gradient(0deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4));background-repeat:no-repeat;background-position:top,bottom;-webkit-backface-visibility:hidden;backface-visibility:hidden;pointer-events:none}.van-picker__frame,.van-picker__loading .van-loading{position:absolute;top:50%;left:0;z-index:1;width:100%;-webkit-transform:translateY(-50%);transform:translateY(-50%);pointer-events:none}.van-tree-select{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;font-size:14px;font-size:var(--tree-select-font-size,14px)}.van-tree-select__nav{-webkit-flex:1;flex:1;background-color:#f7f8fa;background-color:var(--tree-select-nav-background-color,#f7f8fa);--sidebar-padding:12px 8px 12px 12px}.van-tree-select__nav__inner{width:100%!important;height:100%}.van-tree-select__content{-webkit-flex:2;flex:2;background-color:#fff;background-color:var(--tree-select-content-background-color,#fff)}.van-tree-select__item{position:relative;font-weight:700;line-height:44px;line-height:var(--tree-select-item-height,44px)}.van-tree-select__item--active{color:#1989fa;color:var(--tree-select-item-active-color,#1989fa)}.van-tree-select__item--disabled{color:#c8c9cc;color:var(--tree-select-item-disabled-color,#c8c9cc)}.van-tree-select__selected{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);right:0px;} |
||||
@ -0,0 +1,21 @@ |
|||||
|
export const pickerProps = { |
||||
|
title: String, |
||||
|
loading: Boolean, |
||||
|
showToolbar: Boolean, |
||||
|
cancelButtonText: { |
||||
|
type: String, |
||||
|
value: '取消' |
||||
|
}, |
||||
|
confirmButtonText: { |
||||
|
type: String, |
||||
|
value: '确认' |
||||
|
}, |
||||
|
visibleItemCount: { |
||||
|
type: Number, |
||||
|
value: 5 |
||||
|
}, |
||||
|
itemHeight: { |
||||
|
type: Number, |
||||
|
value: 45 |
||||
|
} |
||||
|
}; |
||||
@ -0,0 +1,11 @@ |
|||||
|
<template name="toolbar"> |
||||
|
<view wx:if="{{ showToolbar }}" class="van-picker__toolbar van-hairline--top-bottom toolbar-class"> |
||||
|
<view class="van-picker__cancel" hover-class="van-picker__cancel--hover" hover-stay-time="70" data-type="cancel" bindtap="emit"> |
||||
|
{{ cancelButtonText }} |
||||
|
</view> |
||||
|
<view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{title}}</view> |
||||
|
<view class="van-picker__confirm" hover-class="van-picker__confirm--hover" hover-stay-time="70" data-type="confirm" bindtap="emit"> |
||||
|
{{ confirmButtonText }} |
||||
|
</view> |
||||
|
</view> |
||||
|
</template> |
||||
@ -0,0 +1,24 @@ |
|||||
|
import { VantComponent } from '../common/component'; |
||||
|
VantComponent({ |
||||
|
relation: { |
||||
|
name: 'row', |
||||
|
type: 'ancestor', |
||||
|
current: 'col', |
||||
|
}, |
||||
|
props: { |
||||
|
span: Number, |
||||
|
offset: Number |
||||
|
}, |
||||
|
data: { |
||||
|
viewStyle: '' |
||||
|
}, |
||||
|
methods: { |
||||
|
setGutter(gutter) { |
||||
|
const padding = `${gutter / 2}px`; |
||||
|
const viewStyle = gutter ? `padding-left: ${padding}; padding-right: ${padding};` : ''; |
||||
|
if (viewStyle !== this.data.viewStyle) { |
||||
|
this.setData({ viewStyle }); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
@ -0,0 +1,3 @@ |
|||||
|
{ |
||||
|
"component": true |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
<wxs src="../wxs/utils.wxs" module="utils" /> |
||||
|
|
||||
|
<view |
||||
|
class="custom-class {{ utils.bem('col', [span]) }} {{ offset ? 'van-col--offset-' + offset : '' }}" |
||||
|
style="{{ viewStyle }}" |
||||
|
> |
||||
|
<slot /> |
||||
|
</view> |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss';.van-col{float:left;box-sizing:border-box}.van-col--1{width:4.16666667%}.van-col--offset-1{margin-left:4.16666667%}.van-col--2{width:8.33333333%}.van-col--offset-2{margin-left:8.33333333%}.van-col--3{width:12.5%}.van-col--offset-3{margin-left:12.5%}.van-col--4{width:16.66666667%}.van-col--offset-4{margin-left:16.66666667%}.van-col--5{width:20.83333333%}.van-col--offset-5{margin-left:20.83333333%}.van-col--6{width:25%}.van-col--offset-6{margin-left:25%}.van-col--7{width:29.16666667%}.van-col--offset-7{margin-left:29.16666667%}.van-col--8{width:33.33333333%}.van-col--offset-8{margin-left:33.33333333%}.van-col--9{width:37.5%}.van-col--offset-9{margin-left:37.5%}.van-col--10{width:41.66666667%}.van-col--offset-10{margin-left:41.66666667%}.van-col--11{width:45.83333333%}.van-col--offset-11{margin-left:45.83333333%}.van-col--12{width:50%}.van-col--offset-12{margin-left:50%}.van-col--13{width:54.16666667%}.van-col--offset-13{margin-left:54.16666667%}.van-col--14{width:58.33333333%}.van-col--offset-14{margin-left:58.33333333%}.van-col--15{width:62.5%}.van-col--offset-15{margin-left:62.5%}.van-col--16{width:66.66666667%}.van-col--offset-16{margin-left:66.66666667%}.van-col--17{width:70.83333333%}.van-col--offset-17{margin-left:70.83333333%}.van-col--18{width:75%}.van-col--offset-18{margin-left:75%}.van-col--19{width:79.16666667%}.van-col--offset-19{margin-left:79.16666667%}.van-col--20{width:83.33333333%}.van-col--offset-20{margin-left:83.33333333%}.van-col--21{width:87.5%}.van-col--offset-21{margin-left:87.5%}.van-col--22{width:91.66666667%}.van-col--offset-22{margin-left:91.66666667%}.van-col--23{width:95.83333333%}.van-col--offset-23{margin-left:95.83333333%}.van-col--24{width:100%}.van-col--offset-24{margin-left:100%} |
||||
@ -0,0 +1,95 @@ |
|||||
|
import { VantComponent } from '../common/component'; |
||||
|
VantComponent({ |
||||
|
classes: ['title-class', 'content-class'], |
||||
|
relation: { |
||||
|
name: 'collapse', |
||||
|
type: 'ancestor', |
||||
|
current: 'collapse-item', |
||||
|
}, |
||||
|
props: { |
||||
|
name: null, |
||||
|
title: null, |
||||
|
value: null, |
||||
|
icon: String, |
||||
|
label: String, |
||||
|
disabled: Boolean, |
||||
|
clickable: Boolean, |
||||
|
border: { |
||||
|
type: Boolean, |
||||
|
value: true, |
||||
|
}, |
||||
|
isLink: { |
||||
|
type: Boolean, |
||||
|
value: true, |
||||
|
}, |
||||
|
}, |
||||
|
data: { |
||||
|
expanded: false, |
||||
|
}, |
||||
|
created() { |
||||
|
this.animation = wx.createAnimation({ |
||||
|
duration: 0, |
||||
|
timingFunction: 'ease-in-out', |
||||
|
}); |
||||
|
}, |
||||
|
mounted() { |
||||
|
this.updateExpanded(); |
||||
|
this.inited = true; |
||||
|
}, |
||||
|
methods: { |
||||
|
updateExpanded() { |
||||
|
if (!this.parent) { |
||||
|
return Promise.resolve(); |
||||
|
} |
||||
|
const { value, accordion } = this.parent.data; |
||||
|
const { children = [] } = this.parent; |
||||
|
const { name } = this.data; |
||||
|
const index = children.indexOf(this); |
||||
|
const currentName = name == null ? index : name; |
||||
|
const expanded = accordion |
||||
|
? value === currentName |
||||
|
: (value || []).some((name) => name === currentName); |
||||
|
if (expanded !== this.data.expanded) { |
||||
|
this.updateStyle(expanded); |
||||
|
} |
||||
|
this.setData({ index, expanded }); |
||||
|
}, |
||||
|
updateStyle(expanded) { |
||||
|
const { inited } = this; |
||||
|
this.getRect('.van-collapse-item__content') |
||||
|
.then((rect) => rect.height) |
||||
|
.then((height) => { |
||||
|
const { animation } = this; |
||||
|
if (expanded) { |
||||
|
animation |
||||
|
.height(height) |
||||
|
.top(1) |
||||
|
.step({ |
||||
|
duration: inited ? 300 : 1, |
||||
|
}) |
||||
|
.height('auto') |
||||
|
.step(); |
||||
|
this.setData({ |
||||
|
animation: animation.export(), |
||||
|
}); |
||||
|
return; |
||||
|
} |
||||
|
animation.height(height).top(0).step({ duration: 1 }).height(0).step({ |
||||
|
duration: 300, |
||||
|
}); |
||||
|
this.setData({ |
||||
|
animation: animation.export(), |
||||
|
}); |
||||
|
}); |
||||
|
}, |
||||
|
onClick() { |
||||
|
if (this.data.disabled) { |
||||
|
return; |
||||
|
} |
||||
|
const { name, expanded } = this.data; |
||||
|
const index = this.parent.children.indexOf(this); |
||||
|
const currentName = name == null ? index : name; |
||||
|
this.parent.switch(currentName, !expanded); |
||||
|
}, |
||||
|
}, |
||||
|
}); |
||||
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": { |
||||
|
"van-cell": "../cell/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
<wxs src="../wxs/utils.wxs" module="utils" /> |
||||
|
|
||||
|
<view class="van-collapse-item custom-class {{ index !== 0 ? 'van-hairline--top' : '' }}"> |
||||
|
<van-cell title="{{ title }}" title-class="title-class" icon="{{ icon }}" value="{{ value }}" label="{{ label }}" |
||||
|
is-link="{{ isLink }}" clickable="{{ clickable }}" border="{{ border && expanded }}" |
||||
|
class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}" right-icon-class="van-cell__right-icon" |
||||
|
custom-class="van-cell" hover-class="van-cell--hover" bind:click="onClick" custom-style="min-height: auto;"> |
||||
|
<slot name="title" slot="title" /> |
||||
|
<slot name="icon" slot="icon" /> |
||||
|
<slot name="value" /> |
||||
|
<slot name="right-icon" slot="right-icon" /> |
||||
|
</van-cell> |
||||
|
<view class="{{ utils.bem('collapse-item__wrapper') }}" style="height: 0;" animation="{{ animation }}"> |
||||
|
<view class="van-collapse-item__content content-class"> |
||||
|
<slot /> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss';.van-collapse-item__title .van-cell__right-icon{-webkit-transform:rotate(90deg);transform:rotate(90deg);transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;transition:-webkit-transform var(--collapse-item-transition-duration,.3s);transition:transform var(--collapse-item-transition-duration,.3s);transition:transform var(--collapse-item-transition-duration,.3s),-webkit-transform var(--collapse-item-transition-duration,.3s)}.van-collapse-item__title--expanded .van-cell__right-icon{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.van-collapse-item__title--disabled .van-cell,.van-collapse-item__title--disabled .van-cell__right-icon{color:#c8c9cc!important;color:var(--collapse-item-title-disabled-color,#c8c9cc)!important}.van-collapse-item__title--disabled .van-cell--hover{background-color:#fff!important;background-color:var(--white,#fff)!important}.van-collapse-item__wrapper{overflow:hidden}.van-collapse-item__content{color:#969799;color:var(--collapse-item-content-text-color,#969799);font-size:13px;font-size:var(--collapse-item-content-font-size,13px);line-height:1.5;line-height:var(--collapse-item-content-line-height,1.5);background-color:#fff;background-color:var(--collapse-item-content-background-color,#fff)} |
||||
@ -0,0 +1,47 @@ |
|||||
|
import { VantComponent } from '../common/component'; |
||||
|
VantComponent({ |
||||
|
relation: { |
||||
|
name: 'collapse-item', |
||||
|
type: 'descendant', |
||||
|
current: 'collapse', |
||||
|
}, |
||||
|
props: { |
||||
|
value: { |
||||
|
type: null, |
||||
|
observer: 'updateExpanded', |
||||
|
}, |
||||
|
accordion: { |
||||
|
type: Boolean, |
||||
|
observer: 'updateExpanded', |
||||
|
}, |
||||
|
border: { |
||||
|
type: Boolean, |
||||
|
value: true, |
||||
|
}, |
||||
|
}, |
||||
|
methods: { |
||||
|
updateExpanded() { |
||||
|
this.children.forEach((child) => { |
||||
|
child.updateExpanded(); |
||||
|
}); |
||||
|
}, |
||||
|
switch(name, expanded) { |
||||
|
const { accordion, value } = this.data; |
||||
|
const changeItem = name; |
||||
|
if (!accordion) { |
||||
|
name = expanded |
||||
|
? (value || []).concat(name) |
||||
|
: (value || []).filter((activeName) => activeName !== name); |
||||
|
} else { |
||||
|
name = expanded ? name : ''; |
||||
|
} |
||||
|
if (expanded) { |
||||
|
this.$emit('open', changeItem); |
||||
|
} else { |
||||
|
this.$emit('close', changeItem); |
||||
|
} |
||||
|
this.$emit('change', name); |
||||
|
this.$emit('input', name); |
||||
|
}, |
||||
|
}, |
||||
|
}); |
||||
@ -0,0 +1,3 @@ |
|||||
|
{ |
||||
|
"component": true |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
<view class="custom-class van-collapse {{ border ? 'van-hairline--top-bottom' : '' }}"> |
||||
|
<slot /> |
||||
|
</view> |
||||
@ -0,0 +1 @@ |
|||||
|
@import '../common/index.wxss'; |
||||
@ -0,0 +1 @@ |
|||||
|
"use strict";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)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var hasOwn={}.hasOwnProperty;function classNames(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var r=_typeof(o);if("string"===r||"number"===r)e.push(o);else if(Array.isArray(o)&&o.length){var n=classNames.apply(null,o);n&&e.push(n)}else if("object"===r)for(var s in o)hasOwn.call(o,s)&&o[s]&&e.push(s)}}return e.join(" ")}var _default=classNames;exports.default=_default; |
||||
@ -0,0 +1,7 @@ |
|||||
|
export const RED = '#ee0a24'; |
||||
|
export const BLUE = '#1989fa'; |
||||
|
export const WHITE = '#fff'; |
||||
|
export const GREEN = '#07c160'; |
||||
|
export const ORANGE = '#ff976a'; |
||||
|
export const GRAY = '#323233'; |
||||
|
export const GRAY_DARK = '#969799'; |
||||
@ -0,0 +1,101 @@ |
|||||
|
import { basic } from '../mixins/basic'; |
||||
|
const relationFunctions = { |
||||
|
ancestor: { |
||||
|
linked(parent) { |
||||
|
this.parent = parent; |
||||
|
}, |
||||
|
unlinked() { |
||||
|
this.parent = null; |
||||
|
}, |
||||
|
}, |
||||
|
descendant: { |
||||
|
linked(child) { |
||||
|
this.children = this.children || []; |
||||
|
this.children.push(child); |
||||
|
}, |
||||
|
unlinked(child) { |
||||
|
this.children = (this.children || []).filter(it => it !== child); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
function mapKeys(source, target, map) { |
||||
|
Object.keys(map).forEach(key => { |
||||
|
if (source[key]) { |
||||
|
target[map[key]] = source[key]; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
function makeRelation(options, vantOptions, relation) { |
||||
|
const { type, name, linked, unlinked, linkChanged } = relation; |
||||
|
const { beforeCreate, destroyed } = vantOptions; |
||||
|
if (type === 'descendant') { |
||||
|
options.created = function () { |
||||
|
beforeCreate && beforeCreate.bind(this)(); |
||||
|
this.children = this.children || []; |
||||
|
}; |
||||
|
options.detached = function () { |
||||
|
this.children = []; |
||||
|
destroyed && destroyed.bind(this)(); |
||||
|
}; |
||||
|
} |
||||
|
options.relations = Object.assign(options.relations || {}, { |
||||
|
[`../${name}/index`]: { |
||||
|
type, |
||||
|
linked(node) { |
||||
|
relationFunctions[type].linked.bind(this)(node); |
||||
|
linked && linked.bind(this)(node); |
||||
|
}, |
||||
|
linkChanged(node) { |
||||
|
linkChanged && linkChanged.bind(this)(node); |
||||
|
}, |
||||
|
unlinked(node) { |
||||
|
relationFunctions[type].unlinked.bind(this)(node); |
||||
|
unlinked && unlinked.bind(this)(node); |
||||
|
}, |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
function VantComponent(vantOptions = {}) { |
||||
|
const options = {}; |
||||
|
mapKeys(vantOptions, options, { |
||||
|
data: 'data', |
||||
|
props: 'properties', |
||||
|
mixins: 'behaviors', |
||||
|
methods: 'methods', |
||||
|
beforeCreate: 'created', |
||||
|
created: 'attached', |
||||
|
mounted: 'ready', |
||||
|
relations: 'relations', |
||||
|
destroyed: 'detached', |
||||
|
classes: 'externalClasses' |
||||
|
}); |
||||
|
const { relation } = vantOptions; |
||||
|
if (relation) { |
||||
|
makeRelation(options, vantOptions, relation); |
||||
|
} |
||||
|
// add default externalClasses
|
||||
|
options.externalClasses = options.externalClasses || []; |
||||
|
options.externalClasses.push('custom-class'); |
||||
|
// add default behaviors
|
||||
|
options.behaviors = options.behaviors || []; |
||||
|
options.behaviors.push(basic); |
||||
|
// map field to form-field behavior
|
||||
|
if (vantOptions.field) { |
||||
|
options.behaviors.push('wx://form-field'); |
||||
|
} |
||||
|
if (options.properties) { |
||||
|
Object.keys(options.properties).forEach(name => { |
||||
|
if (Array.isArray(options.properties[name])) { |
||||
|
// miniprogram do not allow multi type
|
||||
|
options.properties[name] = null; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
// add default options
|
||||
|
options.options = { |
||||
|
multipleSlots: true, |
||||
|
addGlobalClass: true |
||||
|
}; |
||||
|
Component(options); |
||||
|
} |
||||
|
export { VantComponent }; |
||||
@ -0,0 +1 @@ |
|||||
|
.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{display:table;clear:both;content:""}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #ebedf0;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} |
||||
@ -0,0 +1 @@ |
|||||
|
.van-clearfix:after{display:table;clear:both;content:""} |
||||
@ -0,0 +1 @@ |
|||||
|
.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3} |
||||
@ -0,0 +1 @@ |
|||||
|
.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #eee;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} |
||||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save