123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
- const sheep_index = require("../../sheep/index.js");
- const sheep_api_trade_order = require("../../sheep/api/trade/order.js");
- require("../../sheep/url/index.js");
- require("../../sheep/store/index.js");
- require("../../sheep/store/app.js");
- require("../../sheep/api/promotion/diy.js");
- require("../../sheep/request/index.js");
- require("../../sheep/config/index.js");
- require("../../sheep/platform/index.js");
- require("../../sheep/platform/provider/wechat/index.js");
- require("../../sheep/platform/provider/wechat/miniProgram.js");
- require("../../sheep/api/member/auth.js");
- require("../../sheep/api/member/social.js");
- require("../../sheep/api/member/user.js");
- require("../../sheep/platform/provider/apple/index.js");
- require("../../sheep/platform/share.js");
- require("../../sheep/router/index.js");
- require("../../sheep/hooks/useModal.js");
- require("../../sheep/helper/index.js");
- require("../../sheep/helper/test.js");
- require("../../sheep/helper/digit.js");
- require("../../sheep/api/member/signin.js");
- require("../../sheep/helper/throttle.js");
- require("../../sheep/platform/pay.js");
- require("../../sheep/api/pay/order.js");
- require("../../sheep/store/user.js");
- require("../../sheep/store/cart.js");
- require("../../sheep/api/trade/cart.js");
- require("../../sheep/api/pay/wallet.js");
- require("../../sheep/api/promotion/coupon.js");
- require("../../sheep/store/sys.js");
- require("../../sheep/store/modal.js");
- require("../../sheep/util/index.js");
- require("../../sheep/api/index.js");
- require("../../sheep/api/distri/score.js");
- require("../../sheep/api/distri/share.js");
- require("../../sheep/api/distri/team.js");
- require("../../sheep/api/infra/file.js");
- require("../../sheep/api/member/address.js");
- require("../../sheep/api/member/point.js");
- require("../../sheep/api/migration/app.js");
- require("../../sheep/api/migration/chat.js");
- require("../../sheep/api/migration/index.js");
- require("../../sheep/api/migration/third.js");
- require("../../sheep/api/pay/channel.js");
- require("../../sheep/api/product/category.js");
- require("../../sheep/api/product/comment.js");
- require("../../sheep/api/product/favorite.js");
- require("../../sheep/api/product/history.js");
- require("../../sheep/api/product/spu.js");
- require("../../sheep/api/promotion/activity.js");
- require("../../sheep/api/promotion/article.js");
- require("../../sheep/api/promotion/bargain.js");
- require("../../sheep/api/promotion/combination.js");
- require("../../sheep/api/promotion/rewardActivity.js");
- require("../../sheep/api/promotion/seckill.js");
- require("../../sheep/api/system/area.js");
- require("../../sheep/api/system/voice.js");
- require("../../sheep/api/trade/afterSale.js");
- require("../../sheep/api/trade/brokerage.js");
- require("../../sheep/api/trade/config.js");
- require("../../sheep/api/trade/delivery.js");
- require("../../sheep/config/zIndex.js");
- if (!Array) {
- const _easycom_su_tabs2 = common_vendor.resolveComponent("su-tabs");
- const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
- const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
- const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
- const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
- const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
- (_easycom_su_tabs2 + _easycom_su_sticky2 + _easycom_s_empty2 + _easycom_s_goods_item2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
- }
- const _easycom_su_tabs = () => "../../sheep/ui/su-tabs/su-tabs.js";
- const _easycom_su_sticky = () => "../../sheep/ui/su-sticky/su-sticky.js";
- const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
- const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js";
- const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
- const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
- if (!Math) {
- (_easycom_su_tabs + _easycom_su_sticky + _easycom_s_empty + _easycom_s_goods_item + _easycom_uni_load_more + _easycom_s_layout)();
- }
- const _sfc_main = {
- __name: "list",
- setup(__props) {
- const pagination = {
- list: [],
- current_page: 1,
- total: 1,
- last_page: 1
- };
- const state = common_vendor.reactive({
- currentTab: 0,
- // 选中的 tabMaps 下标
- pagination: {
- list: [],
- current_page: 1,
- total: 1,
- last_page: 1
- },
- loadStatus: ""
- });
- const tabMaps = common_vendor.reactive([
- {
- name: "全部",
- num: 0,
- isShow: false
- },
- {
- name: "待付款",
- value: 0,
- num: 0,
- isShow: true
- },
- {
- name: "待发货",
- value: 10,
- num: 0,
- isShow: true
- },
- {
- name: "待收货",
- value: 20,
- num: 0,
- isShow: true
- },
- {
- name: "待评价",
- value: 30,
- num: 0,
- isShow: true
- }
- ]);
- function onTabsChange(e) {
- if (state.currentTab === e.index) {
- return;
- }
- state.pagination.list = [];
- state.pagination.current_page = 1;
- state.pagination.total = 1;
- state.pagination.last_page = 1;
- state.currentTab = e.index;
- getOrderList();
- }
- function onOrderDetail(id) {
- sheep_index.sheep.$router.go("/pages/order/detail", {
- id
- });
- }
- function onOrderGroupon(order) {
- sheep_index.sheep.$router.go("/pages/activity/groupon/detail", {
- id: order.ext.groupon_id
- });
- }
- function onPay(id) {
- sheep_index.sheep.$router.go("/pages/pay/index", {
- id,
- openType: 2
- });
- }
- function onComment(id) {
- sheep_index.sheep.$router.go("/pages/goods/comment/add", {
- id
- });
- }
- async function onConfirm(order, ignore = false) {
- let isOpenBusinessView = true;
- common_vendor.index.showModal({
- title: "提示",
- content: "确认收货?",
- success: async function(res) {
- if (res.confirm) {
- if (sheep_index.sheep.$platform.name === "WechatMiniProgram" && !common_vendor.lodashExports.isEmpty(order.wechat_extra_data) && isOpenBusinessView && !ignore) {
- mpConfirm(order);
- return;
- }
- const {
- code
- } = await sheep_api_trade_order.OrderApi.receiveOrder(order.id);
- if (code === 0) {
- state.pagination = pagination;
- await getOrderList();
- }
- }
- }
- });
- }
- function mpConfirm(order) {
- if (!common_vendor.wx$1.openBusinessView) {
- sheep_index.sheep.$helper.toast(`请升级微信版本`);
- return;
- }
- common_vendor.wx$1.openBusinessView({
- businessType: "weappOrderConfirm",
- extraData: {
- merchant_id: "1481069012",
- merchant_trade_no: order.wechat_extra_data.merchant_trade_no,
- transaction_id: order.wechat_extra_data.transaction_id
- },
- success(response) {
- console.log("success:", response);
- if (response.errMsg === "openBusinessView:ok") {
- if (response.extraData.status === "success") {
- onConfirm(order, true);
- }
- }
- },
- fail(error) {
- console.log("error:", error);
- },
- complete(result) {
- console.log("result:", result);
- }
- });
- }
- async function onExpress(id) {
- sheep_index.sheep.$router.go("/pages/order/express/log", {
- id
- });
- }
- async function onCancel(orderId) {
- common_vendor.index.showModal({
- title: "提示",
- content: "确定要取消订单吗?",
- success: async function(res) {
- if (!res.confirm) {
- return;
- }
- const {
- code
- } = await sheep_api_trade_order.OrderApi.cancelOrder(orderId);
- if (code === 0) {
- let index = state.pagination.list.findIndex((order) => order.id === orderId);
- const orderInfo = state.pagination.list[index];
- orderInfo.status = 40;
- sheep_hooks_useGoods.handleOrderButtons(orderInfo);
- state.pagination = pagination;
- await getOrderList();
- }
- }
- });
- }
- function onDelete(orderId) {
- common_vendor.index.showModal({
- title: "提示",
- content: "确定要删除订单吗?",
- success: async function(res) {
- if (res.confirm) {
- const {
- code
- } = await sheep_api_trade_order.OrderApi.deleteOrder(orderId);
- if (code === 0) {
- let index = state.pagination.list.findIndex((order) => order.id === orderId);
- state.pagination.list.splice(index, 1);
- await getOrderList();
- }
- }
- }
- });
- }
- async function getOrderCount() {
- let { data } = await sheep_api_trade_order.OrderApi.getOrderCount();
- tabMaps[0].num = data.allCount;
- tabMaps[1].num = data.unpaidCount;
- tabMaps[2].num = data.undeliveredCount;
- tabMaps[3].num = data.deliveredCount;
- tabMaps[4].num = data.uncommentedCount;
- }
- async function getOrderList(page = 1, list_rows = 5) {
- state.loadStatus = "loading";
- let {
- code,
- data
- } = await sheep_api_trade_order.OrderApi.getOrderPage({
- pageNo: page,
- pageSize: list_rows,
- status: tabMaps[state.currentTab].value,
- commentStatus: tabMaps[state.currentTab].value === 30 ? false : null
- });
- getOrderCount();
- if (code !== 0) {
- return;
- }
- let orderList = common_vendor._.concat(state.pagination.list, data.list);
- data.list.forEach((order) => sheep_hooks_useGoods.handleOrderButtons(order));
- state.pagination.list = orderList;
- state.pagination.total = data.total;
- state.pagination.last_page = Math.ceil(data.total / 5);
- if (state.pagination.current_page < state.pagination.last_page) {
- state.loadStatus = "more";
- } else {
- state.loadStatus = "noMore";
- }
- }
- common_vendor.onLoad(async (options) => {
- if (options.type) {
- state.currentTab = options.type;
- }
- await getOrderList();
- });
- common_vendor.onShow(async () => {
- if (state.loadStatus == "loading") {
- return;
- }
- state.pagination.list = [];
- state.pagination.current_page = 1;
- state.pagination.total = 1;
- state.pagination.last_page = 1;
- await getOrderList();
- });
- function loadMore() {
- if (state.loadStatus !== "noMore") {
- state.pagination.current_page += 1;
- getOrderList(state.pagination.current_page);
- }
- }
- common_vendor.onReachBottom(() => {
- loadMore();
- });
- common_vendor.onPullDownRefresh(() => {
- state.pagination.list = [];
- state.pagination.current_page = 1;
- state.pagination.total = 1;
- state.pagination.last_page = 1;
- getOrderList();
- setTimeout(function() {
- common_vendor.index.stopPullDownRefresh();
- }, 800);
- });
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: common_vendor.o(onTabsChange),
- b: common_vendor.p({
- list: tabMaps,
- scrollable: false,
- current: state.currentTab,
- badge: true
- }),
- c: common_vendor.p({
- bgColor: "#fff"
- }),
- d: state.pagination.total === 0
- }, state.pagination.total === 0 ? {
- e: common_vendor.p({
- icon: "/static/order-empty.png",
- text: "暂无订单"
- })
- } : {}, {
- f: state.pagination.total > 0
- }, state.pagination.total > 0 ? {
- g: common_vendor.f(state.pagination.list, (order, index, i0) => {
- return common_vendor.e({
- a: common_vendor.t(order.no),
- b: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatOrderStatus)(order)),
- c: common_vendor.n(common_vendor.unref(sheep_hooks_useGoods.formatOrderColor)(order)),
- d: common_vendor.f(order.items, (item, k1, i1) => {
- return {
- a: "456ecf67-4-" + i0 + "-" + i1 + ",456ecf67-0",
- b: common_vendor.p({
- img: item.picUrl,
- title: item.spuName,
- skuText: item.properties.map((property) => property.valueName).join(" "),
- price: item.spuPayType === 2 ? item.highPrecisionPrice : item.price,
- num: item.count,
- virtualPirce: item.spuPayType === 2
- }),
- c: item.id
- };
- }),
- e: common_vendor.t(order.productCount),
- f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(order.payPrice)),
- g: order.buttons.includes("combination")
- }, order.buttons.includes("combination") ? {
- h: common_vendor.o(($event) => onOrderGroupon(order), order.id)
- } : {}, {
- i: order.buttons.length === 0
- }, order.buttons.length === 0 ? {
- j: common_vendor.o(($event) => onOrderDetail(order.id), order.id)
- } : {}, {
- k: order.buttons.includes("express")
- }, order.buttons.includes("express") ? {
- l: common_vendor.o(($event) => onExpress(order.id), order.id)
- } : {}, {
- m: order.buttons.includes("confirm")
- }, order.buttons.includes("confirm") ? {
- n: common_vendor.o(($event) => onConfirm(order), order.id)
- } : {}, {
- o: order.buttons.includes("cancel")
- }, order.buttons.includes("cancel") ? {
- p: common_vendor.o(($event) => onCancel(order.id), order.id)
- } : {}, {
- q: order.buttons.includes("comment")
- }, order.buttons.includes("comment") ? {
- r: common_vendor.o(($event) => onComment(order.id), order.id)
- } : {}, {
- s: order.buttons.includes("delete")
- }, order.buttons.includes("delete") ? {
- t: common_vendor.o(($event) => onDelete(order.id), order.id)
- } : {}, {
- v: order.buttons.includes("pay")
- }, order.buttons.includes("pay") ? {
- w: common_vendor.o(($event) => onPay(order.id), order.id)
- } : {}, {
- x: common_vendor.n(order.buttons.length > 3 ? "ss-row-between" : "ss-row-right"),
- y: order.id,
- z: common_vendor.o(($event) => onOrderDetail(order.id), order.id)
- });
- })
- } : {}, {
- h: state.pagination.total > 0
- }, state.pagination.total > 0 ? {
- i: common_vendor.o(_ctx.loadmore),
- j: common_vendor.p({
- status: state.loadStatus,
- ["content-text"]: {
- contentdown: "上拉加载更多"
- }
- })
- } : {}, {
- k: common_vendor.p({
- title: "我的订单"
- })
- });
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-456ecf67"], ["__file", "D:/zx/mall-front-app/pages/order/list.vue"]]);
- wx.createPage(MiniProgramPage);
|