123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <template>
- <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
- <view class="main">
- <view class="one">
- <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" @tap="toShop(item)">
- <view class="list_1">
- <view class="l">
- <image class="image" :src="item.logo&&item.logo.length>0?item.logo[0].url:''" mode=""></image>
- </view>
- <view class="c">
- <view class="name">
- {{item.name}}
- </view>
- <view class="other">
- <text>宝贝数<text>{{item.market_num}}</text></text>
- <text>关注数<text>{{item.follow_num}}</text></text>
- </view>
- </view>
- <view class="r" @tap.stop="toFolllow(item)">
- <text class="iconfont icon-yduishoucangshixin-copy" v-if="item.is_follow==true"></text>
- <text class="iconfont icon-yduishoucangkongxin-copy" v-else></text>
- </view>
- </view>
- <view class="list_2">
- <view class="market" v-for="(tag,indexs) in item.market" :key="indexs" @tap.stop="toBuy(tag)">
- <image class="image" :src="tag.file&&tag.file.length>0?tag.file[0].url:''" mode="">
- </image>
- <view class="money">
- ¥{{tag.sell_money}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- frameStyle: {
- useBar: true
- },
- user: {},
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 10,
- };
- },
- onLoad: async function() {
- const that = this;
- // 监听用户是否登录
- await that.watchLogin();
- // 查询列表
- await that.search();
- },
- onPullDownRefresh: async function() {
- const that = this;
- that.clearPage();
- await that.search();
- uni.stopPullDownRefresh();
- },
- methods: {
- // 监听用户是否登录
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- that.$set(that, `user`, user)
- }
- })
- },
- // 查询列表
- async search() {
- const that = this;
- let info = {
- skip: that.skip,
- limit: that.limit
- }
- const res = await that.$api(`/viewShop/microIndex`, `GET`, {
- ...info,
- })
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- that.$set(that, `list`, list)
- that.$set(that, `total`, res.total)
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- },
- // 分页
- toPage() {
- 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 {}
- },
- // 商铺
- toShop(e) {
- const that = this;
- uni.navigateTo({
- url: `/pagesHome/shop/index?id=${e._id}`
- })
- },
- // 购买
- toBuy(e) {
- const that = this;
- uni.navigateTo({
- url: `/pagesHome/order/detail?id=${e._id}`
- })
- },
- // 关注
- async toFolllow(e) {
- const that = this;
- let user = that.user;
- if (user && user._id && e && e._id) {
- let res = await that.$api(`/storeShop`, `POST`, {
- customer: user._id,
- shop: e._id
- });
- if (res.errcode == '0') {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- })
- that.clearPage();
- that.search()
- }
- } else {
- uni.showToast({
- title: '缺少必要信息,无法收藏',
- icon: 'none'
- })
- }
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- },
- toPath(e) {
- let url = `/${e.route}`;
- if (e.type == '0') uni.redirectTo({
- url
- })
- else {
- uni.navigateTo({
- url
- })
- }
- }
- },
- }
- </script>
- <style lang="scss">
- .main {
- .one {
- .list {
- margin: 2vw 2vw 0 2vw;
- padding: 2vw;
- border-radius: 5px;
- background-color: #f5f5f5;
- .list_1 {
- display: flex;
- flex-direction: row;
- margin: 0 0 1vw 0;
- .l {
- width: 20vw;
- .image {
- width: 100%;
- height: 20vw;
- border-radius: 5px;
- }
- }
- .c {
- padding: 0 0 0 2vw;
- width: 60vw;
- .name {
- font-size: 16px;
- font-weight: bold;
- margin: 0 0 1vw 0;
- }
- .other {
- font-size: 14px;
- text {
- padding: 0 2vw 0 0;
- }
- }
- }
- .r {
- width: 10vw;
- text-align: right;
- text {
- font-size: 30px;
- }
- }
- }
- .list_2 {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- .market {
- position: relative;
- margin: 0 2vw 2vw 0;
- width: 29vw;
- .image {
- width: 100%;
- height: 20vw;
- }
- .money {
- position: absolute;
- bottom: 0;
- font-size: 10px;
- width: 100%;
- background-color: #0000005f;
- color: #fff;
- padding: 0.2vw 0;
- text-align: center;
- font-size: 14px;
- }
- }
- .market:nth-child(3n) {
- margin: 0 0 2vw 0;
- }
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- </style>
|