index.ts 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. onStatisticsClikc(e: any) {
  84. const id = e.currentTarget.id
  85. switch (id) {
  86. case "transactionssold": /// 出售中
  87. wx.switchTab({ url: '/pages/trade/index' })
  88. break;
  89. case "transactioninpurchase": /// 求购中
  90. wx.switchTab({ url: '/pages/trade/index' })
  91. break;
  92. case "purchasedtransactions": /// 已购买
  93. wx.navigateTo({ url: '/mMine/pages/myorders/list/index' })
  94. break;
  95. default: /// 已出售
  96. wx.navigateTo({ url: '/mMine/pages/myorders/list/index' })
  97. break;
  98. }
  99. },
  100. /**
  101. * 查询通知公告消息
  102. */
  103. queryNotice(type: number){
  104. /// loading
  105. showLoading(()=>{
  106. /// 发送查询请求
  107. queryNotice({
  108. data: {
  109. loginID: loginid(),
  110. msgType: type
  111. },
  112. success:(res) => {
  113. /// 数据为空
  114. if (res.code != 200) {
  115. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  116. return
  117. }
  118. hideLoading(()=>{
  119. /// 加载成功 数据复制
  120. this.setData({
  121. notice: res.data[0],
  122. msgs: res.data,
  123. })
  124. })
  125. },
  126. fail: (emsg) => {
  127. /// 加载失败
  128. hideLoading(()=>{}, emsg)
  129. }
  130. })
  131. })
  132. },
  133. /**
  134. * 获取会员风采表
  135. */
  136. queryGZMemberInfo(){
  137. /// loading
  138. showLoading(()=>{
  139. /// 发送查询请求
  140. getGZMemberInfo({
  141. success:(res) => {
  142. /// 数据为空
  143. if (res.code != 200) {
  144. hideLoading(()=>{}, '会员信息请求失败,原因:'+res.msg)
  145. return
  146. }
  147. hideLoading(()=>{
  148. /// 加载成功 数据复制
  149. this.setData({
  150. members: res.data.map(itm => {
  151. var obj = itm
  152. obj.imageurl = (services.config.openApiUrl+itm.imageurl).replace('./uploadFile', '/uploadFile')
  153. obj.membertagsdisplay = itm.membertags.split(',')
  154. return obj
  155. }),
  156. isEmpty: res.data.length === 0
  157. })
  158. })
  159. },
  160. fail: (emsg) => {
  161. /// 加载失败
  162. hideLoading(()=>{}, emsg)
  163. }
  164. })
  165. })
  166. },
  167. /**
  168. * 跳转公告消息页面方法
  169. */
  170. goToMsg() {
  171. wx.navigateTo({
  172. url: '/mHome/pages/msg/msglist/index'
  173. })
  174. },
  175. /// 进入公告消息详情页
  176. goToMsgDetail(r: any) {
  177. let jsonStr = JSON.stringify(this.data.msgs[r.currentTarget.id])
  178. wx.navigateTo({
  179. url: '/mHome/pages/msg/msgdetail/index?id='+jsonStr
  180. })
  181. },
  182. /**
  183. * 生命周期函数--监听页面加载
  184. */
  185. onLoad() {
  186. /// 查询新闻资讯
  187. this.queryNotice(1)
  188. /// 查询轮播图数据
  189. this.queryImageConfigs()
  190. /// 查询会员信息
  191. this.queryGZMemberInfo()
  192. },
  193. /**
  194. * 生命周期函数--监听页面初次渲染完成
  195. */
  196. onReady() {
  197. },
  198. /**
  199. * 生命周期函数--监听页面显示
  200. */
  201. onShow() {
  202. /// 获取新闻首页数据
  203. this.homeData()
  204. /// 初始化tab
  205. this.getTabBar().init()
  206. },
  207. /**
  208. * 生命周期函数--监听页面隐藏
  209. */
  210. onHide() {
  211. },
  212. /**
  213. * 生命周期函数--监听页面卸载
  214. */
  215. onUnload() {
  216. },
  217. /**
  218. * 页面相关事件处理函数--监听用户下拉动作
  219. */
  220. onPullDownRefresh() {
  221. },
  222. /**
  223. * 页面上拉触底事件的处理函数
  224. */
  225. onReachBottom() {
  226. },
  227. /**
  228. * 用户点击右上角分享
  229. */
  230. onShareAppMessage() {
  231. }
  232. })