From 3a84b58e41858d9f569430617d506867bc6986f5 Mon Sep 17 00:00:00 2001 From: slj Date: Tue, 10 May 2022 16:36:04 +0800 Subject: [PATCH] modify --- app.js | 3 +- pages/article/index.js | 4 ++ pages/billboards/index.js | 21 ++++++++ pages/home/index.js | 9 +++- pages/service/service.js | 5 +- pages/topics/activity/activityDetail/index.js | 37 +++++++++++-- .../topics/activity/activityDetail/index.wxss | 4 ++ pages/topics/attract/oceanDetail/index.js | 7 +++ pages/topics/attract/spaceDetail/index.js | 7 +++ pages/topics/index.js | 22 +++++++- pages/user/index.js | 53 ++++++++++++++++++- project.config.json | 3 +- 12 files changed, 163 insertions(+), 12 deletions(-) diff --git a/app.js b/app.js index b69c695..6028a65 100644 --- a/app.js +++ b/app.js @@ -26,6 +26,7 @@ App({ }) http.getConfig(res=>{ + console.log(res) if(res.result.projectFlag == 1){ this.globalData.flag = 1; } @@ -44,5 +45,5 @@ App({ screenHeight:'', flag:0, currentTab:'' - } + }, }) \ No newline at end of file diff --git a/pages/article/index.js b/pages/article/index.js index dca3f9d..8956408 100644 --- a/pages/article/index.js +++ b/pages/article/index.js @@ -71,6 +71,10 @@ Page({ aId: id }) this.fetchArticeApi() + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage'] + }); }, fetchArticeApi () { // wx.showLoading({ diff --git a/pages/billboards/index.js b/pages/billboards/index.js index 6cb2289..add4078 100644 --- a/pages/billboards/index.js +++ b/pages/billboards/index.js @@ -15,7 +15,28 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage'] + }); }, + onShareAppMessage: function (res) { + return { + title: '市北人才赋能平台', + path: 'pages/home/index', + } + }, + // onShareTimeline: function (res) { + // return { + // title: '市北人才赋能平台', + // success: function (res) { + // // 转发成功 + // }, + // fail: function (res) { + // // 转发失败 + // } + // } + // }, onClickItem (e) { const {index} = e.currentTarget.dataset console.log(index) diff --git a/pages/home/index.js b/pages/home/index.js index 01104e0..c99e805 100644 --- a/pages/home/index.js +++ b/pages/home/index.js @@ -35,6 +35,11 @@ Page({ this.fetchHomeBanner() this.fetchHomeHot() }) + + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage'] + }); }, /** * 页面相关事件处理函数--监听用户下拉动作 @@ -238,5 +243,7 @@ Page({ wx.navigateTo({ url: '/pages/resource/navigate/index?url=' + encodeURIComponent(this.data.web) }) - } + }, + + }) \ No newline at end of file diff --git a/pages/service/service.js b/pages/service/service.js index ef8654e..0e0d963 100644 --- a/pages/service/service.js +++ b/pages/service/service.js @@ -29,8 +29,11 @@ Page({ } }) + // wx.showShareMenu({ + // withShareTicket: true, + // menus: ['shareAppMessage', 'shareTimeline'] + // }); }, - /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/pages/topics/activity/activityDetail/index.js b/pages/topics/activity/activityDetail/index.js index d80e72d..77e4fe3 100644 --- a/pages/topics/activity/activityDetail/index.js +++ b/pages/topics/activity/activityDetail/index.js @@ -44,25 +44,42 @@ Page({ confirmTag: true, showMsg:false, flagShow: 0, + // scene:null }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { + console.log(options) this.setData({ activityId: options.activityId, flagShow: app.globalData.flag }) this.fetchDetail() this.fetchDetailMessage() + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage'] + }); + var obj = wx.getLaunchOptionsSync() + console.log('启动小程序场景-->:', obj) + // let scene=null + // //部分版本在无referrerInfo的时候会返回 undefined,可以做一下判断 + // if (options.referrerInfo && options.referrerInfo.appId) { + // scene=obj.scene + // } + // scene=obj.scene + // this.setData({ + // scene:obj.scene + // }) }, //活动详情 fetchDetail() { let activityId = this.data.activityId - // console.log('来活动详情' + activityId) + console.log('来活动详情1' + activityId) topicModel.getActivityDetail(activityId, res => { - console.log('来活动详情', res) + console.log('来活动详情2', res) let data = res.result const date = dayjs(data.createTime).format('MM月DD日') if(data.flag == 0 || data.flag == 1){ @@ -421,7 +438,17 @@ Page({ /** * 用户点击右上角分享 */ - onShareAppMessage: function () { - - } + onShareAppMessage(res) { + return { + title:this.data.title, + url: `/pages/topics/activity/activityDetail/index?activityId=${this.data.activityId}` + } + }, + // onShareTimeline: function () { + // return { + // title: this.data.title, // 可不填 + // query:`activityId=${this.data.activityId}`, // 可不填 传递的参数,只能是这种格式 + // // imageUrl: 'https://www.baidu.com/my/active3.png' // 可不填,可以是网络路径也可以是本地路径,分享到朋友圈显示的图标 + // } + // }, }) \ No newline at end of file diff --git a/pages/topics/activity/activityDetail/index.wxss b/pages/topics/activity/activityDetail/index.wxss index d0696be..177c7c8 100644 --- a/pages/topics/activity/activityDetail/index.wxss +++ b/pages/topics/activity/activityDetail/index.wxss @@ -220,4 +220,8 @@ .standView{ width: 100%; height: 160rpx; +} +.singleton-mode{ + width: 100%; + height: 100%; } \ No newline at end of file diff --git a/pages/topics/attract/oceanDetail/index.js b/pages/topics/attract/oceanDetail/index.js index 6b29271..f0a811e 100644 --- a/pages/topics/attract/oceanDetail/index.js +++ b/pages/topics/attract/oceanDetail/index.js @@ -45,6 +45,13 @@ Page({ path: `/pages/article/index?id=${this.data.aId}` } }, + // onShareTimeline: function () { + // return { + // title: this.data.title, // 可不填 + // query: `id=${this.data.aId}`, // 可不填 传递的参数,只能是这种格式 + // // imageUrl: 'https://www.baidu.com/my/active3.png' // 可不填,可以是网络路径也可以是本地路径,分享到朋友圈显示的图标 + // } + // }, /** * 生命周期函数--监听页面加载 */ diff --git a/pages/topics/attract/spaceDetail/index.js b/pages/topics/attract/spaceDetail/index.js index 9bbc49c..50d0e0d 100644 --- a/pages/topics/attract/spaceDetail/index.js +++ b/pages/topics/attract/spaceDetail/index.js @@ -41,6 +41,13 @@ Page({ path: `/pages/article/index?id=${this.data.aId}` } }, + // onShareTimeline: function () { + // return { + // title: this.data.title, // 可不填 + // query: `id=${this.data.aId}`, // 可不填 传递的参数,只能是这种格式 + // // imageUrl: 'https://www.baidu.com/my/active3.png' // 可不填,可以是网络路径也可以是本地路径,分享到朋友圈显示的图标 + // } + // }, /** * 生命周期函数--监听页面加载 */ diff --git a/pages/topics/index.js b/pages/topics/index.js index 2f55ab8..e51987d 100644 --- a/pages/topics/index.js +++ b/pages/topics/index.js @@ -49,8 +49,28 @@ Page({ this.setData({ flag: app.globalData.flag }) + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage'] + }); }, - + onShareAppMessage: function (res) { + return { + title: '市北人才赋能平台', + path: 'pages/home/index' + } + }, + // onShareTimeline: function (res) { + // return { + // title: '市北人才赋能平台', + // success: function (res) { + // // 转发成功 + // }, + // fail: function (res) { + // // 转发失败 + // } + // } + // }, //进入页面判断是否绑定微信号,如果绑定手机号根据segmentIndex的数值fetch留言互动和赋能中心的资源,否则退回注册页面或者首页 onShow: function () { //文章关联链接跳转 显示 报需求 还是来活动 tab diff --git a/pages/user/index.js b/pages/user/index.js index 08e4bbc..bd2c2b6 100644 --- a/pages/user/index.js +++ b/pages/user/index.js @@ -13,7 +13,10 @@ import { AuthModel } from '../../models/auth.js' let authModel = new AuthModel() - +import { + HomeModel +} from '../../models/home.js' +let homeModel = new HomeModel() import { ServiceModel } from '../../models/service.js' @@ -146,7 +149,8 @@ Page({ }, ], talentsType: -1, - shield: '../../images/shield.png' + shield: '../../images/shield.png', + banners: [], }, @@ -187,6 +191,51 @@ Page({ }) // console.log(this.data.servicePublic) }) + // this.fetchHomeBanner() + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage'] + }); + }, + onShareAppMessage: function (res) { + return { + title: '市北人才赋能平台', + path: 'pages/home/index', + // imageUrl:this.data.banners[0].image?this.data.banners[0].image:'' + } + }, + // onShareTimeline: function (res) { + // return { + // title: '市北人才赋能平台', + // success: function (res) { + // // 转发成功 + // }, + // fail: function (res) { + // // 转发失败 + // } + // } + // }, + fetchHomeBanner() { + this.setData({ + banners: [] + }) + homeModel.getHomeBanner(res => { + //console.log('Banner') + console.log(res) + const datas = res.list + let tempBanners = [] + datas.forEach(item => { + tempBanners.push({ + id: item.id, + image: item.titlePic, + title: item.title, + type: item.type + }) + }) + this.setData({ + banners: tempBanners + }) + }) }, onShow: function () { if (store.hasBindUserInfo()) { diff --git a/project.config.json b/project.config.json index 58e3a5f..b3fb320 100644 --- a/project.config.json +++ b/project.config.json @@ -40,7 +40,8 @@ "showES6CompileOption": false, "disableUseStrict": false, "useStaticServer": true, - "useCompilerPlugins": false + "useCompilerPlugins": false, + "minifyWXML": true }, "compileType": "miniprogram", "libVersion": "2.8.1",