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.

227 line
5.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() {
  35. let that = this;
  36. // 卡余额充足的时候,才可以付钱
  37. console.log(Number(that.data.remainingAmount) >= Number(that.data.inputValue))
  38. if (that.data.inputValue != "" && Number(that.data.remainingAmount) >= Number(that.data.inputValue)) {
  39. Http.post({
  40. url: config.api.cardPayOrder,
  41. data: {
  42. cardId: that.data.cardid,
  43. merchantCode: that.data.merChant.merchant_id,
  44. totalFee: that.data.inputValue
  45. }
  46. })
  47. .then(res => {
  48. console.log(res);
  49. if(res.code==200){
  50. that.startAuth();
  51. }
  52. })
  53. .catch(err => {
  54. wx.showModal({
  55. title: "抱歉",
  56. content: err.message,
  57. showCancel: false
  58. })
  59. })
  60. } else if (that.data.inputValue == "") {
  61. wx.showModal({
  62. title: '抱歉',
  63. content: '请输入金额',
  64. showCancel: false
  65. })
  66. } else if (that.data.inputValue != "" && Number(that.data.remainingAmount) < Number(that.data.inputValue)) {
  67. // wx.showModal({
  68. // title: '抱歉',
  69. // content: '余额不足',
  70. // showCancel: false
  71. // })
  72. that.setData({
  73. showModel: true
  74. })
  75. that.getList();
  76. }
  77. },
  78. // 指纹识别
  79. startAuth() {
  80. let that = this;
  81. const startSoterAuthentication = () => {
  82. wx.startSoterAuthentication({
  83. requestAuthModes: [AUTH_MODE],
  84. challenge: 'test',
  85. authContent: '请验证已有的指纹以继续',
  86. success: (res) => {
  87. wx.navigateTo({
  88. url: '/pages/paySuccess/paySuccess',
  89. })
  90. },
  91. fail: (err) => {
  92. }
  93. })
  94. }
  95. const checkIsEnrolled = () => {
  96. wx.checkIsSoterEnrolledInDevice({
  97. checkAuthMode: AUTH_MODE,
  98. success: (res) => {
  99. console.log(res)
  100. if (parseInt(res.isEnrolled) <= 0) {
  101. wx.showModal({
  102. title: '错误',
  103. content: '您暂未录入指纹信息,请录入后重试',
  104. showCancel: false
  105. })
  106. return
  107. }
  108. startSoterAuthentication();
  109. },
  110. fail: (err) => {
  111. console.error(err)
  112. }
  113. })
  114. }
  115. wx.checkIsSupportSoterAuthentication({
  116. success: (res) => {
  117. console.log(res)
  118. checkIsEnrolled()
  119. },
  120. fail: (err) => {
  121. console.error(err);
  122. wx.showModal({
  123. title: '抱歉',
  124. content: '您的设备不支持指纹识别',
  125. showCancel: false
  126. })
  127. }
  128. })
  129. },
  130. gotonewcard: function() {
  131. wx.navigateTo({
  132. url: '/pages/discountCardList/discountCardList'
  133. })
  134. this.setData({
  135. showModel: false
  136. })
  137. },
  138. getList() {
  139. var that = this;
  140. var data = {
  141. pageNum: 1,
  142. pageSize: 100,
  143. couponType: "7",
  144. couponOrderStatus: 4
  145. }
  146. Http.get({
  147. url: config.api.cardorderList,
  148. data: data
  149. })
  150. .then(res => {
  151. console.log(res)
  152. if (res.code == 200) {
  153. res.data.list.map(file => {
  154. file.merchantVoList.map(files => {
  155. console.log(files.id)
  156. if (files.id == that.data.merChant.merchant_id) {
  157. file.flag = true
  158. }
  159. })
  160. })
  161. that.setData({
  162. showPage: true,
  163. cardList: res.data.list
  164. })
  165. }
  166. })
  167. .catch(err => {
  168. wx.showModal({
  169. title: '提示',
  170. content: err.errMsg,
  171. showCancel: false
  172. })
  173. })
  174. },
  175. check: function(e) {
  176. let ids = e.currentTarget.dataset.id;
  177. this.setData({
  178. ids: ids,
  179. cardId: ids,
  180. remainingAmount: e.currentTarget.dataset.remainingamount
  181. })
  182. },
  183. showModel: function() {
  184. this.setData({
  185. showModel: false
  186. })
  187. },
  188. /**
  189. * 生命周期函数--监听页面隐藏
  190. */
  191. onHide: function() {
  192. },
  193. /**
  194. * 生命周期函数--监听页面卸载
  195. */
  196. onUnload: function() {
  197. },
  198. /**
  199. * 页面相关事件处理函数--监听用户下拉动作
  200. */
  201. onPullDownRefresh: function() {
  202. },
  203. /**
  204. * 页面上拉触底事件的处理函数
  205. */
  206. onReachBottom: function() {
  207. },
  208. /**
  209. * 用户点击右上角分享
  210. */
  211. onShareAppMessage: function() {
  212. }
  213. })