当前位置:   article > 正文

微信小程序实战——消息通知界面_微信小程序消息界面

微信小程序消息界面

先给大家上一个实战的效果图

 

这个是我们小组在开发的一个消息界面,用于实现简单的交流通信功能,只实现了简单的前端框架,下面献上代码供大家参考学习,若有不足,请多多指教。

wxml部分

  1. <!--头部消息中心-->
  2. <view class='title' style='height:{{navH}}px' catchtouchmove='true'>
  3. <view class='title-text'>消息中心</view>
  4. <!-- 私信、通知切换栏 -->
  5. <view class="selectTab" style='margin-top:{{navH}}px' catchtouchmove='true'>
  6. <view class="flex-row">
  7. <view class="message {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">
  8. 私信
  9. <!--气泡提示-->
  10. <view class='bubble'>
  11. <view class='num'>3</view>
  12. </view>
  13. </view>
  14. <view class="notify {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">
  15. 通知
  16. <!--气泡提示-->
  17. <view class='bubble2'>
  18. <view class='num'>21</view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class='onTabLine' style="margin-left:{{175+currentTab*273}}rpx" catchtouchmove="ture"></view>
  23. <view class='line'></view>
  24. </view>
  25. </view>
  26. <!--私信消息列表-->
  27. <scroll-view scroll-y="true" class="message-list" style="margin-top:{{navH+47}}px;height:1200rpx" wx:if="{{currentTab==0}}" >
  28. <!--示例用户1-->
  29. <view class='user' bindtap='goTocontactPage'>
  30. <image class='header-icon' src='/images/icon1.jpeg'></image>
  31. <view class='user-content'>
  32. <view class='firstline'>
  33. <view class='apart'>
  34. <view class='username'>
  35. <text>测试1</text>
  36. </view>
  37. <view class='cooperation'>
  38. <image src='./images/6.png'></image>
  39. </view>
  40. </view>
  41. <view class='time'>
  42. <view class='time-num'>9:36</view>
  43. </view>
  44. </view>
  45. <view class='secondline'>
  46. <view class='dialog'>
  47. <text>你想要怎么拍呢?</text>
  48. </view>
  49. <view class='dialog-nums'>
  50. <view class='bubble3'>
  51. <view class='num'>2</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <!--分割线-->
  58. <view class='linecut'></view>
  59. <!--示例用户2-->
  60. <view class='user' bindtap='goTocontactPage'>
  61. <image class='header-icon' src='https://b267.photo.store.qq.com/psb?/V13v0ZyH3zvYu7/9Ne*obpt0tAkfi3fZZij7.1VF4qT363gGq021zfYWQ0!/b/dAsBAAAAAAAA&bo=bgFuAQAAAAAFByQ!&rf=viewer_4'></image>
  62. <view class='user-content'>
  63. <view class='firstline'>
  64. <view class='apart'>
  65. <view class='username'>
  66. <text>测试2</text>
  67. </view>
  68. <view class='cooperation'>
  69. <!-- <image src='./images/6.png'></image> -->
  70. </view>
  71. </view>
  72. <view class='time'>
  73. <view class='time-num'>8:16</view>
  74. </view>
  75. </view>
  76. <view class='secondline'>
  77. <view class='dialog'>
  78. <text>约拍时间是这周六下午的两点钟</text>
  79. </view>
  80. <view class='dialog-nums'>
  81. <view class='bubble3'>
  82. <view class='num'>1</view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <!--分割线-->
  89. <view class='linecut'></view>
  90. </scroll-view>
  91. <!--关注消息列表框-->
  92. <scroll-view scroll-y class="notify-list" style="margin-top:{{navH+47}}px;height:1800rpx;" wx:if="{{currentTab==1}}">
  93. <!--系统通知-->
  94. <view class='notify-type' bindtap='goToSystemPage'>
  95. <view class='notify-icon'>
  96. <image src='./images/tongzhi.png'></image>
  97. </view>
  98. <view class='notify-name'>
  99. 系统通知
  100. <view class='notify-num'>
  101. <view class='nums'>11</view>
  102. </view>
  103. </view>
  104. <view class='right'>
  105. <!-- <image src=''></image> -->
  106. </view>
  107. </view>
  108. <view class='liner'></view>
  109. <!--点赞-->
  110. <view class='thumbs-up-type' bindtap='goToDianzanPage'>
  111. <view class='notify-icon'>
  112. <image src='./images/dianzan.png'></image>
  113. </view>
  114. <view class='thumbs-up-name'>
  115. 点赞
  116. <view class='thumbs-up-num'>
  117. <view class='nums'>6</view>
  118. </view>
  119. </view>
  120. <view class='right'>
  121. <!-- <image src=''></image> -->
  122. </view>
  123. </view>
  124. <view class='liner'></view>
  125. <!--评论-->
  126. <view class='dialog-type' bindtap='goToCommentPage'>
  127. <view class='dialog-icon'>
  128. <image src='./images/dialog.png'></image>
  129. </view>
  130. <view class='dialog-name'>
  131. 评论
  132. <view class='dialog-num'>
  133. <view class='nums'>2</view>
  134. </view>
  135. </view>
  136. <view class='right'>
  137. <!-- <image src=''></image> -->
  138. </view>
  139. </view>
  140. <view class='liner'></view>
  141. <!--我关注的-->
  142. <view class='follow-type' bindtap='goToConcernPage'>
  143. <view class='follow-icon'>
  144. <image src='./images/guanzhu.png'></image>
  145. </view>
  146. <view class='follow-name'>
  147. 我关注的
  148. <view class='follow-num'>
  149. <view class='nums'>1</view>
  150. </view>
  151. </view>
  152. <view class='right'>
  153. <!-- <image src=''></image> -->
  154. </view>
  155. </view>
  156. <view class='liner'></view>
  157. <!--底部消息提示框-->
  158. <view class="unread">
  159. <text>您有21条未读通知</text>
  160. </view>
  161. </scroll-view>
  162. <!--底部导航-->
  163. <tabbar tabbar="{{tabbar}}"></tabbar>

