setaccount.vue 4.66 KB
Newer Older
王建威's avatar
王建威 committed
1
<template>
王建威's avatar
王建威 committed
2
	<view class="main">
王建威's avatar
王建威 committed
3 4 5 6
		<view class="main_content">
			<TopBar title="账号设置"/>
			<view class="account_base_info flex">
				<view class="flex flex_center">
王建威's avatar
王建威 committed
7
					<image class="portrait" :src="data.portrait || $defaultPortrait" @click="uploadImage()"></image>
王建威's avatar
王建威 committed
8
					<view class="flex flex_center base_info">
王建威's avatar
王建威 committed
9 10
						<text class="customer_name">{{data.customer_name}}</text>
						<text class="custommer_integral">总积分:{{data.total_integral}}</text>
王建威's avatar
王建威 committed
11 12 13
					</view>
				</view>
			</view>
王建威's avatar
王建威 committed
14
			<view class="flex set_item" @click="changeAddress()">
王建威's avatar
王建威 committed
15 16 17
				<text class="set_title">收货地址管理</text>
				<text class="eosfont right_icon">&#xe608;</text>
			</view>
王建威's avatar
王建威 committed
18
			<view class="flex set_item" @click="changePass('phone')">
王建威's avatar
王建威 committed
19 20
				<text class="set_title">更换绑定手机号</text>
				<view class="flex" style="align-items: center;">
王建威's avatar
王建威 committed
21
					<text class="phone_num">{{data.phone_mob.replace(/(\d{3})\d*(\d{4})/,"$1****$2")}}</text>
王建威's avatar
王建威 committed
22 23 24
					<text class="eosfont right_icon">&#xe608;</text>
				</view>
			</view>
王建威's avatar
王建威 committed
25
			<view class="flex set_item" @click="changePass('pay')">
王建威's avatar
王建威 committed
26 27 28
				<text class="set_title">修改支付密码</text>
				<text class="eosfont right_icon">&#xe608;</text>
			</view>
王建威's avatar
王建威 committed
29
			<view class="flex set_item" @click="changePass('login')">
王建威's avatar
王建威 committed
30 31
				<text class="set_title">修改登录密码</text>
				<text class="eosfont right_icon">&#xe608;</text>
王建威's avatar
王建威 committed
32 33
			</view>
		</view>
王建威's avatar
王建威 committed
34 35
		<view class="log_out" @click="logOut()">退出登录</view>
		<BottomBar />
王建威's avatar
王建威 committed
36 37 38 39
	</view>
</template>

<script>
王建威's avatar
王建威 committed
40
	import TopBar from '../../components/TopBar/TopBar';
王建威's avatar
王建威 committed
41
	import BottomBar from "@/components/BottomBar/BottomBar.vue";
王建威's avatar
王建威 committed
42
	import { php } from '../../common/host.js';
王建威's avatar
王建威 committed
43 44 45
	export default {
		data() {
			return {
王建威's avatar
王建威 committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59
				data: {
					portrait: '',
					customer_name: '',
					total_integral: '',
					phone_mob: ''
				}
			}
		},
		onLoad() {
			uni.request({
				url: '/uni/api/member/profile',
				method: 'GET',
				dataType: 'json',
				success: (res) => {
王建威's avatar
王建威 committed
60 61 62 63 64
					if(res.data.code === 0) {
						this.data = res.data.data
					} else {
						this.$jump('/pages/home/home', 2);
					}
王建威's avatar
王建威 committed
65 66 67 68 69 70 71 72
				}
			})
		},
		methods: {
			changeAddress() {
				this.$jump(`${php}app=my_address`);
			},
			changePass(type) {
王建威's avatar
王建威 committed
73
				this.$jump(`/pages/setinfo/setinfo?type=${type}&phone=${this.data.phone_mob}`, 2)
王建威's avatar
王建威 committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
			},
			uploadImage() {
				uni.chooseImage({
					sizeType: ['compress'],
					count:1,
					success: (res) => {
						const tempFilePaths = res.tempFilePaths;
						uni.showLoading({
							title: '上传中'
						})
						uni.uploadFile({
							url: '/uni/api/resources',
							filePath: tempFilePaths[0],
							name: 'file',
							success: (uploadFileRes) => {
								const data = JSON.parse(uploadFileRes.data)
								uni.request({
									url: '/uni/api/member/change_portrait',
									method: 'POST',
									data: {
										portrait: data.data
									},
									dataType: 'json',
									success: (result) => {
										if(result.data.code === 0) {
											uni.hideLoading();
											uni.showToast({
												title: '头像修改成功',
												icon: 'none'
											});
											this.data.portrait = data.data;
										}
									}
								})
							}
						});
					}
				})
王建威's avatar
王建威 committed
112 113 114
			},
			logOut() {
				this.$jump(`${php}app=member&act=logout&synlogout=1`);
王建威's avatar
王建威 committed
115 116 117
			}
		},
		components: {
王建威's avatar
王建威 committed
118 119
			TopBar,
			BottomBar
王建威's avatar
王建威 committed
120 121 122 123 124
		}
	}
</script>

<style lang="less" scoped>
王建威's avatar
王建威 committed
125 126 127 128 129 130
	.main {
		padding-top: 80rpx;
		height: 1334rpx;
		box-sizing: border-box;
		background: #f5f5f5;
	}
王建威's avatar
王建威 committed
131 132 133 134 135 136 137 138 139 140 141
	.flex {
		display: flex;
	}
	.flex_center {
		justify-content: center;
	}
	.right_icon {
		font-size: 24rpx;
		color: #7C7C7C;
	}
	.main_content {
王建威's avatar
王建威 committed
142
		background-color: #fff;
王建威's avatar
王建威 committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
		.account_base_info {
			height: 160rpx;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1Px solid #ECECEC;
			padding: 0 24rpx;
			.base_info {
				flex-direction: column;
			}
			.portrait {
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				margin-right: 20rpx;
			}
			.customer_name {
				color: #16171C;
				font-size: 28rpx;
				line-height: 40rpx;
			}
			.custommer_integral {
				color: #7C7C7C;
				font-size: 22rpx;
				line-height: 32rpx;
			}
		}
王建威's avatar
王建威 committed
169 170 171 172 173
		.set_item {
			height: 92rpx;
			justify-content: space-between;
			align-items: center;
			padding: 0 24rpx;
王建威's avatar
王建威 committed
174
			border-bottom: 1Px solid #d5d5d5;
王建威's avatar
王建威 committed
175 176 177 178 179 180 181 182 183 184 185 186
			.set_title {
				font-size: 28rpx;
				color: #212121;
				line-height: 40rpx;
			}
			.phone_num {
				color: #7C7C7C;
				font-size: 26rpx;
				line-height: 36rpx;
				margin-right: 16rpx;
			}
		}
王建威's avatar
王建威 committed
187 188 189
		.set_item:last-child {
			border-bottom: none;
		}
王建威's avatar
王建威 committed
190 191 192
	}
	.log_out {
		height: 92rpx;
王建威's avatar
王建威 committed
193
		width: 100%;
王建威's avatar
王建威 committed
194 195 196 197 198
		line-height: 92rpx;
		background-color: #fff;
		text-align: center;
		color: #212121;
		font-size: 28rpx;
王建威's avatar
王建威 committed
199
		position: fixed;
王建威's avatar
王建威 committed
200
		bottom: 98rpx;
王建威's avatar
王建威 committed
201
		left: 0;
王建威's avatar
王建威 committed
202 203
	}
</style>