methods.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import Apis from '@/common/apis/index'
  2. const mobileReg = /^1[3456789]\d{9}$/
  3. export default {
  4. async initData() {
  5. try {
  6. uni.showLoading({
  7. title: '加载中...'
  8. })
  9. const res = await Apis.GetAssociation()
  10. this.users = res.data
  11. uni.hideLoading()
  12. } catch (e) {
  13. //TODO handle the exception
  14. }
  15. },
  16. onEnterPage(page, val) {
  17. if (!this.userInfo) {
  18. return uni.navigateTo({
  19. url: '../login/index'
  20. })
  21. }
  22. switch (page) {
  23. case 'index':
  24. this.$store.commit('SET_CURRENT_PATIENT', val)
  25. uni.switchTab({
  26. url: '../index/index'
  27. })
  28. break
  29. case 'addPatient':
  30. uni.navigateTo({
  31. url: '../addPatient/index'
  32. })
  33. break
  34. case 'setting':
  35. uni.navigateTo({
  36. url: '../setting/index'
  37. })
  38. break
  39. }
  40. },
  41. bindOpenUnbundle(val) {
  42. this.unbundleUser = val
  43. this.$refs.userPopup.open()
  44. },
  45. bindUnbundle() {
  46. let that = this
  47. uni.showModal({
  48. title: '提示',
  49. content: '确定解绑此学生信息吗?',
  50. async success(res) {
  51. if (res.confirm) {
  52. console.log('用户点击确定');
  53. await Apis.PostDeleteAssociation({
  54. id: that.unbundleUser.id
  55. })
  56. uni.showToast({
  57. title: '解绑成功'
  58. })
  59. that.initData()
  60. that.$store.commit('SET_CURRENT_PATIENT', null)
  61. that.$refs.userPopup.close()
  62. } else if (res.cancel) {
  63. console.log('用户点击取消');
  64. }
  65. }
  66. });
  67. },
  68. }