index.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // index.ts
  2. // 获取应用实例
  3. const app = getApp<IAppOption>()
  4. Component({
  5. data: {
  6. current: 0,
  7. autoplay: false,
  8. interval: 5000,
  9. duration: 500,
  10. popupShow: false
  11. },
  12. methods: {
  13. // 事件处理函数
  14. changeSwiper(e: any) {
  15. const detail = e.detail;
  16. if(detail.source === 'touch' || detail.source == 'autoplay') {
  17. this.setData({
  18. current: detail.current
  19. })
  20. }
  21. },
  22. isLogin() {
  23. // 判断是否登录
  24. if(!app.globalData.isLogin) {
  25. wx.navigateTo({
  26. url: '../login/login',
  27. })
  28. return false
  29. }
  30. return true
  31. },
  32. /** 我的订单 */
  33. onOrder() {
  34. // 判断是否登录
  35. if(!this.isLogin()) {
  36. return
  37. }
  38. wx.navigateTo({
  39. url: '../orders/orders',
  40. })
  41. },
  42. onBuyShop() {
  43. // 判断是否登录
  44. if(!this.isLogin()) {
  45. return
  46. }
  47. this.setData({
  48. popupShow: true
  49. })
  50. },
  51. onClose() {
  52. this.setData({
  53. popupShow: false
  54. })
  55. },
  56. onSubmit() {
  57. // 判断是否登录
  58. if(!this.isLogin()) {
  59. return
  60. }
  61. wx.navigateTo({
  62. url: '../orders/order-detail',
  63. })
  64. this.setData({
  65. popupShow: false
  66. })
  67. }
  68. // getUserProfile() {
  69. // // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  70. // wx.getUserProfile({
  71. // desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  72. // success: (res) => {
  73. // console.log(res)
  74. // this.setData({
  75. // userInfo: res.userInfo,
  76. // hasUserInfo: true
  77. // })
  78. // }
  79. // })
  80. // },
  81. },
  82. })