Commit 8ab93a72 by 前端

初始化

1 parent 02899a55
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2025-03-24 14:41:52
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2025-03-25 11:16:41
* @FilePath: \gltap-next\api\index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import apiModules from './module/index'
export default apiModules
/*
* @Description:
* @Author: huyue
* @Date: 2024-09-05 14:05:25
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2025-03-25 13:40:21
*/
import http from '../request/http'
const boutiqueApi = {
/**获取APP更新 */
findSoureList(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.soure.findSoureList',
projectName: 'boutique',
...data
})
},
/** 查询可发放礼券-分页查询商户券列表 */
findCouponList(data) {
return http.post({
method: 'dj.api.smartcarlife.merchantCoupon.pageForZYApp',
projectName: 'boutique',
onlyUsable: true,
currentPage: 1,
pageSize: 99999,
...data
})
},
/**查询用户是否领券 */
findCustomerReceivedStatus(data) {
return http.post({
method: 'dj.api.smartcarlife.customerCoupon.pageForZYApp',
projectName: 'boutique',
...data,
currentPage: 1,
pageSize: 99999,
statusList: [0, 1]
})
},
/**历史成交客户 */
historyDealOrderPage(data) {
return http.post({
method: 'dj.api.smartcarlife.order.historyDealOrder.page',
projectName: 'boutique',
...data
})
},
// 历史订单列表
getQuotationList(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.page',
projectName: 'boutique',
...data
})
},
/**客户邀约记录 */
customerInviteRecordPage(data) {
return http.post({
method: 'dj.api.smartcarlife.customerInviteRecord.page',
projectName: 'boutique',
...data
})
},
/**轻改素材配置 */
getBoutiqueMaterialConfig(data) {
return http.post({
method: 'dj.api.boutique.recepiton.material.merchant.detail',
projectName: 'boutique',
...data
})
},
/** 案例视频 */
getCaseList(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.material.case.find',
projectName: 'boutique',
...data
})
},
/** 获取类目 */
getCategory(data) {
return http.post({
method: 'dj.api.boutique.recepiton.material.merchant.category',
projectName: 'boutique',
...data
})
}
}
export default boutiqueApi
import http from '../request/http'
const commonApi = {
/**获取APP更新 */
getAPPVersion(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.findVersion',
projectName: 'boutique',
...data
})
},
// 查询接待素材
findSoureList(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.soure.findSoureList',
projectName: 'boutique',
...data
})
},
// 查询门店支付配置
findPayInfo(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.pay.findPayInfoConfigListByMerchantId',
projectName: 'boutique',
...data
})
},
// 接待客户信息保存
saveRecCustomer(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.customer.saveRecCustomer',
projectName: 'boutique',
...data
})
},
searchRecordingEndTime(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.customer.searchRecordingEndTime',
projectName: 'boutique',
...data
})
},
getToken(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.customer.oss.getToken',
projectName: 'boutique'
})
},
// 历史订单列表
getQuotationList(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.page',
projectName: 'boutique',
...data
})
},
/** 获取门店主营车品牌 */
getMerchantCarBrandList(merchantIdList) {
return http.post(
{
method: 'merchants.api.open.merchant.info',
projectName: 'merchants',
merchantIdList,
merchantInfoSwitch: {
brandFlag: true
}
},
false,
'merchant'
)
},
/**
* 车型
*
*/
getCarBrandsList(data) {
return http.post(
{
method: 'scrm.api.carlife.common.getCarSeriesList',
...data
},
false,
'scrm'
)
},
/**
* 推荐人
*/
getEmployeeList(data) {
return http.post({
method: 'dj.api.smartcarlife.employee.getByMerchantId',
projectName: 'boutique',
sceneList: [0],
...data
})
},
/** 查询接待记录列表 */
getReceptionList(data) {
return http.post({
method: 'dj.api.smartcarlife.reception.customer.page',
projectName: 'boutique',
...data
})
},
/** 接待统计 */
getReceptionStatistics(data) {
return http.post({
method: 'dj.api.smartcarlife.reception.customer.statistics',
projectName: 'boutique',
...data
})
},
/** 埋点进入 */
addRecord(data) {
return http.post({
method: 'dj.api.customer.dynamic.record.add',
projectName: 'boutique',
...data
})
},
/** 埋点离开 */
leaveRecord(data) {
return http.post({
method: 'dj.api.customer.dynamic.record.leave',
projectName: 'boutique',
...data
})
},
/** 保存平板安装包信息 */
saveOrUpdateEmployeeAppUsage(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.customer.saveOrUpdateEmployeeAppUsage',
projectName: 'boutique',
...data
})
},
checkAppUpload(data) {
return http.post({
method: 'dj.api.smartcarlife.recepiton.customer.checkAppUpload',
projectName: 'boutique',
...data
})
}
}
export default commonApi
import http from '../request/http'
export default {
/**查询当前门店是否有客户档案权限 */
haveCustomerAccess(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.findPermissionsMerchantList',
projectName: 'boutique',
...data
})
},
/**查询当前门店客户档案列表 */
getCustomerFileList(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.customerInfoPage',
projectName: 'boutique',
...data
})
},
/* 删除客户档案*/
delCustomerFile(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.deleteVisitsInfo',
projectName: 'boutique',
...data
})
},
/** 根据业务查询接待场景 */
findAllSence(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.findAllSence',
projectName: 'boutique',
...data
})
},
/**根据业务查询客户标签 */
findCustomerTags(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.findSenceTag',
projectName: 'boutique',
...data
})
},
/**
* 查询客户档案详情
*/
findVisitsInfo(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.findVisitsInfo',
projectName: 'boutique',
...data
})
},
/*
* 保存客户档案
*/
saveVisitsInfo(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.saveVisitsInfo',
projectName: 'boutique',
...data
})
},
/**
* 更新客户档案
*/
updateVisitsInfo(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.updateVisitsInfo',
projectName: 'boutique',
...data
})
},
/**查询客户档案列表 */
getCustomerInfoList(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.customerInfoList',
projectName: 'boutique',
...data
})
},
/**接待客户素材
*
*/
getMaterialResponsePage(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.getMaterialResponsePage',
projectName: 'boutique',
...data
})
},
/**素材详情 查询素材详情 */
getMaterialDetail(data) {
return http.post({
method: 'dj.api.smartcarlife.customervisits.getMaterialById',
projectName: 'boutique',
...data
})
},
/**直营驻店人员 */
saleOpen(data) {
return http.post({
method: 'dj.api.car.boutique.resident.direct.sale.merchant',
projectName: 'boutique',
...data
})
}
}
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2025-03-24 14:41:52
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2025-03-25 11:15:45
* @FilePath: \gltap-next\api\module\index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import commonApi from './common'
import systemApi from './systemApi'
import userApi from './userApi'
import boutiqueApi from './boutique'
import customerApi from './customerApi'
import pointApi from './point'
const apiModules = { commonApi, systemApi, userApi, boutiqueApi, customerApi, pointApi }
export default apiModules
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-12-19 11:02:01
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2025-03-07 16:28:37
* @FilePath: \gl-tape\api\module\point.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import http from '../request/http'
export default {
/**驻店规则列表 */
pointRuleList(data) {
return http.post({
method: 'dj.api.car.boutique.resident.point.rule.list',
projectName: 'boutique',
...data
})
} /**驻店规则详情列表 */,
pointRuleDetail(data) {
return http.post({
method: 'dj.api.car.boutique.resident.point.rule.detail.list',
projectName: 'boutique',
...data
})
} /**积分记录 */,
pointRecordList(data) {
return http.post({
method: 'dj.api.car.boutique.resident.point.record.list',
projectName: 'boutique',
...data
})
} /**驻店月份排名 */,
pointMonthRanking(data) {
return http.post({
method: 'dj.api.car.boutique.resident.point.month.ranking',
projectName: 'boutique',
...data
})
} /**每日积分-项目完成情况 */,
pointDayTask(data) {
return http.post({
method: 'dj.api.car.boutique.resident.point.every.day.task',
projectName: 'boutique',
...data
})
},
/**积分首页 */
getPoint(data) {
return http.post({
method: 'dj.api.car.boutique.resident.point.home.page',
projectName: 'boutique',
...data
})
},
/**积分奖励规则 */
rewardRule(data) {
return http.post({
method: 'dj.api.car.boutique.resident.point.reward.rule',
projectName: 'boutique',
...data
})
},
badgeList(data) {
return http.post({
method: 'dj.api.car.boutique.resident.point.month.badge.list',
projectName: 'boutique',
...data
})
},
incomeMeasurementConfig(data) {
return http.post({
method: 'dj.smartcarlife.api.incomeMeasurement.switch.config.search',
projectName: 'boutique',
...data
})
},
/**员工收入测算获取员工信息 */
incomeCalculation(data) {
return http.post({
method: 'dj.api.smartcarlife.staff.incomeCalculation.staffInfo',
projectName: 'boutique',
...data
})
},
/**获取员工绩效测算详情 */
incomeCalculationDetail(data) {
return http.post({
method: 'dj.api.smartcarlife.staff.incomeCalculation.detail',
projectName: 'boutique',
...data
})
},
/**分页查询员工月度工资统计列表 */
pageStat(data) {
return http.post({
method: 'dj.api.smartcarlife.staff.monthSalary.pageStat',
projectName: 'boutique',
...data
})
},
/**获取员工(测算/历史)月度工资明细 */
monthSalaryDetail(data) {
return http.post({
method: 'dj.api.smartcarlife.staff.monthSalary.detail',
projectName: 'boutique',
...data
})
},
/**获取试算门店工资绩效配置详细 */
getLatestConfigDetail(data) {
return http.post({
method: 'dj.api.smartcarlife.staff.incomeCalculation.getLatestConfigDetail',
projectName: 'boutique',
...data
})
},
/**员工工资试算*/
monthSalaryCalculation(data) {
return http.post({
method: 'dj.api.smartcarlife.staff.incomeCalculation.monthSalaryCalculation',
projectName: 'boutique',
...data
})
},
/**员工考勤日历 */
calendarDetail(data) {
return http.post({
method: 'dj.api.smartcarlife.clock.in.staff.calendar',
projectName: 'boutique',
...data
})
},
/**查询员工提示信息 */
getTipsMessage(data) {
return http.post({
method: 'dj.api.smartcarlife.staff.tipsMessage.list',
projectName: 'boutique',
...data
})
},
/**直级介绍配置查询 */
getJobConfig(data) {
return http.post({
method: 'dj.smartcarlife.api.job.rank.config.search',
projectName: 'boutique',
...data
})
},
/** 优惠券二级列表 */
getGrantRecord(data) {
return http.post({
method: 'dj.api.car.boutique.resident.coupon.grant.record',
projectName: 'boutique',
...data
})
},
/** 优惠券领取 */
receiveCoupon(data) {
return http.post({
method: 'dj.api.car.boutique.resident.coupon.receive',
projectName: 'boutique',
...data
})
},
/** 统计 优惠券 类型总数 */
statisticsCount(data) {
return http.post({
method: 'dj.api.smartcarlife.resident.coupon.statistics.count',
projectName: 'boutique',
...data
})
},
/** 查询附近地址 */
searchStoreAddress(data) {
return http.post({
method: 'dj.api.car.boutique.resident.coupon.address.search',
projectName: 'boutique',
...data
})
},
/** 查询勋章列表 */
searchLevelConfig(data) {
return http.post({
method: 'dj.api.car.boutique.resident.level.config.page',
projectName: 'boutique',
...data
})
}
}
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2025-03-24 14:41:52
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2025-03-25 11:14:27
* @FilePath: \gltap-next\api\module\systemApi.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import http from '../request/http'
import { env } from '../../env'
const serverConfig = {
mockRequestCount: null,
mockTimer: {},
mockCache: null
},
bydServerConfig = {
mockRequestCount: null,
mockTimer: {},
mockCache: null
},
boutiqueServerConfig = {
mockRequestCount: null,
mockTimer: {},
mockCache: null
},
configModule = 'app-tape',
bydConfigModule = 'byd-pad-config',
boutiqueConfigModule = 'boutique-pad-config',
configUrl = `https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=${configModule}&env=${env}`,
bydConfigUrl = `https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=${bydConfigModule}&env=${env}`,
boutiqueConfigUrl = `https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=${boutiqueConfigModule}&env=${env}`
/**获取mock数据 */
const getMockData = async (immediate = false) => {
const MOCKDATA = uni.$storage.get('mock_data')
try {
if (!immediate && MOCKDATA && Date.now() - MOCKDATA.createTime < 5 * 60e3) {
return Promise.resolve(MOCKDATA)
} else {
if (!serverConfig.mockRequestCount || immediate) {
serverConfig.mockCache = null
serverConfig.mockRequestCount = Date.now()
const data = await http.uni_request({ url: configUrl })
data.createTime = Date.now()
data.moduleList = await imgToBase64(data.moduleList, 'thumbnail')
data.default_moduleList = await imgToBase64(data.default_moduleList, 'thumbnail')
serverConfig.mockCache = data
uni.$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) {
console.log(error)
if (serverConfig.mockTimer[key]) clearInterval(serverConfig.mockTimer[key])
serverConfig.mockRequestCount = null
return Promise.reject(error)
}
}
const imgToBase64 = (list, urlKey, isArray = true) => {
return new Promise((resolve, reject) => {
let arr = [],
newList = JSON.parse(JSON.stringify(list))
if (isArray) {
list.map((e, index) => {
if (!e[urlKey]) return resolve(list)
if (!e[urlKey].startsWith('https')) return resolve(list)
uni.request({
url: urlKey ? e[urlKey] : e,
method: 'GET',
responseType: 'arraybuffer',
success: res => {
const base64 = `data:image/png;base64,${uni.arrayBufferToBase64(res.data)}`
newList[index][urlKey] = base64
newList[index][`original_${urlKey}`] = e[urlKey]
arr.push(e)
if (arr.length === list.length) resolve(newList)
},
fail: err => {
reject(err)
}
})
})
} else {
Object.keys(list).map(key => {
if (!list[key].startsWith('https')) return resolve(list)
uni.request({
url: list[key],
method: 'GET',
responseType: 'arraybuffer',
success: res => {
const base64 = `data:image/png;base64,${uni.arrayBufferToBase64(res.data)}`
newList[key] = base64
arr.push(key)
if (arr.length === Object.keys(list).length) resolve(newList)
},
fail: err => {
reject(err)
}
})
})
}
})
}
const updateMockData = (dataList, keyList, storageName = 'mock_data') => {
const mockData = uni.$storage.get(storageName)
keyList.map(key => {
mockData[key] = dataList[key]
})
setTimeout(() => {
uni.$storage.set(storageName, mockData)
}, 1e3)
}
/**
*获取比亚迪配置
*/
const getBydMockData = async (immediate = false) => {
const MOCKDATA = uni.$storage.get('byd_mock_data')
try {
if (!immediate && MOCKDATA && Date.now() - MOCKDATA.createTime < 5 * 60e3) {
return Promise.resolve(MOCKDATA)
} else {
if (!bydServerConfig.mockRequestCount || immediate) {
bydServerConfig.mockCache = null
bydServerConfig.mockRequestCount = Date.now()
const data = await http.uni_request({ url: bydConfigUrl })
data.createTime = Date.now()
data.moduleList = await imgToBase64(data.moduleList, 'thumbnail')
bydServerConfig.mockCache = data
uni.$storage.set('byd_mock_data', data)
return Promise.resolve(data)
} else {
const key = Date.now()
return new Promise(resolve => {
bydServerConfig.mockTimer[key] = setInterval(() => {
if (bydServerConfig.mockCache) {
clearInterval(bydServerConfig.mockTimer[key])
bydServerConfig.mockRequestCount = null
resolve(bydServerConfig.mockCache)
}
}, 1e3)
})
}
}
} catch (error) {
console.log(error)
if (bydServerConfig.mockTimer[key]) clearInterval(bydServerConfig.mockTimer[key])
bydServerConfig.mockRequestCount = null
return Promise.reject(error)
}
}
/**
*获取后台素材配置
*/
const findReceptionpriproConfigList = data => {
return http.post({
method: 'dj.api.smartcarlife.recepiton.customer.findReceptionpriproConfigList',
projectName: 'boutique',
...data
})
}
/**
*获取轻改配置
*/
const getBoutiqueMockData = async (immediate = false) => {
const MOCKDATA = uni.$storage.get('boutique_mock_data')
try {
if (!immediate && MOCKDATA && Date.now() - MOCKDATA.createTime < 5 * 60e3) {
return Promise.resolve(MOCKDATA)
} else {
if (!boutiqueServerConfig.mockRequestCount || immediate) {
boutiqueServerConfig.mockCache = null
boutiqueServerConfig.mockRequestCount = Date.now()
const data = await http.uni_request({ url: boutiqueConfigUrl })
data.createTime = Date.now()
boutiqueServerConfig.mockCache = data
uni.$storage.set('boutique_mock_data', data)
return Promise.resolve(data)
} else {
const key = Date.now()
return new Promise(resolve => {
boutiqueServerConfig.mockTimer[key] = setInterval(() => {
if (boutiqueServerConfig.mockCache) {
clearInterval(boutiqueServerConfig.mockTimer[key])
boutiqueServerConfig.mockRequestCount = null
resolve(boutiqueServerConfig.mockCache)
}
}, 1e3)
})
}
}
} catch (error) {
console.log(error)
if (boutiqueServerConfig.mockTimer[key]) clearInterval(boutiqueServerConfig.mockTimer[key])
boutiqueServerConfig.mockRequestCount = null
return Promise.reject(error)
}
}
// 图片版本号
const getImageVersion = async () => {
const accountInfo = await getMockData()
return accountInfo?.version || Date.now()
}
const systemApi = { getImageVersion, getMockData, imgToBase64, updateMockData, getBydMockData, getBoutiqueMockData, findReceptionpriproConfigList }
export default systemApi
import http from '../request/http'
const userApi = {
/**获取短信 */
getSmsCode(data = {}) {
data.projectName = 'boutique'
return http.fetch('dj.api.smartcarlife.sms.get.code', data)
},
/**手机验证码登录 */
smsLogin(data = {}) {
data.projectName = 'boutique'
data.source = 'MINIAPP'
data.productCode = 'PC00c2'
return http.fetch('dj.api.smartcarlife.sms.applogin', data)
},
/**免登 */
autoLogin(data = {}) {
data.projectName = 'boutique'
return http.fetch('dj.api.smartcarlife.sms.noSignIn.login', data)
},
// 获取园区店下的4s店
getSceneMerchantRefStoreList(data) {
data.projectName = 'boutique'
return http.post({
method: 'dj.api.scenemerchantref.query4SRefByYqShopByLogin',
...data
})
},
/**获取帐号列表 */
getListSelectAccount(data = {}) {
data.projectName = 'boutique'
return http.fetch('dj.api.smartcarlife.workWechat.listSelectAccount', data)
},
/**选择帐号登陆 */
selectAccountLogin(data) {
data.projectName = 'boutique'
return http.post({
method: 'dj.api.smartcarlife.workWechat.selectAccountLogin',
...data
})
},
// 选择4s店和场景
selectMerchantScene(data) {
data.projectName = 'boutique'
return http.post({
method: 'dj.api.smartcarlife.selectMerchantScene',
...data
})
},
// 获取园区店开通的场景入口
getYqMerchantSceneConfigAPI(data) {
data.projectName = 'boutique'
return http.post({
method: 'dj.api.smartcarlife.select.openScene.info',
...data
})
},
/**退出*/
logout(data = {}) {
data.projectName = 'boutique'
return http.fetch('dj.api.smartcarlife.logout', data)
},
/**
* 查询门店品牌 "渠道标识channelType 1.问界 2.比亚迪 3.其他"
*/
getMerchantBrand(data = {}) {
data.projectName = 'boutique'
return http.post({
method: 'dj.api.smartcarlife.recepiton.findMerchantBrand',
...data
})
},
/**
* 查询门店保险权益
*/
getMerchantInsuranceList(data = {}) {
data.projectName = 'boutique'
return http.post({
method: 'dj.api.smartcarlife.recepiton.findMerchantItem',
...data
})
},
/**
* 员工隐私密码验证
*/
verifyStaffPassword(data = {}) {
data.projectName = 'boutique'
return http.post({
method: 'dj.api.smartcarlife.staff.private.password.verify',
...data
})
}
}
export default userApi
import sign from './sign.js'
import { secretKey, pathEnum, domain, djDomain, merchantDomain, djSecretKey } from '../../env'
const HOST = {
scrm: domain,
dj: djDomain,
merchant: merchantDomain,
ip: 'http://192.168.1.169:8292'
}
class Request {
get(params, returnAll = false, hostType) {
return this.request('GET', params, returnAll, hostType)
}
post(params, returnAll = false, hostType) {
return this.request('POST', params, returnAll, hostType)
}
fetch(method, data, returnAll = true, hostType) {
return this.post(
{
method,
...data
},
returnAll,
hostType
)
}
request(RequestMethods, params, returnAll, hostType = 'dj') {
return new Promise((resolve, reject) => {
let _this = this
uni.getNetworkType({
success(res) {
if (res.networkType == 'none') {
uni.hideLoading()
// uni.showToast({
// title: '网络异常',
// icon: "error",
// });
reject('网络异常')
return
}
let header =
RequestMethods === 'POST'
? {
'content-type': 'application/x-www-form-urlencoded'
}
: {
'Cache-Control': 'no-cache'
}
let projectName = params.projectName
if (!projectName) projectName = _this.getRopProject(params.method)
const path = pathEnum[projectName]
params = _this.getData(params, hostType)
uni.request({
url: `${HOST[hostType]}${path}router?method=${params.method}`,
data: params,
method: RequestMethods,
header,
dataType: 'json',
responseType: 'text',
success(response) {
/**业务代码 */
let { data, statusCode } = response
if (!data || statusCode != 200) {
uni.hideLoading()
let errMsg = ''
if (!data) errMsg = '获取数据失败,请重试。'
else errMsg = '服务器暂时不可用,请稍后再次尝试。'
return reject(errMsg)
}
let { code, message } = data
if (returnAll) {
resolve(data)
return
}
if (code == 20 || code == 21) {
uni.hideLoading()
uni.reLaunch({
url: '/pages/common/login'
})
} else {
if (code == '0') {
resolve(data.data)
} else {
uni.hideLoading()
uni.showToast({
title: message || '系统异常',
icon: 'none'
})
}
}
},
fail(error) {
uni.hideLoading()
console.error(`${params.method}接口异常:`, error)
uni.showToast({
title: typeof error == 'string' ? error : error.errMsg ? error.errMsg : JSON.stringify(error) || '系统异常',
icon: 'error'
})
reject(error)
},
complete() {
uni.stopPullDownRefresh()
}
})
}
})
})
}
getData(params, hostType = 'scrm') {
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
}
if (hostType == 'dj') {
appKey = djSecretKey.appKey
secret = djSecretKey.secret
}
let { sessionId } = uni.$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 = 'app'
params.appKey = appKey
return sign(params, secret, noSignAttr)
}
getRopProject(method) {
const projectName = method.split('.')[2]
return projectName
}
uni_request({ url, method = 'GET', data = {}, header = {}, dataType = 'json', responseType = 'text' }) {
return new Promise(resolve => {
uni.request({
url,
data,
method,
header,
dataType,
responseType,
success(response) {
resolve(response.data)
}
})
})
}
}
export default new Request()
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2025-03-24 14:41:52
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2025-03-25 14:40:57
* @FilePath: \gltap-next\api\request\sign.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import sha1 from 'sha1'
import qs from 'qs'
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
const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 2
/**
*
0本地
1开发
2测试
3生产
4预发布
*/
const secretKey = {
ip: {},
dev: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
},
uat: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
},
prod: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
},
beta: {
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',
beta: 'https://scrm.beta.glsx.com.cn',
prod: 'https://scrm.glsx.com.cn'
}[target[index]]
const djDomain = {
ip: 'http://192.168.2.59:8292',
// ip: 'http://192.168.2.80:8558',
dev: 'http://dj.dev.glsx.com.cn',
beta: 'https://dj.beta.glsx.com.cn', //预发布 appid: wx9f91c1ec493eb425
uat: 'https://djpadtest.glsx.com.cn', //测试 appid: wxe10067a63c1856ac
prod: 'https://dj.glsx.com.cn',
pet: 'https://cdptest.glsx.com.cn' //压测 appid: wx7ce755e425603084
}[target[index]]
const merchantDomain = {
ip: 'http://rop-merchant.dev.glsx.com.cn',
dev: 'http://rop-merchant.dev.glsx.com.cn',
beta: 'https://rop-merchant.beta.glsx.com.cn',
uat: 'https://rop-merchant.test.glsx.com.cn',
prod: 'https://commodity.glsx.com.cn',
pet: ''
}[target[index]]
const djSecretKey = {
ip: {},
dev: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
uat: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
beta: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
prod: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022',
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
},
pet: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022',
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
}
}[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/',
mindworkplate: '/rop-dj-smartcarlife/',
drac: '/rop-scrm-entmicro/',
busassistant: '/rop-scrm-busassistant/',
boutique: '/rop-dj-car-boutique/',
merchants: '/rop-merchants/'
}
const CONFIG_ENV_MAP = {
1: 'develop',
2: 'test',
3: 'production',
4: 'beta'
}
const env = CONFIG_ENV_MAP[index]
export { index, domain, pathEnum, secretKey, env, djDomain, merchantDomain, djSecretKey }
This diff is collapsed. Click to expand it.
class SQLite {
constructor(name, version, description, size) {
this.name = name
this.version = version || '1.0'
this.description = description || 'SQLite DB'
this.size = size || 50 * 1024 * 1024 // 50MB
this.db = null
}
init() {
return new Promise((resolve, reject) => {
plus.sqlite.openDatabase({
name: this.name, // 数据库名称
path: `_doc/${this.name}.db`, // 数据库地址
success: resolve, // 直接使用 resolve
fail: reject // 直接使用 reject
})
})
}
selectSql(sql) {
return new Promise((resolve, reject) => {
uni.$logger.local.info(`执行SQL语句: ${sql}`)
plus.sqlite.selectSql({
name: this.name,
sql,
success: result => {
// 处理查询结果,尝试还原数组或对象字符串
const processedRows = result.map(row =>
Object.fromEntries(
Object.entries(row).map(([key, value]) => {
try {
// 尝试将字符串解析为对象或数组
return [key, JSON.parse(value)]
} catch {
// 如果解析失败,保留原始值
return [key, value]
}
})
)
)
resolve(processedRows)
},
fail: reject
})
})
}
executeSql(sql) {
return new Promise((resolve, reject) => {
uni.$logger.local.info(`执行SQL语句: ${sql}`)
plus.sqlite.executeSql({
name: this.name,
sql,
success: resolve,
fail: reject
})
})
}
async isTableExists(tableName) {
const sql = `SELECT COUNT(*) as isTable FROM sqlite_master WHERE type='table' and name='${tableName}'`
try {
const result = await this.selectSql(sql)
return result[0].isTable ? true : false
} catch (error) {
console.error('检查表是否存在出错: ', error)
throw error
}
}
// 创建新表示例
createTable(tableName, columns) {
const sql = `CREATE TABLE IF NOT EXISTS ${tableName} (${columns.join(', ')})`
return this.executeSql(sql)
}
// 查询示例
select(tabName, where, order) {
let sql = `SELECT * FROM ${tabName}`
if (where) {
const dataKeys = Object.keys(where)
const conditions = dataKeys.map(key => `${key}=${JSON.stringify(where[key])}`).join(' AND ')
sql += ` WHERE ${conditions}`
}
if (order) {
const orderKey = Object.keys(order)[0] // 获取排序字段
const orderType = order[orderKey] // 获取排序类型
sql += ` ORDER BY ${orderKey} ${orderType}`
}
return this.selectSql(sql)
}
// 插入示例
insert(tabName, keyValues) {
const keys = Object.keys(keyValues)
const keyStr = keys.join(', ')
const valStr = keys
.map(key => {
const value = keyValues[key]
// 使用公共方法进行格式化
return `${this.formatValue(value)}`
})
.join(', ')
const sql = `INSERT INTO ${tabName} (${keyStr}) VALUES (${valStr})`
return this.executeSql(sql)
}
// 更新示例
update(tabName, setData, where) {
const dataKeys = Object.keys(setData)
const setStr = dataKeys
.map(key => {
const value = setData[key]
return `${key} = ${this.formatValue(value)}`
})
.join(', ')
const whereKeys = Object.keys(where)
const whereStr = whereKeys
.map(key => {
const value = where[key]
return `${key} = ${this.formatValue(value)}`
})
.join(' AND ')
const sql = `UPDATE ${tabName} SET ${setStr} WHERE ${whereStr}`
return this.executeSql(sql)
}
// 删除示例
delete(tabName, where) {
const whereKeys = Object.keys(where)
const whereStr = whereKeys
.map(key => {
const value = where[key]
return `${key} = ${this.formatValue(value)}`
})
.join(' AND ')
const sql = `DELETE FROM ${tabName} WHERE ${whereStr}`
return this.executeSql(sql)
}
isOpen() {
let isopen = plus.sqlite.isOpenDatabase({
name: this.name,
path: `_doc/${this.name}.db`
})
return isopen
}
close() {
if (this.db) {
this.db.close()
this.db = null
console.log('数据库连接已关闭')
}
}
drop(tabName) {
const sql = `DROP TABLE ${tabName}`
return this.executeSql(sql)
}
formatValue(value) {
return typeof value === 'object' && value !== null ? `'${JSON.stringify(value)}'` : `'${value}'`
}
}
export default SQLite
// 使用示例
/* const db = new SQLite('mydb', '1.0', 'Test DB', 1 * 1024 * 1024);
db.init().then(() => {
// 进行数据库操作
}).catch(error => {
console.error('数据库初始化失败: ', error);
});*/
import App from './App'
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif
\ No newline at end of file
import { createPinia } from 'pinia'
const pinia = createPinia()
import { createApp } from 'vue'
import { Storage } from './utils/cache/index'
import api from './api/index'
uni.$api = api
// uni.$lock = false
uni.$storage = new Storage()
// 创建 Vue 3 应用实例
const app = createApp(App)
app.use(pinia) // 注册 Pinia
app.mount('#app') // 挂载应用
{
"dependencies": {
"md5": "^2.3.0",
"qs": "^6.14.0",
"sha1": "^1.1.1"
}
}
{
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
"pages": [
{
"path": "pages/index/index",
"path": "pages/login/index",
"style": {
"navigationBarTitleText": "uni-app"
"navigationStyle": "custom"
}
}
],
......@@ -14,4 +14,4 @@
"backgroundColor": "#F8F8F8"
},
"uniIdRouter": {}
}
}
\ No newline at end of file
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title">{{title}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
<template>
<view class="layout">
<view class="bg"></view>
<view class="login">
<view class="title">登录</view>
<view class="sub-title">手机号码登录</view>
<view class="input">
<input type="tel" v-model="mobile" placeholder="请输入手机号" maxlength="11" @blur="input($event, 'mobile')" :key="dateKey.mobile" />
<template v-if="mobile">
<view class="icon" @click="mobile = ''">
<icon type="clear" size="16" color="#000"></icon>
</view>
</template>
</view>
<view class="input">
<input type="number" v-model="code" placeholder="请输入验证码" maxlength="4" @blur="input($event, 'code')" :key="dateKey.code" />
<template v-if="code">
<view class="icon" @click="code = ''">
<icon type="clear" size="16" color="#000"></icon>
</view>
</template>
<view :class="['code-btn', count ? 'code-disabled' : '']" @click="getSmsCode">{{ count ? `重新发送(${count}s)` : '获取验证码' }}</view>
</view>
<button class="btn" @click="login">登录</button>
<view class="form-footer">
<view class="autoLogin" @click="readingStatus = !readingStatus">
<uni-icons :type="readingStatus ? 'checkbox-filled' : 'circle'" :size="18" :color="readingStatus ? '#2C66F7' : '#858A94'"></uni-icons>
我已阅读并同意
<text @click.stop="jumpUrl">《用户隐私协议》</text>
</view>
<view class="autoLogin" @click="noSignIn = !noSignIn">
<uni-icons :type="noSignIn ? 'checkbox-filled' : 'circle'" :size="18" :color="noSignIn ? '#2C66F7' : '#858A94'"></uni-icons>
30天内免登录
</view>
</view>
</view>
<view class="app-code flex">
APP编码:{{ deviceId }}
<view class="sprite-icon icon-clone" @click="copyText"></view>
</view>
<update-box />
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
const phoneRex = /^[1]([3-9])[0-9]{9}$/
// 响应式数据
const mobile = ref('')
const code = ref('')
const count = ref(0)
const noSignIn = ref(true)
const readingStatus = ref(true)
const deviceId = ref('')
const dateKey = ref({
mobile: 0,
code: 0
})
// 生命周期钩子
onMounted(() => {
const options = uni.getLaunchOptionsSync()
if (options?.query?.mobile) {
mobile.value = options.query.mobile
}
const noSignInUuid = uni.$storage.get('noSignInUuid')
if (noSignInUuid) autoLogin(noSignInUuid)
const deviceInfo = uni.getDeviceInfo()
deviceId.value = deviceInfo.deviceId
})
// 方法
const copyText = () => {
uni.setClipboardData({
data: deviceId.value,
success: () => {
uni.showToast({
title: '复制成功',
icon: 'success'
})
}
})
}
const autoLogin = async noSignInUuid => {
uni.showLoading({ mask: true })
const { data } = await uni.$api.userApi.autoLogin({ noSignInUuid })
uni.hideLoading()
if (data) jump(data, true)
}
const getSmsCode = async () => {
try {
if (!mobile.value) throw '请输入手机号'
if (!phoneRex.test(mobile.value)) throw '请输入正确的手机号'
if (count.value) throw '验证码发送过于频繁,请稍后再试'
uni.showLoading({ mask: true })
const { code, message } = await uni.$api.userApi.getSmsCode({ mobile: mobile.value })
uni.hideLoading()
if (code == '0') {
uni.$logger.local.info(`${mobile.value}发送验证码成功`)
uni.showToast({
title: '验证码已发送',
icon: 'none'
})
countDown(60)
} else {
throw message || '发送验证码失败'
}
} catch (error) {
uni.$logger.local.info(`${mobile.value}发送验证码失败,失败原因:${error}`)
uni.hideLoading()
uni.showToast({
title: error,
icon: 'none'
})
}
}
const countDown = countDown => {
if (countDown) count.value = countDown
setTimeout(() => {
count.value--
if (count.value > 0) countDown()
else count.value = 0
}, 1000)
}
const login = async () => {
try {
if (!mobile.value) throw '请输入手机号'
if (!phoneRex.test(mobile.value)) throw '请输入正确的手机号'
if (!code.value) throw '请输入验证码'
if (!readingStatus.value) throw '请阅读用户隐私协议'
const params = {
mobile: mobile.value,
code: code.value
}
if (noSignIn.value) params.noSignIn = noSignIn.value
uni.showLoading({ mask: true })
const { code: resCode, data, message } = await uni.$api.userApi.smsLogin(params)
uni.hideLoading()
if (resCode == 0) {
jump(data, noSignIn.value)
} else {
uni.showModal({
title: '温馨提示',
content: message,
showCancel: false,
confirmText: '知道了',
confirmColor: '#347BFF'
})
}
} catch (error) {
uni.hideLoading()
uni.showToast({
title: error,
icon: 'none'
})
}
}
const getAccountLoginList = loginUserInfoList => {
const stepIndex = loginUserInfoList?.length == 1 ? 1 : 0
uni.navigateTo({
url: `/pages/common/accountItems?stepIndex=${stepIndex}`
})
}
const jumpUrl = () => {
const url = 'https://img01.glsx.com.cn/weapp/resource/saas/app/privacy.html'
uni.navigateTo({
url: `/pages/common/webview?url=${url}`
})
}
const jump = (data, noSignIn) => {
const { loginUserInfoList, noSignInUuid, sessionId } = data
if (loginUserInfoList.length) {
uni.$storage.set('sessionId', sessionId)
if (noSignInUuid && noSignIn) uni.$storage.set('noSignInUuid', noSignInUuid)
getAccountLoginList(loginUserInfoList)
} else {
uni.reLaunch({
url: '/pages/common/nothing'
})
}
}
const input = (e, key) => {
setTimeout(() => {
const { value } = e.detail
const numbers = value.match(/\d+/g)
if (numbers) {
if (key === 'mobile') {
mobile.value = numbers.join('')
} else if (key === 'code') {
code.value = numbers.join('')
}
} else {
if (key === 'mobile') {
mobile.value = ''
} else if (key === 'code') {
code.value = ''
}
}
dateKey.value[key] = Date.now()
}, 0)
}
</script>
<style lang="scss" scoped>
.bg {
position: fixed;
width: 100%;
height: 100%;
left: 0;
top: 0;
background-size: 100% 100%;
}
.login {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
.title {
font-weight: 600;
font-size: 96rpx;
color: #333333;
text-align: center;
}
.sub-title {
font-weight: 500;
font-size: 32rpx;
color: #1a1a1a;
margin: 46rpx 0;
}
.input {
width: 800rpx;
height: 112rpx;
background: #f7f8fa;
border-radius: 56rpx;
margin-bottom: 40rpx;
box-sizing: border-box;
padding-left: 40rpx;
display: flex;
align-items: center;
input {
height: 100%;
flex: 1;
font-size: 32rpx !important;
}
.icon {
margin-left: auto;
flex-shrink: 0;
display: flex;
align-items: center;
padding: 0 40rpx;
height: 100%;
}
.code-btn {
font-weight: 500;
font-size: 32rpx;
color: #2c66f7;
flex-shrink: 0;
border: none;
margin-right: 40rpx;
}
.code-disabled {
color: #9b9b9e;
}
}
.btn {
width: 800rpx;
height: 112rpx;
background-image: linear-gradient(90deg, #48a6ff 0%, #2c66f7 100%);
border-radius: 56rpx;
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
font-size: 40rpx;
color: #ffffff;
}
.btn[disabled]:not([type]),
.btn[disabled][type='default'] {
background: #c9c9c9 !important;
}
.form-footer {
display: flex;
justify-content: center;
margin-top: 40rpx;
flex-direction: column;
gap: 38rpx 0;
padding-left: 142rpx;
.autoLogin {
display: flex;
align-items: center;
margin-right: 20rpx;
.uni-icons {
margin-right: 8rpx;
}
text {
color: #2c66f7;
}
}
}
}
.app-code {
position: fixed;
bottom: 20rpx;
left: 50%;
transform: translate(-50%);
font-size: 24rpx;
color: #999999;
line-height: 40rpx;
.icon-clone {
width: 24rpx;
height: 24rpx;
margin-left: 20rpx;
}
}
</style>
import { defineStore } from 'pinia'
export const useAppStore = defineStore('sys', {
state: () => ({
isInBackground: false // 修正拼写错误:isInBackgound -> isInBackground
}),
actions: {
setBackgroundState(value) {
uni.$logger.local.info(`【==== ${['切回', '切出'][+value]} ====】 APP`)
this.isInBackground = value // 直接修改 state
}
}
})
import { defineStore } from 'pinia'
export const useCustomerStore = defineStore('user', {
state: () => ({
customerInfo: {
customerName: '',
carBrand: '',
carModel: '',
phoneNumber: '',
salesUuid: '',
staffName: '',
newCarFare: '',
carModelId: ''
},
historyStatus: Date.now(),
carBrands: [],
employeeList: [],
paymentType: [],
haveCustomerAccess: false,
boutiqueMediaConfig: {},
receptionTrack: {}, // 接待记录埋点
boutiqueDefaultCarBrandId: '',
viewKey: Date.now(),
boutiqueCarList: [],
receptionKey: Date.now() // 接待记录埋点KEY
}),
actions: {
// 获取客户信息
getCustomerInfo() {
return this.customerInfo
},
// 设置客户信息
setCustomerInfo(data = {}) {
uni.$storage.set('customerInfo', JSON.stringify(data))
this.customerInfo = data
},
// 清空客户信息
clearCustomerInfo() {
const info = {
customerName: '',
carBrand: '',
carModel: '',
phoneNumber: '',
salesUuid: '',
staffName: '',
newCarFare: ''
}
uni.$storage.set('customerInfo', JSON.stringify(info))
this.customerInfo = info
},
// 清空历史状态
clearHistory() {
this.historyStatus = Date.now()
},
// 设置支付类型
setPaymentType(value) {
this.paymentType = value
},
// 设置汽车品牌列表
setCarBrandsList(value) {
this.carBrands = value
},
// 设置员工列表
setEmployeeList(value) {
this.employeeList = value
},
// 设置接待记录埋点
setReceptionTrack({ key, value }) {
this.receptionTrack[key] = value
this.receptionKey = Date.now()
},
// 清空接待记录埋点
clearReceptionTrack() {
this.receptionTrack = {}
this.receptionKey = Date.now()
},
// 更新视图 Key
updateViewKey() {
this.viewKey = Date.now()
}
}
})
// export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/'
// import util from '~/utils/util'
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/app-tape/'
// 缓存get方法为空的默认指定值
export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
// 缓存get方法key的对应才映射值
export const STORAGE_OBJECTKEY = {
DEFAULT_GET_STORAGEKEY,
mock_data: 'mock_data',
storageFile: 'storageFile',
userInfo: 'userInfo',
customerInfo: 'customerInfo',
noSignInUuid: 'noSignInUuid',
noviceGuideStatus: 'noviceGuideStatus',
carBrandList: 'carBrandList',
employeeList: 'employeeList',
recordList: 'recordList',
preRecordList: 'preRecordList',
preRecordId: 'preRecordId',
preRecord: 'preRecord',
preAudioList: 'preAudioList',
recordSuccessList: 'recordSuccessList',
historyList: 'historyList',
storageVersion: 'storageVersion',
clearVersion: 'clearVersion',
boutique_mock_data: 'boutique_mock_data',
findReceptionpriproConfigList: 'findReceptionpriproConfigList',
appInfoList: 'appInfoList'
}
import Storage from './storage'
import storageApi from './storageApi'
import * as constData from './constantData'
export { Storage, storageApi, constData }
/**
* 微信小程序标准版:统一封装的 storage 操作类
*/
import { DEFAULT_GET_STORAGEKEY, STORAGE_OBJECTKEY } from './constantData'
class Storage {
types = {
1: 'get', // get
2: 'set', // set
3: 'rm' // rm
}
envVersion = {
develop: '开发版',
trial: '体验版',
release: '正式版'
}
// defaultGetStorageKey = DEFAULT_GET_STORAGEKEY
/** 构造函数 */
constructor() {
}
/**
*
* @param {*} key | 要操作的键值
* @param {*} type | 类型,是 get set rm
* @param {*} emptyFlag | 是否判断为空情况,默认判断 true,false 为不判断
*/
checkKeyType (key, type, emptyFlag = true) {
if (typeof key != 'string') {
throw new Error(`Storage ${this.types[type]} func: key must be string`)
return false
}
if (emptyFlag) {
let tmpKey = key.TrimStr()
if (tmpKey == '') {
throw new Error(`Storage ${this.types[type]} func: key can not be empty`)
return false
}
// if STORAGE_OBJECTKEY[key]
return tmpKey
}
return key
}
/**
*
* @param {*} key | 要操作的键值
* @param {*} syncFlag | 同步状态,默认 false (异步),true 为同步
*/
get = (key, syncFlag = true) => {
// 有值默认取key值
if (key) {
// 判断值是否是指定的对象值
let tmpKey = this.checkKeyType(key, 1)
let isObjectKey = STORAGE_OBJECTKEY[tmpKey]
// console.log(key)
// console.log(isObjectKey)
if (isObjectKey) {
return this.getObjectKeyValue(isObjectKey)
} else {
throw new Error(`Storage ${this.types[1]} ${key}: key must be register`)
}
} else {
return this.getObjectKeyValue(DEFAULT_GET_STORAGEKEY)
}
}
/**
*
* @param {*} 空key返回默认定义数组的值
*/
getObjectKeyValue (key) {
// ObjectList
if (typeof key == 'string') {
key = this.addEvnToKey(key)
let res = uni.getStorageSync(key)
if (res) {
return JSON.parse(res)
} else {
// reject(errMsg)
return ''
}
} else {
let Obj = {}
key.forEach(key => {
let defaultKey = this.addEvnToKey(key)
let res = uni.getStorageSync(defaultKey)
Obj[key] = res ? JSON.parse(res) : ''
})
return Obj
}
}
/**
*
* @param {*} key | 要操作的键值
* @param {*} data | 要存储的值,会转换为 JSON 串进行存储
* @param {*} syncFlag | 同步状态,默认为同步 false (异步),true 为同步
*/
set = (key, data, syncFlag = true) => {
let tmpKey = this.checkKeyType(key, 2)
if (tmpKey) {
tmpKey = this.addEvnToKey(tmpKey)
const sucMsg = 'Storage set: set data successfully'
const errMsg = 'Storage set: failed to set data'
return new Promise((resolve, reject) => {
let tmpData = JSON.stringify(data)
if (syncFlag) {
try {
uni.setStorageSync(tmpKey, tmpData)
resolve(sucMsg)
} catch (err) {
console.log(err)
reject(errMsg)
}
} else {
uni.setStorage({
data: tmpData,
key: tmpKey,
success: () => {
resolve(sucMsg)
},
fail: err => {
console.log(err)
reject(errMsg)
}
})
}
// const storageInfo = uni.getStorageInfoSync();
// console.log(`Used storage size: ${storageInfo.currentSize} bytes`);
})
}
}
/**
*
* @param {*} key | 要操作的键值,为空则清空所有,有值则清空指定的值
* @param {*} syncFlag | 同步状态,默认 false (异步),true 为同步
*/
rm = (key = '', syncFlag = false) => {
let tmpKey = this.checkKeyType(key, 3, false)
tmpKey = tmpKey.TrimStr()
const sucMsg = 'Storage rm: rm data successfully'
const errMsg = 'Storage rm: failed to rm data'
return new Promise((resolve, reject) => {
if (tmpKey == '') {
if (syncFlag) {
try {
uni.clearStorageSync()
resolve(sucMsg)
} catch (err) {
console.log(err)
reject(errMsg)
}
} else {
uni.clearStorage({
success: res => {
resolve(sucMsg)
},
fail: err => {
console.log(err)
reject(errMsg)
}
})
}
} else {
tmpKey = this.addEvnToKey(tmpKey)
if (syncFlag) {
try {
uni.removeStorageSync(tmpKey)
resolve(sucMsg)
} catch (err) {
console.log(err)
reject(errMsg)
}
} else {
uni.removeStorage({
key: tmpKey,
success: () => {
resolve(sucMsg)
},
fail: err => {
console.log(err)
reject(errMsg)
}
})
}
}
})
}
/**
* @description: key 拼接小程序环境变量
* @param {*} key | 要操作的键值,
* @returns {String} 拼接后的值
*/
addEvnToKey = key => {
return `release_${key}`
}
}
/** 去除前导空格和后导空格 */
String.prototype.TrimStr = function () {
return this.replace(/(^\s*)|(\s*$)/g, '')
}
export default Storage
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-16 09:55:40
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-10-31 11:09:20
* @FilePath: \gl-tape\utils\cache\storageApi.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { STORAGE_OBJECTKEY } from './constantData'
// console.log(storage)
/** */
// 实例化对象存储
import Storage from './storage'
const storage = new Storage()
// console.log(storage)
/** */
export function getSessionId() {
return storage.get('sessionId')
}
export function setSessionId(sessionId) {
storage.set('sessionId', sessionId)
}
export function getUserInfo() {
return storage.get('userInfo')
}
export function setUserInfo(data) {
console.log(data)
storage.set('userInfo', data)
}
export function removeSystemStorage() {
// storage.rm('srcm_shopmall_user_info')
// storage.rm('scrm_shopmall_sessionId')
// storage.rm('guest_no')
// storage.rm('equity_info')
// storage.rm('packageList')
// storage.rm('isVIP')
// storage.rm('bizjiaUrl')
// storage.rm('vip_card_info')
}
export function setStorageSync(key, data) {
storage.set(key, JSON.stringify(data))
}
export function getStorageSync(key) {
return storage.get(key) || null
// JSON.parse(data)
}
/**设置标题栏 */
export function setNavigationBarTitleText(title) {
storage.set('app_title', title)
}
/**获取app标题 */
export function getNavigationBarTitleText() {
return storage.get('app_title')
}
/** 存储设备信息 */
export function setSystem_info(that) {
let info = storage.get('system_info')
!info &&
wx.getSystemInfo({
success(res) {
// console.log(res)
storage.set('system_info', res)
}
})
}
export function getRecords(record = 'recordList') {
return storage.get(STORAGE_OBJECTKEY[record])
}
export function setRecords(data, record = 'recordList') {
storage.set(STORAGE_OBJECTKEY[record], data)
}
export function removeRecords(record = 'recordList') {
storage.rm(STORAGE_OBJECTKEY[record])
}
export default {
getSessionId,
setSessionId,
getUserInfo,
setUserInfo,
removeSystemStorage,
setStorageSync,
getStorageSync,
setNavigationBarTitleText,
getNavigationBarTitleText,
setSystem_info,
getRecords,
setRecords,
removeRecords
}
import defaultStorage from './storage';
/**
* 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss')
*/
Date.prototype.format = function (fmt) {
let o = {
'M+': this.getMonth() + 1, //月份
'd+': this.getDate(), //日
'h+': this.getHours(), //小时
'm+': this.getMinutes(), //分
's+': this.getSeconds(), //秒
//季度
'q+': Math.floor((this.getMonth() + 3) / 3),
S: this.getMilliseconds() //毫秒
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
}
}
return fmt
}
export default defaultStorage;
\ No newline at end of file
export default {
// 设置永久缓存
set(key, value) {
uni.setStorageSync(key, value);
},
// 获取永久缓存
get(key) {
return uni.getStorageSync(key);
},
// 移除永久缓存
remove(key) {
uni.removeStorageSync(key);
},
// 移除全部永久缓存
clear() {
uni.clearStorageSync();
},
};
\ No newline at end of file
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 17:16:46
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2025-01-17 09:37:32
* @FilePath: \gl_tape\utils\utils.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
function convertDateTimeFormat(dateTimeStr, separator = '-') {
const date = new Date(dateTimeStr)
const year = date.getFullYear()
const month = ('0' + (date.getMonth() + 1)).slice(-2) // 月份是从0开始的
const day = ('0' + date.getDate()).slice(-2)
const hours = ('0' + date.getHours()).slice(-2)
const minutes = ('0' + date.getMinutes()).slice(-2)
const seconds = ('0' + date.getSeconds()).slice(-2)
return `${year}${separator}${month}${separator}${day} ${hours}:${minutes}:${seconds}`
}
export function deepClone(value) {
// 排除原始类型的情况,函数时也满足此条件
if (typeof value !== 'object' || value === null) {
return value
}
// 克隆结果:1.数组 2.普通对象
const result = Array.isArray(value) ? [] : {}
// 设置克隆结果的原型链为 value 的原型链(即保持原型一致)
Object.setPrototypeOf(result, Object.getPrototypeOf(value))
// 浅层克隆
for (const key in value) {
// 排除原型上的属性
if (value.hasOwnProperty(key)) {
result[key] = deepClone(value[key]) // 针对这个对象的每一个属性值进行克隆,则达到深度克隆效果
}
}
return result
}
//精确除法
function accDiv(arg1, arg2) {
var t1 = 0,
t2 = 0,
r1,
r2
try {
t1 = arg1.toString().split('.')[1].length
} catch (e) {}
try {
t2 = arg2.toString().split('.')[1].length
} catch (e) {}
r1 = Number(arg1.toString().replace('.', ''))
r2 = Number(arg2.toString().replace('.', ''))
return (r1 / r2) * Math.pow(10, t2 - t1)
}
// 两数相减
function calcAdd(num1, num2) {
var r1, r2, m
try {
r1 = num1.toString().split('.')[1].length
} catch (e) {
r1 = 0
}
try {
r2 = num2.toString().split('.')[1].length
} catch (e) {
r2 = 0
}
m = Math.pow(10, Math.max(r1, r2))
return (Math.round(num1 * m) + Math.round(num2 * m)) / m
}
function debounce(fn, timer) {
var t = null
return function () {
if (t) {
clearTimeout(t)
}
if (t == null) {
fn.apply(this, arguments)
}
t = setTimeout(() => {
t = null
}, timer)
}
}
// var throttle = function (fn, delay) {
// var timer = null;
// return function () {
// var context = this,
// args = arguments;
// clearTimeout(timer);
// timer = setTimeout(function () {
// fn.apply(context, args);
// }, delay);
// };
// };
var throttle = function (func, limit) {
let inThrottle
return function () {
const context = this
const args = arguments
if (!inThrottle) {
func.apply(context, args)
inThrottle = true
setTimeout(function () {
inThrottle = false
}, limit)
}
}
}
//检查是否有网络
var isNetWork = function () {
return new Promise((resolve, reject) => {
uni.getNetworkType({
complete: function (res) {
resolve(res.networkType !== 'none')
}
})
})
}
var uuid = function (len, radix) {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')
var uuid = [],
i
radix = radix || chars.length
if (len) {
// Compact form
for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)]
} else {
// rfc4122, version 4 form
var r
// rfc4122 requires these characters
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'
uuid[14] = '4'
// Fill in random data. At i==19 set the high bits of clock sequence as
// per rfc4122, sec. 4.1.5
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | (Math.random() * 16)
uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r]
}
}
}
return uuid.join('')
}
/**
* 获取文件系统根目录的完整路径
* 这个函数使用 HTML5 的 plus.io.requestFileSystem API 在私有文档目录中请求文件系统访问权限
* 当文件系统访问权限被授予后,使用 resolve 方法返回根目录的完整路径
* 这个 Promise 风格的函数可以被其他代码使用,以异步方式获取文件系统的根路径
* @returns {Promise<string>} 一个 Promise,当获取到文件系统根目录的完整路径时兑现,并返回根目录的路径作为字符串
*/
function getFilePath() {
return new Promise(resolve => {
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function (fs) {
resolve(fs.root.fullPath)
})
})
}
/** 比较版本号的大小
**/
function compareVersions(version1, version2) {
if (!version1 || !version2) return 0
const v1 = version1.split('.').map(v => +v) // 转化成数字数组
const v2 = version2.split('.').map(v => +v)
const b1 = v1.every(v => !isNaN(v)) // 判断数组的每一项是否是数字
const b2 = v2.every(v => !isNaN(v)) // 如果不是则返回错误信息
if (!b1 || !b2) return '版本号错误,只能包含数字、.'
const len = Math.max(v1.length, v2.length)
for (let i = 0; i < len; i++) {
const num1 = v1[i] || 0
const num2 = v2[i] || 0
if (num1 > num2) return 1 // 如果版本号1大于版本号2,则输出1
if (num1 < num2) return -1 // 反之则输出 -1
}
// 如果版本号1 等于版本号2,则输出0
return 0
}
async function getFileSaveFolderOnClient() {
const rootPath = await getFilePath()
return `file://${rootPath}uniapp_save/`
}
async function getAudioFilePath(path = '') {
const rootPath = await getFilePath()
return `file://${rootPath}${path}`
}
export function serializeIfObject(msg) {
return typeof msg === 'object' ? JSON.stringify(msg) : msg.toString()
}
export function isInteger(value) {
if (typeof value === 'number') {
return Number.isInteger(value)
} else if (typeof value === 'string') {
return /^-?\d+$/.test(value)
}
return false
}
export function singleton(className) {
let ins = null
const proxy = new Proxy(className, {
construct(target, args) {
if (!ins) {
ins = Reflect.construct(target, args)
}
return ins
}
})
proxy.prototype.constructor = proxy
return proxy
}
export default {
compareVersions,
convertDateTimeFormat,
deepClone,
accDiv,
debounce,
throttle,
isNetWork,
uuid,
getFilePath,
getFileSaveFolderOnClient,
serializeIfObject,
getAudioFilePath,
calcAdd
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!