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

appointDetail.js 5.8 KiB

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