C端小程序
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.

232 regels
6.0 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. // 卡余额充足的时候,才可以付钱
  37. // if(e){
  38. // if(e.currentTarget.dataset.flags == 'check'){
  39. // console.log("frhufr")
  40. // that.setData({
  41. // ids: e.currentTarget.dataset.id,
  42. // cardid: e.currentTarget.dataset.id,
  43. // remainingAmount: e.currentTarget.dataset.remainingamount,
  44. // })
  45. // const startSoterAuthentication = () => {
  46. // wx.startSoterAuthentication({
  47. // requestAuthModes: [AUTH_MODE],
  48. // challenge: 'test',
  49. // authContent: '请验证已有的指纹以继续',
  50. // success: (res) => {
  51. // that.gotoPayMoney()
  52. // },
  53. // fail: (err) => {
  54. // }
  55. // })
  56. // }
  57. // const checkIsEnrolled = () => {
  58. // wx.checkIsSoterEnrolledInDevice({
  59. // checkAuthMode: AUTH_MODE,
  60. // success: (res) => {
  61. // console.log(res)
  62. // if (parseInt(res.isEnrolled) <= 0) {
  63. // that.gotoPayMoney();
  64. // return
  65. // }
  66. // startSoterAuthentication();
  67. // },
  68. // fail: (err) => {
  69. // console.error(err)
  70. // }
  71. // })
  72. // }
  73. // wx.checkIsSupportSoterAuthentication({
  74. // success: (res) => {
  75. // console.log(res)
  76. // checkIsEnrolled()
  77. // },
  78. // fail: (err) => {
  79. // console.error(err);
  80. // that.gotoPayMoney();
  81. // }
  82. // })
  83. // }
  84. // }
  85. const startSoterAuthentication = () => {
  86. wx.startSoterAuthentication({
  87. requestAuthModes: [AUTH_MODE],
  88. challenge: 'test',
  89. authContent: '请验证已有的指纹以继续',
  90. success: (res) => {
  91. that.gotoPay()
  92. },
  93. fail: (err) => {
  94. }
  95. })
  96. }
  97. const checkIsEnrolled = () => {
  98. wx.checkIsSoterEnrolledInDevice({
  99. checkAuthMode: AUTH_MODE,
  100. success: (res) => {
  101. console.log(res)
  102. if (parseInt(res.isEnrolled) <= 0) {
  103. that.gotoPay();
  104. return
  105. }
  106. startSoterAuthentication();
  107. },
  108. fail: (err) => {
  109. console.error(err)
  110. }
  111. })
  112. }
  113. wx.checkIsSupportSoterAuthentication({
  114. success: (res) => {
  115. console.log(res)
  116. checkIsEnrolled()
  117. },
  118. fail: (err) => {
  119. console.error(err);
  120. that.gotoPay();
  121. }
  122. })
  123. },
  124. gotoPay: function () {
  125. let that = this;
  126. Http.post({
  127. url: config.api.cardPayOrder,
  128. data: {
  129. cardId: that.data.cardid,
  130. merchantCode: that.data.merChant.merchant_id,
  131. totalFee: that.data.inputValue
  132. }
  133. })
  134. .then(res => {
  135. if (res.code == 200) {
  136. that.setData({
  137. showModel: false
  138. })
  139. wx.navigateTo({
  140. url: `/pages/paySuccess/paySuccess?data=${JSON.stringify(res.data)}`,
  141. })
  142. }
  143. })
  144. .catch(err => {
  145. wx.showModal({
  146. title: "抱歉",
  147. content: err.message,
  148. showCancel: false
  149. })
  150. })
  151. },
  152. // 指纹识别
  153. startAuth(e) {
  154. let that = this;
  155. if (e) {
  156. if (e.currentTarget.dataset.flags == 'check') {
  157. that.setData({
  158. ids: e.currentTarget.dataset.id,
  159. cardid: e.currentTarget.dataset.id,
  160. remainingAmount: e.currentTarget.dataset.remainingamount,
  161. })
  162. }
  163. }
  164. if (that.data.inputValue == "" || that.data.inputValue == 0) {
  165. wx.showModal({
  166. title: '抱歉',
  167. content: '请输入金额',
  168. showCancel: false
  169. })
  170. } else if (that.data.inputValue != "" && Number(that.data.remainingAmount) < Number(that.data.inputValue)) {
  171. that.setData({
  172. showModel: true
  173. })
  174. that.getList('notenogth');
  175. } else if (that.data.inputValue != "" && Number(that.data.remainingAmount) >= Number(that.data.inputValue)) {
  176. that.gotoPayMoney();
  177. }
  178. },
  179. gotonewcard: function () {
  180. wx.navigateTo({
  181. url: '/pages/discountCardList/discountCardList'
  182. })
  183. this.setData({
  184. showModel: false
  185. })
  186. },
  187. getList() {
  188. var that = this;
  189. var data = {
  190. pageNum: 1,
  191. pageSize: 100,
  192. couponType: "7",
  193. couponOrderStatus: 4
  194. }
  195. Http.get({
  196. url: config.api.cardorderList,
  197. data: data
  198. })
  199. .then(res => {
  200. console.log(res)
  201. if (res.code == 200) {
  202. res.data.list.map(file => {
  203. file.merchantVoList.map(files => {
  204. if (files.id == that.data.merChant.merchant_id) {
  205. file.flag = true
  206. }
  207. })
  208. })
  209. that.setData({
  210. showPage: true,
  211. cardList: res.data.list
  212. })
  213. }
  214. })
  215. .catch(err => {
  216. wx.showModal({
  217. title: '提示',
  218. content: err.errMsg,
  219. showCancel: false
  220. })
  221. })
  222. },
  223. showModel: function () {
  224. this.setData({
  225. showModel: false
  226. })
  227. },
  228. })