123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667 |
- <template>
- <view>
- <!-- #ifdef MP-ALIPAY -->
- <u-navbar title="提交订单" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" leftIconSize="0"/>
- <!-- #endif -->
- <!-- #ifdef MP-WEIXIN -->
- <u-navbar title="提交订单" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
- <!-- #endif -->
- <!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
- <view v-if="$pagesNum() > 1">
- <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="提交订单" />
- </view>
- <view v-else>
- <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="提交订单">
- <view class="nav-left flex" slot="left" @click="$toIndex()">
- <u-icon name="arrow-left" size="20" color="#333"></u-icon>
- </view>
- </u-navbar>
- </view>
- <!-- #endif -->
- <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.receiver || '-' }}<text>{{ addr.mobile || '-' }}</text></view>
- <view class="settlement-address-desc__item">
- {{ `${ addr.province || '-' } ${ addr.city || '-' } ${ addr.area || '-' }` }} {{ addr.addr || '-' }}</view>
- </view>
- <!-- 地址form -->
- <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="settlement-goods-item" v-for="(item, index) in list" :key="index">
- <image :src="item.picUrl" mode="aspectFit"></image>
- <view class="info">
- <view class="info-title ells">{{ item.title }}</view>
- <view class="info-num flex">
- <view class="info-num-sku ells-one">规格:{{ item.properties || '-' }}</view>
- <view class="info-num-goods">数量:{{ item.goodsNum }}</view>
- </view>
- </view>
- </view>
- </view>
-
- <view class="settlement-freight flex">
- <text>留言</text>
- <!-- #ifndef MP-ALIPAY -->
- <u-input v-model="info.memo" placeholder="请输入留言" clearable inputAlign="right" border="none" />
- <!-- #endif -->
- <!-- #ifdef MP-ALIPAY -->
- <u-input v-model="info.memo" placeholder="请输入留言" inputAlign="right" border="none" />
- <!-- #endif -->
- </view>
- <view class="settlement-freight flex">
- <text>运费</text>
- <text>¥{{ $numberFormat(info.freightAmt) }}</text>
- </view>
- <view class="settlement-tip">
- <view class="settlement-tip-title">尊敬的用户您好!</view>
- <view class="settlement-tip-content">您提交的商品订单将会在第一时间为您处理,正常产品都会在48小时内发货,由于因疫情原因可能导致到货时间延后,我们深表歉意,有任何问题可以点击“我的”一“联系我们”,或者关注盲票公众号联系我们。</view>
- </view>
- </view>
-
- <view class="footer-fixed">
- <view class="content">
- <view class="content-not flex" v-if="info.freightType == 2">
- <icon type="warn" color="#F9832E" style="vertical-align: bottom; margin-right: 20rpx; " size="20"/>
- <text>当前收货地址暂不支持发货</text>
- </view>
- <view class="content-btn flex">
- <view class="content-btn-left">
- <view class="money">
- <text>合计:</text>
- <text class="value">¥{{ $numberFormat(info.payAmt) }}</text>
- </view>
- </view>
- <view class="content-btn-right">
- <text class="save not" v-if="info.freightType == 2">提交</text>
- <text class="save" @click="save" v-else>提交</text>
- </view>
- </view>
- </view>
- </view>
- <area-picker :area-show="areaShow" @cancel="cancel" @confirmArea="confirmArea" />
-
- <auth :auth-show="authShow" @close="authShow = false" />
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- import appId from '@/config/appId.js'
- import AreaPicker from '../../components/area-picker/area-picker.vue'
- import Auth from '../../components/auth/auth.vue'
- export default {
- components: {
- AreaPicker,
- Auth
- },
- 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: {},
- payment: '',
- authShow: false,
- }
- },
- onLoad(opthios) {
- if (opthios.ids) {
- this.ids = JSON.parse(opthios.ids)
- this.getDetail()
- }
- if(opthios.goodsId){
- this.payment = {
- goodsId:opthios.goodsId,
- skuId:opthios.skuId,
- num:opthios.num,
- resource:2,
- }
- 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', {memo:this.info.memo}).then(res => {
- payIng = true
- uni.hideLoading();
- if (res.code == 0) {
- if (res.data.needPay == 1) {
- // #ifdef MP-ALIPAY
- let data = {
- orderId: res.data.orderId,
- payType: 1,
- appSource: appId
- }
- // #endif
- // #ifndef MP-ALIPAY
- let data = {
- orderId: res.data.orderId,
- payType: 2,
- appSource: appId
- }
- // #endif
- $http.post('/api/v1/mp/user/deliver/order/pay', data).then(ele => {
- if (ele.code == 0) {
- // #ifdef MP-ALIPAY
- my.tradePay({
- tradeNO: ele.data.pay_info,
- success(resu) {
- if(resu.resultCode == '9000'){
- uni.showToast({
- title: '支付成功',
- icon: 'success',
- duration: 2000
- })
- setTimeout(() => {
- uni.redirectTo({
- url: `/packageGoods/order/index`
- })
- }, 500)
- }else {
- payIng = false
- setTimeout(() => {
- uni.redirectTo({
- url: `/packageGoods/order/index`
- })
- }, 500)
- }
-
- },
- fail() {
- payIng = false
- setTimeout(() => {
- uni.redirectTo({
- url: `/packageGoods/order/index`
- })
- }, 500)
- }
- })
- // #endif
-
- // #ifndef MP-ALIPAY
- 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)
- }
- })
- // #endif
-
- } else if (ele.code == 1005) {
- _this.authShow = true
- } else if (ele.code == 1026) {
- _this.authShow = true
- } 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(res.msg);
- }
- }).catch(() => {
- payIng = false
- uni.$u.toast('订单创建失败');
- uni.hideLoading();
- })
- },
- getDetail() {
- uni.showLoading({
- title: '加载中'
- });
- let data = {
- ids: this.ids,
- }
- if(this.payment != ""){
- data = this.payment
- }
- data.appSource = appId
- $http.post('/api/v1/mp/user/deliver/order/settle', data ).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: 34rpx;
- padding-bottom: 150rpx;
- &-address {
- background-color: #fff;
- padding: 34rpx;
- margin-bottom: 34rpx;
- border-radius: 22rpx;
- // 选择地址、获取微信地址
- &-top {
- justify-content: space-between;
- padding: 0 0 34rpx;
- border-bottom: 1px solid rgba(236, 236, 236, 100);
- &__left {
- line-height: 40rpx;
- }
- &__right {
- line-height: 40rpx;
- color: rgba(35, 126, 212, 100);
- }
- }
-
- // 收货人、地址
- &-desc {
- margin-top: 34rpx;
-
- &__item {
- line-height: 28rpx;
- margin-bottom: 20rpx;
-
- text {
- padding-left: 8rpx;
- font-size: 24rpx;
- color: #666;
- }
- }
-
- &__item:last-child {
- margin-bottom: 0;
- color: #999;
- }
- }
-
- // 地址form
- &-form {
- .save-btn {
- padding: 10rpx 20rpx;
- ::v-deep button {
- line-height: 76rpx;
- font-size: 28rpx;
- height: 76rpx;
- color: #fff;
- background-color: $uni-bg-color;
- border: none;
- border-radius: 100rpx;
- }
- }
- }
- }
-
- // 商品
- &-goods {
- // 商品列表
- &-item{
- display: flex;
- padding: 34rpx 32rpx 34rpx 22rpx;
- box-shadow: 0px 0px 8px 0px rgba(26, 35, 113, 0.08);
- background-color: #fff;
- border-radius: 22rpx;
- margin-bottom: 34rpx;
-
- image {
- width: 176rpx;
- height: 176rpx;
- border-radius: 12rpx;
- margin-right: 22rpx;
- }
-
- .info {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- flex: 1;
- padding: 8rpx 0;
-
- &-title {
- font-size: 30rpx;
- font-weight: bold;
- line-height: 40rpx;
- }
-
- &-num {
- justify-content: space-between;
-
- &-sku {
- flex: 1;
- color: #666666;
- font-size: 26rpx;
- }
-
- &-goods {
- color: #666666;
- font-size: 26rpx;
- }
- }
- }
- }
- }
- // 留言、运费
- &-freight {
- font-size: 30rpx;
- margin-bottom: 34rpx;
- background-color: #fff;
- justify-content: space-between;
- padding: 34rpx;
- border-radius: 22rpx;
- }
-
- // 留言、运费
- &-tip {
- font-size: 30rpx;
- margin-bottom: 34rpx;
- background-color: #fff;
- justify-content: space-between;
- padding: 34rpx;
- border-radius: 22rpx;
-
- &-title {
- font-size: 26rpx;
- line-height: 24rpx;
- margin-bottom: 24rpx;
- }
-
- &-content {
- font-size: 24rpx;
- line-height: 40rpx;
- }
- }
- }
- .footer-fixed {
- position: fixed;
- bottom: var(--window-bottom);
- left: 0;
- right: 0;
- z-index: 11;
- box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
- background: #fff;
- // 设置ios刘海屏底部横线安全区域
- padding-bottom: constant(safe-area-inset-bottom);
- padding-bottom: env(safe-area-inset-bottom);
- .content {
- padding: 20rpx 0;
- font-size: 30rpx;
- // 不发货提示
- &-not {
- justify-content: flex-start;
- font-size: 30rpx;
- color: #F9832E;
- margin: 0 0 30rpx;
- padding: 0 40rpx 24rpx;
- border-bottom: 1px solid #eee;
- }
- // 提交按钮
- &-btn {
- justify-content: space-between;
- padding: 0 40rpx;
-
- &-left {
- .value {
- color: #FF4208;
- }
- }
-
- &-right {
- display: flex;
- align-items: center;
- justify-content: flex-end;
-
- .save {
- width: 210rpx;
- height: 82rpx;
- line-height: 82rpx;
- background: #F9822C;
- border-radius: 40rpx;
- text-align: center;
- color: #fff;
- }
-
- .not {
- background-color: #6c6c6c;
- }
- }
-
- }
- }
- }
- </style>
|