myinventorys.ts 3.2 KB

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