Browse Source

对接地址列表和新增地址

master
ltlzx 4 years ago
parent
commit
0c715eadef
  1. 20
      api/index.js
  2. 15
      api/request.js
  3. 207
      pages/account/addAddress.vue
  4. 22
      pages/account/address.vue
  5. 1
      pages/account/settings.vue

20
api/index.js

@ -7,7 +7,8 @@ export const defaultRequest =query=>{
method:'post',
data:query,
errMsg:true,
isCookies:false
isCookies:false,
isEncryption:false,
})
}
//默认请求地址 不显示错误信息
@ -17,7 +18,8 @@ export const defaultRequest1 =query=>{
method:'post',
data:query,
errMsg:false,
isCookies:false
isCookies:false,
isEncryption:false,
})
}
//默认请求地址 只用cookies请求数据
@ -27,6 +29,18 @@ export const defaultRequest2 =query=>{
method:'post',
data:query,
errMsg:true,
isCookies:true
isCookies:true,
isEncryption:false,
})
}
//默认请求地址 只用cookies请求数据 对立面的对象进行加密
export const defaultRequest3 =query=>{
return httpRequest({
url:'mapi/api_v2011.php?appcode=DOPE+',
method:'post',
data:query,
errMsg:true,
isCookies:true,
isEncryption:true,
})
}

15
api/request.js

@ -19,14 +19,25 @@ const httpRequest = (params) => {
}
let data=Object.assign(json_data,params.data)
console.info(data)
data=encryption(data)
let consignee
console.info(params.isEncryption)
if(params.isEncryption){
// console.info(JSON.parse(JSON.stringify(data.consignee)))
consignee=encryption(JSON.parse(JSON.stringify(data.consignee)))
// console.info(consignee)
data=encryption(data)
data.consignee=consignee
}else{
data=encryption(data)
}
// console.info(data)
//进行加密
// console.info(encryptDes(JSON.stringify(data),'6780f04cf2e211ec86a8005056c00008'))
// console.info(encrypt_by_des(JSON.stringify(data),'6780f04cf2e211ec86a8005056c00008'))
// data=Base64.encode(encryptDes(JSON.stringify(data),'6780f04cf2e211ec86a8005056c00008'));
data=encryptDes(JSON.stringify(data),'6780f04cf2e211ec86a8005056c00008');
// console.info(data)
// 解密
// let data2 =JSON.parse(decodeURIComponent (decryptDes(Base64.decode(data),'6780f04cf2e211ec86a8005056c00008'))) ;
// console.info(data2)

207
pages/account/addAddress.vue

