index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // index.js
  2. // 获取应用实例
  3. const app = getApp()
  4. const link = app.globalData.url
  5. Page({
  6. data: {
  7. grids1: [{
  8. image: 'order',
  9. text: '我的订单'
  10. }, {
  11. image: 'user',
  12. text: '好友列表'
  13. }, {
  14. image: 'help',
  15. text: '帮助中心'
  16. }, {
  17. image: 'add',
  18. text: '邀请好友'
  19. }, {
  20. image: 'to-top',
  21. text: '手动同步订单'
  22. }, {
  23. image: 'customer-service',
  24. text: '联系客服'
  25. }, {
  26. image: 'setting',
  27. text: '设置'
  28. },
  29. {
  30. image: 'success',
  31. text: '体现'
  32. },
  33. //{
  34. // image: 'eye',
  35. // text: '我的足迹'
  36. // }, {
  37. // image: 'scan',
  38. // text: '扫一扫'
  39. // },
  40. ],
  41. // grids2: [{
  42. // image: 'cart',
  43. // text: '我的购物车'
  44. // }, {
  45. // image: 'help',
  46. // text: '帮助中心'
  47. // }, {
  48. // image: 'address',
  49. // text: '地址管理'
  50. // }, {
  51. // image: 'order',
  52. // text: '我的订单'
  53. // }, {
  54. // image: 'customer-service',
  55. // text: '联系客服'
  56. // }, ],
  57. motto: 'Hello World',
  58. userInfo: {},
  59. hasUserInfo: false,
  60. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  61. canIUseGetUserProfile: false,
  62. canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
  63. },
  64. // 事件处理函数
  65. bindViewTap() {
  66. wx.navigateTo({
  67. url: '../logs/logs'
  68. })
  69. },
  70. onLoad() {
  71. var that = this
  72. var opneId = wx.getStorageSync('openId')
  73. if (wx.getUserProfile) {
  74. this.setData({
  75. canIUseGetUserProfile: true
  76. })
  77. }
  78. //获取金额
  79. wx.request( {
  80. url: link + "/v1/user/wallet/get",
  81. header: {
  82. "Content-Type": "application/json"
  83. },
  84. method: "POST",
  85. data: { openId: opneId },
  86. success (res) {
  87. console.log(res)
  88. // if (res.data.code == 200){
  89. // pid = res.data.data.pid
  90. // }
  91. that.setData({
  92. wallet: res.data.data.wallet
  93. })
  94. }
  95. })
  96. },
  97. clickGrid(e) {
  98. if (e.detail.cell.text == "我的订单"){
  99. wx.navigateTo({
  100. url:"/pages/order/order"
  101. })
  102. } else {
  103. wx.showToast({
  104. title: "功能开发中...",
  105. icon: 'none'
  106. });
  107. }
  108. },
  109. getUserProfile(e) {
  110. // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  111. wx.getUserProfile({
  112. desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  113. success: (res) => {
  114. console.log(res)
  115. this.setData({
  116. userInfo: res.userInfo,
  117. hasUserInfo: true
  118. })
  119. }
  120. })
  121. },
  122. getUserInfo(e) {
  123. // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
  124. console.log(e)
  125. this.setData({
  126. userInfo: e.detail.userInfo,
  127. hasUserInfo: true
  128. })
  129. }
  130. })