index.ts 6.2 KB

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