Commit 6d0e81d6 by luyt

feat;传递api产品,场景数据

1 parent 5d4d22e5
......@@ -13,7 +13,8 @@ Component({
properties: {
stickyTop: Number,
actNum: Number,
senceData: Object,
senceData: Object, //本地数据
apiData:Object, //后端接口数据
isShare: {
type: Boolean,
value: false,
......
......@@ -5,7 +5,13 @@ import { senceData } from "./constant/data";
// `${IMG_URL}index/car2.png`,
//本地图片路径
let IMG_URLLocal = "../../../images/";
import { productBysceneApi,unreadApi,pageApi,readApi,tagApi } from "~/api/index.js";
import {
productBysceneApi,
unreadApi,
pageApi,
readApi,
tagApi,
} from "~/api/index.js";
Page({
// behaviors: [kfMixin],
......@@ -165,8 +171,8 @@ Page({
isShow: false,
// 看线索部分
unreadClueCount: 0,
cluePageSize:10,
clueCurrentPage: 1
cluePageSize: 10,
clueCurrentPage: 1,
},
//引导图
......@@ -216,28 +222,57 @@ Page({
sessionId,
};
let first = true
let first = true;
this.setData({
tabIndx: e.detail,
});
//标记线索已读
if(e.detail == 0 && first ){
first = false
readApi(param)
if (e.detail == 0 && first) {
first = false;
readApi(param);
}
},
gotoApply(e) {
let {type,item} = e.currentTarget.dataset
console.log('type,item: ', type,item);
if(type == "active"){
//申请活动
wx.$router.go("packageOutput.openBusiness");
}else{
let { userInfo } = wx.$storage.get();
let pMerchantName = userInfo.subLoginUser.merchantName
let pMerchantId = userInfo.subLoginUser.merchantId;
let sceneActive;
switch (this.data.actNum) {
case 0:
sceneActive = 1.1;
break;
case 1:
sceneActive = 1.2;
break;
case 2:
sceneActive = 1.3;
break;
case 3:
sceneActive = 1.4;
break;
}
// let pMerchantId = userInfo.subLoginUser.merchantId
let { type, item } = e.currentTarget.dataset;
// console.log("type,item: ", type, item);
const params = {
merchantInfo: {
pMerchantId,
pMerchantName,
merchantId: item.visitList[0].merchantId,
merchantName: item.visitList[0].merchantName,
},
sceneActive,
// sceneCodeList: ['SC001', 'SC002','SC003','SC004']
};
if (type == "active") {
//申请活动
wx.$router.go("packageOutput.openBusiness", params);
} else {
//申请门店
wx.$router.go("apply");
}
// wx.$router.go('apply',1235)
},
getMore(e) {
console.log("显示更多数据");
......@@ -448,41 +483,41 @@ Page({
this.setData({
apiData: data,
});
this.compositionData(senceData,this.data.apiData)
this.getFirstSenceIndex()
this.compositionData(senceData, this.data.apiData);
this.getFirstSenceIndex();
}
});
// 看线索
this.getClueInit()
this.getClueInit();
},
//接口数据,本地数据对接
compositionData(localData, apiData) {
localData.forEach((item, index) => {
apiData.forEach((inner,idx)=>{
if(item.name == inner.stage){
item.sceneStatus = inner.sceneStatus
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
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
})
senceData: localData,
});
},
getFirstSenceIndex(param){
let actTndex = this.data.apiData.findIndex(item =>item.sceneStatus == 1)
getFirstSenceIndex(param) {
let actTndex = this.data.apiData.findIndex((item) => item.sceneStatus == 1);
// console.log('actTndex: ', actTndex);
this.setData({
actNum:actTndex
})
actNum: actTndex,
});
},
// 看线索相关
......@@ -493,8 +528,8 @@ Page({
this.prompt = this.selectComponent("#toast");
},
showToast: function (e) {
let {type,item} = e.currentTarget.dataset;
console.log('type,item: ', type,item);
let { type, item } = e.currentTarget.dataset;
console.log("type,item: ", type, item);
let tipObj = {};
if (item.starTag == 1) {
tipObj = {
......@@ -526,60 +561,60 @@ Page({
//发请求
let { sessionId } = wx.$storage.get();
let params = {
clueId:item.clueId,
sessionId
}
this.getTagApi(params)
clueId: item.clueId,
sessionId,
};
this.getTagApi(params);
},
filterTypeFn(e) {
let index = e.currentTarget.dataset.index;
let itemList = [];
let params = {
clueSource:'',
hasPhone:'',
starTag:''
}
clueSource: "",
hasPhone: "",
starTag: "",
};
console.log("index: ", index);
switch (index) {
case 0:
itemList = ["无","有"];
itemList = ["无", "有"];
break;
case 1:
itemList = ["否","是"];
itemList = ["否", "是"];
break;
case 2:
itemList = ["访客", "门店"]; //线索来源(1访客,2门店)
break;
case 3:
params = {
clueSource:'',
hasPhone:'',
starTag:''
}
clueSource: "",
hasPhone: "",
starTag: "",
};
break;
}
let _this = this;
wx.pro.showActionSheet({
itemList,
success(res) {
let num
if(index == 2){
num = res.tapIndex+1
}else{
num = res.tapIndex
let num;
if (index == 2) {
num = res.tapIndex + 1;
} else {
num = res.tapIndex;
}
switch (index) {
case 0:
params.hasPhone = num
params.hasPhone = num;
break;
case 1:
params.starTag = num
params.starTag = num;
break;
case 2:
params.clueSource = num
params.clueSource = num;
break;
}
_this.getPageApi(params)
_this.getPageApi(params);
},
fail(res) {
console.log(res.errMsg);
......@@ -588,10 +623,9 @@ Page({
console.log("res: ", res);
},
});
if(index == 3){
this.getPageApi(params)
if (index == 3) {
this.getPageApi(params);
}
},
// 打电话
phoneCallFn(e) {
......@@ -604,48 +638,48 @@ Page({
let { phone } = e.currentTarget.dataset;
wx.$api.setCopyData(phone);
},
getClueInit(param){
this.getUnreadApi(param)
this.getPageApi(param)
getClueInit(param) {
this.getUnreadApi(param);
this.getPageApi(param);
},
//未读消息
async getUnreadApi(param){
let {code,data} = await unreadApi(param)
if(code == 0){
this.setData({
unreadClueCount:data.unreadClueCount
})
async getUnreadApi(param) {
let { code, data } = await unreadApi(param);
if (code == 0) {
this.setData({
unreadClueCount: data.unreadClueCount,
});
}
},
//获取浏览线索数据列表
async getPageApi(param){
let {cluePageSize,clueCurrentPage} = this.data
async getPageApi(param) {
let { cluePageSize, clueCurrentPage } = this.data;
let params = {
...param,
pageSize:1000,
currentPage:clueCurrentPage
}
let {code,data} = await pageApi(params)
if(code == 0){
let arr = data.list.map(item=>{
if(item.visitList.length >5){
item.getMoreFlag = true
pageSize: 1000,
currentPage: clueCurrentPage,
};
let { code, data } = await pageApi(params);
if (code == 0) {
let arr = data.list.map((item) => {
if (item.visitList.length > 5) {
item.getMoreFlag = true;
}
return item
})
return item;
});
this.setData({
clueList: arr
})
clueList: arr,
});
}
},
//喜欢收藏功能
async getTagApi(param){
let res = await tagApi(param)
console.log('res: ', res);
this.getPageApi(param)
async getTagApi(param) {
let res = await tagApi(param);
console.log("res: ", res);
this.getPageApi(param);
},
onReachBottom(){
console.log("滑到底部了")
onReachBottom() {
console.log("滑到底部了");
},
/**
* 生命周期函数--监听页面显示
......
......@@ -22,7 +22,7 @@
</view>
</view>
</view>
<product stickyTop="{{headerHeight}}" actNum="{{actNum}}" senceData="{{senceData}}" bindsharehandle="sharehandle" />
<product stickyTop="{{headerHeight}}" actNum="{{actNum}}" senceData="{{senceData}}" apiData="{{apiData}}" bindsharehandle="sharehandle" />
</view>
<!-- 看线索内容 -->
<view class="clue" wx:if="{{tabIndx == 0 }}" hover-class="none" hover-stop-propagation="false">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!