123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- <template>
- <view class="order-pages">
- <view class="order-info">
- <!-- 订单状态 -->
- <view class="order-status">
- <view class="status-title">{{orderInfo.orderStateDictValue}}</view>
- <view v-if="orderInfo.orderState=='WAIT_PAY'" class="status-care">
- 请在 <text>{{leftTime}}</text>分钟内付款,过期系统将自动取消订单
- </view>
- <view v-if="orderInfo.orderState=='CANCEL'" class="status-care">
- 超时未支付,系统已自动取消订单
- </view>
- </view>
- <u-gap height="10" bg-color="#f8f8f8"></u-gap>
- <!-- 地址 -->
- <view class="order-address">
- <view>
- <text class="address-title">{{orderInfo.receiveAddress}}</text>
- </view>
- <view>
- <text style="margin-right: 30upx;">{{orderInfo.receiverName}}</text>
- <text>{{orderInfo.receiverPhone}}</text>
- </view>
- </view>
- <u-gap height="10" bg-color="#f8f8f8"></u-gap>
- <!-- 商品列表 -->
- <view class="bundle-list" v-for="item in orderInfo.orderGoodsList" :key="item.id">
- <view class="img-cont">
- <image :src="item.goodsImages"></image>
- </view>
- <view>
- <view class="ellipsis-two">{{item.goodsName}}</view>
- <view class="bundle-num">
- <view class="num-cont">
- <text class="price-num">{{item.payGold}}</text>
- <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
- </view>
- <view>X {{item.buyQty}}</view>
- </view>
- </view>
- </view>
- <u-gap height="10" bg-color="#f8f8f8"></u-gap>
- <!-- 订单信息 -->
- <u-cell-group>
- <u-cell-item title="订单编号" :value-style="{color: '#000'}" :arrow="false">
- {{orderInfo.orderSn}}
- </u-cell-item>
- <u-cell-item title="下单时间" :value-style="{color: '#000'}" :arrow="false">
- {{orderInfo.orderTime}}
- </u-cell-item>
- <u-cell-item v-if="orderInfo.payTime" title="支付时间" :value-style="{color: '#000'}" :arrow="false">
- {{orderInfo.payTime}}
- </u-cell-item>
- <u-gap height="10" bg-color="#f8f8f8"></u-gap>
- <u-cell-item title="商品合计" :value-style="{color: '#000'}" :arrow="false">
- <view class="num-cont">
- <text class="price-num">{{orderInfo.payGold}}</text>
- <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
- </view>
- </u-cell-item>
- <u-cell-item title="运费" :value-style="{color: '#000'}" :arrow="false">
- 免运费
- </u-cell-item>
- <u-cell-item :title="(orderInfo.orderState=='WAIT_PAY'||orderInfo.orderState=='CANCEL') ? '待支付':'实际支付'" :value-style="{color: '#000'}"
- :arrow="false">
- <view class="num-cont">
- <text class="price-num">{{orderInfo.payGold}}</text>
- <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
- </view>
- </u-cell-item>
- </u-cell-group>
- </view>
- <view v-if="orderInfo.orderState=='WAIT_PAY'" class="footer">
- <u-button @click="toPay" type="success">去支付</u-button>
- </view>
- <!-- 提示用户设置支付密码 -->
- <u-modal v-model="showSetPswModal"
- content="请先设置支付密码,才能使用乐豆"
- show-cancel-button
- confirm-text="去设置"
- cancel-text="暂时放弃"
- @confirm="toSetPwd"
- @cancel="showSetPswModal=false"
- ></u-modal>
- <!-- 确认取消弹窗 -->
- <u-modal v-model="showLeavePsw"
- title="确认放弃支付吗?"
- content="您的订单在30分钟内未支付将被取消"
- show-cancel-button
- confirm-text="确认放弃"
- cancel-text="继续支付"
- @confirm="canclePay"
- @cancel="payAgain"
- ></u-modal>
- <!-- 确认支付弹窗 -->
- <u-popup mode="center" :mask-close-able="false" negative-top="300" closeable @close="closePayModal" v-model="showInputPsw" width="500rpx" >
- <view class="slot-content">
- <view>确认支付</view>
- <view class="text-cont">
- <text class="num-big">{{totalPrice}}</text>
- <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
- </view>
- <view class="footer">
- <input
- v-model="password"
- :focus="focus"
- @confirm="toPayOrder"
- maxlength="30"
- style="text-align: center;" type="password"
- placeholder="请输入支付密码" />
- </view>
- <view class="fot-btn">
- <u-button @click="toPayOrder" type="success" >确认支付</u-button>
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import {
- orderDetail,
- signPay,
- existPayPwd
- } from '@/api/order.js'
- import {
- getLookUpDatas
- } from '@/api/data.js'
- import moment from 'moment'
- export default {
- data() {
- return {
- orderInfo: {},
- totalPrice: 0, // 支付合计
- password: '', // 支付密码
- showSetPswModal: false, // 设置支付密码弹窗
- showInputPsw: false, // 打开输入密码弹窗
- showLeavePsw: false, // 打开确定放弃弹窗
- orderId: '', // 订单id
- leftTime: null,
- payFinish: false , // 是否支付成功
- focus: false
- }
- },
- onLoad(options) {
- // 监听设置密码是否成功
- uni.$once('setPswSuccess', this.setPsw)
- if (options.id) {
- console.log(options.id)
- this.orderId = options.id
- this.getOrderDetail()
- }
- // 开启分享
- uni.showShareMenu({
- withShareTicket: true,
- menus: ['shareAppMessage', 'shareTimeline']
- })
- },
- computed: {
-
- },
- methods: {
- // 支付剩余时间
- leftTimeFun() {
- const date1 = moment().toArray() // 当前时间 数组形式
- const date2 = moment(this.orderInfo.orderTime).toDate() // 下单时间 日期格式
- const date3 = moment(date2).toArray() // 下单时间 数组形式
- const date4 = moment(date1).diff(moment(date3), 'seconds')//计算相差的秒数
- const tt = 30 - Math.ceil(date4/60) //向上取整
- if (tt > 0) {
- this.leftTime = tt
- } else {
- // this.getOrderDetail()
- this.leftTime = '00'
- }
- },
- // 获取订单详情
- getOrderDetail() {
- orderDetail({
- id: this.orderId
- }).then(res => {
- console.log(res,'rrrrrrrr')
- if (res.status == 200) {
- this.orderInfo = res.data
- if(this.orderInfo.orderState=='WAIT_PAY') {
- this.leftTimeFun()
- }
- }
- })
- },
- // 跳转到设置支付密码页
- toSetPwd () {
- uni.navigateTo({
- url:"/pages/userCenter/userInfo/smsVerification"
- })
- },
- // 设置密码成功, 打开输入密码弹窗
- setPsw (e) {
- if (e.success) {
- this.showInputPsw = true
- setTimeout(()=>{
- this.focus = true
- },300)
- }
- },
- // 关闭输入密码弹窗
- closePayModal(){
- if(!this.payFinish) {
- this.showLeavePsw = true
- }
- },
- //确认放弃
- canclePay() {
- this.password = ''
- this.showLeavePsw = false
- this.showInputPsw = false
- this.focus = false
- },
- // 继续支付
- payAgain () {
- this.focus = false
- this.showLeavePsw = false
- this.showInputPsw = true
- setTimeout(()=>{
- this.focus = true
- },300)
- },
- // 支付 判断用户是否设置过支付密码
- toPay() {
- this.totalPrice = this.orderInfo.originalGold
- this.payFinish = false
- // 判断用户是否设置过支付密码
- existPayPwd().then(res=>{
- console.log(res,'rrrrrr')
- if(res.status == 200) {
- // 设置过支付密码,输入密码
- if(res.data) {
- this.showInputPsw = true
- setTimeout(()=>{
- this.focus = true
- },300)
- } else {
- // 没设置过支付密码,提示设置密码
- this.showSetPswModal = true
- }
- }
- })
- },
- // 支付
- toPayOrder() {
- if (this.password === '') {
- uni.showToast({
- title: '请先输入支付密码',
- icon: 'none'
- })
- return false
- }
- let id = this.orderInfo.id
- let params = {
- payPwd: this.password,
- id: id
- }
- signPay(params).then(res=>{
- this.btnLoading = false
- if(res.status == 200) {
- // 关闭弹窗 刷新页面
- this.payFinish = true
- this.showInputPsw = false
- this.getOrderDetail()
- // 刷新订单列表
- uni.$emit('refresh')
- // 跳转到支付完成界面
- uni.navigateTo({
- url:"/pagesA/toOrder/payFinish?id=" + id
- })
- } else{
- this.password = ''
- }
- })
- },
- },
- }
- </script>
- <style lang="scss">
- page {
- height: 100%;
- background-color: #fff;
- }
- .order-pages {
- width: 100%;
- height: 100%;
- padding: 0 24upx;
- display: flex;
- flex-direction: column;
- .order-info {
- width: 100%;
- flex: 1;
- overflow-y: scroll;
- // 状态
- .order-status {
- padding: 30upx 0;
- text-align: center;
- .status-title {
- font-size: 36upx;
- color: #000;
- }
- .status-care {
- font-size: 24upx;
- margin-top: 10upx;
- color: #a9aaac;
- >text {
- color: red;
- }
- }
- }
- // 地址
- .order-address {
- font-size: 32upx;
- padding: 20upx 0;
- >view {
- line-height: 40upx;
- }
- .address-title {
- color: #000;
- word-break: break-all;
- }
- }
- // 订单中商品列表
- .bundle-list {
- display: flex;
- padding: 20upx 10upx;
- font-size: 28upx;
- border-bottom: 1px solid #F8F8F8;
- .img-cont {
- width: 158rpx;
- height: 140upx;
- border-radius: 15upx;
- overflow: hidden;
- >image {
- width: 100%;
- height: 100%;
- }
- }
- >view {
- &:last-child {
- flex: 1;
- margin-left: 20upx;
- padding: 10upx 0;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- }
- }
- .bundle-num {
- display: flex;
- justify-content: space-between;
- }
- }
- .price-text {
- font-size: 20upx;
- margin-left: 10upx;
- }
- .price-num {
- font-size: 32upx;
- color: red;
- font-weight: 600;
- margin-right: 6rpx;
- }
- .u-cell {
- padding: 10rpx 32rpx;
- }
- }
- // 乐豆数量
- .num-cont{
- display: flex;
- align-items: center;
- float: right;
- }
- .footer {
- padding: 20rpx;
- }
- // 支付密码弹窗
- .slot-content{
- padding: 30upx 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: space-between;
- .text-cont{
- width: 100%;
- padding: 60upx 0;
- display: flex;
- align-items: center;
- justify-content: center;
- .num-big{
- font-size: 40upx;
- color: red;
- font-weight: 600;
- margin-right: 6rpx;
- }
- }
- .footer{
- width: 80%;
- border-bottom: 1px solid #b1b1b1;
- margin-bottom: 30upx;
- }
- }
- }
- </style>
|