order.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. Page({
  2. data: {
  3. date: '',
  4. items: [],
  5. itemsId: [1, 2],
  6. yuIndex: 0,
  7. arr: [],
  8. list: [],
  9. fenhao: false,
  10. number: '',
  11. nos: [],
  12. fanqian:false,
  13. money:'',
  14. userId:'',
  15. order_id:''
  16. },
  17. bindDateChange: function (e) {
  18. console.log(e)
  19. this.setData({
  20. date: e.detail.value
  21. })
  22. this.methods(this.data.date, this.data.itemsId)
  23. },
  24. getNowFormatDate: function () {
  25. var date = new Date();
  26. var seperator1 = "-";
  27. var year = date.getFullYear();
  28. var month = date.getMonth() + 1;
  29. var strDate = date.getDate();
  30. if (month >= 1 && month <= 9) {
  31. month = "0" + month;
  32. }
  33. if (strDate >= 0 && strDate <= 9) {
  34. strDate = "0" + strDate;
  35. }
  36. var currentdate = year + seperator1 + month + seperator1 + strDate;
  37. console.log(currentdate)
  38. this.setData({
  39. date: currentdate
  40. })
  41. return currentdate;
  42. },
  43. onLoad: function (options) {
  44. this.getNowFormatDate()
  45. var items = wx.getStorageSync('items');
  46. var arr = [{
  47. 'id': "",
  48. name: '全部'
  49. }];
  50. for (var i = 0; i < items.length; i++) {
  51. var obj = {}
  52. obj.name = items[i].name;
  53. obj.id = items[i].id;
  54. console.log(obj)
  55. arr = arr.concat(obj)
  56. }
  57. this.setData({
  58. items: arr
  59. });
  60. this.methods(this.data.date, this.data.itemsId)
  61. },
  62. dayin:function(e){
  63. var data={
  64. order_id:e.currentTarget.dataset.id
  65. }
  66. wx.request({
  67. url: 'https://yutang.web.ximengnaikang.com/api/admin/printNo',
  68. method: 'POST',
  69. header: {
  70. 'content-type': 'application/x-www-form-urlencoded',
  71. 'Authorization': wx.getStorageSync('token')
  72. },
  73. data:data,
  74. success: function (res) {
  75. console.log(res)
  76. }
  77. })
  78. },
  79. yutang: function (e) {
  80. console.log(e)
  81. var index = e.currentTarget.dataset.index
  82. this.setData({
  83. yuIndex: index
  84. })
  85. if (index == 0) {
  86. this.setData({
  87. itemsId: [1, 2]
  88. })
  89. } else if (index == 1) {
  90. this.setData({
  91. itemsId: [this.data.items[index].id]
  92. })
  93. } else if (index == 2) {
  94. this.setData({
  95. itemsId: [this.data.items[index].id]
  96. })
  97. }
  98. this.methods(this.data.date, this.data.itemsId)
  99. },
  100. methods: function (time, arr) {
  101. var that = this;
  102. wx.request({
  103. url: 'https://yutang.web.ximengnaikang.com/api/admin/byDateUsers?date=' + time + '&sate=' + arr,
  104. method: 'GET',
  105. header: {
  106. 'content-type': 'application/x-www-form-urlencoded',
  107. 'Authorization': wx.getStorageSync('token')
  108. },
  109. success: function (res) {
  110. console.log(res)
  111. that.setData({
  112. list: res.data.data
  113. })
  114. }
  115. })
  116. },
  117. input: function (e) {
  118. var value = e.detail.value;
  119. var arr = value.split("-");
  120. this.setData({
  121. nos: arr
  122. })
  123. },
  124. quxiao: function () {
  125. this.setData({
  126. fenhao: false,
  127. number: '',
  128. fanqian:false
  129. })
  130. },
  131. money:function(e){
  132. this.setData({money:e.detail.value})
  133. },
  134. fanqian:function(e){
  135. this.setData({fanqian:true,userId:e.currentTarget.dataset.user_id})
  136. },
  137. return_money:function(){
  138. var data = {
  139. 'user_id': this.data.userId,
  140. 'money': this.data.money
  141. }
  142. console.log(this.data.data)
  143. wx.request({
  144. url: 'https://yutang.web.ximengnaikang.com/api/admin/refundUserMoney',
  145. method: 'POST',
  146. header: {
  147. 'content-type': 'application/x-www-form-urlencoded',
  148. 'Authorization': wx.getStorageSync('token')
  149. },
  150. data: data,
  151. success: function (res) {
  152. console.log(res)
  153. // that.setData({list:res.data.data})
  154. if(res.data.code==200){
  155. wx.showToast({
  156. title: '操作成功~',
  157. icon:'none'
  158. })
  159. }else{
  160. wx.showToast({
  161. title: res.data.message,
  162. icon:'none'
  163. })
  164. }
  165. that.setData({fanqian:false})
  166. }
  167. })
  168. },
  169. queding: function () {
  170. var that = this;
  171. var data = {
  172. 'order_id': this.data.order_id,
  173. 'nos': this.data.nos
  174. }
  175. console.log(this.data.nos)
  176. wx.request({
  177. url: 'https://yutang.web.ximengnaikang.com/api/admin/makeUserNo',
  178. method: 'POST',
  179. header: {
  180. 'content-type': 'application/x-www-form-urlencoded',
  181. 'Authorization': wx.getStorageSync('token')
  182. },
  183. data: data,
  184. success: function (res) {
  185. console.log(res)
  186. // that.setData({list:res.data.data})
  187. if(res.data.code==200){
  188. wx.showToast({
  189. title: '分号成功',
  190. icon:'none'
  191. })
  192. that.methods(that.data.date, that.data.itemsId)
  193. }else{
  194. wx.showToast({
  195. title: '请求失败请重试',
  196. icon:'none'
  197. })
  198. }
  199. that.setData({
  200. fenhao: false
  201. })
  202. }
  203. })
  204. },
  205. fenhao: function (e) {
  206. console.log(e)
  207. this.setData({
  208. fenhao: true,
  209. number: e.currentTarget.dataset.number,
  210. order_id:e.currentTarget.dataset.id
  211. })
  212. },
  213. onReady: function () {
  214. },
  215. onShow: function () {
  216. },
  217. onHide: function () {
  218. },
  219. onUnload: function () {
  220. },
  221. onPullDownRefresh: function () {
  222. },
  223. onReachBottom: function () {
  224. console.log('没有更多了~')
  225. },
  226. onShareAppMessage: function () {
  227. }
  228. })