与牧同行-小程序用户端
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.

329 lines
7.5 KiB

6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
  1. Page({
  2. data: {
  3. userInfo: {
  4. avatar: '/assets/images/avatar.png',
  5. nickname: '用户昵称',
  6. phone: '138****8888',
  7. isVerified: false,
  8. isDoctor: false
  9. },
  10. // 功能模块
  11. modules: [
  12. {
  13. id: 'info',
  14. icon: 'user-circle',
  15. name: '个人管理',
  16. items: [
  17. {
  18. id: 'profile',
  19. name: '信息管理',
  20. desc: '查看和编辑个人信息',
  21. icon: 'profile',
  22. badge: 0,
  23. arrow: true
  24. },
  25. {
  26. id: 'realname',
  27. name: '实名认证',
  28. desc: '通过输入身份信息',
  29. icon: 'shield-check',
  30. badge: 0,
  31. arrow: true,
  32. status: '未认证', // 认证状态
  33. statusColor: 'text-orange'
  34. }
  35. ]
  36. },
  37. {
  38. id: 'security',
  39. icon: 'lock',
  40. name: '账户安全',
  41. items: [
  42. {
  43. id: 'security_settings',
  44. name: '账户安全',
  45. desc: '设置账户密码和安全问题',
  46. icon: 'settings',
  47. badge: 0,
  48. arrow: true
  49. },
  50. {
  51. id: 'feedback',
  52. name: '反馈建议',
  53. desc: '向平台提交反馈和建议',
  54. icon: 'message',
  55. badge: 3, // 未读回复数
  56. arrow: true
  57. }
  58. ]
  59. },
  60. {
  61. id: 'notification',
  62. icon: 'bell',
  63. name: '消息通知',
  64. items: [
  65. {
  66. id: 'notifications',
  67. name: '消息通知',
  68. desc: '问诊、问答、订单等消息',
  69. icon: 'notification',
  70. badge: 5, // 未读消息数
  71. arrow: true
  72. },
  73. {
  74. id: 'privacy',
  75. name: '隐私设置',
  76. desc: '管理个人信息可见性',
  77. icon: 'eye-off',
  78. badge: 0,
  79. arrow: true
  80. }
  81. ]
  82. },
  83. {
  84. id: 'support',
  85. icon: 'help-circle',
  86. name: '帮助与支持',
  87. items: [
  88. {
  89. id: 'about',
  90. name: '关于我们',
  91. desc: '了解平台信息',
  92. icon: 'info',
  93. badge: 0,
  94. arrow: true
  95. },
  96. {
  97. id: 'service',
  98. name: '客服中心',
  99. desc: '7x24小时在线服务',
  100. icon: 'headphones',
  101. badge: 0,
  102. arrow: true
  103. },
  104. {
  105. id: 'agreement',
  106. name: '用户协议',
  107. desc: '查看平台使用条款',
  108. icon: 'file-text',
  109. badge: 0,
  110. arrow: true
  111. }
  112. ]
  113. }
  114. ],
  115. // 统计数据
  116. stats: [
  117. {
  118. id: 'consultation',
  119. name: '我的问诊',
  120. value: '12',
  121. icon: 'stethoscope',
  122. color: '#07c160'
  123. },
  124. {
  125. id: 'orders',
  126. name: '我的订单',
  127. value: '8',
  128. icon: 'shopping-bag',
  129. color: '#ff6b6b'
  130. },
  131. {
  132. id: 'favorites',
  133. name: '我的收藏',
  134. value: '23',
  135. icon: 'heart',
  136. color: '#ff9f43'
  137. },
  138. {
  139. id: 'coupons',
  140. name: '我的优惠券',
  141. value: '3',
  142. icon: 'tag',
  143. color: '#2e86de'
  144. }
  145. ],
  146. // 快捷操作
  147. quickActions: [
  148. {
  149. id: 'health_record',
  150. name: '健康档案',
  151. icon: 'file-medical',
  152. color: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
  153. },
  154. {
  155. id: 'appointment',
  156. name: '预约挂号',
  157. icon: 'calendar',
  158. color: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)'
  159. },
  160. {
  161. id: 'medicine',
  162. name: '我的药箱',
  163. icon: 'pill',
  164. color: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)'
  165. },
  166. {
  167. id: 'report',
  168. name: '检查报告',
  169. icon: 'clipboard',
  170. color: 'linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)'
  171. }
  172. ],
  173. // 系统信息
  174. systemInfo: {
  175. version: '2.1.0',
  176. lastLogin: '2024-01-15 14:30'
  177. }
  178. },
  179. onLoad() {
  180. this.loadUserInfo()
  181. this.checkNotifications()
  182. },
  183. onShow() {
  184. // 每次显示页面时刷新数据
  185. this.refreshData()
  186. },
  187. // 加载用户信息
  188. loadUserInfo() {
  189. // 模拟API调用
  190. setTimeout(() => {
  191. this.setData({
  192. 'userInfo.nickname': '张小凡',
  193. 'userInfo.phone': '138****5678',
  194. 'userInfo.isVerified': true,
  195. 'userInfo.isDoctor': false
  196. })
  197. }, 500)
  198. },
  199. // 检查通知
  200. checkNotifications() {
  201. // 模拟检查未读消息
  202. const updatedModules = this.data.modules.map(module => {
  203. return {
  204. ...module,
  205. items: module.items.map(item => {
  206. if (item.id === 'notifications') {
  207. return { ...item, badge: Math.floor(Math.random() * 10) }
  208. }
  209. return item
  210. })
  211. }
  212. })
  213. this.setData({ modules: updatedModules })
  214. },
  215. // 刷新数据
  216. refreshData() {
  217. // 刷新统计数据
  218. const updatedStats = this.data.stats.map(stat => ({
  219. ...stat,
  220. value: String(Math.floor(Math.random() * 20) + 5)
  221. }))
  222. this.setData({ stats: updatedStats })
  223. },
  224. // 点击用户头像区域
  225. onTapUserInfo() {
  226. wx.navigateTo({
  227. url: '/pages/profile/edit-profile'
  228. })
  229. },
  230. // 点击统计项
  231. onTapStat(e) {
  232. const { id } = e.currentTarget.dataset
  233. const urls = {
  234. consultation: '/pages/consultation/my-consultation',
  235. orders: '/pages/order/my-orders',
  236. favorites: '/pages/favorites/favorites',
  237. coupons: '/pages/coupon/my-coupons'
  238. }
  239. if (urls[id]) {
  240. wx.navigateTo({ url: urls[id] })
  241. }
  242. },
  243. // 点击快捷操作
  244. onTapQuickAction(e) {
  245. const { id } = e.currentTarget.dataset
  246. const urls = {
  247. health_record: '/pages/health/record',
  248. appointment: '/pages/appointment/list',
  249. medicine: '/pages/medicine/medicine-box',
  250. report: '/pages/report/list'
  251. }
  252. if (urls[id]) {
  253. wx.navigateTo({ url: urls[id] })
  254. }
  255. },
  256. // 点击功能项
  257. onTapMenuItem(e) {
  258. const { moduleid, itemid } = e.currentTarget.dataset
  259. console.log('点击:', moduleid, itemid)
  260. // 根据不同的itemid跳转到不同页面
  261. const pageMap = {
  262. profile: '/pages/profile/edit-profile',
  263. realname: '/pages/auth/realname-auth',
  264. security_settings: '/pages/security/settings',
  265. feedback: '/pages/feedback/feedback',
  266. notifications: '/pages/notification/notification-center',
  267. privacy: '/pages/privacy/settings',
  268. about: '/pages/about/about',
  269. service: '/pages/service/customer-service',
  270. agreement: '/pages/agreement/user-agreement'
  271. }
  272. if (pageMap[itemid]) {
  273. wx.navigateTo({ url: pageMap[itemid] })
  274. }
  275. },
  276. // 设置
  277. onTapSettings() {
  278. wx.navigateTo({
  279. url: '/pages/settings/settings'
  280. })
  281. },
  282. // 退出登录
  283. onLogout() {
  284. wx.showModal({
  285. title: '提示',
  286. content: '确定要退出登录吗?',
  287. success: (res) => {
  288. if (res.confirm) {
  289. // 清除登录状态
  290. wx.removeStorageSync('token')
  291. wx.removeStorageSync('userInfo')
  292. // 跳转到登录页
  293. wx.reLaunch({
  294. url: '/pages/login/login'
  295. })
  296. }
  297. }
  298. })
  299. },
  300. // 分享
  301. onShareAppMessage() {
  302. return {
  303. title: '健康管理,从这里开始',
  304. path: '/pages/index/index'
  305. }
  306. }
  307. })