recruit.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. var app = getApp();
  2. var util = require('../../utils/util.js');
  3. var status = require('../../utils/index.js');
  4. Page({
  5. mixins: [require('../../mixin/commonMixin.js'), require('../../mixin/globalMixin.js')],
  6. data: {
  7. comsissStatus: 0,
  8. canApply: true
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function(options) {
  14. status.setNavBgColor();
  15. status.setGroupInfo().then((groupInfo) => {
  16. let commiss_diy_name = groupInfo && groupInfo.commiss_diy_name || '分销';
  17. wx.setNavigationBarTitle({
  18. title: `会员${commiss_diy_name}`,
  19. })
  20. });
  21. this.get_instruct();
  22. },
  23. /**
  24. * 生命周期函数--监听页面显示
  25. */
  26. onShow: function () {
  27. let that = this;
  28. util.check_login_new().then((res) => {
  29. if (res) {
  30. that.setData({
  31. needAuth: false
  32. })
  33. that.getData();
  34. } else {
  35. that.setData({
  36. needAuth: true
  37. })
  38. }
  39. })
  40. },
  41. get_instruct: function() {
  42. let that = this;
  43. app.util.request({
  44. url: 'entry/wxapp/index',
  45. data: {
  46. controller: 'distribution.get_instruct'
  47. },
  48. dataType: 'json',
  49. success: function (res) {
  50. if (res.data.code == 0) {
  51. let article = res.data.content || '';
  52. that.setData({article})
  53. }
  54. }
  55. })
  56. },
  57. getData: function() {
  58. var token = wx.getStorageSync('token');
  59. let that = this;
  60. app.util.request({
  61. url: 'entry/wxapp/user',
  62. data: {
  63. controller: 'user.get_user_info',
  64. token: token
  65. },
  66. dataType: 'json',
  67. success: function (res) {
  68. wx.hideLoading();
  69. if (res.data.code == 0) {
  70. let member_info = res.data.data;
  71. let { comsiss_flag, comsiss_state } = member_info;
  72. let {
  73. commiss_level,
  74. commiss_sharemember_need,
  75. commiss_biaodan_need,
  76. commiss_share_member_update,
  77. share_member_count,
  78. commiss_become_condition
  79. } = res.data;
  80. let commiss_diy_name = res.data.commiss_diy_name || '分销';
  81. wx.setNavigationBarTitle({
  82. title: `会员${commiss_diy_name}`,
  83. })
  84. let params = {};
  85. let formStatus = 0; //未填写 1 已填写未审核 2 已审核
  86. let need_num_update = 0; //还差多少人升级
  87. //开启分销
  88. if (commiss_level > 0) {
  89. //分销会员状态
  90. let comsissStatus = 0; // 1已成为分销会员 2需要分享未达人数 3需要分享已达人数 4需要表单 5等待审核 6不需要审核
  91. let canApply = false; //可申请
  92. if (comsiss_flag == 1 && comsiss_state == 1){
  93. comsissStatus = 1;
  94. } else {
  95. //需要分享
  96. if (commiss_sharemember_need==1){
  97. need_num_update = commiss_share_member_update * 1 - share_member_count * 1;
  98. comsissStatus = 2;
  99. if (need_num_update <= 0) {
  100. comsissStatus = 3;
  101. canApply = true;
  102. }
  103. } else {
  104. canApply = true;
  105. }
  106. }
  107. params = {
  108. formStatus,
  109. need_num_update,
  110. comsissStatus,
  111. canApply
  112. };
  113. }
  114. that.setData({
  115. ...params,
  116. commiss_diy_name: res.data.commiss_diy_name || '分销'
  117. });
  118. } else {
  119. //is_login
  120. that.setData({
  121. needAuth: true
  122. })
  123. wx.setStorage({
  124. key: "member_id",
  125. data: null
  126. })
  127. }
  128. }
  129. })
  130. },
  131. /**
  132. * 授权成功回调
  133. */
  134. authSuccess: function() {
  135. let that = this;
  136. this.setData({
  137. needAuth: false
  138. },()=>{
  139. that.get_instruct();
  140. that.getData();
  141. })
  142. },
  143. subCommis: function() {
  144. if (!this.authModal()) return;
  145. wx.showLoading();
  146. var token = wx.getStorageSync('token');
  147. let that = this;
  148. app.util.request({
  149. url: 'entry/wxapp/index',
  150. data: {
  151. controller: 'distribution.sub_commission_info',
  152. token
  153. },
  154. dataType: 'json',
  155. success: function (res) {
  156. wx.hideLoading();
  157. if (res.data.code == 0) {
  158. if (res.data.msg == "申请成功,平台将尽快审核"){
  159. wx.navigateTo({
  160. url: '/lionfish_comshop/distributionCenter/pages/apply',
  161. })
  162. } else {
  163. wx.redirectTo({
  164. url: '/lionfish_comshop/distributionCenter/pages/me',
  165. })
  166. }
  167. } else {
  168. if (res.data.msg=="请先登录"){
  169. that.setData({ needAuth: true })
  170. return;
  171. }
  172. if (res.data.msg == "您未填写表单!") {
  173. wx.navigateTo({
  174. url: '/lionfish_comshop/distributionCenter/pages/apply',
  175. })
  176. return;
  177. }
  178. wx.showToast({
  179. title: res.data.msg ? res.data.msg:'申请失败,请重试!',
  180. icon: 'none'
  181. })
  182. }
  183. }
  184. })
  185. },
  186. goNext: function (e) {
  187. if (!this.authModal()) return;
  188. let status = 0;
  189. let member_info = this.data.member_info || {};
  190. let comsiss_flag = member_info.comsiss_flag || 0;
  191. let comsiss_state = member_info.comsiss_state || 0;
  192. if (comsiss_flag == 1) {
  193. comsiss_state == 0 ? status = 1 : status = 2;
  194. }
  195. let type = e.currentTarget.dataset.type;
  196. if (type == 'share') {
  197. wx.navigateTo({
  198. url: '/lionfish_comshop/distributionCenter/pages/share',
  199. })
  200. } else if (type == 'commiss') {
  201. if (this.data.comsissStatus == 1) {
  202. wx.navigateTo({
  203. url: '/lionfish_comshop/distributionCenter/pages/me',
  204. })
  205. } else if (status == 2) {
  206. wx.navigateTo({
  207. url: '/lionfish_comshop/distributionCenter/pages/me',
  208. })
  209. } else {
  210. wx.navigateTo({
  211. url: '/lionfish_comshop/distributionCenter/pages/recruit',
  212. })
  213. }
  214. } else if (type == 'form') {
  215. if (status == 2) {
  216. wx.navigateTo({
  217. url: '/lionfish_comshop/distributionCenter/pages/me',
  218. })
  219. } else {
  220. wx.navigateTo({
  221. url: '/lionfish_comshop/distributionCenter/pages/apply',
  222. })
  223. }
  224. }
  225. }
  226. })