前端-胡立永 3 weeks ago
parent
commit
8fed55e64c
5 changed files with 99 additions and 16 deletions
  1. +3
    -0
      main.js
  2. +68
    -0
      mixins/configList.js
  3. +15
    -15
      pages/index/index.vue
  4. +3
    -1
      store/store.js
  5. +10
    -0
      utils/utils.js

+ 3
- 0
main.js View File

@ -10,6 +10,9 @@ Vue.config.productionTip = false
App.mpType = 'app'
import store from '@/store/store'
import configList from '@/mixins/configList'
Vue.mixin(configList)
import './config'
import './utils/index.js'


+ 68
- 0
mixins/configList.js View File

@ -0,0 +1,68 @@
import { mapState } from 'vuex'
export default {
data() {
return {
// 默认的全局分享内容
Gshare: {
title: '遗产里的景徳镇',
path: '/pages_order/auth/wxLogin', // 全局分享的路径,比如 首页
// imageUrl: '/static/image/login/logo.png', // 全局分享的图片(可本地可网络)
}
}
},
computed: {
...mapState(['configList', 'userInfo']),
currentPagePath() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
let path = `/${currentPage.route}`;
// 获取当前页面的参数
const options = currentPage.options;
if (options && Object.keys(options).length > 0) {
const params = this.$utils.objectToUrlParams(options);
path += `?${params}`;
}
return path;
},
},
onLoad(query) {
if (query.shareId) {
uni.setStorageSync('shareId', query.shareId)
}
},
// 定义全局分享
// 1.发送给朋友
onShareAppMessage(res) {
let o = {
...this.Gshare,
}
if(this.userInfo.id){
if(this.Gshare.path.includes('?')){
o.path += '&shareId=' + this.userInfo.id
}else{
o.path += '?shareId=' + this.userInfo.id
}
}
return o
},
//2.分享到朋友圈
onShareTimeline(res) {
let o = {
...this.Gshare,
}
if(this.userInfo.id){
if(this.Gshare.path.includes('?')){
o.path += '&shareId=' + this.userInfo.id
}else{
o.path += '?shareId=' + this.userInfo.id
}
}
return o
},
methods: {
}
}

+ 15
- 15
pages/index/index.vue View File

@ -95,11 +95,11 @@
data() {
return {
baseList : [
// {
// icon : '/static/image/home/g1.png',
// title : '',
// path : '/pages_order/service/applyRelic',
// },
{
icon : '/static/image/home/g1.png',
title : '申遗历程',
path : '/pages_order/service/applyRelic',
},
{
icon : '/static/image/home/g2.png',
title : '遗产概况',
@ -110,11 +110,11 @@
title : '遗产讲述',
path : '/pages_order/service/tellList?type=tell',
},
{
icon : '/static/image/home/g4.png',
title : '达人同游',
path : '/pages_order/service/tellList?type=travel',
},
// {
// icon : '/static/image/home/g4.png',
// title : '',
// path : '/pages_order/service/tellList?type=travel',
// },
{
icon : '/static/image/home/g5.png',
title : '遗产路径',
@ -145,11 +145,11 @@
// title : '',
// path : '/pages_order/service/carefree',
// },
{
icon : '/static/image/home/g6.png',
title : '申遗新闻',
path : '/pages_order/service/newsList',
},
// {
// icon : '/static/image/home/g6.png',
// title : '',
// path : '/pages_order/service/newsList',
// },
],
bannerList: [
// {


+ 3
- 1
store/store.js View File

@ -5,6 +5,7 @@ Vue.use(Vuex); //vue的插件机制
import api from '@/api/api.js'
import Position from '@/utils/position.js'
import utils from '../utils/utils';
//Vuex.Store 构造器选项
const store = new Vuex.Store({
@ -229,7 +230,8 @@ const store = new Vuex.Store({
url: '/pages_order/auth/wxUserInfo'
})
}else{
uni.navigateBack(-1)
// uni.navigateBack(-1)
utils.navigateBack()
}
})
}


+ 10
- 0
utils/utils.js View File

@ -165,7 +165,17 @@ export function navigateTo(...args){
uni.navigateTo(params(...args))
}
/**
* 返回上一页
* @param {number} num - 返回的页面数默认为-1
*/
export function navigateBack(num = -1){
if(getCurrentPages().length == 1){
uni.reLaunch({
url: '/pages/index/index'
})
return
}
uni.navigateBack(num)
}


Loading…
Cancel
Save