exchange.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // pages/exchange/exchange.js
  2. import { documentList } from "../../api/document"
  3. import { userEntityRecharge } from '../../api/charge'
  4. import { appGetConfigImg } from '../../api/index'
  5. const app = getApp()
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. cardNo: '',
  12. cardSecret: '',
  13. imgUrl: '',
  14. overlayShow: false,
  15. chargestatus: 0,
  16. chargetext: ''
  17. },
  18. onShow () {
  19. this.appGetConfigImgFn()
  20. },
  21. appGetConfigImgFn () {
  22. const that = this
  23. wx.showNavigationBarLoading()
  24. appGetConfigImg({
  25. 'imgType': '4'
  26. }).then(configRes => {
  27. wx.hideNavigationBarLoading()
  28. console.log(configRes, 'configRes')
  29. that.setData({
  30. imgUrl: configRes.data[0].imgUrl
  31. })
  32. })
  33. },
  34. /**
  35. * 确认提交充值
  36. */
  37. handleComfirm() {
  38. var cardNo = this.data.cardNo
  39. var cardSecret = this.data.cardSecret
  40. var that = this
  41. console.log(cardNo, cardSecret);
  42. if (cardNo == '') {
  43. wx.showToast({
  44. title: '请输入卡号',
  45. icon: 'error'
  46. })
  47. return
  48. } else if (cardSecret == '') {
  49. wx.showToast({
  50. title: '请输入卡密',
  51. icon: 'error'
  52. })
  53. return
  54. } else {
  55. var data = {
  56. // CARD202010221647 GBISYX
  57. cardNo: cardNo,
  58. cardSecret: cardSecret
  59. }
  60. wx.showLoading({
  61. title: '充值中...',
  62. mask: true
  63. })
  64. userEntityRecharge(data).then(res => {
  65. wx.hideLoading()
  66. that.setData({
  67. overlayShow: true,
  68. chargestatus: 0,
  69. chargetext: res.msg
  70. })
  71. }).catch(e => {
  72. console.log('é',e)
  73. wx.hideLoading()
  74. that.setData({
  75. chargestatus: 1,
  76. chargetext: e,
  77. overlayShow: true
  78. })
  79. })
  80. }
  81. },
  82. bindCardNo(e) {
  83. this.setData({
  84. cardNo: e.detail.value
  85. })
  86. },
  87. bindCardPwd(e) {
  88. this.setData({
  89. cardSecret: e.detail.value
  90. })
  91. },
  92. /**
  93. * 生命周期函数--监听页面卸载
  94. */
  95. handleCancle() {
  96. wx.navigateBack()
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. reInput() {
  102. this.setData({
  103. overlayShow: false
  104. })
  105. },
  106. // 立即预约
  107. handleAppointment () {
  108. this.setData({
  109. overlayShow: false
  110. })
  111. if (app.globalData.hasAppointment) {
  112. wx.showModal({
  113. content: '您预约的健康筛查还未体验,请先体验',
  114. cancelColor: '#666',
  115. cancelText: '取消',
  116. confirmText: '我的预约',
  117. confirmColor: '#333',
  118. success (res) {
  119. if (res.confirm) {
  120. wx.navigateTo({
  121. url: '/pages/myAppointment/myAppointment',
  122. })
  123. }
  124. }
  125. })
  126. } else {
  127. this.getDocumentList()
  128. }
  129. },
  130. // 获取用户档案信息
  131. getDocumentList () {
  132. var that = this
  133. wx.showLoading({
  134. title: '加载中...',
  135. mask: true
  136. })
  137. documentList({
  138. currentPage: 1
  139. }).then(res => {
  140. wx.hideLoading()
  141. const response = res.data.vos || []
  142. if (response.length == 0) {
  143. wx.showModal({
  144. content: '预约用户前需要先添加检测人员信息',
  145. cancelColor: '#666',
  146. confirmColor: '#333',
  147. success (res) {
  148. if (res.confirm) {
  149. wx.navigateTo({
  150. url: '/pages/createFile/createFile?from=index'
  151. })
  152. }
  153. }
  154. })
  155. } else {
  156. wx.navigateTo({
  157. url: '/pages/appointment/appointment'
  158. })
  159. }
  160. }).catch(e => {
  161. wx.hideLoading()
  162. wx.showModal({
  163. content: e,
  164. confirmColor: '#333',
  165. showCancel: false
  166. })
  167. })
  168. },
  169. /**
  170. * 页面上拉触底事件的处理函数
  171. */
  172. onReachBottom() {
  173. },
  174. /**
  175. * 用户点击右上角分享
  176. */
  177. onShareAppMessage() {
  178. }
  179. })