jmash-core-mp 0.1.21 → 0.1.23

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 (31) hide show
  1. package/lib/api/cms/types.d.ts +4 -3
  2. package/lib/components/cms/cms-channel-list.mpx.d.ts +1 -0
  3. package/lib/components/cms/jmash-cms-activity-page.mpx.d.ts +1 -0
  4. package/lib/components/cms/jmash-cms-article-list.mpx.d.ts +1 -0
  5. package/lib/components/cms/jmash-cms-location-page.mpx.d.ts +1 -0
  6. package/lib/components/cms/jmash-cms-location.mpx.d.ts +1 -0
  7. package/lib/components/common/jmash-none-data.mpx.d.ts +1 -0
  8. package/lib/components/common/jmash-search.mpx.d.ts +1 -0
  9. package/lib/index.d.ts +2 -0
  10. package/lib/index.js +4 -0
  11. package/lib/packages/pages/cms/cms-activity-list.mpx.d.ts +1 -0
  12. package/lib/packages/pages/cms/cms-info.mpx.d.ts +1 -0
  13. package/lib/packages/pages/cms/cms-list.mpx.d.ts +1 -0
  14. package/lib/packages/pages/cms/cms-location-list.mpx.d.ts +1 -0
  15. package/package.json +3 -2
  16. package/src/api/cms/types.ts +7 -1
  17. package/src/components/cms/jmash-cms-activity-page.mpx +360 -0
  18. package/src/components/cms/jmash-cms-article.mpx +174 -11
  19. package/src/components/cms/jmash-cms-location-page.mpx +275 -0
  20. package/src/components/cms/jmash-cms-location.mpx +257 -0
  21. package/src/components/common/jmash-upload-picture.mpx +129 -126
  22. package/src/index.ts +5 -0
  23. package/src/packages/index.mpx +3 -1
  24. package/src/packages/pages/cms/cms-activity-list.mpx +95 -0
  25. package/src/packages/pages/cms/cms-location-list.mpx +95 -0
  26. package/src/packages/pages/cms/cms-location.mpx +33 -0
  27. package/src/pages/home.mpx +0 -2
  28. package/src/pages/home2.mpx +0 -2
  29. package/src/pages/tabbar/home.mpx +45 -34
  30. package/src/components/cms/jmash-cms-acticle-list.mpx +0 -183
  31. package/src/packages/pages/cms/cms-article-list.mpx +0 -165
@@ -1,14 +1,51 @@
1
1
  <template>
2
- <view class="cms_title">{{ article.infoTitle }}</view>
3
- <view class="cms_box" wx:for="{{ contents }}" wx:key="*this">
4
- <rich-text nodes="{{ item.infoContent }}"></rich-text>
2
+ <view class="article-header">
3
+ <view class="article-title">{{ article.infoTitle }}</view>
4
+ <view class="article-meta">
5
+ <view class="meta-item">
6
+ <text class="meta-icon">🕐</text>
7
+ <text class="meta-text">{{ article.publishDateStr }}</text>
8
+ </view>
9
+ <view class="meta-item" style="margin-left: auto;">
10
+ <text class="meta-icon">✍️</text>
11
+ <text class="meta-text">{{ article.author }}</text>
12
+ </view>
13
+ </view>
14
+ <view wx:if="{{ article.address }}" class="location-bar" catch:tap="handleNavigate">
15
+ <view class="location-bar-left">
16
+ <text class="location-bar-pin">📍</text>
17
+ <text class="location-bar-text">{{ article.address }}</text>
18
+ </view>
19
+ <text class="location-bar-nav">导航</text>
20
+ </view>
21
+ </view>
22
+
23
+ <view class="article-body">
24
+ <block wx:for="{{ contents }}" wx:key="*this" wx:for-item="item">
25
+ <block wx:if="{{ item.infoType === 'image' }}">
26
+ <view class="article-image-wrap" wx:for="{{ item.infoContentList }}" wx:key="index" wx:for-item="url">
27
+ <image class="article-image" src="{{ imageUrl + '/clip/' + winWid + '/0/' + url }}"
28
+ mode="widthFix" />
29
+ </view>
30
+ </block>
31
+ <block wx:if="{{ item.infoType === 'movie' }}">
32
+ <view class="article-video-wrap" wx:for="{{ item.infoContentList }}" wx:key="index" wx:for-item="url">
33
+ <video class="article-video" show-mute-btn autoplay="{{ false }}" controls
34
+ src="{{ fileUrl + url }}" />
35
+ </view>
36
+ </block>
37
+ <block wx:if="{{ item.infoType === 'text' }}">
38
+ <rich-text class="article-text" nodes="{{ item.infoContent }}" />
39
+ </block>
40
+ </block>
5
41
  </view>
