抖音小程序C端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
2.6 KiB

  1. const app = getApp()
  2. const navigationBarHeight = (getApp().statusBarHeight + 44) + "px";
  3. const Http = require("../utils/HttpBasics");
  4. const config = require("../config/config");
  5. const imgurl = require("../utils/imgurl");
  6. Page({
  7. data: {
  8. navigationBarHeight,
  9. showPhoem: false,
  10. phoemFalg: true,//授权手机标记
  11. },
  12. showPhoemBtn() {
  13. this.setData({
  14. showPhoem: true
  15. })
  16. },
  17. go(e) {
  18. if (this.data.phoemFalg) {
  19. tt.showToast({
  20. title: '请授权手机号', // 内容
  21. icon: 'none', // 图标
  22. success: (res) => {
  23. },
  24. fail: (res) => {
  25. },
  26. });
  27. } else {
  28. let url = e.currentTarget.dataset.url
  29. console.log(url);
  30. if(url=='/pages/order/index/index?id=all'){
  31. tt.navigateTo({
  32. url: url,
  33. success: (res) => {
  34. },
  35. fail: (res) => {
  36. },
  37. });
  38. }else{
  39. tt.navigateTo({
  40. url: url, // 指定页面的 url
  41. success: (res) => {
  42. },
  43. fail: (res) => {
  44. },
  45. });
  46. }
  47. }
  48. },
  49. setPhone(paramData) {//子组件调用这个方法说明手机号已经授权成功
  50. this.setData({
  51. showPhoem: paramData.detail,
  52. phoemFalg: false
  53. })
  54. tt.showToast({
  55. title: '授权成功', // 内容
  56. icon: 'none', // 图标
  57. success: (res) => {
  58. },
  59. fail: (res) => {
  60. },
  61. });
  62. },
  63. setBox(paramData) {
  64. this.setData({
  65. showPhoem: paramData.detail
  66. })
  67. tt.showToast({
  68. title: '取消授权', // 内容
  69. icon: 'none', // 图标
  70. success: (res) => {
  71. },
  72. fail: (res) => {
  73. },
  74. });
  75. },
  76. onLoad: function (options) {
  77. let _this = this
  78. Http.get({//判断是否授权抖音
  79. url: config.api.checkPhoneStatus,
  80. }).then(res => {
  81. this.setData({
  82. phoemFalg: false
  83. })
  84. }).catch(err => {
  85. console.log(err, "我出错了")
  86. })
  87. tt.getUserInfo({
  88. withCredentials: true,
  89. success: function (res) {
  90. _this.setData({
  91. userData: res.userInfo
  92. })
  93. Http.post({
  94. url: config.api.getUserInfo,
  95. data: {
  96. encryptedData: res.encryptedData,
  97. iv: res.iv
  98. }
  99. }).then(res => {
  100. }).catch(err => {
  101. tt.showToast({
  102. title: err.message ? err.message : err.data,
  103. icon: 'none',
  104. duration: 2000,
  105. mask: false
  106. });
  107. })
  108. },
  109. fail(res) {
  110. tt.navigateTo({
  111. url: 'pages/index/index' // 指定页面的url
  112. });
  113. },
  114. })
  115. }
  116. })