抖音B端厂库
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // pages/operation/index.js
  2. const config = require('../../config/config.js')
  3. const Http = require('../../utils/HttpBasics.js')
  4. const util = require('../../utils/util.js')
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. showDetailIf: true,
  12. type: null,
  13. paramData: '',
  14. array: ['美国', '中国', '巴西', '日本'],
  15. merchentList: [],
  16. spendStr: null,
  17. creditNum: 0,
  18. submitAble: true,
  19. thoroughfare:'',
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. this.setData({
  26. type: options.type,
  27. paramData: options
  28. })
  29. this.getMerchent();
  30. },
  31. /**
  32. * 保存积分操作数据
  33. */
  34. submitForm() {
  35. let _this = this;
  36. const reg = /^[1-9]\d*$/;
  37. if (!reg.test(_this.data.creditNum) || Number(_this.data.creditNum) > 9999999 || Number(_this.data.creditNum) <1) {
  38. tt.showToast({
  39. title: '消费金额限制1~9999999的正整数!',
  40. icon: 'none',
  41. duration: 2000,
  42. mask: false
  43. });
  44. return;
  45. }
  46. _this.setData({
  47. submitAble: false
  48. })
  49. Http.post({
  50. url: config.api.addCredit,
  51. data: {
  52. creditNum: _this.data.creditNum,
  53. creditType: 12,//消费积分
  54. cuserId: _this.data.paramData.id,
  55. operatorType: 3,
  56. merchantId: _this.data.paramData.merchant_id,
  57. changePurpose: _this.data.thoroughfare
  58. }
  59. })
  60. .then(res => {
  61. _this.setData({
  62. merchentList: res.data,
  63. submitAble: true
  64. })
  65. tt.showToast({
  66. title: '保存成功!',
  67. icon: 'none',
  68. duration: 2000,
  69. mask: false
  70. });
  71. tt.navigateTo({
  72. url: '/pages/editSuccess/index?type=2&creditNum=' + _this.data.creditNum + '&creditAmount=' + res.data.creditAmount,
  73. })
  74. })
  75. .catch(err => {
  76. _this.setData({
  77. submitAble: true
  78. })
  79. tt.showToast({
  80. title: err.message,
  81. icon: 'none',
  82. duration: 2000,
  83. mask: false
  84. });
  85. });
  86. },
  87. getPrice(e) {
  88. this.setData({
  89. creditNum: e.detail.value
  90. })
  91. },
  92. getThoroughfare(e){
  93. this.setData({
  94. thoroughfare: e.detail.value
  95. })
  96. },
  97. getMerchent() {
  98. let _this = this;
  99. Http.get({
  100. url: config.api.getMerchentList
  101. })
  102. .then(res => {
  103. _this.setData({
  104. merchentList: res.data
  105. })
  106. })
  107. .catch(err => {
  108. tt.showToast({
  109. title: err.message,
  110. icon: 'none',
  111. duration: 2000,
  112. mask: false
  113. });
  114. });
  115. },
  116. bindPickerChange(e) {
  117. console.log('picker发送选择改变,携带值为', e.detail.value)
  118. this.setData({
  119. index: e.detail.value
  120. })
  121. },
  122. /**
  123. * 生命周期函数--监听页面初次渲染完成
  124. */
  125. onReady: function () {
  126. },
  127. /**
  128. * 生命周期函数--监听页面显示
  129. */
  130. onShow: function () {
  131. this.setData({
  132. submitAble:true
  133. })
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide: function () {
  139. },
  140. /**
  141. * 生命周期函数--监听页面卸载
  142. */
  143. onUnload: function () {
  144. },
  145. /**
  146. * 页面相关事件处理函数--监听用户下拉动作
  147. */
  148. onPullDownRefresh: function () {
  149. },
  150. /**
  151. * 页面上拉触底事件的处理函数
  152. */
  153. onReachBottom: function () {
  154. }
  155. })