index.vue 7.4 KB

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