init
This commit is contained in:
commit
c711239127
1
.cloudbase/container/debug.json
Normal file
1
.cloudbase/container/debug.json
Normal file
@ -0,0 +1 @@
|
||||
{"containers":[],"config":{}}
|
||||
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
# Windows
|
||||
[Dd]esktop.ini
|
||||
Thumbs.db
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
|
||||
# Node.js
|
||||
node_modules/
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"git.ignoreLimitWarning": true
|
||||
}
|
||||
17
api/MyReservation.js
Normal file
17
api/MyReservation.js
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
export const apiArr = {
|
||||
getActiveList:'/wechat/community/activity/list', //获取活动列表
|
||||
getActiveInfoById:"/wechat/community/activity/detail", //获取活动详情
|
||||
|
||||
eliminate:"/wechat/community/activity/eliminate", //核销
|
||||
eliminateList:"/wechat/community/activity/eliminate/list", //核销列表
|
||||
eliminateInfo:"/wechat/community/activity/eliminate/detail", //核销详情
|
||||
ScanCodeInfo:"/wechat/community/activity/one",//商家扫码详情
|
||||
|
||||
getReserationList:"/wechat/community/activity/reservation/list", //获取预约列表
|
||||
Reservation:"/wechat/community/activity/reservation", //预约
|
||||
modify: '/wechat/community/activity/order/modify', // 订单修改
|
||||
|
||||
getShopList:"/wechat/community/activity/shop/list"
|
||||
|
||||
}
|
||||
14
api/api.js
Normal file
14
api/api.js
Normal file
@ -0,0 +1,14 @@
|
||||
const host = 'https://api.hshuishang.com/api/v1';
|
||||
|
||||
|
||||
// 水机
|
||||
const httpUserUrl = host + '/waters';
|
||||
|
||||
|
||||
const apiAddr = {
|
||||
host:host,
|
||||
// 处理主办激活请求
|
||||
board_activation: httpUserUrl + '/board-activation',
|
||||
}
|
||||
|
||||
module.exports = apiAddr;
|
||||
88
api/base.js
Normal file
88
api/base.js
Normal file
@ -0,0 +1,88 @@
|
||||
const host = 'https://zhsq.hshuishang.com';
|
||||
const centerHost = 'https://cloud.rongwu360.com';
|
||||
|
||||
|
||||
const httpUserUrl = host + '/Miniapi/User';
|
||||
const httpIndexUrl = host + '/Miniapi/Index';
|
||||
const httpShopUrl = host + '/Miniapi/Shop';
|
||||
const httpSendUrl = host + '/Miniapi/Sendmsg';
|
||||
const httpHomeUrl = host + '/Miniapi/Home';
|
||||
const httpMeituanUrl = host + '/Miniapi/Meituan';
|
||||
const httpHardwareUrl = host + '/Miniapi/Hardware';
|
||||
const httpDouyinUrl = host + '/Miniapi/Douyin';
|
||||
const httpStatisticsUrl = host + '/Miniapi/Statistics';
|
||||
const httpCommunityUrl = host + '/Miniapi/Community';
|
||||
const httpMapsUrl = host + '/Miniapi/Maps';
|
||||
|
||||
const apiAddr = {
|
||||
host:host,
|
||||
center_host:centerHost,
|
||||
// 获取会话密钥
|
||||
get_session_key: httpUserUrl + '/get_session_key',
|
||||
decrypt_mini_user: httpUserUrl + '/decrypt_mini_user',
|
||||
decrypt_mini_phone: httpUserUrl + '/decrypt_mini_phone',
|
||||
mini_user_bind: httpUserUrl + '/mini_user_bind',
|
||||
add_create_mini_user: httpUserUrl + '/add_create_mini_user',
|
||||
avatar_upload: httpUserUrl + '/avatar_upload',
|
||||
get_user_info: httpUserUrl + '/get_user_info',
|
||||
get_user_menu: httpUserUrl + '/get_user_menu',
|
||||
order_list:httpUserUrl + '/get_order_list',
|
||||
order_module:httpUserUrl + '/get_order_module_list',
|
||||
poster_info:httpUserUrl + '/poster_info',
|
||||
|
||||
get_map_shop_list: httpShopUrl + '/get_map_shop_list',
|
||||
get_booking_type: httpShopUrl + '/get_booking_type',
|
||||
mini_shop_apply: httpShopUrl + '/mini_shop_apply',
|
||||
get_shop_details: httpShopUrl + '/get_shop_details',
|
||||
get_shop_area_list: httpShopUrl + '/get_shop_area_list',
|
||||
get_access_history_shop_list: httpShopUrl + '/get_access_history_shop_list',
|
||||
access_history_shop_del: httpShopUrl + '/access_history_shop_del',
|
||||
get_shop_index_nav: httpShopUrl + '/get_index_nav',
|
||||
get_map_shop_goods_list:httpShopUrl + '/get_map_shop_goods_list',
|
||||
|
||||
get_map_community_list: httpCommunityUrl + '/get_map_community_list',
|
||||
get_community_details: httpCommunityUrl + '/get_community_details',
|
||||
get_community_area_list: httpCommunityUrl + '/get_community_area_list',
|
||||
get_community_tools_nav: httpCommunityUrl + '/get_tools_nav',
|
||||
get_community_index_nav:httpCommunityUrl + '/get_index_nav',
|
||||
|
||||
get_share_pic:httpIndexUrl + '/get_share_pic',
|
||||
get_site_color: httpIndexUrl + '/get_site_color',
|
||||
get_location: httpIndexUrl + '/get_location',
|
||||
get_host_info: httpIndexUrl + '/get_host_info',
|
||||
customer_page_info:httpIndexUrl + '/customer_page_info',
|
||||
footer_nav_list:httpIndexUrl + '/footer_nav_list',
|
||||
setcookie_location:httpIndexUrl + '/setcookie_location',
|
||||
get_site_config:httpIndexUrl + '/get_site_config',
|
||||
get_site_ad:httpIndexUrl + '/get_site_ad', // 获取图片广告
|
||||
get_index_nav:httpIndexUrl + '/get_index_nav', // 获取图片广告
|
||||
get_site_nav:httpIndexUrl + '/get_site_nav', // 获取菜单
|
||||
get_index_block: httpIndexUrl + '/get_index_block', // 组合模块
|
||||
get_index_list_tab:httpIndexUrl + '/get_index_list_tab', // 组合模块
|
||||
|
||||
get_mini_tmpl: httpSendUrl + '/get_mini_tmpl',
|
||||
user_send_apply: httpSendUrl + '/user_send_apply',
|
||||
|
||||
add_port_share:httpHomeUrl + '/add_port_share',
|
||||
|
||||
meituan_shop: httpMeituanUrl + '/meituan_shop',
|
||||
meituan_verify_code: httpMeituanUrl + '/verify_code',
|
||||
|
||||
|
||||
hw_cp_operate: httpHardwareUrl+'/operate',
|
||||
hw_cp_operate_common: httpHardwareUrl+'/operate_common',
|
||||
hw_cp_change_port_state: httpHardwareUrl+'/change_port_mode_state',
|
||||
|
||||
douyinver: httpDouyinUrl+'/getPreVerify',
|
||||
douyin_shop: httpDouyinUrl + '/douyin_shop',
|
||||
douyin_verify_code: httpDouyinUrl + '/verify_code',
|
||||
|
||||
statistics_api:httpStatisticsUrl,
|
||||
|
||||
get_maps_geocoder: httpMapsUrl + '/geocoder',
|
||||
|
||||
third_recharge_order:httpUserUrl + '/get_third_recharge_logs',
|
||||
|
||||
};
|
||||
|
||||
module.exports = apiAddr;
|
||||
4
api/city.js
Normal file
4
api/city.js
Normal file
@ -0,0 +1,4 @@
|
||||
export const city = {
|
||||
getCitys: '/citys/c/list', //获取城市
|
||||
}
|
||||
|
||||
14
api/community.js
Normal file
14
api/community.js
Normal file
@ -0,0 +1,14 @@
|
||||
export const apiArr = {
|
||||
list: '/wechat/community/list', // 获取社区列表
|
||||
info: '/wechat/community/info', // 获取单个社区信息
|
||||
tipsList: '/wechat/community/tips/list', // 获取全部通知列表
|
||||
oneTips: '/wechat/community/tips/one', // 获取单个社区通知
|
||||
apply: '/wechat/community/apply', // 申请加入小区
|
||||
getFacilityList:'/wechat/community/facility/list', //获取楼号,
|
||||
getRoomList:'/wechat/community/room/list', //获取房间号
|
||||
ownerList: '/wechat/community/owner/list', // 获取社区业主列表
|
||||
|
||||
submit:"/wechat/community/owner/feedback-create", //报修提交
|
||||
getListByRepair:"/wechat/community/owner/feedback-list",//报事报修列表
|
||||
getInfoById:"/wechat/community/owner/feedback-info", //报事报修根据id查询详情
|
||||
};
|
||||
6
api/convenServer.js
Normal file
6
api/convenServer.js
Normal file
@ -0,0 +1,6 @@
|
||||
export const apiArr = {
|
||||
list: '/wechat/community/car/list', // 获取社区列表
|
||||
addCar: '/wechat/community/car/add', // 添加车辆
|
||||
getCarList:'/wechat/community/car/list', //获取车辆列表
|
||||
deleteItem:"/wechat/community/car/del"//删除车牌
|
||||
};
|
||||
11
api/doorToDoor.js
Normal file
11
api/doorToDoor.js
Normal file
@ -0,0 +1,11 @@
|
||||
export const apiArr = {
|
||||
AllDoorToDoor: '/wechat/appoints/get-cate-list', //获取服务列表
|
||||
ServerInfo: '/wechat/appoints/get-one', //获取服务列表
|
||||
getServerById: '/wechat/appoints/get-all-list', //跟据不同的id 查分类
|
||||
submitServer: '/wechat/appoint-orders/now', //预约服务
|
||||
createServerOrder: '/wechat/appoint-orders/create', //创建上门服务订单
|
||||
getCurrentShopMsg: '/wechat/water/device/shop-info', //获取店铺支付信息
|
||||
getBanner: '/wechat/banner-list ', //banner图
|
||||
getGoodsList: '/wechat/appoints/get-shop-list', //获取商家列表
|
||||
getGoodsDesc:"/wechat/shop/shop_info", //商家详情
|
||||
}
|
||||
6
api/health.js
Normal file
6
api/health.js
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
export const apiArr = {
|
||||
createRecord:'/wechat/mpuser/health/create', //创建健康自测
|
||||
getReportList:'/wechat/mpuser/health/list', //获取健康自测记录
|
||||
getReportById:"/wechat/mpuser/health/one",//根据id查健康记录
|
||||
}
|
||||
9
api/indexSubcontract.js
Normal file
9
api/indexSubcontract.js
Normal file
@ -0,0 +1,9 @@
|
||||
export const apiArr = {
|
||||
settledShop: '/wechat/shop/settled-shop', // 商家入驻
|
||||
settledDeal: '/wechat/water/dealer/settled-deal', // 经销商入驻
|
||||
settledComm: '/wechat/community/settled-comm', // 社区入驻
|
||||
city: '/citys/s/list', // 获取省份列表
|
||||
area: '/citys/c/list', // 获取城市列表
|
||||
business: '/citys/x/list', // 获取区县列表
|
||||
getTree: '/wechat/shop/cates/get-tree', // 商家商户分类树信息
|
||||
}
|
||||
6
api/kitchen.js
Normal file
6
api/kitchen.js
Normal file
@ -0,0 +1,6 @@
|
||||
export const apiArr = {
|
||||
shopList: '/wechat/shop/shop_list', // 获取商家列表
|
||||
balance: '/wechat/shop/user_balance', // 用户余额
|
||||
pay: '/wechat/shop/shop_pay', // 支付
|
||||
recharge: '/wechat/shop/recharge', // 充值
|
||||
}
|
||||
9
api/pay.js
Normal file
9
api/pay.js
Normal file
@ -0,0 +1,9 @@
|
||||
const pay = '/lakala/preorder' //预下单
|
||||
|
||||
const queryPay = '/lakala/trade-query' //查询交易结果
|
||||
|
||||
const PayJs = {
|
||||
pay,
|
||||
queryPay
|
||||
}
|
||||
module.exports = PayJs;
|
||||
26
api/user.js
Normal file
26
api/user.js
Normal file
@ -0,0 +1,26 @@
|
||||
export const apiArr = {
|
||||
getAllList:' /wechat/appoints/get-all-list', // 上门服务商品列表
|
||||
revoke: '/wechat/appoint-orders/revoke', // 取消订单
|
||||
getOne: '/wechat/appoint-orders/get-one', // 订单详情
|
||||
create: '/wechat/appoint-orders/create', // 订单提交
|
||||
getOrdersAllList: '/wechat/appoint-orders/get-all-list', // 查询这个登录人的所有订单
|
||||
signCycle: '/wechat/sign/sign-cycle', // 签到周期详情
|
||||
signList: '/wechat/sign/sign-list', // 获取签到记录列表
|
||||
sign: '/wechat/sign/sign', // 积分签到
|
||||
signIntegral: '/wechat/sign/integral', // 查询账户积分
|
||||
signInfo: '/wechat/sign/info', // 获取签到详情
|
||||
addr: '/wechat/mpusers/addr', // 获取地址信息
|
||||
setAddr: '/wechat/mpusers/set-addr',// 修改地址接口
|
||||
avatar: '/wechat/mpusers/avatar', // 上传头像
|
||||
modifyPass: '/wechat/mpusers/modify-pass', // 修改登录密码
|
||||
payPass: '/wechat/mpusers/pay-pass', // 设置支付密码
|
||||
couponList: '/wechat/discuss/list', // 获取优惠券列表
|
||||
getUserCommunity:"/wechat/community/owner/mylist",//获取用户社区信息
|
||||
|
||||
// TODO: 以下接口非小程序使用,临时调用添加数据
|
||||
allCate: '/discuss-capon/all_cate', // 获取所有分类
|
||||
list: '/discuss-capon/list', // 获取优惠券商品列表
|
||||
create: '/discuss-capon/create', // 添加优惠券
|
||||
|
||||
|
||||
};
|
||||
177
api/water_filter.js
Normal file
177
api/water_filter.js
Normal file
@ -0,0 +1,177 @@
|
||||
const repair = '/wechat/water/device/one-key-repair' //一键报修
|
||||
const getUserList = '/wechat/water/device/list' //获取用户设备列表
|
||||
const changeDef = '/wechat/water/device/first' //切换默认设备
|
||||
const getpackageList = '/wechat/water/device/package-list' //获取套餐列表
|
||||
const createPackageOrder = '/wechat/water/device/package-buy'//创建套餐订单
|
||||
const getCurrentShopMsg = '/wechat/water/device/shop-info' //获取当前商户信息
|
||||
const getdeviceListByid = '/wechat/water/device/parts-list' //根据id获取可购买设备
|
||||
const createDeviceOrder = '/wechat/water/device/parts-buy' //创建配件购买订单
|
||||
|
||||
|
||||
const changeOrderState = '/wechat/water/device/pay-parts-buy' //变更滤芯订单状态
|
||||
|
||||
const getOrderPayList = '/wechat/water/device/parts-buy-list' //滤芯购买记录
|
||||
|
||||
// const getUserBanlance = '/wechat/water/device/balance' //我的余额
|
||||
const getTotalBanlance = '/wechat/water/dealer/statistics-money' //我的收益
|
||||
const getOrderBuyList = '/wechat/water/device/package-buy-list' //查询套餐订单列表
|
||||
|
||||
|
||||
const getFilterListByid = '/wechat/water/device/device-parts' //根据设备id获取滤芯列表
|
||||
|
||||
|
||||
|
||||
const MasterList = '/wechat/water/dealer/master-list' //师傅列表
|
||||
const masterDesc = '/wechat/water/dealer/one-master' //师傅详情
|
||||
const createMaster = '/wechat/water/dealer/create-master' //创建傅信息
|
||||
const editMaster = '/wechat/water/dealer/set-master' //创建傅信息
|
||||
const getPhoneByUser = '/wechat/water/dealer/phone-master' //创建师傅的时候 使用
|
||||
|
||||
|
||||
const OrderList = '/wechat/water/dealer/repair-order-list' //维修工单列表
|
||||
const addOrderItem = '/wechat/water/dealer/repair-order-create' //新增维修工单
|
||||
const repairOrderOne = '/wechat/water/dealer/repair-order-one' // 维修工单详情
|
||||
const orderRepairAssign = '/wechat/water/dealer/order-repair-assign' // 维修工单分配师傅
|
||||
const RecallRepair = '/wechat/water/dealer/complete-repair' // 撤回维修工单
|
||||
const RecallNewRepair = '/wechat/water/dealer/complete-new-install' // 撤回新装工单
|
||||
|
||||
|
||||
const deviceDesc = '/device/one' //设备详情
|
||||
|
||||
const newOrderList = '/wechat/water/dealer/get_list_new_install' //新装工单列表
|
||||
const userNewOrderList = '/wechat/water/get_list_new_install' //微信新装工单列表
|
||||
|
||||
|
||||
const newOrderDesc = '/wechat/water/dealer/new-install-one' //新装工单详情
|
||||
const creNewOrder = '/new-install/create' //创建新装工单
|
||||
const newInstallAssign = '/wechat/water/dealer/new-install-assign' // 新装工单分配师傅
|
||||
|
||||
const packageList = '/package-buy/list' //套餐列表
|
||||
const packageDesc = '/package-buy/list' //套餐详情
|
||||
|
||||
const BXList = '/wechat/water/device/repair-list' //报修列表
|
||||
const BXOneRepair = '/wechat/water/device/one-repair' // 获取维修工单详情
|
||||
const BXDeviceList = '/wechat/water/device/list' // 获取用户设备列表
|
||||
|
||||
const login = '/wechat/mpusers/login' // 小程序登录
|
||||
const loginInfo = '/wechat/mpusers/login-info'
|
||||
const loginGetPhone = '/wechat/mpusers/get-phone'
|
||||
|
||||
|
||||
const rankingList = '/wechat/water/dealer/ranking-team' //销售排行
|
||||
// const inviteList = '/wechat/water/dealer/statistics-group' //邀请排行
|
||||
const MyinviteList = '/wechat/water/dealer/statistics-group' //我的邀请统计
|
||||
const buyProductList = '/wechat/water/dealer/buy_product_list' //进货记录
|
||||
|
||||
|
||||
const getPartner = '/wechat/water/dealer/info' //合伙人详情
|
||||
const getPartnerOrder = '/wechat/water/dealer/order-statistics' //合伙人订单
|
||||
const getProduct = '/wechat/water/dealer/product-list' //合伙人所有的产品列表
|
||||
const createPartnerOrder = '/wechat/water/dealer/buy_product_create' //创建合伙人订单
|
||||
const deviceList = '/wechat/water/dealer/device-list' // 设备列表
|
||||
const deviceInfo = '/wechat/water/device/one-device' //设备详情
|
||||
|
||||
const createQrcode = '/wechat/water/device/qr-code' //获取小程序码
|
||||
|
||||
|
||||
const getVersion = '/wechat/audit/app_versions' //获取版本信息
|
||||
const accountLogin = '/wechat/audit/app_login' //审核登录
|
||||
|
||||
|
||||
|
||||
//师傅端
|
||||
const getNewOrder = '/wechat/water/master/get_list_new_install' //获取新装工单
|
||||
const gerRepairOrder = '/wechat/water/master/repair-order-list' //获取维修工单
|
||||
const getPartOrder = '/wechat/water/master/part-replace-list' //获取耗材工单
|
||||
|
||||
const NewOrderDesc = '/wechat/water/master/new-install-one' //师傅新装工单详情
|
||||
const RepairOrderDesc = '/wechat/water/master/repair-order-one' //师傅更换工单详情
|
||||
const PartOrderDesc = '/wechat/water/master/part-replace-one' // 师傅耗材更换详情
|
||||
|
||||
const completeNewOrder = '/wechat/water/dealer/complete-new-install' //完成新装工单
|
||||
const completeRepairOrder = '/wechat/water/master/complete-repair' //完成维修工单
|
||||
const completePartOrder = '/wechat/water/master/complete-part-replace' //完成耗材更换工单
|
||||
|
||||
const getDeviceByCode = '/wechat/water/dealer/device-code' //根据编码获取设备信息
|
||||
|
||||
const masterInfo = '/wechat/water/master/master-info' //师傅信息
|
||||
const editMasterInfo = '/wechat/water/master/set-master-info' //修改师傅信息
|
||||
|
||||
const getDeposit = '/wechat/water/deposit_pay' //获取押金信息
|
||||
const city = '/citys/s/list' // 获取省份列表'
|
||||
const area = '/citys/c/list' // 获取市列表'
|
||||
const business = '/citys/x/list' // 获取区列表'
|
||||
const createPosit = '/wechat/water/create_posit_info' //创建押金缴纳
|
||||
|
||||
const apiArr = {
|
||||
createPosit,
|
||||
city,
|
||||
area,
|
||||
business,
|
||||
getDeposit,
|
||||
MasterList,
|
||||
masterDesc,
|
||||
editMaster,
|
||||
getPhoneByUser,
|
||||
OrderList,
|
||||
addOrderItem,
|
||||
repairOrderOne,
|
||||
getUserList,
|
||||
deviceDesc,
|
||||
RecallRepair,
|
||||
RecallNewRepair,
|
||||
newOrderList,
|
||||
userNewOrderList,
|
||||
newOrderDesc,
|
||||
packageList,
|
||||
packageDesc,
|
||||
login,
|
||||
loginInfo,
|
||||
loginGetPhone,
|
||||
BXList,
|
||||
BXOneRepair,
|
||||
BXDeviceList,
|
||||
creNewOrder,
|
||||
createMaster,
|
||||
changeDef,
|
||||
repair,
|
||||
getpackageList,
|
||||
createPackageOrder,
|
||||
getCurrentShopMsg,
|
||||
getFilterListByid,
|
||||
getdeviceListByid,
|
||||
newInstallAssign,
|
||||
orderRepairAssign,
|
||||
createDeviceOrder,
|
||||
changeOrderState,
|
||||
getOrderPayList,
|
||||
// getUserBanlance,
|
||||
getTotalBanlance,
|
||||
getOrderBuyList,
|
||||
rankingList,
|
||||
// inviteList,
|
||||
MyinviteList,
|
||||
buyProductList,
|
||||
getPartner,
|
||||
getPartnerOrder,
|
||||
getProduct,
|
||||
deviceList,
|
||||
createPartnerOrder,
|
||||
deviceInfo,
|
||||
createQrcode,
|
||||
getVersion,
|
||||
accountLogin,
|
||||
getNewOrder,
|
||||
gerRepairOrder,
|
||||
getPartOrder,
|
||||
NewOrderDesc,
|
||||
RepairOrderDesc,
|
||||
PartOrderDesc,
|
||||
completeNewOrder,
|
||||
completeRepairOrder,
|
||||
completePartOrder,
|
||||
masterInfo,
|
||||
editMasterInfo,
|
||||
getDeviceByCode
|
||||
}
|
||||
module.exports = apiArr;
|
||||
319
app.js
Normal file
319
app.js
Normal file
@ -0,0 +1,319 @@
|
||||
import apiArr from './api/water_filter';
|
||||
import util from './utils/util';
|
||||
import apiAddr from '/api/base';
|
||||
App({
|
||||
|
||||
globalData: {
|
||||
isIpx: false,
|
||||
userInfo: null,
|
||||
id: '',
|
||||
navHeight: 0,
|
||||
navTop: 0,
|
||||
windowHeight: 0,
|
||||
isShow: false,
|
||||
isShare: false, // 用于判断是否来源于分享
|
||||
nav_list:[],
|
||||
foot_width:'20%',
|
||||
|
||||
},
|
||||
|
||||
|
||||
getFootNav() {
|
||||
console.log(789789);
|
||||
let that = this;
|
||||
// util.postUrl(apiArr.footer,{},res=>{
|
||||
// that.globalData.nav_list = res;
|
||||
// that.globalData.foot_width = (100 / res.length).toFixed(2) + '%';
|
||||
// })
|
||||
wx.request({
|
||||
url: apiArr.footer,
|
||||
data: {},
|
||||
method: 'POST',
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
success: f => {
|
||||
console.log('successddd');
|
||||
if (f.data.code == "-101" || f.data.code == "-102") {
|
||||
successfn(f.data);
|
||||
} else if (f.data.code == "-103") {
|
||||
successfn(f.data);
|
||||
} else {
|
||||
successfn(f.data);
|
||||
}
|
||||
},
|
||||
error: f => {
|
||||
console.log('error');
|
||||
wx.showToast({
|
||||
title: '系统繁忙',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
onLaunch(options) {
|
||||
let that = this;
|
||||
that.getFootNav()
|
||||
if (options.scene) {
|
||||
const scene = decodeURIComponent(options.scene); // 解码 scene
|
||||
console.log('scene:', scene);
|
||||
}
|
||||
|
||||
if (options.query.scene) {
|
||||
let scene = decodeURIComponent(options.query.scene);
|
||||
that.d.scene = scene;
|
||||
}
|
||||
this.globalData.sysinfo = wx.getSystemInfoSync()
|
||||
//获取系统信息
|
||||
wx.getSystemInfo({
|
||||
success: res => {
|
||||
that.system = res
|
||||
}
|
||||
})
|
||||
//获取胶囊信息
|
||||
that.menu = wx.getMenuButtonBoundingClientRect();
|
||||
// console.log(that.menu)
|
||||
// 判断是否为 iPhone X
|
||||
wx.getSystemInfo({
|
||||
success: function (res) {
|
||||
// X 及以上的异形屏top为44,非异形屏为20
|
||||
if (res.safeArea.top > 20) {
|
||||
that.globalData.isIpx = true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
let menuButtonObject = wx.getMenuButtonBoundingClientRect();
|
||||
wx.getSystemInfo({
|
||||
success: res => {
|
||||
let statusBarHeight = res.statusBarHeight,
|
||||
navTop = menuButtonObject.top, //胶囊按钮与顶部的距离
|
||||
navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight) * 2; //导航高度
|
||||
this.globalData.navHeight = navHeight;
|
||||
this.globalData.navTop = navTop;
|
||||
this.globalData.windowHeight = res.windowHeight;
|
||||
},
|
||||
fail(err) {
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
|
||||
this.autoUpdate()
|
||||
},
|
||||
onShow(options) {
|
||||
const updateManager = wx.getUpdateManager();
|
||||
updateManager.onCheckForUpdate(function (res) {
|
||||
if (res.hasUpdate) {
|
||||
// updateManager.onUpdateReady(function () {
|
||||
// wx.showModal({
|
||||
// title: '温馨提示',
|
||||
// content: '系统检测到有新版本并已准备好更新,是否重启应用?',
|
||||
// success: () => {
|
||||
// if (res.confirm) updateManager.applyUpdate();
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// updateManager.onUpdateFailed(function () {
|
||||
// wx.showModal({
|
||||
// title: '温馨提示',
|
||||
// content: '系统检测到有新版本,请删除当前小程序,重新搜索打开'
|
||||
// })
|
||||
// })
|
||||
}
|
||||
});
|
||||
if (options.scene == 1007) {
|
||||
// 通过单人聊天会话分享进入
|
||||
this.globalData.isShare = true;
|
||||
}
|
||||
if (options.scene == 1008) {
|
||||
// 通过群聊会话分享进入
|
||||
this.globalData.isShare = true;
|
||||
}
|
||||
},
|
||||
/** 5d444af49568c61c47aa7b84dfe7c575
|
||||
* @description 获取本地用户数据
|
||||
* @method getLocalUserInfo
|
||||
* @returns {Object} // 返回用户数据
|
||||
*/
|
||||
getLocalUserInfo(){
|
||||
let userInfo = wx.getStorageSync('userInfo');
|
||||
return !userInfo ? {} : JSON.parse(userInfo);
|
||||
},
|
||||
getSessionKey() {
|
||||
let userSessionKey = wx.getStorageSync('session_key');
|
||||
return userSessionKey || '';
|
||||
},
|
||||
/**
|
||||
* @description 验证用户是否点击授权
|
||||
* @method hasUserAuth
|
||||
* @param {String} errMsg // 提示信息
|
||||
* @returns {Boolean} // 返回 Boolean
|
||||
*/
|
||||
hasUserAuth(errMsg){
|
||||
let [ msg_1, msg_2 ] = errMsg.split(':');
|
||||
return msg_2 === 'ok';
|
||||
},
|
||||
initCustomNavbar(){
|
||||
let { top, height, left } = wx.getMenuButtonBoundingClientRect();
|
||||
let { statusBarHeight, screenWidth } = wx.getSystemInfoSync();
|
||||
let navBarHeight = (top - statusBarHeight) * 2 + height + statusBarHeight;
|
||||
let navBarDetail = {
|
||||
top: statusBarHeight,
|
||||
right: screenWidth - left,
|
||||
height: navBarHeight,
|
||||
};
|
||||
return navBarDetail;
|
||||
},
|
||||
changeHeaderColor(){
|
||||
wx.request({
|
||||
url: apiAddr.get_site_color,
|
||||
method: 'post',
|
||||
header: {
|
||||
'Content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
dataType:'json',
|
||||
success: (result) => {
|
||||
var color = result.data.mobile_color ? result.data.mobile_color : '#ffffff';
|
||||
var font_color = result.data.font_color ? result.data.font_color : '#000000';
|
||||
wx.setStorageSync('mobile_color',color);
|
||||
wx.setNavigationBarColor({
|
||||
frontColor: font_color,
|
||||
backgroundColor: color,
|
||||
animation: {
|
||||
duration: 0,
|
||||
timingFunc: 'linear'
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
goH5Link(event){
|
||||
let url=event.currentTarget.dataset.url;
|
||||
console.log(url);
|
||||
wx.navigateTo({
|
||||
url: `/pages/index/index?q=${url}`,
|
||||
})
|
||||
},
|
||||
goPagesLink(event){
|
||||
let url= event.currentTarget.dataset.url;
|
||||
let tab1 = 'pages/index/community';
|
||||
let tab2 = 'pages/booking/orderlist';
|
||||
let tab3 = '/user/index';
|
||||
if(url.indexOf(tab1) !== -1 || url.indexOf(tab2) !== -1 || url.indexOf(tab3) !== -1){
|
||||
wx.redirectTo({
|
||||
url: url,
|
||||
});
|
||||
}else{
|
||||
wx.navigateTo({
|
||||
url: url,
|
||||
})
|
||||
}
|
||||
},
|
||||
goMiniprogram(event){
|
||||
wx.navigateToMiniProgram({
|
||||
appId: event.currentTarget.dataset.appid
|
||||
})
|
||||
},
|
||||
makeCall(event){
|
||||
wx.makePhoneCall({
|
||||
phoneNumber: event.currentTarget.dataset.tel
|
||||
})
|
||||
},
|
||||
return:function(){
|
||||
//返回到上一个页面
|
||||
console.log('返回');
|
||||
wx.navigateBack()
|
||||
/*
|
||||
var pages = getCurrentPages();//获取页面数据
|
||||
var prevPage = pages[pages.length - 2]; //上一个页面
|
||||
prevPage.onLoad();//对上一个页面进行刷新(执行上一个页面的onLoad方法)
|
||||
prevPage.setData({ //调用上一个页面的setData方法
|
||||
iconStatu: false //给A页面设置一个变量iconStatu,值为false
|
||||
});
|
||||
*/
|
||||
|
||||
},
|
||||
globalData: {
|
||||
appid: 'wx1addb25675dd8e70'
|
||||
},
|
||||
pluginHxj(){
|
||||
// var createPlugin = requirePlugin("hxjlock");
|
||||
// var Plugin = createPlugin()
|
||||
return null;
|
||||
},
|
||||
pluginTts(){
|
||||
return requirePlugin("ttslock");
|
||||
},
|
||||
initQQMapKey(){
|
||||
return '';
|
||||
},
|
||||
autoUpdate:function(){
|
||||
|
||||
var self=this
|
||||
let startParamObj = wx.getLaunchOptionsSync();
|
||||
// 获取小程序更新机制兼容
|
||||
if (wx.canIUse('getUpdateManager')&& startParamObj.scene!=1154) {
|
||||
const updateManager = wx.getUpdateManager()
|
||||
//1. 检查小程序是否有新版本发布
|
||||
updateManager.onCheckForUpdate(function (res) {
|
||||
// 请求完新版本信息的回调
|
||||
if (res.hasUpdate) {
|
||||
//2. 小程序有新版本,则静默下载新版本,做好更新准备
|
||||
updateManager.onUpdateReady(function () {
|
||||
console.log(new Date())
|
||||
wx.showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启应用?',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
//3. 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||
updateManager.applyUpdate()
|
||||
} else if (res.cancel) {
|
||||
//如果需要强制更新,则给出二次弹窗,如果不需要,则这里的代码都可以删掉了
|
||||
wx.showModal({
|
||||
title: '温馨提示~',
|
||||
content: '本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~',
|
||||
success: function (res) {
|
||||
self.autoUpdate()
|
||||
return;
|
||||
//第二次提示后,强制更新
|
||||
if (res.confirm) {
|
||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||
updateManager.applyUpdate()
|
||||
} else if (res.cancel) {
|
||||
//重新回到版本更新提示
|
||||
self.autoUpdate()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
updateManager.onUpdateFailed(function () {
|
||||
// 新的版本下载失败
|
||||
wx.showModal({
|
||||
title: '已经有新版本了哟~',
|
||||
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
if(startParamObj.scene==1154){
|
||||
|
||||
}else{
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
|
||||
})
|
||||
}
|
||||
// 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
|
||||
/* wx.showModal({
|
||||
title: '提示',
|
||||
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
|
||||
})*/
|
||||
}
|
||||
}
|
||||
})
|
||||
142
app.json
Normal file
142
app.json
Normal file
@ -0,0 +1,142 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/water_filter/water_filter",
|
||||
"pages/index/newIndex/newIndex",
|
||||
"pages/index/shopcity",
|
||||
"pages/community/detail",
|
||||
"pages/map/map",
|
||||
"pages/login/login",
|
||||
"pages/phoneGo/phoneGo",
|
||||
"pages/chooseCommunity/chooseCommunity",
|
||||
"pages/device/device",
|
||||
"pages/deposit/deposit",
|
||||
"pages/newOrderList/newOrderList"
|
||||
],
|
||||
"subPackages": [
|
||||
{
|
||||
"root": "packages/WaterPurifier",
|
||||
"independent": false,
|
||||
"pages": [
|
||||
"pages/water_filter/water_filter",
|
||||
"pages/repair/repair",
|
||||
"pages/RechargeRecord/RechargeRecord",
|
||||
"pages/Recharge/Recharge",
|
||||
"pages/payList/payList",
|
||||
"pages/orderDesc/orderDesc",
|
||||
"pages/MaintenanceInfo/MaintenanceInfo",
|
||||
"pages/Maintenance/Maintenance",
|
||||
"pages/filter/filter",
|
||||
"pages/Buyfilter/Buyfilter",
|
||||
"pages/device/deviceList/deviceList",
|
||||
"pages/device/deviceDesc/deviceDesc",
|
||||
"pages/device/myDevice/myDevice",
|
||||
"pages/device/inventory/inventory",
|
||||
"pages/upKeep/upKeep",
|
||||
"pages/newUpKeep/newUpKeep",
|
||||
"pages/shareDerive/shareDerive",
|
||||
"pages/shareWaterFilter/shareWaterFilter",
|
||||
"pages/test/test",
|
||||
"pages/Addfriend/Addfriend",
|
||||
"pages/water_change/water_change"
|
||||
]
|
||||
},
|
||||
{
|
||||
"root": "packages/user",
|
||||
"pages": [
|
||||
"points/detail",
|
||||
"share/index",
|
||||
"marketing/index",
|
||||
"userAvatars/index",
|
||||
"resetPwd/index",
|
||||
"userInfo/index",
|
||||
"transactionRecord/index",
|
||||
"transactionDetail/index",
|
||||
"goPay/index",
|
||||
"addressAdministration/index",
|
||||
"addAress/index",
|
||||
"uploadAvatar/index",
|
||||
"coupon/index",
|
||||
"points/desc",
|
||||
"community/list",
|
||||
"points/sign"
|
||||
]
|
||||
},
|
||||
{
|
||||
"root": "packages/master",
|
||||
"pages":[
|
||||
"order/index",
|
||||
"orderDesc/index",
|
||||
"PersonCen/index"
|
||||
]
|
||||
},
|
||||
{
|
||||
"root": "packages/partner",
|
||||
"pages": [
|
||||
"pages/partner",
|
||||
"pages/purchaseGoods/purchaseGoods",
|
||||
"pages/WorkOrder/WorkOrder",
|
||||
"pages/newWorkOrder/newWorkOrder",
|
||||
"pages/orderDesc/orderDesc",
|
||||
"pages/team/team",
|
||||
"pages/invite/invite",
|
||||
"pages/ranking/ranking",
|
||||
"pages/master/master",
|
||||
"pages/masterDesc/masterDesc",
|
||||
"pages/creatMaster/creatMaster",
|
||||
"pages/desk/desk",
|
||||
"pages/income/income",
|
||||
"pages/incomeDesc/incomeDesc",
|
||||
"pages/incomeDetail/incomeDetail"
|
||||
]
|
||||
}
|
||||
],
|
||||
"requiredPrivateInfos": [
|
||||
"getLocation",
|
||||
"chooseAddress",
|
||||
"chooseLocation"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"navigationBarTitleText": "衡水喜屏智慧社区",
|
||||
"navigationBarTextStyle": "black"
|
||||
},
|
||||
"lazyCodeLoading": "requiredComponents",
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "正在授权您获取当前位置信息"
|
||||
}
|
||||
},
|
||||
"plugins": {},
|
||||
"usingComponents": {
|
||||
"van-grid": "/miniprogram_npm/vant-weapp/grid/index",
|
||||
"van-grid-item": "/miniprogram_npm/vant-weapp/grid-item/index",
|
||||
"van-divider": "/miniprogram_npm/vant-weapp/divider/index",
|
||||
"van-row": "/miniprogram_npm/vant-weapp/row/index",
|
||||
"van-col": "/miniprogram_npm/vant-weapp/col/index",
|
||||
"van-progress": "/miniprogram_npm/vant-weapp/progress/index",
|
||||
"van-icon": "/miniprogram_npm/vant-weapp/icon/index",
|
||||
"van-tab": "/miniprogram_npm/vant-weapp/tab/index",
|
||||
"van-tabs": "/miniprogram_npm/vant-weapp/tabs/index",
|
||||
"van-field": "/miniprogram_npm/vant-weapp/field/index",
|
||||
"van-uploader": "/miniprogram_npm/vant-weapp/uploader/index",
|
||||
"van-datetime-picker": "/miniprogram_npm/vant-weapp/datetime-picker/index",
|
||||
"van-popup": "/miniprogram_npm/vant-weapp/popup/index",
|
||||
"van-circle": "/miniprogram_npm/vant-weapp/circle/index",
|
||||
"van-checkbox": "/miniprogram_npm/vant-weapp/checkbox",
|
||||
"van-checkbox-group": "/miniprogram_npm/vant-weapp/checkbox-group",
|
||||
"van-area": "/miniprogram_npm/vant-weapp/area/index",
|
||||
"van-dropdown-menu": "/miniprogram_npm/vant-weapp/dropdown-menu",
|
||||
"van-dropdown-item": "/miniprogram_npm/vant-weapp/dropdown-item",
|
||||
"van-notice-bar": "/miniprogram_npm/vant-weapp/notice-bar",
|
||||
"van-empty": "/miniprogram_npm/vant-weapp/empty",
|
||||
"van-picker": "/miniprogram_npm/vant-weapp/picker",
|
||||
"van-radio": "/miniprogram_npm/vant-weapp/radio",
|
||||
"van-radio-group": "/miniprogram_npm/vant-weapp/radio-group",
|
||||
"van-stepper": "/miniprogram_npm/vant-weapp/stepper/index"
|
||||
},
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"resolveAlias": {
|
||||
"~/*": "/*"
|
||||
}
|
||||
}
|
||||
5
app.miniapp.json
Normal file
5
app.miniapp.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"adapteByMiniprogram": {
|
||||
"userName": "gh_f54e89bc7e54"
|
||||
}
|
||||
}
|
||||
134
app.wxss
Normal file
134
app.wxss
Normal file
@ -0,0 +1,134 @@
|
||||
page,view,text,input,image{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
page{
|
||||
font-size: 28rpx;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
|
||||
image{
|
||||
display: block;
|
||||
}
|
||||
.container-show-footer{
|
||||
padding-bottom: 76px;
|
||||
}
|
||||
.noDataImg{
|
||||
background:unset;
|
||||
margin: auto;
|
||||
height: auto;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
.noDataImg image{
|
||||
background: unset;
|
||||
width: 70%;
|
||||
margin: 20px 15%;
|
||||
position: relative;
|
||||
}
|
||||
.noDataTips{
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
display: block;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.foot-fixed {
|
||||
position: fixed;
|
||||
bottom: -1px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 999;
|
||||
width: 100%;
|
||||
background: #ffffff;
|
||||
border-top: 1px solid #E8E8E8;
|
||||
box-shadow: 0 0 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
.foot-fixed .foot-item {
|
||||
padding: 0;
|
||||
}
|
||||
.foot-fixed .foot-item {
|
||||
position: relative;
|
||||
}
|
||||
.foot-fixed .foot-item {
|
||||
width: 20%;
|
||||
float: left;
|
||||
text-align: center;
|
||||
color: #777;
|
||||
padding: 5px 0 10px;
|
||||
}
|
||||
a {
|
||||
color: #666;
|
||||
text-decoration: none;
|
||||
}
|
||||
a {
|
||||
background: transparent;
|
||||
}
|
||||
.foot-fixed .foot-item .foot-icon {
|
||||
width: 24px;
|
||||
height: 26px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.foot-fixed .foot-item .foot-label {
|
||||
margin: 5px 0;
|
||||
}
|
||||
.foot-fixed .foot-item .foot-label {
|
||||
height: 15px;
|
||||
line-height: 15px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.foot-fixed .foot-item span {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 自定义导航栏 */
|
||||
.nav-box {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
/* position: relative; */
|
||||
/* position: fixed; */
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar .nav-bar-left,
|
||||
.nav-box .nav-bar .nav-bar-right {
|
||||
padding: 0 20rpx;
|
||||
min-width: 36rpx;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar .nav-bar-left van-icon {
|
||||
vertical-align: sub;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar .nav-bar-title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
letter-spacing: 2rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar-title {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.gray{
|
||||
height: 20rpx;
|
||||
background: #F9F9F9;
|
||||
}
|
||||
|
||||
image{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
84
component/Nav/Nav.js
Normal file
84
component/Nav/Nav.js
Normal file
@ -0,0 +1,84 @@
|
||||
const app = getApp()
|
||||
// component/Nav/index.js
|
||||
Component({
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
Text:{
|
||||
type:String,
|
||||
value:"衡水喜屏智慧社区"
|
||||
},
|
||||
NavPosition:{
|
||||
type:String,
|
||||
value:'fixed'
|
||||
},
|
||||
backColor:{
|
||||
type:String,
|
||||
value:"#000"
|
||||
},
|
||||
backSize:{
|
||||
type:String,
|
||||
value:"36rpx"
|
||||
},
|
||||
backImg:{
|
||||
type:String,
|
||||
value:"arrow-left"
|
||||
},
|
||||
pageUrl:{
|
||||
type:String,
|
||||
value:""
|
||||
},
|
||||
//返回上一页的类型 0返回上一页 1去底部导航 2不保留当前页面跳转 除了0其他必须有pageUrl
|
||||
backType:{
|
||||
type:String,
|
||||
value:0
|
||||
},
|
||||
color:{
|
||||
type:String,
|
||||
value:'#000'
|
||||
},
|
||||
showBack:{
|
||||
type:Boolean,
|
||||
value:true
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
s: app.system.statusBarHeight, // 状态栏高度
|
||||
n: (app.menu.top - app.system.statusBarHeight) * 2 + app.menu.height, // 导航栏高度
|
||||
t: app.menu.top, // 胶囊局顶部距离
|
||||
h: app.menu.height, // 胶囊高度
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
handleNavigateBack(){
|
||||
let that = this
|
||||
if(that.data.backType == 0){
|
||||
wx.navigateBack({
|
||||
delta:1
|
||||
})
|
||||
}else if(that.data.backType == 1 && that.data.pageUrl){
|
||||
wx.switchTab({
|
||||
url: `/pages/${that.data.pageUrl}/${that.data.pageUrl}`,
|
||||
})
|
||||
}else if(that.data.backType == 2 && that.data.pageUrl){
|
||||
wx.redirectTo({
|
||||
url: `/pages/${that.data.pageUrl}/${that.data.pageUrl}`,
|
||||
})
|
||||
}else if(that.data.backType != 0){
|
||||
wx.showToast({
|
||||
title: '请传pageUrl',
|
||||
icon:"none"
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
4
component/Nav/Nav.json
Normal file
4
component/Nav/Nav.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
16
component/Nav/Nav.wxml
Normal file
16
component/Nav/Nav.wxml
Normal file
@ -0,0 +1,16 @@
|
||||
<view class="nav-box" style="padding-top: {{ t }}px;position: {{NavPosition}};">
|
||||
<view class="nav-bar" style="height: {{ h }}px;">
|
||||
<view class="nav-bar-left" bindtap="handleNavigateBack" >
|
||||
<van-icon name="{{backImg}}" color="{{backColor}}" size="{{backSize}}"></van-icon>
|
||||
</view>
|
||||
|
||||
<view class="nav-bar-title" style="height: {{ h }}px;line-height: {{ h }}px;color: {{color}};">
|
||||
{{Text}}
|
||||
</view>
|
||||
|
||||
<view class="nav-bar-right">
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
42
component/Nav/Nav.wxss
Normal file
42
component/Nav/Nav.wxss
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
/* 自定义导航栏 */
|
||||
.nav-box {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
/* position: relative; */
|
||||
/* position: fixed; */
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar .nav-bar-left,
|
||||
.nav-box .nav-bar .nav-bar-right {
|
||||
padding: 0 20rpx;
|
||||
min-width: 36rpx;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar .nav-bar-left van-icon {
|
||||
vertical-align: sub;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar .nav-bar-title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
letter-spacing: 2rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.nav-box .nav-bar-title {
|
||||
color: red;
|
||||
margin-left: -40rpx;
|
||||
}
|
||||
|
||||
/* .nav-bar-right{
|
||||
display: none;
|
||||
} */
|
||||
65
component/card/index.js
Normal file
65
component/card/index.js
Normal file
@ -0,0 +1,65 @@
|
||||
import { stateType } from '../../constants/index';
|
||||
import { img_url } from '../../utils/util';
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
isTopShow: { // 接口通过后根据传递订单编号判断是否展示头部区域
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
isBottomShow: { // 是否显示底部按钮
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
shopInfoShow: { // 是否展示商铺信息
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
state: { // 商品状态 默认不展示
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
headerText: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
headerDesc: {
|
||||
type: String,
|
||||
value: ''
|
||||
},
|
||||
item: {
|
||||
type: Object,
|
||||
value: null,
|
||||
}
|
||||
|
||||
},
|
||||
data: {
|
||||
stateType,
|
||||
picUrl: img_url,
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleLeftClick(e) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
this.triggerEvent('orde', id)
|
||||
},
|
||||
// 详情点击事件
|
||||
handleOptionClick(e) {
|
||||
const { id, ordersn } = e.currentTarget.dataset;
|
||||
// 触发父组件方法 传递订单id 及订单编号
|
||||
this.triggerEvent('details', {id, ordersn});
|
||||
},
|
||||
handleRigthClick(e) {
|
||||
const { item } = e.currentTarget.dataset;
|
||||
if (item.status !== 1) {
|
||||
wx.showToast({
|
||||
title: '当前订单状态无法进行支付',
|
||||
icon: 'none',
|
||||
})
|
||||
return;
|
||||
}
|
||||
// 触发父组件方法
|
||||
this.triggerEvent('goPay', item);
|
||||
}
|
||||
}
|
||||
})
|
||||
4
component/card/index.json
Normal file
4
component/card/index.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
37
component/card/index.wxml
Normal file
37
component/card/index.wxml
Normal file
@ -0,0 +1,37 @@
|
||||
<view class="card">
|
||||
<view class="header" wx:if="{{isTopShow}}">
|
||||
<view class="code">{{headerText}}{{headerDesc}}</view>
|
||||
<view class="state" wx:if="{{state}}">{{stateType[item.status]}}</view>
|
||||
</view>
|
||||
<view class="main">
|
||||
<image class="left_icon" wx:if="{{shopInfoShow}}" src="{{picUrl}}{{item.photo}}" mode=""/>
|
||||
<image class="left_icon" wx:else="" src="{{picUrl}}{{item.appoint.photo}}" mode=""/>
|
||||
<!-- 根据参数shopInfoShow来渲染3行 -->
|
||||
<view class="shop_detail" wx:if="{{shopInfoShow}}">
|
||||
<view class="shop_detail_desc">{{item.shop_name}}</view>
|
||||
<view class="shop_detail_desc">电话:{{item.tel}}</view>
|
||||
<view class="shop_detail_desc">地址:{{item.addr}}</view>
|
||||
</view>
|
||||
|
||||
<view class="main_right" wx:else>
|
||||
<view class="article_title">{{item.appoint.title}}</view>
|
||||
<view class="article_subTitle">
|
||||
小计:
|
||||
<text class="article_symbol">¥</text>
|
||||
<text class="article_desc">{{item.total_price}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{isBottomShow}}" class="bottom">
|
||||
<view class="price article_subTitle">
|
||||
总价
|
||||
<text class="price_symbol article_symbol">¥</text>
|
||||
<text class="price_desc article_desc">{{item.total_price}}</text>
|
||||
</view>
|
||||
<view class="bottom_btn">
|
||||
<view class="btn btn_left" data-id="{{item.order_id}}" bindtap="handleLeftClick">取消订单</view>
|
||||
<view class="btn btn_center" data-orderSn="{{item.order_sn}}" data-id="{{item.order_id}}" bindtap="handleOptionClick">详情</view>
|
||||
<view class="btn btn_right" data-item="{{item}}" bindtap="handleRigthClick">去付款</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
97
component/card/index.wxss
Normal file
97
component/card/index.wxss
Normal file
@ -0,0 +1,97 @@
|
||||
.card {
|
||||
margin: 0 18rpx 30rpx 20rpx;
|
||||
}
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
.code {
|
||||
flex: 1;
|
||||
font-weight: bold;
|
||||
color: #222222;
|
||||
overflow: hidden; /* 隐藏溢出内容 */
|
||||
text-overflow: ellipsis; /* 添加省略号 */
|
||||
white-space: nowrap; /* 防止文本换行 */
|
||||
}
|
||||
.state {
|
||||
width: 100rpx;
|
||||
color: #FF512A;
|
||||
font-weight: bold;
|
||||
}
|
||||
.main {
|
||||
display: flex;
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
.left_icon {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
border-radius: 30rpx 30rpx 30rpx 30rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
.main_right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
.article_title {
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
color: #000000;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
.article_subTitle {
|
||||
font-size: 26rpx;
|
||||
font-weight: 400;
|
||||
color: #222222;
|
||||
}
|
||||
.article_symbol {
|
||||
font-size: 22rpx;
|
||||
color: #FF512A;
|
||||
font-weight: 400;
|
||||
}
|
||||
.article_desc {
|
||||
font-weight: 500;
|
||||
font-size: 36rpx;
|
||||
color: #FF512A;
|
||||
}
|
||||
.bottom {
|
||||
margin-top: 12rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.bottom_btn {
|
||||
display: flex;
|
||||
}
|
||||
.btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #999999;
|
||||
border-radius: 100rpx 100rpx 100rpx 100rpx;
|
||||
font-size: 26rpx;
|
||||
color: #FFFFFF;
|
||||
font-weight: 400;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.btn:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
.btn_left {
|
||||
padding: 10rpx 23rpx;
|
||||
}
|
||||
.btn_center {
|
||||
padding: 10rpx 24rpx;
|
||||
background: #D5AC66;
|
||||
}
|
||||
.btn_right {
|
||||
padding: 10rpx 11rpx;
|
||||
background: #FF512A;
|
||||
}
|
||||
|
||||
.shop_detail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
285
component/ec-canvas/ec-canvas.js
Normal file
285
component/ec-canvas/ec-canvas.js
Normal file
@ -0,0 +1,285 @@
|
||||
import WxCanvas from './wx-canvas';
|
||||
import * as echarts from './echarts';
|
||||
|
||||
|
||||
let ctx;
|
||||
|
||||
function compareVersion(v1, v2) {
|
||||
v1 = v1.split('.')
|
||||
v2 = v2.split('.')
|
||||
const len = Math.max(v1.length, v2.length)
|
||||
|
||||
while (v1.length < len) {
|
||||
v1.push('0')
|
||||
}
|
||||
while (v2.length < len) {
|
||||
v2.push('0')
|
||||
}
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
const num1 = parseInt(v1[i])
|
||||
const num2 = parseInt(v2[i])
|
||||
|
||||
if (num1 > num2) {
|
||||
return 1
|
||||
} else if (num1 < num2) {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
canvasId: {
|
||||
type: String,
|
||||
value: 'ec-canvas'
|
||||
},
|
||||
|
||||
ec: {
|
||||
type: Object
|
||||
},
|
||||
|
||||
forceUseOldCanvas: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
isUseNewCanvas: false
|
||||
},
|
||||
|
||||
ready: function () {
|
||||
// Disable prograssive because drawImage doesn't support DOM as parameter
|
||||
// See https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html
|
||||
echarts.registerPreprocessor(option => {
|
||||
if (option && option.series) {
|
||||
if (option.series.length > 0) {
|
||||
option.series.forEach(series => {
|
||||
series.progressive = 0;
|
||||
});
|
||||
}
|
||||
else if (typeof option.series === 'object') {
|
||||
option.series.progressive = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.data.ec) {
|
||||
console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" '
|
||||
+ 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.data.ec.lazyLoad) {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
init: function (callback) {
|
||||
const version = wx.getSystemInfoSync().SDKVersion
|
||||
|
||||
const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0;
|
||||
const forceUseOldCanvas = this.data.forceUseOldCanvas;
|
||||
const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas;
|
||||
this.setData({ isUseNewCanvas });
|
||||
|
||||
if (forceUseOldCanvas && canUseNewCanvas) {
|
||||
console.warn('开发者强制使用旧canvas,建议关闭');
|
||||
}
|
||||
|
||||
if (isUseNewCanvas) {
|
||||
// console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>');
|
||||
// 2.9.0 可以使用 <canvas type="2d"></canvas>
|
||||
this.initByNewWay(callback);
|
||||
} else {
|
||||
const isValid = compareVersion(version, '1.9.91') >= 0
|
||||
if (!isValid) {
|
||||
console.error('微信基础库版本过低,需大于等于 1.9.91。'
|
||||
+ '参见:https://github.com/ecomfe/echarts-for-weixin'
|
||||
+ '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82');
|
||||
return;
|
||||
} else {
|
||||
console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能');
|
||||
this.initByOldWay(callback);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
initByOldWay(callback) {
|
||||
// 1.9.91 <= version < 2.9.0:原来的方式初始化
|
||||
ctx = wx.createCanvasContext(this.data.canvasId, this);
|
||||
const canvas = new WxCanvas(ctx, this.data.canvasId, false);
|
||||
|
||||
if (echarts.setPlatformAPI) {
|
||||
echarts.setPlatformAPI({
|
||||
createCanvas: () => canvas,
|
||||
});
|
||||
} else {
|
||||
echarts.setCanvasCreator(() => canvas);
|
||||
};
|
||||
// const canvasDpr = wx.getSystemInfoSync().pixelRatio // 微信旧的canvas不能传入dpr
|
||||
const canvasDpr = 1
|
||||
var query = wx.createSelectorQuery().in(this);
|
||||
query.select('.ec-canvas').boundingClientRect(res => {
|
||||
if (typeof callback === 'function') {
|
||||
this.chart = callback(canvas, res.width, res.height, canvasDpr);
|
||||
}
|
||||
else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
|
||||
this.chart = this.data.ec.onInit(canvas, res.width, res.height, canvasDpr);
|
||||
}
|
||||
else {
|
||||
this.triggerEvent('init', {
|
||||
canvas: canvas,
|
||||
width: res.width,
|
||||
height: res.height,
|
||||
canvasDpr: canvasDpr // 增加了dpr,可方便外面echarts.init
|
||||
});
|
||||
}
|
||||
}).exec();
|
||||
},
|
||||
|
||||
initByNewWay(callback) {
|
||||
// version >= 2.9.0:使用新的方式初始化
|
||||
const query = wx.createSelectorQuery().in(this)
|
||||
query
|
||||
.select('.ec-canvas')
|
||||
.fields({ node: true, size: true })
|
||||
.exec(res => {
|
||||
const canvasNode = res[0].node
|
||||
this.canvasNode = canvasNode
|
||||
|
||||
const canvasDpr = wx.getSystemInfoSync().pixelRatio
|
||||
const canvasWidth = res[0].width
|
||||
const canvasHeight = res[0].height
|
||||
|
||||
const ctx = canvasNode.getContext('2d')
|
||||
|
||||
const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode)
|
||||
if (echarts.setPlatformAPI) {
|
||||
echarts.setPlatformAPI({
|
||||
createCanvas: () => canvas,
|
||||
loadImage: (src, onload, onerror) => {
|
||||
if (canvasNode.createImage) {
|
||||
const image = canvasNode.createImage();
|
||||
image.onload = onload;
|
||||
image.onerror = onerror;
|
||||
image.src = src;
|
||||
return image;
|
||||
}
|
||||
console.error('加载图片依赖 `Canvas.createImage()` API,要求小程序基础库版本在 2.7.0 及以上。');
|
||||
// PENDING fallback?
|
||||
}
|
||||
})
|
||||
} else {
|
||||
echarts.setCanvasCreator(() => canvas)
|
||||
}
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr)
|
||||
} else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
|
||||
this.chart = this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr)
|
||||
} else {
|
||||
this.triggerEvent('init', {
|
||||
canvas: canvas,
|
||||
width: canvasWidth,
|
||||
height: canvasHeight,
|
||||
dpr: canvasDpr
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
canvasToTempFilePath(opt) {
|
||||
if (this.data.isUseNewCanvas) {
|
||||
// 新版
|
||||
const query = wx.createSelectorQuery().in(this)
|
||||
query
|
||||
.select('.ec-canvas')
|
||||
.fields({ node: true, size: true })
|
||||
.exec(res => {
|
||||
const canvasNode = res[0].node
|
||||
opt.canvas = canvasNode
|
||||
wx.canvasToTempFilePath(opt)
|
||||
})
|
||||
} else {
|
||||
// 旧的
|
||||
if (!opt.canvasId) {
|
||||
opt.canvasId = this.data.canvasId;
|
||||
}
|
||||
ctx.draw(true, () => {
|
||||
wx.canvasToTempFilePath(opt, this);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
touchStart(e) {
|
||||
if (this.chart && e.touches.length > 0) {
|
||||
var touch = e.touches[0];
|
||||
var handler = this.chart.getZr().handler;
|
||||
handler.dispatch('mousedown', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.dispatch('mousemove', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.processGesture(wrapTouch(e), 'start');
|
||||
}
|
||||
},
|
||||
|
||||
touchMove(e) {
|
||||
if (this.chart && e.touches.length > 0) {
|
||||
var touch = e.touches[0];
|
||||
var handler = this.chart.getZr().handler;
|
||||
handler.dispatch('mousemove', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.processGesture(wrapTouch(e), 'change');
|
||||
}
|
||||
},
|
||||
|
||||
touchEnd(e) {
|
||||
if (this.chart) {
|
||||
const touch = e.changedTouches ? e.changedTouches[0] : {};
|
||||
var handler = this.chart.getZr().handler;
|
||||
handler.dispatch('mouseup', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.dispatch('click', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.processGesture(wrapTouch(e), 'end');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function wrapTouch(event) {
|
||||
for (let i = 0; i < event.touches.length; ++i) {
|
||||
const touch = event.touches[i];
|
||||
touch.offsetX = touch.x;
|
||||
touch.offsetY = touch.y;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
4
component/ec-canvas/ec-canvas.json
Normal file
4
component/ec-canvas/ec-canvas.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
4
component/ec-canvas/ec-canvas.wxml
Normal file
4
component/ec-canvas/ec-canvas.wxml
Normal file
@ -0,0 +1,4 @@
|
||||
<!-- 新的:接口对其了H5 -->
|
||||
<canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
|
||||
<!-- 旧的 -->
|
||||
<canvas wx:else class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
|
||||
4
component/ec-canvas/ec-canvas.wxss
Normal file
4
component/ec-canvas/ec-canvas.wxss
Normal file
@ -0,0 +1,4 @@
|
||||
.ec-canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
45
component/ec-canvas/echarts.js
Normal file
45
component/ec-canvas/echarts.js
Normal file
File diff suppressed because one or more lines are too long
111
component/ec-canvas/wx-canvas.js
Normal file
111
component/ec-canvas/wx-canvas.js
Normal file
@ -0,0 +1,111 @@
|
||||
export default class WxCanvas {
|
||||
constructor(ctx, canvasId, isNew, canvasNode) {
|
||||
this.ctx = ctx;
|
||||
this.canvasId = canvasId;
|
||||
this.chart = null;
|
||||
this.isNew = isNew
|
||||
if (isNew) {
|
||||
this.canvasNode = canvasNode;
|
||||
}
|
||||
else {
|
||||
this._initStyle(ctx);
|
||||
}
|
||||
|
||||
// this._initCanvas(zrender, ctx);
|
||||
|
||||
this._initEvent();
|
||||
}
|
||||
|
||||
getContext(contextType) {
|
||||
if (contextType === '2d') {
|
||||
return this.ctx;
|
||||
}
|
||||
}
|
||||
|
||||
// canvasToTempFilePath(opt) {
|
||||
// if (!opt.canvasId) {
|
||||
// opt.canvasId = this.canvasId;
|
||||
// }
|
||||
// return wx.canvasToTempFilePath(opt, this);
|
||||
// }
|
||||
|
||||
setChart(chart) {
|
||||
this.chart = chart;
|
||||
}
|
||||
|
||||
addEventListener() {
|
||||
// noop
|
||||
}
|
||||
|
||||
attachEvent() {
|
||||
// noop
|
||||
}
|
||||
|
||||
detachEvent() {
|
||||
// noop
|
||||
}
|
||||
|
||||
_initCanvas(zrender, ctx) {
|
||||
zrender.util.getContext = function () {
|
||||
return ctx;
|
||||
};
|
||||
|
||||
zrender.util.$override('measureText', function (text, font) {
|
||||
ctx.font = font || '12px sans-serif';
|
||||
return ctx.measureText(text);
|
||||
});
|
||||
}
|
||||
|
||||
_initStyle(ctx) {
|
||||
ctx.createRadialGradient = () => {
|
||||
return ctx.createCircularGradient(arguments);
|
||||
};
|
||||
}
|
||||
|
||||
_initEvent() {
|
||||
this.event = {};
|
||||
const eventNames = [{
|
||||
wxName: 'touchStart',
|
||||
ecName: 'mousedown'
|
||||
}, {
|
||||
wxName: 'touchMove',
|
||||
ecName: 'mousemove'
|
||||
}, {
|
||||
wxName: 'touchEnd',
|
||||
ecName: 'mouseup'
|
||||
}, {
|
||||
wxName: 'touchEnd',
|
||||
ecName: 'click'
|
||||
}];
|
||||
eventNames.forEach(name => {
|
||||
this.event[name.wxName] = e => {
|
||||
const touch = e.touches[0];
|
||||
this.chart.getZr().handler.dispatch(name.ecName, {
|
||||
zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
|
||||
zrY: name.wxName === 'tap' ? touch.clientY : touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
set width(w) {
|
||||
if (this.canvasNode) this.canvasNode.width = w
|
||||
}
|
||||
set height(h) {
|
||||
if (this.canvasNode) this.canvasNode.height = h
|
||||
}
|
||||
|
||||
get width() {
|
||||
if (this.canvasNode)
|
||||
return this.canvasNode.width
|
||||
return 0
|
||||
}
|
||||
get height() {
|
||||
if (this.canvasNode)
|
||||
return this.canvasNode.height
|
||||
return 0
|
||||
}
|
||||
}
|
||||
97
component/footer/index.js
Normal file
97
component/footer/index.js
Normal file
@ -0,0 +1,97 @@
|
||||
import apiAddr from '../../api/base';
|
||||
import { setData } from '../../utils/index';
|
||||
|
||||
Component({
|
||||
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
nav_list:[],
|
||||
foot_width:'20%',
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
getFootnav(){
|
||||
let _that = this;
|
||||
wx.request({
|
||||
url: apiAddr.footer_nav_list,
|
||||
method: 'post',
|
||||
header: { 'Content-type': 'application/x-www-form-urlencoded' },
|
||||
data: {},
|
||||
dataType: 'json',
|
||||
success: (result) => {
|
||||
|
||||
// let communityId = wx.getStorageSync('communityId')
|
||||
// let communityIdArr = ''
|
||||
// communityIdArr = communityId.join(',')
|
||||
// console.log(communityIdArr,'communityIdcommunityId');
|
||||
|
||||
result.data[0].url = "/pages/index/newIndex/newIndex"
|
||||
result.data[1].url = "/pages/device/device"
|
||||
result.data[2].nav_name = "手机通行"
|
||||
result.data[2].url = "/pages/phoneGo/phoneGo"
|
||||
// result.data[3].url = `/packages/community/communityList/index?communityId=${communityIdArr}`
|
||||
result.data[3].url = `/packages/community/communityList/index`
|
||||
result.data[4].url = "/pages/index/index"
|
||||
|
||||
result.data.splice(1, 2);
|
||||
|
||||
setData(_that,'nav_list', result.data);
|
||||
setData(_that,'foot_width', (100/result.data.length).toFixed(2)+'%');
|
||||
},
|
||||
});
|
||||
},
|
||||
//暂未开通
|
||||
NotOpen(){
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '此功能暂未开通!',
|
||||
showCancel:false,
|
||||
complete: (res) => {
|
||||
if (res.cancel) {
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
jump(e){
|
||||
const ctoken = wx.getStorageSync('ctoken');
|
||||
const authen = ['/pages/index/newIndex/newIndex', '/pages/index/index'];
|
||||
// 除首页及个人中心页不需要鉴定ctoken, 其他tab页均需存在登录态才可访问
|
||||
if (authen.includes(e.currentTarget.dataset.url)) {
|
||||
wx.redirectTo({
|
||||
url: e.currentTarget.dataset.url,
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!ctoken) {
|
||||
wx.redirectTo({
|
||||
url: '/pages/login/login',
|
||||
})
|
||||
return;
|
||||
}
|
||||
wx.redirectTo({
|
||||
url: e.currentTarget.dataset.url,
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
attached: function () {
|
||||
// 组件被添加到页面节点树时执行
|
||||
this.getFootnav();
|
||||
},
|
||||
},
|
||||
})
|
||||
4
component/footer/index.json
Normal file
4
component/footer/index.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
9
component/footer/index.wxml
Normal file
9
component/footer/index.wxml
Normal file
@ -0,0 +1,9 @@
|
||||
<view class="foot-fixed">
|
||||
<block wx:for="{{nav_list}}" wx:key="unique">
|
||||
<!-- <view>{{item.photo}}</view> -->
|
||||
<view id="navIndex" bind:tap="jump" data-idx="{{index}}" data-url="{{item.url}}" style="width:{{foot_width}}" class="foot-item">
|
||||
<view class="foot-icon" style="background: url({{item.photo}}) center center no-repeat; background-size: contain;"></view>
|
||||
<text class="foot-label" id="navIndexLabel">{{item.nav_name}}</text>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
3
component/footer/index.wxss
Normal file
3
component/footer/index.wxss
Normal file
@ -0,0 +1,3 @@
|
||||
/* pages/public/footer.wxss */
|
||||
@import "../../app.wxss";
|
||||
|
||||
125
component/privacyDialog/index.js
Normal file
125
component/privacyDialog/index.js
Normal file
@ -0,0 +1,125 @@
|
||||
let privacyHandler
|
||||
let privacyResolves = new Set()
|
||||
let closeOtherPageshowDialogHooks = new Set()
|
||||
|
||||
if (wx.onNeedPrivacyAuthorization) {
|
||||
wx.onNeedPrivacyAuthorization(resolve => {
|
||||
if (typeof privacyHandler === 'function') {
|
||||
privacyHandler(resolve)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const closeOtherPageshowDialog = (closeDialog) => {
|
||||
closeOtherPageshowDialogHooks.forEach(hook => {
|
||||
if (closeDialog !== hook) {
|
||||
hook()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Component({
|
||||
data: {
|
||||
visible: false,
|
||||
mini_logo: __wxConfig.accountInfo.icon,
|
||||
mini_name: __wxConfig.accountInfo.nickname
|
||||
},
|
||||
properties: {
|
||||
useSafeArea: { // 是否在非tabBar页面引用
|
||||
type: Boolean,
|
||||
value: true
|
||||
}
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
const closeDialog = () => {
|
||||
this.hideDialog()
|
||||
}
|
||||
privacyHandler = resolve => {
|
||||
privacyResolves.add(resolve)
|
||||
this.showDialog()
|
||||
// 额外逻辑:当前页面的隐私弹窗弹起的时候,关掉其他页面的隐私弹窗
|
||||
closeOtherPageshowDialog(closeDialog)
|
||||
}
|
||||
closeOtherPageshowDialogHooks.add(closeDialog)
|
||||
this.closeDialog = closeDialog
|
||||
},
|
||||
detached() {
|
||||
closeOtherPageshowDialogHooks.delete(this.closeDialog)
|
||||
this.handleDisagree()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleAgree() {
|
||||
this.hideDialog()
|
||||
// 这里演示了同时调用多个wx隐私接口时要如何处理:让隐私弹窗保持单例,点击一次同意按钮即可让所有pending中的wx隐私接口继续执行
|
||||
privacyResolves.forEach(resolve => {
|
||||
resolve({
|
||||
event: 'agree',
|
||||
buttonId: 'agree-btn'
|
||||
})
|
||||
})
|
||||
privacyResolves.clear()
|
||||
},
|
||||
handleDisagree(e) {
|
||||
this.hideDialog()
|
||||
privacyResolves.forEach(resolve => {
|
||||
resolve({
|
||||
event: 'disagree'
|
||||
})
|
||||
})
|
||||
privacyResolves.clear()
|
||||
wx.exitMiniProgram();
|
||||
},
|
||||
showDialog() {
|
||||
if (!this.data.visible) {
|
||||
this.setData({
|
||||
visible: true
|
||||
})
|
||||
wx.setPageStyle({
|
||||
style: {
|
||||
overflow: 'hidden'
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
hideDialog() {
|
||||
if (this.data.visible) {
|
||||
this.setData({
|
||||
visible: false
|
||||
})
|
||||
wx.setPageStyle({
|
||||
style: {
|
||||
overflow: 'auto'
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
openPrivacyContract() {
|
||||
wx.openPrivacyContract({
|
||||
success: res => {
|
||||
console.log('openPrivacyContract success', res)
|
||||
},
|
||||
fail: err => {
|
||||
console.error('openPrivacyContract fail', err)
|
||||
}
|
||||
})
|
||||
},
|
||||
tabBarPageShow() {
|
||||
this.handleDisagree()
|
||||
if (this.closeDialog) {
|
||||
privacyHandler = resolve => {
|
||||
privacyResolves.add(resolve)
|
||||
this.showDialog()
|
||||
// 额外逻辑:当前页面的隐私弹窗弹起的时候,关掉其他页面的隐私弹窗
|
||||
closeOtherPageshowDialog(this.closeDialog)
|
||||
}
|
||||
}
|
||||
},
|
||||
openUserAgreementConfig(){
|
||||
wx.navigateTo({
|
||||
url: '/pages/index/illustrate?type=miniprogram_user_agreement',
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
4
component/privacyDialog/index.json
Normal file
4
component/privacyDialog/index.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
16
component/privacyDialog/index.wxml
Normal file
16
component/privacyDialog/index.wxml
Normal file
@ -0,0 +1,16 @@
|
||||
<view class="privacy-dialog {{visible ? 'active' : ''}}">
|
||||
<view class="privacy-back {{visible ? 'active' : ''}}"></view>
|
||||
<view class="privacy-container {{visible ? 'active' : ''}} {{useSafeArea ? 'change' : ''}}">
|
||||
<view class="privacy-info">
|
||||
<image src="{{mini_logo}}" mode="widthFix" class="privacy-logo" />
|
||||
<text class="privacy-name">{{mini_name}}</text>
|
||||
</view>
|
||||
<!-- <view class="privacy-text">在您使用【{{mini_name}}】服务之前,请仔细阅读<text bindtap="openPrivacyContract">《{{mini_name}}隐私保护指引》</text>。如您同意,《{{mini_name}}隐私保护指引》,请点击“同意”开始使用【{{mini_name}}】</view> -->
|
||||
<view class="privacy-text">尊敬的用户,欢迎使用“{{mini_name}}”,我们非常注重您的个人隐私,为了更好地保护您的个人信息,在您使用产品服务前,请仔细阅读<text bindtap="openPrivacyContract">《{{mini_name}}隐私保护政策》</text>和<text bindtap="openUserAgreementConfig">《用户协议》</text>,需要您同意我们收集、使用和保护您的个人信息,我们将严格遵守相关法律法规、监管政策,保护您的个人信息安全。如您同意此政策,请点击“同意”并开始使用我们的产品,如您不同意,我们将无法进一步为您提供服务。</view>
|
||||
<!-- 尊敬的用户,欢迎使用“xxx”,我们非常注重您的个人隐私,为了更好地保护您的个人信息,在您使用产品服务前,请仔细阅读《xxxx》和《服务使用协议》,需要您同意我们收集、使用和保护您的个人信息,我们将严格遵守相关法律法规、监管政策,保护您的个人信息安全。如您同意此政策,请点击“同意”并开始使用我们的产品和服务,如您不同意,我们将无法进一步为您提供服务。 -->
|
||||
<view class="privacy-btns">
|
||||
<button id="disagree-btn" class="privacy-cancel-btn" bindtap="handleDisagree">不同意并退出</button>
|
||||
<button id="agree-btn" open-type="agreePrivacyAuthorization" class="privacy-confirm-btn" bindagreeprivacyauthorization="handleAgree">同意并继续</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
123
component/privacyDialog/index.wxss
Normal file
123
component/privacyDialog/index.wxss
Normal file
@ -0,0 +1,123 @@
|
||||
@import "/app.wxss";
|
||||
|
||||
.privacy-dialog {
|
||||
width: 100%;
|
||||
visibility: hidden;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.privacy-dialog.active {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.privacy-back {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 8888;
|
||||
opacity: 0;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.privacy-back.active {
|
||||
opacity: 1;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.privacy-container {
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 9999;
|
||||
border-radius: 32rpx 32rpx 0 0;
|
||||
padding: 48rpx;
|
||||
transform: translateY(100%);
|
||||
transition: all 0.3s;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.privacy-container.active {
|
||||
transform: translateY(0%);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.privacy-container.change {
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 32rpx);
|
||||
}
|
||||
|
||||
.privacy-info {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.privacy-logo {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.privacy-name {
|
||||
margin-left: 8rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.privacy-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin: 32rpx 0;
|
||||
letter-spacing: 2rpx;
|
||||
}
|
||||
|
||||
.privacy-text text {
|
||||
color: #1277FF;
|
||||
}
|
||||
|
||||
.privacy-btns {
|
||||
width: auto;
|
||||
display: flex;
|
||||
margin: 0 auto;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.privacy-cancel-btn {
|
||||
width: 45%;
|
||||
height: 90rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 14rpx;
|
||||
color: #07c160;
|
||||
background-color: #F2F2F2;
|
||||
font-weight: 500;
|
||||
margin: 10px !important;
|
||||
padding: 0;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.privacy-confirm-btn {
|
||||
width: 45%;
|
||||
height: 90rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 14rpx;
|
||||
color: #fff;
|
||||
background: #07c160;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
margin: 10px !important;
|
||||
padding: 0;
|
||||
}
|
||||
209
component/search/index.js
Normal file
209
component/search/index.js
Normal file
@ -0,0 +1,209 @@
|
||||
import { doNavigateWithUser } from '../../utils/helper';
|
||||
import apiAddr from '../../api/base';
|
||||
|
||||
const app = getApp();
|
||||
Component({
|
||||
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
qqmap_key: app.initQQMapKey(),
|
||||
address: '定位中',
|
||||
selectKeyWord: '',
|
||||
shopArea: [],
|
||||
lat: '',
|
||||
lng: '',
|
||||
mapObj: {},
|
||||
},
|
||||
|
||||
methods: {
|
||||
goPagesLink() {
|
||||
doNavigateWithUser({
|
||||
url: `/pages/index/shopcity`
|
||||
});
|
||||
},
|
||||
|
||||
// 获取地址
|
||||
getAddress() {
|
||||
let that = this;
|
||||
let userlocat = wx.getStorageSync('userlocat');
|
||||
let nowtime = Date.parse(new Date()) / 1000;
|
||||
if (!userlocat || userlocat.overtime < nowtime || !userlocat.city) {
|
||||
wx.showLoading({
|
||||
title: '定位中...'
|
||||
});
|
||||
wx.getLocation({
|
||||
success: (res) => {
|
||||
console.log(res);
|
||||
let overtime = Date.parse(new Date()) / 1000 + 7200;
|
||||
|
||||
this.setData({
|
||||
lat: res.latitude,
|
||||
lng: res.longitude,
|
||||
})
|
||||
|
||||
if (this.data.qqmap_key) {
|
||||
// 微信逆地址解析
|
||||
wx.request({
|
||||
url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + res.latitude + ',' + res.longitude + '&key=' + this.data.qqmap_key + '&get_poi=0',
|
||||
success: function (res) {
|
||||
// console.log('cityres', res);
|
||||
var city = res.data.result.address_component.city;
|
||||
// console.log(city);
|
||||
if (city) {
|
||||
that.setData({
|
||||
address: city
|
||||
})
|
||||
let area = that.data.shopArea;
|
||||
// console.log(area);
|
||||
if (typeof area[city] !== 'undefined') {
|
||||
// setData(that,'area_id',area[city]['area_id']);
|
||||
}
|
||||
}
|
||||
userlocat = {
|
||||
userlat: that.data.lat,
|
||||
userlng: that.data.lng,
|
||||
overtime: overtime,
|
||||
city: city,
|
||||
};
|
||||
wx.setStorageSync('userlocat', userlocat);
|
||||
|
||||
wx.hideLoading();
|
||||
// that.setData({
|
||||
// pageNo: 0, // 当前页数
|
||||
// shopList: [],
|
||||
// })
|
||||
// that.getList();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('11111 走到这列了');
|
||||
let sendData = {
|
||||
lat: res.latitude,
|
||||
lng: res.longitude,
|
||||
};
|
||||
// 后端地图接口
|
||||
wx.request({
|
||||
url: apiAddr.get_maps_geocoder,
|
||||
method: 'post',
|
||||
header: {
|
||||
'Content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
dataType: 'json',
|
||||
data: sendData,
|
||||
success: function (res) {
|
||||
// console.log('cityres2', res);
|
||||
var city = res.data.city;
|
||||
// console.log(city);
|
||||
if (city) {
|
||||
that.setData({
|
||||
address: city
|
||||
})
|
||||
let area = that.data.shopArea;
|
||||
if (typeof area[city] !== 'undefined') {
|
||||
// setData(that,'area_id',area[city]['area_id']);
|
||||
}
|
||||
}
|
||||
|
||||
userlocat = {
|
||||
userlat: that.data.lat,
|
||||
userlng: that.data.lng,
|
||||
overtime: overtime,
|
||||
city: city,
|
||||
};
|
||||
wx.setStorageSync('userlocat', userlocat);
|
||||
wx.hideLoading();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 缓存
|
||||
wx.request({
|
||||
url: apiAddr.setcookie_location,
|
||||
method: 'post',
|
||||
header: {
|
||||
'Content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
dataType: 'json',
|
||||
data: userlocat,
|
||||
success: (result) => {
|
||||
// console.log(result);
|
||||
},
|
||||
})
|
||||
},
|
||||
// fail: () => wx.showToast({ title: '请点击右上角三个点并开启位置权限', icon: 'none', mask: true })
|
||||
})
|
||||
|
||||
} else {
|
||||
// console.log('userlocat', userlocat);
|
||||
that.setData({
|
||||
address: userlocat.city
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
searchInput(e) {
|
||||
console.log('e',e);
|
||||
let _this = this;
|
||||
_this.setData({
|
||||
selectKeyWord: e.detail.value
|
||||
})
|
||||
_this.triggerEvent('search', e.detail.value);
|
||||
},
|
||||
|
||||
// 获取店铺区域列表
|
||||
getShopAreaList() {
|
||||
let shopArea = wx.getStorageSync('shopArea');
|
||||
let nowtime = Date.parse(new Date()) / 1000;
|
||||
if (!shopArea || shopArea.overtime < nowtime) {
|
||||
wx.request({
|
||||
url: apiAddr.get_community_area_list,
|
||||
method: 'get',
|
||||
header: {
|
||||
'Content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
dataType: 'json',
|
||||
success: (result) => {
|
||||
let {
|
||||
data: {
|
||||
list
|
||||
}
|
||||
} = result;
|
||||
if (list) {
|
||||
this.setData({
|
||||
shopArea: list
|
||||
})
|
||||
let overtime = Date.parse(new Date()) / 1000 + 7200;
|
||||
shopArea = {
|
||||
list: list,
|
||||
overtime: overtime
|
||||
};
|
||||
wx.setStorageSync('shopArea', shopArea);
|
||||
}
|
||||
},
|
||||
})
|
||||
} else {
|
||||
this.setData({
|
||||
shopArea: shopArea.list
|
||||
})
|
||||
// setData(this, 'shopArea', shopArea.list);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
attached: function () {
|
||||
// 组件被添加到页面节点树时执行
|
||||
this.getAddress();
|
||||
this.getShopAreaList();
|
||||
},
|
||||
},
|
||||
})
|
||||
4
component/search/index.json
Normal file
4
component/search/index.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
21
component/search/index.wxml
Normal file
21
component/search/index.wxml
Normal file
@ -0,0 +1,21 @@
|
||||
<view class="search">
|
||||
<view class="locat" catchtap="goPagesLink">
|
||||
<image class="local_left_icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/User/_assets/location.png" mode=""/>
|
||||
<text class="local_city">{{address}}</text>
|
||||
<van-icon name="arrow-down" color="#FF512A " />
|
||||
</view>
|
||||
<view class='search_bar'>
|
||||
<image class="search_icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/community/_assets/Group_36.png" mode=""/>
|
||||
<!-- bindinput="searchInput" -->
|
||||
<!-- bindblur="searchInput" -->
|
||||
<input
|
||||
class="search_input"
|
||||
placeholder='输入搜索的社区名称'
|
||||
confirm-type='search'
|
||||
bindinput="searchInput"
|
||||
bindconfirm="searchInput"
|
||||
value="{{ selectKeyWord }}"
|
||||
/>
|
||||
<!-- <image class="search_qrcode" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/community/_assets/Group_49.png" mode=""/> -->
|
||||
</view>
|
||||
</view>
|
||||
52
component/search/index.wxss
Normal file
52
component/search/index.wxss
Normal file
@ -0,0 +1,52 @@
|
||||
.container {
|
||||
background: #F9F9F9;
|
||||
}
|
||||
.search {
|
||||
width: 100%;
|
||||
height: 120rpx;
|
||||
display: flex;
|
||||
background: #F9F9F9;
|
||||
padding-top: 30rpx;
|
||||
padding-bottom: 30rpx;
|
||||
padding-left: 21rpx;
|
||||
}
|
||||
.locat {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.local_left_icon {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.local_city {
|
||||
font-weight: 400;
|
||||
font-size: 26rpx;
|
||||
color: #000000;
|
||||
margin-right: 13rpx;
|
||||
}
|
||||
|
||||
.search_bar {
|
||||
width: 536rpx;
|
||||
border-radius: 100rpx 100rpx 100rpx 100rpx;
|
||||
margin-left: 24rpx;
|
||||
margin-right: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #FFFFFF;
|
||||
flex: 1;
|
||||
}
|
||||
.search_input {
|
||||
flex: 1;
|
||||
}
|
||||
.search_icon {
|
||||
margin-left: 30rpx;
|
||||
margin-right: 15rpx;
|
||||
width: 33rpx;
|
||||
height: 33rpx;
|
||||
}
|
||||
.search_qrcode {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
margin-right: 27rpx;
|
||||
}
|
||||
121
component/tabularCard/index.js
Normal file
121
component/tabularCard/index.js
Normal file
@ -0,0 +1,121 @@
|
||||
import { doNavigateWithUser } from '../../utils/helper';
|
||||
import { isObjEmpty } from '../../utils/index';
|
||||
import { img_url } from '../../utils/util';
|
||||
|
||||
Component({
|
||||
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
item: { // 循环项
|
||||
type: Object,
|
||||
value: null,
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
value: ''
|
||||
},
|
||||
isLast: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
|
||||
joinType:{
|
||||
type:String,
|
||||
value:"2"
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
picUrl: img_url,
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
// 导航触发父组件方法
|
||||
handleOptionClick() {
|
||||
const { item } = this.data;
|
||||
let openParmas = {
|
||||
latitude: Number(item.lat),
|
||||
longitude: Number(item.lng),
|
||||
name: item.name,
|
||||
address: item.addr,
|
||||
}
|
||||
if (!isObjEmpty(openParmas)) {
|
||||
Object.assign(openParmas, this.bMapTransQQMap(openParmas.longitude, openParmas.latitude));
|
||||
wx.openLocation(openParmas);
|
||||
}
|
||||
},
|
||||
|
||||
// 地图转腾讯地图
|
||||
bMapTransQQMap: function (lng, lat) {
|
||||
return {
|
||||
longitude: lng,
|
||||
latitude: lat
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
//拨打电话触发事件
|
||||
headlePhoneClick() {
|
||||
const {
|
||||
item
|
||||
} = this.data;
|
||||
wx.makePhoneCall({
|
||||
phoneNumber: item.tel
|
||||
})
|
||||
},
|
||||
//进入小区
|
||||
headerEnterClick() {
|
||||
const {
|
||||
item,
|
||||
type
|
||||
} = this.data;
|
||||
if (type) {
|
||||
console.log('共享空间点击事件');
|
||||
return;
|
||||
}
|
||||
doNavigateWithUser({
|
||||
url: `/packages/community/dwelling/index?title=${item.name}&id=${item.community_id}`
|
||||
})
|
||||
},
|
||||
headerEnterClick2(e){
|
||||
let that = this
|
||||
if(that.data.joinType == 3){
|
||||
let community_id = e.currentTarget.dataset.id;
|
||||
let name = e.currentTarget.dataset.name;
|
||||
let that= this
|
||||
that.triggerEvent('chooseCommunity',{
|
||||
name,community_id
|
||||
})
|
||||
wx.navigateBack({
|
||||
delta:1
|
||||
})
|
||||
}else{
|
||||
console.log(456);
|
||||
that.headerEnterClick()
|
||||
}
|
||||
},
|
||||
//选择小区
|
||||
chooseClick(e){
|
||||
let community_id = e.currentTarget.dataset.id;
|
||||
let name = e.currentTarget.dataset.name;
|
||||
let that= this
|
||||
// that.triggerEvent('chooseCommunity',{
|
||||
// name,community_id
|
||||
// })
|
||||
wx.setStorageSync('currentCommunity', name)
|
||||
wx.setStorageSync('currentCommunityId', community_id)
|
||||
wx.navigateBack({
|
||||
delta:1
|
||||
})
|
||||
},
|
||||
}
|
||||
})
|
||||
4
component/tabularCard/index.json
Normal file
4
component/tabularCard/index.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
31
component/tabularCard/index.wxml
Normal file
31
component/tabularCard/index.wxml
Normal file
@ -0,0 +1,31 @@
|
||||
<view class="container" bind:tap="headerEnterClick2" data-id="{{item.community_id}}" data-name="{{item.name}}">
|
||||
<image class="left_logo" src="{{picUrl}}{{item.pic}}" mode="aspectFill"/>
|
||||
<view class="right {{isLast && 'no_bottom'}}">
|
||||
<view class="header">
|
||||
<view class="title">{{item.name}}</view>
|
||||
<view class="distance" wx:if="{{item.distance}}">{{item.distance}}</view>
|
||||
</view>
|
||||
<view class="center">物业公司:{{item.shop.shop_name}}</view>
|
||||
<view class="address">
|
||||
<image class="address_icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/community/_assets/Group_50.png" mode=""/>
|
||||
<view class="text-container">
|
||||
<text>{{item.addr}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom">
|
||||
<view class="bottom_left">
|
||||
<view class="btn" catch:tap="handleOptionClick">
|
||||
<image class="btn_icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/community/_assets/Send.png" mode="aspectFill"/>
|
||||
导航
|
||||
</view>
|
||||
<view class="btn mobile" catch:tap="headlePhoneClick">
|
||||
<image class="btn_icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/community/_assets/Phone-telephone.png" mode=""/>
|
||||
电话
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom_right" catch:tap="headerEnterClick" wx:if="{{joinType == 1}}">前往预定</view>
|
||||
<view class="bottom_right" catch:tap="headerEnterClick" wx:if="{{joinType == 2}}">进入小区</view>
|
||||
<view class="bottom_right" catch:tap="chooseClick" wx:if="{{joinType == 3}}" data-id="{{item.community_id}}" data-name="{{item.name}}">选择小区</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
99
component/tabularCard/index.wxss
Normal file
99
component/tabularCard/index.wxss
Normal file
@ -0,0 +1,99 @@
|
||||
.container {
|
||||
display: flex;
|
||||
padding-top: 32rpx;
|
||||
}
|
||||
.left_logo {
|
||||
width: 180rpx !important;
|
||||
height: 180rpx !important;
|
||||
margin-right: 30rpx;
|
||||
margin-left: 19rpx;
|
||||
}
|
||||
.right {
|
||||
flex: 1;
|
||||
margin-right: 21rpx;
|
||||
border-bottom: 1rpx solid #E6E6E6;
|
||||
max-width: 460rpx;
|
||||
}
|
||||
.no_bottom {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.title {
|
||||
font-weight: 400;
|
||||
font-size: 32rpx;
|
||||
color: #000000;
|
||||
margin-bottom: 14rpx;
|
||||
}
|
||||
.distance {
|
||||
font-weight: 400;
|
||||
font-size: 22rpx;
|
||||
color: rgba(168,104,43,0.8);
|
||||
}
|
||||
.center {
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #555555;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
.address {
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
margin-bottom: 25rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.address_icon {
|
||||
display: inline-block;
|
||||
width: 24rpx;
|
||||
height: 26rpx;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
.text-container {
|
||||
flex: 1;
|
||||
white-space: nowrap; /* 强制文本在一行内显示 */
|
||||
overflow: hidden; /* 隐藏超出容器的文本 */
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 35rpx;
|
||||
}
|
||||
.bottom_left {
|
||||
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
background: rgba(255,81,42,0.1);
|
||||
border-radius: 100rpx 100rpx 100rpx 100rpx;
|
||||
padding: 7rpx 22rpx 7rpx 0;
|
||||
}
|
||||
.mobile {
|
||||
background: #FFF2DA;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
.btn_icon {
|
||||
display: inline-block;
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 9rpx;
|
||||
margin-left: 11rpx;
|
||||
}
|
||||
.bottom_right {
|
||||
display: inline-block;
|
||||
font-weight: 400;
|
||||
font-size: 26rpx;
|
||||
color: #FFFFFF;
|
||||
padding: 10rpx 23rpx;
|
||||
background: #D5AC66;
|
||||
border-radius: 100rpx 100rpx 100rpx 100rpx;
|
||||
}
|
||||
10
constants/index.js
Normal file
10
constants/index.js
Normal file
@ -0,0 +1,10 @@
|
||||
export const stateType = {
|
||||
1: '待付款',
|
||||
2: '已付款',
|
||||
3: '已接单',
|
||||
4: '退款中',
|
||||
5: '已退款',
|
||||
6: '退单中',
|
||||
7: '已退单',
|
||||
8: '已完成'
|
||||
}
|
||||
1
miniprogram_npm/vant-weapp/action-sheet/index.d.ts
vendored
Normal file
1
miniprogram_npm/vant-weapp/action-sheet/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
78
miniprogram_npm/vant-weapp/action-sheet/index.js
Normal file
78
miniprogram_npm/vant-weapp/action-sheet/index.js
Normal file
@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var button_1 = require("../mixins/button");
|
||||
(0, component_1.VantComponent)({
|
||||
classes: ['list-class'],
|
||||
mixins: [button_1.button],
|
||||
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,
|
||||
},
|
||||
rootPortal: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onSelect: function (event) {
|
||||
var _this = this;
|
||||
var index = event.currentTarget.dataset.index;
|
||||
var _a = this.data, actions = _a.actions, closeOnClickAction = _a.closeOnClickAction, canIUseGetUserProfile = _a.canIUseGetUserProfile;
|
||||
var item = actions[index];
|
||||
if (item) {
|
||||
this.$emit('select', item);
|
||||
if (closeOnClickAction) {
|
||||
this.onClose();
|
||||
}
|
||||
if (item.openType === 'getUserInfo' && canIUseGetUserProfile) {
|
||||
wx.getUserProfile({
|
||||
desc: item.getUserProfileDesc || ' ',
|
||||
complete: function (userProfile) {
|
||||
_this.$emit('getuserinfo', userProfile);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
onCancel: function () {
|
||||
this.$emit('cancel');
|
||||
},
|
||||
onClose: function () {
|
||||
this.$emit('close');
|
||||
},
|
||||
onClickOverlay: function () {
|
||||
this.$emit('click-overlay');
|
||||
this.onClose();
|
||||
},
|
||||
},
|
||||
});
|
||||
8
miniprogram_npm/vant-weapp/action-sheet/index.json
Normal file
8
miniprogram_npm/vant-weapp/action-sheet/index.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index",
|
||||
"van-popup": "../popup/index",
|
||||
"van-loading": "../loading/index"
|
||||
}
|
||||
}
|
||||
70
miniprogram_npm/vant-weapp/action-sheet/index.wxml
Normal file
70
miniprogram_npm/vant-weapp/action-sheet/index.wxml
Normal file
@ -0,0 +1,70 @@
|
||||
<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 custom-class"
|
||||
safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
|
||||
close-on-click-overlay="{{ closeOnClickOverlay }}"
|
||||
root-portal="{{ rootPortal }}"
|
||||
bind:close="onClickOverlay"
|
||||
>
|
||||
<view wx:if="{{ title }}" class="van-action-sheet__header">
|
||||
{{ title }}
|
||||
<van-icon
|
||||
name="cross"
|
||||
custom-class="van-action-sheet__close"
|
||||
bind:click="onClose"
|
||||
/>
|
||||
</view>
|
||||
<view wx:if="{{ description }}" class="van-action-sheet__description van-hairline--bottom">
|
||||
{{ description }}
|
||||
</view>
|
||||
<view wx:if="{{ actions && actions.length }}" class="list-class">
|
||||
<!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 -->
|
||||
<button
|
||||
wx:for="{{ actions }}"
|
||||
wx:key="index"
|
||||
open-type="{{ item.disabled || item.loading || (canIUseGetUserProfile && item.openType === 'getUserInfo') ? '' : item.openType }}"
|
||||
style="{{ item.color ? 'color: ' + item.color : '' }}"
|
||||
class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} {{ item.className || '' }}"
|
||||
hover-class="van-action-sheet__item--hover"
|
||||
data-index="{{ index }}"
|
||||
bindtap="{{ item.disabled || item.loading ? '' : 'onSelect' }}"
|
||||
bindgetuserinfo="onGetUserInfo"
|
||||
bindcontact="onContact"
|
||||
bindgetphonenumber="onGetPhoneNumber"
|
||||
binderror="onError"
|
||||
bindlaunchapp="onLaunchApp"
|
||||
bindopensetting="onOpenSetting"
|
||||
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 }}
|
||||
<view wx:if="{{ item.subname }}" class="van-action-sheet__subname" >{{ item.subname }}</view>
|
||||
</block>
|
||||
<van-loading wx:else custom-class="van-action-sheet__loading" size="22px" />
|
||||
</button>
|
||||
</view>
|
||||
<slot />
|
||||
<block wx:if="{{ cancelText }}">
|
||||
<view class="van-action-sheet__gap" />
|
||||
<view
|
||||
class="van-action-sheet__cancel"
|
||||
hover-class="van-action-sheet__cancel--hover"
|
||||
hover-stay-time="70"
|
||||
bind:tap="onCancel"
|
||||
>
|
||||
{{ cancelText }}
|
||||
</view>
|
||||
</block>
|
||||
</van-popup>
|
||||
1
miniprogram_npm/vant-weapp/action-sheet/index.wxss
Normal file
1
miniprogram_npm/vant-weapp/action-sheet/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-action-sheet{color:var(--action-sheet-item-text-color,#323233);max-height:var(--action-sheet-max-height,90%)!important}.van-action-sheet__cancel,.van-action-sheet__item{background-color:var(--action-sheet-item-background,#fff);font-size:var(--action-sheet-item-font-size,16px);line-height:var(--action-sheet-item-line-height,22px);padding:14px 16px;text-align:center}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5}.van-action-sheet__cancel:after,.van-action-sheet__item:after{border-width:0}.van-action-sheet__cancel{color:var(--action-sheet-cancel-text-color,#646566)}.van-action-sheet__gap{background-color:var(--action-sheet-cancel-padding-color,#f7f8fa);display:block;height:var(--action-sheet-cancel-padding-top,8px)}.van-action-sheet__item--disabled{color:var(--action-sheet-item-disabled-text-color,#c8c9cc)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{color:var(--action-sheet-subname-color,#969799);font-size:var(--action-sheet-subname-font-size,12px);line-height:var(--action-sheet-subname-line-height,20px);margin-top:var(--padding-xs,8px)}.van-action-sheet__header{font-size:var(--action-sheet-header-font-size,16px);font-weight:var(--font-weight-bold,500);line-height:var(--action-sheet-header-height,48px);text-align:center}.van-action-sheet__description{color:var(--action-sheet-description-color,#969799);font-size:var(--action-sheet-description-font-size,14px);line-height:var(--action-sheet-description-line-height,20px);padding:20px var(--padding-md,16px);text-align:center}.van-action-sheet__close{color:var(--action-sheet-close-icon-color,#c8c9cc);font-size:var(--action-sheet-close-icon-size,22px)!important;line-height:inherit!important;padding:var(--action-sheet-close-icon-padding,0 16px);position:absolute!important;right:0;top:0}.van-action-sheet__loading{display:flex!important}
|
||||
1
miniprogram_npm/vant-weapp/area/index.d.ts
vendored
Normal file
1
miniprogram_npm/vant-weapp/area/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
235
miniprogram_npm/vant-weapp/area/index.js
Normal file
235
miniprogram_npm/vant-weapp/area/index.js
Normal file
@ -0,0 +1,235 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var shared_1 = require("../picker/shared");
|
||||
var utils_1 = require("../common/utils");
|
||||
var EMPTY_CODE = '000000';
|
||||
(0, component_1.VantComponent)({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
props: __assign(__assign({}, shared_1.pickerProps), { showToolbar: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
}, value: {
|
||||
type: String,
|
||||
observer: function (value) {
|
||||
this.code = value;
|
||||
this.setValues();
|
||||
},
|
||||
}, areaList: {
|
||||
type: Object,
|
||||
value: {},
|
||||
observer: 'setValues',
|
||||
}, columnsNum: {
|
||||
type: null,
|
||||
value: 3,
|
||||
}, columnsPlaceholder: {
|
||||
type: Array,
|
||||
observer: function (val) {
|
||||
this.setData({
|
||||
typeToColumnsPlaceholder: {
|
||||
province: val[0] || '',
|
||||
city: val[1] || '',
|
||||
county: val[2] || '',
|
||||
},
|
||||
});
|
||||
},
|
||||
} }),
|
||||
data: {
|
||||
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||
typeToColumnsPlaceholder: {},
|
||||
},
|
||||
mounted: function () {
|
||||
var _this = this;
|
||||
(0, utils_1.requestAnimationFrame)(function () {
|
||||
_this.setValues();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
getPicker: function () {
|
||||
if (this.picker == null) {
|
||||
this.picker = this.selectComponent('.van-area__picker');
|
||||
}
|
||||
return this.picker;
|
||||
},
|
||||
onCancel: function (event) {
|
||||
this.emit('cancel', event.detail);
|
||||
},
|
||||
onConfirm: function (event) {
|
||||
var index = event.detail.index;
|
||||
var value = event.detail.value;
|
||||
value = this.parseValues(value);
|
||||
this.emit('confirm', { value: value, index: index });
|
||||
},
|
||||
emit: function (type, detail) {
|
||||
detail.values = detail.value;
|
||||
delete detail.value;
|
||||
this.$emit(type, detail);
|
||||
},
|
||||
parseValues: function (values) {
|
||||
var columnsPlaceholder = this.data.columnsPlaceholder;
|
||||
return values.map(function (value, index) {
|
||||
if (value &&
|
||||
(!value.code || value.name === columnsPlaceholder[index])) {
|
||||
return __assign(__assign({}, value), { code: '', name: '' });
|
||||
}
|
||||
return value;
|
||||
});
|
||||
},
|
||||
onChange: function (event) {
|
||||
var _this = this;
|
||||
var _a;
|
||||
var _b = event.detail, index = _b.index, picker = _b.picker, value = _b.value;
|
||||
this.code = value[index].code;
|
||||
(_a = this.setValues()) === null || _a === void 0 ? void 0 : _a.then(function () {
|
||||
_this.$emit('change', {
|
||||
picker: picker,
|
||||
values: _this.parseValues(picker.getValues()),
|
||||
index: index,
|
||||
});
|
||||
});
|
||||
},
|
||||
getConfig: function (type) {
|
||||
var areaList = this.data.areaList;
|
||||
return (areaList && areaList["".concat(type, "_list")]) || {};
|
||||
},
|
||||
getList: function (type, code) {
|
||||
if (type !== 'province' && !code) {
|
||||
return [];
|
||||
}
|
||||
var typeToColumnsPlaceholder = this.data.typeToColumnsPlaceholder;
|
||||
var list = this.getConfig(type);
|
||||
var result = Object.keys(list).map(function (code) { return ({
|
||||
code: code,
|
||||
name: list[code],
|
||||
}); });
|
||||
if (code != null) {
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'city') {
|
||||
code = '9';
|
||||
}
|
||||
result = result.filter(function (item) { return item.code.indexOf(code) === 0; });
|
||||
}
|
||||
if (typeToColumnsPlaceholder[type] && result.length) {
|
||||
// set columns placeholder
|
||||
var codeFill = type === 'province'
|
||||
? ''
|
||||
: type === 'city'
|
||||
? EMPTY_CODE.slice(2, 4)
|
||||
: EMPTY_CODE.slice(4, 6);
|
||||
result.unshift({
|
||||
code: "".concat(code).concat(codeFill),
|
||||
name: typeToColumnsPlaceholder[type],
|
||||
});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
getIndex: function (type, code) {
|
||||
var compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
|
||||
var 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 (var i = 0; i < list.length; i++) {
|
||||
if (list[i].code.slice(0, compareNum) === code) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
setValues: function () {
|
||||
var picker = this.getPicker();
|
||||
if (!picker) {
|
||||
return;
|
||||
}
|
||||
var code = this.code || this.getDefaultCode();
|
||||
var provinceList = this.getList('province');
|
||||
var cityList = this.getList('city', code.slice(0, 2));
|
||||
var stack = [];
|
||||
var indexes = [];
|
||||
var columnsNum = this.data.columnsNum;
|
||||
if (columnsNum >= 1) {
|
||||
stack.push(picker.setColumnValues(0, provinceList, false));
|
||||
indexes.push(this.getIndex('province', code));
|
||||
}
|
||||
if (columnsNum >= 2) {
|
||||
stack.push(picker.setColumnValues(1, cityList, false));
|
||||
indexes.push(this.getIndex('city', code));
|
||||
if (cityList.length && code.slice(2, 4) === '00') {
|
||||
code = cityList[0].code;
|
||||
}
|
||||
}
|
||||
if (columnsNum === 3) {
|
||||
stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false));
|
||||
indexes.push(this.getIndex('county', code));
|
||||
}
|
||||
return Promise.all(stack)
|
||||
.catch(function () { })
|
||||
.then(function () { return picker.setIndexes(indexes); })
|
||||
.catch(function () { });
|
||||
},
|
||||
getDefaultCode: function () {
|
||||
var columnsPlaceholder = this.data.columnsPlaceholder;
|
||||
if (columnsPlaceholder.length) {
|
||||
return EMPTY_CODE;
|
||||
}
|
||||
var countyCodes = Object.keys(this.getConfig('county'));
|
||||
if (countyCodes[0]) {
|
||||
return countyCodes[0];
|
||||
}
|
||||
var cityCodes = Object.keys(this.getConfig('city'));
|
||||
if (cityCodes[0]) {
|
||||
return cityCodes[0];
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getValues: function () {
|
||||
var picker = this.getPicker();
|
||||
if (!picker) {
|
||||
return [];
|
||||
}
|
||||
return this.parseValues(picker.getValues().filter(function (value) { return !!value; }));
|
||||
},
|
||||
getDetail: function () {
|
||||
var values = this.getValues();
|
||||
var area = {
|
||||
code: '',
|
||||
country: '',
|
||||
province: '',
|
||||
city: '',
|
||||
county: '',
|
||||
};
|
||||
if (!values.length) {
|
||||
return area;
|
||||
}
|
||||
var names = values.map(function (item) { return 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: function (code) {
|
||||
this.code = code || '';
|
||||
return this.setValues();
|
||||
},
|
||||
},
|
||||
});
|
||||
6
miniprogram_npm/vant-weapp/area/index.json
Normal file
6
miniprogram_npm/vant-weapp/area/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-picker": "../picker/index"
|
||||
}
|
||||
}
|
||||
20
miniprogram_npm/vant-weapp/area/index.wxml
Normal file
20
miniprogram_npm/vant-weapp/area/index.wxml
Normal file
@ -0,0 +1,20 @@
|
||||
<wxs src="./index.wxs" module="computed" />
|
||||
|
||||
<van-picker
|
||||
class="van-area__picker"
|
||||
active-class="active-class"
|
||||
toolbar-class="toolbar-class"
|
||||
column-class="column-class"
|
||||
show-toolbar="{{ showToolbar }}"
|
||||
value-key="name"
|
||||
title="{{ title }}"
|
||||
loading="{{ loading }}"
|
||||
columns="{{ computed.displayColumns(columns, columnsNum) }}"
|
||||
item-height="{{ itemHeight }}"
|
||||
visible-item-count="{{ visibleItemCount }}"
|
||||
cancel-button-text="{{ cancelButtonText }}"
|
||||
confirm-button-text="{{ confirmButtonText }}"
|
||||
bind:change="onChange"
|
||||
bind:confirm="onConfirm"
|
||||
bind:cancel="onCancel"
|
||||
/>
|
||||
8
miniprogram_npm/vant-weapp/area/index.wxs
Normal file
8
miniprogram_npm/vant-weapp/area/index.wxs
Normal file
@ -0,0 +1,8 @@
|
||||
/* eslint-disable */
|
||||
function displayColumns(columns, columnsNum) {
|
||||
return columns.slice(0, +columnsNum);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
displayColumns: displayColumns,
|
||||
};
|
||||
1
miniprogram_npm/vant-weapp/area/index.wxss
Normal file
1
miniprogram_npm/vant-weapp/area/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';
|
||||
1
miniprogram_npm/vant-weapp/button/index.d.ts
vendored
Normal file
1
miniprogram_npm/vant-weapp/button/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
67
miniprogram_npm/vant-weapp/button/index.js
Normal file
67
miniprogram_npm/vant-weapp/button/index.js
Normal file
@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var button_1 = require("../mixins/button");
|
||||
var version_1 = require("../common/version");
|
||||
var mixins = [button_1.button];
|
||||
if ((0, version_1.canIUseFormFieldButton)()) {
|
||||
mixins.push('wx://form-field-button');
|
||||
}
|
||||
(0, component_1.VantComponent)({
|
||||
mixins: mixins,
|
||||
classes: ['hover-class', 'loading-class'],
|
||||
data: {
|
||||
baseStyle: '',
|
||||
},
|
||||
props: {
|
||||
formType: String,
|
||||
icon: String,
|
||||
classPrefix: {
|
||||
type: String,
|
||||
value: 'van-icon',
|
||||
},
|
||||
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',
|
||||
},
|
||||
dataset: null,
|
||||
size: {
|
||||
type: String,
|
||||
value: 'normal',
|
||||
},
|
||||
loadingSize: {
|
||||
type: String,
|
||||
value: '20px',
|
||||
},
|
||||
color: String,
|
||||
},
|
||||
methods: {
|
||||
onClick: function (event) {
|
||||
var _this = this;
|
||||
this.$emit('click', event);
|
||||
var _a = this.data, canIUseGetUserProfile = _a.canIUseGetUserProfile, openType = _a.openType, getUserProfileDesc = _a.getUserProfileDesc, lang = _a.lang;
|
||||
if (openType === 'getUserInfo' && canIUseGetUserProfile) {
|
||||
wx.getUserProfile({
|
||||
desc: getUserProfileDesc || ' ',
|
||||
lang: lang || 'en',
|
||||
complete: function (userProfile) {
|
||||
_this.$emit('getuserinfo', userProfile);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
7
miniprogram_npm/vant-weapp/button/index.json
Normal file
7
miniprogram_npm/vant-weapp/button/index.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index",
|
||||
"van-loading": "../loading/index"
|
||||
}
|
||||
}
|
||||
56
miniprogram_npm/vant-weapp/button/index.wxml
Normal file
56
miniprogram_npm/vant-weapp/button/index.wxml
Normal file
@ -0,0 +1,56 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
<wxs src="./index.wxs" module="computed" />
|
||||
|
||||
<button
|
||||
id="{{ id || buttonId }}"
|
||||
data-detail="{{ dataset }}"
|
||||
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
|
||||
hover-class="{{ disabled || loading ? '' : 'van-button--active hover-class'}}"
|
||||
lang="{{ lang }}"
|
||||
form-type="{{ formType }}"
|
||||
style="{{ computed.rootStyle({ plain, color, customStyle }) }}"
|
||||
open-type="{{ disabled || loading || (canIUseGetUserProfile && openType === 'getUserInfo') ? '' : 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 }}"
|
||||
bindtap="{{ disabled || loading ? '' : 'onClick' }}"
|
||||
bindgetuserinfo="onGetUserInfo"
|
||||
bindcontact="onContact"
|
||||
bindgetphonenumber="onGetPhoneNumber"
|
||||
bindgetrealtimephonenumber="onGetRealTimePhoneNumber"
|
||||
bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
|
||||
binderror="onError"
|
||||
bindlaunchapp="onLaunchApp"
|
||||
bindopensetting="onOpenSetting"
|
||||
bindchooseavatar="onChooseAvatar"
|
||||
>
|
||||
<block wx:if="{{ loading }}">
|
||||
<van-loading
|
||||
custom-class="loading-class"
|
||||
size="{{ loadingSize }}"
|
||||
type="{{ loadingType }}"
|
||||
color="{{ computed.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.2em"
|
||||
name="{{ icon }}"
|
||||
class-prefix="{{ classPrefix }}"
|
||||
class="van-button__icon"
|
||||
custom-style="line-height: inherit;"
|
||||
/>
|
||||
<view class="van-button__text">
|
||||
<slot />
|
||||
</view>
|
||||
</block>
|
||||
</button>
|
||||
39
miniprogram_npm/vant-weapp/button/index.wxs
Normal file
39
miniprogram_npm/vant-weapp/button/index.wxs
Normal file
@ -0,0 +1,39 @@
|
||||
/* eslint-disable */
|
||||
var style = require('../wxs/style.wxs');
|
||||
|
||||
function rootStyle(data) {
|
||||
if (!data.color) {
|
||||
return data.customStyle;
|
||||
}
|
||||
|
||||
var properties = {
|
||||
color: data.plain ? data.color : '#fff',
|
||||
background: data.plain ? null : data.color,
|
||||
};
|
||||
|
||||
// hide border when color is linear-gradient
|
||||
if (data.color.indexOf('gradient') !== -1) {
|
||||
properties.border = 0;
|
||||
} else {
|
||||
properties['border-color'] = data.color;
|
||||
}
|
||||
|
||||
return style([properties, data.customStyle]);
|
||||
}
|
||||
|
||||
function loadingColor(data) {
|
||||
if (data.plain) {
|
||||
return data.color ? data.color : '#c9c9c9';
|
||||
}
|
||||
|
||||
if (data.type === 'default') {
|
||||
return '#c9c9c9';
|
||||
}
|
||||
|
||||
return '#fff';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
rootStyle: rootStyle,
|
||||
loadingColor: loadingColor,
|
||||
};
|
||||
1
miniprogram_npm/vant-weapp/button/index.wxss
Normal file
1
miniprogram_npm/vant-weapp/button/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-button{-webkit-text-size-adjust:100%;align-items:center;-webkit-appearance:none;border-radius:var(--button-border-radius,2px);box-sizing:border-box;display:inline-flex;font-size:var(--button-default-font-size,16px);height:var(--button-default-height,44px);justify-content:center;line-height:var(--button-line-height,20px);padding:0;position:relative;text-align:center;transition:opacity .2s;vertical-align:middle}.van-button:before{background-color:#000;border:inherit;border-color:#000;border-radius:inherit;content:" ";height:100%;left:50%;opacity:0;position:absolute;top:50%;transform:translate(-50%,-50%);width:100%}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{background:var(--button-default-background-color,#fff);border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0);color:var(--button-default-color,#323233)}.van-button--primary{background:var(--button-primary-background-color,#07c160);border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160);color:var(--button-primary-color,#fff)}.van-button--info{background:var(--button-info-background-color,#1989fa);border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa);color:var(--button-info-color,#fff)}.van-button--danger{background:var(--button-danger-background-color,#ee0a24);border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24);color:var(--button-danger-color,#fff)}.van-button--warning{background:var(--button-warning-background-color,#ff976a);border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a);color:var(--button-warning-color,#fff)}.van-button--plain{background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:var(--button-warning-background-color,#ff976a)}.van-button--large{height:var(--button-large-height,50px);width:100%}.van-button--normal{font-size:var(--button-normal-font-size,14px);padding:0 15px}.van-button--small{font-size:var(--button-small-font-size,12px);height:var(--button-small-height,30px);min-width:var(--button-small-min-width,60px);padding:0 var(--padding-xs,8px)}.van-button--mini{display:inline-block;font-size:var(--button-mini-font-size,10px);height:var(--button-mini-height,22px);min-width:var(--button-mini-min-width,50px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:flex;width:100%}.van-button--round{border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{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{line-height:inherit!important;min-width:1em;vertical-align:top}.van-button--hairline{border-width:0;padding-top:1px}.van-button--hairline:after{border-color:inherit;border-radius:calc(var(--button-border-radius, 2px)*2);border-width:1px}.van-button--hairline.van-button--round:after{border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0}
|
||||
70
miniprogram_npm/vant-weapp/calendar/calendar.wxml
Normal file
70
miniprogram_npm/vant-weapp/calendar/calendar.wxml
Normal file
@ -0,0 +1,70 @@
|
||||
<wxs src="./index.wxs" module="computed" />
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
<view class="van-calendar">
|
||||
<header
|
||||
title="{{ title }}"
|
||||
showTitle="{{ showTitle }}"
|
||||
subtitle="{{ subtitle }}"
|
||||
showSubtitle="{{ showSubtitle }}"
|
||||
firstDayOfWeek="{{ firstDayOfWeek }}"
|
||||
bind:click-subtitle="onClickSubtitle"
|
||||
>
|
||||
<slot name="title" slot="title"></slot>
|
||||
</header>
|
||||
|
||||
<scroll-view
|
||||
class="van-calendar__body"
|
||||
scroll-y
|
||||
scroll-into-view="{{ scrollIntoView }}"
|
||||
>
|
||||
<month
|
||||
wx:for="{{ computed.getMonths(minDate, maxDate) }}"
|
||||
wx:key="index"
|
||||
id="month{{ index }}"
|
||||
class="month"
|
||||
data-date="{{ item }}"
|
||||
date="{{ item }}"
|
||||
type="{{ type }}"
|
||||
color="{{ color }}"
|
||||
minDate="{{ minDate }}"
|
||||
maxDate="{{ maxDate }}"
|
||||
showMark="{{ showMark }}"
|
||||
formatter="{{ formatter }}"
|
||||
rowHeight="{{ rowHeight }}"
|
||||
currentDate="{{ currentDate }}"
|
||||
showSubtitle="{{ showSubtitle }}"
|
||||
allowSameDay="{{ allowSameDay }}"
|
||||
showMonthTitle="{{ index !== 0 || !showSubtitle }}"
|
||||
firstDayOfWeek="{{ firstDayOfWeek }}"
|
||||
bind:click="onClickDay"
|
||||
/>
|
||||
</scroll-view>
|
||||
|
||||
<view
|
||||
class="{{ utils.bem('calendar__footer', { safeAreaInsetBottom }) }}"
|
||||
>
|
||||
<slot name="footer"></slot>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="{{ utils.bem('calendar__footer', { safeAreaInsetBottom }) }}"
|
||||
>
|
||||
<van-button
|
||||
wx:if="{{ showConfirm }}"
|
||||
round
|
||||
block
|
||||
type="danger"
|
||||
color="{{ color }}"
|
||||
custom-class="van-calendar__confirm"
|
||||
disabled="{{ computed.getButtonDisabled(type, currentDate, minRange) }}"
|
||||
nativeType="text"
|
||||
bind:click="onConfirm"
|
||||
>
|
||||
{{
|
||||
computed.getButtonDisabled(type, currentDate, minRange)
|
||||
? confirmDisabledText
|
||||
: confirmText
|
||||
}}
|
||||
</van-button>
|
||||
</view>
|
||||
</view>
|
||||
1
miniprogram_npm/vant-weapp/calendar/components/header/index.d.ts
vendored
Normal file
1
miniprogram_npm/vant-weapp/calendar/components/header/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../../../common/component");
|
||||
(0, component_1.VantComponent)({
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
value: '日期选择',
|
||||
},
|
||||
subtitle: String,
|
||||
showTitle: Boolean,
|
||||
showSubtitle: Boolean,
|
||||
firstDayOfWeek: {
|
||||
type: Number,
|
||||
observer: 'initWeekDay',
|
||||
},
|
||||
},
|
||||
data: {
|
||||
weekdays: [],
|
||||
},
|
||||
created: function () {
|
||||
this.initWeekDay();
|
||||
},
|
||||
methods: {
|
||||
initWeekDay: function () {
|
||||
var defaultWeeks = ['日', '一', '二', '三', '四', '五', '六'];
|
||||
var firstDayOfWeek = this.data.firstDayOfWeek || 0;
|
||||
this.setData({
|
||||
weekdays: __spreadArray(__spreadArray([], defaultWeeks.slice(firstDayOfWeek, 7), true), defaultWeeks.slice(0, firstDayOfWeek), true),
|
||||
});
|
||||
},
|
||||
onClickSubtitle: function (event) {
|
||||
this.$emit('click-subtitle', event);
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
<view class="van-calendar__header">
|
||||
<block wx:if="{{ showTitle }}">
|
||||
<view class="van-calendar__header-title"><slot name="title"></slot></view>
|
||||
<view class="van-calendar__header-title">{{ title }}</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{ showSubtitle }}" class="van-calendar__header-subtitle" bind:tap="onClickSubtitle">
|
||||
{{ subtitle }}
|
||||
</view>
|
||||
|
||||
<view class="van-calendar__weekdays">
|
||||
<view wx:for="{{ weekdays }}" wx:key="index" class="van-calendar__weekday">
|
||||
{{ item }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -0,0 +1 @@
|
||||
@import '../../../common/index.wxss';.van-calendar__header{box-shadow:var(--calendar-header-box-shadow,0 2px 10px hsla(220,1%,50%,.16));flex-shrink:0}.van-calendar__header-subtitle,.van-calendar__header-title{font-weight:var(--font-weight-bold,500);height:var(--calendar-header-title-height,44px);line-height:var(--calendar-header-title-height,44px);text-align:center}.van-calendar__header-title+.van-calendar__header-title,.van-calendar__header-title:empty{display:none}.van-calendar__header-title:empty+.van-calendar__header-title{display:block!important}.van-calendar__weekdays{display:flex}.van-calendar__weekday{flex:1;font-size:var(--calendar-weekdays-font-size,12px);line-height:var(--calendar-weekdays-height,30px);text-align:center}
|
||||
6
miniprogram_npm/vant-weapp/calendar/components/month/index.d.ts
vendored
Normal file
6
miniprogram_npm/vant-weapp/calendar/components/month/index.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
export interface Day {
|
||||
date: Date;
|
||||
type: string;
|
||||
text: number;
|
||||
bottomInfo?: string;
|
||||
}
|
||||
158
miniprogram_npm/vant-weapp/calendar/components/month/index.js
Normal file
158
miniprogram_npm/vant-weapp/calendar/components/month/index.js
Normal file
@ -0,0 +1,158 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../../../common/component");
|
||||
var utils_1 = require("../../utils");
|
||||
(0, component_1.VantComponent)({
|
||||
props: {
|
||||
date: {
|
||||
type: null,
|
||||
observer: 'setDays',
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
observer: 'setDays',
|
||||
},
|
||||
color: String,
|
||||
minDate: {
|
||||
type: null,
|
||||
observer: 'setDays',
|
||||
},
|
||||
maxDate: {
|
||||
type: null,
|
||||
observer: 'setDays',
|
||||
},
|
||||
showMark: Boolean,
|
||||
rowHeight: null,
|
||||
formatter: {
|
||||
type: null,
|
||||
observer: 'setDays',
|
||||
},
|
||||
currentDate: {
|
||||
type: null,
|
||||
observer: 'setDays',
|
||||
},
|
||||
firstDayOfWeek: {
|
||||
type: Number,
|
||||
observer: 'setDays',
|
||||
},
|
||||
allowSameDay: Boolean,
|
||||
showSubtitle: Boolean,
|
||||
showMonthTitle: Boolean,
|
||||
},
|
||||
data: {
|
||||
visible: true,
|
||||
days: [],
|
||||
},
|
||||
methods: {
|
||||
onClick: function (event) {
|
||||
var index = event.currentTarget.dataset.index;
|
||||
var item = this.data.days[index];
|
||||
if (item.type !== 'disabled') {
|
||||
this.$emit('click', item);
|
||||
}
|
||||
},
|
||||
setDays: function () {
|
||||
var days = [];
|
||||
var startDate = new Date(this.data.date);
|
||||
var year = startDate.getFullYear();
|
||||
var month = startDate.getMonth();
|
||||
var totalDay = (0, utils_1.getMonthEndDay)(startDate.getFullYear(), startDate.getMonth() + 1);
|
||||
for (var day = 1; day <= totalDay; day++) {
|
||||
var date = new Date(year, month, day);
|
||||
var type = this.getDayType(date);
|
||||
var config = {
|
||||
date: date,
|
||||
type: type,
|
||||
text: day,
|
||||
bottomInfo: this.getBottomInfo(type),
|
||||
};
|
||||
if (this.data.formatter) {
|
||||
config = this.data.formatter(config);
|
||||
}
|
||||
days.push(config);
|
||||
}
|
||||
this.setData({ days: days });
|
||||
},
|
||||
getMultipleDayType: function (day) {
|
||||
var currentDate = this.data.currentDate;
|
||||
if (!Array.isArray(currentDate)) {
|
||||
return '';
|
||||
}
|
||||
var isSelected = function (date) {
|
||||
return currentDate.some(function (item) { return (0, utils_1.compareDay)(item, date) === 0; });
|
||||
};
|
||||
if (isSelected(day)) {
|
||||
var prevDay = (0, utils_1.getPrevDay)(day);
|
||||
var nextDay = (0, utils_1.getNextDay)(day);
|
||||
var prevSelected = isSelected(prevDay);
|
||||
var nextSelected = isSelected(nextDay);
|
||||
if (prevSelected && nextSelected) {
|
||||
return 'multiple-middle';
|
||||
}
|
||||
if (prevSelected) {
|
||||
return 'end';
|
||||
}
|
||||
return nextSelected ? 'start' : 'multiple-selected';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getRangeDayType: function (day) {
|
||||
var _a = this.data, currentDate = _a.currentDate, allowSameDay = _a.allowSameDay;
|
||||
if (!Array.isArray(currentDate)) {
|
||||
return '';
|
||||
}
|
||||
var startDay = currentDate[0], endDay = currentDate[1];
|
||||
if (!startDay) {
|
||||
return '';
|
||||
}
|
||||
var compareToStart = (0, utils_1.compareDay)(day, startDay);
|
||||
if (!endDay) {
|
||||
return compareToStart === 0 ? 'start' : '';
|
||||
}
|
||||
var compareToEnd = (0, utils_1.compareDay)(day, endDay);
|
||||
if (compareToStart === 0 && compareToEnd === 0 && allowSameDay) {
|
||||
return 'start-end';
|
||||
}
|
||||
if (compareToStart === 0) {
|
||||
return 'start';
|
||||
}
|
||||
if (compareToEnd === 0) {
|
||||
return 'end';
|
||||
}
|
||||
if (compareToStart > 0 && compareToEnd < 0) {
|
||||
return 'middle';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getDayType: function (day) {
|
||||
var _a = this.data, type = _a.type, minDate = _a.minDate, maxDate = _a.maxDate, currentDate = _a.currentDate;
|
||||
if ((0, utils_1.compareDay)(day, minDate) < 0 || (0, utils_1.compareDay)(day, maxDate) > 0) {
|
||||
return 'disabled';
|
||||
}
|
||||
if (type === 'single') {
|
||||
return (0, utils_1.compareDay)(day, currentDate) === 0 ? 'selected' : '';
|
||||
}
|
||||
if (type === 'multiple') {
|
||||
return this.getMultipleDayType(day);
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (type === 'range') {
|
||||
return this.getRangeDayType(day);
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getBottomInfo: function (type) {
|
||||
if (this.data.type === 'range') {
|
||||
if (type === 'start') {
|
||||
return '开始';
|
||||
}
|
||||
if (type === 'end') {
|
||||
return '结束';
|
||||
}
|
||||
if (type === 'start-end') {
|
||||
return '开始/结束';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
<wxs src="./index.wxs" module="computed"></wxs>
|
||||
<wxs src="../../../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="van-calendar__month" style="{{ computed.getMonthStyle(visible, date, rowHeight) }}">
|
||||
<view wx:if="{{ showMonthTitle }}" class="van-calendar__month-title">
|
||||
{{ computed.formatMonthTitle(date) }}
|
||||
</view>
|
||||
|
||||
<view wx:if="{{ visible }}" class="van-calendar__days">
|
||||
<view wx:if="{{ showMark }}" class="van-calendar__month-mark">
|
||||
{{ computed.getMark(date) }}
|
||||
</view>
|
||||
|
||||
<view
|
||||
wx:for="{{ days }}"
|
||||
wx:key="index"
|
||||
style="{{ computed.getDayStyle(item.type, index, date, rowHeight, color, firstDayOfWeek) }}"
|
||||
class="{{ utils.bem('calendar__day', [item.type]) }} {{ item.className }}"
|
||||
data-index="{{ index }}"
|
||||
bindtap="onClick"
|
||||
>
|
||||
<view wx:if="{{ item.type === 'selected' }}" class="van-calendar__selected-day" style="width: {{ rowHeight }}px; height: {{ rowHeight }}px; background: {{ color }}">
|
||||
<view wx:if="{{ item.topInfo }}" class="van-calendar__top-info">{{ item.topInfo }}</view>
|
||||
{{ item.text }}
|
||||
<view wx:if="{{ item.bottomInfo }}" class="van-calendar__bottom-info">
|
||||
{{ item.bottomInfo }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:else>
|
||||
<view wx:if="{{ item.topInfo }}" class="van-calendar__top-info">{{ item.topInfo }}</view>
|
||||
{{ item.text }}
|
||||
<view wx:if="{{ item.bottomInfo }}" class="van-calendar__bottom-info">
|
||||
{{ item.bottomInfo }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -0,0 +1,71 @@
|
||||
/* eslint-disable */
|
||||
var utils = require('../../utils.wxs');
|
||||
|
||||
function getMark(date) {
|
||||
return getDate(date).getMonth() + 1;
|
||||
}
|
||||
|
||||
var ROW_HEIGHT = 64;
|
||||
|
||||
function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) {
|
||||
var style = [];
|
||||
var current = getDate(date).getDay() || 7;
|
||||
var offset = current < firstDayOfWeek ? (7 - firstDayOfWeek + current) :
|
||||
current === 7 && firstDayOfWeek === 0 ? 0 :
|
||||
(current - firstDayOfWeek);
|
||||
|
||||
if (index === 0) {
|
||||
style.push(['margin-left', (100 * offset) / 7 + '%']);
|
||||
}
|
||||
|
||||
if (rowHeight !== ROW_HEIGHT) {
|
||||
style.push(['height', rowHeight + 'px']);
|
||||
}
|
||||
|
||||
if (color) {
|
||||
if (
|
||||
type === 'start' ||
|
||||
type === 'end' ||
|
||||
type === 'start-end' ||
|
||||
type === 'multiple-selected' ||
|
||||
type === 'multiple-middle'
|
||||
) {
|
||||
style.push(['background', color]);
|
||||
} else if (type === 'middle') {
|
||||
style.push(['color', color]);
|
||||
}
|
||||
}
|
||||
|
||||
return style
|
||||
.map(function(item) {
|
||||
return item.join(':');
|
||||
})
|
||||
.join(';');
|
||||
}
|
||||
|
||||
function formatMonthTitle(date) {
|
||||
date = getDate(date);
|
||||
return date.getFullYear() + '年' + (date.getMonth() + 1) + '月';
|
||||
}
|
||||
|
||||
function getMonthStyle(visible, date, rowHeight) {
|
||||
if (!visible) {
|
||||
date = getDate(date);
|
||||
|
||||
var totalDay = utils.getMonthEndDay(
|
||||
date.getFullYear(),
|
||||
date.getMonth() + 1
|
||||
);
|
||||
var offset = getDate(date).getDay();
|
||||
var padding = Math.ceil((totalDay + offset) / 7) * rowHeight;
|
||||
|
||||
return 'padding-bottom:' + padding + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getMark: getMark,
|
||||
getDayStyle: getDayStyle,
|
||||
formatMonthTitle: formatMonthTitle,
|
||||
getMonthStyle: getMonthStyle
|
||||
};
|
||||
@ -0,0 +1 @@
|
||||
@import '../../../common/index.wxss';.van-calendar{background-color:var(--calendar-background-color,#fff);display:flex;flex-direction:column;height:100%}.van-calendar__month-title{font-size:var(--calendar-month-title-font-size,14px);font-weight:var(--font-weight-bold,500);height:var(--calendar-header-title-height,44px);line-height:var(--calendar-header-title-height,44px);text-align:center}.van-calendar__days{display:flex;flex-wrap:wrap;position:relative;-webkit-user-select:none;user-select:none}.van-calendar__month-mark{color:var(--calendar-month-mark-color,rgba(242,243,245,.8));font-size:var(--calendar-month-mark-font-size,160px);left:50%;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);z-index:0}.van-calendar__day,.van-calendar__selected-day{align-items:center;display:flex;justify-content:center;text-align:center}.van-calendar__day{font-size:var(--calendar-day-font-size,16px);height:var(--calendar-day-height,64px);position:relative;width:14.285%}.van-calendar__day--end,.van-calendar__day--multiple-middle,.van-calendar__day--multiple-selected,.van-calendar__day--start,.van-calendar__day--start-end{background-color:var(--calendar-range-edge-background-color,#ee0a24);color:var(--calendar-range-edge-color,#fff)}.van-calendar__day--start{border-radius:4px 0 0 4px}.van-calendar__day--end{border-radius:0 4px 4px 0}.van-calendar__day--multiple-selected,.van-calendar__day--start-end{border-radius:4px}.van-calendar__day--middle{color:var(--calendar-range-middle-color,#ee0a24)}.van-calendar__day--middle:after{background-color:currentColor;bottom:0;content:"";left:0;opacity:var(--calendar-range-middle-background-opacity,.1);position:absolute;right:0;top:0}.van-calendar__day--disabled{color:var(--calendar-day-disabled-color,#c8c9cc);cursor:default}.van-calendar__bottom-info,.van-calendar__top-info{font-size:var(--calendar-info-font-size,10px);left:0;line-height:var(--calendar-info-line-height,14px);position:absolute;right:0}@media (max-width:350px){.van-calendar__bottom-info,.van-calendar__top-info{font-size:9px}}.van-calendar__top-info{top:6px}.van-calendar__bottom-info{bottom:6px}.van-calendar__selected-day{background-color:var(--calendar-selected-day-background-color,#ee0a24);border-radius:4px;color:var(--calendar-selected-day-color,#fff);height:var(--calendar-selected-day-size,54px);width:var(--calendar-selected-day-size,54px)}
|
||||
1
miniprogram_npm/vant-weapp/calendar/index.d.ts
vendored
Normal file
1
miniprogram_npm/vant-weapp/calendar/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
383
miniprogram_npm/vant-weapp/calendar/index.js
Normal file
383
miniprogram_npm/vant-weapp/calendar/index.js
Normal file
@ -0,0 +1,383 @@
|
||||
"use strict";
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var utils_1 = require("./utils");
|
||||
var toast_1 = __importDefault(require("../toast/toast"));
|
||||
var utils_2 = require("../common/utils");
|
||||
var initialMinDate = (0, utils_1.getToday)().getTime();
|
||||
var initialMaxDate = (function () {
|
||||
var now = (0, utils_1.getToday)();
|
||||
return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate()).getTime();
|
||||
})();
|
||||
var getTime = function (date) {
|
||||
return date instanceof Date ? date.getTime() : date;
|
||||
};
|
||||
(0, component_1.VantComponent)({
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
value: '日期选择',
|
||||
},
|
||||
color: String,
|
||||
show: {
|
||||
type: Boolean,
|
||||
observer: function (val) {
|
||||
if (val) {
|
||||
this.initRect();
|
||||
this.scrollIntoView();
|
||||
}
|
||||
},
|
||||
},
|
||||
formatter: null,
|
||||
confirmText: {
|
||||
type: String,
|
||||
value: '确定',
|
||||
},
|
||||
confirmDisabledText: {
|
||||
type: String,
|
||||
value: '确定',
|
||||
},
|
||||
rangePrompt: String,
|
||||
showRangePrompt: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
defaultDate: {
|
||||
type: null,
|
||||
value: (0, utils_1.getToday)().getTime(),
|
||||
observer: function (val) {
|
||||
this.setData({ currentDate: val });
|
||||
this.scrollIntoView();
|
||||
},
|
||||
},
|
||||
allowSameDay: Boolean,
|
||||
type: {
|
||||
type: String,
|
||||
value: 'single',
|
||||
observer: 'reset',
|
||||
},
|
||||
minDate: {
|
||||
type: Number,
|
||||
value: initialMinDate,
|
||||
},
|
||||
maxDate: {
|
||||
type: Number,
|
||||
value: initialMaxDate,
|
||||
},
|
||||
position: {
|
||||
type: String,
|
||||
value: 'bottom',
|
||||
},
|
||||
rowHeight: {
|
||||
type: null,
|
||||
value: utils_1.ROW_HEIGHT,
|
||||
},
|
||||
round: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
poppable: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
showMark: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
showTitle: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
showConfirm: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
showSubtitle: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
safeAreaInsetBottom: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
closeOnClickOverlay: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
maxRange: {
|
||||
type: null,
|
||||
value: null,
|
||||
},
|
||||
minRange: {
|
||||
type: Number,
|
||||
value: 1,
|
||||
},
|
||||
firstDayOfWeek: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
},
|
||||
readonly: Boolean,
|
||||
rootPortal: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
subtitle: '',
|
||||
currentDate: null,
|
||||
scrollIntoView: '',
|
||||
},
|
||||
watch: {
|
||||
minDate: function () {
|
||||
this.initRect();
|
||||
},
|
||||
maxDate: function () {
|
||||
this.initRect();
|
||||
},
|
||||
},
|
||||
created: function () {
|
||||
this.setData({
|
||||
currentDate: this.getInitialDate(this.data.defaultDate),
|
||||
});
|
||||
},
|
||||
mounted: function () {
|
||||
if (this.data.show || !this.data.poppable) {
|
||||
this.initRect();
|
||||
this.scrollIntoView();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
reset: function () {
|
||||
this.setData({ currentDate: this.getInitialDate(this.data.defaultDate) });
|
||||
this.scrollIntoView();
|
||||
},
|
||||
initRect: function () {
|
||||
var _this = this;
|
||||
if (this.contentObserver != null) {
|
||||
this.contentObserver.disconnect();
|
||||
}
|
||||
var contentObserver = this.createIntersectionObserver({
|
||||
thresholds: [0, 0.1, 0.9, 1],
|
||||
observeAll: true,
|
||||
});
|
||||
this.contentObserver = contentObserver;
|
||||
contentObserver.relativeTo('.van-calendar__body');
|
||||
contentObserver.observe('.month', function (res) {
|
||||
if (res.boundingClientRect.top <= res.relativeRect.top) {
|
||||
// @ts-ignore
|
||||
_this.setData({ subtitle: (0, utils_1.formatMonthTitle)(res.dataset.date) });
|
||||
}
|
||||
});
|
||||
},
|
||||
limitDateRange: function (date, minDate, maxDate) {
|
||||
if (minDate === void 0) { minDate = null; }
|
||||
if (maxDate === void 0) { maxDate = null; }
|
||||
minDate = minDate || this.data.minDate;
|
||||
maxDate = maxDate || this.data.maxDate;
|
||||
if ((0, utils_1.compareDay)(date, minDate) === -1) {
|
||||
return minDate;
|
||||
}
|
||||
if ((0, utils_1.compareDay)(date, maxDate) === 1) {
|
||||
return maxDate;
|
||||
}
|
||||
return date;
|
||||
},
|
||||
getInitialDate: function (defaultDate) {
|
||||
var _this = this;
|
||||
if (defaultDate === void 0) { defaultDate = null; }
|
||||
var _a = this.data, type = _a.type, minDate = _a.minDate, maxDate = _a.maxDate, allowSameDay = _a.allowSameDay;
|
||||
if (!defaultDate)
|
||||
return [];
|
||||
var now = (0, utils_1.getToday)().getTime();
|
||||
if (type === 'range') {
|
||||
if (!Array.isArray(defaultDate)) {
|
||||
defaultDate = [];
|
||||
}
|
||||
var _b = defaultDate || [], startDay = _b[0], endDay = _b[1];
|
||||
var startDate = getTime(startDay || now);
|
||||
var start = this.limitDateRange(startDate, minDate, allowSameDay ? startDate : (0, utils_1.getPrevDay)(new Date(maxDate)).getTime());
|
||||
var date = getTime(endDay || now);
|
||||
var end = this.limitDateRange(date, allowSameDay ? date : (0, utils_1.getNextDay)(new Date(minDate)).getTime());
|
||||
return [start, end];
|
||||
}
|
||||
if (type === 'multiple') {
|
||||
if (Array.isArray(defaultDate)) {
|
||||
return defaultDate.map(function (date) { return _this.limitDateRange(date); });
|
||||
}
|
||||
return [this.limitDateRange(now)];
|
||||
}
|
||||
if (!defaultDate || Array.isArray(defaultDate)) {
|
||||
defaultDate = now;
|
||||
}
|
||||
return this.limitDateRange(defaultDate);
|
||||
},
|
||||
scrollIntoView: function () {
|
||||
var _this = this;
|
||||
(0, utils_2.requestAnimationFrame)(function () {
|
||||
var _a = _this.data, currentDate = _a.currentDate, type = _a.type, show = _a.show, poppable = _a.poppable, minDate = _a.minDate, maxDate = _a.maxDate;
|
||||
if (!currentDate)
|
||||
return;
|
||||
// @ts-ignore
|
||||
var targetDate = type === 'single' ? currentDate : currentDate[0];
|
||||
var displayed = show || !poppable;
|
||||
if (!targetDate || !displayed) {
|
||||
return;
|
||||
}
|
||||
var months = (0, utils_1.getMonths)(minDate, maxDate);
|
||||
months.some(function (month, index) {
|
||||
if ((0, utils_1.compareMonth)(month, targetDate) === 0) {
|
||||
_this.setData({ scrollIntoView: "month".concat(index) });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
},
|
||||
onOpen: function () {
|
||||
this.$emit('open');
|
||||
},
|
||||
onOpened: function () {
|
||||
this.$emit('opened');
|
||||
},
|
||||
onClose: function () {
|
||||
this.$emit('close');
|
||||
},
|
||||
onClosed: function () {
|
||||
this.$emit('closed');
|
||||
},
|
||||
onClickDay: function (event) {
|
||||
if (this.data.readonly) {
|
||||
return;
|
||||
}
|
||||
var date = event.detail.date;
|
||||
var _a = this.data, type = _a.type, currentDate = _a.currentDate, allowSameDay = _a.allowSameDay;
|
||||
if (type === 'range') {
|
||||
// @ts-ignore
|
||||
var startDay_1 = currentDate[0], endDay = currentDate[1];
|
||||
if (startDay_1 && !endDay) {
|
||||
var compareToStart = (0, utils_1.compareDay)(date, startDay_1);
|
||||
if (compareToStart === 1) {
|
||||
var days_1 = this.selectComponent('.month').data.days;
|
||||
days_1.some(function (day, index) {
|
||||
var isDisabled = day.type === 'disabled' &&
|
||||
getTime(startDay_1) < getTime(day.date) &&
|
||||
getTime(day.date) < getTime(date);
|
||||
if (isDisabled) {
|
||||
(date = days_1[index - 1].date);
|
||||
}
|
||||
return isDisabled;
|
||||
});
|
||||
this.select([startDay_1, date], true);
|
||||
}
|
||||
else if (compareToStart === -1) {
|
||||
this.select([date, null]);
|
||||
}
|
||||
else if (allowSameDay) {
|
||||
this.select([date, date], true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.select([date, null]);
|
||||
}
|
||||
}
|
||||
else if (type === 'multiple') {
|
||||
var selectedIndex_1;
|
||||
// @ts-ignore
|
||||
var selected = currentDate.some(function (dateItem, index) {
|
||||
var equal = (0, utils_1.compareDay)(dateItem, date) === 0;
|
||||
if (equal) {
|
||||
selectedIndex_1 = index;
|
||||
}
|
||||
return equal;
|
||||
});
|
||||
if (selected) {
|
||||
// @ts-ignore
|
||||
var cancelDate = currentDate.splice(selectedIndex_1, 1);
|
||||
this.setData({ currentDate: currentDate });
|
||||
this.unselect(cancelDate);
|
||||
}
|
||||
else {
|
||||
// @ts-ignore
|
||||
this.select(__spreadArray(__spreadArray([], currentDate, true), [date], false));
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.select(date, true);
|
||||
}
|
||||
},
|
||||
unselect: function (dateArray) {
|
||||
var date = dateArray[0];
|
||||
if (date) {
|
||||
this.$emit('unselect', (0, utils_1.copyDates)(date));
|
||||
}
|
||||
},
|
||||
select: function (date, complete) {
|
||||
if (complete && this.data.type === 'range') {
|
||||
var valid = this.checkRange(date);
|
||||
if (!valid) {
|
||||
// auto selected to max range if showConfirm
|
||||
if (this.data.showConfirm) {
|
||||
this.emit([
|
||||
date[0],
|
||||
(0, utils_1.getDayByOffset)(date[0], this.data.maxRange - 1),
|
||||
]);
|
||||
}
|
||||
else {
|
||||
this.emit(date);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.emit(date);
|
||||
if (complete && !this.data.showConfirm) {
|
||||
this.onConfirm();
|
||||
}
|
||||
},
|
||||
emit: function (date) {
|
||||
this.setData({
|
||||
currentDate: Array.isArray(date) ? date.map(getTime) : getTime(date),
|
||||
});
|
||||
this.$emit('select', (0, utils_1.copyDates)(date));
|
||||
},
|
||||
checkRange: function (date) {
|
||||
var _a = this.data, maxRange = _a.maxRange, rangePrompt = _a.rangePrompt, showRangePrompt = _a.showRangePrompt;
|
||||
if (maxRange && (0, utils_1.calcDateNum)(date) > maxRange) {
|
||||
if (showRangePrompt) {
|
||||
(0, toast_1.default)({
|
||||
context: this,
|
||||
message: rangePrompt || "\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 ".concat(maxRange, " \u5929"),
|
||||
});
|
||||
}
|
||||
this.$emit('over-range');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onConfirm: function () {
|
||||
var _this = this;
|
||||
if (this.data.type === 'range' &&
|
||||
!this.checkRange(this.data.currentDate)) {
|
||||
return;
|
||||
}
|
||||
wx.nextTick(function () {
|
||||
// @ts-ignore
|
||||
_this.$emit('confirm', (0, utils_1.copyDates)(_this.data.currentDate));
|
||||
});
|
||||
},
|
||||
onClickSubtitle: function (event) {
|
||||
this.$emit('click-subtitle', event);
|
||||
},
|
||||
},
|
||||
});
|
||||
10
miniprogram_npm/vant-weapp/calendar/index.json
Normal file
10
miniprogram_npm/vant-weapp/calendar/index.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"header": "./components/header/index",
|
||||
"month": "./components/month/index",
|
||||
"van-button": "../button/index",
|
||||
"van-popup": "../popup/index",
|
||||
"van-toast": "../toast/index"
|
||||
}
|
||||
}
|
||||
27
miniprogram_npm/vant-weapp/calendar/index.wxml
Normal file
27
miniprogram_npm/vant-weapp/calendar/index.wxml
Normal file
@ -0,0 +1,27 @@
|
||||
<wxs src="./index.wxs" module="computed" />
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<import src="./calendar.wxml" />
|
||||
|
||||
<van-popup
|
||||
wx:if="{{ poppable }}"
|
||||
custom-class="van-calendar__popup--{{ position }}"
|
||||
close-icon-class="van-calendar__close-icon"
|
||||
show="{{ show }}"
|
||||
round="{{ round }}"
|
||||
position="{{ position }}"
|
||||
closeable="{{ showTitle || showSubtitle }}"
|
||||
close-on-click-overlay="{{ closeOnClickOverlay }}"
|
||||
safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
|
||||
root-portal="{{ rootPortal }}"
|
||||
bind:enter="onOpen"
|
||||
bind:close="onClose"
|
||||
bind:after-enter="onOpened"
|
||||
bind:after-leave="onClosed"
|
||||
>
|
||||
<include src="./calendar.wxml" />
|
||||
</van-popup>
|
||||
|
||||
<include wx:else src="./calendar.wxml" />
|
||||
|
||||
<van-toast id="van-toast" />
|
||||
37
miniprogram_npm/vant-weapp/calendar/index.wxs
Normal file
37
miniprogram_npm/vant-weapp/calendar/index.wxs
Normal file
@ -0,0 +1,37 @@
|
||||
/* eslint-disable */
|
||||
var utils = require('./utils.wxs');
|
||||
|
||||
function getMonths(minDate, maxDate) {
|
||||
var months = [];
|
||||
var cursor = getDate(minDate);
|
||||
|
||||
cursor.setDate(1);
|
||||
|
||||
do {
|
||||
months.push(cursor.getTime());
|
||||
cursor.setMonth(cursor.getMonth() + 1);
|
||||
} while (utils.compareMonth(cursor, getDate(maxDate)) !== 1);
|
||||
|
||||
return months;
|
||||
}
|
||||
|
||||
function getButtonDisabled(type, currentDate, minRange) {
|
||||
if (currentDate == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type === 'range') {
|
||||
return !currentDate[0] || !currentDate[1];
|
||||
}
|
||||
|
||||
if (type === 'multiple') {
|
||||
return currentDate.length < minRange;
|
||||
}
|
||||
|
||||
return !currentDate;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getMonths: getMonths,
|
||||
getButtonDisabled: getButtonDisabled
|
||||
};
|
||||
1
miniprogram_npm/vant-weapp/calendar/index.wxss
Normal file
1
miniprogram_npm/vant-weapp/calendar/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-calendar{background-color:var(--calendar-background-color,#fff);display:flex;flex-direction:column;height:var(--calendar-height,100%)}.van-calendar__close-icon{top:11px}.van-calendar__popup--bottom,.van-calendar__popup--top{height:var(--calendar-popup-height,90%)}.van-calendar__popup--left,.van-calendar__popup--right{height:100%}.van-calendar__body{-webkit-overflow-scrolling:touch;flex:1;overflow:auto}.van-calendar__footer{flex-shrink:0;padding:0 var(--padding-md,16px)}.van-calendar__footer--safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.van-calendar__footer+.van-calendar__footer,.van-calendar__footer:empty{display:none}.van-calendar__footer:empty+.van-calendar__footer{display:block!important}.van-calendar__confirm{height:var(--calendar-confirm-button-height,36px)!important;line-height:var(--calendar-confirm-button-line-height,34px)!important;margin:var(--calendar-confirm-button-margin,7px 0)!important}
|
||||
12
miniprogram_npm/vant-weapp/calendar/utils.d.ts
vendored
Normal file
12
miniprogram_npm/vant-weapp/calendar/utils.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
export declare const ROW_HEIGHT = 64;
|
||||
export declare function formatMonthTitle(date: Date): string;
|
||||
export declare function compareMonth(date1: Date | number, date2: Date | number): 0 | 1 | -1;
|
||||
export declare function compareDay(day1: Date | number, day2: Date | number): 0 | 1 | -1;
|
||||
export declare function getDayByOffset(date: Date, offset: number): Date;
|
||||
export declare function getPrevDay(date: Date): Date;
|
||||
export declare function getNextDay(date: Date): Date;
|
||||
export declare function getToday(): Date;
|
||||
export declare function calcDateNum(date: [Date, Date]): number;
|
||||
export declare function copyDates(dates: Date | Date[]): Date | Date[];
|
||||
export declare function getMonthEndDay(year: number, month: number): number;
|
||||
export declare function getMonths(minDate: number, maxDate: number): number[];
|
||||
97
miniprogram_npm/vant-weapp/calendar/utils.js
Normal file
97
miniprogram_npm/vant-weapp/calendar/utils.js
Normal file
@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMonths = exports.getMonthEndDay = exports.copyDates = exports.calcDateNum = exports.getToday = exports.getNextDay = exports.getPrevDay = exports.getDayByOffset = exports.compareDay = exports.compareMonth = exports.formatMonthTitle = exports.ROW_HEIGHT = void 0;
|
||||
exports.ROW_HEIGHT = 64;
|
||||
function formatMonthTitle(date) {
|
||||
if (!(date instanceof Date)) {
|
||||
date = new Date(date);
|
||||
}
|
||||
return "".concat(date.getFullYear(), "\u5E74").concat(date.getMonth() + 1, "\u6708");
|
||||
}
|
||||
exports.formatMonthTitle = formatMonthTitle;
|
||||
function compareMonth(date1, date2) {
|
||||
if (!(date1 instanceof Date)) {
|
||||
date1 = new Date(date1);
|
||||
}
|
||||
if (!(date2 instanceof Date)) {
|
||||
date2 = new Date(date2);
|
||||
}
|
||||
var year1 = date1.getFullYear();
|
||||
var year2 = date2.getFullYear();
|
||||
var month1 = date1.getMonth();
|
||||
var month2 = date2.getMonth();
|
||||
if (year1 === year2) {
|
||||
return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
|
||||
}
|
||||
return year1 > year2 ? 1 : -1;
|
||||
}
|
||||
exports.compareMonth = compareMonth;
|
||||
function compareDay(day1, day2) {
|
||||
if (!(day1 instanceof Date)) {
|
||||
day1 = new Date(day1);
|
||||
}
|
||||
if (!(day2 instanceof Date)) {
|
||||
day2 = new Date(day2);
|
||||
}
|
||||
var compareMonthResult = compareMonth(day1, day2);
|
||||
if (compareMonthResult === 0) {
|
||||
var date1 = day1.getDate();
|
||||
var date2 = day2.getDate();
|
||||
return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
|
||||
}
|
||||
return compareMonthResult;
|
||||
}
|
||||
exports.compareDay = compareDay;
|
||||
function getDayByOffset(date, offset) {
|
||||
date = new Date(date);
|
||||
date.setDate(date.getDate() + offset);
|
||||
return date;
|
||||
}
|
||||
exports.getDayByOffset = getDayByOffset;
|
||||
function getPrevDay(date) {
|
||||
return getDayByOffset(date, -1);
|
||||
}
|
||||
exports.getPrevDay = getPrevDay;
|
||||
function getNextDay(date) {
|
||||
return getDayByOffset(date, 1);
|
||||
}
|
||||
exports.getNextDay = getNextDay;
|
||||
function getToday() {
|
||||
var today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
return today;
|
||||
}
|
||||
exports.getToday = getToday;
|
||||
function calcDateNum(date) {
|
||||
var day1 = new Date(date[0]).getTime();
|
||||
var day2 = new Date(date[1]).getTime();
|
||||
return (day2 - day1) / (1000 * 60 * 60 * 24) + 1;
|
||||
}
|
||||
exports.calcDateNum = calcDateNum;
|
||||
function copyDates(dates) {
|
||||
if (Array.isArray(dates)) {
|
||||
return dates.map(function (date) {
|
||||
if (date === null) {
|
||||
return date;
|
||||
}
|
||||
return new Date(date);
|
||||
});
|
||||
}
|
||||
return new Date(dates);
|
||||
}
|
||||
exports.copyDates = copyDates;
|
||||
function getMonthEndDay(year, month) {
|
||||
return 32 - new Date(year, month - 1, 32).getDate();
|
||||
}
|
||||
exports.getMonthEndDay = getMonthEndDay;
|
||||
function getMonths(minDate, maxDate) {
|
||||
var months = [];
|
||||
var cursor = new Date(minDate);
|
||||
cursor.setDate(1);
|
||||
do {
|
||||
months.push(cursor.getTime());
|
||||
cursor.setMonth(cursor.getMonth() + 1);
|
||||
} while (compareMonth(cursor, maxDate) !== 1);
|
||||
return months;
|
||||
}
|
||||
exports.getMonths = getMonths;
|
||||
25
miniprogram_npm/vant-weapp/calendar/utils.wxs
Normal file
25
miniprogram_npm/vant-weapp/calendar/utils.wxs
Normal file
@ -0,0 +1,25 @@
|
||||
/* eslint-disable */
|
||||
function getMonthEndDay(year, month) {
|
||||
return 32 - getDate(year, month - 1, 32).getDate();
|
||||
}
|
||||
|
||||
function compareMonth(date1, date2) {
|
||||
date1 = getDate(date1);
|
||||
date2 = getDate(date2);
|
||||
|
||||
var year1 = date1.getFullYear();
|
||||
var year2 = date2.getFullYear();
|
||||
var month1 = date1.getMonth();
|
||||
var month2 = date2.getMonth();
|
||||
|
||||
if (year1 === year2) {
|
||||
return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
|
||||
}
|
||||
|
||||
return year1 > year2 ? 1 : -1;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getMonthEndDay: getMonthEndDay,
|
||||
compareMonth: compareMonth
|
||||
};
|
||||
1
miniprogram_npm/vant-weapp/card/index.d.ts
vendored
Normal file
1
miniprogram_npm/vant-weapp/card/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
51
miniprogram_npm/vant-weapp/card/index.js
Normal file
51
miniprogram_npm/vant-weapp/card/index.js
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var link_1 = require("../mixins/link");
|
||||
var component_1 = require("../common/component");
|
||||
(0, component_1.VantComponent)({
|
||||
classes: [
|
||||
'num-class',
|
||||
'desc-class',
|
||||
'thumb-class',
|
||||
'title-class',
|
||||
'price-class',
|
||||
'origin-price-class',
|
||||
],
|
||||
mixins: [link_1.link],
|
||||
props: {
|
||||
tag: String,
|
||||
num: String,
|
||||
desc: String,
|
||||
thumb: String,
|
||||
title: String,
|
||||
price: {
|
||||
type: String,
|
||||
observer: 'updatePrice',
|
||||
},
|
||||
centered: Boolean,
|
||||
lazyLoad: Boolean,
|
||||
thumbLink: String,
|
||||
originPrice: String,
|
||||
thumbMode: {
|
||||
type: String,
|
||||
value: 'aspectFit',
|
||||
},
|
||||
currency: {
|
||||
type: String,
|
||||
value: '¥',
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
updatePrice: function () {
|
||||
var price = this.data.price;
|
||||
var priceArr = price.toString().split('.');
|
||||
this.setData({
|
||||
integerStr: priceArr[0],
|
||||
decimalStr: priceArr[1] ? ".".concat(priceArr[1]) : '',
|
||||
});
|
||||
},
|
||||
onClickThumb: function () {
|
||||
this.jumpLink('thumbLink');
|
||||
},
|
||||
},
|
||||
});
|
||||
6
miniprogram_npm/vant-weapp/card/index.json
Normal file
6
miniprogram_npm/vant-weapp/card/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-tag": "../tag/index"
|
||||
}
|
||||
}
|
||||
56
miniprogram_npm/vant-weapp/card/index.wxml
Normal file
56
miniprogram_npm/vant-weapp/card/index.wxml
Normal file
@ -0,0 +1,56 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="custom-class van-card">
|
||||
<view class="{{ utils.bem('card__header', { center: centered }) }}">
|
||||
<view class="van-card__thumb" bind:tap="onClickThumb">
|
||||
<image
|
||||
wx:if="{{ thumb }}"
|
||||
src="{{ thumb }}"
|
||||
mode="{{ thumbMode }}"
|
||||
lazy-load="{{ lazyLoad }}"
|
||||
class="van-card__img thumb-class"
|
||||
/>
|
||||
<slot wx:else name="thumb" />
|
||||
<van-tag
|
||||
wx:if="{{ tag }}"
|
||||
mark
|
||||
type="danger"
|
||||
custom-class="van-card__tag"
|
||||
>
|
||||
{{ tag }}
|
||||
</van-tag>
|
||||
<slot wx:else name="tag" />
|
||||
</view>
|
||||
|
||||
<view class="van-card__content {{ utils.bem('card__content', { center: centered }) }}">
|
||||
<view>
|
||||
<view wx:if="{{ title }}" class="van-card__title title-class">{{ title }}</view>
|
||||
<slot wx:else name="title" />
|
||||
|
||||
<view wx:if="{{ desc }}" class="van-card__desc desc-class">{{ desc }}</view>
|
||||
<slot wx:else name="desc" />
|
||||
|
||||
<slot name="tags" />
|
||||
</view>
|
||||
|
||||
<view class="van-card__bottom">
|
||||
<slot name="price-top" />
|
||||
<view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">
|
||||
<text>{{ currency }}</text>
|
||||
<text class="van-card__price-integer">{{ integerStr }}</text>
|
||||
<text class="van-card__price-decimal">{{ decimalStr }}</text>
|
||||
</view>
|
||||
<slot wx:else name="price" />
|
||||
<view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
|
||||
<slot wx:else name="origin-price" />
|
||||
<view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>
|
||||
<slot wx:else name="num" />
|
||||
<slot name="bottom" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="van-card__footer">
|
||||
<slot name="footer" />
|
||||
</view>
|
||||
</view>
|
||||
1
miniprogram_npm/vant-weapp/card/index.wxss
Normal file
1
miniprogram_npm/vant-weapp/card/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-card{background-color:var(--card-background-color,#fafafa);box-sizing:border-box;color:var(--card-text-color,#323233);font-size:var(--card-font-size,12px);padding:var(--card-padding,8px 16px);position:relative}.van-card__header{display:flex}.van-card__header--center{align-items:center;justify-content:center}.van-card__thumb{flex:none;height:var(--card-thumb-size,88px);margin-right:var(--padding-xs,8px);position:relative;width:var(--card-thumb-size,88px)}.van-card__thumb:empty{display:none}.van-card__img{border-radius:8px;height:100%;width:100%}.van-card__content{display:flex;flex:1;flex-direction:column;justify-content:space-between;min-height:var(--card-thumb-size,88px);min-width:0;position:relative}.van-card__content--center{justify-content:center}.van-card__desc,.van-card__title{word-wrap:break-word}.van-card__title{font-weight:700;line-height:var(--card-title-line-height,16px)}.van-card__desc{color:var(--card-desc-color,#646566);line-height:var(--card-desc-line-height,20px)}.van-card__bottom{line-height:20px}.van-card__price{color:var(--card-price-color,#ee0a24);display:inline-block;font-size:var(--card-price-font-size,12px);font-weight:700}.van-card__price-integer{font-size:var(--card-price-integer-font-size,16px)}.van-card__price-decimal,.van-card__price-integer{font-family:var(--card-price-font-family,Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif)}.van-card__origin-price{color:var(--card-origin-price-color,#646566);display:inline-block;font-size:var(--card-origin-price-font-size,10px);margin-left:5px;text-decoration:line-through}.van-card__num{float:right}.van-card__tag{left:0;position:absolute!important;top:2px}.van-card__footer{flex:none;text-align:right;width:100%}
|
||||
1
miniprogram_npm/vant-weapp/cascader/index.d.ts
vendored
Normal file
1
miniprogram_npm/vant-weapp/cascader/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
228
miniprogram_npm/vant-weapp/cascader/index.js
Normal file
228
miniprogram_npm/vant-weapp/cascader/index.js
Normal file
@ -0,0 +1,228 @@
|
||||
"use strict";
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var FieldName;
|
||||
(function (FieldName) {
|
||||
FieldName["TEXT"] = "text";
|
||||
FieldName["VALUE"] = "value";
|
||||
FieldName["CHILDREN"] = "children";
|
||||
})(FieldName || (FieldName = {}));
|
||||
var defaultFieldNames = {
|
||||
text: FieldName.TEXT,
|
||||
value: FieldName.VALUE,
|
||||
children: FieldName.CHILDREN,
|
||||
};
|
||||
(0, component_1.VantComponent)({
|
||||
props: {
|
||||
title: String,
|
||||
value: {
|
||||
type: String,
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
value: '请选择',
|
||||
},
|
||||
activeColor: {
|
||||
type: String,
|
||||
value: '#1989fa',
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
swipeable: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
closeable: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
ellipsis: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
showHeader: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
closeIcon: {
|
||||
type: String,
|
||||
value: 'cross',
|
||||
},
|
||||
fieldNames: {
|
||||
type: Object,
|
||||
value: defaultFieldNames,
|
||||
observer: 'updateFieldNames',
|
||||
},
|
||||
useTitleSlot: Boolean,
|
||||
},
|
||||
data: {
|
||||
tabs: [],
|
||||
activeTab: 0,
|
||||
textKey: FieldName.TEXT,
|
||||
valueKey: FieldName.VALUE,
|
||||
childrenKey: FieldName.CHILDREN,
|
||||
innerValue: '',
|
||||
},
|
||||
watch: {
|
||||
options: function () {
|
||||
this.updateTabs();
|
||||
},
|
||||
value: function (newVal) {
|
||||
this.updateValue(newVal);
|
||||
},
|
||||
},
|
||||
created: function () {
|
||||
this.updateTabs();
|
||||
},
|
||||
methods: {
|
||||
updateValue: function (val) {
|
||||
var _this = this;
|
||||
if (val !== undefined) {
|
||||
var values = this.data.tabs.map(function (tab) { return tab.selected && tab.selected[_this.data.valueKey]; });
|
||||
if (values.indexOf(val) > -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.innerValue = val;
|
||||
this.updateTabs();
|
||||
},
|
||||
updateFieldNames: function () {
|
||||
var _a = this.data.fieldNames || defaultFieldNames, _b = _a.text, text = _b === void 0 ? 'text' : _b, _c = _a.value, value = _c === void 0 ? 'value' : _c, _d = _a.children, children = _d === void 0 ? 'children' : _d;
|
||||
this.setData({
|
||||
textKey: text,
|
||||
valueKey: value,
|
||||
childrenKey: children,
|
||||
});
|
||||
},
|
||||
getSelectedOptionsByValue: function (options, value) {
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
var option = options[i];
|
||||
if (option[this.data.valueKey] === value) {
|
||||
return [option];
|
||||
}
|
||||
if (option[this.data.childrenKey]) {
|
||||
var selectedOptions = this.getSelectedOptionsByValue(option[this.data.childrenKey], value);
|
||||
if (selectedOptions) {
|
||||
return __spreadArray([option], selectedOptions, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
updateTabs: function () {
|
||||
var _this = this;
|
||||
var options = this.data.options;
|
||||
var innerValue = this.innerValue;
|
||||
if (!options.length) {
|
||||
return;
|
||||
}
|
||||
if (innerValue !== undefined) {
|
||||
var selectedOptions = this.getSelectedOptionsByValue(options, innerValue);
|
||||
if (selectedOptions) {
|
||||
var optionsCursor_1 = options;
|
||||
var tabs_1 = selectedOptions.map(function (option) {
|
||||
var tab = {
|
||||
options: optionsCursor_1,
|
||||
selected: option,
|
||||
};
|
||||
var next = optionsCursor_1.find(function (item) { return item[_this.data.valueKey] === option[_this.data.valueKey]; });
|
||||
if (next) {
|
||||
optionsCursor_1 = next[_this.data.childrenKey];
|
||||
}
|
||||
return tab;
|
||||
});
|
||||
if (optionsCursor_1) {
|
||||
tabs_1.push({
|
||||
options: optionsCursor_1,
|
||||
selected: null,
|
||||
});
|
||||
}
|
||||
this.setData({
|
||||
tabs: tabs_1,
|
||||
});
|
||||
wx.nextTick(function () {
|
||||
_this.setData({
|
||||
activeTab: tabs_1.length - 1,
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
tabs: [
|
||||
{
|
||||
options: options,
|
||||
selected: null,
|
||||
},
|
||||
],
|
||||
activeTab: 0,
|
||||
});
|
||||
},
|
||||
onClose: function () {
|
||||
this.$emit('close');
|
||||
},
|
||||
onClickTab: function (e) {
|
||||
var _a = e.detail, tabIndex = _a.index, title = _a.title;
|
||||
this.$emit('click-tab', { title: title, tabIndex: tabIndex });
|
||||
this.setData({
|
||||
activeTab: tabIndex,
|
||||
});
|
||||
},
|
||||
// 选中
|
||||
onSelect: function (e) {
|
||||
var _this = this;
|
||||
var _a = e.currentTarget.dataset, option = _a.option, tabIndex = _a.tabIndex;
|
||||
if (option && option.disabled) {
|
||||
return;
|
||||
}
|
||||
var _b = this.data, valueKey = _b.valueKey, childrenKey = _b.childrenKey;
|
||||
var tabs = this.data.tabs;
|
||||
tabs[tabIndex].selected = option;
|
||||
if (tabs.length > tabIndex + 1) {
|
||||
tabs = tabs.slice(0, tabIndex + 1);
|
||||
}
|
||||
if (option[childrenKey]) {
|
||||
var nextTab = {
|
||||
options: option[childrenKey],
|
||||
selected: null,
|
||||
};
|
||||
if (tabs[tabIndex + 1]) {
|
||||
tabs[tabIndex + 1] = nextTab;
|
||||
}
|
||||
else {
|
||||
tabs.push(nextTab);
|
||||
}
|
||||
wx.nextTick(function () {
|
||||
_this.setData({
|
||||
activeTab: tabIndex + 1,
|
||||
});
|
||||
});
|
||||
}
|
||||
this.setData({
|
||||
tabs: tabs,
|
||||
});
|
||||
var selectedOptions = tabs.map(function (tab) { return tab.selected; }).filter(Boolean);
|
||||
var value = option[valueKey];
|
||||
var params = {
|
||||
value: value,
|
||||
tabIndex: tabIndex,
|
||||
selectedOptions: selectedOptions,
|
||||
};
|
||||
this.innerValue = value;
|
||||
this.$emit('change', params);
|
||||
if (!option[childrenKey]) {
|
||||
this.$emit('finish', params);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
8
miniprogram_npm/vant-weapp/cascader/index.json
Normal file
8
miniprogram_npm/vant-weapp/cascader/index.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index",
|
||||
"van-tab": "../tab/index",
|
||||
"van-tabs": "../tabs/index"
|
||||
}
|
||||
}
|
||||
55
miniprogram_npm/vant-weapp/cascader/index.wxml
Normal file
55
miniprogram_npm/vant-weapp/cascader/index.wxml
Normal file
@ -0,0 +1,55 @@
|
||||
<wxs src="./index.wxs" module="utils" />
|
||||
|
||||
<view wx:if="{{ showHeader }}" class="van-cascader__header">
|
||||
<slot name="title" wx:if="{{ useTitleSlot }}"></slot>
|
||||
<text class="van-cascader__title" wx:else>{{ title }}</text>
|
||||
<van-icon
|
||||
wx:if="{{ closeable }}"
|
||||
name="{{ closeIcon }}"
|
||||
class="van-cascader__close-icon"
|
||||
bind:tap="onClose"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<van-tabs
|
||||
active="{{ activeTab }}"
|
||||
custom-class="van-cascader__tabs"
|
||||
wrap-class="van-cascader__tabs-wrap"
|
||||
tab-class="van-cascader__tab"
|
||||
color="{{ activeColor }}"
|
||||
border="{{ false }}"
|
||||
swipeable="{{ swipeable }}"
|
||||
ellipsis="{{ ellipsis }}"
|
||||
bind:click="onClickTab"
|
||||
>
|
||||
<van-tab
|
||||
wx:for="{{ tabs }}"
|
||||
wx:for-item="tab"
|
||||
wx:for-index="tabIndex"
|
||||
wx:key="tabIndex"
|
||||
title="{{ tab.selected ? tab.selected[textKey] : placeholder }}"
|
||||
style="width: 100%;"
|
||||
title-style="{{ !tab.selected ? 'color: #969799;font-weight:normal;' : '' }}"
|
||||
>
|
||||
<!-- 暂不支持 -->
|
||||
<!-- <slot name="options-top"></slot> -->
|
||||
|
||||
<view class="van-cascader__options">
|
||||
<view
|
||||
wx:for="{{ tab.options }}"
|
||||
wx:for-item="option"
|
||||
wx:key="index"
|
||||
class="{{ option.className }} {{ utils.optionClass(tab, valueKey, option) }}"
|
||||
style="{{ utils.optionStyle({ tab, valueKey, option, activeColor }) }}"
|
||||
data-option="{{ option }}"
|
||||
data-tab-index="{{ tabIndex }}"
|
||||
bind:tap="onSelect"
|
||||
>
|
||||
<text>{{ option[textKey] }}</text>
|
||||
<van-icon wx:if="{{ utils.isSelected(tab, valueKey, option) }}" name="success" size="18" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 暂不支持 -->
|
||||
<!-- <slot name="options-bottom"></slot> -->
|
||||
</van-tab>
|
||||
</van-tabs>
|
||||
24
miniprogram_npm/vant-weapp/cascader/index.wxs
Normal file
24
miniprogram_npm/vant-weapp/cascader/index.wxs
Normal file
@ -0,0 +1,24 @@
|
||||
var utils = require('../wxs/utils.wxs');
|
||||
var style = require('../wxs/style.wxs');
|
||||
|
||||
function isSelected(tab, valueKey, option) {
|
||||
return tab.selected && tab.selected[valueKey] === option[valueKey]
|
||||
}
|
||||
|
||||
function optionClass(tab, valueKey, option) {
|
||||
return utils.bem('cascader__option', { selected: isSelected(tab, valueKey, option), disabled: option.disabled })
|
||||
}
|
||||
|
||||
function optionStyle(data) {
|
||||
var color = data.option.color || (isSelected(data.tab, data.valueKey, data.option) ? data.activeColor : undefined);
|
||||
return style({
|
||||
color
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
isSelected: isSelected,
|
||||
optionClass: optionClass,
|
||||
optionStyle: optionStyle,
|
||||
};
|
||||
1
miniprogram_npm/vant-weapp/cascader/index.wxss
Normal file
1
miniprogram_npm/vant-weapp/cascader/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-cascader__header{align-items:center;display:flex;height:48px;justify-content:space-between;padding:0 16px}.van-cascader__title{font-size:16px;font-weight:600;line-height:20px}.van-cascader__close-icon{color:#c8c9cc;font-size:22px;height:22px}.van-cascader__tabs-wrap{height:48px!important;padding:0 8px}.van-cascader__tab{color:#323233!important;flex:none!important;font-weight:600!important;padding:0 8px!important}.van-cascader__tab--unselected{color:#969799!important;font-weight:400!important}.van-cascader__option{align-items:center;cursor:pointer;display:flex;font-size:14px;justify-content:space-between;line-height:20px;padding:10px 16px}.van-cascader__option:active{background-color:#f2f3f5}.van-cascader__option--selected{color:#1989fa;font-weight:600}.van-cascader__option--disabled{color:#c8c9cc;cursor:not-allowed}.van-cascader__option--disabled:active{background-color:initial}.van-cascader__options{-webkit-overflow-scrolling:touch;box-sizing:border-box;height:384px;overflow-y:auto;padding-top:6px}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user