You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
import {
|
|
|
|
|
defineStore
|
|
|
|
|
} from 'pinia'
|
|
|
|
|
import {
|
|
|
|
|
ref
|
|
|
|
|
} from 'vue'
|
|
|
|
|
import {
|
|
|
|
|
getOrdera,shop
|
|
|
|
|
} from '../../api/api.js'
|
|
|
|
|
export const order = defineStore('order', () => {
|
|
|
|
|
const orders = ref([])
|
|
|
|
|
const total = ref([])
|
|
|
|
|
const oNum = ref(0)
|
|
|
|
|
const orderid = ref('')
|
|
|
|
|
const mid = ref('')
|
|
|
|
|
const current =ref([])
|
|
|
|
|
const getOrders = (data) => {
|
|
|
|
|
if(oNum.value===1){
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
oNum.value=1
|
|
|
|
|
getOrdera({
|
|
|
|
|
phoneNumber: uni.getStorageSync('phoneNumber'),
|
|
|
|
|
pageNum: data.Maxs,
|
|
|
|
|
status:data.num
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
const newOrders = res.rows.filter(newOrder => !orders.value.find(oldOrder => oldOrder.id === newOrder.id));
|
|
|
|
|
total.value=res.total
|
|
|
|
|
orders.value =[...orders.value,...newOrders]
|
|
|
|
|
console.log(orders.value);
|
|
|
|
|
oNum.value=0
|
|
|
|
|
console.log();
|
|
|
|
|
}).catch(err=>{
|
|
|
|
|
oNum.value=0
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const getClose = (data)=>{
|
|
|
|
|
shop({
|
|
|
|
|
phone:uni.getStorageSync('phoneNumber'),
|
|
|
|
|
mid:data.mid,
|
|
|
|
|
orderId:data.id,
|
|
|
|
|
}).then((res)=>{
|
|
|
|
|
current.value = res.data
|
|
|
|
|
console.log(res);
|
|
|
|
|
if(res.code===200){
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon:"none",
|
|
|
|
|
title:"关闭成功"
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
uni.setStorageSync('orderid',orderid.value)
|
|
|
|
|
uni.setStorageSync('mid',mid.value)
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
orders,
|
|
|
|
|
getOrders,
|
|
|
|
|
getClose,
|
|
|
|
|
total
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|