detail.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. const util = require("../../../../utils/util");
  2. const api = require('../../../../api/api.js');
  3. var check = require('../../../../utils/check.js');
  4. import moment from 'moment'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. currentMonth:moment(new Date()).format('YYYY-MM'),
  11. salaryList: [],
  12. total: 0,
  13. month: '',
  14. type: 1,
  15. showAuth: false,
  16. servantType: 0, //servantType 表示服务者身份99是临时服务者 明细页可以显示提现按钮
  17. blance: 0, //可提现金额
  18. mobile: '',
  19. nid: '',
  20. name: '',
  21. checked: false
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. this.setData({
  28. month: options.month,
  29. total: options.total,
  30. type: options.type,
  31. servantType: options.servantType,
  32. blance: options.blance
  33. })
  34. this.getSalary();
  35. },
  36. lastMonth(){
  37. let params=util.getYearMonth(this.data.month,'-');
  38. this.setData({
  39. month:params
  40. });
  41. this.getSalary();
  42. },
  43. nextMonth(){
  44. let params=util.getYearMonth(this.data.month,'+');
  45. this.setData({
  46. month:params
  47. });
  48. this.getSalary();
  49. },
  50. onChange(e) {
  51. console.log(e);
  52. this.setData({
  53. checked: e.detail,
  54. });
  55. },
  56. userProtocol() {
  57. wx.navigateTo({
  58. url: '/pages/servant/salary/protocol/protocol'
  59. });
  60. },
  61. getSalary() {
  62. let that = this
  63. wx.showLoading();
  64. util.request(api.SalaryDetail, {
  65. month: that.data.month,
  66. type: that.data.type,
  67. salaryType: 0
  68. }).then(res => {
  69. wx.hideLoading();
  70. let sumtotl=0;
  71. res.data.forEach(r=>{
  72. sumtotl=r.salary+sumtotl;
  73. })
  74. that.setData({
  75. salaryList: res.data,
  76. total:sumtotl,
  77. })
  78. }).catch(res => {
  79. wx.hideLoading();
  80. })
  81. },
  82. getSalaryDetail(e) { //获取项目的构成明细 比如工单计提 每单的详细情况
  83. let that = this
  84. let salaryType = e.currentTarget.dataset.salarytype;
  85. let salaryList = that.data.salaryList;
  86. let salary = null;
  87. salaryList.forEach(item => {
  88. if (item.salaryType == salaryType)
  89. salary = item;
  90. })
  91. salary.isShow = !salary.isShow;
  92. if (salary.details != null && salary.details.length > 0) {
  93. that.setData({
  94. salaryList: salaryList
  95. })
  96. return;
  97. }
  98. wx.showLoading();
  99. util.request(api.SalaryDetail, {
  100. month: that.data.month,
  101. type: 99,
  102. salaryType: salaryType
  103. }).then(res => {
  104. wx.hideLoading();
  105. salary.details = res.data;
  106. that.setData({
  107. salaryList: salaryList
  108. })
  109. }).catch(res => {
  110. wx.hideLoading();
  111. })
  112. },
  113. goCheckAuth() { //是否实名认证过
  114. let that = this
  115. util.request(api.ParterAuthCheck, {}).then(function (res) {
  116. if (res.errno === 0 && res.data) {
  117. that.goCashout();
  118. } else {
  119. that.setData({
  120. showAuth: true
  121. })
  122. }
  123. })
  124. },
  125. goCashout() { //提现申请
  126. let that = this
  127. wx.showModal({
  128. title: '提示',
  129. content: '提现金额为' + that.data.blance + ',平台通过授权第三方(“云账户”)向您的微信钱包打款,涉及手续费由引荐人自行承担,故最终提现金额应以实际到账金额为准。',
  130. success: function (sm) {
  131. if (sm.confirm) {
  132. util.request(api.ParterCashout, {
  133. cashout: that.data.blance
  134. }).then(function (res) {
  135. console.info(res)
  136. if (res.errno === 0) {
  137. wx.showToast({
  138. title: '提现申请成功',
  139. icon: 'none',
  140. duration: 2000
  141. });
  142. that.setData({
  143. showAuth: false,
  144. blance: 0
  145. })
  146. }
  147. });
  148. } else if (sm.cancel) {
  149. console.log('用户点击取消')
  150. }
  151. }
  152. })
  153. },
  154. goList() {
  155. wx.navigateTo({
  156. url: '/pages/servant/salary/list/list',
  157. })
  158. },
  159. goCancel() {
  160. this.setData({
  161. showAuth: false
  162. })
  163. },
  164. bindinputName(e) {
  165. let val = e.detail.value;
  166. this.setData({
  167. name: val
  168. });
  169. },
  170. bindinputNid(e) {
  171. let val = e.detail.value;
  172. this.setData({
  173. nid: val
  174. })
  175. },
  176. cashoutAuth() {
  177. if (this.data.name == '') {
  178. wx.showToast({
  179. title: '请输入真实姓名',
  180. icon: 'none',
  181. duration: 2000
  182. });
  183. return false;
  184. } else if (!check.isCardCheck(this.data.nid)) {
  185. wx.showToast({
  186. title: '请输入正确的身份证号',
  187. icon: 'none',
  188. duration: 2000
  189. });
  190. return false;
  191. } else if (!this.data.checked) {
  192. wx.showToast({
  193. title: '请阅读《用户条款》并勾选',
  194. icon: 'none',
  195. duration: 2000
  196. });
  197. return false;
  198. }
  199. util.request(api.ParterAuth, {
  200. name: this.data.name,
  201. nid: this.data.nid
  202. }).then(res => {
  203. if (res.errno == 0) {
  204. this.goCashout();
  205. }
  206. });
  207. },
  208. goBack() {
  209. wx.navigateBack({
  210. delta: 1
  211. })
  212. },
  213. /**
  214. * 生命周期函数--监听页面初次渲染完成
  215. */
  216. onReady: function () {
  217. },
  218. /**
  219. * 生命周期函数--监听页面显示
  220. */
  221. onShow: function () {
  222. },
  223. /**
  224. * 生命周期函数--监听页面隐藏
  225. */
  226. onHide: function () {
  227. },
  228. /**
  229. * 生命周期函数--监听页面卸载
  230. */
  231. onUnload: function () {
  232. },
  233. /**
  234. * 页面相关事件处理函数--监听用户下拉动作
  235. */
  236. onPullDownRefresh: function () {
  237. },
  238. /**
  239. * 页面上拉触底事件的处理函数
  240. */
  241. onReachBottom: function () {
  242. },
  243. /**
  244. * 用户点击右上角分享
  245. */
  246. onShareAppMessage: function () {
  247. }
  248. })