import requst from './requst.js'; import toolAll from './tools.js'; import store from '@/store/index.js' export function collectionEV(data){//收藏事件 return requst.post('archives/record',data).then(res=>{ if(res.code==0) { let newMsg = '点赞成功' let num = 2 if(data.action=='collect'){ num = 3 newMsg = '收藏成功' } let maiOjb = { e:num,//内容收藏 c:data.archive_id*1, t:new Date().getTime()//当前时间戳 } toolAll.tools.maiDian(maiOjb) toolAll.tools.showToast(newMsg,'none',1500) } },error=>{}) } export function cancleCollectionEV(data){//取消收藏事件 return requst.post('archives/un-record',data).then(res=>{ if(res.code==0) { let newMsg = '已取消点赞' if(data.action=='collect'){ newMsg = '已取消收藏' } toolAll.tools.showToast(newMsg,'none',1500) } },error=>{}) } // 商品收藏、积分收藏 export function collectionShopEV(data){//收藏事件 console.log(data); return requst.post('spu/record',data).then(res=>{ if(res.code==0) { let newMsg = '' let num = 0 if(data.action=='collect'){ num = 3 newMsg = '收藏成功' } let maiOjb = { e:num,//内容收藏 c:data.id*1, t:new Date().getTime()//当前时间戳 } toolAll.tools.maiDian(maiOjb) toolAll.tools.showToast(newMsg,'none',1500) } },error=>{}) } export function cancleCollectionShopEV(data){//取消收藏事件 return requst.post('spu/un-record',data).then(res=>{ if(res.code==0) { let newMsg = '' if(data.action=='collect'){ newMsg = '已取消收藏' } toolAll.tools.showToast(newMsg,'none',1500) } },error=>{}) } export function buriedPoint(){//查询埋点类型事件 return requst.post('statistics/event').then(res=>{ // console.log('查询所有需要埋点的类型:',res); if(res.code==0) uni.setStorageSync('buriedPoint',res.data) },error=>{}) } export function reportBuriedPoint(data){//上报埋点事件 // console.log('埋点的数据:',data); return requst.post('statistics/report',data).then(res=>{},error=>{}) } export function themeEv(){//查询主题色 return requst.post('index/mini-program-setting','',false).then(res=>{ if(res.code==0){ if(res.data.length!=0){ let imgList = []; let titleList = []; if(res.data.footBar.length!=0){//底部导航 res.data.footBar.forEach(item=>{ let newName = item.name let newObj = { iconPath:'https://dxscrm.scdxtc.com' + item.icon[0], selectedIconPath:'https://dxscrm.scdxtc.com' + item.icon[1], } if(item.key=="home"){ imgList[0] = newObj titleList[0] = newName } if(item.key=="category"){ imgList[1] = newObj titleList[1] = newName } if(item.key=="service"){ imgList[2] = newObj titleList[2] = newName } if(item.key=="shop"){ imgList[3] = newObj titleList[3] = newName } if(item.key=="my"){ imgList[4] = newObj titleList[4] = newName } }) store.commit('updateState', { titleList, imgList, publicColor:res.data.mainColor }) } } } }) } export function checkSwip(){//查询主题色 return requst.post('common/slide-positions').then(res=>{ if(res.code==0){ console.log(res); } },error=>{}) } export function checkBanner(data){//查询banner return requst.post('common/slides',data,false) } export function checkQuan(){//查询优惠券 return requst.post('user/home-coupon',{},false).then(res=>{ if(res.code==0){ if(res.data.has_coupon==1){ uni.setStorageSync('isQuan',true); uni.setStorageSync('quanImg','https://dxscrm.scdxtc.com' + res.data.home_coupon.cover); uni.setStorageSync('quanId',res.data.home_coupon.id); } else { uni.setStorageSync('isQuan',false); } } }) }