Commit f4f08371 by chenwq

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

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