jmash-core-mp 0.1.24 → 0.1.26

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.
Files changed (33) hide show
  1. package/lib/api/types.d.ts +1 -0
  2. package/lib/components/cms/jmash-cms-activity-item.mpx.d.ts +1 -0
  3. package/lib/components/cms/jmash-cms-activity-list.mpx.d.ts +1 -0
  4. package/lib/components/cms/jmash-cms-location-list.mpx.d.ts +1 -0
  5. package/lib/components/cms/jmash-cms-product-item.mpx.d.ts +1 -0
  6. package/lib/components/cms/jmash-cms-product-list.mpx.d.ts +1 -0
  7. package/lib/components/core/jmash-login.mpx.d.ts +1 -0
  8. package/lib/packages/pages/cms/cms-product-list.mpx.d.ts +1 -0
  9. package/lib/utils/config.js +1 -0
  10. package/package.json +1 -1
  11. package/src/api/types.ts +2 -0
  12. package/src/components/cms/jmash-cms-activity-item.mpx +208 -0
  13. package/src/components/cms/{jmash-cms-activity-page.mpx → jmash-cms-activity-list.mpx} +6 -9
  14. package/src/components/cms/jmash-cms-article-item.mpx +59 -80
  15. package/src/components/cms/jmash-cms-article-list.mpx +248 -0
  16. package/src/components/cms/jmash-cms-article.mpx +1 -1
  17. package/src/components/cms/{jmash-cms-location-page.mpx → jmash-cms-location-list.mpx} +3 -2
  18. package/src/components/cms/jmash-cms-location.mpx +1 -1
  19. package/src/components/cms/jmash-cms-product-item.mpx +184 -0
  20. package/src/components/cms/jmash-cms-product-list.mpx +229 -0
  21. package/src/components/common/jmash-upload-picture.mpx +3 -2
  22. package/src/packages/index.mpx +2 -0
  23. package/src/packages/pages/auth/cms-protocol.mpx +2 -2
  24. package/src/packages/pages/cms/cms-activity-list.mpx +6 -14
  25. package/src/packages/pages/cms/cms-article-list.mpx +89 -0
  26. package/src/packages/pages/cms/cms-article.mpx +2 -2
  27. package/src/packages/pages/cms/cms-location-list.mpx +6 -12
  28. package/src/packages/pages/cms/cms-location.mpx +2 -2
  29. package/src/packages/pages/cms/cms-product-list.mpx +89 -0
  30. package/src/pages/home.mpx +8 -4
  31. package/src/pages/tabbar/home.mpx +4 -1
  32. package/src/pages/tabbar/my.mpx +2 -3
  33. package/src/utils/config.ts +1 -0
