Commit 6d0e81d6 by luyt

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

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