detail-logic.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. export default {
  2. data() {
  3. return {
  4. orderType: 1, // 1:接送, 2:喂遛, 3:洗护
  5. // Define steps dynamically based on type
  6. stepsPickup: ['接单', '到达', '出发', '送达', '完成'],
  7. stepsWalkWash: ['接单', '到达', '开始', '结束', '完成'],
  8. currentStep: 1, // 0-indexed (1 means 到达)
  9. // Mock Data
  10. orderDetail: {
  11. type: 1,
  12. price: '20.00',
  13. timeLabel: '取货时间',
  14. time: '2026/02/10 10:00',
  15. petAvatar: '/static/dog.png',
  16. petName: '哈士奇宝宝',
  17. petBreed: '哈士奇',
  18. serviceTag: '宠物接送',
  19. startLocation: '武汉大学宠物店',
  20. startAddress: '武汉市洪山区珞喻路458号',
  21. endLocation: '张** 189****8451',
  22. endAddress: '武汉市武昌区新区大道凤凰广场A座一楼25号',
  23. serviceContent: '这里是订单服务内容。',
  24. remark: '这里是订单备注信息。',
  25. orderNo: 'T1001',
  26. createTime: '2026/02/10 09:30',
  27. progressLogs: [
  28. { status: '您已接单', time: '2026-02-10 10:00' }
  29. ]
  30. },
  31. // Modal states
  32. showPetModal: false,
  33. currentPetInfo: {},
  34. showNavModal: false,
  35. navTargetPointType: '',
  36. // Upload Modal State
  37. showUploadModal: false,
  38. modalMediaList: [],
  39. modalRemark: '',
  40. // 宠护小结弹窗状态
  41. showSumModal: false,
  42. sumContent: '',
  43. sumDate: '',
  44. sumSigner: '张*哥',
  45. // 宠物备注弹窗状态
  46. showPetRemarkInput: false,
  47. petRemarkText: ''
  48. }
  49. },
  50. computed: {
  51. steps() {
  52. return this.orderType === 1 ? this.stepsPickup : this.stepsWalkWash;
  53. },
  54. displayStatusText() {
  55. let status = this.steps[this.currentStep];
  56. if (status === '已完成' || status === '完成') return '已完成';
  57. if (status === '已拒绝') return '已拒绝';
  58. if (status === '接单') {
  59. return this.orderType === 1 ? '待接送' : '待服务';
  60. }
  61. // For other active states (出发, 到达, 送达, 开始, 结束)
  62. return this.orderType === 1 ? '配送中' : '服务中';
  63. },
  64. currentStatusText() {
  65. return this.steps[this.currentStep];
  66. },
  67. currentTaskTitle() {
  68. let action = this.steps[this.currentStep];
  69. if (action === '到达') return '到达打卡';
  70. if (action === '开始') return '开始服务';
  71. if (action === '出发') return '确认出发';
  72. if (action === '送达' || action === '结束') return '服务完成';
  73. return action;
  74. },
  75. currentTaskDesc() {
  76. let action = this.steps[this.currentStep];
  77. if (action === '到达') {
  78. return '打卡穿着工装消毒站门口的照片或视频';
  79. }
  80. if (this.orderType === 1) { // 送货
  81. if (action === '出发') return '拍摄宠物上车/出发时的状态照片或视频';
  82. if (action === '送达') return '打卡确认送达的照片或视频';
  83. } else if (this.orderType === 2) { // 喂遛
  84. if (action === '开始') return '开始服务并拍摄照片或视频';
  85. if (action === '结束') return '服务完成拍摄照片或视频';
  86. } else if (this.orderType === 3) { // 洗护
  87. if (action === '开始') return '开始服务并拍摄照片或视频';
  88. if (action === '结束') return '服务完成拍摄照片或视频';
  89. }
  90. return '请按要求提交照片或视频及备注';
  91. }
  92. },
  93. onLoad(options) {
  94. if (options.type) {
  95. this.orderType = parseInt(options.type);
  96. this.orderDetail.type = this.orderType;
  97. if (this.orderType === 2 || this.orderType === 3) {
  98. this.orderDetail.serviceTag = this.orderType === 2 ? '上门喂遛' : '上门洗护';
  99. this.orderDetail.orderNo = this.orderType === 2 ? 'W1002' : 'X1003';
  100. this.currentStep = 1;
  101. }
  102. }
  103. },
  104. methods: {
  105. showPetProfile() {
  106. // Use orderDetail basic info and mock the rest
  107. this.currentPetInfo = {
  108. ...this.orderDetail,
  109. petGender: 'M',
  110. petAge: '2岁',
  111. petWeight: '15kg',
  112. petPersonality: '活泼亲人,精力旺盛',
  113. petHobby: '喜欢追飞盘,爱吃肉干',
  114. petRemark: '肠胃较弱,不能乱喂零食;出门易爆冲,请拉紧牵引绳。',
  115. petTags: ['拉响警报', '不能吃鸡肉', '精力旺盛'],
  116. petLogs: [
  117. { date: '2026-02-09 14:00', content: '今天遛弯拉了两次粑粑,精神状态很好。', recorder: '王阿姨' },
  118. { date: '2026-02-08 10:30', content: '有些挑食,剩了小半碗狗粮。', recorder: '李师傅' },
  119. { date: '2026-02-05 09:00', content: '建档。', recorder: '系统记录' }
  120. ]
  121. };
  122. this.showPetModal = true;
  123. },
  124. closePetProfile() {
  125. this.showPetModal = false;
  126. },
  127. openPetRemarkInput() {
  128. this.petRemarkText = '';
  129. this.showPetRemarkInput = true;
  130. },
  131. closePetRemarkInput() {
  132. this.showPetRemarkInput = false;
  133. },
  134. submitPetRemark() {
  135. if (!this.petRemarkText.trim()) {
  136. uni.showToast({ title: '备注内容不能为空', icon: 'none' });
  137. return;
  138. }
  139. const now = new Date();
  140. const date = `${now.getFullYear()}/${String(now.getMonth() + 1).padStart(2, '0')}/${String(now.getDate()).padStart(2, '0')}`;
  141. if (!this.currentPetInfo.petLogs) {
  142. this.currentPetInfo.petLogs = [];
  143. }
  144. this.currentPetInfo.petLogs.unshift({
  145. date: date,
  146. content: this.petRemarkText,
  147. recorder: '张*哥'
  148. });
  149. this.closePetRemarkInput();
  150. uni.showToast({ title: '备注已添加', icon: 'success' });
  151. },
  152. goToAnomaly() {
  153. uni.navigateTo({
  154. url: '/pages/orders/anomaly?orderId=' + (this.orderDetail.orderNo || '')
  155. });
  156. },
  157. callPhone() {
  158. uni.makePhoneCall({ phoneNumber: '18900008451' });
  159. },
  160. openNavigation(type) {
  161. this.navTargetPointType = type;
  162. this.showNavModal = true;
  163. },
  164. closeNavModal() {
  165. this.showNavModal = false;
  166. },
  167. chooseMap(mapType) {
  168. let pointType = this.navTargetPointType;
  169. let name = pointType === 'start' ? this.orderDetail.startLocation : this.orderDetail.endLocation;
  170. let address = pointType === 'start' ? this.orderDetail.startAddress : this.orderDetail.endAddress;
  171. this.showNavModal = false;
  172. uni.openLocation({
  173. latitude: 30.52, // Mock lat
  174. longitude: 114.31, // Mock lng
  175. name: name || '目的地',
  176. address: address || '默认地址',
  177. success: function () {
  178. console.log('打开导航成功: ' + mapType);
  179. }
  180. });
  181. },
  182. openUploadModal() {
  183. this.modalMediaList = [];
  184. this.modalRemark = '';
  185. this.showUploadModal = true;
  186. },
  187. closeUploadModal() {
  188. this.showUploadModal = false;
  189. },
  190. chooseModalMedia() {
  191. uni.chooseImage({
  192. count: 5 - this.modalMediaList.length,
  193. success: (res) => {
  194. this.modalMediaList = this.modalMediaList.concat(res.tempFilePaths);
  195. uni.showToast({ title: '添加成功', icon: 'none' });
  196. }
  197. });
  198. },
  199. removeModalMedia(index) {
  200. this.modalMediaList.splice(index, 1);
  201. },
  202. getCurrentTime() {
  203. const now = new Date();
  204. const y = now.getFullYear();
  205. const m = String(now.getMonth() + 1).padStart(2, '0');
  206. const d = String(now.getDate()).padStart(2, '0');
  207. const h = String(now.getHours()).padStart(2, '0');
  208. const min = String(now.getMinutes()).padStart(2, '0');
  209. return `${y}/${m}/${d} ${h}:${min}`;
  210. },
  211. confirmUploadModal() {
  212. if (this.modalMediaList.length === 0) {
  213. uni.showToast({ title: '请上传至少一张图片或视频', icon: 'none' });
  214. return;
  215. }
  216. // Append to timeline
  217. this.orderDetail.progressLogs.unshift({
  218. status: this.currentTaskTitle,
  219. time: this.getCurrentTime(),
  220. medias: [...this.modalMediaList],
  221. remark: this.modalRemark
  222. });
  223. // Advance step
  224. if (this.currentStep < this.steps.length - 1) {
  225. this.currentStep++;
  226. }
  227. this.closeUploadModal();
  228. uni.showToast({ title: '打卡成功', icon: 'success' });
  229. // Check if it's finished now
  230. if (this.currentStep === this.steps.length - 1) {
  231. setTimeout(() => {
  232. uni.showToast({ title: '订单已完成', icon: 'none' });
  233. }, 1500);
  234. }
  235. },
  236. copyOrderNo() {
  237. uni.setClipboardData({
  238. data: this.orderDetail.orderNo,
  239. success: () => {
  240. uni.showToast({ title: '复制成功', icon: 'none' });
  241. }
  242. });
  243. },
  244. openSumModal() {
  245. // 初始化日期
  246. const now = new Date();
  247. const y = now.getFullYear();
  248. const m = String(now.getMonth() + 1).padStart(2, '0');
  249. const d = String(now.getDate()).padStart(2, '0');
  250. this.sumDate = `${y}/${m}/${d}`;
  251. // 预设服务内容模板
  252. if (!this.sumContent) {
  253. this.sumContent =
  254. '1. 精神/身体状态:\n' +
  255. '2. 进食/饮水:\n' +
  256. '3. 排泤情况:\n' +
  257. '4. 卫生情况:\n' +
  258. '5. 互动情况:\n' +
  259. '6. 特殊情况/备注:';
  260. }
  261. this.showSumModal = true;
  262. },
  263. closeSumModal() {
  264. this.showSumModal = false;
  265. },
  266. submitSumModal() {
  267. if (!this.sumContent.trim()) {
  268. uni.showToast({ title: '请填写服务内容', icon: 'none' });
  269. return;
  270. }
  271. this.closeSumModal();
  272. uni.showToast({ title: '小结已提交', icon: 'success' });
  273. }
  274. }
  275. }