detail.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. //保留两位小数
  75. sumtotl=sumtotl.toFixed(2);
  76. that.setData({
  77. salaryList: res.data,
  78. total:sumtotl,
  79. })
  80. }).catch(res => {
  81. wx.hideLoading();
  82. })
  83. },
  84. getSalaryDetail(e) { //获取项目的构成明细 比如工单计提 每单的详细情况
  85. let that = this
  86. let salaryType = e.currentTarget.dataset.salarytype;
  87. let salaryList = that.data.salaryList;
  88. let salary = null;
  89. salaryList.forEach(item => {
  90. if (item.salaryType == salaryType)
  91. salary = item;
  92. })
  93. salary.isShow = !salary.isShow;
  94. if (salary.details != null && salary.details.length > 0) {
  95. that.setData({
  96. salaryList: salaryList
  97. })
  98. return;
  99. }
  100. wx.showLoading();
  101. util.request(api.SalaryDetail, {
  102. month: that.data.month,
  103. type: 99,
  104. salaryType: salaryType
  105. }).then(res => {
  106. wx.hideLoading();
  107. salary.details = res.data;
  108. that.setData({
  109. salaryList: salaryList
  110. })
  111. }).catch(res => {
  112. wx.hideLoading();
  113. })
  114. },
  115. goCheckAuth() { //是否实名认证过
  116. let that = this
  117. util.request(api.ParterAuthCheck, {}).then(function (res) {
  118. if (res.errno === 0 && res.data) {
  119. that.goCashout();
  120. } else {
  121. that.setData({
  122. showAuth: true
  123. })
  124. }
  125. })
  126. },
  127. goCashout() { //提现申请
  128. let that = this
  129. wx.showModal({
  130. title: '提示',
  131. content: '提现金额为' + that.data.blance + ',平台通过授权第三方(“云账户”)向您的微信钱包打款,涉及手续费由引荐人自行承担,故最终提现金额应以实际到账金额为准。',
  132. success: function (sm) {
  133. if (sm.confirm) {
  134. util.request(api.ParterCashout, {
  135. cashout: that.data.blance
  136. }).then(function (res) {
  137. console.info(res)
  138. if (res.errno === 0) {
  139. wx.showToast({
  140. title: '提现申请成功',
  141. icon: 'none',
  142. duration: 2000
  143. });
  144. that.setData({
  145. showAuth: false,
  146. blance: 0
  147. })
  148. }
  149. });
  150. } else if (sm.cancel) {
  151. console.log('用户点击取消')
  152. }
  153. }
  154. })
  155. },
  156. goList() {
  157. wx.navigateTo({
  158. url: '/pages/servant/salary/list/list',
  159. })
  160. },
  161. goCancel() {
  162. this.setData({
  163. showAuth: false
  164. })
  165. },
  166. bindinputName(e) {
  167. let val = e.detail.value;
  168. this.setData({
  169. name: val
  170. });
  171. },
  172. bindinputNid(e) {
  173. let val = e.detail.value;
  174. this.setData({
  175. nid: val
  176. })
  177. },
  178. cashoutAuth() {
  179. if (this.data.name == '') {
  180. wx.showToast({
  181. title: '请输入真实姓名',
  182. icon: 'none',
  183. duration: 2000
  184. });
  185. return false;
  186. } else if (!check.isCardCheck(this.data.nid)) {
  187. wx.showToast({
  188. title: '请输入正确的身份证号',
  189. icon: 'none',
  190. duration: 2000
  191. });
  192. return false;
  193. } else if (!this.data.checked) {
  194. wx.showToast({
  195. title: '请阅读《用户条款》并勾选',
  196. icon: 'none',
  197. duration: 2000
  198. });
  199. return false;
  200. }
  201. util.request(api.ParterAuth, {
  202. name: this.data.name,
  203. nid: this.data.nid
  204. }).then(res => {
  205. if (res.errno == 0) {
  206. this.goCashout();
  207. }
  208. });
  209. },
  210. goBack() {
  211. wx.navigateBack({
  212. delta: 1
  213. })
  214. },
  215. /**
  216. * 生命周期函数--监听页面初次渲染完成
  217. */
  218. onReady: function () {
  219. },
  220. /**
  221. * 生命周期函数--监听页面显示
  222. */
  223. onShow: function () {
  224. },
  225. /**
  226. * 生命周期函数--监听页面隐藏
  227. */
  228. onHide: function () {
  229. },
  230. /**
  231. * 生命周期函数--监听页面卸载
  232. */
  233. onUnload: function () {
  234. },
  235. /**
  236. * 页面相关事件处理函数--监听用户下拉动作
  237. */
  238. onPullDownRefresh: function () {
  239. },
  240. /**
  241. * 页面上拉触底事件的处理函数
  242. */
  243. onReachBottom: function () {
  244. },
  245. /**
  246. * 用户点击右上角分享
  247. */
  248. onShareAppMessage: function () {
  249. }
  250. })