You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

433 lines
9.4 KiB

  1. <template>
  2. <view class="companion-select-page">
  3. <!-- 顶部警告提示 -->
  4. <view class="warning-tip">
  5. <view class="warning-icon">
  6. <uni-icons type="info" size="16" color="#A94F20"></uni-icons>
  7. </view>
  8. <view class="warning-text">
  9. <text>相距距离仅供参考伴宠师位置可能不是实时位置请提前10天下单</text>
  10. </view>
  11. </view>
  12. <!-- 伴宠师列表 -->
  13. <scroll-view scroll-y class="companion-scroll">
  14. <view class="companion-list">
  15. <view
  16. class="companion-item"
  17. v-for="(item, index) in companionList"
  18. :key="index"
  19. @click="selectCompanion(item)"
  20. :class="{'selected': selectedCompanionId === item.id}"
  21. >
  22. <!-- 左侧选中标记 -->
  23. <view class="select-icon">
  24. <view class="radio-circle" :class="{'checked': selectedCompanionId === item.id}">
  25. <view class="radio-inner" v-if="selectedCompanionId === item.id"></view>
  26. </view>
  27. </view>
  28. <!-- 伴宠师卡片内容 -->
  29. <view class="companion-card">
  30. <!-- 头像和基本信息 -->
  31. <view class="card-header">
  32. <view class="companion-avatar">
  33. <image :src="item.avatar" mode="aspectFill"></image>
  34. <image v-if="item.verified" class="verified-icon" src="/static/images/details/verified.svg"></image>
  35. </view>
  36. <view class="companion-basic-info">
  37. <view class="companion-name-row">
  38. <text class="companion-name">{{item.name}}</text>
  39. <image :src="item.gender === '男生' ? '/static/images/details/boy.svg' : '/static/images/details/girl.svg'" class="gender-icon"></image>
  40. </view>
  41. <view class="companion-rating">
  42. <text class="client-rating">客户点赞: {{item.likes}}</text>
  43. <image src="/static/images/details/like.svg" class="like-icon"></image>
  44. </view>
  45. <view class="companion-distance">
  46. <text>距离您: {{item.distance}} km</text>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 描述信息 -->
  51. <view class="companion-desc">
  52. <text>{{item.description || '简介:有一只3岁金猫-忽悠,热爱小宠物...'}}</text>
  53. </view>
  54. <!-- 伴宠师经验描述 -->
  55. <view class="companion-experience">
  56. <text>{{item.experience}}</text>
  57. </view>
  58. <!-- 查看详情按钮 -->
  59. <view class="view-detail-btn" @click.stop="viewCompanionDetail(item.id)">
  60. <text>查看详情</text>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 无数据提示 -->
  65. <view class="no-data" v-if="companionList.length === 0">
  66. <image src="/static/images/personal/no-data.png" mode="aspectFit"></image>
  67. <text>暂无伴宠师数据</text>
  68. </view>
  69. </view>
  70. </scroll-view>
  71. <!-- 底部按钮 -->
  72. <view class="footer-buttons">
  73. <view class="cancel-btn" @click="cancel">
  74. <text>取消</text>
  75. </view>
  76. <view class="confirm-btn" @click="confirm">
  77. <text>确定</text>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. companionList: [
  87. {
  88. id: '1',
  89. name: '宠物宝贝',
  90. gender: '男生',
  91. avatar: 'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/details/QR_Code.png',
  92. verified: true,
  93. rating: 5.0,
  94. likes: 5601,
  95. distance: 10.8,
  96. description: '简介:有一只3岁金猫-忽悠,热爱小宠物...',
  97. experience: '养宠4年 | 评价11条 | 服务小结13份'
  98. },
  99. {
  100. id: '2',
  101. name: '宠物宝贝',
  102. gender: '女生',
  103. avatar: 'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/details/QR_Code.png',
  104. verified: true,
  105. rating: 5.0,
  106. likes: 5601,
  107. distance: 10.8,
  108. description: '简介:有一只3岁金猫-忽悠,热爱小宠物...',
  109. experience: '养宠4年 | 评价11条 | 服务小结13份'
  110. }
  111. ],
  112. selectedCompanionId: '',
  113. };
  114. },
  115. computed: {
  116. // 获取当前选中的伴宠师
  117. selectedCompanion() {
  118. if (!this.selectedCompanionId) return null;
  119. return this.companionList.find(item => item.id === this.selectedCompanionId);
  120. }
  121. },
  122. onLoad(options) {
  123. // 获取选择过的伴宠师列表
  124. this.getServicedCompanions();
  125. },
  126. methods: {
  127. // 获取服务过的伴宠师
  128. getServicedCompanions() {
  129. // 实际项目中应调用API获取服务过的伴宠师列表
  130. // 示例代码:
  131. /*
  132. getServicedCompanions().then(res => {
  133. if (res && res.code === 200) {
  134. this.companionList = res.data || [];
  135. }
  136. }).catch(err => {
  137. console.error('获取服务过的伴宠师失败', err);
  138. });
  139. */
  140. // 使用模拟数据
  141. console.log('获取服务过的伴宠师列表');
  142. },
  143. // 选择伴宠师
  144. selectCompanion(companion) {
  145. this.selectedCompanionId = companion.id;
  146. },
  147. // 取消选择
  148. cancel() {
  149. uni.navigateBack();
  150. },
  151. // 确认选择
  152. confirm() {
  153. if (!this.selectedCompanionId) {
  154. uni.showToast({
  155. title: '请选择伴宠师',
  156. icon: 'none'
  157. });
  158. return;
  159. }
  160. // 将选择的伴宠师信息返回给上一页
  161. // 实际项目中应根据需求处理
  162. // 示例代码:
  163. /*
  164. const pages = getCurrentPages();
  165. const prevPage = pages[pages.length - 2];
  166. prevPage.$vm.setSelectedCompanion(this.selectedCompanion);
  167. */
  168. uni.navigateBack();
  169. },
  170. // 查看伴宠师详情
  171. viewCompanionDetail(companionId) {
  172. // 跳转到伴宠师详情页面
  173. uni.navigateTo({
  174. url: `/pages/companionPetList/companionPetInfo?id=${companionId}`
  175. });
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. .companion-select-page {
  182. background-color: #F5F5F5;
  183. min-height: 100vh;
  184. display: flex;
  185. flex-direction: column;
  186. padding-bottom: 120rpx;
  187. }
  188. .warning-tip {
  189. background-color: #FFF4E5;
  190. padding: 20rpx 30rpx;
  191. display: flex;
  192. align-items: center;
  193. margin: 20rpx;
  194. .warning-icon {
  195. margin-right: 10rpx;
  196. }
  197. .warning-text {
  198. flex: 1;
  199. font-size: 24rpx;
  200. color: #A94F20;
  201. line-height: 1.4;
  202. }
  203. }
  204. .companion-scroll {
  205. flex: 1;
  206. height: calc(100vh - 250rpx);
  207. }
  208. .companion-list {
  209. padding: 20rpx;
  210. }
  211. .companion-item {
  212. background-color: #FFFFFF;
  213. border-radius: 16rpx;
  214. padding: 20rpx;
  215. margin-bottom: 20rpx;
  216. display: flex;
  217. align-items: flex-start;
  218. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  219. border: 2rpx solid #fff;
  220. .select-icon {
  221. width: 40rpx;
  222. height: 40rpx;
  223. margin-right: 20rpx;
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. .radio-circle {
  228. width: 32rpx;
  229. height: 32rpx;
  230. border: 2rpx solid #DDDDDD;
  231. border-radius: 50%;
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. &.checked {
  236. border-color: #FFAA48;
  237. }
  238. .radio-inner {
  239. width: 18rpx;
  240. height: 18rpx;
  241. background-color: #FFAA48;
  242. border-radius: 50%;
  243. }
  244. }
  245. }
  246. &.selected {
  247. border: 2rpx solid #FFAA48;
  248. }
  249. .companion-card {
  250. flex: 1;
  251. }
  252. .card-header {
  253. display: flex;
  254. margin-bottom: 16rpx;
  255. }
  256. .companion-avatar {
  257. position: relative;
  258. width: 100rpx;
  259. height: 100rpx;
  260. margin-right: 20rpx;
  261. image {
  262. width: 100%;
  263. height: 100%;
  264. border-radius: 10rpx;
  265. }
  266. .verified-icon {
  267. position: absolute;
  268. right: -10rpx;
  269. bottom: -10rpx;
  270. width: 30rpx;
  271. height: 30rpx;
  272. }
  273. }
  274. .companion-basic-info {
  275. flex: 1;
  276. display: flex;
  277. flex-direction: column;
  278. justify-content: center;
  279. }
  280. .companion-name-row {
  281. display: flex;
  282. align-items: center;
  283. margin-bottom: 6rpx;
  284. .companion-name {
  285. font-size: 32rpx;
  286. font-weight: bold;
  287. color: #333;
  288. margin-right: 10rpx;
  289. }
  290. .gender-icon {
  291. width: 24rpx;
  292. height: 24rpx;
  293. }
  294. }
  295. .companion-rating {
  296. display: flex;
  297. align-items: center;
  298. margin-bottom: 6rpx;
  299. .client-rating {
  300. font-size: 24rpx;
  301. color: #666;
  302. margin-right: 6rpx;
  303. }
  304. .like-icon {
  305. width: 24rpx;
  306. height: 24rpx;
  307. }
  308. }
  309. .companion-distance {
  310. font-size: 24rpx;
  311. color: #999;
  312. }
  313. .companion-desc {
  314. font-size: 24rpx;
  315. color: #666;
  316. margin-bottom: 16rpx;
  317. line-height: 1.4;
  318. }
  319. .companion-experience {
  320. font-size: 24rpx;
  321. color: #999;
  322. background-color: #FFF9E6;
  323. padding: 16rpx;
  324. border-radius: 8rpx;
  325. margin-bottom: 16rpx;
  326. color: #be721b;
  327. text-align: center;
  328. }
  329. .view-detail-btn {
  330. align-self: flex-end;
  331. background-color: #FFAA48;
  332. color: #FFFFFF;
  333. font-size: 26rpx;
  334. padding: 12rpx 30rpx;
  335. border-radius: 30rpx;
  336. text-align: center;
  337. width: fit-content;
  338. margin-left: auto;
  339. }
  340. }
  341. .no-data {
  342. text-align: center;
  343. padding: 100rpx 0;
  344. image {
  345. width: 200rpx;
  346. height: 200rpx;
  347. margin-bottom: 20rpx;
  348. }
  349. text {
  350. font-size: 28rpx;
  351. color: #999;
  352. }
  353. }
  354. .footer-buttons {
  355. position: fixed;
  356. bottom: 0;
  357. left: 0;
  358. right: 0;
  359. display: flex;
  360. padding: 20rpx 30rpx;
  361. background-color: #FFFFFF;
  362. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  363. .cancel-btn, .confirm-btn {
  364. flex: 1;
  365. height: 88rpx;
  366. line-height: 88rpx;
  367. text-align: center;
  368. border-radius: 44rpx;
  369. font-size: 30rpx;
  370. }
  371. .cancel-btn {
  372. background-color: #FFFFFF;
  373. color: #666;
  374. border: 1px solid #DDDDDD;
  375. margin-right: 20rpx;
  376. }
  377. .confirm-btn {
  378. background-color: #FFAA48;
  379. color: #FFFFFF;
  380. box-shadow: 0 4rpx 8rpx rgba(255, 170, 72, 0.3);
  381. }
  382. }
  383. </style>