index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const { async } = require("../../../utils/runtime");
  2. const app = getApp();
  3. const api = app.api;
  4. var startX = 0;
  5. const minXOffset = 40;
  6. Page({
  7. /**
  8. * 记录手势落点坐标
  9. * @param {*} event
  10. */
  11. touchStart: function (event) {
  12. startX = event.touches[0].pageX;
  13. },
  14. /**
  15. * 手势结束计算偏移量并切换卡片
  16. * @param {*} event
  17. */
  18. touchEnd: async function(event) {
  19. let endX = event.changedTouches[0].pageX;
  20. let xOffset = startX - endX;
  21. if (xOffset > minXOffset) {
  22. // 授权登录校验
  23. const isAuth = await app.authorization();
  24. if(isAuth) {
  25. // 查询已登记信息
  26. app.post(api.InvitationGet, {}).then(response => {
  27. if(response.success) {
  28. wx.redirectTo({
  29. url: '../navigation/index',
  30. })
  31. }
  32. }).catch(() => {
  33. wx.redirectTo({
  34. url: '../protocol/index',
  35. })
  36. })
  37. }
  38. }
  39. },
  40. /**
  41. * 手势被打断重置落点坐标
  42. * @param {*} event
  43. */
  44. touchCancel: function(event) {
  45. startX = 0;
  46. },
  47. /**
  48. * 生命周期函数--监听页面显示
  49. */
  50. onShow: async function () {
  51. wx.setNavigationBarTitle({
  52. title: '邀请函',
  53. })
  54. },
  55. /** 分享设置 */
  56. onShareAppMessage: function(res) {
  57. return { title: '邀请函' }
  58. }
  59. })