gdpaomg
This commit is contained in:
commit
1b5bf33166
@ -173,10 +173,17 @@ export default {
|
||||
goods_id: id
|
||||
});
|
||||
},
|
||||
getStoreGoodsList({ id, page = 0}){
|
||||
getStoreGoodsList({ id, page, order, gc_id }){
|
||||
return vm.$u.post('Store/getStoreGoodsList', {
|
||||
id: id,
|
||||
page:page
|
||||
page: page,
|
||||
order: order,
|
||||
gc_id: gc_id,
|
||||
});
|
||||
},
|
||||
getStoreClassifyList({ id }) {
|
||||
return vm.$u.post('Store/getStoreClassifyList', {
|
||||
id: id
|
||||
});
|
||||
},
|
||||
getStoreImgVideoList({id}){
|
||||
@ -306,7 +313,11 @@ export default {
|
||||
// 达人上架商品
|
||||
goodsShelves({live_id}){
|
||||
return vm.$u.post('Specialci/goodsShelves',{live_id})
|
||||
}
|
||||
},
|
||||
//
|
||||
addFavoriteStore({ id }) {
|
||||
return vm.$u.post('member/addFavoriteStore',{ fid: id })
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,9 +175,10 @@ export default {
|
||||
return vm.$u.post('Member/getFavoritesList', params);
|
||||
},
|
||||
// 取消收藏(商品/店铺)
|
||||
removeFavorite({ id }) {
|
||||
removeFavorite({ id, type }) {
|
||||
return vm.$u.post('Member/removeFavorite', {
|
||||
id: id,
|
||||
fav_id: id,
|
||||
type: type,
|
||||
});
|
||||
},
|
||||
// 设置-用户信息
|
||||
|
@ -7,7 +7,7 @@
|
||||
<view class="label">
|
||||
<u-tabs-swiper ref="group" :list="classifyList" name="gc_name" :is-scroll="true" active-color="#FF780F" :current="current" font-size="24" :show-bar="false" @change="tabsChange" height="88"></u-tabs-swiper>
|
||||
</view>
|
||||
<swiper :current="swiperCurrent" @animationfinish="animationfinish" style="height: 130px">
|
||||
<swiper :current="swiperCurrent" @animationfinish="animationfinish" style="height: 260rpx">
|
||||
<swiper-item class="swiper-item list" v-for="(_, i) in classifyList" :key="i">
|
||||
<!-- 最多显示3个 -->
|
||||
<sitem :info="info" v-for="(info, index) in groupList.slice(0, 3)" :key="index"></sitem>
|
||||
@ -97,8 +97,8 @@ export default {
|
||||
box-sizing: border-box;
|
||||
padding: 0 30rpx;
|
||||
display: flex;
|
||||
&:not(:nth-child(3n)) {
|
||||
> view {
|
||||
> view {
|
||||
&:not(:nth-child(3n)) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<view class="list">
|
||||
<view class="top">商品推荐</view>
|
||||
<view>
|
||||
<u-tabs-swiper ref="uTabs" :list="classifyList" name="gc_name" :is-scroll="true" active-color="#FF780F" :current="current" font-size="24" :show-bar="false" @change="tabsChange" height="60" ></u-tabs-swiper>
|
||||
<u-tabs-swiper ref="uTabs" :list="classifyList" name="gc_name" :is-scroll="true" active-color="#FF780F" :current="current" font-size="24" :show-bar="false" @change="tabsChange" height="60"></u-tabs-swiper>
|
||||
</view>
|
||||
<swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" :style="{height: swiperHeight}">
|
||||
<swiper-item class="swiper-item" v-for="(_, index) in classifyList" :key="index">
|
||||
@ -39,6 +39,7 @@ export default {
|
||||
watch: {
|
||||
current(index) {
|
||||
this.page = 1;
|
||||
this.goodsList = [];
|
||||
const id = this.classifyList[index].gc_id;
|
||||
this.getGoodsRecommend({gc_id: id});
|
||||
}
|
||||
@ -68,7 +69,7 @@ export default {
|
||||
this.page--;
|
||||
})
|
||||
},
|
||||
getGoodsClassRecommend(gc_id) {
|
||||
getGoodsClassRecommend() {
|
||||
this.$u.api.getGoodsClassRecommend().then(res => {
|
||||
if (res.errCode == 0) {
|
||||
// 初始化 current
|
||||
@ -82,6 +83,7 @@ export default {
|
||||
page: page,
|
||||
gc_id: gc_id,
|
||||
})
|
||||
// this.swiperCurrent = this.current;
|
||||
if (res.errCode == 0) {
|
||||
this.timer = true;
|
||||
if(reload) this.goodsList = res.data.goodsList;
|
||||
@ -93,13 +95,14 @@ export default {
|
||||
},
|
||||
setSwiperHeight() {
|
||||
// height: 230px, margin-bottom: 13
|
||||
// const height = Math.ceil(this.goodsList.length / 2) * (510 + 26);
|
||||
// this.swiperHeight = height == 0 ? '230rpx' : height + 'rpx';
|
||||
this.swiperHeight = Math.ceil(this.goodsList.length / 2) * (270 + 13) + 'px';
|
||||
const height = Math.ceil(this.goodsList.length / 2) * (540 + 26);
|
||||
this.swiperHeight = height == 0 ? '230rpx' : height + 'rpx';
|
||||
// this.swiperHeight = Math.ceil(this.goodsList.length / 2) * (270 + 13) + 'px';
|
||||
},
|
||||
// tabs通知swiper切换
|
||||
tabsChange(index) {
|
||||
this.swiperCurrent = index;
|
||||
this.current = index;
|
||||
// this.getGoodsRecommend({ gc_id: this.classifyList[this.current].gc_id });
|
||||
},
|
||||
// swiper-item左右移动,通知tabs的滑块跟随移动
|
||||
transition(e) {
|
||||
@ -111,8 +114,9 @@ export default {
|
||||
animationfinish(e) {
|
||||
let current = e.detail.current;
|
||||
this.$refs.uTabs.setFinishCurrent(current);
|
||||
this.swiperCurrent = current;
|
||||
this.current = current;
|
||||
this.swiperCurrent = current;
|
||||
// this.getGoodsRecommend({ gc_id: this.classifyList[this.current].gc_id });
|
||||
},
|
||||
}
|
||||
}
|
||||
|
5
main.js
5
main.js
@ -1,11 +1,12 @@
|
||||
import Vue from 'vue'
|
||||
import App from './App'
|
||||
|
||||
import IMService from './static/imservice.js'
|
||||
import uView from "uview-ui";
|
||||
Vue.config.productionTip = false
|
||||
Vue.use(uView);
|
||||
App.mpType = 'app'
|
||||
|
||||
Vue.prototype.imService = new IMService();
|
||||
Vue.prototype.a = 1;
|
||||
import store from '@/common/store/index.js'
|
||||
|
||||
Vue.prototype.$store = store;
|
||||
|
@ -135,7 +135,7 @@
|
||||
</u-popup>
|
||||
<!-- 普通商品 tool -->
|
||||
<view class="tloos" v-if="type == 1">
|
||||
<view class="navs">
|
||||
<view class="navs" @click="toOthersPage('pageC/merchant/index?id=' + storeInfo.store_id)">
|
||||
<image src="/static/image/common/18.png"></image>
|
||||
店铺
|
||||
</view>
|
||||
@ -155,7 +155,7 @@
|
||||
<!-- 秒杀 tool -->
|
||||
<view class="spike-tool" v-if="type==3">
|
||||
<view class="left">
|
||||
<view>
|
||||
<view @click="toOthersPage('pageC/merchant/index?id=' + storeInfo.store_id)">
|
||||
<image src="/static/image/common/18.png"></image>
|
||||
<text>店铺</text>
|
||||
</view>
|
||||
@ -183,7 +183,8 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
list: [], // 轮播图列表
|
||||
goodsInfo: {}, // 商品信息
|
||||
goodsInfo: {}, // 商品信息
|
||||
storeInfo: {},
|
||||
glist: [], // 规格列表
|
||||
id: 0, // 商品id/秒杀id/拼团 id
|
||||
type: '', // 商品类型 商品详情 1普通 2拼团 3秒杀 4优惠券
|
||||
@ -311,6 +312,7 @@ export default {
|
||||
if (res.errCode == 0) {
|
||||
this.evaluate = res.data.goods_evaluate_info;
|
||||
this.goodsInfo = res.data.goods;
|
||||
this.storeInfo = res.data.store;
|
||||
this.setSwiperList(res.data.goods_image);
|
||||
this.glist = res.data.spec_list;
|
||||
// console.log(this.goodsInfo.mobile_body);
|
||||
@ -452,6 +454,9 @@ export default {
|
||||
title: title
|
||||
});
|
||||
},
|
||||
toOthersPage(url) {
|
||||
this.$u.route(url);
|
||||
},
|
||||
viewComment() {
|
||||
this.$u.route({
|
||||
url: 'pageB/comment/index',
|
||||
|
@ -200,11 +200,13 @@ export default {
|
||||
if(!this.debounce) return;
|
||||
this.debounce = false;
|
||||
if(this.orderType == 2) {
|
||||
// this.sendOrder(0);
|
||||
this.withImmediate();
|
||||
} else if(this.orderType == 1) {
|
||||
this.sendOrder(0);
|
||||
} else {
|
||||
this.sendOrder(1);
|
||||
}
|
||||
else this.sendOrder(1);
|
||||
},
|
||||
// @params {Number} ifcart 是否是购物车商品
|
||||
sendOrder(ifcart) {
|
||||
@ -254,6 +256,7 @@ export default {
|
||||
// console.log(params);
|
||||
this.$u.api.sendOrder(params).then(res => {
|
||||
if(res.errCode == 0) {
|
||||
// this.withImmediate();
|
||||
this.$u.route({
|
||||
type: 'redirect',
|
||||
url: '/pageC/cart/cashier',
|
||||
|
215
pageC/merchant/classifyGoods.vue
Normal file
215
pageC/merchant/classifyGoods.vue
Normal file
@ -0,0 +1,215 @@
|
||||
<template>
|
||||
<view class="classify-goods">
|
||||
<view class="tab-container">
|
||||
<view class="overall" :class="{ 'current' : current == 0 }" @click="switchCurrent(0)">综合</view>
|
||||
<view class="salenum" :class="{ 'current' : current == 1 }" @click="switchCurrent(1)">销量</view>
|
||||
<view class="new" :class="{ 'current' : current == 2 }" @click="switchCurrent(2)">新品</view>
|
||||
<view class="price" :class="{ 'current' : current == 3 }" @click="switchCurrent(3)">
|
||||
<view class="text">价格</view>
|
||||
<view class="icon">
|
||||
<u-icon name="arrow-up-fill" :color="(current == 3 && priceOrderAsc) ? '#FF780F' : '#333333'" size="22"></u-icon>
|
||||
<u-icon name="arrow-down-fill" :color="(current == 3 && !priceOrderAsc) ? '#FF780F' : '#333333'" size="22"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view scroll-y class="scroll-container" :style="{ height: scrollHeight }" @scrolltolower="loadMore">
|
||||
<view class="goods-container">
|
||||
<view v-for="goods in goodsList" :key="goods.goods_id" class="goods-view" @click="toDetailsPage(goods.goods_id)">
|
||||
<goodsItem :info="goods"></goodsItem>
|
||||
</view>
|
||||
</view>
|
||||
<u-loadmore :status="loadStatus" bgColor="#FFFFFF" margin-top="20" margin-bottom="20" v-if="goodsList.length >= pageSize"></u-loadmore>
|
||||
<u-empty mode="list" v-if="!goodsList.length"></u-empty>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import goodsItem from "@/components/shop/list/item"
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
pageSize: 15,
|
||||
cid: '',
|
||||
page: 1,
|
||||
current: 0,
|
||||
priceOrderAsc: true, // 是否升序
|
||||
goodsList: [],
|
||||
scrollHeight: '',
|
||||
loadStatus: 'loadmore',
|
||||
timer: true, // 防止上拉加载短时间内多次调用
|
||||
}
|
||||
},
|
||||
components: {
|
||||
goodsItem
|
||||
},
|
||||
watch: {
|
||||
current(value) {
|
||||
this.page = 1;
|
||||
this.goodsList = [];
|
||||
this.getStoreGoodsList({ laod: 'reload' });
|
||||
},
|
||||
priceOrderAsc(value) {
|
||||
this.page = 1;
|
||||
this.getStoreGoodsList({ laod: 'reload' });
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
if(option.cid == 'all') {
|
||||
this.current = 0;
|
||||
this.cid = 0;
|
||||
} else if(option.cid == 'new') {
|
||||
this.current = 2;
|
||||
this.cid = 0;
|
||||
} else {
|
||||
this.cid = option.cid;
|
||||
}
|
||||
this.setTitle(option.name);
|
||||
this.sid = option.sid;
|
||||
this.setViewHeight();
|
||||
this.getStoreGoodsList({ load: 'reload' });
|
||||
},
|
||||
methods: {
|
||||
setOrderSort() {
|
||||
let sort = '';
|
||||
if(this.current == 0) {
|
||||
sort = 'goods_sort';
|
||||
} else if(this.current == 1) {
|
||||
sort = 'goods_salenum';
|
||||
} else if(this.current == 2) {
|
||||
sort = 'goods_addtime';
|
||||
} else if(this.current == 3) {
|
||||
if(this.priceOrderAsc) sort = 'goods_price_asc';
|
||||
else sort = 'goods_price_desc';
|
||||
}
|
||||
return sort;
|
||||
},
|
||||
// 排序方式 goods_salenum:销量 evaluation_count:评价 goods_price_asc:价格从低到高 goods_price_desc:价格从高到低
|
||||
async getStoreGoodsList({ load = 'reload' } = {}) {
|
||||
const sort = this.setOrderSort();
|
||||
let params = {
|
||||
id: this.sid,
|
||||
page: this.page,
|
||||
order: sort,
|
||||
};
|
||||
console.log(this.cid);
|
||||
if(this.cid) Object.assign(params, { gc_id: this.cid })
|
||||
const res = await this.$u.api.getStoreGoodsList(params);
|
||||
this.timer = true;
|
||||
if(res.errCode == 0) {
|
||||
this.pageSize = res.data.per_page;
|
||||
if(load == 'reload') this.goodsList = res.data.data;
|
||||
else if(load == 'loadmore') this.goodsList.push(...res.data.data);
|
||||
}
|
||||
return res.data.data.length;
|
||||
},
|
||||
loadMore() {
|
||||
if(this.goodsList.length < this.pageSize) return false;
|
||||
if(!this.timer) return false;
|
||||
this.loadStatus = "loading";
|
||||
this.page++;
|
||||
this.getStoreGoodsList({ load: 'loadmore' }).then(length => {
|
||||
if(length == 0) {
|
||||
this.page--;
|
||||
this.loadStatus = 'nomore';
|
||||
} else {
|
||||
this.loadStatus = 'loading';
|
||||
}
|
||||
}).catch(() => {
|
||||
this.loadStatus = "nomore";
|
||||
this.page--;
|
||||
})
|
||||
},
|
||||
switchCurrent(current) {
|
||||
if(current == 3 && this.current == 3) this.priceOrderAsc = !this.priceOrderAsc;
|
||||
this.current = current;
|
||||
},
|
||||
setViewHeight() {
|
||||
const res = uni.getSystemInfoSync();
|
||||
this.scrollHeight = res.windowHeight - 90 / 2 + 'px';
|
||||
// console.log(this.scrollHeight);
|
||||
},
|
||||
toDetailsPage(id) {
|
||||
this.$u.route('/pageB/sdetails/index', {
|
||||
id: id,
|
||||
type: 1 // 商品详情 商品类型 1普通 2拼团 3秒杀 4优惠券
|
||||
});
|
||||
},
|
||||
setTitle(title){
|
||||
uni.setNavigationBarTitle({
|
||||
title: title
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.classify-goods {
|
||||
width: 100%;
|
||||
background-color: #FFFFFF;
|
||||
.tab-container {
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx 40rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
> view {
|
||||
height: 30rpx;
|
||||
line-height: 30rpx;
|
||||
font-size: 32rpx;
|
||||
color: rgba(51,51,51,1);
|
||||
}
|
||||
.price {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
.text {
|
||||
margin-right: 5rpx;
|
||||
}
|
||||
.icon {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
.current {
|
||||
color: rgba(255,120,15,1);
|
||||
}
|
||||
}
|
||||
.scroll-container {
|
||||
box-sizing: border-box;
|
||||
padding: 0 30rpx;
|
||||
.goods-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
// .goods-view {
|
||||
// margin: 0 auto;
|
||||
// width: 690rpx;
|
||||
// display: flex;
|
||||
// background-color: #F5F5F5;
|
||||
// margin-bottom: 30rpx;
|
||||
// align-items: center;
|
||||
// > image {
|
||||
// width: 220rpx;
|
||||
// height: 170rpx;
|
||||
// flex-shrink: 0;
|
||||
// margin-right: 30rpx;
|
||||
// }
|
||||
// .right {
|
||||
// width: 418rpx;
|
||||
// .name {
|
||||
// font-size: 30rpx;
|
||||
// color: rgba(51,51,51,1);
|
||||
// margin-bottom: 20rpx;
|
||||
// }
|
||||
// .briefing {
|
||||
// font-size: 28rpx;
|
||||
// color: rgba(102,102,102,1);
|
||||
// line-height: 36rpx;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
</style>
|
@ -3,14 +3,14 @@
|
||||
<view class="top">
|
||||
<image :src="info.store_avatar"></image>
|
||||
<view class="name">{{info.store_name}}</view>
|
||||
<view class="info">创建时间:{{store_addtime|date}} | {{info.live_store_address}}</view>
|
||||
<view class="info">创建时间:{{ info.store_addtime | date('yyyy年mm月dd日') }} | {{ info.live_store_address || '暂无地址' }}</view>
|
||||
<view class="num">
|
||||
<view>
|
||||
<view class="value">{{info.store_collect}}</view>
|
||||
<view class="title">粉丝数</view>
|
||||
</view>
|
||||
<view>
|
||||
<view class="value">23435</view>
|
||||
<view class="value">{{ info.evaluatecount }}</view>
|
||||
<view class="title">评价</view>
|
||||
</view>
|
||||
<view>
|
||||
@ -22,9 +22,9 @@
|
||||
<view class="bottom">
|
||||
<view class="title">
|
||||
<view>工商执照</view>
|
||||
<image></image>
|
||||
<u-icon name="arrow-down" color="#999999" size="28"></u-icon>
|
||||
</view>
|
||||
<view class="image-list">
|
||||
<view class="image-list" v-if="info.business_licence_number_electronic">
|
||||
<image :src="info.business_licence_number_electronic"></image>
|
||||
</view>
|
||||
</view>
|
||||
@ -37,9 +37,9 @@ export default {
|
||||
info:{}
|
||||
}
|
||||
},
|
||||
onLoad(){
|
||||
this.$u.api.getStoreInfo({id:1}).then((res)=>{
|
||||
console.log(res)
|
||||
onLoad(option){
|
||||
this.$u.api.getStoreInfo({id: option.id}).then((res)=>{
|
||||
// console.log(res)
|
||||
this.info = res.data
|
||||
})
|
||||
}
|
||||
@ -113,11 +113,6 @@ export default {
|
||||
font-weight: 500;
|
||||
color: rgba(51,51,51,1);
|
||||
}
|
||||
> image {
|
||||
width: 24rpx;
|
||||
height: 14rpx;
|
||||
background-color: aqua;
|
||||
}
|
||||
}
|
||||
.image-list {
|
||||
background-color: #ffffff;
|
||||
|
200
pageC/merchant/goods.vue
Normal file
200
pageC/merchant/goods.vue
Normal file
@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<view class="classify-goods">
|
||||
<view class="tab-container">
|
||||
<view class="overall" :class="{ 'current' : current == 0 }" @click="switchCurrent(0)">综合</view>
|
||||
<view class="salenum" :class="{ 'current' : current == 1 }" @click="switchCurrent(1)">销量</view>
|
||||
<view class="new" :class="{ 'current' : current == 2 }" @click="switchCurrent(2)">新品</view>
|
||||
<view class="price" :class="{ 'current' : current == 3 }" @click="switchCurrent(3)">
|
||||
<view class="text">价格</view>
|
||||
<view class="icon">
|
||||
<u-icon name="arrow-up-fill" :color="(current == 3 && priceOrderAsc) ? '#FF780F' : '#333333'" size="22"></u-icon>
|
||||
<u-icon name="arrow-down-fill" :color="(current == 3 && !priceOrderAsc) ? '#FF780F' : '#333333'" size="22"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view scroll-y class="scroll-container" :style="{ height: scrollHeight }" @scrolltolower="loadMore">
|
||||
<view class="goods-container">
|
||||
<view v-for="goods in goodsList" :key="goods.goods_id" class="goods-view" @click="toDetailsPage(goods.goods_id)">
|
||||
<goodsItem :info="goods"></goodsItem>
|
||||
</view>
|
||||
</view>
|
||||
<u-loadmore :status="loadStatus" bgColor="#FFFFFF" margin-top="20" margin-bottom="20" v-if="goodsList.length >= pageSize"></u-loadmore>
|
||||
<u-empty mode="list" v-if="!goodsList.length"></u-empty>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import goodsItem from "@/components/shop/list/item"
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
pageSize: 15,
|
||||
cid: '',
|
||||
page: 1,
|
||||
current: 0,
|
||||
priceOrderAsc: true, // 是否升序
|
||||
goodsList: [],
|
||||
scrollHeight: '',
|
||||
loadStatus: 'loadmore',
|
||||
timer: true, // 防止上拉加载短时间内多次调用
|
||||
}
|
||||
},
|
||||
components: {
|
||||
goodsItem
|
||||
},
|
||||
props: {
|
||||
sid: String
|
||||
},
|
||||
watch: {
|
||||
current(value) {
|
||||
this.page = 1;
|
||||
this.goodsList = [];
|
||||
this.getStoreGoodsList({ laod: 'reload' });
|
||||
},
|
||||
priceOrderAsc(value) {
|
||||
this.page = 1;
|
||||
this.getStoreGoodsList({ laod: 'reload' });
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.setViewHeight();
|
||||
this.getStoreGoodsList({ load: 'reload' });
|
||||
},
|
||||
methods: {
|
||||
setOrderSort() {
|
||||
let sort = '';
|
||||
if(this.current == 0) {
|
||||
sort = 'goods_sort';
|
||||
} else if(this.current == 1) {
|
||||
sort = 'goods_salenum';
|
||||
} else if(this.current == 2) {
|
||||
sort = 'goods_addtime';
|
||||
} else if(this.current == 3) {
|
||||
if(this.priceOrderAsc) sort = 'goods_price_asc';
|
||||
else sort = 'goods_price_desc';
|
||||
}
|
||||
return sort;
|
||||
},
|
||||
// 排序方式 goods_salenum:销量 evaluation_count:评价 goods_price_asc:价格从低到高 goods_price_desc:价格从高到低
|
||||
async getStoreGoodsList({ load = 'reload' } = {}) {
|
||||
const sort = this.setOrderSort();
|
||||
const res = await this.$u.api.getStoreGoodsList({
|
||||
id: this.sid,
|
||||
page: this.page,
|
||||
order: sort,
|
||||
})
|
||||
this.timer = true;
|
||||
if(res.errCode == 0) {
|
||||
this.pageSize = res.data.per_page;
|
||||
if(load == 'reload') this.goodsList = res.data.data;
|
||||
else if(load == 'loadmore') this.goodsList.push(...res.data.data);
|
||||
}
|
||||
return res.data.data.length;
|
||||
},
|
||||
loadMore() {
|
||||
if(this.goodsList.length < this.pageSize) return false;
|
||||
if(!this.timer) return false;
|
||||
this.loadStatus = "loading";
|
||||
this.page++;
|
||||
this.getStoreGoodsList({ load: 'loadmore' }).then(length => {
|
||||
if(length == 0) {
|
||||
this.page--;
|
||||
this.loadStatus = 'nomore';
|
||||
} else {
|
||||
this.loadStatus = 'loading';
|
||||
}
|
||||
}).catch(() => {
|
||||
this.loadStatus = "nomore";
|
||||
this.page--;
|
||||
})
|
||||
},
|
||||
switchCurrent(current) {
|
||||
if(current == 1 && this.current == 1) this.priceOrderAsc = !this.priceOrderAsc;
|
||||
this.current = current;
|
||||
},
|
||||
setViewHeight() {
|
||||
const res = uni.getSystemInfoSync();
|
||||
const otherHeight = 347 + 140 + 20 + 98;
|
||||
this.scrollHeight = res.windowHeight - otherHeight / 2 + 'px';
|
||||
// console.log(this.scrollHeight);
|
||||
},
|
||||
toDetailsPage(id) {
|
||||
this.$u.route('/pageB/sdetails/index', {
|
||||
id: id,
|
||||
type: 1 // 商品详情 商品类型 1普通 2拼团 3秒杀 4优惠券
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.classify-goods {
|
||||
width: 100%;
|
||||
background-color: #FFFFFF;
|
||||
.tab-container {
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx 40rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
> view {
|
||||
height: 30rpx;
|
||||
line-height: 30rpx;
|
||||
font-size: 32rpx;
|
||||
color: rgba(51,51,51,1);
|
||||
}
|
||||
.price {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
.text {
|
||||
margin-right: 5rpx;
|
||||
}
|
||||
.icon {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
.current {
|
||||
color: rgba(255,120,15,1);
|
||||
}
|
||||
}
|
||||
.scroll-container {
|
||||
box-sizing: border-box;
|
||||
padding: 0 30rpx;
|
||||
.goods-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
// .goods-view {
|
||||
// margin: 0 auto;
|
||||
// width: 690rpx;
|
||||
// display: flex;
|
||||
// background-color: #F5F5F5;
|
||||
// margin-bottom: 30rpx;
|
||||
// align-items: center;
|
||||
// > image {
|
||||
// width: 220rpx;
|
||||
// height: 170rpx;
|
||||
// flex-shrink: 0;
|
||||
// margin-right: 30rpx;
|
||||
// }
|
||||
// .right {
|
||||
// width: 418rpx;
|
||||
// .name {
|
||||
// font-size: 30rpx;
|
||||
// color: rgba(51,51,51,1);
|
||||
// margin-bottom: 20rpx;
|
||||
// }
|
||||
// .briefing {
|
||||
// font-size: 28rpx;
|
||||
// color: rgba(102,102,102,1);
|
||||
// line-height: 36rpx;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
</style>
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="merchant">
|
||||
<view v-if="show">
|
||||
<!-- <view v-if="show" class="show-hide">
|
||||
<view>
|
||||
<image></image>
|
||||
<view>消息</view>
|
||||
@ -13,67 +13,70 @@
|
||||
<image></image>
|
||||
<view>我的</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="top" :style="{'background-image':'url(' + info.store_banner + ')'}">
|
||||
<image :src="info.store_avatar"></image>
|
||||
<view class="info">
|
||||
<view class="name u-line-1">{{info.store_name}}</view>
|
||||
<view class="num">粉丝数:{{info.store_collect}}</view>
|
||||
</view>
|
||||
<view class="btn">
|
||||
<image></image>
|
||||
<view>{{ 0 ? "关注" : "已关注" }}</view>
|
||||
<view class="btn" @click="attentionMember">
|
||||
<image src="/static/image/shop/8.png"></image>
|
||||
<view>{{ info.is_attention == 0 ? "关注" : "已关注" }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="follow">
|
||||
<view class="follow" v-if="info.attention_member && info.attention_member.length">
|
||||
<view class="title">关注</view>
|
||||
<scroll-view scroll-x class="list">
|
||||
<view class="list-items">
|
||||
<view v-for="(item, index) in 9" :key="index" class="item">
|
||||
<image></image>
|
||||
<view class="nickname u-line-1">用户昵称</view>
|
||||
<view v-for="(item, index) in info.attention_member" :key="index" class="item">
|
||||
<image :src="item.friend_frommavatar"></image>
|
||||
<view class="nickname u-line-1">{{ item.friend_frommname }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="main">
|
||||
<view class="classify" v-if="cur==0">
|
||||
<view class="video-image" v-if="cur==0 && indextop.length">
|
||||
<view v-for="item in indextop" :key="item.id">
|
||||
<videoTop :url="item.url" v-if="item.type == 2"></videoTop>
|
||||
<imageTop v-else :url="item.url"></imageTop>
|
||||
</view>
|
||||
<view style="display: flex;flex-wrap: wrap;">
|
||||
<view style="display: flex;flex-wrap: wrap;" v-if="indexlist.length">
|
||||
<listitem :style="{'margin-left': index%2 == 1 ? '20rpx':'0'}" v-for="(item,index) in indexlist" :key="item.id" :type="item.type" :url="item.url"></listitem>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- 商品筛选排序未完成 -->
|
||||
<view class="item" v-if="cur==1">
|
||||
<item v-for="item in list" :key="item.gc_id" :info="item" class="item"></item>
|
||||
<!-- <item v-for="item in list" :key="item.gc_id" :info="item" class="item"></item> -->
|
||||
<goods :sid="sid"></goods>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tabbar">
|
||||
<view @click="cur=0">
|
||||
<image></image>
|
||||
<view @click="switchCurrent(0)">
|
||||
<image src="/static/image/shop/9.png"></image>
|
||||
<view>商品分类</view>
|
||||
</view>
|
||||
<view @click="cur=1">
|
||||
<image></image>
|
||||
<view>商品列表</view>
|
||||
<view @click="switchCurrent(1)">
|
||||
<image src="/static/image/shop/10.png" v-if="cur != 1"></image>
|
||||
<image src="/static/image/shop/13.png" v-else></image>
|
||||
<view :style="{ color: cur == 1 ? '#FF780F' : '#999999' }">商品列表</view>
|
||||
</view>
|
||||
<view @click="toDetailsPage">
|
||||
<image></image>
|
||||
<view @click="switchCurrent(2)">
|
||||
<image src="/static/image/shop/11.png"></image>
|
||||
<view>店铺信息</view>
|
||||
</view>
|
||||
<view>
|
||||
<image></image>
|
||||
<view @click="switchCurrent(3)">
|
||||
<image src="/static/image/shop/12.png"></image>
|
||||
<view>联系客服</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import item from "@/components/shop/list/item"
|
||||
// import item from "@/components/shop/list/item"
|
||||
import goods from "./goods"
|
||||
import videoTop from "../components/merchant/video-top"
|
||||
import imageTop from "../components/merchant/image-top"
|
||||
import listitem from "../components/merchant/list-item"
|
||||
@ -81,6 +84,7 @@ import listitem from "../components/merchant/list-item"
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
sid: '',
|
||||
show: false,
|
||||
cur: 0,
|
||||
list:[],
|
||||
@ -90,38 +94,64 @@ export default {
|
||||
}
|
||||
},
|
||||
components:{
|
||||
item,
|
||||
goods,
|
||||
videoTop,
|
||||
imageTop,
|
||||
listitem
|
||||
},
|
||||
methods: {
|
||||
toDetailsPage() {
|
||||
uni.navigateTo({
|
||||
url: './details'
|
||||
});
|
||||
}
|
||||
onPullDownRefresh() {
|
||||
this.getStoreInfo();
|
||||
this.getStoreImgVideoList();
|
||||
},
|
||||
onLoad(){
|
||||
this.$u.api.getStoreGoodsList({id:1}).then((res)=>{
|
||||
// console.log(res.data)
|
||||
this.list= res.data.list
|
||||
})
|
||||
this.$u.api.getStoreImgVideoList({id:1}).then((res)=>{
|
||||
console.log(res.data)
|
||||
this.indextop = [res.data[0],res.data[1]]
|
||||
this.indexlist = res.data.slice(2,)
|
||||
})
|
||||
this.$u.api.getStoreInfo({id:1}).then((res)=>{
|
||||
console.log(res)
|
||||
this.info = res.data
|
||||
})
|
||||
onNavigationBarButtonTap(e) {
|
||||
// console.log(e.index);
|
||||
if(e.index == 1) this.$u.route('/pageC/cart/index');
|
||||
// if(e.index == 0) this.show = true;
|
||||
},
|
||||
methods: {
|
||||
switchCurrent(current) {
|
||||
this.cur = current;
|
||||
if(current == 0) {
|
||||
this.$u.route('/pageC/merchant/storeClassify', { id: this.sid });
|
||||
} else if(current == 2) {
|
||||
this.$u.route('./details', { id: this.sid });
|
||||
}
|
||||
},
|
||||
getStoreInfo() {
|
||||
this.$u.api.getStoreInfo({ id: this.sid }).then((res)=>{
|
||||
this.info = res.data;
|
||||
uni.stopPullDownRefresh();
|
||||
})
|
||||
},
|
||||
getStoreImgVideoList() {
|
||||
this.$u.api.getStoreImgVideoList({ id: this.sid }).then((res)=>{
|
||||
if(res.data.length) {
|
||||
this.indextop = [res.data[0], res.data[1]];
|
||||
this.indexlist = res.data.slice(2,);
|
||||
}
|
||||
uni.stopPullDownRefresh();
|
||||
})
|
||||
},
|
||||
attentionMember() {
|
||||
this.$u.api.attentionMember({ member_id: this.info.member_id }).then(res => {
|
||||
if(res.errCode == 0) {
|
||||
this.getStoreInfo();
|
||||
}
|
||||
this.$u.toast(res.message);
|
||||
})
|
||||
},
|
||||
},
|
||||
onLoad(option){
|
||||
this.sid = option.id;
|
||||
console.log(this.sid);
|
||||
this.getStoreInfo();
|
||||
this.getStoreImgVideoList();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.merchant {
|
||||
min-height: 100vh;
|
||||
// min-height: 100vh;
|
||||
background-color: #ECECEC;
|
||||
padding-top: calc(350rpx - var(--window-top));
|
||||
.top {
|
||||
@ -168,7 +198,6 @@ export default {
|
||||
height: 28rpx;
|
||||
flex-shrink: 0;
|
||||
margin-right: 14rpx;
|
||||
background-color: aqua;
|
||||
}
|
||||
> view {
|
||||
white-space: nowrap;
|
||||
@ -230,13 +259,18 @@ export default {
|
||||
}
|
||||
}
|
||||
.main{
|
||||
padding-bottom: 98rpx;
|
||||
.video-image {
|
||||
padding-bottom: 98rpx;
|
||||
}
|
||||
> view {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
}
|
||||
.tabbar {
|
||||
border-top: 1rpx #DBDADA solid;
|
||||
width: 100%;
|
||||
height: 98rpx;
|
||||
background: rgb(95, 64, 64);
|
||||
background: rgba(251,251,251,1);
|
||||
display: flex;
|
||||
padding: 10rpx 55rpx;
|
||||
position: fixed;
|
||||
@ -251,7 +285,6 @@ export default {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-bottom: 15rpx;
|
||||
background-color: aqua;
|
||||
}
|
||||
> view {
|
||||
font-size: 24rpx;
|
||||
@ -259,12 +292,5 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
.item{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
// margin-top: 20rpx;
|
||||
padding:25rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
88
pageC/merchant/storeClassify.vue
Normal file
88
pageC/merchant/storeClassify.vue
Normal file
@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<view class="classify">
|
||||
<view class="item-view" @click="viewGoods({ type: 'all', name: '全部宝贝' })">
|
||||
<view>全部宝贝</view>
|
||||
<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
|
||||
</view>
|
||||
<view class="item-view" @click="viewGoods({ type: 'new', name: '新品上架' })">
|
||||
<view>新品上架</view>
|
||||
<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
|
||||
</view>
|
||||
<view class="classify-container">
|
||||
<view v-for="classifyA in classifyList" :key="classifyA.gc_parent_id" class="classify-view">
|
||||
<view class="title">{{ classifyA.gc_parent_name }}</view>
|
||||
<view class="classifyA-view">
|
||||
<view v-for="classifyB in classifyA.gc_child" :key="classifyB.gc_id" class="classifyB-item u-line-1" @click="viewGoods({ type: classifyB.gc_parent_id, name: classifyB.gc_parent_name })">{{ classifyB.gc_parent_name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
classifyList: [],
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.sid = option.id;
|
||||
this.getStoreClassifyList();
|
||||
},
|
||||
methods: {
|
||||
viewGoods({ type, name }) {
|
||||
console.log(11);
|
||||
this.$u.route('pageC/merchant/classifyGoods', { sid: this.sid, cid: type, name: name });
|
||||
},
|
||||
getStoreClassifyList() {
|
||||
this.$u.api.getStoreClassifyList({ id: this.sid }).then(res => {
|
||||
this.classifyList = res.data;
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.classify {
|
||||
padding-top: 20rpx;
|
||||
background-color: #ECECEC;
|
||||
min-height: calc(100vh - var(--window-top));
|
||||
.item-view {
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 35rpx 30rpx;
|
||||
font-size: 30rpx;
|
||||
color: rgba(51,51,51,1);
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
.classify-container {
|
||||
.classify-view {
|
||||
padding: 30rpx 35rpx;
|
||||
background-color: #FFFFFF;
|
||||
margin-bottom: 20rpx;
|
||||
.title {
|
||||
font-size: 30rpx;
|
||||
color: rgba(51,51,51,1);
|
||||
margin-bottom: 34rpx;
|
||||
}
|
||||
.classifyA-view {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
.classifyB-item {
|
||||
width: 335rpx;
|
||||
height: 74rpx;
|
||||
line-height: 74rpx;
|
||||
background: rgba(255,241,230,1);
|
||||
padding: 0 20rpx;
|
||||
font-size: 30rpx;
|
||||
color: rgba(51,51,51,1);
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@ -3,13 +3,13 @@
|
||||
<u-empty mode="list" v-if="!list.length" color="#000" img-width="200" font-size="30" margin-top="300"></u-empty>
|
||||
<u-swipe-action
|
||||
v-for="(item, index) in list" :key="index"
|
||||
:index='item.favlog_id'
|
||||
:index='item.store_id'
|
||||
:show="item.show"
|
||||
:options="options"
|
||||
@click="removeFavorite"
|
||||
@open="open"
|
||||
>
|
||||
<view class="item u-border-bottom">
|
||||
<view class="item u-border-bottom" @click="toDetailsPage(item.store_id)">
|
||||
<image :src="item.store_avatar"></image>
|
||||
<!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
|
||||
<view class="title-wrap">
|
||||
@ -46,12 +46,15 @@ export default {
|
||||
getStoreFavoritesList() {
|
||||
this.$u.api.getFavoritesList({
|
||||
type: 2 // 店铺 type: 2
|
||||
}).then(res => {
|
||||
this.list = res.data;
|
||||
})
|
||||
},
|
||||
removeFavorite(id) {
|
||||
console.log(id);
|
||||
this.$u.api.removeFavorite({
|
||||
id: id
|
||||
id: id,
|
||||
type: 'store'
|
||||
}).then(res => {
|
||||
this.$u.toast(res.message);
|
||||
if(res.errCode == 0) {
|
||||
@ -59,6 +62,11 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
toDetailsPage(id) {
|
||||
this.$u.route('pageC/merchant/index', {
|
||||
id: id
|
||||
});
|
||||
},
|
||||
open(index) {
|
||||
// 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
|
||||
// 原本为'false',再次设置为'false'会无效
|
||||
|
47
pages.json
47
pages.json
@ -301,23 +301,28 @@
|
||||
{
|
||||
"path": "merchant/index",
|
||||
"style": {
|
||||
"enablePullDownRefresh": true,
|
||||
"app-plus": {
|
||||
"titleSize": "36px",
|
||||
"titleNView": {
|
||||
"titleColor": "#333333",
|
||||
"backgroundColor": "rgba(255,255,255,0)",
|
||||
"buttons": [
|
||||
{
|
||||
"type":"none",
|
||||
"text":"...",
|
||||
"float":"right",
|
||||
"fontSize":"16"
|
||||
},
|
||||
// {
|
||||
// "type":"none",
|
||||
// "text":"\ue62b",
|
||||
// "float":"right",
|
||||
// "fontSize":"20",
|
||||
// "fontSrc": "/static/fonts/more.ttf",
|
||||
// "color": "#FFFFFF"
|
||||
// },
|
||||
{
|
||||
"type":"none",
|
||||
"text":"\ue582",
|
||||
"text":"\ue636",
|
||||
"float":"right",
|
||||
"fontSize":"16"
|
||||
"fontSize":"22",
|
||||
"fontSrc": "/static/fonts/cart.ttf",
|
||||
"color": "#FFFFFF"
|
||||
}
|
||||
],
|
||||
"searchInput": {
|
||||
@ -345,6 +350,32 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "merchant/storeClassify",
|
||||
"style": {
|
||||
"navigationBarTitleText": "商品分类",
|
||||
"app-plus": {
|
||||
"titleSize": "36px",
|
||||
"titleNView": {
|
||||
"titleColor": "#333333",
|
||||
"backgroundColor": "#FFFFFF"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "merchant/classifyGoods",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"app-plus": {
|
||||
"titleSize": "36px",
|
||||
"titleNView": {
|
||||
"titleColor": "#333333",
|
||||
"backgroundColor": "#FFFFFF"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "cart/ConfirmOrder",
|
||||
"style": {
|
||||
|
@ -18,11 +18,11 @@
|
||||
<view id="information">
|
||||
<view class="information_dl" v-for="(item,index) in information_dl" :key="index" >
|
||||
<view>
|
||||
<image :src="item.url"></image>
|
||||
<image :src="item.avatar"></image>
|
||||
</view>
|
||||
<view class="title">{{item.title}}</view>
|
||||
<view class="contentes">{{item.contentes}}</view>
|
||||
<view class="times">{{item.title}}</view>
|
||||
<view class="title">{{item.name}}</view>
|
||||
<view class="contentes">{{item.text}}</view>
|
||||
<view class="times">{{item.time}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -91,13 +91,39 @@
|
||||
show: false
|
||||
};
|
||||
},
|
||||
onShow(){
|
||||
this.information_dl = this.imService.friends;
|
||||
this.imService.onFriendListChange=this.onFriendListChange;
|
||||
},
|
||||
onLoad() {
|
||||
// /消息模块的请求
|
||||
if (this.hasLogin) {
|
||||
this.messageIndex();
|
||||
}
|
||||
if (this.hasLogin) {
|
||||
this.messageIndex();
|
||||
}
|
||||
if(this.$store.state.hasLogin){
|
||||
const user = uni.getStorageSync('user_info');
|
||||
console.log(user)
|
||||
this.imService.login(user.member.member_id,user.member.member_nickname,user.member.member_avatar)
|
||||
this.imService.connectIM()
|
||||
let that = this
|
||||
setTimeout(function(){
|
||||
that.imService.disconnect()
|
||||
console.log("guanbi")
|
||||
},1000)
|
||||
setTimeout(function(){
|
||||
console.log("lianjie")
|
||||
that.imService.connectIM()
|
||||
},2000)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onFriendListChange(onlineFriends) {
|
||||
//todo:比较垃圾的处理方式,因为Uniapp的基于MAP的双向绑定在H5端不稳定,H5端偶尔会抽风
|
||||
// 下边这一行删掉,有时候页面可以更新,有时候不行,大家有优雅的方式,也欢迎跟我们沟通
|
||||
this.information_dl = this.imService.friends;
|
||||
|
||||
this.$forceUpdate();
|
||||
},
|
||||
// 选中某个复选框时,由checkbox时触发
|
||||
checkboxChange(e) {
|
||||
//console.log(e);
|
||||
|
@ -22,8 +22,8 @@
|
||||
<!-- <view @click="toOtherPage('/mine/GoodsCollection')">
|
||||
<view>{{ userInfo.member_fav_goods_num || 0 }}</view>
|
||||
<view>商品收藏</view>
|
||||
</view>
|
||||
<view @click="toOtherPage('/mine/StoreCollection')">
|
||||
</view> -->
|
||||
<!-- <view @click="toOtherPage('/mine/StoreCollection')">
|
||||
<view>{{ userInfo.member_fav_store_num || 0 }}</view>
|
||||
<view>店铺收藏</view>
|
||||
</view> -->
|
||||
@ -248,8 +248,8 @@ export default {
|
||||
box-sizing: border-box;
|
||||
padding: 0 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
// justify-content: flex-start;
|
||||
// justify-content: space-between;
|
||||
justify-content: flex-start;
|
||||
> view {
|
||||
margin-right: 80rpx;
|
||||
text-align: center;
|
||||
|
BIN
static/fonts/more.ttf
Normal file
BIN
static/fonts/more.ttf
Normal file
Binary file not shown.
4
static/goeasy-1.0.17.js
Normal file
4
static/goeasy-1.0.17.js
Normal file
File diff suppressed because one or more lines are too long
BIN
static/image/shop/10.png
Normal file
BIN
static/image/shop/10.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
static/image/shop/11.png
Normal file
BIN
static/image/shop/11.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
static/image/shop/12.png
Normal file
BIN
static/image/shop/12.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
static/image/shop/13.png
Normal file
BIN
static/image/shop/13.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
static/image/shop/8.png
Normal file
BIN
static/image/shop/8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
static/image/shop/9.png
Normal file
BIN
static/image/shop/9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
512
static/imservice.js
Normal file
512
static/imservice.js
Normal file
@ -0,0 +1,512 @@
|
||||
/*
|
||||
* @Author: jack.lu
|
||||
* @Date: 2020-4-21 10:10:20
|
||||
* @Last Modified by: jack.lu
|
||||
* @Last Modified time: 2020-4-21 15:01:41
|
||||
*/
|
||||
|
||||
import GoEasyIM from './goeasy-im-1.0.9';
|
||||
import restApi from './restapi';
|
||||
|
||||
function Friend(uuid, name, avatar) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.avatar = avatar;
|
||||
this.online = false;
|
||||
this.unReadMessage = 0;
|
||||
this.text = "";
|
||||
this.time = "";
|
||||
}
|
||||
|
||||
function Group(uuid, name, avatar) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.avatar = avatar;
|
||||
this.unReadMessage = 0;
|
||||
}
|
||||
|
||||
function CurrentUser(uuid, name, avatar) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
function IMService() {
|
||||
this.im = GoEasyIM.getInstance({
|
||||
host:'hangzhou.goeasy.io',//qos=1
|
||||
appkey:'BC-453aa755c4ea48148abefc55a86df283'
|
||||
});
|
||||
//当前“我”
|
||||
this.currentUser = null;
|
||||
//我的好友
|
||||
this.friends = {};
|
||||
//我的群
|
||||
this.groups = {};
|
||||
//私聊消息记录,map格式,每个好友对应一个数组
|
||||
this.privateMessages = {};
|
||||
|
||||
//群聊消息记录,map格式,每个群对应一个数组
|
||||
this.groupMessages = {};
|
||||
|
||||
/*
|
||||
* 监听器们
|
||||
*
|
||||
* 可以在页面里,根据需求,重写以下监听器,
|
||||
* 便于当各种事件触发时,页面能够执行对应的响应
|
||||
*
|
||||
*/
|
||||
//收到一条私聊消息
|
||||
this.onNewPrivateMessageReceive = function (friendId, message) {};
|
||||
//完成一次私聊历史加载
|
||||
this.onPrivateHistoryLoad = function (friendId, messages) {};
|
||||
//收到一条群聊消息
|
||||
this.onNewGroupMessageReceive = function (groupId, message) {};
|
||||
//完成一次群聊历史加载
|
||||
this.onGroupHistoryLoad = function (groupId, messages) {};
|
||||
//好友列表发生改变
|
||||
this.onFriendListChange = function (friends) {};
|
||||
//群列表发生改变
|
||||
this.onGroupListChange = function (groups) {};
|
||||
}
|
||||
|
||||
//登录
|
||||
IMService.prototype.login = function (uuid, name, avatar) {
|
||||
//初始化当前用户
|
||||
this.currentUser = new CurrentUser(uuid, name, avatar);
|
||||
//初始化联系人信息,包括群
|
||||
// this.initialContacts();
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
//初始化联系人信息
|
||||
IMService.prototype.initialContacts = function (friendList) {
|
||||
//查询并初始化好友信息
|
||||
// let friendList = restApi.findFriends(this.currentUser);
|
||||
|
||||
//将用户列表初始化为一个map,便于后续根据friendId得到friend
|
||||
friendList.map(friend => {
|
||||
this.friends[friend.uuid] = new Friend(friend.uuid, friend.name, friend.avatar);
|
||||
});
|
||||
|
||||
//查询并初始化与自己相关的群信息
|
||||
// let groupList = restApi.findGroups(this.currentUser);
|
||||
|
||||
// //将群列表初始化为一个map,方便后续根据groupId索引
|
||||
// groupList.map(group => {
|
||||
// this.groups[group.uuid] = new Group(group.uuid, group.name, group.avatar);
|
||||
// });
|
||||
};
|
||||
|
||||
//获取群成员
|
||||
IMService.prototype.getGroupMembers = function (groupId) {
|
||||
let members = restApi.findGroupMembers(groupId);
|
||||
let membersMap = {};
|
||||
members.map(item => {
|
||||
membersMap[item.uuid] = item
|
||||
});
|
||||
return membersMap;
|
||||
};
|
||||
|
||||
IMService.prototype.getGroupMessages = function (groupId) {
|
||||
if (!this.groupMessages[groupId]) {
|
||||
this.groupMessages[groupId] = {
|
||||
sentMessages:[],
|
||||
pendingMessages:[]
|
||||
};
|
||||
}
|
||||
return this.groupMessages[groupId]
|
||||
};
|
||||
|
||||
|
||||
IMService.prototype.getPrivateMessages = function (friendId) {
|
||||
if (!this.privateMessages[friendId]) {
|
||||
this.privateMessages[friendId] = {
|
||||
sentMessages:[],
|
||||
pendingMessages:[]
|
||||
};
|
||||
}
|
||||
return this.privateMessages[friendId]
|
||||
};
|
||||
|
||||
//重置群聊未读消息
|
||||
IMService.prototype.resetGroupUnReadMessage = function (group) {
|
||||
this.groups[group.uuid].unReadMessage = 0;
|
||||
this.onGroupListChange(this.groups);
|
||||
};
|
||||
|
||||
//将好友的未读消息数字清零
|
||||
IMService.prototype.resetFriendUnReadMessage = function (friend) {
|
||||
if(friend && friend.uuid){
|
||||
this.friends[friend.uuid].unReadMessage = 0;
|
||||
}
|
||||
this.onFriendListChange(this.friends);
|
||||
};
|
||||
|
||||
//连接GoEasy
|
||||
IMService.prototype.connectIM = function () {
|
||||
//初始化IM相关的监听器
|
||||
try {
|
||||
this.initialIMListeners();
|
||||
|
||||
} catch (error) {
|
||||
console.log(123)
|
||||
}
|
||||
try {
|
||||
this.im.connect({
|
||||
id: this.currentUser.uuid,
|
||||
data: {
|
||||
avatar: this.currentUser.avatar,
|
||||
name: this.currentUser.name
|
||||
}
|
||||
}).then(() => {
|
||||
console.log('连接成功')
|
||||
//订阅与自己相关的群信息
|
||||
this.subscribeGroupMessage();
|
||||
//初始化好友们的在线状态
|
||||
this.initialFriendOnlineStatus();
|
||||
//订阅我的好友们的上下线信息
|
||||
this.subscribeFriendsPresence();
|
||||
}).catch(error => {
|
||||
console.log('连接失败,请确保网络正常,appkey和host正确,code:' + error.code + " content:" + error.content);
|
||||
this.connectIM()
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(12323)
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//IM监听
|
||||
IMService.prototype.initialIMListeners = function () {
|
||||
this.im.on(GoEasyIM.EVENT.CONNECTED, () => {
|
||||
console.log('连接成功.')
|
||||
});
|
||||
|
||||
this.im.on(GoEasyIM.EVENT.DISCONNECTED, () => {
|
||||
console.log('连接断开.')
|
||||
});
|
||||
|
||||
//监听好友上下线
|
||||
this.im.on(GoEasyIM.EVENT.USER_PRESENCE, (user) => {
|
||||
console.log(user)
|
||||
//更新好友在线状态
|
||||
let onlineStatus = user.action == 'online' ? true : false;
|
||||
let friend = this.friends[user.userId];
|
||||
friend.online = onlineStatus;
|
||||
|
||||
//如果页面传入了相应的listener,执行listener
|
||||
this.onFriendListChange(this.friends);
|
||||
});
|
||||
|
||||
//监听私聊消息
|
||||
this.im.on(GoEasyIM.EVENT.PRIVATE_MESSAGE_RECEIVED, (message) => {
|
||||
console.log(message)
|
||||
//如果不是自己发的,朋友未读消息数 +1
|
||||
if (message.senderId != this.currentUser.uuid) {
|
||||
let friend = this.friends[message.senderId];
|
||||
console.log(friend)
|
||||
// return ;
|
||||
let that = this
|
||||
if(!friend && friend == undefined){
|
||||
const token = uni.getStorageSync('token');
|
||||
console.log(token)
|
||||
uni.request({
|
||||
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
|
||||
data:{
|
||||
userId:message.senderId
|
||||
},
|
||||
method:"POST",
|
||||
header:{
|
||||
"Authorization" : 'Bearer' + " " + token
|
||||
},
|
||||
success(res){
|
||||
console.log(res)
|
||||
that.friends[message.senderId] = new Friend(res.data.data.member_id, res.data.data.member_nickname, res.data.data.member_avatar);
|
||||
friend = that.friends[message.senderId];
|
||||
console.log(friend)
|
||||
friend.unReadMessage++;
|
||||
friend.text = message.type != "text" ? "其他消息" : message.payload.text
|
||||
let time = new Date(message.timestamp)
|
||||
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
|
||||
that.onFriendListChange(that.friends);
|
||||
console.log(that.friends)
|
||||
}
|
||||
})
|
||||
}else{
|
||||
console.log(friend)
|
||||
friend.unReadMessage++;
|
||||
friend.text = message.type != "text" ? "其他消息" : message.payload.text
|
||||
let time = new Date(message.timestamp)
|
||||
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
|
||||
this.onFriendListChange(this.friends);
|
||||
console.log(this.friends)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//更新私聊消息记录
|
||||
let friendId;
|
||||
if (this.currentUser.uuid == message.senderId) {
|
||||
friendId = message.receiverId;
|
||||
} else {
|
||||
friendId = message.senderId;
|
||||
}
|
||||
removePrivatePendingMessage(this, friendId, message);
|
||||
|
||||
let friendMessages = this.getPrivateMessages(friendId);
|
||||
friendMessages.sentMessages.push(message);
|
||||
|
||||
//如果页面传入了相应的listener,执行listener
|
||||
this.onNewPrivateMessageReceive(friendId, message);
|
||||
});
|
||||
|
||||
//监听群聊消息
|
||||
this.im.on(GoEasyIM.EVENT.GROUP_MESSAGE_RECEIVED, (message) => {
|
||||
let groupId = message.groupId;
|
||||
//群未读消息+1
|
||||
let group = this.groups[groupId];
|
||||
group.unReadMessage++;
|
||||
removeGroupPendingMessage(this, groupId, message);
|
||||
//如果页面传入了相应的listener,执行listener
|
||||
this.onGroupListChange(this.groups);
|
||||
|
||||
//更新群聊消息记录
|
||||
let groupMessages = this.getGroupMessages(groupId);
|
||||
let sentMessages = groupMessages.sentMessages;
|
||||
sentMessages.push(message);
|
||||
//如果页面传入了相应的listener,执行listener
|
||||
this.onNewGroupMessageReceive(groupId, message);
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
//订阅群消息
|
||||
IMService.prototype.subscribeGroupMessage = function () {
|
||||
let groupIds = Object.keys(this.groups);
|
||||
this.im.subscribeGroup(groupIds)
|
||||
.then(() => {
|
||||
console.log('订阅群消息成功')
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('订阅群消息失败')
|
||||
console.log(error)
|
||||
})
|
||||
};
|
||||
|
||||
//初始化好友在线状态
|
||||
IMService.prototype.initialFriendOnlineStatus = function () {
|
||||
let friendIds = Object.keys(this.friends);
|
||||
this.im.hereNow({
|
||||
userIds: friendIds
|
||||
}).then(result => {
|
||||
let onlineFriends = result.content;
|
||||
onlineFriends.map(user => {
|
||||
let friend = this.friends[user.userId];
|
||||
friend.online = true;
|
||||
});
|
||||
this.onFriendListChange(this.friends);
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
if (error.code == 401) {
|
||||
console.log("获取在线用户失败,您尚未开通用户在线状态,请登录GoEasy,查看应用详情里自助启用.");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
//监听所有好友上下线
|
||||
IMService.prototype.subscribeFriendsPresence = function () {
|
||||
let friendIds = Object.keys(this.friends);
|
||||
this.im.subscribeUserPresence(friendIds)
|
||||
.then(() => {
|
||||
console.log('监听好友上下线成功')
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
if (error.code == 401) {
|
||||
console.log("监听好友上下线失败,您尚未开通用户状态提醒,请登录GoEasy,查看应用详情里自助启用.");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//加载单聊历史消息
|
||||
IMService.prototype.loadPrivateHistoryMessage = function (friendId, timeStamp) {
|
||||
this.im.history({
|
||||
friendId: friendId,
|
||||
lastTimestamp: timeStamp
|
||||
}).then(result => {
|
||||
let history = result.content;
|
||||
let privateMessages = this.getPrivateMessages(friendId);
|
||||
let friendMessages = privateMessages.sentMessages;
|
||||
for (let i = history.length - 1; i >=0; i--) {
|
||||
friendMessages.unshift(history[i])
|
||||
}
|
||||
//如果页面传入了相应的listener,执行listener
|
||||
this.onPrivateHistoryLoad(friendId, history);
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
if (error.code == 401) {
|
||||
console.log("您尚未开通历史消息,请登录GoEasy,查看应用详情里自助启用.");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
//发送私聊消息
|
||||
IMService.prototype.sendPrivateTextMessage = function (friendId, text) {
|
||||
let textMessage = this.im.createTextMessage({
|
||||
text: text
|
||||
});
|
||||
this.sendPrivateMessage(friendId, textMessage);
|
||||
};
|
||||
|
||||
//私聊图片消息
|
||||
IMService.prototype.sendPrivateImageMessage = function (friendId, imageFile) {
|
||||
let imageMessage = this.im.createImageMessage({
|
||||
file: imageFile,
|
||||
onProgress :function (progress) {
|
||||
console.log(progress)
|
||||
}
|
||||
});
|
||||
this.sendPrivateMessage(friendId, imageMessage);
|
||||
};
|
||||
|
||||
//私聊视频消息
|
||||
IMService.prototype.sendPrivateVideoMessage = function (friendId, videoFile) {
|
||||
let videoMessage = this.im.createVideoMessage({
|
||||
file: videoFile,
|
||||
onProgress :function (progress) {
|
||||
console.log(progress)
|
||||
}
|
||||
});
|
||||
this.sendPrivateMessage(friendId, videoMessage);
|
||||
};
|
||||
|
||||
IMService.prototype.sendPrivateAudioMessage = function (friendId, audiofile) {
|
||||
let audioMessage = this.im.createAudioMessage({
|
||||
file: audiofile,
|
||||
onProgress :function (progress) {
|
||||
console.log(progress)
|
||||
}
|
||||
});
|
||||
|
||||
this.sendPrivateMessage(friendId, audioMessage);
|
||||
};
|
||||
|
||||
//发送私聊消息
|
||||
IMService.prototype.sendPrivateMessage = function (friendId, message) {
|
||||
|
||||
//加入pendingMessage列表,成功后将会被挪除
|
||||
let privateMessages = this.getPrivateMessages(friendId);
|
||||
privateMessages.pendingMessages.push(message);
|
||||
|
||||
//发送
|
||||
this.im.sendPrivateMessage(friendId, message)
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
})
|
||||
};
|
||||
|
||||
//发送群聊消息
|
||||
IMService.prototype.sendGroupTextMessage = function (groupId, message) {
|
||||
let textMessage = this.im.createTextMessage({
|
||||
text:message
|
||||
});
|
||||
this.sendGroupMessage(groupId, textMessage);
|
||||
};
|
||||
//私聊图片消息
|
||||
IMService.prototype.sendGroupImageMessage = function (groupId, imageFile) {
|
||||
let imageMessage = this.im.createImageMessage({
|
||||
file: imageFile,
|
||||
onProgress :function (progress) {
|
||||
console.log(progress)
|
||||
}
|
||||
});
|
||||
this.sendGroupMessage(groupId, imageMessage);
|
||||
};
|
||||
|
||||
|
||||
//私聊视频消息
|
||||
IMService.prototype.sendGroupVideoMessage = function (groupId, videoFile) {
|
||||
let videoMessage = this.im.createVideoMessage({
|
||||
file: videoFile,
|
||||
onProgress :function (progress) {
|
||||
console.log(progress)
|
||||
}
|
||||
});
|
||||
this.sendGroupMessage(groupId, videoMessage);
|
||||
};
|
||||
|
||||
IMService.prototype.sendGroupAudioMessage = function (groupId, audioFile) {
|
||||
let audioMessage = this.im.createAudioMessage({
|
||||
file: audioFile,
|
||||
onProgress :function (progress) {
|
||||
console.log(progress)
|
||||
}
|
||||
});
|
||||
this.sendGroupMessage(groupId, audioMessage);
|
||||
};
|
||||
|
||||
IMService.prototype.sendGroupMessage =function(groupId, groupMessage) {
|
||||
//先放入Pending列表,待成功后挪除
|
||||
let groupMessages = this.getGroupMessages(groupId);
|
||||
let pendingMessages = groupMessages.pendingMessages;
|
||||
pendingMessages.push(groupMessage)
|
||||
|
||||
this.im.sendGroupMessage(groupId, groupMessage)
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
})
|
||||
}
|
||||
|
||||
//群聊历史消息
|
||||
IMService.prototype.loadGroupHistoryMessage = function (groupId, timeStamp) {
|
||||
this.im.history({
|
||||
groupId: groupId,
|
||||
lastTimestamp: timeStamp
|
||||
}).then(result => {
|
||||
let history = result.content;
|
||||
let groupMessages = this.getGroupMessages(groupId);
|
||||
let sentGroupMessages = groupMessages.sentMessages;
|
||||
for (let i = history.length - 1; i >= 0; i--) {
|
||||
sentGroupMessages.unshift(history[i]);
|
||||
}
|
||||
this.onGroupHistoryLoad(groupId, history);
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
if (error.code == 401) {
|
||||
console.log("您尚未开通历史消息,请登录GoEasy,查看应用详情里自助启用.");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
IMService.prototype.disconnect = function () {
|
||||
this.im.disconnect()
|
||||
};
|
||||
|
||||
|
||||
function removePrivatePendingMessage(imService,friendId, message){
|
||||
let privateMessages = imService.getPrivateMessages(friendId);
|
||||
let pendingMessages = privateMessages.pendingMessages;
|
||||
let pendingMessageIndex = pendingMessages.findIndex(item => item.messageId == message.messageId);
|
||||
if(pendingMessageIndex > -1) {
|
||||
pendingMessages.splice(pendingMessageIndex,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function removeGroupPendingMessage(imService,groupId, message){
|
||||
let groupMessages = imService.getGroupMessages(groupId);
|
||||
let pendingMessages = groupMessages.pendingMessages;
|
||||
let pendingMessageIndex = pendingMessages.findIndex(item => item.messageId == message.messageId);
|
||||
if(pendingMessageIndex > -1) {
|
||||
pendingMessages.splice(pendingMessageIndex,1);
|
||||
}
|
||||
}
|
||||
|
||||
export default IMService;
|
79
static/restapi.js
Normal file
79
static/restapi.js
Normal file
@ -0,0 +1,79 @@
|
||||
//用户数据示例
|
||||
let users = [
|
||||
{
|
||||
"uuid": "08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a",
|
||||
"name": "Mattie",
|
||||
"password": "123",
|
||||
"avatar": '../../static/images/Avatar-1.png'
|
||||
},
|
||||
{
|
||||
"uuid": "3bb179af-bcc5-4fe0-9dac-c05688484649",
|
||||
"name": "Wallace",
|
||||
"password": "123",
|
||||
"avatar": '../../static/images/Avatar-2.png'
|
||||
},
|
||||
{
|
||||
"uuid": "fdee46b0-4b01-4590-bdba-6586d7617f95",
|
||||
"name": "Tracy",
|
||||
"password": "123",
|
||||
"avatar": '../../static/images/Avatar-3.png'
|
||||
},
|
||||
{
|
||||
"uuid": "33c3693b-dbb0-4bc9-99c6-fa77b9eb763f",
|
||||
"name": "Juanita",
|
||||
"password": "123",
|
||||
"avatar": '../../static/images/Avatar-4.png'
|
||||
}
|
||||
];
|
||||
|
||||
//群数据示例
|
||||
let groups = [
|
||||
{
|
||||
"uuid": "group-a42b-47b2-bb1e-15e0f5f9a19a",
|
||||
"name": "群1",
|
||||
"userList": ['08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a', '3bb179af-bcc5-4fe0-9dac-c05688484649', 'fdee46b0-4b01-4590-bdba-6586d7617f95', '33c3693b-dbb0-4bc9-99c6-fa77b9eb763f']
|
||||
},
|
||||
{
|
||||
"uuid": "group-4b01-4590-bdba-6586d7617f95",
|
||||
"name": "群2",
|
||||
"userList": ['08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a', 'fdee46b0-4b01-4590-bdba-6586d7617f95', '33c3693b-dbb0-4bc9-99c6-fa77b9eb763f']
|
||||
},
|
||||
{
|
||||
"uuid": "group-dbb0-4bc9-99c6-fa77b9eb763f",
|
||||
"name": "群3",
|
||||
"userList": ['08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a', '3bb179af-bcc5-4fe0-9dac-c05688484649']
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
function RestApi() {
|
||||
|
||||
}
|
||||
|
||||
RestApi.prototype.findFriends = function (user) {
|
||||
var friendList = users.filter(v => v.uuid != user.uuid);
|
||||
return friendList;
|
||||
}
|
||||
|
||||
RestApi.prototype.findGroups = function (user) {
|
||||
var groupList = groups.filter(v => v.userList.find(id => id == user.uuid));
|
||||
return groupList;
|
||||
}
|
||||
|
||||
RestApi.prototype.findUser = function (username, password) {
|
||||
var user = users.find(user => (user.name == username && user.password == password))
|
||||
return user;
|
||||
}
|
||||
|
||||
RestApi.prototype.findGroupMembers = function (groupId) {
|
||||
let members = [];
|
||||
let group = groups.find(v => v.uuid == groupId);
|
||||
users.map(user => {
|
||||
if (group.userList.find(v => v == user.uuid)) {
|
||||
members.push(user)
|
||||
}
|
||||
});
|
||||
return members;
|
||||
}
|
||||
|
||||
export default new RestApi();
|
Loading…
Reference in New Issue
Block a user