index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. <tabs :tabs="tabs" @tabsChange="tabsChange">
  9. <view class="tabsList">
  10. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  11. <view class="list-scroll-view">
  12. <view class="list" v-for="(item, index) in list" :key="index" @click="toShare(item)">
  13. <view class="image">
  14. <image class="file" v-for="(tag, indexs) in item.persons.slice(0,9)"
  15. :key="indexs" :src="tag.icon&&tag.icon.length>0?tag.icon[0].url:''" mode="">
  16. </image>
  17. </view>
  18. <view class="list_1">
  19. <view class="name">
  20. {{item.person_limit||0}}人即可开团成功
  21. </view>
  22. <view class="some">
  23. <text>团长</text>
  24. <text>{{item.leader.name||'暂无'}}</text>
  25. </view>
  26. <view class="some">
  27. <text>参团人数</text>
  28. <text>{{item.persons.length||0}}人</text>
  29. </view>
  30. <view class="some">
  31. <text>开团时间</text>
  32. <text>{{item.time||'暂无'}}</text>
  33. </view>
  34. </view>
  35. <view class="other">
  36. <view v-if="item.status=='0'" class="btn">
  37. <text>{{item.zhStatus||'暂无状态'}}</text>
  38. </view>
  39. <view v-else-if="item.status=='-1'" class="button">
  40. {{item.zhStatus||'暂无状态'}}
  41. </view>
  42. <view v-else-if="item.status=='2'" class="button">
  43. 已退团
  44. </view>
  45. <view v-else class="button">
  46. {{item.zhStatus||'暂无状态'}}
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </scroll-view>
  52. </view>
  53. </tabs>
  54. </view>
  55. </view>
  56. </mobile-frame>
  57. </template>
  58. <script>
  59. import moment from 'moment';
  60. import tabs from '@/components/tabs/index.vue';
  61. export default {
  62. components: {
  63. tabs
  64. },
  65. data() {
  66. return {
  67. user: {},
  68. searchInfo: {},
  69. list: [],
  70. total: 0,
  71. skip: 0,
  72. limit: 6,
  73. page: 0,
  74. statusList: [],
  75. tabs: {
  76. active: '0',
  77. menu: [{
  78. title: '开团中',
  79. active: '0'
  80. },
  81. {
  82. title: '已散团',
  83. active: '-1'
  84. },
  85. // {
  86. // title: '已退团',
  87. // active: '2'
  88. // },
  89. {
  90. title: '已结束',
  91. active: '1'
  92. }
  93. ]
  94. },
  95. status: '0',
  96. };
  97. },
  98. onShow: function() {
  99. const that = this;
  100. that.watchLogin();
  101. uni.startPullDownRefresh();
  102. },
  103. methods: {
  104. // 输入框
  105. toInput(e) {
  106. const that = this;
  107. if (e.detail.value) that.$set(that.searchInfo, `name`, e.detail.value);
  108. that.clearPage();
  109. that.search();
  110. },
  111. // 选择选项卡
  112. tabsChange(e) {
  113. const that = this;
  114. that.$set(that.tabs, `active`, e.active)
  115. that.$set(that, `status`, e.active);
  116. that.clearPage();
  117. that.search()
  118. },
  119. // 分享
  120. toShare(e) {
  121. const that = this;
  122. that.clearPage();
  123. uni.navigateTo({
  124. url: `/pagesHome/group/share?id=${e._id}`
  125. })
  126. },
  127. // 监听用户是否登录
  128. watchLogin() {
  129. const that = this;
  130. uni.getStorage({
  131. key: 'token',
  132. success: async function(res) {
  133. let user = that.$jwt(res.data);
  134. that.$set(that, `user`, user);
  135. let status = await that.$api(`/dictData`, 'GET', {
  136. code: "group_status"
  137. });
  138. if (status.errcode == '0') {
  139. that.$set(that, `statusList`, status.data)
  140. }
  141. that.search()
  142. },
  143. fail: function(err) {
  144. uni.reLaunch({
  145. url: `/pages/login/index`
  146. })
  147. }
  148. })
  149. },
  150. // 查询列表
  151. async search() {
  152. const that = this;
  153. let user = that.user;
  154. let status = that.status;
  155. if (user._id) {
  156. let info = {
  157. skip: that.skip,
  158. limit: that.limit,
  159. person: user._id,
  160. status: that.status,
  161. }
  162. let res = await that.$api(`/group`, 'GET', {
  163. ...info,
  164. ...that.searchInfo
  165. })
  166. if (res.errcode == '0') {
  167. let list = [...that.list, ...res.data];
  168. for (let val of list) {
  169. let personsstatus = val.persons.find(i => i.customer == user._id)
  170. if (personsstatus?.status == '1') {
  171. val.status = '2';
  172. }
  173. if (that.status != '-1') {
  174. val.persons = val.persons.filter(i => i.status == '0')
  175. }
  176. let status = that.statusList.find(i => i.value == val.status)
  177. if (status) val.zhStatus = status.label;
  178. val.time = moment(val.meta.createdAt).format('YYYY-MM-DD HH:mm:ss')
  179. }
  180. that.$set(that, `list`, list);
  181. that.$set(that, `total`, res.total)
  182. }
  183. }
  184. },
  185. // 分页
  186. toPage(e) {
  187. const that = this;
  188. let list = that.list;
  189. let limit = that.limit;
  190. if (that.total > list.length) {
  191. uni.showLoading({
  192. title: '加载中',
  193. mask: true
  194. })
  195. let page = that.page + 1;
  196. that.$set(that, `page`, page)
  197. let skip = page * limit;
  198. that.$set(that, `skip`, skip)
  199. that.search();
  200. uni.hideLoading();
  201. } else {}
  202. },
  203. // 清空列表
  204. clearPage() {
  205. const that = this;
  206. that.$set(that, `list`, [])
  207. that.$set(that, `skip`, 0)
  208. that.$set(that, `limit`, 6)
  209. that.$set(that, `page`, 0)
  210. }
  211. },
  212. onPullDownRefresh: async function() {
  213. const that = this;
  214. that.$set(that, `list`, [])
  215. that.$set(that, `skip`, 0)
  216. that.$set(that, `limit`, 6)
  217. that.$set(that, `page`, 0)
  218. await that.search();
  219. uni.stopPullDownRefresh();
  220. }
  221. }
  222. </script>
  223. <style lang="scss">
  224. .main {
  225. display: flex;
  226. flex-direction: column;
  227. width: 100vw;
  228. height: 100vh;
  229. .one {
  230. padding: 2vw;
  231. input {
  232. padding: 2vw;
  233. background-color: var(--f1Color);
  234. font-size: var(--font14Size);
  235. border-radius: 5px;
  236. }
  237. }
  238. .two {
  239. position: relative;
  240. flex-grow: 1;
  241. padding: 2vw 0 0 0;
  242. .tabsList {
  243. position: relative;
  244. width: 100vw;
  245. height: 82vh;
  246. .list {
  247. display: flex;
  248. flex-direction: row;
  249. justify-content: space-between;
  250. align-items: center;
  251. width: 91vw;
  252. border: 1px solid var(--f1Color);
  253. margin: 2vw 2vw 0 2vw;
  254. padding: 0 2vw;
  255. border-radius: 5px;
  256. .image {
  257. display: flex;
  258. flex-wrap: wrap;
  259. justify-content: center;
  260. align-items: center;
  261. width: 27vw;
  262. height: 27vw;
  263. border-radius: 5px;
  264. margin: 0 2vw 0 0;
  265. .file {
  266. width: 9vw;
  267. height: 9vw;
  268. }
  269. }
  270. .list_1 {
  271. display: flex;
  272. flex-direction: column;
  273. flex-grow: 1;
  274. padding: 2vw 0;
  275. width: 35vw;
  276. .name {
  277. font-size: var(--font16Size);
  278. margin: 0 0 1vw 0;
  279. }
  280. .some {
  281. color: var(--f85Color);
  282. font-size: var(--font14Size);
  283. margin: 0 0 1vw 0;
  284. text:last-child {
  285. margin: 0 0 0 1vw;
  286. color: var(--f00Color);
  287. }
  288. }
  289. }
  290. .other {
  291. .btn {
  292. display: flex;
  293. flex-direction: column;
  294. align-items: center;
  295. margin: 0 2vw;
  296. padding: 2vw 3vw;
  297. background-color: var(--ff0Color);
  298. color: var(--fffColor);
  299. border-radius: 2vw;
  300. font-size: var(--font14Size);
  301. text {
  302. font-size: var(--font12Size);
  303. }
  304. }
  305. .button {
  306. margin: 0 2vw;
  307. padding: 2vw 3vw;
  308. background-color: var(--fcColor);
  309. color: var(--f00Color);
  310. border-radius: 2vw;
  311. font-size: var(--font14Size);
  312. }
  313. }
  314. }
  315. }
  316. }
  317. }
  318. .scroll-view {
  319. position: absolute;
  320. top: 0;
  321. left: 0;
  322. right: 0;
  323. bottom: 0;
  324. .list-scroll-view {
  325. display: flex;
  326. flex-direction: column;
  327. }
  328. }
  329. </style>