@ -5,12 +5,15 @@
</view>
<view class="address_info">
<view class="address_info_item address_info_item1">
<view class="info_item_title">
<view>
<view class="info_item_title" >
<picker @change="bindPickerChange" :value="index" :range="countryList" range-key="region_name" class="info_item_title_pick">
<text>*Country/Region</text>
<view class="info_item_title_span">United States</view>
</view>
<view class="info_item_title_span">{{countryText}}</view>
</picker>
<image src="../../static/img/right1.png" mode=""></image>
</view>
</view>
@ -21,7 +24,7 @@
</view>
</view>
<view class="info_item_input">
<input type="text">
<input type="text" v-model="query.consignee.consignee">
</view>
</view>
<view class="address_info_item">
@ -31,17 +34,17 @@
</view>
</view>
<view class="info_item_input">
<input type="text">
<input type="number" v-model="query.consignee.mobile">
</view>
</view>
<view class="address_info_item">
<view class="info_item_title">
<view>
<text>Stree adderss or P.O.Box</text>
<text>*Stree adderss or P.O.Box</text>
</view>
</view>
<view class="info_item_input">
<input type="text">
<input type="text" v-model="query.consignee.address">
</view>
</view>
<view class="address_info_item">
@ -51,34 +54,63 @@
</view>
</view>
<view class="info_item_input">
<input type="text">
<input type="text" v-model="query.consignee.sign_building">
</view>
</view>
<view class="address_info_item">
<view class="info_item_title">
<view class="address_info_item address_info_item1">
<view class="info_item_title" v-if="isSelect1">
<picker @change="bindPickerChange2" :value="cityIndex" :range="cityList" range-key="region_name" class="info_item_title_pick">
<text >*City/Town</text>
<view class="info_item_title_span">{{cityText}}</view>
</picker>
<image src="../../static/img/right1.png" mode=""></image>
</view>
<template v-else>
<view class="info_item_title" >
<text >*City/Town</text>
</view>
<view class="info_item_input">
<input type="text" v-model="city">
</view>
</template>
<!-- <view class="info_item_title">
<view>
<text>*City/Town</text>
</view>
</view>
<view class="info_item_input">
<input type="text">
</view>
<input type="text" v-model="city">
</view> -->
</view>
</view>
<view class="address_info">
<view class="address_info_item">
<view class="info_item_title">
<view>
<text class="info_item_title_span">State/Province</text>
</view>
<image src="../../static/img/bottom.png" mode=""></image>
</view>
<view class="info_item_input">
<input type="text">
<view class="address_info_item address_info_item1">
<view class="info_item_title" v-if="isSelect">
<picker @change="bindPickerChange1" :value="provinceIndex" :range="provinceList" range-key="region_name" class="info_item_title_pick">
<text >State/Province</text>
<view class="info_item_title_span">{{provinceText}}</view>
</picker>
<image src="../../static/img/right1.png" mode=""></image>
</view>
<template v-else>
<view class="info_item_title" >
<text >State/Province</text>
</view>
<view class="info_item_input">
<input type="text" v-model="province">
</view>
</template>
</view>
<view class="address_info_item">
@ -88,38 +120,149 @@
</view>
</view>
<view class="info_item_input">
<input type="text">
<input type="text" v-model="query.consignee.zipcode">
</view>
</view>
</view>
<view class="address_switch">
<text>Make this my default address</text>
<switch checked="true" color="#B22234"/>
<switch :checked="query.is_default==1" color="#B22234" @change="isDefault"/>
</view>
<view class="address_submit">
<button>FINISH</button>
<button @click="save">FINISH</button>
</view>
</view>
</template>
<script>
import {defaultRequest2} from '../../api/index.js'
import {defaultRequest2,defaultRequest3} from '../../api/index.js'
export default {
data() {
return {
isSelect:false,
isSelect1:false,
countryList:[],
index:0,
countryText:'',
provinceList:[],
provinceIndex:0,
provinceText:'',
cityList:[],
cityIndex:0,
cityText:'',
query:{
_action:'saveconsignee',
consignee:{
address_id:0,
consignee:'',
country:0,
province:0,
city:0,
district:1,
address:'',
zipcode:'',
email:'',
tel:'',
mobile:'',
sign_building:'',
best_time:''
},
is_default:0
},
province:'',
city:''
}
},
methods:{
//
save(){
if(!this.isSelect1){
this.query.consignee.address=this.city+this.query.consignee.address
}
if(!this.isSelect){
this.query.consignee.address=this.province+this.query.consignee.address
}
console.info(this.query)
defaultRequest3(this.query).then(res=>{
console.info(res)
if(res.error==0){
uni.showToast({
icon:'none',
title:res.message
})
uni.navigateBack()
}
})
},
//
isDefault(e){
console.info(e)
if(e.detail.value){
this.query.is_default=1
}else{
this.query.is_default=0
}
},
//
getCountry(){
let data={_action:'getregions',parent_region_id:0}
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
this.countryList=res.data
}
})
},
//
bindPickerChange(e){
this.index=e.detail.value
if(this.countryList[this.index].regions){
this.isSelect=true
this.provinceList=this.countryList[this.index].regions
}else{
this.isSelect=false
this.isSelect1=false
this.provinceText=''
this.cityText=''
}
this.query.consignee.country=this.countryList[this.index].region_id
this.countryText=this.countryList[this.index].region_name
},
//
bindPickerChange1(e){
console.info(e.detail.value)
this.provinceIndex=e.detail.value
if(this.provinceList[this.provinceIndex].regions){
this.isSelect1=true
this.cityList=this.provinceList[this.index].regions
}else{
this.isSelect1=false
this.cityText=''
}
this.query.consignee.province=this.provinceList[this.provinceIndex].region_id
this.provinceText=this.provinceList[this.provinceIndex].region_name
},
//
bindPickerChange2(e){
this.cityIndex=e.detail.value
this.query.consignee.city=this.cityList[this.cityIndex].region_id
this.cityText=this.cityList[this.cityIndex].region_name
}
},
onLoad() {
this.getCountry()
}
}
</script>
<style lang="scss" scoped>
<style>
page{
background-color: #F6F5FA;
padding-bottom: 20rpx;
}
</style>
<style lang="scss" scoped>
.address_serch{
background-color: white;
padding: 26.67rpx 24rpx;
@ -160,6 +303,10 @@
align-items: center;
font-weight: bold;
margin-bottom: 10rpx;
.info_item_title_pick{
width: 100%;
}
.info_item_title_span{
color: black;
margin-top: 15.33rpx;

22
pages/account/address.vue

@ -1,15 +1,15 @@
<template>
<view>
<view class="address_item" v-for="(item,index) in 2" :key="index">
<view class="address_item" v-for="(item,index) in list" :key="index">
<view class="address_info">
<view class="address_info_title">
<view class="info_title_span">Nathanael</view>
<text>5838590290</text>
<view class="info_title_span">{{item.consignee}}</view>
<text>{{item.mobile}}</text>
</view>
<view class="address_info_content">
<view class="info_content_left">
<view>B Oakdale Mall</view>
<text>Johnson City NEW YORKUnitedStates13790-1294</text>
<view>{{item.sign_building}} </view>
<text>{{item.country_name}} {{item.province_name}} {{item.city_name}} {{item.address}} {{item.mobile}}</text>
</view>
<image src="../../static/img/update.png" mode=""></image>
</view>
@ -42,7 +42,7 @@
},
methods:{
getList(){
let data={_action:'cleargoodsbrowsehistory'}
let data={_action:'getconsignees'}
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
@ -51,17 +51,19 @@
})
}
},
onLoad() {
onShow() {
this.getList()
}
}
</script>
<style lang="scss" scoped>
<style>
page{
background-color: #F6F5FA;
padding-bottom: 160rpx;
}
</style>
<style lang="scss" scoped>
.address_foot{
padding: 42rpx 24rpx;
background-color: white;
@ -105,9 +107,11 @@
.address_info_content{
display: flex;
align-items: center;
width: 100%;
.info_content_left{
padding-right: 38.67rpx;
margin-right: 34rpx;
min-width: 100%;
border-right: 1px solid #E2E2E2;
}
image{

1
pages/account/settings.vue

@ -19,7 +19,6 @@
<view class="profile_item ">
<text>Legal</text>
<image src="../../static/img/right1.png" mode="" class="right_img"></image>
</view>
<view class="set_button">
<button @click="signOut">SIGN OUT</button>

Loading…
Cancel
Save