dengjie commit : 我的页面部分接口

This commit is contained in:
clay
2023-01-05 21:57:51 +08:00
parent 2417d8fe28
commit 458f5a2562
17 changed files with 341 additions and 371 deletions

View File

@@ -1,6 +1,6 @@
<template>
<view class="my_avatar">
<view style="border: 1px solid #EEEEEE;border-radius: 50rpx;">
<view style="border-radius: 50rpx;">
<u-avatar :src="avatar" size="100rpx" shape="circle"></u-avatar>
</view>
<view style="margin-top: 10rpx;margin-bottom: 4rpx;">
@@ -10,12 +10,11 @@
</u--image>
</view>
<view style="display: flex;align-items: center;">
<text style="margin-right: 8rpx;">顾发航</text>
<text style="margin-right: 8rpx;">{{nickname}}</text>
<u--image v-if="showEdit==true" src="/static/my/wd_icon_bj.png" width="22rpx" height="22rpx"
@click="changeAvatar()">
</u--image>
</view>
</view>
</template>
@@ -32,7 +31,8 @@
return {
show: false,
showEdit: true,
avatar: 'https://cdn.uviewui.com/uview/album/2.jpg',
avatar: '',
nickname: '',
normal: '/static/my/wo_icon_pthy.png',
VIP: '/static/my/wo_icon_vip.png',
};
@@ -41,6 +41,8 @@
if (this.center != false) {
this.showEdit = false
}
this.avatar = uni.getStorageSync('avatar')
this.nickname = uni.getStorageSync('nickname')
},
methods: {
//修改头像
@@ -48,11 +50,7 @@
uni.navigateTo({
url: '../../packageMy/changeAvatar/changeAvatar'
})
}
},
}
}
</script>
<style>
</style>

View File

@@ -21,8 +21,8 @@
return {
model: {
userInfo: {
name: '',
phone: '',
name: '姓名',
phone: '2342233',
},
},
};

View File

