index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. },
  102. methods: {
  103. // 选择选项卡
  104. tabsChange(e) {
  105. const that = this;
  106. that.$set(that.tabs, `active`, e.active)
  107. that.$set(that, `status`, e.active);
  108. that.clearPage();
  109. that.search()
  110. },
  111. // 分享
  112. toShare(e) {
  113. const that = this;
  114. that.clearPage();
  115. uni.navigateTo({
  116. url: `/pagesHome/group/share?id=${e._id}`
  117. })
  118. },
  119. // 监听用户是否登录
  120. watchLogin() {
  121. const that = this;
  122. uni.getStorage({
  123. key: 'token',
  124. success: async function(res) {
  125. let user = that.$jwt(res.data);
  126. that.$set(that, `user`, user);
  127. let status = await that.$api(`/dictData`, 'GET', {
  128. code: "group_status"
  129. });
  130. if (status.errcode == '0') {
  131. that.$set(that, `statusList`, status.data)
  132. }
  133. that.search()
  134. },
  135. fail: function(err) {
  136. uni.reLaunch({
  137. url: `/pages/login/index`
  138. })
  139. }
  140. })
  141. },
  142. // 查询列表
  143. async search() {
  144. const that = this;
  145. let user = that.user;
  146. let status = that.status;
  147. if (user._id) {
  148. let info = {
  149. skip: that.skip,
  150. limit: that.limit,
  151. person: user._id,
  152. status: that.status,
  153. }
  154. let res = await that.$api(`/group`, 'GET', {
  155. ...info,
  156. ...that.searchInfo
  157. })
  158. if (res.errcode == '0') {
  159. let list = [...that.list, ...res.data];
  160. for (let val of list) {
  161. let personsstatus = val.persons.find(i => i.customer == user._id)
  162. if (personsstatus?.status == '1') {
  163. val.status = '2';
  164. }
  165. if (that.status != '-1') {
  166. val.persons = val.persons.filter(i => i.status == '0')
  167. }
  168. let status = that.statusList.find(i => i.value == val.status)
  169. if (status) val.zhStatus = status.label;
  170. val.time = moment(val.meta.createdAt).format('YYYY-MM-DD HH:mm:ss')
  171. }
  172. that.$set(that, `list`, list);
  173. that.$set(that, `total`, res.total)
  174. }
  175. }
  176. },
  177. // 分页
  178. toPage(e) {
  179. const that = this;
  180. let list = that.list;
  181. let limit = that.limit;
  182. if (that.total > list.length) {
  183. uni.showLoading({
  184. title: '加载中',
  185. mask: true
  186. })
  187. let page = that.page + 1;
  188. that.$set(that, `page`, page)
  189. let skip = page * limit;
  190. that.$set(that, `skip`, skip)
  191. that.search();
  192. uni.hideLoading();
  193. } else uni.showToast({
  194. title: '没有更多数据了',
  195. icon: 'none'
  196. });
  197. },
  198. // 清空列表
  199. clearPage() {
  200. const that = this;
  201. that.$set(that, `list`, [])
  202. that.$set(that, `skip`, 0)
  203. that.$set(that, `limit`, 6)
  204. that.$set(that, `page`, 0)
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. .main {
  211. display: flex;
  212. flex-direction: column;
  213. width: 100vw;
  214. height: 100vh;
  215. .one {
  216. padding: 2vw;
  217. input {
  218. padding: 2vw;
  219. background-color: var(--f1Color);
  220. font-size: var(--font14Size);
  221. border-radius: 5px;
  222. }
  223. }
  224. .two {
  225. position: relative;
  226. flex-grow: 1;
  227. padding: 2vw 0 0 0;
  228. .tabsList {
  229. position: relative;
  230. width: 100vw;
  231. height: 82vh;
  232. .list {
  233. display: flex;
  234. flex-direction: row;
  235. justify-content: space-between;
  236. align-items: center;
  237. width: 91vw;
  238. border: 1px solid var(--f1Color);
  239. margin: 2vw 2vw 0 2vw;
  240. padding: 0 2vw;
  241. border-radius: 5px;
  242. .image {
  243. display: flex;
  244. flex-wrap: wrap;
  245. justify-content: center;
  246. align-items: center;
  247. width: 27vw;
  248. height: 27vw;
  249. border-radius: 5px;
  250. margin: 0 2vw 0 0;
  251. .file {
  252. width: 9vw;
  253. height: 9vw;
  254. }
  255. }
  256. .list_1 {
  257. display: flex;
  258. flex-direction: column;
  259. flex-grow: 1;
  260. padding: 2vw 0;
  261. width: 35vw;
  262. .name {
  263. font-size: var(--font16Size);
  264. margin: 0 0 1vw 0;
  265. }
  266. .some {
  267. color: var(--f85Color);
  268. font-size: var(--font14Size);
  269. margin: 0 0 1vw 0;
  270. text:last-child {
  271. margin: 0 0 0 1vw;
  272. color: var(--f00Color);
  273. }
  274. }
  275. }
  276. .other {
  277. .btn {
  278. display: flex;
  279. flex-direction: column;
  280. align-items: center;
  281. margin: 0 2vw;
  282. padding: 2vw 3vw;
  283. background-color: var(--ff0Color);
  284. color: var(--fffColor);
  285. border-radius: 2vw;
  286. font-size: var(--font14Size);
  287. text {
  288. font-size: var(--font12Size);
  289. }
  290. }
  291. .button {
  292. margin: 0 2vw;
  293. padding: 2vw 3vw;
  294. background-color: var(--fcColor);
  295. color: var(--f00Color);
  296. border-radius: 2vw;
  297. font-size: var(--font14Size);
  298. }
  299. }
  300. }
  301. }
  302. }
  303. }
  304. </style>