Commit ef265726 by zhangxw

小程序模板初始化

0 parents
Showing 120 changed files with 4803 additions and 0 deletions
import api from '~/utils/request/request'
import indexApi from './indexApi'
import ssoApi from './ssoApi'
import discoveryApi from './discoveryApi'
import shopmallApi from './shopmallApi'
import mineApi from './mineApi'
import couponsApi from './coupons'
import equityApi from './equity'
import entmicroApi from './entmicroApi'
import boutiquecouponApi from './boutiquecouponApi'
import psdApi from './psdApi'
import sopApi from './sopApi'
import carlifeApi from './carlifeApi'
import bigdatautilApi from './bigdatautil'
const common = 'scrm.api.carlife.common.'
module.exports = {
ssoApi,
indexApi,
discoveryApi,
shopmallApi,
mineApi,
couponsApi,
equityApi,
entmicroApi,
boutiquecouponApi,
psdApi,
sopApi,
carlifeApi,
bigdatautilApi,
commonApi: {
/**上传图片
*/
uploadImg(data) {
return api.post({
method: `${common}uploadImg`,
...data,
noSignAttr: ['file']
})
},
/**视频上传
*/
uploadVideo(data) {
return api.post({
method: `${common}uploadVideo`,
...data,
noSignAttr: ['file']
})
},
// /**根据sceneId 查参数 */
// getSceneById(data) {
// return api.post('dj.api.smartcarlife.common.getSceneById', data)
// },
/** 首页、发现列表 搜索接口 */
search(data) {
return api.post({
method: 'scrm.api.carlife.weapp.homeSearch.search',
pageSize: 10,
...data
})
},
/** 根据sap编码获取商户详情 */
getBySapCode(data) {
return api.post(
{
method: `scrm.api.carlife.merchant.getBySapCode`,
...data
},
true
)
},
/**获取图片版本号 */
getImgVersion() {
return api.getMock()
}
}
}
import api from '~/utils/request/request'
module.exports = {
/**埋点 数据上报*/
reportCustomer(params) {
return api.post({
method: 'entmicro.api.customercollect.reportCustomer',
...params,
projectName: 'customercollect'
})
}
}
import api from '~/utils/request/request'
module.exports = {
/**分页查询核销用户券 */
getBoutiquecouponList(data) {
return api.post({
method: `scrm.api.boutiquecoupon.customer.coupon.search`,
...data
})
},
/**获取商户券详情 */
getMerchantCoupon(id) {
return api.post({
method: `scrm.api.boutiquecoupon.merchantCoupon.getById`,
id
})
},
/** 获取精品礼券详情 */
getCouponDetail(id) {
return api.post({
method: 'scrm.api.boutiquecoupon.customer.coupon.detail',
id
})
},
/** 领取礼券 生成待核销码 */
getCoupon(data) {
return api.post({
method: `scrm.api.boutiquecoupon.customer.coupon.add`,
...data
})
},
/**获取园区店信息 */
getYqInfo(data) {
return api.post({
method: 'scrm.api.boutiquecoupon.serviceMerchant.getByMerchantId',
...data
})
},
/** 精品交付单列表 */
getUserBoutiqueList(data) {
data.pageSize = 10
return api.post(
{
method: 'scrm.api.boutiquecoupon.goodsOrder.listMyOrder',
...data
},
true
)
},
/**扫码后根据订单号获取订单详情 */
scanGetDetailByOrderCode(data) {
return api.post({
method: 'scrm.api.boutiquecoupon.order.detailScan',
...data
})
},
/**根据订单号获取订单详情 */
getDetailByOrderCode(data) {
return api.post({
method: 'scrm.api.boutiquecoupon.order.detail',
...data
})
},
/**评价 */
addComment(data) {
return api.post({
method: 'scrm.api.boutiquecoupon.orderComment.add',
...data
})
}
}
import api from '~/utils/request/request'
module.exports = {
/** 获取用户绑定设备信息 */
getUserDevInfo() {
return api.post({
method: 'scrm.api.carlife.devicebind.get.accountbinding',
deviceType: 'GPS'
})
},
/** 绑定设备 */
bindDev(data) {
return api.post(
{
method: 'scrm.api.carlife.devicebind.binding',
appType: 'CgacarMiniprogram',
...data
},
true
)
},
/** 解绑设备 */
unbindDev(data) {
return api.post({
method: 'scrm.api.carlife.devicebind.unbinding',
...data
})
},
/**获取设备最新位置信息 */
getCarPosition(data) {
return api.post({
method: 'scrm.api.carlife.deviceposition.get.vehicle.position',
...data
})
},
/**获取设备最近行程 */
getPathList(data) {
return api.post({
method: 'scrm.api.carlife.deviceposition.get.recently.journey',
pageSize: 10,
...data
})
},
/** 获取设备总里程 */
getDevMileage(data) {
return api.post({
method: 'scrm.api.carlife.deviceposition.get.total.mileage',
...data
})
},
/** 获取线索列表 */
getClueList(data) {
return api.post({
method: 'scrm.api.carlife.weapp.clue.listWithPage',
pageSize: 10,
channelType: 'GH',
...data
})
},
/**获取设备日行程 */
getPathListByDay(data) {
return api.post({
method: 'scrm.api.carlife.deviceposition.get.journey.bydate',
pageSize: 10,
...data
})
},
/**获取指定行程信息 */
getPathDetail(journeyId) {
return api.post(
{
method: 'scrm.api.carlife.deviceposition.get.journey.by.id',
journeyId
},
true
)
},
/**底部商城导航栏跳转至第三方倍礼安商城 */
getBizjiaUrl(data) {
return api.post({
method: `scrm.api.carlife.cgacar.api.shopmall`,
...data
})
},
/**判断是否绑定车架号 */
checkBindVIN(data) {
return api.post({
method: `scrm.api.carlife.cgacar.commom.list.veh`,
...data
})
}
}
import api from '~/utils/request/request'
const path = 'scrm.api.coupon.'
const ghPath = 'scrm.api.carlife.cgacar.'
import { defaultMerchantId } from '~/utils/request/environment'
module.exports = {
/**获取卡券列表 */
getCardData(data) {
return api.post({
method: `${path}app.list`,
...data
// discountTypes: [3, 7]
})
},
/**获取卡券数量 */
getCouponNum() {
return api.post({
method: 'scrm.api.coupon.list.by.account.id',
useMemberType: 0
})
},
/**获取首页可以领取的券 */
getHomeCardData(data) {
let merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
if (merchantId) {
merchantId = Number(JSON.parse(merchantId))
data.merchantId = merchantId
}
if (merchantId) {
data.merchantId = merchantId
}
return api.post({
method: `${path}list.merchant.account`,
...data
})
},
/**领取优惠券 */
toReciveCard(data) {
let merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
if (merchantId) {
merchantId = Number(JSON.parse(merchantId))
data.merchantId = merchantId
} else {
data.merchantId = defaultMerchantId
}
return api.post({
method: `${path}customer.receive`,
...data,
receiveWay: 1,
receiveSource: 3
})
},
/**卡券详情 */
couponsDetail(data) {
return api.post({
method: `${path}verification.code.detail`,
...data
})
},
/**广汇卡券 卡券全部列表 */
ghCouponsData() {
return api.post({
method: `${ghPath}coupon.list.benefits`
})
},
/**广汇卡券 抵用记录列表 */
ghDealNote() {
return api.post({
method: `${ghPath}coupon.list.credit.cards`
})
},
/**广汇卡券 发布确认列表 */
ghDealPublish() {
return api.post({
method: `${ghPath}coupon.list.card.deal`
})
},
/**广汇卡券 抵用确认列表 */
ghDealResist() {
return api.post({
method: `${ghPath}coupon.list.resist.deal`
})
},
/**抵用确认提交 */
ghSumbitResist(data) {
return api.post({
method: `${ghPath}coupon.resist.deal`,
...data
})
},
/**发布确认提交 */
ghSumbitPublish(data) {
return api.post({
method: `${ghPath}coupon.card.deal`,
...data
})
},
/**免费领取体验卡 */
tolqFreecard(data) {
return api.post(
{
method: `scrm.api.equity.h5.free.card.receive`,
...data
},
true
)
},
/**获取体验卡天数 */
getFreeCardDay(data) {
return api.post({
method: `scrm.api.equity.class.free.day.get`,
...data
})
},
/** 获取企微分享优惠卷信息 */
getCouponInfo(data) {
return api.post({
method: `${path}share.info`,
...data
})
},
/**领取优惠券 */
receiveCoupon(data) {
return api.post(
{
method: `${path}share.receive`,
...data,
receiveSource: 4
},
true
)
},
/**获取套餐详情(权益) */
packageInfo(data) {
return api.post({
method: `scrm.api.equity.main.page.package.detail.get`,
...data
})
},
/**获取门店单号(权益) */
createOrderNum(data) {
return api.post({
method: `scrm.api.equity.merchant.order.code.create`,
...data
})
},
/**创建门店订单(权益) */
createOrder(data) {
return api.post({
method: `scrm.api.equity.merchant.order.create`,
...data
})
},
/**获取折扣券 兑换券详情 */
getWWCoupon(data) {
return api.post({
method: `scrm.api.coupon.verification.code.detail`,
...data
})
},
/** 检查是否领取优惠券 */
checkCoupon(data) {
return api.post({
method: `scrm.api.coupon.share.receive.check`,
...data
})
},
// 定向礼包详情
giftsDetail(data) {
return api.post({
method: `scrm.api.coupon.directional.gift.detail`,
...data
})
},
// 定向礼包领取
giftsRecive(data) {
return api.post({
method: `scrm.api.coupon.user.directional.gift.create`,
...data
})
},
/**查询会员开通的套餐列表 */
getVipList(data) {
return api.post({
method: `scrm.api.equity.package.info.list.with.account`,
pageSize: 9999,
...data
})
},
/** 查询包含已使用卡券的会员套餐列表 */
getVipUsedList(data) {
return api.post({
method: `scrm.api.equity.package.info.list.with.used.service`,
pageSize: 9999,
...data
})
},
/** 查询包含失效卡券的会员套餐列表 */
getVipFailList(data) {
return api.post({
method: `scrm.api.equity.package.info.list.with.invalid.service`,
pageSize: 9999,
...data
})
},
// 获取优惠券详情--道路救援
getDigitalCoupons(data) {
return api.post({
method: `scrm.api.coupon.detail`,
...data
})
}
}
import api from '~/utils/request/request'
const path = 'scrm.api.shopmall.zoneInfo.weapp.'
module.exports = {
/**查询商户的指定类型专区列表 */
getZoneInfo(zoneType) {
return api.post({
method: `${path}listByMerchantId`,
zoneType //专区类型(1发现频道,2商城专区)
})
},
/** 晒单详情 */
getOrderShareRecordDetail(id) {
return api.post({
method: 'scrm.api.shopmall.weapp.orderShareRecord.detail',
id
})
}
}
import api from '~/utils/request/request'
module.exports = {
getServiceCode(data) {
return api.post(
{
method: 'dracIm.api.entmicro.findMiniProgramIm',
...data
},
true
)
},
/**数字化道路救援 */
getDigitalPageInfo(data) {
return api.post({
method: 'entmicro.api.drac.rescue.getRescueCustomerView',
...data
})
},
/**刷新数字化道路救援二维码 */
toFreshCode(data) {
return api.post({
method: 'entmicro.api.drac.rescue.getRescueStaffCode',
...data
})
},
/**重新定位获取数据 */
toRegetDigitalData(data) {
return api.post({
method: 'entmicro.api.drac.rescue.rescueReacquireLocation',
...data
})
},
/**智能外呼-联系人 */
findByActivityIdAndPhone(data) {
return api.post(
{
method: 'dracIm.api.entmicro.findByActivityIdAndPhone',
...data
},
true
)
}
}
import api from '~/utils/request/request'
module.exports = {
/**激活卡(权益) */
activeEquity(data) {
return api.post({
method: `scrm.api.equity.open.card.by.cardno`,
...data
})
},
/**获取代驾服务接口*/
getEdjurl(data) {
return api.post({
method: `scrm.api.equity.edj.url`,
...data
})
},
/**获取所有权益 */
getAllEquity(data) {
return api.post({
method: `scrm.api.equity.third.get`,
...data
})
},
//查询是否开通会员
checkOpenMember(data) {
return api.post(
{
method: `scrm.api.equity.info`,
...data
},
true
)
},
// 获取商品信息
commodityMsg(data) {
return api.post({
method: `scrm.api.equity.coupon.detail`,
...data
})
},
// 查询商品库存
checkStock(data) {
return api.post(
{
method: `scrm.api.equity.goods.stock.get`,
...data
},
true
)
},
// 首页--附近优惠
lasteCommodity(data) {
return api.post({
method: `scrm.api.equity.main.page.carefully.chosen.get`,
...data
})
},
// 首页--门店套餐
storePackage(data) {
return api.post({
method: `scrm.api.equity.main.page.merchant.package.get`,
...data
})
},
// 首页--获取会员卡信息
memberCard(data) {
return api.post({
method: `scrm.api.equity.open.card.price.get.by.merchantid`,
...data
})
},
// 购买权益卡
buyMemberCard(data) {
return api.post({
method: `scrm.api.equity.open.card.to.buy`,
...data
})
},
// 首页--获取养车服务
serviceDataOfhome(data) {
return api.post({
method: `scrm.api.equity.service.h5.main.page.service.get`,
...data
})
},
// 查询服务条款
serviceTerms(data) {
return api.post({
method: `scrm.api.equity.service.h5.items.terms.get`,
...data
})
},
// 根据身份证查询订单
checkOrderByIdcard(data) {
return api.post({
method: `scrm.api.equity.service.h5.order.by.card`,
...data
})
},
// 首页--检测是否领取了权益卡
checkCustomCardNote(data) {
return api.post({
method: `scrm.api.equity.service.h5.customer.equity.card.get`,
...data
})
},
// 通过购买售前权益套餐后领卡
openCardByPreSale(data) {
return api.post(
{
method: `scrm.api.equity.open.card.receive.by.package`,
...data
},
true
)
},
// 购买商品获取订单号
getOrderCode(data) {
return api.post({
method: `scrm.api.equity.ordercode.get`,
...data
})
},
/** 会员商城商品数据 */
getMerchantGoodsList(data) {
return api.post({
method: `scrm.api.shopmall.goods.page.curMerchant.wechat`,
pageNum: 1,
pageSize: 999,
...data
})
},
// 支付订单号
payGoodsOrder(data) {
return api.post({
method: `scrm.api.equity.create.order`,
...data
})
},
// 服务项目详情
serviceDetailMsg(data) {
return api.post({
method: `scrm.api.equity.service.h5.bill.detail.get`,
...data
})
},
// 门店订单套餐详情
packageOrderDetail(data) {
return api.post({
method: `scrm.api.equity.h5.package.order.detail.get`,
...data
})
},
// 获取直充商品数据
chargeData(data) {
return api.post({
method: `scrm.api.equity.charge.detail`,
...data
})
},
// 获取订单详情
orderDetailData(data) {
return api.post({
method: `scrm.api.equity.h5.order.detail.get`,
...data
})
},
// 创建售后
createdSale(data) {
return api.post({
method: `scrm.api.equity.order.refund.detail.create`,
...data
})
},
// 获取售后详情
saleDetailInfo(data) {
return api.post({
method: `scrm.api.equity.h5.order.refund.detail.get`,
...data
})
},
// 套餐申请售后
packageApply(data) {
return api.post({
method: `scrm.api.equity.merchant.order.refund`,
...data
})
},
// 我的卡券
cardListData(data) {
return api.post({
method: `scrm.api.equity.h5.order.list.get`,
...data
})
},
// 确认收货
comfirmRevice(data) {
return api.post({
method: `scrm.api.equity.h5.order.finish.confirm`,
...data
})
},
// 查询热线电话
hotLine(data) {
return api.post({
method: `scrm.api.equity.service.package.merchant.hotline.get`,
...data
})
},
// 查询商户信息
getMerchantInfo(data) {
return api.post({
method: `scrm.api.equity.common.merchant.detail.det`,
...data
})
},
// 查询是否开通售前权益配置
preSaleSetting(data) {
return api.post({
method: `scrm.api.equity.service.merchant.config.get`,
...data
})
},
// 生成理赔核销码
createdQrCode(data) {
return api.post({
method: `scrm.api.equity.service.order.h5.writeOff.code.generate`,
...data
})
},
// 新增救援服务线索
addClueRescue(data) {
return api.post({
method: `scrm.api.carlife.weapp.clue.rescue`,
...data
})
},
// 获取权益功能菜单
equityFnMenu(data) {
return api.post({
method: `scrm.api.equity.main.page.third.equity.get`,
...data
})
},
// 会员套餐列表
equityPacks(data) {
return api.post({
method: `scrm.api.equity.main.page.group.package.get`,
...data
})
},
// 会员开通记录
equityOpenNote(data) {
return api.post({
method: `scrm.api.equity.card.user.record`,
...data
})
},
// 会员套餐服务列表
equityServices(data) {
return api.post({
method: `scrm.api.equity.package.service.list`,
...data
})
},
// 新版购买权益卡+套餐
equityBuy(data) {
return api.post({
method: `scrm.api.equity.merchant.order.gh.create`,
...data
})
},
// 新版查看已购买套餐
checkHaveBuyPackage(data) {
return api.post({
method: `scrm.api.equity.package.info.list.with.account`,
...data
})
},
// 会员商城专区
getZoneInfo(data) {
return api.post({
method: `scrm.api.shopmall.zoneInfo.weapp.listByMerchantId`,
...data
})
},
// 购买套餐默认回显上次填写的车牌号(只查车牌号不查车架号)
getLastBindPlatNum(data) {
return api.post(
{
method: `scrm.api.equity.merchant.order.bind.car.record`,
...data
},
true
)
},
// 集团套餐详情
equityJTpackageDetail(data) {
return api.post({
method: `scrm.api.equity.main.page.group.package.detail`,
...data
})
}
}
import api from '~/utils/request/request'
const path = 'scrm.api.shopmall.'
module.exports = {
/**获取商户小程序首页配置 */
getHomeConfig(data) {
return api.post({ method: `${path}weapp.homeConfig.getByMerchant`, ...data })
},
/**查询当前商户的分类列表 */
getClassifyList(data) {
return api.post({ method: `${path}classify.weapp.listByMerchantId`, ...data })
},
/**获取附近商户接口 */
getMerchantList(data) {
return api.post({ method: `scrm.api.carlife.merchant.recently.merchant`, storeCount: 10, ...data })
},
/** 分页查询活动 */
getActivityList(data) {
return api.post({ method: `${path}weapp.activity.page`, pageSize: 10, ...data })
},
/**分页查询直播 */
getLiveList(data) {
return api.post({ method: `scrm.api.live.weapp.live.page`, pageSize: 10, ...data })
},
/** 广汇获取城市列表 */
getCityList() {
return api.post({ method: 'scrm.api.carlife.cgacar.api.cities' })
},
/** 广汇获取车辆品牌列表 */
getBrandList() {
return api.post({ method: 'scrm.api.carlife.cgacar.api.brands' })
},
/** 广汇获取门店列表 */
getGHStoreList(data) {
return api.post({ method: 'scrm.api.carlife.cgacar.api.stores', pageSize: 10, ...data })
},
/** 创建维保预约单接口 */
createMaintainOrder(data) {
return api.post({ method: 'scrm.api.carlife.cgacar.commom.maintain.create', ...data })
},
/**新车频道 */
/**获取品牌列表 */
newBrandList(data) {
return api.post({ method: 'scrm.api.carlife.weapp.clue.vehicle.brandList', ...data })
},
/**获取车系列表 */
newCarSeriesList(data) {
return api.post({ method: 'scrm.api.carlife.weapp.clue.vehicle.seriesList', ...data })
},
/**获取车型列表 */
newCarTypeList(data) {
return api.post({ method: 'scrm.api.carlife.weapp.clue.vehicle.shapeList', ...data })
},
/**新增试驾预约 */
addAppointment(data) {
return api.post({ method: 'scrm.api.carlife.weapp.clue.drive.add', ...data })
},
/**新增新车询价 */
addNewCarEnquiry(data) {
return api.post({ method: 'scrm.api.carlife.weapp.clue.newCar', ...data })
}
}
import api from '~/utils/request/request'
const path = 'scrm.api.shopmall.weapp.'
const carlife = 'scrm.api.carlife.weapp.'
const carlifeApi = {
/** 获取车品牌列表 */
getCarBrandList() {
return api.post({
method: 'scrm.api.carlife.common.getOnlyCarBrandList'
})
},
/** 获取车系列表 */
getCarSeriesList(data) {
return api.post({
method: 'scrm.api.carlife.common.getCarSeriesList',
...data
})
},
/** 获取车型 */
getCarTypeList(carSeriesId) {
return api.post({
method: 'scrm.api.carlife.common.getCarTypeList',
carSeriesId
})
},
/** 获取当前用户的车辆列表 */
getUserCarList(data) {
return api.post({
method: `${carlife}userCar.list`,
...data
})
},
/**新增用户车辆 */
addUserCar(data) {
return api.post({
method: `${carlife}userCar.add`,
...data
})
},
/** 更新用户车辆 */
updateUserCar(data) {
return api.post({
method: `${carlife}userCar.update`,
...data
})
},
/** 获取用户车辆 */
getUserCar(carId) {
return api.post({
method: `${carlife}userCar.getById`,
carId
})
},
/**删除用户车辆 */
delUserCar(carId) {
return api.post({
method: `${carlife}userCar.delete`,
carId
})
},
/**获取当前用户的收货地址列表 */
getUserAddressList(data) {
return api.post({
method: `${carlife}userAddress.list`,
...data
})
},
/**根据ID获取用户收货地址 */
getUserAddress(data) {
return api.post({
method: `${carlife}userAddress.getById`,
...data
})
},
/** 新增用户收货地址 */
addUserAddress(data) {
return api.post({
method: `${carlife}userAddress.add`,
...data
})
},
/**编辑用户收货地址 */
updateUserAddress(data) {
return api.post({
method: `${carlife}userAddress.update`,
...data
})
},
/** 更改为默认收货地址 */
setUserAddressDefault(data) {
return api.post({
method: `${carlife}userAddress.updateDefault`,
...data
})
},
/** 删除用户收货地址 */
delUserAddress(data) {
return api.post({
method: `${carlife}userAddress.delete`,
...data
})
},
/** 获取用户默认收货地址 */
getUserAddressDefault() {
return api.post(
{
method: `${carlife}userAddress.getDefault`
},
true
)
},
/** 预约历史 */
getAppointmentList(pageNum) {
return api.post({
method: 'scrm.api.carlife.cgacar.commom.list.appointment',
pageNum
})
}
}
module.exports = {
...carlifeApi,
/**获取集团或者门店详细信息 */
getMerchantDetail(data) {
return api.post({
method: 'scrm.api.carlife.merchant.detail',
...data
})
},
/**. 分页查询订单 */
getOrderList(data) {
return api.post({
method: `${path}order.page`,
pageSize: 9999,
...data
})
},
/** 获取用户卷列表 */
getUserCouponList() {
return api.post({
method: 'scrm.api.coupon.user.list',
discountTypes: [3, 7]
})
},
/** 广汇车辆列表接口 */
getGHUserCarList() {
return api.post(
{
method: 'scrm.api.carlife.cgacar.commom.list.veh'
},
true
)
},
/** 广汇客户车辆绑定接口 */
bindGHVehicle(data) {
return api.post(
{
method: 'scrm.api.carlife.cgacar.commom.vehicle.bind',
...data
},
true
)
},
/** 获取广汇用户信息 */
getGHUserInfo() {
return api.post(
{
method: 'scrm.api.carlife.cgacar.commom.user.info.get'
},
true
)
},
/** 获取当前用户顾问配置 */
getConsultantInfo(data) {
return api.post(
{
method: 'scrm.api.carlife.config.consultant.get',
...data
},
true
)
},
/** 获取顾问列表*/
getConsultantList(data) {
return api.post(
{
method: 'scrm.api.carlife.config.consultant.list',
...data
},
true
)
},
// 服务顾问配置更新
updateConsultant(data) {
return api.post({
method: 'scrm.api.carlife.config.consultant.update',
...data
})
}
}
import api from '~/utils/request/request'
module.exports = {
/** 素材发送/阅读埋点 */
viewReadBuriedPoint(params) {
return api.post({
method: 'marketing.api.open.material.sendReadBuriedPoint',
list: [params],
projectName: 'material'
})
},
/** 素材详情 */
getPsdDetail(data) {
return api.post(
{
method: `marketing.api.material.detail`,
...data,
flag: 1
},
true
)
}
}
import api from '~/utils/request/request'
const path = 'scrm.api.shopmall.weapp.'
const couponpath = 'scrm.api.coupon.'
const wechatPath = 'scrm.api.wechat.'
module.exports = {
/** 分页查询商城专区的商品信息 */
getGoodsList(data) {
return api.post({
method: `scrm.api.shopmall.zoneInfo.weapp.goodsPage`,
pageNum: 1,
pageSize: 999,
...data
})
},
/** 根据商品ID获取商品 */
getGoodsDetail(id) {
return api.post(
{
method: `${path}goods.getById`,
id,
viewAmount: true
},
true
)
},
/** 添加购物车 */
addShoppingcart(data) {
return api.post({
method: `${path}shoppingcart.add`,
...data
})
},
/** 购物车删除商品 */
delShoppingcart(id) {
return api.post({
method: `${path}shoppingcart.delete`,
id
})
},
/** 分页获取购物车 */
getShoppingcartList() {
return api.post({
method: `${path}shoppingcart.list`
})
},
/** 购物车商品变更(比如修改数量) */
updateShoppingcart(data) {
return api.post({
method: `${path}shoppingcart.update`,
...data
})
},
/**购物车结算 */
settlementShoppingcart(data) {
return api.post({
method: `${path}shoppingcart.settlement`,
...data
})
},
/**根据规格值组合获取规格组合库存及零售价 */
getGoodsSpecificationExtra(data) {
return api.post({
method: `${path}goods.getGoodsSpecificationExtra`,
...data
})
},
/** 创建订单(立即购买) */
createOrder(data) {
return api.post({
method: `${path}order.create`,
...data
})
},
/**创建支付订单(去付款) */
payOrder(data) {
return api.post({
method: `${path}order.createPay`,
...data
})
},
/** 确认收货 */
confirmReceipt(orderCode) {
return api.post({
method: `${path}order.confirmReceipt`,
orderCode
})
},
/**订单详情 */
getOrderDetail(orderCode) {
return api.post({
method: `${path}order.detail`,
orderCode
})
},
/** 申请售后 */
afterSale(data) {
return api.post(
{
method: `${path}orderRefund.apply`,
...data
},
true
)
},
/**活动详情 */
getActivityDetail(id) {
return api.post(
{
method: `${path}activity.detail`,
id
},
true
)
},
/** 直播活动详情 */
getLiveActivityDetail(data) {
return api.post(
{
method: `${path}live.activity.detail`,
...data
},
true
)
},
/**获取订单的售后详情 */
getOrderRefundDetail(orderCode) {
return api.post({
method: `${path}orderRefund.detail`,
orderCode
})
},
/** 为售后添加退货快递信息 */
addDelivery(data) {
return api.post({
method: `${path}orderRefund.addDelivery`,
...data
})
},
/** 获取商品关联优惠券列表 */
getGoodscouponList(id) {
return api.post(
{
method: `${path}goods.user.coupons.get`,
...id
},
true
)
},
/** 领取商品详情优惠券 */
getCoupon(data) {
return api.post(
{
method: `${couponpath}customer.receive`,
...data
},
true
)
},
/** 领取确认订单最大优惠券 */
getMaxCoupon(orderGoods) {
return api.post(
{
method: `${path}order.coupons.get`,
orderGoods
},
true
)
},
/**更换优惠券*/
updateCoupon(orderGoods) {
return api.post(
{
method: `${path}order.coupons.change`,
orderGoods
},
true
)
},
//立即评价
addComment(data) {
return api.post(
{
method: `${path}orderGoodsComment.saveByOrder`,
...data
},
true
)
},
//评论列表
getCommentList(data) {
return api.post(
{
method: `${path}orderGoodsComment.page`,
...data
},
true
)
},
//获取订单的评论详情
getOrderCommentDetails(orderCode) {
return api.post(
{
method: `${path}orderGoodsComment.customerOrderGoodsComment`,
orderCode
},
true
)
},
//取消付款
cancelPay(orderCode) {
return api.post(
{
method: `${path}order.cancelPay`,
orderCode
},
true
)
},
//申请售后待审核的订单取消售后
cancelOrder(orderCode) {
return api.post(
{
method: `${path}orderRefund.cancel`,
orderCode
},
true
)
},
/** 直播活动详情id */
getLiveActivityId(id) {
return api.post(
{
method: `${wechatPath}get.scene.by.id`,
...id
},
true
)
},
/** 获取活动分享链接 */
getActivitylink(id) {
return api.post(
{
method: `scrm.api.shopmall.activity.get.shared`,
id
},
true
)
},
/** 获取商品分享链接 */
getGoodslink(id) {
return api.post(
{
method: `scrm.api.shopmall.goods.get.shared`,
id
},
true
)
},
// scrm.api.shopmall.weapp.
requestSubscribeMessage() {
return api.post(
{
method: `scrm.api.shopmall.weapp.order.listSubscribeMsgTemplateIds`
},
true
)
},
/** 小程序端根据优惠券id查询可使用商品列表(分页) */
getCouponGoodsPage(data) {
// let merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
// if (merchantId) data.merchantId = merchantId
data.pageSize = 8
return api.post({
method: 'scrm.app.shopmall.coupon.goods.page',
...data
})
}
}
import api from '~/utils/request/request'
module.exports = {
/** sop用户行为记录(埋点调用)
*/
customerBehavior(data) {
return api.post({
method: 'scrm.api.sop.task.customerBehavior.add',
flag: 1,
...data
})
}
}
import api from '~/utils/request/request'
const path = 'scrm.api.sso.weapp.'
module.exports = {
/**wx.login登录 */
jsCodeLogin(data) {
return api.post(
{
method: `${path}jscode.login`,
...data
},
true
)
},
/**授权用户信息 */
authUserInfo(data) {
return api.post(
{
method: 'scrm.api.sso.weapp.auth.userinfo',
...data
},
true
)
},
/**授权手机号 */
authUserPhone(data) {
return api.post(
{
method: `${path}auth.phone`,
...data
},
true
)
},
/**退出 */
logout() {
return api.post(
{
method: `scrm.api.sso.user.logout`
},
true
)
},
//保存用户授权信息
saveuserProfile(data) {
return api.post(
{
method: `scrm.api.wechat.auth.userProfile.save`,
...data
},
true
)
},
/**更新客户手机号 */
updataCustomerPhone(data) {
return api.post({
method: `scrm.api.sso.weapp.mark.phone`,
...data
})
}
}
// import api from '../api/request'
import api from '~/utils/request/request'
const { appId } = wx.getAccountInfoSync().miniProgram
class UsersApi {
/**调用后台接口获取用户信息 */
async login() {
return this.getWxCode().then(({ code }) => {
return api.post(
{
method: 'scrm.api.sso.weapp.jscode.login',
appId,
code
},
true
)
})
}
/**调用接口获取登录凭证(code)。通过凭证进而换取用户登录态信息,包括用户在当前小程序的唯一标识(openid)、微信开放平台帐号下的唯一标识(unionid,若当前小程序已绑定到微信开放平台帐号)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。 */
getWxCode() {
return new Promise((resolve, reject) => {
wx.login({
success: res => resolve(res),
fail: err => reject(err)
})
})
}
/**授权手机号 */
async authUserPhone(detail, sessionId) {
if (!sessionId) {
wx.$util.showToast('缺少sessionId')
Promise.reject()
}
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (detail.iv && detail.encryptedData) {
wx.$util.showLoading()
detail.sessionId = sessionId
return api.post(
{
method: 'scrm.api.sso.weapp.auth.phone',
...detail
},
true
)
} else Promise.reject()
}
/**更新客户手机号 */
updataCustomerPhone() {
let customerId = wx.$storage.get('srcm_shopmall_customer_id'),
merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
api
.post({
method: 'scrm.api.sso.weapp.mark.phone',
customerId,
merchantId
})
.then(() => {
wx.removeStorageSync('srcm_shopmall_customer_id')
})
}
}
export default UsersApi
import UsersApi from './UsersApi.js'
export default new UsersApi()
\ No newline at end of file \ No newline at end of file
// app.js
import util from './utils/util.js'
import '~/router/routerBefore.js'
import router from './router/index.js'
// 有问题 前后顺序不能随意调整
import { ssoApi, commonApi, shopmallApi } from './api/api'
import { filterUrlParam } from '~/utils/routerApi'
import { setUserInfo, setSessionId } from '~/utils/cache/userInfo'
import { setSystem_info } from '~/utils/cache/storageApi'
// console.log(setSystem_info)
// 判断小程序是否需要更新
import getUpdateManager from './utils/lib/wxUpdateManager'
// 埋点
import './utils/track/Track'
import eventbus from './utils/evenbus'
// 微信小程序异步使用 使用方法wx.pro+对应api即可 promisify 这个是配置单独某个api
import { promisifyAll } from './utils/lib/wx-promise-pro'
promisifyAll()
// promisify(wx.getSystemInfo)().then(console.log)
// 实例化对象存储
import { Storage } from './utils/cache/storage'
const $Storage = new Storage()
App({
onLaunch(options) {
/**挂载到wx对象 */
wx.$authStatus = false
wx.$util = util
wx.$router = router
wx.$storage = $Storage /** 挂载全局缓存方法 */
wx.$eventbus = eventbus
// 存储设备信息
setSystem_info()
},
// $Storage: $Storage,
// getStorage: $Storage.get,
// setStorage: $Storage.set,
// rmStorage: $Storage.rm,
setPageParmas(query) {
if (query.merchantId) $Storage.set('srcm_shopmall_merchant_id', query.merchantId)
if (query.customerId) $Storage.set('srcm_shopmall_customer_id', query.customerId)
let storeCode = query.storeCode || filterUrlParam(decodeURIComponent(query.scene))['storeCode']
if (query.scene) {
let scene = decodeURIComponent(query.scene)
let [key, val] = scene.split('=')
if (key == 'storeCode') {
this.getGHMerchant(val)
return
}
shopmallApi
.getLiveActivityId({
id: val
})
.then(({ code, data }) => {
console.log(data)
if (code == 0) {
let op = {}
data.scene.split('&').map(item => {
const [key, val] = item.split('=')
op[key] = val
})
if (op.storeCode) this.getGHMerchant(op.storeCode)
}
})
return
}
if (storeCode) {
this.getGHMerchant(storeCode)
return
}
if (query.merchantId) {
$Storage.set('srcm_shopmall_merchant_id', query.merchantId)
this.login()
return
}
},
getGHMerchant(storeCode, callBack) {
$Storage.set('srcm_shopmall_store_code', storeCode)
commonApi
.getBySapCode({
sapCode: storeCode
})
.then(({ code, data }) => {
if (code == '0') $Storage.set('srcm_shopmall_merchant_id', data.merchantNo)
this.login().then(res => {
if (callBack) callBack(res)
})
})
},
login(returnResponse) {
let _this = this
return new Promise((resolve, reject) => {
wx.login({
success({ code }) {
const appId = wx.getAccountInfoSync().miniProgram.appId
ssoApi
.jsCodeLogin({
code,
appId
})
.then(res => {
wx.$isGroup = res.data.group
wx.$authStatus = res.code != 0
if (res && res.data) {
if (res.data.sapCode) $Storage.set('srcm_shopmall_store_code', res.data.sapCode)
}
if (returnResponse) {
resolve(res)
} else {
if (res.data)
wx.$storage.set('merchant_info', {
merchantId: res.data.merchantId,
merchantName: res.data.merchantName,
sapCode: res.data.sapCode || ''
})
if (res.code != -1) {
if (res.code == 0) {
setUserInfo(res.data)
setSessionId(res.data.sessionId)
let customerId = $Storage.get('srcm_shopmall_customer_id')
let merchantId = $Storage.get('srcm_shopmall_merchant_id')
if (customerId) {
ssoApi
.updataCustomerPhone({
customerId,
merchantId
})
.then(() => {
wx.removeStorageSync('srcm_shopmall_customer_id')
})
}
// 登录完加载权益会员信息接口(目前只针对权益商品页面)
eventbus.emit('EQUITYGOODS', true)
} else {
util.showToast(res.message || '网络异常')
}
}
resolve(res)
}
})
.catch(() => {
wx.$authStatus = true
reject()
})
}
})
})
},
onShow(options) {
getUpdateManager()
let query = Object.keys(options.query)
if (query.length)
query.map(e => {
let params = decodeURIComponent(e).split('&')
params.map(i => {
let [key, val] = i.split('=')
if (!val) val = options.query[key]
this.setPageParmas({
[key]: val
})
})
})
else this.login()
},
/**页面不存在时触发 */
onPageNotFound(e) {
wx.$router.goHome()
},
onHide() {},
globalData: {
// appId: '',
// merchantId: '44189923' // 44184606 44189923
}
})
{
"pages": ["pages/index/index","pages/tab/index/index", "pages/tab/output/output", "pages/tab/mine/mine", "pages/webView/webView"],
"requiredPrivateInfos": ["getLocation"],
"lazyCodeLoading": "requiredComponents",
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle": "black"
},
"tabBar": {
"color": "#5A6066",
"selectedColor": "#3666FE",
"backgroundColor": "#FFFFFF",
"borderStyle": "white",
"list": [{
"pagePath": "pages/tab/index/index",
"text": "拓客户",
"iconPath": "images/home.png",
"selectedIconPath": "images/home_active.png"
},
{
"pagePath": "pages/tab/output/output",
"text": "看产值",
"iconPath": "images/mall.png",
"selectedIconPath": "images/mall_active.png"
},
{
"pagePath": "pages/tab/mine/mine",
"text": "个人中心",
"iconPath": "images/mine.png",
"selectedIconPath": "images/mine_active.png"
}
]
},
"subpackages": [],
"usingComponents": {
},
"style": "v2",
"resolveAlias": {
"~/*": "/*"
},
"sitemapLocation": "sitemap.json",
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"plugins": {}
}
\ No newline at end of file \ No newline at end of file
@import "/common.wxss";
@import "/sprite.wxss";
page {
background-color: #F7F7F7;
color: #282829;
font-size: 28rpx;
--themeColor: #F13C3D;
--btnColor: #FC5B32;
--borderRadius: 8rpx;
--margin: 32rpx;
}
image {
width: 100%;
height: 100%;
vertical-align: top;
}
.icon-mine-arrow {
width: 16rpx !important;
height: 28rpx !important;
transform: translateY(7rpx);
}
\ No newline at end of file \ No newline at end of file
/**app.wxss**/
.sticky {
position: sticky;
top: 0;
left: 0;
z-index: 2;
background-color: #fff;
}
.flex-center {
display: flex;
align-items: center;
justify-content: start;
}
.y-center {
top: 50%;
transform: translateY(-50%);
}
.x-center {
left: 50%;
transform: translateX(-50%);
}
.box-center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.text-hide {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.text-two-line {
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
}
.text-center {
display: flex;
align-items: center;
justify-content: center;
}
.isFullSucreen {
/* padding-bottom: 34px !important; */
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
.isFullSucreen-bottom {
bottom: constant(safe-area-inset-bottom) !important;
bottom: env(safe-area-inset-bottom) !important;
}
.default-btn {
width: 686rpx;
height: 88rpx;
background: var(--btnColor);
border-radius: var(--borderRadius);
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: var(--margin);
}
.list-nothing {
width: 100%;
padding: 8rpx 0 30rpx;
text-align: center;
font-size: 28rpx;
color: #C1C2C3;
}
.list-nothing .icon {
width: 320rpx;
height: 320rpx;
}
.list-not {
display: flex;
align-items: center;
justify-content: center;
color: #999;
font-size: 24rpx;
height: 100%;
}
@keyframes show-box {
0% {
opacity: 0;
transform: scale(2.5);
}
100% {
opacity: 1;
transform: scale(1);
}
}
@keyframes show-box-opacity {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
\ No newline at end of file \ No newline at end of file
// components/Authorize/Authorize.js
import {
componentsMixin
} from '../../mixins/index'
Component({
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
properties: {
scopeType: String,
/**是否自动打开 */
autoOpen: Boolean,
show: Boolean,
title: {
type: String,
value: '是否打开授权设置?'
},
confirmText: {
type: String,
value: '确定'
},
cancelText: {
type: String,
value: '取消'
},
buttonType: String,
confirmColor: String,
cancelColor: String,
isShowCheck: {
type: Boolean,
value: true
},
init: {
type: Boolean,
observer(n) {
if (n) this.check()
}
}
},
observers: {
'show': function (newVal) {
this.setData({
openSet: newVal
})
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
/**
* 禁止滑动
*/
noScroll: wx.$util.noScroll(),
cancel(e) {
let {
confirm
} = e.currentTarget.dataset
let {
buttonType,
title
} = this.data
let _this = this
if (buttonType == 'getUserInfo' && confirm) {
wx.getUserProfile({
desc: title,
success(res) {
_this.triggerEvent('success', {
message: '授权成功',
data: res
})
}
})
}
this.setData({
openSet: false
})
this.triggerEvent('cancel')
},
/**检验是否已授权位置 */
check() {
const _this = this
let {
buttonType,
scopeType,
autoOpen
} = this.properties
if (buttonType != 'getPhoneNumber') {
let type = `scope.${scopeType}`
buttonType = 'openSetting'
if (type === 'scope.userInfo') buttonType = 'getUserInfo'
this.setData({
buttonType
})
wx.getSetting({
success(res) {
if (!res.authSetting[type]) {
wx.authorize({
scope: type,
success() {
_this.triggerEvent('success', {
message: '授权成功'
})
},
fail() {
_this.triggerEvent('fail', {
message: '未授权'
})
if (autoOpen) {
_this.setData({
openSet: true
})
}
}
})
} else {
_this.triggerEvent('success', {
message: '已授权'
})
}
}
})
}
},
/**授权手机号 */
getPhoneNumber({
detail
}) {
console.log(detail)
this.triggerEvent('getphonenumber', detail)
}
},
pageLifetimes: {
show: function () {
if (this.data.isShowCheck || this.data.init) this.check()
},
hide: function () {}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="open-seting-bg text-center" wx:if="{{openSet}}" catchtap="cancel" catchtouchmove="noScroll">
<view class="open-set-inner">
<view class="set-title"><text>{{title}}</text></view>
<view class="btn-openset">
<view catchtap="cancel" class="btn text-center" style="color:{{cancelColor}};">{{cancelText}}</view>
<view class="btn text-center" style="color:{{confirmColor}};">
{{confirmText}}
<block wx:if="{{buttonType == 'getPhoneNumber'}}">
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="button-style"></button>
</block>
<block wx:else>
<button open-type="{{buttonType}}" class="button-style" catchtap="cancel" data-confirm></button>
</block>
</view>
</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
/* components/Authorize/Authorize.wxss */
.open-seting-bg {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 998;
}
.text-center {
display: flex;
align-items: center;
justify-content: center;
}
.open-set-inner {
width: 564rpx;
height: 400rpx;
background: #FFFFFF;
border-radius: 16px;
}
@keyframes show-auth-box {
0% {
opacity: 0;
transform: scale(2);
}
100% {
opacity: 1;
transform: scale(1);
}
}
.set-title {
font-size: 36rpx;
min-height: 286rpx;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
flex-direction: column;
}
.btn-openset {
display: flex;
font-size: 36rpx;
height: 112rpx;
border-top: 2rpx solid #E5E5E5;
font-weight: 500;
letter-spacing: 1rpx;
}
.btn {
flex: 1;
height: 100%;
position: relative;
}
.button-style {
position: absolute;
width: 100% !important;
height: 100%;
box-sizing: border-box;
opacity: 0;
top: 0;
left: 0;
}
\ No newline at end of file \ No newline at end of file
// components/Calendar/Calendar.js
import Calendar from './Calendar_Function'
import _component_ from './Static_Properties'
const CalendarFunction = Symbol('CalendarFunction')
import {componentsMixin } from '../../mixins/index'
Component({
behaviors:[componentsMixin],
/**
* 组件的属性列表
*/
properties: _component_.properties,
/**
* 组件的初始数据
*/
data: _component_.data,
/**
* 组件的方法列表
*/
methods: {
noScroll() {},
setCalenderBodyHeight() {
this[CalendarFunction].setCalenderBodyHeight()
},
showCalendar(e) {
let type = e && e.currentTarget && e.currentTarget.dataset.type || ''
let result = type === 'show'
if (!result) {
this.setData({
hideCalendar: true
})
setTimeout(() => {
this.setData({
show: result,
hideCalendar: false
})
}, 300)
} else {
this.setData({
show: result
})
if (!this.data.calenderBodyHeight) this[CalendarFunction].setCalenderBodyHeight()
}
},
dateChange(e) {
let {
current
} = e.detail
this.setData({
current
})
},
choose(e) {
let {
dateType,
minDate,
maxDate
} = this.data
let {
data
} = e.currentTarget.dataset
if ((minDate && Date.parse(minDate) > Date.parse(data)) || (maxDate && Date.parse(maxDate) < Date.parse(data))) return
this[CalendarFunction][dateType](e)
},
done() {
let {
dateType
} = this.data
this[CalendarFunction].done(dateType)
},
changeDate(e) {
let { value } = e.detail
this.setData({
current: value
})
},
showShortcutPicker() {
this.setData({
showShortcut: !this.data.showShortcut
})
},
chooseAll() {
this[CalendarFunction].chooseAll()
}
},
attached() {
this[CalendarFunction] = new Calendar(this)
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class='calender-picker' bindtap="showCalendar" data-type='show'>
<slot></slot>
</view>
<!-- 弹框模式 -->
<view class='calender-box' hidden='{{!show}}' catchtouchmove="noScroll">
<view class='calender-bg' bindtap="showCalendar"></view>
<view class='calender-view {{hasRadius}} {{hideCalendar?"hideCalendar":""}} {{!showConfirm?"isFullSucreen":""}}' style="height:{{height}}">
<view class='calender-header'>
<view class='calender-title' wx:if='{{showTitle}}'>
<block wx:if="{{rangeAll && dateType == 'range'}}">
<view class="calender-all" style="color:{{calenderColor}};" bindtap="chooseAll">全选</view>
</block>
{{title||'日期选择'}}
<view class='calender-close' bindtap="showCalendar">
<image webp src="./images/close.png?v={{img_version}}" class='calender-close-image'></image>
</view>
</view>
<block wx:if='{{showSubTitle}}'>
<picker class='calender-subtitle' bindchange="changeDate" bindcancel='showShortcutPicker' value="{{current}}" range="{{dateList}}" wx:if='{{shortcut}}'>
<view class='calender-subtitle-text' bindtap="showShortcutPicker">
{{dateList[current]}}
<view class='arrow {{showShortcut}}'></view>
</view>
</picker>
<view class='calender-subtitle' wx:else>{{dateList[current]}}</view>
</block>
<view class='calendar-weekdays'>
<block wx:for='{{weekdays}}' wx:key='index'>
<view class='calendar-weekday'>{{item}}</view>
</block>
</view>
</view>
<view class='calender-body' style="height:calc(100% - {{calenderBodyHeight}})">
<swiper class='calender-swiper' bindchange='dateChange' current='{{current}}' vertical='{{vertical}}'>
<block wx:for='{{monthList}}' wx:key='index'>
<swiper-item>
<view class='calender-mark box-center' wx:if="{{!hideMark}}">{{item.mark}}</view>
<view class='calender-month'>
<block wx:for='{{item.data}}' wx:for-item='i' wx:for-index='ind' wx:key='ind'>
<view class='calender-day {{ind == 0?i.week:""}} {{i.active?"active":""}} {{i.disable?"disable":""}}' style="background:{{i.active?calenderColor:''}};color:{{i.middle?calenderColor:''}}" bindtap="choose" data-index='{{index}}' data-ind='{{ind}}' data-data='{{i.data}}'>
<view class='calender-middle' style="background:{{calenderColor}};" wx:if='{{i.middle}}'></view>
<view class='box-center text'>
{{i.day}}
<view wx:if='{{dateType==="range"}}' class='calender-tips'>
<view wx:if='{{i.start}}'>{{rangeText.start}}</view>
<view wx:if='{{i.end}}'>{{rangeText.end}}</view>
</view>
</view>
</view>
</block>
</view>
</swiper-item>
</block>
</swiper>
</view>
<view class='calender-footer isFullSucreen' wx:if='{{showConfirm}}'>
<view class='calender-btn {{dateType === "range" && !rangeDate.end ?"disable":""}} {{dateType === "multiple" && multipleDate.length < 1 ?"disable":""}}' style="background:{{calenderColor}}" bindtap="done">
{{confirmText||'确定'}}
</view>
</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
/* components/Calendar/Calendar.wxss */
.calender-box {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 99;
}
.calender-bg {
position: absolute;
background: rgba(0, 0, 0, .5);
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.calender-view {
position: absolute;
left: 0;
width: 100%;
background: #fff;
animation: show-calender .5s forwards;
color: #333;
}
.calender-view.true {
border-radius: 40rpx 40rpx 0 0;
}
.calender-view.isFullSucreen {
box-sizing: border-box;
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
.isFullSucreen {
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
@keyframes show-calender {
from {
bottom: -100%;
}
to {
bottom: 0;
}
}
.calender-view.hideCalendar {
animation: hide-calender .5s forwards;
}
@keyframes hide-calender {
from {
bottom: 0;
}
to {
bottom: -100%;
}
}
.calender-header {
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.10);
}
.calender-title,
.calender-subtitle {
width: 100%;
height: 88rpx;
text-align: center;
position: relative;
font-size: 32rpx;
display: flex;
align-items: center;
justify-content: center;
}
.calender-all {
position: absolute;
top: 50%;
left: 24rpx;
transform: translateY(-50%);
font-size: 20rpx;
}
.calender-subtitle-text {
display: flex;
align-items: center;
justify-content: center;
}
.calender-subtitle {
font-size: 28rpx;
}
.calender-subtitle .arrow {
width: 14rpx;
height: 14rpx;
border-top: 2rpx solid transparent;
border-right: 2rpx solid #ccc;
border-bottom: 2rpx solid #ccc;
border-left: 2rpx solid transparent;
transform: rotate(45deg) translateY(-4rpx);
margin-left: 16rpx;
transition: all .3s;
}
.calender-subtitle .arrow.true {
transform: rotate(225deg) translateY(0) translateX(-4rpx);
}
.calender-close {
position: absolute;
width: 40rpx;
height: 40rpx;
top: 50%;
right: 24rpx;
transform: translateY(-50%);
display: flex;
align-items: center;
justify-content: center;
}
.calender-close-image {
width: 24rpx;
height: 24rpx;
}
.calendar-weekdays {
display: grid;
grid-template-columns: repeat(7, 1fr);
font-size: 24rpx;
line-height: 60rpx;
}
.calendar-weekday {
text-align: center;
}
.calender-body {
width: 100%;
padding: 20rpx 0;
box-sizing: border-box;
}
.calender-swiper {
height: 100%;
}
.calender-mark {
color: rgba(0, 0, 0, .1);
text-shadow: 0 4rpx 20rpx rgba(0, 0, 0, .1);
font-size: 320rpx;
width: 100%;
text-align: center;
}
.box-center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.calender-month {
height: 100%;
position: relative;
z-index: 1;
display: grid;
grid-template-rows: repeat(minmax(5, 6), 1fr);
grid-template-columns: repeat(7, 1fr);
}
.calender-day {
position: relative;
font-size: 32rpx;
display: flex;
}
.calender-day.active {
color: #fff;
border-radius: 8rpx;
}
.calender-day.disable {
opacity: .25;
}
.calender-day .calender-middle {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0.1;
}
.calender-day .text {
text-align: center;
width: 100%;
}
.calender-tips {
font-size: 14rpx;
}
.week-1 {
grid-column-start: 2;
}
.week-2 {
grid-column-start: 3;
}
.week-3 {
grid-column-start: 4;
}
.week-4 {
grid-column-start: 5;
}
.week-5 {
grid-column-start: 6;
}
.week-6 {
grid-column-start: 7;
}
.calender-footer {
position: absolute;
width: 100%;
left: 0;
bottom: 0;
padding: 14rpx 32rpx;
box-sizing: border-box;
}
.calender-footer.true {
padding-bottom: 34px !important;
}
.calender-footer .calender-btn {
width: 100%;
height: 72rpx;
font-size: 28rpx;
color: #fff;
border-radius: 8rpx;
display: flex;
justify-content: center;
align-items: center;
}
.calender-footer .calender-btn.disable {
opacity: .3;
}
\ No newline at end of file \ No newline at end of file
const _CalendarObject_ = Symbol('_CalendarObject_')
const _nowDate_ = Symbol('_nowDate_')
const _separator_ = Symbol('_separator_')
class Calendar {
[_CalendarObject_] = {};
[_nowDate_] = new Date();
[_separator_] = '-';
constructor(calendarObject) {
this[_CalendarObject_] = calendarObject
this[_separator_] = calendarObject.data.separator
this.setCalenderHeight()
this.setMonthList()
let {
weekdays,
firstDayOfWeek
} = calendarObject.data
let firstDay = weekdays[firstDayOfWeek - 1]
let [last, first] = weekdays.join('').split(firstDay)
calendarObject.setData({
weekdays: [firstDay, ...first, ...last]
})
}
/**设置日历高度 */
setCalenderHeight() {
let _this = this[_CalendarObject_]
let {
data: calenderHeight
} = _this
let height = '80%'
if (typeof calenderHeight === 'number') {
wx.$util.getPhoneInfo(res => {
let {
windowHeight
} = res
if (calenderHeight > windowHeight) calenderHeight = windowHeight
if (calenderHeight < windowHeight * 0.5) calenderHeight = windowHeight * 0.5
height = `${calenderHeight}px`
})
}
if (typeof calenderHeight === 'string') {
if (calenderHeight.includes('%')) {
height = calenderHeight
let [num] = calenderHeight.split('%')
if (num < 50) height = '50%'
if (num > 100) height = '80%'
} else {
if (calenderHeight < 50) calenderHeight = '50'
if (calenderHeight > 100) calenderHeight = '80'
height = `${calenderHeight}%`
}
}
_this.setData({
height
})
}
/**设置日期高度 */
setCalenderBodyHeight() {
let _this = this[_CalendarObject_]
wx.$util.getViewInfo('.calender-header', header => {
wx.$util.getViewInfo('.calender-footer', footer => {
let headerHeight = header.height
let footerHeight = footer && footer.height || 0
_this.setData({
calenderBodyHeight: `${headerHeight + footerHeight}px`
})
}, _this)
}, _this)
}
/**设置日期列表 */
setMonthList() {
let {
separator,
previous,
minDate,
maxDate,
next
} = this[_CalendarObject_].data
if (maxDate || minDate) {
if (!minDate) {
let nowMonth = new Date().getMonth()
minDate = new Date(new Date().setMonth(nowMonth - previous)).format(`yyyy${separator}MM${separator}dd`)
}
if (!maxDate) {
maxDate = this[_nowDate_].format(`yyyy${separator}MM${separator}dd`)
}
previous = this.getMonthDifference(minDate, this[_nowDate_].format(`yyyy${separator}MM${separator}dd`))
next = this.getMonthDifference(this[_nowDate_].format(`yyyy${separator}MM${separator}dd`), maxDate)
} else {
previous = previous < 0 ? 0 : previous
next = next < 0 ? 0 : next
}
let nowMonth = this[_nowDate_].getMonth()
let now = new Date().setDate(1)
for (let i = nowMonth - previous; i <= nowMonth + next; i++) {
this.init(new Date(now).setMonth(i))
}
}
/**初始化日期 */
init(date) {
let _this = this[_CalendarObject_]
let {
firstDayOfWeek,
allowSameDay,
multipleDate,
monthList,
rangeDate,
dateList,
dateType,
current,
minDate,
maxDate,
value,
} = _this.data
let separator = this[_separator_]
let [year, month] = new Date(date).format(`yyyy${separator}MM`).split(separator)
let days = this.getDayNumber(year, Number(month))
let week = new Date(year, Number(month) - 1, 1).getDay()
let dateFormat = `yyyy${separator}MM${separator}dd`
let today = value || this[_nowDate_].format(dateFormat)
let nextDay = ''
let arr = []
dateList.push(`${year}${separator}${month}`)
if (dateType === 'range') {
nextDay = new Date(new Date().setDate(new Date(new Date(today)).getDate() + 1)).format(dateFormat)
}
let [now_year, now_month, now_day] = today.split(separator)
let [next_year, next_month, next_day] = allowSameDay ? today.split(separator) : nextDay.split(separator)
for (let i = 1; i <= days; i++) {
let todayStr = `${year}${separator}${month}${separator}${now_day}`
let dayStr = `${year}${separator}${month}${separator}${i < 10 ? `0${i}`:i}`
let obj = {
day: i,
data: dayStr,
active: now_year == year && now_month == month && i == Number(now_day)
}
if ((minDate && Date.parse(minDate) > Date.parse(dayStr)) || (maxDate && Date.parse(maxDate) < Date.parse(dayStr))) obj.disable = true
if (dateType === 'multiple') multipleDate.push(todayStr)
if (nextDay) {
if (now_year == year && now_month == month && i == Number(now_day)) {
obj.start = true
rangeDate.start = todayStr
}
if (next_year == year && next_month == month && i == Number(next_day)) {
obj.active = true
obj.end = true
rangeDate.end = `${year}${separator}${next_month}${separator}${next_day}`
}
}
firstDayOfWeek = firstDayOfWeek == 7 ? 0 : firstDayOfWeek
if (i === 1) obj.week = `week-${week - firstDayOfWeek}`
arr.push(obj)
}
monthList.push({
data: arr,
mark: Number(month)
})
if (current <= 1) {
let [nowYear, nowMonth] = today.split(separator)
current = dateList.findIndex(e => e === `${nowYear}${separator}${nowMonth}`)
}
_this.setData({
multipleDate,
date: today,
rangeDate,
monthList,
dateList,
current
})
}
/**当设置最小日期或者最大日期时 自动设置前后月份 */
getMonthDifference(date1, date2) {
let separator = this[_separator_]
//获取年,月数
let [year1, month1] = date1.split(separator)
let [year2, month2] = date2.split(separator)
let months = (parseInt(year2) - parseInt(year1)) * 12 + (parseInt(month2) - parseInt(month1))
return months
}
/**单选 */
single(e) {
let _this = this[_CalendarObject_]
let {
index,
data,
ind
} = e.currentTarget.dataset
let {
showConfirm,
monthList
} = _this.data
monthList.map(x => {
x.data.map(i => i.active = false)
})
monthList[index].data[ind].active = true
_this.setData({
monthList,
date: data
})
if (!showConfirm) this.done()
}
/**多选 */
multiple(e) {
let _this = this[_CalendarObject_]
let {
index,
ind,
} = e.currentTarget.dataset
let {
monthList
} = _this.data
let arr = []
monthList[index].data[ind].active = !monthList[index].data[ind].active
monthList.map(x => x.data.map(i => {
if (i.active) arr.push(i.data)
}))
_this.setData({
[`monthList[${index}].data`]: monthList[index].data,
multipleDate: arr
})
}
/**范围选择 */
range(e) {
const _this = this[_CalendarObject_]
let {
index,
data,
ind
} = e.currentTarget.dataset
let {
allowSameDay,
showConfirm,
monthList,
rangeDate
} = _this.data
const start = Date.parse(rangeDate.start)
if (rangeDate.end || start > Date.parse(data)) {
monthList = this.clearStatus({
monthList,
index,
ind
})
rangeDate.start = data
rangeDate.end = ''
} else {
if (!allowSameDay && Date.parse(data) == Date.parse(rangeDate.start)) return
monthList[index].data[ind].active = true
monthList[index].data[ind].end = true
rangeDate.end = data
monthList.map(x => {
x.data.map(i => {
let day = Date.parse(i.data)
i.middle = day > start && day < Date.parse(data)
})
})
}
_this.setData({
monthList,
rangeDate
})
if (!showConfirm && rangeDate.end) this.done()
}
/**点击完成 */
done() {
let _this = this[_CalendarObject_]
let {
multipleDate,
rangeDate,
dateType,
date
} = _this.data
let targer = {
'single': date,
'multiple': multipleDate,
'range': rangeDate
}
if ((dateType === 'multiple' && multipleDate.length < 1) || (dateType === 'range' && !rangeDate.end)) return
_this.triggerEvent('select', {
date: targer[dateType]
})
_this.showCalendar()
}
/**清空范围选择状态 */
clearStatus(params) {
let {
monthList,
index,
ind
} = params
monthList.map(x => x.data.map(i => {
i.active = false
i.start = false
i.end = false
i.middle = false
}))
monthList[index].data[ind].active = true
monthList[index].data[ind].start = true
return monthList
}
/**
* 获取月份天数
*/
getDayNumber(year, month) {
let days = 31
switch (month) {
case 2:
days = (year % 4 == 0 && year % 100 !== 0) || year % 400 == 0 ? 29 : 28
break;
case 4:
case 6:
case 9:
case 11:
days = 30
break;
}
return days
}
/**日期范围 点击全选 */
chooseAll() {
let _this = this[_CalendarObject_]
let {
monthList,
minDate,
maxDate
} = _this.data
monthList.map((e, index) => {
e.data.map((i, ind) => {
let obj = {
currentTarget: {
dataset: {
index,
ind,
data: i.data
}
}
}
if (i.data == minDate) this.range(obj)
if(i.data == maxDate) this.range(obj)
})
})
}
}
export default Calendar
\ No newline at end of file \ No newline at end of file
export default {
properties: {
calenderHeight: {
type:String
// type: [String,Number], 企微暂不支持
},
title: String, // 标题名称
hasRadius: {
type: Boolean,
value: true
}, // 是否圆角
showTitle: {
type: Boolean,
value: true
}, // 是否显示标题
showSubTitle: {
type: Boolean,
value: true
}, // 是否显示副标题
confirmText: String, // 确定按钮文本
showConfirm: {
type: Boolean,
value: true
}, // 是否显示确定按钮
calenderColor: {
type: String,
value: '#FC5B32'
}, // 日历主题色
previous: {
type: Number,
value: 3
}, // 当前月的前几个月 ,默认3个月
next: {
type: Number,
value: 3
}, // 当前月的后几个月 , 默认3个月
vertical: Boolean, //是否纵向滑动
/** 选择类型默认单选,single 单选, multiple多个日期,range日期范围 */
dateType: {
type: String,
value: 'single'
},
value: String, //单选绑定数据
shortcut: Boolean, //日期快捷切换 默认为false
/** 分隔符,默认为 "-" */
separator: {
type: String,
value: '-'
},
/** 日期范围-开始结束文本 */
rangeText: {
type: Object,
value: {
start: '开始',
end: '结束'
}
},
/**是否显示日期范围 全选 */
rangeAll: Boolean,
/** 是否允许日期范围的起止时间为同一天, 默认为false */
allowSameDay: Boolean,
/** 周起始日,默认周日 */
firstDayOfWeek: {
type: Number,
// type: [Number, String], 企微暂不支持
value: 7
},
/**
* 可选最小日期,不传则默认无限制。
* 格式yyyy-MM-dd, 需跟separator一致。 */
minDate: String,
/** 可选最大日期,不传则默认无限制。
* 格式yyyy-MM-dd, 需跟separator一致 */
maxDate: String,
/**隐藏水印 */
hideMark: Boolean
},
data: {
weekdays: ['一', '二', '三', '四', '五', '六', '日'],
monthList: [],
dateList: [],
current: 0,
height: '80%',
rangeDate: {},
multipleDate: []
}
}
\ No newline at end of file \ No newline at end of file
// components/navigationBar/navigationBar.js
import {
componentsMixin
} from '../../mixins/index'
Component({
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
properties: {
navStyle: String,
custom: Boolean,
pageTitle: {
type: String,
value: '',
observer(n) {
if (n) {
this.title = n
this.setPageTitle()
}
}
}
},
title: '',
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
setPageTitle() {
let thisPage = wx.$router.getPageInstance()
if (thisPage) thisPage.navigationBarTitleText = this.title
},
init() {
/**
* 获取自定义导航栏信息
*/
wx.getSystemInfo().then(res => {
let {
fontSizeSetting,
statusBarHeight,
screenWidth
} = res
const {
height,
right,
width,
top
} = wx.getMenuButtonBoundingClientRect()
let navigationBarHeight = height + ((top - statusBarHeight) * 2) + 4 // 4
let navigationBarPadding = screenWidth - right
let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width) - width
this.setData({
statusBarHeight,
navigationBarHeight,
navigationBarStyle: `font-size:${fontSizeSetting}px;`,
navigationBarTextWidth: `width:${navigationBarWidth}px;padding:0 ${navigationBarPadding}px;`
})
this.emit({
navigationBarHeight,
statusBarHeight
})
})
},
emit({
navigationBarHeight,
statusBarHeight
}) {
let navHeight = navigationBarHeight + statusBarHeight
const thisPage = wx.$router.getPageInstance()
const currentPages = getCurrentPages()
this.triggerEvent('navbarReady', {
height: navHeight,
statusBarHeight
})
this.setData({
showNavBar: true
})
thisPage.setData({
navHeight,
statusBarHeight
})
if (currentPages.length == 1 && !thisPage.rootName) thisPage.setData({
showHomeBtn: true
})
}
},
lifetimes: {
attached() {
this.init()
this.setPageTitle()
}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="navigation-bar" id="navigation-bar"
style="padding-top:{{statusBarHeight}}px;height:{{navigationBarHeight}}px;{{navStyle}}">
<block wx:if="{{!custom}}">
<view class="navigation-bar-box" wx:if="{{showNavBar}}" style="{{navigationBarStyle}}">
<view class="navigation-bar-titleText" style="{{navigationBarTextWidth}}">
<slot></slot>
</view>
</view>
</block>
<block wx:else>
<slot></slot>
</block>
</view>
\ No newline at end of file \ No newline at end of file
/* components/navigationBar/navigationBar.wxss */
.navigation-bar{
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
background-color: #fff;
transition: all .15s;
}
.navigation-bar-box{
position: relative;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.navigation-bar-titleText{
color: #333333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: 500;
box-sizing: border-box;
text-align: center;
letter-spacing: 1rpx;
}
.back-box{
width: 76rpx;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
.back{
position: absolute;
left: 20rpx;
top: 50%;
transform: translateY(-50%);
width: 36rpx;
height: 36rpx;
}
\ No newline at end of file \ No newline at end of file
// tabWorkOrder/pages/createOrder/createOrderComponents/Popup/Popup.js
import {
componentsMixin
} from '../../mixins/index'
Component({
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
value: false,
observer: function (n, o) {
if (!n) {
this.setData({
close: true
})
setTimeout(() => {
this.setData({
showPopup: false
})
}, 0.2 * 1000)
} else {
let hideTab = wx.$hideTab
console.log(hideTab)
this.setData({
showPopup: true,
close: false,
hideTab
})
}
}
},
title: String,
height: {
type: String,
value: '85%'
},
only: {
type: Boolean,
value: true
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
noScroll() {},
hidePopup() {
this.setData({
show: false
})
},
confirm() {
this.triggerEvent('confirm')
}
},
attached() {
const {
isTab
} = wx.$router.getRouterList().find(item => item.url === `/${wx.$router.getPageInstance().route}`)
this.setData({
isTab
})
},
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="popup " hidden="{{!showPopup}}" catchtouchmove="noScroll">
<view class="popup-bg" bindtap="hidePopup"></view>
<view class="popup-content {{close?'close':''}}" style="height:{{height}}">
<block wx:if="{{title}}">
<view class="popup-title text-center">{{title}}</view>
</block>
<view class="popup-slot {{isTab && !hideTab? '': title?'isFullSucreen':'isFullSucreen-notitle'}}">
<slot></slot>
</view>
<view class="popup-footer {{isTab && !hideTab?'':'isFullSucreen'}}" wx:if="{{only}}">
<view class="cancel btn text-center" bindtap="hidePopup">取消</view>
<view class="confirm btn text-center" bindtap="confirm">确认</view>
</view>
<view class="popup-footer {{isTab && !hideTabb?'':'isFullSucreen'}}" wx:else>
<view class="confirm doubtn text-center" bindtap="confirm">确认</view>
</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
/* tabWorkOrder/pages/createOrder/createOrderComponents/Popup/Popup.wxss */
.popup {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 998;
}
.popup-bg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: rgba(0, 0, 0, .6);
}
.text-center {
display: flex;
align-items: center;
justify-content: center;
}
.popup-content {
position: absolute;
left: 0;
width: 100%;
background: #FFFFFF;
border-radius: 20rpx 20rpx 0 0;
animation: show-popup .2s forwards;
box-sizing: border-box;
}
.popup-content.close {
animation: hide-popup-box .5s forwards;
}
.popup-title {
height: 98rpx;
font-size: 32rpx;
color: #333333;
border-bottom: 2rpx solid #EBEDF0;
}
.popup-slot {
height: calc(100% - 200rpx);
}
.popup-slot.isFullSucreen {
height: calc(100% - 258rpx);
}
.popup-slot.isFullSucreen-notitle {
height: calc(100% - 158rpx);
}
.popup-footer {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 32rpx;
position: relative;
background-color: #fff;
z-index: 2;
}
.popup-footer.isFullSucreen {
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
.popup-footer .btn {
width: 330rpx;
height: 80rpx;
box-sizing: border-box;
border-radius: 12rpx;
font-size: 28rpx;
}
.popup-footer .doubtn {
width: 670rpx;
height: 80rpx;
box-sizing: border-box;
border-radius: 12rpx;
font-size: 28rpx;
}
.popup-footer .cancel {
color: #323233;
border: 2rpx solid #DCDEE0;
}
.popup-footer .confirm {
background: var(--btnColor);
color: #fff;
}
@keyframes show-popup {
0% {
bottom: -100%;
}
100% {
bottom: 0;
}
}
@keyframes hide-popup-box {
0% {
bottom: 0;
}
100% {
bottom: -100%;
}
}
\ No newline at end of file \ No newline at end of file
// components/SearchBox/SearchBox.js
import {componentsMixin } from '../../mixins/index';
Component({
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
properties: {
placeholder: {
type: String,
value: "请输入搜索内容",
},
value: {
type: String,
value: "",
observer(n) {
this.setData({
inputValue: n,
});
},
},
searchType: {
type: Number,
value: 1,
},
couponDetails: Boolean,
},
/**
* 组件的初始数据
*/
data: {
inputValue: "",
},
/**
* 组件的方法列表
*/
methods: {
input(e) {
let { value } = e.detail;
this.setData({
inputValue: value,
});
},
blur(e) {
let { inputValue } = this.data;
this.setData({
inputValue,
});
},
clear() {
this.setData({
inputValue: "",
});
},
confirm(e) {
let { value } = e.detail;
this.triggerEvent("search", value);
},
search(e) {
let { value } = e.currentTarget.dataset;
this.triggerEvent("search", value);
},
},
});
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="search-box box-center">
<view class="search type-{{searchType}}">
<view class="input-box" style="{{couponDetails?'width: 528rpx;':''}}">
<view class="icon box-center">
<icon type="search" size="20"></icon>
</view>
<input type="text" bindinput="input" bindblur="blur" value="{{inputValue}}" placeholder-class="input-placeholder" placeholder="{{placeholder}}" confirm-type="search" class="input" bindconfirm="confirm" />
<block wx:if="{{inputValue}}">
<view class="clear-box" bindtap="clear">
<view class="sprite-icon icon-clear"></view>
</view>
</block>
</view>
<view class="button box-center" bindtap="search" data-value="{{inputValue}}">搜索</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
/* components/SearchBox/SearchBox.wxss */
@import '/sprite.wxss';
.search-box {
height: 104rpx;
box-sizing: border-box;
padding: 0 var(--margin);
background-color: #fff;
}
.box-center {
display: flex;
align-items: center;
justify-content: center;
}
.search {
width: 100%;
height: 72rpx;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
}
.type-1 {
padding: 0 6rpx;
border-radius: 38px;
border: 3rpx solid var(--btnColor);
}
.type-1 .button {
width: 104rpx;
height: 60rpx;
border-radius: 38rpx;
background-color: var(--btnColor);
color: #fff;
font-size: var(--margin);
}
.type-1 .input-box {
width: calc(100% - 110rpx);
display: flex;
align-items: center;
}
.input-box .icon {
width: 58rpx;
}
.type-1 .input-box .input,
.type-2 .input-box .input {
width: calc(100% - 130rpx);
font-size: 28rpx;
}
.input-box .clear-box{
width: 58rpx;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.input-box .clear-box .icon-clear{
opacity: .7;
}
.type-2 .input-box {
display: flex;
align-items: center;
width: 592rpx;
height: 100%;
background: #F8F8F8;
border-radius: 38rpx;
}
.type-2 .button {
color: #656566;
font-size: var(--margin);
}
.input-placeholder {
color: #CFCFCF;
font-size: 28rpx;
}
\ No newline at end of file \ No newline at end of file
// components/SearchInput/SearchInput.js
import {componentsMixin } from '../../mixins/index'
Component({
behaviors:[componentsMixin],
/**
* 组件的属性列表
*/
properties: {
maxlength: {
type: Number,
value: -1
},
placeholder: String,
disabled: Boolean,
value: String,
filterEmoji: {
type: Boolean,
value: true
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
setValue(value) {
if (this.properties.filterEmoji) {
if (wx.$util.haveEmoji(value)) value = wx.$util.replaceEmoji(value)
}
this.setData({
value
})
},
input(e) {
let {
value
} = e.detail
this.setValue(value)
this.triggerEvent('input', {
value
})
},
inputBlur(e) {
this.emit(e)
},
inputConfifm(e) {
this.emit(e)
},
emit(e) {
let {
detail:{
value
},
type
} = e
this.setData({
edit: false
})
this.setValue(value)
this.triggerEvent(type == 'confirm' ? 'search' : 'blur', {
value
})
}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="search-box">
<view class="search-input">
<input type="text" maxlength="{{maxlength}}" class="input" value='{{value}}' confirm-type="search" bindinput='input' bindblur="inputBlur" bindconfirm="inputConfifm" placeholder=" {{placeholder||'查找'}}" placeholder-class="placeholder" />
<block wx:if="{{!value}}">
<view class="icon">
<icon type="search" size="14"></icon>
</view>
</block>
</view>
</view>
\ No newline at end of file \ No newline at end of file
/* components/SearchInput/SearchInput.wxss */
.search-box {
height: 104rpx;
border-bottom: 2rpx solid #EBEDF0;
margin: 0 32rpx;
font-size: 28rpx;
padding-top: 16rpx;
box-sizing: border-box;
}
.search-box .search-input {
width: 686rpx;
height: 72rpx;
background: #F7F8FA;
border-radius: 38rpx;
color: #333;
position: relative;
}
.search-input .input {
height: 100%;
width: 100%;
text-align: center;
}
.search-input .icon {
width: 28rpx;
height: 28rpx;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-200%, -50%);
}
.search-input .placeholder {
color: #C8C9CC;
text-align: center;
}
\ No newline at end of file \ No newline at end of file
// components/Tab/Tab.js
import {componentsMixin } from '../../mixins/index'
Component({
behaviors:[componentsMixin],
/**
* 组件的属性列表
*/
properties: {
tab: Array,
openScroll: Boolean,
index: {
type: Number,
observer: function (n) {
this.setData({
count: n,
to: `to-${n}`
})
}
},
align: {
type: String,
default: ''
}
},
/**
* 组件的初始数据
*/
data: {
count: 0,
to: ''
},
/**
* 组件的方法列表
*/
methods: {
click(e) {
let {
count
} = e.currentTarget.dataset
this.setData({
count,
to: `to-${count}`
})
this.triggerEvent('click', count)
}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<block wx:if="{{openScroll}}">
<scroll-view class="tab-box {{align}}" scroll-x enable-flex scroll-with-animation scroll-into-view="{{to}}">
<block wx:for="{{tab}}" wx:key="index">
<view class="tab {{index==count?'active':''}}" bindtap="click" data-count="{{index}}" id="to-{{index}}" >
<view class="text" >{{item}}</view>
<!-- <view class="text" style="width:{{38 * item.length + 20}}rpx;">{{item}}</view> -->
<view class="line"></view>
</view>
</block>
</scroll-view>
</block>
<block wx:else>
<view class="tab-box flex">
<block wx:for="{{tab}}" wx:key="index">
<view class="tab {{index==count?'active':''}}" bindtap="click" data-count="{{index}}">
<view class="text text-center">{{item}}</view>
<view class="line"></view>
</view>
</block>
</view>
</block>
\ No newline at end of file \ No newline at end of file
/* components/Tab/Tab.wxss */
@import "../../common.wxss";
.tab-box {
display: flex;
width: 100%;
height: 92rpx;
box-sizing: border-box;
}
.tab-box.left{
padding-left: 32rpx;
}
.left .tab{
padding-right:40rpx;
}
.flex .tab {
flex: 1;
}
.tab {
position: relative;
flex-shrink: 0;
}
.tab .text {
height: 84rpx;
display: flex;
align-items: center;
box-sizing: border-box;
color: #A9A9A9;
justify-content: center;
}
.left .text{
justify-content: flex-start;
}
.flex .tab .text {
padding: 0;
}
.tab.active .text {
font-weight: 500;
font-size: 28rpx;
transition: all .25s;
color: #2C2C2C;
}
.tab .line {
width: 48rpx;
height: var(--borderRadius);
background: var(--btnColor);
border-radius: 2rpx;
margin: 0 auto;
transform: scale(0);
transition: all .25s;
}
.tab.active .line {
transform: scale(1);
}
.tab-box::-webkit-scrollbar {
display: none;
width: 0;
height: 0;
color: transparent;
}
\ No newline at end of file \ No newline at end of file
images/mall.png

928 Bytes

module.exports = {
}
\ No newline at end of file \ No newline at end of file
// pages/index/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/index/index.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/index/index.wxml-->
<text>pages/index/index.wxml</text>
const navStyle = 'background-color: transparent;'
Page({
// behaviors: [kfMixin],
/**
* 页面的初始数据
*/
data: {
navStyle,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
{
"usingComponents": {
},
"navigationStyle": "custom",
"onReachBottomDistance": 10,
"backgroundColor": "#FC5B32",
"enablePullDownRefresh": true
}
// pages/tab/mine/mine.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
})
{
"navigationStyle": "custom",
"enablePullDownRefresh": true
}
\ No newline at end of file \ No newline at end of file
File mode changed
<view class="navigation-bar">
<navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady" page-title="个人中心">个人中心</navigation-bar>
</view>
<view class="layout" wx:if="{{user_box_style}}">
<view class="user-box" style="{{user_box_style}}">
<view class="user-info">
<view class="avatar">
<block wx:if="{{userInfo && userInfo.headImgUrl}}">
<image webp src="{{userInfo.headImgUrl}}"></image>
</block>
<block wx:else>
<image webp src="{{IMGURL}}mine/default-avatar.jpg?v={{img_version}}"></image>
</block>
</view>
<view class="info {{userInfo?'':'auth'}}">
<block wx:if="{{userInfo}}">
<view class="nickName">
{{userInfo.nickName || '微信用户'}}
<view class="vip text-center">已认证</view>
</view>
<view class="phone">{{userInfo.phone}}</view>
</block>
<block wx:else>点击登录</block>
</view>
<block wx:if="{{!userInfo}}">
<view class="auth-button" bindtap="login"></view>
<!-- <button open-type="getPhoneNumber" bindtap="login" bindgetphonenumber="getPhoneNumber" class="auth-button"></button> -->
</block>
<block wx:if="{{userInfo && !userInfo.nickName}}">
<view class="auth-button" bindtap="showAuthModal"></view>
</block>
</view>
<view class="coupon-info flex">
<view class="item flex" bindtap="goto" data-url="coupon">
{{total || '0'}}
<view>我的优惠券/张</view>
</view>
<view class="item flex" bindtap="goto" data-url="boutique">
{{gitTotal || '0'}}
<view>精品礼券/张</view>
</view>
</view>
</view>
<!-- 广汇车辆 -->
<block wx:if="{{carFlag}}">
<view class="car-box box GH">
<block wx:if="{{!carList.length}}">
<view class="add-car text-center">
添加爱车专属优惠
<view class="btn flex" bindtap="goto" data-url="GHVehicleInfo">
<view class="sprite-icon icon-mine-add"></view>
添加
</view>
</view>
</block>
<block wx:else>
<view class="car-info">
<view class="title">
我的爱车
<view class="edit" bindtap="goto" data-url="GHVehicleInfo" data-name="list">
管理
<view class="sprite-icon icon-mine-arrow"></view>
</view>
</view>
<view class="my-car">
<gh-car-card item="{{carList[0]}}" selectedCar="null"></gh-car-card>
</view>
</view>
</block>
</view>
</block>
<block wx:if="{{merchantDetail}}">
<view class="merchant-box box">
<view class="title">
<view class="name text-hide">{{merchantDetail.storeName}}</view>
</view>
<view class="address">{{merchantDetail.address}}</view>
<view class="serve-item">
<block wx:if="{{merchantDetail.appointmentPhone}}">
<view class="item flex" bindtap="phoneCall" data-phone="{{merchantDetail.appointmentPhone}}">
<view class="sprite-icon icon-mine-gh-phone"></view>
通话
</view>
</block>
<block wx:if="{{merchantDetail.merchantAddress}}">
<view class="item flex" bindtap="openLocation" data-item="{{merchantDetail}}">
<view class="sprite-icon icon-mine-gh-gps"></view>
导航
</view>
</block>
<block wx:if="{{consultant == null}}">
<view class="item-counselor flex" bindtap="openConsultant" data-item="{{merchantDetail}}">
<view class="icon">
<image webp src="{{IMGURL}}mine/serve.png?v={{img_version}}"></image>
</view>
选择服务顾问
</view>
</block>
</view>
<block wx:if="{{consultant != null}}">
<view class="counselor">
<view class="userInfo">
<view class="counselor-avatar">
<block wx:if="{{consultant.avatar}}">
<image webp src="{{consultant.avatar}}"></image>
</block>
<block wx:else>
<image webp src="{{IMGURL}}mine/default-avatar.png?v={{img_version}}"></image>
</block>
</view>
<view>{{consultant.consultantName}}</view>
</view>
<view class="userInfo">
<view class="user-phone" bindtap="phoneCall" data-phone="{{consultant.phone}}">
<view class="sprite-icon icon-mine-gh-phone"></view>
通话
</view>
<view class="more" bindtap="goCounselor">更多</view>
</view>
</view>
</block>
</view>
</block>
<view class="user-items box">
<block wx:for="{{utilList}}" wx:key="index">
<view class="item" bindtap="jump" data-item="{{item}}">
<view class="label">
<view class="sprite-icon icon-mine-{{item.icon || item.url}} icon"></view>
{{item.text}}
</view>
<view class="sprite-icon icon-mine-arrow"></view>
</view>
</block>
</view>
</view>
<login show="{{showLogin}}"></login>
<authorize scopeType="userInfo" title="是否授权用户昵称&头像" confirmText="授权" cancelText="拒绝" show="{{showAuth}}" bindsuccess="authSuccess"></authorize>
\ No newline at end of file \ No newline at end of file
// pages/tab/output/output.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/tab/output/output.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/tab/output/output.wxml-->
<text>pages/tab/output/output.wxml</text>
// pages/webView/webView.js
Page({
/**
* 页面的初始数据
*/
data: {
flag: true
},
getParams(str) {
let params = str.split('?')
if (params.length < 2) return {}
let param = params[1].split('&')
let obj = {}
for (let i = 0; i < param.length; i++) {
let paramsA = param[i].split('=')
let key = paramsA[0]
let value = paramsA[1]
obj[key] = value
}
return obj
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
wx.$util.showLoading('加载中...')
let decodeUrl = decodeURIComponent(options.url);
let param = this.getParams(decodeUrl)
if (param.urlParam) {
let query = JSON.parse(param.urlParam)
this.data.refresh = query.refresh
}
this.setData({
url: decodeUrl,
})
wx.hideLoading()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
if (this.data.refresh) {
this.setData({
flag: true
}, () => {
this.setData({
url: this.data.url
})
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
if (this.data.refresh) {
this.setData({
flag: false
})
}
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
if (this.data.refresh) {
this.setData({
flag: false
})
}
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<!-- <web-view src="{{url}}"></web-view> -->
<block wx:if="{{flag}}">
<web-view src="{{url}}"></web-view>
</block>
\ No newline at end of file \ No newline at end of file
/* pages/webView/webView.wxss */
\ No newline at end of file \ No newline at end of file
{
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"setting": {
"urlCheck": true,
"scopeDataCheck": false,
"coverView": true,
"es6": false,
"postcss": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"preloadBackgroundData": false,
"minified": true,
"autoAudits": false,
"newFeature": false,
"uglifyFileName": false,
"uploadWithSourceMap": true,
"useIsolateContext": false,
"nodeModules": false,
"enhance": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"showShadowRootInWxmlPanel": true,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"disableUseStrict": false,
"ignoreUploadUnusedFiles": true,
"minifyWXML": true,
"useStaticServer": true,
"showES6CompileOption": false,
"checkInvalidKey": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useCompilerPlugins": [
"sass"
]
},
"compileType": "miniprogram",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {
"qywx_simulator_plugin": "2.4.0"
},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
},
"libVersion": "2.23.4",
"packOptions": {
"ignore": [
{
"value": ".md",
"type": "file"
}
],
"include": []
},
"appid": "wxfe82b8d65d07808f",
"projectname": "miniprogram-scrm-shopmall",
"condition": {}
}
\ No newline at end of file \ No newline at end of file
{
"setting": {
"compileHotReLoad": true,
"urlCheck": false,
"lazyloadPlaceholderEnable": true
},
"condition": {
"miniprogram": {
"list": [
{
"name": "加油",
"pathName": "packageEquity/pages/oil/oil",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "车牌键盘",
"pathName": "packageEquity/pages/keyboard/keyboard",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/tab/index/index",
"query": "merchantId=44205858",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageMine/pages/coupon/recommend/recommend",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/serviceCode/serviceCode",
"query": "id=100&sendDate=1656496796863139&merchantId=123",
"launchMode": "default",
"scene": 1194
},
{
"name": "",
"pathName": "pages/serviceCode/serviceCode",
"query": "id=100&sendDate=1656496796863139",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/index/index",
"query": "",
"launchMode": "default",
"scene": null
}
]
}
},
"projectname": "miniprogram-template",
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "2.24.4"
}
\ No newline at end of file \ No newline at end of file
import Router from "./router.js";
import routes from "./routers.js";
export default new Router(routes);
const _routeHooks = Symbol('_routeHooks')
const _query = Symbol('_query')
const _routerList = Symbol('_routerList')
import { wxOnAppRouteFn, generateRoutList } from './wxOnAppRoute.js'
import { getNavigationBarTitleText } from '~/utils/cache/storageApi'
import { getUserInfo } from '~/utils/cache/userInfo'
class Router {
[_query] = {};
[_routeHooks] = [];
[_routerList] = []
constructor(router) {
this[_routerList] = generateRoutList(router)
let obj = {
query: this[_query],
routeHooks: this[_routeHooks],
routerList: this[_routerList],
getPageInstance: this.getPageInstance,
getRootName: this.getRootName,
setNavigationBarTitleText: this.setNavigationBarTitleText,
getRouterList: this.getRouterList
}
wxOnAppRouteFn(obj)
}
/**设置标题栏 */
setNavigationBarTitleText = thisPage => {
let title = getNavigationBarTitleText()
if (getUserInfo()) title = getUserInfo().merchantName
const router = `${thisPage.__route__}.html`
if (__wxConfig && __wxConfig.page && __wxConfig.page[router]) {
let { navigationBarTitleText, navigationStyle } = __wxConfig.page[router].window
if (!title) title = '广汇车生活'
if (!navigationBarTitleText && !navigationStyle)
wx.setNavigationBarTitle({
title
})
}
}
/**获取路由列表 */
getRouterList = () => {
return this[_routerList]
}
/**获取当前分包名 */
getRootName = () => {
let router = `/${this.getPageInstance().__route__}`
let { rootName } = this.getRouterList().find(item => router === item.url)
return rootName
}
/**获取页面对象实例 */
getPageInstance = (size = 1) => {
const pages = getCurrentPages()
return pages[pages.length - size]
}
checkRouter(route, events) {
this[_query] = events || {}
const [_parent, _name, last_name] = route.split('.')
let name = route
let [parent] = this.getPageInstance().__route__.split('/')
let query = ''
if (route.includes('?')) {
let [_name_, _query_] = route.split('?')
query = `?${_query_}`
name = _name_
}
if (_parent && _name) {
name = _name.split('?')[0]
parent = _parent
}
/**只传页面名 默认跳转当前包下的页面,相同名称默认第一个 */
if (!_name && !last_name) {
name = _parent
parent = this.getRootName() || parent
}
const routerMapItem = this[_routerList].find(item => {
if (last_name) {
return item.parent === parent && item.name === last_name && item.subPages === name
} else {
return item.parent === parent && item.name === name
}
})
if (!routerMapItem) {
console.error('找不到路由')
return
}
return {
routerMapItem,
query
}
}
/**跳转至H5 */
jumpH5(url) {
this.intercept().then(response => {
if (response) return
wx.navigateTo({
url: `/pages/webView/webView?url=${encodeURIComponent(url)}`
})
})
}
/**页面跳转
*
*/
jump(e) {
const item = e.currentTarget.dataset
this.go(item.url, item)
}
/**
* 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面 ||
* 保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 $router.back() 可以返回到原页面。小程序中页面栈最多十层
*/
go(route, events) {
let { routerMapItem, query } = this.checkRouter(route, events)
if (routerMapItem.isTab) {
wx.switchTab({
url: routerMapItem.url
})
} else {
if (events && events.notIntercept) {
wx.navigateTo({
url: `${routerMapItem.url}${query}`,
success: res => events && res.eventChannel.emit('getData', events)
})
} else {
this.intercept().then(response => {
if (response) return
wx.navigateTo({
url: `${routerMapItem.url}${query}`,
success: res => events && res.eventChannel.emit('getData', events)
})
})
}
}
}
/**关闭所有页面,打开到应用内的某个页面 */
reLaunch(route, events) {
let { routerMapItem, query } = this.checkRouter(route, events)
this.intercept().then(response => {
if (response) return
wx.reLaunch({
url: `${routerMapItem.url}${query}`
})
})
}
/**关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。 */
redirectTo(route, events) {
let { routerMapItem, query } = this.checkRouter(route, events)
this.intercept().then(response => {
if (response) return
wx.redirectTo({
url: `${routerMapItem.url}${query}`
})
})
}
/**prevPageSize = 1
* 返回上prevPageSize页
* callBack返回上prevPageSize页对象 */
back(callBack, prevPageSize = 1) {
let prevPage = this.getPageInstance(Number(prevPageSize) + 1)
if (callBack && 'function' === typeof callBack) callBack(prevPage)
wx.navigateBack({
delta: prevPageSize
}).catch(err => {
this.goHome()
})
}
goHome() {
let [index] = this[_routerList]
wx.switchTab({
url: index.url
})
}
/**获取上一个页面传的数据 */
getData(callBack) {
const data = this.getPageInstance().getOpenerEventChannel()
if (Object.keys(data).length !== 0) data.on('getData', res => callBack(res))
}
onRoute(fn) {
this[_routeHooks].push(fn)
return () => {
const i = list.indexOf(fn)
if (i > -1) list.splice(i, 1)
}
}
async intercept() {
const authStatus = wx.$authStatus
if (authStatus) {
const thisPage = this.getPageInstance()
thisPage.setData({
showLogin: true
})
return await true
} else {
return await false
}
}
}
export default Router
/**
* 执行路由前的准备工作
*/
/**处理前置钩子逻辑 */
const routerBefore = (next) => {
// console.log("处理前置钩子逻辑");
next();
};
/**处理后置钩子逻辑 */
const routerAfter = (next) => {
// console.log("处理后置钩子逻辑");
next();
};
// 重写Page方法
const OldPage = Page;
Page = function (options) {
const oldShow = options.onShow;
const oldHide = options.onHide;
options.onShow = function () {
routerBefore(() => {
oldShow.apply(this, arguments);
});
};
options.onHide = function () {
routerAfter(() => {
oldHide.apply(this, arguments);
});
};
OldPage(options);
};
export default routerBefore;
export default __wxConfig.pages.map(item => ({
url: `/${item}`,
name: item.split('/').pop(),
parent: item.split('/')[0]
}))
\ No newline at end of file \ No newline at end of file
import util from '../utils/util.js'
import { getUserInfo } from '~/utils/cache/userInfo'
import { IMG_URL } from '~/utils/constantData'
/**
* wx.onAppRoute钩子方法,
* 所有的参数都是路由类上的参数
* @param {*} obj.query
* @param {*} obj.routeHooks
* @param {*} obj.routerList
* @param {*} obj.getPageInstance
* @param {*} obj.getRootName
* @param {*} obj.setNavigationBarTitleText
* @param {*} obj.getRouterList
*/
export const wxOnAppRouteFn = obj => {
wx.onAppRoute &&
wx.onAppRoute(e => {
let thisPage = obj.getPageInstance()
const rootName = obj.getRootName()
if (rootName) {
const selectedColor = rootName == 'packageEquity' ? '#f7dcbc' : '#FC5B32'
wx.setTabBarStyle({
selectedColor,
color: '#979899',
backgroundColor: '#FFFFFF',
borderStyle: 'white'
})
}
if (thisPage) {
obj.setNavigationBarTitleText(thisPage)
let onRoute = thisPage.onRoute
thisPage.$query = obj.query
typeof onRoute === 'function' && onRoute(obj.query)
thisPage.rootName = rootName
obj.getRouterList().find(item => {
if (`/${thisPage.__route__}` === item.url) {
const authStatus = wx.$authStatus
// if (item.isTab) thisPage.setData({
// showLogin: authStatus
// })
}
})
if (!wx.$version)
util.getImgVersion().then(({ version }) => {
wx.$version = version || '1.0.0'
thisPage.setData({
img_version: wx.$version
})
})
else
thisPage.setData({
img_version: wx.$version
})
// console.log(app)
thisPage.setData({
IMGURL: IMG_URL
})
let userInfo = getUserInfo()
if (userInfo && userInfo.phone) {
if (wx.$authStatus) {
thisPage.setData({
userInfo: null
})
} else {
thisPage.setData({
userInfo
})
if (thisPage.init) thisPage.init(userInfo)
}
}
}
obj.routeHooks.forEach(fn => {
try {
typeof fn === 'function' && fn(e, obj.query, obj.routerList)
} catch (err) {
console.log(err)
}
})
obj.query = {}
})
}
/**
* 生成特定格式路由
*
* @param {*} routerList 路由参数
* @returns
*/
export const generateRoutList = routerList => {
let _routerList = routerList
try {
__wxConfig &&
__wxConfig.tabBar &&
__wxConfig.tabBar.list &&
(_routerList = routerList.map(item => {
let obj = {}
if (item.parent != '__plugin__') {
obj = {
...item,
isTab: __wxConfig.tabBar.list.some(({ pagePath }) => item.url.includes(pagePath.replace('.html', '')))
}
if (item.parent !== 'pages') {
let parentList = item.url.split(`/`)
if (parentList.length > 5) {
item.url = item.url.replace(/\/__plugin__\/[a-z0-9A-Z]+/, '')
obj.subPages = item.url.split(`/${item.parent}/pages/`)[1].split('/')[0]
}
}
if (obj.isTab) {
__wxConfig.tabBar.list.map(e => {
if (obj.url === `/${e.pagePath.replace('.html', '')}`) obj.rootName = e.rootName
})
}
}
return obj
}))
} catch (err) {}
return _routerList
}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!