Files
rlz/coupon/pages/index/index.js
renjianbo ea6a6087d4 fix: comprehensive mini program bug fixes - image URLs, API calls, UI issues
- Fix hospital/service/caregiver images blank by prepending baseUrl for relative paths
- Add icon name mapping and resolveIcon() for service icon fallback
- Fix login phone field: res.phone -> res.data.phoneNumber
- Fix pagination stuck at page 1 in mechanism.js and qianbao.js
- Fix response parsing to handle both {code:200} and {erro:0} formats
- Replace raw wx.request calls with unified request() utility (6+ instances)
- Fix hardcoded phone number exposure in orderdetail.js
- Fix broken privacy URL (http: -> https://)
- Fix expired date range in goddess.wxml (2025 -> 2030)
- Remove duplicate refund box in orderdetail.wxml
- Fix service icon fallback ternary logic
- Add proper error handling replacing empty .catch() blocks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 10:46:31 +08:00

221 lines
5.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 服务图标名称 -> 本地 PNG 文件名的映射(以防 DB icon 字段为空或名称不匹配)
var iconNameMap = {
'全面陪诊': '全程陪诊',
'提前约号': '诊前约号',
'取送结果': '取送结果',
'代办买药': '代办买药',
'出入院办理': '出入院办理',
'代取报告': '代办问诊',
'夜间陪诊': '全程陪诊',
'测试陪诊服务': '全程陪诊',
'陪护服务': '院内陪护-back',
'代办问诊': '代办问诊'
}
function resolveIcon(s) {
if (s.icon && s.icon.indexOf('http') === 0) return s.icon
if (s.icon && iconNameMap[s.icon]) return iconNameMap[s.icon]
if (s.name && iconNameMap[s.name]) return iconNameMap[s.name]
return s.name || '全程陪诊'
}
var app = getApp();
const { request } = require('../../utils/request')
Page({
data: {
hospitalData: [],
bannerdata: [
"home-banner",
"home-banner",
"home-banner"
],
itemView: [],
firstLoad: true
},
/**
* 诊前约号、代办买药、取送结果、出入院办理、就医陪诊、园内护理
*/
itemClick(options) {
if (wx.getStorageSync('phone') == '') {
wx.setStorageSync('uidFlag', false);
console.log('请登录')
this.isdenglu()
} else {
let item = JSON.stringify(options.currentTarget.dataset.item);
wx.navigateTo({
// url: "/pages/peizhen/peizhendetail?servername=" + options.currentTarget.dataset.id,
url: "/pages/peizhen/peizhendetail?item=" + item,
});
}
},
goService() {
wx.switchTab({ url: '/pages/service/service' })
},
go_peizhen() {
if (wx.getStorageSync('phone') == '') {
wx.setStorageSync('uidFlag', false);
console.log('请登录')
this.isdenglu()
} else {
wx.navigateTo({
url: '/pages/peizhen/peizhen',
})
}
},
go_peihu() {
if (wx.getStorageSync('phone') == '') {
wx.setStorageSync('uidFlag', false);
console.log('请登录')
this.isdenglu()
} else {
wx.navigateTo({
url: '/pages/peihu/peihu?' + "hospitalId=" + "",
})
}
},
//获取服务类型列表(从后台动态加载,最多显示8个热门推荐)
getServiceTypes: function () {
var that = this;
request({
url: '/system/serviceType/enabled',
method: 'GET',
data: { category: '2' },
loading: false
}).then(res => {
var services = res.data || [];
if (services.length) {
var mapped = services.slice(0, 8).map(function (s) {
return {
icon: resolveIcon(s),
title: s.name,
price: s.price,
describe: s.description || '',
ordertype: s.typeCode
}
})
that.setData({ itemView: mapped })
}
}).catch(function() {
wx.showToast({ title: '加载服务失败', icon: 'none' })
})
},
//获取医院列表
getHospitalList: function () {
var that = this;
request({
url: '/system/hospital/list',
method: 'GET',
loading: false
}).then(res => {
var hospitals = res.rows || res.data || [];
if (hospitals.length) {
var baseUrl = app.globalData.url;
var mapped = hospitals.map(function (h) {
var imgUrl = h.hospitalImage || '';
if (imgUrl && imgUrl.indexOf('http') !== 0) {
imgUrl = baseUrl + imgUrl;
}
return {
id: h.id,
name: h.hospitalname,
grade: h.hospitalLevel || '三甲',
genre: h.hospitalType || '综合医院',
skiled: h.hospitalDesc || '',
address: h.address || '',
img: imgUrl
}
})
that.setData({ hospitalData: mapped })
}
}).catch(function() {
wx.showToast({ title: '加载医院失败', icon: 'none' })
})
},
/**
* 医院列表
*/
listItemTap(options) {
// console.log(options.currentTarget.dataset.id),
if (wx.getStorageSync('phone') == '') {
wx.setStorageSync('uidFlag', false);
console.log('请登录')
this.isdenglu()
} else {
wx.navigateTo({
url: '/pages/peihu/peihu?' + "hospitalId=" + options.currentTarget.dataset.id,
})
}
},
//是否登录
isdenglu() {
wx.showModal({
title: '提示',
content: '请先登录',
success(res) {
if (res.confirm) {
console.log('用户点击确定')
wx.switchTab({
url: '/pages/my/my'
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
if (this.data.firstLoad) {
this.setData({ firstLoad: false })
this.getServiceTypes()
this.getHospitalList()
}
},
onPullDownRefresh() {
this.getServiceTypes()
this.getHospitalList()
wx.stopPullDownRefresh()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})