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 @@
import newApi from '~/packageUsedCar/api'
import { setConfigInfo } from '~/store/index'
const IMG_URL = "https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/"
import { checkDailyReport } from "~/packageUsedCar/ModalToQueueUsedCarControl";
function throttle(func, delay) {
let timeoutId;
let lastExecTime = 0;
......@@ -86,7 +87,12 @@ Component({
}, {
menuText: "检测管理",
icon: "crowdFunding/report"
}],
}, {
menuText: "车况信息",
icon: "usedCar/vehicle-message",
checkReport: true,
getOpenId: true
}],
current: 0,
itemDataList: [{
label: "二手车成交量",
......@@ -114,7 +120,8 @@ Component({
let { menuList } = this.data
try {
const config = await setConfigInfo(app.globalData)
const reportWebview = config?.report_webview
const reportWebview = config?.report_webview
const vehicleWebView = config?.vehicle_webview
if (reportWebview) {
const raw = String(reportWebview).trim().replace(/\/+$/, '')
const hasHomePath = /\/home(?:[?#]|$)/.test(raw)
......@@ -127,10 +134,10 @@ Component({
webviewUrl = `${raw}${sep}openType=miniApp`
} else {
webviewUrl = `${raw}/home?openType=miniApp`
}
}
console.log('[report_webview] raw:', reportWebview, '=> final:', webviewUrl)
menuList = menuList.map(item =>
item.menuText === '检测管理' ? { ...item, webviewUrl } : item
item.menuText === '检测管理' ? { ...item, webviewUrl } : item.menuText === '车况信息' ? { ...item, webviewUrl: `${vehicleWebView}/vehicle-list` } : item
)
}
} catch (e) {
......@@ -178,6 +185,14 @@ Component({
}, () => {
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) {
let { item, h5Url } = e.currentTarget.dataset
......@@ -187,12 +202,58 @@ Component({
const res = await newApi.checkPermissionsAPI({buttonCode: item.buttonCode})
wx.$util.hideLoading()
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) {
const targetUrl = `/pages/webView/h5Full?url=${encodeURIComponent(item.webviewUrl)}`
console.log('[navGo] webviewUrl:', item.webviewUrl, '=> navigateTo:', targetUrl)
wx.navigateTo({ url: targetUrl })
return
if (item.getOpenId) {
let openId = wx.$util.getOpenId()
let sessionId = wx.$util.getSessionId()
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) {
return wx.$util.showToast('功能暂不可用')
......
......@@ -9,7 +9,8 @@ export function createWebViewPage(sharePagePath) {
return {
data: {
flag: true,
isH5Bind: false
isH5Bind: false,
shareTitle: '报告详情'
},
getBaseUrl(url) {
......@@ -42,12 +43,12 @@ export function createWebViewPage(sharePagePath) {
obj[key] = value
}
return obj
},
},
onLoad: function (options) {
wx.$util.showLoading('加载中...')
let decodeUrl = decodeURIComponent(options.url)
const baseUrl = this.getBaseUrl(decodeUrl)
const baseUrl = this.getBaseUrl(decodeUrl)
try {
const stored = wx.getStorageSync(WEBVIEW_H5_TOKENS_KEY)
if (stored) {
......@@ -83,7 +84,14 @@ export function createWebViewPage(sharePagePath) {
}
})
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) {
......@@ -117,7 +125,7 @@ export function createWebViewPage(sharePagePath) {
})
}
)
}
}
},
onHide: function () {
......@@ -175,20 +183,22 @@ export function createWebViewPage(sharePagePath) {
onReachBottom: function () {},
onShareAppMessage() {
const { url } = this.data
onShareAppMessage(options) {
const { url, shareTitle } = this.data
if (options.webviewUrl.includes('/vehicle-detail')) shareTitle = '车况信息'
const encoded = encodeURIComponent(url || '')
return {
title: '报告详情',
title: shareTitle,
path: `${sharePagePath}?url=${encoded}`
}
},
onShareTimeline() {
const { url } = this.data
const { url, shareTitle } = this.data
if (options.webviewUrl.includes('/vehicle-detail')) shareTitle = '车况信息'
const encoded = encodeURIComponent(url || '')
return {
title: '报告详情',
title: shareTitle,
query: `url=${encoded}`
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!