admin.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. var app = getApp();
  2. Page({
  3. data: {
  4. open: true,
  5. user: '',
  6. balance: '', //我的钱包
  7. phone: [],
  8. actionSheetHidden: true,
  9. state: '',
  10. arr:[],
  11. time:wx.getStorageSync('home').customer_service_time,
  12. screenHeight:'',
  13. adHeight:'',
  14. img:app.globalData.imgUrl,
  15. title:app.globalData.title,
  16. show:false,
  17. date: '',
  18. items: [],
  19. itemsId:[]
  20. },
  21. bindDateChange:function(e){
  22. console.log(e)
  23. this.setData({date:e.detail.value})
  24. },
  25. getNowFormatDate:function() {
  26. var date = new Date();
  27. var seperator1 = "-";
  28. var year = date.getFullYear();
  29. var month = date.getMonth() + 1;
  30. var strDate = date.getDate();
  31. if (month >= 1 && month <= 9) {
  32. month = "0" + month;
  33. }
  34. if (strDate >= 0 && strDate <= 9) {
  35. strDate = "0" + strDate;
  36. }
  37. var currentdate = year + seperator1 + month + seperator1 + strDate;
  38. console.log(currentdate)
  39. this.setData({date:currentdate})
  40. return currentdate;
  41. },
  42. userinfo: function(e) {
  43. var that = this;
  44. },
  45. oneKey:function(){
  46. this.setData({show:true})
  47. },
  48. checkboxChange(e) {
  49. console.log('checkbox发生change事件,携带value值为:', e.detail.value)
  50. const items = this.data.items
  51. const values = e.detail.value
  52. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  53. items[i].checked = false
  54. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  55. if (items[i].id == values[j]) {
  56. items[i].checked = true
  57. break
  58. }
  59. }
  60. }
  61. this.setData({
  62. items,
  63. itemsId:e.detail.value
  64. })
  65. },
  66. quxiao:function(){
  67. this.setData({show:false})
  68. },
  69. queren:function(){
  70. var items = this.data.items;
  71. if(this.data.itemsId==''){
  72. var arr = []
  73. for(var i=0;i<items.length;i++){
  74. arr = arr.concat(items[i].id)
  75. }
  76. console.log(arr)
  77. this.fenhao(arr)
  78. }else{
  79. this.fenhao(this.data.itemsId)
  80. }
  81. },
  82. fenhao:function(arr){
  83. var data = {
  84. 'date':this.data.date,
  85. 'sate':arr
  86. }
  87. wx.request({
  88. url: 'https://yutang.web.ximengnaikang.com/api/admin/makeNos',
  89. method: 'POST',
  90. data:data,
  91. header: {
  92. 'content-type': 'application/x-www-form-urlencoded',
  93. 'Authorization':wx.getStorageSync('token')
  94. },
  95. success: function (res) {
  96. console.log(res)
  97. if (res.statusCode == 200) {
  98. wx.showToast({
  99. title: '分号成功',
  100. icon:'none'
  101. })
  102. this.setData({show:false})
  103. }
  104. }
  105. })
  106. },
  107. onLoad: function(options) {
  108. this.setData({screenHeight: app.globalData.screenHeight,user:wx.getStorageSync('userInfo')})
  109. this.getNowFormatDate()
  110. var items = wx.getStorageSync('items');
  111. var arr = [];
  112. for(var i=0;i<items.length;i++){
  113. var obj = {}
  114. obj.name = items[i].name;
  115. obj.id = items[i].id;
  116. obj.checked = true;
  117. console.log(obj)
  118. arr = arr.concat(obj)
  119. }
  120. this.setData({
  121. items:arr
  122. });
  123. //获取实名认证状态
  124. },
  125. onReady: function() {
  126. },
  127. onShow: function() {
  128. var that = this;
  129. that.setData({time:wx.getStorageSync('home').customer_service_time})
  130. // app.request("/card_riding/user_card", '', "GET").then(res => {
  131. // console.log(res)
  132. // that.setData({ arr: res.data.user_card,show:res.data.is_card_begin })
  133. // })
  134. // app.request("/user/status", '', "GET").then(res => {
  135. // console.log(res)
  136. // if (res.statusCode == 200) {
  137. // if (res.data.is_card_certified == 1) {
  138. // this.setData({
  139. // state: '已实名'
  140. // })
  141. // } else {
  142. // this.setData({
  143. // state: '未实名'
  144. // })
  145. // }
  146. // wx.setStorageSync('userState', res.data)
  147. // }
  148. // })
  149. },
  150. onHide: function() {
  151. },
  152. onUnload: function() {
  153. },
  154. onPullDownRefresh: function() {
  155. wx.showNavigationBarLoading();
  156. var that = this;
  157. // app.request("/me", '', "GET").then(res => {
  158. // 200 == res.statusCode && wx.setStorageSync("userInfo", res.data), that.setData({
  159. // user: res.data
  160. // })
  161. // wx.hideNavigationBarLoading()
  162. // wx.stopPullDownRefresh();
  163. // })
  164. },
  165. onReachBottom: function() {
  166. },
  167. onShareAppMessage: function() {
  168. }
  169. })