Compare commits

...

2 Commits

@ -58,3 +58,7 @@ export const addressListApi = (parm) => {
export const editAddressApi = (parm) => { export const editAddressApi = (parm) => {
return http.put("/wxapi/address", parm) return http.put("/wxapi/address", parm)
} }
//默认地址查询
export const getAddressApi = (parm) => {
return http.get("/wxapi/address/getAddress", parm)
}

@ -1,6 +1,9 @@
<template> <template>
<view> <view>
<radio-group @change="radioChange">
<view class="item" v-for="(res, index) in siteList.list" :key="res.id"> <view class="item" v-for="(res, index) in siteList.list" :key="res.id">
<radio :value="JSON.stringify(res)" :checked="res.addressId == store.checkedId" />
<view style="flex-grow: 1;">
<view class="top"> <view class="top">
<view class="name">{{ res.userName }}</view> <view class="name">{{ res.userName }}</view>
<view class="phone">{{ res.phone }}</view> <view class="phone">{{ res.phone }}</view>
@ -13,6 +16,8 @@
<u-icon @click="update(res)" name="edit-pen" :size="40" color="#999999"></u-icon> <u-icon @click="update(res)" name="edit-pen" :size="40" color="#999999"></u-icon>
</view> </view>
</view> </view>
</view>
</radio-group>
<view class="addSite" @tap="toAddSite"> <view class="addSite" @tap="toAddSite">
<view class="add"> <view class="add">
<u-icon name="plus" color="#ffffff" class="icon" :size="30"></u-icon> <u-icon name="plus" color="#ffffff" class="icon" :size="30"></u-icon>
@ -30,9 +35,13 @@
reactive, reactive,
ref ref
} from 'vue' } from 'vue'
import {
addressStore
} from '../../store/address.js'
import { import {
addressListApi addressListApi
} from '../../api/user.js' } from '../../api/user.js'
const store = addressStore()
// //
const siteList = reactive({ const siteList = reactive({
list: [] list: []
@ -57,9 +66,23 @@
const update = (item) => { const update = (item) => {
console.log(item) console.log(item)
uni.navigateTo({ uni.navigateTo({
url: '../address/address' url: '../address/address?item=' + JSON.stringify(item)
}); });
} }
//
const radioChange = (e) => {
console.log(e)
if (e.detail.value) {
let item = JSON.parse(e.detail.value)
store.checkedId = item.addressId
store.userName = item.userName
store.phone = item.phone
store.area = item.area
store.address = item.address
//
uni.navigateBack()
}
}
onShow(() => { onShow(() => {
getList() getList()
}) })
@ -68,6 +91,8 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.item { .item {
padding: 40rpx 20rpx; padding: 40rpx 20rpx;
display: flex;
align-items: center;
.top { .top {
display: flex; display: flex;

@ -3,14 +3,14 @@
<view> <view>
<view class="info"> <view class="info">
<view class="name"> <view class="name">
张明 {{astore.userName}}
</view> </view>
<view class="phone"> <view class="phone">
18681xxxxx {{astore.phone}}
</view> </view>
</view> </view>
<view> <view>
北京工业大学 {{astore.area}}{{astore.address}}
</view> </view>
</view> </view>
<u-icon name="arrow-right" color="#c8c9cc"></u-icon> <u-icon name="arrow-right" color="#c8c9cc"></u-icon>
@ -53,8 +53,18 @@
import { import {
orderStore orderStore
} from '../../store/order.js' } from '../../store/order.js'
import {
addressStore
} from '../../store/address.js'
import {
getAddressApi
} from '../../api/user.js'
import {
onLoad
} from '@dcloudio/uni-app';
//store //store
const store = orderStore() const store = orderStore()
const astore = addressStore()
const goods = computed(() => { const goods = computed(() => {
return store.orderList return store.orderList
}) })
@ -119,9 +129,26 @@
// //
const toAddress = (item) => { const toAddress = (item) => {
uni.navigateTo({ uni.navigateTo({
url: '../address/address' url: '../addresslist/addresslist'
}); });
} }
//
const getAddress = async () => {
let res = await getAddressApi({
openid: uni.getStorageSync('openid')
})
console.log(res)
if (res && res.code == 200) {
astore.checkedId = res.data.addressId
astore.userName = res.data.userName
astore.phone = res.data.phone
astore.area = res.data.area
astore.address = res.data.address
}
}
onLoad(() => {
getAddress()
})
</script> </script>
<style lang="scss"> <style lang="scss">

@ -0,0 +1,22 @@
// 引入
import {
defineStore
} from 'pinia';
//通过defineStore定义一个store,
// defineStore 第一个参数是唯一的
export const addressStore = defineStore('addressStore', {
state: () => {
return {
checkedId: '',
userName: '',
phone: '',
area: '',
address: ''
};
},
// 也可以这样定义
// state: () => ({ count: 0 })
actions: {
},
});
Loading…
Cancel
Save