index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // index.js
  2. let myPro = require("../../utils/wxRequest.js");
  3. let util = require("../../utils/util.js");
  4. // 获取应用实例
  5. const app = getApp();
  6. Page({
  7. data: {
  8. current: 0, // 轮播图展示第几个
  9. interval: 3000, // 自动切换时间间隔
  10. adList: ['/statics/img/join/1.png','/statics/img/join/2.png','/statics/img/join/3.png'],
  11. name: '',
  12. phone: '',
  13. city: '',
  14. remark: '',
  15. showBack: true,
  16. pageTitle: "招商加盟",
  17. showHeader: false, // header显示状态
  18. setBgHeight: getApp().globalData.setBgHeight,
  19. loading: false // 全局loading
  20. },
  21. onLoad: function (options) {
  22. // Do some initialize when page load.
  23. },
  24. onShow: function () {
  25. // Do something when page show.
  26. let that = this;
  27. },
  28. onReady: function () {
  29. // Do something when page ready.
  30. },
  31. onHide: function () {
  32. // Do something when page hide.
  33. },
  34. onUnload: function () {
  35. // Do something when page close.
  36. },
  37. onPullDownRefresh: function () {
  38. // Do something when pull down.
  39. },
  40. onReachBottom: function () {
  41. // Do something when page reach bottom.
  42. },
  43. onPageScroll: function (event) {
  44. // Do something when page scroll
  45. let that = this;
  46. let scrollTop = event.scrollTop;
  47. if(scrollTop >= that.data.setBgHeight){
  48. that.setData({
  49. showHeader: true
  50. });
  51. }else{
  52. that.setData({
  53. showHeader: false
  54. });
  55. }
  56. },
  57. onResize: function () {
  58. // Do something when page resize
  59. },
  60. // 广告轮播图切换
  61. changeAd(event){
  62. let that = this;
  63. that.setData({
  64. current: event.detail.current,
  65. });
  66. },
  67. // 加盟人姓名
  68. getName(event){
  69. let that = this;
  70. that.setData({
  71. name: event.detail
  72. });
  73. },
  74. // 加盟人电话
  75. getPhone(event){
  76. let that = this;
  77. that.setData({
  78. phone: event.detail
  79. });
  80. },
  81. // 加盟人地址
  82. getCity(event){
  83. let that = this;
  84. that.setData({
  85. city: event.detail
  86. });
  87. },
  88. // 加盟人留言
  89. getRemark(event){
  90. let that = this;
  91. that.setData({
  92. remark: event.detail
  93. });
  94. },
  95. // 提交
  96. tijiao(){
  97. let that = this;
  98. if(!that.data.name){
  99. wx.showToast({
  100. title: "请填写您的姓名",
  101. icon: "none",
  102. });
  103. return;
  104. };
  105. if(!that.data.phone || !(/^1[3456789]\d{9}$/.test(that.data.phone))){
  106. wx.showToast({
  107. title: "手机号有误,请重新填写",
  108. icon: "none",
  109. });
  110. return;
  111. };
  112. if(!that.data.city){
  113. wx.showToast({
  114. title: "请填写您所在的城市",
  115. icon: "none",
  116. });
  117. return;
  118. };
  119. let params = {
  120. name: that.data.name,
  121. phone: that.data.phone,
  122. city: that.data.city
  123. };
  124. if(that.data.remark){
  125. params.remark = that.data.remark
  126. };
  127. myPro.wxRequest("user/v2/joinUs","GET",params).then(res=>{
  128. wx.showToast({
  129. title: res.msg,
  130. icon: "none"
  131. });
  132. that.setData({
  133. name: "",
  134. phone: "",
  135. city: "",
  136. remark: ""
  137. });
  138. }).catch(err=>{
  139. console.log("报错信息",err);
  140. wx.showToast({
  141. title: err,
  142. icon: "none"
  143. })
  144. })
  145. }
  146. });