Browse Source

refactor(分享功能): 重构分享功能调用逻辑并更新分享图片配置

将分享功能调用从App.vue移至登录和store初始化逻辑中
更新微信分享图片配置为使用登录logo
hfll
主管理员 2 weeks ago
parent
commit
6f4574eaca
4 changed files with 21 additions and 7 deletions
  1. +0
    -6
      App.vue
  2. +11
    -0
      stores/index.js
  3. +9
    -0
      subPages/login/login.vue
  4. +1
    -1
      utils/share.js

+ 0
- 6
App.vue View File

@ -1,7 +1,4 @@
<script>
// #ifdef H5
import share from '@/utils/share.js'
// #endif
export default {
methods: {
//
@ -26,9 +23,6 @@
//
this.getQrcode()
// #ifdef H5
share()
// #endif
},
async onShow() {
// if(!uni.getStorageSync('token')){


+ 11
- 0
stores/index.js View File

@ -2,6 +2,10 @@ import Vue from 'vue'
import Vuex from 'vuex'
import * as api from '@/api'
// #ifdef H5
import share from '@/utils/share.js'
// #endif
Vue.use(Vuex)
const store = new Vuex.Store({
@ -87,8 +91,15 @@ const store = new Vuex.Store({
if (config.creen_image) {
uni.setStorageSync('screen_image', config.creen_image.content)
}
if (config.login_logo) {
uni.setStorageSync('login_logo', config.login_logo.content)
}
commit('setConfigList', config)
// #ifdef H5
share()
// #endif
},
// 查询部门列表
async getDepartment({ commit }) {


+ 9
- 0
subPages/login/login.vue View File

@ -62,6 +62,11 @@
</template>
<script>
// #ifdef H5
import share from '@/utils/share.js'
// #endif
import uvParse from '../../uni_modules/uv-parse/components/uv-parse/uv-parse.vue';
export default {
components: { uvParse },
@ -185,6 +190,10 @@ export default {
// store
this.$store.dispatch('updateUserInfo', userInfo);
// #ifdef H5
share()
// #endif
if (!userInfo.avatar || !userInfo.name || !userInfo.phone) {
uni.navigateTo({
url: '/subPages/login/userInfo'


+ 1
- 1
utils/share.js View File

@ -48,7 +48,7 @@ function share() { //微信分享
"link": addQueryParams(data.url),
"desc": "四零语境",
"title": "四零语境,温柔呵护每一刻!",
imgUrl: location.href.split('#')[0] + '/static/share/logo.png',
imgUrl: uni.getStorageSync('login_logo'),
success: function () {
//分享成功可以做相应的数据处理
console.log('注册分享成功');


Loading…
Cancel
Save