123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- Page({
- data: {
- date: '',
- items: [],
- itemsId: [1, 2],
- yuIndex: 0,
- arr: [],
- list: [],
- fenhao: false,
- number: '',
- nos: [],
- fanqian:false,
- money:'',
- userId:'',
- order_id:''
- },
- bindDateChange: function (e) {
- console.log(e)
- this.setData({
- date: e.detail.value
- })
- this.methods(this.data.date, this.data.itemsId)
- },
- getNowFormatDate: function () {
- var date = new Date();
- var seperator1 = "-";
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- var currentdate = year + seperator1 + month + seperator1 + strDate;
- console.log(currentdate)
- this.setData({
- date: currentdate
- })
- return currentdate;
- },
- onLoad: function (options) {
- this.getNowFormatDate()
- var items = wx.getStorageSync('items');
- var arr = [{
- 'id': "",
- name: '全部'
- }];
- for (var i = 0; i < items.length; i++) {
- var obj = {}
- obj.name = items[i].name;
- obj.id = items[i].id;
- console.log(obj)
- arr = arr.concat(obj)
- }
- this.setData({
- items: arr
- });
- this.methods(this.data.date, this.data.itemsId)
- },
- dayin:function(e){
- var data={
- order_id:e.currentTarget.dataset.id
- }
- wx.request({
- url: 'https://yutang.web.ximengnaikang.com/api/admin/printNo',
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': wx.getStorageSync('token')
- },
- data:data,
- success: function (res) {
- console.log(res)
-
- }
- })
- },
- yutang: function (e) {
- console.log(e)
- var index = e.currentTarget.dataset.index
- this.setData({
- yuIndex: index
- })
- if (index == 0) {
- this.setData({
- itemsId: [1, 2]
- })
- } else if (index == 1) {
- this.setData({
- itemsId: [this.data.items[index].id]
- })
- } else if (index == 2) {
- this.setData({
- itemsId: [this.data.items[index].id]
- })
- }
- this.methods(this.data.date, this.data.itemsId)
- },
- methods: function (time, arr) {
- var that = this;
- wx.request({
- url: 'https://yutang.web.ximengnaikang.com/api/admin/byDateUsers?date=' + time + '&sate=' + arr,
- method: 'GET',
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': wx.getStorageSync('token')
- },
- success: function (res) {
- console.log(res)
- that.setData({
- list: res.data.data
- })
- }
- })
- },
- input: function (e) {
- var value = e.detail.value;
- var arr = value.split("-");
- this.setData({
- nos: arr
- })
- },
- quxiao: function () {
- this.setData({
- fenhao: false,
- number: '',
- fanqian:false
- })
- },
- money:function(e){
- this.setData({money:e.detail.value})
- },
- fanqian:function(e){
- this.setData({fanqian:true,userId:e.currentTarget.dataset.user_id})
- },
- return_money:function(){
- var data = {
- 'user_id': this.data.userId,
- 'money': this.data.money
- }
- console.log(this.data.data)
- wx.request({
- url: 'https://yutang.web.ximengnaikang.com/api/admin/refundUserMoney',
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': wx.getStorageSync('token')
- },
- data: data,
- success: function (res) {
- console.log(res)
- // that.setData({list:res.data.data})
- if(res.data.code==200){
- wx.showToast({
- title: '操作成功~',
- icon:'none'
- })
- }else{
- wx.showToast({
- title: res.data.message,
- icon:'none'
- })
- }
- that.setData({fanqian:false})
- }
- })
- },
- queding: function () {
- var that = this;
- var data = {
- 'order_id': this.data.order_id,
- 'nos': this.data.nos
- }
- console.log(this.data.nos)
- wx.request({
- url: 'https://yutang.web.ximengnaikang.com/api/admin/makeUserNo',
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': wx.getStorageSync('token')
- },
- data: data,
- success: function (res) {
- console.log(res)
- // that.setData({list:res.data.data})
- if(res.data.code==200){
- wx.showToast({
- title: '分号成功',
- icon:'none'
- })
- that.methods(that.data.date, that.data.itemsId)
- }else{
- wx.showToast({
- title: '请求失败请重试',
- icon:'none'
- })
- }
- that.setData({
- fenhao: false
- })
- }
- })
- },
- fenhao: function (e) {
- console.log(e)
- this.setData({
- fenhao: true,
- number: e.currentTarget.dataset.number,
- order_id:e.currentTarget.dataset.id
- })
- },
- onReady: function () {
- },
- onShow: function () {
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- onPullDownRefresh: function () {
- },
- onReachBottom: function () {
- console.log('没有更多了~')
- },
- onShareAppMessage: function () {
- }
- })
|