xiaoe_mp_npm 1.0.39 → 1.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,6 @@ import {
23
23
  } from "../common/utils/constants.js";
24
24
 
25
25
  const { utils, sensorLog } = require("live-mp-tools");
26
-
27
26
  const computedBehavior = require('miniprogram-computed').behavior
28
27
 
29
28
  const formatNum = (num) => {
@@ -1,6 +1,10 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- "van-switch": "@vant/weapp/switch/index"
5
- }
6
- }
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "van-switch": "@vant/weapp/switch/index",
5
+ "level-member-bar": "/subpkg/npm-compoent/miniprogram_npm/xiaoe_mp_npm/LevelMemberBar/index"
6
+ },
7
+ "componentPlaceholder": {
8
+ "level-member-bar": "view"
9
+ }
10
+ }
@@ -73,6 +73,9 @@
73
73
  </view>
74
74
  </view>
75
75
 
76
+ <!-- 等级会员-专属商品标识 -->
77
+ <level-member-bar good-data="{{ goodsItem }}" />
78
+
76
79
  <!-- 活动进度条 -->
77
80
  <view
78
81
  class="progress"
@@ -0,0 +1,45 @@
1
+ import { formatMembershipNameStr, checkCanBuyMemberGood, showMemberGoodsDescModal } from './utils.js'
2
+
3
+ Component({
4
+ behaviors: [require('miniprogram-computed').behavior],
5
+ properties: {
6
+ goodData: {
7
+ type: Object,
8
+ value: {},
9
+ },
10
+ userType: {
11
+ type: String,
12
+ value: 'student' // student or teacher
13
+ },
14
+ },
15
+ computed: {
16
+ // 是否显示等级会员-专属商品标识
17
+ visibleLevelMemberGoodsDesc(properties) {
18
+ const { have_constrain, ranks } = properties.goodData || {}
19
+
20
+ return Boolean(have_constrain && Array.isArray(ranks) && ranks.length)
21
+ },
22
+ // 等级会员-专属商品时,显示专属会员等级
23
+ levelMemberGoodsDesc(properties) {
24
+ return `仅${formatMembershipNameStr(properties.goodData?.ranks, '/')}可购买`
25
+ },
26
+ },
27
+ methods: {
28
+ /**
29
+ * @description 检查是否有购买该【等级会员专属商品】的权益
30
+ *
31
+ * @return {Boolean} 检查结果,true 有,false 没有
32
+ */
33
+ checkCanBuyMemberGood() {
34
+ const { goodData, userType } = this.properties
35
+ return checkCanBuyMemberGood({ goodData, userType })
36
+ },
37
+ /**
38
+ * @description 点击等级会员-专属商品标识文本,展示具体内容
39
+ */
40
+ showMemberGoodsDescModal() {
41
+ const { goodData, userType } = this.properties
42
+ showMemberGoodsDescModal({ goodData, userType })
43
+ },
44
+ },
45
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,51 @@
1
+ @import "../common/css/index.wxss";
2
+
3
+ $deviceWidth: 750;
4
+ @function vmin($rpx) {
5
+ @return #{$rpx * 100 / $deviceWidth}vmin;
6
+ }
7
+
8
+ @mixin level-member-goods {
9
+ display: inline-block;
10
+ max-width: vmin(230);
11
+ height: vmin(32);
12
+ padding: 0 vmin(8);
13
+ margin: vmin(8) 0;
14
+ line-height: vmin(32);
15
+ font-size: vmin(20);
16
+ font-weight: 500;
17
+ background-color: #FFF3EB;
18
+ color: #FF781F;
19
+ white-space: nowrap;
20
+ overflow: hidden;
21
+ text-overflow: ellipsis;
22
+ }
23
+
24
+ .level-member-goods {
25
+ @include level-member-goods;
26
+ }
27
+
28
+ // 竖屏pad
29
+ @media screen and (min-width: 768px) and (orientation: portrait) {
30
+ $deviceWidth: 1536 !global;
31
+ .level-member-goods {
32
+ @include level-member-goods;
33
+ }
34
+ }
35
+
36
+ // PC 放大适配
37
+ @media screen and (min-height: 630px) and (orientation: landscape) {
38
+ $deviceWidth: 1260 !global;
39
+
40
+ .level-member-goods {
41
+ @include level-member-goods;
42
+ }
43
+ }
44
+
45
+ // 横屏pad
46
+ @media screen and (min-height: 768px) and (orientation: landscape) {
47
+ $deviceWidth: 1536 !global;
48
+ .level-member-goods {
49
+ @include level-member-goods;
50
+ }
51
+ }
@@ -0,0 +1,3 @@
1
+ <view wx:if="{{ visibleLevelMemberGoodsDesc }}" catchtap="showMemberGoodsDescModal">
2
+ <text class="level-member-goods">{{ levelMemberGoodsDesc }}</text>
3
+ </view>
@@ -0,0 +1,66 @@
1
+ .level-member-goods {
2
+ display: inline-block;
3
+ max-width: 30.66667vmin;
4
+ height: 4.26667vmin;
5
+ padding: 0 1.06667vmin;
6
+ margin: 1.06667vmin 0;
7
+ line-height: 4.26667vmin;
8
+ font-size: 2.66667vmin;
9
+ font-weight: 500;
10
+ background-color: #FFF3EB;
11
+ color: #FF781F;
12
+ white-space: nowrap;
13
+ overflow: hidden;
14
+ text-overflow: ellipsis;
15
+ }
16
+ @media screen and (min-width: 768px) and (orientation: portrait) {
17
+ .level-member-goods {
18
+ display: inline-block;
19
+ max-width: 14.97396vmin;
20
+ height: 2.08333vmin;
21
+ padding: 0 0.52083vmin;
22
+ margin: 0.52083vmin 0;
23
+ line-height: 2.08333vmin;
24
+ font-size: 1.30208vmin;
25
+ font-weight: 500;
26
+ background-color: #FFF3EB;
27
+ color: #FF781F;
28
+ white-space: nowrap;
29
+ overflow: hidden;
30
+ text-overflow: ellipsis;
31
+ }
32
+ }
33
+ @media screen and (min-height: 630px) and (orientation: landscape) {
34
+ .level-member-goods {
35
+ display: inline-block;
36
+ max-width: 18.25397vmin;
37
+ height: 2.53968vmin;
38
+ padding: 0 0.63492vmin;
39
+ margin: 0.63492vmin 0;
40
+ line-height: 2.53968vmin;
41
+ font-size: 1.5873vmin;
42
+ font-weight: 500;
43
+ background-color: #FFF3EB;
44
+ color: #FF781F;
45
+ white-space: nowrap;
46
+ overflow: hidden;
47
+ text-overflow: ellipsis;
48
+ }
49
+ }
50
+ @media screen and (min-height: 768px) and (orientation: landscape) {
51
+ .level-member-goods {
52
+ display: inline-block;
53
+ max-width: 14.97396vmin;
54
+ height: 2.08333vmin;
55
+ padding: 0 0.52083vmin;
56
+ margin: 0.52083vmin 0;
57
+ line-height: 2.08333vmin;
58
+ font-size: 1.30208vmin;
59
+ font-weight: 500;
60
+ background-color: #FFF3EB;
61
+ color: #FF781F;
62
+ white-space: nowrap;
63
+ overflow: hidden;
64
+ text-overflow: ellipsis;
65
+ }
66
+ }
@@ -0,0 +1,75 @@
1
+ import membershipStore from '../../../../../store/page/common/membership-store.js'
2
+ import liveRoomStore from '../../../../../store/page/common/live-room-store.js'
3
+
4
+ /**
5
+ * @description 获取 rank_id => membership 的映射
6
+ *
7
+ * @return {Object} 返回映射 Map
8
+ */
9
+ export const getMembershipMap = () => {
10
+ return (membershipStore?.data || []).reduce((acc, membership) => {
11
+ acc[membership.rank_id] = membership
12
+ return acc
13
+ }, {})
14
+ }
15
+
16
+ /**
17
+ * @description 获取通过等级会员 ID 数组,返回对应字符串
18
+ * @param {Array} ranks 等级会员 ID 数组
19
+ * @param {String} symbolText 间隔符号文本
20
+ *
21
+ * @return {String} 返回对应格式字符串
22
+ */
23
+ export const formatMembershipNameStr = (ranks, symbolText= '、') => {
24
+ const membershipMap = getMembershipMap()
25
+ return (ranks || []).map(rank_id => membershipMap[rank_id]?.rank_name).filter(Boolean).join(symbolText)
26
+ }
27
+
28
+ /**
29
+ * @description 检查是否有购买该【等级会员专属商品】的权益
30
+ * @param {Object} goodData 商品详情
31
+ * @param {String} userType 用户角色:student or teacher
32
+ *
33
+ * @return {Boolean} 检查结果,true 有,false 没有
34
+ */
35
+ export const checkCanBuyMemberGood = ({ goodData, userType }) => {
36
+ // have_constrain 该商品是否开启了等级会员专属商品限制,true 开启,false 关闭
37
+ // ranks 该商品对应的等级会员专属商品等级列表
38
+ const { have_constrain, ranks } = goodData || {}
39
+ const { member_id } = liveRoomStore?.room?.userInfo?.level_member || {}
40
+
41
+ // 是专属商品,如果不是专属的会员,则提示
42
+ if (have_constrain && !ranks?.includes(member_id)) {
43
+ showMemberGoodsDescModal({ goodData, userType })
44
+ return false
45
+ }
46
+
47
+ return true
48
+ }
49
+
50
+ /**
51
+ * @description 点击等级会员-专属商品标识文本,展示具体内容
52
+ * @param {Object} goodData 商品详情
53
+ * @param {String} userType 用户角色:student or teacher
54
+ */
55
+ export const showMemberGoodsDescModal = ({ goodData, userType }) => {
56
+ const isStudent = userType === 'student'
57
+
58
+ wx.showModal({
59
+ content: `该商品仅支持【${formatMembershipNameStr(goodData?.ranks)}】购买`,
60
+ confirmText: isStudent ? '查看权益' : '确认',
61
+ cancelText: '取消',
62
+ confirmColor: '#1472FF',
63
+ success: (res) => {
64
+ if (!isStudent || !res.confirm) return
65
+
66
+ const appId = liveRoomStore?.data?.room?.aliveInfo.app_id
67
+ const levelMembershipPageUrl = `https://${appId}.h5.xiaoeknow.com/p/t/v1/account-platform/h5_user/level-member/member`
68
+
69
+ // 学员 -> 点击查看权益 -> 跳转等级会员权益页面
70
+ wx.navigateTo({
71
+ url: `/pages/webviewContainer/index?path=${levelMembershipPageUrl}`,
72
+ })
73
+ }
74
+ })
75
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xiaoe_mp_npm",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "description": "",
5
5
  "main": "miniprogram_dist/index.js",
6
6
  "scripts": {
@@ -75,4 +75,4 @@
75
75
  "miniprogram-computed": "4.2.1",
76
76
  "mp-plugins-info-collection": "1.1.4"
77
77
  }
78
- }
78
+ }
@@ -23,7 +23,6 @@ import {
23
23
  } from "../common/utils/constants.js";
24
24
 
25
25
  const { utils, sensorLog } = require("live-mp-tools");
26
-
27
26
  const computedBehavior = require('miniprogram-computed').behavior
28
27
 
29
28
  const formatNum = (num) => {
@@ -1,6 +1,10 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- "van-switch": "@vant/weapp/switch/index"
5
- }
6
- }
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "van-switch": "@vant/weapp/switch/index",
5
+ "level-member-bar": "/subpkg/npm-compoent/miniprogram_npm/xiaoe_mp_npm/LevelMemberBar/index"
6
+ },
7
+ "componentPlaceholder": {
8
+ "level-member-bar": "view"
9
+ }
10
+ }
@@ -73,6 +73,9 @@
73
73
  </view>
