hookehuyr

处理详情页分享跳转问题,首页封面图从系统参数里面取的问题

1 /* 1 /*
2 * @Date: 2023-12-22 10:29:37 2 * @Date: 2023-12-22 10:29:37
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-22 11:28:17 4 + * @LastEditTime: 2023-12-22 16:35:54
5 * @FilePath: /meihuaApp/src/api/index.js 5 * @FilePath: /meihuaApp/src/api/index.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -12,6 +12,7 @@ const Api = { ...@@ -12,6 +12,7 @@ const Api = {
12 SEND_SMS_CODE: '/srv/?a=room_order&t=send_sms_code', 12 SEND_SMS_CODE: '/srv/?a=room_order&t=send_sms_code',
13 SHOW_SESSION: '/srv/?a=room_order&t=show_session', 13 SHOW_SESSION: '/srv/?a=room_order&t=show_session',
14 SAVE_CUSTOMER_INFO: '/srv/?a=room_order&t=save_customer_info', 14 SAVE_CUSTOMER_INFO: '/srv/?a=room_order&t=save_customer_info',
15 + SYS_PARAM: '/srv/?a=room_order&t=sys_param',
15 } 16 }
16 17
17 /** 18 /**
...@@ -41,3 +42,9 @@ export const showMyInfoAPI = (params) => fn(fetch.get(Api.SHOW_SESSION, params)) ...@@ -41,3 +42,9 @@ export const showMyInfoAPI = (params) => fn(fetch.get(Api.SHOW_SESSION, params))
41 * @returns 42 * @returns
42 */ 43 */
43 export const saveCustomerInfoAPI = (params) => fn(fetch.post(Api.SAVE_CUSTOMER_INFO, params)); 44 export const saveCustomerInfoAPI = (params) => fn(fetch.post(Api.SAVE_CUSTOMER_INFO, params));
45 +
46 +/**
47 + * @description: 获取系统参数
48 + * @returns
49 + */
50 +export const sysParamAPI = (params) => fn(fetch.get(Api.SYS_PARAM, params));
......
1 /* 1 /*
2 * @Date: 2023-12-14 17:45:15 2 * @Date: 2023-12-14 17:45:15
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-22 09:28:22 4 + * @LastEditTime: 2023-12-22 17:41:53
5 * @FilePath: /meihuaApp/src/app.js 5 * @FilePath: /meihuaApp/src/app.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -16,15 +16,22 @@ const App = createApp({ ...@@ -16,15 +16,22 @@ const App = createApp({
16 onLaunch(options) { 16 onLaunch(options) {
17 // 未授权状态跳转授权页面,首页不需要权限 17 // 未授权状态跳转授权页面,首页不需要权限
18 const path = options.path; 18 const path = options.path;
19 + const query = options.query;
19 // 缓存没有权限的地址 20 // 缓存没有权限的地址
20 const router = routerStore(); 21 const router = routerStore();
21 router.add(path); 22 router.add(path);
22 // if (path !== 'pages/index/index' && !wx.getStorageSync("sessionid")) { 23 // if (path !== 'pages/index/index' && !wx.getStorageSync("sessionid")) {
23 if (!wx.getStorageSync("sessionid")) { 24 if (!wx.getStorageSync("sessionid")) {
24 console.warn("没有权限"); 25 console.warn("没有权限");
25 - Taro.navigateTo({ 26 + if (path === 'pages/detail/index') {
26 - url: './pages/auth/index', 27 + Taro.navigateTo({
27 - }) 28 + url: `./pages/auth/index?url=${path}&id=${query.id}&start_date=${query.start_date}&end_date=${query.end_date}`,
29 + })
30 + } else {
31 + Taro.navigateTo({
32 + url: './pages/auth/index?url=' + path,
33 + })
34 + }
28 } 35 }
29 }, 36 },
30 onShow (options) {}, 37 onShow (options) {},
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-22 15:07:20 4 + * @LastEditTime: 2023-12-22 17:41:02
5 * @FilePath: /meihuaApp/src/pages/auth/index.vue 5 * @FilePath: /meihuaApp/src/pages/auth/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -58,13 +58,17 @@ export default { ...@@ -58,13 +58,17 @@ export default {
58 // url: '../apxUserInfo/index' 58 // url: '../apxUserInfo/index'
59 // }) 59 // })
60 // } 60 // }
61 - // console.warn(getCurrentPageParam()); 61 + // TAG:处理分享跳转问题
62 - // Taro.reLaunch({ 62 + const params = getCurrentPageParam();
63 - // url: getCurrentPageParam().url 63 + if (getCurrentPageParam().url === 'pages/detail/index') { // 详情页的分享跳转处理
64 - // }) 64 + Taro.reLaunch({
65 - Taro.reLaunch({ 65 + url: `../../${params.url}?id=${params.id}&start_date=${params.start_date}&end_date=${params.end_date}`
66 - url: '/pages/index/index' 66 + })
67 - }) 67 + } else { // 其他页面分享跳首页
68 + Taro.reLaunch({
69 + url: `/pages/index/index`
70 + })
71 + }
68 Taro.hideLoading(); 72 Taro.hideLoading();
69 } 73 }
70 } else { 74 } else {
......
1 /* 1 /*
2 * @Date: 2023-12-15 13:57:34 2 * @Date: 2023-12-15 13:57:34
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-15 13:57:50 4 + * @LastEditTime: 2023-12-22 17:05:58
5 * @FilePath: /meihuaApp/src/pages/detail/index.config.js 5 * @FilePath: /meihuaApp/src/pages/detail/index.config.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -9,4 +9,5 @@ export default { ...@@ -9,4 +9,5 @@ export default {
9 navigationBarTitleText: '房间详情', 9 navigationBarTitleText: '房间详情',
10 usingComponents: { 10 usingComponents: {
11 }, 11 },
12 + enableShareAppMessage: true
12 } 13 }
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-21 16:49:40 4 + * @LastEditTime: 2023-12-22 17:38:15
5 * @FilePath: /meihuaApp/src/pages/detail/index.vue 5 * @FilePath: /meihuaApp/src/pages/detail/index.vue
6 * @Description: 房间详情页面 6 * @Description: 房间详情页面
7 --> 7 -->
...@@ -192,5 +192,39 @@ import mixin from '@/utils/mixin'; ...@@ -192,5 +192,39 @@ import mixin from '@/utils/mixin';
192 export default { 192 export default {
193 name: "detailPage", 193 name: "detailPage",
194 mixins: [mixin.init], 194 mixins: [mixin.init],
195 + onShareAppMessage(options) {
196 + let params = getCurrentPageParam();
197 + // 设置菜单中的转发按钮触发转发事件时的转发内容
198 + var shareObj = {
199 + title: "梅花岛-房间详情", // 默认是小程序的名称(可以写slogan等)
200 + path: `pages/detail/index?id=${params.id}&start_date=${params.start_date}&end_date=${params.end_date}`, // 默认是当前页面,必须是以‘/'开头的完整路径
201 + imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
202 + success: function (res) {
203 + // 转发成功之后的回调
204 + if (res.errMsg == 'shareAppMessage:ok') {
205 + //
206 + }
207 + },
208 + fail: function () {
209 + // 转发失败之后的回调
210 + if (res.errMsg == 'shareAppMessage:fail cancel') {
211 + // 用户取消转发
212 + } else if (res.errMsg == 'shareAppMessage:fail') {
213 + // 转发失败,其中 detail message 为详细失败信息
214 + }
215 + },
216 + complete: function () {
217 + // 转发结束之后的回调(转发成不成功都会执行)
218 + }
219 + }
220 + // 来自页面内的按钮的转发
221 + // if (options.from == 'button') {
222 + // var eData = options.target.dataset;
223 + // // 此处可以修改 shareObj 中的内容
224 + // shareObj.path = '/pages/goods/goods?goodId=' + eData.id;
225 + // }
226 + // 返回shareObj
227 + return shareObj;
228 + }
195 }; 229 };
196 </script> 230 </script>
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-22 15:31:12 4 + * @LastEditTime: 2023-12-22 17:09:11
5 * @FilePath: /meihuaApp/src/pages/index/index.vue 5 * @FilePath: /meihuaApp/src/pages/index/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
9 <view class="index-page"> 9 <view class="index-page">
10 <scroll-view :style="scrollStyle" :scroll-y="true" :scroll-top="scrollTop" :scroll-with-animation="true" @scroll="onScroll" @scrolltoupper="onScrollToUpper" @scrolltolower="onScrollToLower"> 10 <scroll-view :style="scrollStyle" :scroll-y="true" :scroll-top="scrollTop" :scroll-with-animation="true" @scroll="onScroll" @scrolltoupper="onScrollToUpper" @scrolltolower="onScrollToLower">
11 <view class="index-cover"> 11 <view class="index-cover">
12 - <image :style="coverStyle" mode="aspectFill" src="https://cdn.ipadbiz.cn/meihua/banner1@2x.png" /> 12 + <image :style="coverStyle" mode="aspectFill" :src="banner_url" />
13 <view @tap="onArrowDown" class="cover-arrow"> 13 <view @tap="onArrowDown" class="cover-arrow">
14 <IconFont color="#f9f9f9" size="30" name="joy-smile" class="nut-icon-am-jump nut-icon-am-infinite"></IconFont> 14 <IconFont color="#f9f9f9" size="30" name="joy-smile" class="nut-icon-am-jump nut-icon-am-infinite"></IconFont>
15 </view> 15 </view>
...@@ -50,6 +50,7 @@ import "./index.less"; ...@@ -50,6 +50,7 @@ import "./index.less";
50 // import { activityHomeAPI } from '@/api/Host/index' 50 // import { activityHomeAPI } from '@/api/Host/index'
51 import { $ } from '@tarojs/extend' 51 import { $ } from '@tarojs/extend'
52 import mixin from '@/utils/mixin'; 52 import mixin from '@/utils/mixin';
53 +import { sysParamAPI } from '@/api/index'
53 54
54 export default { 55 export default {
55 name: "indexPage", 56 name: "indexPage",
...@@ -128,7 +129,7 @@ export default { ...@@ -128,7 +129,7 @@ export default {
128 }; 129 };
129 }, 130 },
130 }, 131 },
131 - mounted () { 132 + async mounted () {
132 // 设置首页封面高度 133 // 设置首页封面高度
133 const windowHeight = wx.getSystemInfoSync().windowHeight; 134 const windowHeight = wx.getSystemInfoSync().windowHeight;
134 setTimeout(async () => { 135 setTimeout(async () => {
...@@ -142,9 +143,14 @@ export default { ...@@ -142,9 +143,14 @@ export default {
142 status: 'enable' 143 status: 'enable'
143 }) 144 })
144 } 145 }
146 + const { code, data } = await sysParamAPI();
147 + if (code) {
148 + this.banner_url = data.home_banner ? data.home_banner : 'https://cdn.ipadbiz.cn/meihua/banner1@2x.png';
149 + }
145 }, 150 },
146 data() { 151 data() {
147 return { 152 return {
153 + banner_url: '',
148 indexCoverHeight: 0, 154 indexCoverHeight: 0,
149 scrollTop: 0, 155 scrollTop: 0,
150 room_list: [], 156 room_list: [],
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
3 position: relative; 3 position: relative;
4 display: flex; 4 display: flex;
5 align-items: center; 5 align-items: center;
6 - background-color: #3a2013; 6 + // background-color: #3a2013;
7 + background-image: url('https://cdn.ipadbiz.cn/meihua/top@2x.png');
8 + background-size: cover;
7 color: #fff; 9 color: #fff;
8 padding: 40rpx 0 40rpx 25rpx; 10 padding: 40rpx 0 40rpx 25rpx;
9 .user-info { 11 .user-info {
......