123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- <template>
- <view class="main">
- <view class="one">
- <view class="one_1">
- <view v-if="user._id" class="top">
- <image class="image" :src="user.logo&&user.logo.length>0?user.logo[0].url:'../../static/my.png'"
- mode=""></image>
- <text>{{user.nick_name||'微信用户'}}</text>
- </view>
- <view v-else class="top" @tap="toLogin">
- <text class="iconfont icon-yonghu"></text>
- <text>登录/注册</text>
- </view>
- </view>
- <view class="one_2">
- <view class="bottom">
- <view class="list" v-for="(item,index) in list" :key="index" @tap="toLike(item)">
- <text>{{item.num}}</text>
- <text>{{item.title}}</text>
- </view>
- </view>
- </view>
- </view>
- <view class="two">
- <view class="two_1">
- <view class="left">我的订单</view>
- <view class="right" @tap="toCommon(`pagesIndex/order/index`)">查看全部订单 <text
- class="iconfont icon-dayuhao"></text></view>
- </view>
- <view class="two_2">
- <view class="list" v-for="(item,index) in orderList" :key="index" @tap="toRoute(item)">
- <uni-badge :text="item.num" absolute="rightTop" size="normal">
- <view class="icon">
- <text class="iconfont" :class="[item.icon]"></text>
- </view>
- <text class="title">{{item.title}}</text>
- </uni-badge>
- </view>
- </view>
- </view>
- <view class="thr">
- <view class="list" v-for="(item, index) in menuList" :key="index" @click="toCommon(item.route)">
- <view class="left">
- <view class="icon">
- <text class="iconfont" :class="[item.icon]"></text>
- </view>
- <text class="title">{{item.title||'暂无'}}</text>
- </view>
- <view class="right">
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- user: {},
- // 获赞数
- list: [{
- title: '点赞',
- route: 'pagesIndex/like/index',
- type: '0',
- num: 0,
- },
- {
- title: '收藏',
- route: 'pagesIndex/collect/index',
- type: '1',
- num: 0,
- },
- {
- title: '评论',
- route: 'pagesIndex/comment/index',
- type: '2',
- num: 0,
- },
- ],
- // 订单图标菜单
- orderList: [],
- // 菜单
- menuList: []
- }
- },
- onLoad: async function() {
- const that = this;
- await that.searchOther();
- },
- onShow: async function(e) {
- const that = this;
- that.searchToken();
- await that.search();
- },
- methods: {
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) that.$set(that, `user`, res);
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- // 查询
- async search() {
- const that = this;
- let res;
- res = await that.$api(`/user/statistics`, 'GET', {
- user: that.user._id
- })
- if (res.errcode == '0') {
- that.$set(that, `list`, res.data)
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- },
- // 登录或注册
- async toLogin() {
- uni.navigateTo({
- url: `/pagesIndex/login/index`
- })
- },
- // 点赞或收藏
- toLike(item) {
- const that = this;
- if (that.user && that.user._id) {
- if (item.type == '2') {
- uni.navigateTo({
- url: `/${item.route}`
- })
- } else {
- uni.navigateTo({
- url: `/${item.route}?type=${item.type}`
- })
- }
- } else {
- uni.navigateTo({
- url: `/pagesIndex/login/index`
- })
- }
- },
- // 订单或维修跳转
- toRoute(item) {
- const that = this;
- if (that.user && that.user._id) {
- uni.navigateTo({
- url: `/${item.route}?status=${item.status}`
- })
- } else {
- uni.navigateTo({
- url: `/pagesIndex/login/index`
- })
- }
- },
- // 公共跳转
- toCommon(e) {
- const that = this;
- if (that.user && that.user._id) {
- uni.navigateTo({
- url: `/${e}`
- })
- } else {
- uni.navigateTo({
- url: `/pagesIndex/login/index`
- })
- }
- },
- async searchOther() {
- const that = this;
- let config = that.$config;
- that.$set(that, `orderList`, config.orderList);
- that.$set(that, `menuList`, config.menuList);
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- background-image: linear-gradient(to top, rgba(241, 241, 241, 1), rgba(241, 241, 241, 1), rgba(0, 122, 255, 1));
- .one {
- .one_1 {
- padding: 4vw;
- .top {
- display: flex;
- align-items: center;
- font-size: var(--font18Size);
- .image {
- width: 15vw;
- height: 15vw;
- border-radius: 15vw;
- margin: 0 2vw;
- }
- .iconfont {
- font-size: 40px;
- color: var(--f85Color);
- padding: 2vw;
- }
- }
- }
- .one_2 {
- padding: 5vw;
- .bottom {
- display: flex;
- justify-content: space-around;
- .list {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- }
- }
- }
- .two {
- display: flex;
- flex-direction: column;
- padding: 2vw;
- margin: 2vw;
- border-radius: 10px;
- background-color: var(--mainColor);
- .two_1 {
- display: flex;
- justify-content: space-between;
- padding: 2vw;
- border-bottom: 1px solid var(--f9Color);
- .left {
- font-weight: 600;
- font-size: var(--font14Size);
- }
- .right {
- display: flex;
- align-items: center;
- font-size: var(--font12Size);
- color: var(--f99Color);
- }
- }
- .two_2 {
- display: flex;
- justify-content: space-between;
- padding: 3vw 4vw;
- .list {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- text-align: center;
- .icon {
- .iconfont {
- font-size: 25px;
- }
- }
- .title {
- display: inline-block;
- margin: 1vw 0 0 0;
- font-size: var(--font12Size);
- }
- }
- }
- }
- .thr {
- display: flex;
- flex-direction: column;
- padding: 2vw;
- margin: 0 2vw;
- border-radius: 10px;
- background-color: var(--mainColor);
- .list {
- display: flex;
- justify-content: space-between;
- padding: 2vw;
- border-bottom: 1px solid var(--f9Color);
- .left {
- display: flex;
- align-items: center;
- font-size: var(--font12Size);
- .icon {
- padding: 0 1vw 0 0;
- .iconfont {
- color: var(--f3CColor);
- font-size: var(--font18Size);
- }
- }
- .title {
- display: inline-block;
- font-size: var(--font12Size);
- }
- }
- .right {
- display: flex;
- align-items: center;
- font-size: var(--font12Size);
- color: var(--f99Color);
- }
- }
- }
- }
- </style>
|