接口联调

version/0412
wangdong 7 months ago
parent acc7d61b8d
commit 9f8396ff9e
  1. 15
      api/feedback/index.js
  2. 24
      api/squareDynamic/index.js
  3. 6
      pages/activity/newPeople.vue
  4. 42
      pages/feedback/form.vue
  5. 99
      pages/feedback/list.vue
  6. 10
      pages/index/index.vue
  7. 7
      pages/shopList/certificate.vue
  8. 38
      pages/shopList/index.vue
  9. 235
      pages/shopList/shopPage.vue
  10. 117
      pages/squareDynamic/index.vue
  11. 20
      pages/squareDynamic/publish.vue
  12. 2
      project.config.json

@ -4,7 +4,9 @@ import request from '@/utils/request'
const api = {
list: 'user/getFeedBack',
shopList: 'store/getStore',
add:'user/addFeedback'
add:'user/addFeedback',
addFeedback: 'feedback/add',
getMyFeedback: 'feedback/list',
}
// 我的反馈列表
@ -20,3 +22,14 @@ export const shopList = (param, option) => {
export const add=(data)=> {
return request.post(api.add, data)
}
// 发布动态
export function addFeedback(param) {
return request.post(api.addFeedback, { ...param })
}
// 获取动态列表
export function getMyFeedback(param) {
return request.get(api.getMyFeedback, { ...param })
}

@ -0,0 +1,24 @@
import request from '@/utils/request'
// api地址
const api = {
publishDynamic: 'square/add',
getDynamic: 'square/list',
dynamicLike: 'square/dynamicLike'
}
// 发布动态
export function publishDynamic(param) {
return request.post(api.publishDynamic, { ...param })
}
// 获取动态列表
export function getDynamic(param) {
return request.get(api.getDynamic, { ...param })
}
// 动态点赞
export function dynamicLike(param) {
return request.post(api.dynamicLike, { ...param })
}

@ -79,7 +79,7 @@
isLoading: true,
background: {
background: 'url(https://www.royaum.com.cn/static/news/newPeople-bg.png) center top no-repeat',
backgroundSize: '200% auto',
backgroundSize: '500% auto',
},
goodList: [],
@ -208,12 +208,12 @@
padding: 100rpx 0;
}
.newpeople {
background: url(https://www.royaum.com.cn/static/news/newPeople-bg.png) center 24rpx no-repeat;
background: url(https://www.royaum.com.cn/static/news/newPeople-bg.png) center 88rpx no-repeat;
background-size: 100% auto;
overflow: hidden;
&-hd {
height: 288rpx;
height: 376rpx;
.rule {
right: 0;

@ -6,8 +6,8 @@
<text class="label-flag">*</text>问题类型
</view>
<view class="form-item-content">
<view v-for="(item, index) in typeList" class="type" @click="form.type = item">
<image v-if="form.type !== item" src="/static/feedback/circle.png" mode="aspectFill"></image>
<view v-for="(item, index) in typeList" :key="index" class="type" @click="form.type = index + 1">
<image v-if="form.type !== index + 1" src="/static/feedback/circle.png" mode="aspectFill"></image>
<image v-else src="/static/feedback/circle-choose.png" mode="aspectFill"></image>
{{ item }}
</view>
@ -27,7 +27,7 @@
<image :src="item" mode="aspectFill" @click="previewImage(item)"></image>
<image src="/static/delete.png" mode="aspectFill" class="delete" @click.stop="deleteImage(index)"></image>
</view>
<view v-if="form.images.length < 5" class="upload-btn">
<view v-if="form.images.length < 5" class="upload-btn" @click="addImage">
<image src="/static/feedback/photo.png" mode="aspectFill"></image>
<view class="tip">添加照片</view>
<view class="sub-tip">最多5张</view>
@ -58,6 +58,8 @@
</template>
<script>
import * as UploadApi from '@/api/upload'
import * as Api from '@/api/feedback/index.js'
export default {
data() {
return {
@ -71,11 +73,12 @@
type: '',
suggest: '',
images: [],
uploadImage: [],
uploadImages: [],
name: '',
phone: '',
unit: '',
}
},
loading: false,
};
},
methods: {
@ -102,7 +105,7 @@
UploadApi.image([path])
.then(fileIds => {
console.log(fileIds);
that.uploadImages.push(fileIds);
that.form.uploadImages.push(fileIds[0]);
resolve(fileIds)
})
.catch(reject)
@ -176,6 +179,30 @@
});
return false;
}
if (!this.loading) {
this.loading = true;
Api.addFeedback({
imgs: this.form.uploadImages.join(','),
type: this.form.type,
suggest: this.form.suggest,
name: this.form.name,
phone: this.form.phone,
unit: this.form.unit,
})
.then(res => {
console.log(res);
this.loading = false;
uni.showToast({
title: '添加成功!'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
})
.catch(() => {
this.loading = false;
})
}
},
},
};
@ -206,6 +233,7 @@
color: #333;
.textarea-box {
position: relative;
width: fit-content;
.text-num {
position: absolute;
right: 31rpx;
@ -312,7 +340,7 @@
.info-name {
margin-right: 40rpx;
}
uni-input {
input {
flex: 1;
}
.input-placeholder {

@ -4,15 +4,15 @@
<view v-for="(item, index) in list" :key="index" class="f-item">
<view class="f-top">
<view class="top-type">
<view class="type-info">您的反馈{{ item.type }}</view>
<view class="type-info">您的反馈{{ typeList[item.type - 1] }}</view>
<text :class="{ 'ing': item.status !== 1 }">{{ item.status === 1 ? '已完成' : '受理中' }}</text>
</view>
<view class="top-suggest">
<view class="suggest" :class="{'suggest-mask': !item.openSuggest }">
{{ item.suggest }}
<view v-if="!item.openSuggest" class="mask"></view>
<view v-if="!item.openSuggest && item.showSuggestBtn" class="mask"></view>
</view>
<view class="btn" @click="item.openSuggest = !item.openSuggest">
<view v-if="item.showSuggestBtn" class="btn" @click="item.openSuggest = !item.openSuggest">
{{ item.openSuggest ? '收起' : '展开' }}
<image src="/static/arrow-right.png" mode="aspectFill" :style="{ transform: `rotate(${item.openSuggest ? '-90deg': '90deg'})`}"></image>
</view>
@ -22,7 +22,7 @@
<view v-if="item.status === 1" class="f-bottom">
<view class="title">
处理结果
<view class="btn" @click="item.openResult = !item.openResult">
<view v-if="item.showResultBtn" class="btn" @click="item.openResult = !item.openResult">
{{ item.openResult ? '收起' : '展开' }}
<image src="/static/arrow-right.png" mode="aspectFill" :style="{ transform: `rotate(${item.openResult ? '-90deg': '90deg'})`}"></image>
</view>
@ -35,7 +35,7 @@
<view class="result-label">回复内容</view>
<view class="result-content" :class="{'result-mask': !item.openResult }">
{{ item.solveResult }}
<view v-if="!item.openResult" class="mask"></view>
<view v-if="!item.openResult && item.showResultBtn" class="mask"></view>
</view>
</view>
</view>
@ -49,33 +49,78 @@
</template>
<script>
import * as Api from '@/api/feedback/index.js'
export default {
data() {
return {
typeList: [
'功能异常:系统功能异常或不可用',
'系统建议:用的不爽,我有建议',
'功能新增:我想用的功能,希望能开发新增',
'服务建议:服务商服务不到位,我有建议',
],
list: [
{
type: '系统功能异常或不可用',
suggest: '点击退款按钮,系统一直转圈,没有反应,请尽快修复解决,另外,系统上能否对接更多好资源。有时候系统打开会显示一直在加载中,不知道是什么原因有时候又没有这个情况。',
create_time: '2024-04-01 20:22:31',
status: 0,
solveTime: '2024-04-01 20:22:31',
solveResult: '您好,您反馈的系统问题,我们已经修复,请您删除下小程序,再重新搜索进入小程序即可。供应链系统资源我们-直都在努力对接中,感谢您',
openSuggest: false,
openResult: false,
},
{
type: '系统功能异常或不可用系统功能异常或不可用系统功能异常或不可用',
suggest: '点击退款按钮,系统一直转圈,没有反应,请尽快修复解决,另外,系统上能否对接更多好资源。有时候系统打开会显示一直在加载中,不知道是什么原因有时候又没有这个情况。',
create_time: '2024-04-01 20:22:31',
status: 1,
solveTime: '2024-04-01 20:22:31',
solveResult: '您好,您反馈的系统问题,我们已经修复,请您删除下小程序,再重新搜索进入小程序即可。供应链系统资源我们-直都在努力对接中,感谢您',
openSuggest: false,
openResult: false,
}
// {
// type: '',
// suggest: '退',
// create_time: '2024-04-01 20:22:31',
// status: 0,
// solveTime: '2024-04-01 20:22:31',
// solveResult: '-',
// openSuggest: false,
// openResult: false,
// },
// {
// type: '',
// suggest: '退',
// create_time: '2024-04-01 20:22:31',
// status: 1,
// solveTime: '2024-04-01 20:22:31',
// solveResult: '-',
// openSuggest: false,
// openResult: false,
// }
],
loading: false,
};
},
mounted() {
this.getMyFeedback();
},
methods: {
async getMyFeedback() {
if (this.loading) {
return;
}
this.loading = true;
Api.getMyFeedback({})
.then(result => {
console.log(result);
const data = result.data.data;
this.list = [...data]
// this.list = this.list.concat(data);
for (const item of this.list) {
item.openSuggest = false;
item.openResult = false;
item.showSuggestBtn = this.calcContentWidth(item.suggest);
item.showResultBtn = this.calcContentWidth(item.solveResult);
}
})
.finally(() => this.loading = false)
},
calcContentWidth(cont) {
let len = 0;
let spliti = 0;
for (var i = 0; i < cont.length; i++) {
if (cont.charCodeAt(i) > 255 || cont.charCodeAt(i<0)) {
len += 17;
} else {
len += 10;
}
}
return len > 816;
},
},
};
</script>
@ -91,12 +136,13 @@
.top-type {
display: flex;
margin-bottom: 27rpx;
justify-content: space-between;
.type-info {
color: #333333;
font-size: 30rpx;
width: calc(100% - 130rpx);
}
uni-text {
text {
width: 90rpx;
height: 40rpx;
background: #EFFBF7;
@ -128,6 +174,7 @@
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
width: 100%;
}
.mask {
position: absolute;

@ -618,6 +618,12 @@
path: '/pages/squareDynamic/index',
type: 2
},
{
image: `${this.$picUrl}/static/index/g5.png?n=` + new Date().getTime(),
text: "意见反馈",
path: '/pages/feedback/index',
type: 2
},
],
catagoryList: [],
paihangList: [],
@ -682,8 +688,8 @@
data
} = await GoodsApi.wxAppStyle({});
if (status == 200) {
console.log(data);
uni.setStorageSync('styleIndex', data.detail || '');
console.log(data, data.style.style);
uni.setStorageSync('styleIndex', data.style.style || '');
}
},
onChangeSeckillCutDownTime(e) {

@ -14,7 +14,7 @@
export default {
data() {
return {
cerList: ['', '', '', '', '']
cerList: []
};
},
onLoad({ id }) {
@ -28,6 +28,11 @@
})
.then(result => {
console.log(result);
const arr = [];
for (const image of result.data.detail.licenseImg) {
arr.push(image.external_url);
}
this.cerList = [...arr];
})
.finally(() => this.loading = false)
},

@ -3,19 +3,19 @@
<view class="form" :style="{ 'background-color': navBgColor }">
<view class="left flex-center-x">
<image :src="$picUrl+'/static/home/search.png'" mode="" class="searchIcon"></image>
<input v-model.trim="search" confirm-type="search" @input="onSearch(search)" placeholder="搜索商" />
<input v-model.trim="search" confirm-type="search" @input="onSearch(search)" placeholder="搜索商" />
</view>
<!-- <image src="@/static/position.png" mode="aspectFill" class="position"></image> -->
</view>
<view class="filter-box">
<view v-for="(item, index) in filterItems" :key="index" class="filter-item" :class="{active: activeFilter === item}">{{ item }}</view>
<view v-for="(item, index) in filterItems" :key="index" class="filter-item" :class="{active: activeFilter === item.key}" @click="activeFilter = item.key">{{ item.name }}</view>
<!-- <view class="filter-item">
筛选
<image src="@/static/filter.png" mode="aspectFill"></image>
</view> -->
</view>
<view class="list">
<view v-for="(item, index) in shopsList" class="shop-item">
<view v-for="(item, index) in shopsList" :key="index" class="shop-item">
<view class="shop-info">
<image :src="item.logoImage.external_url" mode="aspectFill" class="logo"></image>
<view class="info-box">
@ -30,10 +30,10 @@
</view>
<view class="toShop" @click="toShop(item)">进店</view>
</view>
<view v-if="item.goods && item.goods.length > 0" class="shop-goods-list">
<view v-for="(good, k) in item.goods" :key="k" class="good-item">
<image :src="good.pic" mode="aspectFill" class="good-pic"></image>
<view class="price">{{ good.price }}</view>
<view v-if="item.goodsInfo && item.goodsInfo.data && item.goodsInfo.data.length > 0" class="shop-goods-list">
<view v-for="(good, k) in item.goodsInfo.data" :key="k" class="good-item">
<image :src="good.goods_image" mode="aspectFill" class="good-pic"></image>
<view class="price">{{ good.goods_price_min }}</view>
</view>
</view>
</view>
@ -60,7 +60,7 @@
return {
search: '',
categoryId: '',
activeFilter: '默认',
activeFilter: '',
shopsList: [
// {
// logo: '',
@ -89,7 +89,11 @@
loadTitle: '',
loading: false,
finished: false,
filterItems: ['默认', '销量', '好评']
filterItems: [
{ name: '默认', key: ''},
{ name: '销量', key: 'sale'},
{ name: '好评', key: 'score'},
]
};
},
computed: {
@ -112,6 +116,12 @@
})
},
},
activeFilter() {
this.page = 1;
this.finished = false;
this.shopsList = [];
this.getshopsList();
},
},
onLoad() {
this.getshopsList();
@ -133,10 +143,10 @@
}
this.loadTitle = "";
Api.getShopList({
filter: this.activeFilter,
sort: this.activeFilter,
page: this.page++,
limit: this.limit,
keyword: this.search,
pageSize: this.limit,
search: this.search,
})
.then(result => {
console.log(result);
@ -272,6 +282,9 @@
font-size: 30rpx;
line-height: 40rpx;
// flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.label {
height: 40rpx;
@ -283,6 +296,7 @@
margin-left: 20rpx;
color: #FFFFFF;
font-size: 22rpx;
flex-shrink: 0;
}
}
.info-bottom {

@ -27,11 +27,11 @@
</view>
</view>
<view class="shop-info">
<image :src="shopDetail.logo" mode="aspectFill" class="logo"></image>
<image :src="shopDetail.logoImage && shopDetail.logoImage[0].external_url" mode="aspectFill" class="logo"></image>
<view class="info-box">
<view class="name">{{ shopDetail.name }}</view>
<view class="name">{{ shopDetail.shop_name }}</view>
<view class="intro">
<text class="label">{{ shopDetail.label }}</text>
<text class="label">{{ shopDetail.shop_label }}</text>
<view @click="toCer">
<image src="/static/cer.png" mode="aspectFill"></image>
证书
@ -39,10 +39,10 @@
</view>
</view>
</view>
<view class="shop-goods">
<view v-if="goodsCate.filter(v => v.name === firstCate)[0].children.length > 0" class="second-cate">
<view v-if="firstCate" class="shop-goods">
<view v-if="goodsCate.filter(v => v.category_id === firstCate)[0].children.length > 0" class="second-cate">
<scroll-view class="second-cate-tabs" scroll-x>
<view v-for="(item, index) in goodsCate.filter(v => v.name === firstCate)[0].children" :key="index" class="cate-item" :class="{active: secondCate === item.name}" @click="secondCate = item.name">
<view v-for="(item, index) in goodsCate.filter(v => v.category_id === firstCate)[0].children" :key="index" class="cate-item" :class="{active: secondCate === item.category_id}" @click="secondCate = item.category_id">
{{ item.name }}
</view>
</scroll-view>
@ -50,7 +50,7 @@
<view class="goods-content">
<view class="first-cate">
<scroll-view class="first-cate-tabs" scroll-y>
<view v-for="(item, index) in goodsCate" :key="index" class="cate-item" :class="{active: firstCate === item.name}" @click="firstCate = item.name;secondCate = '';">
<view v-for="(item, index) in goodsCate" :key="index" class="cate-item" :class="{active: firstCate === item.category_id}" @click="firstCate = item.category_id;secondCate = '';">
{{ item.name }}
</view>
</scroll-view>
@ -81,6 +81,9 @@
</view>
</view>
</view>
<view class="toCart" @click="toCart">
<image :src="$picUrl+'/static/tabbar/cart.png'"></image>
</view>
<view class="toTop" v-if="isTop" @click="openScrollTo()">
<image :src="$picUrl+'/static/toTop.png?=1'"></image>
</view>
@ -91,6 +94,8 @@
<script>
import styleColor from '../styleColor';
import * as Api from '@/api/shop/index';
import * as cstegory from '@/api/category'
import * as GoodsApi from '@/api/goods'
export default {
data() {
@ -113,8 +118,8 @@
{ id: 1, name: '电脑', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]},
{ id: 1, name: '冰箱', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]},
],
firstCate: '手机',
secondCate: '二级分类2',
firstCate: '',
secondCate: '',
activeFilter: '综合',
filterDirection: 'ASC',
filterList: ['综合', '价格', '折扣', '销量'],
@ -125,66 +130,66 @@
loading: false,
finished: true,
goods: [
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809,
},
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809,
},
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809,
},
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809
},
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809,
},
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809,
},
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809,
},
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809,
},
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809,
},
{
pic: '',
name: '小米耳机最新版小米耳机最新版',
price: 208.00,
originPrice: 809,
},
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809,
// },
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809,
// },
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809,
// },
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809
// },
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809,
// },
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809,
// },
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809,
// },
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809,
// },
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809,
// },
// {
// pic: '',
// name: '',
// price: 208.00,
// originPrice: 809,
// },
]
};
},
@ -197,6 +202,16 @@
// return this.styleIndex ? (styleColor.shopNavBgColor[this.styleIndex - 1] || '#FFA3B2') : '#FFA3B2'
// }
// },
watch: {
secondCate() {
console.log(this.secondCate);
this.goods = [];
this.page = 1;
this.loading = false;
this.finished = false;
this.getGoodsList();
},
},
onPageScroll(e) {
if (e.scrollTop <= 200) { // true
this.isTop = false
@ -207,6 +222,10 @@
onLoad({ id }) {
this.id = id;
this.getShopDetail()
this.getGoodsTypeList();
},
onReachBottom() {
this.getGoodsList();
},
methods: {
back() {
@ -242,9 +261,57 @@
})
.then(result => {
console.log(result);
this.shopDetail = result.data.detail;
})
.finally(() => this.loading = false)
},
getGoodsTypeList() {
const that = this;
return new Promise((resolve, reject) => {
cstegory.list({
// merchantId: this.id
})
.then(res => {
//
console.log(res, '分类数据')
that.goodsCate = res.data.list;
that.firstCate = res.data.list[0].category_id;
})
.catch(reject)
})
},
/**
* 获取商品列表
* @param {number} pageNo 页码
*/
getGoodsList() {
if (this.loading || this.finished) {
return;
}
this.loadTitle = "";
const param = {
sortType: this.activeFilter,
sortPrice: this.filterDirection === 'ASC' ? 1 : 0,
categoryId: this.secondCate,
// goodsName: app.options.search || '',
page: this.page++,
pageSize: 10
}
GoodsApi.list(param)
.then(result => {
//
const data = result.data.list.data;
console.log(data);
this.goods = this.goods.concat(data);
this.finished = data.length < 10;
this.loadTitle = this.finished ? "已全部加载完" : "上拉加载更多";
})
},
toCart() {
uni.switchTab({
url: '/pages/cart/index'
})
},
}
};
</script>
@ -312,6 +379,8 @@
}
.shop-info {
display: flex;
margin-top: 30rpx;
padding: 0 24rpx;
.logo {
width: 90rpx;
height: 90rpx;
@ -319,7 +388,6 @@
margin-right: 10rpx;
}
.info-box {
margin-top: 30rpx;
.name {
font-size: 30rpx;
color: #fff;
@ -543,12 +611,31 @@
}
}
}
.toCart {
position: fixed;
bottom: 170rpx;
right: 26rpx;
width: 80rpx;
height: 80rpx;
border-radius: 50%;
opacity: 1;
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
background: #F34A40;
image {
width: 60%;
height: 60%;
}
}
.toTop {
position: fixed;
bottom: 120rpx;
right: 16rpx;
width: 99rpx;
height: 99rpx;
bottom: 65rpx;
right: 26rpx;
width: 80rpx;
height: 80rpx;
border-radius: 50%;
opacity: 1;
z-index: 999;

@ -10,30 +10,30 @@
<view class="list">
<view v-for="(item, index) in dynamicList" :key="index" class="dynamic-item">
<view class="user">
<image v-if="item.avatar" :src="item.avatar" mode="aspectFill"></image>
<image v-if="item.avatar_url && item.avatar_url[0]" :src="item.avatar_url[0].external_url" mode="aspectFill"></image>
<image v-else src="/static/touxiang.png" mode="aspectFill"></image>
<view class="user-info">
<view class="name">{{ item.name }}</view>
<view class="time">{{ item.time }}</view>
<view class="name">{{ item.real_name }}</view>
<view class="time">{{ item.update_time }}</view>
</view>
</view>
<view class="cont">
{{ showFullCont.includes(index) ? item.content : calcContentWidth(item.content).splitStr }}
<view v-if="!showFullCont.includes(index) && calcContentWidth(item.content).isSplit" class="show-more" @click="showFullCont.push(index)">全文</view>
</view>
<view v-if="item.pic && item.pic.length > 0" class="pic-list">
<image v-for="(pic, k) in item.pic" :key="k" :src="pic" mode="aspectFill"></image>
<view v-if="item.imgs && item.imgs.length > 0" class="pic-list">
<image v-for="(pic, k) in item.imgs" :key="k" :src="pic.external_url" mode="aspectFill"></image>
</view>
<view class="btns">
<view class="btn" v-if="item.content" @click="clipCont(item.content)">
<image src="/static/copy.png" mode="aspectFill"></image>
<view>复制文案</view>
</view>
<view class="btn" v-if="item.pic && item.pic.length > 0" @click="downloadMultipleImages(item.pic)">
<view class="btn" v-if="item.imgs && item.imgs.length > 0" @click="downloadMultipleImages(item.pic)">
<image src="/static/download.png" mode="aspectFill"></image>
<view>下载图片</view>
</view>
<view class="btn" @click="togggleLike(item.id)">
<view class="btn" @click="togggleLike(item, index)">
<image v-if="!item.isLike" src="/static/nolike.png" mode="aspectFill"></image>
<image v-else src="/static/like.png" mode="aspectFill"></image>
<view>{{ item.likeNum }}</view>
@ -55,30 +55,32 @@
</template>
<script>
import * as Api from '@/api/squareDynamic/index.js'
export default {
data() {
return {
tabList: ['推荐', '精选', '晒单', '日常', '文章'],
activeTab: '推荐',
dynamicList: [
{
avatar: '',
name: '幽默的先生',
time: '11:23',
content: '今天天气真好啊!碧蓝的天空,绿油油的油菜花,空 中飘香,远远的山脉看着忽远忽近。',
pic: ['', '', '', '', ''],
likeNum: 1000,
isLike: true,
},
{
avatar: '',
name: '幽默的先生',
time: '4月12日 11:21',
content: '今天天气真好啊!碧蓝的天空,绿油油的油菜花,空 中飘香,远远的山脉看着忽远忽近。远远的山脉看着忽远忽近。远远的山脉看着忽远忽近。远远的山脉看着忽远忽近。远远的山脉看着忽远忽近。',
pic: ['', '', '', '', ''],
likeNum: 1000,
isLike: false,
},
// {
// avatar: '',
// name: '',
// time: '11:23',
// content: '绿 ',
// pic: ['', '', '', '', ''],
// likeNum: 1000,
// isLike: true,
// },
// {
// avatar: '',
// name: '',
// time: '412 11:21',
// content: '绿 ',
// pic: ['', '', '', '', ''],
// likeNum: 1000,
// isLike: false,
// },
],
page: 1,
limit: 10,
@ -88,30 +90,60 @@
showFullCont: [],
};
},
watch: {
activeTab() {
this.loading = false;
this.finished = false;
this.page = 1;
this.getDynamicList();
},
},
onLoad() {
uni.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: '#E7F1FC',
})
});
console.log(this.dynamicList, this.dynamicList[0]);
this.getDynamicList();
},
methods: {
async getDynamicList() {
if (this.loading || this.finished) {
return;
}
this.loadTitle = "";
Api.getDynamic({
cate: this.activeTab,
page: this.page++,
pageSize: this.limit,
})
.then(result => {
console.log(result);
const data = result.data.data;
this.dynamicList = this.dynamicList.concat(data);
this.finished = data.length < this.limit;
this.loadTitle = this.finished ? "已全部加载完" : "上拉加载更多";
})
.finally(() => this.loading = false)
},
calcContentWidth(cont) {
let len = 0;
let spliti = 0;
for (var i = 0; i < cont.length; i++) {
if (cont.charCodeAt(i) > 255 || cont.charCodeAt(i<0)) {
len += 2;
const code = cont.charCodeAt(i);
if (cont.charCodeAt(i) > 255 || cont.charCodeAt(i) < 0) {
len += 17;
} else {
len ++;
len += 10;
}
if (len > 84 && spliti === 0) {
if (len > 714 && spliti === 0) {
spliti = i;
}
}
console.log(cont, spliti, len);
console.log(cont, cont.length, spliti, len);
return {
isSplit: len > 88,
splitStr: len > 88 ? `${cont.split('').splice(0, spliti).join('')}...` : cont,
isSplit: len > 748,
splitStr: len > 714 ? `${cont.split('').splice(0, spliti).join('')}...` : cont,
};
},
clipCont(cont) {
@ -144,8 +176,22 @@
  })
  return Promise.all(tasks)
},
togggleLike() {
togggleLike(item, index) {
Api.dynamicLike({
id: item.square_id,
})
.then(res => {
if (item.isLike) {
item.isLike = false;
item.likeNum -= 1;
} else {
item.isLike = true;
item.likeNum += 1;
}
})
.catch((e) => {
console.log(e);
})
},
publish() {
uni.navigateTo({
@ -240,6 +286,7 @@
line-height: 40rpx;
position: relative;
color: #222222;
word-break: break-word;
.show-more {
position: absolute;
right: 10rpx;

@ -41,6 +41,7 @@
<script>
import * as UploadApi from '@/api/upload'
import * as Api from '@/api/squareDynamic/index.js'
export default {
data() {
return {
@ -50,6 +51,7 @@ import * as UploadApi from '@/api/upload'
cateList: ['晒单', '日常', '文章'],
cateIndex: -1,
isPublish: false,
loading: false,
};
},
methods: {
@ -76,7 +78,7 @@ import * as UploadApi from '@/api/upload'
UploadApi.image([path])
.then(fileIds => {
console.log(fileIds);
that.uploadImages.push(fileIds);
that.uploadImages.push(fileIds[0]);
resolve(fileIds)
})
.catch(reject)
@ -113,6 +115,22 @@ import * as UploadApi from '@/api/upload'
});
return false;
}
if (!this.loading) {
this.loading = true;
Api.publishDynamic({
imgs: this.uploadImages.join(','),
content: this.content,
cate: this.cateList[this.cateIndex],
})
.then(res => {
console.log(res);
this.loading = false;
this.isPublish = true;
})
.catch(() => {
this.loading = false;
})
}
},
back() {
uni.navigateBack();

@ -1,5 +1,5 @@
{
"appid": "wx68d198de972a9e9d",
"appid": "wxe843b6d7a4bd3389",
"compileType": "miniprogram",
"libVersion": "3.3.3",
"packOptions": {

Loading…
Cancel
Save