writeOff.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function () {
  34. this.getHexiaoList();
  35. this.getStoreListByStaff();
  36. },
  37. /**
  38. * 生命周期函数--监听页面隐藏
  39. */
  40. onHide: function () {
  41. },
  42. /**
  43. * 生命周期函数--监听页面卸载
  44. */
  45. onUnload: function () {
  46. },
  47. /**
  48. * 页面相关事件处理函数--监听用户下拉动作
  49. */
  50. onPullDownRefresh: function () {
  51. },
  52. /**
  53. * 页面上拉触底事件的处理函数
  54. */
  55. onReachBottom: function () {
  56. },
  57. /**
  58. * 用户点击右上角分享
  59. */
  60. onShareAppMessage: function () {
  61. },
  62. // 订单数据
  63. getHexiaoList: function() {
  64. WelfareMall.getHexiaoList({
  65. page: this.data.page,
  66. pageSize: this.data.pageSize,
  67. mobile: getMobileCache(),
  68. }).then(res => {
  69. if (res.code == 200) {
  70. this.userHexiaoListView(res.data)
  71. }
  72. this.data.lock = false
  73. }).catch(_ => {
  74. console.log(_)
  75. this.data.lock = false
  76. })
  77. },
  78. userHexiaoListView: function(data) {
  79. if (!Array.isArray(data) || data.length == 0) {
  80. console.log("核销列表数据为空");
  81. if (this.data.page == 1) {
  82. this.setData({
  83. mobileTop:getMobileCache(),
  84. noResult: true
  85. })
  86. } else {
  87. this.setData({
  88. mobileTop:getMobileCache(),
  89. noMore: true
  90. })
  91. }
  92. return
  93. }
  94. this.data.hexiaoList = data
  95. this.setData({
  96. mobileTop:getMobileCache(),
  97. hexiaoList: this.data.hexiaoList
  98. })
  99. },
  100. // 根据职员获取门店列表
  101. getStoreListByStaff: function() {
  102. WelfareMall.getStoreListByStaff({
  103. mobile: getMobileCache(),
  104. }).then(res => {
  105. if (res.code == 200) {
  106. this.userstoreListView(res.data)
  107. }
  108. this.data.lock = false
  109. }).catch(_ => {
  110. console.log(_)
  111. this.data.lock = false
  112. })
  113. },
  114. userstoreListView: function(data) {
  115. if (!Array.isArray(data) || data.length == 0) {
  116. console.log("门店列表数据为空");
  117. if (this.data.page == 1) {
  118. this.setData({
  119. mobileTop:getMobileCache(),
  120. noResult: true
  121. })
  122. } else {
  123. this.setData({
  124. mobileTop:getMobileCache(),
  125. noMore: true
  126. })
  127. }
  128. return
  129. }
  130. const storeNameList = []
  131. data.forEach(v => {
  132. storeNameList.push(v.storeName)
  133. })
  134. this.setData({
  135. mobileTop:getMobileCache(),
  136. storeList: storeNameList
  137. })
  138. },
  139. bindPickerChange: function (e) {
  140. console.log(e)
  141. this.setData({
  142. index: e.detail.value
  143. })
  144. },
  145. })