index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. onShow() {
  52. uni.$emit("updateUserInfo")
  53. // #ifdef H5
  54. var getList = () => {
  55. if (this.timeId) {
  56. clearTimeout(this.timeId)
  57. }
  58. api.postJson('/user/talk/list2', {
  59. userId: this.$store.state.user.userId,
  60. pageNum: 1,
  61. pageSize: -1
  62. }, false).then(res => {
  63. this.list = res.data.records
  64. this.timeId = setTimeout(getList, 2000)
  65. })
  66. }
  67. getList()
  68. // #endif
  69. },
  70. // #ifdef H5
  71. data() {
  72. return {
  73. imageUrl: this.$imageUrl,
  74. scrollTop: 0,
  75. list: []
  76. }
  77. },
  78. onHide() {
  79. if (this.timeId) {
  80. clearTimeout(this.timeId)
  81. }
  82. },
  83. methods: {
  84. upper() {
  85. console.log("顶")
  86. },
  87. lower() {
  88. console.log("底")
  89. },
  90. scroll(e) {
  91. this.scrollTop = e.detail.scrollTop
  92. },
  93. goMsgView(item) {
  94. this.$navToPage({
  95. url: '/pages/message/msgView?goodsId=' + (item.goodsId || '') + "&groupId=" + (item.groupId || '')
  96. })
  97. },
  98. goFpzn(item) {
  99. this.$navToPage({
  100. url: '/pages/mine/parse?type=1'
  101. })
  102. },
  103. },
  104. // #endif
  105. // #ifndef H5
  106. // #endif
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. page {
  111. height: 100%;
  112. overflow: hidden;
  113. }
  114. .message_view_page {
  115. overflow: hidden;
  116. width: 100%;
  117. /* #ifdef H5 */
  118. height: 100%;
  119. /* #endif */
  120. /* #ifndef H5 */
  121. height: 100vh;
  122. /* #endif */
  123. display: flex;
  124. flex-direction: column;
  125. .message_user_aview {
  126. width: 100%;
  127. height: auto;
  128. box-sizing: border-box;
  129. padding: 0 20rpx;
  130. background: #fff;
  131. .message_user_a {
  132. width: 100%;
  133. height: auto;
  134. box-sizing: border-box;
  135. padding: 20rpx 0;
  136. }
  137. &:not(:last-child) {
  138. .message_user_a {
  139. border-bottom: 1rpx solid #ddd;
  140. }
  141. }
  142. .message_user_info {
  143. width: 100%;
  144. display: flex;
  145. justify-content: space-between;
  146. align-items: flex-start;
  147. .user_head {
  148. width: 80rpx;
  149. height: 80rpx;
  150. }
  151. .user_info {
  152. width: 500rpx;
  153. min-height: 100rpx;
  154. box-sizing: border-box;
  155. padding: 0 16rpx;
  156. .user_name {
  157. width: 100%;
  158. font-size: 28rpx;
  159. font-weight: bold;
  160. overflow: hidden;
  161. /*超出部分隐藏*/
  162. white-space: nowrap;
  163. /*禁止换行*/
  164. text-overflow: ellipsis;
  165. /*省略号*/
  166. }
  167. .user_goods {
  168. width: 100%;
  169. font-size: 24rpx;
  170. overflow: hidden;
  171. /*超出部分隐藏*/
  172. white-space: nowrap;
  173. /*禁止换行*/
  174. text-overflow: ellipsis;
  175. /*省略号*/
  176. margin: 10rpx 0;
  177. }
  178. .user_time {
  179. width: 100%;
  180. font-size: 20rpx;
  181. color: #aaa;
  182. overflow: hidden;
  183. /*超出部分隐藏*/
  184. white-space: nowrap;
  185. /*禁止换行*/
  186. text-overflow: ellipsis;
  187. /*省略号*/
  188. }
  189. }
  190. .goods_img {
  191. width: 100rpx;
  192. height: 100rpx;
  193. }
  194. }
  195. }
  196. .goods_info {
  197. width: 100%;
  198. height: auto;
  199. padding: 20rpx;
  200. box-sizing: border-box;
  201. background: #fff;
  202. display: flex;
  203. .goods_img {
  204. width: 100rpx;
  205. height: 100rpx;
  206. }
  207. .goods_text {
  208. flex: 1;
  209. min-height: 100rpx;
  210. height: auto;
  211. box-sizing: border-box;
  212. padding-left: 16rpx;
  213. .goods_name {
  214. width: 100%;
  215. margin-bottom: 10rpx;
  216. font-size: 28rpx;
  217. font-weight: bold;
  218. overflow: hidden;
  219. /*超出部分隐藏*/
  220. white-space: nowrap;
  221. /*禁止换行*/
  222. text-overflow: ellipsis;
  223. /*省略号*/
  224. }
  225. .goods_jiag {
  226. font-size: 26rpx;
  227. color: red;
  228. }
  229. .goods_fuwu {
  230. font-size: 24rpx;
  231. color: #aaa;
  232. }
  233. .goods_pon {
  234. width: 100%;
  235. display: flex;
  236. justify-content: space-between;
  237. align-items: center;
  238. .go_goods_btn {
  239. width: auto;
  240. height: auto;
  241. box-sizing: border-box;
  242. padding: 14rpx 28rpx;
  243. border-radius: 10rpx;
  244. font-size: 24rpx;
  245. font-weight: bold;
  246. color: #fff;
  247. background: rgb(250, 42, 42);
  248. }
  249. }
  250. }
  251. }
  252. .message_view {
  253. width: 100%;
  254. flex: 1;
  255. position: relative;
  256. .message_view_scroll {
  257. position: absolute;
  258. top: 0;
  259. bottom: 0;
  260. left: 0;
  261. right: 0;
  262. }
  263. }
  264. .gonggao {
  265. width: 100%;
  266. height: 80rpx;
  267. background: #fff2d4;
  268. box-sizing: border-box;
  269. padding: 0 20rpx;
  270. display: flex;
  271. align-items: center;
  272. justify-content: space-between;
  273. font-size: 24rpx;
  274. color: rgb(230, 138, 19);
  275. view {
  276. color: rgb(230, 138, 19);
  277. }
  278. }
  279. }
  280. </style>