circle.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import { queryMyFavorite } from "../../services/api/orders/index"
  2. import Toast from '@vant/weapp/toast/toast';
  3. import { clientType, isEncrypted, marketid, protoHeader, userid, timetample } from "../../services/utils";
  4. import { sendMsgToMQ } from "../../services/api/common/index";
  5. import { FunCode } from "../../constants/enum/funcode";
  6. // pages/circle/circle.ts
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. /// 底部安全区域
  13. safeBottom: getApp().globalData.safeBottom,
  14. /// 窗口高度
  15. windowHeight: getApp().globalData.windowHeight,
  16. /// tabs
  17. tabs: [{id: 2, name: '单颗裸钻'}, {id: 5, name: '单颗彩钻'}],
  18. /// tab索引
  19. active: 0,
  20. /// 列头
  21. titles: [['重量', '形状', '尺寸', '编号'],
  22. ['颜色', '净度', '切工', '对称', '抛光', '荧光', '证书', '价格']],
  23. /// 我的收藏
  24. favorites: <GuangZuan.MyFavorite[]>[],
  25. /// 是否空数据
  26. isEmpty: true
  27. },
  28. /**
  29. * tab触发事件
  30. */
  31. onTabChange(e: any) {
  32. this.setData({ active: e.detail.index })
  33. /// 查询数据
  34. this.queryMyFavorite()
  35. },
  36. /**
  37. * 按钮点击事件
  38. */
  39. onButtonPressed(e: any) {
  40. console.log(e)
  41. /// 页面跳转
  42. wx.navigateTo({
  43. url: '/mCircle/pages/contrast/contrast'
  44. })
  45. },
  46. /**
  47. * tab触发事件
  48. */
  49. onCancelFavorite(e: any) {
  50. /// loding.....
  51. Toast.loading({ message: '请求中.....'})
  52. const wrtradeorderid = this.data.favorites[e.target.id].wrtradeorderid
  53. /// 参数信息
  54. const info = {
  55. UserID: userid(),
  56. OperateType: 2,
  57. ClientType: clientType(),
  58. MarketID: marketid(),
  59. ClientSerialNo: timetample().toString(),
  60. WRTradeOrderID: wrtradeorderid,
  61. Header: protoHeader(FunCode.GoodsFavoriteOperateReq)
  62. }
  63. /// 发送请求
  64. sendMsgToMQ({
  65. data: {
  66. data: JSON.stringify(info),
  67. funCodeReq: FunCode.GoodsFavoriteOperateReq,
  68. funCodeRsp: FunCode.GoodsFavoriteOperateRsp,
  69. isEncrypted: isEncrypted()
  70. },
  71. success: (res) => {
  72. /// 操作失败
  73. if (res.code != 0) {
  74. Toast.fail({message: '请求失败,原因:'+res.msg})
  75. return
  76. }
  77. console.log(res)
  78. /// 操作成功
  79. Toast.success({message: '请求成功'})
  80. /// 更新数据
  81. this.queryMyFavorite()
  82. },
  83. fail: (emsg) => {
  84. /// 操作失败
  85. Toast.fail({ message: '请求失败,原因:'+emsg})
  86. }, complete: () => {}
  87. })
  88. },
  89. /// 查询我的收藏数据信息
  90. queryMyFavorite() {
  91. /// loding.....
  92. Toast.loading({message: '加载中...'});
  93. /// 发送查询
  94. queryMyFavorite({
  95. data: {
  96. userid: userid(),
  97. zscategorys: this.data.active == 0 ? '2' : '5'
  98. },
  99. /// 加载成功
  100. success: (res) => {
  101. if (res.code != 200) {
  102. /// 加载失败
  103. Toast.fail({ message: '加载失败...'});
  104. return
  105. }
  106. /// 数据赋值
  107. this.setData({
  108. favorites: res.data,
  109. isEmpty: res.data.length == 0
  110. })
  111. },
  112. fail: (emsg) => {
  113. /// 加载失败
  114. Toast.fail({ message: '加载失败...'+emsg});
  115. },
  116. complete: () => {}
  117. })
  118. },
  119. /**
  120. * 生命周期函数--监听页面加载
  121. */
  122. onLoad() {
  123. /// 查询数据
  124. this.queryMyFavorite()
  125. },
  126. /**
  127. * 生命周期函数--监听页面初次渲染完成
  128. */
  129. onReady() {
  130. },
  131. /**
  132. * 生命周期函数--监听页面显示
  133. */
  134. onShow() {
  135. this.getTabBar().init()
  136. },
  137. /**
  138. * 生命周期函数--监听页面隐藏
  139. */
  140. onHide() {
  141. },
  142. /**
  143. * 生命周期函数--监听页面卸载
  144. */
  145. onUnload() {
  146. },
  147. /**
  148. * 页面相关事件处理函数--监听用户下拉动作
  149. */
  150. onPullDownRefresh() {
  151. /// 查询数据
  152. this.queryMyFavorite()
  153. },
  154. /**
  155. * 页面上拉触底事件的处理函数
  156. */
  157. onReachBottom() {
  158. },
  159. /**
  160. * 用户点击右上角分享
  161. */
  162. onShareAppMessage() {
  163. }
  164. })