"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const api_durian = require("../../api/durian.js"); if (!Array) { const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons"); const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup"); (_easycom_uni_icons2 + _easycom_uni_popup2)(); } const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js"; const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"; if (!Math) { (statusBar + _easycom_uni_icons + _easycom_uni_popup)(); } const statusBar = () => "../../components/header/statusBar.js"; const _sfc_main = { __name: "deal", setup(__props) { const store = common_vendor.useStore(); const userinfo = common_vendor.computed(() => { let result = store.state.userinfo; return result; }); const tabList = common_vendor.reactive([ { name: "全部" }, { name: "交易中" }, { name: "已完成" }, { name: "已取消" } ]); const tabIndex = common_vendor.ref(0); const saleData = common_vendor.ref([]); const gender = [ { id: 1, name: "挂买" }, { id: 2, name: "挂卖" } ]; const genderIndex = common_vendor.ref(0); const form = common_vendor.reactive({ sellNum: "", totalPrice: "" }); common_vendor.onReady(() => { }); getOrderList(); function getOrderList() { api_durian.durian.getOrderList({ query: { userId: userinfo.value.userId, status: tabIndex.value } }).then((rs) => { saleData.value = rs.rows; console.log(rs); }); } function handleTabIndex(index) { if (tabIndex.value === index) return; tabIndex.value = index; getOrderList(); } function handleGender(ev) { const value = ev.detail.value; if (genderIndex.value === value) return; genderIndex.value = value; } function release() { api_durian.durian.fruitForSale({ query: { totalPrice: form.totalPrice, sellNum: form.sellNum, type: genderIndex.value } }).then((rs) => { if (rs.code === 200) { common_vendor.index.showToast({ title: "发布成功", icon: "success", duration: 1500 }); } else { common_vendor.index.showToast({ title: rs.msg, icon: "error", duration: 1500 }); } }); } function cancelSale(item) { api_durian.durian.cancelSale({ query: { orderId: item.id } }).then((rs) => { if (rs.code === 200) { common_vendor.index.showToast({ title: "取消成功", icon: "success", duration: 1500 }); } else { common_vendor.index.showToast({ title: rs.msg, icon: "error", duration: 1500 }); } }); } return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.p({ type: "left", size: "40rpx" }), b: common_vendor.o$1(($event) => _ctx.$refs.saleRef.open()), c: common_vendor.f(saleData.value, (item, index, i0) => { return common_vendor.e({ a: item.status == 1 }, item.status == 1 ? {} : {}, { b: item.status == 2 }, item.status == 2 ? {} : {}, { c: item.status == 3 }, item.status == 3 ? {} : {}, { d: common_vendor.t(item.totalPrice), e: common_vendor.t(item.sellNum), f: item.status == 1 }, item.status == 1 ? { g: common_vendor.o$1(($event) => cancelSale(item), index) } : {}, { h: item.type == 1 }, item.type == 1 ? {} : {}, tabIndex.value == 2 ? { i: common_vendor.t(item.orderNo), j: common_assets._imports_1$2 } : {}, { k: index }); }), d: common_assets._imports_0$8, e: tabIndex.value == 2, f: common_vendor.f(tabList, (item, index, i0) => { return { a: common_vendor.t(item.name), b: index, c: index === tabIndex.value ? 1 : "", d: common_vendor.o$1(($event) => handleTabIndex(index), index) }; }), g: genderIndex.value == -1 }, genderIndex.value == -1 ? {} : { h: common_vendor.t(gender[genderIndex.value].name) }, { i: gender, j: common_vendor.o$1(handleGender), k: common_vendor.p({ type: "right" }), l: common_assets._imports_0$8, m: form.sellNum, n: common_vendor.o$1(($event) => form.sellNum = $event.detail.value), o: form.totalPrice, p: common_vendor.o$1(($event) => form.totalPrice = $event.detail.value), q: common_vendor.o$1(release), r: common_vendor.sr("saleRef", "33a62dd7-3"), s: common_vendor.p({ type: "center" }) }); }; } }; wx.createPage(_sfc_main);