123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- <template>
- <view>
- <u-navbar title="提交订单" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
- <view class="settlement">
- <view class="settlement-address">
- <view class="flex settlement-address-top" v-if="info.addr !== null">
- <view class="settlement-address-top__left">配送地址</view>
- <view class="flex settlement-address-top__right" @click="toAddress">
- <view class="">更改地址</view>
- <u-icon name="arrow-right" size="18" color="#237ED4 100%"></u-icon>
- </view>
- </view>
- <view class="flex settlement-address-top" v-else>
- <view class="settlement-address-top__left">配送地址</view>
- <view class="flex settlement-address-top__right" @click="toWeixinAddress">
- <view class="">微信地址</view>
- <u-icon name="arrow-right" size="18" color="#237ED4 100%"></u-icon>
- </view>
- </view>
- <view class="settlement-address-desc" v-if="info.addr !== null">
- <view class="settlement-address-desc__item">
- {{ `${ addr.province || '-' }-${ addr.city || '-' }-${ addr.area || '-' }` }}
- {{ addr.addr || '-' }}
- </view>
- <view class="settlement-address-desc__item">{{ addr.receiver || '-' }} {{ addr.mobile || '-' }}
- </view>
- </view>
- <view class="settlement-address-form" v-else>
- <view class="address-add">
- <u--form labelPosition="left" ref="form" labelWidth="90">
- <u-form-item label="收货人:" borderBottom required>
- <u--input v-model="form.receiver" border="none" placeholder="请输入收货人"></u--input>
- </u-form-item>
- <u-form-item label="手机号码:" borderBottom required>
- <u--input v-model="form.mobile" border="none" placeholder="请输入手机号码"></u--input>
- </u-form-item>
- <u-form-item label="所在地区:" borderBottom required @click="selectArea">
- <u--input v-model="form.cityShow" border="none" disabled disabledColor="#ffffff"
- placeholder="请选择地区">
- </u--input>
- <u-icon slot="right" name="arrow-right"></u-icon>
- </u-form-item>
- <u-form-item label="详细地址:" :borderBottom="false" required>
- <u--textarea v-model="form.addr" placeholder="请输入详细地址"></u--textarea>
- </u-form-item>
- </u--form>
- </view>
- <!-- 操作按钮 -->
- <view class="save-btn">
- <button :loading="loading" type="default" @click="saveAddress">保存并使用</button>
- </view>
- </view>
- </view>
- <view class="settlement-goods">
- <view class="flex settlement-goods__detail" v-for="(item, index) in list" :key="index">
- <view class="settlement-goods__detail__left">
- <view class="img">
- <image class="img" :src="item.picUrl" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="settlement-goods__detail__right">
- <view class="ells title">{{ item.title }}</view>
- <view class="sku" v-if="item.properties">规格:{{ item.properties }}</view>
- <view class="">数量:{{ item.goodsNum }}</view>
- </view>
- </view>
- </view>
- <view class="flex settlement-freight">
- <text style="margin-right: 30rpx;">留言</text>
- <u-input v-model="info.memo" placeholder="请输入留言" clearable inputAlign="right" border="none" />
- </view>
- <view class="flex settlement-freight">
- <text>运费</text>
- <text>¥{{ $numberFormat(info.freightAmt) }}</text>
- </view>
- </view>
-
- <view class="footer-fixed">
- <view v-if="info.freightType == 2" class="footer-fixed-color"><icon type="warn" style="vertical-align: bottom; margin-right: 20rpx; " size="20"/><text>当前收货地址暂不支持发货</text></view>
- <view class="flex btn">
- <view class="btn-left">
- <view class="money">
- <text>合计:</text>
- <text class="value">¥{{ $numberFormat(info.payAmt) }}</text>
- </view>
- </view>
- <view class="btn-rightTwo" v-if="info.freightType == 2">
- <text class="save" >提交</text>
- </view>
- <view class="btn-right" v-else>
- <text class="save" @click="save">提交</text>
- </view>
- </view>
- </view>
- <area-picker :area-show="areaShow" @cancel="cancel" @confirmArea="confirmArea" />
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- import AreaPicker from '../../components/area-picker/area-picker.vue'
- export default {
- components: {
- AreaPicker
- },
- data() {
- return {
- ids: [],
- info: {},
- addr: {},
- list: [],
- loading: false,
- addrId: '',
- form: {
- receiver: '',
- mobile: '',
- name: '',
- cityShow: '',
- addr: '',
- provinceId: '', // 省ID/编码
- province: '', // 省
- cityId: '', // 市ID/编码
- city: '', // 市
- areaId: '', // 区ID/编码
- area: '', // 区
- },
- areaShow: false,
- toAddressShow: false,
-
- wxAddress: {}
- }
- },
- onLoad(opthios) {
- if (opthios.ids) {
- this.ids = JSON.parse(opthios.ids)
- this.getDetail()
- }
- },
- onShow() {
- if (this.toAddressShow) {
- this.getDetail()
- }
- },
- methods: {
- save() {
- if (this.info.addr == null) {
- uni.$u.toast('请先保存配送地址');
- return
- }
- let _this = this
- let payIng = false
- if (payIng) return
- uni.showLoading({
- title: '加载中'
- });
- $http.post('/api/v1/mp/user/deliver/order/submit', this.info).then(res => {
- payIng = true
- uni.hideLoading();
- if (res.code == 0) {
- console.log(res)
- if (res.data.needPay == 1) {
- $http.post('/api/v1/mp/user/deliver/order/pay', {
- orderId: res.data.orderId,
- payType: 2
- }).then(ele => {
- if (ele.code == 0) {
- uni.requestPayment({
- timeStamp: ele.data.timeStamp,
- nonceStr: ele.data.nonceStr,
- package: ele.data.package,
- signType: ele.data.signType,
- paySign: ele.data.paySign,
- success() {
- uni.showToast({
- title: '支付成功',
- icon: 'success',
- duration: 2000
- })
- setTimeout(() => {
- uni.redirectTo({
- url: `/packageGoods/order/index`
- })
- }, 500)
- },
- fail() {
- payIng = false
- setTimeout(() => {
- uni.redirectTo({
- url: `/packageGoods/order/index`
- })
- }, 500)
- }
- })
- } else {
- payIng = false
- uni.$u.toast('支付失败!');
- setTimeout(() => {
- uni.redirectTo({
- url: `/packageGoods/order/index`
- })
- }, 500)
- }
- }).catch(() => {
- payIng = false
- uni.$u.toast('支付失败!');
- setTimeout(() => {
- uni.redirectTo({
- url: `/packageGoods/order/index`
- })
- }, 500)
- })
- } else {
- uni.showToast({
- title: '提交成功',
- icon: 'success',
- duration: 2000
- })
- setTimeout(() => {
- uni.redirectTo({
- url: `/packageGoods/order/index`
- })
- }, 500)
- }
- } else {
- payIng = false
- uni.$u.toast('提交失败!');
- }
- }).catch(() => {
- payIng = false
- uni.$u.toast('提交失败!');
- uni.hideLoading();
- })
- },
- getDetail() {
- uni.showLoading({
- title: '加载中'
- });
- $http.post('/api/v1/mp/user/deliver/order/settle', {
- ids: this.ids
- }).then(res => {
- uni.hideLoading();
- if (res.code == 0) {
- this.info = res.data
- this.addr = res.data.addr
- res.data.prizeList.forEach(item => {
- let picUrlArr = item.picUrl.split(',')
- item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
- })
- this.list = res.data.prizeList
- }
- }).catch(() => {
- uni.hideLoading();
- })
- },
- selectArea() {
- this.areaShow = true
- },
- confirmArea(obj) {
- this.form.province = obj.province
- this.form.provinceId = obj.provinceId
- this.form.city = obj.city
- this.form.cityId = obj.cityId
- this.form.area = obj.area
- this.form.areaId = obj.areaId
- this.form.cityShow = obj.cityShow
- this.areaShow = false
- },
- cancel() {
- this.areaShow = false
- },
- toAddress() {
- this.toAddressShow = true
- uni.navigateTo({
- url: "/packageOperate/address/index"
- })
- },
- toWeixinAddress() {
- let _this = this
- uni.chooseAddress({
- success(res) {
- _this.wxAddress = res
- _this.getArea()
- }
- })
- },
-
- // 回显微信地址
- async getArea() {
- // 获取省
- let provinceRes = await $http.post('/api/v1/mp/area/listByPid', {
- pid: 0
- })
- let provinceItem = provinceRes && provinceRes.data.find((item=> item.areaName == this.wxAddress.provinceName))
- // 获取市
- let cityRes = await $http.post('/api/v1/mp/area/listByPid', {
- pid: provinceItem && provinceItem.areaId
- })
- let cityItem = cityRes && cityRes.data.find((item=> item.areaName == this.wxAddress.cityName))
- // 获取区
- let areaRes = await $http.post('/api/v1/mp/area/listByPid', {
- pid: cityItem && cityItem.areaId
- })
- let areaItem = areaRes && areaRes.data.find((item=> item.areaName == this.wxAddress.countyName))
- // 赋值
- this.form.province = provinceItem.areaName
- this.form.provinceId = provinceItem.areaId
- this.form.city = cityItem.areaName
- this.form.cityId = cityItem.areaId
- this.form.area = areaItem.areaName
- this.form.areaId = areaItem.areaId
- this.form.cityShow = `${ provinceItem.areaName }-${ cityItem.areaName }-${ areaItem.areaName }`
- this.form.addr = this.wxAddress.detailInfo
- this.form.receiver = this.wxAddress.userName
- this.form.mobile = this.wxAddress.telNumber
- },
- saveAddress() {
- let _this = this
- if (!_this.form.receiver) {
- uni.$u.toast('请输入收货人');
- return
- }
- if (!_this.form.mobile) {
- uni.$u.toast('请输入手机号码');
- return
- }
- const rule = /^[1][0-9][0-9]{9}$/
- if (!rule.test(_this.form.mobile)) {
- uni.$u.toast('请输入正确的手机号');
- return
- }
- if (!_this.form.cityShow) {
- uni.$u.toast('请选择所在地区');
- return
- }
- if (!_this.form.addr) {
- uni.$u.toast('请输入详细地址');
- return
- }
- let url = '/api/v1/mp/user/addr/create'
- $http.post(url, this.form).then(res => {
- if (res.code == 0) {
- uni.$u.toast('保存成功');
- this.getDetail()
- }
- })
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .settlement {
- margin: 10rpx;
- padding-bottom: 100rpx;
- &-address {
- background-color: #fff;
- padding: 0 16rpx 24rpx;
- margin-bottom: 20rpx;
- &-top {
- justify-content: space-between;
- padding: 24rpx 0;
- border-bottom: 1px solid rgba(236, 236, 236, 100);
- &__left {
- line-height: 40rpx;
- }
- &__right {
- line-height: 40rpx;
- color: rgba(35, 126, 212, 100);
- }
- }
- &-desc {
- &__item {
- line-height: 40rpx;
- margin-top: 16rpx;
- }
- }
- &-form {
- .save-btn {
- padding: 10rpx 20rpx;
- /deep/ button {
- line-height: 76rpx;
- font-size: 28rpx;
- height: 76rpx;
- color: #fff;
- background-color: $uni-bg-color;
- border: none;
- border-radius: 100rpx;
- }
- }
- }
- }
- &-goods {
- background-color: #fff;
- padding: 0 40rpx;
- margin-bottom: 20rpx;
- &__detail {
- padding: 20rpx 0;
- justify-content: space-between;
- border-bottom: 1px solid rgba(236, 236, 236, 100);
- &__left {
- display: flex;
- height: 170rpx;
- .img {
- image {
- width: 170rpx;
- height: 170rpx;
- margin-right: 20rpx;
- }
- }
- }
- &__right {
- flex: 1;
- display: flex;
- height: 170rpx;
- flex-direction: column;
- justify-content: space-between;
- align-items: flex-start;
- font-size: 30rpx;
- .title {
- font-weight: bold;
- }
- .sku {
- color: #848484;
- }
- }
- }
- &__detail:last-child {
- border: none;
- }
- }
- &-freight {
- margin-bottom: 20rpx;
- background-color: #fff;
- justify-content: space-between;
- padding: 20rpx 16rpx;
- }
- }
- .footer-fixed {
- position: fixed;
- bottom: var(--window-bottom);
- left: 0;
- right: 0;
- // min-height: 120rpx;
- z-index: 11;
- box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
- background: #fff;
- // margin-bottom: 40rpx;
- // 设置ios刘海屏底部横线安全区域
- padding-bottom: constant(safe-area-inset-bottom);
- padding-bottom: env(safe-area-inset-bottom);
- &-color {
- font-size: 30rpx;
- color: $uni-text-color;
- margin: 10rpx 40rpx;
- }
- .btn {
- justify-content: space-between;
- padding: 20rpx 40rpx;
- &-left {
- .value {
- color: $uni-text-color;
- }
- }
- &-right {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- .save {
- width: 190rpx;
- height: 60rpx;
- line-height: 60rpx;
- border-radius: 8rpx;
- text-align: center;
- margin-left: 40rpx;
- background-color: rgba(236, 112, 9, 100);
- color: rgba(255, 255, 255, 100);
- }
- }
- &-rightTwo {
- display: flex;
- align-items: center;
- justify-content: flex-end;
-
- .save {
- width: 190rpx;
- height: 60rpx;
- line-height: 60rpx;
- border-radius: 8rpx;
- text-align: center;
- margin-left: 40rpx;
- background-color: #6c6c6c;
- color: #ffffff;
- }
- }
- }
- }
- </style>
|