C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

193 lignes
4.6 KiB

  1. const util = require("../../utils/util.js");
  2. const config = require("../../config/config.js");
  3. const Http = require("../../utils/HttpBasics");
  4. const AUTH_MODE = 'fingerPrint';
  5. let app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. merChant: {},
  12. focus: true,
  13. inputValue: '',
  14. cardList: [],
  15. showModel: false,
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. let that = this;
  22. that.setData({
  23. merChant: JSON.parse(options.merChant),
  24. cardid: options.cardid,
  25. remainingAmount: options.remainingAmount
  26. })
  27. },
  28. bindKeyInput(e) {
  29. console.log(e)
  30. this.setData({
  31. inputValue: e.detail.value
  32. })
  33. },
  34. gotoPayMoney: function (flags) {
  35. let that = this;
  36. const startSoterAuthentication = () => {
  37. wx.startSoterAuthentication({
  38. requestAuthModes: [AUTH_MODE],
  39. challenge: 'test',
  40. authContent: '请验证已有的指纹以继续',
  41. success: (res) => {
  42. that.gotoPay()
  43. },
  44. fail: (err) => {
  45. }
  46. })
  47. }
  48. const checkIsEnrolled = () => {
  49. wx.checkIsSoterEnrolledInDevice({
  50. checkAuthMode: AUTH_MODE,
  51. success: (res) => {
  52. console.log(res)
  53. if (res.isEnrolled) {
  54. startSoterAuthentication();
  55. }else{
  56. that.gotoPay();
  57. }
  58. },
  59. fail: (err) => {
  60. console.error(err)
  61. }
  62. })
  63. }
  64. wx.checkIsSupportSoterAuthentication({
  65. success: (res) => {
  66. console.log(res)
  67. if(res.supportMode == []){
  68. that.gotoPay();
  69. }else if(res.supportMode == ['fingerPrint']){
  70. checkIsEnrolled()
  71. }else if(res.supportMode = ['fingerPrint', 'facial'] ){
  72. checkIsEnrolled()
  73. }
  74. },
  75. fail: (err) => {
  76. console.error(err);
  77. that.gotoPay();
  78. }
  79. })
  80. },
  81. gotoPay: function () {
  82. let that = this;
  83. Http.post({
  84. url: config.api.cardPayOrder,
  85. data: {
  86. cardId: that.data.cardid,
  87. merchantCode: that.data.merChant.merchant_id,
  88. totalFee: that.data.inputValue
  89. }
  90. })
  91. .then(res => {
  92. if (res.code == 200) {
  93. wx.hideLoading();
  94. that.setData({
  95. showModel: false
  96. })
  97. wx.navigateTo({
  98. url: `/pages/paySuccess/paySuccess?data=${JSON.stringify(res.data)}`,
  99. })
  100. }
  101. })
  102. .catch(err => {
  103. wx.hideLoading()
  104. wx.showModal({
  105. title: "抱歉",
  106. content: err.message,
  107. showCancel: false
  108. })
  109. })
  110. },
  111. // 指纹识别
  112. startAuth(e) {
  113. let that = this;
  114. if (e) {
  115. if (e.currentTarget.dataset.flags == 'check') {
  116. that.setData({
  117. ids: e.currentTarget.dataset.id,
  118. cardid: e.currentTarget.dataset.id,
  119. remainingAmount: e.currentTarget.dataset.remainingamount,
  120. })
  121. }
  122. }
  123. if (that.data.inputValue == "" || that.data.inputValue == 0) {
  124. wx.showModal({
  125. title: '抱歉',
  126. content: '请输入金额',
  127. showCancel: false
  128. })
  129. } else if (that.data.inputValue != "" && Number(that.data.remainingAmount) < Number(that.data.inputValue)) {
  130. that.setData({
  131. showModel: true
  132. })
  133. that.getList('notenogth');
  134. } else if (that.data.inputValue != "" && Number(that.data.remainingAmount) >= Number(that.data.inputValue)) {
  135. wx.showLoading({
  136. title: '付款中',
  137. })
  138. that.gotoPayMoney();
  139. }
  140. },
  141. gotonewcard: function () {
  142. wx.navigateTo({
  143. url: '/pages/discountCardList/discountCardList'
  144. })
  145. this.setData({
  146. showModel: false
  147. })
  148. },
  149. getList() {
  150. var that = this;
  151. var data = {
  152. pageNum: 1,
  153. pageSize: 100,
  154. couponType: "7",
  155. couponOrderStatus: 4
  156. }
  157. Http.get({
  158. url: config.api.cardorderList,
  159. data: data
  160. })
  161. .then(res => {
  162. console.log(res)
  163. if (res.code == 200) {
  164. res.data.list.map(file => {
  165. file.merchantVoList.map(files => {
  166. if (files.id == that.data.merChant.merchant_id) {
  167. file.flag = true
  168. }
  169. })
  170. })
  171. that.setData({
  172. showPage: true,
  173. cardList: res.data.list
  174. })
  175. }
  176. })
  177. .catch(err => {
  178. wx.showModal({
  179. title: '提示',
  180. content: err.errMsg,
  181. showCancel: false
  182. })
  183. })
  184. },
  185. showModel: function () {
  186. this.setData({
  187. showModel: false
  188. })
  189. },
  190. })