You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.4 KiB

  1. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  2. let appVersion = extConfig.appVersion;
  3. var app = getApp();
  4. const config = require('../../config/config.js')
  5. const Http = require('../../utils/HttpBasics.js')
  6. Page({
  7. data: {
  8. cashOutOpenHeadImg: "", //用户头像
  9. cashOutOpenNickName: "", //用户名
  10. cashOutCount: "", //当日已提现次数
  11. cashOutNumber: "", // 可提现余额
  12. cashOutSupport: "", // 1 - 支持提现 0-不支持提现
  13. cashOutLimit: "", // 当日提现次数限制
  14. city: '',
  15. userInfo: {},
  16. flag: 'hidden',
  17. isSet: false,
  18. haveData: false,
  19. organizationType: -1,
  20. payVersion: '',
  21. mchType: ''
  22. },
  23. toDetail() {
  24. wx.navigateTo({
  25. url: `./signInDetail/signInDetail?userInfo=${this.data.userInfo}`
  26. })
  27. },
  28. phone(e) {
  29. wx.makePhoneCall({
  30. phoneNumber: e.currentTarget.dataset.phone
  31. })
  32. },
  33. toExit() {
  34. console.log(1)
  35. wx.reLaunch({
  36. url: '/pages/index/index',
  37. })
  38. },
  39. showVersion: function () {
  40. /**
  41. * 长按显示版本号
  42. */
  43. let that = this;
  44. if (that.data.flag == 'hidden') {
  45. that.setData({
  46. flag: 'show'
  47. });
  48. }
  49. console.log(that.data.flag)
  50. },
  51. //获取支付配置
  52. getPayAccount() {
  53. Http.post({
  54. url: config.api.getPayAccount,
  55. data: {
  56. appId: config.weapp.appId,
  57. }
  58. }).then(res => {
  59. console.log(res, "res")
  60. this.setData({
  61. payVersion: res.data.payVersion,
  62. mchType: res.data.mchType
  63. })
  64. }).catch(err => {
  65. wx.showToast({
  66. title: err.message,
  67. icon: "none",
  68. duration: 2000
  69. })
  70. })
  71. },
  72. //获取提现信息
  73. getTx() {
  74. Http.get({
  75. url: config.api.balance
  76. }).then(res => {
  77. console.log(111)
  78. this.setData({
  79. cashOutCount: res.data.cashOutCount, //当日已提现次数
  80. cashOutNumber: res.data.cashOutNumber, // 可提现余额
  81. cashOutSupport: res.data.cashOutSupport, // 1 - 支持提现 0-不支持提现
  82. cashOutLimit: res.data.cashOutLimit, // 当日提现次数限制
  83. withdrawNun: res.data.cashOutLimit - res.data.cashOutCount,
  84. cashOutOpenHeadImg: res.data.cashOutOpenHeadImg,
  85. cashOutOpenNickName: res.data.cashOutOpenNickName
  86. })
  87. }).catch(err => {
  88. wx.showToast({
  89. title: err.message,
  90. icon: "none",
  91. duration: 2000
  92. })
  93. })
  94. },
  95. onLoad() {
  96. this.findJurisdiction()
  97. },
  98. onShow() {
  99. // this.getPayAccount()
  100. this.getTx()
  101. app.globalData.userInfo().then(res => {
  102. this.setData({
  103. userInfo: res
  104. })
  105. console.log(this.data.userInfo)
  106. if (this.data.userInfo.merchant_id) {
  107. this.findAccountById(this.data.userInfo.merchant_id);
  108. }
  109. })
  110. this.setData({
  111. appVersion: appVersion
  112. })
  113. },
  114. //提现按钮
  115. withdraw() {
  116. console.log(this.data.cashOutOpenNickName)
  117. wx.navigateTo({
  118. url: `/pages/withdraw/withdraw?money=${this.data.cashOutNumber}&userTop=${this.data.cashOutOpenHeadImg}&userName=${this.data.cashOutOpenNickName}`,
  119. })
  120. },
  121. /**
  122. * 查询是否有修改账户权限
  123. */
  124. findJurisdiction() {
  125. Http.get({
  126. url: config.api.permitModifiy,
  127. }).then(res => {
  128. console.log(res)
  129. /**
  130. * data:true
  131. * 如有:显示
  132. * 没有;不显示
  133. */
  134. if (res && res.data == true) {
  135. this.setData({
  136. haveData: true,
  137. })
  138. } else {
  139. this.setData({
  140. haveData: false,
  141. })
  142. }
  143. }).catch(error => {
  144. console.log(error)
  145. })
  146. },
  147. /**
  148. * 查询收款账户状态
  149. */
  150. findAccountById(merchant_id) {
  151. Http.get({
  152. url: config.api.findAccountById,
  153. data: {
  154. id: merchant_id
  155. }
  156. }).then(res => {
  157. console.log(res)
  158. /**
  159. * receiverAccount
  160. * 如有:已设置收款账户
  161. * 没有;未设置收款账户
  162. */
  163. this.setData({
  164. mchType: res.data.mchType
  165. })
  166. if (res && res.data && res.data.receiver) {
  167. this.setData({
  168. isSet: true,
  169. receiverAccount: res.data.receiver.receiverAccount,
  170. receiverComments: res.data.receiver.receiverComments,
  171. receiverType: res.data.receiver.receiverType,
  172. })
  173. } else {
  174. this.setData({
  175. isSet: false
  176. })
  177. }
  178. }).catch(error => {
  179. console.log(error)
  180. })
  181. }
  182. })