Browse Source

bug fix + 活动页面

dev
kola-web 8 hours ago
parent
commit
957454fa40
  1. 31
      src/components/popup/index.scss
  2. BIN
      src/images/icon47.png
  3. BIN
      src/images/icon48.png
  4. 16
      src/pages/health/index.ts
  5. 4
      src/pages/heartForm/index.ts
  6. 26
      src/pages/hotTopicDetail/index.scss
  7. 44
      src/pages/hotTopicDetail/index.wxml
  8. 4
      src/pages/index/index.ts
  9. 15
      src/pages/login/index.scss
  10. 4
      src/pages/login/index.ts
  11. 43
      src/pages/login/index.wxml
  12. 4
      src/pages/my/index.ts
  13. 2
      src/pages/myWall/index.wxml
  14. 36
      src/pages/wall/index.scss
  15. 8
      src/pages/wall/index.wxml
  16. 16
      src/pages/wallDetail/index.scss
  17. 3
      src/pages/wallDetail/index.wxml
  18. 13
      src/pages/wallForm/index.scss
  19. 56
      src/pages/wallForm/index.ts
  20. 61
      src/pages/wallForm/index.wxml
  21. 11
      src/utils/tools.wxs

31
src/components/popup/index.scss

@ -15,6 +15,7 @@
font-size: 36rpx; font-size: 36rpx;
color: rgba(100, 116, 139, 1); color: rgba(100, 116, 139, 1);
line-height: 52rpx; line-height: 52rpx;
white-space: nowrap;
} }
.code { .code {
margin: 70rpx auto 0; margin: 70rpx auto 0;
@ -148,35 +149,9 @@
text-align: center; text-align: center;
} }
.code { .code {
margin: 52rpx auto 0;
display: block; display: block;
width: 348rpx; width: 100%;
height: 348rpx; height: 100%;
}
}
}
}
.popup5 {
.popup-container {
.container {
padding-top: 572rpx;
width: 690rpx;
height: 720rpx;
border-radius: 42rpx;
box-sizing: border-box;
.btn {
display: block;
margin: 0 auto;
width: 626rpx;
height: 96rpx;
font-size: 40rpx;
color: rgba(255, 255, 255, 1);
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(270deg, #439fc7 0%, #2f82a9 100%);
border-radius: 24rpx 24rpx 24rpx 24rpx;
} }
} }
} }

BIN
src/images/icon47.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

BIN
src/images/icon48.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 841 B

16
src/pages/health/index.ts

