Commit acbda2df by wangzhihui

Merge branch 'SAAS+V5.7.1' of http://192.168.3.233:8090/saas_plus/dj-car-boutiqu…

…e-work-wechat into SAAS+V5.7.1
2 parents b2b02dbd f007ef98
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import newApi from '~/packageUsedCar/api' import newApi from '~/packageUsedCar/api'
import { setConfigInfo } from '~/store/index' import { setConfigInfo } from '~/store/index'
const IMG_URL = "https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/" const IMG_URL = "https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/"
import { checkDailyReport } from "~/packageUsedCar/ModalToQueueUsedCarControl";
function throttle(func, delay) { function throttle(func, delay) {
let timeoutId; let timeoutId;
let lastExecTime = 0; let lastExecTime = 0;
...@@ -86,7 +87,12 @@ Component({ ...@@ -86,7 +87,12 @@ Component({
}, { }, {
menuText: "检测管理", menuText: "检测管理",
icon: "crowdFunding/report" icon: "crowdFunding/report"
}], }, {
menuText: "车况信息",
icon: "usedCar/vehicle-message",
checkReport: true,
getOpenId: true
}],
current: 0, current: 0,
itemDataList: [{ itemDataList: [{
label: "二手车成交量", label: "二手车成交量",
...@@ -114,7 +120,8 @@ Component({ ...@@ -114,7 +120,8 @@ Component({
let { menuList } = this.data let { menuList } = this.data
try { try {
const config = await setConfigInfo(app.globalData) const config = await setConfigInfo(app.globalData)
const reportWebview = config?.report_webview const reportWebview = config?.report_webview
const vehicleWebView = config?.vehicle_webview
if (reportWebview) { if (reportWebview) {
const raw = String(reportWebview).trim().replace(/\/+$/, '') const raw = String(reportWebview).trim().replace(/\/+$/, '')
const hasHomePath = /\/home(?:[?#]|$)/.test(raw) const hasHomePath = /\/home(?:[?#]|$)/.test(raw)
...@@ -127,10 +134,10 @@ Component({ ...@@ -127,10 +134,10 @@ Component({
webviewUrl = `${raw}${sep}openType=miniApp` webviewUrl = `${raw}${sep}openType=miniApp`
} else { } else {
webviewUrl = `${raw}/home?openType=miniApp` webviewUrl = `${raw}/home?openType=miniApp`
} }
console.log('[report_webview] raw:', reportWebview, '=> final:', webviewUrl) console.log('[report_webview] raw:', reportWebview, '=> final:', webviewUrl)
menuList = menuList.map(item => menuList = menuList.map(item =>
item.menuText === '检测管理' ? { ...item, webviewUrl } : item item.menuText === '检测管理' ? { ...item, webviewUrl } : item.menuText === '车况信息' ? { ...item, webviewUrl: `${vehicleWebView}/vehicle-list` } : item
) )
} }
} catch (e) { } catch (e) {
...@@ -178,6 +185,14 @@ Component({ ...@@ -178,6 +185,14 @@ Component({
}, () => { }, () => {
this.getStatic() this.getStatic()
}) })
},
buildQuery(params) {
if (!params) return ''
return Object.keys(params)
.map(key => {
return `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`;
})
.join('&')
}, },
navGo: throttle(async function (e) { navGo: throttle(async function (e) {
let { item, h5Url } = e.currentTarget.dataset let { item, h5Url } = e.currentTarget.dataset
...@@ -187,12 +202,58 @@ Component({ ...@@ -187,12 +202,58 @@ Component({
const res = await newApi.checkPermissionsAPI({buttonCode: item.buttonCode}) const res = await newApi.checkPermissionsAPI({buttonCode: item.buttonCode})
wx.$util.hideLoading() wx.$util.hideLoading()
if (!res.data.data) return wx.$util.showToast('功能暂未开放') if (!res.data.data) return wx.$util.showToast('功能暂未开放')
} }
if (item.checkReport) {
// 校验是否填写日报
wx.$util.showLoading()
let staffCheck = await checkDailyReport(7)
wx.$util.hideLoading()
if (staffCheck) return
}
if (item.webviewUrl) { if (item.webviewUrl) {
const targetUrl = `/pages/webView/h5Full?url=${encodeURIComponent(item.webviewUrl)}` if (item.getOpenId) {
console.log('[navGo] webviewUrl:', item.webviewUrl, '=> navigateTo:', targetUrl) let openId = wx.$util.getOpenId()
wx.navigateTo({ url: targetUrl }) let sessionId = wx.$util.getSessionId()
return let userInfo = wx.$util.getUserInfo()
const queryObj = {
source: 2,
openId: openId,
sessionId: sessionId,
phone: userInfo.phone,
operator: userInfo.name,
operatorId: userInfo.uuid,
conversionUserId: userInfo.uuid,
conversionName: userInfo.name,
conversionMerchantId: userInfo.merchantId,
conversionMerchantName: userInfo.merchantName,
merchantId: userInfo.shopMerchantId,
merchantName: userInfo.shopMerchantName
};
const queryString = this.buildQuery(queryObj)
const finalPath = `${item.webviewUrl}?${queryString}`
return wx.requestSubscribeMessage({
tmplIds: ["MgjDgIpo1Xm8keYIUUtVbMbMj-Ms4q-xfbk7kM-L8EE"],
success(res) {
// wx.showToast({
// title: "订阅成功",
// icon: "none",
// });
return wx.navigateTo({
url: `/pages/webView/webView?url=${encodeURIComponent(finalPath)}`,
})
},
fail(res) {
return wx.navigateTo({
url: `/pages/webView/webView?url=${encodeURIComponent(finalPath)}`,
})
}
})
} else {
const targetUrl = `/pages/webView/h5Full?url=${encodeURIComponent(item.webviewUrl)}`
console.log('[navGo] webviewUrl:', item.webviewUrl, '=> navigateTo:', targetUrl)
wx.navigateTo({ url: targetUrl })
return
}
} }
if (!item.path) { if (!item.path) {
return wx.$util.showToast('功能暂不可用') return wx.$util.showToast('功能暂不可用')
......
...@@ -9,7 +9,8 @@ export function createWebViewPage(sharePagePath) { ...@@ -9,7 +9,8 @@ export function createWebViewPage(sharePagePath) {
return { return {
data: { data: {
flag: true, flag: true,
isH5Bind: false isH5Bind: false,
shareTitle: '报告详情'
}, },
getBaseUrl(url) { getBaseUrl(url) {
...@@ -42,12 +43,12 @@ export function createWebViewPage(sharePagePath) { ...@@ -42,12 +43,12 @@ export function createWebViewPage(sharePagePath) {
obj[key] = value obj[key] = value
} }
return obj return obj
}, },
onLoad: function (options) { onLoad: function (options) {
wx.$util.showLoading('加载中...') wx.$util.showLoading('加载中...')
let decodeUrl = decodeURIComponent(options.url) let decodeUrl = decodeURIComponent(options.url)
const baseUrl = this.getBaseUrl(decodeUrl) const baseUrl = this.getBaseUrl(decodeUrl)
try { try {
const stored = wx.getStorageSync(WEBVIEW_H5_TOKENS_KEY) const stored = wx.getStorageSync(WEBVIEW_H5_TOKENS_KEY)
if (stored) { if (stored) {
...@@ -83,7 +84,14 @@ export function createWebViewPage(sharePagePath) { ...@@ -83,7 +84,14 @@ export function createWebViewPage(sharePagePath) {
} }
}) })
this.setTime(param) this.setTime(param)
} }
// AI收车报告,特殊处理跳转,将登录人名称带入
if (decodeUrl.includes('/ai-purchase') && options?.push) {
let userInfo = wx.$util.getUserInfo()
this.setData({
url: `${decodeUrl}?pushed=${options.pushed}&source=${options.source}&carConditionCode=${options.carConditionCode}&operator=${userInfo.name}`
})
}
}, },
setTime(param) { setTime(param) {
...@@ -117,7 +125,7 @@ export function createWebViewPage(sharePagePath) { ...@@ -117,7 +125,7 @@ export function createWebViewPage(sharePagePath) {
}) })
} }
) )
} }
}, },
onHide: function () { onHide: function () {
...@@ -175,20 +183,22 @@ export function createWebViewPage(sharePagePath) { ...@@ -175,20 +183,22 @@ export function createWebViewPage(sharePagePath) {
onReachBottom: function () {}, onReachBottom: function () {},
onShareAppMessage() { onShareAppMessage(options) {
const { url } = this.data const { url, shareTitle } = this.data
if (options.webviewUrl.includes('/vehicle-detail')) shareTitle = '车况信息'
const encoded = encodeURIComponent(url || '') const encoded = encodeURIComponent(url || '')
return { return {
title: '报告详情', title: shareTitle,
path: `${sharePagePath}?url=${encoded}` path: `${sharePagePath}?url=${encoded}`
} }
}, },
onShareTimeline() { onShareTimeline() {
const { url } = this.data const { url, shareTitle } = this.data
if (options.webviewUrl.includes('/vehicle-detail')) shareTitle = '车况信息'
const encoded = encodeURIComponent(url || '') const encoded = encodeURIComponent(url || '')
return { return {
title: '报告详情', title: shareTitle,
query: `url=${encoded}` query: `url=${encoded}`
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!