index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // pages/market_buy/index.js
  2. const { buy_status } = require('../../utils/dict');
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '采买需求信息', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. // 采买列表
  13. list: [],
  14. // 弹框
  15. dialog: { title: '详细信息', show: false, type: '1' },
  16. // 详细信息
  17. info: {},
  18. // 导出条件
  19. exportForm: {},
  20. // 商品状态
  21. statusList: buy_status
  22. },
  23. back: function () {
  24. wx.navigateBack({ url: '/pages/home/index' })
  25. },
  26. // 导出条件
  27. export_term: function () {
  28. this.setData({ dialog: { title: '导出条件', show: true, type: '2' }, })
  29. },
  30. // 选择状态
  31. statusChange: function (e) {
  32. let { value } = e.detail;
  33. if (value) {
  34. let data = this.data.statusList[value];
  35. this.setData({ 'exportForm.status': data.value })
  36. }
  37. },
  38. // 开始时间
  39. startChange: function (e) {
  40. let { value } = e.detail;
  41. this.setData({ 'exportForm.apply_date@start': value })
  42. },
  43. // 结束时间
  44. endChange: function (e) {
  45. let { value } = e.detail;
  46. this.setData({ 'exportForm.apply_date@end': value })
  47. },
  48. // 重置条件
  49. expertReset: function (e) {
  50. this.setData({ exportForm: { user_name: '', mech_name: '', receive_user_name: '', status: null } })
  51. },
  52. // 确认导出
  53. exportSubmit: function (e) {
  54. wx.showModal({
  55. title: '提示',
  56. content: '是否确认导出并打开文档',
  57. success(res) {
  58. if (res.confirm) {
  59. console.log('打开文档成功')
  60. }
  61. }
  62. })
  63. },
  64. // 添加采购申请
  65. toAdd: function () {
  66. wx.navigateTo({ url: `/pages/market_buy/detail` })
  67. },
  68. // 详细信息
  69. toView: function (e) {
  70. let item = e.currentTarget.dataset.item;
  71. this.setData({ info: item })
  72. this.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  73. },
  74. // 订单签收
  75. toSign: function (e) {
  76. wx.showModal({
  77. title: '是否确认签收订单',
  78. success(res) {
  79. if (res.confirm) {
  80. wx.showToast({ title: `订单签收完成`, icon: 'success', duration: 2000 })
  81. } else if (res.cancel) {
  82. }
  83. }
  84. })
  85. },
  86. /**
  87. * 生命周期函数--监听页面加载
  88. */
  89. onLoad: function (options) {
  90. this.watchLogin();
  91. // 计算高度
  92. this.searchHeight();
  93. },
  94. // 监听用户是否登录
  95. watchLogin: function () {
  96. let data = [
  97. { order_num: 'Hgj4757945hdFueu', receive_user_name: '胡图图', mech_name: '翻斗幼儿园-小豆班', status_name: '待供货单位确认', status: '1', user_name: '采购人员', user_phone: '12345678901', money: '3344', receive_user_phone: '98765432109', receive_address: '翻斗大街翻斗花园2号楼1001室', order: [{ name: '小洋人', num: '123', money: '3000' }, { name: '娃哈哈', num: '123', money: '344' }] }
  98. ]
  99. this.setData({ list: data })
  100. // wx.getStorage({
  101. // key: 'user',
  102. // success: res => {
  103. // if (res.data) {
  104. // // 查询菜单
  105. // if (res.data) this.searchRouter(res.data);
  106. // res.data.type = type.find((i) => i.value == res.data.type).label;
  107. // if (res.data) this.setData({ userInfo: res.data });
  108. // if (res.data && res.data.avatarUrl) this.setData({ avatarUrl: res.data.avatarUrl });
  109. // } else {
  110. // wx.redirectTo({ url: '/pages/login/index', })
  111. // }
  112. // }
  113. // })
  114. },
  115. // 计算高度
  116. searchHeight: function () {
  117. let frameStyle = this.data.frameStyle;
  118. let client = app.globalData.client;
  119. // 减去状态栏
  120. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  121. // 是否减去底部菜单
  122. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  123. if (infoHeight) this.setData({ infoHeight: infoHeight })
  124. },
  125. /**
  126. * 生命周期函数--监听页面初次渲染完成
  127. */
  128. onReady: function () {
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow: function () {
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide: function () {
  139. },
  140. /**
  141. * 生命周期函数--监听页面卸载
  142. */
  143. onUnload: function () {
  144. },
  145. /**
  146. * 页面相关事件处理函数--监听用户下拉动作
  147. */
  148. onPullDownRefresh: function () {
  149. },
  150. /**
  151. * 页面上拉触底事件的处理函数
  152. */
  153. onReachBottom: function () {
  154. },
  155. /**
  156. * 用户点击右上角分享
  157. */
  158. onShareAppMessage: function () {
  159. }
  160. })