123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568 |
- <template>
- <view class="my">
- <MyNav title="我的" bgColor="" :backIcon="false"></MyNav>
- <view class="topCard" :style="{backgroundImage:'url('+imgurl+')'}">
- <!-- 用户名 -->
- <view class="user">
- <view v-if="admin.avatar">
- <button class="avatar" open-type="chooseAvatar" @click="handleGetWechatUserInfo">
- <image class="user-avatar" style="height: 176rpx;width: 176rpx;border-radius: 50%;"
- :src="admin.avatar? admin.avatar : '/static/icon/avatar.png'" />
- </button>
- <view class="userinfo" @click="goPersonData">
- <text class="unlogin">{{admin.nickname}}</text>
- </view>
- </view>
- <view v-else>
- <image class="user-avatar" src="/static/icon/avatar.png" style="height: 176rpx;width: 176rpx;">
- </image>
- <view class="userinfo">
- <text class="unlogin" v-if="!islogin" @click="login">请点击登录</text>
- </view>
- </view>
- <image src="/static/icon/setting.png" @click="goSetting"
- style="width: 44rpx;height: 44rpx; position: absolute;top:0rpx;right: 24rpx;"></image>
- </view>
- <!-- 会员 -->
- <view class="membership" @click="goJoin">
- <view class="flex">
- <view style="display: flex;align-items: center;">
- <image style="width: 68rpx ;height: 62rpx;" src="../../static/icon/vip.png"></image>
- <text class="join">加入会员</text>
- </view>
- <view style="display: flex;align-items: center;">
- <text class="gojoin">去加入</text>
- <image style="width: 12rpx ;height: 20rpx;" src="../../static/icon/right05.png"></image>
- </view>
- </view>
- </view>
- <!-- 订单 -->
- <view class="orders">
- <view class="nav">
- <view class="myorder">我的订单</view>
- <view class="more">
- <text style="margin-right: 8rpx;" @click="goMyorders(0)">查看更多</text>
- <image style="width: 12rpx ;height: 20rpx;" src="../../static/icon/right05.png"></image>
- </view>
- </view>
- <view class="content">
- <view class="flexbox" @click="goMyorders(1)">
- <view
- style="width: 56rpx; height: 56rpx; display: flex;align-items: center;justify-content: center; ">
- <image style="width: 56rpx ;height: 42rpx;" src="../../static/icon/exchange.png"></image>
- </view>
- <text>待兑换</text>
- </view>
- <view class="flexbox" @click="goMyorders(2)">
- <view
- style="width: 56rpx; height: 56rpx;display: flex;align-items: center;justify-content: center; ">
- <image style="width: 54rpx ;height: 52rpx;" src="../../static/icon/shipments.png"></image>
- </view>
- <text>待发货</text>
- </view>
- <view class="flexbox" @click="goMyorders(3)">
- <view
- style="width: 56rpx; height: 56rpx;display: flex;align-items: center;justify-content: center; ">
- <image style="width: 56rpx ;height: 56rpx;" src="../../static/icon/Receipt.png"></image>
- </view>
- <text>待收货</text>
- </view>
- <view class="flexbox" @click="goMyorders(4)">
- <view
- style="width: 56rpx; height: 56rpx;display: flex;align-items: center;justify-content: center; ">
- <image style="width: 54rpx ;height: 54rpx;" src="../../static/icon/finish.png"></image>
- </view>
- <text>已完成</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 列表 -->
- <view style="padding:0 30rpx;">
- <view class="list" v-for="(item,index) in list" :key="index" @click="goDetail(index)">
- <view class="title">{{item.title}}</view>
- <view class="container">{{item.content}}</view>
- <image src="../../static/icon/right.png"></image>
- </view>
- </view>
- <u-modal @close="closeMask" closeOnClickOverlay="true" :show="modal.show" :title="modal.title"
- :show-confirm-button="false">
- <view>
- <button class="avatar" open-type="chooseAvatar" @chooseavatar="handleChooseAvatar">
- <image class="user-avatar" style="height: 176rpx;width: 176rpx;border-radius: 50%;"
- :src="modal.avatar?modal.avatar:'/static/icon/avatar.png'" />
- </button>
- <input class="avatar" type="nickname" :value="modal.nickname" placeholder="填写昵称"
- @change="handleChangeNickname">
- <button class="confirm" @click="handleConfirmWechatUserInfo">提交</button>
- </view>
- </u-modal>
- <!-- 底部导航栏 -->
- <view style="height: 140rpx; width: 100%;"></view>
- <tab-bar checked="my"></tab-bar>
- </view>
- </template>
- <script>
- // 引入组件
- import TabBar from '../../components/TabBar/tabbar.vue'
- import MyNav from "@/components/my-nav/my-nav.vue"
- export default {
- // 注册组件
- components: {
- TabBar,
- MyNav
- },
- data() {
- return {
- modal: {
- show: false,
- title: '用户信息获取',
- nickname: '',
- avatar: ''
- },
- admin: '',
- // 顶部背景图
- imgurl: 'http://t9.9026.com/imgs/bg@2x.png',
- // 是否登录
- islogin: false,
- // 列表内容
- list: [{
- title: '积分',
- content: '积分兑换奖品'
- }, {
- title: '奖品',
- content: '查看所有奖品'
- }, {
- title: '点赞',
- content: '查看所有点赞'
- }]
- };
- },
- onShow() {
- this.admin = this.$store.getters.userInfo
- console.log(this.admin);
- },
- methods: {
- //关闭遮罩层
- closeMask() {
- this.modal.show = false
- },
- // 微信获取头像
- handleGetWechatUserInfo() {
- console.log(1111);
- this.modal.show = true
- this.modal.nickname = this.admin.nickname
- this.modal.avatar = this.admin.avatar
- },
- //提交微信名称和头像
- handleConfirmWechatUserInfo() {
- if (!this.modal.avatar) {
- this.$u.toast('请上传头像')
- return
- }
- if (!this.modal.nickname) {
- this.$u.toast('请填写昵称')
- return
- }
- this.$loading('数据提交中...')
- this.$api.my.update({
- avatar: this.modal.avatar,
- nickname: this.modal.nickname
- }).then(res => {
- this.$hideLoading()
- this.$store.dispatch('user/info', res.data)
- this.admin = this.$store.getters.userInfo
- this.modal.show = false
- })
- },
- // 微信获取头像
- handleChooseAvatar(e) {
- console.log(e.detail);
- this.modal.avatar = e.detail.avatarUrl
- },
- handleChangeNickname(res) {
- this.modal.nickname = res.detail.value
- },
- // 跳转登录页
- login() {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- },
- // 跳转个人信息
- goPersonData() {
- uni.navigateTo({
- url: '/pages/my/PersonalData/personalData'
- })
- },
- // 跳转设置页面
- goSetting() {
- if (this.admin == undefined) {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- } else {
- uni.navigateTo({
- url: '/pages/my/setting/setting'
- })
- }
- },
- // 跳转积分页
- goDetail(index) {
- if (this.admin == undefined) {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- } else {
- if (index == 0) {
- uni.navigateTo({
- url: '/pages/my/integral/integral'
- })
- } else if (index == 1) {
- uni.navigateTo({
- url: '/pages/my/prize/prize'
- })
- } else {
- uni.navigateTo({
- url: '/pages/my/Kudos/Kudos'
- })
- }
- }
- },
- // 跳转订单页
- goMyorders(index) {
- if (this.admin == undefined) {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- } else {
- switch (index) {
- case 0:
- uni.navigateTo({
- url: '/pages/my/myorders/orders'
- })
- break;
- case 1:
- uni.navigateTo({
- url: '/pages/my/myorders/orders?isActive=' + 1
- })
- break;
- case 2:
- uni.navigateTo({
- url: '/pages/my/myorders/orders?isActive=' + 2
- })
- break;
- case 3:
- uni.navigateTo({
- url: '/pages/my/myorders/orders?isActive=' + 3
- })
- break;
- case 4:
- uni.navigateTo({
- url: '/pages/my/myorders/orders?isActive=' + 4
- })
- break;
- }
- }
- },
- //获取当前页面路径
- getPageUrl() {
- const pages = getCurrentPages();
- console.log(pages,'--------->pages')
- if(pages.length==1){
- const currentPage = pages[0];
- let pageUrl = `/${currentPage.route}`;
- return pageUrl
- console.log('当前页面url:', pageUrl);
- }else{
- const currentPage = pages[pages.length - 1];
- let pageUrl = `/${currentPage.route}`;
- return pageUrl
- console.log('当前页面url:', pageUrl);
- }
- },
- // 跳转其他小程序
- goJoin() {
- let _this = this
- wx.navigateToMiniProgram({
- appId: 'wx255b58f0992b3c53', //appid
- path: 'newUIMain/enrollment/enrollment', //path
- extraData: { //参数
- foo: 'bar'
- },
- // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
- success(res) {
- let page = _this.getPageUrl()
- let user_id = ''
- if (_this.admin != null) {
- user_id = _this.admin.id
- } else {
- user_id = 0
- }
- console.log('成功', page)
- _this.$api.my.userMemberAdd({
- user_id,
- page,
- }).then(res => {
- console.log(res.data);
- })
- // 打开成功
- },
- fail(e) {
- console.log(e, '失败')
- }
- })
- },
- // 上传头像
- uploadAvatar() {
- // let img = []
- // uni.chooseImage({
- // count: 1, //默认9
- // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
- // sourceType: ['album'], //从相册选择
- // success: function (res) {
- // console.log(JSON.stringify(res.tempFilePaths));
- // img = res.tempFilePaths[0]
- // uni.uploadFile({
- // //后端接口地址
- // url: `${baseUrl}` + '/api/attachment/upload',
- // //图片临时地址
- // filePath: img,
- // // 上传文件类型
- // formData: {
- // tag: 'avatar'
- // },
- // success: (res) => {
- // //后端返回的图片名称
- // let data = JSON.parse(res.data)
- // // _this.formData.avatar = data.data.file
- // },
- // })
- // },
- // });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- $pageColor:#F9F9F9;
- $bgColor:#FFFFFF;
- .my {
- height: 100%;
- background-color: $pageColor;
- }
- .avatar {
- width: 176rpx;
- height: 176rpx;
- border-radius: 50%;
- }
- .topCard {
- width: 100%;
- border-radius: 0rpx 0rpx 16rpx 16rpx;
- padding: 40rpx 30rpx 38rpx 30rpx;
- box-sizing: border-box;
- background-position: center;
- background-repeat: no-repeat;
- background-size: cover;
- .user {
- width: 690rpx;
- height: 176rpx;
- position: relative;
- margin-bottom: 38rpx;
- .user-avatar {
- object-fit: cover;
- object-position: center;
- }
- .userinfo {
- position: absolute;
- top: 38rpx;
- left: 200rpx;
- .unlogin {
- width: 220rpx;
- font-size: 44rpx;
- font-family: PingFang-SC-Heavy, PingFang-SC;
- font-weight: 500;
- color: #FFFFFF;
- display: block;
- margin-top: 20rpx;
- }
- .username {
- width: 184rpx;
- height: 44rpx;
- font-size: 44rpx;
- font-family: PingFang-SC-Heavy, PingFang-SC;
- font-weight: 500;
- color: #FFFFFF;
- line-height: 44rpx;
- display: block;
- margin-bottom: 24rpx;
- }
- .userId {
- font-size: 32rpx;
- font-family: PingFang-SC-Medium, PingFang-SC;
- font-weight: 400;
- color: #FFFFFF;
- line-height: 32rpx;
- }
- }
- }
- .membership {
- width: 690rpx;
- height: 110rpx;
- background: $bgColor;
- border-radius: 8rpx;
- display: flex;
- align-items: center;
- padding-left: 28rpx;
- padding-right: 24rpx;
- box-sizing: border-box;
- margin-bottom: 24rpx;
- .flex {
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 68rpx;
- width: 650rpx;
- .join {
- font-size: 36rpx;
- font-family: PingFang-SC-Bold, PingFang-SC;
- font-weight: 600;
- color: #627885;
- margin-left: 8rpx;
- }
- .gojoin {
- font-size: 30rpx;
- font-family: PingFang-SC-Bold, PingFang-SC;
- font-weight: 600;
- color: #627885;
- margin-right: 8rpx;
- }
- }
- }
- .orders {
- width: 690rpx;
- background: $bgColor;
- border-radius: 8rpx;
- padding: 40rpx 30rpx 36rpx 36rpx;
- box-sizing: border-box;
- .nav {
- height: 50rpx;
- width: 633rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .myorder {
- font-size: 28rpx;
- font-family: PingFang-SC-Heavy, PingFang-SC;
- font-weight: 800;
- color: #333333;
- }
- .more {
- font-size: 28rpx;
- font-family: PingFang-SC-Bold, PingFang-SC;
- font-weight: bold;
- color: #627885;
- }
- }
- .content {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 20rpx;
- margin-top: 72rpx;
- .flexbox {
- display: flex;
- flex-direction: column;
- align-items: center;
- text {
- margin-top: 16rpx;
- font-size: 28rpx;
- font-family: PingFang-SC-Medium, PingFang-SC;
- font-weight: 500;
- color: #627885;
- }
- }
- }
- }
- }
- .list {
- width: 100%;
- padding-top: 32rpx;
- padding-bottom: 32rpx;
- border-bottom: 2rpx solid #F0F0F0;
- display: flex;
- flex-direction: column;
- justify-content: center;
- position: relative;
- &:first-child {
- padding-top: 50rpx;
- }
- .title {
- font-size: 36rpx;
- font-family: PingFang-SC-Bold, PingFang-SC;
- font-weight: bold;
- color: #333333;
- margin-bottom: 16rpx;
- }
- .container {
- font-size: 28rpx;
- font-family: PingFang-SC-Medium, PingFang-SC;
- font-weight: 500;
- color: #333333;
- }
- image {
- width: 12rpx;
- height: 20rpx;
- position: absolute;
- top: 70rpx;
- right: 0rpx;
- }
- }
- </style>
|