@@ -48,9 +48,7 @@
created() {
this.getProducts()
this.imgUrl = uni.getStorageSync('img_url')
},
methods: {
//获取产品列表
getProducts() {

View File

@@ -0,0 +1,126 @@
<template>
<view>
<view class="products_box">
<u-grid :border="false" col="2">
<u-grid-item v-for="(item,index) in productList" :key="index">
<u-image src="/static/products/sy_bb.png" width="354rpx" height="539rpx" :lazy-load="true">
</u-image>
<view class="bgContent">
<view>
<u-image :src="imgUrl+item.cover" width="346rpx" height="320rpx" :lazy-load="true"
@click="toDetailPage()">
</u-image>
<view class="img_tag">{{item.cate_name}}</view>
</view>
<view style="padding: 14rpx 22rpx;">
<view class="title_box">
<text class="title">{{item.name}}</text>
<u-tag :text="item.tags" type="warning" shape="circle"></u-tag>
</view>
<view class="product_desc">
{{item.title}}
</view>
<view class="releaseDate">
<u-image src="/static/products/xp_icon_sjf.png" width="22rpx" height="22rpx"
:lazy-load="true">
</u-image>
<text class="release">发布日期</text>
<text>{{item.create_time}}</text>
</view>
</view>
</view>
<u-button v-if="type==1" type="success" text="移除" color="#0EBB5B" @click="showModal()"></u-button>
<u-button v-if="type==2" type="success" text="取消收藏" color="#0EBB5B"></u-button>
</u-grid-item>
</u-grid>
<u-modal :show="showM" :content="content" showCancelButton closeOnClickOverlay @confirm="confirm"
@cancel="cancel" @close="close">
</u-modal>
<view style="font-size: 24rpx;color: #A3A3A3;text-align: center;padding: 26rpx 0;"
v-if="type==1&&productList.length==0">
暂无更多浏览记录</view>
<view style="font-size: 24rpx;color: #A3A3A3;text-align: center;padding: 26rpx 0;"
v-if="type==2&&productList.length==0">
暂无更多收藏记录</view>
</view>
</view>
</template>
<script>
import {
dateFormatHistory
} from '../../utills/date.js'
export default {
data() {
return {
productId: '',
imgUrl: '',
tagsArray: [],
productList: [],
showM: false,
content: '您确定移除吗?',
productList: []
}
},
props: {
type: String
},
created() {
this.getHistoryOrCollection()
this.imgUrl = uni.getStorageSync('img_url')
},
methods: {
//获取历史记录
getHistoryOrCollection() {
this.$apiServe.getHistoryOrCollection(this.type).then(res => {
let data = res.data.data
for (const item of data) {
let tag = item.tags
this.tagsArray = tag.split(',')
item.tags = this.tagsArray[0]
item.create_time = dateFormatHistory(item.create_time)
}
// console.log('获取历史记录', res.data);
this.productId = data.id
this.productList = data
}).finally(_ => {
})
},
//移除按钮
showModal() {
this.showM = true
},
confirm() {
this.showM = false
console.log('删除成功');
// this.$apiServe.deleteHistoryOrCollection(this.productId).then(res => {
// console.log('删除历史记录或收藏', res);
// this.getHistoryOrCollection()
// }).finally(_ => {})
},
cancel() {
this.showM = false
},
close() {
this.showM = false
}
}
}
</script>
<style lang="scss">
.u-modal__content {
padding: 43rpx 104rpx !important;
text-indent: 25rpx;
}
.u-button {
width: 150rpx !important;
height: 50rpx !important;
background: #0EBB5B;
border-radius: 10rpx !important;
margin-top: 22rpx;
margin-bottom: 50rpx;
}
</style>

View File

@@ -0,0 +1,43 @@
<template>
<view>
<myForm ref="nameAndphone"></myForm>
<u-button type="success" text="确定" color="#0EBB5B" @click="handleSureClick()"></u-button>
</view>
</template>
<script>
export default {
data() {
return {
name: '',
phone: '',
}
},
onLoad() {
this.name = this.$refs.nameAndphone.model.userInfo.name
this.phone = this.$refs.nameAndphone.model.userInfo.phone
},
methods: {
handleSureClick() {
this.$apiServe.bindComponyAndUpdate({
uid: 1,
type: 1,
companyPhone: this.phone,
companyName: this.name
}).then(res => {
// console.log('绑定公司', res);
}).finally(_ => {})
}
}
}
</script>
<style lang="scss">
.u-button {
width: 644rpx !important;
height: 86rpx !important;
background: #0EBB5B;
border-radius: 20rpx !important;
margin-top: 168rpx;
}
</style>

View File

@@ -1,29 +0,0 @@
<template>
<view>
<myForm></myForm>
<u-button type="success" text="确定" color="#0EBB5B"></u-button>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss">
.u-button {
width: 644rpx !important;
height: 86rpx !important;
background: #0EBB5B;
border-radius: 20rpx !important;
margin-top: 168rpx;
}
</style>

View File

@@ -1,43 +1,6 @@
<template>
<view>
<view class="products_box">
<u-grid :border="false" col="2">
<u-grid-item v-for="(item,index) in productList" :key="index">
<u-image src="/static/products/sy_bb.png" width="354rpx" height="539rpx" :lazy-load="true">
</u-image>
<view class="bgContent">
<view>
<u-image :src="item.src" width="346rpx" height="320rpx" :lazy-load="true"
@click="toDetailPage()">
</u-image>
<view class="img_tag">{{item.img_tag}}</view>
</view>
<view style="padding: 14rpx 22rpx;">
<view class="title_box">
<text class="title">{{item.title}}</text>
<u-tag :text="item.tag" type="warning" shape="circle"></u-tag>
</view>
<view class="product_desc">
{{item.desc}}
</view>
<view class="releaseDate">
<u-image src="/static/products/xp_icon_sjf.png" width="22rpx" height="22rpx"
:lazy-load="true">
</u-image>
<text class="release">发布日期</text>
<text>{{item.time}}</text>
</view>
</view>
</view>
<u-button v-if="type==1" type="success" text="移除" color="#0EBB5B" @click="showModal()"></u-button>
<u-button v-if="type==2" type="success" text="取消收藏" color="#0EBB5B"></u-button>
</u-grid-item>
</u-grid>
<u-modal :show="showM" :content="content" showCancelButton closeOnClickOverlay @confirm="confirm"
@cancel="cancel" @close="close">
</u-modal>
</view>
<productsBtn :type="1"></productsBtn>
</view>
</template>
@@ -45,202 +8,8 @@
export default {
data() {
return {
showM: false,
content: '您确定移除吗?',
type: '',
productList: [{
src: '/static/products/zhanwei_dg.png',
title: '锅巴',
tag: '无添加剂',
img_tag: '零食铺子',
desc: '糯米蟹黄锅巴散装,非油炸绿色健康食品',
time: '2022-12-04'
},
{
src: '/static/products/zhanwei_dg.png',
title: '干吃汤圆',
tag: '天然原料',
img_tag: '糕点卷酥',
desc: '休闲食品厂家甜品糯米食品零食闽南特产宵夜好吃糍粑',
time: '2022-12-04'
},
{
src: '/static/products/zhanwei_dg.png',
title: '紫薯魔芋人参魔芋人参魔芋人参…',
tag: '天然原料',
img_tag: '健康创新',
desc: '紫薯魔芋人参代餐粉 冲调饮品贴牌加工 五谷杂粮粉代餐',
time: '2022-12-04'
},
{
src: '/static/products/zhanwei_dg.png',
title: '焦糖饼干',
tag: '无防腐剂',
img_tag: '饼干曲奇',
desc: '比利时风味焦糖饼干代餐小吃零食品',
time: '2022-12-04'
}
]
}
},
onLoad(options) {
this.type = options.id
},
methods: {
//移除按钮
showModal() {
this.showM = true
},
confirm() {
},
cancel() {
this.showM = false
},
close() {
this.showM = false
type: ''
}
}
}
</script>
<style lang="scss">
.u-modal {
width: 472rpx !important;
}
.u-modal__button-group__wrapper--cancel {
background: #D8D8D8;
.u-modal__button-group__wrapper__text {
color: #fff !important;
}
}
.u-modal__content {
padding: 43rpx 104rpx !important;
text-indent: 25rpx;
}
.u-modal__content__text {
font-size: 32rpx !important;
font-weight: 400;
color: #252421 !important;
}
.u-modal__button-group__wrapper--confirm {
background: #0EBB5B;
.u-modal__button-group__wrapper__text {
color: #fff !important;
}
}
.u-button {
width: 150rpx !important;
height: 50rpx !important;
background: #0EBB5B;
border-radius: 10rpx !important;
margin-top: 22rpx;
margin-bottom: 50rpx;
}
.products_box {
padding: 10rpx;
.u-grid-item {
.bgContent {
position: absolute;
right: 0;
top: 0;
.u-image__image {
margin-left: 6px;
}
.img_tag {
position: absolute;
padding: 2rpx 8rpx;
right: 5px;
top: 30rpx;
border-radius: 54rpx 0px 0px 54rpx;
box-shadow: 0px 2rpx 4rpx 0px #078C42;
background: linear-gradient(135deg, #0DB658 0%, #16DD6D 100%);
font-size: 20rpx;
color: #FFFFFF;
line-height: 28rpx;
}
.title_box {
position: relative;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.title {
width: 186rpx;
font-size: 26rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: bold;
color: #0EBB5B;
line-height: 37rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.u-tag {
height: 26rpx;
line-height: 26rpx;
background: linear-gradient(124deg, #FEAA19 0%, #FDCF3A 100%);
.u-tag__text {
font-size: 20rpx;
}
}
}
.product_desc {
font-size: 22rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #3E3E3E;
line-height: 26rpx;
margin-top: 24rpx;
margin-bottom: 20rpx;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.releaseDate {
font-size: 22rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #A3A3A3;
line-height: 26rpx;
display: flex;
align-items: center;
padding-bottom: 25rpx;
image {
margin-left: 0;
}
.release {
padding: 0 10rpx 0 5rpx;
}
}
}
}
}
</style>

View File

@@ -4,7 +4,7 @@
<u--image src="/static/my/wo_icon_hyzxbj.png" width="750rpx" height="349rpx" :lazy-load="true">
</u--image>
<myAvatar :center="show"></myAvatar>
<myForm></myForm>
<myForm ref="nameAndphone"></myForm>
<view class="commitment">
{{commitment}}
</view>
@@ -20,6 +20,8 @@
export default {
data() {
return {
name: '',
phone: '',
showM: false,
//会员中心的用户名旁边不显示edit图标
show: false,
@@ -28,6 +30,10 @@
commitment: '承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置'
}
},
onLoad() {
this.name = this.$refs.nameAndphone.model.userInfo.name
this.phone = this.$refs.nameAndphone.model.userInfo.phone
},
methods: {
// 联系客服模态框
showModal() {
@@ -35,6 +41,14 @@
},
confirm() {
this.showM = false
this.$apiServe.bindComponyAndUpdate({
uid: 1,
type: 2,
companyPhone: this.phone,
companyName: this.name
}).then(res => {
console.log('升级VIP', res);
}).finally(_ => {})
},
cancel() {
this.showM = false
@@ -63,30 +77,10 @@
border-radius: 20rpx !important;
}
.u-modal {
width: 472rpx !important;
}
.u-modal__content {
padding: 43rpx 104rpx !important;
text-indent: 14rpx;
}
.u-modal__content__text {
font-size: 32rpx !important;
font-weight: 400;
color: #252421 !important;
}
.u-modal__button-group__wrapper--hover {
background: #0EBB5B !important;
}
.u-modal__button-group__wrapper--confirm {
background: #0EBB5B;
.u-modal__button-group__wrapper__text {
color: #fff !important;
}
}
</style>

View File

@@ -0,0 +1,15 @@
<template>
<view>
<productsBtn :type="2"></productsBtn>
</view>
</template>
<script>
export default {
data() {
return {
type: '',
}
}
}
</script>

View File

@@ -46,10 +46,9 @@
//获取认证厂家详情
getCertifiedCjDetail() {
this.$apiServe.getCertifiedCjDetail(this.id).then(res => {
console.log('认证厂家详情页', res.data.data)
// console.log('认证厂家详情页', res.data.data)
let data = res.data.data
data.images = data.images.split(';')
console.log('data.images', data.images);
this.detailList = data
}).finally(_ => {})
},

View File

@@ -68,7 +68,7 @@
"subPackages": [{
"root": "packageMy",
"pages": [{
"path": "bindCompony/bindCompony",
"path": "bindCompany/bindCompany",
"style": {
"navigationBarTitleText": "绑定公司",
"navigationBarTextStyle": "white",
@@ -108,6 +108,15 @@
"enablePullDownRefresh": false
}
}, {
"path": "myCollection/myCollection",
"style": {
"navigationBarTitleText": "我的收藏",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#12CA64",
"enablePullDownRefresh": false
}
}]
},
{

View File

@@ -3,16 +3,15 @@
<view :key="index">
<u-image :src="imgUrl+detailList.cover" width="750rpx" height="530rpx">
</u-image>
<view class="collect">
<view class="collect" @click="starTap">
<view class="star">
<u-image v-if="showStar==false" src="/static/detail/xp_icon_wstar.png" width="28rpx" height="28rpx"
@click="starTap">
<u-image v-if="detailList.type==0" src="/static/detail/xp_icon_wstar.png" width="28rpx"
height="28rpx">
</u-image>
<u-image v-if="showStar==true" src="/static/detail/xp_icon_star.png" width="28rpx" height="28rpx"
@click="starTap">
<u-image v-if="detailList.type==1" src="/static/detail/xp_icon_star.png" width="28rpx"
height="28rpx">
</u-image>
</view>
<u-image src="/static/detail/xiangqing_icon_shoucang.png" width="119rpx" height="48rpx">
</u-image>
</view>
@@ -32,20 +31,20 @@
<view>
<text class="tagOne" v-for="item in detailList.tags" :key="item.id">{{item}}</text>
</view>
<view v-if="isThumb==false" class="heart">
<u-image v-if="showHeart==false" src="/static/detail/xp_icon_heart.png" width="34rpx"
height="32rpx" @click="heartTap">
</u-image>
<u-image v-if="showHeart==true" src="/static/detail/xp_icon_ysc.png" width="34rpx"
height="32rpx" @click="heartTap">
</u-image>
<text class="thumb">点赞</text>
</view>
<view v-if="isThumb==true" class="heart">
<u-image src="/static/detail/xp_icon_ysc.png" width="34rpx" height="32rpx" @click="heartTap">
<view v-if="detailList.thumb" class="heart">
<u-image src="/static/detail/xp_icon_ysc.png" width="34rpx" height="32rpx">
</u-image>
<text class="thumb">{{detailList.thumb}}</text>
</view>
<view v-else class="heart" @click="heartTap">
<u-image v-if="showHeart==false" src="/static/detail/xp_icon_heart.png" width="34rpx"
height="32rpx">
</u-image>
<u-image v-if="showHeart==true" src="/static/detail/xp_icon_ysc.png" width="34rpx"
height="32rpx">
</u-image>
<text class="thumb">点赞</text>
</view>
</view>
</view>
@@ -71,9 +70,7 @@
id: '',
imgUrl: '',
tagsArray: [],
showStar: false,
showHeart: false,
isThumb: false,
detailList: []
}
},
@@ -86,7 +83,7 @@
//获取详情信息
getProductDetail() {
this.$apiServe.getProductDetail(this.id).then(res => {
// console.log('详情页', res.data.data)
console.log('详情页', res.data.data)
if (res.data.data.thumb) {
this.isThumb = true
}
@@ -100,7 +97,12 @@
},
//收藏按钮
starTap() {
this.showStar = !this.showStar
this.detailList.type = !this.detailList.type
// this.$apiServe.collect(this.id).then(res => {
// console.log('收藏成功', res.data)
// this.detailList.type = 1
// }).finally(_ => {})
},
//点赞按钮
heartTap() {

View File

@@ -78,7 +78,6 @@
this.getToken()
this.imgUrl = uni.getStorageSync('img_url')
},
methods: {
getToken() {
var that = this
@@ -89,15 +88,14 @@
const {
code
} = event
console.log("登录code", code);
let fromData = {
code: code
}
that.$apiServe.login({
code: code
}).then(res => {
console.log('登录code换取的用户', res.data.data);
uni.setStorageSync('token', res.data.data.token);
var data = res.data.data
// console.log('登录code换取的信息', data);
uni.setStorageSync('token', data.token);
uni.setStorageSync('avatar', data.avatar);
uni.setStorageSync('nickname', data.nickname);
})
},
fail: function(err) {

View File

@@ -24,27 +24,29 @@
</u-cell-group>
<u-modal :show="showM" showCancelButton closeOnClickOverlay confirmText="是" cancelText="否"
@confirm="confirm" @cancel="cancel" @close="close">
<rich-text :nodes="content"></rich-text>
<view>
<text>{{phone}}</text>
<text>是否拨打客服电话</text>
</view>
</u-modal>
</view>
</view>
</template>
<script>
import loginVue from './login/login.vue'
export default {
data() {
return {
showM: false,
content: `138 1222 222<br>
是否拨打客服电话`,
phone: '138 1222 222',
}
},
methods: {
//跳转到绑定公司页面
bindCompany() {
uni.navigateTo({
url: '../../packageMy/bindCompony/bindCompony'
url: '../../packageMy/bindCompany/bindCompany'
})
},
//跳转到会员中心页面
@@ -56,14 +58,13 @@
//跳转到浏览记录页面
toBrowseHistory() {
uni.navigateTo({
url: '../../packageMy/browseHistory/browseHistory?id=' + 1
url: '../../packageMy/browseHistory/browseHistory'
})
},
//跳转到我的收藏页面
toMyCollect() {
uni.navigateTo({
url: '../../packageMy/browseHistory/browseHistory?id=' + 2
url: '../../packageMy/myCollection/myCollection'
})
},
//跳转到我的发布页面
@@ -72,7 +73,6 @@
url: '../../packageMy/myRelease/myRelease'
})
},
// 联系客服模态框
showModal() {
this.showM = true
@@ -139,36 +139,10 @@
color: #CCCCCC !important;
}
.u-modal {
width: 472rpx !important;
}
.u-modal__button-group__wrapper--cancel {
background: #D8D8D8;
.u-modal__button-group__wrapper__text {
color: #fff !important;
}
}
.u-modal__content {
padding: 43rpx 104rpx !important;
text-indent: 25rpx;
}
.u-modal__content__text {
font-size: 32rpx !important;
font-weight: 400;
color: #252421 !important;
}
.u-modal__button-group__wrapper--confirm {
background: #0EBB5B;
.u-modal__button-group__wrapper__text {
color: #fff !important;
}
}
</style>

View File

@@ -116,7 +116,6 @@ const service = {
})
})
}
}
const toastDuration = 1500
const toast = {
@@ -223,7 +222,41 @@ const apiService = {
resolve(service.get(url, id))
})
},
//绑定公司和升级VIP
bindComponyAndUpdate(data) {
const url = `/center/update`
return new Promise((resolve, reject) => {
resolve(service.post(url, data))
})
},
//获取历史记录或收藏
getHistoryOrCollection(type) {
const url = `/center/favlist/?type=${type}`
return new Promise((resolve, reject) => {
resolve(service.get(url, type))
})
},
//删除历史记录或收藏
deleteHistoryOrCollection(id) {
const url = `/center/delfav/?id=${id}`
return new Promise((resolve, reject) => {
resolve(service.post(url, id))
})
},
//收藏按钮
collect(pid) {
const url = `/center/addfav/?pid=${pid}`
return new Promise((resolve, reject) => {
resolve(service.post(url, pid))
})
},
//点赞按钮
thumb(pid) {
const url = `/center/thumb/?pid=${pid}`
return new Promise((resolve, reject) => {
resolve(service.post(url, pid))
})
},
// 获取首页分类Tag
getTags(data) {
const url = `/home/tags`

View File

@@ -16,20 +16,46 @@
}
.my_avatar {
position: absolute;
right: 325rpx;
top: 152rpx;
margin-top: -200rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text {
font-size: 26rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
line-height: 37rpx;
}
}
// 头像后面的背景定位
.u-image {
position: static !important;
}
//模态框公共样式
.u-modal {
width: 472rpx !important;
}
.u-modal__content__text {
font-size: 32rpx !important;
font-weight: 400;
color: #252421 !important;
}
.u-modal__button-group__wrapper--confirm {
background: #0EBB5B;
.u-modal__button-group__wrapper__text {
color: #fff !important;
}
}
.u-modal__button-group__wrapper--cancel {
background: #D8D8D8;
.u-modal__button-group__wrapper__text {
color: #fff !important;
}
}

View File

@@ -41,8 +41,23 @@ function dateFormatXwDetail(time) {
return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
}
//时间戳转换为2022-12-03
function dateFormatHistory(time) {
time = time * 1000
let date = new Date(time);
let year = date.getFullYear();
// 在日期格式中月份是从0开始的因此要加0使用三元表达式在小于10的前面加0以达到格式统一 如 09:11:05
let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
// 拼接
return year + "-" + month + "-" + day;
}
module.exports = {
dateFormat,
dateFormatDetail,
dateFormatXwDetail
dateFormatXwDetail,
dateFormatHistory
}