index.ts 5.4 KB

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