nurseWeChatAppletUI/pages/CommodityOrder/CommodityOrder.vue

343 lines
11 KiB
Vue
Raw Normal View History

<template>
<view class="app">
<view class="inputs">
<i class="icon"></i>
<input v-model="goodsName" type="text" name="" id="" class="input" placeholder="请输入商品名称">
</view>
<view class="" v-if="total>0">
<view class="Apayment" v-for='(item,index) in orderlist' :key="index">
<view class="names">店铺名称
2023-02-24 14:35:29 +08:00
<image class="picture" src="../../static/huijiantou.png" mode=""></image>
2023-01-12 16:16:36 +08:00
<span v-if="item.orderStatus=='WAIT_PAY'">待付款</span>
<span v-if="item.orderStatus=='WAIT_REFUND'">退款中</span>
<span v-if="item.orderStatus=='CANCEL'">已取消</span>
<span v-if="item.orderStatus=='WAIT_RECEIVED_GOODS'">待收货</span>
<span v-if="item.orderStatus=='RECEIVED_GOODS'">待评价</span>
<span v-if="item.orderStatus=='EVALUATED'">已完成</span>
<span v-if="item.orderStatus=='PAY'">待发货</span>
<span v-if="item.orderStatus=='REFUNDED'">退款成功</span>
<span v-if="item.orderStatus=='WAIT_RETURNED_GOODS'">待退货</span>
<span v-if="item.orderStatus=='RETURNED_GOODS'">退款成功</span>
</view>
<view class="details" @tap='goorderdetails(item)'>
<view class="detailslist">
<image :src="baseurl+item.attributePitureUrl" mode=""></image>
<view class="model">
<view class="top">
2023-03-10 13:59:01 +08:00
<span v-if="item.orderType =='HEALTH_CONSULTATION'">健康咨询</span>
<span v-else>{{item.goodsName}}</span>
<!-- <span v-if="item.orderType =='HEALTH_CONSULTATION'">{{item.totalPrice}}</span> -->
<span
v-if="item.goodsPrice&&item.orderType !='HEALTH_CONSULTATION'">{{item.goodsPrice}}</span>
</view>
2023-03-10 13:59:01 +08:00
<view class="bottom" v-if="item.orderType !='HEALTH_CONSULTATION'">
<span class="box">型号{{item.goodsAttributeName}}</span>
<span class="box">×{{item.goodsCount}}</span>
</view>
<view class="refund">
2023-03-03 13:31:01 +08:00
<span>
2023-03-03 10:04:13 +08:00
实付款
</span>
2023-03-10 13:59:01 +08:00
<text class="price"
v-if="item.orderType=='DIRECT_BUY'||item.orderType =='HEALTH_CONSULTATION'">{{item.totalPrice}}</text>
2023-03-03 10:04:13 +08:00
<text class="price"
v-if="item.orderType=='INTEGRAL_EXCHANGE'">{{item.integralExchangeSill}}</text>
2023-03-10 13:59:01 +08:00
<text class="price" v-if="item.orderType=='INTEGRAL_EXCHANGE'"
style='padding-left: 10rpx;'>
2023-03-03 10:04:13 +08:00
积分
2023-03-10 13:59:01 +08:00
</text>
</view>
</view>
</view>
</view>
<view class="anniu">
2022-12-27 09:22:42 +08:00
<view class="logistics" v-if="item.orderStatus=='WAIT_REFUND'" style="background-color: coral;"
@tap='goorderdetails(item)'>退款中
</view>
2023-03-10 13:59:01 +08:00
<view class="logistics"
v-if="item.orderStatus=='WAIT_RECEIVED_GOODS'&&item.orderType !='HEALTH_CONSULTATION'"
@tap='gologistics(item)'>查看物流
</view>
2023-01-12 16:16:36 +08:00
<view class="logistics harvest" @tap='buy(item)' v-if="item.orderStatus=='WAIT_PAY'">
去支付</view>
2023-03-10 13:59:01 +08:00
<view class="logistics harvest" @tap='Receipt(item)'
v-if="item.orderStatus=='WAIT_RECEIVED_GOODS'&&item.orderType !='HEALTH_CONSULTATION'">
确认收货</view>
2023-03-10 13:59:01 +08:00
<view class="logistics harvest" @tap='Receipt(item)'
v-if="item.orderStatus=='WAIT_RECEIVED_GOODS'&&item.orderType =='HEALTH_CONSULTATION'">
咨询完成</view>
2022-12-27 09:22:42 +08:00
<view class="logistics harvest" style="background-color: #60c5f1;" @tap='rate(item)'
v-if="item.orderStatus=='RECEIVED_GOODS'">
去评价</view>
<view class="logistics harvest" v-if="item.orderStatus=='EVALUATED'" @tap='golookrate(item)'>
查看评价</view>
</view>
</view>
</view>
<view class="noorder" v-else>
2023-03-10 11:14:58 +08:00
<u-empty mode="order" icon-size='220'></u-empty>
</view>
<!-- 弹框 -->
<view class="frame">
2023-03-17 16:35:28 +08:00
<u-popup v-model="show" mode="bottom" length="45%" border-radius="30" :closeable='true'>
<view class="payment">
2023-03-10 15:41:27 +08:00
<span v-if="orderNoitem.orderType =='HEALTH_CONSULTATION'">确认咨询完成了吗</span>
<span v-else>确认收到货了吗</span>
</view>
<view class="chat">
2023-03-10 15:41:27 +08:00
<view class="image" style="height:182rpx">
<image :src="baseurl+img" mode="" v-if="orderNoitem.orderType !='HEALTH_CONSULTATION'"></image>
<view class="blackground" v-if="orderNoitem.orderType !='HEALTH_CONSULTATION'">共1件</view>
</view>
2023-03-10 15:41:27 +08:00
<view class="word" v-if="orderNoitem.orderType =='HEALTH_CONSULTATION'">为了保证您的售后权益请确认健康咨询无误后再确认完成
</view>
<view class="word" v-else>为了保证您的售后权益请收到商品确认无误后再确认收货</view>
</view>
<view class="submits" @tap='Receipts'>确定</view>
</u-popup>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
import {
ssgoodsOrder,
confirmReceipt
} from '@/api/CommodityOrder/index.js'
import baseurl from '@/api/baseurl.js'
import {
appletGoodsOrderPay
} from '@/api/confirmOrder/index.js'
export default {
data() {
return {
orderNoitem: null,
patientId: '',
openid: '',
title: '商品订单', //导航标题
baseurl: '', //url
orderlist: [], //商品订单list
total: 0, //list长度
show: false, //确认收获开关
img: '', //确认收货页面图片
orderStatus: '', //
goodsOrderId: '', //
2022-12-27 09:22:42 +08:00
pageSize: 15, //
pageNum: 1, //
goodsName: '',
getCodeText: null,
}
},
methods: {
2022-12-27 09:22:42 +08:00
//查看评价
golookrate(item) {
uni.navigateTo({
url: `/pages/lookrate/lookrate?item=${JSON.stringify(item)}`
})
},
//收货
Receipts() {
confirmReceipt(this.orderNoitem.goOrderNo).then(res => {
if (res.code == 200) {
this.$refs.uToast.show({
title: '收货成功',
type: 'success',
duration: '1000'
})
this.show = false
2022-12-27 09:22:42 +08:00
uni.setStorageSync("Refresh", 'Refresh')
setTimeout(e => {
uni.navigateTo({
2022-12-27 09:22:42 +08:00
url: `/pages/goodsorderRate/goodsorderRate?item=${JSON.stringify(this.orderNoitem)}&delta=${3}`
})
// uni.navigateTo({
// url: `/pages/orderDetails/orderDetails?goodsOrderId=${this.orderNoitem.goodsOrderId}`
// })
}, 1000)
2022-12-27 09:22:42 +08:00
} else {
this.$refs.uToast.show({
title: '收货失败',
type: 'error',
duration: '1000'
})
this.show = false
}
})
},
//支付
buy(item) {
let obj = {
patientId: this.patientId,
openid: this.openid,
orderNo: item.goOrderNo,
orderChannel: "WECHAT_APPLET",
paymentPrice: item.totalPrice,
payType: "WECHAT_PAY",
buySource: item.buySource,
}
var that = this
appletGoodsOrderPay(obj).then(response => {
if (response.code == 200) {
uni.requestPayment({
timeStamp: response.data.timeStamp,
nonceStr: response.data.nonceStr,
package: response.data.prepayId,
signType: response.data.signType,
paySign: response.data.paySign,
success: function(res) {
2022-12-27 09:22:42 +08:00
uni.setStorageSync("Refresh", 'Refresh')
that.$refs.uToast.show({
title: '支付成功',
type: 'success',
2023-01-12 16:16:36 +08:00
duration: 1500,
2022-12-27 09:22:42 +08:00
url: `/pages/paysuccess/paysuccess`,
})
},
fail: function(err) {
that.$refs.uToast.show({
title: '取消支付',
type: 'error',
2023-01-12 16:16:36 +08:00
duration: 1500,
})
}
});
} else {
that.$refs.uToast.show({
title: response.msg,
type: 'error',
2023-01-12 16:16:36 +08:00
duration: 2000
})
}
})
},
//物流页面
gologistics(item) {
uni.navigateTo({
url: `/pages/logistics/logistics?item=${JSON.stringify(item)}`
})
},
//评价
rate(item) {
uni.navigateTo({
2022-12-27 09:22:42 +08:00
url: `/pages/goodsorderRate/goodsorderRate?item=${JSON.stringify(item)}&delta=${3}`
})
},
//订单详情页面
goorderdetails(item) {
uni.navigateTo({
url: `/pages/orderDetails/orderDetails?goodsOrderId=${item.goodsOrderId}`
})
},
//商品订单请求
goodsOrderinfo() {
ssgoodsOrder(this.patientId, this.orderStatus, this.goodsOrderId, this.pageSize, this.pageNum, this
.goodsName).then(
res => {
2022-12-27 09:22:42 +08:00
if (res.code == 200) {
this.orderlist = res.rows
2023-01-12 16:16:36 +08:00
// this.orderlist.forEach(e => {
// e.timestamp = null
// var time = new Date(e.orderTime).getTime() / 1000 + (60 * 60 * 24)
// var times = new Date().getTime() / 1000
// e.timestamp = time - times
// })
2022-12-27 09:22:42 +08:00
uni.removeStorageSync('Refresh');
this.total = res.total
2023-03-17 16:35:28 +08:00
} else if (res.code == 9999) {
this.$refs.uToast.show({
title: '未登录,请先登录',
type: 'error',
})
2022-12-27 09:22:42 +08:00
}
})
},
//确认收货
Receipt(item) {
this.orderNoitem = item
this.img = item.attributePitureUrl
this.show = true
},
},
watch: { //监听
goodsName() {
2022-12-27 09:22:42 +08:00
this.pageNum = 1
this.goodsOrderinfo()
},
},
onReady() { //更改导航栏文字
uni.setNavigationBarTitle({
title: this.title,
});
},
2022-12-27 09:22:42 +08:00
onShow() {
this.pageNum = 1;
this.baseurl = baseurl;
let that = this
2023-03-03 10:04:13 +08:00
const value3 = uni.getStorageSync('Refresh');
if (value3) {
that.goodsOrderinfo();
}
2022-12-27 09:22:42 +08:00
},
onLoad(options) { //开局调用
let that = this
2023-03-09 16:07:29 +08:00
const value = uni.getStorageSync('patientId');
const value2 = uni.getStorageSync('openid');
if (value && value2) {
that.patientId = value
that.openid = value2
if (options.orderStatus) {
that.orderStatus = options.orderStatus
if (options.orderStatus == 'WAIT_PAY') {
that.title = '待付款'
that.goodsOrderinfo();
} else if (options.orderStatus == 'WAIT_RECEIVED_GOODS') {
that.title = '待收货'
that.goodsOrderinfo();
} else if (options.orderStatus == 'RECEIVED_GOODS') {
that.title = '待评价'
that.goodsOrderinfo();
} else if (options.orderStatus == 'EVALUATED') {
that.title = '已完成'
2022-12-27 09:22:42 +08:00
that.goodsOrderinfo();
}
2023-03-09 16:07:29 +08:00
} else {
that.goodsOrderinfo();
}
2023-03-17 17:17:34 +08:00
}else{
that.$refs.uToast.show({
title: '未登录,请先登录',
type: 'error',
})
2023-03-09 16:07:29 +08:00
}
},
onReachBottom() { //下滑加载
if (this.orderlist.length >= this.total) {} else {
this.pageNum++;
ssgoodsOrder(this.patientId, this.orderStatus, this.goodsOrderId, this.pageSize, this.pageNum, this
2022-12-06 10:08:19 +08:00
.goodsName).then(res => {
res.rows.forEach(e => {
2023-01-12 16:16:36 +08:00
// e.timestamp = null
// var time = new Date(e.orderTime).getTime() / 1000 + (60 * 60 * 24)
// var times = new Date().getTime() / 1000
// e.timestamp = time - times
2022-12-06 10:08:19 +08:00
this.orderlist.push(e)
})
2022-12-06 10:08:19 +08:00
this.total = res.total
})
}
},
onPullDownRefresh() { //下拉刷新
this.pageNum = 1;
2022-12-06 10:08:19 +08:00
this.goodsOrderinfo();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
},
}
</script>
<style lang="scss">
@import "./CommodityOrder.scss";
</style>