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

258 line
5.8 KiB

  1. // c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttb\pages\appointDetail\appointDetail.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. id: "",
  10. detail: null,
  11. isShowBtns: true,
  12. isSetTime: false,
  13. isSetAddress: false,
  14. pickedDate: "请选择日期",
  15. pickedStartTime: "请选择",
  16. pickedEndTime: "请选择",
  17. startTime: "",
  18. endTime: ""
  19. },
  20. onLoad(options) {
  21. console.log(options, 'options');
  22. if (options.id) {
  23. this.setData({
  24. id: options.id
  25. })
  26. this.getDetail(options.id)
  27. }
  28. },
  29. getDetail(id) {
  30. const that = this
  31. const data = {
  32. id
  33. }
  34. HttpBasics.get({
  35. url: config.api.appointDetail,
  36. data
  37. })
  38. .then(res => {
  39. console.log(res, 'res');
  40. const appointStart = util.timestampToTime(res.data.startDate, 'YYYY-MM-DD hh:mm:ss')
  41. const appointEnd = util.timestampToTime(res.data.endDate, 'hh:mm:ss')
  42. if (res.data.startDate && res.data.endDate) {
  43. res.data.appointTime = appointStart + ' - ' + appointEnd
  44. } else {
  45. res.data.appointTime = "暂无";
  46. }
  47. that.setData({
  48. detail: res.data,
  49. pickedDate: util.timestampToTime(res.data.startDate, 'YYYY-MM-DD') || '请选择日期',
  50. pickedStartTime: util.timestampToTime(res.data.startDate, 'hh:mm') || '请选择',
  51. pickedEndTime: util.timestampToTime(res.data.endDate, 'hh:mm') || '请选择',
  52. })
  53. }).catch(err => {
  54. console.log(err, 'err');
  55. })
  56. },
  57. back() {
  58. tt.navigateBack();
  59. },
  60. chooseDate(e) {
  61. console.log(e.detail.value, 'e');
  62. this.setData({
  63. pickedDate: e.detail.value
  64. })
  65. },
  66. chooseStartTime(e) {
  67. console.log(e.detail.value, 'e');
  68. this.setData({
  69. pickedStartTime: e.detail.value
  70. })
  71. },
  72. chooseEndTime(e) {
  73. console.log(e.detail.value, 'e');
  74. this.setData({
  75. pickedEndTime: e.detail.value
  76. })
  77. },
  78. cancel() {
  79. const that = this
  80. tt.showModal({
  81. title: "提示",
  82. content: "是否与用户取得联系并取消确认?",
  83. showCancel: true,
  84. confirmText: "确认取消",
  85. confirmColor: "#52a0fd",
  86. cancelText: "返回",
  87. success(res) {
  88. if (res.confirm) {
  89. that.goChange(that.data.id, 0)
  90. }
  91. if (res.cancel) {
  92. return
  93. }
  94. }
  95. });
  96. },
  97. confirm() {
  98. const that = this
  99. tt.showModal({
  100. title: "提示",
  101. content: "是否与用户取得联系并完成预约?",
  102. showCancel: true,
  103. confirmText: "确认完成",
  104. confirmColor: "#52a0fd",
  105. cancelText: "关闭",
  106. success(res) {
  107. if (res.confirm) {
  108. that.goChange(that.data.id, 5)
  109. }
  110. if (res.cancel) {
  111. return
  112. }
  113. }
  114. });
  115. },
  116. setDate() {
  117. const isSetTime = !this.data.isSetTime
  118. this.setData({
  119. isSetTime,
  120. isSetAddress: false
  121. })
  122. },
  123. confirmDate() {
  124. const isSetTime = !this.data.isSetTime
  125. this.setData({
  126. isSetTime,
  127. isSetAddress: false
  128. })
  129. if (!isSetTime) {
  130. const tempData = this.data
  131. if (tempData.pickedDate == '请选择日期') {
  132. tt.showToast({
  133. title: '请请选择日期!',
  134. icon: 'fail'
  135. });
  136. return
  137. }
  138. if (tempData.pickedStartTime == '请选择') {
  139. tt.showToast({
  140. title: '请起始时间!',
  141. icon: 'fail'
  142. });
  143. return
  144. }
  145. if (tempData.pickedEndTime == '请选择') {
  146. tt.showToast({
  147. title: '请结束时间!',
  148. icon: 'fail'
  149. });
  150. return
  151. }
  152. const data = {
  153. id: this.data.detail.id,
  154. couponOrderId: this.data.detail.couponOrderId,
  155. startDate: tempData.pickedDate + " " + tempData.pickedStartTime + ":00",
  156. endDate: tempData.pickedDate + " " + tempData.pickedEndTime + ":00"
  157. }
  158. this.goSetDate(data)
  159. console.log(data, 'data');
  160. }
  161. },
  162. setAddress() {
  163. const isSetAddress = !this.data.isSetAddress
  164. this.setData({
  165. isSetAddress,
  166. isSetTime: false
  167. })
  168. },
  169. settingAddress(e) {
  170. const detail = this.data.detail
  171. detail.detailedAddress = e.detail.value
  172. this.setData({
  173. detail
  174. })
  175. },
  176. confirmAddress() {
  177. const isSetAddress = !this.data.isSetAddress
  178. this.setData({
  179. isSetAddress,
  180. isSetTime: false
  181. })
  182. const data = {
  183. id: this.data.detail.id,
  184. couponOrderId: this.data.detail.couponOrderId,
  185. detailedAddress: this.data.detail.detailedAddress,
  186. }
  187. this.goSetDate(data)
  188. },
  189. goChange(id, status) {
  190. const data = {
  191. id,
  192. status
  193. }
  194. HttpBasics.post({
  195. url: config.api.appointConfirm,
  196. data
  197. })
  198. .then(res => {
  199. console.log(res, 'res');
  200. tt.showToast({
  201. title: status == 5 ? '确认成功!' : '取消成功!',
  202. icon: "success",
  203. duration: 2000
  204. });
  205. setTimeout(() => {
  206. tt.navigateBack();
  207. }, 2000);
  208. }).catch(err => {
  209. console.log(err, 'err');
  210. tt.showToast({
  211. title: err.message,
  212. icon: "none"
  213. });
  214. })
  215. },
  216. goSetDate(data) {
  217. const that = this
  218. HttpBasics.post({
  219. url: config.api.appointSetDate,
  220. data
  221. })
  222. .then(res => {
  223. console.log(res, 'res');
  224. tt.showToast({
  225. title: '修改成功!',
  226. icon: "success",
  227. duration: 2000
  228. });
  229. that.getDetail(that.data.id)
  230. }).catch(err => {
  231. console.log(err, 'err');
  232. tt.showToast({
  233. title: err.message,
  234. icon: "none"
  235. });
  236. })
  237. }
  238. })