Files
rlz/coupon/pages/mechanism/mechanism.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

110 lines
3.1 KiB
JavaScript

const app = getApp()
const { request } = require('../../utils/request')
Page({
data: {
navHeight: '',
menuButtonInfo: {},
searchMarginTop: 0,
searchWidth: 0,
searchHeight: 0,
page: 1,
search: '',
lists: [],
firstLoad: true
},
changeSearch: function (e) {
this.setData({ search: e.detail.value, page: 1 })
this.getMechanismList()
},
back() {
wx.navigateBack()
},
mechanism(e) {
wx.navigateTo({
url: "/pages/institutions/institutions?id=" + e.currentTarget.dataset.id,
})
},
Seemore() {
// 查看更多
},
onLoad: function (options) {
this.setData({ menuButtonInfo: wx.getMenuButtonBoundingClientRect() })
const { top, width, height, right } = this.data.menuButtonInfo
wx.getSystemInfo({
success: (res) => {
const { statusBarHeight } = res
const margin = top - statusBarHeight
this.setData({
navHeight: (height + statusBarHeight + (margin * 2)),
searchMarginTop: statusBarHeight + margin,
searchHeight: height,
searchWidth: right - width
})
},
})
},
onShow: function () {
if (this.data.firstLoad) {
this.setData({ firstLoad: false })
this.getMechanismList()
}
},
onPullDownRefresh: function () {
this.setData({ page: 1 })
this.getMechanismList().finally(() => wx.stopPullDownRefresh())
},
onReachBottom: function () {
this.getMechanismList()
},
getMechanismList: function () {
var that = this
var baseUrl = app.globalData.url
return request({
url: '/app/Goddesswechat/getMechanismList',
method: 'POST',
loading: true,
data: {
uid: wx.getStorageSync('uid'),
token: wx.getStorageSync('token'),
page: String(this.data.page),
page_size: 50,
city: '',
style_id: '',
serach_name: this.data.search,
px_type: '',
lng: '',
lat: '',
}
}).then(res => {
if (res.code === 200 || res.erro === 0) {
var lists = res.lists || res.data || [];
lists = lists.map(function(item) {
if (item.wechat_logo && item.wechat_logo.indexOf('http') !== 0) {
item.wechat_logo = baseUrl + item.wechat_logo;
}
return item;
});
if (that.data.page === 1) {
that.setData({ lists: lists })
} else {
that.setData({ lists: that.data.lists.concat(lists) })
}
that.setData({ page: that.data.page + 1 })
}
}).catch(function() {
wx.showToast({ title: '加载失败', icon: 'none' })
})
},
})