index.ts 7.1 KB

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