index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. person: 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. icon:'none'
  155. });
  156. },
  157. // 清空列表
  158. clearPage() {
  159. const that = this;
  160. that.$set(that, `list`, [])
  161. that.$set(that, `skip`, 0)
  162. that.$set(that, `limit`, 6)
  163. that.$set(that, `page`, 0)
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="scss">
  169. .main {
  170. display: flex;
  171. flex-direction: column;
  172. width: 100vw;
  173. height: 100vh;
  174. .one {
  175. border-bottom: 1px solid var(--f85Color);
  176. padding: 2vw;
  177. input {
  178. padding: 2vw;
  179. background-color: var(--f1Color);
  180. font-size: var(--font14Size);
  181. border-radius: 5px;
  182. }
  183. }
  184. .two {
  185. position: relative;
  186. flex-grow: 1;
  187. padding: 2vw 0 0 0;
  188. .list {
  189. display: flex;
  190. flex-direction: row;
  191. justify-content: space-between;
  192. align-items: center;
  193. width: 91vw;
  194. border: 1px solid var(--f1Color);
  195. margin: 2vw 2vw 0 2vw;
  196. padding: 0 2vw;
  197. border-radius: 5px;
  198. .image {
  199. display: flex;
  200. flex-wrap: wrap;
  201. justify-content: center;
  202. align-items: center;
  203. width: 27vw;
  204. height: 27vw;
  205. border-radius: 5px;
  206. margin: 0 2vw 0 0;
  207. .file {
  208. width: 9vw;
  209. height: 9vw;
  210. }
  211. }
  212. .list_1 {
  213. display: flex;
  214. flex-direction: column;
  215. flex-grow: 1;
  216. padding: 2vw 0;
  217. width: 35vw;
  218. .name {
  219. font-size: var(--font16Size);
  220. margin: 0 0 1vw 0;
  221. }
  222. .some {
  223. color: var(--f85Color);
  224. font-size: var(--font14Size);
  225. margin: 0 0 1vw 0;
  226. text:last-child {
  227. margin: 0 0 0 1vw;
  228. color: var(--f00Color);
  229. }
  230. }
  231. }
  232. .other {
  233. .btn {
  234. display: flex;
  235. flex-direction: column;
  236. align-items: center;
  237. margin: 0 2vw;
  238. padding: 2vw 3vw;
  239. background-color: var(--ff0Color);
  240. color: var(--fffColor);
  241. border-radius: 2vw;
  242. font-size: var(--font14Size);
  243. text {
  244. font-size: var(--font12Size);
  245. }
  246. }
  247. .button {
  248. margin: 0 2vw;
  249. padding: 2vw 3vw;
  250. background-color: var(--fcColor);
  251. color: var(--f00Color);
  252. border-radius: 2vw;
  253. font-size: var(--font14Size);
  254. }
  255. }
  256. }
  257. }
  258. }
  259. </style>