lilei преди 4 години
родител
ревизия
fefe9de743
променени са 3 файла, в които са добавени 65 реда и са изтрити 17 реда
  1. 1 1
      pages/toOrder/editAddress.vue
  2. 1 1
      pages/userCenter/index.vue
  3. 63 15
      pages/userCenter/userInfo/userInfo.vue

+ 1 - 1
pages/toOrder/editAddress.vue

@@ -12,7 +12,7 @@
 				<u-picker v-model="show" @confirm="chooseArea" mode="region"></u-picker>
 			</u-form-item>
 			<u-form-item label="详细地址" required prop="receiveAddress">
-				<u-input placeholder="请输入收货详细地址(最多500个字符)" :maxlength="500" v-model="form.receiveAddress" />
+				<u-input type="textarea" placeholder="请输入收货详细地址(最多500个字符)" :maxlength="500" v-model="form.receiveAddress" />
 			</u-form-item>
 		</u-form>
 		<view class="buttons">

+ 1 - 1
pages/userCenter/index.vue

@@ -16,7 +16,7 @@
 		</view>
 		<view class="my-ledou" v-if="hasLogin">
 			<view class="user-jifen">
-				<view>我的乐豆:<text>345</text></view>
+				<view>我的乐豆:<text>{{userData.currentGold||0}}</text></view>
 				<u-image mode="scaleToFill" width="35rpx" height="35rpx" src="/static/ledou.png"></u-image>
 			</view>
 			<view>

+ 63 - 15
pages/userCenter/userInfo/userInfo.vue

@@ -2,11 +2,11 @@
 	<view class="userInfo-container">
 		<u-cell-group>
 			<u-cell-item title="头像" :arrow="false" center>
-				<u-avatar src="" :size="70" slot="right-icon"></u-avatar>
+				<view class="user-photo"><open-data type="userAvatarUrl"></open-data></view>
 			</u-cell-item>
-			<u-cell-item title="手机号码" value="15709284545" :arrow="false"></u-cell-item>
-			<u-cell-item title="收货地址" index="0" @click="toPage"></u-cell-item>
-			<u-cell-item title="支付密码" index="1" @click="toPage"></u-cell-item>
+			<u-cell-item title="手机号码" :value="userDate.mobile" :arrow="false"></u-cell-item>
+			<u-cell-item v-if="address!=null" title="收货地址" :value="address?'修改收货地址':'设置收货地址'" index="0" @click="editAddress"></u-cell-item>
+			<u-cell-item v-if="existPayPwd!=null" title="支付密码" :value="existPayPwd?'修改密码':'设置密码'" @click="setPayPwd"></u-cell-item>
 		</u-cell-group>
 		<!-- 退出 -->
 		<view class="user-btn">
@@ -16,6 +16,8 @@
 </template>
 
 <script>
+	import {existPayPwd} from '@/api/order.js'
+	import {findAddressBycustomerNo} from '@/api/receiveAddress.js'
 	import {logout} from '@/api/login.js'
 	export default {
 		data() {
@@ -24,22 +26,60 @@
 					borderRadius:'100rpx',
 					fontSize:'30rpx',
 					background: '#01c9b2'
-				}
+				},
+				userDate: {},
+				existPayPwd: null,
+				address: null,
+				userInfo: {}
 			}
 		},
 		onShow() {
-		},
-		onLoad() {
+			this.userDate = this.$store.state.vuex_userData
+			this.getPayPwd()
+			this.getAddress()
 		},
 		methods:{
-			// 打开对应的页面
-			toPage(index){
-				let pageUrl=[
-					'/pages/toOrder/editAddress',
-					'/pages/userCenter/userInfo/changePayPwd'
-					// '/pages/userCenter/userInfo/smsVerification'
-					]
-				uni.navigateTo({ url: pageUrl[index] })
+			// 获取用户位置
+			getAddress() {
+				 findAddressBycustomerNo({}).then(res => {
+					 console.log(res)
+					 if (res.status == 200&&res.data.length) {
+						 this.address = res.data[0].receiveAddress
+						 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:"/pages/toOrder/editAddress"
+				})
+			},
+			// 设置密码
+			setPayPwd(){
+				// 设置过支付密码,则修改密码
+				if(this.existPayPwd){
+					uni.navigateTo({ url: '/pages/userCenter/userInfo/paymentPwd' })
+				}else{
+					// 没设置过支付密码,提示设置密码
+					uni.navigateTo({ url: '/pages/userCenter/userInfo/changePayPwd' })
+				}
 			},
 			// 退出登录
 			quitSys(){
@@ -76,5 +116,13 @@
 		.user-btn{
 			padding: 85rpx 200rpx;
 		}
+		.user-photo{
+			width: 100rpx;
+			height: 100rpx;
+			border-radius: 50%;
+			overflow: hidden;
+			margin-right: 5rpx;
+			float: right;
+		}
 	}
 </style>