Commit f4f08371 by chenwq

feat(scene): 优化场景选择逻辑,简化代码并移除冗余场景配置

1 parent 0346e090
...@@ -4,7 +4,6 @@ import api from '~/api/api' ...@@ -4,7 +4,6 @@ import api from '~/api/api'
import { checkLoginEnvironment } from '~/utils/loginEnvironmentCheck' import { checkLoginEnvironment } from '~/utils/loginEnvironmentCheck'
const app = getApp() const app = getApp()
import { getYQorderInfo, get4SStoreList } from '~/store/index' import { getYQorderInfo, get4SStoreList } from '~/store/index'
import { getShopSceneConfig } from '~/store/index'
import { setUserInfo } from '~/utils/cache/storageApi' import { setUserInfo } from '~/utils/cache/storageApi'
Page({ Page({
/** /**
...@@ -38,18 +37,18 @@ Page({ ...@@ -38,18 +37,18 @@ Page({
console.log(id, 'id') console.log(id, 'id')
id ? this.qrCodeScene(id) : this.getListSelectAccount() id ? this.qrCodeScene(id) : this.getListSelectAccount()
}, },
/**
* 账号确认后进入门店选择,避免已保存的业务配置跳过用户确认步骤。
* @param {string|number} yqMerchantId 园区店商户标识
* @param {object} loginUserObj 已确认的账号信息
* @returns {Promise<void>}
*/
async getSceneArr(yqMerchantId, loginUserObj) { async getSceneArr(yqMerchantId, loginUserObj) {
if (!wx.$hasPermission?.canSkipValidation?.(loginUserObj)) { if (!wx.$hasPermission?.canSkipValidation?.(loginUserObj)) {
let checkAgree = await this.checkAgree(loginUserObj) let checkAgree = await this.checkAgree(loginUserObj)
if (!checkAgree) return false if (!checkAgree) return false
} }
if (wx.$hasPermission?.canSelectMultiStore?.(loginUserObj)) return this.get4SStoreList(loginUserObj)
// 获取4s店关联场景数据
getShopSceneConfig({ yqMerchantId }).then(result => {
if (!result?.length)
return wx.$util.showToast('暂无开通业务,请联系总部管理员')
this.get4SStoreList(loginUserObj)
})
}, },
open() { open() {
this.setData({ this.setData({
...@@ -267,10 +266,6 @@ Page({ ...@@ -267,10 +266,6 @@ Page({
get4SStoreList(loginUserObj) { get4SStoreList(loginUserObj) {
let { merchantId, uuid } = loginUserObj let { merchantId, uuid } = loginUserObj
const canSkip = wx.$hasPermission?.canSelectMultiStore?.(loginUserObj) const canSkip = wx.$hasPermission?.canSelectMultiStore?.(loginUserObj)
if (canSkip) {
wx.$router.go('pages.sceneIndex')
return
}
get4SStoreList( get4SStoreList(
{ {
merchantId: canSkip ? undefined : merchantId, merchantId: canSkip ? undefined : merchantId,
...@@ -279,18 +274,12 @@ Page({ ...@@ -279,18 +274,12 @@ Page({
canSkip, canSkip,
true true
).then(result => { ).then(result => {
let obj = (result && result[0]) || {} if (!result?.length) {
// 仅一家4s店
if (result?.length == 1) {
this.setShopMerchantObj(obj)
wx.$router.go('pages.sceneIndex')
} else if (!result?.length) {
return wx.$util.showToast( return wx.$util.showToast(
'园区店关联的4s店商户账号无效,请联系总部管理员' '园区店关联的4s店商户账号无效,请联系总部管理员'
) )
} else {
wx.$router.go('pages.merchantList')
} }
wx.$router.go('pages.merchantList')
}) })
}, },
......
const sceneList = [ const sceneList = [
{ {
sceneName: '精品升级',
sceneDesc: '太阳膜升级转化下单',
sceneType: 1,
actived: false,
recordId:1,
},
{
sceneName: '会员权益/升级',
sceneDesc: '新车车损险下单',
sceneType: 0,
actived: false,
recordId:2,
},
{
sceneName: '售后众筹',
sceneDesc: '门店存量客户众筹下单',
sceneType: 3,
actived: false,
recordId:3,
},
{
sceneName: '次新车转化',
sceneDesc: '次新车用户领取套餐包转化',
sceneType: 2,
actived: false,
recordId:4,
},
{
sceneName: '二手车', sceneName: '二手车',
sceneDesc: '二手车业务', sceneDesc: '二手车业务',
sceneType: 7, sceneType: 7,
...@@ -36,12 +8,7 @@ const sceneList = [ ...@@ -36,12 +8,7 @@ const sceneList = [
} }
] ]
// 0 会员权益升级 1 精品升级 3 售后众筹 ,2次新车转化
const pageUrl = { const pageUrl = {
0: 'packageEquity.equityPage',
1: 'tabIndex.index',
3: 'packageCrowdFunding.crowdFundingPage',
2: 'subvehicleConversion.conversionPage',
7: 'packageUsedCar.usedCarPage' 7: 'packageUsedCar.usedCarPage'
} }
......
...@@ -105,4 +105,4 @@ Page({ ...@@ -105,4 +105,4 @@ Page({
this.initData(false) this.initData(false)
} }
} }
})
\ No newline at end of file \ No newline at end of file
})
// pages/sceneIndex/sceneIndex.js // pages/sceneIndex/sceneIndex.js
import constantData from "../constant/data"; import constantData from "../constant/data";
import api from "~/api/api"; import api from "~/api/api";
import { getShopSceneConfig, getBusinessSchoolScene } from "~/store/index";
import { ImgUrl } from "~/config"; import { ImgUrl } from "~/config";
// import reportPageTrackMixin from '~/mixins/reportPageTrackMixin' // import reportPageTrackMixin from '~/mixins/reportPageTrackMixin'
Page({ Page({
...@@ -24,19 +23,11 @@ Page({ ...@@ -24,19 +23,11 @@ Page({
if (jumpPageFlag) return; if (jumpPageFlag) return;
this.setData({ jumpPageFlag: true }); this.setData({ jumpPageFlag: true });
let userInfo = wx.$util.getUserInfo(); let userInfo = wx.$util.getUserInfo();
if (!openSceneArr.includes(Number(scene))) {
if (
!openSceneArr.includes(scene) &&
!wx.$hasPermission?.canSelectMultiStore?.(userInfo)
) {
this.setData({ jumpPageFlag: false }); this.setData({ jumpPageFlag: false });
return wx.$util.showToast("暂未开通此场景"); return wx.$util.showToast("暂未开通二手车场景");
}
// 非驻店人员不可进入二手车场景
if (wx.$hasPermission?.canSelectMultiStore?.(userInfo) && scene == 7) {
this.setData({jumpPageFlag: false})
return wx.$util.showToast("暂未开放")
} }
sceneList.map((i) => (i.actived = false)); sceneList.map((i) => (i.actived = false));
sceneList[index].actived = true; sceneList[index].actived = true;
// if (userInfo?.isSuper) { // if (userInfo?.isSuper) {
...@@ -96,50 +87,33 @@ Page({ ...@@ -96,50 +87,33 @@ Page({
}); });
this.getSceneArr(); this.getSceneArr();
}, },
selectBusinessschoo() { /**
// wx.$router.go('packageEquity.collegeScene', { reLaunchPath: 'pages.sceneIndex' }) * 查询当前账号在已选门店开通的二手车场景,阻止未开通账号进入业务首页。
wx.$router.go("packageEquity.collegeScene"); * @returns {Promise<void>}
}, */
getSceneArr() { getSceneArr() {
// 超管默认开通全部场景
let userInfo = wx.$util.getUserInfo(); let userInfo = wx.$util.getUserInfo();
if (wx.$hasPermission?.isSuper?.(userInfo)) return this.setData({ showPage: true }); api
wx.$util.showLoading(); .getYqMerchantSceneConfigAPI({
// 获取4s店关联场景数据 yqMerchantId: userInfo?.subLoginUser?.merchantId,
getShopSceneConfig({ merchantId: userInfo?.shopMerchantId,
yqMerchantId: userInfo?.subLoginUser?.merchantId, })
merchantId: wx.$hasPermission?.isSuper?.(userInfo) ? undefined : userInfo?.shopMerchantId, .then(({ code, data, message }) => {
}).then((result) => { if (code != 0) {
wx.$util.hideLoading(); wx.$util.showToast(message);
let arr = return;
result?.filter(v => v.sceneOpenFlag == 0)?.map((val) => {
return val.scene;
}) || [];
for (var i = 0; i < arr.length; i++) {
if (arr.indexOf(arr[i]) !== i) {
arr.splice(i, 1);
i--;
} }
} const openSceneArr = (data || [])
// 仅开通一个场景直接进入场景页面 .filter((item) => item.sceneOpenFlag == 0 && item.scene == 7)
if (arr.length == 1) { .map((item) => Number(item.scene));
wx.$util.setUserInfo({ this.setData({ openSceneArr });
...wx.$util.getUserInfo(), })
sceneType: arr[0], .catch(() => {
}); wx.$util.showToast("场景开通状态查询失败");
wx.$router.reLaunch("pages.loading"); })
} .finally(() => {
this.setData({ openSceneArr: arr, showPage: true }); this.setData({ showPage: true });
}); });
getBusinessSchoolScene({}).then((res) => {
console.log(res, "res");
if (res || wx.$hasPermission?.isSuper?.(userInfo)) {
this.setData({
businessschooScene: true,
});
}
// }
});
}, },
/** /**
...@@ -152,12 +126,8 @@ Page({ ...@@ -152,12 +126,8 @@ Page({
*/ */
onShow() { onShow() {
let { sceneList } = this.data; let { sceneList } = this.data;
let userInfo = wx.$util.getUserInfo();
sceneList.map((i) => { sceneList.map((i) => {
i.actived = false; i.actived = i.sceneType == 7;
if (i.sceneType == userInfo?.sceneType) {
i.actived = true;
}
return i; return i;
}); });
this.setData({ sceneList, jumpPageFlag: false }); this.setData({ sceneList, jumpPageFlag: false });
......
...@@ -12,21 +12,5 @@ ...@@ -12,21 +12,5 @@
</view> </view>
</view> </view>
</block> </block>
<block wx:if="{{businessschooScene}}">
<view class="businessSchoolTitle">
工资绩效
</view>
<view class="businessSchoolBox">
<view class="scene-item {{item.actived ? 'active' : ''}}" bindtap="selectBusinessschoo">
<view class="left">
<image class="scene-icon" src="{{ImgUrl}}/crowdFunding/businessschoo.png" />
<view class="item-text">
<view class="name">工资绩效</view>
<view class="desc">员工绩效提成</view>
</view>
</view>
</view>
</view>
</block>
</scroll-view> </scroll-view>
</view>
\ No newline at end of file \ No newline at end of file
</view>
...@@ -275,17 +275,12 @@ Page({ ...@@ -275,17 +275,12 @@ Page({
}) })
} }
}, },
checkLoginMessage(needSelectAccount, loginUserObj) { /**
if (!needSelectAccount && Object.keys(loginUserObj)?.length && (loginUserObj?.shopMerchantId || wx.$hasPermission?.canSelectMultiStore?.(loginUserObj)) && !((loginUserObj?.sceneType ?? '') === '')) { * 登录成功后统一从账号选择开始,避免接口缓存的选择状态跳过账号、门店或场景步骤。
this.getYqMerchantSceneConfig(loginUserObj, 0) * @returns {void}
} else if (!needSelectAccount && Object.keys(loginUserObj)?.length && loginUserObj?.shopMerchantId && (loginUserObj?.sceneType ?? '') === '') { // 已选园区店、4s店 */
this.getYqMerchantSceneConfig(loginUserObj, 1) checkLoginMessage() {
} else if (!needSelectAccount) { // 仅选择园区店 wx.$router.reLaunch('pages.accountItems')
this.getYqMerchantSceneConfig(loginUserObj, 2)
} else { // 未记录到登录信息
// this.getAccountLoginList(loginUserInfoList)
this.getAccountLoginList(needSelectAccount)
}
}, },
playCountDown() { playCountDown() {
let { let {
...@@ -733,4 +728,4 @@ Page({ ...@@ -733,4 +728,4 @@ Page({
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { } onReachBottom: function () { }
})
\ No newline at end of file \ No newline at end of file
})
...@@ -256,6 +256,6 @@ ...@@ -256,6 +256,6 @@
"tabIndent": "insertSpaces", "tabIndent": "insertSpaces",
"tabSize": 2 "tabSize": 2
}, },
"appid": "wx570d9331f9ace0bd", "appid": "wx39a574d259fe58a0",
"simulatorPluginLibVersion": {} "simulatorPluginLibVersion": {}
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!