index.vue 6.1 KB

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