writeOff.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // pages/welfareMall/writeOff/writeOff.js
  2. import WelfareMall from '../../../api/welfareMall'
  3. import { parseTime } from '../../../utils/util'
  4. import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. page: 1,
  11. pageSize: 10,
  12. lock: false,
  13. noResult: false,
  14. noMore: false,
  15. mobileTop: 'TONY WU',
  16. hexiaoList: [],
  17. storeList: [],
  18. index: 0,
  19. storeNo: '',
  20. date: '',
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. },
  27. /**
  28. * 生命周期函数--监听页面初次渲染完成
  29. */
  30. onReady: function () {
  31. },
  32. /**
  33. * 生命周期函数--监听页面显示
  34. */
  35. onShow: function () {
  36. this.getHexiaoList();
  37. this.getStoreListByStaff();
  38. },
  39. /**
  40. * 生命周期函数--监听页面隐藏
  41. */
  42. onHide: function () {
  43. },
  44. /**
  45. * 生命周期函数--监听页面卸载
  46. */
  47. onUnload: function () {
  48. },
  49. /**
  50. * 页面相关事件处理函数--监听用户下拉动作
  51. */
  52. onPullDownRefresh: function () {
  53. },
  54. /**
  55. * 页面上拉触底事件的处理函数
  56. */
  57. onReachBottom: function () {
  58. },
  59. /**
  60. * 用户点击右上角分享
  61. */
  62. onShareAppMessage: function () {
  63. },
  64. // 获取核销记录
  65. getHexiaoList: function() {
  66. WelfareMall.getHexiaoList({
  67. page: this.data.page,
  68. pageSize: this.data.pageSize,
  69. mobile: getMobileCache(),
  70. storeNo: this.data.storeNo,
  71. date: this.data.date,
  72. }).then(res => {
  73. if (res.code == 200) {
  74. this.userHexiaoListView(res.data)
  75. }
  76. this.data.lock = false
  77. }).catch(_ => {
  78. console.log(_)
  79. this.data.lock = false
  80. })
  81. },
  82. userHexiaoListView: function(data) {
  83. if (!Array.isArray(data) || data.length == 0) {
  84. console.log("核销列表数据为空");
  85. if (this.data.page == 1) {
  86. this.setData({
  87. mobileTop:getMobileCache(),
  88. noResult: true
  89. })
  90. } else {
  91. this.setData({
  92. mobileTop:getMobileCache(),
  93. noMore: true
  94. })
  95. }
  96. return
  97. }
  98. this.data.hexiaoList = data
  99. this.setData({
  100. mobileTop:getMobileCache(),
  101. hexiaoList: this.data.hexiaoList
  102. })
  103. },
  104. // 根据职员获取门店列表
  105. getStoreListByStaff: function() {
  106. WelfareMall.getStoreListByStaff({
  107. mobile: getMobileCache(),
  108. }).then(res => {
  109. if (res.code == 200) {
  110. this.userstoreListView(res.data)
  111. }
  112. this.data.lock = false
  113. }).catch(_ => {
  114. console.log(_)
  115. this.data.lock = false
  116. })
  117. },
  118. userstoreListView: function(data) {
  119. if (!Array.isArray(data) || data.length == 0) {
  120. console.log("门店列表数据为空");
  121. if (this.data.page == 1) {
  122. this.setData({
  123. mobileTop:getMobileCache(),
  124. noResult: true
  125. })
  126. } else {
  127. this.setData({
  128. mobileTop:getMobileCache(),
  129. noMore: true
  130. })
  131. }
  132. return
  133. }
  134. //增加全部门店空数据
  135. data.unshift({storeNo:"",storeName:"全部门店"})
  136. this.data.storeList = data
  137. this.setData({
  138. mobileTop:getMobileCache(),
  139. storeList: this.data.storeList
  140. })
  141. },
  142. //选择门店
  143. bindPickerChange: function (e) {
  144. console.log(e)
  145. this.setData({
  146. index: e.detail.value
  147. })
  148. },
  149. //选择日期
  150. bindDateChange: function (e) {
  151. this.setData({
  152. date: e.detail.value
  153. })
  154. },
  155. })