index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <view class="message_view_page">
  4. <!-- 横幅 -->
  5. <view class="gonggao" @click="goFpzn">
  6. <view>防骗手册,为您保驾护航</view>
  7. <text class="iconfont icon-jinru"></text>
  8. </view>
  9. <!-- 聊天内容 -->
  10. <view class="message_view">
  11. <scroll-view class="message_view_scroll" :scroll-y="true" :scroll-top="scrollTop" :enhanced="true"
  12. :bounces="false" :show-scrollbar="false" @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
  13. <view class="message_user_aview" v-for="(item,index) in list" :key="index" @click="goMsgView(item)">
  14. <view class="message_user_a">
  15. <view class="message_user_info">
  16. <!-- 头像 -->
  17. <view class="user_head" style="position: relative;">
  18. <image v-if="item.userPic" style="width: 100%; height: 100%;" mode="aspectFill"
  19. :src="imageUrl + item.userPic"></image>
  20. <image v-else style="width: 100%; height: 100%;" mode="aspectFill" src="@/static/common/logo.png">
  21. </image>
  22. <u-badge type="error" :value="item.unread" :absolute="true" :offset="[0,0]"></u-badge>
  23. </view>
  24. <view class="user_info">
  25. <!-- 姓名 -->
  26. <view class="user_name">{{item.userName}}</view>
  27. <!-- 聊天信息最后一条 -->
  28. <view class="user_goods">{{item.message}}</view>
  29. <!-- 聊天信息最后一条的时间 -->
  30. <view class="user_time">{{item.createTime}}</view>
  31. </view>
  32. <!-- 商品图片 -->
  33. <view class="goods_img">
  34. <image style="width: 100%; height: 100%;" mode="aspectFill" :src="imageUrl + item.goodsImg"></image>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <Loading v-if="!list.length" :loadStatus="2" :dataList="list" />
  40. </scroll-view>
  41. </view>
  42. </view>
  43. <!-- #endif -->
  44. <!-- #ifndef H5 -->
  45. <web-view :src="webViewHref('/pages/message/index',crossPagePam)" @message="crossPage.$listener"></web-view>
  46. <!-- #endif -->
  47. </template>
  48. <script>
  49. import api from '@/common/http/'
  50. export default {
  51. // #ifdef H5
  52. data() {
  53. return {
  54. imageUrl: this.$imageUrl,
  55. scrollTop: 0,
  56. list: []
  57. }
  58. },
  59. onShow() {
  60. uni.$emit("updateUserInfo")
  61. var getList = () => {
  62. if (this.timeId) {
  63. clearTimeout(this.timeId)
  64. }
  65. api.postJson('/user/talk/list2', {
  66. userId: this.$store.state.user.userId,
  67. pageNum: 1,
  68. pageSize: -1
  69. }, false).then(res => {
  70. this.list = res.data.records
  71. this.timeId = setTimeout(getList, 2000)
  72. })
  73. }
  74. getList()
  75. },
  76. onHide() {
  77. if (this.timeId) {
  78. clearTimeout(this.timeId)
  79. }
  80. },
  81. methods: {
  82. upper() {
  83. console.log("顶")
  84. },
  85. lower() {
  86. console.log("底")
  87. },
  88. scroll(e) {
  89. this.scrollTop = e.detail.scrollTop
  90. },
  91. goMsgView(item) {
  92. this.$navToPage({
  93. url: '/pages/message/msgView?goodsId=' + (item.goodsId || '') + "&groupId=" + (item.groupId || '')
  94. })
  95. },
  96. goFpzn(item) {
  97. this.$navToPage({
  98. url: '/pages/mine/parse?type=1'
  99. })
  100. },
  101. },
  102. // #endif
  103. // #ifndef H5
  104. // #endif
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. page {
  109. height: 100%;
  110. overflow: hidden;
  111. }
  112. .message_view_page {
  113. overflow: hidden;
  114. width: 100%;
  115. /* #ifdef H5 */
  116. height: 100%;
  117. /* #endif */
  118. /* #ifndef H5 */
  119. height: 100vh;
  120. /* #endif */
  121. display: flex;
  122. flex-direction: column;
  123. .message_user_aview {
  124. width: 100%;
  125. height: auto;
  126. box-sizing: border-box;
  127. padding: 0 20rpx;
  128. background: #fff;
  129. .message_user_a {
  130. width: 100%;
  131. height: auto;
  132. box-sizing: border-box;
  133. padding: 20rpx 0;
  134. }
  135. &:not(:last-child) {
  136. .message_user_a {
  137. border-bottom: 1rpx solid #ddd;
  138. }
  139. }
  140. .message_user_info {
  141. width: 100%;
  142. display: flex;
  143. justify-content: space-between;
  144. align-items: flex-start;
  145. .user_head {
  146. width: 80rpx;
  147. height: 80rpx;
  148. }
  149. .user_info {
  150. width: 500rpx;
  151. min-height: 100rpx;
  152. box-sizing: border-box;
  153. padding: 0 16rpx;
  154. .user_name {
  155. width: 100%;
  156. font-size: 28rpx;
  157. font-weight: bold;
  158. overflow: hidden;
  159. /*超出部分隐藏*/
  160. white-space: nowrap;
  161. /*禁止换行*/
  162. text-overflow: ellipsis;
  163. /*省略号*/
  164. }
  165. .user_goods {
  166. width: 100%;
  167. font-size: 24rpx;
  168. overflow: hidden;
  169. /*超出部分隐藏*/
  170. white-space: nowrap;
  171. /*禁止换行*/
  172. text-overflow: ellipsis;
  173. /*省略号*/
  174. margin: 10rpx 0;
  175. }
  176. .user_time {
  177. width: 100%;
  178. font-size: 20rpx;
  179. color: #aaa;
  180. overflow: hidden;
  181. /*超出部分隐藏*/
  182. white-space: nowrap;
  183. /*禁止换行*/
  184. text-overflow: ellipsis;
  185. /*省略号*/
  186. }
  187. }
  188. .goods_img {
  189. width: 100rpx;
  190. height: 100rpx;
  191. }
  192. }
  193. }
  194. .goods_info {
  195. width: 100%;
  196. height: auto;
  197. padding: 20rpx;
  198. box-sizing: border-box;
  199. background: #fff;
  200. display: flex;
  201. .goods_img {
  202. width: 100rpx;
  203. height: 100rpx;
  204. }
  205. .goods_text {
  206. flex: 1;
  207. min-height: 100rpx;
  208. height: auto;
  209. box-sizing: border-box;
  210. padding-left: 16rpx;
  211. .goods_name {
  212. width: 100%;
  213. margin-bottom: 10rpx;
  214. font-size: 28rpx;
  215. font-weight: bold;
  216. overflow: hidden;
  217. /*超出部分隐藏*/
  218. white-space: nowrap;
  219. /*禁止换行*/
  220. text-overflow: ellipsis;
  221. /*省略号*/
  222. }
  223. .goods_jiag {
  224. font-size: 26rpx;
  225. color: red;
  226. }
  227. .goods_fuwu {
  228. font-size: 24rpx;
  229. color: #aaa;
  230. }
  231. .goods_pon {
  232. width: 100%;
  233. display: flex;
  234. justify-content: space-between;
  235. align-items: center;
  236. .go_goods_btn {
  237. width: auto;
  238. height: auto;
  239. box-sizing: border-box;
  240. padding: 14rpx 28rpx;
  241. border-radius: 10rpx;
  242. font-size: 24rpx;
  243. font-weight: bold;
  244. color: #fff;
  245. background: rgb(250, 42, 42);
  246. }
  247. }
  248. }
  249. }
  250. .message_view {
  251. width: 100%;
  252. flex: 1;
  253. position: relative;
  254. .message_view_scroll {
  255. position: absolute;
  256. top: 0;
  257. bottom: 0;
  258. left: 0;
  259. right: 0;
  260. }
  261. }
  262. .gonggao {
  263. width: 100%;
  264. height: 80rpx;
  265. background: #fff2d4;
  266. box-sizing: border-box;
  267. padding: 0 20rpx;
  268. display: flex;
  269. align-items: center;
  270. justify-content: space-between;
  271. font-size: 24rpx;
  272. color: rgb(230, 138, 19);
  273. view {
  274. color: rgb(230, 138, 19);
  275. }
  276. }
  277. }
  278. </style>