index.vue 5.4 KB

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