index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" v-model="searchInfo.name" @blur="toInput" placeholder="搜索商品名称">
  6. </view>
  7. <view class="two">
  8. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  9. <view class="list-scroll-view">
  10. <view class="list" v-for="(item, index) in list" :key="index">
  11. <view class="image">
  12. <image class="file" v-for="(tag, indexs) in item.persons.slice(0,7)" :key="indexs"
  13. :src="tag.icon&&tag.icon.length>0?tag.icon[0].url:''" mode="">
  14. </view>
  15. </image>
  16. <view class="list_1">
  17. <view class="name">
  18. {{item.person_limit||0}}人即可开团成功
  19. </view>
  20. <view class="some">
  21. <text>团长</text>
  22. <text>{{item.leader.name||'暂无'}}</text>
  23. </view>
  24. <view class="some">
  25. <text>参团人数</text>
  26. <text>{{item.persons.length||0}}人</text>
  27. </view>
  28. </view>
  29. <view class="other">
  30. <view class="btn" @click="onSubmit(item)">
  31. <text>{{item.zhStatus||'暂无状态'}}</text>立即参团
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </scroll-view>
  37. </view>
  38. </view>
  39. </mobile-frame>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. user: {},
  46. searchInfo: {},
  47. list: [],
  48. total: 0,
  49. skip: 0,
  50. limit: 6,
  51. page: 0,
  52. statusList: [],
  53. };
  54. },
  55. onShow: function() {
  56. const that = this;
  57. that.watchLogin()
  58. },
  59. methods: {
  60. // 监听用户是否登录
  61. watchLogin() {
  62. const that = this;
  63. uni.getStorage({
  64. key: 'token',
  65. success: async function(res) {
  66. let user = that.$jwt(res.data);
  67. that.$set(that, `user`, user);
  68. let status = await that.$api(`/dictData`, 'GET', {
  69. code: "group_status"
  70. });
  71. if (status.errcode == '0') {
  72. that.$set(that, `statusList`, status.data)
  73. }
  74. that.search()
  75. },
  76. fail: function(err) {
  77. uni.reLaunch({
  78. url: `/pages/login/index`
  79. })
  80. }
  81. })
  82. },
  83. // 查询列表
  84. async search() {
  85. const that = this;
  86. let user = that.user;
  87. if (user._id) {
  88. let info = {
  89. skip: that.skip,
  90. limit: that.limit,
  91. persons: user._id
  92. }
  93. let res = await that.$api(`/group`, 'GET', {
  94. ...info,
  95. ...that.searchInfo
  96. })
  97. if (res.errcode == '0') {
  98. let list = [...that.list, ...res.data];
  99. for (let val of list) {
  100. let status = that.statusList.find(i => i.value == val.status)
  101. if (status) val.zhStatus = status.label;
  102. }
  103. that.$set(that, `list`, list);
  104. that.$set(that, `total`, res.total)
  105. }
  106. }
  107. },
  108. // 分页
  109. toPage(e) {
  110. const that = this;
  111. let list = that.list;
  112. let limit = that.limit;
  113. if (that.total > list.length) {
  114. uni.showLoading({
  115. title: '加载中',
  116. mask: true
  117. })
  118. let page = that.page + 1;
  119. that.$set(that, `page`, page)
  120. let skip = page * limit;
  121. that.$set(that, `skip`, skip)
  122. that.search();
  123. uni.hideLoading();
  124. } else uni.showToast({
  125. title: '没有更多数据了'
  126. });
  127. },
  128. // 清空列表
  129. clearPage() {
  130. const that = this;
  131. that.$set(that, `list`, [])
  132. that.$set(that, `skip`, 0)
  133. that.$set(that, `limit`, 6)
  134. that.$set(that, `page`, 0)
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss">
  140. .main {
  141. display: flex;
  142. flex-direction: column;
  143. width: 100vw;
  144. height: 100vh;
  145. .one {
  146. border-bottom: 1px solid var(--f85Color);
  147. padding: 2vw;
  148. input {
  149. padding: 2vw;
  150. background-color: var(--f1Color);
  151. font-size: var(--font14Size);
  152. border-radius: 5px;
  153. }
  154. }
  155. .two {
  156. position: relative;
  157. flex-grow: 1;
  158. padding: 2vw 0 0 0;
  159. .list {
  160. display: flex;
  161. flex-direction: row;
  162. justify-content: space-between;
  163. align-items: center;
  164. width: 91vw;
  165. border: 1px solid var(--f1Color);
  166. margin: 2vw 2vw 0 2vw;
  167. padding: 0 2vw;
  168. border-radius: 5px;
  169. .image {
  170. display: flex;
  171. flex-wrap: wrap;
  172. justify-content: center;
  173. align-items: center;
  174. width: 27vw;
  175. height: 27vw;
  176. border-radius: 5px;
  177. margin: 0 2vw 0 0;
  178. .file {
  179. width: 9vw;
  180. height: 9vw;
  181. }
  182. }
  183. .list_1 {
  184. display: flex;
  185. flex-direction: column;
  186. flex-grow: 1;
  187. padding: 2vw 0;
  188. .name {
  189. font-size: var(--font16Size);
  190. margin: 0 0 1vw 0;
  191. }
  192. .some {
  193. color: var(--f85Color);
  194. font-size: var(--font14Size);
  195. margin: 0 0 1vw 0;
  196. text:last-child {
  197. margin: 0 0 0 1vw;
  198. color: var(--f00Color);
  199. }
  200. }
  201. }
  202. .other {
  203. .btn {
  204. display: flex;
  205. flex-direction: column;
  206. align-items: center;
  207. margin: 0 2vw;
  208. padding: 2vw 3vw;
  209. background-color: var(--ff0Color);
  210. color: var(--fffColor);
  211. border-radius: 2vw;
  212. font-size: var(--font14Size);
  213. text {
  214. font-size: var(--font12Size);
  215. }
  216. }
  217. }
  218. }
  219. }
  220. }
  221. </style>