diff --git a/common/platform/AppPlatform.js b/common/platform/AppPlatform.js index 966c3e7..ebc1ac5 100644 --- a/common/platform/AppPlatform.js +++ b/common/platform/AppPlatform.js @@ -8,5 +8,20 @@ class AppPlatform extends BasePlatform { this.code = 'APP_ANDROID'; this.env = 'app'; } + async pay(data, event) { + console.log('pay', data, event); + return new Promise((resolve, reject) => { + uni.requestPayment({ + provider: 'alipay', + orderInfo: data, + success: (res) => { + resolve({ isPay: true }); + }, + fail: (err) => { + resolve({ isPay: false }); + } + }); + }); + } } export default AppPlatform; \ No newline at end of file diff --git a/common/platform/BasePlatform.js b/common/platform/BasePlatform.js index cf29e5d..0f50cb5 100644 --- a/common/platform/BasePlatform.js +++ b/common/platform/BasePlatform.js @@ -50,9 +50,7 @@ class BasePlatform { * @param {number} amount - 支付金额(分) * @param {string} orderId - 订单号 */ - pay({ - data - }, event) { + async pay(data, event) { throw new Error('子类必须实现 pay 方法'); } diff --git a/common/server/order.js b/common/server/order.js new file mode 100644 index 0000000..abc7db6 --- /dev/null +++ b/common/server/order.js @@ -0,0 +1,184 @@ +import HttpRequest from "../system/request"; + +/** + * 立即购买 + * @param {Number} product_id 商品id + * @returns {Promise} 立即购买 + */ +export const pay_by_order = async (product_id) => { + const res = await HttpRequest.post('pay_by_order', { + product_id: product_id + }); + if (res.status == 1) { + return res.data; + } + uni.showToast({ + title: res.msg, + icon: 'none' + }); + return null; +} + +/** + * 创建订单 + * @param {Number} product_id 商品id + * @param {Number} address_id 地址id + * @param {Number} coupon_id 优惠券id + * @returns {Promise} 创建订单 + */ +export const pay_by_create_order = async (product_id, address_id, coupon_id) => { + const res = await HttpRequest.post('pay_by_create_order', { + product_id: product_id, + address_id: address_id, + coupon_id: coupon_id + }); + if (res.status == 1) { + return res.data; + } + return null; +} + +/** + * 支付成功 + * @param {String} order_no 订单号 + * @returns {Promise} 支付成功 + */ +export const pay_by_pay = async (order_no) => { + const res = await HttpRequest.post('order_pay_success', { + order_no: order_no + }); + if (res.status == 1) { + return res.data; + } + return null; +} + +/** + * 获取订单列表 + * @param {Number} status 订单状态 + * @param {Number} page 页码 + * @param {Number} page_size 每页条数 + * @param {String} title 商品标题搜索关键词 + * @returns {Promise} 获取订单列表 + */ +export const get_order_list = async (status, page, page_size, title = "") => { + // 接收参数 + const res = await HttpRequest.post('get_order_list', { + status: status, + keyword: title, + page: page, + limit: page_size + }); + return res.data; +} +/** + * 订单收货 + * @param {String} order_no 订单号 + * @returns {Promise} 订单收货结果 + */ +export const order_receive = async (order_no) => { + const res = await HttpRequest.post('order_receive', { + order_no: order_no + }); + if (res.status == 1) { + return res.data; + } + return null; +} + +/** + * 申请售后 + * @param {String} order_no 订单号 + * @param {String} extend_info 扩展信息 + * @returns {Promise} 申请售后结果 + */ +export const apply_refund = async (order_no, extend_info = "") => { + const res = await HttpRequest.post('apply_refund', { + order_no: order_no, + extend_info: extend_info + }); + if (res.status == 1) { + return res.data; + } + return null; +} + +/** + * 取消售后 + * @param {String} order_no 订单号 + * @returns {Promise} 取消售后结果 + */ +export const cancel_refund = async (order_no) => { + const res = await HttpRequest.post('cancel_refund', { + order_no: order_no + }); + if (res.status == 1) { + return res.data; + } + return null; +} + +/** + * 删除订单 + * @param {String} order_no 订单号 + * @returns {Promise} 删除订单结果 + */ +export const delete_order = async (order_no) => { + const res = await HttpRequest.post('delete_order', { + order_no: order_no + }); + if (res.status == 1) { + return res.data; + } + return null; +} + +/** + * 获取订单详情 + * @param {String} order_no 订单号 + * @returns {Promise} 获取订单详情 + */ +export const get_order_detail = async (order_no) => { + const res = await HttpRequest.post('get_order_detail', { + order_no: order_no + }); + if (res.status == 1) { + return res.data; + } + return null; +} + +/** + * 申请发票 + * @param {String} order_no 订单号 + * @param {String} invoice_title 发票抬头 + * @param {String} invoice_content 发票内容 + * @param {Number} invoice_type 发票类型 + * @param {String} user_email 用户邮箱 + * @returns {Promise} 申请发票结果 + */ +export const apply_invoice = async (order_no, invoice_title, invoice_content, invoice_type, user_email) => { + const res = await HttpRequest.post('apply_invoice', { + order_no: order_no, + invoice_title: invoice_title, + invoice_content: invoice_content, + invoice_type: invoice_type, + user_email: user_email + }); + if (res.status == 1) { + return true; + } + return false; +} + +/** + * 获取订单统计 + * @returns {Promise} 获取订单统计 + */ +export const get_order_statistics = async () => { + const res = await HttpRequest.post('get_order_statistics'); + if (res.status == 1) { + return res.data; + } + return null; +} \ No newline at end of file diff --git a/common/server/other.js b/common/server/other.js index 6af944e..4e93bb7 100644 --- a/common/server/other.js +++ b/common/server/other.js @@ -22,6 +22,8 @@ export const getAgreement = async (type) => { type_id = 4; } else if (type == "privacy") { type_id = 5; + } else if (type == "product") { + type_id = 32; } const res = await HttpRequest.get('/getAgreement', { type: type_id diff --git a/common/server/product.js b/common/server/product.js index 2ef5568..e9fb129 100644 --- a/common/server/product.js +++ b/common/server/product.js @@ -43,3 +43,72 @@ export const getProductDetail = async (id) => { } return null; } + + +/** + * 获取用户收藏商品列表 + * @param {Number} page 页码 + * @param {Number} limit 每页条数 + * @returns {Promise} 收藏商品列表 + */ +export const getFavoriteList = async (page = 1, limit = 10) => { + const res = await HttpRequest.get('/get_favorite_list', { + page: page, + limit: limit + }); + if (res.status == 1) { + return res.data; + } + return []; +} + +/** + * 添加商品收藏 + * @param {Number} product_id 商品ID + * @returns {Promise} 收藏结果 + */ +export const addFavorite = async (product_id) => { + const res = await HttpRequest.post('/add_favorite', { + product_id: product_id + }); + return res.status == 1; +} + +/** + * 取消商品收藏 + * @param {Number} product_id 商品ID + * @returns {Promise} 取消收藏结果 + */ +export const cancelFavorite = async (product_id) => { + const res = await HttpRequest.post('/cancel_favorite', { + product_id: product_id + }); + return res.status == 1; +} + +/** + * 批量取消商品收藏 + * @param {Array} product_ids 商品ID数组 + * @returns {Promise} 批量取消收藏结果 + */ +export const batchCancelFavorite = async (product_ids) => { + const res = await HttpRequest.post('/batch_cancel_favorite', { + product_ids: product_ids + }); + return res.status == 1; +} + +/** + * 检查商品是否已收藏 + * @param {Number} product_id 商品ID + * @returns {Promise} 是否已收藏 + */ +export const checkIsFavorite = async (product_id) => { + const res = await HttpRequest.get('/check_is_favorite', { + product_id: product_id + }); + if (res.status == 1) { + return res.data.is_favorite; + } + return false; +} \ No newline at end of file diff --git a/components.d.ts b/components.d.ts index 17fb582..52dde71 100644 --- a/components.d.ts +++ b/components.d.ts @@ -14,9 +14,11 @@ declare module 'vue' { OrderListItem: typeof import('./components/youdas-container/order-list-item.vue')['default'] PageBaseContainer: typeof import('./components/youdas-container/page-base-container.vue')['default'] PageContainer: typeof import('./components/youdas-container/page-container.vue')['default'] + PageKefu: typeof import('./components/youdas-container/page-kefu.vue')['default'] PageLine: typeof import('./components/youdas-container/page-line.vue')['default'] PageNoContainer: typeof import('./components/youdas-container/page-no-container.vue')['default'] PagePopup: typeof import('./components/youdas-container/page-popup.vue')['default'] + PaymentPopup: typeof import('./components/youdas-container/payment-popup.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] TextSearch: typeof import('./components/youdas-container/text-search.vue')['default'] diff --git a/components/youdas-container/order-list-item.vue b/components/youdas-container/order-list-item.vue index d030b46..da92610 100644 --- a/components/youdas-container/order-list-item.vue +++ b/components/youdas-container/order-list-item.vue @@ -4,11 +4,55 @@ + + + - - {{ item.title }} - {{ item.detail }} - + + + 订单号:{{ item.order_no }} + {{ item.order_status_text }} + + + + + {{ item.product_title }} + ¥{{ item.payment_amount }} + + + + {{ item.payment_time }} + + + + + + + + + + + + + + + + + + + + + 申请发票 + × + + + + + + {{ currentProduct.product_title }} + ¥{{ currentProduct.payment_amount }} + + + + + 发票类型 + + + {{ type.label }} + + + + + + 发票抬头* + + + + + + + 发票内容* + + + + + + + 申请邮箱* + + + + + + + 取消 + 提交申请 + + + + + + + + + + 申请售后 + × + + + + + + {{ currentProduct.product_title }} + ¥{{ currentProduct.payment_amount }} + + + + + 售后类型 + + + {{ type.label }} + + + + + + 申请原因 + + + {{ reason }} + + + + + + 申请说明* + +