index.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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: loginQuery().userInfo.customername,
  26. /// 资金账户信息
  27. ta: <GuangZuan.TaAccount>({}),
  28. /// 登录账号
  29. loginid: loginid(),
  30. /// 是否脱敏显示
  31. isOpenEye: false,
  32. /// 签约信息
  33. sign: <GuangZuan.BankAccountSign>({})
  34. },
  35. onEye() {
  36. this.setData({
  37. isOpenEye: !this.data.isOpenEye
  38. })
  39. },
  40. /**
  41. * 按钮点击响应事件
  42. */
  43. onButtonPressed(e: any) {
  44. /// 出入金操作
  45. this.goToInOutGold(e.target.id)
  46. },
  47. /// 出入金操作
  48. goToInOutGold(id: string) {
  49. if (this.data.sign === undefined) {
  50. showToast('当前未查询到签约信息,请先签约!')
  51. return
  52. }
  53. switch (id) {
  54. case 'into-gold': /// 充值
  55. wx.navigateTo({ url: '/mMine/pages/inoutgold/index?id=0' })
  56. break;
  57. default: /// 提现
  58. wx.navigateTo({ url: '/mMine/pages/inoutgold/index?id=1' })
  59. break;
  60. }
  61. },
  62. /**
  63. * 进入系统设置
  64. */
  65. goToSettings() {
  66. wx.navigateTo({
  67. url: '/mMine/pages/settings/settings'
  68. })
  69. },
  70. /**
  71. * 生命周期函数--监听页面加载
  72. */
  73. onLoad() {
  74. /// 获取微信头像
  75. let url = wx.getStorageSync('avatarUrl')
  76. if (url) {
  77. this.setData({ avatarUrl: url })
  78. }
  79. this.setData({
  80. /// 设置账户信息
  81. ta: taAccount(accountid())
  82. })
  83. /// 查询签约信息
  84. this.queryBankAccountSign()
  85. },
  86. /**
  87. * 查询用户已签约信息
  88. */
  89. queryBankAccountSign() {
  90. /// loding.....
  91. showLoading(() => {
  92. /// 发送请求
  93. queryBankAccountSign({
  94. data: {
  95. userid: userid()
  96. },
  97. success: (res) => {
  98. /// 请求失败
  99. if (res.code != 200) {
  100. hideLoading(() => {}, '用户签约信息请求失败,原因:'+res.msg)
  101. return
  102. }
  103. hideLoading(() => {
  104. const sign = res.data.filter(obj => {
  105. return obj.signstatus === 2 || obj.signstatus === 3 || obj.signstatus === 4
  106. })[0]
  107. /// 数据赋值
  108. this.setData({ sign: sign })
  109. })
  110. },
  111. fail: (emsg) => {
  112. hideLoading(() => {}, emsg, 'error')
  113. }
  114. })
  115. })
  116. },
  117. /**
  118. * 系统登出响应
  119. */
  120. onLoginOut() {
  121. Dialog.confirm({
  122. title: '提示',
  123. message: '确定要退出系统吗?',
  124. }).then(() => {
  125. /// 清楚所有的缓存数据
  126. wx.clearStorage()
  127. /// loding....
  128. showLoading(()=>{
  129. /// 登出
  130. setTimeout(function () {
  131. hideLoading(()=>{
  132. // on confirm
  133. wx.reLaunch({ url: '/pages/login/index' })
  134. }, '登出成功', 'success')
  135. }, 3000)
  136. }, '登出中....')
  137. }).catch(() => {
  138. // on cancel
  139. });
  140. },
  141. /**
  142. * 生命周期函数--监听页面初次渲染完成
  143. */
  144. onReady() {
  145. },
  146. /**
  147. * 生命周期函数--监听页面显示
  148. */
  149. onShow() {
  150. this.getTabBar().init()
  151. },
  152. /**
  153. * 生命周期函数--监听页面隐藏
  154. */
  155. onHide() {
  156. },
  157. /**
  158. * 生命周期函数--监听页面卸载
  159. */
  160. onUnload() {
  161. },
  162. /**
  163. * 页面相关事件处理函数--监听用户下拉动作
  164. */
  165. onPullDownRefresh() {
  166. },
  167. /**
  168. * 页面上拉触底事件的处理函数
  169. */
  170. onReachBottom() {
  171. },
  172. /**
  173. * 用户点击右上角分享
  174. */
  175. onShareAppMessage() {
  176. }
  177. })