Commit 18352a81 by liimin

feat: points-mall 物理迁入 apps/mp/points 并接入 api-core SHA1 签名

- 整仓源码自 gitlab points-mall 迁入(app.js/app.json + packageIndex/Cart/Equity/Mine
  四分包 + api/components/utils/lib 等);排除 .git/package-lock/文档 jpg
- 请求层改造(api/request/http.js):本地 sign.js 退役,签名改由
  @uj/api-core createSha1Signer 出(迁移前用 node 脚本比对:扁平参数含中文、
  noSignAttr 大字段两场景签名逐字节一致);getData 改 async、request await 后再
  wx.request;登录态跳转(20/21)/toast/sentry/merchantId/sessionId 业务编排全保留
- package.json 合入 lane 规范:name @uj/mp-points、main:app.js、依赖只留
  @uj/api-core(workspace:*)——glsx-applet-component/glsx-map-sdk/number-precision
  等 devtool 构建 npm 依赖暂不入 pnpm 图(待定依赖模型);lint 收窄为 eslint src
- 已知未决(交接):~/ 别名 49 文件的 devtool 解析方式;构建 npm 与 pnpm 符号链接
  的兼容;dist 未随本仓提交,devtool 使用前需先构建 api-core
1 parent bc376f43
Showing 530 changed files with 4735 additions and 0 deletions
node_modules/
/miniprogram_npm/
*.log
.DS_Store
*.tmp
\ No newline at end of file \ No newline at end of file
File mode changed
import { preReleaseAppId } from '~/config'
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
let index = 2
/**
*
0本地
1开发
2测试
3生产
4预发布
*/
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo);
// console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面index false就默认为2
const manual = false
const release = false
// 判断小程序环境
// develop:开发版(正常开发工具,测试时)
// trial:体验版
// release:正式版
// console.log( systemInfo.platform);
// console.log(accountInfo.miniProgram.envVersion);
// 对比一下appkey
// console.log();
if (systemInfo.platform != 'devtools') {
// 判断预发布的appid 是强制锁定为4(预发布的地址)
if (accountInfo.miniProgram.appId == preReleaseAppId) {
index = 4
} else {
switch (accountInfo.miniProgram.envVersion) {
case 'develop':
// this.globalData.url = 'http://192.168.0.252:3000/api'; //
break
case 'trial':
index = manual ? index : 2
break
case 'release':
index = release ? index : 3
break
default:
index = 3
break
}
}
}
const secretKey = {
ip: {},
dev: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
},
uat: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
},
prod: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
},
preRelease: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
}
}[target[index]]
const domain = {
// ip: 'http://192.168.2.94:8558',
// ip: 'http://192.168.2.3:8315',
ip: 'http://192.168.1.117:8315',
/**登录: 192.168.2.3:8315
商城: 192.168.2.3:8558 */
dev: 'https://scrm.dev.glsx.com.cn',
uat: 'https://scrm.test.glsx.com.cn',
preRelease: 'https://scrm.beta.glsx.com.cn',
prod: 'https://scrm.glsx.com.cn'
}[target[index]]
const pathEnum = {
sso: '/rop-scrm-sso/',
shopmall: '/rop-scrm-shopmall/',
coupon: '/rop-scrm-coupon/',
carlife: '/rop-scrm-carlife/',
live: '/rop-scrm-live/',
equity: '/rop-scrm-equity/',
entmicro: '/rop-scrm-entmicro/',
wechat: '/rop-scrm-wechat/',
boutiquecoupon: '/rop-scrm-boutiquecoupon/',
material: '/rop-scrm-marketing/', //素材
sop: '/rop-scrm-sop/',
customercollect: '/rop-scrm-bigdatautil/',
drac: '/rop-scrm-entmicro/',
busassistant: '/rop-scrm-busassistant/'
}
const defaultMerchantId = {
ip: '44211227',
dev: '44211227',
uat: '44210895',
prod: '44208317',
preRelease: '44211283'
}[target[index]]
const CONFIG_ENV_MAP={
'1':'develop',
'2':'test',
'3':'production',
'4':'beta'
}
module.exports = {
index,
domain,
pathEnum,
secretKey,
defaultMerchantId,
env:CONFIG_ENV_MAP[index]
}
import apiModules from './module/index'
module.exports = apiModules
\ No newline at end of file \ No newline at end of file
import api from '../request/http'
module.exports = {
/**获取集团或者门店详细信息 */
getMerchantDetail(data) {
return api.post({
method: 'scrm.api.carlife.merchant.detail',
...data
})
}
}
\ No newline at end of file \ No newline at end of file
import api from '../request/http'
module.exports = {
/**查询购物车 */
getCartList(data) {
return api.post({
method: 'scrm.api.shopmall.points.shopping.car.get',
...data
})
},
/**加入购物车 */
addToCart(data) {
return api.post({
method: 'scrm.api.shopmall.points.shopping.car.add',
...data
})
},
/**购物车更新商品(将商品数量改为1) */
updateGoodsFormCart(data) {
return api.post({
method: 'scrm.api.shopmall.points.shopping.car.reduce',
...data
})
}
}
\ No newline at end of file \ No newline at end of file
import http from '../request/http'
const common = 'scrm.api.carlife.common.'
module.exports = {
/**上传图片
*/
uploadImg(data) {
return http.post({
method: `${common}uploadImg`,
...data,
noSignAttr: ["file"],
});
},
/**视频上传
*/
uploadVideo(data) {
return http.post({
method: `${common}uploadVideo`,
...data,
noSignAttr: ["file"],
});
},
/** 首页、发现列表 搜索接口 */
search(data) {
return http.post({
method: "scrm.api.carlife.weapp.homeSearch.search",
pageSize: 10,
...data,
});
},
/** 根据sap编码获取商户详情 */
getBySapCode(data) {
return http.fetch(`scrm.api.carlife.merchant.getBySapCode`,data);
},
/**获取图片版本号 */
getImgVersion() {
return http.getMock();
},
/**手机号验证码登录 */
phoneSmsLogin(data) {
return http.fetch('scrm.api.sso.sms.login', {
source: 'MINIAPP',
...data
})
},
/**微信授权手机号登录 */
authPhoneLogin(data) {
return http.fetch('scrm.api.sso.weapp.auth.phone', {
source: 'MINIAPP',
...data
})
},
/**获取积分渠道列表 */
getPointsSourceList(data) {
return http.fetch('scrm.api.shopmall.score.get.channelSource', {
...data
})
},
/**查询积分钱包 */
getPointsWalletData(data) {
return http.fetch('scrm.api.shopmall.pointswallet.get', {
...data
})
},
/**开通积分钱包 */
openPointsWallet(data) {
return http.fetch('scrm.api.shopmall.pointswallet.open', {...data})
},
/**替换积分钱包昵称 */
replaceWalletName(data) {
return http.fetch('scrm.api.sso.nickName.replace', {...data})
},
/**获取积分汇总数据 */
getPointsSummary(data) {
return http.fetch('scrm.api.shopmall.score.summary.search', {...data})
},
/**获取用户信息 */
getLoginInfo(data) {
return http.fetch('scrm.api.sso.weapp.loginfo.get', {...data})
},
/**获取门店数据 */
getMerchantData(data) {
return http.fetch('scrm.api.shopmall.score.list.merchant', {...data})
},
/**进入商品详情页面埋点 */
dynamicRecordAdd(data) {
return http.fetch('scrm.api.shopmall.scrm.customer.dynamic.record.add', {...data})
},
/**离开商品详情页面埋点 */
dynamicRecordLeave(data) {
return http.fetch('scrm.api.shopmall.scrm.customer.dynamic.record.leave', {...data})
}
};
import api from '../request/http'
module.exports = {
/**获取卡券列表 */
getCardData(data) {
return api.post({
method: `scrm.api.coupon.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.p.storage.get('merchant_info')
if (merchantId) {
merchantId = Number(JSON.parse(merchantId))
data.merchantId = merchantId
}
return api.post({
method: `scrm.api.coupon.list.merchant.account`,
...data
})
},
/**领取优惠券 */
toReciveCard(data) {
let {
merchantId
} = wx.p.storage.get('merchant_info')
if (merchantId) {
merchantId = Number(JSON.parse(merchantId))
data.merchantId = merchantId
}
return api.post({
method: `scrm.api.coupon.customer.receive`,
...data,
receiveWay: 1,
receiveSource: 3
})
},
/**卡券详情 */
couponsDetail(data) {
return api.post({
method: `scrm.api.coupon.verification.code.detail`,
...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: `scrm.api.coupon.share.info`,
...data
})
},
/**领取优惠券 */
receiveCoupon(data) {
return api.post({
method: `scrm.api.coupon.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
})
},
// 获取优惠券详情--道路救援
getDigitalCoupons(data) {
return api.post({
method: `scrm.api.coupon.detail`,
...data
})
},
// 领取发现模块的优惠券
toReciveDiscoverCard(data) {
let {
merchantId
} = wx.p.storage.get('merchant_info')
if (merchantId) {
merchantId = Number(JSON.parse(merchantId))
data.merchantId = merchantId
}
return api.post({
method: `scrm.api.coupon.customer.receive`,
...data,
receiveWay: 9,
receiveSource: 3
})
},
}
import api from '../request/http'
module.exports = {
/**查询商户的指定类型专区列表 */
getZoneInfo(zoneType) {
return api.post({
method: `scrm.api.shopmall.zoneInfo.weapp.listByMerchantId`,
zoneType //专区类型(1发现频道,2商城专区)
})
},
}
\ No newline at end of file \ No newline at end of file
import api from "../request/http";
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,
});
},
// 首页--附近优惠 新接口
getLasteCommodity(data) {
return api.post({
method: `scrm.api.equity.main.page.carefully.chosen.page`,
...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,
});
},
// 根据merchantId查询服务条款
serviceTermsById(data) {
return api.post({
method: `scrm.api.equity.serviceterms.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,
});
},
// 购买商品获取订单号
getOrderCode(data) {
return api.post({
method: `scrm.api.equity.ordercode.get`,
...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,
});
},
// 服务项目详情
serviceDetailById(data) {
return api.post({
method: `scrm.api.equity.service.h5.bill.merchant.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,
});
},
// 新增救援服务线索
addClueRescue(data) {
return api.post({
method: `scrm.api.carlife.weapp.clue.rescue`,
...data,
});
},
// 订单详情
orderDetail(data) {
return api.post({
method: `scrm.api.shopmall.weapp.order.detail`,
...data,
});
},
// 获取优惠券兑换码
getExchangecode(data) {
return api.post({
method: `scrm.api.shopmall.weapp.order.exchangecode.get`,
...data,
});
},
// 客户赠送权益列表查询
getCustomerEquityList(data) {
return api.post({
method: `scrm.api.equity.renew.customer.list`,
...data,
});
},
// 客户赠送权益列表查询前注册
setCustomerEquity(data) {
return api.post({
method: `scrm.api.shopmall.weapp.get.equity`,
...data,
});
},
// 手机号码快速直充
toRechargeByPhone(data) {
return api.post({
method: `scrm.api.shopmall.weapp.order.charge`,
...data,
});
},
// 获取国任省市区列表
areaList(data) {
return api.post({
method: `scrm.api.equity.service.claims.area`,
...data,
});
},
// 未开通服务项目查询服务条款
notOpenTerms(data) {
return api.post({
method: `scrm.api.equity.service.items.grade.detail`,
...data,
});
},
};
import api from '../request/http'
module.exports = {
/**获取商城首页商品数据 */
getGoodsStockroomList(data) {
return api.post({
method: 'scrm.api.shopmall.app.platform.goods.stockroom.page',
...data
})
},
/**获取商品详情 */
getGoodsDetailInfo(data) {
return api.post({
method: 'scrm.api.shopmall.app.stockroom.goods.detail',
...data
})
},
/**获取前端分类 */
getHomeCategoryList(data) {
return api.post({
method: 'scrm.api.shopmall.scrm.frontendcategory.listAll',
...data
})
},
/**确认订单下单 */
createOrder(data) {
return api.post({
method: 'scrm.api.shopmall.points.order.create',
...data
})
},
/**获取积分会首页配置数据 */
getHomeConfigData(data) {
return api.post({
method: 'scrm.api.shopmall.scrm.mallmini.findByType',
...data
})
}
}
\ No newline at end of file \ No newline at end of file
import wechatApi from './wechat'
import userApi from './user'
import homeApi from './home'
import discoveryApi from './discovery'
import shopmallApi from './shopmall'
import mineApi from './mine'
import systemApi from './system'
import couponsApi from './coupons'
import equityApi from './equity'
import common from './common'
import withdrawalApi from './withdrawal'
module.exports = {
wechatApi,
userApi,
homeApi,
discoveryApi,
shopmallApi,
mineApi,
systemApi,
couponsApi,
equityApi,
common,
withdrawalApi
}
\ No newline at end of file \ No newline at end of file
import api from '../request/http'
module.exports = {
}
\ No newline at end of file \ No newline at end of file
import api from '../request/http'
module.exports = {
/**. 分页查询订单 */
getOrderList(data) {
return api.post({
method: `scrm.api.shopmall.platform.order.page`,
...data
})
},
/**. 分页查询订单 */
getSalesOrderList(data) {
return api.post({
method: `scrm.api.shopmall.platform.after.sales.order.page`,
...data
})
},
/**获取订单状态数量 */
getOrderNumberList(data) {
return api.post({
method: 'scrm.api.shopmall.weapp.order.statis',
...data
})
},
/**获取客户保存的地址列表 */
getCustomerAddressList(data) {
return api.post({
method: 'scrm.api.shopmall.platform.customer.address.list',
...data
})
},
/**保存或更新收货地址 */
saveAddress(data) {
return api.post({
method: 'scrm.api.shopmall.platform.customer.address.save',
...data
})
},
/**删除收货地址 */
removeAddress(data) {
return api.post({
method: 'scrm.api.shopmall.platform.customer.address.delete',
...data
})
},
/**获取地址基础数据 */
getBaseAddress(data) {
return api.post({
method: 'scrm.api.shopmall.platform.base.address.list',
...data
})
},
}
\ No newline at end of file \ No newline at end of file
### 注意:
1. 此文件夹只分:
1.1. mall.js (商城模块)
1.2. cart.js (购物车模块)
1.3. mine.js (我的模块)
1.4. common.js (除以上三大模块之外的所有接口统一放在此文件)
1.5. index.js (首页模块 对外统一导出)
2. 后续如果有模块新增再调整
\ No newline at end of file \ No newline at end of file
import api from '../request/http'
module.exports = {
/** 分页查询商城专区的商品信息 */
getGoodsList(data) {
return api.post({
method: `scrm.api.shopmall.zoneInfo.weapp.goodsPage.HMD`,
pageNum: 1,
pageSize: 999,
...data
})
},
/** 添加购物车 */
addShoppingcart(data) {
return api.post({
method: `scrm.api.shopmall.weapp.shoppingcart.add`,
...data
})
},
/** 购物车删除商品 */
delShoppingcart(data) {
return api.post({
method: `scrm.api.shopmall.weapp.shoppingcart.delete`,
...data
})
},
/** 分页获取购物车 */
getShoppingcartList(data) {
return api.post({
method: `scrm.api.shopmall.weapp.shoppingcart.list`,
...data
})
},
/** 购物车商品变更(比如修改数量) */
updateShoppingcart(data) {
return api.post({
method: `scrm.api.shopmall.weapp.shoppingcart.update`,
...data
})
},
/** 领取确认订单最大优惠券 */
getMaxCoupon(orderGoods) {
return api.fetch('scrm.api.shopmall.weapp.order.coupons.get.HMD', {
orderGoods
})
},
/**购物车结算 */
settlementShoppingcart(data) {
return api.post({
method: `scrm.api.shopmall.weapp.shoppingcart.settlement`,
...data
})
},
/** 创建订单(立即购买) */
createOrder(data) {
return api.post({
method: `scrm.api.shopmall.weapp.order.create`,
...data
})
},
/**创建支付订单(去付款) */
payOrder(data) {
return api.post({
method: `scrm.api.shopmall.weapp.order.createPay`,
...data
})
},
/**订单详情 */
getOrderDetail(data) {
return api.post({
method: `scrm.api.shopmall.platform.order.detail`,
...data
})
},
/**获取订单的售后详情 */
getOrderRefundDetail(orderCode) {
return api.post({
method: `scrm.api.shopmall.weapp.orderRefund.detail`,
orderCode
})
},
//取消付款
cancelPay(orderCode) {
return api.fetch('scrm.api.shopmall.weapp.order.cancelPay', {
orderCode
})
},
/** 申请售后-自营商品 */
afterSale(data) {
return api.fetch('scrm.api.shopmall.points.afterSales.add', data)
},
/** 申请售后-云中鹤申请售后 */
afterSalesPlatform(data) {
return api.fetch('scrm.api.shopmall.platform.afterSales.add', data)
},
//申请售后待审核的订单取消售后
cancelOrder(orderCode) {
return api.fetch('scrm.api.shopmall.weapp.orderRefund.cancel', {
orderCode
})
},
/** 售后寄回商品填写快递信息 */
addDelivery(data) {
return api.post({
method: `scrm.api.shopmall.platform.sendBack.goods`,
...data
})
},
/**云中鹤查看物流列表(售后寄回)*/
queryExpressList(data={}){
return api.post({
method: 'scrm.api.shopmall.platform.query.expressList',
...data
})
},
/** 云中鹤-售后订单详情*/
platformSaleDetail(data) {
return api.post({
method: 'scrm.api.shopmall.platform.afterSales.detail',
...data
})
},
/**自营-售后订单详情 */
afterSaleDetail(data) {
return api.post({
method: 'scrm.api.shopmall.points.afterSales.detail',
...data
})
},
/** 确认收货 */
confirmReceipt(subOrderCode) {
return api.post({
method: `scrm.api.shopmall.platform.confirm.receipt`,
subOrderCode
})
},
/**平台商城接口---取消售后 */
platformEditSale(data) {
return api.post({
method: 'scrm.api.shopmall.platform.afterSales.cancel',
...data
})
},
/** 查看物流轨迹 */
queryLogistics(data) {
return api.post({
method: `scrm.api.shopmall.platform.order.queryLogistics`,
...data
})
},
/**云中鹤查看可申请售后的商品数量 */
getYzhAvailableQty(data) {
return api.post({
method: 'scrm.api.shopmall.platform.afterSales.available.qty',
...data
})
},
/**自营查看可申请售后的商品数量(暂无) */
getAvailableQty(data) {
return Promise.resolve(null)
}
}
\ No newline at end of file \ No newline at end of file
import http from "../request/http";
import { env } from "../env/index";
const serverConfig = {
mockRequestCount: null,
mockTimer: {},
mockCache: null,
};
const configModule = 'mini-points-mall'
const configUrl = `https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=${configModule}&env=${env}`;
/**获取mock数据 */
const getMockData = async () => {
const MOCKDATA = wx.p.storage.get("mock_data");
try {
if (MOCKDATA && Date.now() - MOCKDATA.createTime < 5 * 60e3) {
return Promise.resolve(MOCKDATA);
} else {
if (!serverConfig.mockRequestCount) {
serverConfig.mockCache = null;
serverConfig.mockRequestCount = Date.now();
const data = await http.wx_request({ url:configUrl });;
data.createTime = Date.now();
serverConfig.mockCache = data;
wx.p.storage.set("mock_data", data);
return Promise.resolve(data);
} else {
const key = Date.now();
return new Promise((resolve) => {
serverConfig.mockTimer[key] = setInterval(() => {
if (serverConfig.mockCache) {
clearInterval(serverConfig.mockTimer[key]);
serverConfig.mockRequestCount = null;
resolve(serverConfig.mockCache);
}
}, 1e3);
});
}
}
} catch (error) {
if (serverConfig.mockTimer[key]) clearInterval(serverConfig.mockTimer[key]);
serverConfig.mockRequestCount = null;
return Promise.reject(error);
}
};
// 实时获取配置中心数据
const getConfigData = async () => {
return http.wx_request({ url: configUrl })
}
// 图片版本号
const getImageVersion = async () => {
const accountInfo = await getMockData()
return accountInfo?.version || Date.now()
}
module.exports={
getImageVersion,
getMockData,
getConfigData
}
import http from '../request/http'
const { appId } = wx.getAccountInfoSync().miniProgram
let loginCount = null,
loginCache = null,
loginTimer = null
class UsersApi {
/**调用后台接口获取用户信息 */
async login() {
const appEnter = wx.getEnterOptionsSync()
try {
if (appEnter.scene === 1154 && appEnter.mode === 'singlePage') throw 'login:fail rejected due to no permission currently'
if (!loginCount) {
loginCache = null
loginCount = Date.now()
const {
code
} = await this.getWxCode(),
data = await http.fetch('scrm.api.sso.weapp.jscode.getOpenIdAndLogin', {
appId,
code,
delSessionId: true
})
loginCache = data
loginCount = null
return Promise.resolve(data)
} else {
return new Promise((resolve) => {
loginTimer = setInterval(() => {
if (loginCache) {
clearInterval(loginTimer)
loginCount = null
resolve(loginCache)
}
}, 1e3)
})
}
} catch (error) {
if (loginTimer) clearInterval(loginTimer)
loginCount = null
return Promise.reject(error)
}
}
/**调用接口获取登录凭证(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.p.wxApi.showToast('缺少sessionId')
Promise.reject({
errMsg: '缺少sessionId'
})
}
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (detail.iv && detail.encryptedData) {
wx.p.wxApi.showLoading()
detail.sessionId = sessionId
return http.fetch('scrm.api.sso.weapp.auth.phone', detail)
} else Promise.reject(detail.errMsg)
}
/**退出登录 */
logout() {
return http.fetch('scrm.api.sso.user.logout')
}
/** 手机号获取短信验证码 */
getSmsCode(mobile) {
return http.fetch('scrm.api.sso.wechat.applets.sms.get.code', {
mobile
})
}
/** 手机号短信验证码登录 */
phoneSmsLogin(data = {}) {
return http.fetch('scrm.api.sso.wechat.applets.sms.login', {
...data,
source: 'MINIAPP',
platformEntrance: 'STORE_ASSISTANT'
})
}
/*
*C端手机号短信登录
*/
phoneLogin(data) {
return http.fetch('scrm.api.sso.weapp.auth.phone.mini', {
source: 'MINIAPP',
...data
})
}
}
export default new UsersApi()
\ No newline at end of file \ No newline at end of file
import http from '../request/http'
const path = 'scrm.api.wechat.'
module.exports = {
/** 解析scene */
getSceneById(data) {
// return api.post({
// method: `${path}get.scene.by.id`,
// ...data
// }, true)
return http.fetch(`${path}get.scene.by.id`,data);
}
}
import api from '../request/http'
module.exports = {
/**积分汇总查询 */
searchScoreSummary(data) {
return api.fetch(
'scrm.api.shopmall.score.summary.search',
data,
);
},
/**积分明细列表查询 */
getScoreProfitList(data) {
return api.fetch(
'scrm.api.shopmall.score.profit.list',
data
)
},
/**积分明细查询 */
getScoreDetail(data) {
return api.fetch(
'scrm.api.shopmall.score.detail.get',
data
)
},
/**提现列表查询 */
getScoreWithdrawalPage(data) {
return api.fetch(
'scrm.api.shopmall.score.withdrawal.page',
data
)
},
/** 免责协议地址获取*/
getAgreementUrl(data) {
return api.fetch(
'scrm.api.shopmall.score.withdrawal.disclaimer.agreement.get',
data
)
},
/** 积分提现*/
saveWithdrawal(data) {
return api.fetch('scrm.api.shopmall.score.withdrawal.save', data)
},
/**查询税率 */
getTaxRate(data) {
return api.fetch('scrm.api.shopmall.score.get.taxRate', data)
},
/**根据手机号查询员工银行卡列表 */
getStaffBankList(data) {
return api.fetch(
'scrm.api.shopmall.score.bank.list',
data,
);
},
/** 插入或更新员工银行卡信息 */
insetorupdateStaffBank(data) {
return api.fetch('scrm.api.shopmall.score.bank.insertOrUpdate',
data);
},
/**根据id查询银行卡详情 */
getBankDetail(data) {
return api.fetch('scrm.api.shopmall.score.bank.get.detail', data)
},
/**查询上传证件配置信息 */
getConfig(data){
return api.fetch('scrm.api.shopmall.score.bank.get.document.config',data)
},
/**开通积分钱包 */
openPointsWallet(data){
return api.fetch('scrm.api.shopmall.pointswallet.open',data)
},
/**检查银行卡身份信息 */
checkbankConfig(data){
return api.fetch('scrm.api.shopmall.score.bank.check.config',data)
}
}
\ No newline at end of file \ No newline at end of file
import { createSha1Signer } from '@uj/api-core'
import {
defaultMerchantId,
secretKey,
pathEnum,
domain,
} from '../env/index'
// 签名统一收口到 @uj/api-core 的 SHA1 预设(与老 sign.js 字节级一致,迁移时脚本验证过)。
// 业务编排(登录态跳转 / toast / sentry)仍保留在下方 Request 类,不动。
const pointsSigner = createSha1Signer({ id: 'points-sha1' })
/**接口 */
class Request {
get(params, returnAll = false) {
return this.request('GET', params, returnAll)
}
post(params, returnAll = false) {
return this.request('POST', params, returnAll)
}
fetch(method, data, returnAll = true) {
return this.post({
method,
...data,
},
returnAll
);
}
wx_request({
url,
method = 'GET',
data = {},
header = {},
dataType = 'json',
responseType = "text"
}) {
return new Promise((resolve) => {
wx.request({
url,
data,
method,
header,
dataType,
responseType,
success(response) {
resolve(response.data)
}
})
})
}
reportTrack(params) {
return this.request('POST', params, true)
}
async request(RequestMethods, params, returnAll) {
wx.showNavigationBarLoading()
let header = RequestMethods === 'POST' ? {
'content-type': 'application/x-www-form-urlencoded'
} : {
'Cache-Control': 'no-cache'
}
let {
merchantId
} = wx.p.storage.get('merchant_info')
header.merchantId = wx.$merchant_id || merchantId || defaultMerchantId
let projectName = params.projectName
if (!projectName) projectName = this.getRopProject(params.method)
const path = pathEnum[projectName]
params = await this.getData(params)
return new Promise((resolve, reject) => {
wx.request({
url: `${domain}${path}router?method=${params.method}`,
data: params,
method: RequestMethods,
header,
dataType: 'json',
responseType: 'text',
success(response) {
/**业务代码 */
let {
data: {
code,
message
},
data
} = response
if (returnAll) {
resolve(data)
return
}
if (code == 20 || code == 21) {
wx.hideLoading()
const thisPage = wx.p.router.getPageInstance(),
options = Object.keys(thisPage.options)
let currentRoute = thisPage.route,
query = []
if (options.length) {
options.map(key => {
query.push(`${key}=${thisPage.options[key]}`)
})
}
if (query.length) currentRoute += `?${query.join('&')}`
wx.p.storage.rm('sessionId')
wx.p.isLogin = false
wx.p.storage.rm('userInfo')
return wx.p.router.redirectTo('/pages/Login/Login')
} else {
if (code == '0') {
resolve(data.data)
} else {
wx.showToast({
title: message || '系统异常',
icon: 'none'
})
wx.p.sentry.reportError(`接口异常:${message}`, {code,message,params})
}
}
},
fail(error) {
wx.hideLoading()
wx.showToast({
title: typeof error == 'string' ? error : JSON.stringify(error) || '系统异常',
icon: 'error'
})
console.error(`接口异常:`, error)
wx.p.sentry.reportError(`接口异常:${error.message}`, {error,params})
reject(error)
},
complete() {
wx.stopPullDownRefresh()
wx.hideNavigationBarLoading()
}
})
})
}
async getData(params) {
let projectName = params.projectName
if (!projectName) projectName = this.getRopProject(params.method)
else delete params.projectName
let appKey = '48e5e13229b82c1b4e6e8c96151f0637'
let secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
if (secretKey[projectName]) {
appKey = secretKey[projectName].appKey
secret = secretKey[projectName].secret
}
let {
sessionId
} = wx.p.storage.get()
let noSignAttr = []
if (!params.sessionId && sessionId) params.sessionId = sessionId
if (params.delSessionId) {
delete params.sessionId
delete params.delSessionId
}
if (params.noSignAttr) {
noSignAttr = params.noSignAttr
delete params.noSignAttr
}
params.v = '1.0.0'
params.format = 'json'
params.locale = 'zh_CN'
params.source = 'dj-wechat'
params.appKey = appKey
// 签名统一收口到 @uj/api-core(与老 sign.js 逐字节一致,迁移时脚本验证过)。
// params 此时尚不含 sign;signer 仅取其 .sign 并入,不动业务参数。
const signed = await pointsSigner.fields({
method: params.method,
appKey,
secret,
version: params.v,
format: params.format,
params,
exclude: noSignAttr,
})
params.sign = signed.sign
return params
}
getRopProject(method) {
const projectName = method.split('.')[2]
return projectName
}
}
export default new Request()
\ No newline at end of file \ No newline at end of file
// app.js
import api from "./api/index";
import { router, routerBefore } from "./router/index";
// 判断小程序是否需要更新
import { getUpdateManager } from "./lib/index";
import utils from "./utils/index";
// 埋点 有需要再引入
// import './utils/track/Track'
/**分享 */
import "~/utils/share";
App({
onLaunch(options) {
getUpdateManager();
/**挂载到wx对象 */
wx.p = {
authStatus: false,
...utils,
api,
router,
isLogin: false,
storage: new utils.cache.Storage(),
};
// 存储设备信息
utils.cache.storageApi.setSystem_info();
},
/**页面不存在时触发 */
onPageNotFound(e) {
wx.p.router.goHome();
},
onHide() {},
globalData: {
ROUTE_QUERY: {},
goodsPageParam: {
appearance: 1,
pageSize: 0,
pageCount: 3,
},
goodsLoaded: false,
goodsCommodityList: [],
},
});
{
"pages": [
"pages/loading/loading",
"pages/tab/index/index",
"pages/tab/cart/index",
"pages/tab/mine/index",
"pages/webView/webView",
"pages/Login/Login",
"pages/chooseMerchant/index"
],
"requiredPrivateInfos": [
"getLocation"
],
"lazyCodeLoading": "requiredComponents",
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle": "black"
},
"tabBar": {
"color": "#9DA4B3",
"selectedColor": "#4B5466",
"backgroundColor": "#FFFFFF",
"borderStyle": "white",
"list": [
{
"pagePath": "pages/tab/index/index",
"text": "商城",
"iconPath": "assets/images/index.png",
"selectedIconPath": "assets/images/index_active.png"
},
{
"pagePath": "pages/tab/cart/index",
"text": "购物车",
"iconPath": "assets/images/cart.png",
"selectedIconPath": "assets/images/cart_active.png"
},
{
"pagePath": "pages/tab/mine/index",
"text": "我的",
"iconPath": "assets/images/mine.png",
"selectedIconPath": "assets/images/mine_active.png"
}
]
},
"subpackages": [
{
"root": "packageIndex",
"pages": [
"pages/bannerJumpPage/bannerJumpPage",
"pages/common/contact/contact",
"pages/serviceCode/serviceCode",
"pages/integral/index/index",
"pages/integral/withdrawal/withdrawal",
"pages/bankAccount/add/add",
"pages/bankAccount/list/list",
"pages/integral/withdrawalNote/withdrawalNote",
"pages/integral/withdrawalSuccess/withdrawalSuccess",
"pages/SpecialSale/SpecialSale",
"pages/goodsDetail/index",
"pages/integral/withdrawalRules/withdrawalRules",
"pages/confirmOrder/index",
"pages/exchangeSuccess/index",
"pages/integral/withdrawalDetail/withdrawalDetail"
]
},
{
"root": "packageCart",
"pages": [
"pages/shoppingCart/shoppingCart",
"pages/pay/pay",
"pages/detail/detail",
"pages/search/search",
"pages/coupon/coupon"
]
},
{
"root": "packageMine",
"pages": [
"pages/setting/index",
"pages/address/index/index",
"pages/address/detail/detail",
"pages/order/index/index",
"pages/order/detail/detail",
"pages/order/complete/complete",
"pages/order/afterSale_step_two/afterSale_step_two",
"pages/order/afterSaleDetail/afterSaleDetail"
]
}
],
"usingComponents": {
"navigation-bar": "/components/NavigationBar/NavigationBar",
"glsx-image": "/components/image/index",
"authorize": "/components/Authorize/Authorize",
"popup": "/components/Popup/Popup",
"goods-action": "/components/GoodsAction/GoodsAction",
"glsx-privacy": "glsx-applet-component/GlsxPrivacy/index",
"mp-icon": "weui-miniprogram/icon/icon",
"mp-dialog": "weui-miniprogram/dialog/dialog",
"mp-cell": "weui-miniprogram/cell/cell",
"mp-cells": "weui-miniprogram/cells/cells",
"Dialog": "/components/Dialog/Dialog"
},
"style": "v2",
"resolveAlias": {
"~/*": "/*"
},
"sitemapLocation": "sitemap.json",
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"plugins": {},
"useExtendedLib": {
"weui": true
},
"__usePrivacyCheck__": true
}
\ No newline at end of file \ No newline at end of file
@import "assets/style/common.wxss";
page {
background-color: #F7F8FA !important;
color: #282829;
font-size: 28rpx;
--themeColor: #FC5B32;
--btnColor: #FC8A32;
--fontColor: #7E4C15;
--borderRadius: 8rpx;
--margin: 32rpx;
/* 兼容 IOS<11.2 先constant再env */
--constantSafeAreaInsetBottom: constant(safe-area-inset-bottom);
/* 兼容 IOS>11.2 */
--envSafeAreaInsetBottom: env(safe-area-inset-bottom);
}
image {
width: 100%;
height: 100%;
vertical-align: top;
}
.flex_sc {
display: flex;
align-items: center;
}
.flex_cc {
display: flex;
align-items: center;
justify-content: center;
}
.flex_scb {
display: flex;
align-items: center;
justify-content: space-between;
}
.suggest-box {
font-size: 28rpx;
color: #1B233D;
}
.btn_primary {
color: #FC5B32;
font-weight: 500;
font-size: 28rpx;
}
.btn_cancel {
font-weight: 400;
font-size: 28rpx;
color: #1B233D;
}
.express-wrap{
height:1200rpx;
}
.express-wrap .weui-actionsheet__menu{
height:calc(100% - 100rpx);
overflow-y: auto;
}
\ No newline at end of file \ No newline at end of file
/**app.wxss**/
.flex {
display: flex;
align-items: center;
}
.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;
}
.flex-column{
flex-direction: column;
}
.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;
}
}
@keyframes show-box-inset{
0% {
opacity: 0;
transform: scale(.1);
}
100% {
opacity: 1;
transform: scale(1);
}
}
.safe-area {
display: block;
width: 100%;
height: 0;
opacity: 0;
}
\ No newline at end of file \ No newline at end of file
import mineApi from '~/api/module/mine.js'
Component({
/**
* 组件的属性列表
*/
properties: {
defaultAddress: Object,
address:Array,
show: {
type: Boolean,
observer: function (val, o) {
if (val && this.properties.address.length) {
console.log(this.properties.defaultAddress?.id)
this.properties.address.forEach((item, index) => {
item.active = false
if (item.id == this.properties.defaultAddress?.id) {
item.active = true
}
})
this.setData({
address: this.properties.address
})
}
}
},
staff:Boolean
},
/**
* 组件的初始数据
*/
data: {
addressList: []
},
/**
* 组件的方法列表
*/
methods: {
back() {
this.cancel()
},
addNew (e) {
let { url } = e.currentTarget.dataset
wx.p.router.go(url,{
platform:true,
staff:this.data.staff,
notIntercept:this.data.staff
})
},
// 确认
confirm(e) {
let { address } = this.data
const item = address?.find(val => val.active == true)
if (!item || !Object.keys(item)?.length) return wx.p.wxApi.showToast('请选择收货地址')
const contactAddress = item.provinceName+item.cityName+item.countyName+item.address
this.triggerEvent('getAddress', {defaultAddress:item,contactAddress})
this.cancel()
},
cancel() {
this.setData({
show: false
})
this.triggerEvent('cancel')
},
toSelect(e) {
const { item } = e.currentTarget.dataset
let { address } = this.data
address?.forEach(val => {
val.active = false
if (item.id == val.id) val.active = true
})
this.setData({address})
},
addressList() {
mineApi.getCustomerAddressList().then(data => {
// 新增地址后默认将新增的选中
data?.forEach((val, index) => {
val.active = false
if (index == 0) val.active = true
})
this.setData({
address: data
})
wx.hideLoading()
})
}
},
lifetimes: {
attached: function () {
wx.p.eventbus.on('REFRESH_PLATFORM_ADDRESS',()=>{
this.addressList()
})
},
},
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
.popclass {
border-radius: 16rpx 16rpx 0 0;
}
.address-container {
position: fixed;
left: 0;
bottom: 0;
right: 0;
top: 0;
z-index: 9;
.address-bg {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .6);
}
.container {
position: absolute;
width: 100%;
height: 65%;
box-sizing: border-box;
background: #FFFFFF;
border-radius: 32rpx 32rpx 0 0;
left: 0;
bottom: 0;
animation: show-sku-box .5s forwards;
z-index: 2;
}
}
.headeer {
height: 104rpx;
background: #F7F7F7;
border-radius: 16rpx 16rpx 0 0;
box-sizing: border-box;
padding: 0 40rpx;
.icon {
width: 40rpx;
height: 40rpx;
}
.title {
font-weight: 500;
font-size: 32rpx;
color: #282829;
}
}
.list-pannel {
height: calc(100% - 260rpx);
.scroll {
height: 100%;
}
.cell {
display: flex;
align-items: center;
box-sizing: border-box;
padding: 32rpx 40rpx;
position: relative;
.icon {
width: 40rpx;
height: 40rpx;
margin-right: 24rpx;
}
.content-box {
.name-phone {
font-weight: 400;
font-size: 24rpx;
color: #707071;
}
.address {
width: 606rpx;
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 28rpx;
color: #333435;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
word-break: break-all;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-height: 44rpx;
margin: 4rpx 0 8rpx 0;
}
.default-tip {
width: 104rpx;
height: 32rpx;
background: #f13c3d0f;
border: 1.2rpx solid #F13C3D;
border-radius: 4rpx;
font-weight: 400;
font-size: 20rpx;
color: #F13C3D;
}
}
.line {
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
width: 670rpx;
height: 2rpx;
background: #EFF0F2;
}
}
.nothing {
height: 100%;
display: flex;
flex-flow: column;
align-items: center;
justify-content: center;
color: #7A8299;
.icon{
width: 320rpx;
height: 300rpx;
margin-bottom: 20rpx;
}
}
}
.footer {
height: 104rpx;
background: #FFFFFF;
box-shadow: 0 0 0 0 #E9E9E9;
box-sizing: border-box;
padding: 0 32rpx;
.btn {
width: calc(50% - 7rpx);
height: 80rpx;
background: #ffffff0f;
border: 2rpx solid #FB8A32;
border-radius: 20rpx;
font-weight: 500;
font-size: 28rpx;
color: #FB8A32;
margin-right: 17rpx;
}
.confirm_btn {
background: #FB8A32;
color: #FFFFFF;
}
}
.flex_sbc {
display: flex;
align-items: center;
justify-content: space-between;
}
.flex_cc {
display: flex;
align-items: center;
justify-content: center;
}
\ No newline at end of file \ No newline at end of file
<!-- <van-popup show="{{ show }}" bind:click-overlay="cancel" custom-class="popclass" position="bottom" custom-style="height: 1076rpx"></van-popup> -->
<view class="address-container" hidden="{{!show}}">
<view class="address-bg" bindtap="cancel"></view>
<view class="container">
<view class="headeer flex_sbc">
<glsx-image bind:tap="cancel" class="icon" src="/index/back.png"></glsx-image>
<view class="title">选择收货地址</view>
<glsx-image bind:tap="cancel" webp class="icon" src="/index/close.png"></glsx-image>
</view>
<view class="list-pannel">
<scroll-view class="scroll" scroll-y="{{true}}" wx:if="{{address.length}}">
<block wx:for="{{address}}" wx:key="index">
<view bind:tap="toSelect" data-item="{{item}}" data-index="{{index}}" class="cell">
<view class="icon">
<icon type="{{item.active?'success':'circle'}}" color="{{item.active?'#FB8A32':'#B1B1B3'}}" size="20">
</icon>
</view>
<view class="content-box">
<view class="name-phone">{{item.receiveName}} {{item.receiveMobile}}</view>
<view class="address">{{item.provinceName}}{{item.cityName}}{{item.countyName}}{{item.address}}</view>
<view wx:if="{{item.isDefault==1}}" class="default-tip flex_cc">默认地址</view>
</view>
<view class="line"></view>
</view>
</block>
</scroll-view>
<view wx:else class="nothing">
<view class="icon">
<glsx-image webp src="/cart/nothing-icon.png" />
</view>
暂无收货地址
</view>
</view>
<view class="footer flex_cc">
<view bind:tap="addNew" data-url="/packageMine/pages/address/detail/detail" class="btn flex_cc">新增地址</view>
<view bind:tap="confirm" class="btn confirm_btn flex_cc">确认</view>
</view>
</view>
</view>
// components/Authorize/Authorize.js
Component({
/**
* 组件的属性列表
*/
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() {},
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')
},
openSetting() {
let _this = this
wx.openSetting({
success() {
_this.setData({
init: true,
openSet: false
})
}
})
},
/**检验是否已授权位置 */
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.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 class="button-style" catchtap="openSetting" ></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/Dialog/dialog.js
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
value: false
},
// 弹窗的标题
title: {
type: String,
value: ''
},
//是否显示蒙层
mask: {
type: Boolean,
value: true
},
buttons: {
type: Array,
default: () => [{
text: '取消',
extClass: 'btn_cancel'
}, {
text: '确定',
extClass: 'btn_primary'
}]
},
//['success','fail','loading]
statusIcon: {
type: String,
default: ""
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
handleClick(e) {
let {
index
} = e.detail
this.triggerEvent('buttontap', {
value: index
})
},
onClose() {}
}
})
\ 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
/* components/Dialog/dialog.wxss */
.auth-dialog-class {
text-align: center;
font-size: var(--fontSize28);
font-weight: 400;
}
.auth-dialog-class .van-dialog__header {
font-size: var(--fontSize36);
font-weight: 500;
color: #333333;
}
.title_text {
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 40rpx;
color: #000000;
text-align: center;
}
.status {
width: 88rpx;
height: 88rpx;
position: relative;
left:50%;
transform: translateX(-50%);
margin-bottom:28rpx;
.icon{
width:100%;
height:100%;
}
}
\ No newline at end of file \ No newline at end of file
<!--components/Dialog/dialog.wxml-->
<mp-dialog show="{{ show }}" class="auth-dialog-class" width="var(--fontSize552)" bindclose="onClose" mask="{{mask}}" bindbuttontap="handleClick" buttons="{{buttons}}" bindclose="onClose">
<view slot="title" wx:if="{{title}}">
<view class="title_text">{{title}}</view>
</view>
<view class="status" wx:if="{{statusIcon}}">
<glsx-image webp src="/status/{{statusIcon}}.png" class="icon"></glsx-image>
</view>
<slot></slot>
</mp-dialog>
// pages/Login/components/EnableSuccess/EnableSuccess.js
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
confirm() {
this.setData({show: false})
}
}
})
\ 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
/* pages/Login/components/EnableSuccess/EnableSuccess.wxss */
.success {
position: fixed;
left: 0;
bottom: 0;
right: 0;
top: 0;
z-index: 9;
.success-bg {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .6);
}
.success-content {
position: absolute;
width: calc(100% - 208rpx);
height: 578rpx;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 2;
.content-bg {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 1;
}
.content-box {
position: absolute;
z-index: 2;
margin-top: 226rpx;
width: 100%;
display: flex;
flex-flow: column;
align-items: center;
.success-text {
font-size: 48rpx;
font-weight: 700;
color: #FB8A32;
margin-bottom: 20rpx;
}
.success-tips {
line-height: 50rpx;
}
.success-btn {
width: 352rpx;
height: 96rpx;
background-image: linear-gradient(119deg, #FFB14E 11%, #FB8A32 96%);
box-shadow: 0 12rpx 12rpx 4rpx #fb8a321a;
border-radius: 48rpx;
display: flex;
align-items: center;
justify-content: center;
color: #FFFFFF;
font-size: 32rpx;
font-weight: 500;
margin-top: 24rpx;
}
}
}
}
\ No newline at end of file \ No newline at end of file
<!--pages/Login/components/EnableSuccess/EnableSuccess.wxml-->
<view class="success" catchtouchmove="noScroll" hidden="{{!show}}">
<view class="success-bg"></view>
<view class="success-content">
<view class="content-bg">
<glsx-image src="/login/success-bg.png"></glsx-image>
</view>
<view class="content-box">
<view class="success-text">开通成功</view>
<view class="success-tips">
<view>您的积分钱包开通成功!</view>
<view>即刻开启您的财富之旅!</view>
</view>
<view class="success-btn" bindtap="confirm">我知道了</view>
</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
// pages/Login/components/EnableWallet/EnableWallet.js
import commonApi from '~/api/module/common.js'
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer: function(n) {
this.setData({
copyWalletObj: JSON.parse(JSON.stringify(this.data.walletObj))
})
}
},
walletObj: {
type: Object
}
},
/**
* 组件的初始数据
*/
data: {
stepDataArr: [{
icon: 'wallet-icon-1',
label: '开通钱包',
tips: '一站式积分管理体验'
}, {
icon: 'wallet-icon-2',
label: '查询积分',
tips: '您的第一笔可用积分',
pointsFlag: true
}, {
icon: 'wallet-icon-3',
label: '积分随心用',
tips: '兑换商品/分享亲友/话费充值, 想怎么用就怎么用!'
}]
},
/**
* 组件的方法列表
*/
methods: {
// 关闭弹窗
closeWallet() {
let { copyWalletObj } = this.data
this.setData({show: false})
// 仅替换积分数据返回的内容,使用copyWalletObj 防止修改弹窗内容也做了替换
this.replaceNickName(copyWalletObj)
},
// 替换积分钱包名称
replaceNickName(data) {
let userInfo = wx.p.storage.get('userInfo')
let { phone, scoreSource } = data
if (!phone || !scoreSource) {
wx.p.sentry.reportParamError(
'替换积分钱包姓名异常:phone, scoreSource',
data
)
}
commonApi.replaceWalletName({
nickName: data?.name,
phone: data?.phone,
scoreSource: data?.scoreSource
}).then(res => {
let { code, message } = res
if (code == 0) {
wx.p.storage.set('userInfo', {...userInfo, nickName: data?.name}) // 更新storage中的nickName
} else {
wx.p.wxApi.showToast(message)
}
})
},
input(e) {
let { target } = e.currentTarget.dataset
let { value } = e.detail
value = target == 'phone' ? value.replace(/[^0-9]/g, '') : value
this.setData({
[`walletObj.${target}`]: value
})
},
// 一键开通积分钱包
enableWalletConfirm() {
let { walletObj } = this.data
commonApi.openPointsWallet(walletObj).then(res => {
let { code, message } = res
if (code == 0) {
this.setData({
showEnableSuccess: true,
show: false
})
this.replaceNickName(walletObj)
this.triggerEvent('open')
} else {
wx.p.wxApi.showToast(message)
}
})
},
// 开通
confirm() {
let { walletObj } = this.data
if (!walletObj?.name) return wx.p.wxApi.showToast('姓名不能为空')
if (!walletObj?.phone || !/^[1]([3-9])[0-9]{9}$/.test(walletObj?.phone)) return wx.p.wxApi.showToast('请输入正确手机号')
this.enableWalletConfirm()
}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {
"enable-success": "/components/EnableSuccess/EnableSuccess"
}
}
\ No newline at end of file \ No newline at end of file
/* pages/Login/components/EnableWallet/EnableWallet.wxss */
.wallet {
position: fixed;
left: 0;
bottom: 0;
right: 0;
top: 0;
z-index: 9;
.wallet-bg {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .6);
}
.wallet-content {
position: absolute;
width: calc(100% - 32rpx);
height: 968rpx;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 2;
.content-bg {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 1;
}
.close {
width: 48rpx;
height: 48rpx;
position: absolute;
top: 0;
right: 10rpx;
z-index: 2;
}
.content-box {
position: absolute;
z-index: 2;
width: calc(100% - 80rpx);
margin: 220rpx 40rpx 0 40rpx;
.box-item {
display: flex;
align-items: center;
margin-bottom: 26rpx;
.wallet-icon {
width: 76rpx;
height: 76rpx;
margin-right: 24rpx;
}
.label {
font-size: 26rpx;
color: #322811;
font-weight: 700;
}
.tips {
font-size: 24rpx;
color: #666666;
}
}
.text {
font-size: 24rpx;
color: #999999;
margin: 56rpx 0 16rpx;
}
.input-box {
height: 80rpx;
background: #F5F6F7;
border-radius: 16rpx;
display: flex;
align-items: center;
margin-bottom: 16rpx;
.input-label {
flex-shrink: 0;
width: 164rpx;
padding-left: 32rpx;
}
}
.wallet-btn {
height: 96rpx;
background-image: linear-gradient(108deg, #FFB14E 11%, #FB8A32 96%);
box-shadow: 0 12rpx 12rpx 4rpx #fb8a321a;
border-radius: 48rpx;
display: flex;
align-items: center;
justify-content: center;
color: #FFFFFF;
font-size: 32rpx;
font-weight: 500;
margin-top: 36rpx;
}
}
}
}
\ No newline at end of file \ No newline at end of file
<!--pages/Login/components/EnableWallet/EnableWallet.wxml-->
<view class="wallet" catchtouchmove="noScroll" hidden="{{!show}}">
<view class="wallet-bg"></view>
<view class="wallet-content">
<view class="content-bg">
<glsx-image src="/login/wallet-bg.png"></glsx-image>
</view>
<view class="close" bindtap="closeWallet">
<glsx-image src="/login/wallet-close.png"></glsx-image>
</view>
<view class="content-box">
<view class="box-item" wx:for="{{stepDataArr}}" wx:key="index">
<view class="wallet-icon">
<glsx-image src="/login/{{item.icon}}.png"></glsx-image>
</view>
<view>
<view class="label">{{item.label}}</view>
<view class="tips">
{{item.tips}}
<text class="label" wx:if="{{item.pointsFlag}}">{{walletObj.currentScore}}</text>
</view>
</view>
</view>
<view class="text">请确认信息无误</view>
<view class="input-box">
<view class="input-label">姓名</view>
<input bindinput="input" data-target="name" maxlength="20" value="{{walletObj.name}}" type="text" placeholder="请输入"/>
</view>
<view class="input-box">
<view class="input-label">手机号</view>
<input bindinput="input" data-target="phone" maxlength="11" disabled value="{{walletObj.phone}}" type="text" placeholder="请输入"/>
</view>
<view class="wallet-btn" bindtap="confirm">一键开通</view>
</view>
</view>
</view>
<!-- 钱包开通成功 -->
<enable-success show="{{showEnableSuccess}}" bindconfirm="successConfirm"></enable-success>
\ No newline at end of file \ No newline at end of file
// components/glTextarea/glTextarea.js
import { haveEmoji, replaceEmoji } from '~/utils/emoji'
Component({
/**
* 组件的属性列表
*/
properties: {
maxlength: {
type: Number,
value: -1
},
customMaxLength: Boolean,
placeholder: String,
showWordLimit: Boolean,
disabled: Boolean,
value: String,
textStyle: String,
filterEmoji: {
type: Boolean,
value: true
}
},
/**
* 组件的初始数据
*/
data: {
edit: true,
value: null
},
/**
* 组件的方法列表
*/
methods: {
/**
* 打开文本编辑器
*/
openTextarea() {
if (this.data.disabled) return
this.setData({
edit: false,
textareaFocus: true
})
},
setValue(value) {
let { customMaxLength, maxlength } = this.data
if (this.properties.filterEmoji) {
if (haveEmoji(value)) value = replaceEmoji(value)
}
if (customMaxLength && maxlength != -1) value = value.substring(0, maxlength)
this.setData({ value })
return value
},
textareaInput(e) {
let { value } = e.detail
value = this.setValue(value)
this.triggerEvent('input', {
value
})
},
textareaBlur(e) {
let { value } = e.detail
this.setData({
edit: true
})
value = this.setValue(value)
this.triggerEvent('blur', {
value
})
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class='textarea-box {{maxlength>0&&showWordLimit?"showWordLimit":""}}'>
<block wx:if='{{edit}}'>
<text class='textarea' bindtap="openTextarea"
style="color:{{value?'#282829':'#B1B1B3'}}; {{textStyle}}">{{value||placeholder||'请输入'}}</text>
</block>
<block wx:else>
<textarea class='_textarea_' maxlength="{{customMaxLength?-1:maxlength}}" value='{{value}}'
bindinput='textareaInput' focus='{{textareaFocus}}' bindblur='textareaBlur' bindconfirm='textareaBlur'></textarea>
</block>
<block wx:if='{{maxlength>0&&showWordLimit}}'>
<view class='wordLimit'>
{{value.length||0}} / {{maxlength}}
</view>
</block>
</view>
\ No newline at end of file \ No newline at end of file
/* components/glTextarea/glTextarea.wxss */
.textarea-box {
width: 100%;
min-height: 120rpx;
position: relative;
height: 100%;
}
.textarea-box .textarea {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow-y: scroll;
line-height: 32rpx;
word-break: break-all;
}
._textarea_ {
width: 100%;
height: calc(100% - 40rpx);
}
.textarea-box.showWordLimit .textarea {
height: calc(100% - 40rpx);
}
.wordLimit {
position: absolute;
bottom: 0;
right: 0;
color: #999;
}
// components/GoodsAction/GoodsAction.js
import cartApi from '~/api/module/cart.js'
import NP from 'number-precision'
Component({
/**
* 组件的属性列表
*/
properties: {
hideShop: Boolean,
payDisabled: Boolean,
custom: Boolean,
stock: Boolean,
buyFlag: Boolean,
platformShop:Boolean
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
getViewInfo() {
wx.p.wxApi.getViewInfo(
'.goods-action-box',
res => {
this.triggerEvent('ready', res.height)
},
this
)
},
jump(e) {
wx.p.router.switchTab('/pages/tab/cart/index')
},
click(e) {
let { event } = e.currentTarget.dataset
this.triggerEvent('click', event)
},
getCartNum() {
let userInfo = wx.p.storage.get('userInfo')
let para = {
scoreSource: userInfo?.channelSource,
merchantId: userInfo?.merchantId
}
cartApi.getCartList(para).then(res => {
let cartNum = 0
res?.goodsList?.forEach(el => {
if (!el.flag) {
cartNum = NP.plus(cartNum, el.sellQty || 0)
}
})
this.setData({
cartNum
})
})
}
},
lifetimes: {
attached() {
this.getViewInfo()
let { custom } = this.data
if (!custom) {
this.getCartNum()
}
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="goods-action-box isFullSucreen">
<block wx:if="{{custom}}">
<slot></slot>
</block>
<block wx:else>
<view class="goods-action">
<view class="navigation-box">
<view class="item" wx:if="{{!hideShop}}" bindtap="jump">
<view v-if="{{true}}" class="goods-num">
<text>{{cartNum}}</text>
</view>
<view class="sprite-icon" >
<glsx-image src="/index/goods-cart.png"></glsx-image>
</view>
购物车
</view>
</view>
<view class="btn-box {{hideShop}}">
<view class="btn join text-center {{stock?'disabled':''}}" bindtap="click" data-event="join">
加入购物车
</view>
<view class="btn pay text-center {{payDisabled && hideShop?'disabled':''}} {{stock?'disabled':''}} {{buyFlag?'disabled':''}}" bindtap="click" data-event="pay">
立即兑换
</view>
</view>
</view>
</block>
</view>
\ No newline at end of file \ No newline at end of file
/* components/GoodsAction/GoodsAction.wxss */
.text-center {
display: flex;
align-items: center;
justify-content: center;
}
.goods-action-box {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #fff;
z-index: 9;
animation: show-goods-action .55s forwards;
}
@keyframes show-goods-action{
0%{
bottom: -100%;
}
100%{
bottom: 0;
}
}
.goods-action {
padding: 12rpx 24rpx;
display: flex;
align-items: center;
box-sizing: border-box;
height: 100rpx;
}
.isFullSucreen {
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
.navigation-box {
display: flex;
align-items: center;
font-size: 20rpx;
justify-content: space-between;
}
.navigation-box .item{
display: flex;
flex-direction: column;
align-items: center;
margin:0 14rpx;
position: relative;
}
.navigation-box .item .goods-num {
position: absolute;
top: -10rpx;
right: -16rpx;
height: 28rpx;
background: #F75454;
border: 1rpx solid #FFFFFF;
border-radius: 14rpx;
font-size: 18rpx;
color: #FFFFFF;
padding: 0 8rpx;
}
.navigation-box .sprite-icon{
width: 40rpx;
height: 40rpx;
}
.btn-box {
display: flex;
align-items: center;
margin-left: auto;
border-radius: 20rpx;
overflow: hidden;
font-weight: 500;
}
.btn-box .btn {
width: 304rpx;
height: 84rpx;
color: #fff;
font-size: 32rpx;
}
.btn-box .pay {
background-color: #FB8A32;
}
.btn-box .join {
color: #FB8A32;
background-color: #FEF2EA;
}
.btn-box.true .join{
display: none;
}
.btn-box.true .btn{
width: 588rpx;
background-color: var(--themeColor);
}
// components/navigationBar/navigationBar.js
Component({
/**
* 组件的属性列表
*/
properties: {
navStyle: String,
custom: Boolean,
showBack: Boolean,
pageTitle: {
type: String,
value: '',
observer(n) {
if (n) {
this.title = n
this.setPageTitle()
}
}
}
},
title: '',
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
setPageTitle() {
let thisPage = wx.p.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(),
currentPages = getCurrentPages(), {
showBack
} = this.data
if (showBack && currentPages.length > 1) this.setData({
SHOWBACK: true
})
let navigationBarHeight = height + ((top - statusBarHeight) * 2)
let navigationBarPadding = screenWidth - right
let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width * 2)
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.p.router.getPageInstance()
this.triggerEvent('navbarReady', {
height: navHeight,
statusBarHeight
})
this.setData({
showNavBar: true
})
thisPage.setData({
navHeight,
statusBarHeight
})
},
back() {
wx.p.router.back()
}
},
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;line-height:{{navigationBarHeight}}px;{{navStyle}}">
<block wx:if="{{!custom}}">
<view class="navigation-bar-box" wx:if="{{showNavBar}}" style="{{navigationBarStyle}}">
<block wx:if="{{SHOWBACK}}">
<view class="back " bindtap="back">
<mp-icon icon="back" color="#2C2C2C" size="{{12}}"></mp-icon>
</view>
</block>
<view class="navigation-bar-titleText" style="{{navigationBarTextWidth}}">
<slot/>
</view>
</view>
</block>
<block wx:else>
<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: #2D2D2E;
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: 0;
top: 50%;
transform: translateY(-50%);
width: 100rpx;
/* height: 34rpx; */
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.back .img {
width: 16rpx;
height: 34rpx;
}
\ No newline at end of file \ No newline at end of file
// tabWorkOrder/pages/createOrder/createOrderComponents/Popup/Popup.js
Component({
/**
* 组件的属性列表
*/
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
},
showCloseButton: {
type: Boolean,
value: false
},
showFooter: {
type: Boolean,
value: true
},
headerColor: {
type: String,
value: ''
},
showConfirm:{
type: Boolean,
value: true
},
bodyColor:{
type: String,
value: ''
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
noScroll() {},
hidePopup() {
this.setData({
show: false
})
wx.setPageStyle({
style: {
overflow: 'unset'
}
})
},
confirm() {
this.triggerEvent('confirm')
}
}
})
\ 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}}">
<view class="popup-bg" bindtap="hidePopup"></view>
<view class="popup-content {{close?'close':''}}" style="height:{{height}};background:{{bodyColor}}">
<block wx:if="{{title}}">
<view class="popup-title text-center" style="background:{{headerColor}}">{{title}}
<view class="popup-close" wx:if="{{showCloseButton}}" bindtap="hidePopup">
<mp-icon icon="close2" color="#B1B1B3" size="20"></mp-icon>
</view>
</view>
</block>
<view class="popup-slot {{title?'':'notitle' }}">
<slot></slot>
</view>
<view class="popup-footer isFullSucreen {{!showConfirm?'cancel-only':''}}" wx:if="{{showFooter}}">
<view class="cancel btn text-center" wx:if="{{only}}" bindtap="hidePopup">取消</view>
<view class="confirm {{only?'btn':'doubtn'}} text-center" wx:if="{{showConfirm}}" 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 */
@import "/assets/style/common.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;
border-radius: 20rpx 20rpx 0 0;
position: relative;
}
.popup-close {
position: absolute;
right: 40rpx;
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
}
.popup-slot {
height: calc(100% - 200rpx - var(--constantSafeAreaInsetBottom));
height: calc(100% - 200rpx - var(--envSafeAreaInsetBottom));
}
.popup-slot.notitle {
height: calc(100% - 158rpx - var(--constantSafeAreaInsetBottom));
height: calc(100% - 158rpx - var(--envSafeAreaInsetBottom));
}
.popup-footer {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 32rpx;
position: relative;
background-color: #fff;
z-index: 2;
}
.popup-footer.cancel-only{
padding: 0 !important;
}
.popup-footer .btn {
width: 330rpx;
height: 80rpx;
box-sizing: border-box;
border-radius: 20rpx;
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.cancel-only .cancel {
border-radius: 0;
width: 100%;
border-bottom: 0;
}
.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
import NP from "number-precision";
import cartApi from '~/api/module/cart.js'
Component({
/**
* 组件的属性列表
*/
properties: {
show: Boolean,
address: Array,
type: String,
goods: {
type: Object,
observer: function(n) {
this.setData({
detailInfo: JSON.parse(JSON.stringify(n))
}, () => {
this.setDefaultSku(n)
})
}
},
defaultAddress: Object,
defaultAds: String,
canPay:Boolean,
clickType: String
},
data: {
currentIndex: 0,
goodsNumber: 1,
showJfModal: false,
detailInfo: {}
},
/**
* 组件的方法列表
*/
methods: {
cancel() {
this.setData({
show: false
})
this.triggerEvent('cancelSku')
},
setDefaultSku(detailInfo) {
let specificationDetailList = detailInfo.platformGlGoodsSpecifications && detailInfo.platformGlGoodsSpecifications[0]
if (detailInfo?.specificationData) {
specificationDetailList = detailInfo?.platformGlGoodsSpecifications?.find(val => val.specificationData == detailInfo.specificationData)
}
let defaultGoods = specificationDetailList?.specificationData.split('&')
detailInfo.platformGlGoodsSpecificationList?.map(e => {
defaultGoods?.map(i => {
let [key, value] = i.split('-')
if (key == e.specificationName) {
e.platformSpecificationValueList.map(c => {
if (c.specificationValue == value) c.active = true
})
}
})
})
this.setData({
detailInfo,
['detailInfo.goodsStock']: specificationDetailList?.stock || detailInfo.goodsStock, // 多规格商品库存在每个规格组中
goodsNumber: detailInfo?.sellQty || 1
})
},
// 选择规格
choose(e) {
let { index, ind } = e.currentTarget.dataset
let { detailInfo } = this.data
let { platformGlGoodsSpecificationList, platformGlGoodsSpecifications } = detailInfo
let activeList = []
if (platformGlGoodsSpecificationList[index].platformSpecificationValueList[ind].active) return
platformGlGoodsSpecificationList[index].platformSpecificationValueList.map(i => (i.active = false))
platformGlGoodsSpecificationList[index].platformSpecificationValueList[ind].active = true
platformGlGoodsSpecificationList.map(i => {
i.platformSpecificationValueList.map(c => {
if (c.active) activeList.push(`${i.specificationName}-${c.specificationValue}`)
})
})
let specificationData = activeList.join('&')
let goodsStock
platformGlGoodsSpecifications?.map(val => {
if (val.specificationData == specificationData) {
goodsStock = val.stock
}
})
this.setData({
detailInfo,
['detailInfo.goodsStock']: goodsStock,
['detailInfo.specificationData']: specificationData
})
const thisPage = wx.p.router.getPageInstance()
thisPage.setData({
activeSku: specificationData,
goodsStock
})
},
changeCount(e) {
this.triggerEvent('getCount', e.detail)
this.setData({
goodsNumber: e.detail
})
},
toShowAddressModal() {
let thisPage = wx.p.router.getPageInstance()
thisPage.setData({
showAddress: true
})
},
intRemain(e) {
this.setData({
remain: e.detail.value
})
},
toCreatedOrder() {
let { clickType, remain, detailInfo, defaultAddress, goodsNumber } = this.data
const userInfo = wx.p.storage.get('userInfo')
if (!['pay', 'join', 'change'].includes(clickType)) {
return this.cancel()
}
if (clickType == 'change') {
this.cancel()
return this.triggerEvent('changeSku', {specificationData: detailInfo.specificationData, sellQty: goodsNumber || detailInfo.startQty})
}
console.log(detailInfo)
if (!detailInfo.goodsStock) return
detailInfo.sellQty = goodsNumber || detailInfo.sellQty
detailInfo?.platformGlGoodsSpecifications?.forEach(val => {
if (val.active) detailInfo.specificationData = val.specificationData
})
if (clickType == 'join') {
// 加入购物车
const PARAMS = {
goodsId: detailInfo.id,
sellQty: goodsNumber || detailInfo.startQty,
goodsSource: detailInfo.goodsSource,
scoreSource: userInfo?.channelSource,
specificationData: detailInfo?.specificationData,
merchantId: userInfo?.merchantId
}
wx.p.wxApi.showLoading()
cartApi.addToCart(PARAMS).then(res => {
wx.hideLoading()
wx.p.wxApi.showToast('加入购物车成功')
this.cancel()
this.triggerEvent('joinSuccess')
})
return
}
if(!defaultAddress.receiveName){
return wx.p.wxApi.showToast('请选择收货地址')
}
// 跳转到确认订单
let query = {
defaultAddress,
buyerMsg: remain,
goodsList: [{...detailInfo}],
}
wx.p.router.go('/packageIndex/pages/confirmOrder/index', query)
}
}
})
{
"component": true,
"usingComponents": {
"stepper": "/components/Stepper/Stepper"
}
}
\ No newline at end of file \ No newline at end of file
.sku-container {
position: fixed;
left: 0;
bottom: 0;
right: 0;
top: 0;
z-index: 9;
height: 100vh;
.sku-bg {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .6);
}
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
.container {
position: absolute;
width: 100%;
height: 80%;
box-sizing: border-box;
background: #FFFFFF;
border-radius: 20rpx 20rpx 0 0;
left: 0;
bottom: 0;
animation: show-sku-box .5s forwards;
z-index: 2;
padding: 44rpx 40rpx;
overflow: auto;
}
}
.goods-box {
.cover {
width: 180rpx;
height: 180rpx;
border-radius: 24rpx;
overflow: hidden;
flex-shrink: 0;
}
.right-box {
padding-left: 40rpx;
width: calc(100% - 220rpx);
.price-box {
font-weight: 700;
color: #FC5B32;
display: table-cell;
vertical-align: bottom;
text {
color: #FF6038;
font-size: 40rpx;
font-weight: 600;
margin-right: 4rpx;
}
.price {
font-size: 64rpx;
}
}
.stock {
font-weight: 400;
font-size: 22rpx;
color: #858A94;
margin: 10rpx 0 8rpx 0;
}
.selct-box {
font-weight: 400;
font-size: 22rpx;
color: #858A94;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
}
.sku-box {
.title {
font-weight: 500;
font-size: 28rpx;
color: #1B233D;
margin-top: 48rpx;
margin-bottom: 26rpx;
}
.sku-list {
.sku-title {
color: #2D2D2E;
font-weight: 500;
padding-top: 32rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.sku-item {
display: flex;
flex-wrap: wrap;
.item {
min-width: 112rpx;
box-sizing: border-box;
height: 52rpx;
display: flex;
align-items: center;
justify-content: center;
background: #F7F8FA;
padding: 0 20rpx;
margin: 20rpx 20rpx 0 0;
font-size: 26rpx;
color: #656566;
border: 2rpx solid #F7F8FA;
box-sizing: border-box;
border-radius: 12rpx;
&.active {
border-color: #FC5B32;
color: #FC5B32;
background-color: #fc5b320f;
}
}
}
.sku {
padding: 6rpx 20rpx;
background: #F7F8FA;
font-weight: 400;
font-size: 26rpx;
border-radius: 12rpx;
margin-right: 16rpx;
margin-bottom: 20rpx;
}
.sku_active {
background: #fc5b320f;
border: 2rpx solid #FC5B32;
color: #FC5B32;
}
.disabled{
background-color: #B1B1B3 !important;
color: #000000!important;
}
}
.flex-w {
display: flex;
flex-wrap: wrap;
}
}
.count-box {
margin-top: 32rpx;
.title {
font-size: 28rpx;
color: #2D2D2E;
font-weight: 500;
}
.right {
.tip {
font-weight: 400;
font-size: 20rpx;
color: #F13C3D;
}
.stepper {
margin-left: 16rpx;
}
}
}
.textarea-box {
margin-top: 48rpx;
.title {
font-size: 28rpx;
color: #2D2D2E;
font-weight: 500;
margin-bottom: 20rpx;
}
.pannel {
width: 100%;
box-sizing: border-box;
padding: 16rpx 20rpx;
height: 128rpx;
background: #F5F6FA;
border-radius: 16rpx;
.textarea-placeholder {
font-weight: 400;
font-size: 24rpx;
color: #9E9EA8;
}
.textArea {
height: 100%;
}
}
}
.adress-box {
margin-top: 52rpx;
.title {
font-size: 28rpx;
color: #2D2D2E;
font-weight: 500;
}
.content {
font-weight: 400;
font-size: 24rpx;
color: #333435;
width: 490rpx;
text-align: right;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-right: 8rpx;
}
.emptyText {
color: #858A94;
}
.pos {
width: 36rpx;
height: 36rpx;
}
}
.btn-wrap {
position: fixed;
left: 0;
right: 0;
bottom: 0;
box-sizing: border-box;
padding: 8rpx 40rpx 68rpx;
background: white;
z-index: 5;
.btn {
width: 100%;
height: 84rpx;
background: #FB8A32;
border-radius: 20rpx;
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;
}
.disabled{
background: #FB8A324C;
}
}
.flex_sc {
display: flex;
align-items: center;
}
.flex_cc {
display: flex;
align-items: center;
justify-content: center;
}
.flex_scb {
display: flex;
align-items: center;
justify-content: space-between;
}
\ No newline at end of file \ No newline at end of file
<!-- <van-popup show="{{ show }}" bind:click-overlay="cancel" custom-class="popclass" position="bottom" custom-style="height: 90%"></van-popup> -->
<view class="sku-container" hidden="{{!show}}">
<view class="sku-bg" bindtap="cancel"></view>
<view class="container">
<view class="goods-box flex_sc">
<view class="cover">
<glsx-image class="cover" src="{{detailInfo.goodsSource == 2 ? detailInfo.goodsImage : detailInfo.imageResponses[0].imgUrl}}" />
</view>
<view class="right-box">
<view class="price-box">
<text class="price">{{detailInfo.redeemPoints}}</text><text>积分</text>
</view>
<view wx:if="{{detailInfo.goodsStock}}" class="stock">有货(库存{{detailInfo.goodsStock}})</view>
<view wx:else class="stock">暂无存货</view>
<block>
<view wx:if="{{detailInfo.goodsSource == 1}}" class="selct-box">已选:{{goodsNumber}}{{detailInfo.goodsUnit}}</view>
<view wx:if="{{detailInfo.specificationData}}" class="selct-box">已选:{{detailInfo.specificationData}}</view>
</block>
</view>
</view>
<view class="sku-box">
<block wx:if="{{detailInfo.goodsSource == 1}}">
<view class="title">规格</view>
<view class="sku-list flex-w">
<block wx:for="{{detailInfo.specificationResponses}}" wx:key="index">
<view class="sku flex_cc sku_active">{{item.specName}}:{{item.specValue}}</view>
</block>
</view>
</block>
<view class="sku-list" wx:else>
<block wx:for="{{detailInfo.platformGlGoodsSpecificationList}}" wx:key="index">
<view class="sku-title">{{item.specificationName}}</view>
<view class="sku-item">
<block wx:for="{{item.platformSpecificationValueList}}" wx:key="ind" wx:for-index="ind" wx:for-item="i">
<view class="item text-center {{i.active?'active':''}} {{i.stock ===0?'disabled':''}}" bindtap="choose" data-index="{{index}}"
data-ind="{{ind}}">{{i.specificationValue}}</view>
</block>
</view>
<!-- <view class="sku flex_cc {{item.active ? 'sku_active' : ''}} {{i.stock ===0?'disabled':''}}" bindtap="choose" data-target="{{item}}">{{item.specificationData}}</view> -->
</block>
</view>
</view>
<view class="count-box flex_scb">
<view class="title">数量</view>
<view class="right flex_sc">
<!-- <view class="tip">至少购买{{goods.startQty}}{{goods.goodsUnit}}</view> -->
<view class="stepper">
<stepper count="{{goodsNumber}}" max="{{detailInfo.goodsStock || 1}}" catchchange="changeCount"></stepper>
</view>
</view>
</view>
<view class="textarea-box" wx:if="{{clickType != 'join' && clickType != 'change'}}">
<view class="title">订单备注</view>
<view class="pannel">
<textarea bindinput="intRemain" maxlength="100" class="textArea" placeholder="请输入备注信息(选填)" placeholder-class="textarea-placeholder"></textarea>
</view>
</view>
<view bind:tap="toShowAddressModal" class="adress-box flex_scb" wx:if="{{clickType != 'join' && clickType != 'change'}}">
<view class="title">收货地址</view>
<view class="right flex_scb">
<view class="content {{defaultAds?'':'emptyText'}}">{{defaultAds || '请选择'}}</view>
<mp-icon icon="arrow" bind:tap="showSkuModal" color="#B1B1B3" size="{{10}}"></mp-icon>
</view>
</view>
<view class="btn-wrap flex_cc">
<view bind:tap="toCreatedOrder" class="btn flex_cc {{!detailInfo.goodsStock ? 'disabled' : ''}}">确认</view>
</view>
<view style="height:290rpx"></view>
</view>
</view>
// components/Stepper/Stepper.js
Component({
/**
* 组件的属性列表
*/
properties: {
count: Number,
min: {
type: Number,
value: 1
},
max: {
type: Number,
value: 99,
observer(n) {
if (n && this.data.count > n) {
this.setData({ count: n })
this.triggerEvent('change', Number(n))
}
}
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
input(e) {
let { value } = e.detail
let {
max,
} = this.data
if (value > max) value = max
this.setData({ count: value })
},
tap() { },
blur(e) {
let { value } = e.detail
let {
min,
} = this.data
if (value < min) value = min
this.setData({ count: value })
this.triggerEvent('change', Number(value))
},
change(e) {
let {
add
} = e.currentTarget.dataset
let num = add ? 1 : -1
let {
count,
min,
max
} = this.data
if (count == min && !add) return
if (count == max && add) return
count += num
this.triggerEvent('change', Number(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
<view class="stepper-box">
<view class="minus count-box text-center {{count == min?'opacity':''}}" catchtap="change"></view>
<input class="num text-center" type="number" catchinput="input" value="{{count}}" catchblur="blur" catchtap="tap" />
<view class="add count-box text-center {{count == max?'opacity':''}}" catchtap="change" data-add>
</view>
</view>
\ No newline at end of file \ No newline at end of file
/* components/Stepper/Stepper.wxss */
@import "/assets/style/common.wxss";
.stepper-box {
display: flex;
align-items: center;
}
.stepper-box .count-box {
width: 52rpx;
height: 52rpx;
background: #F0F0F0;
margin-left: 7rpx;
font-size: 26rpx;
text-align: center;
color: #323233;
font-weight: normal;
position: relative;
}
.stepper-box .count-box.opacity::after ,.stepper-box .count-box.opacity::before{
opacity: .25;
}
.stepper-box .minus {
border-radius: 7rpx 0 0 7rpx;
background: transparent;
}
.stepper-box .num {
width: 72rpx;
box-sizing: border-box;
padding: 0 4rpx;
border-radius: 8rpx;
font-size: 26rpx;
height: 48rpx;
background: #F0F0F0;
text-align: center;
}
.stepper-box .add {
border-radius: 0 7rpx 7rpx 0;
background: transparent;
}
.stepper-box .add::before,
.stepper-box .add::after,
.stepper-box .minus::after {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
content: '';
background-color: #2C2C2C;
border-radius: 2rpx;
}
.stepper-box .add::before,.stepper-box .minus::after {
width: 25rpx;
height: 2rpx;
}
.stepper-box .add::after{
width: 2rpx;
height: 25rpx;
}
\ No newline at end of file \ No newline at end of file
// components/Tab/Tab.js
Component({
/**
* 组件的属性列表
*/
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,
item
} = e.currentTarget.dataset
this.setData({
count,
to: `to-${count}`
})
this.triggerEvent('click', count)
this.triggerEvent('change', {count,item})
},
}
})
\ 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||count==item.code?'active':''}}" bindtap="click" data-count="{{index}}" data-item="{{item}}" id="to-{{index}}" >
<view class="text" >{{item.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||count==item.code?'active':''}}" bindtap="click" data-count="{{index}}" data-item="{{item}}">
<view class="text text-center">{{item.text||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 "/assets/style/common.wxss";
.tab-box {
display: flex;
width: 100%;
height: 92rpx;
box-sizing: border-box;
background: #fff;
}
.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: #1B233D;
justify-content: center;
font-size: 30rpx;
/* 添加以下属性防止文本换行 */
white-space: nowrap;
min-width: 100%;
transition: all 0.25s;
}
.left .text{
justify-content: flex-start;
}
.flex .tab .text {
padding: 0;
}
.tab.active .text {
font-weight: 600;
transition: all .25s;
color:#1B233D;
/* 确保激活状态下文本不会换行 */
white-space: nowrap;
}
.tab .line {
width: 48rpx;
height: 8rpx;
background: var(--themeColor);
border-radius: 6rpx;
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
/*可视化地呈现时间流信息*/
Component({
properties: {
// 时间轴节点数据
nodes: {
type: Array,
value: [],
observer(newVal) {
this.formatContent(newVal);
},
},
},
data: {
timeLineNodes: [],
},
methods: {
formatContent(nodes) {
nodes.forEach((item) => {
if (item.type == "special") {
item.content = [{ type: "text", txt: item.content }];
} else {
item.content = this.parsePhone(item.content);
}
});
this.setData({
timeLineNodes: nodes,
});
},
// 把原始文本切成 text | phone 两种节点
parsePhone(str) {
if(!str){
return [];
}
const phoneReg = /(1[3-9]\d{9}|0\d{2,3}[-]?\d{7,8})/g; // 简易手机号正则
let lastIndex = 0;
const res = [];
let match;
while ((match = phoneReg.exec(str)) !== null) {
// 1. match 之前的纯文本
if (match.index > lastIndex) {
res.push({ type: "text", txt: str.slice(lastIndex, match.index) });
}
// 2. 手机号本身
res.push({ type: "phone", txt: match[0] });
lastIndex = match.index + match[0].length;
}
// 3. 尾部剩余文本
if (lastIndex < str.length) {
res.push({ type: "text", txt: str.slice(lastIndex) });
}
return res;
},
// 拨打电话
makePhoneCall(e) {
const phone = e.currentTarget.dataset.phone;
if (phone) {
wx.makePhoneCall({
phoneNumber: phone,
});
}
},
},
});
{
"component": true,
"usingComponents": {
"mp-html":"/components/mp-html/index"
}
}
\ No newline at end of file \ No newline at end of file
/* 时间轴容器 */
.timeline-container {
// padding: 20rpx 0;
overflow-y: auto;
}
/* 时间轴节点 */
.timeline-node {
position: relative;
padding-bottom: 32rpx;
display: flex;
&:last-child {
padding-bottom: 0;
}
}
/* 时间轴节点点容器 */
.timeline-node__dot-wrapper {
width: 36rpx;
display: flex;
justify-content: center;
align-items: flex-start;
flex-shrink: 0;
padding-top: 6rpx;
}
/* 时间轴节点点 */
.timeline-node__dot {
width: 20rpx;
height: 20rpx;
background-color: #e8e8ea;
border-radius: 50%;
z-index: 1;
/* 激活状态的节点点 */
&.timeline-node__dot--special-small-active,
//组合容错
&.timeline-node__dot--special-active-small,
&.timeline-node__dot--small-active-special,
&.timeline-node__dot--small-special-active,
&.timeline-node__dot--active-small-special,
&.timeline-node__dot--active-special-small,
&.timeline-node__dot--special-active,
&.timeline-node__dot--active-special,
&.timeline-node__dot--special-normal-active,
&.timeline-node__dot--special-active-normal,
&.timeline-node__dot--small-active,
&.timeline-node__dot--active-small,
&.timeline-node__dot--normal-active,
&.timeline-node__dot--active {
background-color: var(--btnColor);
}
/* 小型节点点 */
&.timeline-node__dot--special-small-active,
//组合容错
&.timeline-node__dot--special-active-small,
&.timeline-node__dot--small-active-special,
&.timeline-node__dot--small-special-active,
&.timeline-node__dot--active-small-special,
&.timeline-node__dot--active-special-small,
&.timeline-node__dot--special-active,
&.timeline-node__dot--active-special,
&.timeline-node__dot--special-normal-active,
&.timeline-node__dot--special-active-normal,
&.timeline-node__dot--small-active,
&.timeline-node__dot--active-small,
&.timeline-node__dot--special,
&.timeline-node__dot--small {
width: 12rpx;
height: 12rpx;
}
}
/* 时间轴连接线 */
.timeline-node__line {
position: absolute;
top: 18rpx;
left: 18rpx;
height: calc(100% - 16rpx);
border-left: 1px solid #e8e8ea;
z-index: 0;
}
/* 时间轴内容 */
.timeline-node__content {
flex: 1;
padding-left: 20rpx;
color: #b1b1b3;
}
.timeline-node__content--special,
.timeline-node__content--special-normal,
.timeline-node__content--special-normal-active,
.timeline-node__content--special-small,
.timeline-node__content--special-active,
.timeline-node__content--special-small-active,
.timeline-node__content--special-active-small {
.timeline-node__title,
.timeline-node__tip {
font-weight: 400;
font-size: 24rpx;
}
.timeline-node__title {
color: #282829;
}
.timeline-node__tip {
color: #666666;
}
}
/* 时间轴头部 */
.timeline-node__header {
display: flex;
margin-bottom: 8rpx;
align-items: center;
gap: 20rpx;
}
/* 时间轴标题 */
.timeline-node__title {
font-weight: 500;
font-size: 32rpx;
margin-bottom: 8rpx;
line-height: 1.4;
}
/* 时间轴时间 */
.timeline-node__time {
font-weight: 400;
font-size: 24rpx;
line-height: 1.4;
}
/* 时间轴提示信息 */
.timeline-node__tip {
font-weight: 400;
font-size: 24rpx;
line-height: 1.5;
.content {
white-space: pre-wrap;
.phone {
color: #fb8a32;
}
}
}
.timeline-node__content--active,
.timeline-node__content--active-small,
.timeline-node__content--active-special {
.timeline-node__title {
color: #282829;
}
.timeline-node__time {
color: #909399;
}
.timeline-node__tip {
color: #656566;
}
}
.phone-numbers {
margin-top: 8rpx;
}
.phone-number {
display: inline-block;
margin-right: 16rpx;
margin-top: 8rpx;
}
.phone-call-text {
color: #fff;
font-size: 24rpx;
background-color: var(--btnColor);
padding: 4rpx 12rpx;
border-radius: 24rpx;
}
<!-- 时间轴组件 -->
<view class="timeline-container">
<view wx:for="{{timeLineNodes}}" wx:key="index" class="timeline-node">
<!-- 时间轴节点 -->
<view class="timeline-node__dot-wrapper">
<!-- 使用预处理的样式类 -->
<view class="timeline-node__dot timeline-node__dot--{{item.type}}"></view>
</view>
<!-- 时间轴连接线 -->
<view wx:if="{{index !== nodes.length - 1}}" class="timeline-node__line"></view>
<!-- 时间轴内容 -->
<view class="timeline-node__content timeline-node__content--{{item.type}} ">
<view class="timeline-node__header">
<view wx:if="{{item.statusDesc}}" class="timeline-node__title">{{item.statusDesc}}</view>
<view wx:if="{{item.operateTime}}" class="timeline-node__time">{{item.operateTime}}</view>
</view>
<view class="timeline-node__tip">
<view class="content">
<block wx:for="{{item.content}}" wx:key="index" wx:for-item="content">
<block wx:if="{{content.type==='text'}}">{{content.txt}}</block>
<label wx:elif="{{content.type==='phone'}}"
catchtap="makePhoneCall"
data-phone="{{content.txt}}"
class="phone">{{content.txt}}</label>
</block>
</view>
</view>
</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
// component/test.js
Component({
properties: {
chargeInfo: Object
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
toDetail() {
let {
chargeInfo
} = this.data
let param = {
brandName: chargeInfo.brandName,
supplier: chargeInfo.supplier,
icon: chargeInfo.icon
}
wx.p.router.go('/packageEquity/pages/commodity/chargeDetail/chargeDetail', {
param,
notIntercept: true
})
},
toDetailPage(e) {
let {
item
} = e.currentTarget.dataset
let {
chargeInfo
} = this.data
let param = {
brandName: chargeInfo.brandName,
supplier: chargeInfo.supplier,
id: item.id,
productName: item.productName,
icon: chargeInfo.icon
}
wx.p.router.go('/packageEquity/pages/commodity/chargeDetail/chargeDetail', {
param,
notIntercept: true
})
}
}
})
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!