myinventorys.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import { queryMyWRPosition } from "../../../services/api/orders/index";
  2. // moduleMine/pages/myinventorys/myinventorys.ts
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. /// 底部安全区域
  9. safeBottom: getApp().globalData.safeBottom,
  10. /// tab激活索引
  11. active: 0,
  12. /// tabs
  13. tabs: [{id: 1, name: '单颗裸钻'},
  14. {id: 2, name: '钻石首饰'},
  15. {id: 3, name: '彩色钻石'}],
  16. /// 列头
  17. titles: ['形状', '价格', '克拉单价', '颜色', '净度', '克拉重量', '冻结重量'],
  18. /// 查询数据
  19. datas: [{}],
  20. /// 数据是否为空
  21. isEmpty: false
  22. },
  23. /**
  24. * tab触发事件
  25. */
  26. onTabChange(e: any) {
  27. /// 设置激活项
  28. this.setData({
  29. active: e.detail.index
  30. })
  31. switch (e.detail.index) {
  32. case 0 || 2: /// 单颗裸钻 彩色钻石
  33. this.setData({
  34. /// 列头
  35. titles: ['形状', '价格', '克拉单价', '颜色', '净度', '克拉重量', '冻结重量'],
  36. active: e.detail.index
  37. })
  38. break;
  39. default: /// 首饰
  40. this.setData({
  41. /// 列头
  42. titles: ['主石形状', '款式', '价格', '主石颜色', '主石净度', '主石切工', '主石重量'],
  43. active: e.detail.index
  44. })
  45. break;
  46. }
  47. /// 查询我的库存
  48. this.queryMyWRPosition(e.detail.index+1)
  49. },
  50. /// 查询我的库存
  51. queryMyWRPosition(zscategory: number) {
  52. /// loding
  53. wx.showLoading({ title: '数据请求中' })
  54. /// 查询我的库存
  55. queryMyWRPosition({
  56. data: {
  57. zscategory: zscategory,
  58. wruserid: wx.getStorageSync('UserId')
  59. },
  60. success: (res) => {
  61. console.log(res)
  62. /// 请求失败
  63. if (res.code != 200) {
  64. wx.showToast({ icon: 'error', title: '请求失败,原因:'+res.msg })
  65. return
  66. }
  67. /// 设置数据
  68. this.setData({
  69. /// 数据信息
  70. datas: res.data,
  71. isEmpty: res.data.length == 0
  72. })
  73. },
  74. fail: () => {
  75. wx.showToast({title: '查询失败', icon: 'error'})
  76. },
  77. complete: () => {
  78. wx.hideLoading()
  79. }
  80. })
  81. },
  82. /**
  83. * 生命周期函数--监听页面加载
  84. */
  85. onLoad() {
  86. },
  87. /**
  88. * 生命周期函数--监听页面初次渲染完成
  89. */
  90. onReady() {
  91. },
  92. /**
  93. * 生命周期函数--监听页面显示
  94. */
  95. onShow() {
  96. /// 查询我的库存
  97. this.queryMyWRPosition(1)
  98. },
  99. /**
  100. * 生命周期函数--监听页面隐藏
  101. */
  102. onHide() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面卸载
  106. */
  107. onUnload() {
  108. },
  109. /**
  110. * 页面相关事件处理函数--监听用户下拉动作
  111. */
  112. onPullDownRefresh() {
  113. /// 查询我的库存
  114. this.queryMyWRPosition(this.data.active+1)
  115. },
  116. /**
  117. * 页面上拉触底事件的处理函数
  118. */
  119. onReachBottom() {
  120. },
  121. /**
  122. * 用户点击右上角分享
  123. */
  124. onShareAppMessage() {
  125. }
  126. })