index.ts 6.8 KB

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