index.vue 5.7 KB

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