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>
This commit is contained in:
renjianbo
2026-06-07 10:46:31 +08:00
parent a4dd5c80ac
commit ea6a6087d4
16 changed files with 167 additions and 212 deletions

View File

@@ -56,7 +56,7 @@ Page({
xieyi(e){
wx.navigateTo({
url: "/pages/webpage/webpage?url=" + 'http:www.baidu.com' // 解码
url: "/pages/webpage/webpage?url=" + 'https://www.baidu.com'
})
},

View File

@@ -1,3 +1,24 @@
// 服务图标名称 -> 本地 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')
@@ -24,10 +45,7 @@ Page({
console.log('请登录')
this.isdenglu()
} else {
// console.log(options.currentTarget.dataset.id)
let item = JSON.stringify(options.currentTarget.dataset.item);
// console.log("传递的item" + item);
console.log("传递的item" + item);
wx.navigateTo({
// url: "/pages/peizhen/peizhendetail?servername=" + options.currentTarget.dataset.id,
url: "/pages/peizhen/peizhendetail?item=" + item,
@@ -75,7 +93,7 @@ Page({
if (services.length) {
var mapped = services.slice(0, 8).map(function (s) {
return {
icon: s.icon || s.name,
icon: resolveIcon(s),
title: s.name,
price: s.price,
describe: s.description || '',
@@ -84,7 +102,9 @@ Page({
})
that.setData({ itemView: mapped })
}
}).catch(() => {})
}).catch(function() {
wx.showToast({ title: '加载服务失败', icon: 'none' })
})
},
//获取医院列表
@@ -115,7 +135,9 @@ Page({
})
that.setData({ hospitalData: mapped })
}
}).catch(() => {})
}).catch(function() {
wx.showToast({ title: '加载医院失败', icon: 'none' })
})
},
/**
* 医院列表

View File

@@ -16,7 +16,7 @@ Page({
},
changeSearch: function (e) {
this.setData({ search: e.detail.value })
this.setData({ search: e.detail.value, page: 1 })
this.getMechanismList()
},
@@ -31,7 +31,7 @@ Page({
},
Seemore() {
console.log('点击了查看更多')
// 查看更多
},
onLoad: function (options) {
@@ -69,6 +69,7 @@ Page({
getMechanismList: function () {
var that = this
var baseUrl = app.globalData.url
return request({
url: '/app/Goddesswechat/getMechanismList',
method: 'POST',
@@ -76,7 +77,7 @@ Page({
data: {
uid: wx.getStorageSync('uid'),
token: wx.getStorageSync('token'),
page: '1',
page: String(this.data.page),
page_size: 50,
city: '',
style_id: '',
@@ -86,10 +87,24 @@ Page({
lat: '',
}
}).then(res => {
if (res.erro === 0) {
that.setData({ lists: res.lists || [] })
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(() => {})
}).catch(function() {
wx.showToast({ title: '加载失败', icon: 'none' })
})
},
})

View File

@@ -58,7 +58,7 @@ Page({
}
})
app.globalData.phone = res.phone;
app.globalData.phone = res.data.phoneNumber;
wx.setStorageSync('phone', res.data.phoneNumber);
wx.setStorageSync('uid', res.data.userId);
wx.setStorageSync('token', res.data.token);
@@ -66,7 +66,7 @@ Page({
this.setData({
uidFlag: true,
phone: res.phone
phone: res.data.phoneNumber
})
app.globalData.uid = res.data.userId;
@@ -90,14 +90,15 @@ Page({
// 同步登录信息
syncLogin() {
wx.request({
url: app.buildUrltwo("/member/logintwo"),
header: app.getRequestHeader(),
method: "POST",
request({
url: '/member/logintwo',
method: 'POST',
loading: false,
showError: false,
data: {
name: wx.getStorageSync('uid'),
uid: wx.getStorageSync('uid'),
phone: wx.getStorageSync('phone'),
storename: wx.getStorageSync('token')
token: wx.getStorageSync('token')
}
})
},
@@ -110,10 +111,10 @@ Page({
data: { phonenumber: this.data.phone },
loading: false
}).then(resp => {
if (resp.erro == 0) {
if (resp.code === 200 || resp.erro === 0) {
that.setData({ infor: resp.infor })
}
}).catch(() => {})
}).catch(function() {})
},
/**

View File

@@ -97,7 +97,9 @@ Page({
pageNum: 2,
hasMore: list.length >= 30
})
} catch (e) {}
} catch (e) {
wx.showToast({ title: '加载失败', icon: 'none' })
}
this.setData({ loading: false })
},

View File

@@ -35,7 +35,7 @@
<view style="height: 1rpx;background: #ECECEC;"></view>
<view class="details_box">
<image src="{{item.userbAvatar || '/pages/image/userimg.png'}}" class="Group-image"></image>
<image src="{{(item.userbAvatar && item.userbAvatar.indexOf('http') === 0) ? item.userbAvatar : (item.userbAvatar ? 'https://ruilaizipj.com/prod-api' + item.userbAvatar : '/pages/image/userimg.png')}}" class="Group-image"></image>
<view style="margin-left: 31rpx;margin-top: 40rpx;">
<view class="title">{{item.userbName}}</view>
<view class="detail_number">{{item.serviceTime}}天</view>

View File

@@ -102,7 +102,6 @@ Page({
order_id: e.id
})
//从下单成功后的查看详情进入详情页,调取接口获取详情页数据,除外都是通过列表传参的方式展示详情页数据。
console.log('e.type' + e.type);
if (e.type == 3) {
this.getOrderDetail();
return
@@ -113,12 +112,9 @@ Page({
let item = JSON.parse(e.item);
that.setData({
item: item,
charge_phone: 18133233292,
charge_phone: item.usercPhonenumber || '',
order_id: item.orderId
});
console.log("进入订单详情的status==" + that.data.item.status)
console.log("进入订单详情的orderId==" + that.data.item.orderId)
console.log("进入订单详情的orderNumber==" + that.data.item.orderNumber)
},
/**
@@ -200,18 +196,9 @@ Page({
* 订单状态:3:待支付 时候的付款
*/
cancelOrderfwz() {
this.completeService()
// console.log('点击了取消订单')
// this.setData({
// dingdan_msgfwz: true,
// mengceng: true
// })
},
okcancel() {
console.log('点击了联系客服取消订单')
var that = this;
this.setData({
dingdan_msgfwz: false,
@@ -223,30 +210,17 @@ Page({
*/
cancelok() {
var that = this;
wx.request({
url: app.globalData.url + '/system/order/concelOrder/' + this.data.order_id,
header: app.getRequestHeader(),
request({
url: '/system/order/concelOrder/' + this.data.order_id,
method: 'GET',
data: {
// id: this.data.item.orderId,
},
success: (res) => {
if (res.data.code == 200) {
wx.showToast({
title: res.data.msg,
icon: 'none'
});
setTimeout(function () {
//要延时执行的代码
wx.navigateBack()
}, 2000) //延迟时间 这里是2秒
}
loading: true
}).then(function(res) {
if (res.code === 200 || res.erro === 0) {
wx.showToast({ title: res.msg || '取消成功', icon: 'none' });
setTimeout(function() { wx.navigateBack() }, 2000);
}
});
this.setData({
dingdan_msg: false,
mengceng: false
})
}).catch(function() {});
this.setData({ dingdan_msg: false, mengceng: false })
},
mengceng() {
this.setData({
@@ -266,51 +240,32 @@ Page({
//确认开始服务
startService() {
var that = this;
wx.request({
url: app.globalData.url + '/system/view/startServiceWithOrder',
header: app.getRequestHeader(),
method: 'post',
data: {
orderId: that.data.order_id
},
success: function (res) {
var resp = res.data;
if (res.data.code == 200) {
wx.showToast({
title: res.data.msg,
})
setTimeout(function () {
//要延时执行的代码
wx.navigateBack()
}, 2000) //延迟时间 这里是2秒
}
request({
url: '/system/view/startServiceWithOrder',
method: 'POST',
loading: true,
data: { orderId: that.data.order_id }
}).then(function(res) {
if (res.code === 200) {
wx.showToast({ title: res.msg || '操作成功' });
setTimeout(function() { wx.navigateBack() }, 2000);
}
});
}).catch(function() {});
},
//确认完成服务
completeService() {
var that = this;
wx.request({
url: app.globalData.url + '/system/view/completeOrder',
header: app.getRequestHeader(),
method: 'post',
data: {
orderId: that.data.order_id
},
success: function (res) {
var resp = res.data;
if (res.data.code == 200) {
wx.showToast({
title: res.data.msg,
})
setTimeout(function () {
//要延时执行的代码
wx.navigateBack()
}, 2000) //延迟时间 这里是2秒
}
request({
url: '/system/view/completeOrder',
method: 'POST',
loading: true,
data: { orderId: that.data.order_id }
}).then(function(res) {
if (res.code === 200) {
wx.showToast({ title: res.msg || '操作成功' });
setTimeout(function() { wx.navigateBack() }, 2000);
}
});
}).catch(function() {});
},
/**
* 服务中时确认完成服务
@@ -348,39 +303,17 @@ Page({
refund() {
var that = this;
var reason = this.data.refund_reason || '';
wx.request({
url: app.globalData.url + '/system/order/applyRefund/' + this.data.order_id,
header: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + app.getCache("token")
},
request({
url: '/system/order/applyRefund/' + this.data.order_id,
method: 'POST',
data: {
remark: reason
},
success: (res) => {
var resp = res.data;
if (res.data.code == 200) {
wx.showToast({
title: resp.msg || '退款申请成功',
icon: 'none'
})
setTimeout(function () {
wx.navigateBack()
}, 2000)
} else {
wx.showToast({
title: resp.msg || '申请失败',
icon: 'none'
})
}
}
});
this.setData({
refund_box: false,
mengceng: false
})
loading: true,
data: { remark: reason },
header: { 'content-type': 'application/json' }
}).then(function(res) {
wx.showToast({ title: res.msg || '退款申请成功', icon: 'none' });
setTimeout(function() { wx.navigateBack() }, 2000);
}).catch(function() {});
this.setData({ refund_box: false, mengceng: false })
},
radioChange(e) {
var idx = e.detail.value;

View File

@@ -19,7 +19,7 @@
<view wx:if="{{item.status==8}}" class="status_msg">{{"已结算"}}</view>
</view>
<view class="details_box">
<image src="{{item.userbAvatar || '/pages/image/userimg.png'}}" binderror="onAvatarError" style="width:230rpx;height:230rpx;"></image>
<image src="{{(item.userbAvatar && item.userbAvatar.indexOf('http') === 0) ? item.userbAvatar : (item.userbAvatar ? 'https://ruilaizipj.com/prod-api' + item.userbAvatar : '/pages/image/userimg.png')}}" binderror="onAvatarError" style="width:230rpx;height:230rpx;"></image>
<view style="margin-left: 31rpx;">
<view class="title">专业陪护服务({{item.userbName}})</view>
<!-- <view class="detail_number">数量x{{detail.num}}</view> -->
@@ -70,7 +70,7 @@
<view class="contact">
<view class="contact_title">联系信息</view>
<view style="display: flex;align-items: center;">
<image src="{{item.userbAvatar || '/pages/image/userimg.png'}}" binderror="onAvatarError" style="width:94rpx;height:94rpx;border-radius:50%;margin-right:23rpx;">
<image src="{{(item.userbAvatar && item.userbAvatar.indexOf('http') === 0) ? item.userbAvatar : (item.userbAvatar ? 'https://ruilaizipj.com/prod-api' + item.userbAvatar : '/pages/image/userimg.png')}}" binderror="onAvatarError" style="width:94rpx;height:94rpx;border-radius:50%;margin-right:23rpx;">
</image>
<view>
<view style="color: #333;font-size: 28rpx;font-family: PingFang SC;font-weight: bold;">{{item.userbName}}</view>
@@ -164,27 +164,4 @@
</view>
</view>
</radio-group>
<view style="height:50rpx;"></view>
</scroll-view>
<button type="primary" plain="true" style="margin-bottom:20rpx" bindtap="isok">完成</button>
</view>
<!-- 退款弹窗 -->
<view wx:if="{{refund_box}}" class="refund_box">
<view class="gang" bindtap="gang"></view>
<view class="refund_title">
退款原因</view>
<scroll-view scroll-y style="height: 500rpx;">
<radio-group bindchange="radioChange">
<view wx:for="{{list}}" class="list_box">
<view>{{item.text}}</view>
<view>
<radio value="{{index}}" />
</view>
</view>
</radio-group>
<view style="height:50rpx;"></view>
</scroll-view>
<button type="primary" plain="true" style="margin-bottom:20rpx" bindtap="isok">完成</button>
</view>

View File

@@ -44,7 +44,9 @@ Page({
})
})
that.setData({ option1: options, hospitalData: hospitals })
}).catch(() => {})
}).catch(function() {
that.setData({ option1: [{ text: '加载失败', value: 0 }] })
})
},
// 加载陪护人员列表
@@ -56,8 +58,18 @@ Page({
loading: true,
data: { hospitalId: this.data.hospitalId }
}).then(res => {
that.setData({ special_offer: res.data || [] })
}).catch(() => {})
var list = res.data || [];
var baseUrl = app.globalData.url;
list = list.map(function(item) {
if (item.facePic && item.facePic.indexOf('http') !== 0) {
item.facePic = baseUrl + item.facePic;
}
return item;
});
that.setData({ special_offer: list })
}).catch(function() {
wx.showToast({ title: '加载失败', icon: 'none' })
})
},
// 跳转详情

View File

@@ -41,7 +41,9 @@ Page({
})
})
that.setData({ option1: options, hospitalData: hospitals })
}).catch(() => {})
}).catch(function() {
that.setData({ option1: [{ text: '加载失败', value: 0 }] })
})
},
// 加载服务类型
@@ -60,12 +62,15 @@ Page({
icon: s.icon || s.name,
title: s.name,
price: s.price,
describe: s.description || ''
describe: s.description || '',
ordertype: s.typeCode
}
})
that.setData({ itemView: mapped })
}
}).catch(() => {})
}).catch(function() {
wx.showToast({ title: '加载服务失败', icon: 'none' })
})
},
// 跳转详情

View File

@@ -24,14 +24,11 @@
<view wx:for="{{itemView}}" wx:key="{{index}}" wx:for-item="item" class="flex-item bc_green" style='display:flex;background-color: white;margin-right: 10rpx;margin-bottom: 24rpx;'>
<view class="Group" bindtap="details" data-item="{{item}}">
<view class="Group-image">
<image src="../image/abc.png"></image>
<image src="{{item.icon.indexOf('http') === 0 ? item.icon : '../image/home/' + item.icon + '.png'}}"></image>
</view>
<view class="content">
<view style="display: flex; flex-direction:row;align-items : flex-end;">
<view class="title1">{{item.title}}</view>
<view class="title2"></view>
<view wx:if="{{item.sex==1}}" class="title3">{{"男"}}</view>
<view wx:if="{{item.sex==0}}" class="title3">{{"女"}}</view>
<view class="title4">{{item.price}}元</view>
</view>
<view class="tejia">

View File

@@ -110,38 +110,24 @@ Page({
},
getprice: function () {
var that = this;
wx.request({
url: app.globalData.url + '/system/config/configKey/price',
header: app.getRequestHeader(),
request({
url: '/system/config/configKey/price',
method: 'GET',
data: {},
success: (res) => {
var resp = res.data;
if (res.data.code == 200) {
that.setData({
special_offer: resp.data,
});
}
}
});
loading: false
}).then(resp => {
that.setData({ special_offer: resp.data })
}).catch(function() {})
},
//获取类型
getpriceType: function () {
var that = this;
wx.request({
url: app.globalData.url + '/system/config/configKey/priceType',
header: app.getRequestHeader(),
request({
url: '/system/config/configKey/priceType',
method: 'GET',
data: {},
success: (res) => {
var resp = res.data;
if (res.data.code == 200) {
that.setData({
special_offer: resp.data,
});
}
}
});
loading: false
}).then(resp => {
that.setData({ special_offer: resp.data })
}).catch(function() {})
},
onClose() {
this.setData({
@@ -150,7 +136,7 @@ Page({
},
onSelect(event) {
console.log(event.detail);
// 选择器事件
},
isPhone(value) {
@@ -225,7 +211,6 @@ Page({
//转换成天数
var day = parseInt(ms / (1000 * 60 * 60 * 24));
//do something
console.log("day = ", day);
return day + 1
},
onClickLeft() {
@@ -259,7 +244,7 @@ Page({
that.setData({
item: item
});
console.log("进入订单详情的title==" + that.data.item.title)
// item loaded
},
@@ -328,11 +313,7 @@ Page({
},
//普通选择器2:
bindPickerChange2: function (e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
objectIndex: e.detail.value
})
console.log('picker发送选择改变,医院的id值为', this.data.objectArray[this.data.objectIndex].value)
this.setData({ objectIndex: e.detail.value })
},
})

View File

@@ -6,7 +6,7 @@
<view style='display:flex;background-color: white;'>
<view class="Group">
<view class="Group-image">
<image src="../image/abc.png"></image>
<image src="{{item.icon.indexOf('http') === 0 ? item.icon : '../image/home/' + item.icon + '.png'}}"></image>
</view>
<view class="content">
<view style="display: flex; flex-direction:row;align-items : flex-end;">

View File

@@ -23,7 +23,7 @@
<view class="service-card" bindtap="onServiceTap" data-item="{{item}}">
<view class="card-left">
<view class="card-icon">
<image src="{{item.icon || '/pages/image/empty.png'}}" mode="aspectFit"></image>
<image src="{{item.icon && item.icon.indexOf('http') === 0 ? item.icon : '../image/home/' + (item.icon || 'empty') + '.png'}}" mode="aspectFit"></image>
</view>
</view>
<view class="card-body">
@@ -48,7 +48,7 @@
<view class="service-card" bindtap="onServiceTap" data-item="{{item}}">
<view class="card-left">
<view class="card-icon">
<image src="{{item.icon || '/pages/image/empty.png'}}" mode="aspectFit"></image>
<image src="{{item.icon && item.icon.indexOf('http') === 0 ? item.icon : '../image/home/' + (item.icon || 'empty') + '.png'}}" mode="aspectFit"></image>
</view>
</view>
<view class="card-body">

View File

@@ -10,6 +10,7 @@ Page({
searchMarginTop: 0,
searchWidth: 0,
searchHeight: 0,
page: 1,
firstLoad: true
},
@@ -29,6 +30,7 @@ Page({
},
onPullDownRefresh: function () {
this.setData({ page: 1 })
this.getGoodsList().finally(() => wx.stopPullDownRefresh())
},
@@ -50,13 +52,21 @@ Page({
data: {
uid: wx.getStorageSync('uid'),
token: wx.getStorageSync('token'),
page: '1',
page: String(this.data.page),
page_size: 10,
}
}).then(res => {
if (res.erro === 0) {
that.setData({ order_list: res.detail || [] })
if (res.code === 200 || res.erro === 0) {
var list = res.detail || res.data || [];
if (that.data.page === 1) {
that.setData({ order_list: list })
} else {
that.setData({ order_list: that.data.order_list.concat(list) })
}
that.setData({ page: that.data.page + 1 })
}
}).catch(() => {})
}).catch(function() {
wx.showToast({ title: '加载失败', icon: 'none' })
})
},
})

View File

@@ -6,7 +6,7 @@
<view style='display:flex;background-color: white;'>
<view class="Group">
<view class="Group-image">
<image src="{{item.facePic}}"></image>
<image src="{{item.facePic.indexOf('http') === 0 ? item.facePic : item.facePic ? 'https://ruilaizipj.com/prod-api' + item.facePic : '/pages/image/userimg.png'}}"></image>
</view>
<view class="content">
<view style="display: flex; flex-direction:row;align-items : flex-end;">
@@ -42,7 +42,7 @@
<view class="row-wrap">
<view class="label" style="margin-left: 33rpx;">开始日期</view>
<view class="label-right">
<picker mode="date" value="{{date}}" start="2022-01-01" end="2025-12-01" bindchange="bindDateChange">
<picker mode="date" value="{{date}}" start="2022-01-01" end="2030-12-31" bindchange="bindDateChange">
<view class="picker">
{{seckill_start}}
</view>
@@ -52,7 +52,7 @@
<view class="row-wrap">
<view class="label" style="margin-left: 33rpx;">结束日期</view>
<view class="label-right">
<picker mode="date" value="{{date}}" start="2022-01-01" end="2025-12-01" bindchange="bindDateChangetwo">
<picker mode="date" value="{{date}}" start="2022-01-01" end="2030-12-31" bindchange="bindDateChangetwo">
<view class="picker">
{{seckill_endx}}
</view>