joinMaster.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. const user = require('../../../utils/user.js');
  5. Page({
  6. data: {
  7. finishedSubmit: false,
  8. masterName: '',
  9. rid: '',
  10. shareType: '',
  11. name: '',
  12. mobile: '',
  13. city: '',
  14. showPicker: false,
  15. columns: [
  16. '上海市',
  17. '北京市',
  18. '深圳市',
  19. '南京市',
  20. '苏州市',
  21. '无锡市',
  22. '杭州市',
  23. '青岛市',
  24. '宜昌市',
  25. '重庆市',
  26. '成都市',
  27. '广州市',
  28. '昆山市',
  29. '长沙市',
  30. '西安市',
  31. '武汉市'
  32. ],
  33. },
  34. /**
  35. * 生命周期函数--监听页面加载
  36. */
  37. onLoad: function (options) {
  38. console.log(options,"111");
  39. if(options.scene){
  40. var scene = decodeURIComponent(options.scene);
  41. console.log(scene);
  42. var sceneStr = scene.split(',')[1];
  43. var shareType = scene.split(',')[3];
  44. console.log(sceneStr);
  45. this.setData({
  46. rid: sceneStr,
  47. shareType: shareType
  48. });
  49. this.getMasterInfo();
  50. }
  51. if(options.shareType&&options.shareType!=''){
  52. this.setData({
  53. rid: options.rid,
  54. shareType: options.shareType
  55. });
  56. this.getMasterInfo();
  57. }
  58. // this.getMasterInfo()
  59. },
  60. getMasterInfo() {
  61. util.request(api.getTransferIntroductionInfo, {
  62. transferSponsorNo: this.data.rid
  63. }, 'GET').then(res => {
  64. if (res.errno === 0) {
  65. this.setData({
  66. masterName: res.data
  67. });
  68. } else {
  69. // wx.showToast({
  70. // title: res.errmsg,
  71. // icon: 'none'
  72. // });
  73. }
  74. })
  75. },
  76. bindName(e) {
  77. this.setData({
  78. name: e.detail.value
  79. });
  80. },
  81. bindMobile(e) {
  82. this.setData({
  83. mobile: e.detail.value
  84. });
  85. },
  86. cityTap() {
  87. this.setData({
  88. showPicker: true,
  89. });
  90. },
  91. pickerCancel() {
  92. this.setData({
  93. showPicker: false,
  94. })
  95. },
  96. pickerConfirm(e) {
  97. console.log(e);
  98. this.setData({
  99. city: e.detail.value,
  100. showPicker: false,
  101. });
  102. },
  103. onReachBottom() {
  104. },
  105. /**
  106. * 生命周期函数--监听页面初次渲染完成
  107. */
  108. onReady: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面显示
  112. */
  113. onShow: function () {
  114. },
  115. onHide: function () {
  116. },
  117. onUnload: function () {
  118. },
  119. submit() {
  120. if (this.data.finishedSubmit) {
  121. return false;
  122. }
  123. if (this.data.name == '') {
  124. wx.showToast({
  125. title: '请输入姓名',
  126. icon: 'none'
  127. });
  128. return false;
  129. } else if (this.data.mobile == '') {
  130. wx.showToast({
  131. title: '请输入手机号码',
  132. icon: 'none'
  133. });
  134. return false;
  135. } else if (!/^1\d{10}$/.test(this.data.mobile)) {
  136. wx.showToast({
  137. title: '请输入正确的手机号码',
  138. icon: 'none'
  139. });
  140. return false;
  141. } else if (this.data.city == '') {
  142. wx.showToast({
  143. title: '请选择城市',
  144. icon: 'none'
  145. });
  146. return false;
  147. } else {
  148. wx.showLoading({
  149. title: '加载中...',
  150. });
  151. util.request(api.transferIntroduction, {
  152. city: this.data.city,
  153. name: this.data.name,
  154. tel: this.data.mobile,
  155. transferSponsorNo: this.data.rid,
  156. shareType: this.data.shareType
  157. }, 'POST').then(res => {
  158. wx.hideLoading();
  159. if (res.errno === 0) {
  160. this.setData({
  161. finishedSubmit: true
  162. });
  163. wx.showToast({
  164. title: '提交成功'
  165. });
  166. } else {
  167. wx.showToast({
  168. title: res.errmsg,
  169. icon: 'none'
  170. });
  171. }
  172. }).catch(err => {
  173. wx.hideLoading();
  174. });
  175. }
  176. },
  177. /**
  178. * 页面相关事件处理函数--监听用户下拉动作
  179. */
  180. onPullDownRefresh: function () {
  181. },
  182. /**
  183. * 页面上拉触底事件的处理函数
  184. */
  185. onReachBottom: function () {
  186. },
  187. /**
  188. * 用户点击右上角分享
  189. */
  190. onShareAppMessage: function () {
  191. },
  192. })