index.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. import services from "../../services/index"
  2. import { queryImageConfigs, queryNotice } from "../../services/api/common/index"
  3. import { homeData } from "../../services/api/orders/index"
  4. import { loginid, loginQuery, userid } from "../../services/utils"
  5. import { hideLoading, showLoading } from "../../utils/message/index"
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. /// 底部安全区域
  12. safeBottom: getApp().globalData.safeBottom,
  13. /// 窗口高度
  14. windowHeight: getApp().globalData.windowHeight,
  15. /// banner轮播图
  16. banners: [''],
  17. /// 功能菜单
  18. menus: [{id: 1, icon: 'home-gpdt', title: '挂牌大厅', path: '/pages/trade/index'},
  19. {id: 2, icon: 'home-ss', title: '钻石首饰', path: '/mHome/pages/jewelry/list/index'},
  20. {id: 3, icon: 'home-cjjc', title: '出境检测', path: '/mHome/pages/inspection/list/index'},
  21. {id: 4, icon: 'home-bsfw', title: '保税服务', path: '/mHome/pages/bond/list/index'},
  22. {id: 5, icon: 'home-bscyw', title: '保税仓业务', path: '/pages/trade/index'},
  23. {id: 6, icon: 'home-zsss', title: '钻石搜索', path: '/mHome/pages/search/index'},
  24. {id: 7, icon: 'home-jsq', title: '钻石计算器', path: '/mHome/pages/calculator/index'},
  25. {id: 8, icon: 'home-zscx', title: '证书查询', path: '/mHome/pages/cerserach/index'},
  26. {id: 9, icon: 'home-jjjy', title: '竞价交易', path: '/mHome/pages/bond/list/index'},
  27. {id: 10, icon: 'home-cnys', title: '产能预售', path: '/mHome/pages/bond/list/index'},
  28. {id: 11, icon: 'home-jcyj', title: '集采交易', path: '/mHome/pages/bond/list/index'}],
  29. /// 统计
  30. statistics: [{id: 1, title: '出售中', value: 0, class: ''}],
  31. /// tabs
  32. tabs:[{id: 1, title: '公告'}, {id: 2, title: '消息'}],
  33. /// 公告消息
  34. notice: {},
  35. /// 公告系XO
  36. msgs: [{}],
  37. /// 是否为空
  38. isEmpty: true
  39. },
  40. /**
  41. * 获取首页轮播图数据
  42. */
  43. queryImageConfigs() {
  44. /// 获取首页轮播图数据
  45. queryImageConfigs({
  46. data: { imageType: 1 },
  47. success:(res) => {
  48. /// 数据设置
  49. this.setData({
  50. banners: res.data.map(item => {
  51. return (services.config.openApiUrl+item.imagepath).replace('./uploadFile', '/uploadFile')
  52. })
  53. })
  54. }
  55. })
  56. },
  57. /**
  58. * 获取首页数据信息
  59. */
  60. homeData() {
  61. /// 获取新闻首页数据
  62. homeData({
  63. data: { userid: userid() },
  64. success:(res) => {
  65. /// 数据设置
  66. this.setData({
  67. statistics: [
  68. { id: 1, title: '出售中', value: res.data.transactionssold, class: 'transactionssold' },
  69. { id: 2, title: '求购中', value: res.data.transactioninpurchase, class: 'transactioninpurchase' },
  70. { id: 3, title: '已购买', value: res.data.purchasedtransactions, class: 'purchasedtransactions' },
  71. { id: 4, title: '已出售', value: res.data.transactionsonsale, class: 'transactionsonsale' },
  72. { id: 5, title: '今日汇率', value: loginQuery().exchangeRateConfigs[0].exchangerate, class: 'exchangerate' },
  73. ]
  74. })
  75. }
  76. })
  77. },
  78. /**
  79. * 查询通知公告消息
  80. */
  81. queryNotice(type: number){
  82. /// loading
  83. showLoading(()=>{
  84. /// 发送查询请求
  85. queryNotice({
  86. data: {
  87. loginID: loginid(),
  88. msgType: type
  89. },
  90. success:(res) => {
  91. /// 数据为空
  92. if (res.code != 200) {
  93. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  94. return
  95. }
  96. hideLoading(()=>{
  97. /// 加载成功 数据复制
  98. this.setData({
  99. notice: res.data[0],
  100. msgs: res.data,
  101. isEmpty: res.data.length === 0
  102. })
  103. })
  104. },
  105. fail: (emsg) => {
  106. /// 加载失败
  107. hideLoading(()=>{}, emsg)
  108. }
  109. })
  110. })
  111. },
  112. /**
  113. * 跳转公告消息页面方法
  114. */
  115. goToMsg() {
  116. wx.navigateTo({
  117. url: '/mHome/pages/msg/msglist/index'
  118. })
  119. },
  120. /**
  121. * 计算器跳转
  122. */
  123. goToCalculator() {
  124. wx.navigateTo({
  125. url: '/mHome/pages/calculator/index'
  126. })
  127. },
  128. /// onTabChange
  129. onTabChange(e: any) {
  130. /// 查询公告消息
  131. this.queryNotice(e.detail.index)
  132. },
  133. /**
  134. * 证书查询
  135. */
  136. goToCerserach() {
  137. wx.navigateTo({
  138. url: '/mHome/pages/cerserach/index'
  139. })
  140. },
  141. /// 进入公告消息详情页
  142. goToMsgDetail(r: any) {
  143. let jsonStr = JSON.stringify(this.data.msgs[r.currentTarget.id])
  144. wx.navigateTo({
  145. url: '/mHome/pages/msg/msgdetail/index?id='+jsonStr
  146. })
  147. },
  148. /// onGirdClick
  149. onGirdClick(e: any) {
  150. switch (e.currentTarget.id) {
  151. case "2":
  152. wx.switchTab({
  153. url: e.currentTarget.dataset.url
  154. })
  155. break;
  156. default: /// 其他页面跳转
  157. wx.navigateTo({
  158. url: e.currentTarget.dataset.url
  159. })
  160. break;
  161. }
  162. },
  163. /**
  164. * 生命周期函数--监听页面加载
  165. */
  166. onLoad() {
  167. /// 获取新闻首页数据
  168. this.homeData()
  169. /// 查询新闻资讯
  170. this.queryNotice(1)
  171. /// 查询轮播图数据
  172. this.queryImageConfigs()
  173. },
  174. /**
  175. * 生命周期函数--监听页面初次渲染完成
  176. */
  177. onReady() {
  178. },
  179. /**
  180. * 生命周期函数--监听页面显示
  181. */
  182. onShow() {
  183. this.getTabBar().init()
  184. },
  185. /**
  186. * 生命周期函数--监听页面隐藏
  187. */
  188. onHide() {
  189. },
  190. /**
  191. * 生命周期函数--监听页面卸载
  192. */
  193. onUnload() {
  194. },
  195. /**
  196. * 页面相关事件处理函数--监听用户下拉动作
  197. */
  198. onPullDownRefresh() {
  199. },
  200. /**
  201. * 页面上拉触底事件的处理函数
  202. */
  203. onReachBottom() {
  204. },
  205. /**
  206. * 用户点击右上角分享
  207. */
  208. onShareAppMessage() {
  209. }
  210. })