123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <template>
- <view class="userInfo-container">
- <u-cell-group>
- <u-cell-item title="头像" :arrow="false" center>
- <view class="user-photo"><open-data type="userAvatarUrl"></open-data></view>
- </u-cell-item>
- <u-cell-item title="手机号码" :value="userDate.mobile" :arrow="false"></u-cell-item>
- <u-cell-item title="收货地址" :value="address?'修改收货地址':'设置收货地址'" index="0" @click="editAddress"></u-cell-item>
- <u-cell-item title="支付密码" :value="existPayPwd?'修改密码':'设置密码'" @click="setPayPwd"></u-cell-item>
- </u-cell-group>
- <!-- 退出 -->
- <view class="user-btn">
- <u-button type="success" :custom-style="quitButton" @click="quitSys" shape="circle">退出登录</u-button>
- </view>
- </view>
- </template>
- <script>
- import {existPayPwd} from '@/api/order.js'
- import {findAddressBycustomerNo} from '@/api/receiveAddress.js'
- import {logout} from '@/api/login.js'
- export default {
- data() {
- return {
- quitButton: {
- borderRadius:'100rpx',
- fontSize:'30rpx',
- background: '#01c9b2'
- },
- userDate: {},
- existPayPwd: null,
- address: null,
- userInfo: {}
- }
- },
- onShow() {
- this.userDate = this.$store.state.vuex_userData
- this.getPayPwd()
- this.getAddress()
- },
- methods:{
- // 获取用户位置
- getAddress() {
- findAddressBycustomerNo({}).then(res => {
- console.log(res)
- if (res.status == 200&&res.data.length) {
- this.address = res.data[0].receiveAreasName
- this.userInfo = res.data[0]
- } else {
- this.address = ''
- this.userInfo = {}
- }
- })
- },
- // 判断是否设置过支付密码
- getPayPwd(){
- existPayPwd().then(res=>{
- if(res.status == 200) {
- if(res.data) {
- this.existPayPwd = true
- } else {
- this.existPayPwd = false
- }
- }
- })
- },
- // 修改收货地址
- editAddress(index){
- this.$u.vuex("vuex_OrderAddress",this.userInfo)
- uni.navigateTo({
- url:"/pagesA/toOrder/editAddress"
- })
- },
- // 设置密码
- setPayPwd(){
- // 设置过支付密码,则修改密码
- if(this.existPayPwd){
- uni.navigateTo({ url: '/pages/userCenter/userInfo/changePayPwd' })
- }else{
- // 没设置过支付密码,提示设置密码
- uni.navigateTo({ url: '/pages/userCenter/userInfo/smsVerification' })
- }
- },
- // 退出登录
- quitSys(){
- let _this = this
- uni.showModal({
- title: '提示',
- content: '您确定要退出登录吗?',
- success(res) {
- if (res.confirm) {
- logout({}).then(res => {
- getApp().globalData.token = ''
- _this.$u.vuex('vuex_token','')
- _this.$u.vuex('vuex_userData','')
- _this.$u.vuex('vuex_cartList','')
- _this.$u.vuex('vuex_OrderAddress','')
- _this.$u.vuex('vuex_toOrderList','')
- // 关闭socket
- _this.$store.commit("$closeWebsocket")
- uni.reLaunch({
- url: '/pages/index/index'
- })
- })
- }
- }
- })
- }
- }
- }
- </script>
- <style lang="less">
- .userInfo-container{
- width: 100%;
- .logout-btn{
- width: 60%;
- margin-top: 200rpx;
- }
- .user-btn{
- padding: 85rpx 200rpx;
- }
- .user-photo{
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- overflow: hidden;
- margin-right: 5rpx;
- float: right;
- }
- }
- </style>
|