index.ts 5.1 KB

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