index.ts 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. import { EOrderSrc, EValidType } from "../../../constants/enum/index";
  2. import { FunCode } from "../../../constants/enum/funcode";
  3. import { sendMsgToMQ } from "../../../services/api/common/index";
  4. import { accountid, clientType, isEncrypted, marketid, protoHeader, timetample, userid } from "../../../services/utils";
  5. import { hideLoading, showLoading, showModel } from "../../../utils/message/index";
  6. import { isnullstr } from "../../../utils/util";
  7. import { queryMySellOrder, queryPermancePlanTmp } from "../../../services/api/orders/index";
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. /// 底部安全区域
  14. safeBottom: getApp().globalData.safeBottom,
  15. /// tabs
  16. tabs: [{id: 2, name: '单颗裸钻'}, {id: 5, name: '单颗彩钻'}],
  17. /// tab索引
  18. active: 0,
  19. /// 出售挂牌
  20. sellorders: <GuangZuan.MySellOrder[]>[],
  21. /// 选中的单据
  22. sellorder: <GuangZuan.MySellOrder>({}),
  23. /// 列头
  24. titles: [['重量', '形状', '尺寸', '编号'],
  25. ['颜色 | 净度 | 切工 | 对称 | 抛光 | 荧光 | 证书', '价格']],
  26. /// 显示的值
  27. values: [{ up: [''], dwn: [''], isChecked: false }],
  28. /// 是否空数据
  29. isEmpty: false,
  30. /// 当前页
  31. page: 1,
  32. /// 履约模板信息
  33. tmps: <GuangZuan.PermancePlanTmp[]>[],
  34. /// 选中履约模板
  35. tmp: <GuangZuan.PermancePlanTmp>({}),
  36. /// 是否显示
  37. show: false,
  38. /// 显示信息
  39. actions: [''],
  40. },
  41. /**
  42. * 返回上层视图
  43. */
  44. backToParent() {
  45. /// 返回上层视图
  46. wx.navigateBack()
  47. },
  48. /// 显示履约模板
  49. showPlanTmps() {
  50. this.setData({ show: true })
  51. },
  52. /// 关闭
  53. onClose() {
  54. this.setData({ show: false })
  55. },
  56. onSelect(e: any) {
  57. /// 默认显示项
  58. const { index } = e.detail;
  59. this.setData({ tmp: this.data.tmps[index], show: false })
  60. },
  61. /**
  62. * 每行选中触发事件
  63. */
  64. onSelectItem(e: any) {
  65. var objs = this.data.values
  66. objs.forEach(obj => {
  67. obj.isChecked = false
  68. })
  69. objs[e.currentTarget.id].isChecked = true
  70. /// 数据赋值
  71. this.setData({
  72. values: objs,
  73. sellorder: this.data.sellorders[e.currentTarget.id]
  74. })
  75. },
  76. /**
  77. * tab触发事件
  78. */
  79. onTabChange(e: any) {
  80. /// 设置激活项
  81. this.setData({ active: e.detail.index })
  82. },
  83. /// 获取履约模板信息
  84. queryPermancePlanTmp() {
  85. /// showLoading
  86. showLoading(() => {
  87. queryPermancePlanTmp({
  88. data: {
  89. marketid: marketid()
  90. },
  91. success: (res) => {
  92. /// 获取数据
  93. this.setData({
  94. tmps: res.data,
  95. tmp: res.data[0],
  96. actions: res.data.map(obj => { return obj.templatename })
  97. })
  98. },
  99. complete: () => {
  100. /// hideLoading
  101. hideLoading()
  102. }
  103. })
  104. })
  105. },
  106. /// 查询出售挂牌
  107. queryMySellOrder() {
  108. /// loding
  109. showLoading(()=>{
  110. /// 数据查询请求
  111. queryMySellOrder({
  112. data: {
  113. userid: userid(),
  114. page: this.data.page,
  115. pagesize: 20,
  116. },
  117. success: (res) => {
  118. /// 请求失败
  119. if (res.code != 200) {
  120. /// 加载失败
  121. hideLoading(()=>{}, '请求失败,原因:'+res.msg, 'error')
  122. return
  123. }
  124. hideLoading(()=>{
  125. /// 设置数据
  126. this.setData({
  127. /// 设置列头
  128. sellorders: res.data,
  129. isEmpty: res.data.length === 0,
  130. active: 0,
  131. /// 显示的值
  132. values: res.data.map(obj => {
  133. return { up: [obj.totalqty+'ct',
  134. isnullstr(obj.zsshapetypedisplay),
  135. '--',
  136. isnullstr(obj.size1),
  137. obj.goodsno],
  138. dwn: [isnullstr(obj.zsczcolor1typedisplay)+' | '+
  139. isnullstr(obj.zsclaritytype1display)+' | '+
  140. isnullstr(obj.zscuttype1display)+' | '+
  141. isnullstr(obj.zssymmetrytype1display)+' | '+
  142. isnullstr(obj.zspolishtype1display)+' | '+
  143. isnullstr(obj.zsfluorescencetype1display)+' | '+
  144. isnullstr(obj.zscerttypedisplay),
  145. obj.zscurrencytypedisplayunit+obj.price.toFixed(2)],
  146. isChecked: false}
  147. })
  148. })
  149. })
  150. },
  151. fail: (emsg) => {
  152. /// 加载失败
  153. hideLoading(()=>{}, '请求失败,原因:'+emsg, 'error')
  154. },
  155. complete: () => {
  156. /// 停止下拉刷新
  157. wx.stopPullDownRefresh()
  158. }
  159. })
  160. })
  161. },
  162. /// 摘卖
  163. doListingSell() {
  164. /// showModel
  165. showModel(() => {
  166. /// showLoading
  167. showLoading(() => {
  168. const { wrstandardid, wrfactortypeid, selledqty } = this.data.sellorder
  169. const { autoid } = this.data.tmp
  170. /// 请求参数
  171. const params = {
  172. Header: protoHeader(FunCode.ZSSellOrderListingReq),
  173. UserID: userid(),
  174. AccountID: accountid(),
  175. WRStandardID: wrstandardid,
  176. WRFactorTypeID: wrfactortypeid,
  177. OrderQty: selledqty,
  178. PerformanceTemplateID: autoid,
  179. TimevalidType: EValidType.VALIDTYPE_YZ,
  180. OrderSrc: EOrderSrc.ORDERSRC_CLIENT,
  181. ClientSerialNo: timetample().toString(),
  182. ClientType: clientType(),
  183. MarketID: marketid(),
  184. }
  185. /// 发送请求
  186. sendMsgToMQ({
  187. data: {
  188. data: JSON.stringify(params),
  189. funCodeReq: FunCode.ZSSellOrderListingReq,
  190. funCodeRsp: FunCode.ZSSellOrderListingRsp,
  191. isEncrypted: isEncrypted()
  192. },
  193. success: (res) => {
  194. /// 请求失败
  195. if (res.code != 0) {
  196. hideLoading(()=>{}, '出售请求失败,原因:'+res.msg, 'error')
  197. return
  198. }
  199. /// 求购发布请求成功
  200. hideLoading(() => {
  201. wx.navigateBack()
  202. }, '出售发布请求成功', 'success')
  203. },
  204. fail: (emsg) => {
  205. hideLoading(()=>{}, '出售请求失败,原因:'+emsg, 'error')
  206. }
  207. })
  208. }, '出售请求中....')
  209. }, '提示', '确认要发布出售吗?')
  210. },
  211. /**
  212. * 生命周期函数--监听页面加载
  213. */
  214. onLoad() {
  215. /// 查询我的出售
  216. this.queryMySellOrder()
  217. /// 获取履约模板信息
  218. this.queryPermancePlanTmp()
  219. },
  220. /**
  221. * 生命周期函数--监听页面初次渲染完成
  222. */
  223. onReady() {
  224. },
  225. /**
  226. * 生命周期函数--监听页面显示
  227. */
  228. onShow() {
  229. },
  230. /**
  231. * 生命周期函数--监听页面隐藏
  232. */
  233. onHide() {
  234. },
  235. /**
  236. * 生命周期函数--监听页面卸载
  237. */
  238. onUnload() {
  239. },
  240. /**
  241. * 页面相关事件处理函数--监听用户下拉动作
  242. */
  243. onPullDownRefresh() {
  244. },
  245. /**
  246. * 页面上拉触底事件的处理函数
  247. */
  248. onReachBottom() {
  249. },
  250. /**
  251. * 用户点击右上角分享
  252. */
  253. onShareAppMessage() {
  254. }
  255. })