6
42
  </template>
7
43
 
8
44
  <script lang="ts">
9
- import { createComponent, ref, toRefs, watch } from '@mpxjs/core'
45
+ import mpx, { createComponent, ref, toRefs, watch } from '@mpxjs/core'
10
46
  import { cmsApi } from '../../api/cms/index'
11
47
  import { CmsInfoModel, CmsInfoContentReq, CmsInfoContentModel } from '../../api/cms/types'
48
+ import * as dayjs from 'dayjs';
12
49
 
13
50
  createComponent({
14
51
  properties: {
@@ -29,35 +66,161 @@ createComponent({
29
66
  }
30
67
  },
31
68
  setup(props) {
69
+ let config = getApp().globalData.config;
32
70
  let contents = ref([{} as CmsInfoContentModel]);
33
71
  let article = ref({} as CmsInfoModel);
34
72
  const { infoId } = toRefs(props)
35
73
  watch(infoId, (newVal) => {
36
74
  cmsApi.findCmsInfoById({ infoId: newVal, tenant: props.tenant }).then(({ data }) => {
37
75
  article.value = data;
76
+ article.value.publishDateStr = dayjs(article.value.publishDate).format("YYYY-MM-DD");
38
77
  })
39
78
  cmsApi.findCmsInfoContent({ siteId: props.siteId, infoId: newVal, tenant: props.tenant } as CmsInfoContentReq).then(({ data }) => {
40
79
  contents.value = data.results;
80
+ for (let item of contents.value) {
81
+ if (item.infoType !== "text") {
82
+ item.infoContentList = item.infoContent?.split(',') || [];
83
+ }
84
+ }
41
85
  console.log(contents)
42
86
  })
43
87
  })
88
+ let imageUrl = config.baseUrl + "/v1/file/image";
89
+ // 视频资源路径
90
+ let fileUrl = config.baseUrl + "/v1/file/range/";
91
+ let winWid = mpx.getWindowInfo().screenWidth;
92
+
93
+ const handleNavigate = () => {
94
+ const { address, geoLatitude, geoLongitude, infoTitle } = article.value;
95
+ if (!geoLatitude || !geoLongitude) {
96
+ mpx.showToast({ title: '暂无坐标信息', icon: 'none' });
97
+ return;
98
+ }
99
+ wx.openLocation({
100
+ latitude: geoLatitude,
101
+ longitude: geoLongitude,
102
+ name: infoTitle,
103
+ address: address,
104
+ scale: 16
105
+ });
106
+ };
107
+
44
108
  return {
45
109
  article,
46
- contents
110
+ contents,
111
+ imageUrl,
112
+ fileUrl,
113
+ winWid,
114
+ handleNavigate
47
115
  };
48
116
  },
49
117
  })
50
118
  </script>
51
119
 
52
120
  <style lang="scss">
53
- .cms_box {
54
- padding: 15px 3%;
55
- font-size: 28rpx;
56
- line-height: 25px;
121
+ .article-header {
122
+ padding: 32rpx 30rpx 24rpx;
123
+ border-bottom: 1rpx solid #f0f0f0;
124
+
125
+ .article-title {
126
+ font-size: 36rpx;
127
+ font-weight: 700;
128
+ color: #111;
129
+ line-height: 1.5;
130
+ margin-bottom: 20rpx;
131
+ }
132
+
133
+ .article-meta {
134
+ display: flex;
135
+ align-items: center;
136
+ gap: 32rpx;
137
+
138
+ .meta-item {
139
+ display: flex;
140
+ align-items: center;
141
+ gap: 8rpx;
142
+
143
+ .meta-icon {
144
+ font-size: 22rpx;
145
+ }
146
+
147
+ .meta-text {
148
+ font-size: 24rpx;
149
+ color: #999;
150
+ }
151
+ }
152
+ }
153
+
154
+ .location-bar {
155
+ display: flex;
156
+ align-items: center;
157
+ justify-content: space-between;
158
+ margin-top: 20rpx;
159
+ padding: 18rpx 20rpx;
160
+ background: #f7f8fa;
161
+ border-radius: 12rpx;
162
+
163
+ .location-bar-left {
164
+ display: flex;
165
+ align-items: center;
166
+ gap: 8rpx;
167
+ min-width: 0;
168
+ flex: 1;
169
+
170
+ .location-bar-pin {
171
+ font-size: 22rpx;
172
+ flex-shrink: 0;
173
+ }
174
+
175
+ .location-bar-text {
176
+ font-size: 24rpx;
177
+ color: #666;
178
+ overflow: hidden;
179
+ white-space: nowrap;
180
+ text-overflow: ellipsis;
181
+ }
182
+ }
183
+
184
+ .location-bar-nav {
185
+ flex-shrink: 0;
186
+ font-size: 24rpx;
187
+ color: #409eff;
188
+ font-weight: 500;
189
+ }
190
+ }
57
191
  }
58
192
 
59
- .cms_title {
60
- text-align: center;
193
+ .article-body {
194
+ padding: 30rpx;
195
+ line-height: 1.8;
196
+
197
+ .article-image-wrap {
198
+ margin-bottom: 24rpx;
199
+ border-radius: 12rpx;
200
+ overflow: hidden;
201
+
202
+ .article-image {
203
+ display: block;
204
+ width: 100%;
205
+ }
206
+ }
207
+
208
+ .article-video-wrap {
209
+ margin-bottom: 24rpx;
210
+ border-radius: 12rpx;
211
+ overflow: hidden;
212
+
213
+ .article-video {
214
+ width: 100%;
215
+ }
216
+ }
217
+
218
+ .article-text {
219
+ font-size: 30rpx;
220
+ color: #333;
221
+ line-height: 1.8;
222
+ margin-bottom: 16rpx;
223
+ }
61
224
  }
62
225
  </style>
63
226
 
@@ -0,0 +1,275 @@
1
+ <template>
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' }}">
4
+ <view class="article-border" bind:tap="handleInfo" data-item="{{ item }}">
5
+ <view class="cms-info">
6
+ <view class="cms-image" catch:tap="handlePreview" data-url="{{ item.imgUrl }}">
7
+ <image class="cms-image-thumb" src="{{ imageUrl + item.imgUrl }}" mode="aspectFill" />
8
+ </view>
9
+ <view class="cms-text">
10
+ <view class="cms-text-title">{{ item.infoTitle }}</view>
11
+ <view class="cms-text-desc">{{ item.intro }}</view>
12
+ <view class="cms-text-meta">
13
+ <text class="cms-meta-icon">📍</text>
14
+ <text class="cms-meta-text">{{ item.address }}</text>
15
+ </view>
16
+ </view>
17
+ </view>
18
+ <view class="cms-arrow">›</view>
19
+ </view>
20
+ </block>
21
+ <view wx:if="{{ loading }}" class="load-tip">加载中...</view>
22
+ <view wx:elif="{{ !hasMore && articleList.length > 0 }}" class="load-tip">没有更多了</view>
23
+ </scroll-view>
24
+ </template>
25
+
26
+ <script lang="ts">
27
+ import mpx, { createComponent, ref, watch } from "@mpxjs/core";
28
+ import { EventBase } from "../../api/types";
29
+ import { cmsApi } from '../../api/cms';
30
+ import { CmsInfoModel } from '../../api/cms/types';
31
+
32
+ createComponent({
33
+ properties: {
34
+ // 样式
35
+ style: {
36
+ type: String,
37
+ value: "0",
38
+ },
39
+ // 组织租户
40
+ organTenant: {
41
+ type: String,
42
+ value: ""
43
+ },
44
+ // 站点ID
45
+ siteId: {
46
+ type: String,
47
+ value: ""
48
+ },
49
+ // 栏目ID
50
+ channelId: {
51
+ type: String,
52
+ value: ""
53
+ },
54
+ // 栏目别名
55
+ channelAlias: {
56
+ type: String,
57
+ value: ""
58
+ },
59
+ // 数量
60
+ pageSize: {
61
+ type: Number,
62
+ value: 5
63
+ },
64
+ // 搜索标题
65
+ likeInfoTitle: {
66
+ type: String,
67
+ value: ""
68
+ },
69
+ //refreshKey
70
+ refreshKey: {
71
+ type: Number,
72
+ value: 0
73
+ },
74
+ },
75
+ setup(props) {
76
+ let config = getApp().globalData.config;
77
+ const curPage = ref(1)
78
+ const hasMore = ref(true)
79
+ const loading = ref(false)
80
+ const scrollTop = ref(0)
81
+ // 资源路径
82
+ let resourceUrl = config.resourceUrl + '/images';
83
+ // 文章列表
84
+ let articleList = ref([] as CmsInfoModel[]);
85
+ console.log("cms", props);
86
+
87
+ const loadRecords = function (page: number = 1) {
88
+ if (loading.value) return
89
+ loading.value = true;
90
+ cmsApi.findCmsInfoPage({
91
+ tenant: props.organTenant || config.tenant,
92
+ siteId: props.siteId,
93
+ channelId: props.channelId,
94
+ channelAlias: props.channelAlias,
95
+ curPage: curPage.value,
96
+ pageSize: props.pageSize,
97
+ likeInfoTitle: props.likeInfoTitle,
98
+ }).then(res => {
99
+ if (res.statusCode === 200) {
100
+ if (curPage.value === 1) {
101
+ scrollTop.value = 0
102
+ articleList.value = res.data.results || []
103
+ } else {
104
+ articleList.value = [...articleList.value, ...(res.data.results || [])];
105
+ }
106
+ }
107
+ }).finally(() => {
108
+ loading.value = false
109
+ });
110
+ }
111
+ // 接口图片资源路径 容器宽高度150rpx 裁剪2倍
112
+ let imageUrl = config.baseUrl + "/v1/file/image/clip/300/300/";
113
+ const loadMore = () => {
114
+ if (!hasMore.value || loading.value) return
115
+ loadRecords(curPage.value + 1)
116
+ }
117
+ loadRecords(1);
118
+ watch(
119
+ () => props.refreshKey,
120
+ () => {
121
+ loadRecords(1)
122
+ }
123
+ )
124
+ return { resourceUrl, articleList, imageUrl, curPage, hasMore, loading, scrollTop, loadMore }
125
+ },
126
+ methods: {
127
+ // 点击详情事件
128
+ handleInfo(e: EventBase) {
129
+ let config = getApp().globalData.config;
130
+ let item = e.currentTarget.dataset.item;
131
+ mpx.navigateTo({
132
+ url: '/jmash/pages/cms/cms-location?siteId=' + this.siteId + '&infoId=' + item.infoId,
133
+ });
134
+ // 浏览
135
+ this.handelBrowse(this.organTenant || config.tenant, item.infoId);
136
+ this.triggerEvent("info", item);
137
+ },
138
+ // 浏览
139
+ handelBrowse(tenant: string, infoId: string) {
140
+ const tempData = {
141
+ // 用于检测重复请求的唯一字符串ID
142
+ requestId: Math.random() * 10 + "",
143
+ // 类型
144
+ type: "information",
145
+ // 关系
146
+ relationId: infoId,
147
+ // 租户
148
+ tenant: tenant
149
+ };
150
+ cmsApi.createfrontBrowseRecord(tempData);
151
+ },
152
+ }
153
+ })
154
+ </script>
155
+
156
+ <style lang="scss">
157
+ @use "../../styles/index.scss" as *;
158
+
159
+ .article-main {
160
+ padding: 0 30rpx;
161
+ border-radius: 20rpx;
162
+ background-color: #fff;
163
+ }
164
+
165
+ // 有分割线列表
166
+ .article-border {
167
+ padding: 24rpx 0;
168
+ border-bottom: 1rpx solid $border-line;
169
+
170
+ &:last-child {
171
+ border: none;
172
+ }
173
+ }
174
+
175
+ // 无分割线列表
176
+ .article-info {
177
+ position: relative;
178
+ padding: 24rpx;
179
+ background-color: #fff;
180
+ border-radius: 16rpx;
181
+ margin-bottom: 20rpx;
182
+ box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
183
+ }
184
+
185
+ .cms-info {
186
+ display: flex;
187
+ align-items: center;
188
+ gap: 24rpx;
189
+
190
+ .cms-text {
191
+ flex: 1;
192
+ min-width: 0;
193
+ display: flex;
194
+ flex-direction: column;
195
+ gap: 12rpx;
196
+
197
+ .cms-text-title {
198
+ color: #222;
199
+ font-size: 30rpx;
200
+ font-weight: 600;
201
+ line-height: 1.4;
202
+ overflow: hidden;
203
+ white-space: nowrap;
204
+ text-overflow: ellipsis;
205
+ }
206
+
207
+ .cms-text-desc {
208
+ color: #888;
209
+ font-size: 24rpx;
210
+ line-height: 1.5;
211
+ overflow: hidden;
212
+ display: -webkit-box;
213
+ -webkit-box-orient: vertical;
214
+ -webkit-line-clamp: 2;
215
+ text-overflow: ellipsis;
216
+ }
217
+
218
+ .cms-text-meta {
219
+ display: flex;
220
+ align-items: center;
221
+ gap: 6rpx;
222
+
223
+ .cms-meta-icon {
224
+ font-size: 22rpx;
225
+ }
226
+
227
+ .cms-meta-text {
228
+ color: #aaa;
229
+ font-size: 22rpx;
230
+ overflow: hidden;
231
+ white-space: nowrap;
232
+ text-overflow: ellipsis;
233
+ }
234
+ }
235
+ }
236
+
237
+ .cms-image {
238
+ flex-shrink: 0;
239
+ width: 180rpx;
240
+ height: 180rpx;
241
+ border-radius: 12rpx;
242
+ overflow: hidden;
243
+ background: #f0f0f0;
244
+
245
+ .cms-image-thumb {
246
+ width: 100%;
247
+ height: 100%;
248
+ }
249
+ }
250
+ }
251
+
252
+ .cms-arrow {
253
+ display: none;
254
+ }
255
+
256
+ // 无分割线列表显示右箭头
257
+ .article-info .cms-arrow {
258
+ display: block;
259
+ position: absolute;
260
+ right: 24rpx;
261
+ top: 50%;
262
+ transform: translateY(-50%);
263
+ font-size: 36rpx;
264
+ color: #ccc;
265
+ }
266
+ </style>
267
+
268
+ <script type="application/json">
269
+ {
270
+ "component": true,
271
+ "usingComponents": {
272
+ "jmash-cms-like": "./jmash-cms-like"
273
+ }
274
+ }
275
+ </script>