74
74
  </view>
75
75
 
76
+ <!-- 等级会员-专属商品标识 -->
77
+ <level-member-bar good-data="{{ goodsItem }}" />
78
+
76
79
  <!-- 活动进度条 -->
77
80
  <view
78
81
  class="progress"
@@ -0,0 +1,45 @@
1
+ import { formatMembershipNameStr, checkCanBuyMemberGood, showMemberGoodsDescModal } from './utils.js'
2
+
3
+ Component({
4
+ behaviors: [require('miniprogram-computed').behavior],
5
+ properties: {
6
+ goodData: {
7
+ type: Object,
8
+ value: {},
9
+ },
10
+ userType: {
11
+ type: String,
12
+ value: 'student' // student or teacher
13
+ },
14
+ },
15
+ computed: {
16
+ // 是否显示等级会员-专属商品标识
17
+ visibleLevelMemberGoodsDesc(properties) {
18
+ const { have_constrain, ranks } = properties.goodData || {}
19
+
20
+ return Boolean(have_constrain && Array.isArray(ranks) && ranks.length)
21
+ },
22
+ // 等级会员-专属商品时,显示专属会员等级
23
+ levelMemberGoodsDesc(properties) {
24
+ return `仅${formatMembershipNameStr(properties.goodData?.ranks, '/')}可购买`
25
+ },
26
+ },
27
+ methods: {
28
+ /**
29
+ * @description 检查是否有购买该【等级会员专属商品】的权益
30
+ *
31
+ * @return {Boolean} 检查结果,true 有,false 没有
32
+ */
33
+ checkCanBuyMemberGood() {
34
+ const { goodData, userType } = this.properties
35
+ return checkCanBuyMemberGood({ goodData, userType })
36
+ },
37
+ /**
38
+ * @description 点击等级会员-专属商品标识文本,展示具体内容
39
+ */
40
+ showMemberGoodsDescModal() {
41
+ const { goodData, userType } = this.properties
42
+ showMemberGoodsDescModal({ goodData, userType })
43
+ },
44
+ },
45
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,51 @@
1
+ @import "../common/css/index.wxss";
2
+
3
+ $deviceWidth: 750;
4
+ @function vmin($rpx) {
5
+ @return #{$rpx * 100 / $deviceWidth}vmin;
6
+ }
7
+
8
+ @mixin level-member-goods {
9
+ display: inline-block;
10
+ max-width: vmin(230);
11
+ height: vmin(32);
12
+ padding: 0 vmin(8);
13
+ margin: vmin(8) 0;
14
+ line-height: vmin(32);
15
+ font-size: vmin(20);
16
+ font-weight: 500;
17
+ background-color: #FFF3EB;
18
+ color: #FF781F;
19
+ white-space: nowrap;
20
+ overflow: hidden;
21
+ text-overflow: ellipsis;
22
+ }
23
+
24
+ .level-member-goods {
25
+ @include level-member-goods;
26
+ }
27
+
28
+ // 竖屏pad
29
+ @media screen and (min-width: 768px) and (orientation: portrait) {
30
+ $deviceWidth: 1536 !global;
31
+ .level-member-goods {
32
+ @include level-member-goods;
33
+ }
34
+ }
35
+
36
+ // PC 放大适配
37
+ @media screen and (min-height: 630px) and (orientation: landscape) {
38
+ $deviceWidth: 1260 !global;
39
+
40
+ .level-member-goods {
41
+ @include level-member-goods;
42
+ }
43
+ }
44
+
45
+ // 横屏pad
46
+ @media screen and (min-height: 768px) and (orientation: landscape) {
47
+ $deviceWidth: 1536 !global;
48
+ .level-member-goods {
49
+ @include level-member-goods;
50
+ }
51
+ }
@@ -0,0 +1,3 @@
1
+ <view wx:if="{{ visibleLevelMemberGoodsDesc }}" catchtap="showMemberGoodsDescModal">
2
+ <text class="level-member-goods">{{ levelMemberGoodsDesc }}</text>
3
+ </view>
@@ -0,0 +1 @@
1
+ .level-member-goods{display:inline-block;max-width:30.66667vmin;height:4.26667vmin;padding:0 1.06667vmin;margin:1.06667vmin 0;line-height:4.26667vmin;font-size:2.66667vmin;font-weight:500;background-color:#FFF3EB;color:#FF781F;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media screen and (min-width: 768px) and (orientation: portrait){.level-member-goods{display:inline-block;max-width:14.97396vmin;height:2.08333vmin;padding:0 .52083vmin;margin:.52083vmin 0;line-height:2.08333vmin;font-size:1.30208vmin;font-weight:500;background-color:#FFF3EB;color:#FF781F;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}}@media screen and (min-height: 630px) and (orientation: landscape){.level-member-goods{display:inline-block;max-width:18.25397vmin;height:2.53968vmin;padding:0 .63492vmin;margin:.63492vmin 0;line-height:2.53968vmin;font-size:1.5873vmin;font-weight:500;background-color:#FFF3EB;color:#FF781F;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}}@media screen and (min-height: 768px) and (orientation: landscape){.level-member-goods{display:inline-block;max-width:14.97396vmin;height:2.08333vmin;padding:0 .52083vmin;margin:.52083vmin 0;line-height:2.08333vmin;font-size:1.30208vmin;font-weight:500;background-color:#FFF3EB;color:#FF781F;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}}
@@ -0,0 +1,75 @@
1
+ import membershipStore from '../../../../../store/page/common/membership-store.js'
2
+ import liveRoomStore from '../../../../../store/page/common/live-room-store.js'
3
+
4
+ /**
5
+ * @description 获取 rank_id => membership 的映射
6
+ *
7
+ * @return {Object} 返回映射 Map
8
+ */
9
+ export const getMembershipMap = () => {
10
+ return (membershipStore?.data || []).reduce((acc, membership) => {
11
+ acc[membership.rank_id] = membership
12
+ return acc
13
+ }, {})
14
+ }
15
+
16
+ /**
17
+ * @description 获取通过等级会员 ID 数组,返回对应字符串
18
+ * @param {Array} ranks 等级会员 ID 数组
19
+ * @param {String} symbolText 间隔符号文本
20
+ *
21
+ * @return {String} 返回对应格式字符串
22
+ */
23
+ export const formatMembershipNameStr = (ranks, symbolText= '、') => {
24
+ const membershipMap = getMembershipMap()
25
+ return (ranks || []).map(rank_id => membershipMap[rank_id]?.rank_name).filter(Boolean).join(symbolText)
26
+ }
27
+
28
+ /**
29
+ * @description 检查是否有购买该【等级会员专属商品】的权益
30
+ * @param {Object} goodData 商品详情
31
+ * @param {String} userType 用户角色:student or teacher
32
+ *
33
+ * @return {Boolean} 检查结果,true 有,false 没有
34
+ */
35
+ export const checkCanBuyMemberGood = ({ goodData, userType }) => {
36
+ // have_constrain 该商品是否开启了等级会员专属商品限制,true 开启,false 关闭
37
+ // ranks 该商品对应的等级会员专属商品等级列表
38
+ const { have_constrain, ranks } = goodData || {}
39
+ const { member_id } = liveRoomStore?.room?.userInfo?.level_member || {}
40
+
41
+ // 是专属商品,如果不是专属的会员,则提示
42
+ if (have_constrain && !ranks?.includes(member_id)) {
43
+ showMemberGoodsDescModal({ goodData, userType })
44
+ return false
45
+ }
46
+
47
+ return true
48
+ }
49
+
50
+ /**
51
+ * @description 点击等级会员-专属商品标识文本,展示具体内容
52
+ * @param {Object} goodData 商品详情
53
+ * @param {String} userType 用户角色:student or teacher
54
+ */
55
+ export const showMemberGoodsDescModal = ({ goodData, userType }) => {
56
+ const isStudent = userType === 'student'
57
+
58
+ wx.showModal({
59
+ content: `该商品仅支持【${formatMembershipNameStr(goodData?.ranks)}】购买`,
60
+ confirmText: isStudent ? '查看权益' : '确认',
61
+ cancelText: '取消',
62
+ confirmColor: '#1472FF',
63
+ success: (res) => {
64
+ if (!isStudent || !res.confirm) return
65
+
66
+ const appId = liveRoomStore?.data?.room?.aliveInfo.app_id
67
+ const levelMembershipPageUrl = `https://${appId}.h5.xiaoeknow.com/p/t/v1/account-platform/h5_user/level-member/member`
68
+
69
+ // 学员 -> 点击查看权益 -> 跳转等级会员权益页面
70
+ wx.navigateTo({
71
+ url: `/pages/webviewContainer/index?path=${levelMembershipPageUrl}`,
72
+ })
73
+ }
74
+ })
75
+ }