全新UI视觉体验,移动端API优化降低重复调用,提高并发6倍,修复N多Bug

This commit is contained in:
stivepeim
2021-06-11 17:41:16 +08:00
parent 0b9f28fa52
commit b76840e10f
582 changed files with 35633 additions and 28276 deletions

View File

@@ -1,126 +1,135 @@
<template>
<view class="new-users">
<view class="head">
<view class="user-card">
<view class="new-users copy-data" :style="{height:pageHeight}">
<view class="mid" style="flex:1;overflow: hidden;">
<scroll-view scroll-y="true" style="height: 100%;">
<view class="bg"></view>
<view class="user-info">
<image class="avatar" :src='userInfo.avatar' v-if="userInfo.avatar" @click="goEdit()"></image>
<image v-else class="avatar" src="/static/images/f.png" mode="" @click="goEdit()"></image>
<view class="info">
<!-- #ifdef MP -->
<view class="name" v-if="!userInfo.uid" @tap="openAuto">
请点击授权
</view>
<!-- #endif -->
<!-- #ifdef H5 -->
<view class="name" v-if="!userInfo.uid && isWeixin" @tap="openAuto">
请点击授权
</view>
<!-- #endif -->
<view class="name" v-if="userInfo.uid">
{{userInfo.nickname}}
<view class="vip" v-if="userInfo.vip">
<image :src="userInfo.vipIcon" alt="">
<view style="margin-left: 10rpx;" class="vip-txt">{{userInfo.vipName || ''}}</view>
<view class="head pad30">
<view class="user-card">
<view class="user-info">
<image class="avatar" :src='userInfo.avatar' v-if="userInfo.avatar && uid"
@click="goEdit()"></image>
<image v-else class="avatar" src="/static/images/f.png" mode="" @click="goEdit()"></image>
<view class="info">
<view class="name" v-if="!uid" @tap="openAuto">
请点击登录
</view>
<view class="name" v-if="uid">
{{userInfo.nickname}}
<view class="vip" v-if="userInfo.vip">
<image :src="userInfo.vipIcon" alt="">
<view style="margin-left: 10rpx;" class="vip-txt">{{userInfo.vipName || ''}}
</view>
</view>
</view>
<view class="num" v-if="userInfo.phone && uid" @click="goEdit()">
<view class="num-txt">{{userInfo.phone}}</view>
<view class="icon">
<image src="/static/images/edit.png" mode=""></image>
</view>
</view>
<view class="phone" v-if="!userInfo.phone && isLogin" @tap="bindPhone">绑定手机号</view>
</view>
</view>
<view class="num" v-if="userInfo.phone" @click="goEdit()">
<view class="num-txt">{{userInfo.phone}}</view>
<view class="icon">
<image src="/static/images/edit.png" mode=""></image>
<view class="num-wrapper">
<view class="num-item" @click="goMenuPage('/pages/users/user_money/index')">
<text
class="num">{{userInfo.nowMoney && uid ?Number(userInfo.nowMoney).toFixed(2):0}}</text>
<view class="txt">余额</view>
</view>
<view class="num-item" @click="goMenuPage('/pages/users/user_integral/index')">
<text class="num">{{userInfo.integral && uid ? userInfo.integral: 0}}</text>
<view class="txt">积分</view>
</view>
<view class="num-item" @click="goMenuPage('/pages/users/user_coupon/index')">
<text class="num">{{userInfo.couponCount && uid ? userInfo.couponCount : 0}}</text>
<view class="txt">优惠券</view>
</view>
<view class="num-item" @click="goMenuPage('/pages/users/user_goods_collection/index')">
<text class="num">{{userInfo.collectCount && uid ? userInfo.collectCount : 0}}</text>
<view class="txt">收藏</view>
</view>
</view>
<view class="phone" v-if="!userInfo.phone && isLogin" @tap="bindPhone">绑定手机号</view>
<!-- <view class="sign" @click="goSignIn">签到</view> -->
</view>
<view class="order-wrapper">
<view class="order-hd flex">
<view class="left">订单中心</view>
<navigator class="right flex" hover-class="none" url="/pages/users/order_list/index"
open-type="navigate">
查看全部
<text class="iconfont icon-xiangyou"></text>
</navigator>
</view>
<view class="order-bd">
<block v-for="(item,index) in orderMenu" :key="index">
<navigator class="order-item" hover-class="none" :url="item.url">
<view class="pic">
<image :src="item.img" mode=""></image>
<text class="order-status-num" v-if="item.num > 0">{{ item.num }}</text>
</view>
<view class="txt">{{item.title}}</view>
</navigator>
</block>
</view>
</view>
</view>
<view class="num-wrapper">
<view class="num-item" @click="goMenuPage('/pages/users/user_money/index')">
<text class="num">{{userInfo.nowMoney?Number(userInfo.nowMoney).toFixed(2):0}}</text>
<view class="txt">余额</view>
<view class="contenBox">
<!-- 轮播 -->
<view class="slider-wrapper" v-if="imgUrls.length>0">
<swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval"
:duration="duration" indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
<block v-for="(item,index) in imgUrls" :key="index">
<swiper-item class="borRadius14">
<image :src="item.pic" class="slide-image" @click="navito(item.url)"></image>
</swiper-item>
</block>
</swiper>
</view>
<view class="num-item" @click="goMenuPage('/pages/users/user_integral/index')">
<text class="num">{{userInfo.integral || 0}}</text>
<view class="txt">积分</view>
</view>
<view class="num-item" @click="goMenuPage('/pages/users/user_coupon/index')">
<text class="num">{{userInfo.couponCount || 0}}</text>
<view class="txt">优惠券</view>
</view>
</view>
<view class="sign" @click="goSignIn">签到</view>
</view>
<view class="order-wrapper">
<view class="order-hd flex">
<view class="left">订单中心</view>
<navigator class="right flex" hover-class="none" url="/pages/users/order_list/index" open-type="navigate">
查看全部
<text class="iconfont icon-xiangyou"></text>
</navigator>
</view>
<view class="order-bd">
<block v-for="(item,index) in orderMenu" :key="index">
<navigator class="order-item" hover-class="none" :url="item.url">
<view class="pic">
<image :src="item.img" mode=""></image>
<text class="order-status-num" v-if="item.num > 0">{{ item.num }}</text>
<!-- 会员菜单 -->
<view class="user-menus" style="margin-top: 20rpx;">
<view class="menu-title">我的服务</view>
<view class="list-box">
<block v-for="(item,index) in MyMenus" :key="index">
<navigator class="item" :url="item.url" hover-class="none"
v-if="!(item.url =='/pages/service/index' || (item.url =='/pages/users/user_spread_user/index' && !userInfo.isPromoter))">
<image :src="item.pic"></image>
<text>{{item.name}}</text>
</navigator>
</block>
<!-- #ifndef MP -->
<view class="item" @click="kefuClick">
<image :src="servicePic"></image>
<text>联系客服</text>
</view>
<view class="txt">{{item.title}}</view>
</navigator>
</block>
</view>
</view>
</view>
<!-- 轮播 -->
<view class="slider-wrapper" v-if="imgUrls.length>0">
<swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval" :duration="duration"
indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
<block v-for="(item,index) in imgUrls" :key="index">
<swiper-item>
<image :src="item.pic" class="slide-image" @click="navito(item.url)"></image>
</swiper-item>
</block>
</swiper>
</view>
<!-- 会员菜单 -->
<view class="user-menus" style="margin-top: 20rpx;">
<block v-for="(item,index) in MyMenus" :key="index">
<navigator class="item" :url="item.url" hover-class="none" v-if="!(item.url =='/pages/service/index' || (item.url =='/pages/users/user_spread_user/index' && !userInfo.isPromoter))">
<view class="left">
<image :src="item.pic"></image>
<text>{{item.name}}</text>
<!-- #endif -->
<!-- #ifdef MP -->
<button class="item" open-type='contact' hover-class='none'>
<image :src="servicePic"></image>
<text>联系客服</text>
</button>
<!-- #endif -->
</view>
</view>
<view class="iconfont icon-xiangyou"></view>
</navigator>
</block>
<!-- #ifdef H5 -->
<view class="item" @click="kefuClick">
<view class="left">
<image :src="servicePic"></image>
<text>联系客服</text>
<image src="/static/images/support.png" alt="" class='support'>
<view class="uni-p-b-98"></view>
</view>
<view class="iconfont icon-xiangyou"></view>
</view>
<!-- #endif -->
<!-- #ifdef MP -->
<button class="item" open-type='contact' hover-class='none'>
<view class="left">
<image :src="servicePic"></image>
<text>联系客服</text>
</view>
<view class="iconfont icon-xiangyou"></view>
</button>
<!-- #endif -->
</scroll-view>
</view>
<img src="/static/images/support.png" alt="" class='support'>
<!-- #ifdef MP -->
<authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
<!-- #endif -->
</view>
</template>
<script>
let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
import Cache from '@/utils/cache';
import {
getMenuList,
getUserInfo
BACK_URL
} from '@/config/cache';
import {
getMenuList
// setVisit
} from '@/api/user.js';
import {
@@ -145,7 +154,7 @@
authorize
// #endif
},
computed: mapGetters(['isLogin']),
computed: mapGetters(['isLogin', 'chatUrl', 'userInfo', 'uid']),
data() {
return {
orderMenu: [{
@@ -188,10 +197,16 @@
isAuto: false, //没有授权的不会自动授权
isShowAuth: false, //是否隐藏授权
orderStatusNum: {},
userInfo: {},
MyMenus: [],
wechatUrl: [],
servicePic: '',
servicePic: '/static/images/customer.png',
sysHeight: sysHeight,
// #ifdef MP
pageHeight: '100%',
// #endif
// #ifdef H5
pageHeight: app.globalData.windowHeight,
// #endif
// #ifdef H5
isWeixin: Auth.isWeixin()
//#endif
@@ -199,33 +214,32 @@
},
onLoad() {
let that = this;
// #ifdef H5
that.$set(that, 'pageHeight', app.globalData.windowHeight);
// #endif
that.$set(that, 'MyMenus', app.globalData.MyMenus);
console.log('user页面',that.isLogin)
// if (that.isLogin == false) {
// // #ifdef H5 || APP-PLUS
// toLogin();
// // #endif
// // #ifdef MP
// this.isAuto = true;
// this.$set(this, 'isShowAuth', true);
// // #endif
// }
if (that.isLogin == false) {
// #ifdef H5
toLogin()
// #endif
}
},
onShow: function() {
let that = this;
// #ifdef H5
uni.getSystemInfo({
success: function(res) {
that.pageHeight = res.windowHeight + 'px'
}
});
// #endif
if (that.isLogin) {
this.getUserInfo();
this.getMyMenus();
// this.setVisit();
this.getOrderData();
}else{
// #ifdef H5 || APP-PLUS
this.$store.dispatch('USERINFO');
} else {
toLogin();
// #endif
// #ifdef MP
this.isAuto = true;
this.$set(this, 'isShowAuth', true);
// #endif
}
},
methods: {
@@ -235,15 +249,15 @@
// url:'/pages/user/index'
// }).then(res=>{})
// },
navito(e){
navito(e) {
window.location.href = 'https://' + e;
},
kefuClick(){
location.href = this.wechatUrl[0].wap_url;
kefuClick() {
location.href = this.chatUrl;
},
getOrderData(){
getOrderData() {
let that = this;
orderData().then(res=>{
orderData().then(res => {
that.orderMenu.forEach((item, index) => {
switch (item.title) {
case '待付款':
@@ -263,17 +277,16 @@
break
}
})
that.$set(that,'orderMenu',that.orderMenu);
that.$set(that, 'orderMenu', that.orderMenu);
})
},
// 打开授权
openAuto() {
this.isAuto = true;
this.isShowAuth = true
Cache.set(BACK_URL, '')
toLogin();
},
// 授权回调
onLoadFun() {
this.getUserInfo();
this.getMyMenus();
// this.setVisit();
this.getOrderData();
@@ -292,20 +305,9 @@
// 绑定手机
bindPhone() {
uni.navigateTo({
url: '/pages/users/user_phone/index'
url: '/pages/users/app_login/index'
})
},
/**
* 获取个人用户信息
*/
getUserInfo: function() {
const _app = getApp();
let that = this;
getUserInfo().then(res => {
that.userInfo = res.data;
that.$store.commit("SETUID", res.data.uid);
});
},
/**
*
* 获取个人中心图标
@@ -319,7 +321,7 @@
return item.url.indexOf('service') !== -1
})
res.data.routine_my_menus.map((item) => {
if(item.url.indexOf('service') !==-1) that.servicePic = item.pic
if (item.url.indexOf('service') !== -1) that.servicePic = item.pic
})
that.imgUrls = res.data.routine_my_banner
});
@@ -327,21 +329,12 @@
// 编辑页面
goEdit() {
if (this.isLogin == false) {
// #ifdef H5 || APP-PLUS
toLogin();
// #endif
// #ifdef MP
this.isAuto = true;
this.$set(this, 'isShowAuth', true);
// #endif
} else {
uni.navigateTo({
url: '/pages/users/user_info/index'
})
}
// uni.navigateTo({
// url: '/pages/users/user_info/index'
// })
},
// 签到
goSignIn() {
@@ -350,14 +343,14 @@
})
},
// goMenuPage
goMenuPage(url){
if(this.isLogin){
goMenuPage(url) {
if (this.isLogin) {
uni.navigateTo({
url
})
}else{
} else {
// #ifdef MP
this.openAuto()
this.openAuto()
// #endif
}
}
@@ -366,37 +359,62 @@
</script>
<style lang="scss" scoped>
page,
body {
height: 100%;
}
.bg {
position: absolute;
left: 0;
top: 0;
width:100%;
height: 420rpx;
background-image: url('~@/static/images/user_bg.png');
background-repeat: no-repeat;
background-size: 100% 100%;
}
.contenBox {
padding: 0 30rpx;
}
.support {
width: 219rpx;
height: 74rpx;
margin: 54rpx auto;
display: block;
}
.new-users {
display: flex;
flex-direction: column;
height: 100%;
.sys-head {
position: relative;
width: 100%;
background: linear-gradient(90deg, $bg-star1 0%, $bg-end1 100%);
.sys-title {
z-index: 10;
position: relative;
height: 43px;
text-align: center;
line-height: 43px;
font-size: 36rpx;
color: #FFFFFF;
}
}
.head {
padding-top: 30rpx;
background: #fff;
background: linear-gradient(360deg, rgba(255, 121, 49, 0) 0%, rgba(248, 74, 29, 0.82) 39%, #E93323 100%);
// padding: 0 30rpx;
.user-card {
position: relative;
width: 710rpx;
height: 340rpx;
width: 100%;
margin: 0 auto;
padding: 35rpx 28rpx;
background: linear-gradient(90deg, $bg-star 0%, $bg-end 100%);
box-shadow: 0px 10rpx 20rpx 0px rgba(255, 2, 0, 0.2);
border-radius: 24rpx;
.bg {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-image: url('~@/static/images/user_bg.png');
background-size: 100% 100%;
}
padding: 35rpx 0 30rpx 0;
.user-info {
z-index: 20;
position: relative;
@@ -430,7 +448,6 @@
border-radius: 18px;
font-size: 20rpx;
margin-left: 12rpx;
// margin-top: 2rpx;
image {
width: 27rpx;
@@ -460,8 +477,7 @@
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 60rpx;
// padding: 0 47rpx;
margin-top: 30rpx;
color: #fff;
.num-item {
@@ -474,7 +490,7 @@
}
.txt {
margin-top: 8rpx;
margin-top: 10rpx;
font-size: 26rpx;
color: rgba(255, 255, 255, 0.6);
}
@@ -500,13 +516,24 @@
}
.order-wrapper {
background-color: #fff;
border-radius: 14rpx;
padding: 30rpx 16rpx;
position: relative;
z-index: 11;
.order-hd {
justify-content: space-between;
padding: 0 20rpx 28rpx;
margin-top: 33rpx;
border-bottom: 1px solid #F5F5F5;
font-size: 30rpx;
color: #282828;
margin-bottom: 40rpx;
padding: 0 16rpx;
.left {
color: #282828;
font-size: 30rpx;
font-weight: 600;
}
.right {
align-items: center;
@@ -515,22 +542,21 @@
.icon-xiangyou {
margin-left: 5rpx;
margin-top: 6rpx;
font-size: 26rpx;
font-size: 24rpx;
}
}
}
.order-bd {
display: flex;
padding: 0 24rpx;
justify-content: space-between;
padding: 0;
.order-item {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 20%;
height: 160rpx;
.pic {
position: relative;
@@ -554,7 +580,7 @@
.slider-wrapper {
margin: 20rpx 0;
height: 130rpx;
height: 138rpx;
swiper,
swiper-item {
@@ -563,47 +589,51 @@
image {
width: 100%;
height: 130rpx;
height: 100%;
}
}
.user-menus {
background-color: #fff;
border-radius: 14rpx;
.menu-title {
padding: 30rpx 30rpx 40rpx;
font-size: 30rpx;
color: #282828;
font-weight: 600;
}
.list-box {
display: flex;
flex-wrap: wrap;
padding: 0;
}
.item {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
height: 90rpx;
padding: 0 30rpx;
flex-direction: column;
width: 25%;
margin-bottom: 47rpx;
font-size: 26rpx;
color: #333333;
.left {
display: flex;
align-items: center;
image {
width: 46rpx;
height: 46rpx;
margin-right: 25rpx;
}
image {
width: 52rpx;
height: 52rpx;
margin-bottom: 18rpx;
}
&::before {
content: ' ';
position: absolute;
right: 0;
bottom: 0;
width: 655rpx;
height: 1px;
background-color: #EEEEEE;
}
&:last-child::before {
display: none;
}
}
button{
button {
font-size: 28rpx;
}
}
@@ -613,13 +643,13 @@
}
.order-status-num {
min-width:12rpx;
min-width: 12rpx;
background-color: #fff;
color: #ee5a52;
border-radius: 15px;
position: absolute;
right:-14rpx;
right: -14rpx;
top: -15rpx;
font-size: 20rpx;
padding: 0 8rpx;