Browse Source

控制分享返回按钮&鱼市通知页面

viczhq 4 months ago
parent
commit
32cbf43d2e

+ 14 - 7
project.private.config.json

@@ -10,6 +10,20 @@
10 10
     "miniprogram": {
11 11
       "list": [
12 12
         {
13
+          "name": "pages/mineSub/inform/index",
14
+          "pathName": "pages/mineSub/inform/index",
15
+          "query": "",
16
+          "launchMode": "default",
17
+          "scene": null
18
+        },
19
+        {
20
+          "name": "pages/indexSub/activity/index",
21
+          "pathName": "pages/indexSub/activity/index",
22
+          "query": "isShare=true",
23
+          "launchMode": "default",
24
+          "scene": null
25
+        },
26
+        {
13 27
           "name": "pages/mineSub/explain/index",
14 28
           "pathName": "pages/mineSub/explain/index",
15 29
           "query": "",
@@ -52,13 +66,6 @@
52 66
           "scene": null
53 67
         },
54 68
         {
55
-          "name": "pages/indexSub/activity/index",
56
-          "pathName": "pages/indexSub/activity/index",
57
-          "query": "",
58
-          "launchMode": "default",
59
-          "scene": null
60
-        },
61
-        {
62 69
           "name": "pages/indexSub/seckillIndex/index",
63 70
           "pathName": "pages/indexSub/seckillIndex/index",
64 71
           "query": "id=124&title=%E8%82%AF%E9%BA%A6%E5%BF%85%E6%BD%AE%E8%B6%B4&isBanner=true",

+ 2 - 1
src/app.config.js

@@ -39,7 +39,8 @@ export default defineAppConfig({
39 39
       pages: [
40 40
         "infoEdit/index",
41 41
         "userSpecification/index",
42
-        "explain/index"
42
+        "explain/index",
43
+        "inform/index"
43 44
       ]
44 45
     },
45 46
     {

+ 22 - 4
src/pages/indexSub/activity/index.jsx

@@ -3,6 +3,7 @@ import { View, Image, Text, ScrollView } from "@tarojs/components";
3 3
 import { AtTabs, AtActivityIndicator } from "taro-ui";
4 4
 import "./index.less";
5 5
 import Taro from "@tarojs/taro";
6
+import { getShareSwitch } from "../../../service";
6 7
 import {
7 8
   getNewYearTab,
8 9
   getNewYearProductList,
@@ -17,6 +18,7 @@ export default class Index extends Component {
17 18
     tabList: [], //tab列表
18 19
     productList: [], //商品列表
19 20
     isShare: false, // 是否是分享跳转
21
+    shareSwitch: 1, //分享返回开关
20 22
     isShowBack: false, // 是否显示返回按钮
21 23
   };
22 24
   componentDidMount() {
@@ -29,8 +31,8 @@ export default class Index extends Component {
29 31
         shareUserId: shareUserId || "",
30 32
       },
31 33
       () => {
32
-        if (isShare) {
33
-          Taro.hideHomeButton(); //隐藏返回首页
34
+        if (this.state.isShare) {
35
+          this.getShareSwitch(); //获取分享开关
34 36
         }
35 37
         this.getTab(); //获取tab
36 38
         handleLog({
@@ -45,6 +47,15 @@ export default class Index extends Component {
45 47
       }
46 48
     );
47 49
   }
50
+  // 获取分享开关
51
+  getShareSwitch = async () => {
52
+    const res = await getShareSwitch({
53
+      key: "share_switch",
54
+    });
55
+    this.setState({
56
+      shareSwitch: Number(res.value),
57
+    });
58
+  };
48 59
   // 获取tab
49 60
   getTab = async () => {
50 61
     const res = await getNewYearTab();
@@ -77,7 +88,14 @@ export default class Index extends Component {
77 88
   };
78 89
   // 返回
79 90
   handleBack = () => {
80
-    Taro.navigateBack();
91
+    const pages = Taro.getCurrentPages();
92
+    if (pages.length > 1) {
93
+      Taro.navigateBack();
94
+    } else {
95
+      Taro.switchTab({
96
+        url: "/pages/index/index",
97
+      });
98
+    }
81 99
   };
82 100
   // 专场点击
83 101
   siteClick = (title, index) => {
@@ -134,7 +152,7 @@ export default class Index extends Component {
134 152
     return (
135 153
       <View className="index">
136 154
         {/* 返回按钮 */}
137
-        {!this.state.isShare && (
155
+        {this.state.shareSwitch == 1 && (
138 156
           <Image
139 157
             onClick={this.handleBack}
140 158
             style={{ top: Taro.navigationBarHeight + "px" }}

+ 20 - 4
src/pages/indexSub/productDetail/index.jsx

@@ -7,6 +7,7 @@ import {
7 7
   getProductPromotion,
8 8
   getShareJump,
9 9
   bindShareJump,
10
+  getShareSwitch,
10 11
 } from "../../../service";
11 12
 import { handleLog } from "../../../common/track";
12 13
 import { isDebounce } from "../../../common/debounce";
@@ -35,6 +36,7 @@ export default class Index extends Component {
35 36
     shareTitle: "", //分享标题
36 37
     shareUserId: "", //分享用户id
37 38
     isShowBack: false, //是否显示返回
39
+    shareSwitch: 1, //分享返回开关
38 40
   };
39 41
   // 获取产品详情的方法
40 42
   fetchProductDetails = async (id) => {
@@ -57,7 +59,7 @@ export default class Index extends Component {
57 59
     const res = await getProductPromotion({
58 60
       goods_id: [this.state.id],
59 61
       item_id: [this.state.productDetail.item_id],
60
-      material_type:1,//1:自购省,2:红包购买
62
+      material_type: 1, //1:自购省,2:红包购买
61 63
     });
62 64
     this.setState({
63 65
       productPromotion:
@@ -78,9 +80,9 @@ export default class Index extends Component {
78 80
       tagTitle,
79 81
       shareType,
80 82
       isShowBack,
81
-      share_unique_value
83
+      share_unique_value,
82 84
     } = Taro.getCurrentInstance().router.params;
83
-    shareJump = shareJump || share_unique_value
85
+    shareJump = shareJump || share_unique_value;
84 86
     let session_key = Taro.getStorageSync("session_key");
85 87
     let userInfo = Taro.getStorageSync("userInfo");
86 88
     let isShowSign = Taro.getStorageSync("isShowSign");
@@ -94,6 +96,11 @@ export default class Index extends Component {
94 96
         isShowBack: isShowBack === "true" || false,
95 97
       },
96 98
       () => {
99
+        // 分享页面才判断是否展示
100
+        if (this.state.isShare) {
101
+          // 获取分享开关
102
+          this.getShareSwitch();
103
+        }
97 104
         // 获取分享跳转标识
98 105
         shareJump &&
99 106
           Taro.setStorage({
@@ -134,6 +141,15 @@ export default class Index extends Component {
134 141
       }
135 142
     );
136 143
   }
144
+  // 获取分享开关
145
+  getShareSwitch = async () => {
146
+    const res = await getShareSwitch({
147
+      key: "share_switch",
148
+    });
149
+    this.setState({
150
+      shareSwitch: Number(res.value),
151
+    });
152
+  };
137 153
   // 复制商品编号
138 154
   handleCopy = (text) => {
139 155
     Taro.setClipboardData({
@@ -239,7 +255,7 @@ export default class Index extends Component {
239 255
         className="index"
240 256
         style={{ paddingTop: Taro.navigationBarHeight + "px" }}
241 257
       >
242
-        {!this.state.isShare && (
258
+        {this.state.shareSwitch == 1 && (
243 259
           <View className="back-btn" onClick={this.handleBack}>
244 260
             <AtIcon value="chevron-left" size="24" color="#999999"></AtIcon>
245 261
           </View>

+ 15 - 1
src/pages/indexSub/seckillIndex/index.jsx

@@ -8,6 +8,7 @@ import {
8 8
   getShareJump,
9 9
   bindShareJump,
10 10
   getFishMarketTags,
11
+  getShareSwitch,
11 12
 } from "../../../service";
12 13
 import { handleLog } from "../../../common/track";
13 14
 import { getShareContent } from "../../../common/share";
@@ -30,6 +31,7 @@ export default class Index extends Component {
30 31
     current: 0, // 当前选中的tab索引
31 32
     tabList: [], // 标签列表
32 33
     isTabFixed: false, // 添加新的状态来控制tab是否固定
34
+    shareSwitch: 1, //分享返回开关
33 35
   };
34 36
   componentDidMount() {
35 37
     const {
@@ -60,7 +62,7 @@ export default class Index extends Component {
60 62
           title: this.state.title || "鱼市",
61 63
         });
62 64
         if (isShare) {
63
-          Taro.hideHomeButton(); //隐藏返回首页
65
+          this.getShareSwitch(); //获取分享开关
64 66
         }
65 67
         handleLog({
66 68
           event_type: isDirect
@@ -98,6 +100,18 @@ export default class Index extends Component {
98 100
       }
99 101
     );
100 102
   }
103
+  // 获取分享开关
104
+  getShareSwitch = async () => {
105
+    const res = await getShareSwitch({
106
+      key: "share_switch",
107
+    });
108
+    if (res.value == 0) {
109
+      Taro.hideHomeButton(); //隐藏返回首页
110
+    }
111
+    this.setState({
112
+      shareSwitch: Number(res.value),
113
+    });
114
+  };
101 115
   // 获取标签
102 116
   getFishMarketTags = async () => {
103 117
     let res = await getFishMarketTags({

+ 15 - 2
src/pages/memberSub/storeManagement/index.jsx

@@ -9,6 +9,7 @@ import {
9 9
   getShareShopProductList,
10 10
   getShareJump,
11 11
   bindShareJump,
12
+  getShareSwitch,
12 13
 } from "../../../service";
13 14
 import storeManagement from "../../../images/storeManagement/storeManagement.png";
14 15
 import storeManagementIcon from "../../../images/storeManagement/storeManagementIcon.png";
@@ -27,6 +28,7 @@ export default class Index extends Component {
27 28
     shopId: "", // 店铺id
28 29
     isNoMore: false, // 是否没有更多
29 30
     isShowBack: false, // 是否显示返回
31
+    shareSwitch: 1, //分享返回开关
30 32
   };
31 33
   // 获取店铺详情
32 34
   getMyShopDetail = async () => {
@@ -82,8 +84,7 @@ export default class Index extends Component {
82 84
         this.getMyShopDetail(); //获取店铺详情
83 85
         this.getMyShopList(true); //获取店铺数据
84 86
         if (isShare) {
85
-          // 分享隐藏返回首页
86
-          Taro.hideHomeButton();
87
+          this.getShareSwitch(); //获取分享开关
87 88
         }
88 89
         // 获取分享跳转标识
89 90
         shareJump &&
@@ -102,6 +103,18 @@ export default class Index extends Component {
102 103
       }
103 104
     );
104 105
   }
106
+  // 获取分享开关
107
+  getShareSwitch = async () => {
108
+    const res = await getShareSwitch({
109
+      key: "share_switch",
110
+    });
111
+    if (res.value == 0) {
112
+      Taro.hideHomeButton();
113
+    }
114
+    this.setState({
115
+      shareSwitch: Number(res.value),
116
+    });
117
+  };
105 118
   // 绑定分享跳转标识
106 119
   bindShareJump = async () => {
107 120
     let shareJump = Taro.getStorageSync("shareJump");

+ 3 - 0
src/pages/mineSub/inform/index.config.js

@@ -0,0 +1,3 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '通知'
3
+})

+ 30 - 0
src/pages/mineSub/inform/index.jsx

@@ -0,0 +1,30 @@
1
+import { Component } from 'react'
2
+import { View, RichText } from '@tarojs/components'
3
+import './index.less'
4
+import { getUserAgreement } from '../../../service'
5
+export default class Index extends Component {
6
+  state = {
7
+    agreement: ''
8
+  }
9
+  componentDidMount () { 
10
+    this.getUserAgreement()
11
+  }
12
+  // 获取用户协议
13
+  getUserAgreement = async () => {
14
+    const res = await getUserAgreement({
15
+      type:5
16
+    })
17
+    // 替换图片样式
18
+    res.content = res.content.replace(/<img/g, '<img style="max-width: 100%; width: 100%; height: auto; display: block; margin: 0 auto;"')
19
+    this.setState({
20
+      agreement: res.content
21
+    })
22
+  }
23
+  render () {
24
+    return (
25
+      <View className='index'>
26
+        {this.state.agreement && <RichText nodes={this.state.agreement} />}
27
+      </View>
28
+    )
29
+  }
30
+}

+ 6 - 0
src/pages/mineSub/inform/index.less

@@ -0,0 +1,6 @@
1
+.index {
2
+  padding: 20rpx;
3
+  background-color: #f5f5f5;
4
+  min-height: 100vh;
5
+  box-sizing: border-box;
6
+}

+ 8 - 1
src/service/index.js

@@ -229,7 +229,14 @@ export const addLog = data =>
229 229
     method: 'POST',
230 230
     data,
231 231
   })
232
-
232
+// ----------------------------------------字典
233
+// 分享开关接口(0关闭,1打开)
234
+export const getShareSwitch = data =>
235
+  Request({
236
+    url: '/user/get_app_dict_list',
237
+    method: 'POST',
238
+    data,
239
+  })
233 240
 
234 241
 
235 242