partnerBusinessEarnings.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. // pages/partnerBusinessEarnings /partnerBusinessEarnings .js
  2. Page({
  3. data: {
  4. urlHttp: '',
  5. hiddenmodal: true, //提示弹窗
  6. year:'',//年份
  7. month:'',//月份
  8. perPersonNum: 0,//业绩指标 - 邀请客户
  9. perSum: 0, //业绩指标 - 累计成交
  10. sharePersonNum: 0, //累计完成 - 邀请客户
  11. accumulativeTotalMoney: 0, //累计完成 - 累计成交
  12. needDonePersonNum : 0, //尚需完成 - 邀请客户
  13. needDoneSum: 0, //尚需完成 - 累计成交
  14. level : '不达标', //提成档
  15. levelPercent : 0, //提成档的提成比例
  16. performanceMoney : 0, //业绩提成
  17. },
  18. onLoad: function (options) {
  19. var that = this;
  20. var host = getApp().globalData.servsers;
  21. var nowYear = (new Date()).getFullYear();//系统时间年份
  22. var nowMonth = (new Date()).getMonth() + 1;//系统时间月份
  23. that.setData({
  24. urlHttp: host,
  25. year: nowYear,
  26. month: nowMonth
  27. })
  28. },
  29. getData:function(e){
  30. var that = this;
  31. var host = getApp().globalData.servsers;
  32. var un_id = getApp().globalData.un_id;
  33. var openid = getApp().globalData.openid;
  34. var year = that.data.year;
  35. var month = that.data.month < 10 ? '0' + that.data.month : that.data.month;
  36. var perPersonNum = that.data.perPersonNum;
  37. var perSum = that.data.perSum;
  38. var sharePersonNum = that.data.sharePersonNum;
  39. var accumulativeTotalMoney = that.data.accumulativeTotalMoney;
  40. var needDonePersonNum = that.data.needDonePersonNum;
  41. var needDoneSum = that.data.needDoneSum;
  42. var level = that.data.level; //提成档
  43. var levelPercent = that.data.levelPercent; //提成档的提成比例
  44. var performanceMoney = that.data.performanceMoney;//业绩提成
  45. //获取用户当前考核指标信息
  46. wx.request({
  47. url: host + "api/distributeSell/getPerformanceIndexInfo",
  48. data: {
  49. userId: un_id, //当前用户userId
  50. date: year + '-' + month, //用户角色
  51. },
  52. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  53. header: {
  54. 'Accept': 'application/json'
  55. },
  56. success: function (res) {
  57. console.log(res);
  58. if (res.data.code == '200') {
  59. var passPersonNum = parseInt(res.data.data.rule.passPersonNum); //达标 - 业绩指标 - 邀请客户 1
  60. var passSum = parseInt(res.data.data.rule.passSum); //达标 - 业绩指标 - 累计成交 100
  61. var passSharePoint = parseInt(res.data.data.rule.passSharePoint); //达标 - 提成档 5
  62. var excellentPersonNum = parseInt(res.data.data.rule.excellentPersonNum); //优秀 - 业绩指标 - 邀请客户 2
  63. var excellentSum = parseInt(res.data.data.rule.excellentSum); //优秀 - 业绩指标 - 累计成交 1000
  64. var excellentSharePoint = parseInt(res.data.data.rule.excellentSharePoint); //优秀 - 提成档 10
  65. var sharePersonNum = parseInt(res.data.data.sharePersonNum); //累计完成 - 邀请客户 2
  66. var accumulativeTotalMoney = parseInt(res.data.data.accumulativeTotalMoney);//累计完成 - 累计成交 698
  67. if ((sharePersonNum < passPersonNum || accumulativeTotalMoney < passSum) ){
  68. perPersonNum = passPersonNum; //业绩指标 - 邀请客户
  69. perSum = passSum; //业绩指标 - 累计成交
  70. level = '不达标';
  71. levelPercent = 0;
  72. performanceMoney = 0;
  73. needDonePersonNum = passPersonNum - sharePersonNum;
  74. needDoneSum = passSum - accumulativeTotalMoney;
  75. }else if (sharePersonNum >= excellentPersonNum && accumulativeTotalMoney >= excellentSum) {
  76. perPersonNum = excellentPersonNum; //业绩指标 - 邀请客户
  77. perSum = excellentSum; //业绩指标 - 累计成交
  78. needDonePersonNum = 0;
  79. needDoneSum = 0;
  80. level = '优秀';
  81. levelPercent = excellentSharePoint;
  82. performanceMoney = accumulativeTotalMoney * excellentSharePoint / 100;
  83. }else {
  84. perPersonNum = excellentPersonNum; //业绩指标 - 邀请客户
  85. perSum = excellentSum; //业绩指标 - 累计成交
  86. if (sharePersonNum < excellentPersonNum){
  87. needDonePersonNum = excellentPersonNum - sharePersonNum;
  88. }else{
  89. needDonePersonNum = 0;
  90. }
  91. if (accumulativeTotalMoney < excellentSum){
  92. needDoneSum = excellentSum - accumulativeTotalMoney;
  93. }else{
  94. needDoneSum = 0;
  95. }
  96. level = '达标';
  97. levelPercent = passSharePoint;
  98. performanceMoney = accumulativeTotalMoney * passSharePoint / 100;
  99. }
  100. that.setData({
  101. perPersonNum: perPersonNum,
  102. perSum: perSum,
  103. sharePersonNum: sharePersonNum,
  104. accumulativeTotalMoney: accumulativeTotalMoney,
  105. needDonePersonNum: needDonePersonNum,
  106. needDoneSum: needDoneSum,
  107. level: level,
  108. levelPercent: levelPercent,
  109. performanceMoney: performanceMoney,
  110. })
  111. }
  112. if (res == null || res.data == null) {
  113. console.error('网络请求失败');
  114. return;
  115. }
  116. }
  117. })
  118. },
  119. onShow: function () {
  120. var that = this;
  121. that.getData();
  122. },
  123. //查看成交记录
  124. monthRecord:function(e){
  125. var that = this;
  126. var tabId = 0;
  127. var year = e.currentTarget.dataset.year;
  128. var month = e.currentTarget.dataset.month;
  129. wx.navigateTo({
  130. url: '/pages/partnerBusinessRecord/partnerBusinessRecord?year=' + year + '&month=' + month,
  131. })
  132. },
  133. //上一个月的记录
  134. monthPre: function (e) {
  135. var that = this;
  136. var month = that.data.month;
  137. var year = that.data.year;
  138. if (month > 1) {
  139. month--;
  140. } else {
  141. month = 12;
  142. year--;
  143. }
  144. that.setData({
  145. month: month,
  146. year: year
  147. })
  148. that.getData();
  149. },
  150. //下一个月的记录
  151. monthN: function (e) {
  152. var that = this;
  153. var nowMonth = (new Date()).getMonth() + 1;//系统时间月份
  154. var month = that.data.month;
  155. var year = that.data.year;
  156. if (month < 12 && month < nowMonth) {
  157. month++;
  158. } else if (month == 12) {
  159. month = 1;
  160. year++;
  161. }
  162. that.setData({
  163. month: month,
  164. year: year
  165. })
  166. that.getData();
  167. },
  168. //累计完成 - 进入详情页
  169. recordInfor:function(e){
  170. var that = this;
  171. var tabId = e.currentTarget.dataset.id;
  172. var year = that.data.year;
  173. var month = that.data.month;
  174. wx.navigateTo({
  175. url: '/pages/partnerBusinessRecord/partnerBusinessRecord?year=' + year + '&month=' + month + '&tabId=' + tabId,
  176. })
  177. },
  178. //邀请好友 - 页面分享
  179. onShareAppMessage: function (res) {
  180. var that = this;
  181. var host = getApp().globalData.servsers;
  182. var un_id = getApp().globalData.un_id;
  183. var fromUserPhoto = getApp().globalData.userInfo.avatarUrl;
  184. var fromUserName = getApp().globalData.userInfo.nickName;
  185. var fromUserRole = getApp().globalData.userRole;
  186. if (res.from === 'button') {
  187. // 来自页面内转发按钮
  188. }
  189. return {
  190. title: that.data.title,
  191. path: '/pages/partnerShare/partnerShare?fromUserId=' + un_id + '&fromUserPhoto=' + fromUserPhoto + '&fromUserName=' + fromUserName + '&fromUserRole=' + fromUserRole,
  192. imageUrl: '/images/share_img.jpg',
  193. success: function (res) {
  194. // 转发成功
  195. that.setData({
  196. hiddenmodal: false,
  197. modalCont: '分享成功'
  198. })
  199. setTimeout(function () {
  200. that.setData({
  201. hiddenmodal: true
  202. })
  203. }, 1000)
  204. },
  205. fail: function (res) {
  206. // 取消分享、转发失败
  207. }
  208. }
  209. },
  210. })