logic.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. export default {
  2. data() {
  3. return {
  4. taskList: [],
  5. currentFilter: 'default', // default, distance, time
  6. filterCondition: '筛选条件',
  7. sortDistance: 'asc', // asc, desc
  8. sortTime: 'asc',
  9. scrollTop: 0, // Track scroll position
  10. isFilterShow: false,
  11. tempFilter: {
  12. service: '全部',
  13. distance: '全部',
  14. amount: '全部'
  15. },
  16. activeFilter: {
  17. service: '全部',
  18. distance: '全部',
  19. amount: '全部'
  20. },
  21. workStatus: 'working', // working | resting
  22. showConfirmModal: false,
  23. showPetModal: false,
  24. currentPetInfo: {},
  25. showRejectModal: false,
  26. rejectReason: '',
  27. currentOrder: null,
  28. showAcceptConfirmModal: false,
  29. showNavModal: false,
  30. navTargetItem: null,
  31. navTargetPointType: ''
  32. }
  33. },
  34. onPageScroll(e) {
  35. this.scrollTop = e.scrollTop;
  36. },
  37. onLoad() {
  38. // Initial load
  39. this.checkWorkStatus();
  40. this.loadTaskList();
  41. },
  42. onShow() {
  43. // Update status when returning from other pages
  44. this.checkWorkStatus();
  45. },
  46. methods: {
  47. checkWorkStatus() {
  48. const status = uni.getStorageSync('workStatus');
  49. if (status) {
  50. this.workStatus = status;
  51. } else {
  52. // Default to working if not set
  53. this.workStatus = 'working';
  54. uni.setStorageSync('workStatus', 'working');
  55. }
  56. },
  57. toggleFilter() {
  58. if (this.workStatus === 'resting') return; // Disable filter when resting? Or keep it? User didn't specify, but usually disabled. Let's keep it enabled for now as they might look at filters before working.
  59. this.isFilterShow = !this.isFilterShow;
  60. },
  61. goToWorkStatus() {
  62. uni.navigateTo({
  63. url: '/pages/home/work-status'
  64. });
  65. },
  66. startWork() {
  67. this.showConfirmModal = true;
  68. },
  69. confirmStartWork() {
  70. this.workStatus = 'working';
  71. uni.setStorageSync('workStatus', 'working');
  72. this.loadTaskList();
  73. this.showConfirmModal = false;
  74. uni.showToast({ title: '已开始接单', icon: 'success' });
  75. },
  76. closeConfirmModal() {
  77. this.showConfirmModal = false;
  78. },
  79. showPetProfile(item) {
  80. this.currentPetInfo = item;
  81. this.showPetModal = true;
  82. },
  83. closePetProfile() {
  84. this.showPetModal = false;
  85. },
  86. openRejectModal(item) {
  87. this.currentOrder = item;
  88. this.rejectReason = '';
  89. this.showRejectModal = true;
  90. },
  91. closeRejectModal() {
  92. this.showRejectModal = false;
  93. this.currentOrder = null;
  94. },
  95. confirmReject() {
  96. if (!this.rejectReason.trim()) {
  97. uni.showToast({ title: '请输入拒绝理由', icon: 'none' });
  98. return;
  99. }
  100. // Add actual API call here
  101. uni.showToast({ title: '已拒绝接单', icon: 'success' });
  102. this.showRejectModal = false;
  103. },
  104. openAcceptModal(item) {
  105. this.currentOrder = item;
  106. this.showAcceptConfirmModal = true;
  107. },
  108. closeAcceptModal() {
  109. this.showAcceptConfirmModal = false;
  110. this.currentOrder = null;
  111. },
  112. confirmAccept() {
  113. // Add actual API call here
  114. uni.showToast({ title: '接单成功', icon: 'success' });
  115. this.showAcceptConfirmModal = false;
  116. },
  117. openNavigation(item, pointType) {
  118. this.navTargetItem = item;
  119. this.navTargetPointType = pointType;
  120. this.showNavModal = true;
  121. },
  122. closeNavModal() {
  123. this.showNavModal = false;
  124. },
  125. chooseMap(mapType) {
  126. let item = this.navTargetItem;
  127. let pointType = this.navTargetPointType;
  128. let name = pointType === 'start' ? item.startLocation : item.endLocation;
  129. let address = pointType === 'start' ? item.startAddress : item.endAddress;
  130. this.showNavModal = false;
  131. uni.openLocation({
  132. latitude: 30.52, // Mock lat
  133. longitude: 114.31, // Mock lng
  134. name: name || '目的地',
  135. address: address || '默认地址',
  136. success: function () {
  137. console.log('打开导航成功: ' + mapType);
  138. }
  139. });
  140. },
  141. selectService(type) {
  142. this.tempFilter.service = type;
  143. },
  144. selectDistance(type) {
  145. this.tempFilter.distance = type;
  146. },
  147. selectAmount(type) {
  148. this.tempFilter.amount = type;
  149. },
  150. resetFilter() {
  151. this.tempFilter = {
  152. service: '全部',
  153. distance: '全部',
  154. amount: '全部'
  155. };
  156. },
  157. confirmFilter() {
  158. this.activeFilter = { ...this.tempFilter };
  159. this.isFilterShow = false;
  160. uni.showToast({ title: '筛选已生效', icon: 'none' });
  161. // Add filtering logic here if needed
  162. },
  163. closeFilter() {
  164. this.isFilterShow = false;
  165. },
  166. goToDetail(item) {
  167. console.log('Go to detail', item);
  168. },
  169. loadTaskList() {
  170. this.taskList = [
  171. {
  172. type: 1, // 接送
  173. typeText: '接送',
  174. typeIcon: '/static/icons/car.svg', // Ensure this is the yellow car icon
  175. price: '20.00',
  176. timeLabel: '取货时间',
  177. time: '2026/02/10 10:00',
  178. petAvatar: '/static/dog.png',
  179. petName: '哈士奇宝宝',
  180. petBreed: '哈士奇',
  181. petGender: 'M',
  182. petAge: '2岁',
  183. petWeight: '12kg',
  184. petPersonality: '活泼好动,亲人',
  185. petHobby: '喜欢追球,爱吃鸡胸肉',
  186. petRemark: '无特殊过敏史',
  187. petTags: ['已免疫', '已绝育', '性格温顺'],
  188. petLogs: [
  189. { date: '2026/01/15', content: '左后腿有点敏感,剪指甲时要注意。', recorder: '李海' },
  190. { date: '2025/12/28', content: '今天便便正常,精神很好。', recorder: '张三' },
  191. { date: '2025/10/11', content: '模拟更多备注数据,测试吸顶滚动效果 1...', recorder: '系统记录' },
  192. { date: '2025/10/12', content: '模拟更多备注数据,测试吸顶滚动效果 2...', recorder: '系统记录' }
  193. ],
  194. startLocation: '武汉大学宠物店',
  195. startAddress: '武汉市洪山区珞喻路458号',
  196. startDistance: '0.5km',
  197. endLocation: '张** 189****8451',
  198. endAddress: '武汉市武昌区新区大道凤凰广场A座一楼25号',
  199. endDistance: '2.5km',
  200. remark: '这里是订单备注信息。'
  201. },
  202. {
  203. type: 2, // 喂遛
  204. typeText: '喂遛',
  205. typeIcon: '/static/icons/walk.svg', // Ensure this is the orange walk icon
  206. price: '35.00',
  207. timeLabel: '服务时间',
  208. time: '2026/02/11 14:00',
  209. petAvatar: '/static/dog.png',
  210. petName: '金毛',
  211. petBreed: '金毛寻回犬',
  212. petGender: 'F',
  213. petAge: '3岁',
  214. petWeight: '25kg',
  215. petPersonality: '温顺,听话',
  216. petHobby: '喜欢玩飞盘',
  217. petRemark: '暂无',
  218. petTags: ['已免疫', '未绝育'],
  219. petLogs: [],
  220. // Walking order typically has a service address (destination)
  221. endLocation: '王女士 138****1234',
  222. endAddress: '武汉市江汉区泛海国际居住区',
  223. endDistance: '1.2km',
  224. serviceContent: '需自带牵引绳,遛弯30分钟。',
  225. remark: '狗狗比较活泼,请注意安全。'
  226. },
  227. {
  228. type: 3, // 洗护
  229. typeText: '洗护',
  230. typeIcon: '/static/icons/wash.svg',
  231. price: '50.00',
  232. timeLabel: '服务时间',
  233. time: '2026/02/12 09:30',
  234. petAvatar: '/static/dog.png', // Or cat avatar if available
  235. petName: 'Mimi',
  236. petBreed: '布偶猫',
  237. petGender: 'F',
  238. petAge: '1.5岁',
  239. petWeight: '5kg',
  240. petPersonality: '胆小,怕生',
  241. petHobby: '喜欢梳毛',
  242. petRemark: '对水敏感',
  243. petTags: ['已免疫'],
  244. petLogs: [],
  245. endLocation: '赵先生 159****9876',
  246. endAddress: '武汉市汉阳区钟家村',
  247. endDistance: '3.0km',
  248. serviceContent: '上门洗澡,剪指甲。',
  249. remark: '猫咪有点怕生。'
  250. },
  251. {
  252. type: 1, // 接送 (Repeat for demo)
  253. typeText: '接送',
  254. typeIcon: '/static/icons/car.svg',
  255. price: '25.00',
  256. timeLabel: '取货时间',
  257. time: '2026/02/13 11:00',
  258. petAvatar: '/static/dog.png',
  259. petName: '柯基',
  260. petBreed: '柯基犬',
  261. petGender: 'M',
  262. petAge: '2岁',
  263. petWeight: '10kg',
  264. petPersonality: '活泼',
  265. petHobby: '散步',
  266. petRemark: '',
  267. petTags: [],
  268. petLogs: [],
  269. startLocation: '宠物医院',
  270. startAddress: '武汉市武昌区中南路',
  271. startDistance: '1.0km',
  272. endLocation: '李小姐 136****5678',
  273. endAddress: '武汉市武昌区积玉桥',
  274. endDistance: '4.5km',
  275. remark: '请带上笼子。'
  276. }
  277. ]
  278. },
  279. setFilter(type) {
  280. this.currentFilter = type;
  281. if (type === 'distance') {
  282. this.sortDistance = this.sortDistance === 'asc' ? 'desc' : 'asc';
  283. uni.showToast({ title: `按距离${this.sortDistance === 'asc' ? '升序' : '降序'}`, icon: 'none' });
  284. } else if (type === 'time') {
  285. this.sortTime = this.sortTime === 'asc' ? 'desc' : 'asc';
  286. uni.showToast({ title: `按时间${this.sortTime === 'asc' ? '升序' : '降序'}`, icon: 'none' });
  287. }
  288. },
  289. showFilterDropdown() {
  290. this.toggleFilter();
  291. }
  292. }
  293. }