diff --git a/pages.json b/pages.json
index 228de21..0fe29aa 100644
--- a/pages.json
+++ b/pages.json
@@ -353,6 +353,20 @@
"navigationBarTitleText": "订单详情",
"enablePullDownRefresh": false
}
+ },
+ {
+ "path": "my/my-drug/invoice-apply",
+ "style": {
+ "navigationBarTitleText": "申请开票",
+ "enablePullDownRefresh": true
+ }
+ },
+ {
+ "path": "my/my-drug/invoice-detail",
+ "style": {
+ "navigationBarTitleText": "开票详情",
+ "enablePullDownRefresh": false
+ }
}
]
},
diff --git a/request/api/api.js b/request/api/api.js
index 467e032..1c0c626 100644
--- a/request/api/api.js
+++ b/request/api/api.js
@@ -339,9 +339,9 @@ export async function getUseWayPay(params) {
return data
}
-// 更新配送方式 http://xiaokang.com/member/v1/product-order/update-delivery
+// 更新配送方式(Laravel:单品包邮重算)
export async function getDelivery(params) {
- let data = await http('/oldApi/v1/product-order/update-delivery', params)
+ let data = await http('/xkApi/product-order/update-delivery', params)
return data
}
diff --git a/request/api/invoice.js b/request/api/invoice.js
new file mode 100644
index 0000000..2307475
--- /dev/null
+++ b/request/api/invoice.js
@@ -0,0 +1,33 @@
+import { get, post } from './http'
+
+/**
+ * 将 xk-api 的 code/result 规范为 errcode/data,便于页面统一判断
+ */
+function normalizeXkApiResponse(res) {
+ if (res && res.data && (res.data.code === 0 || res.data.code === '0')) {
+ res.data.errcode = 0
+ res.data.data = res.data.result
+ }
+ return res
+}
+
+/**
+ * 申请开票
+ * @param {object} params order_id, title_type, title_name, tax_no, receive_type, email
+ */
+export async function applyInvoiceApi(params) {
+ const data = await post('/invoice/apply', params, 3)
+ return normalizeXkApiResponse(data)
+}
+
+/**
+ * 开票详情
+ * @param {object} params id 或 order_id
+ */
+export async function getInvoiceDetailApi(params) {
+ const data = await get('/invoice/detail', params, 3)
+ return normalizeXkApiResponse(data)
+}
+
+/** 与 config/xk.php invoice_notice 保持一致的订阅消息模板 ID */
+export const INVOICE_NOTICE_TMPL_ID = '2FuQhhO74mABSqGx2cF7vRR2wGekrIMM9kZMvVI6h-Q'
diff --git a/subPackages/my/my-drug/drug-info.vue b/subPackages/my/my-drug/drug-info.vue
index 36ca4cb..d2e8219 100644
--- a/subPackages/my/my-drug/drug-info.vue
+++ b/subPackages/my/my-drug/drug-info.vue
@@ -431,52 +431,63 @@ export default {
})
return
}
-
- // 先调用接口更新,成功后再更新页面状态
+
if (index == 1) {
// 到店自取:先调用接口,成功后再更新页面
- this.toUpdata(index)
+ this.toUpdata(1)
+ return
+ }
+
+ // 快递到家:已有地址则直接切配送;否则去地址页(地址页会带 delivery_method=0 提交)
+ // 禁止在此处只改本地状态而不调接口,否则 onShow 可能用旧 delivery_method=1 覆盖
+ const hasAddress = !!(this.orderInfo.ProductOrder && this.orderInfo.ProductOrder.address_id)
+ || !!uni.getStorageSync('address_id')
+ if (hasAddress) {
+ this.toUpdata(0)
} else {
- // 快递到家:跳转到地址选择页面
this.isshowed = false
this.isshow = true
this.toChoose()
}
},
- // 更新配送方式
+ // 更新配送方式(仅用户明确操作时调用,禁止 onShow 盲调)
toUpdata(deliveryMethodIndex) {
if (!this.order_id) return
-
- // 如果传入了参数,使用传入的值,否则使用当前的 delivery_method
- const targetDeliveryMethod = deliveryMethodIndex !== undefined ? deliveryMethodIndex : this.delivery_method
-
+ if (deliveryMethodIndex === undefined || deliveryMethodIndex === null) {
+ return
+ }
+
+ const targetDeliveryMethod = deliveryMethodIndex
+ const addressId = uni.getStorageSync('address_id')
+ || (this.orderInfo.ProductOrder && this.orderInfo.ProductOrder.address_id)
+ || 0
+
getDelivery({
method: "post",
data: {
- address_id: uni.getStorageSync('address_id'),
+ address_id: addressId,
delivery_method: targetDeliveryMethod,
order_id: this.order_id,
store_id: uni.getStorageSync('store_id') || '11001'
}
}).then((res) => {
- if (res.data.errcode === 0) {
- // 接口成功后再更新页面状态
- if (deliveryMethodIndex !== undefined) {
- this.delivery_method = deliveryMethodIndex
- if (deliveryMethodIndex == 1) {
- this.isshowed = true
- this.isshow = false
- } else {
- this.isshowed = false
- this.isshow = true
- }
+ const ok = res.data && (res.data.code === 0 || res.data.errcode === 0)
+ if (ok) {
+ this.delivery_method = targetDeliveryMethod
+ uni.setStorageSync('delivery_method', targetDeliveryMethod)
+ if (targetDeliveryMethod == 1) {
+ this.isshowed = true
+ this.isshow = false
+ } else {
+ this.isshowed = false
+ this.isshow = true
}
// 刷新订单信息
this.getInfo()
} else {
// 错误处理:拒绝更新并显示错误信息,不更新页面状态
this.$refs.uToast.show({
- title: res.data.msg || '更新失败',
+ title: (res.data && (res.data.message || res.data.msg)) || '更新失败',
type: 'default',
icon: false
})
@@ -597,7 +608,7 @@ export default {
}
})
},
- // 地址列表
+ // 地址列表(仅拉取列表,禁止自动 toUpdata,避免用旧 delivery_method=1 覆盖刚改好的快递)
getList() {
getaddressList({
method: "post",
@@ -609,8 +620,6 @@ export default {
this.actionList = res.data.data
}
})
-
- this.toUpdata()
},
// 地址
toChoose() {
diff --git a/subPackages/my/my-drug/drug-list.vue b/subPackages/my/my-drug/drug-list.vue
index 105831b..913df12 100644
--- a/subPackages/my/my-drug/drug-list.vue
+++ b/subPackages/my/my-drug/drug-list.vue
@@ -130,8 +130,16 @@
-
+
+
+ 查看发票
+
+
取消
@@ -167,7 +175,21 @@
查看物流
-
+
+ 申请开票
+
+
+ 开票详情
+
+
@@ -304,6 +326,24 @@ export default {
url: '/subPackages/shop/logistics?id=' + e
})
},
+ /**
+ * 跳转申请开票页
+ */
+ toInvoiceApply(item) {
+ uni.navigateTo({
+ url: '/subPackages/my/my-drug/invoice-apply?order_id=' + item.id
+ + '&order_no=' + encodeURIComponent(item.order_no || '')
+ + '&amount=' + encodeURIComponent(item.total_pay_price || '')
+ })
+ },
+ /**
+ * 跳转开票详情/下载页
+ */
+ toInvoiceDetail(invoiceId) {
+ uni.navigateTo({
+ url: '/subPackages/my/my-drug/invoice-detail?id=' + invoiceId
+ })
+ },
next(id) {
this.id = id
@@ -850,10 +890,26 @@ export default {
.choose_btn {
display: flex;
- justify-content: flex-end;
+ justify-content: space-between;
+ align-items: center;
margin-top: 32rpx;
flex-wrap: wrap;
+ .invoice_link {
+ font-size: 26rpx;
+ font-weight: 500;
+ color: #5f71fe;
+ padding: 12rpx 0;
+ margin-right: auto;
+ }
+
+ .btn_right {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ margin-left: auto;
+ }
+
.order_info {
font-size: 26rpx;
font-weight: 400;
diff --git a/subPackages/my/my-drug/invoice-apply.vue b/subPackages/my/my-drug/invoice-apply.vue
new file mode 100644
index 0000000..d2772db
--- /dev/null
+++ b/subPackages/my/my-drug/invoice-apply.vue
@@ -0,0 +1,326 @@
+
+
+
+
+ 订单信息
+
+ 订单号
+ {{ orderNo }}
+
+
+ 开票金额
+ ¥{{ amount }}
+
+
+
+
+
+ 抬头信息
+
+ 抬头类型
+
+ 个人
+ 企业
+
+
+
+ *抬头名称
+
+
+
+ *企业税号
+
+
+
+
+
+
+ 接收方式
+
+ 小程序下载
+ 邮箱接收
+
+
+
+
+
+ 接收邮箱
+
+ 邮箱
+
+
+ 开具发票后可到小程序或邮箱中查收
+
+
+
+
+
+
+
+
+
+
diff --git a/subPackages/my/my-drug/invoice-detail.vue b/subPackages/my/my-drug/invoice-detail.vue
new file mode 100644
index 0000000..d7b34f8
--- /dev/null
+++ b/subPackages/my/my-drug/invoice-detail.vue
@@ -0,0 +1,250 @@
+
+
+
+
+ {{ info.status_text || '' }}
+ ¥{{ info.amount || '' }}
+
+ 订单号{{ info.order_no }}
+ 抬头类型{{ info.title_type_text }}
+ 抬头名称{{ info.title_name }}
+
+ 税号{{ info.tax_no }}
+
+ 接收方式{{ info.receive_type_text }}
+
+ 邮箱{{ info.email }}
+
+
+ 票据代码{{ info.invoice_code }}
+
+
+ 拒绝原因{{ info.reject_reason }}
+
+
+ 发票已发送至邮箱{{ info.email_sent == 1 ? '' : '(如未收到可联系客服)' }}
+
+
+
+
+ 发票文件
+
+
+ PDF
+ {{ fileName(url, index) }}
+ {{ isImage(url) ? '预览' : '打开文档预览' }}
+
+
+
+ 暂无开票信息
+
+
+
+
+
+
diff --git a/subPackages/my/record-pay.vue b/subPackages/my/record-pay.vue
index b7d42e6..c893987 100644
--- a/subPackages/my/record-pay.vue
+++ b/subPackages/my/record-pay.vue
@@ -393,56 +393,65 @@
})
return
}
-
- // 先调用接口更新,成功后再更新页面状态
+
if (index == 1) {
// 到店自取:先调用接口,成功后再更新页面
- this.toUpdata(index)
+ this.toUpdata(1)
+ return
+ }
+
+ // 快递到家:已有地址则直接切配送;否则去地址页
+ const hasAddress = !!(this.orderInfo.ProductOrder && this.orderInfo.ProductOrder.address_id)
+ || !!uni.getStorageSync('address_id')
+ if (hasAddress) {
+ this.toUpdata(0)
} else {
- // 快递到家:跳转到地址选择页面
this.isshowed = false
this.isshow = true
this.toChoose()
}
- // console.log(`点击了第${index + 1}项,内容为:${this.list[index].text}`)
},
- // 更新配送方式
+ // 更新配送方式(仅用户明确操作时调用,禁止 onShow 盲调)
toUpdata(deliveryMethodIndex) {
- // 如果传入了参数,使用传入的值,否则使用当前的 delivery_method
- const targetDeliveryMethod = deliveryMethodIndex !== undefined ? deliveryMethodIndex : this.delivery_method
+ if (this.order_id == '') {
+ return
+ }
+ if (deliveryMethodIndex === undefined || deliveryMethodIndex === null) {
+ return
+ }
+
+ const targetDeliveryMethod = deliveryMethodIndex
+ const addressId = uni.getStorageSync('address_id')
+ || (this.orderInfo.ProductOrder && this.orderInfo.ProductOrder.address_id)
+ || 0
- if (this.order_id == '') {
- return ;
- }
getDelivery({
method: "post",
data: {
- address_id: uni.getStorageSync('address_id'),
+ address_id: addressId,
delivery_method: targetDeliveryMethod,
order_id: this.order_id,
store_id: uni.getStorageSync('store_id') || '11001'
}
}).then((res) => {
- if (res.data.errcode === 0) {
- // 接口成功后再更新页面状态
- if (deliveryMethodIndex !== undefined) {
- this.wayText = this.list[deliveryMethodIndex].text
- this.delivery_method = deliveryMethodIndex
- if (deliveryMethodIndex == 1) {
- this.isshowed = true
- this.isshow = false
- } else {
- this.isshowed = false
- this.isshow = true
- }
+ const ok = res.data && (res.data.code === 0 || res.data.errcode === 0)
+ if (ok) {
+ this.wayText = this.list[targetDeliveryMethod] && this.list[targetDeliveryMethod].text
+ this.delivery_method = targetDeliveryMethod
+ uni.setStorageSync('delivery_method', targetDeliveryMethod)
+ if (targetDeliveryMethod == 1) {
+ this.isshowed = true
+ this.isshow = false
+ } else {
+ this.isshowed = false
+ this.isshow = true
}
// 刷新订单信息
this.getInfo()
- // console.log(res, '确定代煎');
} else {
// 错误处理:拒绝更新并显示错误信息,不更新页面状态
this.$refs.uToast.show({
- title: res.data.msg || '更新失败',
+ title: (res.data && (res.data.message || res.data.msg)) || '更新失败',
type: 'default',
icon: false
})
@@ -591,7 +600,7 @@
}
})
},
- // 地址列表
+ // 地址列表(仅拉取列表,禁止自动 toUpdata,避免用旧 delivery_method=1 覆盖刚改好的快递)
getList() {
getaddressList({
method: "post",
@@ -604,7 +613,6 @@
this.actionList = res.data.data
}
})
- this.toUpdata()
},
// 地址
toChoose() {
diff --git a/subPackages/setup/area-list.vue b/subPackages/setup/area-list.vue
index 2d187dd..f384d1e 100644
--- a/subPackages/setup/area-list.vue
+++ b/subPackages/setup/area-list.vue
@@ -136,7 +136,9 @@
store_id: uni.getStorageSync('store_id') || '11001',
}
}).then((res) => {
- if (res.data.errcode == 0) {
+ const ok = res.data && (res.data.code === 0 || res.data.errcode === 0)
+ if (ok) {
+ uni.setStorageSync('delivery_method', 0)
uni.showLoading({
title: "加载中"
});
@@ -150,6 +152,12 @@
});
}, 1300)
+ } else {
+ uni.showToast({
+ title: (res.data && (res.data.message || res.data.msg)) || '更新失败',
+ icon: 'none',
+ duration: 1500
+ })
}
})
}