Commit 85d3782a authored by 刘帅阳's avatar 刘帅阳

修改

parent d6e9cff5
<template>
<view class="wrap">
<view class="top">
<view class="item">
<view class="left">收货人</view>
<input type="text" placeholder-class="line" placeholder="请填写收货人姓名" v-model="address.name" />
</view>
<view class="item">
<view class="left">手机号码</view>
<input type="text" placeholder-class="line" placeholder="请填写收货人手机号" v-model="address.tel" />
</view>
<view class="item" @tap="showRegionPicker">
<view class="left">所在地区</view>
<input disabled type="text" placeholder-class="line" placeholder="省市区县、乡镇等" v-model="addressShowValue" />
</view>
<view class="item address">
<view class="left">详细地址</view>
<textarea type="text" placeholder-class="line" placeholder="街道、楼牌等" v-model="address.addressDetail" />
</view>
</view>
<view class="bottom">
<view class="default">
<view class="left">
<view class="set">设置默认地址</view>
<view class="tips">提醒:每次下单会默认推荐该地址</view>
</view>
<view class="right"><u-switch v-model="address.isDefault" @change = "changeDefault"></u-switch></view>
</view>
</view>
<u-button type="error" shape="circle" @click="save">保存</u-button>
<br>
<u-button type="default" shape="circle" v-if="id!=''" @click="del">删除</u-button>
<u-picker mode="region" ref="uPicker" v-model="show" :area-code="defaultRegion" @confirm="confirmArea" />
</view>
</template>
<script>
export default {
data() {
return {
choose:true,
show: false,
id:'',
address:{isDefault:false},
defaultRegion:['','','']
};
},
computed:{
addressShowValue(){
if(this.address.province){
return this.address.province+' '+this.address.city+' '+this.address.district;
}
}
},
onLoad(option){
this.id = option.id
if(option.choose){
this.choose = option.choose
}
if(this.id){
this.init()
}else{
this.id = ''
//显示默认的地区
this.defaultRegion = ["11", "1101", "110101"]
}
},
methods: {
init(){
this.$u.get('user/address/'+this.id).then( res => {
const code1 = res.areaCode.substr(0,2)
const code2 = res.areaCode.substr(0,4)
const code3 = res.areaCode
this.defaultRegion = [code1,code2,code3]
this.address = res
});
},
setDefault() {},
showRegionPicker() {
this.show = true
},
confirmArea(e){
this.address.areaCode = e.area.value
//设置选择器默认值
this.defaultRegion = [e.province.value,e.city.value,e.area.value]
//设置输入框值
this.address = Object.assign({},this.address)
this.address.province = e.province.label
this.address.city = e.city.label
this.address.district = e.area.label
},
changeDefault(e){
if(this.address.id){
this.$u.post('user/address/'+this.address.id+'/'+e).then( res => {
this.$u.toast(e?'设置默认地址':'取消默认地址')
})
}
},
save(){
this.$u.post('user/address/save',this.address).then( res => {
if(this.choose){
let idCarts = uni.getStorageSync('idCarts')
if (idCarts && idCarts !== '') {
uni.setStorageSync('chooseAddrId', res.id);
// this.$u.route({
// url:'/pages/checkout/checkout',
// params:{
// ids:idCarts
// }
// })
}else{
this.$u.route('/address/address/list')
}
}else{
this.$u.route('/address/address/list')
}
})
},
del(){
this.$u.delete('user/address/'+this.address.id).then( res => {
this.$u.route('/address/address/list')
})
}
}
};
</script>
<style lang="scss" scoped>
.wrap {
padding:0rpx 30rpx;
.top {
padding: 22rpx;
.item {
display: flex;
font-size: 32rpx;
line-height: 100rpx;
align-items: center;
border-bottom: solid 2rpx $u-border-color;
.left {
width: 180rpx;
}
input {
text-align: left;
}
}
.address {
padding: 20rpx 0;
textarea {
// width: 100%;
height: 150rpx;
background-color: #f7f7f7;
line-height: 60rpx;
margin: 40rpx auto;
padding: 20rpx;
}
}
.site-clipboard {
padding-right: 40rpx;
textarea {
// width: 100%;
height: 150rpx;
background-color: #f7f7f7;
line-height: 60rpx;
margin: 40rpx auto;
padding: 20rpx;
}
.clipboard {
display: flex;
justify-content: center;
align-items: center;
font-size: 26rpx;
color: $u-tips-color;
height: 80rpx;
.icon {
margin-top: 6rpx;
margin-left: 10rpx;
}
}
}
}
.bottom {
margin-top: 20rpx;
padding: 40rpx;
padding-right: 0;
background-color: #ffffff;
font-size: 28rpx;
.tag {
display: flex;
.left {
width: 160rpx;
}
.right {
display: flex;
flex-wrap: wrap;
.tags {
width: 140rpx;
padding: 16rpx 8rpx;
border: solid 2rpx $u-border-color;
text-align: center;
border-radius: 50rpx;
margin: 0 10rpx 20rpx;
display: flex;
font-size: 28rpx;
align-items: center;
justify-content: center;
color: $u-content-color;
line-height: 1;
}
.plus {
//padding: 10rpx 0;
}
}
}
.default {
margin-top: 50rpx;
display: flex;
justify-content: space-between;
border-bottom: solid 2rpx $u-border-color;
line-height: 64rpx;
.tips {
font-size: 24rpx;
}
.right {
}
}
}
}
</style>
<template>
<view class="wrap">
<u-radio-group>
<view class="item" v-for="(res, index) in addrList" :key="res.id">
<u-row>
<u-col :span="1" v-if="choose">
<u-radio @change="chgRadio(res.id)" :name="res.id"></u-radio>
</u-col>
<u-col :span="choose==true?11:12">
<view class="top">
<view class="name">{{ res.name }}</view>
<view class="phone">{{ res.tel }}</view>
<view class="tag" v-if="res.isDefault">
<text class="red">默认</text>
</view>
</view>
<view class="bottom">
{{res.wholeAddressInfo}}
<u-icon name="edit-pen" :size="40" color="#999999" @click="toEditAddr(res.id)"></u-icon>
</view>
</u-col>
</u-row>
</view>
</u-radio-group>
<view class="addSite" @tap="toAddAddr">
<view class="add">
<u-icon name="plus" color="#ffffff" class="icon" :size="30"></u-icon>新建收货地址
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
siteList: [],
addrList: [],
choose: false
};
},
onLoad(option) {
if (option.choose) {
this.choose = true
}
},
onShow() {
this.init()
},
methods: {
init() {
this.$u.get('user/address/queryByUser').then(res => {
this.addrList = res;
});
},
toEditAddr(id) {
this.$u.route({
url: '/address/address/address',
params: {
id: id
}
})
},
toAddAddr() {
this.$u.route({
url: '/address/address/address',
params: {
choose: this.choose
}
})
},
chgRadio(id){
uni.setStorageSync('chooseAddrId', id)
this.$u.route({
type:'navigateBack',
delta:1
})
return true
}
}
};
</script>
<style lang="scss" scoped>
.wrap {
padding: 0rpx 30rpx;
.item {
width:100%;
padding: 40rpx 20rpx;
.top {
display: flex;
font-weight: bold;
font-size: 34rpx;
.phone {
margin-left: 60rpx;
}
.tag {
display: flex;
font-weight: normal;
align-items: center;
text {
display: block;
width: 60rpx;
height: 34rpx;
line-height: 34rpx;
color: #ffffff;
font-size: 20rpx;
border-radius: 6rpx;
text-align: center;
margin-left: 30rpx;
background-color: rgb(49, 145, 253);
}
.red {
background-color: red
}
}
}
.bottom {
display: flex;
margin-top: 20rpx;
font-size: 28rpx;
justify-content: space-between;
color: #999999;
}
}
.addSite {
display: flex;
justify-content: space-around;
width: 600rpx;
line-height: 100rpx;
position: absolute;
bottom: 30rpx;
left: 80rpx;
background-color: red;
border-radius: 60rpx;
font-size: 30rpx;
.add {
display: flex;
align-items: center;
color: #ffffff;
.icon {
margin-right: 10rpx;
}
}
}
}
</style>
This diff is collapsed.
<template>
<view>
<u-tabs :list="vuex_navlist" :is-scroll="false" :current="activeNav" @change="changeNav"></u-tabs>
<u-swiper :list="banners" @click="clickBanner"></u-swiper>
<view>
<view class="gl-body">
<u-row v-for="(item,index) in goodsList" :key="index">
<u-col :span="4" class="gl-img">
<u-image width="170rpx" height="170rpx" :src="item.img" @click="toDetail(item.id)"></u-image>
</u-col>
<u-col :span="8" @click="toDetail(item.id)">
<view class="gl-name">{{item.name}}</view>
<view class="gl-descript">{{item.descript}}</view>
<view class="gl-price">{{formatPrice(item.price)}}</view>
</u-col>
</u-row>
<u-loadmore :status="status" />
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
activeNav: 1,
banners: [],
originBanners: [],
goodsList: [],
listQuery: {
page: 1,
limit: 20,
idCategory: undefined
},
total: 0,
status: 'loadmore'
}
},
onLoad(option) {
this.activeNav = option.itemId
this.listQuery.page = 1
this.goodsList = []
this.init()
},
onReachBottom() {
this.listQuery.page = this.listQuery.page + 1
this.getGoods(this.activeNav)
},
methods: {
init() {
this.getBanners(this.activeNav)
this.getGoods(this.activeNav)
},
async getBanners(categoryIndex) {
const baseApi = this.baseApi
let bannerList = null
let navList = this.vuex_navlist
if (navList.length == 0) {
let ret = await this.$u.get('category/list');
navList = ret;
navList.splice(0, 0, {
name: '推荐',
id: '0'
})
this.$u.vuex('vuex_navlist', navList);
}
for (const i in navList) {
if (navList[i].id == categoryIndex) {
bannerList = navList[i].bannerList
}
}
this.originBanners = bannerList;
let imgList = new Array()
for (let i = 0; i < bannerList.length; i++) {
imgList.push({
image: baseApi + '/file/getImgStream?idFile=' + bannerList[i].idFile
})
}
this.banners = imgList
},
changeNav(index) {
this.activeNav = index
if (index == 0) {
this.$u.route({
type: 'switchTab',
url: '/pages/shop/index'
})
} else {
this.listQuery.page = 1
this.goodsList = []
this.getBanners(index)
this.getGoods(index)
}
},
clickBanner(index) {
let banners = this.originBanners
for (let i = 0; i < banners.length; i++) {
if (index == i) {
let url = ''
let page = banners[i].page
if (page != '') {
if (page.indexOf('http') === 0) {
url = page
} else {
url = '/goods/' + banners[i].page
}
}
if (banners[i].param != '' && banners[i].param != null) {
const param = JSON.parse(banners[i].param);
this.$u.route({
url: url,
params: param
});
}
if (url.startsWith("http")) {
window.location.href = url
}
}
}
},
getGoods(idCategory) {
this.status = 'loading'
this.listQuery['idCategory'] = idCategory
const page = this.listQuery.page
const limit = this.listQuery.limit
const baseApi = this.baseApi;
this.$u.get('goods/queryGoods?page=' + page + '&limit=' + limit + '&idCategory=' + idCategory).then(res => {
let list = res.records
this.total = res.total
if (list.length < limit) {
this.status = 'nomore'
} else {
this.status = 'loadmore'
}
for (var index in list) {
const item = list[index]
item.img = baseApi + '/file/getImgStream?idFile=' + item.pic
this.goodsList.push(item)
}
}).catch((err) => {
Toast(err)
})
},
formatPrice(price) {
return (price / 100).toFixed(2)
},
toDetail(id) {
this.$u.route({
url: '/goods/goods/goods',
params: {
id: id
}
})
}
}
}
</script>
<style>
.gl-title {
padding: 20rpx;
}
.gl-img {
padding: 30rpx;
}
.gl-name {
font-size: 26rpx;
}
.gl-descript {
font-size: 20rpx;
}
.gl-price {
font-size: 24rpx;
color: #FA3534;
}
</style>
......@@ -109,7 +109,7 @@
},
"quickapp" : {},
"mp-weixin" : {
"appid" : "wx1ae10de4e32e12c1",
"appid" : "wxbf6bd5cf0be78539",
"setting" : {
"urlCheck" : true,
"es6" : true,
......
......@@ -112,34 +112,7 @@
}
],
"subPackages": [
{
"root": "address",
"pages": [
{
"path": "address/list",
"style": {
"navigationBarTitleText": "收货地址"
}
}, {
"path": "address/address",
"style": {
"navigationBarTitleText": "编辑收货地址"
}
}
]
},
{
"root": "goods",
"pages": [
{
"path": "goods/goods",
"style": {}
}, {
"path": "goods/list",
"style": {}
}
]
},
{
"root": "login",
"pages": [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment