index.ts 6.2 KB

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