wxss部分

  1. /*头部标题*/
  2. .title{
  3. width: 100%;
  4. /* overflow: hidden; */
  5. position: fixed;
  6. top: 0;
  7. left: 0;
  8. background: #fff;
  9. z-index: 999;
  10. }
  11. .title-text{
  12. width: 100%;
  13. height: 45px;
  14. line-height: 45px;
  15. text-align: center;
  16. position: absolute;
  17. bottom: 0;
  18. left: 0;
  19. font-size: 40rpx;
  20. font-weight: 500;
  21. }
  22. /*私信、通知*/
  23. .flex-row{
  24. flex-direction: row;
  25. display: flex;
  26. }
  27. .onTabLine{
  28. width: 120rpx;
  29. height: 5rpx;
  30. background-color:#4074DD;
  31. margin-top:15rpx;
  32. }
  33. .line{
  34. width: 750rpx;
  35. height: 2rpx;
  36. background-color: #F2F2F2;
  37. margin: 0rpx auto 0 auto;
  38. }
  39. .message,.notify{
  40. display: flex;
  41. flex-direction: row;
  42. font-size:36rpx;
  43. margin-top: 20rpx;
  44. width: 120rpx;
  45. color:#CDCDCD;
  46. }
  47. .message{
  48. margin-left: 200rpx;
  49. }
  50. .notify{
  51. margin-left: 150rpx;
  52. }
  53. .active{
  54. color:#4074DD;
  55. }
  56. .selectTab{
  57. position: fixed;
  58. background-color: #fff;
  59. z-index: 100;
  60. }
  61. /*气泡框样式*/
  62. .bubble{
  63. background-color: #4074DD;
  64. border-radius: 50rpx;
  65. width: 30rpx;
  66. height: 30rpx;
  67. position: relative;
  68. left: 10rpx;
  69. bottom: 10rpx;
  70. }
  71. .bubble .num{
  72. font-size: 24rpx;
  73. color:#ffffff;
  74. margin-left: 8rpx;
  75. margin-top: -2rpx;
  76. }
  77. .bubble2{
  78. background-color: #4074DD;
  79. border-radius: 20rpx;
  80. width: 40rpx;
  81. height: 30rpx;
  82. position: relative;
  83. left: 10rpx;
  84. bottom: 10rpx;
  85. }
  86. .bubble2 .num{
  87. font-size: 24rpx;
  88. color:#ffffff;
  89. margin-left: 8rpx;
  90. margin-top: -2rpx;
  91. }
  92. /*私信消息*/
  93. .message-list{
  94. /* background-color:#f2f2f2; */
  95. display: flex;
  96. flex-direction: column;
  97. }
  98. .user{
  99. display: flex;
  100. flex-direction: row;
  101. }
  102. .user-content{
  103. display: flex;
  104. flex-direction: column;
  105. }
  106. .header-icon{
  107. width: 104rpx;
  108. height: 104rpx;
  109. border-radius: 80rpx;
  110. margin-left: 20rpx;
  111. margin-top: 26rpx;
  112. }
  113. .firstline{
  114. display: flex;
  115. flex-direction: row;
  116. }
  117. .apart{
  118. margin-left: 20rpx;
  119. display: flex;
  120. flex-direction: row;
  121. width: 400rpx;
  122. }
  123. .username{
  124. font-size: 36rpx;
  125. margin-top: 26rpx;
  126. font-weight: 400;
  127. }
  128. .cooperation{
  129. width: 40rpx;
  130. }
  131. .cooperation image{
  132. width: 40rpx;
  133. height: 34rpx;
  134. margin-top: 34rpx;
  135. margin-left: 10rpx;
  136. }
  137. .time{
  138. display: flex;
  139. width: 60rpx;
  140. font-size: 24rpx;
  141. margin-top: 36rpx;
  142. color: #aeaeae;
  143. margin-left: 140rpx;
  144. }
  145. .time-num{
  146. /* margin-right: 200rpx; */
  147. }
  148. /*内容第二行*/
  149. .secondline{
  150. display: flex;
  151. flex-direction: row;
  152. }
  153. /*对话框消息内容*/
  154. .dialog{
  155. width: 545rpx;
  156. font-size: 28rpx;
  157. color: #aeaeae;
  158. margin-left: 20rpx;
  159. margin-top: 15rpx;
  160. }
  161. /*对话框提示数目*/
  162. .dialog-nums{
  163. /* width: 100rpx; */
  164. }
  165. /*气泡样式*/
  166. .bubble3{
  167. background-color: #4074DD;
  168. border-radius: 80rpx;
  169. width: 40rpx;
  170. height: 40rpx;
  171. /* margin-left: 200rpx; */
  172. margin-top: 20rpx;
  173. }
  174. .bubble3 .num{
  175. font-size: 28rpx;
  176. color: #ffffff;
  177. font-weight: 500;
  178. margin-left: 12rpx;
  179. }
  180. /*分割线*/
  181. .linecut{
  182. width: 100%;
  183. height: 2rpx;
  184. background-color: #F2F2F2;
  185. margin-top: 26rpx;
  186. }
  187. /*通知界面*/
  188. /*系统通知*/
  189. .notify-type{
  190. display: flex;
  191. flex-direction: row;
  192. }
  193. .notify-icon{
  194. margin-left: 20rpx;
  195. margin-top: 20rpx;
  196. }
  197. .notify-icon image{
  198. width: 80rpx;
  199. height: 80rpx;
  200. }
  201. .notify-name{
  202. font-size: 36rpx;
  203. font-weight: 500;
  204. margin-top: 35rpx;
  205. margin-left: 36rpx;
  206. }
  207. .notify-num{
  208. width: 40rpx;
  209. height: 30rpx;
  210. background-color: red;
  211. border-radius: 40rpx;
  212. display: flex;
  213. flex-direction: row;
  214. position: relative;
  215. bottom: 60rpx;
  216. left: 150rpx;
  217. }
  218. .notify-num .nums{
  219. font-size: 24rpx;
  220. color: #fff;
  221. margin-left: 8rpx;
  222. margin-bottom: 6rpx;
  223. }
  224. /*最帅的分割线*/
  225. .liner{
  226. width: 100%;
  227. height: 2rpx;
  228. background-color: #F2F2F2;
  229. margin-top: 20rpx;
  230. }
  231. /*点赞*/
  232. .thumbs-up-type{
  233. display: flex;
  234. flex-direction: row;
  235. }
  236. .thumbs-up-icon{
  237. margin-left: 20rpx;
  238. margin-top: 20rpx;
  239. }
  240. .thumbs-up-icon image{
  241. width: 80rpx;
  242. height: 80rpx;
  243. }
  244. .thumbs-up-name{
  245. font-size: 36rpx;
  246. font-weight: 500;
  247. margin-top: 35rpx;
  248. margin-left: 36rpx;
  249. }
  250. .thumbs-up-num{
  251. width: 30rpx;
  252. height: 30rpx;
  253. background-color: #4074DD;
  254. border-radius: 40rpx;
  255. display: flex;
  256. flex-direction: row;
  257. position: relative;
  258. bottom: 60rpx;
  259. left: 80rpx;
  260. }
  261. .thumbs-up-num .nums{
  262. font-size: 24rpx;
  263. color: #fff;
  264. margin-left: 8rpx;
  265. margin-bottom: 6rpx;
  266. }
  267. /*评论*/
  268. .dialog-type{
  269. display: flex;
  270. flex-direction: row;
  271. }
  272. .dialog-icon{
  273. margin-left: 30rpx;
  274. margin-top: 35rpx;
  275. }
  276. .dialog-icon image{
  277. width: 65rpx;
  278. height: 65rpx;
  279. }
  280. .dialog-name{
  281. font-size: 36rpx;
  282. font-weight: 500;
  283. margin-top: 35rpx;
  284. margin-left: 41rpx;
  285. }
  286. .dialog-num{
  287. width: 30rpx;
  288. height: 30rpx;
  289. background-color: #4074DD;
  290. border-radius: 40rpx;
  291. display: flex;
  292. flex-direction: row;
  293. position: relative;
  294. bottom: 60rpx;
  295. left: 80rpx;
  296. }
  297. .dialog-num .nums{
  298. font-size: 24rpx;
  299. color: #fff;
  300. margin-left: 8rpx;
  301. margin-bottom: 6rpx;
  302. }
  303. /*我关注的*/
  304. .follow-type{
  305. display: flex;
  306. flex-direction: row;
  307. }
  308. .follow-icon{
  309. margin-left: 20rpx;
  310. margin-top: 20rpx;
  311. }
  312. .follow-icon image{
  313. width: 80rpx;
  314. height: 80rpx;
  315. }
  316. .follow-name{
  317. font-size: 36rpx;
  318. font-weight: 500;
  319. margin-top: 35rpx;
  320. margin-left: 36rpx;
  321. }
  322. .follow-num{
  323. width: 30rpx;
  324. height: 30rpx;
  325. background-color: #4074DD;
  326. border-radius: 40rpx;
  327. display: flex;
  328. flex-direction: row;
  329. position: relative;
  330. bottom: 60rpx;
  331. left: 150rpx;
  332. }
  333. .follow-num .nums{
  334. font-size: 24rpx;
  335. color: #fff;
  336. margin-left: 8rpx;
  337. margin-bottom: 6rpx;
  338. }
  339. /*未读消息框*/
  340. .unread{
  341. margin-top: 16rpx;
  342. font-size: 26rpx;
  343. color: #aeaeae;
  344. text-align: center;
  345. }

其中部分bindtap有跳转函数,较为简单,此处就不一一列出,我们使用的是自定义头部标题,所以在使用前,须将app.js中的"navigationStyle"设置为"custom",

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/849422
推荐阅读
相关标签
  

闽ICP备14008679号