jsk 我的 我的地址
This commit is contained in:
parent
0d28f0f427
commit
eec6abba36
|
|
@ -0,0 +1,63 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
|
||||
/**
|
||||
* @param {Object} data获取个人地址列表
|
||||
*/
|
||||
export function queryCustAddrApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/custaddr/queryCustAddrForApp',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"openid": uni.getStorageSync('openId'),
|
||||
"sourceType": "7",
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} data获取单个地址
|
||||
*/
|
||||
export function queryChildPlaceByIdApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/custaddr/queryChildPlaceById',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"openid": uni.getStorageSync('openId'),
|
||||
"sourceType": "7",
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} data 新增个人地址
|
||||
*/
|
||||
export function updateCustAddrApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/custaddr/updateCustAddrForApp',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"openid": uni.getStorageSync('openId'),
|
||||
"sourceType": "7",
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} data设置默认地址
|
||||
*/
|
||||
export function updateDefaultAddrApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/custaddr/updateDefaultAddrForApp',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"openid": uni.getStorageSync('openId'),
|
||||
"sourceType": "7",
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -235,6 +235,12 @@
|
|||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mine/me/upAddress",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/feedback/index",
|
||||
"style": {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { getAdvanceOrderStallApi } from '@/api/advanceOrder/index.js'
|
||||
import { getAdvanceOrderStallApi } from '@/api/advanceOrder/index.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
v-for="(item, index) in addressList"
|
||||
:key="index"
|
||||
class="address-item"
|
||||
@click="handleEdit(index)"
|
||||
@click="handleEdit(item)"
|
||||
>
|
||||
<view class="address-info">
|
||||
<text class="address-text">{{ item.address }}</text>
|
||||
|
|
@ -14,42 +14,83 @@
|
|||
<text class="contact-text">{{ item.phone }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<span size="10">{{item.ifDefault=="1"?"默认":""}}</span>
|
||||
<u-icon name="edit-pen-fill" color="#c8c9cc" size="22"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { queryCustAddrApi } from '@/api/mine/information.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
addressList: [
|
||||
{
|
||||
address: '府前西街与站前北街交叉口南200米',
|
||||
name: '冯先生1',
|
||||
phone: '153****5876'
|
||||
name: '冯先生1',id: '1',
|
||||
phone: '153****5876',
|
||||
ifDefault:"1"
|
||||
},
|
||||
{
|
||||
address: '怡馨家园30号楼(近达人街商城)',
|
||||
name: '冯先生',
|
||||
name: '冯先生',id: '2',ifDefault:"0",
|
||||
phone: '153****5876'
|
||||
},
|
||||
{
|
||||
address: '西辛南区46号楼2单元101室',
|
||||
name: '冯先生',
|
||||
name: '冯先生',id: '3',ifDefault:"0",
|
||||
phone: '153****5876'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.queryCustAddrList()
|
||||
},
|
||||
methods: {
|
||||
handleEdit(index) {
|
||||
async queryCustAddrList() {
|
||||
try {
|
||||
let param = {
|
||||
"custId":uni.getStorageSync('custId'),
|
||||
}
|
||||
const res = await queryCustAddrApi(param)
|
||||
console.log('🚀 ~ getList ~ res:', res)
|
||||
this.addressList = res.data;
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
async updateDefaultAddr() {
|
||||
try {
|
||||
let param = {
|
||||
"custId":uni.getStorageSync('custId'),
|
||||
}
|
||||
const res = await updateDefaultAddrApi(param)
|
||||
console.log('🚀 ~ getList ~ res:', res)
|
||||
if(res.code==200){
|
||||
uni.$u.toast(`操作成功!`)
|
||||
}else{
|
||||
uni.$u.toast(`操作成功!`)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
handleEdit(address) {
|
||||
// 处理编辑事件
|
||||
uni.$u.toast(`编辑第${index + 1}个地址`)
|
||||
// uni.$u.toast(`编辑第${index + 1}个地址`)
|
||||
console.log('🚀 ==='+address)
|
||||
uni.navigateTo({
|
||||
url: `/pages/mine/me/upAddress?address=${encodeURIComponent(JSON.stringify(address))}`
|
||||
})
|
||||
},
|
||||
addAddress() {
|
||||
console.log('🚀 ~ handleRightText ~ ')
|
||||
uni.navigateTo({
|
||||
url: `/pages/mine/me/upAddress`
|
||||
})
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,171 @@
|
|||
<template>
|
||||
<view class="pwd-retrieve-container">
|
||||
<uni-forms ref="form" :value="user" labelWidth="80px">
|
||||
<uni-easyinput type="text" style="display: none;" v-model="user.id"/>
|
||||
<uni-forms-item name="address" label="地址">
|
||||
<uni-easyinput type="text" v-model="user.address" placeholder="请输入" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="name" label="用户">
|
||||
<uni-easyinput type="text" v-model="user.name" placeholder="请输入" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="phone" label="电话号码">
|
||||
<uni-easyinput type="text" v-model="user.phone" placeholder="请输入" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="phone" label="默认">
|
||||
<radio-group @change="radioChange">
|
||||
<radio value="1" :checked="!user.selected">是</radio>
|
||||
<radio value="0" :checked="user.selected">否</radio>
|
||||
</radio-group>
|
||||
</uni-forms-item>
|
||||
<button type="primary" @click="submit">提交</button>
|
||||
</uni-forms>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { updateCustAddrApi } from '@/api/mine/information.js';
|
||||
import { updateDefaultAddrApi } from '@/api/mine/information.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
user: {
|
||||
id: "",
|
||||
ifDefault:0,
|
||||
address: undefined,
|
||||
name: undefined,
|
||||
phone: undefined,
|
||||
selected:true
|
||||
|
||||
},
|
||||
sexShow: false,
|
||||
columns: [['是', '否']],
|
||||
rules: {
|
||||
address: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '不能为空'
|
||||
}]
|
||||
},
|
||||
name: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '不能为空',
|
||||
},
|
||||
{
|
||||
minLength: 1,
|
||||
maxLength: 10,
|
||||
errorMessage: '长度在 2 到 20 个字符'
|
||||
}
|
||||
]
|
||||
},
|
||||
phone: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '不能为空'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
this.$refs.form.setRules(this.rules)
|
||||
},
|
||||
onLoad(options) {
|
||||
const addressStr = options.address;
|
||||
console.log("addressStr=="+addressStr)
|
||||
var address={};
|
||||
if(addressStr!=undefined&&""!=addressStr){
|
||||
address = JSON.parse(decodeURIComponent(addressStr));
|
||||
console.log('Received user data:', address);
|
||||
}else{
|
||||
address={
|
||||
id: undefined,
|
||||
ifDefault:0,
|
||||
address: undefined,
|
||||
name: undefined,
|
||||
phone: undefined,
|
||||
selected:true
|
||||
}
|
||||
}
|
||||
if(address.ifDefault==1){
|
||||
address.selected=false;
|
||||
}
|
||||
this.user=address;
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
const id=this.user.id;
|
||||
if(id!=undefined&&id!=""){
|
||||
updatedata(this.user);
|
||||
}else{
|
||||
insertdata(this.user);
|
||||
}
|
||||
},
|
||||
radioChange(e) {
|
||||
console.log('radioChange', e.detail.value)
|
||||
if(e.detail.value=="1"){
|
||||
this.user.ifDefault=1;
|
||||
}else{
|
||||
this.user.ifDefault=0;
|
||||
}
|
||||
},
|
||||
async updatedata(user){
|
||||
try {
|
||||
let param = {
|
||||
"custId":uni.getStorageSync('custId'),
|
||||
"id":this.user.id,
|
||||
"ifDefault":this.user.ifDefault,
|
||||
"address": this.user.address,
|
||||
"name": this.user.name,
|
||||
"phone": this.user.phone
|
||||
}
|
||||
const res = await updateCustAddrApi(param);
|
||||
await updateDefaultAddrApi(param);
|
||||
console.log('🚀 ~ getList ~ res:', res)
|
||||
if(res.code==200){
|
||||
uni.$u.toast(`操作成功!`)
|
||||
}else{
|
||||
uni.$u.toast(`操作成功!`)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
async insertdata(user){
|
||||
try {
|
||||
let param = {
|
||||
"custId":uni.getStorageSync('custId'),
|
||||
"id":this.user.id,
|
||||
"ifDefault":this.user.ifDefault,
|
||||
"address": this.user.address,
|
||||
"name": this.user.name,
|
||||
"phone": this.user.phone
|
||||
}
|
||||
const res = await updateCustAddrApi(param);
|
||||
await updateDefaultAddrApi(param);
|
||||
console.log('🚀 ~ getList ~ res:', res)
|
||||
if(res.code==200){
|
||||
uni.$u.toast(`操作成功!`)
|
||||
}else{
|
||||
uni.$u.toast(`操作成功!`)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.pwd-retrieve-container {
|
||||
padding-top: 36rpx;
|
||||
padding: 15px;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue