| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- // order-detail.js
- Page({
- data: {
- order: null
- },
- onLoad(options) {
- const orderId = parseInt(options.id)
- const app = getApp()
- const orders = app.getOrders()
- const order = orders.find(o => o.id === orderId)
-
- if (order) {
- this.setData({
- order: order
- })
- } else {
- wx.showToast({
- title: '订单不存在',
- icon: 'none'
- })
- setTimeout(() => {
- wx.navigateBack()
- }, 1500)
- }
- },
- // 返回上一页
- goBack() {
- wx.navigateBack({
- delta: 1
- })
- },
- // 联系客服
- contactSupport() {
- wx.showModal({
- title: '联系客服',
- content: '客服电话:400-123-4567\n工作时间:9:00-18:00',
- showCancel: false
- })
- },
- // 再次购买
- reorder() {
- const order = this.data.order
- wx.showModal({
- title: '再次购买',
- content: `确认再次购买${order.hospital}的药品吗?`,
- success: (res) => {
- if (res.confirm) {
- // 跳转到下单页面
- wx.switchTab({
- url: '/pages/order/order'
- })
-
- // 延迟设置搜索关键词
- setTimeout(() => {
- const pages = getCurrentPages()
- const orderPage = pages.find(page => page.route === 'pages/order/order')
- if (orderPage) {
- orderPage.setData({
- currentTab: 0,
- hospitalKeyword: order.hospital
- })
- }
- }, 500)
- }
- }
- })
- },
- // 删除订单
- deleteOrder() {
- const order = this.data.order
- wx.showModal({
- title: '确认删除',
- content: '确定要删除这个订单吗?删除后无法恢复。',
- success: (res) => {
- if (res.confirm) {
- const app = getApp()
- app.deleteOrder(order.id)
-
- wx.showToast({
- title: '订单已删除',
- icon: 'success',
- success: () => {
- setTimeout(() => {
- wx.navigateBack()
- }, 1500)
- }
- })
- }
- }
- }
- )
- }
- })
|