Commit c9510e86 by 杨北旺

提交

1 parent d86580c0
Showing 154 changed files with 4281 additions and 0 deletions
project.private.config.json
project.config.json
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 = true
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.170: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
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
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();
},
};
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
import api from '../request/http'
module.exports = {
getServiceCode(data) {
return api.fetch('dracIm.api.entmicro.findMiniProgramIm', data)
},
/**智能外呼-联系人 */
findByActivityIdAndPhone(data) {
return api.fetch('dracIm.api.entmicro.findByActivityIdAndPhone', data)
}
}
\ 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 = {
/**获取商户小程序首页配置 */
getHomeConfig(data) {
return api.post({
method: `scrm.api.shopmall.weapp.homeConfig.getByMerchant`,
...data
})
},
/**查询当前商户的分类列表 */
getClassifyList(data) {
return api.post({
method: `scrm.api.shopmall.classify.weapp.listByMerchantId`,
...data
})
},
/** 分页查询活动 */
getActivityList(data) {
return api.post({
method: 'scrm.api.shopmall.weapp.activity.page',
pageSize: 10,
...data
})
},
}
\ 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 entmicroApi from './entmicro'
module.exports = {
wechatApi,
userApi,
homeApi,
discoveryApi,
shopmallApi,
mineApi,
systemApi,
couponsApi,
equityApi,
common,
entmicroApi
}
\ 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
})
},
/**获取当前用户的收货地址列表 */
getUserAddressList(data) {
return api.post({
method: `scrm.api.carlife.weapp.userAddress.list`,
...data
})
},
/**根据ID获取用户收货地址 */
getUserAddress(data) {
return api.post({
method: `scrm.api.carlife.weapp.userAddress.getById`,
...data
})
},
/** 新增用户收货地址 */
addUserAddress(data) {
return api.post({
method: `scrm.api.carlife.weapp.userAddress.add`,
...data
})
},
/**编辑用户收货地址 */
updateUserAddress(data) {
return api.post({
method: `scrm.api.carlife.weapp.userAddress.update`,
...data
})
},
/** 更改为默认收货地址 */
setUserAddressDefault(data) {
return api.post({
method: `scrm.api.carlife.weapp.userAddress.updateDefault`,
...data
})
},
/** 删除用户收货地址 */
delUserAddress(data) {
return api.post({
method: `scrm.api.carlife.weapp.userAddress.delete`,
...data
})
},
/** 获取用户默认收货地址 */
getUserAddressDefault() {
return api.fetch('scrm.api.carlife.weapp.userAddress.getDefault')
},
/**. 分页查询订单 */
getOrderList(data) {
return api.post({
method: `scrm.api.shopmall.weapp.order.page`,
pageSize: 99999,
...data
})
},
/**获取订单状态数量 */
getOrderNumberList(data) {
return api.post({
method: 'scrm.api.shopmall.weapp.order.statis',
...data
})
}
}
\ 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(orderCode) {
return api.post({
method: `scrm.api.shopmall.weapp.order.detail`,
orderCode
})
},
/**获取订单的售后详情 */
getOrderRefundDetail(orderCode) {
return api.post({
method: `scrm.api.shopmall.weapp.orderRefund.detail`,
orderCode
})
},
/**活动详情 */
getActivityDetail(id) {
return api.fetch('scrm.api.shopmall.weapp.activity.detail', {
id
})
},
/** 根据商品ID获取商品 */
getGoodsDetail(id) {
return api.fetch('scrm.api.shopmall.weapp.goods.getById.HMD', {
id,
viewAmount: true
})
},
/** 获取商品关联优惠券列表 */
getGoodscouponList(data) {
return api.fetch('scrm.api.coupon.seahorse.knife.goods.list', data)
},
/** 领取商品详情优惠券 */
getCoupon(data) {
return api.fetch('scrm.api.coupon.customer.receive', data)
},
/**根据规格值组合获取规格组合库存及零售价 */
getGoodsSpecificationExtra(data) {
return api.post({
method: `scrm.api.shopmall.weapp.goods.getGoodsSpecificationExtra`,
...data
})
},
/** 小程序端根据优惠券id查询可使用商品列表(分页) */
getCouponGoodsPage(data) {
data.pageSize = 8
return api.post({
method: 'scrm.app.shopmall.coupon.goods.page',
...data
})
},
//取消付款
cancelPay(orderCode) {
return api.fetch('scrm.api.shopmall.weapp.order.cancelPay', {
orderCode
})
},
/** 申请售后 */
afterSale(data) {
return api.fetch('scrm.api.shopmall.weapp.orderRefund.apply', data)
},
//申请售后待审核的订单取消售后
cancelOrder(orderCode) {
return api.fetch('scrm.api.shopmall.weapp.orderRefund.cancel', {
orderCode
})
},
/** 为售后添加退货快递信息 */
addDelivery(data) {
return api.post({
method: `scrm.api.shopmall.weapp.orderRefund.addDelivery`,
...data
})
},
requestSubscribeMessage() {
return api.fetch('scrm.api.shopmall.weapp.order.listSubscribeMsgTemplateIds')
},
/** 确认收货 */
confirmReceipt(orderCode) {
return api.post({
method: `scrm.api.shopmall.weapp.order.confirmReceipt`,
orderCode
})
},
/**分类列表
*
*/
getMerchantClassify(data) {
return api.post({
method: `scrm.api.shopmall.classify.page.curMerchant`,
pageSize: 9999,
currentPage: 1,
...data
})
},
/**分类商品 */
getMerchantClassifyGoods(data) {
return api.post({
method: `scrm.api.shopmall.classify.getById`,
pageSize: 10,
currentPage: 1,
...data
})
},
/** 获取活动分享链接 */
getActivitylink(id) {
return api.post({
method: 'scrm.api.shopmall.activity.get.shared',
id
})
},
/** 获取商品分享链接 */
getGoodslink(id) {
return api.post({
method: 'scrm.api.shopmall.goods.get.shared',
id
})
},
}
\ 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-hmd'
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 getImageVersion = async () => {
const accountInfo = await getMockData()
return accountInfo?.version || Date.now()
}
module.exports={
getImageVersion,
getMockData
}
\ No newline at end of file
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.login', {
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
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 sign from './sign.js'
import {
defaultMerchantId,
secretKey,
pathEnum,
domain,
} from '../env/index'
/**接口 */
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)
}
request(RequestMethods, params, returnAll) {
return new Promise((resolve, reject) => {
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 = this.getData(params)
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('&')}`
return wx.p.router.redirectTo('/pages/loading/loading', {
url: `/${currentRoute}`
})
} else {
if (code == '0') {
resolve(data.data)
} else {
wx.showToast({
title: message || '系统异常',
icon: 'none'
})
}
}
},
fail(error) {
wx.hideLoading()
console.error(`接口异常:`, error)
wx.showToast({
title: typeof error == 'string' ? error : JSON.stringify(error) || '系统异常',
icon: 'error'
})
reject(error)
},
complete() {
wx.stopPullDownRefresh()
wx.hideNavigationBarLoading()
}
})
})
}
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
return sign(params, secret, noSignAttr)
}
getRopProject(method) {
const projectName = method.split('.')[2]
return projectName
}
}
export default new Request()
\ No newline at end of file
import {sha1,qs} from '../../lib/index'
const sign = (params, secret, noSignAttr = []) => {
delete params.sign
var objStr = qs.stringify(params, {
arrayFormat: 'indices',
allowDots: true,
encodeValuesOnly: true
})
var objVal = objStr.split('&')
var realObj = {}
objVal.forEach(item => {
const idx = item.indexOf('=')
realObj[item.split('=')[0]] = decodeURIComponent(item.slice(idx + 1))
})
const keys = Object.keys(realObj).sort()
var str = []
var obj = null
for (const key in realObj) {
obj = realObj[key]
if (obj === null) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
realObj[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + realObj[e])
})
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj
}
export default sign
\ No newline at end of file
// app.js
// 初始化sentry
import sentryInit from "~/utils/sentryConfig/sentryInit";
sentryInit();
import api from "./api/index";
import { router } 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,
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/tab/index/index",
"pages/tab/equity/index",
"pages/tab/mall/index",
"pages/tab/mine/index",
"pages/tab/select/index",
"pages/webView/webView",
"pages/Login/Login"
],
"requiredPrivateInfos": [
"getLocation"
],
"lazyCodeLoading": "requiredComponents",
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle": "black"
},
"tabBar": {
"color": "#999999",
"selectedColor": "#3772EC",
"backgroundColor": "#FFFFFF",
"borderStyle": "white",
"list": [{
"pagePath": "pages/tab/index/index",
"text": "首页",
"iconPath": "assets/images/home.png",
"selectedIconPath": "assets/images/home_active.png"
},
{
"pagePath": "pages/tab/equity/index",
"text": "省钱",
"iconPath": "assets/images/money.png",
"selectedIconPath": "assets/images/money_active.png"
},
{
"pagePath": "pages/tab/mall/index",
"text": "甄选",
"iconPath": "assets/images/strategy.png",
"selectedIconPath": "assets/images/strategy_active.png"
},
{
"pagePath": "pages/tab/select/index",
"text": "攻略",
"iconPath": "assets/images/select.png",
"selectedIconPath": "assets/images/select_active.png"
},
{
"pagePath": "pages/tab/mine/index",
"text": "我的",
"iconPath": "assets/images/mine.png",
"selectedIconPath": "assets/images/mine_active.png"
}
]
},
"subpackages": [],
"usingComponents": {
"navigation-bar": "/components/NavigationBar/NavigationBar",
"glsx-image": "/components/image/index",
"authorize": "/components/Authorize/Authorize",
"popup": "/components/Popup/Popup",
"goods-action": "/components/GoodsAction/GoodsAction"
},
"style": "v2",
"resolveAlias": {
"~/*": "/*"
},
"sitemapLocation": "sitemap.json",
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"plugins": {
"authorization-plugin": {
"version": "1.0.2",
"provider": "wxe10067a63c1856ac"
}
},
"__usePrivacyCheck__": true
}
\ No newline at end of file
@import "assets/style/common.wxss";
page {
background-color: #F9F7F7 !important;
color: #282829;
font-size: 28rpx;
--themeColor: #8A303A;
--btnColor: #8A303A;
--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;
}
\ 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;
}
.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
// 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
{
"component": true,
"usingComponents": {}
}
\ 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
/* 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
// 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
<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
/* 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
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) {
let { url } = e.currentTarget.dataset
if (url == 'home') wx.p.router.goHome()
else wx.p.router.go('/packageMall/pages/shoppingCart/shoppingCart')
},
click(e) {
let { event } = e.currentTarget.dataset
this.triggerEvent('click', event)
}
},
lifetimes: {
attached() {
this.getViewInfo()
}
}
})
{
"component": true,
"usingComponents": {}
}
\ 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" bindtap="jump" data-url="home">
<view class="sprite-icon">
<glsx-image src="mall/goods-home.png"></glsx-image>
</view>
首页
</view>
<view class="item" wx:if="{{!hideShop}}" bindtap="jump">
<view class="sprite-icon" >
<glsx-image src="mall/goods-shopping.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
/* 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: 10rpx var(--margin);
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;
}
.navigation-box .sprite-icon{
width: 40rpx;
height: 40rpx;
}
.btn-box {
display: flex;
align-items: center;
margin-left: auto;
border-radius: var(--borderRadius);
overflow: hidden;
}
.btn-box .btn {
width: 258rpx;
height: 80rpx;
color: #fff;
font-size: 28rpx;
}
.btn-box .pay {
background-color: var(--btnColor);
}
.btn-box .join {
background-color: #FDC23E;
}
.btn-box.true .join{
display: none;
}
.btn-box.true .btn{
width: 588rpx;
background-color: var(--themeColor);
}
.btn-box .pay.disabled{
background-color: #B1B1B3 !important;
}
.btn-box .disabled{
background-color: #B1B1B3 !important;
}
\ No newline at end of file
// 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
{
"component": true,
"usingComponents": {}
}
\ 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}}">
<block wx:if="{{SHOWBACK}}">
<view class="back " bindtap="back">
<image class="img" src="./images/icon-back.png" />
</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
/* components/navigationBar/navigationBar.wxss */
.navigation-bar {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
background-color: #F9F7F7;
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: 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
// 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
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
noScroll() {},
hidePopup() {
this.setData({
show: false
})
},
confirm() {
this.triggerEvent('confirm')
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ 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 {{title?'':'notitle' }}">
<slot></slot>
</view>
<view class="popup-footer 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 isFullSucreen" wx:else>
<view class="confirm doubtn text-center" bindtap="confirm">确认</view>
</view>
</view>
</view>
\ 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;
}
.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 .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
// 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
} = e.currentTarget.dataset
this.setData({
count,
to: `to-${count}`
})
this.triggerEvent('click', count)
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ 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
/* components/Tab/Tab.wxss */
@import "/assets/style/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
// 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
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="charge_element_wrapper flex_sc" catchtap="toDetail">
<image webp class="charge_banner" src="{{chargeInfo.bgurl}}" />
<view class="charge_content">
<view class="charge_title_wrapper">
<view class="flex_sc">
<view class="charge_title_text">{{chargeInfo.brandName}}</view>
<view class="charge_sign flex_ccc">直充</view>
</view>
<view class="chage_more">查看更多</view>
</view>
<view class="charge_scroll_wrap">
<scroll-view scroll-x="{{true}}" style="height:124rpx">
<block wx:for="{{chargeInfo.couponsGoodsList}}" wx:key="index">
<view class="charge_package_element" data-item="{{item}}" catchtap="toDetailPage">
<glsx-image webp class="charge_cou" src="equity/scrm_quan_bg.png" />
<view class="charge_name hide-text">{{item.productName}}</view>
<view class="charge_price_left">
<view class="charge_min_price">¥</view>
<view class="chage_max_price">{{item.salesPrice}}</view>
<view class="charge_price_right">¥{{item.lineationPrice}}</view>
</view>
</view>
</block>
</scroll-view>
</view>
</view>
</view>
\ No newline at end of file
/*直充元素样式*/
.charge_element_wrapper {
background: #FFFFFF;
height: 244rpx;
box-shadow: 0px 4rpx 16rpx 0px rgba(239, 240, 242, 1);
border-radius: 16rpx;
border: 1rpx solid #EFF0F2;
margin-bottom: 20rpx;
}
.charge_banner {
width: 168rpx;
height: 100%;
background: linear-gradient(90deg, #FFF1DB 0%, #FBE6E6 100%);
border-radius: 16rpx 0px 0rpx 16rpx;
}
.charge_content {
width: calc(100% - 168rpx);
height: 100%;
box-sizing: border-box;
padding-left: 20rpx;
}
.charge_title_wrapper {
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 38rpx 30rpx 22rpx 0;
}
.charge_title_text {
font-size: 28rpx;
font-weight: 600;
color: #282829;
}
.charge_sign {
width: 54rpx;
height: 30rpx;
background: linear-gradient(143deg, #FFEAD1 0%, #E6BB8A 100%);
border-radius: 4rpx;
font-size: 20rpx;
font-weight: 400;
color: #000000;
margin-left: 28rpx;
}
.chage_more {
font-size: 20rpx;
font-weight: 400;
color: #717171;
}
.charge_scroll_wrap {
/* width: 100%; */
overflow: hidden;
vertical-align: top;
white-space: nowrap;
height: 124rpx;
}
.charge_package_element {
display: inline-block;
width: 256rpx;
height: 124rpx;
position: relative;
margin-right: 20rpx;
}
.charge_cou {
width: 256rpx;
height: 124rpx;
}
.charge_name {
position: absolute;
left: 20rpx;
top: 12rpx;
width: 168rpx;
font-size: 24rpx;
font-weight: 400;
color: #2D2D2E;
}
.charge_price_left {
display: flex;
align-items: flex-end;
position: absolute;
left: 20rpx;
bottom: 16rpx;
}
.charge_min_price {
font-size: 20rpx;
font-weight: 400;
margin-right: 4rpx;
line-height: 20rpx;
}
.chage_max_price{
font-size: 33rpx;
font-weight: 600;
color: #282829;
line-height: 33rpx;
}
.charge_price_right {
font-size: 20rpx;
font-weight: 400;
color: #282829;
text-decoration: line-through;
margin-left: 10rpx;
line-height: 20rpx;
}
.hide-text {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.flex_sc {
display: flex;
align-items: center;
}
.flex_ccc {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
\ No newline at end of file
Component({
properties: {
businessInfo: Object,
address: Object
},
data: {
curErrorIndex: -1,
},
/**
* 组件的方法列表
*/
methods: {
toDetail() {
const {
businessInfo,
address
} = this.data
let param = {
supplier: businessInfo.supplier,
brandName: businessInfo.brandName,
lat: address.location.lat,
lng: address.location.lng,
}
wx.p.router.go('/packageEquity/pages/commodity/detail/detail', {
param,
notIntercept: true
})
},
toDetailPage(e) {
const {
item
} = e.currentTarget.dataset
const {
businessInfo,
address
} = this.data
let param = {
supplier: businessInfo.supplier,
brandName: businessInfo.brandName,
lat: address.location.lat,
lng: address.location.lng,
id: item.id
}
wx.p.router.go('/packageEquity/pages/commodity/detail/detail', {
param,
notIntercept: true
})
},
// 打开地图
openMap() {
const {
businessInfo
} = this.data
wx.openLocation({
latitude: parseFloat(businessInfo.lat),
longitude: parseFloat(businessInfo.lng),
address: businessInfo.localAddress
})
},
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="element_wrapper" catchtap="toDetail">
<view class="header_wrap">
<image webp class="header_icon" src="{{businessInfo.icon}}" />
<view class="header_desc">
<view class="desc_title_wrap">
<view class="desc_title hide-text">{{businessInfo.localShopName}}</view>
<view class="latest_sign">最近</view>
</view>
<view class="desc_address">
<view class="address_text hide-text">{{businessInfo.localAddress}}</view>
<view class="flex_sc" catchtap="openMap">
<view class="address_line"></view>
<view class="address_num">{{businessInfo.localAddressDistance}}km</view>
<glsx-image webp class="address_icon" src="equity/scrm_loca_icon_new.png" />
</view>
</view>
</view>
</view>
<view class="scroll_wrap">
<scroll-view scroll-x="{{true}}" style="height:216rpx">
<block wx:for="{{businessInfo.couponsGoodsList}}" wx:key="index">
<view class="scroll_item" data-item="{{item}}" catchtap="toDetailPage">
<view wx:if="{{!item.noMemberPrice}}" class="vip_sign flex_ccc">
<view class="vip_text">会员专属</view>
<glsx-image webp class="vip_icon" src="equity/member.png" />
</view>
<image webp bind:error="binderror" data-index="{{index}}" class="item_banner" src="{{item.goodsImage}}" />
<view class="item_text">
<view class="color_text"><text class="min_color_text">¥</text>{{item.salesPrice}}</view>
<view class="line_color_text">¥{{item.lineationPrice}}</view>
</view>
</view>
</block>
</scroll-view>
</view>
</view>
\ No newline at end of file
.element_wrapper {
background: #FFFFFF;
height: 376rpx;
box-shadow: 0px 4rpx 16rpx 0px rgba(239, 240, 242, 1);
border-radius: 8rpx;
border: 1rpx solid #EFF0F2;
margin-bottom: 20rpx;
}
.header_wrap {
display: flex;
justify-content: space-between;
box-sizing: border-box;
padding: 32rpx 32rpx 0 32rpx;
}
.header_icon {
width: 82rpx;
height: 82rpx;
border-radius: 50%;
background: #FA8A59;
}
.header_desc {
width: calc(100% - 82rpx);
box-sizing: border-box;
padding-left: 22rpx;
}
.desc_title_wrap {
display: flex;
align-items: center;
}
.desc_title {
font-size: 28rpx;
font-weight: 600;
color: #282829;
line-height: 40rpx;
max-width: 392rpx;
}
.desc_address {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 8rpx;
width: 100%;
}
.address_text {
font-size: 24rpx;
font-weight: 400;
color: #656566;
line-height: 34rpx;
}
.address_line {
width: 2rpx;
height: 24rpx;
opacity: 0.24;
margin-right: 12rpx;
background-color: #656566;
}
.address_num {
font-size: 24rpx;
font-weight: 400;
color: #656566;
line-height: 34rpx;
}
.address_icon {
width: 40rpx;
height: 40rpx;
/* background: linear-gradient(129deg, #FFC08B 0%, #FA8A59 100%); */
border-radius: 50%;
margin-left: 12rpx;
}
.hide-text {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.latest_sign {
border-radius: 4rpx;
border: 2rpx solid #8A303A;
padding: 6rpx 8rpx;
font-size: 20rpx;
font-weight: 400;
color: #8A303A;
margin-left: 14rpx;
}
.scroll_wrap {
margin-top: 26rpx;
box-sizing: border-box;
padding: 0 2rpx 20rpx 32rpx;
overflow: hidden;
white-space: nowrap;
vertical-align: top;
}
.scroll_item {
width: 256rpx;
height: 216rpx;
display: inline-block;
margin-right: 20rpx;
position: relative;
}
.vip_sign {
position: absolute;
right: 0;
top: 0;
width: 120rpx;
height: 28rpx;
}
.vip_icon {
width: 120rpx;
height: 28rpx;
position: absolute;
right: 0;
top: 0;
z-index: 2;
}
.vip_text {
position: relative;
z-index: 3;
font-size: 20rpx;
font-weight: 500;
color: #FFFFFF;
}
.item_banner {
width: 256rpx;
height: 158rpx;
border-radius: 16rpx;
}
.item_text {
display: flex;
align-items: flex-end;
justify-content: center;
}
.color_text {
font-size: 36rpx;
font-weight: 600;
color: #8A303A;
}
.min_color_text {
font-size: 24rpx;
font-weight: 400;
}
.line_color_text {
font-size: 24rpx;
font-weight: 400;
color: #666666;
text-decoration: line-through;
margin-left: 10rpx;
padding-bottom: 5rpx;
}
.flex_sc {
display: flex;
align-items: center;
}
.flex_ccc {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
\ No newline at end of file
// components/image/index.js
import {
IMG_URL,
} from '~/config'
import {
systemApi
} from '~/api/index'
Component({
externalClasses: ['custom-class', 'class'],
/**
* 组件的属性列表
*/
properties: {
src: {
type: null,
value: '',
observer: async function (url, o) {
if (url) {
let isWebp = url.includes('webp'),
checkList = ['https://', 'http://'],
isFullAdd = checkList.map(item => url.includes(item)).some(item => item),
isBASE64 = url.includes('data:image'),
v = await systemApi.getImageVersion()
this.setData({
isWebp,
imagePath: `${isFullAdd || isBASE64 ? '' : IMG_URL}${url}` + (isBASE64 ? '' : `?v=${v}`)
})
}
}
},
mode: {
type: String,
value: 'scaleToFill'
},
webp: {
type: Boolean,
value: true
},
alt: {
type: String,
value: ''
},
showMenuByLongpress: Boolean
},
/**
* 组件的初始数据
*/
data: {
imagePath: '',
isWebp: false
},
// 组件生命周期
lifetimes: {
// 在组件实例进入页面节点树时执行
// attached: function () {
// let src = this.data.src
// let prefix = IMG_URL
// this.setData({
// imagePath: `${prefix}${src}?v=` + IMG_VERSION()
// })
// },
// 在组件实例被从页面节点树移除时执行
detached: function () {}
},
/**
* 组件的方法列表
*/
methods: {}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!-- components/image/index.wxml -->
<image src="{{imagePath}}" mode="{{mode}}" webp="{{webp||isWebp}}" alt="{{alt}}" lazy-load class="custom-class class" show-menu-by-longpress="{{showMenuByLongpress}}" />
\ No newline at end of file
/* components/image/index.wxss */
\ No newline at end of file
/**
* 用来配置小程序项目的变量
* 统一管理
*/
// 配置预发布的小程序aapId
export const preReleaseAppId = 'wx6e40cfb83ce4ffb1'
// sentry Dsn 地址
export const dsnUrl = 'https://44b18e4acc2e4ab18f12a69a561b55bc@sentry.glsx.com.cn/39'
// cdn图片地址
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/wuye/'
import sha1 from './sha1.js'
import qs from './qs'
import wxqrcode from './wxqrcode.js'
import getUpdateManager from "./wxUpdateManager";
import * as Sentry from './sentry-miniapp'
module.exports ={ sha1,qs,wxqrcode,getUpdateManager,Sentry }
\ No newline at end of file
This diff is collapsed. Click to expand it.
var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var S=_((le,M)=>{"use strict";M.exports=N;function y(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function N(t){if(t=t||{},t.circles)return Q(t);return t.proto?s:a;function e(f,i){for(var r=Object.keys(f),n=new Array(r.length),u=0;u<r.length;u++){var o=r[u],p=f[o];typeof p!="object"||p===null?n[o]=p:p instanceof Date?n[o]=new Date(p):ArrayBuffer.isView(p)?n[o]=y(p):n[o]=i(p)}return n}function a(f){if(typeof f!="object"||f===null)return f;if(f instanceof Date)return new Date(f);if(Array.isArray(f))return e(f,a);if(f instanceof Map)return new Map(e(Array.from(f),a));if(f instanceof Set)return new Set(e(Array.from(f),a));var i={};for(var r in f)if(Object.hasOwnProperty.call(f,r)!==!1){var n=f[r];typeof n!="object"||n===null?i[r]=n:n instanceof Date?i[r]=new Date(n):n instanceof Map?i[r]=new Map(e(Array.from(n),a)):n instanceof Set?i[r]=new Set(e(Array.from(n),a)):ArrayBuffer.isView(n)?i[r]=y(n):i[r]=a(n)}return i}function s(f){if(typeof f!="object"||f===null)return f;if(f instanceof Date)return new Date(f);if(Array.isArray(f))return e(f,s);if(f instanceof Map)return new Map(e(Array.from(f),s));if(f instanceof Set)return new Set(e(Array.from(f),s));var i={};for(var r in f){var n=f[r];typeof n!="object"||n===null?i[r]=n:n instanceof Date?i[r]=new Date(n):n instanceof Map?i[r]=new Map(e(Array.from(n),s)):n instanceof Set?i[r]=new Set(e(Array.from(n),s)):ArrayBuffer.isView(n)?i[r]=y(n):i[r]=s(n)}return i}}function Q(t){var e=[],a=[];return t.proto?i:f;function s(r,n){for(var u=Object.keys(r),o=new Array(u.length),p=0;p<u.length;p++){var c=u[p],l=r[c];if(typeof l!="object"||l===null)o[c]=l;else if(l instanceof Date)o[c]=new Date(l);else if(ArrayBuffer.isView(l))o[c]=y(l);else{var h=e.indexOf(l);h!==-1?o[c]=a[h]:o[c]=n(l)}}return o}function f(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return s(r,f);if(r instanceof Map)return new Map(s(Array.from(r),f));if(r instanceof Set)return new Set(s(Array.from(r),f));var n={};e.push(r),a.push(n);for(var u in r)if(Object.hasOwnProperty.call(r,u)!==!1){var o=r[u];if(typeof o!="object"||o===null)n[u]=o;else if(o instanceof Date)n[u]=new Date(o);else if(o instanceof Map)n[u]=new Map(s(Array.from(o),f));else if(o instanceof Set)n[u]=new Set(s(Array.from(o),f));else if(ArrayBuffer.isView(o))n[u]=y(o);else{var p=e.indexOf(o);p!==-1?n[u]=a[p]:n[u]=f(o)}}return e.pop(),a.pop(),n}function i(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return s(r,i);if(r instanceof Map)return new Map(s(Array.from(r),i));if(r instanceof Set)return new Set(s(Array.from(r),i));var n={};e.push(r),a.push(n);for(var u in r){var o=r[u];if(typeof o!="object"||o===null)n[u]=o;else if(o instanceof Date)n[u]=new Date(o);else if(o instanceof Map)n[u]=new Map(s(Array.from(o),i));else if(o instanceof Set)n[u]=new Set(s(Array.from(o),i));else if(ArrayBuffer.isView(o))n[u]=y(o);else{var p=e.indexOf(o);p!==-1?n[u]=a[p]:n[u]=i(o)}}return e.pop(),a.pop(),n}}});var V=_((ce,I)=>{"use strict";var C=Array.isArray,W=Object.keys,Z=Object.prototype.hasOwnProperty;I.exports=function t(e,a){if(e===a)return!0;if(e&&a&&typeof e=="object"&&typeof a=="object"){var s=C(e),f=C(a),i,r,n;if(s&&f){if(r=e.length,r!=a.length)return!1;for(i=r;i--!=0;)if(!t(e[i],a[i]))return!1;return!0}if(s!=f)return!1;var u=e instanceof Date,o=a instanceof Date;if(u!=o)return!1;if(u&&o)return e.getTime()==a.getTime();var p=e instanceof RegExp,c=a instanceof RegExp;if(p!=c)return!1;if(p&&c)return e.toString()==a.toString();var l=W(e);if(r=l.length,r!==W(a).length)return!1;for(i=r;i--!=0;)if(!Z.call(a,l[i]))return!1;for(i=r;i--!=0;)if(n=l[i],!t(e[n],a[n]))return!1;return!0}return e!==e&&a!==a}});var q=_(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0}),A.parseMultiDataPaths=ee,A.getDataOnPath=void 0;var E=/^\s/,b=function(t,e){throw new Error('Parsing data path "'+t+'" failed at char "'+t[e]+'" (index '+e+")")},L=function(t,e){for(var a=e.index;e.index<e.length;){var s=t[e.index];if(/^[0-9]/.test(s)){e.index++;continue}break}return a===e.index&&b(t,e.index),parseInt(t.slice(a,e.index),10)},R=function(t,e){var a=e.index,s=t[a];if(/^[_a-zA-Z$]/.test(s))for(e.index++;e.index<e.length;){var f=t[e.index];if(/^[_a-zA-Z0-9$]/.test(f)){e.index++;continue}break}else b(t,e.index);return t.slice(a,e.index)},B=function(t,e){for(var a=[R(t,e)],s={deepCmp:!1};e.index<e.length;){var f=t[e.index];if(f==="[")e.index++,a.push(L(t,e)),t[e.index]!=="]"&&b(t,e.index),e.index++;else if(f==="."){if(e.index++,t[e.index]==="*"){if(e.index++,t[e.index]==="*"){e.index++,s.deepCmp=!0;break}b(t,e.index)}a.push(R(t,e))}else break}return{path:a,options:s}},X=function(t,e){for(;E.test(t[e.index]);)e.index++;for(var a=[B(t,e)],s=!1;e.index<e.length;){var f=t[e.index];E.test(f)?e.index++:f===","?(s=!0,e.index++):s?(s=!1,a.push(B(t,e))):b(t,e.index)}return a},k=function(t,e){e.index<e.length&&b(t,e.index)};function ee(t){var e={length:t.length,index:0},a=X(t,e);return k(t,e),a}var te=function(t,e){var a=t;return e.forEach(function(s){a=typeof a!="object"||a===null?void 0:a[s]}),a};A.getDataOnPath=te});var H=_(m=>{"use strict";Object.defineProperty(m,"__esModule",{value:!0}),m.create=re,m.unwrap=ne;var z=function(t,e,a){if(typeof t!="object"||t===null)return t;var s={get:function(f,i){if(i==="__rawObject__")return t;var r=a.concat(i),n=t[i];return e.push({path:r,value:n}),z(n,e,r)}};return new Proxy(t,s)};function re(t,e){return z(t,e,[])}function ne(t){return typeof t!="object"||t===null||typeof t.__rawObject__!="object"?t:t.__rawObject__}});var K=_(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0}),x.behavior=void 0;var $,ae=G(S()),ie=G(V()),w=U(q()),j=U(H());function F(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function G(t){return t&&t.__esModule?t:{default:t}}function U(t){if(t&&t.__esModule)return t;var e={};if(t!=null){for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){var s=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,a):{};s.get||s.set?Object.defineProperty(e,a,s):e[a]=t[a]}}return e.default=t,e}var T=ae.default({proto:!0}),fe=0,oe=Behavior({lifetimes:{attached:function(){this.setData({_computedWatchInit:"attached"})},created:function(){this.setData({_computedWatchInit:"created"})}},definitionFilter:function(t){var e=t.computed,a=t.watch,s=[],f=fe++;s.push({fields:"_computedWatchInit",observer:function(){var i=this.data._computedWatchInit;if(i==="created"){var r={computedUpdaters:[],computedRelatedPathValues:{},watchCurVal:{}};this._computedWatchInfo||(this._computedWatchInfo={}),this._computedWatchInfo[f]=r,a&&Object.keys(a).forEach(function(u){var o=w.parseMultiDataPaths(u).map(function(p){var c=p.path,l=p.options,h=w.getDataOnPath(this.data,c);return l.deepCmp?T(h):h}.bind(this));r.watchCurVal[u]=o}.bind(this))}else if(i==="attached"){var n=this._computedWatchInfo[f];e&&Object.keys(e).forEach(function(u){var o=e[u],p=[],c=o(j.create(this.data,p)),l=p.map(function(d){var v=d.path;return{path:v,value:w.getDataOnPath(this.data,v)}}.bind(this));this.setData(F({},u,j.unwrap(c))),n.computedRelatedPathValues[u]=l;var h=function(){for(var d=n.computedRelatedPathValues[u],v=!1,D=0;D<d.length;D++){var P=d[D],Y=P.path;if(P.value!==w.getDataOnPath(this.data,Y)){v=!0;break}}if(!v)return!1;var g=[],J=o(j.create(this.data,g));return this.setData(F({},u,j.unwrap(J))),n.computedRelatedPathValues[u]=g,!0}.bind(this);n.computedUpdaters.push(h)}.bind(this))}}}),e&&s.push({fields:"**",observer:function(){if(this._computedWatchInfo){var i,r=this._computedWatchInfo[f];if(r)do i=r.computedUpdaters.some(function(n){return n.call(this)}.bind(this));while(i)}}}),a&&Object.keys(a).forEach(function(i){var r=w.parseMultiDataPaths(i);s.push({fields:i,observer:function(){if(this._computedWatchInfo){var n=this._computedWatchInfo[f];if(n){var u=n.watchCurVal[i],o=r.map(function(h){var d=h.path,v=h.options;return{val:w.getDataOnPath(this.data,d),options:v}}.bind(this)),p=o.map(function(h){var d=h.val;return h.options.deepCmp?T(d):d});n.watchCurVal[i]=p;for(var c=!1,l=0;l<p.length;l++)if(r[l].options.deepCmp?!ie.default(u[l],p[l]):u[l]!==p[l]){c=!0;break}c&&a[i].apply(this,o.map(function(h){return h.val}))}}}})}),typeof t.observers!="object"&&(t.observers={}),Array.isArray(t.observers)?($=t.observers).push.apply($,s):s.forEach(function(i){var r=t.observers[i.fields];r?t.observers[i.fields]=function(){i.observer.call(this),r.call(this)}:t.observers[i.fields]=i.observer})}});x.behavior=oe});"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"behavior",{enumerable:!0,get:function(){return O.behavior}}),exports.ComponentWithComputed=se,exports.BehaviorWithComputed=ue;var O=K();function se(t){return Array.isArray(t.behaviors)||(t.behaviors=[]),t.behaviors.unshift(O.behavior),Component(t)}function ue(t){return Array.isArray(t.behaviors)||(t.behaviors=[]),t.behaviors.unshift(O.behavior),Behavior(t)}
This diff is collapsed. Click to expand it.
function encodeUTF8(s) {
var i, r = [], c, x;
for (i = 0; i < s.length; i++)
if ((c = s.charCodeAt(i)) < 0x80) r.push(c);
else if (c < 0x800) r.push(0xC0 + (c >> 6 & 0x1F), 0x80 + (c & 0x3F));
else {
if ((x = c ^ 0xD800) >> 10 == 0) //对四字节UTF-16转换为Unicode
c = (x << 10) + (s.charCodeAt(++i) ^ 0xDC00) + 0x10000,
r.push(0xF0 + (c >> 18 & 0x7), 0x80 + (c >> 12 & 0x3F));
else r.push(0xE0 + (c >> 12 & 0xF));
r.push(0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F));
};
return r;
}
// 字符串加密成 hex 字符串
function sha1(s) {
var data = new Uint8Array(encodeUTF8(s))
var i, j, t;
var l = ((data.length + 8) >>> 6 << 4) + 16, s = new Uint8Array(l << 2);
s.set(new Uint8Array(data.buffer)), s = new Uint32Array(s.buffer);
for (t = new DataView(s.buffer), i = 0; i < l; i++)s[i] = t.getUint32(i << 2);
s[data.length >> 2] |= 0x80 << (24 - (data.length & 3) * 8);
s[l - 1] = data.length << 3;
var w = [], f = [
function () { return m[1] & m[2] | ~m[1] & m[3]; },
function () { return m[1] ^ m[2] ^ m[3]; },
function () { return m[1] & m[2] | m[1] & m[3] | m[2] & m[3]; },
function () { return m[1] ^ m[2] ^ m[3]; }
], rol = function (n, c) { return n << c | n >>> (32 - c); },
k = [1518500249, 1859775393, -1894007588, -899497514],
m = [1732584193, -271733879, null, null, -1009589776];
m[2] = ~m[0], m[3] = ~m[1];
for (i = 0; i < s.length; i += 16) {
var o = m.slice(0);
for (j = 0; j < 80; j++)
w[j] = j < 16 ? s[i + j] : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1),
t = rol(m[0], 5) + f[j / 20 | 0]() + m[4] + w[j] + k[j / 20 | 0] | 0,
m[1] = rol(m[1], 30), m.pop(), m.unshift(t);
for (j = 0; j < 5; j++)m[j] = m[j] + o[j] | 0;
};
t = new DataView(new Uint32Array(m).buffer);
for (var i = 0; i < 5; i++)m[i] = t.getUint32(i << 2);
var hex = Array.prototype.map.call(new Uint8Array(new Uint32Array(m).buffer), function (e) {
return (e < 16 ? "0" : "") + e.toString(16);
}).join("");
return hex;
}
module.exports = sha1
function e(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,a)}return o}function t(t){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?e(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var a=["canvasGetImageData","canvasPutImageData","canvasToTempFilePath","setEnableDebug","startAccelerometer","stopAccelerometer","getBatteryInfo","getClipboardData","setClipboardData","startCompass","stopCompass","addPhoneContact","startGyroscope","stopGyroscope","startBeaconDiscovery","stopBeaconDiscovery","getBeacons","startLocalServiceDiscovery","stopLocalServiceDiscovery","startDeviceMotionListening","stopDeviceMotionListening","getNetworkType","makePhoneCall","scanCode","getSystemInfo","vibrateShort","vibrateLong","getExtConfig","chooseLocation","getLocation","openLocation","chooseMessageFile","loadFontFace","chooseImage","previewImage","getImageInfo","saveImageToPhotosAlbum","compressImage","chooseVideo","saveVideoToPhotosAlbum","downloadFile","request","connectSocket","closeSocket","sendSocketMessage","uploadFile","login","checkSession","chooseAddress","authorize","addCard","openCard","chooseInvoice","chooseInvoiceTitle","getUserInfo","requestPayment","getWeRunData","showModal","showToast","hideToast","showLoading","hideLoading","showActionSheet","pageScrollTo","startPullDownRefresh","stopPullDownRefresh","setBackgroundColor","setBackgroundTextStyle","setTabBarBadge","removeTabBarBadge","showTabBarRedDot","hideTabBarRedDot","showTabBar","hideTabBar","setTabBarStyle","setTabBarItem","setTopBarText","saveFile","openDocument","getSavedFileList","getSavedFileInfo","removeSavedFile","getFileInfo","getStorage","setStorage","removeStorage","clearStorage","getStorageInfo","closeBLEConnection","closeBluetoothAdapter","createBLEConnection","getBLEDeviceCharacteristics","getBLEDeviceServices","getBluetoothAdapterState","getBluetoothDevices","getConnectedBluetoothDevices","notifyBLECharacteristicValueChange","openBluetoothAdapter","readBLECharacteristicValue","startBluetoothDevicesDiscovery","stopBluetoothDevicesDiscovery","writeBLECharacteristicValue","getHCEState","sendHCEMessage","startHCE","stopHCE","getScreenBrightness","setKeepScreenOn","setScreenBrightness","connectWifi","getConnectedWifi","getWifiList","setWifiList","startWifi","stopWifi","getBackgroundAudioPlayerState","playBackgroundAudio","pauseBackgroundAudio","seekBackgroundAudio","stopBackgroundAudio","getAvailableAudioSources","startRecord","stopRecord","setInnerAudioOption","playVoice","pauseVoice","stopVoice","getSetting","openSetting","getShareInfo","hideShareMenu","showShareMenu","updateShareMenu","checkIsSoterEnrolledInDevice","checkIsSupportSoterAuthentication","startSoterAuthentication","navigateBackMiniProgram","navigateToMiniProgram","setNavigationBarTitle","showNavigationBarLoading","hideNavigationBarLoading","setNavigationBarColor","redirectTo","reLaunch","navigateTo","switchTab","navigateBack"];Promise.prototype.finally||(Promise.prototype.finally=function(e){var t=this.constructor;return this.then((function(o){return t.resolve(e()).then((function(){return o}))}),(function(o){return t.resolve(e()).then((function(){throw o}))}))});var r=function(e){return function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise((function(a,r){e(t({fail:r,success:a},o))}))}},n=function(){wx.pro={},Object.keys(wx).forEach((function(e){a.indexOf(e)>=0?wx.pro[e]=r(wx[e]):"createSignal"!==e&&"lanDebug"!==e&&(wx.pro[e]=wx[e])}))};export{r as promisify,n as promisifyAll};
//# sourceMappingURL=wx-promise-pro.js.map
const getUpdateManager = () => {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
})
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
// 新版本下载失败
})
}
export default getUpdateManager
module.exports = Behavior(
{
data: {
afterType:{
1:'我要退款退货',
2:'我要退款(无需退货)'
}
}
})
\ No newline at end of file
import { iosTimeFormat } from "~/utils/format";
module.exports = Behavior({
methods: {
countDown({
timer,
hideDay,
targetObject
}) {
const {
name,
key
} = targetObject
let activityStatus = this.data[name][key] // activityStatus 1:未开始,2进行中,3已结束
const addZero = i => i < 10 ? `0${i}` : `${i}`,
[activityStartTime, activityEndTime] = timer,
start = iosTimeFormat(activityStartTime),
end = iosTimeFormat(activityEndTime)
if ((new Date().getTime() > new Date(end).getTime()) || activityStatus == 3) {
this.setData({
timeFlag: true,
finished: '活动已结束',
[`${name}.${key}`]: 3
})
return
}
if (new Date().getTime() >= new Date(start).getTime() && activityStatus != 2) {
this.setData({
[`${name}.${key}`]: 2
})
activityStatus = 2
}
let starTime = new Date(),
endTime = new Date(activityStatus == 2 ? end : start),
lefttime = parseInt((endTime.getTime() - starTime.getTime()) / 1e3),
d = parseInt(lefttime / (24 * 60 * 60)),
h = addZero(parseInt(hideDay ? lefttime / (60 * 60) : lefttime / (60 * 60) % 24)),
m = addZero(parseInt(lefttime / 60 % 60)),
s = addZero(parseInt(lefttime % 60)),
type = {
1: '距开始',
2: '距结束'
} [activityStatus]
if (this.time) {
clearTimeout(this.time)
this.time = null
}
let activityTime = {
dayList: [h, m, s],
type
}
if (d > 0) activityTime.day = `${d}天`
this.setData({
activityTime,
timeFlag: true
})
this.time = setTimeout(() => {
this.countDown({
timer,
hideDay,
targetObject
})
}, 1e3)
}
}
})
\ No newline at end of file
import kfMixin from './kfMixin'
import orderMixin from './orderMixin'
import afterSaleMixin from './afterSaleMixin'
import countdownMixin from './countdownMixin'
module.exports = {
kfMixin,
orderMixin,
afterSaleMixin,
countdownMixin
}
module.exports = Behavior({
data: {},
methods: {
filterKfList(data) {
let showKF = false,
customerlist = [],
kfUrl = ''
if (data.customerServerType) {
if (data.customerServerType == 1)
customerlist[0] = {
thumbAvatar: data.customerServerAvatar,
staffName: data.customerServerName,
qrCode: data.customerServerOrCode
}
else kfUrl = data.customerServerUrl
showKF = true
}
this.setData({
showKF,
kfUrl,
customerlist
})
},
async openKF(e) {
let {
kfUrl,
widgetStatus
} = this.data, {
corpId
} = await wx.p.api.systemApi.getMockData()
if (kfUrl)
wx.openCustomerServiceChat({
extInfo: {
url: kfUrl
},
corpId,
success(res) {
console.log(res)
},
fail({
errMsg
}) {
console.log(errMsg)
wx.p.wxApi.showToast(errMsg)
}
})
else
this.setData({
widgetStatus: !widgetStatus
})
}
}
})
\ No newline at end of file
module.exports = Behavior({
data: {
//1:待付款;2:已支付;3:已关闭;4:已发货;5:已收货;6:待发货;7:待安装;8:已安装;9:售后中;10:售后完成
statusEnum: {
1: '待付款',
2: '已支付',
3: '已关闭',
4: '已发货',
5: '已收货',
6: '待发货',
7: '待安装',
8: '已安装',
9: '售后中',
10: '售后完成'
},
/**售后状态 1:待审核;2:审核通过;3:审核不通过;4:待确认收到退货;5:退款中;6:已退款;7:退款失败;8已取消 */
afterSaleStatus: {
1: '待审核',
2: '审核通过',
3: '审核不通过',
4: '待确认收到退货',
5: '退款中',
6: '已退款',
7: '退款失败',
8: '已取消'
},
/**权益&套餐 */
cardStatus: {
0: '未支付',
1: '已支付',
2: '待收货',
3: '已完成',
4: '售后中',
5: '退款失败',
6: '已退款'
},
reStatus: {
2: '充值中',
3: '充值成功',
4: '退款中',
6: '充值失败',
}
}
})
\ No newline at end of file
{
"name": "hmd",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"glsx-applet-component": {
"version": "1.1.24",
"resolved": "https://registry.npmjs.org/glsx-applet-component/-/glsx-applet-component-1.1.24.tgz",
"integrity": "sha512-3XTG9J99rgKVJpcC7aKS/+N7CaS+MNYdy5qmWH8siFaRFiSo1PeBRDaprfjCazaud/c31RvpoDFUof/fxNkxjw=="
},
"glsx-map-sdk": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/glsx-map-sdk/-/glsx-map-sdk-0.2.0.tgz",
"integrity": "sha512-uEFlXvJEDofYjasR4mwkmF5yNTRs5QA2ZAynGPHiKpKdpjQkVFPJH0zGupmQEkxmh4f5B0wPbDobHvLgld7mVw=="
},
"number-precision": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/number-precision/-/number-precision-1.6.0.tgz",
"integrity": "sha512-05OLPgbgmnixJw+VvEh18yNPUo3iyp4BEWJcrLu4X9W05KmMifN7Mu5exYvQXqxxeNWhvIF+j3Rij+HmddM/hQ=="
}
}
}
{
"name": "hmd",
"version": "1.0.0",
"main": "app.js",
"dependencies": {
"glsx-applet-component": "^1.1.24",
"glsx-map-sdk": "^0.2.0",
"number-precision": "^1.6.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "http://192.168.3.233:8090/saas/mini-program/hmd"
},
"author": "",
"license": "ISC",
"description": ""
}
const phoneRex = /^[1]([3-9])[0-9]{9}$/
Page({
/**
* 页面的初始数据
*/
data: {
loginType: 0,
isAgree: false,
mobile: '',
captcha: '',
count: 0
},
changeLoginType() {
const {
loginType
} = this.data
this.setData({
loginType: loginType == 0 ? 1 : 0
})
},
// 同意隐私政策
handleChangeAgree() {
this.setData({
isAgree: !this.data.isAgree
})
},
// 跳转隐私政策页面
handleAgree(e) {
const {
name
} = e.currentTarget.dataset
wx.p.router.jumpH5(`https://img02.glsx.com.cn/weapp/resource/saas/scrm/html/hmd/${name}.html`, true)
},
async onLoad() {
wx.p.wxApi.showLoading()
const {
data,
code
} = await wx.p.api.userApi.login()
if (code == '0') this.customerLoginCallBack(data)
if (data) this.sessionId = data.sessionId
wx.hideLoading()
},
input(e) {
const {
value
} = e.detail, {
name
} = e.target.dataset
this.setData({
[name]: value
})
},
/**获取验证码 */
async getSmsCode() {
const {
mobile,
count
} = this.data
try {
if (!phoneRex.test(mobile)) throw '请输入正确的手机号'
if (count) throw '验证码发送过于频繁,请稍后在试'
} catch (error) {
return wx.p.wxApi.showToast(error)
}
wx.p.wxApi.showLoading()
try {
const {
code,
message
} = await wx.p.api.userApi.getSmsCode(mobile)
if (code == '0') {
wx.p.wxApi.showToast('验证码已发送')
this.countDown(60)
} else wx.p.wxApi.showToast(message || '发送验证码失败')
} catch (error) {
wx.p.wxApi.showToast(error)
}
},
/**验证码倒计时 */
countDown(countDown) {
if (countDown) this.setData({
count: countDown
})
setTimeout(() => {
let {
count
} = this.data
this.setData({
count: --count
})
if (count > 0) this.countDown()
else this.setData({
count: null
})
}, 1e3)
},
showTips(message) {
wx.p.wxApi.showToast(typeof message == 'string' ? message : '请同意以下用户协议')
},
/**手机号短信登录 */
async phoneLogin() {
const {
mobile,
captcha,
isAgree
} = this.data
try {
if (!mobile) throw '请输入手机号'
if (!captcha) throw '请输入验证码'
if (!phoneRex.test(mobile)) throw '请输入正确的手机号'
if (!isAgree) throw '请同意以下用户协议'
wx.p.wxApi.showLoading()
const {
code,
data,
message
} = await wx.p.api.userApi.phoneLogin({
mobile,
captcha,
sessionId: this.sessionId
})
if (code == '0') this.customerLoginCallBack(data)
else throw message
wx.hideLoading()
} catch (error) {
this.showTips(error || '服务不可用')
setTimeout(() => {
this.onLoad()
}, 1500)
}
},
/**微信登录 */
async getPhoneNumber({
detail
}) {
const {
isAgree
} = this.data
try {
if (detail.errMsg && ['authorized', 'deny'].findIndex(e => detail.errMsg.toLowerCase().includes(e)) != -1) return
if (!detail?.code) throw '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
if (!isAgree) throw '请同意以下用户协议'
wx.p.wxApi.showLoading()
const {
code,
data,
message
} = await wx.p.api.userApi.authUserPhone(detail, this.sessionId)
wx.hideLoading()
if (code == '0') this.customerLoginCallBack(data)
else throw message
} catch (error) {
console.log(error)
this.showTips(error || '服务不可用')
setTimeout(() => {
this.onLoad()
}, 1500)
}
},
/**C端登录回调 */
customerLoginCallBack(data) {
wx.$LoginStatus = false
wx.p.storage.set('userInfo', data)
wx.p.storage.set('sessionId', data.sessionId)
// 返回上一页
wx.p.router.back(thisPage => {
thisPage && thisPage.setData({
userInfo: data
})
thisPage.onLoginSuccess && thisPage.onLoginSuccess() //登陆成功后页面回调
})
},
back() {
wx.p.router.back()
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationStyle": "custom"
}
\ No newline at end of file
<view class="layout">
<view class="login-bg x-center">
<glsx-image src="login/login-bg.png"></glsx-image>
</view>
<navigation-bar navStyle="background:transparent;" custom page-title="登录">
<view class="nav-bar flex">
<view class="back flex" bindtap="back">
<view class="icon">
<glsx-image src="login/login-back.png"></glsx-image>
</view>
</view>
登录
</view>
</navigation-bar>
<view class="content" style="margin-top: {{navHeight}}px;">
<block wx:if="{{loginType==0}}">
<view class="h1">
欢迎使用
<view class="logo">
<glsx-image src="login/logo.png"></glsx-image>
</view>
</view>
<view class="wx-box">
<block wx:if="{{!isAgree}}">
<button class="wx-auth-button text-center {{isAgree}}" bindtap="showTips">登录</button>
</block>
<block wx:else>
<button open-type="getPhoneNumber" catchgetphonenumber="getPhoneNumber" class="wx-auth-button text-center">登录</button>
</block>
</view>
</block>
<block wx:else>
<view class="h3">
手机号登录
</view>
<view class="box">
<view class="login-item flex">
<input maxlength="11" type="number" adjust-position="{{false}}" placeholder-class="placeholderClass" placeholder="填写手机号" bindinput="input" data-name="mobile" class="input" value="{{mobile}}" />
</view>
<view class="login-item flex">
<input maxlength="4" type="number" adjust-position="{{false}}" placeholder-class="placeholderClass" placeholder="填写验证码" bindinput="input" data-name="captcha" class="input" value="{{captcha}}" />
<button disabled="{{!mobile}}" class="code-btn" bindtap="getSmsCode">{{count? count + 's':'获取验证码'}}</button>
</view>
</view>
<button class="wx-auth-button text-center" bindtap="phoneLogin">登录</button>
</block>
<view class="type-box flex">
<view class="title" bindtap="changeLoginType">
{{loginType==0?'手机号登录':'微信登录'}}
</view>
<!-- <view class="type" bindtap="changeLoginType">
<view class="icon">
<glsx-image src="common/{{loginType == 0?'phone':'wx'}}.png"></glsx-image>
</view>
{{loginType == 0?'手机号':'微信登录'}}
</view> -->
</view>
<view class="tips text-center" bindtap="handleChangeAgree">
<view class="check {{isAgree}}">
<glsx-image src="login/check.png" class="icon"></glsx-image>
</view>
阅读并同意以下协议
<text class="txt-orange" catchtap="handleAgree" data-name="privacy">《隐私协议》</text>
<text class="txt-orange" catchtap="handleAgree" data-name="agreement">《服务使用协议》</text>
</view>
</view>
</view>
<glsx-privacy appletName="海马刀"></glsx-privacy>
\ No newline at end of file
/* pages/login/login.wxss */
.login-bg {
position: fixed;
z-index: -2;
width: 1350rpx;
height: 1664rpx;
top: -60rpx;
}
.layout::before{
position: fixed;
left: 0;
top: 0;
width: 100vw;
height: 600rpx;
background-image: linear-gradient(0deg, #0a030300 22%, #0A0303 100%);
z-index: -1;
content: '';
}
.layout::after {
position: fixed;
left: 0;
bottom: 0;
width: 100vw;
height: 400rpx;
transform: scaleY(-1);
background-image: linear-gradient(0deg, #0a030300 22%, #0A0303 90%);
z-index: -1;
content: '';
}
.nav-bar {
height: 100%;
position: relative;
font-weight: 600;
font-size: 34rpx;
color: #FFFFFF;
justify-content: center;
}
.nav-bar .back {
height: 100%;
justify-content: center;
padding: 0 40rpx;
position: absolute;
top: 0;
left: 0;
}
.nav-bar .back .icon {
width: 16rpx;
height: 28rpx;
}
@keyframes opacity {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.h1 {
padding: 20rpx 0;
font-size: 44rpx;
color: #fff;
text-align: center;
}
.h1 .logo {
width: 402rpx;
height: 144rpx;
margin: 44rpx auto 0;
}
.h3 {
font-weight: 500;
font-size: 44rpx;
color: #fff;
padding: 146rpx 106rpx 0;
}
.wx-box {
margin: 472rpx auto 0;
}
.wx-auth-button {
width: 590rpx !important;
height: 96rpx;
background: var(--btnColor);
border-radius: 16rpx;
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;
padding: 0;
}
.wx-auth-button[disabled]:not([type]) {
background: #CCCED1 !important;
border-color: #CCCED1 !important;
color: #fff !important;
box-shadow: none;
}
.wx-auth-button[disabled]:not([type])::after {
border-color: #CCCED1 !important;
}
.type-box {
flex-direction: column;
margin-top: 33rpx;
font-size: 28rpx;
color: #fff;
}
.type .icon {
width: 68rpx;
height: 68rpx;
margin: 40rpx auto 12rpx;
}
.tips {
font-size: 24rpx;
color: #C9C9C9;
position: fixed;
bottom: 56rpx;
left: 0;
width: 100%;
padding: 20rpx 0;
}
.tips .check {
width: 24rpx;
height: 24rpx;
box-sizing: border-box;
border-radius: 100%;
border: 2rpx solid #fff;
margin-right: 8rpx;
position: relative;
}
.tips .check.true {
border-color: var(--btnColor);
}
.tips .check .icon {
display: none;
width: 100%;
height: 100%;
}
.tips .check.true .icon {
display: block;
}
.txt-orange {
color: #fff;
}
/* 手机号 */
.box {
margin: 0 105rpx 306rpx;
animation: opacity .25s forwards;
}
.login-item {
height: 88rpx;
border-bottom: 2rpx solid #E3E3E6;
margin-top: 34rpx;
}
.login-item .input {
flex: 1;
color: #fff;
}
.placeholderClass {
color: #CCCED1;
}
.code-btn {
font-size: 24rpx;
color: #fff;
flex-shrink: 0;
margin-left: auto;
padding: 8rpx 16rpx !important;
width: fit-content !important;
background-color: #AA656B;
}
.code-btn[disabled]:not([type]) {
background-color: #8A8C90;
color: #fff;
}
.code-btn::after {
display: none;
}
\ 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
{
"usingComponents": {}
}
\ No newline at end of file
/* pages/index/index.wxss */
\ No newline at end of file
<!--pages/index/index.wxml-->
<text>pages/index/index.wxml</text>
// pages/loading/loading.js
import {
systemApi
} from '~/api/index'
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options) {
console.log('---------------- 页面初始化 ----------------')
console.log('options参数:', options)
systemApi.getImageVersion() //获取图片版本号
this.tabList = __wxConfig.tabBar.list
wx.p.wxApi.showLoading()
//scenc获取页面参数并跳转
if (options.scene) {
return this.getSceneById(options.scene)
}
if (options.url) {
return this.login(options)
}
this.login()
},
async login(options = {}) {
if (options.merchantId) wx.$merchant_id = options.merchantId
try {
const {
code,
data,
message
} = await wx.p.api.userApi.login()
wx.$LoginStatus = code != 0
if (data) wx.p.storage.set('merchant_info', {
merchantId: data.merchantId,
merchantName: data.merchantName
})
if (code == '0') {
wx.p.storage.set('userInfo', data)
wx.p.storage.set('sessionId', data.sessionId)
if (!data) throw message
} else {
wx.p.storage.rm('userInfo')
wx.p.storage.rm('sessionId')
}
console.log('登陆信息:', data)
if (options.url) {
return this.jumpPage(options.url)
}
// 默认跳转到首页
wx.p.router.goHome()
} catch (error) {
wx.$LoginStatus = true //请求失败默认未登录
console.log(error)
wx.p.wxApi.showToast(String(error))
wx.p.router.goHome()
}
},
async getSceneById(scene) {
const id = decodeURIComponent(scene).split('=').at(-1)
try {
const {
code,
data
} = await wx.p.api.wechatApi.getSceneById({
id
})
const params = data.scene.split('url='),
options = {}
if (params.length > 1) options.url = params.at(-1)
if (code == 0) this.login(options)
else throw {}
} catch (error) {
wx.p.wxApi.showToast(error || '获取scene失败')
this.login()
}
},
jumpPage(val) {
const targetPath = decodeURIComponent(val),
{
url,
events
} = this.setRouteData(targetPath),
routeName = this.tabList.findIndex(e => `/${e.pagePath}` == `${url}.html`) > -1 ? 'switchTab' : 'redirectTo'
events.notIntercept = true
wx.p.router[routeName](url, events)
},
setRouteData(targetPath) {
let [url, query] = targetPath.split('?'),
events = {}
if (query) {
let arr = query.split('&')
arr.map(e => {
let [key, val] = e.split('=')
if (val == 'false' || val == 'true') val = JSON.parse(val)
Object.assign(events, {
[key]: val
})
})
}
return {
url,
events
}
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationStyle": "custom"
}
\ No newline at end of file
/* pages/loading/loading.wxss */
\ No newline at end of file
Page({
properties: {},
onLoad() {
},
onShow() {
},
})
\ No newline at end of file
{
"navigationStyle": "custom",
"enablePullDownRefresh": true,
"onReachBottomDistance": 10,
"usingComponents": {
}
}
\ No newline at end of file
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!