feat 页面访问记录

develop
GJW200011 4 years ago
parent 01708bce28
commit 89a4b28f76

@ -0,0 +1,145 @@
const router_list = [
{
id: 1,
router_name: "pages/index/index/index",
},
{
id: 2,
router_name: "pages/user/login/login",
},
{
id: 3,
router_name: "pages/user/user_index/user",
},
{
id: 4,
router_name: "pages/opera/activity_topics/topics",
},
{
id: 5,
router_name: "pages/make_order/choose_sit/choose_sit",
},
{
id: 6,
router_name: "pages/make_order/coupon/coupon",
},
{
id: 7,
router_name: "pages/opera/opera/opera_IP",
},
{
id: 8,
router_name: "pages/user/my_show/finished_show/finished_show",
},
{
id: 9,
router_name: "pages/user/my_show/wanted_show/wanted_show",
},
{
id: 10,
router_name: "pages/user/my_order/my_order",
},
{
id: 11,
router_name: "pages/user/order_detail/order_detail",
},
{
id: 12,
router_name: "pages/opera/IP_more/IP_more",
},
{
id: 13,
router_name: "pages/opera/IP_detail/IP_detail",
},
{
id: 14,
router_name: "pages/make_order/make_order/make_order",
},
{
id: 15,
router_name: "pages/make_order/random_sit/random_sit",
},
{
id: 16,
router_name: "pages/opera/show/show_detail",
},
{
id: 17,
router_name: "pages/index/search/search",
},
{
id: 18,
router_name: "pages/user/invoice/invoice_index/invoice_index",
},
{
id: 19,
router_name: "pages/user/invoice/invoice_edit/invoice_edit_newMake",
},
{
id: 20,
router_name: "pages/user/invoice/invoice_edit/invoice_edit_content",
},
{
id: 21,
router_name: "pages/user/invoice/invoice_edit/invoice_edit",
},
{
id: 22,
router_name: "pages/user/invoice/invoice_history/invoice_history",
},
{
id: 23,
router_name: "pages/user/invoice/my_invoice/my_invoice",
},
{
id: 24,
router_name: "pages/user/invoice/make_invoice/make_invoice",
},
{
id: 25,
router_name: "pages/user/discount/discount/discount",
},
{
id: 26,
router_name: "pages/user/discount/coupons/coupons",
},
{
id: 27,
router_name: "pages/user/discount/discount_ex/discount_ex",
},
{
id: 28,
router_name: "pages/user/discount/discount_avilable/discount_avilable",
},
{
id: 29,
router_name: "pages/user/auto_service/auto_service",
},
{
id: 30,
router_name: "pages/user/wallet/wallet/wallet",
},
{
id: 31,
router_name: "pages/user/wallet/code_exchange/code_exchange",
},
{
id: 32,
router_name: "pages/user/viewer_list/viewer_list",
},
{
id: 33,
router_name: "pages/index/calendar/calendar",
},
{
id: 34,
router_name: "pages/index/city/selectcity"
},
]
module.exports = {
router_list
}

@ -4,7 +4,7 @@
*
* @param {*} Page 原生Page
*/
import {http,httpUtil} from './utils/util'
import { http, httpUtil, getRouter, location_city } from './utils/util'
const pageExtend = Page => {
return object => {
@ -16,7 +16,16 @@ const pageExtend = Page => {
// 公共的onLoad生命周期函数
object.onLoad = function (options) {
wx.getStorageSync('xid') ? "" : this.getxid()
if (!getApp().globalData.city_id) {
location_city().then(res => {
this.getroutermi(options, res.city_info.city_id)
})
} else {
this.getroutermi(options, getApp().globalData.city_id)
}
// 在onLoad中执行的代码
console.log(getCurrentPages()[getCurrentPages().length - 1].route, '拦截页面参数:')
console.log(options)
if (options.cps) {
@ -45,8 +54,24 @@ const pageExtend = Page => {
if (typeof onLoad === 'function') {
onLoad.call(this, options)
}
}
}
object.getroutermi = function (option, cityId) {
let xid = wx.getStorageSync('xid')
if (new Date().getTime() > xid.substring(0, xid.length - 4) - 0 + 1200000) {
this.getxid()
}
let data = { xid:wx.getStorageSync('xid'),action_id:getRouter(getCurrentPages()[getCurrentPages().length - 1].route),city_id:cityId-0,mini_type:1,...option}
http('/api/v1/user-behavior', 'post', data).then(res => {
console.log(res,'res');
})
}
object.getxid = function () {
// console.log(new Date().getTime(),'min');
// console.log(new Date().getTime()+(Math.floor(Math.random()*(9999-1000))+1000).toString(),'min');
let xid = new Date().getTime() + (Math.floor(Math.random() * (9999 - 1000)) + 1000).toString()
wx.setStorageSync('xid', xid)
}
return Page(object)
}
}

@ -39,7 +39,7 @@
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.17.3",
"libVersion": "2.20.0",
"appid": "wx35bc60d481961c1d",
"projectname": "miniprogram2",
"debugOptions": {

@ -1,6 +1,18 @@
import {
host
} from '../Gdata'
import { router_list } from '../config'
const getRouter = function () {
var pages = getCurrentPages() //获取加载的页面
var currentPage = pages[pages.length - 1] //获取当前页面的对象
let id = ''
router_list.forEach(item => {
if (item.router_name == currentPage.route) {
id = item.id
}
})
return id
}
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
@ -262,5 +274,6 @@ module.exports = {
httpUtil,
http,
login_check,
location_city
location_city,
getRouter
}

Loading…
Cancel
Save