抖音b端
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.

198 lines
4.5 KiB

  1. // c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttb\pages\Appointment\appointment\appointment.js
  2. const config = require('../../config/config.js')
  3. const Http = require('../../utils/http.js')
  4. const HttpBasics = require('../../utils/HttpBasics.js')
  5. const util = require('../../utils/util')
  6. var app = getApp()
  7. Page({
  8. data: {
  9. currentID: "",
  10. pickedTime: "",
  11. startTime: "开始时间",
  12. endTime: "结束时间",
  13. pageNum: 1,
  14. status: 0,
  15. list: [],
  16. Phone: '',
  17. },
  18. onLoad(options) {
  19. this.getList()
  20. },
  21. getList(status, startTime, endTime) {
  22. const that = this
  23. const data = {
  24. pageNum: this.data.pageNum,
  25. userPhone: this.data.Phone,
  26. pageSize: 200,
  27. }
  28. if (startTime && endTime) {
  29. data.serchStartDate = startTime
  30. data.serchEndDate = endTime
  31. }
  32. if (status || status === 0) {
  33. data.status = status
  34. }
  35. HttpBasics.get({
  36. url: config.api.appointmentList,
  37. data
  38. })
  39. .then(res => {
  40. console.log(res, 'res');
  41. res.data.list.forEach(item => {
  42. const appointStart = util.timestampToTime(item.startDate, 'YYYY-MM-DD hh:mm:ss')
  43. const appointEnd = util.timestampToTime(item.endDate, 'hh:mm:ss')
  44. if (item.startDate && item.endDate) {
  45. item.appointTime = appointStart + ' - ' + appointEnd
  46. } else {
  47. item.appointTime = "暂无";
  48. }
  49. })
  50. that.setData({
  51. list: res.data.list,
  52. })
  53. }).catch(err => {
  54. console.log(err, 'err');
  55. })
  56. },
  57. setNav(e) {
  58. const id = e.currentTarget.dataset.id
  59. this.setData({
  60. currentID: id == this.data.currentID ? '' : id
  61. })
  62. console.log(this.data.currentID, 'currentID');
  63. },
  64. setType(e) {
  65. const type = e.currentTarget.dataset.type
  66. this.setData({
  67. currentID: '',
  68. })
  69. if (type === 'X') {
  70. this.getList(false)
  71. } else if (type === 'Y') {
  72. this.getList(0)
  73. } else {
  74. this.getList(type * 1)
  75. }
  76. },
  77. setStartTime(e) {
  78. console.log(e.detail.value, 'e');
  79. this.setData({
  80. startTime: e.detail.value
  81. })
  82. },
  83. setEndTime(e) {
  84. console.log(e.detail.value, 'e');
  85. this.setData({
  86. endTime: e.detail.value
  87. })
  88. },
  89. search() {
  90. if (this.data.startTime == '开始时间' || this.data.endTime == '结束时间') {
  91. return
  92. }
  93. const startTime = this.data.startTime + " 00:00:00"
  94. const endTime = this.data.endTime + " 23:59:59"
  95. this.getList(false, startTime, endTime)
  96. },
  97. goDetail(e) {
  98. const id = e.currentTarget.dataset.id
  99. tt.navigateTo({
  100. url: `/pages/appointDetail/appointDetail?id=${id}`,
  101. });
  102. },
  103. // 核销
  104. goVerification(e) {
  105. let _this = this
  106. // console.log(id, shop);
  107. console.log(e);
  108. // const id = BigInt(e.currentTarget.dataset.id)
  109. const id = e.currentTarget.dataset.id
  110. console.log(typeof (id));
  111. console.log(id);
  112. const shop = e.currentTarget.dataset.shop
  113. const data = {
  114. id
  115. }
  116. tt.showModal({
  117. title: "提示",
  118. content: `当前正在核销【${shop}】的预约订单,请确认是否核销?`,
  119. showCancel: true,
  120. confirmText: "确认核销",
  121. confirmColor: "#52a0fd",
  122. cancelText: "返回",
  123. success(res) {
  124. if (res.confirm) {
  125. HttpBasics.post({
  126. url: config.api.verify,
  127. data
  128. }).then(res => {
  129. console.log(res, 'res');
  130. _this.getList()
  131. tt.showToast({
  132. image: './../../assets/images/success.png',
  133. title: '核销成功',
  134. })
  135. }).catch(err => {
  136. console.log(err, 'err');
  137. tt.showToast({
  138. image: './../../assets/images/fail.png',
  139. title: '核销失败',
  140. })
  141. })
  142. }
  143. if (res.cancel) {
  144. return
  145. }
  146. }
  147. });
  148. },
  149. // 解决数字丢失精度
  150. parseBigNumber(numberStr) {
  151. let result = '';
  152. let carry = 0;
  153. for (let i = numberStr.length - 1; i >= 0; i--) {
  154. const digit = Number(numberStr[i]);
  155. const sum = digit + carry;
  156. if (sum >= 10) {
  157. result = (sum - 10).toString() + result;
  158. carry = 1;
  159. } else {
  160. result = sum.toString() + result;
  161. carry = 0;
  162. }
  163. }
  164. if (carry === 1) {
  165. result = '1' + result;
  166. }
  167. return result;
  168. },
  169. handleInput(e) {
  170. // console.log(e.detail.value);
  171. this.data.Phone = e.detail.value
  172. },
  173. onShow() {
  174. this.getList()
  175. }
  176. })