index.vue 7.4 KB

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