my.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { loginByUserInfo,loginByUserInfo1 } from '../../utils/login'
  2. const app = getApp();
  3. Page({
  4. options: {
  5. addGlobalClass: true,
  6. },
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. grid_list: [
  12. { name: '分享', icon:'https://4d-tjw.oss-cn-shenzhen.aliyuncs.com/4dHouse/nav.svg', url:"/pages/share-history/share-history", needLogin: true },
  13. { name: '关注', icon:'https://4d-tjw.oss-cn-shenzhen.aliyuncs.com/4dHouse/follow.svg', url:"/pages/follow-list/follow-list", needLogin: true },
  14. { name: '浏览', icon:'https://4d-tjw.oss-cn-shenzhen.aliyuncs.com/4dHouse/history.svg', url:"/pages/view-history/view-history", needLogin: true },
  15. ],
  16. cu_items: [
  17. { title: '反馈问题', icon: 'feedback', bottomType: 'feedback' },
  18. { title: '关注公众号', icon: 'guanzhu', value: '/pages/contact/contact', tip: '获取最新资讯,咨询' },
  19. { title: '客服电话', icon: 'call', tip: '400-669-8025', value: '400-669-8025', action: 'call'},
  20. { title: '关于我们', icon: 'about', value: '/pages/about/about' },
  21. ],
  22. user_code: '',
  23. isLogined: app.globalData.token ? true : false,
  24. userinfo: app.globalData.userinfo
  25. },
  26. Navigator_to(e){
  27. const { value, action } = e.currentTarget.dataset
  28. if (value) {
  29. if (action === 'call') {
  30. wx.makePhoneCall({
  31. phoneNumber: value
  32. })
  33. return
  34. }
  35. console.log(value)
  36. wx.navigateTo({
  37. url: value,
  38. })
  39. }
  40. },
  41. toModifyUser () {
  42. if (!this.data.isLogined) {
  43. return
  44. }
  45. wx.navigateTo({
  46. url: '/pages/user-info/user-info',
  47. })
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad: function (e) {
  53. wx.login({
  54. success: (res) => {
  55. this.setData({
  56. user_code: res.code
  57. })
  58. }
  59. })
  60. },
  61. onShow: function () {
  62. this.setData({
  63. isLogined: app.globalData.token ? true : false,
  64. userinfo: app.globalData.userinfo
  65. });
  66. },
  67. /**
  68. * 生命周期函数--监听页面隐藏
  69. */
  70. onHide: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面卸载
  74. */
  75. onUnload: function () {
  76. },
  77. bindgetuserinfo (e) {
  78. loginByUserInfo(e, this.data.user_code).then(res => {
  79. this.setData({
  80. isLogined: app.globalData.token ? true : false,
  81. userinfo: app.globalData.userinfo
  82. })
  83. })
  84. },
  85. bindgetuserinfo1 (e) {
  86. // wx.getUserProfile({
  87. // desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  88. // success: (res) => {
  89. loginByUserInfo1().then(res => {
  90. this.setData({
  91. isLogined: app.globalData.token ? true : false,
  92. userinfo: app.globalData.userinfo
  93. })
  94. })
  95. // this.setData({
  96. // isLogined: app.globalData.token ? true : false,
  97. // userinfo: app.globalData.userinfo
  98. // })
  99. // }
  100. // })
  101. },
  102. })