From 78c9bfbcd85dc154692161cf812f5e38e929329c Mon Sep 17 00:00:00 2001 From: unknown <331404948@qq.com> Date: Tue, 26 Sep 2023 20:28:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/tabbar/index/index.vue | 5 ++- store/index.js | 4 +- store/modules/add.js | 91 -------------------------------------------- store/modules/school.js | 91 ++++++++++++++++++++++++++++++++++++++++++++ store/modules/user.js | 1 + 5 files changed, 97 insertions(+), 95 deletions(-) delete mode 100644 store/modules/add.js create mode 100644 store/modules/school.js diff --git a/pages/tabbar/index/index.vue b/pages/tabbar/index/index.vue index 7df73d5..f12eaca 100644 --- a/pages/tabbar/index/index.vue +++ b/pages/tabbar/index/index.vue @@ -16,7 +16,7 @@ --> - + @@ -277,7 +277,8 @@ }, async onLoad() { await this.$store.dispatch('getCity') - // console.log('有 啦') + console.log('有 啦') + console.log(this.$store.state.user.vuex_cityInfo) // console.log(this.$store.state.user.vuex_cityInfo) }, diff --git a/store/index.js b/store/index.js index 50a9fb1..cc030fc 100644 --- a/store/index.js +++ b/store/index.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import Vuex from 'vuex'; -import add from './modules/add'; +import school from './modules/school'; import user from './modules/user'; import getters from './getters'; @@ -26,7 +26,7 @@ const store = new Vuex.Store({ }, modules: { - add, + school, user, }, }); diff --git a/store/modules/add.js b/store/modules/add.js deleted file mode 100644 index d5e9a65..0000000 --- a/store/modules/add.js +++ /dev/null @@ -1,91 +0,0 @@ - -// import addApi from '@/api/add.js'; // 引入 - -const add = { - state: { - addList: [] - }, - mutations: { - // 更新广告列表 - upDateAddList(state, list) { - state.addList = list - }, - - // 更新当前广告点击量 - upDateViews(state, id) { - let add = state.addList.find(item=>item.id==id) - add.clicks ++ - }, - - - - - }, - actions: { - // 点击广告 - async addClick({commit, dispatch}, curAdd) { - // await dispatch('updateStatistics') - curAdd.clicks ++ - if(!curAdd.adBannerDO.jumpUrl) { - return false - } - - commit('updateWebVeiwUrl', curAdd.adBannerDO.jumpUrl) - uni.navigateTo({ - url:'/pages/commeWebView/addWebView' - }) - }, - // 获取当前广告 - getCurrentAdd({state},id) { - console.log(id) - console.log(state.addList) - let curAdd = state.addList.find(item=>item.id==id) - if(curAdd) { - curAdd.views ++ - return curAdd - }else { - return {} - } - }, - // // 广告 - // async addPageFn({commit,state, dispatch}) { - // await dispatch('updateStatistics') - // let obj = { - // pageNo: 1, - // pageSize: 30, - // adClient: 1 - // } - // const [err, res] = await addApi.addPage(obj) - // let list = res.data.records.map(item=>{ - // item.views = 0 - // item.clicks = 0 - // return item - // }) - // commit('upDateAddList', list) - // console.log('广告列表') - // console.log(list) - - // }, - // 更新广告点击量 - async updateStatistics({ dispatch,state, commit }) { - let statistics = state.addList.filter(item=>item.views) - console.log('调用更新广告接口') - if(statistics.length) { - let stcsList = statistics.map(add=>{ - let obj = { - "adPositionId": add.id, - "adId": add.adId, - "views": add.views, - "clicks": add.clicks - } - return obj - }) - const [err, res] = await addApi.batchUpdate(stcsList) - console.log('更新广告点击量请求结果') - console.log(res) - } - } - } -} - - export default add \ No newline at end of file diff --git a/store/modules/school.js b/store/modules/school.js new file mode 100644 index 0000000..d5e9a65 --- /dev/null +++ b/store/modules/school.js @@ -0,0 +1,91 @@ + +// import addApi from '@/api/add.js'; // 引入 + +const add = { + state: { + addList: [] + }, + mutations: { + // 更新广告列表 + upDateAddList(state, list) { + state.addList = list + }, + + // 更新当前广告点击量 + upDateViews(state, id) { + let add = state.addList.find(item=>item.id==id) + add.clicks ++ + }, + + + + + }, + actions: { + // 点击广告 + async addClick({commit, dispatch}, curAdd) { + // await dispatch('updateStatistics') + curAdd.clicks ++ + if(!curAdd.adBannerDO.jumpUrl) { + return false + } + + commit('updateWebVeiwUrl', curAdd.adBannerDO.jumpUrl) + uni.navigateTo({ + url:'/pages/commeWebView/addWebView' + }) + }, + // 获取当前广告 + getCurrentAdd({state},id) { + console.log(id) + console.log(state.addList) + let curAdd = state.addList.find(item=>item.id==id) + if(curAdd) { + curAdd.views ++ + return curAdd + }else { + return {} + } + }, + // // 广告 + // async addPageFn({commit,state, dispatch}) { + // await dispatch('updateStatistics') + // let obj = { + // pageNo: 1, + // pageSize: 30, + // adClient: 1 + // } + // const [err, res] = await addApi.addPage(obj) + // let list = res.data.records.map(item=>{ + // item.views = 0 + // item.clicks = 0 + // return item + // }) + // commit('upDateAddList', list) + // console.log('广告列表') + // console.log(list) + + // }, + // 更新广告点击量 + async updateStatistics({ dispatch,state, commit }) { + let statistics = state.addList.filter(item=>item.views) + console.log('调用更新广告接口') + if(statistics.length) { + let stcsList = statistics.map(add=>{ + let obj = { + "adPositionId": add.id, + "adId": add.adId, + "views": add.views, + "clicks": add.clicks + } + return obj + }) + const [err, res] = await addApi.batchUpdate(stcsList) + console.log('更新广告点击量请求结果') + console.log(res) + } + } + } +} + + export default add \ No newline at end of file diff --git a/store/modules/user.js b/store/modules/user.js index ec63add..93b52c3 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -34,6 +34,7 @@ const user = { getCity({commit}) { return new Promise((resolve, reject) => { // #ifdef APP-PLUS||H5 + console.log('h5经纬度的代码') getCityInfo(resolve, reject,commit) // #endif // #ifdef MP-WEIXIN