index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 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. let status = that.statusList.find(i => i.value == val.status)
  112. if (status) val.zhStatus = status.label;
  113. val.time = moment(val.meta.createdAt).format('YYYY-MM-DD HH:mm:ss')
  114. }
  115. that.$set(that, `list`, list);
  116. that.$set(that, `total`, res.total)
  117. }
  118. }
  119. },
  120. // 分页
  121. toPage(e) {
  122. const that = this;
  123. let list = that.list;
  124. let limit = that.limit;
  125. if (that.total > list.length) {
  126. uni.showLoading({
  127. title: '加载中',
  128. mask: true
  129. })
  130. let page = that.page + 1;
  131. that.$set(that, `page`, page)
  132. let skip = page * limit;
  133. that.$set(that, `skip`, skip)
  134. that.search();
  135. uni.hideLoading();
  136. } else uni.showToast({
  137. title: '没有更多数据了'
  138. });
  139. },
  140. // 清空列表
  141. clearPage() {
  142. const that = this;
  143. that.$set(that, `list`, [])
  144. that.$set(that, `skip`, 0)
  145. that.$set(that, `limit`, 6)
  146. that.$set(that, `page`, 0)
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. .main {
  153. display: flex;
  154. flex-direction: column;
  155. width: 100vw;
  156. height: 100vh;
  157. .one {
  158. border-bottom: 1px solid var(--f85Color);
  159. padding: 2vw;
  160. input {
  161. padding: 2vw;
  162. background-color: var(--f1Color);
  163. font-size: var(--font14Size);
  164. border-radius: 5px;
  165. }
  166. }
  167. .two {
  168. position: relative;
  169. flex-grow: 1;
  170. padding: 2vw 0 0 0;
  171. .list {
  172. display: flex;
  173. flex-direction: row;
  174. justify-content: space-between;
  175. align-items: center;
  176. width: 91vw;
  177. border: 1px solid var(--f1Color);
  178. margin: 2vw 2vw 0 2vw;
  179. padding: 0 2vw;
  180. border-radius: 5px;
  181. .image {
  182. display: flex;
  183. flex-wrap: wrap;
  184. justify-content: center;
  185. align-items: center;
  186. width: 27vw;
  187. height: 27vw;
  188. border-radius: 5px;
  189. margin: 0 2vw 0 0;
  190. .file {
  191. width: 9vw;
  192. height: 9vw;
  193. }
  194. }
  195. .list_1 {
  196. display: flex;
  197. flex-direction: column;
  198. flex-grow: 1;
  199. padding: 2vw 0;
  200. width: 35vw;
  201. .name {
  202. font-size: var(--font16Size);
  203. margin: 0 0 1vw 0;
  204. }
  205. .some {
  206. color: var(--f85Color);
  207. font-size: var(--font14Size);
  208. margin: 0 0 1vw 0;
  209. text:last-child {
  210. margin: 0 0 0 1vw;
  211. color: var(--f00Color);
  212. }
  213. }
  214. }
  215. .other {
  216. .btn {
  217. display: flex;
  218. flex-direction: column;
  219. align-items: center;
  220. margin: 0 2vw;
  221. padding: 2vw 3vw;
  222. background-color: var(--ff0Color);
  223. color: var(--fffColor);
  224. border-radius: 2vw;
  225. font-size: var(--font14Size);
  226. text {
  227. font-size: var(--font12Size);
  228. }
  229. }
  230. .button{
  231. margin: 0 2vw;
  232. padding: 2vw 3vw;
  233. background-color: var(--fcColor);
  234. color: var(--f00Color);
  235. border-radius: 2vw;
  236. font-size: var(--font14Size);
  237. }
  238. }
  239. }
  240. }
  241. }
  242. </style>