Commit 9d3daf15 by luyt

fix:本地数据与线上数据合并问题

1 parent 643d6712
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
const navStyle = "background-color: #fff"; const navStyle = "background-color: #fff";
import { senceData } from "~/pages/tab/index/constant/data"; import { senceData } from "~/pages/tab/index/constant/data";
import { IMG_URL } from "~/utils/constantData.js"; import { IMG_URL } from "~/utils/constantData.js";
import { productBysceneApi } from '~/api/index.js'
import Draw from "~/utils/Draw.js"; import Draw from "~/utils/Draw.js";
import { createQrCodeApi, sceneByIdApi } from "~/api/checkProduct.js"; import { createQrCodeApi, sceneByIdApi } from "~/api/checkProduct.js";
import utils from "~/utils/util.js"; import utils from "~/utils/util.js";
...@@ -93,6 +94,45 @@ Page({ ...@@ -93,6 +94,45 @@ Page({
isShow: true, isShow: true,
}); });
}, },
//如果是直接查看页面,获取合成apiData
getData() {
console.log(123456)
// 看产品
productBysceneApi().then(res => {
let { code, data } = res
if (code == 0 && data) {
// this.setData({
// apiData: data
// })
this.compositionData(senceData, data)
// this.getFirstSenceIndex();
}
})
},
//接口数据,本地数据对接
compositionData(localData, apiData) {
localData.forEach((item, index) => {
apiData.forEach((inner, idx) => {
if (item.name == inner.stage) {
item.sceneStatus = inner.sceneStatus
item.productList.forEach((outChild, outIndex) => {
inner.productList.forEach((innerChild, innerIndex) => {
if (outChild.proName == innerChild.productName) {
outChild.productStatus = innerChild.productStatus
}
})
})
}
})
})
// console.log('localData, apiData: ', localData);
this.setData({
senceData: localData
})
},
//接受跳转的路由参数(小程序页面跳转) //接受跳转的路由参数(小程序页面跳转)
onRoute(options) { onRoute(options) {
console.log("分享options: ", options); console.log("分享options: ", options);
...@@ -280,6 +320,7 @@ Page({ ...@@ -280,6 +320,7 @@ Page({
* 生命周期函数--监听页面加载 (扫码,分享链接) * 生命周期函数--监听页面加载 (扫码,分享链接)
*/ */
async onLoad(options) { async onLoad(options) {
this.getData()
console.log("分享options12255565: ", options); console.log("分享options12255565: ", options);
// actNum,activeNavIdx isShare // actNum,activeNavIdx isShare
if (!options || utils.isEmptyObj(options)) return; if (!options || utils.isEmptyObj(options)) return;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!