index.vue 7.0 KB

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