You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

728 lines
18 KiB

2 years ago
<template>
<page-meta :page-style="'overflow:'+(showinfo?'hidden':'visible')"></page-meta>
<view class="cotainer">
<view class="orderInfo">
2 years ago
<view class="orderInfo-title">
<view>{{cardInfo.sku?cardInfo.sku.name:''}}</view>
2 years ago
</view>
<view class="orderInfo-info">
2 years ago
<image :src="require('@/static/share.jpg')"></image>
2 years ago
<view>
2 years ago
<view>
{{cardInfo.sku?cardInfo.sku.specs:''}}
</view>
<view>
<view>今日剩余可提货量</view>
<view>99</view>
</view>
<view>
<view>卡券状态</view>
<view class="status" v-html="cardInfo.status_label"></view>
</view>
2 years ago
</view>
2 years ago
</view>
<view class="orderInfo-status">
<view>提货时间</view>
<view @click="openDatePicker">
<view class="">
<view>顺丰快递</view>
<view>9月28日 [周三] 09:00-15:00</view>
</view>
<view>
<u-icon name="arrow-down-fill" color="#ccc" size='28'></u-icon>
</view>
2 years ago
</view>
</view>
</view>
2 years ago
<date-picker ref="datePickers" :data="listDates" :express="listExpress"></date-picker>
2 years ago
<view class="orderForm">
2 years ago
<u-form :model="form" ref="uForm" :error-type="['border-bottom']">
<!-- <u-form-item label="预约提货时间" required prop="send_date" label-position="top">
2 years ago
<u-input v-model="form.send_date" placeholder="请选择预约提货时间" @click="showCalendar = true"
2 years ago
type="hidden" />
</u-form-item> -->
<view class="orderForm-wrap">
<u-form-item label="收货人" label-width="180" prop="contact" label-position="left">
<u-input v-model="form.contact" placeholder="请填写收货人姓名" />
</u-form-item>
<u-form-item label="手机号码" label-width="180" prop="mobile" label-position="left">
<u-input v-model="form.mobile" placeholder="请填写手机号码" />
</u-form-item>
<u-form-item label="备用号码" label-width="180" prop="mobile2" label-position="left">
<u-input v-model="form.mobile2" placeholder="请填写备用号码" />
</u-form-item>
<u-form-item label="所在地区" prop="area" label-width="180" label-position="left">
<u-input v-model="form.area" placeholder="请选择所在地区" @click="openArea" />
<view slot="right" class="arearight" @click="changeLocation">
<u-icon name="map"></u-icon>
定位
</view>
</u-form-item>
<u-form-item label="详细地址" label-width="180" prop="address" label-position="left">
<u-input v-model="form.address" placeholder="请填写详细地址" />
</u-form-item>
<u-form-item label="设置默认地址" :border-bottom="false" label-width="180" prop="checked"
label-position="left">
<u-switch slot="right" v-model="form.checked" active-color="#ba8b45" inactive-color="#adadac"
size="40"></u-switch>
</u-form-item>
</view>
<!-- <view class="orderForm-address">
2 years ago
<text><text>*</text>收货地址</text>
<u-button @click="changeLocation" size="mini">获取位置</u-button>
2 years ago
</view> -->
<view class="orderForm-wrap">
<u-form-item label="是否本人收货" label-width="180" prop="myself" label-position="left">
<u-input v-model="myself" placeholder="选填" @click="showIsMySelf = true" type="select" />
</u-form-item>
<u-form-item label="购买人姓名" label-width="180" prop="buy_name" label-position="left">
<u-input v-model="form.buy_name" placeholder="选填" />
</u-form-item>
<u-form-item label="购买人电话" :border-bottom="false" label-width="180" prop="buy_mobile"
label-position="left">
<u-input v-model="form.buy_mobile" placeholder="选填" />
</u-form-item>
2 years ago
</view>
2 years ago
2 years ago
</u-form>
<view class="orderForm-btn">
2 years ago
<view @click="submit"></view>
2 years ago
</view>
2 years ago
</view>
2 years ago
<!-- <u-calendar max-date="2050-12-31" v-model="showCalendar" @change="changeDate" :mode="'date'"></u-calendar> -->
<!-- <u-picker mode="region" v-model="showArea" @confirm="changeArea"></u-picker> -->
<aui-picker ref="pickers" :title="'地区选择'" :data="listArea" @callback="changeArea"></aui-picker>
<u-select @confirm="changeDate" v-model="showCalendar" :list="listDates"></u-select>
<u-select @confirm="changeIsMySelf" v-model="showIsMySelf" :list="listIsMySelf"></u-select>
<!-- 确认信息 -->
<view class="showinfo" v-if="showinfo">
<view class="content">
<view class="showinfo-info">
<view>您提货的商品是</view>
<u-image :src="require('@/static/share.jpg')" width="450" height="450"></u-image>
<view>{{cardInfo.sku?cardInfo.sku.name:''}}{{cardInfo.sku?cardInfo.sku.specs:''}}</view>
</view>
<view class="showinfo-wrap">
<view>发货时间</view>
<view style="text-align: center;">{{momentDay(date)}}</view>
</view>
<view class="showinfo-wrap">
<view>收货信息</view>
<view>
<view>
<text>收货人</text>
<text>{{form.contact}}</text>
</view>
<view>
<text>收货人电话</text>
<text>{{form.mobile}}</text>
</view>
<view>
<text>收货地址</text>
<text>{{form.area}}{{form.address}}</text>
</view>
</view>
</view>
<view class="showinfo-btn">
<u-button @click="showinfo = false">返回修改</u-button>
<u-button type="primary" @click="submit"></u-button>
</view>
</view>
</view>
<!-- 选择地址 -->
<view class="addressinfo" v-if="showAddress">
<view class="content">
<view class="content-close" @click="showAddress=false">
<u-icon name="close-circle" color="#000" size="50"></u-icon>
</view>
<view class="content-wrap">
<u-radio-group v-model="addressInfo" @change="changeAddress">
<u-radio v-for="(item, index) in listAddress" :key="index" :name="item.id">
<view class="content-contact">{{item.contact}} {{item.mobile}}</view>
<view class="content-address">{{item.area}}{{item.address}}</view>
</u-radio>
</u-radio-group>
</view>
</view>
</view>
</view>
</template>
<script>
import {
toast,
isMobile,
isNull
} from '@/common/util.js'
import solarLunar from '@/node_modules/solarlunar';
2 years ago
import auiPicker from '@/components/aui-picker.vue';
import datePicker from '@/components/date-picker/date-picker.vue'
2 years ago
export default {
components: {
2 years ago
auiPicker,
datePicker
2 years ago
},
data() {
return {
showinfo: false,
showAddress: false,
listAddress: [],
addressInfo: '',
cardInfo: {},
form: {
card_number: '',
password: '',
send_date: '',
area: '',
address: '',
province_id: '',
city_id: '',
district_id: '',
contact: '',
mobile: '',
mobile2: '',
2 years ago
checked: false,
2 years ago
myself: 1,
buy_name: '',
buy_mobile: ''
2 years ago
},
listExpress:[{
id:0,
value:'顺丰快递'
},{
id:1,
value:'中通快递'
}],
2 years ago
listDates: [],
showCalendar: false,
date: '',
listArea: [],
showArea: false,
showIsMySelf: false,
myself: '是',
listIsMySelf: [{
value: 1,
label: '是'
}, {
value: 0,
label: '否'
}],
rules: {
send_date: [{
required: true,
message: '请选择预约提货时间',
trigger: ['change', 'blur'],
}],
area: [{
required: true,
message: '请选择收货地址',
trigger: ['change', 'blur'],
}],
address: [{
required: true,
message: '请填写详细地址',
trigger: ['blur'],
}],
contact: [{
required: true,
message: '请填写收货人姓名',
trigger: ['blur'],
}],
mobile: [{
required: true,
message: '请填写收货人电话',
trigger: ['blur'],
}, {
validator: (rule, value, callback) => {
return this.$u.test.mobile(value);
},
message: '手机号码不正确',
trigger: ['blur'],
}]
}
}
},
onReady() {
2 years ago
// this.$refs.uForm.setRules(this.rules);
2 years ago
},
onLoad(option) {
if (option.hasCard) {
this.cardInfo = uni.getStorageSync("vuex_card") ? uni.getStorageSync("vuex_card").card : {}
this.form.card_number = uni.getStorageSync("vuex_card") ? uni.getStorageSync("vuex_card").card_number : ''
this.form.password = uni.getStorageSync("vuex_card") ? uni.getStorageSync("vuex_card").password : ''
2 years ago
// uni.removeStorageSync("vuex_card")
2 years ago
this.getAddress()
this.getDates()
this.getArea()
} else {
toast("未查询到卡券信息")
uni.removeStorageSync("vuex_card")
uni.redirectTo({
url: '/pages/change/change'
})
}
},
methods: {
async getAddress() {
const res = await this.$u.api.getUserAddress()
this.listAddress = res.address
this.showAddress = this.listAddress.length > 0 ? true : false
},
changeAddress(e) {
console.log("e", e)
if (e) {
this.listAddress.map(item => {
if (item.id == e) {
this.form.address_id = item.id
this.form.area = item.area
this.form.address = item.address
this.form.province_id = item.province_id
this.form.city_id = item.city_id
this.form.district_id = item.district_id
this.form.contact = item.contact
this.form.mobile = item.mobile
this.showAddress = false
}
})
}
2 years ago
},
2 years ago
async getDates() {
await this.$u.api.getDates({
card_number: this.form.card_number,
2 years ago
password: this.form.password,
2 years ago
}).then(res => {
console.log("dare", res)
let data = res.card
if (data.open_dates) {
2 years ago
for (var k in data.open_dates) {
let _k = this.momentDay(k)
this.listDates.push(_k)
2 years ago
}
2 years ago
}
console.log("this.listDates",this.listDates)
2 years ago
}).then(res => {
})
2 years ago
},
momentDay(date) {
if (date) {
const weeks = ["周日", '周一', '周二', '周三', '周四', '周五', '周六', ]
let dateArr = date.split("-")
let ymd = this.$moment(date).format("M月DD日")
let week = weeks[this.$moment(date).day()]
const solar2lunarData = solarLunar.solar2lunar(dateArr[0], dateArr[1], dateArr[2]);
return {
ymd:ymd,
week:week,
lunarData:`农历${solar2lunarData.monthCn}${solar2lunarData.dayCn}`,
}
}
},
openDatePicker(){
this.$refs.datePickers.show = true
2 years ago
},
changeDate(e) {
console.log(e)
if (e) {
// this.form.send_date = e.result
// this.date = e
this.date = e[0].label
this.form.send_date = e[0].value
}
},
async getArea() {
const res = await this.$u.api.getRegion()
this.listArea = res.regions
console.log(res)
console.log(this.listArea)
},
openArea() {
this.$refs.pickers.open().then(function() {
console.log('picker打开');
});
},
changeArea(e) {
console.log(e)
// return
if (e) {
let data = e.data
let _this = this
data.forEach(function(item, index) {
_this.form.area += item.value + ' ';
});
this.form.province_id = data[0] ? data[0].id : ''
this.form.city_id = data[1] ? data[1].id : ''
this.form.district_id = data[2] ? data[2].id : ''
console.log(this.form)
// this.form.area = e.province.label + e.city.label + e.area.label
// this.$u.api.matchRegion({
// province: e.province.label,
// city: e.city.label,
// district: e.area.label
// }).then(res => {
// this.form.province_id = res.province_id ? res.province_id.id : ''
// this.form.city_id = res.city_id ? res.city_id.id : ''
// this.form.district_id = res.district_id ? res.district_id.id : ''
// })
}
},
changeIsMySelf(e) {
console.log(e)
if (e) {
this.myself = e[0].label
this.form.myself = e[0].value
}
},
changeLocation() {
console.log("location")
let _this = this
uni.authorize({
scope: 'scope.userLocation',
success: (res) => {
console.log("authorize", res)
uni.chooseLocation({
success(res) {
console.log("res", res)
_this.form.area = res.address
_this.form.address = res.name
},
fail(res) {
console.log("fail", res)
}
})
},
fail(res) {
console.log("authorize-fail", res)
}
})
},
submit() {
if ((!isNull(this.form.mobile2) && this.form.mobile2.length > 0) || (!isNull(this.form.buy_mobile) && this
.form.buy_mobile.length > 0)) {
if (!isMobile(this.form.mobile2)) {
toast('备用电话不正确')
return
}
if (!isMobile(this.form.buy_mobile)) {
toast('购买人电话不正确')
return
}
}
this.$refs.uForm.validate(valid => {
console.log('验证通过');
if (valid) {
if (!this.showinfo) {
this.showinfo = true
console.log("this.showinfo", this.showinfo)
} else {
console.log('submit');
this.form.show = 0
this.$u.api.addUserOrder(this.form).then(res => {
console.log("res", res)
uni.removeStorageSync('vuex_card')
toast(res.msg)
setTimeout(function() {
uni.redirectTo({
url: '/packages/myorder/myorder'
})
}, 2000)
}).then(res => {
console.log('res1', res)
})
}
} else {
console.log('验证失败');
}
});
}
}
}
</script>
<style lang="scss">
.cotainer {
2 years ago
padding: 29rpx 54rpx;
background-color: #f0efed;
padding-bottom: 200rpx;
2 years ago
.addressinfo {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, .5);
z-index: 9999999;
display: flex;
align-items: center;
justify-content: center;
.content {
width: 80%;
height: 600rpx;
position: relative;
&-wrap {
box-sizing: border-box;
background: #fff;
border-radius: 20rpx;
overflow: scroll;
width: 100%;
height: 100%;
padding: 40rpx;
}
&-close {
position: absolute;
top: -20rpx;
right: -20rpx;
}
.u-radio {
align-items: baseline;
}
&-contact {}
&-address {
color: #ccc;
line-height: 1.2;
font-size: 28rpx;
}
}
}
.showinfo {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, .5);
z-index: 9999999;
display: flex;
align-items: center;
justify-content: center;
.content {
width: 100vw;
height: 100vh;
padding: 40rpx;
box-sizing: border-box;
background: #fff;
// border-radius: 16rpx;
overflow: scroll;
}
&-info {
display: flex;
flex-wrap: wrap;
justify-content: center;
>view {
margin: 20rpx;
font-size: 36rpx;
&:last-child {
width: 350rpx;
color: #ccc;
font-size: 28rpx;
text-align: center;
}
}
}
&-wrap {
>view {
&:first-child {
text-align: center;
margin: 20rpx;
}
&:last-child {
border: 1px solid #333;
padding: 20rpx;
border-radius: 15rpx;
font-weight: bold;
>view {
margin-bottom: 10rpx;
}
}
}
}
&-btn {
display: flex;
align-items: center;
justify-content: center;
margin: 30rpx;
u-button {
margin: 0 20rpx;
}
}
}
.orderInfo {
2 years ago
padding: 40rpx 24rpx;
border-radius: 10rpx;
background-color: #fff;
font-size: 24rpx;
color: #000;
&-title {
2 years ago
>view {
2 years ago
font-size: 24rpx;
font-weight: bolder;
margin-bottom: 20rpx;
2 years ago
}
}
&-info {
display: flex;
2 years ago
font-weight: normal;
margin-bottom: 40rpx;
image {
width: 150rpx;
height: 150rpx;
border: 1px solid #ba8b45;
border-radius: 10rpx;
margin-right: 20rpx;
}
2 years ago
>view {
2 years ago
&:last-child {
width: calc(100% - 170rpx);
>view {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
.status {
background-color: #ba8b45;
color: #fff;
padding: 5rpx 20rpx;
border-radius: 10rpx;
}
}
}
2 years ago
}
}
&-status {
display: flex;
flex-wrap: wrap;
2 years ago
justify-content: space-between;
2 years ago
>view {
&:last-child {
2 years ago
text-align: right;
display: flex;
align-items: center;
2 years ago
2 years ago
>view {
&:first-child {
view {
margin-bottom: 15rpx;
&:last-child {
margin-bottom: 0rpx
}
}
}
&:last-child {
margin-left: 20rpx
}
}
2 years ago
}
}
}
}
.orderForm {
2 years ago
&-wrap {
padding: 40rpx 24rpx;
border-radius: 10rpx;
background-color: #fff;
font-size: 24rpx;
color: #000;
margin-top: 24rpx;
.u-form-item {
padding-bottom: 0
}
.arearight {
color: #000
}
}
2 years ago
&-address {
height: 72rpx;
display: flex;
justify-content: space-between;
align-items: center;
line-height: 72rpx;
padding-top: 20rpx;
position: relative;
text {
text {
position: absolute;
left: -16rpx;
vertical-align: middle;
color: #fa3534;
padding-top: 6rpx;
}
}
}
&-btn {
2 years ago
background: #fff;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
padding: 40rpx;
z-index: 9;
>view {
background-color: #ba8b45;
color: #fff;
border-radius: 40rpx;
width: 60%;
margin: 0 auto;
height: 75rpx;
text-align: center;
line-height: 75rpx;
}
2 years ago
}
}
}
</style>