@ -437,10 +437,18 @@ Page({
}, },
}).then(() => { }).then(() => {
if (!userInfo.isHeartRateTips) { if (!userInfo.isHeartRateTips) {
this.setData({ if (userInfo.isFollow == 1) {
popupShow: true, wx.showToast({
popupType: 'popup1', icon: 'none',
}) title: '设置成功,我们将在每周五下午7点提醒您记录',
duration: 3000,
})
} else {
this.setData({
popupShow: true,
popupType: 'popup1',
})
}
} }
this.setData({ this.setData({
['userInfo.isHeartRateTips']: !userInfo.isHeartRateTips, ['userInfo.isHeartRateTips']: !userInfo.isHeartRateTips,

4
src/pages/heartForm/index.ts

@ -1,3 +1,5 @@
import dayjs from "dayjs"
const app = getApp<IAppOption>() const app = getApp<IAppOption>()
Page({ Page({
@ -11,7 +13,7 @@ Page({
id: '', id: '',
heartRate: '', heartRate: '',
recordDateTime: '', recordDateTime: dayjs().format("YYYY-MM-DD HH:mm"),
datetimePickerShow: false, datetimePickerShow: false,
datetimeValue: Date.now(), datetimeValue: Date.now(),
maxDate: Date.now(), maxDate: Date.now(),

26
src/pages/hotTopicDetail/index.scss

@ -113,23 +113,45 @@ page {
line-height: 32rpx; line-height: 32rpx;
box-sizing: border-box; box-sizing: border-box;
} }
.content { .title {
margin-top: 32rpx; margin-top: 32rpx;
font-size: 32rpx; font-size: 32rpx;
color: rgba(24, 28, 30, 1); color: rgba(24, 28, 30, 1);
font-weight: bold;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.content {
margin-top: 12rpx;
font-size: 32rpx;
color: rgba(24, 28, 30, 1);
line-height: 52rpx; line-height: 52rpx;
.c-topic { .c-topic {
display: inline; display: inline;
font-size: 32rpx; font-size: 32rpx;
color: rgba(47, 130, 169, 1); color: rgba(47, 130, 169, 1);
} }
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
} }
.tags { .tags {
margin-top: 24rpx; margin-top: 24rpx;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: nowrap;
gap: 16rpx; gap: 16rpx;
overflow-x: auto;
overflow-y: hidden;
&::-webkit-scrollbar {
display: none;
}
.tag { .tag {
flex-shrink: 0;
padding: 0 24rpx; padding: 0 24rpx;
height: 48rpx; height: 48rpx;
font-size: 24rpx; font-size: 24rpx;

44
src/pages/hotTopicDetail/index.wxml

@ -29,13 +29,24 @@
<view class="date">{{item.publishTime}}</view> <view class="date">{{item.publishTime}}</view>
</view> </view>
</view> </view>
<view class="hot" wx:if="{{item.isRecommend===1}}" style="background: url('{{imageUrl}}bg11.png?t={{Timestamp}}') no-repeat top center/100%">热门推荐</view> <view
class="hot"
wx:if="{{item.isRecommend===1}}"
style="background: url('{{imageUrl}}bg11.png?t={{Timestamp}}') no-repeat top center/100%"
>
热门推荐
</view>
<view class="title">{{item.title}}</view>
<view class="content"> <view class="content">
<view class="c-topic" wx:for="{{item.topics}}" wx:key="topicId" wx:for-item="topic">#{{topic.topicName}}</view> <view class="c-topic" wx:for="{{item.topics}}" wx:key="topicId" wx:for-item="topic">
#{{topic.topicName}}
</view>
{{item.content}} {{item.content}}
</view> </view>
<view class="tags" wx:if="{{item.categories && item.categories.length}}"> <view class="tags" wx:if="{{item.categories && item.categories.length}}">
<view class="tag" wx:for="{{item.categories}}" wx:key="categoryId" wx:for-item="cate">{{cate.categoryName}}</view> <view class="tag" wx:for="{{item.categories}}" wx:key="categoryId" wx:for-item="cate">
{{cate.categoryName}}
</view>
</view> </view>
<!-- 单图 --> <!-- 单图 -->
<image <image
@ -59,13 +70,26 @@
<image class="play-icon" src="{{imageUrl}}icon17.png?t={{Timestamp}}"></image> <image class="play-icon" src="{{imageUrl}}icon17.png?t={{Timestamp}}"></image>
</view> </view>
<!-- 多图/视频混合 --> <!-- 多图/视频混合 -->
<view <view wx:if="{{item.attachments.length>1}}" class="photo9">
wx:if="{{item.attachments.length>1}}" <view
class="photo9" class="p-item"
> wx:for="{{item.attachments}}"
<view class="p-item" wx:for="{{item.attachments}}" wx:for-item="att" wx:key="id" catch:tap="handlePreviewMedia" data-index="{{index}}" data-attachments="{{item.attachments}}"> wx:for-item="att"
<image class="p-img" mode="aspectFill" src="{{att.attachmentType==2 ? att.videoCoverUrl : att.attachmentUrl}}"></image> wx:key="id"
<image class="play-icon" wx:if="{{att.attachmentType==2}}" src="{{imageUrl}}icon17.png?t={{Timestamp}}"></image> catch:tap="handlePreviewMedia"
data-index="{{index}}"
data-attachments="{{item.attachments}}"
>
<image
class="p-img"
mode="aspectFill"
src="{{att.attachmentType==2 ? att.videoCoverUrl : att.attachmentUrl}}"
></image>
<image
class="play-icon"
wx:if="{{att.attachmentType==2}}"
src="{{imageUrl}}icon17.png?t={{Timestamp}}"
></image>
</view> </view>
</view> </view>
<view class="footer"> <view class="footer">

4
src/pages/index/index.ts

@ -10,7 +10,7 @@ Page({
} as any, } as any,
userInfo: {} as any, userInfo: {} as any,
days: 0, days: 1,
cateList: [] as Array<{ CateId: string; CateName: string }>, cateList: [] as Array<{ CateId: string; CateName: string }>,
activeCateId: '', activeCateId: '',
picTextList: [] as Array<any>, picTextList: [] as Array<any>,
@ -125,7 +125,7 @@ Page({
method: 'GET', method: 'GET',
url: '?r=psvt/patient/my-info', url: '?r=psvt/patient/my-info',
}).then((res: any) => { }).then((res: any) => {
let days = 0 let days = 1
if (res.firstOpenTime) { if (res.firstOpenTime) {
const first = new Date(res.firstOpenTime.replace(/-/g, '/')) const first = new Date(res.firstOpenTime.replace(/-/g, '/'))
const now = new Date() const now = new Date()

15
src/pages/login/index.scss

@ -6,7 +6,7 @@
} }
.container { .container {
margin-top: 440rpx; margin-top: 440rpx;
padding: 74rpx 40rpx; padding: 54rpx 40rpx;
background-color: #fff; background-color: #fff;
border-radius: 32rpx 32rpx 0 0; border-radius: 32rpx 32rpx 0 0;
.tip { .tip {
@ -21,7 +21,7 @@
height: 390rpx; height: 390rpx;
} }
.phone-btn { .phone-btn {
margin: 124rpx 0 0; margin: 144rpx 0 0;
height: 96rpx; height: 96rpx;
line-height: 96rpx; line-height: 96rpx;
text-align: center; text-align: center;
@ -46,7 +46,14 @@
margin-top: 56rpx; margin-top: 56rpx;
font-size: 32rpx; font-size: 32rpx;
color: rgba(47, 130, 169, 1); color: rgba(47, 130, 169, 1);
text-align: center; display: flex;
align-items: center;
justify-content: center;
gap: 16rpx;
.icon {
width: 24rpx;
height: 40rpx;
}
} }
.form { .form {
margin-top: 32rpx; margin-top: 32rpx;
@ -70,8 +77,8 @@
} }
.code { .code {
margin-left: 24rpx; margin-left: 24rpx;
padding: 0 32rpx;
flex-shrink: 0; flex-shrink: 0;
width: 212rpx;
height: 68rpx; height: 68rpx;
border-radius: 24rpx; border-radius: 24rpx;
font-size: 28rpx; font-size: 28rpx;

4
src/pages/login/index.ts

@ -6,7 +6,7 @@ Page({
menuTop: 0, menuTop: 0,
checked: false, checked: false,
codeText: '发送验证码', codeText: '验证码',
showTel: false, showTel: false,
mobile: '', mobile: '',
@ -58,7 +58,7 @@ Page({
clearInterval(timer as number) clearInterval(timer as number)
timer = null timer = null
this.setData({ this.setData({
codeText: '发送验证码', codeText: '验证码',
}) })
} }
}, 1000) }, 1000)

43
src/pages/login/index.wxml

@ -1,19 +1,23 @@
<view class="page" style="background: url('{{imageUrl}}bg1.png?t={{Timestamp}}') no-repeat top center/100%;padding-top: {{menuTop}}px;"> <view
class="page"
style="background: url('{{imageUrl}}bg1.png?t={{Timestamp}}') no-repeat top center/100%;padding-top: {{menuTop}}px;"
>
<image class="logo" src="{{imageUrl}}logo1.png?t={{Timestamp}}"></image> <image class="logo" src="{{imageUrl}}logo1.png?t={{Timestamp}}"></image>
<view class="container"> <view class="container">
<view class="tip">请先阅读并同意相关协议。立即加入后,我们将为您提供更匹配的科普内容与服务支持。</view> <view class="tip">请先阅读并同意相关协议。立即加入后,我们将为您提供更匹配的科普内容与服务支持。</view>
<button wx:if="{{checked}}" class="phone-btn" open-type="getPhoneNumber" bindgetphonenumber="handleWxSubmit"> <block wx:if="{{!showTel}}">
<image class="icon" src="{{imageUrl}}icon1.png?t={{Timestamp}}"></image> <button wx:if="{{checked}}" class="phone-btn" open-type="getPhoneNumber" bindgetphonenumber="handleWxSubmit">
手机号快捷登录 <image class="icon" src="{{imageUrl}}icon1.png?t={{Timestamp}}"></image>
</button> 手机号快捷登录
<button wx:else class="phone-btn" bind:tap="handleWxCheck"> </button>
<image class="icon" src="{{imageUrl}}icon1.png?t={{Timestamp}}"></image> <button wx:else class="phone-btn" bind:tap="handleWxCheck">
手机号快捷登录 <image class="icon" src="{{imageUrl}}icon1.png?t={{Timestamp}}"></image>
</button> 手机号快捷登录
<view class="switch" bind:tap="handleShowTel">或输入手机号</view> </button>
</block>
<view class="form" wx:if="{{showTel}}"> <view class="form" wx:if="{{showTel}}">
<view class="row"> <view class="row">
<input type="number" model:value="{{mobile}}" class="input" placeholder="请输入手机号" /> <input type="number" focus="{{showTel}}" model:value="{{mobile}}" class="input" placeholder="请输入手机号" />
</view> </view>
<view class="row"> <view class="row">
<input type="number" model:value="{{code}}" class="input" placeholder="请输入验证码" /> <input type="number" model:value="{{code}}" class="input" placeholder="请输入验证码" />
@ -22,22 +26,21 @@
<view wx:if="{{checked}}" class="submit" bind:tap="handleSubmit">立即加入</view> <view wx:if="{{checked}}" class="submit" bind:tap="handleSubmit">立即加入</view>
<view wx:else class="submit" bind:tap="handleWxCheck">立即加入</view> <view wx:else class="submit" bind:tap="handleWxCheck">立即加入</view>
</view> </view>
<view class="switch" wx:if="{{showTel}}" bind:tap="handleShowTel">
<image class="icon" src="{{imageUrl}}icon47.png?t={{Timestamp}}"></image>
手机号一键注册
</view>
<view class="switch" wx:else bind:tap="handleShowTel">或输入手机号</view>
<view class="argument"> <view class="argument">
<view class="a-col"> <view class="a-col">
<checkbox class="check" checked="{{checked}}" bind:tap="handleCheck"> <checkbox class="check" checked="{{checked}}" bind:tap="handleCheck">
<view class="check-content"> <view class="check-content">
我已阅读并同意 我已阅读并同意
<view class="link" catch:tap="handleLink" data-url="/doc/pages/doc1/index?active=2"> <view class="link" catch:tap="handleLink" data-url="/doc/pages/doc1/index?active=2">《用户协议》</view>
《用户协议》
</view>
以及 以及
<view class="link" catch:tap="handleLink" data-url="/doc/pages/doc1/index?active=1"> <view class="link" catch:tap="handleLink" data-url="/doc/pages/doc1/index?active=1">《隐私政策》</view>
《隐私政策》
</view>
<view class="link" catch:tap="handleLink" data-url="/doc/pages/doc1/index?active=3"> <view class="link" catch:tap="handleLink" data-url="/doc/pages/doc1/index?active=3">《法律声明》</view>
《法律声明》
</view>
并同意平台基于服务需要收集和使用我的必要个人信息。 并同意平台基于服务需要收集和使用我的必要个人信息。
</view> </view>
</checkbox> </checkbox>

4
src/pages/my/index.ts

@ -3,7 +3,7 @@ const app = getApp()
Page({ Page({
data: { data: {
userInfo: {} as any, userInfo: {} as any,
days: 0, days: 1,
}, },
onShow() { onShow() {
app.waitLogin({ type: 1 }).then(() => { app.waitLogin({ type: 1 }).then(() => {
@ -15,7 +15,7 @@ Page({
method: 'GET', method: 'GET',
url: '?r=psvt/patient/my-info', url: '?r=psvt/patient/my-info',
}).then((res) => { }).then((res) => {
let days = 0 let days = 1
if (res.firstOpenTime) { if (res.firstOpenTime) {
const first = new Date(res.firstOpenTime.replace(/-/g, '/')) const first = new Date(res.firstOpenTime.replace(/-/g, '/'))
const now = new Date() const now = new Date()

2
src/pages/myWall/index.wxml

@ -45,7 +45,7 @@
</view> </view>
</view> </view>
<view class="date">{{item.dateText}}</view> <view class="date">{{item.dateText}}</view>
<view class="rejected" wx:if="{{item.postStatus === 3 && item.rejectReason}}"> <view class="rejected" wx:if="{{item.postStatus == 3 && item.rejectReason}}">
<image class="icon" src="{{imageUrl}}icon39.png?t={{Timestamp}}"></image> <image class="icon" src="{{imageUrl}}icon39.png?t={{Timestamp}}"></image>
<view class="blod">驳回原因:</view> <view class="blod">驳回原因:</view>
{{item.rejectReason}} {{item.rejectReason}}

36
src/pages/wall/index.scss

@ -106,7 +106,7 @@ page {
padding: 36rpx 32rpx 12rpx; padding: 36rpx 32rpx 12rpx;
border-radius: 32rpx; border-radius: 32rpx;
border: 2rpx solid #f1f5f9; border: 2rpx solid #f1f5f9;
background: rgba(255, 255, 255, 0.70); background: rgba(255, 255, 255, 0.7);
box-shadow: 0 16rpx 48rpx -8rpx rgba(0, 99, 132, 0.06); box-shadow: 0 16rpx 48rpx -8rpx rgba(0, 99, 132, 0.06);
box-sizing: border-box; box-sizing: border-box;
.user { .user {
@ -133,33 +133,55 @@ page {
} }
.hot { .hot {
position: absolute; position: absolute;
top: 0; top: -12rpx;
right: 0; right: 36rpx;
padding: 8rpx 0 0 44rpx; padding: 8rpx 0 0 44rpx;
font-size: 28rpx; font-size: 28rpx;
color: rgba(255, 255, 255, 1); color: rgba(255, 255, 255, 1);
width: 180rpx; width: 104rpx;
height: 68rpx; height: 48rpx;
line-height: 32rpx; line-height: 32rpx;
box-sizing: border-box; box-sizing: border-box;
} }
.content { .title {
margin-top: 32rpx; margin-top: 32rpx;
font-size: 32rpx; font-size: 32rpx;
color: rgba(24, 28, 30, 1); color: rgba(24, 28, 30, 1);
font-weight: bold;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.content {
margin-top: 12rpx;
font-size: 32rpx;
color: rgba(24, 28, 30, 1);
line-height: 52rpx; line-height: 52rpx;
.c-topic { .c-topic {
display: inline; display: inline;
font-size: 32rpx; font-size: 32rpx;
color: rgba(47, 130, 169, 1); color: rgba(47, 130, 169, 1);
} }
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
} }
.tags { .tags {
margin-top: 24rpx; margin-top: 24rpx;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: nowrap;
gap: 16rpx; gap: 16rpx;
overflow-x: auto;
overflow-y: hidden;
&::-webkit-scrollbar {
display: none;
}
.tag { .tag {
flex-shrink: 0;
padding: 0 24rpx; padding: 0 24rpx;
height: 48rpx; height: 48rpx;
font-size: 24rpx; font-size: 24rpx;

8
src/pages/wall/index.wxml

@ -48,13 +48,13 @@
<view class="date">{{item.publishTime}}</view> <view class="date">{{item.publishTime}}</view>
</view> </view>
</view> </view>
<view <view
class="hot" class="hot"
wx:if="{{item.isRecommend===1}}" wx:if="{{item.isRecommend===1}}"
style="background: url('{{imageUrl}}bg11.png?t={{Timestamp}}') no-repeat top center/100%" style="background: url('{{imageUrl}}bg16.png?t={{Timestamp}}') no-repeat top center/100%"
> ></view>
热门推荐 <view class="title">{{item.title}}</view>
</view>
<view class="content"> <view class="content">
<view <view
class="c-topic" class="c-topic"

16
src/pages/wallDetail/index.scss

@ -61,10 +61,16 @@ page {
} }
} }
} }
.content { .title {
margin-top: 32rpx; margin-top: 32rpx;
font-size: 32rpx; font-size: 32rpx;
color: rgba(24, 28, 30, 1); color: rgba(24, 28, 30, 1);
font-weight: bold;
}
.content {
margin-top: 12rpx;
font-size: 32rpx;
color: rgba(24, 28, 30, 1);
line-height: 52rpx; line-height: 52rpx;
.c-topic { .c-topic {
display: inline; display: inline;
@ -75,9 +81,15 @@ page {
.tags { .tags {
margin-top: 24rpx; margin-top: 24rpx;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: nowrap;
gap: 16rpx; gap: 16rpx;
overflow-x: auto;
overflow-y: hidden;
&::-webkit-scrollbar {
display: none;
}
.tag { .tag {
flex-shrink: 0;
padding: 0 24rpx; padding: 0 24rpx;
height: 48rpx; height: 48rpx;
font-size: 24rpx; font-size: 24rpx;

3
src/pages/wallDetail/index.wxml

@ -31,6 +31,7 @@
<view class="date">{{post.publishTime}}</view> <view class="date">{{post.publishTime}}</view>
</view> </view>
</view> </view>
<view class="title">{{post.title}}</view>
<view class="content"> <view class="content">
<view <view
class="c-topic" class="c-topic"
@ -108,7 +109,7 @@
<view class="op" bind:tap="handleCommentLike" data-id="{{item.id}}" data-index="{{pIndex}}"> <view class="op" bind:tap="handleCommentLike" data-id="{{item.id}}" data-index="{{pIndex}}">
<image <image
class="icon" class="icon"
src="{{imageUrl}}{{item.hasLiked ? 'icon9-1' : 'icon9'}}.png?t={{Timestamp}}" src="{{imageUrl}}{{item.hasLiked ? 'icon9-active' : 'icon9'}}.png?t={{Timestamp}}"
></image> ></image>
<view class="num">{{item.likeCount || 0}}</view> <view class="num">{{item.likeCount || 0}}</view>
</view> </view>

13
src/pages/wallForm/index.scss

@ -68,6 +68,19 @@ page {
.txa-place { .txa-place {
color: rgba(148, 163, 184, 1); color: rgba(148, 163, 184, 1);
} }
.limit {
margin-bottom: 30rpx;
margin-top: 32rpx;
display: flex;
align-items: center;
gap: 12rpx;
font-size: 28rpx;
color: rgba(186, 26, 26, 1);
.icon {
width: 32rpx;
height: 32rpx;
}
}
.topic-list { .topic-list {
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;

56
src/pages/wallForm/index.ts

@ -29,26 +29,26 @@ Page({
this.setData({ isEdit: true, editPostId: options.id }) this.setData({ isEdit: true, editPostId: options.id })
} }
app.waitLogin({ type: 1 }).then(() => { app.waitLogin({ type: 1 }).then(() => {
this.getTopicList() const listReady = Promise.all([this.getTopicList(), this.getCategoryList()])
this.getCategoryList()
if (this.data.isEdit) { if (this.data.isEdit) {
this.getPostDetail() listReady.then(() => {
this.getPostDetail()
})
} }
}) })
}, },
getTopicList() { getTopicList() {
wx.ajax({ return wx.ajax({
method: 'GET', method: 'GET',
url: '?r=psvt/topic/top-list', url: '?r=psvt/topic/top-list',
}).then((res: any) => { }).then((res: any) => {
this.setData({ this.setData({
topicList: res.list || [], topicList: res.list || [],
selectedTopics: this.computeSelectedTopics(this.data.selectedTopicIds, res.list || []),
}) })
}) })
}, },
getCategoryList() { getCategoryList() {
wx.ajax({ return wx.ajax({
method: 'GET', method: 'GET',
url: '?r=psvt/wall/index-category', url: '?r=psvt/wall/index-category',
}).then((res: any) => { }).then((res: any) => {
@ -80,16 +80,20 @@ Page({
url: item.attachmentUrl || '', url: item.attachmentUrl || '',
} }
}) })
// Build selectedTopics directly from the post detail, which already carries
// topicName. We must NOT rely on topicList.find() here because topic/top-list
// only returns the top-10 by weight, so a post's topics may not be in it.
const selectedTopics = (res.topics || []).map((t: any) => ({
id: Number(t.topicId),
topicName: t.topicName || '',
}))
this.setData({ this.setData({
title: res.title || '', title: res.title || '',
content: res.content || '', content: res.content || '',
visibility: res.visibility || 1, visibility: res.visibility || 1,
selectedTopicIds: (res.topics || []).map((t: any) => t.topicId), selectedTopicIds: selectedTopics.map((t: any) => t.id),
selectedTopics: this.computeSelectedTopics( selectedTopics,
(res.topics || []).map((t: any) => t.topicId), selectedCategoryIds: (res.categories || []).map((c: any) => Number(c.categoryId)),
this.data.topicList,
),
selectedCategoryIds: (res.categories || []).map((c: any) => c.categoryId),
fileList, fileList,
}) })
}) })
@ -103,27 +107,29 @@ Page({
handleTopicTap(e: any) { handleTopicTap(e: any) {
const id = Number(e.currentTarget.dataset.id) const id = Number(e.currentTarget.dataset.id)
const selectedTopicIds = [...this.data.selectedTopicIds] const selectedTopicIds = [...this.data.selectedTopicIds]
const selectedTopics = [...this.data.selectedTopics]
const index = selectedTopicIds.indexOf(id) const index = selectedTopicIds.indexOf(id)
if (index > -1) { if (index > -1) {
selectedTopicIds.splice(index, 1) selectedTopicIds.splice(index, 1)
selectedTopics.splice(index, 1)
} else { } else {
selectedTopicIds.push(id) const topic = this.data.topicList.find((t: any) => Number(t.id) === id)
if (topic) {
selectedTopicIds.push(id)
selectedTopics.push({ id: Number(topic.id), topicName: topic.topicName })
}
} }
this.setData({ this.setData({ selectedTopicIds, selectedTopics })
selectedTopicIds,
selectedTopics: this.computeSelectedTopics(selectedTopicIds, this.data.topicList),
})
}, },
handleRemoveTopic(e: any) { handleRemoveTopic(e: any) {
const id = Number(e.currentTarget.dataset.id) const id = Number(e.currentTarget.dataset.id)
const selectedTopicIds = this.data.selectedTopicIds.filter((tid) => tid !== id) const index = this.data.selectedTopicIds.indexOf(id)
this.setData({ if (index === -1) return
selectedTopicIds, const selectedTopicIds = [...this.data.selectedTopicIds]
selectedTopics: this.computeSelectedTopics(selectedTopicIds, this.data.topicList), const selectedTopics = [...this.data.selectedTopics]
}) selectedTopicIds.splice(index, 1)
}, selectedTopics.splice(index, 1)
computeSelectedTopics(ids: number[], list: any[]) { this.setData({ selectedTopicIds, selectedTopics })
return ids.map((id) => list.find((t) => String(t.id) === String(id))).filter((t) => t)
}, },
showTopicPopup() { showTopicPopup() {
this.setData({ topicShow: true }) this.setData({ topicShow: true })

61
src/pages/wallForm/index.wxml

@ -13,9 +13,23 @@
> >
<view class="form"> <view class="form">
<view class="upload-wrap"> <view class="upload-wrap">
<uploadFile fileList="{{fileList}}" fileType="mix" maxNum="{{9}}" bind:setData="handleSetData" bind:deleteFile="handleDeleteFile"></uploadFile> <uploadFile
fileList="{{fileList}}"
fileType="mix"
maxNum="{{9}}"
bind:setData="handleSetData"
bind:deleteFile="handleDeleteFile"
></uploadFile>
</view> </view>
<input type="text" class="title" placeholder-class="title-place" placeholder="请添加标题" maxlength="{{50}}" value="{{title}}" bindinput="onTitleInput" /> <input
type="text"
class="title"
placeholder-class="title-place"
placeholder="请添加标题"
maxlength="{{50}}"
value="{{title}}"
bindinput="onTitleInput"
/>
<view class="selected-topics" wx:if="{{selectedTopics.length}}"> <view class="selected-topics" wx:if="{{selectedTopics.length}}">
<view class="s-item" wx:for="{{selectedTopics}}" wx:key="id" bind:tap="handleRemoveTopic" data-id="{{item.id}}"> <view class="s-item" wx:for="{{selectedTopics}}" wx:key="id" bind:tap="handleRemoveTopic" data-id="{{item.id}}">
#{{item.topicName}} #{{item.topicName}}
@ -28,9 +42,20 @@
placeholder="分享你的经历、心得或问题,帮助更多病友..." placeholder="分享你的经历、心得或问题,帮助更多病友..."
value="{{content}}" value="{{content}}"
bindinput="onContentInput" bindinput="onContentInput"
maxlength="{{500}}"
></textarea> ></textarea>
<view class="limit" wx:if="{{content.length>=500}}">
<image class="icon" src="{{imageUrl}}icon48.png?t={{Timestamp}}"></image>
最多可输入500字
</view>
<view class="topic-list"> <view class="topic-list">
<view class="t-item" wx:for="{{topicList}}" wx:key="id" bind:tap="handleTopicTap" data-id="{{item.id}}"> <view
class="t-item"
wx:for="{{tools.excludeByIds(topicList, selectedTopicIds)}}"
wx:key="id"
bind:tap="handleTopicTap"
data-id="{{item.id}}"
>
<image class="icon" src="{{imageUrl}}icon18.png?t={{Timestamp}}"></image> <image class="icon" src="{{imageUrl}}icon18.png?t={{Timestamp}}"></image>
{{item.topicName}} {{item.topicName}}
</view> </view>
@ -40,7 +65,7 @@
<image class="icon" src="{{imageUrl}}icon18.png?t={{Timestamp}}"></image> <image class="icon" src="{{imageUrl}}icon18.png?t={{Timestamp}}"></image>
话题 话题
</view> </view>
<view class="total">{{content.length || 0}}/2000</view> <view class="total">{{content.length || 0}}/500</view>
</view> </view>
</view> </view>
<view class="tag-module"> <view class="tag-module">
@ -49,7 +74,15 @@
内容标签 内容标签
</view> </view>
<view class="tag-wrap"> <view class="tag-wrap">
<view class="tag {{tools.include(item.id, selectedCategoryIds) ? 'active' : ''}}" wx:for="{{categoryList}}" wx:key="id" bind:tap="handleCategoryTap" data-id="{{item.id}}">{{item.categoryName}}</view> <view
class="tag {{tools.include(item.id, selectedCategoryIds) ? 'active' : ''}}"
wx:for="{{categoryList}}"
wx:key="id"
bind:tap="handleCategoryTap"
data-id="{{item.id}}"
>
{{item.categoryName}}
</view>
</view> </view>
</view> </view>
<view class="view-module"> <view class="view-module">
@ -59,14 +92,20 @@
</view> </view>
<view class="v-wrap"> <view class="v-wrap">
<view class="item {{visibility === 1 ? 'active' : ''}}" bind:tap="handleVisibilityChange" data-value="1"> <view class="item {{visibility === 1 ? 'active' : ''}}" bind:tap="handleVisibilityChange" data-value="1">
<image class="icon" src="{{imageUrl}}{{visibility === 1 ? 'icon21-active' : 'icon21'}}.png?t={{Timestamp}}"></image> <image
class="icon"
src="{{imageUrl}}{{visibility === 1 ? 'icon21-active' : 'icon21'}}.png?t={{Timestamp}}"
></image>
<view class="wrap"> <view class="wrap">
<view class="name">公开</view> <view class="name">公开</view>
<view class="content">所有用户可见</view> <view class="content">所有用户可见</view>
</view> </view>
</view> </view>
<view class="item {{visibility === 2 ? 'active' : ''}}" bind:tap="handleVisibilityChange" data-value="2"> <view class="item {{visibility === 2 ? 'active' : ''}}" bind:tap="handleVisibilityChange" data-value="2">
<image class="icon" src="{{imageUrl}}{{visibility === 2 ? 'icon22-active' : 'icon22'}}.png?t={{Timestamp}}"></image> <image
class="icon"
src="{{imageUrl}}{{visibility === 2 ? 'icon22-active' : 'icon22'}}.png?t={{Timestamp}}"
></image>
<view class="wrap"> <view class="wrap">
<view class="name">私密</view> <view class="name">私密</view>
<view class="content">仅自己可见</view> <view class="content">仅自己可见</view>
@ -93,7 +132,13 @@
<van-icon class="cross" name="cross" bind:tap="topicPopupClose" /> <van-icon class="cross" name="cross" bind:tap="topicPopupClose" />
</view> </view>
<view class="tp-list"> <view class="tp-list">
<view class="li {{tools.include(item.id, selectedTopicIds) ? 'active' : ''}}" wx:for="{{topicList}}" wx:key="id" bind:tap="handleTopicTap" data-id="{{item.id}}"> <view
class="li {{tools.include(item.id, selectedTopicIds) ? 'active' : ''}}"
wx:for="{{topicList}}"
wx:key="id"
bind:tap="handleTopicTap"
data-id="{{item.id}}"
>
<view class="num">{{index+1}}</view> <view class="num">{{index+1}}</view>
<view class="content"># {{item.topicName}}</view> <view class="content"># {{item.topicName}}</view>
<view class="total">{{item.postCount}}篇帖子</view> <view class="total">{{item.postCount}}篇帖子</view>

11
src/utils/tools.wxs

@ -7,7 +7,18 @@ function include(value, arr) {
return false return false
} }
function excludeByIds(list, ids) {
var result = []
for (var i = 0; i < list.length; i++) {
if (!include(list[i].id, ids)) {
result.push(list[i])
}
}
return result
}
module.exports = { module.exports = {
include: include, include: include,
inArray: include, inArray: include,
excludeByIds: excludeByIds,
} }

Loading…
Cancel
Save