123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <input type="text" v-model="searchInfo.name" @blur="toInput" placeholder="搜索商品名称">
- </view>
- <view class="two">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
- <view class="list-scroll-view">
- <view class="list" v-for="(item, index) in list" :key="index">
- <view class="image">
- <image class="file" v-for="(tag, indexs) in item.persons.slice(0,7)" :key="indexs"
- :src="tag.icon&&tag.icon.length>0?tag.icon[0].url:''" mode="">
- </view>
- </image>
- <view class="list_1">
- <view class="name">
- {{item.person_limit||0}}人即可开团成功
- </view>
- <view class="some">
- <text>团长</text>
- <text>{{item.leader.name||'暂无'}}</text>
- </view>
- <view class="some">
- <text>参团人数</text>
- <text>{{item.persons.length||0}}人</text>
- </view>
- </view>
- <view class="other">
- <view class="btn" @click="onSubmit(item)">
- <text>{{item.zhStatus||'暂无状态'}}</text>立即参团
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- user: {},
- searchInfo: {},
- list: [],
- total: 0,
- skip: 0,
- limit: 6,
- page: 0,
- statusList: [],
- };
- },
- onShow: function() {
- const that = this;
- that.watchLogin()
- },
- methods: {
- // 监听用户是否登录
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: async function(res) {
- let user = that.$jwt(res.data);
- that.$set(that, `user`, user);
- let status = await that.$api(`/dictData`, 'GET', {
- code: "group_status"
- });
- if (status.errcode == '0') {
- that.$set(that, `statusList`, status.data)
- }
- that.search()
- },
- fail: function(err) {
- uni.reLaunch({
- url: `/pages/login/index`
- })
- }
- })
- },
- // 查询列表
- async search() {
- const that = this;
- let user = that.user;
- if (user._id) {
- let info = {
- skip: that.skip,
- limit: that.limit,
- persons: user._id
- }
- let res = await that.$api(`/group`, 'GET', {
- ...info,
- ...that.searchInfo
- })
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- for (let val of list) {
- let status = that.statusList.find(i => i.value == val.status)
- if (status) val.zhStatus = status.label;
- }
- that.$set(that, `list`, list);
- that.$set(that, `total`, res.total)
- }
- }
- },
- // 分页
- toPage(e) {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.search();
- uni.hideLoading();
- } else uni.showToast({
- title: '没有更多数据了'
- });
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- }
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- border-bottom: 1px solid var(--f85Color);
- padding: 2vw;
- input {
- padding: 2vw;
- background-color: var(--f1Color);
- font-size: var(--font14Size);
- border-radius: 5px;
- }
- }
- .two {
- position: relative;
- flex-grow: 1;
- padding: 2vw 0 0 0;
- .list {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- width: 91vw;
- border: 1px solid var(--f1Color);
- margin: 2vw 2vw 0 2vw;
- padding: 0 2vw;
- border-radius: 5px;
- .image {
- display: flex;
- flex-wrap: wrap;
- justify-content: center;
- align-items: center;
- width: 27vw;
- height: 27vw;
- border-radius: 5px;
- margin: 0 2vw 0 0;
- .file {
- width: 9vw;
- height: 9vw;
- }
- }
- .list_1 {
- display: flex;
- flex-direction: column;
- flex-grow: 1;
- padding: 2vw 0;
- .name {
- font-size: var(--font16Size);
- margin: 0 0 1vw 0;
- }
- .some {
- color: var(--f85Color);
- font-size: var(--font14Size);
- margin: 0 0 1vw 0;
- text:last-child {
- margin: 0 0 0 1vw;
- color: var(--f00Color);
- }
- }
- }
- .other {
- .btn {
- display: flex;
- flex-direction: column;
- align-items: center;
- margin: 0 2vw;
- padding: 2vw 3vw;
- background-color: var(--ff0Color);
- color: var(--fffColor);
- border-radius: 2vw;
- font-size: var(--font14Size);
- text {
- font-size: var(--font12Size);
- }
- }
- }
- }
- }
- }
- </style>
|