@@ -11,6 +11,7 @@ export interface AppConfig {
11
11
  wechatComponentAppId: string;
12
12
  wechatAppId: string;
13
13
  wechatBiz: string;
14
+ siteTenant: string;
14
15
  siteId: string;
15
16
  dev: boolean;
16
17
  testNewUser: boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -11,6 +11,7 @@ const defaultConfig = {
11
11
  wechatComponentAppId: "",
12
12
  wechatAppId: "",
13
13
  wechatBiz: "",
14
+ siteTenant: "xyvcard",
14
15
  siteId: "c0a28f0f-023a-420b-b4e8-0ce138ac8269",
15
16
  };
16
17
  const config = { ...defaultConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/api/types.ts CHANGED
@@ -24,6 +24,8 @@ export interface AppConfig {
24
24
  wechatAppId: string;
25
25
  // 微信公众号Biz
26
26
  wechatBiz: string;
27
+ //站点租户
28
+ siteTenant: string;
27
29
  //站点ID.
28
30
  siteId: string;
29
31
  //是否开发环境.
@@ -0,0 +1,208 @@
1
+ <template>
2
+ <block wx:for="{{ articleList }}" wx:key="infoId">
3
+ <view class="article-border" bind:tap="handleInfo" data-item="{{ item }}">
4
+ <view class="activity-card">
5
+ <view class="activity-accent"></view>
6
+ <view class="activity-body">
7
+ <view class="activity-title">{{ item.infoTitle }}</view>
8
+ <view class="activity-address">
9
+ <text class="meta-dot address-dot"></text>
10
+ <text class="meta-text">{{ item.address }}</text>
11
+ </view>
12
+ <view class="activity-time">
13
+ <text class="meta-dot time-dot"></text>
14
+ <text class="meta-text">{{ item.publishDateStr }}</text>
15
+ </view>
16
+ </view>
17
+ </view>
18
+ </view>
19
+ </block>
20
+ </template>
21
+
22
+ <script lang="ts">
23
+ import mpx, { createComponent, ref, onMounted } from "@mpxjs/core";
24
+ import { EventBase } from "../../api/types";
25
+ import { cmsApi } from '../../api/cms';
26
+ import { CmsInfoModel } from '../../api/cms/types';
27
+ import * as dayjs from 'dayjs';
28
+
29
+ createComponent({
30
+ properties: {
31
+ // 是否更多详情
32
+ isInfo: {
33
+ type: Boolean,
34
+ value: false
35
+ },
36
+ // 样式
37
+ style: {
38
+ type: String,
39
+ value: "0",
40
+ },
41
+ // 组织租户
42
+ organTenant: {
43
+ type: String,
44
+ value: ""
45
+ },
46
+ // 站点ID
47
+ siteId: {
48
+ type: String,
49
+ value: ""
50
+ },
51
+ // 栏目ID
52
+ channelId: {
53
+ type: String,
54
+ value: ""
55
+ },
56
+ // 栏目别名
57
+ channelAlias: {
58
+ type: String,
59
+ value: ""
60
+ },
61
+ // 数量
62
+ pageSize: {
63
+ type: Number,
64
+ value: 5
65
+ },
66
+ },
67
+ setup(props) {
68
+ let config = getApp().globalData.config;
69
+ // 资源路径
70
+ let resourceUrl = config.resourceUrl + '/images';
71
+ // 文章列表
72
+ let articleList = ref([] as CmsInfoModel[]);
73
+ console.log("cms", props);
74
+ onMounted(() => {
75
+ cmsApi.findCmsInfoPage({
76
+ tenant: props.organTenant || config.siteTenant,
77
+ siteId: props.siteId,
78
+ channelId: props.channelId,
79
+ channelAlias: props.channelAlias,
80
+ curPage: 1,
81
+ pageSize: props.pageSize,
82
+ status: "published",
83
+ }).then(res => {
84
+ if (res.statusCode === 200) {
85
+ // 格式化时间
86
+ res.data.results.forEach(item => {
87
+ item.publishDateStr = dayjs(item.publishDate).format("YYYY年MM月DD日 dddd");
88
+ })
89
+ articleList.value = res.data.results;
90
+ }
91
+ });
92
+ });
93
+ // 接口图片资源路径 容器宽高度150rpx 裁剪2倍
94
+ let imageUrl = config.baseUrl + "/v1/file/image/clip/300/300/";
95
+ return { resourceUrl, articleList, imageUrl }
96
+ },
97
+ methods: {
98
+ // 点击详情事件
99
+ handleInfo(e: EventBase) {
100
+ let config = getApp().globalData.config;
101
+ let item = e.currentTarget.dataset.item;
102
+ mpx.navigateTo({
103
+ url: '/jmash/pages/cms/cms-article?tenant=' + this.organTenant + '&siteId=' + this.siteId + '&infoId=' + item.infoId,
104
+ });
105
+ // 浏览
106
+ this.handelBrowse(this.organTenant || config.siteTenant, item.infoId);
107
+ this.triggerEvent("info", item);
108
+ },
109
+ // 浏览
110
+ handelBrowse(tenant: string, infoId: string) {
111
+ const tempData = {
112
+ // 用于检测重复请求的唯一字符串ID
113
+ requestId: Math.random() * 10 + "",
114
+ // 类型
115
+ type: "information",
116
+ // 关系
117
+ relationId: infoId,
118
+ // 租户
119
+ tenant: tenant
120
+ };
121
+ cmsApi.createfrontBrowseRecord(tempData);
122
+ },
123
+ }
124
+ })
125
+ </script>
126
+
127
+ <style lang="scss">
128
+ @use "../../styles/index.scss" as *;
129
+
130
+ .article-border {
131
+ padding: 24rpx 0;
132
+ border-bottom: 1rpx solid $border-line;
133
+
134
+ &:last-child {
135
+ border: none;
136
+ }
137
+ }
138
+
139
+ .activity-card {
140
+ display: flex;
141
+ align-items: flex-start;
142
+ gap: 20rpx;
143
+
144
+ .activity-accent {
145
+ flex-shrink: 0;
146
+ width: 6rpx;
147
+ height: 110rpx;
148
+ background: linear-gradient(180deg, #409eff, #67c23a);
149
+ border-radius: 3rpx;
150
+ }
151
+
152
+ .activity-body {
153
+ flex: 1;
154
+ min-width: 0;
155
+ display: flex;
156
+ flex-direction: column;
157
+ gap: 12rpx;
158
+
159
+ .activity-title {
160
+ font-size: 32rpx;
161
+ font-weight: 700;
162
+ color: #1a1a1a;
163
+ line-height: 1.4;
164
+ text-align: left;
165
+ overflow: hidden;
166
+ white-space: nowrap;
167
+ text-overflow: ellipsis;
168
+ }
169
+
170
+ .activity-address,
171
+ .activity-time {
172
+ display: flex;
173
+ align-items: center;
174
+ gap: 8rpx;
175
+
176
+ .meta-dot {
177
+ width: 10rpx;
178
+ height: 10rpx;
179
+ border-radius: 50%;
180
+ flex-shrink: 0;
181
+ }
182
+
183
+ .address-dot {
184
+ background: #e6a23c;
185
+ }
186
+
187
+ .time-dot {
188
+ background: #67c23a;
189
+ }
190
+
191
+ .meta-text {
192
+ font-size: 24rpx;
193
+ color: #888;
194
+ overflow: hidden;
195
+ white-space: nowrap;
196
+ text-overflow: ellipsis;
197
+ }
198
+ }
199
+ }
200
+ }
201
+ </style>
202
+
203
+ <script type="application/json">
204
+ {
205
+ "component": true,
206
+ "usingComponents": {}
207
+ }
208
+ </script>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <scroll-view class="article-main" type="custom" scroll-y scroll-top="{{ scrollTop }}" bindscrolltolower="loadMore">
3
- <block wx:for="{{ articleList }}" wx:key="index" wx:if="{{ style == '1' }}">
3
+ <block wx:for="{{ articleList }}" wx:key="infoId">
4
4
  <view class="article-border" bind:tap="handleInfo" data-item="{{ item }}">
5
5
  <view class="activity-card">
6
6
  <view class="activity-accent"></view>
@@ -33,11 +33,6 @@ import { CmsInfoModel } from '../../api/cms/types';
33
33
 
34
34
  createComponent({
35
35
  properties: {
36
- // 样式
37
- style: {
38
- type: String,
39
- value: "0",
40
- },
41
36
  // 组织租户
42
37
  organTenant: {
43
38
  type: String,
@@ -87,10 +82,12 @@ createComponent({
87
82
  console.log("cms", props);
88
83
 
89
84
  const loadRecords = function (page: number = 1) {
85
+ if (!props.channelAlias && !props.channelId) return
90
86
  if (loading.value) return
91
87
  loading.value = true;
88
+ curPage.value = page;
92
89
  cmsApi.findCmsInfoPage({
93
- tenant: props.organTenant || config.tenant,
90
+ tenant: props.organTenant || config.siteTenant,
94
91
  siteId: props.siteId,
95
92
  channelId: props.channelId,
96
93
  channelAlias: props.channelAlias,
@@ -121,13 +118,13 @@ createComponent({
121
118
  if (!hasMore.value || loading.value) return
122
119
  loadRecords(curPage.value + 1)
123
120
  }
124
- loadRecords(1);
125
121
  watch(
126
122
  () => props.refreshKey,
127
123
  () => {
128
124
  loadRecords(1)
129
125
  }
130
126
  )
127
+ loadRecords(1);
131
128
  return { resourceUrl, articleList, imageUrl, curPage, hasMore, loading, scrollTop, loadMore }
132
129
  },
133
130
  methods: {
@@ -139,7 +136,7 @@ createComponent({
139
136
  url: '/jmash/pages/cms/cms-article?tenant=' + this.organTenant + '&siteId=' + this.siteId + '&infoId=' + item.infoId,
140
137
  });
141
138
  // 浏览
142
- this.handelBrowse(this.organTenant || config.tenant, item.infoId);
139
+ this.handelBrowse(this.organTenant || config.siteTenant, item.infoId);
143
140
  this.triggerEvent("info", item);
144
141
  },
145
142
  // 浏览
@@ -10,53 +10,26 @@
10
10
  * @event info 文章详情点击事件,参数为文章项item
11
11
  */
12
12
  <template>
13
- <!-- 文章内容列表item -->
14
13
  <view class="{{ isInfo ? '' : 'article-main' }}">
15
- <!-- 默认图片在右侧的样式 枚举值为0 -->
16
- <block wx:for="{{ articleList }}" wx:key="index" wx:if="{{ style == '0' }}">
17
- <view class="{{ isInfo ? 'article-info' : 'article-border' }}" bind:tap="handleInfo" data-item="{{ item }}">
18
- <!-- 内容 -->
19
- <view class="cms-info">
20
- <view class="cms-left">
21
- <!-- 标题 -->
22
- <view class="cms-left-title">{{ item.infoTitle }}</view>
23
- <!-- 内容 -->
24
- <view class="cms-left-info">{{ item.intro }}</view>
25
- </view>
26
- <view bind:tap="handlePreview" data-url="{{ item.imgUrl }}">
27
- <image class="cms-right-image" src="{{ imageUrl + item.imgUrl }}" mode="widthFix" />
28
- </view>
14
+ <view class="{{ isInfo ? 'article-card' : 'article-row' }}" wx:for="{{ articleList }}" wx:key="index"
15
+ bind:tap="handleInfo" data-item="{{ item }}">
16
+ <view class="article-item {{ itemClass }}">
17
+ <view class="article-text">
18
+ <view class="article-text-title">{{ item.infoTitle }}</view>
19
+ <view class="article-text-desc">{{ item.intro }}</view>
29
20
  </view>
30
- <!-- 底部时间、点赞数、预览数 -->
31
- <jmash-cms-like organTenant="{{ organTenant }}" interactId="{{ item.infoId }}"
32
- publishDate="{{ item.publishDate }}"></jmash-cms-like>
33
- </view>
34
- </block>
35
- <!-- 默认图片在左侧的样式 枚举值为1 -->
36
- <block wx:for="{{ articleList }}" wx:key="index" wx:if="{{ style == '1' }}">
37
- <view class="{{ isInfo ? 'article-info' : 'article-border' }}" bind:tap="handleInfo" data-item="{{ item }}">
38
- <!-- 内容 -->
39
- <view class="cms-info">
40
- <view bind:tap="handlePreview" data-url="{{ item.imgUrl }}">
41
- <image class="cms-right-image" src="{{ imageUrl + item.imgUrl }}" mode="widthFix" />
42
- </view>
43
- <view class="cms-left">
44
- <!-- 标题 -->
45
- <view class="cms-left-title">{{ item.infoTitle }}</view>
46
- <!-- 内容 -->
47
- <view class="cms-left-info">{{ item.intro }}</view>
48
- </view>
21
+ <view class="article-thumb" catch:tap="handlePreview" data-url="{{ item.imgUrl }}">
22
+ <image class="article-thumb-img" src="{{ imageUrl + item.imgUrl }}" mode="aspectFill" />
49
23
  </view>
50
- <!-- 底部时间、点赞数、预览数 -->
51
- <jmash-cms-like organTenant="{{ organTenant }}" interactId="{{ item.infoId }}"
52
- publishDate="{{ item.publishDate }}"></jmash-cms-like>
53
24
  </view>
54
- </block>
25
+ <jmash-cms-like organTenant="{{ organTenant }}" interactId="{{ item.infoId }}"
26
+ publishDate="{{ item.publishDate }}"></jmash-cms-like>
27
+ </view>
55
28
  </view>
56
29
  </template>
57
30
 
58
31
  <script lang="ts">
59
- import mpx, { createComponent, ref, onMounted } from "@mpxjs/core";
32
+ import mpx, { createComponent, ref, onMounted, computed } from "@mpxjs/core";
60
33
  import { EventBase } from "../../api/types";
61
34
  import { cmsApi } from '../../api/cms';
62
35
  import { CmsInfoModel } from '../../api/cms/types';
@@ -108,12 +81,13 @@ createComponent({
108
81
  console.log("cms", props);
109
82
  onMounted(() => {
110
83
  cmsApi.findCmsInfoPage({
111
- tenant: props.organTenant || config.tenant,
84
+ tenant: props.organTenant || config.siteTenant,
112
85
  siteId: props.siteId,
113
86
  channelId: props.channelId,
114
87
  channelAlias: props.channelAlias,
115
88
  curPage: 1,
116
89
  pageSize: props.pageSize,
90
+ status: "published",
117
91
  }).then(res => {
118
92
  if (res.statusCode === 200) {
119
93
  articleList.value = res.data.results;
@@ -122,7 +96,10 @@ createComponent({
122
96
  });
123
97
  // 接口图片资源路径 容器宽高度150rpx 裁剪2倍
124
98
  let imageUrl = config.baseUrl + "/v1/file/image/clip/300/300/";
125
- return { resourceUrl, articleList, imageUrl }
99
+
100
+ const itemClass = computed(() => props.style === '1' ? 'article-item--reverse' : '')
101
+
102
+ return { resourceUrl, articleList, imageUrl, itemClass }
126
103
  },
127
104
  methods: {
128
105
  // 点击详情事件
@@ -130,10 +107,10 @@ createComponent({
130
107
  let config = getApp().globalData.config;
131
108
  let item = e.currentTarget.dataset.item;
132
109
  mpx.navigateTo({
133
- url: '/jmash/pages/cms/cms-article?siteId=' + this.siteId + '&infoId=' + item.infoId,
110
+ url: '/jmash/pages/cms/cms-article?tenant=' + this.organTenant + '&siteId=' + this.siteId + '&infoId=' + item.infoId,
134
111
  });
135
112
  // 浏览
136
- this.handelBrowse(this.organTenant || config.tenant, item.infoId);
113
+ this.handelBrowse(this.organTenant || config.siteTenant, item.infoId);
137
114
  this.triggerEvent("info", item);
138
115
  },
139
116
  // 浏览
@@ -158,76 +135,78 @@ createComponent({
158
135
  @use "../../styles/index.scss" as *;
159
136
 
160
137
  .article-main {
161
- padding: 0 30rpx;
162
- border-radius: 20rpx;
163
- background-color: #fff;
138
+ padding: 0 24rpx;
139
+ background-color: #f5f5f5;
164
140
  }
165
141
 
166
- // 有分割线列表
167
- .article-border {
168
- padding: 30rpx 0;
142
+ .article-row {
143
+ padding: 24rpx 0;
169
144
  border-bottom: 1rpx solid $border-line;
170
145
 
171
- // 分割线最后一条内容无分割线
172
146
  &:last-child {
173
147
  border: none;
174
148
  }
175
149
  }
176
150
 
177
- // 无分割线列表
178
- .article-info {
179
- padding: 30rpx;
151
+ .article-card {
152
+ padding: 24rpx;
180
153
  background-color: #fff;
181
- border-radius: 20rpx;
154
+ border-radius: 16rpx;
182
155
  margin-bottom: 20rpx;
156
+ box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
183
157
  }
184
158
 
185
- .cms-info {
159
+ .article-item {
186
160
  display: flex;
187
161
  align-items: center;
188
- justify-content: space-between;
189
- gap: 30rpx;
190
- margin-bottom: 30rpx;
162
+ gap: 24rpx;
163
+ margin-bottom: 24rpx;
191
164
 
192
- // 文章左侧内容
193
- .cms-left {
194
- width: 450rpx;
165
+ &--reverse {
166
+ flex-direction: row-reverse;
167
+ }
168
+
169
+ .article-text {
170
+ flex: 1;
171
+ min-width: 0;
195
172
  display: flex;
196
173
  flex-direction: column;
174
+ gap: 16rpx;
197
175
 
198
- .cms-left-title {
199
- color: #333;
200
- font-size: 28rpx;
176
+ .article-text-title {
177
+ color: #1a1a1a;
178
+ font-size: 30rpx;
201
179
  font-weight: 600;
202
- margin-bottom: 20rpx;
180
+ line-height: 1.4;
203
181
  overflow: hidden;
204
- /* 隐藏超出部分 */
205
182
  white-space: nowrap;
206
- /* 强制文本不换行 */
207
183
  text-overflow: ellipsis;
208
- /* 超出部分以省略号显示 */
209
184
  }
210
185
 
211
- .cms-left-info {
212
- color: #666;
213
- font-size: 26rpx;
214
- line-height: 37rpx;
186
+ .article-text-desc {
187
+ color: #888;
188
+ font-size: 24rpx;
189
+ line-height: 1.5;
215
190
  overflow: hidden;
216
- /* 隐藏超出部分 */
217
191
  display: -webkit-box;
218
192
  -webkit-box-orient: vertical;
219
193
  -webkit-line-clamp: 2;
220
- /* 文本只显示两行 */
221
194
  text-overflow: ellipsis;
222
- /* 超出部分以省略号显示 */
223
195
  }
224
196
  }
225
197
 
226
- // 文章右侧图片
227
- .cms-right-image {
228
- width: 150rpx;
229
- height: 150rpx;
230
- border-radius: 10rpx;
198
+ .article-thumb {
199
+ flex-shrink: 0;
200
+ width: 180rpx;
201
+ height: 180rpx;
202
+ border-radius: 12rpx;
203
+ overflow: hidden;
204
+ background: #f0f0f0;
205
+
206
+ .article-thumb-img {
207
+ width: 100%;
208
+ height: 100%;
209
+ }
231
210
  }
232
211
  }
233
212
  </style>