index.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. import { appConfig } from '../../config/index';
  2. import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog'
  3. import { queryBankAccountSign } from '../../services/api/account/index';
  4. import { accountid, loginid, loginQuery, taAccount, userid } from '../../services/utils';
  5. import { hideLoading, showLoading, showToast } from '../../utils/message/index';
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. // 功能菜单项
  12. menulists: [{id: 1, title: '我的库存', img: appConfig.imgUrl+'mine-wdkc', path: '/mMine/pages/myinventorys/list/index'},
  13. {id: 2, title: "我的订单", img: appConfig.imgUrl+'mine-wddd', path: '/mMine/pages/myorders/list/index'},
  14. {id: 3, title: '我的履约', img: appConfig.imgUrl+'mine-wdly', path: '/mMine/pages/myperformance/list/index'},
  15. {id: 4, title: '我的出境', img: appConfig.imgUrl+'mine-cjjc', path: '/mHome/pages/inspection/list/index'},
  16. {id: 5, title: '我的保税', img: appConfig.imgUrl+'mine-bsfw', path: '/mHome/pages/bond/list/index'}],
  17. // 列表菜单项
  18. tablelists: [{id: 1, title: '签约账户', iconfont: appConfig.imgUrl+'mine-qyzh', path: '/mMine/pages/bank/index'},
  19. {id: 2, title: '收货地址', iconfont: appConfig.imgUrl+'mine-shdz', path: '/mMine/pages/address/list/index'},
  20. {id: 3, title: '发票信息', iconfont: appConfig.imgUrl+'mine-fpxx', path: '/mMine/pages/invoice/list/index'},
  21. {id: 4, title: '账户安全', iconfont: appConfig.imgUrl+'mine-mmxg', path: '/mMine/pages/modifypwd/index'},
  22. {id: 5, title: '关于我们', iconfont: appConfig.imgUrl+'mine-gywm', path: '/mMine/pages/about/about/index'}],
  23. /// 微信头像
  24. avatarUrl: "",
  25. /// 微信昵称
  26. nickName: '',
  27. /// 资金账户信息
  28. ta: <GuangZuan.TaAccount>({}),
  29. /// 登录账号
  30. loginid: loginid(),
  31. /// 是否脱敏显示
  32. isOpenEye: false,
  33. /// 签约信息
  34. sign: <GuangZuan.BankAccountSign>({}),
  35. /// 状态栏高度
  36. statusBarHeight: getApp().globalData.statusBarHeight,
  37. /// 导航栏高度
  38. navHeight: getApp().globalData.navHeight
  39. },
  40. onEye() {
  41. this.setData({
  42. isOpenEye: !this.data.isOpenEye
  43. })
  44. },
  45. /**
  46. * 按钮点击响应事件
  47. */
  48. onButtonPressed(e: any) {
  49. /// 出入金操作
  50. this.goToInOutGold(e.target.id)
  51. },
  52. /// 出入金操作
  53. goToInOutGold(id: string) {
  54. if (this.data.sign === undefined) {
  55. showToast('当前未查询到签约信息,请先签约!')
  56. return
  57. }
  58. switch (id) {
  59. case 'into-gold': /// 充值
  60. wx.navigateTo({ url: '/mMine/pages/inoutgold/index?id=0' })
  61. break;
  62. default: /// 提现
  63. wx.navigateTo({ url: '/mMine/pages/inoutgold/index?id=1' })
  64. break;
  65. }
  66. },
  67. /**
  68. * 进入系统设置
  69. */
  70. goToSettings() {
  71. wx.navigateTo({
  72. url: '/mMine/pages/settings/settings'
  73. })
  74. },
  75. /**
  76. * 生命周期函数--监听页面加载
  77. */
  78. onLoad() {
  79. /// 获取微信头像
  80. let url = wx.getStorageSync('avatarUrl')
  81. if (url) {
  82. this.setData({ avatarUrl: url })
  83. }
  84. this.setData({
  85. /// 设置账户信息
  86. ta: taAccount(accountid()),
  87. nickName: loginQuery().userInfo.customername
  88. })
  89. /// 查询签约信息
  90. this.queryBankAccountSign()
  91. },
  92. /**
  93. * 查询用户已签约信息
  94. */
  95. queryBankAccountSign() {
  96. /// loding.....
  97. showLoading(() => {
  98. /// 发送请求
  99. queryBankAccountSign({
  100. data: {
  101. userid: userid()
  102. },
  103. success: (res) => {
  104. /// 请求失败
  105. if (res.code != 200) {
  106. hideLoading(() => {}, '用户签约信息请求失败,原因:'+res.msg)
  107. return
  108. }
  109. hideLoading(() => {
  110. const sign = res.data.filter(obj => {
  111. return obj.signstatus === 2 || obj.signstatus === 3 || obj.signstatus === 4
  112. })[0]
  113. /// 数据赋值
  114. this.setData({ sign: sign })
  115. })
  116. },
  117. fail: (emsg) => {
  118. hideLoading(() => {}, emsg)
  119. }
  120. })
  121. })
  122. },
  123. /**
  124. * 系统登出响应
  125. */
  126. onLoginOut() {
  127. Dialog.confirm({
  128. title: '提示',
  129. message: '确定要退出系统吗?',
  130. }).then(() => {
  131. /// 清楚所有的缓存数据
  132. wx.clearStorage()
  133. /// loding....
  134. showLoading(()=>{
  135. /// 登出
  136. setTimeout(function () {
  137. hideLoading(()=>{
  138. // on confirm
  139. wx.reLaunch({ url: '/pages/login/index' })
  140. }, '登出成功', 'success')
  141. }, 3000)
  142. }, '登出中....')
  143. }).catch(() => {
  144. // on cancel
  145. });
  146. },
  147. /**
  148. * 生命周期函数--监听页面初次渲染完成
  149. */
  150. onReady() {
  151. },
  152. /**
  153. * 生命周期函数--监听页面显示
  154. */
  155. onShow() {
  156. this.getTabBar().init()
  157. },
  158. /**
  159. * 生命周期函数--监听页面隐藏
  160. */
  161. onHide() {
  162. },
  163. /**
  164. * 生命周期函数--监听页面卸载
  165. */
  166. onUnload() {
  167. },
  168. /**
  169. * 页面相关事件处理函数--监听用户下拉动作
  170. */
  171. onPullDownRefresh() {
  172. },
  173. /**
  174. * 页面上拉触底事件的处理函数
  175. */
  176. onReachBottom() {
  177. },
  178. /**
  179. * 用户点击右上角分享
  180. */
  181. onShareAppMessage() {
  182. }
  183. })