list.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <view class="app" :style="'width: '+boxWidth+'px;min-height: '+boxHeight+'px'">
  3. <view :class="['header-box',fixedTop?'header-fixed':'']">
  4. <navbar title="我加入的群" :showLeft="true" :place="true">
  5. </navbar>
  6. <view class="search-box">
  7. <uv-search placeholder="搜索群聊名称" v-model="params.keyword" action-text="搜索" bgColor="#fff"
  8. :actionStyle="{color: '#fff',background: '#15B3B2',padding:'.25rem .75rem',borderRadius: '10rem',marginRight: '.25rem'}"
  9. @search="search" @custom="search" @clear="search()" height="36" :animation="false"
  10. :customStyle="{fontSize:'24rpx'}">
  11. </uv-search>
  12. </view>
  13. </view>
  14. <view class="main" v-if="loaded">
  15. <view class="loading" v-if="loading && (!dataList || dataList.length<=0)">
  16. </view>
  17. <uv-empty class="empty" v-else-if="!dataList || dataList.length<=0" mode="data" text="暂无群聊" icon-size="0"
  18. width="90" height="90" textColor="var(--empty-color)"></uv-empty>
  19. <view class="list-box" v-else>
  20. <view class="list-item" v-for="(v,k) in dataList" :key="k">
  21. <view class="info-box">
  22. <view class="info-row">
  23. <view class="avatar">
  24. <uv-avatar class="image" :src="v.headimg" shape="square" size="3.25rem" />
  25. </view>
  26. <view class="info">
  27. <view class="text-box title-box">
  28. <view class="title">
  29. {{v.title}}
  30. </view>
  31. <view class="publish">
  32. 发布者 {{v.nick_name || '微信用户'}}
  33. </view>
  34. </view>
  35. <view class="text-box desc">
  36. {{v.content}}
  37. </view>
  38. </view>
  39. </view>
  40. <view class="action-box">
  41. <view class="count-box">
  42. <text class="area">{{getArea(v.area)}}</text>
  43. <text class="num">{{v.group_user||0}}人</text>
  44. </view>
  45. <view class="btn-box">
  46. <view class="btn entry" @click="gotoPage('/pages/group/chat?id='+v.id)">
  47. 进入群聊
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="loaded" v-if="params.loaded">
  54. 没有更多了
  55. </view>
  56. </view>
  57. </view>
  58. <showModal ref="uvModal"></showModal>
  59. <uv-loading-icon class="loading" :show="loading" textSize="30rpx" color="var(--color)"
  60. :customStyle="{position:'absolute',top:'50%',left:0,right:0}"></uv-loading-icon>
  61. </view>
  62. </template>
  63. <script>
  64. import navbar from "../../components/navbar.vue"
  65. import showModal from "../../components/showModal.vue"
  66. export default {
  67. components: {
  68. navbar,
  69. showModal
  70. },
  71. data() {
  72. return {
  73. loading: false,
  74. loaded: false,
  75. submitLoading: false,
  76. boxHeight: 800,
  77. boxWidth: 360,
  78. fixedTop: false,
  79. leftIconStyle: {
  80. width: '1.5rem',
  81. height: '1.5rem'
  82. },
  83. userInfo: {
  84. id: 0,
  85. },
  86. params: {
  87. uid: 0,
  88. cate_id: [],
  89. info_type: 3,
  90. keyword: "",
  91. page: 1,
  92. pageSize: 10,
  93. loaded: false,
  94. },
  95. dataList: [],
  96. }
  97. },
  98. onLoad(e) {
  99. const windowInfo = uni.getWindowInfo();
  100. this.boxHeight = windowInfo.windowHeight
  101. this.boxWidth = windowInfo.windowWidth
  102. this.getInfo();
  103. },
  104. onHide() {
  105. this.$refs.uvModal.close();
  106. },
  107. onPullDownRefresh() {
  108. uni.stopPullDownRefresh()
  109. this.params.page = 1;
  110. this.params.loade = false;
  111. this.getInfo()
  112. },
  113. onPageScroll(e) {
  114. if (e.scrollTop > 30) {
  115. this.fixedTop = true;
  116. } else if (e.scrollTop <= 0) {
  117. this.fixedTop = false;
  118. }
  119. },
  120. onReachBottom() {
  121. if (!this.params.loaded && this.userInfo.id) {
  122. this.params.page++;
  123. this.getList()
  124. }
  125. uni.stopPullDownRefresh()
  126. },
  127. methods: {
  128. getArea(text) {
  129. let data = text ? text.split('/') : [];
  130. return typeof(data[1]) != 'undefined' ? data[1] : (typeof(data[0]) != 'undefined' ? data[0] : '');
  131. },
  132. // 用户信息
  133. async getInfo() {
  134. this.loading = true;
  135. this.userInfo = await this.$request.apiGetUserInfo(this, true);
  136. this.loading = false;
  137. this.loaded = true;
  138. if (!this.userInfo || this.userInfo.id <= 0) {
  139. this.$refs.uvModal.open({
  140. title: '提示',
  141. content: '您暂未登录,请先登录~',
  142. confirmText: '立即登录',
  143. confirmColor: "#15B3B2",
  144. confirm: function(e) {
  145. uni.navigateTo({
  146. url: '/pages/login/login'
  147. })
  148. }
  149. });
  150. return false;
  151. }
  152. this.params.uid = this.userInfo.id;
  153. this.getList();
  154. },
  155. // 搜索
  156. search() {
  157. this.params.page = 1;
  158. this.params.loaded = false;
  159. this.getList();
  160. },
  161. // 列表
  162. async getList() {
  163. let _this = this
  164. this.loading = true;
  165. const res = await this.$request.api('/index/infoList', this.params)
  166. this.loading = false;
  167. this.loaded = true;
  168. if (res.code == 200) {
  169. if (this.params.page == 1) {
  170. this.dataList = res.data
  171. } else if (res.data.length > 0) {
  172. this.dataList = this.dataList.concat(res.data);
  173. } else {
  174. this.params.loaded = true
  175. }
  176. if (res.data.length < this.params.pageSize) {
  177. this.params.loaded = true
  178. }
  179. } else if (res.code == 510) {
  180. this.dataList = [];
  181. this.$refs.uvModal.open({
  182. title: '提示',
  183. content: '您暂未登录,请先登录~',
  184. confirmText: '立即登录',
  185. confirmColor: "#15B3B2",
  186. confirm: function(e) {
  187. uni.navigateTo({
  188. url: '/pages/login/login'
  189. })
  190. }
  191. });
  192. } else {
  193. let msg = typeof(res.msg) != 'undefined' ? res.msg : ''
  194. if (msg) {
  195. uni.showToast({
  196. title: msg,
  197. icon: 'none'
  198. })
  199. }
  200. }
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="scss" scoped>
  206. page {
  207. height: 100%;
  208. width: 100%;
  209. // background: #F4F5F5;
  210. }
  211. .app {
  212. height: 100%;
  213. }
  214. .header-box {
  215. width: 100%;
  216. position: fixed;
  217. padding-bottom: .5rem;
  218. z-index: 99;
  219. left: 0;
  220. top: 0;
  221. &.header-fixed {
  222. position: fixed;
  223. background: linear-gradient(to bottom, #15B3B2, #9de8db);
  224. }
  225. .search-box {
  226. background-color: #fff;
  227. border-radius: 10rem;
  228. margin: 3.5rem .5rem 0;
  229. }
  230. }
  231. .main {
  232. margin: 10.5rem .75rem 0;
  233. /* #ifdef H5 */
  234. margin-top: 8rem;
  235. /* #endif */
  236. ::v-deep .uv-empty {
  237. padding-top: 2rem;
  238. }
  239. .list-box {
  240. padding-bottom: 1.5rem;
  241. .list-item {
  242. background-color: #fff;
  243. margin-bottom: 1.125rem;
  244. border-radius: 1rem;
  245. .info-box {
  246. padding: .75rem;
  247. .info-row {
  248. display: flex;
  249. flex-direction: row;
  250. padding-bottom: 1rem;
  251. .avatar {
  252. width: 3.25rem;
  253. height: 3.25rem;
  254. .image {
  255. width: 100%;
  256. }
  257. }
  258. .info {
  259. flex: 1;
  260. margin-left: .75rem;
  261. .text-box {
  262. font-size: .75rem;
  263. color: var(--text-color);
  264. &.title-box {
  265. display: flex;
  266. flex-direction: row;
  267. align-items: center;
  268. margin-bottom: .25rem;
  269. .title {
  270. flex: 1;
  271. color: var(--title-color);
  272. margin-right: .5rem;
  273. font-weight: 500;
  274. font-size: 1rem;
  275. }
  276. .publish {
  277. font-size: .625rem;
  278. border: .0125rem solid var(--text-color);
  279. padding: 0rem .15rem;
  280. border-radius: .1rem;
  281. }
  282. }
  283. &.desc {
  284. overflow: hidden;
  285. display: -webkit-box;
  286. -webkit-line-clamp: 2;
  287. -webkit-box-orient: vertical;
  288. }
  289. }
  290. }
  291. }
  292. .action-box {
  293. display: flex;
  294. flex-direction: row;
  295. align-items: center;
  296. justify-content: flex-end;
  297. .count-box {
  298. flex: 1;
  299. display: flex;
  300. flex-direction: row;
  301. align-items: center;
  302. font-size: .675rem;
  303. .area {
  304. border: .025rem solid var(--color);
  305. border-top-left-radius: 10rem;
  306. border-bottom-left-radius: 10rem;
  307. color: #fff;
  308. background-color: var(--color);
  309. padding: 0rem .425rem;
  310. min-width: 1.5rem;
  311. }
  312. .num {
  313. min-width: 1.5rem;
  314. color: var(--color);
  315. padding: 0rem .425rem;
  316. border: .025rem solid var(--color);
  317. border-top-right-radius: 10rem;
  318. border-bottom-right-radius: 10rem;
  319. text-align: center;
  320. }
  321. }
  322. .btn-box {
  323. display: flex;
  324. flex-direction: row;
  325. align-items: center;
  326. .btn {
  327. padding: .15rem .75rem;
  328. color: var(--color);
  329. font-size: .75rem;
  330. font-weight: 500;
  331. /* #ifdef APP */
  332. padding: .375rem .75rem;
  333. /* #endif */
  334. }
  335. .money {
  336. min-width: 2rem;
  337. // background: url("@/static/images/icon-money-bg.png") no-repeat 100%;
  338. background-size: cover;
  339. border-radius: 0;
  340. border-bottom-left-radius: 1rem;
  341. border-top-left-radius: 1rem;
  342. border-top-right-radius: .5rem;
  343. display: flex;
  344. flex-direction: row;
  345. align-items: center;
  346. .icon {
  347. width: 2rem;
  348. }
  349. .text {
  350. flex: 1;
  351. color: #fff;
  352. font-size: 1rem;
  353. }
  354. }
  355. .entry {
  356. height: 1.375rem;
  357. line-height: 1.375rem;
  358. width: 3.4rem;
  359. text-align: center;
  360. // background: url("@/static/images/icon-entry-bg.png") no-repeat 100%;
  361. background-size: 100% 100%;
  362. margin-left: -.3rem;
  363. color: #fff;
  364. }
  365. }
  366. }
  367. }
  368. }
  369. .loaded {
  370. padding: .5rem 0;
  371. text-align: center;
  372. font-size: .75rem;
  373. color: #999;
  374. }
  375. }
  376. }
  377. </style>